summaryrefslogtreecommitdiffstats
path: root/views/controls/menu/menu_host_gtk.h
blob: 97223f837a40d0d206899b45383c54e7eac1fbc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) 2010 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_MENU_HOST_GTK_H_
#define VIEWS_CONTROLS_MENU_MENU_HOST_GTK_H_

#include "views/controls/menu/menu_host.h"
#include "views/widget/widget_gtk.h"

namespace views {

class SubmenuView;

// MenuHost implementation for Gtk.
class MenuHostGtk : public WidgetGtk, public MenuHost {
 public:
  explicit MenuHostGtk(SubmenuView* submenu);
  virtual ~MenuHostGtk();

  // MenuHost overrides.
  void Init(gfx::NativeWindow parent,
            const gfx::Rect& bounds,
            View* contents_view,
            bool do_capture);
  virtual bool IsMenuHostVisible();
  virtual void ShowMenuHost(bool do_capture);
  virtual void HideMenuHost();
  virtual void DestroyMenuHost();
  virtual void SetMenuHostBounds(const gfx::Rect& bounds);
  virtual void ReleaseMenuHostCapture();
  virtual gfx::NativeWindow GetMenuHostWindow();

 protected:
  virtual RootView* CreateRootView();

  // Overriden to return false, we do NOT want to release capture on mouse
  // release.
  virtual bool ReleaseCaptureOnMouseReleased();

  // Overriden to also release pointer grab.
  virtual void ReleaseGrab();

  virtual void OnDestroy(GtkWidget* object);
  virtual gboolean OnGrabBrokeEvent(GtkWidget* widget, GdkEvent* event);

 private:
  void DoCapture();

  // If true, DestroyMenuHost has been invoked.
  bool destroying_;

  // The view we contain.
  SubmenuView* submenu_;

  // Have we done a pointer grab?
  bool did_pointer_grab_;

  DISALLOW_COPY_AND_ASSIGN(MenuHostGtk);
};

}  // namespace views

#endif  // VIEWS_CONTROLS_MENU_MENU_HOST_GTK_H_