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

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

Issue 10831234: Clean-up inline members of nested classes (ui/) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | « no previous file | ui/views/controls/menu/menu.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_H_ 5 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_H_
6 #define UI_VIEWS_CONTROLS_MENU_MENU_H_ 6 #define UI_VIEWS_CONTROLS_MENU_MENU_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 20 matching lines...) Expand all
31 // 31 //
32 // Classes implement this interface to tell the menu system more about each 32 // Classes implement this interface to tell the menu system more about each
33 // item as it is created. 33 // item as it is created.
34 // 34 //
35 ///////////////////////////////////////////////////////////////////////////// 35 /////////////////////////////////////////////////////////////////////////////
36 class VIEWS_EXPORT Delegate { 36 class VIEWS_EXPORT Delegate {
37 public: 37 public:
38 virtual ~Delegate() {} 38 virtual ~Delegate() {}
39 39
40 // Whether or not an item should be shown as checked. 40 // Whether or not an item should be shown as checked.
41 virtual bool IsItemChecked(int id) const { 41 virtual bool IsItemChecked(int id) const;
42 return false;
43 }
44 42
45 // Whether or not an item should be shown as the default (using bold). 43 // Whether or not an item should be shown as the default (using bold).
46 // There can only be one default menu item. 44 // There can only be one default menu item.
47 virtual bool IsItemDefault(int id) const { 45 virtual bool IsItemDefault(int id) const;
48 return false;
49 }
50 46
51 // The string shown for the menu item. 47 // The string shown for the menu item.
52 virtual string16 GetLabel(int id) const { 48 virtual string16 GetLabel(int id) const;
53 return string16();
54 }
55 49
56 // The delegate needs to implement this function if it wants to display 50 // The delegate needs to implement this function if it wants to display
57 // the shortcut text next to each menu item. If there is an accelerator 51 // the shortcut text next to each menu item. If there is an accelerator
58 // for a given item id, the implementor must return it. 52 // for a given item id, the implementor must return it.
59 virtual bool GetAcceleratorInfo(int id, ui::Accelerator* accel) { 53 virtual bool GetAcceleratorInfo(int id, ui::Accelerator* accel);
60 return false;
61 }
62 54
63 // The icon shown for the menu item. 55 // The icon shown for the menu item.
64 virtual const gfx::ImageSkia& GetIcon(int id) const { 56 virtual const gfx::ImageSkia& GetIcon(int id) const;
65 return GetEmptyIcon();
66 }
67 57
68 // The number of items to show in the menu 58 // The number of items to show in the menu
69 virtual int GetItemCount() const { 59 virtual int GetItemCount() const;
70 return 0;
71 }
72 60
73 // Whether or not an item is a separator. 61 // Whether or not an item is a separator.
74 virtual bool IsItemSeparator(int id) const { 62 virtual bool IsItemSeparator(int id) const;
75 return false;
76 }
77 63
78 // Shows the context menu with the specified id. This is invoked when the 64 // Shows the context menu with the specified id. This is invoked when the
79 // user does the appropriate gesture to show a context menu. The id 65 // user does the appropriate gesture to show a context menu. The id
80 // identifies the id of the menu to show the context menu for. 66 // identifies the id of the menu to show the context menu for.
81 // is_mouse_gesture is true if this is the result of a mouse gesture. 67 // is_mouse_gesture is true if this is the result of a mouse gesture.
82 // If this is not the result of a mouse gesture |p| is the recommended 68 // If this is not the result of a mouse gesture |p| is the recommended
83 // location to display the content menu at. In either case, |p| is in 69 // location to display the content menu at. In either case, |p| is in
84 // screen coordinates. 70 // screen coordinates.
85 virtual void ShowContextMenu(Menu* source, 71 virtual void ShowContextMenu(Menu* source,
86 int id, 72 int id,
87 const gfx::Point& p, 73 const gfx::Point& p,
88 bool is_mouse_gesture) { 74 bool is_mouse_gesture) {
89 } 75 }
90 76
91 // Whether an item has an icon. 77 // Whether an item has an icon.
92 virtual bool HasIcon(int id) const { 78 virtual bool HasIcon(int id) const;
93 return false;
94 }
95 79
96 // Notification that the menu is about to be popped up. 80 // Notification that the menu is about to be popped up.
97 virtual void MenuWillShow() { 81 virtual void MenuWillShow() {
98 } 82 }
99 83
100 // Whether to create a right-to-left menu. The default implementation 84 // Whether to create a right-to-left menu. The default implementation
101 // returns true if the locale's language is a right-to-left language (such 85 // returns true if the locale's language is a right-to-left language (such
102 // as Hebrew) and false otherwise. This is generally the right behavior 86 // as Hebrew) and false otherwise. This is generally the right behavior
103 // since there is no reason to show left-to-right menus for right-to-left 87 // since there is no reason to show left-to-right menus for right-to-left
104 // locales. However, subclasses can override this behavior so that the menu 88 // locales. However, subclasses can override this behavior so that the menu
105 // is a right-to-left menu only if the view's layout is right-to-left 89 // is a right-to-left menu only if the view's layout is right-to-left
106 // (since the view can use a different layout than the locale's language 90 // (since the view can use a different layout than the locale's language
107 // layout). 91 // layout).
108 virtual bool IsRightToLeftUILayout() const; 92 virtual bool IsRightToLeftUILayout() const;
109 93
110 // Controller 94 // Controller
111 virtual bool SupportsCommand(int id) const { 95 virtual bool SupportsCommand(int id) const;
112 return true; 96 virtual bool IsCommandEnabled(int id) const;
113 } 97 virtual bool GetContextualLabel(int id, string16* out) const;
114 virtual bool IsCommandEnabled(int id) const {
115 return true;
116 }
117 virtual bool GetContextualLabel(int id, string16* out) const {
118 return false;
119 }
120 virtual void ExecuteCommand(int id) { 98 virtual void ExecuteCommand(int id) {
121 } 99 }
122 100
123 protected: 101 protected:
124 // Returns an empty icon. 102 // Returns an empty icon.
125 const gfx::ImageSkia& GetEmptyIcon() const; 103 const gfx::ImageSkia& GetEmptyIcon() const;
126 }; 104 };
127 105
128 // How this popup should align itself relative to the point it is run at. 106 // How this popup should align itself relative to the point it is run at.
129 enum AnchorPoint { 107 enum AnchorPoint {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 244
267 // How this popup menu should be aligned relative to the point it is run at. 245 // How this popup menu should be aligned relative to the point it is run at.
268 AnchorPoint anchor_; 246 AnchorPoint anchor_;
269 247
270 DISALLOW_COPY_AND_ASSIGN(Menu); 248 DISALLOW_COPY_AND_ASSIGN(Menu);
271 }; 249 };
272 250
273 } // namespace views 251 } // namespace views
274 252
275 #endif // UI_VIEWS_CONTROLS_MENU_MENU_H_ 253 #endif // UI_VIEWS_CONTROLS_MENU_MENU_H_
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/menu/menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698