1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_HOST_H_
6 #define UI_VIEWS_CONTROLS_MENU_MENU_HOST_H_
8 #include "base/compiler_specific.h"
9 #include "ui/gfx/rect.h"
10 #include "ui/views/widget/widget.h"
19 // SubmenuView uses a MenuHost to house the SubmenuView.
21 // SubmenuView owns the MenuHost. When SubmenuView is done with the MenuHost
22 // |DestroyMenuHost| is invoked. The one exception to this is if the native
23 // OS destroys the widget out from under us, in which case |MenuHostDestroyed|
24 // is invoked back on the SubmenuView and the SubmenuView then drops references
26 class MenuHost
: public Widget
{
28 explicit MenuHost(SubmenuView
* submenu
);
31 // Initializes and shows the MenuHost.
32 // WARNING: |parent| may be NULL.
33 void InitMenuHost(Widget
* parent
,
34 const gfx::Rect
& bounds
,
38 // Returns true if the menu host is visible.
39 bool IsMenuHostVisible();
41 // Shows the menu host. If |do_capture| is true the menu host should do a
43 void ShowMenuHost(bool do_capture
);
45 // Hides the menu host.
48 // Destroys and deletes the menu host.
49 void DestroyMenuHost();
51 // Sets the bounds of the menu host.
52 void SetMenuHostBounds(const gfx::Rect
& bounds
);
54 // Releases a mouse grab installed by |ShowMenuHost|.
55 void ReleaseMenuHostCapture();
58 // Overridden from Widget:
59 virtual internal::RootView
* CreateRootView() OVERRIDE
;
60 virtual void OnMouseCaptureLost() OVERRIDE
;
61 virtual void OnNativeWidgetDestroyed() OVERRIDE
;
62 virtual void OnOwnerClosing() OVERRIDE
;
63 virtual void OnDragWillStart() OVERRIDE
;
64 virtual void OnDragComplete() OVERRIDE
;
66 // The view we contain.
67 SubmenuView
* submenu_
;
69 // If true, DestroyMenuHost has been invoked.
72 // If true and capture is lost we don't notify the delegate.
73 bool ignore_capture_lost_
;
75 DISALLOW_COPY_AND_ASSIGN(MenuHost
);
80 #endif // UI_VIEWS_CONTROLS_MENU_MENU_HOST_H_