Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: views/controls/menu/menu_host.h

Issue 7015051: Re-land: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef VIEWS_CONTROLS_MENU_MENU_HOST_H_ 5 #ifndef VIEWS_CONTROLS_MENU_MENU_HOST_H_
6 #define VIEWS_CONTROLS_MENU_MENU_HOST_H_ 6 #define VIEWS_CONTROLS_MENU_MENU_HOST_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "ui/gfx/native_widget_types.h" 10 #include "ui/gfx/native_widget_types.h"
11 #include "ui/gfx/rect.h" 11 #include "ui/gfx/rect.h"
12 #include "views/controls/menu/native_menu_host_delegate.h" 12 #include "views/controls/menu/native_menu_host_delegate.h"
13 #include "views/widget/widget.h"
13 14
14 namespace views { 15 namespace views {
15 16
16 class NativeMenuHost; 17 class NativeMenuHost;
17 class NativeWidget; 18 class NativeWidget;
18 class SubmenuView; 19 class SubmenuView;
19 class View; 20 class View;
20 class Widget; 21 class Widget;
21 22
22 // SubmenuView uses a MenuHost to house the SubmenuView. MenuHost typically 23 // SubmenuView uses a MenuHost to house the SubmenuView. MenuHost typically
23 // extends the native Widget type, but is defined here for clarity of what 24 // extends the native Widget type, but is defined here for clarity of what
24 // methods SubmenuView uses. 25 // methods SubmenuView uses.
25 // 26 //
26 // SubmenuView owns the MenuHost. When SubmenuView is done with the MenuHost 27 // SubmenuView owns the MenuHost. When SubmenuView is done with the MenuHost
27 // |DestroyMenuHost| is invoked. The one exception to this is if the native 28 // |DestroyMenuHost| is invoked. The one exception to this is if the native
28 // OS destroys the widget out from under us, in which case |MenuHostDestroyed| 29 // OS destroys the widget out from under us, in which case |MenuHostDestroyed|
29 // is invoked back on the SubmenuView and the SubmenuView then drops references 30 // is invoked back on the SubmenuView and the SubmenuView then drops references
30 // to the MenuHost. 31 // to the MenuHost.
31 class MenuHost : public internal::NativeMenuHostDelegate { 32 class MenuHost : public Widget,
33 public internal::NativeMenuHostDelegate {
32 public: 34 public:
33 explicit MenuHost(SubmenuView* submenu); 35 explicit MenuHost(SubmenuView* submenu);
34 virtual ~MenuHost(); 36 virtual ~MenuHost();
35 37
36 // Initializes and shows the MenuHost. 38 // Initializes and shows the MenuHost.
37 void InitMenuHost(gfx::NativeWindow parent, 39 void InitMenuHost(gfx::NativeWindow parent,
38 const gfx::Rect& bounds, 40 const gfx::Rect& bounds,
39 View* contents_view, 41 View* contents_view,
40 bool do_capture); 42 bool do_capture);
41 43
(...skipping 16 matching lines...) Expand all
58 // Releases a mouse grab installed by |ShowMenuHost|. 60 // Releases a mouse grab installed by |ShowMenuHost|.
59 void ReleaseMenuHostCapture(); 61 void ReleaseMenuHostCapture();
60 62
61 // Returns the native window of the MenuHost. 63 // Returns the native window of the MenuHost.
62 gfx::NativeWindow GetMenuHostWindow(); 64 gfx::NativeWindow GetMenuHostWindow();
63 65
64 Widget* GetWidget(); 66 Widget* GetWidget();
65 NativeWidget* GetNativeWidget(); 67 NativeWidget* GetNativeWidget();
66 68
67 private: 69 private:
70 // Overridden from Widget:
71 virtual RootView* CreateRootView() OVERRIDE;
72 virtual bool ShouldReleaseCaptureOnMouseReleased() const OVERRIDE;
73
68 // Overridden from NativeMenuHostDelegate: 74 // Overridden from NativeMenuHostDelegate:
69 virtual void OnNativeMenuHostDestroy() OVERRIDE; 75 virtual void OnNativeMenuHostDestroy() OVERRIDE;
70 virtual void OnNativeMenuHostCancelCapture() OVERRIDE; 76 virtual void OnNativeMenuHostCancelCapture() OVERRIDE;
71 virtual RootView* CreateRootView() OVERRIDE; 77 virtual internal::NativeWidgetDelegate* AsNativeWidgetDelegate() OVERRIDE;
72 virtual bool ShouldReleaseCaptureOnMouseRelease() const OVERRIDE;
73 78
74 NativeMenuHost* native_menu_host_; 79 NativeMenuHost* native_menu_host_;
75 80
76 // The view we contain. 81 // The view we contain.
77 SubmenuView* submenu_; 82 SubmenuView* submenu_;
78 83
79 // If true, DestroyMenuHost has been invoked. 84 // If true, DestroyMenuHost has been invoked.
80 bool destroying_; 85 bool destroying_;
81 86
82 DISALLOW_COPY_AND_ASSIGN(MenuHost); 87 DISALLOW_COPY_AND_ASSIGN(MenuHost);
83 }; 88 };
84 89
85 } // namespace views 90 } // namespace views
86 91
87 #endif // VIEWS_CONTROLS_MENU_MENU_HOST_H_ 92 #endif // VIEWS_CONTROLS_MENU_MENU_HOST_H_
OLDNEW
« no previous file with comments | « views/controls/combobox/native_combobox_views_unittest.cc ('k') | views/controls/menu/menu_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698