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

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

Issue 23530070: backup for dynamic recent tabs submenu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: new RecentTabsMenuModelDelegate w/ new intf Created 7 years, 2 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
« no previous file with comments | « ui/views/controls/menu/menu_item_view.h ('k') | ui/views/controls/menu/menu_model_adapter.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) 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 #include "ui/views/controls/menu/menu_item_view.h" 5 #include "ui/views/controls/menu/menu_item_view.h"
6 6
7 #include "base/i18n/case_conversion.h" 7 #include "base/i18n/case_conversion.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "grit/ui_resources.h" 10 #include "grit/ui_resources.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 SEPARATOR, ui::NORMAL_SEPARATOR); 304 SEPARATOR, ui::NORMAL_SEPARATOR);
305 } 305 }
306 306
307 MenuItemView* MenuItemView::AppendMenuItemWithIcon(int item_id, 307 MenuItemView* MenuItemView::AppendMenuItemWithIcon(int item_id,
308 const string16& label, 308 const string16& label,
309 const gfx::ImageSkia& icon) { 309 const gfx::ImageSkia& icon) {
310 return AppendMenuItemImpl(item_id, label, string16(), string16(), icon, 310 return AppendMenuItemImpl(item_id, label, string16(), string16(), icon,
311 NORMAL, ui::NORMAL_SEPARATOR); 311 NORMAL, ui::NORMAL_SEPARATOR);
312 } 312 }
313 313
314 MenuItemView* MenuItemView::AppendMenuItemFromModel(ui::MenuModel* model,
315 int index,
316 int id) {
317 gfx::Image icon;
318 model->GetIconAt(index, &icon);
319 string16 label, sublabel, minor_text;
320 ui::MenuSeparatorType separator_style = ui::NORMAL_SEPARATOR;
321 MenuItemView::Type type;
322 ui::MenuModel::ItemType menu_type = model->GetTypeAt(index);
323 switch (menu_type) {
324 case ui::MenuModel::TYPE_COMMAND:
325 type = MenuItemView::NORMAL;
326 label = model->GetLabelAt(index);
327 sublabel = model->GetSublabelAt(index);
328 minor_text = model->GetMinorTextAt(index);
329 break;
330 case ui::MenuModel::TYPE_CHECK:
331 type = MenuItemView::CHECKBOX;
332 label = model->GetLabelAt(index);
333 sublabel = model->GetSublabelAt(index);
334 minor_text = model->GetMinorTextAt(index);
335 break;
336 case ui::MenuModel::TYPE_RADIO:
337 type = MenuItemView::RADIO;
338 label = model->GetLabelAt(index);
339 sublabel = model->GetSublabelAt(index);
340 minor_text = model->GetMinorTextAt(index);
341 break;
342 case ui::MenuModel::TYPE_SEPARATOR:
343 icon = gfx::Image();
344 type = MenuItemView::SEPARATOR;
345 separator_style = model->GetSeparatorTypeAt(index);
346 break;
347 case ui::MenuModel::TYPE_SUBMENU:
348 type = MenuItemView::SUBMENU;
349 label = model->GetLabelAt(index);
350 sublabel = model->GetSublabelAt(index);
351 minor_text = model->GetMinorTextAt(index);
352 break;
353 default:
354 NOTREACHED();
355 type = MenuItemView::NORMAL;
356 break;
357 }
358
359 return AppendMenuItemImpl(id,
360 label,
361 sublabel,
362 minor_text,
363 icon.IsEmpty() ? gfx::ImageSkia() : *icon.ToImageSkia(),
364 type,
365 separator_style);
366 }
367
368 MenuItemView* MenuItemView::AppendMenuItemImpl( 314 MenuItemView* MenuItemView::AppendMenuItemImpl(
369 int item_id, 315 int item_id,
370 const string16& label, 316 const string16& label,
371 const string16& sublabel, 317 const string16& sublabel,
372 const string16& minor_text, 318 const string16& minor_text,
373 const gfx::ImageSkia& icon, 319 const gfx::ImageSkia& icon,
374 Type type, 320 Type type,
375 ui::MenuSeparatorType separator_style) { 321 ui::MenuSeparatorType separator_style) {
376 const int index = submenu_ ? submenu_->child_count() : 0; 322 const int index = submenu_ ? submenu_->child_count() : 0;
377 return AddMenuItemAt(index, item_id, label, sublabel, minor_text, icon, type, 323 return AddMenuItemAt(index, item_id, label, sublabel, minor_text, icon, type,
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 } else { 1056 } else {
1111 const Type& type = menu_item->GetType(); 1057 const Type& type = menu_item->GetType();
1112 if (type == CHECKBOX || type == RADIO) 1058 if (type == CHECKBOX || type == RADIO)
1113 return true; 1059 return true;
1114 } 1060 }
1115 } 1061 }
1116 return false; 1062 return false;
1117 } 1063 }
1118 1064
1119 } // namespace views 1065 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_item_view.h ('k') | ui/views/controls/menu/menu_model_adapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698