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

Side by Side Diff: ui/views/controls/menu/menu_item_view.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_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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/string16.h" 14 #include "base/string16.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "third_party/skia/include/core/SkBitmap.h" 16 #include "ui/gfx/image/image_skia.h"
17 #include "ui/views/view.h" 17 #include "ui/views/view.h"
18 18
19 #if defined(OS_WIN) 19 #if defined(OS_WIN)
20 #include <windows.h> 20 #include <windows.h>
21 21
22 #include "ui/base/native_theme/native_theme.h" 22 #include "ui/base/native_theme/native_theme.h"
23 #endif 23 #endif
24 24
25 namespace gfx { 25 namespace gfx {
26 class Font; 26 class Font;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 const string16& item_text, const string16& accelerator_text); 127 const string16& item_text, const string16& accelerator_text);
128 128
129 // Hides and cancels the menu. This does nothing if the menu is not open. 129 // Hides and cancels the menu. This does nothing if the menu is not open.
130 void Cancel(); 130 void Cancel();
131 131
132 // Add an item to the menu at a specified index. ChildrenChanged() should 132 // Add an item to the menu at a specified index. ChildrenChanged() should
133 // called after adding menu items if the menu may be active. 133 // called after adding menu items if the menu may be active.
134 MenuItemView* AddMenuItemAt(int index, 134 MenuItemView* AddMenuItemAt(int index,
135 int item_id, 135 int item_id,
136 const string16& label, 136 const string16& label,
137 const SkBitmap& icon, 137 const gfx::ImageSkia& icon,
138 Type type); 138 Type type);
139 139
140 // Remove an item from the menu at a specified index. 140 // Remove an item from the menu at a specified index.
141 // ChildrenChanged() should be called after removing menu items (whether 141 // ChildrenChanged() should be called after removing menu items (whether
142 // the menu may be active or not). 142 // the menu may be active or not).
143 void RemoveMenuItemAt(int index); 143 void RemoveMenuItemAt(int index);
144 144
145 // Appends an item to this menu. 145 // Appends an item to this menu.
146 // item_id The id of the item, used to identify it in delegate callbacks 146 // item_id The id of the item, used to identify it in delegate callbacks
147 // or (if delegate is NULL) to identify the command associated 147 // or (if delegate is NULL) to identify the command associated
148 // with this item with the controller specified in the ctor. Note 148 // with this item with the controller specified in the ctor. Note
149 // that this value should not be 0 as this has a special meaning 149 // that this value should not be 0 as this has a special meaning
150 // ("NULL command, no item selected") 150 // ("NULL command, no item selected")
151 // label The text label shown. 151 // label The text label shown.
152 // type The type of item. 152 // type The type of item.
153 MenuItemView* AppendMenuItem(int item_id, 153 MenuItemView* AppendMenuItem(int item_id,
154 const string16& label, 154 const string16& label,
155 Type type); 155 Type type);
156 156
157 // Append a submenu to this menu. 157 // Append a submenu to this menu.
158 // The returned pointer is owned by this menu. 158 // The returned pointer is owned by this menu.
159 MenuItemView* AppendSubMenu(int item_id, 159 MenuItemView* AppendSubMenu(int item_id,
160 const string16& label); 160 const string16& label);
161 161
162 // Append a submenu with an icon to this menu. 162 // Append a submenu with an icon to this menu.
163 // The returned pointer is owned by this menu. 163 // The returned pointer is owned by this menu.
164 MenuItemView* AppendSubMenuWithIcon(int item_id, 164 MenuItemView* AppendSubMenuWithIcon(int item_id,
165 const string16& label, 165 const string16& label,
166 const SkBitmap& icon); 166 const gfx::ImageSkia& icon);
167 167
168 // This is a convenience for standard text label menu items where the label 168 // This is a convenience for standard text label menu items where the label
169 // is provided with this call. 169 // is provided with this call.
170 MenuItemView* AppendMenuItemWithLabel(int item_id, 170 MenuItemView* AppendMenuItemWithLabel(int item_id,
171 const string16& label); 171 const string16& label);
172 172
173 // This is a convenience for text label menu items where the label is 173 // This is a convenience for text label menu items where the label is
174 // provided by the delegate. 174 // provided by the delegate.
175 MenuItemView* AppendDelegateMenuItem(int item_id); 175 MenuItemView* AppendDelegateMenuItem(int item_id);
176 176
177 // Adds a separator to this menu 177 // Adds a separator to this menu
178 void AppendSeparator(); 178 void AppendSeparator();
179 179
180 // Appends a menu item with an icon. This is for the menu item which 180 // Appends a menu item with an icon. This is for the menu item which
181 // needs an icon. Calling this function forces the Menu class to draw 181 // needs an icon. Calling this function forces the Menu class to draw
182 // the menu, instead of relying on Windows. 182 // the menu, instead of relying on Windows.
183 MenuItemView* AppendMenuItemWithIcon(int item_id, 183 MenuItemView* AppendMenuItemWithIcon(int item_id,
184 const string16& label, 184 const string16& label,
185 const SkBitmap& icon); 185 const gfx::ImageSkia& icon);
186 186
187 // Creates a menu item for the specified entry in the model and appends it as 187 // Creates a menu item for the specified entry in the model and appends it as
188 // a child. |index| should be offset by GetFirstItemIndex() before calling 188 // a child. |index| should be offset by GetFirstItemIndex() before calling
189 // this function. 189 // this function.
190 MenuItemView* AppendMenuItemFromModel(ui::MenuModel* model, 190 MenuItemView* AppendMenuItemFromModel(ui::MenuModel* model,
191 int index, 191 int index,
192 int id); 192 int id);
193 193
194 // All the AppendXXX methods funnel into this. 194 // All the AppendXXX methods funnel into this.
195 MenuItemView* AppendMenuItemImpl(int item_id, 195 MenuItemView* AppendMenuItemImpl(int item_id,
196 const string16& label, 196 const string16& label,
197 const SkBitmap& icon, 197 const gfx::ImageSkia& icon,
198 Type type); 198 Type type);
199 199
200 // Returns the view that contains child menu items. If the submenu has 200 // Returns the view that contains child menu items. If the submenu has
201 // not been creates, this creates it. 201 // not been creates, this creates it.
202 virtual SubmenuView* CreateSubmenu(); 202 virtual SubmenuView* CreateSubmenu();
203 203
204 // Returns true if this menu item has a submenu. 204 // Returns true if this menu item has a submenu.
205 virtual bool HasSubmenu() const; 205 virtual bool HasSubmenu() const;
206 206
207 // Returns the view containing child menu items. 207 // Returns the view containing child menu items.
(...skipping 19 matching lines...) Expand all
227 // the mouse around the menu while open. 227 // the mouse around the menu while open.
228 void SetSelected(bool selected); 228 void SetSelected(bool selected);
229 229
230 // Returns true if the item is selected. 230 // Returns true if the item is selected.
231 bool IsSelected() const { return selected_; } 231 bool IsSelected() const { return selected_; }
232 232
233 // Sets the |tooltip| for a menu item view with |item_id| identifier. 233 // Sets the |tooltip| for a menu item view with |item_id| identifier.
234 void SetTooltip(const string16& tooltip, int item_id); 234 void SetTooltip(const string16& tooltip, int item_id);
235 235
236 // Sets the icon for the descendant identified by item_id. 236 // Sets the icon for the descendant identified by item_id.
237 void SetIcon(const SkBitmap& icon, int item_id); 237 void SetIcon(const gfx::ImageSkia& icon, int item_id);
238 238
239 // Sets the icon of this menu item. 239 // Sets the icon of this menu item.
240 void SetIcon(const SkBitmap& icon); 240 void SetIcon(const gfx::ImageSkia& icon);
241 241
242 // Returns the icon. 242 // Returns the icon.
243 const SkBitmap& GetIcon() const { return icon_; } 243 const gfx::ImageSkia& GetIcon() const { return icon_; }
244 244
245 // Sets the command id of this menu item. 245 // Sets the command id of this menu item.
246 void SetCommand(int command) { command_ = command; } 246 void SetCommand(int command) { command_ = command; }
247 247
248 // Returns the command id of this item. 248 // Returns the command id of this item.
249 int GetCommand() const { return command_; } 249 int GetCommand() const { return command_; }
250 250
251 // Paints the menu item. 251 // Paints the menu item.
252 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; 252 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
253 253
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 // Command id. 429 // Command id.
430 int command_; 430 int command_;
431 431
432 // Submenu, created via CreateSubmenu. 432 // Submenu, created via CreateSubmenu.
433 SubmenuView* submenu_; 433 SubmenuView* submenu_;
434 434
435 // Title. 435 // Title.
436 string16 title_; 436 string16 title_;
437 437
438 // Icon. 438 // Icon.
439 SkBitmap icon_; 439 gfx::ImageSkia icon_;
440 440
441 // Does the title have a mnemonic? Only useful on the root menu item. 441 // Does the title have a mnemonic? Only useful on the root menu item.
442 bool has_mnemonics_; 442 bool has_mnemonics_;
443 443
444 // Should we show the mnemonic? Mnemonics are shown if this is true or 444 // Should we show the mnemonic? Mnemonics are shown if this is true or
445 // MenuConfig says mnemonics should be shown. Only used on the root menu item. 445 // MenuConfig says mnemonics should be shown. Only used on the root menu item.
446 bool show_mnemonics_; 446 bool show_mnemonics_;
447 447
448 bool has_icons_; 448 bool has_icons_;
449 449
(...skipping 29 matching lines...) Expand all
479 // If set to false, the right margin will be removed for menu lines 479 // If set to false, the right margin will be removed for menu lines
480 // containing other elements. 480 // containing other elements.
481 bool use_right_margin_; 481 bool use_right_margin_;
482 482
483 DISALLOW_COPY_AND_ASSIGN(MenuItemView); 483 DISALLOW_COPY_AND_ASSIGN(MenuItemView);
484 }; 484 };
485 485
486 } // namespace views 486 } // namespace views
487 487
488 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_ 488 #endif // UI_VIEWS_CONTROLS_MENU_MENU_ITEM_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698