| 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 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "ui/base/models/menu_separator_types.h" | 15 #include "ui/base/models/menu_separator_types.h" |
| 16 #include "ui/gfx/image/image_skia.h" | 16 #include "ui/gfx/image/image_skia.h" |
| 17 #include "ui/views/controls/menu/menu_config.h" | |
| 18 #include "ui/views/view.h" | 17 #include "ui/views/view.h" |
| 19 | 18 |
| 20 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
| 21 #include <windows.h> | 20 #include <windows.h> |
| 22 | 21 |
| 23 #include "ui/base/native_theme/native_theme.h" | 22 #include "ui/base/native_theme/native_theme.h" |
| 24 #endif | 23 #endif |
| 25 | 24 |
| 26 namespace gfx { | 25 namespace gfx { |
| 27 class Font; | 26 class Font; |
| 28 } | 27 } |
| 29 | 28 |
| 30 namespace ui { | 29 namespace ui { |
| 31 class MenuModel; | 30 class MenuModel; |
| 32 } | 31 } |
| 33 | 32 |
| 34 namespace views { | 33 namespace views { |
| 35 | 34 |
| 36 namespace internal { | 35 namespace internal { |
| 37 class MenuRunnerImpl; | 36 class MenuRunnerImpl; |
| 38 } | 37 } |
| 39 | 38 |
| 39 struct MenuConfig; |
| 40 class MenuController; | 40 class MenuController; |
| 41 class MenuDelegate; | 41 class MenuDelegate; |
| 42 class SubmenuView; | 42 class SubmenuView; |
| 43 | 43 |
| 44 // MenuItemView -------------------------------------------------------------- | 44 // MenuItemView -------------------------------------------------------------- |
| 45 | 45 |
| 46 // MenuItemView represents a single menu item with a label and optional icon. | 46 // MenuItemView represents a single menu item with a label and optional icon. |
| 47 // Each MenuItemView may also contain a submenu, which in turn may contain | 47 // Each MenuItemView may also contain a submenu, which in turn may contain |
| 48 // any number of child MenuItemViews. | 48 // any number of child MenuItemViews. |
| 49 // | 49 // |
| (...skipping 263 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 // Setting |menu_config_| to NULL will make menu to use a default MenuConfig. | |
| 325 void set_menu_config(const MenuConfig* menu_config) { | |
| 326 menu_config_.reset(menu_config); | |
| 327 } | |
| 328 | |
| 329 // Returns a reference to MenuConfig to be used with this menu. | |
| 330 const MenuConfig& GetMenuConfig() const; | |
| 331 | |
| 332 protected: | 323 protected: |
| 333 // Creates a MenuItemView. This is used by the various AddXXX methods. | 324 // Creates a MenuItemView. This is used by the various AddXXX methods. |
| 334 MenuItemView(MenuItemView* parent, int command, Type type); | 325 MenuItemView(MenuItemView* parent, int command, Type type); |
| 335 | 326 |
| 336 // MenuRunner owns MenuItemView and should be the only one deleting it. | 327 // MenuRunner owns MenuItemView and should be the only one deleting it. |
| 337 virtual ~MenuItemView(); | 328 virtual ~MenuItemView(); |
| 338 | 329 |
| 339 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; | 330 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; |
| 340 | 331 |
| 341 virtual std::string GetClassName() const OVERRIDE; | 332 virtual std::string GetClassName() const OVERRIDE; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 // |menu_position_| is the requested position with respect to the bounds. | 493 // |menu_position_| is the requested position with respect to the bounds. |
| 503 // |actual_menu_position_| is used by the controller to cache the | 494 // |actual_menu_position_| is used by the controller to cache the |
| 504 // position of the menu being shown. | 495 // position of the menu being shown. |
| 505 MenuPosition requested_menu_position_; | 496 MenuPosition requested_menu_position_; |
| 506 MenuPosition actual_menu_position_; | 497 MenuPosition actual_menu_position_; |
| 507 | 498 |
| 508 // If set to false, the right margin will be removed for menu lines | 499 // If set to false, the right margin will be removed for menu lines |
| 509 // containing other elements. | 500 // containing other elements. |
| 510 bool use_right_margin_; | 501 bool use_right_margin_; |
| 511 | 502 |
| 512 // |menu_config_| to replace default one, could be NULL, | |
| 513 // applies to root menu item only. | |
| 514 scoped_ptr<const MenuConfig> menu_config_; | |
| 515 | |
| 516 DISALLOW_COPY_AND_ASSIGN(MenuItemView); | 503 DISALLOW_COPY_AND_ASSIGN(MenuItemView); |
| 517 }; | 504 }; |
| 518 | 505 |
| 519 } // namespace views | 506 } // namespace views |
| 520 | 507 |
| 521 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ | 508 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
| OLD | NEW |