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/examples/menu_example.h" | 5 #include "ui/views/examples/menu_example.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "ui/base/models/simple_menu_model.h" | 10 #include "ui/base/models/simple_menu_model.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 scoped_ptr<ui::SimpleMenuModel> submenu_; | 52 scoped_ptr<ui::SimpleMenuModel> submenu_; |
53 std::set<int> checked_fruits_; | 53 std::set<int> checked_fruits_; |
54 int current_encoding_command_id_; | 54 int current_encoding_command_id_; |
55 | 55 |
56 DISALLOW_COPY_AND_ASSIGN(ExampleMenuModel); | 56 DISALLOW_COPY_AND_ASSIGN(ExampleMenuModel); |
57 }; | 57 }; |
58 | 58 |
59 class ExampleMenuButton : public MenuButton, public MenuButtonListener { | 59 class ExampleMenuButton : public MenuButton, public MenuButtonListener { |
60 public: | 60 public: |
61 explicit ExampleMenuButton(const string16& test); | 61 explicit ExampleMenuButton(const base::string16& test); |
62 virtual ~ExampleMenuButton(); | 62 virtual ~ExampleMenuButton(); |
63 | 63 |
64 private: | 64 private: |
65 // Overridden from MenuButtonListener: | 65 // Overridden from MenuButtonListener: |
66 virtual void OnMenuButtonClicked(View* source, | 66 virtual void OnMenuButtonClicked(View* source, |
67 const gfx::Point& point) OVERRIDE; | 67 const gfx::Point& point) OVERRIDE; |
68 | 68 |
69 ui::SimpleMenuModel* GetMenuModel(); | 69 ui::SimpleMenuModel* GetMenuModel(); |
70 | 70 |
71 scoped_ptr<ExampleMenuModel> menu_model_; | 71 scoped_ptr<ExampleMenuModel> menu_model_; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 DVLOG(1) << "Unchecked " << checked_fruit; | 169 DVLOG(1) << "Unchecked " << checked_fruit; |
170 checked_fruits_.erase(iter); | 170 checked_fruits_.erase(iter); |
171 } | 171 } |
172 break; | 172 break; |
173 } | 173 } |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
177 // ExampleMenuButton ----------------------------------------------------------- | 177 // ExampleMenuButton ----------------------------------------------------------- |
178 | 178 |
179 ExampleMenuButton::ExampleMenuButton(const string16& test) | 179 ExampleMenuButton::ExampleMenuButton(const base::string16& test) |
180 : MenuButton(NULL, test, this, true) { | 180 : MenuButton(NULL, test, this, true) { |
181 } | 181 } |
182 | 182 |
183 ExampleMenuButton::~ExampleMenuButton() { | 183 ExampleMenuButton::~ExampleMenuButton() { |
184 } | 184 } |
185 | 185 |
186 void ExampleMenuButton::OnMenuButtonClicked(View* source, | 186 void ExampleMenuButton::OnMenuButtonClicked(View* source, |
187 const gfx::Point& point) { | 187 const gfx::Point& point) { |
188 menu_runner_.reset(new MenuRunner(GetMenuModel())); | 188 menu_runner_.reset(new MenuRunner(GetMenuModel())); |
189 | 189 |
(...skipping 21 matching lines...) Expand all Loading... |
211 void MenuExample::CreateExampleView(View* container) { | 211 void MenuExample::CreateExampleView(View* container) { |
212 // We add a button to open a menu. | 212 // We add a button to open a menu. |
213 ExampleMenuButton* menu_button = new ExampleMenuButton( | 213 ExampleMenuButton* menu_button = new ExampleMenuButton( |
214 ASCIIToUTF16("Open a menu")); | 214 ASCIIToUTF16("Open a menu")); |
215 container->SetLayoutManager(new FillLayout); | 215 container->SetLayoutManager(new FillLayout); |
216 container->AddChildView(menu_button); | 216 container->AddChildView(menu_button); |
217 } | 217 } |
218 | 218 |
219 } // namespace examples | 219 } // namespace examples |
220 } // namespace views | 220 } // namespace views |
OLD | NEW |