Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: ui/base/models/button_menu_item_model.cc

Issue 1003853004: MacViews: Gets wrench menu working (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@grd
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/base/models/button_menu_item_model.h ('k') | ui/views/controls/menu/menu_model_adapter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/base/models/button_menu_item_model.h" 5 #include "ui/base/models/button_menu_item_model.h"
6 6
7 #include "ui/base/l10n/l10n_util.h" 7 #include "ui/base/l10n/l10n_util.h"
8 8
9 namespace ui { 9 namespace ui {
10 10
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 int ButtonMenuItemModel::GetCommandIdAt(int index) const { 81 int ButtonMenuItemModel::GetCommandIdAt(int index) const {
82 return items_[index].command_id; 82 return items_[index].command_id;
83 } 83 }
84 84
85 bool ButtonMenuItemModel::IsItemDynamicAt(int index) const { 85 bool ButtonMenuItemModel::IsItemDynamicAt(int index) const {
86 if (delegate_) 86 if (delegate_)
87 return delegate_->IsItemForCommandIdDynamic(GetCommandIdAt(index)); 87 return delegate_->IsItemForCommandIdDynamic(GetCommandIdAt(index));
88 return false; 88 return false;
89 } 89 }
90 90
91 bool ButtonMenuItemModel::GetAcceleratorAt(int index,
92 ui::Accelerator* accelerator) const {
93 if (delegate_) {
94 return delegate_->GetAcceleratorForCommandId(GetCommandIdAt(index),
95 accelerator);
96 }
97 return false;
98 }
99
91 base::string16 ButtonMenuItemModel::GetLabelAt(int index) const { 100 base::string16 ButtonMenuItemModel::GetLabelAt(int index) const {
92 if (IsItemDynamicAt(index)) 101 if (IsItemDynamicAt(index))
93 return delegate_->GetLabelForCommandId(GetCommandIdAt(index)); 102 return delegate_->GetLabelForCommandId(GetCommandIdAt(index));
94 return items_[index].label; 103 return items_[index].label;
95 } 104 }
96 105
97 bool ButtonMenuItemModel::GetIconAt(int index, int* icon_idr) const { 106 bool ButtonMenuItemModel::GetIconAt(int index, int* icon_idr) const {
98 if (items_[index].icon_idr == -1) 107 if (items_[index].icon_idr == -1)
99 return false; 108 return false;
100 109
101 *icon_idr = items_[index].icon_idr; 110 *icon_idr = items_[index].icon_idr;
102 return true; 111 return true;
103 } 112 }
104 113
105 bool ButtonMenuItemModel::PartOfGroup(int index) const { 114 bool ButtonMenuItemModel::PartOfGroup(int index) const {
106 return items_[index].part_of_group; 115 return items_[index].part_of_group;
107 } 116 }
108 117
109 void ButtonMenuItemModel::ActivatedCommand(int command_id) { 118 void ButtonMenuItemModel::ActivatedAt(int index) {
110 if (delegate_) 119 if (delegate_)
111 delegate_->ExecuteCommand(command_id, 0); 120 delegate_->ExecuteCommand(GetCommandIdAt(index), 0);
112 } 121 }
113 122
114 bool ButtonMenuItemModel::IsEnabledAt(int index) const { 123 bool ButtonMenuItemModel::IsEnabledAt(int index) const {
115 return IsCommandIdEnabled(items_[index].command_id); 124 return IsCommandIdEnabled(items_[index].command_id);
116 } 125 }
117 126
118 bool ButtonMenuItemModel::DismissesMenuAt(int index) const { 127 bool ButtonMenuItemModel::DismissesMenuAt(int index) const {
119 return DoesCommandIdDismissMenu(items_[index].command_id); 128 return DoesCommandIdDismissMenu(items_[index].command_id);
120 } 129 }
121 130
122 bool ButtonMenuItemModel::IsCommandIdEnabled(int command_id) const { 131 bool ButtonMenuItemModel::IsCommandIdEnabled(int command_id) const {
123 if (delegate_) 132 if (delegate_)
124 return delegate_->IsCommandIdEnabled(command_id); 133 return delegate_->IsCommandIdEnabled(command_id);
125 return true; 134 return true;
126 } 135 }
127 136
128 bool ButtonMenuItemModel::DoesCommandIdDismissMenu(int command_id) const { 137 bool ButtonMenuItemModel::DoesCommandIdDismissMenu(int command_id) const {
129 if (delegate_) 138 if (delegate_)
130 return delegate_->DoesCommandIdDismissMenu(command_id); 139 return delegate_->DoesCommandIdDismissMenu(command_id);
131 return true; 140 return true;
132 } 141 }
133 142
134 143
135 } // namespace ui 144 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/models/button_menu_item_model.h ('k') | ui/views/controls/menu/menu_model_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698