diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-16 21:44:56 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-16 21:44:56 +0000 |
commit | 735085ed203ee840e493971d9a87c156f45d67b0 (patch) | |
tree | eb1c3bb90981f5014665e9231fead42d7593f60a /app/menus | |
parent | 87641841064ef4d2a3c084693682c72f16d7ebe9 (diff) | |
download | chromium_src-735085ed203ee840e493971d9a87c156f45d67b0.zip chromium_src-735085ed203ee840e493971d9a87c156f45d67b0.tar.gz chromium_src-735085ed203ee840e493971d9a87c156f45d67b0.tar.bz2 |
Move implementations in menu model stuff from header to implementation.
This breaks a dependency on SkBitmap.h for everything that just uses menus.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/2854046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52751 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/menus')
-rw-r--r-- | app/menus/button_menu_item_model.cc | 21 | ||||
-rw-r--r-- | app/menus/button_menu_item_model.h | 17 | ||||
-rw-r--r-- | app/menus/simple_menu_model.cc | 30 | ||||
-rw-r--r-- | app/menus/simple_menu_model.h | 25 |
4 files changed, 60 insertions, 33 deletions
diff --git a/app/menus/button_menu_item_model.cc b/app/menus/button_menu_item_model.cc index 19cbdab3..c1c7f7a 100644 --- a/app/menus/button_menu_item_model.cc +++ b/app/menus/button_menu_item_model.cc @@ -8,6 +8,24 @@ namespace menus { +bool ButtonMenuItemModel::Delegate::IsLabelForCommandIdDynamic( + int command_id) const { + return false; +} + +string16 ButtonMenuItemModel::Delegate::GetLabelForCommandId( + int command_id) const { + return string16(); +} + +struct ButtonMenuItemModel::Item { + int command_id; + ButtonType type; + string16 label; + int icon_idr; + bool part_of_group; +}; + ButtonMenuItemModel::ButtonMenuItemModel( int string_id, ButtonMenuItemModel::Delegate* delegate) @@ -15,6 +33,9 @@ ButtonMenuItemModel::ButtonMenuItemModel( delegate_(delegate) { } +ButtonMenuItemModel::~ButtonMenuItemModel() { +} + void ButtonMenuItemModel::AddGroupItemWithStringId( int command_id, int string_id) { Item item = { command_id, TYPE_BUTTON, l10n_util::GetStringUTF16(string_id), diff --git a/app/menus/button_menu_item_model.h b/app/menus/button_menu_item_model.h index 6292904..ec30d0a 100644 --- a/app/menus/button_menu_item_model.h +++ b/app/menus/button_menu_item_model.h @@ -25,18 +25,15 @@ class ButtonMenuItemModel { class Delegate { public: // Some command ids have labels that change over time. - virtual bool IsLabelForCommandIdDynamic(int command_id) const { - return false; - } - virtual string16 GetLabelForCommandId(int command_id) const { - return string16(); - } + virtual bool IsLabelForCommandIdDynamic(int command_id) const; + virtual string16 GetLabelForCommandId(int command_id) const; // Performs the action associated with the specified command id. virtual void ExecuteCommand(int command_id) = 0; }; ButtonMenuItemModel(int string_id, ButtonMenuItemModel::Delegate* delegate); + ~ButtonMenuItemModel(); // Adds a button that will emit |command_id|. All buttons created through // this method will have the same size, based on the largest button. @@ -85,13 +82,7 @@ class ButtonMenuItemModel { // The non-clickable label to the left of the buttons. string16 item_label_; - struct Item { - int command_id; - ButtonType type; - string16 label; - int icon_idr; - bool part_of_group; - }; + struct Item; std::vector<Item> items_; Delegate* delegate_; diff --git a/app/menus/simple_menu_model.cc b/app/menus/simple_menu_model.cc index 291aa5a..6a40f75 100644 --- a/app/menus/simple_menu_model.cc +++ b/app/menus/simple_menu_model.cc @@ -5,11 +5,37 @@ #include "app/menus/simple_menu_model.h" #include "app/l10n_util.h" +#include "third_party/skia/include/core/SkBitmap.h" static const int kSeparatorId = -1; namespace menus { +struct SimpleMenuModel::Item { + int command_id; + string16 label; + SkBitmap icon; + ItemType type; + int group_id; + MenuModel* submenu; + ButtonMenuItemModel* button_model; +}; + +//////////////////////////////////////////////////////////////////////////////// +// SimpleMenuModel::Delegate, public: + +bool SimpleMenuModel::Delegate::IsLabelForCommandIdDynamic( + int command_id) const { + return false; +} + +string16 SimpleMenuModel::Delegate::GetLabelForCommandId(int command_id) const { + return string16(); +} + +void SimpleMenuModel::Delegate::CommandIdHighlighted(int command_id) { +} + //////////////////////////////////////////////////////////////////////////////// // SimpleMenuModel, public: @@ -131,6 +157,10 @@ void SimpleMenuModel::SetIcon(int index, const SkBitmap& icon) { items_[index].icon = icon; } +void SimpleMenuModel::Clear() { + items_.clear(); +} + int SimpleMenuModel::GetIndexOfCommandId(int command_id) { std::vector<Item>::iterator itr; for (itr = items_.begin(); itr != items_.end(); itr++) { diff --git a/app/menus/simple_menu_model.h b/app/menus/simple_menu_model.h index 34031c9..d57e924 100644 --- a/app/menus/simple_menu_model.h +++ b/app/menus/simple_menu_model.h @@ -9,7 +9,6 @@ #include "base/string16.h" #include "app/menus/menu_model.h" -#include "third_party/skia/include/core/SkBitmap.h" namespace menus { @@ -34,16 +33,12 @@ class SimpleMenuModel : public MenuModel { menus::Accelerator* accelerator) = 0; // Some command ids have labels that change over time. - virtual bool IsLabelForCommandIdDynamic(int command_id) const { - return false; - } - virtual string16 GetLabelForCommandId(int command_id) const { - return string16(); - } + virtual bool IsLabelForCommandIdDynamic(int command_id) const; + virtual string16 GetLabelForCommandId(int command_id) const; // Notifies the delegate that the item with the specified command id was // visually highlighted within the menu. - virtual void CommandIdHighlighted(int command_id) {} + virtual void CommandIdHighlighted(int command_id); // Performs the action associated with the specified command id. virtual void ExecuteCommand(int command_id) = 0; @@ -88,9 +83,7 @@ class SimpleMenuModel : public MenuModel { void SetIcon(int index, const SkBitmap& icon); // Clears all items. Note that it does not free MenuModel of submenu. - void Clear() { - items_.clear(); - } + void Clear(); // Returns the index of the item that has the given |command_id|. Returns // -1 if not found. @@ -125,15 +118,7 @@ class SimpleMenuModel : public MenuModel { Delegate* delegate() { return delegate_; } private: - struct Item { - int command_id; - string16 label; - SkBitmap icon; - ItemType type; - int group_id; - MenuModel* submenu; - ButtonMenuItemModel* button_model; - }; + struct Item; std::vector<Item> items_; // Functions for inserting items into |items_|. |