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_MENU_ITEM_VIEW_H_ | 5 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
6 #define UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ | 6 #define UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // The height of the menu item. | 111 // The height of the menu item. |
112 int height; | 112 int height; |
113 }; | 113 }; |
114 | 114 |
115 // Constructor for use with the top level menu item. This menu is never | 115 // Constructor for use with the top level menu item. This menu is never |
116 // shown to the user, rather its use as the parent for all menu items. | 116 // shown to the user, rather its use as the parent for all menu items. |
117 explicit MenuItemView(MenuDelegate* delegate); | 117 explicit MenuItemView(MenuDelegate* delegate); |
118 | 118 |
119 // Overridden from View: | 119 // Overridden from View: |
120 virtual bool GetTooltipText(const gfx::Point& p, | 120 virtual bool GetTooltipText(const gfx::Point& p, |
121 base::string16* tooltip) const OVERRIDE; | 121 base::string16* tooltip) const override; |
122 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; | 122 virtual void GetAccessibleState(ui::AXViewState* state) override; |
123 | 123 |
124 // Returns the preferred height of menu items. This is only valid when the | 124 // Returns the preferred height of menu items. This is only valid when the |
125 // menu is about to be shown. | 125 // menu is about to be shown. |
126 static int pref_menu_height() { return pref_menu_height_; } | 126 static int pref_menu_height() { return pref_menu_height_; } |
127 | 127 |
128 // X-coordinate of where the label starts. | 128 // X-coordinate of where the label starts. |
129 static int label_start() { return label_start_; } | 129 static int label_start() { return label_start_; } |
130 | 130 |
131 // Returns if a given |anchor| is a bubble or not. | 131 // Returns if a given |anchor| is a bubble or not. |
132 static bool IsBubble(MenuAnchorPosition anchor); | 132 static bool IsBubble(MenuAnchorPosition anchor); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 void SetIconView(View* icon_view); | 253 void SetIconView(View* icon_view); |
254 View* icon_view() { return icon_view_; } | 254 View* icon_view() { return icon_view_; } |
255 | 255 |
256 // Sets the command id of this menu item. | 256 // Sets the command id of this menu item. |
257 void SetCommand(int command) { command_ = command; } | 257 void SetCommand(int command) { command_ = command; } |
258 | 258 |
259 // Returns the command id of this item. | 259 // Returns the command id of this item. |
260 int GetCommand() const { return command_; } | 260 int GetCommand() const { return command_; } |
261 | 261 |
262 // Paints the menu item. | 262 // Paints the menu item. |
263 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 263 virtual void OnPaint(gfx::Canvas* canvas) override; |
264 | 264 |
265 // Returns the preferred size of this item. | 265 // Returns the preferred size of this item. |
266 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 266 virtual gfx::Size GetPreferredSize() const override; |
267 | 267 |
268 // Gets the preferred height for the given |width|. This is only different | 268 // Gets the preferred height for the given |width|. This is only different |
269 // from GetPreferredSize().width() if the item has a child view with flexible | 269 // from GetPreferredSize().width() if the item has a child view with flexible |
270 // dimensions. | 270 // dimensions. |
271 virtual int GetHeightForWidth(int width) const OVERRIDE; | 271 virtual int GetHeightForWidth(int width) const override; |
272 | 272 |
273 // Return the preferred dimensions of the item in pixel. | 273 // Return the preferred dimensions of the item in pixel. |
274 const MenuItemDimensions& GetDimensions() const; | 274 const MenuItemDimensions& GetDimensions() const; |
275 | 275 |
276 // Returns the object responsible for controlling showing the menu. | 276 // Returns the object responsible for controlling showing the menu. |
277 MenuController* GetMenuController(); | 277 MenuController* GetMenuController(); |
278 const MenuController* GetMenuController() const; | 278 const MenuController* GetMenuController() const; |
279 | 279 |
280 // Returns the delegate. This returns the delegate of the root menu item. | 280 // Returns the delegate. This returns the delegate of the root menu item. |
281 MenuDelegate* GetDelegate(); | 281 MenuDelegate* GetDelegate(); |
(...skipping 16 matching lines...) Expand all Loading... |
298 bool has_icons() const { return has_icons_; } | 298 bool has_icons() const { return has_icons_; } |
299 | 299 |
300 // Returns the descendant with the specified command. | 300 // Returns the descendant with the specified command. |
301 MenuItemView* GetMenuItemByID(int id); | 301 MenuItemView* GetMenuItemByID(int id); |
302 | 302 |
303 // Invoke if you remove/add children to the menu while it's showing. This | 303 // Invoke if you remove/add children to the menu while it's showing. This |
304 // recalculates the bounds. | 304 // recalculates the bounds. |
305 void ChildrenChanged(); | 305 void ChildrenChanged(); |
306 | 306 |
307 // Sizes any child views. | 307 // Sizes any child views. |
308 virtual void Layout() OVERRIDE; | 308 virtual void Layout() override; |
309 | 309 |
310 // Returns true if the menu has mnemonics. This only useful on the root menu | 310 // Returns true if the menu has mnemonics. This only useful on the root menu |
311 // item. | 311 // item. |
312 bool has_mnemonics() const { return has_mnemonics_; } | 312 bool has_mnemonics() const { return has_mnemonics_; } |
313 | 313 |
314 // Set top and bottom margins in pixels. If no margin is set or a | 314 // Set top and bottom margins in pixels. If no margin is set or a |
315 // negative margin is specified then MenuConfig values are used. | 315 // negative margin is specified then MenuConfig values are used. |
316 void SetMargins(int top_margin, int bottom_margin); | 316 void SetMargins(int top_margin, int bottom_margin); |
317 | 317 |
318 // Suppress the right margin if this is set to false. | 318 // Suppress the right margin if this is set to false. |
319 void set_use_right_margin(bool use_right_margin) { | 319 void set_use_right_margin(bool use_right_margin) { |
320 use_right_margin_ = use_right_margin; | 320 use_right_margin_ = use_right_margin; |
321 } | 321 } |
322 | 322 |
323 // Returns a reference to MenuConfig to be used with this menu. | 323 // Returns a reference to MenuConfig to be used with this menu. |
324 const MenuConfig& GetMenuConfig() const; | 324 const MenuConfig& GetMenuConfig() const; |
325 | 325 |
326 protected: | 326 protected: |
327 // Creates a MenuItemView. This is used by the various AddXXX methods. | 327 // Creates a MenuItemView. This is used by the various AddXXX methods. |
328 MenuItemView(MenuItemView* parent, int command, Type type); | 328 MenuItemView(MenuItemView* parent, int command, Type type); |
329 | 329 |
330 // MenuRunner owns MenuItemView and should be the only one deleting it. | 330 // MenuRunner owns MenuItemView and should be the only one deleting it. |
331 virtual ~MenuItemView(); | 331 virtual ~MenuItemView(); |
332 | 332 |
333 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; | 333 virtual void ChildPreferredSizeChanged(View* child) override; |
334 | 334 |
335 virtual const char* GetClassName() const OVERRIDE; | 335 virtual const char* GetClassName() const override; |
336 | 336 |
337 // Returns the preferred size (and padding) of any children. | 337 // Returns the preferred size (and padding) of any children. |
338 virtual gfx::Size GetChildPreferredSize() const; | 338 virtual gfx::Size GetChildPreferredSize() const; |
339 | 339 |
340 // Returns the various margins. | 340 // Returns the various margins. |
341 int GetTopMargin() const; | 341 int GetTopMargin() const; |
342 int GetBottomMargin() const; | 342 int GetBottomMargin() const; |
343 | 343 |
344 private: | 344 private: |
345 friend class internal::MenuRunnerImpl; // For access to ~MenuItemView. | 345 friend class internal::MenuRunnerImpl; // For access to ~MenuItemView. |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 // If set to false, the right margin will be removed for menu lines | 516 // If set to false, the right margin will be removed for menu lines |
517 // containing other elements. | 517 // containing other elements. |
518 bool use_right_margin_; | 518 bool use_right_margin_; |
519 | 519 |
520 DISALLOW_COPY_AND_ASSIGN(MenuItemView); | 520 DISALLOW_COPY_AND_ASSIGN(MenuItemView); |
521 }; | 521 }; |
522 | 522 |
523 } // namespace views | 523 } // namespace views |
524 | 524 |
525 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ | 525 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
OLD | NEW |