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

Side by Side Diff: views/controls/menu/simple_menu_model.cc

Issue 150171: Convert menu strings to UTF16, fix some views-GTK build errors. (Closed)
Patch Set: Created 11 years, 5 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 | « views/controls/menu/simple_menu_model.h ('k') | views/widget/widget_gtk.h » ('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) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "views/controls/menu/simple_menu_model.h" 5 #include "views/controls/menu/simple_menu_model.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 8
9 namespace views { 9 namespace views {
10 10
11 //////////////////////////////////////////////////////////////////////////////// 11 ////////////////////////////////////////////////////////////////////////////////
12 // SimpleMenuModel, public: 12 // SimpleMenuModel, public:
13 13
14 SimpleMenuModel::SimpleMenuModel(Delegate* delegate) : delegate_(delegate) { 14 SimpleMenuModel::SimpleMenuModel(Delegate* delegate) : delegate_(delegate) {
15 } 15 }
16 16
17 SimpleMenuModel::~SimpleMenuModel() { 17 SimpleMenuModel::~SimpleMenuModel() {
18 } 18 }
19 19
20 void SimpleMenuModel::AddItem(int command_id, const std::wstring& label) { 20 void SimpleMenuModel::AddItem(int command_id, const string16& label) {
21 Item item = { command_id, label, TYPE_COMMAND, -1, NULL }; 21 Item item = { command_id, label, TYPE_COMMAND, -1, NULL };
22 items_.push_back(item); 22 items_.push_back(item);
23 } 23 }
24 24
25 void SimpleMenuModel::AddItemWithStringId(int command_id, int string_id) { 25 void SimpleMenuModel::AddItemWithStringId(int command_id, int string_id) {
26 AddItem(command_id, l10n_util::GetString(string_id)); 26 AddItem(command_id, l10n_util::GetStringUTF16(string_id));
27 } 27 }
28 28
29 void SimpleMenuModel::AddSeparator() { 29 void SimpleMenuModel::AddSeparator() {
30 Item item = { -1, std::wstring(), TYPE_SEPARATOR, -1, NULL }; 30 Item item = { -1, string16(), TYPE_SEPARATOR, -1, NULL };
31 items_.push_back(item); 31 items_.push_back(item);
32 } 32 }
33 33
34 void SimpleMenuModel::AddCheckItem(int command_id, const std::wstring& label) { 34 void SimpleMenuModel::AddCheckItem(int command_id, const string16& label) {
35 Item item = { command_id, label, TYPE_CHECK, -1, NULL }; 35 Item item = { command_id, label, TYPE_CHECK, -1, NULL };
36 items_.push_back(item); 36 items_.push_back(item);
37 } 37 }
38 38
39 void SimpleMenuModel::AddCheckItemWithStringId(int command_id, int string_id) { 39 void SimpleMenuModel::AddCheckItemWithStringId(int command_id, int string_id) {
40 AddCheckItem(command_id, l10n_util::GetString(string_id)); 40 AddCheckItem(command_id, l10n_util::GetStringUTF16(string_id));
41 } 41 }
42 42
43 void SimpleMenuModel::AddRadioItem(int command_id, const std::wstring& label, 43 void SimpleMenuModel::AddRadioItem(int command_id, const string16& label,
44 int group_id) { 44 int group_id) {
45 Item item = { command_id, label, TYPE_RADIO, group_id, NULL }; 45 Item item = { command_id, label, TYPE_RADIO, group_id, NULL };
46 items_.push_back(item); 46 items_.push_back(item);
47 } 47 }
48 48
49 void SimpleMenuModel::AddRadioItemWithStringId(int command_id, int string_id, 49 void SimpleMenuModel::AddRadioItemWithStringId(int command_id, int string_id,
50 int group_id) { 50 int group_id) {
51 AddRadioItem(command_id, l10n_util::GetString(string_id), group_id); 51 AddRadioItem(command_id, l10n_util::GetStringUTF16(string_id), group_id);
52 } 52 }
53 53
54 void SimpleMenuModel::AddSubMenu(const std::wstring& label, Menu2Model* model) { 54 void SimpleMenuModel::AddSubMenu(const string16& label, Menu2Model* model) {
55 Item item = { -1, label, TYPE_SUBMENU, -1, model }; 55 Item item = { -1, label, TYPE_SUBMENU, -1, model };
56 items_.push_back(item); 56 items_.push_back(item);
57 } 57 }
58 58
59 void SimpleMenuModel::AddSubMenuWithStringId(int string_id, Menu2Model* model) { 59 void SimpleMenuModel::AddSubMenuWithStringId(int string_id, Menu2Model* model) {
60 AddSubMenu(l10n_util::GetString(string_id), model); 60 AddSubMenu(l10n_util::GetStringUTF16(string_id), model);
61 } 61 }
62 62
63 //////////////////////////////////////////////////////////////////////////////// 63 ////////////////////////////////////////////////////////////////////////////////
64 // SimpleMenuModel, Menu2Model implementation: 64 // SimpleMenuModel, Menu2Model implementation:
65 65
66 bool SimpleMenuModel::HasIcons() const { 66 bool SimpleMenuModel::HasIcons() const {
67 return false; 67 return false;
68 } 68 }
69 69
70 int SimpleMenuModel::GetItemCount() const { 70 int SimpleMenuModel::GetItemCount() const {
71 return static_cast<int>(items_.size()); 71 return static_cast<int>(items_.size());
72 } 72 }
73 73
74 Menu2Model::ItemType SimpleMenuModel::GetTypeAt(int index) const { 74 Menu2Model::ItemType SimpleMenuModel::GetTypeAt(int index) const {
75 return items_.at(FlipIndex(index)).type; 75 return items_.at(FlipIndex(index)).type;
76 } 76 }
77 77
78 int SimpleMenuModel::GetCommandIdAt(int index) const { 78 int SimpleMenuModel::GetCommandIdAt(int index) const {
79 return items_.at(FlipIndex(index)).command_id; 79 return items_.at(FlipIndex(index)).command_id;
80 } 80 }
81 81
82 std::wstring SimpleMenuModel::GetLabelAt(int index) const { 82 string16 SimpleMenuModel::GetLabelAt(int index) const {
83 if (IsLabelDynamicAt(index)) 83 if (IsLabelDynamicAt(index))
84 return delegate_->GetLabelForCommandId(GetCommandIdAt(index)); 84 return delegate_->GetLabelForCommandId(GetCommandIdAt(index));
85 return items_.at(FlipIndex(index)).label; 85 return items_.at(FlipIndex(index)).label;
86 } 86 }
87 87
88 bool SimpleMenuModel::IsLabelDynamicAt(int index) const { 88 bool SimpleMenuModel::IsLabelDynamicAt(int index) const {
89 if (delegate_) 89 if (delegate_)
90 return delegate_->IsLabelForCommandIdDynamic(GetCommandIdAt(index)); 90 return delegate_->IsLabelForCommandIdDynamic(GetCommandIdAt(index));
91 return false; 91 return false;
92 } 92 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 void SimpleMenuModel::ActivatedAt(int index) { 130 void SimpleMenuModel::ActivatedAt(int index) {
131 if (delegate_) 131 if (delegate_)
132 delegate_->ExecuteCommand(GetCommandIdAt(index)); 132 delegate_->ExecuteCommand(GetCommandIdAt(index));
133 } 133 }
134 134
135 Menu2Model* SimpleMenuModel::GetSubmenuModelAt(int index) const { 135 Menu2Model* SimpleMenuModel::GetSubmenuModelAt(int index) const {
136 return items_.at(FlipIndex(index)).submenu; 136 return items_.at(FlipIndex(index)).submenu;
137 } 137 }
138 138
139 } // namespace views 139 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/menu/simple_menu_model.h ('k') | views/widget/widget_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698