Chromium Code Reviews| Index: chrome/browser/ui/views/action_box_menu_item_view.cc |
| diff --git a/chrome/browser/ui/views/action_box_menu_item_view.cc b/chrome/browser/ui/views/action_box_menu_item_view.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3c3e8c016fa4a8a4c33745a88aa8f74f2ff517d4 |
| --- /dev/null |
| +++ b/chrome/browser/ui/views/action_box_menu_item_view.cc |
| @@ -0,0 +1,75 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/views/action_box_menu_item_view.h" |
| + |
| +#include "chrome/browser/ui/toolbar/action_box_menu_model.h" |
| +#include "ui/views/controls/menu/submenu_view.h" |
| + |
| +// ActionBoxMenuItemView ------------------------------------------------------- |
|
Aaron Boodman
2012/07/02 22:41:34
Delete this line.
|
| + |
| +ActionBoxMenuItemView::ActionBoxMenuItemView(views::MenuDelegate* delegate) |
| + : views::MenuItemView(delegate) { |
| +} |
| + |
| +void ActionBoxMenuItemView::Layout() { |
| + MenuItemView::Layout(); |
| + if (!has_children()) |
| + return; |
| + |
| + View* child = child_at(0); |
| + child->SetPosition(gfx::Point(0,0)); |
| + child->SizeToPreferredSize(); |
| +} |
| + |
| +ActionBoxMenuItemView::ActionBoxMenuItemView(MenuItemView* parent, |
| + int command, |
| + MenuItemView::Type type) |
| + : MenuItemView(parent, command, type) { |
| +} |
| + |
| +ActionBoxMenuItemView::~ActionBoxMenuItemView() { |
| +} |
| + |
| +void ActionBoxMenuItemView::OnPaint(gfx::Canvas* canvas) { |
| + MenuItemView::OnPaint(canvas); |
| +} |
| + |
| +views::MenuItemView* ActionBoxMenuItemView::AppendMenuItemFromModel( |
| + ActionBoxMenuModel* model, int index, int id) { |
| + string16 label; |
| + MenuItemView::Type type; |
| + ui::MenuModel::ItemType menu_type = model->GetTypeAt(index); |
| + switch (menu_type) { |
| + case ui::MenuModel::TYPE_COMMAND: |
|
Aaron Boodman
2012/07/02 22:41:34
We don't expect to be receiving most of these type
|
| + type = MenuItemView::NORMAL; |
| + label = model->GetLabelAt(index); |
| + break; |
| + case ui::MenuModel::TYPE_CHECK: |
| + type = MenuItemView::CHECKBOX; |
| + label = model->GetLabelAt(index); |
| + break; |
| + case ui::MenuModel::TYPE_RADIO: |
| + type = MenuItemView::RADIO; |
| + label = model->GetLabelAt(index); |
| + break; |
| + case ui::MenuModel::TYPE_SEPARATOR: |
| + type = MenuItemView::SEPARATOR; |
| + break; |
| + case ui::MenuModel::TYPE_SUBMENU: |
| + type = MenuItemView::SUBMENU; |
| + label = model->GetLabelAt(index); |
| + break; |
| + default: |
| + NOTREACHED(); |
| + type = MenuItemView::NORMAL; |
| + break; |
| + } |
| + |
| + MenuItemView* item = new ActionBoxMenuItemView(this, id, type); |
| + item->SetTitle(label); |
| + int menu_index = GetSubmenu()->child_count(); |
| + AddMenuItemAt(menu_index, item); |
| + return item; |
| +} |