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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 // Sets MenuConfig to be used instead of default one. | |
324 void set_menu_config(MenuConfig* menu_config) { menu_config_ = menu_config; } | |
sky
2012/10/05 21:33:40
This approach encourages leaking. MenuItemView sho
yefimt
2012/10/08 20:02:47
Yes, was going to do it but forgot :(
The best wou
| |
325 | |
326 // Returns a reference to MenuConfig to be used with this menu. | |
327 const MenuConfig& GetMenuConfig() const; | |
328 | |
323 protected: | 329 protected: |
324 // Creates a MenuItemView. This is used by the various AddXXX methods. | 330 // Creates a MenuItemView. This is used by the various AddXXX methods. |
325 MenuItemView(MenuItemView* parent, int command, Type type); | 331 MenuItemView(MenuItemView* parent, int command, Type type); |
326 | 332 |
327 // MenuRunner owns MenuItemView and should be the only one deleting it. | 333 // MenuRunner owns MenuItemView and should be the only one deleting it. |
328 virtual ~MenuItemView(); | 334 virtual ~MenuItemView(); |
329 | 335 |
330 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; | 336 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; |
331 | 337 |
332 virtual std::string GetClassName() const OVERRIDE; | 338 virtual std::string GetClassName() const OVERRIDE; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
493 // |menu_position_| is the requested position with respect to the bounds. | 499 // |menu_position_| is the requested position with respect to the bounds. |
494 // |actual_menu_position_| is used by the controller to cache the | 500 // |actual_menu_position_| is used by the controller to cache the |
495 // position of the menu being shown. | 501 // position of the menu being shown. |
496 MenuPosition requested_menu_position_; | 502 MenuPosition requested_menu_position_; |
497 MenuPosition actual_menu_position_; | 503 MenuPosition actual_menu_position_; |
498 | 504 |
499 // If set to false, the right margin will be removed for menu lines | 505 // If set to false, the right margin will be removed for menu lines |
500 // containing other elements. | 506 // containing other elements. |
501 bool use_right_margin_; | 507 bool use_right_margin_; |
502 | 508 |
509 // |menu_config_| to replace default one, could be NULL, | |
510 // applies to root menu item only. | |
511 const MenuConfig* menu_config_; | |
512 | |
503 DISALLOW_COPY_AND_ASSIGN(MenuItemView); | 513 DISALLOW_COPY_AND_ASSIGN(MenuItemView); |
504 }; | 514 }; |
505 | 515 |
506 } // namespace views | 516 } // namespace views |
507 | 517 |
508 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ | 518 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
OLD | NEW |