OLD | NEW |
(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 #ifndef VIEWS_CONTROLS_MENU_NATIVE_MENU_GTK_H_ |
| 6 #define VIEWS_CONTROLS_MENU_NATIVE_MENU_GTK_H_ |
| 7 |
| 8 #include <gtk/gtk.h> |
| 9 |
| 10 #include "views/controls/menu/menu_wrapper.h" |
| 11 |
| 12 namespace views { |
| 13 |
| 14 class Menu2Model; |
| 15 class Menu2Delegate; |
| 16 |
| 17 // A Gtk implementation of MenuWrapper. |
| 18 // TODO(beng): rename to MenuGtk once the old class is dead. |
| 19 class NativeMenuGtk : public MenuWrapper { |
| 20 public: |
| 21 NativeMenuGtk(Menu2Model* model, |
| 22 Menu2Delegate* delegate); |
| 23 virtual ~NativeMenuGtk(); |
| 24 |
| 25 // Overridden from MenuWrapper: |
| 26 virtual void RunMenuAt(const gfx::Point& point, int alignment); |
| 27 virtual void Rebuild(); |
| 28 virtual void UpdateStates(); |
| 29 virtual gfx::NativeMenu GetNativeMenu() const; |
| 30 |
| 31 private: |
| 32 void AddSeparatorAt(int index); |
| 33 void AddMenuItemAt(int index, GtkRadioMenuItem** last_radio_item); |
| 34 |
| 35 static void UpdateStateCallback(GtkWidget* menu_item, gpointer data); |
| 36 |
| 37 void ResetMenu(); |
| 38 |
| 39 // Callback for gtk_menu_popup to position the menu. |
| 40 static void MenuPositionFunc(GtkMenu* menu, int* x, int* y, gboolean* push_in, |
| 41 void* data); |
| 42 |
| 43 // Event handlers: |
| 44 void OnActivate(GtkMenuItem* menu_item); |
| 45 |
| 46 // Gtk signal handlers. |
| 47 static void CallActivate(GtkMenuItem* menu_item, NativeMenuGtk* native_menu); |
| 48 |
| 49 Menu2Model* model_; |
| 50 Menu2Delegate* delegate_; |
| 51 |
| 52 GtkWidget* menu_; |
| 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(NativeMenuGtk); |
| 55 }; |
| 56 |
| 57 } // namespace views |
| 58 |
| 59 #endif // VIEWS_CONTROLS_MENU_NATIVE_MENU_GTK_H_ |
OLD | NEW |