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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/menu/menu_2.cc
===================================================================
--- views/controls/menu/menu_2.cc (revision 0)
+++ views/controls/menu/menu_2.cc (revision 0)
@@ -0,0 +1,62 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in the
+// LICENSE file.
+
+#include "views/controls/menu/menu_2.h"
+
+#include "base/compiler_specific.h"
+#include "views/controls/menu/menu_wrapper.h"
+
+namespace views {
+
+////////////////////////////////////////////////////////////////////////////////
+// Menu2Model, public:
+
+// static
+bool Menu2Model::GetModelAndIndexForCommandId(int command_id,
+ Menu2Model** model, int* index) {
+ int item_count = (*model)->GetItemCount();
+ for (int i = 0; i < item_count; ++i) {
+ if ((*model)->GetTypeAt(i) == TYPE_SUBMENU) {
+ Menu2Model* submenu_model = (*model)->GetSubmenuModelAt(i);
+ if (GetModelAndIndexForCommandId(command_id, &submenu_model, index)) {
+ *model = submenu_model;
+ return true;
+ }
+ }
+ if ((*model)->GetCommandIdAt(i) == command_id) {
+ *index = i;
+ return true;
+ }
+ }
+ return false;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Menu2, public:
+
+Menu2::Menu2(Menu2Model* model, Menu2Delegate* delegate)
+ : model_(model),
+ delegate_(delegate),
+ ALLOW_THIS_IN_INITIALIZER_LIST(
+ wrapper_(MenuWrapper::CreateWrapper(this))) {
+ Rebuild();
+}
+
+gfx::NativeMenu Menu2::GetNativeMenu() const {
+ return wrapper_->GetNativeMenu();
+}
+
+void Menu2::RunMenuAt(const gfx::Point& point, Alignment alignment) {
+ wrapper_->RunMenuAt(point, alignment);
+}
+
+void Menu2::Rebuild() {
+ wrapper_->Rebuild();
+}
+
+void Menu2::UpdateStates() {
+ wrapper_->UpdateStates();
+}
+
+} // namespace
« 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