| 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_DELEGATE_H_ | 5 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_DELEGATE_H_ |
| 6 #define UI_VIEWS_CONTROLS_MENU_MENU_DELEGATE_H_ | 6 #define UI_VIEWS_CONTROLS_MENU_MENU_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 virtual ~MenuDelegate(); | 56 virtual ~MenuDelegate(); |
| 57 | 57 |
| 58 // Whether or not an item should be shown as checked. This is invoked for | 58 // Whether or not an item should be shown as checked. This is invoked for |
| 59 // radio buttons and check buttons. | 59 // radio buttons and check buttons. |
| 60 virtual bool IsItemChecked(int id) const; | 60 virtual bool IsItemChecked(int id) const; |
| 61 | 61 |
| 62 // The string shown for the menu item. This is only invoked when an item is | 62 // The string shown for the menu item. This is only invoked when an item is |
| 63 // added with an empty label. | 63 // added with an empty label. |
| 64 virtual string16 GetLabel(int id) const; | 64 virtual base::string16 GetLabel(int id) const; |
| 65 | 65 |
| 66 // The font for the menu item label. | 66 // The font for the menu item label. |
| 67 virtual const gfx::Font* GetLabelFont(int id) const; | 67 virtual const gfx::Font* GetLabelFont(int id) const; |
| 68 | 68 |
| 69 // Override the text color of a given menu item dependent on the | 69 // Override the text color of a given menu item dependent on the |
| 70 // |command_id| and its |is_hovered| state. Returns true if it chooses to | 70 // |command_id| and its |is_hovered| state. Returns true if it chooses to |
| 71 // override the color. | 71 // override the color. |
| 72 virtual bool GetForegroundColor(int command_id, | 72 virtual bool GetForegroundColor(int command_id, |
| 73 bool is_hovered, | 73 bool is_hovered, |
| 74 SkColor* override_color) const; | 74 SkColor* override_color) const; |
| 75 | 75 |
| 76 // Override the background color of a given menu item dependent on the | 76 // Override the background color of a given menu item dependent on the |
| 77 // |command_id| and its |is_hovered| state. Returns true if it chooses to | 77 // |command_id| and its |is_hovered| state. Returns true if it chooses to |
| 78 // override the color. | 78 // override the color. |
| 79 virtual bool GetBackgroundColor(int command_id, | 79 virtual bool GetBackgroundColor(int command_id, |
| 80 bool is_hovered, | 80 bool is_hovered, |
| 81 SkColor* override_color) const; | 81 SkColor* override_color) const; |
| 82 | 82 |
| 83 // The tooltip shown for the menu item. This is invoked when the user | 83 // The tooltip shown for the menu item. This is invoked when the user |
| 84 // hovers over the item, and no tooltip text has been set for that item. | 84 // hovers over the item, and no tooltip text has been set for that item. |
| 85 virtual string16 GetTooltipText(int id, const gfx::Point& screen_loc) const; | 85 virtual base::string16 GetTooltipText(int id, |
| 86 const gfx::Point& screen_loc) const; |
| 86 | 87 |
| 87 // If there is an accelerator for the menu item with id |id| it is set in | 88 // If there is an accelerator for the menu item with id |id| it is set in |
| 88 // |accelerator| and true is returned. | 89 // |accelerator| and true is returned. |
| 89 virtual bool GetAccelerator(int id, ui::Accelerator* accelerator); | 90 virtual bool GetAccelerator(int id, ui::Accelerator* accelerator); |
| 90 | 91 |
| 91 // Shows the context menu with the specified id. This is invoked when the | 92 // Shows the context menu with the specified id. This is invoked when the |
| 92 // user does the appropriate gesture to show a context menu. The id | 93 // user does the appropriate gesture to show a context menu. The id |
| 93 // identifies the id of the menu to show the context menu for. | 94 // identifies the id of the menu to show the context menu for. |
| 94 // is_mouse_gesture is true if this is the result of a mouse gesture. | 95 // is_mouse_gesture is true if this is the result of a mouse gesture. |
| 95 // If this is not the result of a mouse gesture |p| is the recommended | 96 // If this is not the result of a mouse gesture |p| is the recommended |
| 96 // location to display the content menu at. In either case, |p| is in | 97 // location to display the content menu at. In either case, |p| is in |
| 97 // screen coordinates. | 98 // screen coordinates. |
| 98 // Returns true if a context menu was displayed, otherwise false | 99 // Returns true if a context menu was displayed, otherwise false |
| 99 virtual bool ShowContextMenu(MenuItemView* source, | 100 virtual bool ShowContextMenu(MenuItemView* source, |
| 100 int id, | 101 int id, |
| 101 const gfx::Point& p, | 102 const gfx::Point& p, |
| 102 ui::MenuSourceType source_type); | 103 ui::MenuSourceType source_type); |
| 103 | 104 |
| 104 // Controller | 105 // Controller |
| 105 virtual bool SupportsCommand(int id) const; | 106 virtual bool SupportsCommand(int id) const; |
| 106 virtual bool IsCommandEnabled(int id) const; | 107 virtual bool IsCommandEnabled(int id) const; |
| 107 virtual bool GetContextualLabel(int id, string16* out) const; | 108 virtual bool GetContextualLabel(int id, base::string16* out) const; |
| 108 virtual void ExecuteCommand(int id) { | 109 virtual void ExecuteCommand(int id) { |
| 109 } | 110 } |
| 110 | 111 |
| 111 // If nested menus are showing (nested menus occur when a menu shows a context | 112 // If nested menus are showing (nested menus occur when a menu shows a context |
| 112 // menu) this is invoked to determine if all the menus should be closed when | 113 // menu) this is invoked to determine if all the menus should be closed when |
| 113 // the user selects the menu with the command |id|. This returns true to | 114 // the user selects the menu with the command |id|. This returns true to |
| 114 // indicate that all menus should be closed. Return false if only the | 115 // indicate that all menus should be closed. Return false if only the |
| 115 // context menu should be closed. | 116 // context menu should be closed. |
| 116 virtual bool ShouldCloseAllMenusOnExecute(int id); | 117 virtual bool ShouldCloseAllMenusOnExecute(int id); |
| 117 | 118 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 int* left_margin, | 225 int* left_margin, |
| 225 int* right_margin) const; | 226 int* right_margin) const; |
| 226 // Returns true if the labels should reserve additional spacing for e.g. | 227 // Returns true if the labels should reserve additional spacing for e.g. |
| 227 // submenu indicators at the end of the line. | 228 // submenu indicators at the end of the line. |
| 228 virtual bool ShouldReserveSpaceForSubmenuIndicator() const; | 229 virtual bool ShouldReserveSpaceForSubmenuIndicator() const; |
| 229 }; | 230 }; |
| 230 | 231 |
| 231 } // namespace views | 232 } // namespace views |
| 232 | 233 |
| 233 #endif // UI_VIEWS_CONTROLS_MENU_MENU_DELEGATE_H_ | 234 #endif // UI_VIEWS_CONTROLS_MENU_MENU_DELEGATE_H_ |
| OLD | NEW |