OLD | NEW |
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_RUNNER_H_ | 5 #ifndef VIEWS_CONTROLS_MENU_MENU_RUNNER_H_ |
6 #define VIEWS_CONTROLS_MENU_MENU_RUNNER_H_ | 6 #define VIEWS_CONTROLS_MENU_MENU_RUNNER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "views/controls/menu/menu_item_view.h" | 11 #include "views/controls/menu/menu_item_view.h" |
12 | 12 |
13 namespace views { | 13 namespace views { |
14 | 14 |
15 class MenuButton; | 15 class MenuButton; |
16 class Widget; | 16 class Widget; |
17 | 17 |
18 // MenuRunner handles the lifetime of the root MenuItemView. MenuItemView runs a | 18 // MenuRunner handles the lifetime of the root MenuItemView. MenuItemView runs a |
19 // nested message loop, which means care must be taken when the MenuItemView | 19 // nested message loop, which means care must be taken when the MenuItemView |
20 // needs to be deleted. MenuRunner makes sure the menu is deleted after the | 20 // needs to be deleted. MenuRunner makes sure the menu is deleted after the |
21 // nested message loop completes. | 21 // nested message loop completes. |
22 // | 22 // |
23 // MenuRunner can be deleted at any time and will correctly handle deleting the | 23 // MenuRunner can be deleted at any time and will correctly handle deleting the |
24 // underlying menu. | 24 // underlying menu. |
25 // | 25 // |
26 // TODO: this is a work around for 57890. If we fix it this class shouldn't be | 26 // TODO: this is a work around for 57890. If we fix it this class shouldn't be |
27 // needed. | 27 // needed. |
28 class VIEWS_API MenuRunner { | 28 class VIEWS_EXPORT MenuRunner { |
29 public: | 29 public: |
30 explicit MenuRunner(MenuItemView* menu); | 30 explicit MenuRunner(MenuItemView* menu); |
31 ~MenuRunner(); | 31 ~MenuRunner(); |
32 | 32 |
33 // Runs the menu. | 33 // Runs the menu. |
34 void RunMenuAt(Widget* parent, | 34 void RunMenuAt(Widget* parent, |
35 MenuButton* button, | 35 MenuButton* button, |
36 const gfx::Rect& bounds, | 36 const gfx::Rect& bounds, |
37 MenuItemView::AnchorPosition anchor, | 37 MenuItemView::AnchorPosition anchor, |
38 bool has_mnemonics); | 38 bool has_mnemonics); |
39 | 39 |
40 private: | 40 private: |
41 class Holder; | 41 class Holder; |
42 | 42 |
43 Holder* holder_; | 43 Holder* holder_; |
44 | 44 |
45 DISALLOW_COPY_AND_ASSIGN(MenuRunner); | 45 DISALLOW_COPY_AND_ASSIGN(MenuRunner); |
46 }; | 46 }; |
47 | 47 |
48 } // namespace views | 48 } // namespace views |
49 | 49 |
50 #endif // VIEWS_CONTROLS_MENU_MENU_RUNNER_H_ | 50 #endif // VIEWS_CONTROLS_MENU_MENU_RUNNER_H_ |
OLD | NEW |