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 CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_BUTTON_H_ |
6 #define CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_BUTTON_H_ | 6 #define CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_BUTTON_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
| 11 #include "ui/gfx/font.h" |
11 #include "ui/views/controls/button/menu_button.h" | 12 #include "ui/views/controls/button/menu_button.h" |
12 #include "ui/views/controls/menu/view_menu_delegate.h" | 13 #include "ui/views/controls/menu/view_menu_delegate.h" |
13 | 14 |
14 namespace gfx { | |
15 class Font; | |
16 } | |
17 | |
18 // Button to be used to represent status and allow menus to be popped up. | 15 // Button to be used to represent status and allow menus to be popped up. |
19 // Shows current button state by drawing a border around the current icon. | 16 // Shows current button state by drawing a border around the current icon. |
20 class StatusAreaButton : public views::MenuButton { | 17 class StatusAreaButton : public views::MenuButton { |
21 public: | 18 public: |
22 // Different text styles for different types of backgrounds. | 19 // Different text styles for different types of backgrounds. |
23 enum TextStyle { | 20 enum TextStyle { |
24 WHITE_PLAIN, | 21 WHITE_PLAIN_BOLD, |
25 GRAY_PLAIN, | 22 GRAY_PLAIN_LIGHT, |
26 WHITE_HALOED, | 23 WHITE_HALOED_BOLD, |
27 GRAY_EMBOSSED | 24 GRAY_EMBOSSED_BOLD |
28 }; | 25 }; |
29 | 26 |
30 class Delegate { | 27 class Delegate { |
31 public: | 28 public: |
32 // Commands to be passed to ExecuteCommand(). | 29 // Commands to be passed to ExecuteCommand(). |
33 enum Command { | 30 enum Command { |
34 SHOW_LANGUAGE_OPTIONS, | 31 SHOW_LANGUAGE_OPTIONS, |
35 SHOW_NETWORK_OPTIONS, | 32 SHOW_NETWORK_OPTIONS, |
36 SHOW_SYSTEM_OPTIONS | 33 SHOW_SYSTEM_OPTIONS |
37 }; | 34 }; |
38 | 35 |
39 // |command_id| can be any int, passed from the button to the delegate. | 36 // |command_id| can be any int, passed from the button to the delegate. |
40 virtual bool ShouldExecuteStatusAreaCommand( | 37 virtual bool ShouldExecuteStatusAreaCommand( |
41 const views::View* button_view, int command_id) const = 0; | 38 const views::View* button_view, int command_id) const = 0; |
42 | 39 |
43 virtual void ExecuteStatusAreaCommand( | 40 virtual void ExecuteStatusAreaCommand( |
44 const views::View* button_view, int command_id) = 0; | 41 const views::View* button_view, int command_id) = 0; |
45 | 42 |
46 // Return the button font. |font| is set to the default button font. | 43 // Get the style that should currently be used in rendering the button's |
47 virtual gfx::Font GetStatusAreaFont(const gfx::Font& font) const = 0; | 44 // text. |
48 | |
49 virtual TextStyle GetStatusAreaTextStyle() const = 0; | 45 virtual TextStyle GetStatusAreaTextStyle() const = 0; |
50 | 46 |
51 // Handle visibility changes (e.g. resize the status area). | 47 // Handle visibility changes (e.g. resize the status area). |
52 virtual void ButtonVisibilityChanged(views::View* button_view) = 0; | 48 virtual void ButtonVisibilityChanged(views::View* button_view) = 0; |
53 | 49 |
54 protected: | 50 protected: |
55 virtual ~Delegate() {} | 51 virtual ~Delegate() {} |
56 }; | 52 }; |
57 | 53 |
58 StatusAreaButton(Delegate* button_delegate, | 54 StatusAreaButton(Delegate* button_delegate, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 gfx::Insets insets_; | 95 gfx::Insets insets_; |
100 | 96 |
101 // Controls whether or not the menu can be activated. This is independent of | 97 // Controls whether or not the menu can be activated. This is independent of |
102 // IsEnabled state, so that we can prevent the menu from appearing without | 98 // IsEnabled state, so that we can prevent the menu from appearing without |
103 // affecting the appearance of the button. | 99 // affecting the appearance of the button. |
104 bool menu_active_; | 100 bool menu_active_; |
105 | 101 |
106 private: | 102 private: |
107 Delegate* delegate_; | 103 Delegate* delegate_; |
108 | 104 |
| 105 // Fonts used to render the button's text. |
| 106 gfx::Font light_font_; |
| 107 gfx::Font bold_font_; |
| 108 |
109 DISALLOW_COPY_AND_ASSIGN(StatusAreaButton); | 109 DISALLOW_COPY_AND_ASSIGN(StatusAreaButton); |
110 }; | 110 }; |
111 | 111 |
112 #endif // CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_BUTTON_H_ | 112 #endif // CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_BUTTON_H_ |
OLD | NEW |