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

Side by Side Diff: ui/views/examples/menu_example.cc

Issue 9693022: views: Rename MenuButtonDelegate::RunMenu to something more obvious. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: menu_button_listener.h Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/button/menu_button_listener.h ('k') | ui/views/views.gyp » ('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) 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/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "ui/base/models/simple_menu_model.h" 10 #include "ui/base/models/simple_menu_model.h"
11 #include "ui/views/controls/button/menu_button.h" 11 #include "ui/views/controls/button/menu_button.h"
12 #include "ui/views/controls/button/menu_button_delegate.h" 12 #include "ui/views/controls/button/menu_button_listener.h"
13 #include "ui/views/controls/button/text_button.h" 13 #include "ui/views/controls/button/text_button.h"
14 #include "ui/views/controls/menu/menu_2.h" 14 #include "ui/views/controls/menu/menu_2.h"
15 #include "ui/views/layout/fill_layout.h" 15 #include "ui/views/layout/fill_layout.h"
16 #include "ui/views/view.h" 16 #include "ui/views/view.h"
17 17
18 namespace views { 18 namespace views {
19 namespace examples { 19 namespace examples {
20 20
21 namespace { 21 namespace {
22 22
(...skipping 29 matching lines...) Expand all
52 }; 52 };
53 53
54 scoped_ptr<Menu2> menu_; 54 scoped_ptr<Menu2> menu_;
55 scoped_ptr<ui::SimpleMenuModel> submenu_; 55 scoped_ptr<ui::SimpleMenuModel> submenu_;
56 std::set<int> checked_fruits_; 56 std::set<int> checked_fruits_;
57 int current_encoding_command_id_; 57 int current_encoding_command_id_;
58 58
59 DISALLOW_COPY_AND_ASSIGN(ExampleMenuModel); 59 DISALLOW_COPY_AND_ASSIGN(ExampleMenuModel);
60 }; 60 };
61 61
62 class ExampleMenuButton : public MenuButton, public MenuButtonDelegate { 62 class ExampleMenuButton : public MenuButton, public MenuButtonListener {
63 public: 63 public:
64 ExampleMenuButton(const string16& test, bool show_menu_marker); 64 ExampleMenuButton(const string16& test, bool show_menu_marker);
65 virtual ~ExampleMenuButton(); 65 virtual ~ExampleMenuButton();
66 66
67 private: 67 private:
68 // Overridden from MenuButtonDelegate: 68 // Overridden from MenuButtonListener:
69 virtual void RunMenu(View* source, const gfx::Point& point) OVERRIDE; 69 virtual void OnMenuButtonClicked(View* source,
70 const gfx::Point& point) OVERRIDE;
70 71
71 scoped_ptr<ExampleMenuModel> menu_model_; 72 scoped_ptr<ExampleMenuModel> menu_model_;
72 DISALLOW_COPY_AND_ASSIGN(ExampleMenuButton); 73 DISALLOW_COPY_AND_ASSIGN(ExampleMenuButton);
73 }; 74 };
74 75
75 // ExampleMenuModel --------------------------------------------------------- 76 // ExampleMenuModel ---------------------------------------------------------
76 77
77 ExampleMenuModel::ExampleMenuModel() 78 ExampleMenuModel::ExampleMenuModel()
78 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), 79 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)),
79 current_encoding_command_id_(kCommandSelectAscii) { 80 current_encoding_command_id_(kCommandSelectAscii) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 181
181 ExampleMenuButton::ExampleMenuButton(const string16& test, 182 ExampleMenuButton::ExampleMenuButton(const string16& test,
182 bool show_menu_marker) 183 bool show_menu_marker)
183 : ALLOW_THIS_IN_INITIALIZER_LIST( 184 : ALLOW_THIS_IN_INITIALIZER_LIST(
184 MenuButton(NULL, test, this, show_menu_marker)) { 185 MenuButton(NULL, test, this, show_menu_marker)) {
185 } 186 }
186 187
187 ExampleMenuButton::~ExampleMenuButton() { 188 ExampleMenuButton::~ExampleMenuButton() {
188 } 189 }
189 190
190 void ExampleMenuButton::RunMenu(View* source, const gfx::Point& point) { 191 void ExampleMenuButton::OnMenuButtonClicked(View* source,
192 const gfx::Point& point) {
191 if (!menu_model_.get()) 193 if (!menu_model_.get())
192 menu_model_.reset(new ExampleMenuModel); 194 menu_model_.reset(new ExampleMenuModel);
193 195
194 menu_model_->RunMenuAt(point); 196 menu_model_->RunMenuAt(point);
195 } 197 }
196 198
197 } // namespace 199 } // namespace
198 200
199 MenuExample::MenuExample() : ExampleBase("Menu") { 201 MenuExample::MenuExample() : ExampleBase("Menu") {
200 } 202 }
201 203
202 MenuExample::~MenuExample() { 204 MenuExample::~MenuExample() {
203 } 205 }
204 206
205 void MenuExample::CreateExampleView(View* container) { 207 void MenuExample::CreateExampleView(View* container) {
206 // Menu2 is not a sub class of View, hence we cannot directly 208 // Menu2 is not a sub class of View, hence we cannot directly
207 // add to the container. Instead, we add a button to open a menu. 209 // add to the container. Instead, we add a button to open a menu.
208 const bool show_menu_marker = true; 210 const bool show_menu_marker = true;
209 ExampleMenuButton* menu_button = new ExampleMenuButton( 211 ExampleMenuButton* menu_button = new ExampleMenuButton(
210 ASCIIToUTF16("Open a menu"), show_menu_marker); 212 ASCIIToUTF16("Open a menu"), show_menu_marker);
211 container->SetLayoutManager(new FillLayout); 213 container->SetLayoutManager(new FillLayout);
212 container->AddChildView(menu_button); 214 container->AddChildView(menu_button);
213 } 215 }
214 216
215 } // namespace examples 217 } // namespace examples
216 } // namespace views 218 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/button/menu_button_listener.h ('k') | ui/views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698