OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_ | 5 #ifndef UI_VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_ |
6 #define UI_VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_ | 6 #define UI_VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 // Returns the number of child views that are MenuItemViews. | 48 // Returns the number of child views that are MenuItemViews. |
49 // MenuItemViews are identified by ID. | 49 // MenuItemViews are identified by ID. |
50 int GetMenuItemCount(); | 50 int GetMenuItemCount(); |
51 | 51 |
52 // Returns the MenuItemView at the specified index. | 52 // Returns the MenuItemView at the specified index. |
53 MenuItemView* GetMenuItemAt(int index); | 53 MenuItemView* GetMenuItemAt(int index); |
54 | 54 |
55 // Positions and sizes the child views. This tiles the views vertically, | 55 // Positions and sizes the child views. This tiles the views vertically, |
56 // giving each child the available width. | 56 // giving each child the available width. |
57 virtual void Layout() OVERRIDE; | 57 virtual void Layout() override; |
58 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 58 virtual gfx::Size GetPreferredSize() const override; |
59 | 59 |
60 // Override from View. | 60 // Override from View. |
61 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; | 61 virtual void GetAccessibleState(ui::AXViewState* state) override; |
62 virtual ui::TextInputClient* GetTextInputClient() OVERRIDE; | 62 virtual ui::TextInputClient* GetTextInputClient() override; |
63 | 63 |
64 // Painting. | 64 // Painting. |
65 virtual void PaintChildren(gfx::Canvas* canvas, | 65 virtual void PaintChildren(gfx::Canvas* canvas, |
66 const views::CullSet& cull_view) OVERRIDE; | 66 const views::CullSet& cull_view) override; |
67 | 67 |
68 // Drag and drop methods. These are forwarded to the MenuController. | 68 // Drag and drop methods. These are forwarded to the MenuController. |
69 virtual bool GetDropFormats( | 69 virtual bool GetDropFormats( |
70 int* formats, | 70 int* formats, |
71 std::set<OSExchangeData::CustomFormat>* custom_formats) OVERRIDE; | 71 std::set<OSExchangeData::CustomFormat>* custom_formats) override; |
72 virtual bool AreDropTypesRequired() OVERRIDE; | 72 virtual bool AreDropTypesRequired() override; |
73 virtual bool CanDrop(const OSExchangeData& data) OVERRIDE; | 73 virtual bool CanDrop(const OSExchangeData& data) override; |
74 virtual void OnDragEntered(const ui::DropTargetEvent& event) OVERRIDE; | 74 virtual void OnDragEntered(const ui::DropTargetEvent& event) override; |
75 virtual int OnDragUpdated(const ui::DropTargetEvent& event) OVERRIDE; | 75 virtual int OnDragUpdated(const ui::DropTargetEvent& event) override; |
76 virtual void OnDragExited() OVERRIDE; | 76 virtual void OnDragExited() override; |
77 virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE; | 77 virtual int OnPerformDrop(const ui::DropTargetEvent& event) override; |
78 | 78 |
79 // Scrolls on menu item boundaries. | 79 // Scrolls on menu item boundaries. |
80 virtual bool OnMouseWheel(const ui::MouseWheelEvent& e) OVERRIDE; | 80 virtual bool OnMouseWheel(const ui::MouseWheelEvent& e) override; |
81 | 81 |
82 // Overridden from ui::EventHandler. | 82 // Overridden from ui::EventHandler. |
83 // Scrolls on menu item boundaries. | 83 // Scrolls on menu item boundaries. |
84 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 84 virtual void OnGestureEvent(ui::GestureEvent* event) override; |
85 | 85 |
86 // Overridden from PrefixDelegate. | 86 // Overridden from PrefixDelegate. |
87 virtual int GetRowCount() OVERRIDE; | 87 virtual int GetRowCount() override; |
88 virtual int GetSelectedRow() OVERRIDE; | 88 virtual int GetSelectedRow() override; |
89 virtual void SetSelectedRow(int row) OVERRIDE; | 89 virtual void SetSelectedRow(int row) override; |
90 virtual base::string16 GetTextForRow(int row) OVERRIDE; | 90 virtual base::string16 GetTextForRow(int row) override; |
91 | 91 |
92 // Returns true if the menu is showing. | 92 // Returns true if the menu is showing. |
93 bool IsShowing(); | 93 bool IsShowing(); |
94 | 94 |
95 // Shows the menu at the specified location. Coordinates are in screen | 95 // Shows the menu at the specified location. Coordinates are in screen |
96 // coordinates. max_width gives the max width the view should be. | 96 // coordinates. max_width gives the max width the view should be. |
97 void ShowAt(Widget* parent, const gfx::Rect& bounds, bool do_capture); | 97 void ShowAt(Widget* parent, const gfx::Rect& bounds, bool do_capture); |
98 | 98 |
99 // Resets the bounds of the submenu to |bounds|. | 99 // Resets the bounds of the submenu to |bounds|. |
100 void Reposition(const gfx::Rect& bounds); | 100 void Reposition(const gfx::Rect& bounds); |
(...skipping 10 matching lines...) Expand all Loading... |
111 // being processed by the host, so that host is on the stack when we need to | 111 // being processed by the host, so that host is on the stack when we need to |
112 // close the window. If we closed the window immediately (and deleted it), | 112 // close the window. If we closed the window immediately (and deleted it), |
113 // when control returned back to host we would crash as host was deleted. | 113 // when control returned back to host we would crash as host was deleted. |
114 void Hide(); | 114 void Hide(); |
115 | 115 |
116 // If mouse capture was grabbed, it is released. Does nothing if mouse was | 116 // If mouse capture was grabbed, it is released. Does nothing if mouse was |
117 // not captured. | 117 // not captured. |
118 void ReleaseCapture(); | 118 void ReleaseCapture(); |
119 | 119 |
120 // Overriden from View to prevent tab from doing anything. | 120 // Overriden from View to prevent tab from doing anything. |
121 virtual bool SkipDefaultKeyEventProcessing(const ui::KeyEvent& e) OVERRIDE; | 121 virtual bool SkipDefaultKeyEventProcessing(const ui::KeyEvent& e) override; |
122 | 122 |
123 // Returns the parent menu item we're showing children for. | 123 // Returns the parent menu item we're showing children for. |
124 MenuItemView* GetMenuItem() const; | 124 MenuItemView* GetMenuItem() const; |
125 | 125 |
126 // Set the drop item and position. | 126 // Set the drop item and position. |
127 void SetDropMenuItem(MenuItemView* item, | 127 void SetDropMenuItem(MenuItemView* item, |
128 MenuDelegate::DropPosition position); | 128 MenuDelegate::DropPosition position); |
129 | 129 |
130 // Returns whether the selection should be shown for the specified item. | 130 // Returns whether the selection should be shown for the specified item. |
131 // The selection is NOT shown during drag and drop when the drop is over | 131 // The selection is NOT shown during drag and drop when the drop is over |
(...skipping 19 matching lines...) Expand all Loading... |
151 } | 151 } |
152 | 152 |
153 // Automatically resize menu if a subview's preferred size changes. | 153 // Automatically resize menu if a subview's preferred size changes. |
154 bool resize_open_menu() const { return resize_open_menu_; } | 154 bool resize_open_menu() const { return resize_open_menu_; } |
155 void set_resize_open_menu(bool resize_open_menu) { | 155 void set_resize_open_menu(bool resize_open_menu) { |
156 resize_open_menu_ = resize_open_menu; | 156 resize_open_menu_ = resize_open_menu; |
157 } | 157 } |
158 | 158 |
159 protected: | 159 protected: |
160 // Overridden from View: | 160 // Overridden from View: |
161 virtual const char* GetClassName() const OVERRIDE; | 161 virtual const char* GetClassName() const override; |
162 | 162 |
163 // View method. Overridden to schedule a paint. We do this so that when | 163 // View method. Overridden to schedule a paint. We do this so that when |
164 // scrolling occurs, everything is repainted correctly. | 164 // scrolling occurs, everything is repainted correctly. |
165 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; | 165 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) override; |
166 | 166 |
167 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; | 167 virtual void ChildPreferredSizeChanged(View* child) override; |
168 | 168 |
169 private: | 169 private: |
170 // Paints the drop indicator. This is only invoked if item is non-NULL and | 170 // Paints the drop indicator. This is only invoked if item is non-NULL and |
171 // position is not DROP_NONE. | 171 // position is not DROP_NONE. |
172 void PaintDropIndicator(gfx::Canvas* canvas, | 172 void PaintDropIndicator(gfx::Canvas* canvas, |
173 MenuItemView* item, | 173 MenuItemView* item, |
174 MenuDelegate::DropPosition position); | 174 MenuDelegate::DropPosition position); |
175 | 175 |
176 void SchedulePaintForDropIndicator(MenuItemView* item, | 176 void SchedulePaintForDropIndicator(MenuItemView* item, |
177 MenuDelegate::DropPosition position); | 177 MenuDelegate::DropPosition position); |
178 | 178 |
179 // Calculates the location of th edrop indicator. | 179 // Calculates the location of th edrop indicator. |
180 gfx::Rect CalculateDropIndicatorBounds(MenuItemView* item, | 180 gfx::Rect CalculateDropIndicatorBounds(MenuItemView* item, |
181 MenuDelegate::DropPosition position); | 181 MenuDelegate::DropPosition position); |
182 | 182 |
183 // Implementation of ScrollDelegate | 183 // Implementation of ScrollDelegate |
184 virtual bool OnScroll(float dx, float dy) OVERRIDE; | 184 virtual bool OnScroll(float dx, float dy) override; |
185 | 185 |
186 // Parent menu item. | 186 // Parent menu item. |
187 MenuItemView* parent_menu_item_; | 187 MenuItemView* parent_menu_item_; |
188 | 188 |
189 // Widget subclass used to show the children. This is deleted when we invoke | 189 // Widget subclass used to show the children. This is deleted when we invoke |
190 // |DestroyMenuHost|, or |MenuHostDestroyed| is invoked back on us. | 190 // |DestroyMenuHost|, or |MenuHostDestroyed| is invoked back on us. |
191 MenuHost* host_; | 191 MenuHost* host_; |
192 | 192 |
193 // If non-null, indicates a drop is in progress and drop_item is the item | 193 // If non-null, indicates a drop is in progress and drop_item is the item |
194 // the drop is over. | 194 // the drop is over. |
(...skipping 24 matching lines...) Expand all Loading... |
219 float roundoff_error_; | 219 float roundoff_error_; |
220 | 220 |
221 PrefixSelector prefix_selector_; | 221 PrefixSelector prefix_selector_; |
222 | 222 |
223 DISALLOW_COPY_AND_ASSIGN(SubmenuView); | 223 DISALLOW_COPY_AND_ASSIGN(SubmenuView); |
224 }; | 224 }; |
225 | 225 |
226 } // namespace views | 226 } // namespace views |
227 | 227 |
228 #endif // UI_VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_ | 228 #endif // UI_VIEWS_CONTROLS_MENU_SUBMENU_VIEW_H_ |
OLD | NEW |