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

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

Issue 250943008: Move enum MenuAnchorPosition to reduce deps on menu_item_view.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix indent Created 6 years, 7 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/textfield/textfield.cc ('k') | ui/views/examples/tree_view_example.cc » ('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/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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 : MenuButton(NULL, test, this, true) { 182 : MenuButton(NULL, test, this, true) {
183 } 183 }
184 184
185 ExampleMenuButton::~ExampleMenuButton() { 185 ExampleMenuButton::~ExampleMenuButton() {
186 } 186 }
187 187
188 void ExampleMenuButton::OnMenuButtonClicked(View* source, 188 void ExampleMenuButton::OnMenuButtonClicked(View* source,
189 const gfx::Point& point) { 189 const gfx::Point& point) {
190 menu_runner_.reset(new MenuRunner(GetMenuModel())); 190 menu_runner_.reset(new MenuRunner(GetMenuModel()));
191 191
192 if (menu_runner_->RunMenuAt(source->GetWidget()->GetTopLevelWidget(), this, 192 if (menu_runner_->RunMenuAt(source->GetWidget()->GetTopLevelWidget(),
193 gfx::Rect(point, gfx::Size()), MenuItemView::TOPRIGHT, 193 this,
194 ui::MENU_SOURCE_NONE, MenuRunner::HAS_MNEMONICS) == 194 gfx::Rect(point, gfx::Size()),
195 MenuRunner::MENU_DELETED) 195 MENU_ANCHOR_TOPRIGHT,
196 ui::MENU_SOURCE_NONE,
197 MenuRunner::HAS_MNEMONICS) ==
198 MenuRunner::MENU_DELETED) {
196 return; 199 return;
200 }
197 } 201 }
198 202
199 ui::SimpleMenuModel* ExampleMenuButton::GetMenuModel() { 203 ui::SimpleMenuModel* ExampleMenuButton::GetMenuModel() {
200 if (!menu_model_.get()) 204 if (!menu_model_.get())
201 menu_model_.reset(new ExampleMenuModel); 205 menu_model_.reset(new ExampleMenuModel);
202 return menu_model_.get(); 206 return menu_model_.get();
203 } 207 }
204 208
205 } // namespace 209 } // namespace
206 210
207 MenuExample::MenuExample() : ExampleBase("Menu") { 211 MenuExample::MenuExample() : ExampleBase("Menu") {
208 } 212 }
209 213
210 MenuExample::~MenuExample() { 214 MenuExample::~MenuExample() {
211 } 215 }
212 216
213 void MenuExample::CreateExampleView(View* container) { 217 void MenuExample::CreateExampleView(View* container) {
214 // We add a button to open a menu. 218 // We add a button to open a menu.
215 ExampleMenuButton* menu_button = new ExampleMenuButton( 219 ExampleMenuButton* menu_button = new ExampleMenuButton(
216 ASCIIToUTF16("Open a menu")); 220 ASCIIToUTF16("Open a menu"));
217 container->SetLayoutManager(new FillLayout); 221 container->SetLayoutManager(new FillLayout);
218 container->AddChildView(menu_button); 222 container->AddChildView(menu_button);
219 } 223 }
220 224
221 } // namespace examples 225 } // namespace examples
222 } // namespace views 226 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/textfield.cc ('k') | ui/views/examples/tree_view_example.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698