OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_H_ | 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_H_ |
6 #define UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_H_ | 6 #define UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "ui/gfx/font.h" | 13 #include "ui/gfx/font.h" |
14 #include "ui/views/background.h" | 14 #include "ui/views/background.h" |
15 #include "ui/views/controls/button/text_button.h" | 15 #include "ui/views/controls/button/text_button.h" |
16 | 16 |
17 namespace views { | 17 namespace views { |
18 | 18 |
19 class MouseEvent; | 19 class MouseEvent; |
20 class MenuButtonDelegate; | 20 class MenuButtonListener; |
21 | 21 |
22 | 22 |
23 //////////////////////////////////////////////////////////////////////////////// | 23 //////////////////////////////////////////////////////////////////////////////// |
24 // | 24 // |
25 // MenuButton | 25 // MenuButton |
26 // | 26 // |
27 // A button that shows a menu when the left mouse button is pushed | 27 // A button that shows a menu when the left mouse button is pushed |
28 // | 28 // |
29 //////////////////////////////////////////////////////////////////////////////// | 29 //////////////////////////////////////////////////////////////////////////////// |
30 class VIEWS_EXPORT MenuButton : public TextButton { | 30 class VIEWS_EXPORT MenuButton : public TextButton { |
31 public: | 31 public: |
32 static const char kViewClassName[]; | 32 static const char kViewClassName[]; |
33 | 33 |
34 // Create a Button. | 34 // Create a Button. |
35 MenuButton(ButtonListener* listener, | 35 MenuButton(ButtonListener* listener, |
36 const string16& text, | 36 const string16& text, |
37 MenuButtonDelegate* menu_delegate, | 37 MenuButtonListener* menu_button_listener, |
38 bool show_menu_marker); | 38 bool show_menu_marker); |
39 virtual ~MenuButton(); | 39 virtual ~MenuButton(); |
40 | 40 |
41 void set_menu_marker(const SkBitmap* menu_marker) { | 41 void set_menu_marker(const SkBitmap* menu_marker) { |
42 menu_marker_ = menu_marker; | 42 menu_marker_ = menu_marker; |
43 } | 43 } |
44 | 44 |
45 const gfx::Point& menu_offset() const { return menu_offset_; } | 45 const gfx::Point& menu_offset() const { return menu_offset_; } |
46 void set_menu_offset(int x, int y) { menu_offset_.SetPoint(x, y); } | 46 void set_menu_offset(int x, int y) { menu_offset_.SetPoint(x, y); } |
47 | 47 |
(...skipping 28 matching lines...) Expand all Loading... |
76 int GetMaximumScreenXCoordinate(); | 76 int GetMaximumScreenXCoordinate(); |
77 | 77 |
78 // We use a time object in order to keep track of when the menu was closed. | 78 // We use a time object in order to keep track of when the menu was closed. |
79 // The time is used for simulating menu behavior for the menu button; that | 79 // The time is used for simulating menu behavior for the menu button; that |
80 // is, if the menu is shown and the button is pressed, we need to close the | 80 // is, if the menu is shown and the button is pressed, we need to close the |
81 // menu. There is no clean way to get the second click event because the | 81 // menu. There is no clean way to get the second click event because the |
82 // menu is displayed using a modal loop and, unlike regular menus in Windows, | 82 // menu is displayed using a modal loop and, unlike regular menus in Windows, |
83 // the button is not part of the displayed menu. | 83 // the button is not part of the displayed menu. |
84 base::Time menu_closed_time_; | 84 base::Time menu_closed_time_; |
85 | 85 |
86 // The associated menu's resource identifier. | 86 // Our listener. Not owned. |
87 MenuButtonDelegate* menu_delegate_; | 87 MenuButtonListener* listener_; |
88 | 88 |
89 // Whether or not we're showing a drop marker. | 89 // Whether or not we're showing a drop marker. |
90 bool show_menu_marker_; | 90 bool show_menu_marker_; |
91 | 91 |
92 // The down arrow used to differentiate the menu button from normal | 92 // The down arrow used to differentiate the menu button from normal |
93 // text buttons. | 93 // text buttons. |
94 const SkBitmap* menu_marker_; | 94 const SkBitmap* menu_marker_; |
95 | 95 |
96 // If non-null the destuctor sets this to true. This is set while the menu is | 96 // If non-null the destuctor sets this to true. This is set while the menu is |
97 // showing and used to detect if the menu was deleted while running. | 97 // showing and used to detect if the menu was deleted while running. |
98 bool* destroyed_flag_; | 98 bool* destroyed_flag_; |
99 | 99 |
100 DISALLOW_COPY_AND_ASSIGN(MenuButton); | 100 DISALLOW_COPY_AND_ASSIGN(MenuButton); |
101 }; | 101 }; |
102 | 102 |
103 } // namespace views | 103 } // namespace views |
104 | 104 |
105 #endif // UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_H_ | 105 #endif // UI_VIEWS_CONTROLS_BUTTON_MENU_BUTTON_H_ |
OLD | NEW |