OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/views/controls/menu/menu_model_adapter.h" | 5 #include "ui/views/controls/menu/menu_model_adapter.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/base/l10n/l10n_util.h" | 8 #include "ui/base/l10n/l10n_util.h" |
9 #include "ui/base/models/menu_model.h" | 9 #include "ui/base/models/menu_model.h" |
10 #include "ui/gfx/image/image.h" | 10 #include "ui/gfx/image/image.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 52 } |
53 | 53 |
54 // Static. | 54 // Static. |
55 MenuItemView* MenuModelAdapter::AddMenuItemFromModelAt(ui::MenuModel* model, | 55 MenuItemView* MenuModelAdapter::AddMenuItemFromModelAt(ui::MenuModel* model, |
56 int model_index, | 56 int model_index, |
57 MenuItemView* menu, | 57 MenuItemView* menu, |
58 int menu_index, | 58 int menu_index, |
59 int item_id) { | 59 int item_id) { |
60 gfx::Image icon; | 60 gfx::Image icon; |
61 model->GetIconAt(model_index, &icon); | 61 model->GetIconAt(model_index, &icon); |
62 string16 label, sublabel, minor_text; | 62 base::string16 label, sublabel, minor_text; |
63 ui::MenuSeparatorType separator_style = ui::NORMAL_SEPARATOR; | 63 ui::MenuSeparatorType separator_style = ui::NORMAL_SEPARATOR; |
64 MenuItemView::Type type; | 64 MenuItemView::Type type; |
65 ui::MenuModel::ItemType menu_type = model->GetTypeAt(model_index); | 65 ui::MenuModel::ItemType menu_type = model->GetTypeAt(model_index); |
66 | 66 |
67 switch (menu_type) { | 67 switch (menu_type) { |
68 case ui::MenuModel::TYPE_COMMAND: | 68 case ui::MenuModel::TYPE_COMMAND: |
69 type = MenuItemView::NORMAL; | 69 type = MenuItemView::NORMAL; |
70 label = model->GetLabelAt(model_index); | 70 label = model->GetLabelAt(model_index); |
71 sublabel = model->GetSublabelAt(model_index); | 71 sublabel = model->GetSublabelAt(model_index); |
72 minor_text = model->GetMinorTextAt(model_index); | 72 minor_text = model->GetMinorTextAt(model_index); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 ui::Accelerator* accelerator) { | 164 ui::Accelerator* accelerator) { |
165 ui::MenuModel* model = menu_model_; | 165 ui::MenuModel* model = menu_model_; |
166 int index = 0; | 166 int index = 0; |
167 if (ui::MenuModel::GetModelAndIndexForCommandId(id, &model, &index)) | 167 if (ui::MenuModel::GetModelAndIndexForCommandId(id, &model, &index)) |
168 return model->GetAcceleratorAt(index, accelerator); | 168 return model->GetAcceleratorAt(index, accelerator); |
169 | 169 |
170 NOTREACHED(); | 170 NOTREACHED(); |
171 return false; | 171 return false; |
172 } | 172 } |
173 | 173 |
174 string16 MenuModelAdapter::GetLabel(int id) const { | 174 base::string16 MenuModelAdapter::GetLabel(int id) const { |
175 ui::MenuModel* model = menu_model_; | 175 ui::MenuModel* model = menu_model_; |
176 int index = 0; | 176 int index = 0; |
177 if (ui::MenuModel::GetModelAndIndexForCommandId(id, &model, &index)) | 177 if (ui::MenuModel::GetModelAndIndexForCommandId(id, &model, &index)) |
178 return model->GetLabelAt(index); | 178 return model->GetLabelAt(index); |
179 | 179 |
180 NOTREACHED(); | 180 NOTREACHED(); |
181 return string16(); | 181 return base::string16(); |
182 } | 182 } |
183 | 183 |
184 const gfx::Font* MenuModelAdapter::GetLabelFont(int id) const { | 184 const gfx::Font* MenuModelAdapter::GetLabelFont(int id) const { |
185 ui::MenuModel* model = menu_model_; | 185 ui::MenuModel* model = menu_model_; |
186 int index = 0; | 186 int index = 0; |
187 if (ui::MenuModel::GetModelAndIndexForCommandId(id, &model, &index)) { | 187 if (ui::MenuModel::GetModelAndIndexForCommandId(id, &model, &index)) { |
188 const gfx::Font* font = model->GetLabelFontAt(index); | 188 const gfx::Font* font = model->GetLabelFontAt(index); |
189 if (font) | 189 if (font) |
190 return font; | 190 return font; |
191 } | 191 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 has_icons = has_icons || item->has_icons(); | 276 has_icons = has_icons || item->has_icons(); |
277 | 277 |
278 menu_map_[item] = submodel; | 278 menu_map_[item] = submodel; |
279 } | 279 } |
280 } | 280 } |
281 | 281 |
282 menu->set_has_icons(has_icons); | 282 menu->set_has_icons(has_icons); |
283 } | 283 } |
284 | 284 |
285 } // namespace views | 285 } // namespace views |
OLD | NEW |