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

Side by Side Diff: views/controls/menu/menu_2.cc

Issue 119237: A new menu system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 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 | « views/controls/menu/menu_2.h ('k') | views/controls/menu/native_menu_gtk.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file.
4
5 #include "views/controls/menu/menu_2.h"
6
7 #include "base/compiler_specific.h"
8 #include "views/controls/menu/menu_wrapper.h"
9
10 namespace views {
11
12 ////////////////////////////////////////////////////////////////////////////////
13 // Menu2Model, public:
14
15 // static
16 bool Menu2Model::GetModelAndIndexForCommandId(int command_id,
17 Menu2Model** model, int* index) {
18 int item_count = (*model)->GetItemCount();
19 for (int i = 0; i < item_count; ++i) {
20 if ((*model)->GetTypeAt(i) == TYPE_SUBMENU) {
21 Menu2Model* submenu_model = (*model)->GetSubmenuModelAt(i);
22 if (GetModelAndIndexForCommandId(command_id, &submenu_model, index)) {
23 *model = submenu_model;
24 return true;
25 }
26 }
27 if ((*model)->GetCommandIdAt(i) == command_id) {
28 *index = i;
29 return true;
30 }
31 }
32 return false;
33 }
34
35 ////////////////////////////////////////////////////////////////////////////////
36 // Menu2, public:
37
38 Menu2::Menu2(Menu2Model* model, Menu2Delegate* delegate)
39 : model_(model),
40 delegate_(delegate),
41 ALLOW_THIS_IN_INITIALIZER_LIST(
42 wrapper_(MenuWrapper::CreateWrapper(this))) {
43 Rebuild();
44 }
45
46 gfx::NativeMenu Menu2::GetNativeMenu() const {
47 return wrapper_->GetNativeMenu();
48 }
49
50 void Menu2::RunMenuAt(const gfx::Point& point, Alignment alignment) {
51 wrapper_->RunMenuAt(point, alignment);
52 }
53
54 void Menu2::Rebuild() {
55 wrapper_->Rebuild();
56 }
57
58 void Menu2::UpdateStates() {
59 wrapper_->UpdateStates();
60 }
61
62 } // namespace
OLDNEW
« no previous file with comments | « views/controls/menu/menu_2.h ('k') | views/controls/menu/native_menu_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698