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

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

Issue 331993009: MacViews: Run native Cocoa context menus to support Services. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add VIEWS_EXPORT for unit test access Created 6 years, 5 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
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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 180
181 ExampleMenuButton::ExampleMenuButton(const base::string16& test) 181 ExampleMenuButton::ExampleMenuButton(const base::string16& test)
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(), MenuRunner::HAS_MNEMONICS));
191 191
192 if (menu_runner_->RunMenuAt(source->GetWidget()->GetTopLevelWidget(), 192 if (menu_runner_->RunMenuAt(source->GetWidget()->GetTopLevelWidget(),
193 this, 193 this,
194 gfx::Rect(point, gfx::Size()), 194 gfx::Rect(point, gfx::Size()),
195 MENU_ANCHOR_TOPRIGHT, 195 MENU_ANCHOR_TOPRIGHT,
196 ui::MENU_SOURCE_NONE, 196 ui::MENU_SOURCE_NONE) ==
197 MenuRunner::HAS_MNEMONICS) ==
198 MenuRunner::MENU_DELETED) { 197 MenuRunner::MENU_DELETED) {
199 return; 198 return;
200 } 199 }
201 } 200 }
202 201
203 ui::SimpleMenuModel* ExampleMenuButton::GetMenuModel() { 202 ui::SimpleMenuModel* ExampleMenuButton::GetMenuModel() {
204 if (!menu_model_.get()) 203 if (!menu_model_.get())
205 menu_model_.reset(new ExampleMenuModel); 204 menu_model_.reset(new ExampleMenuModel);
206 return menu_model_.get(); 205 return menu_model_.get();
207 } 206 }
208 207
209 } // namespace 208 } // namespace
210 209
211 MenuExample::MenuExample() : ExampleBase("Menu") { 210 MenuExample::MenuExample() : ExampleBase("Menu") {
212 } 211 }
213 212
214 MenuExample::~MenuExample() { 213 MenuExample::~MenuExample() {
215 } 214 }
216 215
217 void MenuExample::CreateExampleView(View* container) { 216 void MenuExample::CreateExampleView(View* container) {
218 // We add a button to open a menu. 217 // We add a button to open a menu.
219 ExampleMenuButton* menu_button = new ExampleMenuButton( 218 ExampleMenuButton* menu_button = new ExampleMenuButton(
220 ASCIIToUTF16("Open a menu")); 219 ASCIIToUTF16("Open a menu"));
221 container->SetLayoutManager(new FillLayout); 220 container->SetLayoutManager(new FillLayout);
222 container->AddChildView(menu_button); 221 container->AddChildView(menu_button);
223 } 222 }
224 223
225 } // namespace examples 224 } // namespace examples
226 } // namespace views 225 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698