| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 5 |
| 6 #ifndef VIEWS_CONTROLS_MENU_MENU_HOST_GTK_H_ | 6 #ifndef VIEWS_CONTROLS_MENU_MENU_HOST_GTK_H_ |
| 7 #define VIEWS_CONTROLS_MENU_MENU_HOST_GTK_H_ | 7 #define VIEWS_CONTROLS_MENU_MENU_HOST_GTK_H_ |
| 8 | 8 |
| 9 #include "views/controls/menu/menu_host.h" |
| 9 #include "views/widget/widget_gtk.h" | 10 #include "views/widget/widget_gtk.h" |
| 10 | 11 |
| 11 namespace views { | 12 namespace views { |
| 12 | 13 |
| 13 class SubmenuView; | 14 class SubmenuView; |
| 14 | 15 |
| 15 // MenuHost implementation for Gtk. | 16 // MenuHost implementation for Gtk. |
| 16 class MenuHost : public WidgetGtk { | 17 class MenuHostGtk : public WidgetGtk, public MenuHost { |
| 17 public: | 18 public: |
| 18 explicit MenuHost(SubmenuView* submenu); | 19 explicit MenuHostGtk(SubmenuView* submenu); |
| 20 virtual ~MenuHostGtk(); |
| 19 | 21 |
| 22 // MenuHost overrides. |
| 20 void Init(gfx::NativeWindow parent, | 23 void Init(gfx::NativeWindow parent, |
| 21 const gfx::Rect& bounds, | 24 const gfx::Rect& bounds, |
| 22 View* contents_view, | 25 View* contents_view, |
| 23 bool do_capture); | 26 bool do_capture); |
| 24 | 27 virtual bool IsMenuHostVisible(); |
| 25 gfx::NativeWindow GetNativeWindow(); | 28 virtual void ShowMenuHost(bool do_capture); |
| 26 | 29 virtual void HideMenuHost(); |
| 27 void Show(); | 30 virtual void DestroyMenuHost(); |
| 28 virtual void Hide(); | 31 virtual void SetMenuHostBounds(const gfx::Rect& bounds); |
| 29 virtual void HideWindow(); | 32 virtual void ReleaseMenuHostCapture(); |
| 30 void DoCapture(); | 33 virtual gfx::NativeWindow GetMenuHostWindow(); |
| 31 void ReleaseCapture(); | |
| 32 | 34 |
| 33 protected: | 35 protected: |
| 34 virtual RootView* CreateRootView(); | 36 virtual RootView* CreateRootView(); |
| 35 | 37 |
| 36 virtual gboolean OnGrabBrokeEvent(GtkWidget* widget, GdkEvent* event); | |
| 37 | |
| 38 // Overriden to return false, we do NOT want to release capture on mouse | 38 // Overriden to return false, we do NOT want to release capture on mouse |
| 39 // release. | 39 // release. |
| 40 virtual bool ReleaseCaptureOnMouseReleased(); | 40 virtual bool ReleaseCaptureOnMouseReleased(); |
| 41 | 41 |
| 42 // Overriden to also release pointer grab. | 42 // Overriden to also release pointer grab. |
| 43 virtual void ReleaseGrab(); | 43 virtual void ReleaseGrab(); |
| 44 | 44 |
| 45 virtual void OnDestroy(GtkWidget* object); |
| 46 virtual gboolean OnGrabBrokeEvent(GtkWidget* widget, GdkEvent* event); |
| 47 |
| 45 private: | 48 private: |
| 46 // If true, we've been closed. | 49 void DoCapture(); |
| 47 bool closed_; | 50 |
| 51 // If true, DestroyMenuHost has been invoked. |
| 52 bool destroying_; |
| 48 | 53 |
| 49 // The view we contain. | 54 // The view we contain. |
| 50 SubmenuView* submenu_; | 55 SubmenuView* submenu_; |
| 51 | 56 |
| 52 // Have we done a pointer grab? | 57 // Have we done a pointer grab? |
| 53 bool did_pointer_grab_; | 58 bool did_pointer_grab_; |
| 54 | 59 |
| 55 DISALLOW_COPY_AND_ASSIGN(MenuHost); | 60 DISALLOW_COPY_AND_ASSIGN(MenuHostGtk); |
| 56 }; | 61 }; |
| 57 | 62 |
| 58 } // namespace views | 63 } // namespace views |
| 59 | 64 |
| 60 #endif // VIEWS_CONTROLS_MENU_MENU_HOST_GTK_H_ | 65 #endif // VIEWS_CONTROLS_MENU_MENU_HOST_GTK_H_ |
| OLD | NEW |