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

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

Issue 16979002: Add ContextMenuSourceType to views::ContextMenuController::ShowContextMenuForView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 7 years, 6 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/tree/tree_view.cc ('k') | ui/views/examples/tree_view_example.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) 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 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
190 if (menu_runner_->RunMenuAt(source->GetWidget()->GetTopLevelWidget(), this, 190 if (menu_runner_->RunMenuAt(source->GetWidget()->GetTopLevelWidget(), this,
191 gfx::Rect(point, gfx::Size()), MenuItemView::TOPRIGHT, 191 gfx::Rect(point, gfx::Size()), MenuItemView::TOPRIGHT,
192 MenuRunner::HAS_MNEMONICS) == MenuRunner::MENU_DELETED) 192 ui::MENU_SOURCE_NONE, MenuRunner::HAS_MNEMONICS) ==
193 MenuRunner::MENU_DELETED)
193 return; 194 return;
194 } 195 }
195 196
196 ui::SimpleMenuModel* ExampleMenuButton::GetMenuModel() { 197 ui::SimpleMenuModel* ExampleMenuButton::GetMenuModel() {
197 if (!menu_model_.get()) 198 if (!menu_model_.get())
198 menu_model_.reset(new ExampleMenuModel); 199 menu_model_.reset(new ExampleMenuModel);
199 return menu_model_.get(); 200 return menu_model_.get();
200 } 201 }
201 202
202 } // namespace 203 } // namespace
203 204
204 MenuExample::MenuExample() : ExampleBase("Menu") { 205 MenuExample::MenuExample() : ExampleBase("Menu") {
205 } 206 }
206 207
207 MenuExample::~MenuExample() { 208 MenuExample::~MenuExample() {
208 } 209 }
209 210
210 void MenuExample::CreateExampleView(View* container) { 211 void MenuExample::CreateExampleView(View* container) {
211 // We add a button to open a menu. 212 // We add a button to open a menu.
212 ExampleMenuButton* menu_button = new ExampleMenuButton( 213 ExampleMenuButton* menu_button = new ExampleMenuButton(
213 ASCIIToUTF16("Open a menu")); 214 ASCIIToUTF16("Open a menu"));
214 container->SetLayoutManager(new FillLayout); 215 container->SetLayoutManager(new FillLayout);
215 container->AddChildView(menu_button); 216 container->AddChildView(menu_button);
216 } 217 }
217 218
218 } // namespace examples 219 } // namespace examples
219 } // namespace views 220 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/tree/tree_view.cc ('k') | ui/views/examples/tree_view_example.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698