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" | |
17 #include "ui/views/view.h" | 18 #include "ui/views/view.h" |
18 | 19 |
19 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
20 #include <windows.h> | 21 #include <windows.h> |
21 | 22 |
22 #include "ui/base/native_theme/native_theme.h" | 23 #include "ui/base/native_theme/native_theme.h" |
23 #endif | 24 #endif |
24 | 25 |
25 namespace gfx { | 26 namespace gfx { |
26 class Font; | 27 class Font; |
27 } | 28 } |
28 | 29 |
29 namespace ui { | 30 namespace ui { |
30 class MenuModel; | 31 class MenuModel; |
31 } | 32 } |
32 | 33 |
33 namespace views { | 34 namespace views { |
34 | 35 |
35 namespace internal { | 36 namespace internal { |
36 class MenuRunnerImpl; | 37 class MenuRunnerImpl; |
37 } | 38 } |
38 | 39 |
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. | |
sky
2012/10/09 00:40:42
Document NULL resets to default.
yefimt
2012/10/09 00:53:25
Done.
| |
324 void set_menu_config(const MenuConfig* menu_config) { | |
325 menu_config_.reset(menu_config); | |
326 } | |
327 | |
328 // Returns a reference to MenuConfig to be used with this menu. | |
329 const MenuConfig& GetMenuConfig() const; | |
330 | |
323 protected: | 331 protected: |
324 // Creates a MenuItemView. This is used by the various AddXXX methods. | 332 // Creates a MenuItemView. This is used by the various AddXXX methods. |
325 MenuItemView(MenuItemView* parent, int command, Type type); | 333 MenuItemView(MenuItemView* parent, int command, Type type); |
326 | 334 |
327 // MenuRunner owns MenuItemView and should be the only one deleting it. | 335 // MenuRunner owns MenuItemView and should be the only one deleting it. |
328 virtual ~MenuItemView(); | 336 virtual ~MenuItemView(); |
329 | 337 |
330 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; | 338 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; |
331 | 339 |
332 virtual std::string GetClassName() const OVERRIDE; | 340 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. | 501 // |menu_position_| is the requested position with respect to the bounds. |
494 // |actual_menu_position_| is used by the controller to cache the | 502 // |actual_menu_position_| is used by the controller to cache the |
495 // position of the menu being shown. | 503 // position of the menu being shown. |
496 MenuPosition requested_menu_position_; | 504 MenuPosition requested_menu_position_; |
497 MenuPosition actual_menu_position_; | 505 MenuPosition actual_menu_position_; |
498 | 506 |
499 // If set to false, the right margin will be removed for menu lines | 507 // If set to false, the right margin will be removed for menu lines |
500 // containing other elements. | 508 // containing other elements. |
501 bool use_right_margin_; | 509 bool use_right_margin_; |
502 | 510 |
511 // |menu_config_| to replace default one, could be NULL, | |
512 // applies to root menu item only. | |
513 scoped_ptr<const MenuConfig> menu_config_; | |
514 | |
503 DISALLOW_COPY_AND_ASSIGN(MenuItemView); | 515 DISALLOW_COPY_AND_ASSIGN(MenuItemView); |
504 }; | 516 }; |
505 | 517 |
506 } // namespace views | 518 } // namespace views |
507 | 519 |
508 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ | 520 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
OLD | NEW |