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

Side by Side Diff: views/controls/menu/menu_item_view.cc

Issue 5110011: A non-GTK version of menus for touchui. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: fix compile for touch on chromeos Created 10 years 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 | « views/controls/menu/menu_item_view.h ('k') | views/controls/menu/native_menu_x.h » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "views/controls/menu/menu_item_view.h" 5 #include "views/controls/menu/menu_item_view.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/menus/menu_model.h"
8 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
9 #include "gfx/canvas.h" 10 #include "gfx/canvas.h"
10 #include "grit/app_strings.h" 11 #include "grit/app_strings.h"
11 #include "views/controls/button/text_button.h" 12 #include "views/controls/button/text_button.h"
12 #include "views/controls/button/menu_button.h" 13 #include "views/controls/button/menu_button.h"
13 #include "views/controls/menu/menu_config.h" 14 #include "views/controls/menu/menu_config.h"
14 #include "views/controls/menu/menu_controller.h" 15 #include "views/controls/menu/menu_controller.h"
15 #include "views/controls/menu/menu_separator.h" 16 #include "views/controls/menu/menu_separator.h"
16 #include "views/controls/menu/submenu_view.h" 17 #include "views/controls/menu/submenu_view.h"
17 18
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 controller_->Run(parent, NULL, this, bounds, anchor, NULL); 231 controller_->Run(parent, NULL, this, bounds, anchor, NULL);
231 } 232 }
232 233
233 void MenuItemView::Cancel() { 234 void MenuItemView::Cancel() {
234 if (controller_ && !canceled_) { 235 if (controller_ && !canceled_) {
235 canceled_ = true; 236 canceled_ = true;
236 controller_->Cancel(MenuController::EXIT_ALL); 237 controller_->Cancel(MenuController::EXIT_ALL);
237 } 238 }
238 } 239 }
239 240
241 MenuItemView* MenuItemView::AppendMenuItemFromModel(menus::MenuModel* model,
242 int index,
243 int id) {
244 SkBitmap icon;
245 std::wstring label;
246 MenuItemView::Type type;
247 menus::MenuModel::ItemType menu_type = model->GetTypeAt(index);
248 switch (menu_type) {
249 case menus::MenuModel::TYPE_COMMAND:
250 model->GetIconAt(index, &icon);
251 type = MenuItemView::NORMAL;
252 label = UTF16ToWide(model->GetLabelAt(index));
253 break;
254 case menus::MenuModel::TYPE_CHECK:
255 type = MenuItemView::CHECKBOX;
256 label = UTF16ToWide(model->GetLabelAt(index));
257 break;
258 case menus::MenuModel::TYPE_RADIO:
259 type = MenuItemView::RADIO;
260 label = UTF16ToWide(model->GetLabelAt(index));
261 break;
262 case menus::MenuModel::TYPE_SEPARATOR:
263 type = MenuItemView::SEPARATOR;
264 break;
265 case menus::MenuModel::TYPE_SUBMENU:
266 type = MenuItemView::SUBMENU;
267 label = UTF16ToWide(model->GetLabelAt(index));
268 break;
269 default:
270 NOTREACHED();
271 type = MenuItemView::NORMAL;
272 break;
273 }
274
275 return AppendMenuItemImpl(id, label, icon, type);
276 }
277
240 MenuItemView* MenuItemView::AppendMenuItemImpl(int item_id, 278 MenuItemView* MenuItemView::AppendMenuItemImpl(int item_id,
241 const std::wstring& label, 279 const std::wstring& label,
242 const SkBitmap& icon, 280 const SkBitmap& icon,
243 Type type) { 281 Type type) {
244 if (!submenu_) 282 if (!submenu_)
245 CreateSubmenu(); 283 CreateSubmenu();
246 if (type == SEPARATOR) { 284 if (type == SEPARATOR) {
247 submenu_->AddChildView(new MenuSeparator()); 285 submenu_->AddChildView(new MenuSeparator());
248 return NULL; 286 return NULL;
249 } 287 }
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 } 656 }
619 657
620 std::wstring MenuItemView::GetAcceleratorText() { 658 std::wstring MenuItemView::GetAcceleratorText() {
621 Accelerator accelerator; 659 Accelerator accelerator;
622 return (GetDelegate() && 660 return (GetDelegate() &&
623 GetDelegate()->GetAccelerator(GetCommand(), &accelerator)) ? 661 GetDelegate()->GetAccelerator(GetCommand(), &accelerator)) ?
624 accelerator.GetShortcutText() : std::wstring(); 662 accelerator.GetShortcutText() : std::wstring();
625 } 663 }
626 664
627 } // namespace views 665 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/menu/menu_item_view.h ('k') | views/controls/menu/native_menu_x.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698