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 |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 virtual void Layout() OVERRIDE; | 283 virtual void Layout() OVERRIDE; |
284 | 284 |
285 // Returns the amount of space needed to accommodate the accelerator. The | 285 // Returns the amount of space needed to accommodate the accelerator. The |
286 // space needed for the accelerator is NOT included in the preferred width. | 286 // space needed for the accelerator is NOT included in the preferred width. |
287 int GetAcceleratorTextWidth(); | 287 int GetAcceleratorTextWidth(); |
288 | 288 |
289 // 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 |
290 // item. | 290 // item. |
291 bool has_mnemonics() const { return has_mnemonics_; } | 291 bool has_mnemonics() const { return has_mnemonics_; } |
292 | 292 |
| 293 // Returns true if the menu is the root layer of a context menu. |
| 294 bool is_root_context_menu() const { return is_root_context_menu_; } |
| 295 |
293 // Set top and bottom margins in pixels. If no margin is set or a | 296 // Set top and bottom margins in pixels. If no margin is set or a |
294 // negative margin is specified then MenuConfig values are used. | 297 // negative margin is specified then MenuConfig values are used. |
295 void SetMargins(int top_margin, int bottom_margin); | 298 void SetMargins(int top_margin, int bottom_margin); |
296 | 299 |
297 // Suppress the right margin if this is set to false. | 300 // Suppress the right margin if this is set to false. |
298 void set_use_right_margin(bool use_right_margin) { | 301 void set_use_right_margin(bool use_right_margin) { |
299 use_right_margin_ = use_right_margin; | 302 use_right_margin_ = use_right_margin; |
300 } | 303 } |
301 | 304 |
302 protected: | 305 protected: |
(...skipping 23 matching lines...) Expand all Loading... |
326 void UpdateMenuPartSizes(); | 329 void UpdateMenuPartSizes(); |
327 | 330 |
328 // Called by the two constructors to initialize this menu item. | 331 // Called by the two constructors to initialize this menu item. |
329 void Init(MenuItemView* parent, | 332 void Init(MenuItemView* parent, |
330 int command, | 333 int command, |
331 MenuItemView::Type type, | 334 MenuItemView::Type type, |
332 MenuDelegate* delegate); | 335 MenuDelegate* delegate); |
333 | 336 |
334 // The RunXXX methods call into this to set up the necessary state before | 337 // The RunXXX methods call into this to set up the necessary state before |
335 // running. | 338 // running. |
336 void PrepareForRun(bool has_mnemonics, bool show_mnemonics); | 339 void PrepareForRun(bool has_mnemonics, bool show_mnemonics, |
| 340 bool is_root_context_menu); |
337 | 341 |
338 // Returns the flags passed to DrawStringInt. | 342 // Returns the flags passed to DrawStringInt. |
339 int GetDrawStringFlags(); | 343 int GetDrawStringFlags(); |
340 | 344 |
341 // Returns the font to use for menu text. | 345 // Returns the font to use for menu text. |
342 const gfx::Font& GetFont(); | 346 const gfx::Font& GetFont(); |
343 | 347 |
344 // If this menu item has no children a child is added showing it has no | 348 // If this menu item has no children a child is added showing it has no |
345 // children. Otherwise AddEmtpyMenus is recursively invoked on child menu | 349 // children. Otherwise AddEmtpyMenus is recursively invoked on child menu |
346 // items that have children. | 350 // items that have children. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 // Title. | 434 // Title. |
431 string16 title_; | 435 string16 title_; |
432 | 436 |
433 // Does the title have a mnemonic? Only useful on the root menu item. | 437 // Does the title have a mnemonic? Only useful on the root menu item. |
434 bool has_mnemonics_; | 438 bool has_mnemonics_; |
435 | 439 |
436 // Should we show the mnemonic? Mnemonics are shown if this is true or | 440 // Should we show the mnemonic? Mnemonics are shown if this is true or |
437 // MenuConfig says mnemonics should be shown. Only used on the root menu item. | 441 // MenuConfig says mnemonics should be shown. Only used on the root menu item. |
438 bool show_mnemonics_; | 442 bool show_mnemonics_; |
439 | 443 |
| 444 // Is this menu the root layer of a context menu |
| 445 bool is_root_context_menu_; |
| 446 |
440 // Set if menu has icons or icon_views (applies to root menu item only). | 447 // Set if menu has icons or icon_views (applies to root menu item only). |
441 bool has_icons_; | 448 bool has_icons_; |
442 | 449 |
443 // Pointer to a view with a menu icon. | 450 // Pointer to a view with a menu icon. |
444 View* icon_view_; | 451 View* icon_view_; |
445 | 452 |
446 // The tooltip to show on hover for this menu item. | 453 // The tooltip to show on hover for this menu item. |
447 string16 tooltip_; | 454 string16 tooltip_; |
448 | 455 |
449 // Width of a menu icon area. | 456 // Width of a menu icon area. |
(...skipping 28 matching lines...) Expand all Loading... |
478 // If set to false, the right margin will be removed for menu lines | 485 // If set to false, the right margin will be removed for menu lines |
479 // containing other elements. | 486 // containing other elements. |
480 bool use_right_margin_; | 487 bool use_right_margin_; |
481 | 488 |
482 DISALLOW_COPY_AND_ASSIGN(MenuItemView); | 489 DISALLOW_COPY_AND_ASSIGN(MenuItemView); |
483 }; | 490 }; |
484 | 491 |
485 } // namespace views | 492 } // namespace views |
486 | 493 |
487 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ | 494 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ |
OLD | NEW |