OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/views/action_box_menu_item_view.h" | |
6 | |
7 #include "chrome/browser/ui/toolbar/action_box_menu_model.h" | |
8 #include "ui/views/controls/menu/submenu_view.h" | |
9 | |
10 // ActionBoxMenuItemView ------------------------------------------------------- | |
Aaron Boodman
2012/07/02 22:41:34
Delete this line.
| |
11 | |
12 ActionBoxMenuItemView::ActionBoxMenuItemView(views::MenuDelegate* delegate) | |
13 : views::MenuItemView(delegate) { | |
14 } | |
15 | |
16 void ActionBoxMenuItemView::Layout() { | |
17 MenuItemView::Layout(); | |
18 if (!has_children()) | |
19 return; | |
20 | |
21 View* child = child_at(0); | |
22 child->SetPosition(gfx::Point(0,0)); | |
23 child->SizeToPreferredSize(); | |
24 } | |
25 | |
26 ActionBoxMenuItemView::ActionBoxMenuItemView(MenuItemView* parent, | |
27 int command, | |
28 MenuItemView::Type type) | |
29 : MenuItemView(parent, command, type) { | |
30 } | |
31 | |
32 ActionBoxMenuItemView::~ActionBoxMenuItemView() { | |
33 } | |
34 | |
35 void ActionBoxMenuItemView::OnPaint(gfx::Canvas* canvas) { | |
36 MenuItemView::OnPaint(canvas); | |
37 } | |
38 | |
39 views::MenuItemView* ActionBoxMenuItemView::AppendMenuItemFromModel( | |
40 ActionBoxMenuModel* model, int index, int id) { | |
41 string16 label; | |
42 MenuItemView::Type type; | |
43 ui::MenuModel::ItemType menu_type = model->GetTypeAt(index); | |
44 switch (menu_type) { | |
45 case ui::MenuModel::TYPE_COMMAND: | |
Aaron Boodman
2012/07/02 22:41:34
We don't expect to be receiving most of these type
| |
46 type = MenuItemView::NORMAL; | |
47 label = model->GetLabelAt(index); | |
48 break; | |
49 case ui::MenuModel::TYPE_CHECK: | |
50 type = MenuItemView::CHECKBOX; | |
51 label = model->GetLabelAt(index); | |
52 break; | |
53 case ui::MenuModel::TYPE_RADIO: | |
54 type = MenuItemView::RADIO; | |
55 label = model->GetLabelAt(index); | |
56 break; | |
57 case ui::MenuModel::TYPE_SEPARATOR: | |
58 type = MenuItemView::SEPARATOR; | |
59 break; | |
60 case ui::MenuModel::TYPE_SUBMENU: | |
61 type = MenuItemView::SUBMENU; | |
62 label = model->GetLabelAt(index); | |
63 break; | |
64 default: | |
65 NOTREACHED(); | |
66 type = MenuItemView::NORMAL; | |
67 break; | |
68 } | |
69 | |
70 MenuItemView* item = new ActionBoxMenuItemView(this, id, type); | |
71 item->SetTitle(label); | |
72 int menu_index = GetSubmenu()->child_count(); | |
73 AddMenuItemAt(menu_index, item); | |
74 return item; | |
75 } | |
OLD | NEW |