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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
6 #include "ui/base/l10n/l10n_util.h" | 6 #include "ui/base/l10n/l10n_util.h" |
7 #include "ui/base/models/menu_model.h" | 7 #include "ui/base/models/menu_model.h" |
8 #include "ui/base/models/menu_model_delegate.h" | 8 #include "ui/base/models/menu_model_delegate.h" |
9 #include "ui/views/controls/menu/menu_item_view.h" | 9 #include "ui/views/controls/menu/menu_item_view.h" |
10 #include "ui/views/controls/menu/menu_model_adapter.h" | 10 #include "ui/views/controls/menu/menu_model_adapter.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 | 44 |
45 virtual ui::MenuSeparatorType GetSeparatorTypeAt( | 45 virtual ui::MenuSeparatorType GetSeparatorTypeAt( |
46 int index) const OVERRIDE { | 46 int index) const OVERRIDE { |
47 return ui::NORMAL_SEPARATOR; | 47 return ui::NORMAL_SEPARATOR; |
48 } | 48 } |
49 | 49 |
50 virtual int GetCommandIdAt(int index) const OVERRIDE { | 50 virtual int GetCommandIdAt(int index) const OVERRIDE { |
51 return index + command_id_base_; | 51 return index + command_id_base_; |
52 } | 52 } |
53 | 53 |
54 virtual string16 GetLabelAt(int index) const OVERRIDE { | 54 virtual base::string16 GetLabelAt(int index) const OVERRIDE { |
55 return items_[index].label; | 55 return items_[index].label; |
56 } | 56 } |
57 | 57 |
58 virtual bool IsItemDynamicAt(int index) const OVERRIDE { | 58 virtual bool IsItemDynamicAt(int index) const OVERRIDE { |
59 return false; | 59 return false; |
60 } | 60 } |
61 | 61 |
62 virtual const gfx::Font* GetLabelFontAt(int index) const OVERRIDE { | 62 virtual const gfx::Font* GetLabelFontAt(int index) const OVERRIDE { |
63 return NULL; | 63 return NULL; |
64 } | 64 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 struct Item { | 126 struct Item { |
127 Item(ItemType item_type, | 127 Item(ItemType item_type, |
128 const std::string& item_label, | 128 const std::string& item_label, |
129 ui::MenuModel* item_submenu) | 129 ui::MenuModel* item_submenu) |
130 : type(item_type), | 130 : type(item_type), |
131 label(ASCIIToUTF16(item_label)), | 131 label(ASCIIToUTF16(item_label)), |
132 submenu(item_submenu) { | 132 submenu(item_submenu) { |
133 } | 133 } |
134 | 134 |
135 ItemType type; | 135 ItemType type; |
136 string16 label; | 136 base::string16 label; |
137 ui::MenuModel* submenu; | 137 ui::MenuModel* submenu; |
138 }; | 138 }; |
139 | 139 |
140 const Item& GetItemDefinition(int index) { | 140 const Item& GetItemDefinition(int index) { |
141 return items_[index]; | 141 return items_[index]; |
142 } | 142 } |
143 | 143 |
144 // Access index argument to ActivatedAt(). | 144 // Access index argument to ActivatedAt(). |
145 int last_activation() const { return last_activation_; } | 145 int last_activation() const { return last_activation_; } |
146 void set_last_activation(int last_activation) { | 146 void set_last_activation(int last_activation) { |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 submodel->set_last_activation(-1); | 300 submodel->set_last_activation(-1); |
301 } | 301 } |
302 | 302 |
303 // Check that selecting the root item is safe. The MenuModel does | 303 // Check that selecting the root item is safe. The MenuModel does |
304 // not care about the root so MenuModelAdapter should do nothing | 304 // not care about the root so MenuModelAdapter should do nothing |
305 // (not hit the NOTREACHED check) when the root is selected. | 305 // (not hit the NOTREACHED check) when the root is selected. |
306 static_cast<views::MenuDelegate*>(&delegate)->SelectionChanged(menu); | 306 static_cast<views::MenuDelegate*>(&delegate)->SelectionChanged(menu); |
307 } | 307 } |
308 | 308 |
309 } // namespace views | 309 } // namespace views |
OLD | NEW |