summaryrefslogtreecommitdiffstats
path: root/app/menus/simple_menu_model.cc
diff options
context:
space:
mode:
Diffstat (limited to 'app/menus/simple_menu_model.cc')
-rw-r--r--app/menus/simple_menu_model.cc33
1 files changed, 23 insertions, 10 deletions
diff --git a/app/menus/simple_menu_model.cc b/app/menus/simple_menu_model.cc
index 8631666..3e51986 100644
--- a/app/menus/simple_menu_model.cc
+++ b/app/menus/simple_menu_model.cc
@@ -20,7 +20,7 @@ SimpleMenuModel::~SimpleMenuModel() {
}
void SimpleMenuModel::AddItem(int command_id, const string16& label) {
- Item item = { command_id, label, SkBitmap(), TYPE_COMMAND, -1, NULL };
+ Item item = { command_id, label, SkBitmap(), TYPE_COMMAND, -1, NULL, NULL };
AppendItem(item);
}
@@ -30,7 +30,7 @@ void SimpleMenuModel::AddItemWithStringId(int command_id, int string_id) {
void SimpleMenuModel::AddSeparator() {
Item item = { kSeparatorId, string16(), SkBitmap(), TYPE_SEPARATOR, -1,
- NULL };
+ NULL, NULL };
AppendItem(item);
}
@@ -45,7 +45,8 @@ void SimpleMenuModel::AddCheckItemWithStringId(int command_id, int string_id) {
void SimpleMenuModel::AddRadioItem(int command_id, const string16& label,
int group_id) {
- Item item = { command_id, label, SkBitmap(), TYPE_RADIO, group_id, NULL };
+ Item item = { command_id, label, SkBitmap(), TYPE_RADIO, group_id, NULL,
+ NULL };
AppendItem(item);
}
@@ -54,9 +55,15 @@ void SimpleMenuModel::AddRadioItemWithStringId(int command_id, int string_id,
AddRadioItem(command_id, l10n_util::GetStringUTF16(string_id), group_id);
}
+void SimpleMenuModel::AddButtonItem(int command_id,
+ ButtonMenuItemModel* model) {
+ Item item = { 0, string16(), SkBitmap(), TYPE_BUTTON_ITEM, -1, NULL, model };
+ AppendItem(item);
+}
+
void SimpleMenuModel::AddSubMenu(int command_id, const string16& label,
MenuModel* model) {
- Item item = { command_id, label, SkBitmap(), TYPE_SUBMENU, -1, model };
+ Item item = { command_id, label, SkBitmap(), TYPE_SUBMENU, -1, model, NULL };
AppendItem(item);
}
@@ -67,7 +74,7 @@ void SimpleMenuModel::AddSubMenuWithStringId(int command_id,
void SimpleMenuModel::InsertItemAt(
int index, int command_id, const string16& label) {
- Item item = { command_id, label, SkBitmap(), TYPE_COMMAND, -1, NULL };
+ Item item = { command_id, label, SkBitmap(), TYPE_COMMAND, -1, NULL, NULL };
InsertItemAtIndex(item, index);
}
@@ -78,13 +85,13 @@ void SimpleMenuModel::InsertItemWithStringIdAt(
void SimpleMenuModel::InsertSeparatorAt(int index) {
Item item = { kSeparatorId, string16(), SkBitmap(), TYPE_SEPARATOR, -1,
- NULL };
+ NULL, NULL };
InsertItemAtIndex(item, index);
}
void SimpleMenuModel::InsertCheckItemAt(
int index, int command_id, const string16& label) {
- Item item = { command_id, label, SkBitmap(), TYPE_CHECK, -1, NULL };
+ Item item = { command_id, label, SkBitmap(), TYPE_CHECK, -1, NULL, NULL };
InsertItemAtIndex(item, index);
}
@@ -96,7 +103,8 @@ void SimpleMenuModel::InsertCheckItemWithStringIdAt(
void SimpleMenuModel::InsertRadioItemAt(
int index, int command_id, const string16& label, int group_id) {
- Item item = { command_id, label, SkBitmap(), TYPE_RADIO, group_id, NULL };
+ Item item = { command_id, label, SkBitmap(), TYPE_RADIO, group_id, NULL,
+ NULL };
InsertItemAtIndex(item, index);
}
@@ -108,7 +116,7 @@ void SimpleMenuModel::InsertRadioItemWithStringIdAt(
void SimpleMenuModel::InsertSubMenuAt(
int index, int command_id, const string16& label, MenuModel* model) {
- Item item = { command_id, label, SkBitmap(), TYPE_SUBMENU, -1, model };
+ Item item = { command_id, label, SkBitmap(), TYPE_SUBMENU, -1, model, NULL };
InsertItemAtIndex(item, index);
}
@@ -199,9 +207,14 @@ bool SimpleMenuModel::GetIconAt(int index, SkBitmap* icon) const {
return true;
}
+ButtonMenuItemModel* SimpleMenuModel::GetButtonMenuItemAt(int index) const {
+ return items_.at(FlipIndex(index)).button_model;
+}
+
bool SimpleMenuModel::IsEnabledAt(int index) const {
int command_id = GetCommandIdAt(index);
- if (!delegate_ || command_id == kSeparatorId)
+ if (!delegate_ || command_id == kSeparatorId ||
+ items_.at(FlipIndex(index)).button_model)
return true;
return delegate_->IsCommandIdEnabled(command_id);
}