summaryrefslogtreecommitdiffstats
path: root/views/controls/menu
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-14 15:49:40 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-14 15:49:40 +0000
commit44cbd9e3734527f73a83f8a864be0bb5ccae0a7a (patch)
treea997fb0565558d63e0eab62b631ef984de3e9596 /views/controls/menu
parent0c1c047d641a599ffffa280ab50d564cedb3e436 (diff)
downloadchromium_src-44cbd9e3734527f73a83f8a864be0bb5ccae0a7a.zip
chromium_src-44cbd9e3734527f73a83f8a864be0bb5ccae0a7a.tar.gz
chromium_src-44cbd9e3734527f73a83f8a864be0bb5ccae0a7a.tar.bz2
Move models from app to ui/base/models
BUG=none TEST=none TBR=brettw git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71446 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/menu')
-rw-r--r--views/controls/menu/menu_2.cc2
-rw-r--r--views/controls/menu/menu_2.h8
-rw-r--r--views/controls/menu/menu_delegate.h2
-rw-r--r--views/controls/menu/menu_item_view.cc16
-rw-r--r--views/controls/menu/menu_item_view.h4
-rw-r--r--views/controls/menu/native_menu_gtk.cc28
-rw-r--r--views/controls/menu/native_menu_gtk.h4
-rw-r--r--views/controls/menu/native_menu_win.cc18
-rw-r--r--views/controls/menu/native_menu_win.h10
-rw-r--r--views/controls/menu/native_menu_x.cc26
-rw-r--r--views/controls/menu/native_menu_x.h8
11 files changed, 63 insertions, 63 deletions
diff --git a/views/controls/menu/menu_2.cc b/views/controls/menu/menu_2.cc
index 037d5de..f64f275 100644
--- a/views/controls/menu/menu_2.cc
+++ b/views/controls/menu/menu_2.cc
@@ -9,7 +9,7 @@
namespace views {
-Menu2::Menu2(menus::MenuModel* model)
+Menu2::Menu2(ui::MenuModel* model)
: model_(model),
ALLOW_THIS_IN_INITIALIZER_LIST(
wrapper_(MenuWrapper::CreateWrapper(this))) {
diff --git a/views/controls/menu/menu_2.h b/views/controls/menu/menu_2.h
index 2d0ff23..8916b7c 100644
--- a/views/controls/menu/menu_2.h
+++ b/views/controls/menu/menu_2.h
@@ -6,8 +6,8 @@
#define VIEWS_CONTROLS_MENU_MENU_2_H_
#pragma once
-#include "app/menus/menu_model.h"
#include "base/scoped_ptr.h"
+#include "ui/base/models/menu_model.h"
#include "views/controls/menu/menu_wrapper.h"
namespace gfx {
@@ -32,7 +32,7 @@ class Menu2 {
// from the constructor. EG:
// MyClass : menu_(this) {}
// is likely to have problems.
- explicit Menu2(menus::MenuModel* model);
+ explicit Menu2(ui::MenuModel* model);
virtual ~Menu2() {}
// How the menu is aligned relative to the point it is shown at.
@@ -74,7 +74,7 @@ class Menu2 {
void RemoveMenuListener(MenuListener* listener);
// Accessors.
- menus::MenuModel* model() const { return model_; }
+ ui::MenuModel* model() const { return model_; }
// Sets the minimum width of the menu.
void SetMinimumWidth(int width);
@@ -82,7 +82,7 @@ class Menu2 {
private:
friend class NativeMenuGtk;
- menus::MenuModel* model_;
+ ui::MenuModel* model_;
// The object that actually implements the menu.
scoped_ptr<MenuWrapper> wrapper_;
diff --git a/views/controls/menu/menu_delegate.h b/views/controls/menu/menu_delegate.h
index ec9b944..d24ef81 100644
--- a/views/controls/menu/menu_delegate.h
+++ b/views/controls/menu/menu_delegate.h
@@ -27,7 +27,7 @@ class MenuButton;
// Delegate for a menu. This class is used as part of MenuItemView, see it
// for details.
-// TODO(sky): merge this with menus::MenuModel.
+// TODO(sky): merge this with ui::MenuModel.
class MenuDelegate : Controller {
public:
// Used during drag and drop to indicate where the drop indicator should
diff --git a/views/controls/menu/menu_item_view.cc b/views/controls/menu/menu_item_view.cc
index 8d2b84d..ee60c79 100644
--- a/views/controls/menu/menu_item_view.cc
+++ b/views/controls/menu/menu_item_view.cc
@@ -5,10 +5,10 @@
#include "views/controls/menu/menu_item_view.h"
#include "app/l10n_util.h"
-#include "app/menus/menu_model.h"
#include "base/utf_string_conversions.h"
#include "gfx/canvas.h"
#include "grit/app_strings.h"
+#include "ui/base/models/menu_model.h"
#include "views/controls/button/text_button.h"
#include "views/controls/button/menu_button.h"
#include "views/controls/menu/menu_config.h"
@@ -239,31 +239,31 @@ void MenuItemView::Cancel() {
}
}
-MenuItemView* MenuItemView::AppendMenuItemFromModel(menus::MenuModel* model,
+MenuItemView* MenuItemView::AppendMenuItemFromModel(ui::MenuModel* model,
int index,
int id) {
SkBitmap icon;
std::wstring label;
MenuItemView::Type type;
- menus::MenuModel::ItemType menu_type = model->GetTypeAt(index);
+ ui::MenuModel::ItemType menu_type = model->GetTypeAt(index);
switch (menu_type) {
- case menus::MenuModel::TYPE_COMMAND:
+ case ui::MenuModel::TYPE_COMMAND:
model->GetIconAt(index, &icon);
type = MenuItemView::NORMAL;
label = UTF16ToWide(model->GetLabelAt(index));
break;
- case menus::MenuModel::TYPE_CHECK:
+ case ui::MenuModel::TYPE_CHECK:
type = MenuItemView::CHECKBOX;
label = UTF16ToWide(model->GetLabelAt(index));
break;
- case menus::MenuModel::TYPE_RADIO:
+ case ui::MenuModel::TYPE_RADIO:
type = MenuItemView::RADIO;
label = UTF16ToWide(model->GetLabelAt(index));
break;
- case menus::MenuModel::TYPE_SEPARATOR:
+ case ui::MenuModel::TYPE_SEPARATOR:
type = MenuItemView::SEPARATOR;
break;
- case menus::MenuModel::TYPE_SUBMENU:
+ case ui::MenuModel::TYPE_SUBMENU:
type = MenuItemView::SUBMENU;
label = UTF16ToWide(model->GetLabelAt(index));
break;
diff --git a/views/controls/menu/menu_item_view.h b/views/controls/menu/menu_item_view.h
index 83e5102..23036a4 100644
--- a/views/controls/menu/menu_item_view.h
+++ b/views/controls/menu/menu_item_view.h
@@ -21,7 +21,7 @@
#include "gfx/native_theme_win.h"
#endif
-namespace menus {
+namespace ui {
class MenuModel;
}
@@ -184,7 +184,7 @@ class MenuItemView : public View {
// Creates a menu item for the specified entry in the model and appends it as
// a child. |index| should be offset by GetFirstItemIndex() before calling
// this function.
- MenuItemView* AppendMenuItemFromModel(menus::MenuModel* model,
+ MenuItemView* AppendMenuItemFromModel(ui::MenuModel* model,
int index,
int id);
diff --git a/views/controls/menu/native_menu_gtk.cc b/views/controls/menu/native_menu_gtk.cc
index 3aecff8..57033d4 100644
--- a/views/controls/menu/native_menu_gtk.cc
+++ b/views/controls/menu/native_menu_gtk.cc
@@ -8,7 +8,6 @@
#include <map>
#include <string>
-#include "app/menus/menu_model.h"
#include "base/i18n/rtl.h"
#include "base/message_loop.h"
#include "base/time.h"
@@ -18,6 +17,7 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/keycodes/keyboard_codes.h"
#include "ui/base/keycodes/keyboard_code_conversion_gtk.h"
+#include "ui/base/models/menu_model.h"
#include "views/accelerator.h"
#include "views/controls/menu/menu_2.h"
#include "views/controls/menu/nested_dispatcher_gtk.h"
@@ -44,10 +44,10 @@ struct Position {
};
// Returns true if the menu item type specified can be executed as a command.
-bool MenuTypeCanExecute(menus::MenuModel::ItemType type) {
- return type == menus::MenuModel::TYPE_COMMAND ||
- type == menus::MenuModel::TYPE_CHECK ||
- type == menus::MenuModel::TYPE_RADIO;
+bool MenuTypeCanExecute(ui::MenuModel::ItemType type) {
+ return type == ui::MenuModel::TYPE_COMMAND ||
+ type == ui::MenuModel::TYPE_CHECK ||
+ type == ui::MenuModel::TYPE_RADIO;
}
// A callback to gtk_container_foreach to remove all children.
@@ -174,10 +174,10 @@ void NativeMenuGtk::Rebuild() {
std::map<int, GtkRadioMenuItem*> radio_groups_;
for (int i = 0; i < model_->GetItemCount(); ++i) {
- menus::MenuModel::ItemType type = model_->GetTypeAt(i);
- if (type == menus::MenuModel::TYPE_SEPARATOR) {
+ ui::MenuModel::ItemType type = model_->GetTypeAt(i);
+ if (type == ui::MenuModel::TYPE_SEPARATOR) {
AddSeparatorAt(i);
- } else if (type == menus::MenuModel::TYPE_RADIO) {
+ } else if (type == ui::MenuModel::TYPE_RADIO) {
const int radio_group_id = model_->GetGroupIdAt(i);
std::map<int, GtkRadioMenuItem*>::const_iterator iter
= radio_groups_.find(radio_group_id);
@@ -329,12 +329,12 @@ GtkWidget* NativeMenuGtk::AddMenuItemAt(int index,
std::string label = gfx::ConvertAcceleratorsFromWindowsStyle(UTF16ToUTF8(
model_->GetLabelAt(index)));
- menus::MenuModel::ItemType type = model_->GetTypeAt(index);
+ ui::MenuModel::ItemType type = model_->GetTypeAt(index);
switch (type) {
- case menus::MenuModel::TYPE_CHECK:
+ case ui::MenuModel::TYPE_CHECK:
menu_item = gtk_check_menu_item_new_with_mnemonic(label.c_str());
break;
- case menus::MenuModel::TYPE_RADIO:
+ case ui::MenuModel::TYPE_RADIO:
if (radio_group) {
menu_item = gtk_radio_menu_item_new_with_mnemonic_from_widget(
radio_group, label.c_str());
@@ -343,8 +343,8 @@ GtkWidget* NativeMenuGtk::AddMenuItemAt(int index,
menu_item = gtk_radio_menu_item_new_with_mnemonic(NULL, label.c_str());
}
break;
- case menus::MenuModel::TYPE_SUBMENU:
- case menus::MenuModel::TYPE_COMMAND: {
+ case ui::MenuModel::TYPE_SUBMENU:
+ case ui::MenuModel::TYPE_COMMAND: {
SkBitmap icon;
// Create menu item with icon if icon exists.
if (model_->HasIcons() && model_->GetIconAt(index, &icon)) {
@@ -380,7 +380,7 @@ GtkWidget* NativeMenuGtk::AddMenuItemAt(int index,
pango_font_description_free(pfd);
}
- if (type == menus::MenuModel::TYPE_SUBMENU) {
+ if (type == ui::MenuModel::TYPE_SUBMENU) {
Menu2* submenu = new Menu2(model_->GetSubmenuModelAt(index));
static_cast<NativeMenuGtk*>(submenu->wrapper_.get())->set_parent(this);
g_object_set_data(G_OBJECT(menu_item), "submenu", submenu);
diff --git a/views/controls/menu/native_menu_gtk.h b/views/controls/menu/native_menu_gtk.h
index f15bc19..58a6993 100644
--- a/views/controls/menu/native_menu_gtk.h
+++ b/views/controls/menu/native_menu_gtk.h
@@ -15,7 +15,7 @@
#include "base/task.h"
#include "views/controls/menu/menu_wrapper.h"
-namespace menus {
+namespace ui {
class MenuModel;
}
@@ -101,7 +101,7 @@ class NativeMenuGtk : public MenuWrapper,
// If we're a submenu, this is the parent.
NativeMenuGtk* parent_;
- menus::MenuModel* model_;
+ ui::MenuModel* model_;
GtkWidget* menu_;
diff --git a/views/controls/menu/native_menu_win.cc b/views/controls/menu/native_menu_win.cc
index efdaa67..687e932 100644
--- a/views/controls/menu/native_menu_win.cc
+++ b/views/controls/menu/native_menu_win.cc
@@ -121,7 +121,7 @@ class NativeMenuWin::MenuHostWindow {
// Called when the user selects a specific item.
void OnMenuCommand(int position, HMENU menu) {
NativeMenuWin* intergoat = GetNativeMenuWinFromHMENU(menu);
- menus::MenuModel* model = intergoat->model_;
+ ui::MenuModel* model = intergoat->model_;
model->ActivatedAt(position);
}
@@ -297,7 +297,7 @@ const wchar_t* NativeMenuWin::MenuHostWindow::kWindowClassName =
////////////////////////////////////////////////////////////////////////////////
// NativeMenuWin, public:
-NativeMenuWin::NativeMenuWin(menus::MenuModel* model, HWND system_menu_for)
+NativeMenuWin::NativeMenuWin(ui::MenuModel* model, HWND system_menu_for)
: model_(model),
menu_(NULL),
owner_draw_(l10n_util::NeedOverrideDefaultUIFont(NULL, NULL) &&
@@ -357,7 +357,7 @@ void NativeMenuWin::Rebuild() {
for (int menu_index = first_item_index_;
menu_index < first_item_index_ + model_->GetItemCount(); ++menu_index) {
int model_index = menu_index - first_item_index_;
- if (model_->GetTypeAt(model_index) == menus::MenuModel::TYPE_SEPARATOR)
+ if (model_->GetTypeAt(model_index) == ui::MenuModel::TYPE_SEPARATOR)
AddSeparatorItemAt(menu_index, model_index);
else
AddMenuItemAt(menu_index, model_index);
@@ -486,13 +486,13 @@ void NativeMenuWin::AddMenuItemAt(int menu_index, int model_index) {
ItemData* item_data = new ItemData;
item_data->label = std::wstring();
- menus::MenuModel::ItemType type = model_->GetTypeAt(model_index);
- if (type == menus::MenuModel::TYPE_SUBMENU) {
+ ui::MenuModel::ItemType type = model_->GetTypeAt(model_index);
+ if (type == ui::MenuModel::TYPE_SUBMENU) {
item_data->submenu.reset(new Menu2(model_->GetSubmenuModelAt(model_index)));
mii.fMask |= MIIM_SUBMENU;
mii.hSubMenu = item_data->submenu->GetNativeMenu();
} else {
- if (type == menus::MenuModel::TYPE_RADIO)
+ if (type == ui::MenuModel::TYPE_RADIO)
mii.fType |= MFT_RADIOCHECK;
mii.wID = model_->GetCommandIdAt(model_index);
}
@@ -551,8 +551,8 @@ void NativeMenuWin::UpdateMenuItemInfoForString(
int model_index,
const std::wstring& label) {
std::wstring formatted = label;
- menus::MenuModel::ItemType type = model_->GetTypeAt(model_index);
- if (type != menus::MenuModel::TYPE_SUBMENU) {
+ ui::MenuModel::ItemType type = model_->GetTypeAt(model_index);
+ if (type != ui::MenuModel::TYPE_SUBMENU) {
// Add accelerator details to the label if provided.
views::Accelerator accelerator(ui::VKEY_UNKNOWN, false, false, false);
if (model_->GetAcceleratorAt(model_index, &accelerator)) {
@@ -612,7 +612,7 @@ void NativeMenuWin::CreateHostWindow() {
////////////////////////////////////////////////////////////////////////////////
// SystemMenuModel:
-SystemMenuModel::SystemMenuModel(menus::SimpleMenuModel::Delegate* delegate)
+SystemMenuModel::SystemMenuModel(ui::SimpleMenuModel::Delegate* delegate)
: SimpleMenuModel(delegate) {
}
diff --git a/views/controls/menu/native_menu_win.h b/views/controls/menu/native_menu_win.h
index e364bcc..eb28bbe 100644
--- a/views/controls/menu/native_menu_win.h
+++ b/views/controls/menu/native_menu_win.h
@@ -8,8 +8,8 @@
#include <vector>
-#include "app/menus/simple_menu_model.h"
#include "base/scoped_ptr.h"
+#include "ui/base/models/simple_menu_model.h"
#include "views/controls/menu/menu_wrapper.h"
namespace views {
@@ -21,7 +21,7 @@ class NativeMenuWin : public MenuWrapper {
// Construct a NativeMenuWin, with a model and delegate. If |system_menu_for|
// is non-NULL, the NativeMenuWin wraps the system menu for that window.
// The caller owns the model and the delegate.
- NativeMenuWin(menus::MenuModel* model, HWND system_menu_for);
+ NativeMenuWin(ui::MenuModel* model, HWND system_menu_for);
virtual ~NativeMenuWin();
// Overridden from MenuWrapper:
@@ -100,7 +100,7 @@ class NativeMenuWin : public MenuWrapper {
int n_code, WPARAM w_param, LPARAM l_param);
// Our attached model and delegate.
- menus::MenuModel* model_;
+ ui::MenuModel* model_;
HMENU menu_;
@@ -145,12 +145,12 @@ class NativeMenuWin : public MenuWrapper {
// A SimpleMenuModel subclass that allows the system menu for a window to be
// wrapped.
-class SystemMenuModel : public menus::SimpleMenuModel {
+class SystemMenuModel : public ui::SimpleMenuModel {
public:
explicit SystemMenuModel(Delegate* delegate);
virtual ~SystemMenuModel();
- // Overridden from menus::MenuModel:
+ // Overridden from ui::MenuModel:
virtual int GetFirstItemIndex(gfx::NativeMenu native_menu) const;
protected:
diff --git a/views/controls/menu/native_menu_x.cc b/views/controls/menu/native_menu_x.cc
index 45f9446..a952ea2 100644
--- a/views/controls/menu/native_menu_x.cc
+++ b/views/controls/menu/native_menu_x.cc
@@ -71,35 +71,35 @@ void NativeMenuX::SetMinimumWidth(int width) {
bool NativeMenuX::IsItemChecked(int cmd) const {
int index;
- menus::MenuModel* model = model_;
- if (!menus::MenuModel::GetModelAndIndexForCommandId(cmd, &model, &index))
+ ui::MenuModel* model = model_;
+ if (!ui::MenuModel::GetModelAndIndexForCommandId(cmd, &model, &index))
return false;
return model->IsItemCheckedAt(index);
}
bool NativeMenuX::IsCommandEnabled(int cmd) const {
int index;
- menus::MenuModel* model = model_;
- if (!menus::MenuModel::GetModelAndIndexForCommandId(cmd, &model, &index))
+ ui::MenuModel* model = model_;
+ if (!ui::MenuModel::GetModelAndIndexForCommandId(cmd, &model, &index))
return false;
return model->IsEnabledAt(index);
}
void NativeMenuX::ExecuteCommand(int cmd) {
int index;
- menus::MenuModel* model = model_;
- if (!menus::MenuModel::GetModelAndIndexForCommandId(cmd, &model, &index))
+ ui::MenuModel* model = model_;
+ if (!ui::MenuModel::GetModelAndIndexForCommandId(cmd, &model, &index))
return;
model->ActivatedAt(index);
}
bool NativeMenuX::GetAccelerator(int id, views::Accelerator* accelerator) {
int index;
- menus::MenuModel* model = model_;
- if (!menus::MenuModel::GetModelAndIndexForCommandId(id, &model, &index))
+ ui::MenuModel* model = model_;
+ if (!ui::MenuModel::GetModelAndIndexForCommandId(id, &model, &index))
return false;
- menus::Accelerator menu_accelerator;
+ ui::Accelerator menu_accelerator;
if (!model->GetAcceleratorAt(index, &menu_accelerator))
return false;
@@ -110,7 +110,7 @@ bool NativeMenuX::GetAccelerator(int id, views::Accelerator* accelerator) {
// private
void NativeMenuX::AddMenuItemsFromModel(MenuItemView* parent,
- menus::MenuModel* model) {
+ ui::MenuModel* model) {
for (int i = 0; i < model->GetItemCount(); ++i) {
int index = i + model->GetFirstItemIndex(NULL);
MenuItemView* child = parent->AppendMenuItemFromModel(model, index,
@@ -123,10 +123,10 @@ void NativeMenuX::AddMenuItemsFromModel(MenuItemView* parent,
}
void NativeMenuX::UpdateMenuFromModel(SubmenuView* menu,
- menus::MenuModel* model) {
+ ui::MenuModel* model) {
for (int i = 0, sep = 0; i < model->GetItemCount(); ++i) {
int index = i + model->GetFirstItemIndex(NULL);
- if (model->GetTypeAt(index) == menus::MenuModel::TYPE_SEPARATOR) {
+ if (model->GetTypeAt(index) == ui::MenuModel::TYPE_SEPARATOR) {
++sep;
continue;
}
@@ -147,7 +147,7 @@ void NativeMenuX::UpdateMenuFromModel(SubmenuView* menu,
mitem->SetIcon(icon);
}
- if (model->GetTypeAt(index) == menus::MenuModel::TYPE_SUBMENU) {
+ if (model->GetTypeAt(index) == ui::MenuModel::TYPE_SUBMENU) {
DCHECK(mitem->HasSubmenu());
UpdateMenuFromModel(mitem->GetSubmenu(), model->GetSubmenuModelAt(index));
}
diff --git a/views/controls/menu/native_menu_x.h b/views/controls/menu/native_menu_x.h
index b13f33e..2621fb3 100644
--- a/views/controls/menu/native_menu_x.h
+++ b/views/controls/menu/native_menu_x.h
@@ -10,7 +10,7 @@
#include "views/controls/menu/menu_item_view.h"
#include "views/controls/menu/menu_wrapper.h"
-namespace menus {
+namespace ui {
class MenuModel;
}
@@ -41,11 +41,11 @@ class NativeMenuX : public MenuWrapper,
virtual bool GetAccelerator(int id, views::Accelerator* accelerator);
private:
- void AddMenuItemsFromModel(MenuItemView* parent, menus::MenuModel* model);
- void UpdateMenuFromModel(SubmenuView* menu, menus::MenuModel* model);
+ void AddMenuItemsFromModel(MenuItemView* parent, ui::MenuModel* model);
+ void UpdateMenuFromModel(SubmenuView* menu, ui::MenuModel* model);
// The attached model and delegate. Does not assume ownership.
- menus::MenuModel* model_;
+ ui::MenuModel* model_;
scoped_ptr<MenuItemView> root_;
DISALLOW_COPY_AND_ASSIGN(NativeMenuX);