| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 base::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 base::string16(); | 181 return base::string16(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 const gfx::Font* MenuModelAdapter::GetLabelFont(int id) const { | 184 const gfx::FontList* MenuModelAdapter::GetLabelFontList(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::FontList* font_list = model->GetLabelFontListAt(index); |
| 189 if (font) | 189 if (font_list) |
| 190 return font; | 190 return font_list; |
| 191 } | 191 } |
| 192 | 192 |
| 193 // This line may be reached for the empty menu item. | 193 // This line may be reached for the empty menu item. |
| 194 return MenuDelegate::GetLabelFont(id); | 194 return MenuDelegate::GetLabelFontList(id); |
| 195 } | 195 } |
| 196 | 196 |
| 197 bool MenuModelAdapter::IsCommandEnabled(int id) const { | 197 bool MenuModelAdapter::IsCommandEnabled(int id) const { |
| 198 ui::MenuModel* model = menu_model_; | 198 ui::MenuModel* model = menu_model_; |
| 199 int index = 0; | 199 int index = 0; |
| 200 if (ui::MenuModel::GetModelAndIndexForCommandId(id, &model, &index)) | 200 if (ui::MenuModel::GetModelAndIndexForCommandId(id, &model, &index)) |
| 201 return model->IsEnabledAt(index); | 201 return model->IsEnabledAt(index); |
| 202 | 202 |
| 203 NOTREACHED(); | 203 NOTREACHED(); |
| 204 return false; | 204 return false; |
| (...skipping 71 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 |