Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: ui/views/controls/menu/menu_item_view.h

Issue 11026076: Added MenuConfig setter to MenuItemView, updated rest of the code to use set MenuConfig if it avail… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/menu/menu_delegate.cc ('k') | ui/views/controls/menu/menu_item_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
323 protected: 332 protected:
324 // Creates a MenuItemView. This is used by the various AddXXX methods. 333 // Creates a MenuItemView. This is used by the various AddXXX methods.
325 MenuItemView(MenuItemView* parent, int command, Type type); 334 MenuItemView(MenuItemView* parent, int command, Type type);
326 335
327 // MenuRunner owns MenuItemView and should be the only one deleting it. 336 // MenuRunner owns MenuItemView and should be the only one deleting it.
328 virtual ~MenuItemView(); 337 virtual ~MenuItemView();
329 338
330 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; 339 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE;
331 340
332 virtual std::string GetClassName() const OVERRIDE; 341 virtual std::string GetClassName() const OVERRIDE;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 // |menu_position_| is the requested position with respect to the bounds. 502 // |menu_position_| is the requested position with respect to the bounds.
494 // |actual_menu_position_| is used by the controller to cache the 503 // |actual_menu_position_| is used by the controller to cache the
495 // position of the menu being shown. 504 // position of the menu being shown.
496 MenuPosition requested_menu_position_; 505 MenuPosition requested_menu_position_;
497 MenuPosition actual_menu_position_; 506 MenuPosition actual_menu_position_;
498 507
499 // If set to false, the right margin will be removed for menu lines 508 // If set to false, the right margin will be removed for menu lines
500 // containing other elements. 509 // containing other elements.
501 bool use_right_margin_; 510 bool use_right_margin_;
502 511
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
503 DISALLOW_COPY_AND_ASSIGN(MenuItemView); 516 DISALLOW_COPY_AND_ASSIGN(MenuItemView);
504 }; 517 };
505 518
506 } // namespace views 519 } // namespace views
507 520
508 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ 521 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_delegate.cc ('k') | ui/views/controls/menu/menu_item_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698