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 CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_VIEW_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_VIEW_H_ |
6 #define CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_VIEW_H_ | 6 #define CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_VIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include <list> |
| 10 |
9 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
10 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "chrome/browser/chromeos/status/status_area_button.h" |
11 #include "chrome/browser/ui/views/accessible_pane_view.h" | 14 #include "chrome/browser/ui/views/accessible_pane_view.h" |
12 #include "views/view.h" | 15 #include "views/view.h" |
13 | 16 |
14 namespace chromeos { | |
15 | |
16 class AccessibilityMenuButton; | |
17 class CapsLockMenuButton; | |
18 class ClockMenuButton; | |
19 class InputMethodMenuButton; | |
20 class MemoryMenuButton; | |
21 class NetworkMenuButton; | |
22 class PowerMenuButton; | |
23 class StatusAreaHost; | |
24 | |
25 // This class is used to wrap the small informative widgets in the upper-right | 17 // This class is used to wrap the small informative widgets in the upper-right |
26 // of the window title bar. It is used on ChromeOS only. | 18 // of the window title bar. It is used on ChromeOS only. |
27 class StatusAreaView : public AccessiblePaneView, | 19 class StatusAreaView : public AccessiblePaneView, |
28 public base::SupportsWeakPtr<StatusAreaView> { | 20 public base::SupportsWeakPtr<StatusAreaView> { |
29 public: | 21 public: |
30 explicit StatusAreaView(StatusAreaHost* host); | 22 explicit StatusAreaView(); |
31 virtual ~StatusAreaView(); | 23 virtual ~StatusAreaView(); |
32 | 24 |
33 virtual void Init(); | 25 void AddButton(StatusAreaButton* button, bool bordered); |
| 26 void RemoveButton(StatusAreaButton* button); |
| 27 |
34 void MakeButtonsActive(bool active); | 28 void MakeButtonsActive(bool active); |
35 void ButtonVisibilityChanged(views::View* button_view); | 29 void UpdateButtonVisibility(); |
36 | 30 |
37 // Takes focus and transfers it to the first (last if |reverse| is true). | 31 // Takes focus and transfers it to the first (last if |reverse| is true). |
38 // After focus has traversed through all elements, clears focus and calls | 32 // After focus has traversed through all elements, clears focus and calls |
39 // |return_focus_cb(reverse)| from the message loop. | 33 // |return_focus_cb(reverse)| from the message loop. |
40 typedef base::Callback<void(bool)> ReturnFocusCallback; | 34 typedef base::Callback<void(bool)> ReturnFocusCallback; |
41 void TakeFocus(bool reverse, | 35 void TakeFocus(bool reverse, |
42 const ReturnFocusCallback& return_focus_cb); | 36 const ReturnFocusCallback& return_focus_cb); |
43 | 37 |
44 // Overridden from views::FocusChangeListener: | 38 // Overridden from views::FocusChangeListener: |
45 virtual void FocusWillChange(views::View* focused_before, | 39 virtual void FocusWillChange(views::View* focused_before, |
46 views::View* focused_now) OVERRIDE; | 40 views::View* focused_now) OVERRIDE; |
47 | 41 |
48 // views::View* overrides. | 42 // views::View* overrides. |
49 virtual gfx::Size GetPreferredSize(); | 43 virtual gfx::Size GetPreferredSize() OVERRIDE; |
50 virtual void Layout(); | 44 virtual void Layout() OVERRIDE; |
51 virtual void ChildPreferredSizeChanged(View* child); | 45 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE; |
52 | |
53 AccessibilityMenuButton* accessibility_view() { return accessibility_view_; } | |
54 CapsLockMenuButton* caps_lock_view() { return caps_lock_view_; } | |
55 ClockMenuButton* clock_view() { return clock_view_; } | |
56 InputMethodMenuButton* input_method_view() { return input_method_view_; } | |
57 NetworkMenuButton* network_view() { return network_view_; } | |
58 PowerMenuButton* power_view() { return power_view_; } | |
59 | 46 |
60 private: | 47 private: |
61 StatusAreaHost* host_; | 48 StatusAreaButton::Delegate* delegate_; |
62 | |
63 AccessibilityMenuButton* accessibility_view_; | |
64 CapsLockMenuButton* caps_lock_view_; | |
65 ClockMenuButton* clock_view_; | |
66 InputMethodMenuButton* input_method_view_; | |
67 MemoryMenuButton* memory_view_; | |
68 NetworkMenuButton* network_view_; | |
69 PowerMenuButton* power_view_; | |
70 | 49 |
71 // True if focus needs to be returned via |return_focus_cb_| when it wraps. | 50 // True if focus needs to be returned via |return_focus_cb_| when it wraps. |
72 bool need_return_focus_; | 51 bool need_return_focus_; |
73 ReturnFocusCallback return_focus_cb_; | 52 ReturnFocusCallback return_focus_cb_; |
74 | 53 |
| 54 std::list<StatusAreaButton*> buttons_; |
| 55 |
75 // Clears focus and calls |return_focus_cb_|. | 56 // Clears focus and calls |return_focus_cb_|. |
76 void ReturnFocus(bool reverse); | 57 void ReturnFocus(bool reverse); |
77 | 58 |
78 DISALLOW_COPY_AND_ASSIGN(StatusAreaView); | 59 DISALLOW_COPY_AND_ASSIGN(StatusAreaView); |
79 }; | 60 }; |
80 | 61 |
81 } // namespace chromeos | |
82 | |
83 #endif // CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_VIEW_H_ | 62 #endif // CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_VIEW_H_ |
OLD | NEW |