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

Side by Side Diff: ui/base/models/simple_menu_model.h

Issue 10437006: Converts ui/views/controls, ui/views/examples, ui/base/models to ImageSkia (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years, 7 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
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_BASE_MODELS_SIMPLE_MENU_MODEL_H_ 5 #ifndef UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_
6 #define UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_ 6 #define UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "ui/base/models/menu_model.h" 13 #include "ui/base/models/menu_model.h"
14 14
15 namespace gfx {
16 class ImageSkia;
17 }
18
15 namespace ui { 19 namespace ui {
16 20
17 class ButtonMenuItemModel; 21 class ButtonMenuItemModel;
18 22
19 // A simple MenuModel implementation with an imperative API for adding menu 23 // A simple MenuModel implementation with an imperative API for adding menu
20 // items. This makes it easy to construct fixed menus. Menus populated by 24 // items. This makes it easy to construct fixed menus. Menus populated by
21 // dynamic data sources may be better off implementing MenuModel directly. 25 // dynamic data sources may be better off implementing MenuModel directly.
22 // The breadth of MenuModel is not exposed through this API. 26 // The breadth of MenuModel is not exposed through this API.
23 class UI_EXPORT SimpleMenuModel : public MenuModel { 27 class UI_EXPORT SimpleMenuModel : public MenuModel {
24 public: 28 public:
25 class UI_EXPORT Delegate { 29 class UI_EXPORT Delegate {
26 public: 30 public:
27 // Methods for determining the state of specific command ids. 31 // Methods for determining the state of specific command ids.
28 virtual bool IsCommandIdChecked(int command_id) const = 0; 32 virtual bool IsCommandIdChecked(int command_id) const = 0;
29 virtual bool IsCommandIdEnabled(int command_id) const = 0; 33 virtual bool IsCommandIdEnabled(int command_id) const = 0;
30 virtual bool IsCommandIdVisible(int command_id) const; 34 virtual bool IsCommandIdVisible(int command_id) const;
31 35
32 // Gets the accelerator for the specified command id. Returns true if the 36 // Gets the accelerator for the specified command id. Returns true if the
33 // command id has a valid accelerator, false otherwise. 37 // command id has a valid accelerator, false otherwise.
34 virtual bool GetAcceleratorForCommandId( 38 virtual bool GetAcceleratorForCommandId(
35 int command_id, 39 int command_id,
36 ui::Accelerator* accelerator) = 0; 40 ui::Accelerator* accelerator) = 0;
37 41
38 // Some command ids have labels and icons that change over time. 42 // Some command ids have labels and icons that change over time.
39 virtual bool IsItemForCommandIdDynamic(int command_id) const; 43 virtual bool IsItemForCommandIdDynamic(int command_id) const;
40 virtual string16 GetLabelForCommandId(int command_id) const; 44 virtual string16 GetLabelForCommandId(int command_id) const;
41 // Gets the icon for the item with the specified id, returning true if there 45 // Gets the icon for the item with the specified id, returning true if there
42 // is an icon, false otherwise. 46 // is an icon, false otherwise.
43 virtual bool GetIconForCommandId(int command_id, SkBitmap* icon) const; 47 virtual bool GetIconForCommandId(int command_id,
48 gfx::ImageSkia* icon) const;
44 49
45 // Notifies the delegate that the item with the specified command id was 50 // Notifies the delegate that the item with the specified command id was
46 // visually highlighted within the menu. 51 // visually highlighted within the menu.
47 virtual void CommandIdHighlighted(int command_id); 52 virtual void CommandIdHighlighted(int command_id);
48 53
49 // Performs the action associated with the specified command id. 54 // Performs the action associated with the specified command id.
50 virtual void ExecuteCommand(int command_id) = 0; 55 virtual void ExecuteCommand(int command_id) = 0;
51 // Performs the action associates with the specified command id 56 // Performs the action associates with the specified command id
52 // with |event_flags|. 57 // with |event_flags|.
53 virtual void ExecuteCommand(int command_id, int event_flags); 58 virtual void ExecuteCommand(int command_id, int event_flags);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 void InsertRadioItemAt( 96 void InsertRadioItemAt(
92 int index, int command_id, const string16& label, int group_id); 97 int index, int command_id, const string16& label, int group_id);
93 void InsertRadioItemWithStringIdAt( 98 void InsertRadioItemWithStringIdAt(
94 int index, int command_id, int string_id, int group_id); 99 int index, int command_id, int string_id, int group_id);
95 void InsertSubMenuAt( 100 void InsertSubMenuAt(
96 int index, int command_id, const string16& label, MenuModel* model); 101 int index, int command_id, const string16& label, MenuModel* model);
97 void InsertSubMenuWithStringIdAt( 102 void InsertSubMenuWithStringIdAt(
98 int index, int command_id, int string_id, MenuModel* model); 103 int index, int command_id, int string_id, MenuModel* model);
99 104
100 // Sets the icon for the item at |index|. 105 // Sets the icon for the item at |index|.
101 void SetIcon(int index, const SkBitmap& icon); 106 void SetIcon(int index, const gfx::ImageSkia& icon);
102 107
103 // Clears all items. Note that it does not free MenuModel of submenu. 108 // Clears all items. Note that it does not free MenuModel of submenu.
104 void Clear(); 109 void Clear();
105 110
106 // Returns the index of the item that has the given |command_id|. Returns 111 // Returns the index of the item that has the given |command_id|. Returns
107 // -1 if not found. 112 // -1 if not found.
108 int GetIndexOfCommandId(int command_id); 113 int GetIndexOfCommandId(int command_id);
109 114
110 // Overridden from MenuModel: 115 // Overridden from MenuModel:
111 virtual bool HasIcons() const OVERRIDE; 116 virtual bool HasIcons() const OVERRIDE;
112 virtual int GetItemCount() const OVERRIDE; 117 virtual int GetItemCount() const OVERRIDE;
113 virtual ItemType GetTypeAt(int index) const OVERRIDE; 118 virtual ItemType GetTypeAt(int index) const OVERRIDE;
114 virtual int GetCommandIdAt(int index) const OVERRIDE; 119 virtual int GetCommandIdAt(int index) const OVERRIDE;
115 virtual string16 GetLabelAt(int index) const OVERRIDE; 120 virtual string16 GetLabelAt(int index) const OVERRIDE;
116 virtual bool IsItemDynamicAt(int index) const OVERRIDE; 121 virtual bool IsItemDynamicAt(int index) const OVERRIDE;
117 virtual bool GetAcceleratorAt(int index, 122 virtual bool GetAcceleratorAt(int index,
118 ui::Accelerator* accelerator) const OVERRIDE; 123 ui::Accelerator* accelerator) const OVERRIDE;
119 virtual bool IsItemCheckedAt(int index) const OVERRIDE; 124 virtual bool IsItemCheckedAt(int index) const OVERRIDE;
120 virtual int GetGroupIdAt(int index) const OVERRIDE; 125 virtual int GetGroupIdAt(int index) const OVERRIDE;
121 virtual bool GetIconAt(int index, SkBitmap* icon) OVERRIDE; 126 virtual bool GetIconAt(int index, gfx::ImageSkia* icon) OVERRIDE;
122 virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt( 127 virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt(
123 int index) const OVERRIDE; 128 int index) const OVERRIDE;
124 virtual bool IsEnabledAt(int index) const OVERRIDE; 129 virtual bool IsEnabledAt(int index) const OVERRIDE;
125 virtual bool IsVisibleAt(int index) const OVERRIDE; 130 virtual bool IsVisibleAt(int index) const OVERRIDE;
126 virtual void HighlightChangedTo(int index) OVERRIDE; 131 virtual void HighlightChangedTo(int index) OVERRIDE;
127 virtual void ActivatedAt(int index) OVERRIDE; 132 virtual void ActivatedAt(int index) OVERRIDE;
128 virtual void ActivatedAt(int index, int event_flags) OVERRIDE; 133 virtual void ActivatedAt(int index, int event_flags) OVERRIDE;
129 virtual MenuModel* GetSubmenuModelAt(int index) const OVERRIDE; 134 virtual MenuModel* GetSubmenuModelAt(int index) const OVERRIDE;
130 virtual void MenuWillShow() OVERRIDE; 135 virtual void MenuWillShow() OVERRIDE;
131 virtual void MenuClosed() OVERRIDE; 136 virtual void MenuClosed() OVERRIDE;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 MenuModelDelegate* menu_model_delegate_; 170 MenuModelDelegate* menu_model_delegate_;
166 171
167 base::WeakPtrFactory<SimpleMenuModel> method_factory_; 172 base::WeakPtrFactory<SimpleMenuModel> method_factory_;
168 173
169 DISALLOW_COPY_AND_ASSIGN(SimpleMenuModel); 174 DISALLOW_COPY_AND_ASSIGN(SimpleMenuModel);
170 }; 175 };
171 176
172 } // namespace ui 177 } // namespace ui
173 178
174 #endif // UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_ 179 #endif // UI_BASE_MODELS_SIMPLE_MENU_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698