diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-08 20:59:19 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-08 20:59:19 +0000 |
commit | 4bd23f35c4b4b7eab1796170789a8f00e7984972 (patch) | |
tree | 7808a313bbc7c4bf7b79717175dc29fc0b8557f1 /views/controls/menu/native_menu_gtk.h | |
parent | d09b0922f3831944386850682b584e4dccf60357 (diff) | |
download | chromium_src-4bd23f35c4b4b7eab1796170789a8f00e7984972.zip chromium_src-4bd23f35c4b4b7eab1796170789a8f00e7984972.tar.gz chromium_src-4bd23f35c4b4b7eab1796170789a8f00e7984972.tar.bz2 |
A new menu system for views.
This is all the functionality needed for the page, app menus and browser system menus.
Review URL: http://codereview.chromium.org/119237
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17895 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/menu/native_menu_gtk.h')
-rw-r--r-- | views/controls/menu/native_menu_gtk.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/views/controls/menu/native_menu_gtk.h b/views/controls/menu/native_menu_gtk.h new file mode 100644 index 0000000..1c311b5 --- /dev/null +++ b/views/controls/menu/native_menu_gtk.h @@ -0,0 +1,59 @@ +// 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. + +#ifndef VIEWS_CONTROLS_MENU_NATIVE_MENU_GTK_H_ +#define VIEWS_CONTROLS_MENU_NATIVE_MENU_GTK_H_ + +#include <gtk/gtk.h> + +#include "views/controls/menu/menu_wrapper.h" + +namespace views { + +class Menu2Model; +class Menu2Delegate; + +// A Gtk implementation of MenuWrapper. +// TODO(beng): rename to MenuGtk once the old class is dead. +class NativeMenuGtk : public MenuWrapper { + public: + NativeMenuGtk(Menu2Model* model, + Menu2Delegate* delegate); + virtual ~NativeMenuGtk(); + + // Overridden from MenuWrapper: + virtual void RunMenuAt(const gfx::Point& point, int alignment); + virtual void Rebuild(); + virtual void UpdateStates(); + virtual gfx::NativeMenu GetNativeMenu() const; + + private: + void AddSeparatorAt(int index); + void AddMenuItemAt(int index, GtkRadioMenuItem** last_radio_item); + + static void UpdateStateCallback(GtkWidget* menu_item, gpointer data); + + void ResetMenu(); + + // Callback for gtk_menu_popup to position the menu. + static void MenuPositionFunc(GtkMenu* menu, int* x, int* y, gboolean* push_in, + void* data); + + // Event handlers: + void OnActivate(GtkMenuItem* menu_item); + + // Gtk signal handlers. + static void CallActivate(GtkMenuItem* menu_item, NativeMenuGtk* native_menu); + + Menu2Model* model_; + Menu2Delegate* delegate_; + + GtkWidget* menu_; + + DISALLOW_COPY_AND_ASSIGN(NativeMenuGtk); +}; + +} // namespace views + +#endif // VIEWS_CONTROLS_MENU_NATIVE_MENU_GTK_H_ |