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

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

Issue 10829176: Update drop down menu look & feel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: png crush 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 | « ui/views/controls/menu/menu_controller.cc ('k') | no next file » | 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
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 TOPRIGHT 93 TOPRIGHT
94 }; 94 };
95 95
96 // Where the menu should be drawn, above or below the bounds (when 96 // Where the menu should be drawn, above or below the bounds (when
97 // the bounds is non-empty). POSITION_BEST_FIT (default) positions 97 // the bounds is non-empty). POSITION_BEST_FIT (default) positions
98 // the menu below the bounds unless the menu does not fit on the 98 // the menu below the bounds unless the menu does not fit on the
99 // screen and the re is more space above. 99 // screen and the re is more space above.
100 enum MenuPosition { 100 enum MenuPosition {
101 POSITION_BEST_FIT, 101 POSITION_BEST_FIT,
102 POSITION_ABOVE_BOUNDS, 102 POSITION_ABOVE_BOUNDS,
103 POSITION_BELOW_BOUNDS, 103 POSITION_BELOW_BOUNDS
104 POSITION_OVER_BOUNDS
105 }; 104 };
106 105
107 // Constructor for use with the top level menu item. This menu is never 106 // Constructor for use with the top level menu item. This menu is never
108 // shown to the user, rather its use as the parent for all menu items. 107 // shown to the user, rather its use as the parent for all menu items.
109 explicit MenuItemView(MenuDelegate* delegate); 108 explicit MenuItemView(MenuDelegate* delegate);
110 109
111 // Overridden from View: 110 // Overridden from View:
112 virtual bool GetTooltipText(const gfx::Point& p, 111 virtual bool GetTooltipText(const gfx::Point& p,
113 string16* tooltip) const OVERRIDE; 112 string16* tooltip) const OVERRIDE;
114 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; 113 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 MenuItemView* GetParentMenuItem() { return parent_menu_item_; } 209 MenuItemView* GetParentMenuItem() { return parent_menu_item_; }
211 const MenuItemView* GetParentMenuItem() const { return parent_menu_item_; } 210 const MenuItemView* GetParentMenuItem() const { return parent_menu_item_; }
212 211
213 // Sets/Gets the title. 212 // Sets/Gets the title.
214 void SetTitle(const string16& title); 213 void SetTitle(const string16& title);
215 const string16& title() const { return title_; } 214 const string16& title() const { return title_; }
216 215
217 // Returns the type of this menu. 216 // Returns the type of this menu.
218 const Type& GetType() const { return type_; } 217 const Type& GetType() const { return type_; }
219 218
220 // Returns the requested menu position.
221 const MenuPosition& GetRequestedMenuPosition() {
222 return requested_menu_position_;
223 }
224
225 // Sets whether this item is selected. This is invoked as the user moves 219 // Sets whether this item is selected. This is invoked as the user moves
226 // the mouse around the menu while open. 220 // the mouse around the menu while open.
227 void SetSelected(bool selected); 221 void SetSelected(bool selected);
228 222
229 // Returns true if the item is selected. 223 // Returns true if the item is selected.
230 bool IsSelected() const { return selected_; } 224 bool IsSelected() const { return selected_; }
231 225
232 // Sets the |tooltip| for a menu item view with |item_id| identifier. 226 // Sets the |tooltip| for a menu item view with |item_id| identifier.
233 void SetTooltip(const string16& tooltip, int item_id); 227 void SetTooltip(const string16& tooltip, int item_id);
234 228
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 int GetAcceleratorTextWidth(); 287 int GetAcceleratorTextWidth();
294 288
295 // Returns true if the menu has mnemonics. This only useful on the root menu 289 // Returns true if the menu has mnemonics. This only useful on the root menu
296 // item. 290 // item.
297 bool has_mnemonics() const { return has_mnemonics_; } 291 bool has_mnemonics() const { return has_mnemonics_; }
298 292
299 // Set top and bottom margins in pixels. If no margin is set or a 293 // Set top and bottom margins in pixels. If no margin is set or a
300 // negative margin is specified then MenuConfig values are used. 294 // negative margin is specified then MenuConfig values are used.
301 void SetMargins(int top_margin, int bottom_margin); 295 void SetMargins(int top_margin, int bottom_margin);
302 296
303 // Set the position of the menu with respect to the bounds (top
304 // level only).
305 void set_menu_position(MenuPosition menu_position) {
306 requested_menu_position_ = menu_position;
307 }
308
309 // Suppress the right margin if this is set to false. 297 // Suppress the right margin if this is set to false.
310 void set_use_right_margin(bool use_right_margin) { 298 void set_use_right_margin(bool use_right_margin) {
311 use_right_margin_ = use_right_margin; 299 use_right_margin_ = use_right_margin;
312 } 300 }
313 301
314 protected: 302 protected:
315 // Creates a MenuItemView. This is used by the various AddXXX methods. 303 // Creates a MenuItemView. This is used by the various AddXXX methods.
316 MenuItemView(MenuItemView* parent, int command, Type type); 304 MenuItemView(MenuItemView* parent, int command, Type type);
317 305
318 // MenuRunner owns MenuItemView and should be the only one deleting it. 306 // MenuRunner owns MenuItemView and should be the only one deleting it.
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 // If set to false, the right margin will be removed for menu lines 478 // If set to false, the right margin will be removed for menu lines
491 // containing other elements. 479 // containing other elements.
492 bool use_right_margin_; 480 bool use_right_margin_;
493 481
494 DISALLOW_COPY_AND_ASSIGN(MenuItemView); 482 DISALLOW_COPY_AND_ASSIGN(MenuItemView);
495 }; 483 };
496 484
497 } // namespace views 485 } // namespace views
498 486
499 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ 487 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698