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 "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "chrome/browser/chromeos/status/status_area_button.h" |
11 #include "chrome/browser/ui/views/accessible_pane_view.h" | 12 #include "chrome/browser/ui/views/accessible_pane_view.h" |
12 #include "views/view.h" | 13 #include "views/view.h" |
13 | 14 |
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 | 15 // 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. | 16 // of the window title bar. It is used on ChromeOS only. |
27 class StatusAreaView : public AccessiblePaneView, | 17 class StatusAreaView : public AccessiblePaneView, |
28 public base::SupportsWeakPtr<StatusAreaView> { | 18 public base::SupportsWeakPtr<StatusAreaView> { |
29 public: | 19 public: |
30 explicit StatusAreaView(StatusAreaHost* host); | 20 explicit StatusAreaView(); |
31 virtual ~StatusAreaView(); | 21 virtual ~StatusAreaView(); |
32 | 22 |
33 virtual void Init(); | 23 void AddButton(StatusAreaButton* button, bool bordered); |
| 24 |
34 void MakeButtonsActive(bool active); | 25 void MakeButtonsActive(bool active); |
35 void ButtonVisibilityChanged(views::View* button_view); | 26 void UpdateButtonVisibility(); |
36 | 27 |
37 // Takes focus and transfers it to the first (last if |reverse| is true). | 28 // 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 | 29 // After focus has traversed through all elements, clears focus and calls |
39 // |return_focus_cb(reverse)| from the message loop. | 30 // |return_focus_cb(reverse)| from the message loop. |
40 typedef base::Callback<void(bool)> ReturnFocusCallback; | 31 typedef base::Callback<void(bool)> ReturnFocusCallback; |
41 void TakeFocus(bool reverse, | 32 void TakeFocus(bool reverse, |
42 const ReturnFocusCallback& return_focus_cb); | 33 const ReturnFocusCallback& return_focus_cb); |
43 | 34 |
44 // Overridden from views::FocusChangeListener: | 35 // Overridden from views::FocusChangeListener: |
45 virtual void FocusWillChange(views::View* focused_before, | 36 virtual void FocusWillChange(views::View* focused_before, |
46 views::View* focused_now) OVERRIDE; | 37 views::View* focused_now) OVERRIDE; |
47 | 38 |
48 // views::View* overrides. | 39 // views::View* overrides. |
49 virtual gfx::Size GetPreferredSize(); | 40 virtual gfx::Size GetPreferredSize() OVERRIDE; |
50 virtual void Layout(); | 41 virtual void Layout() OVERRIDE; |
51 virtual void ChildPreferredSizeChanged(View* child); | 42 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 | 43 |
60 private: | 44 private: |
61 StatusAreaHost* host_; | 45 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 | 46 |
71 // True if focus needs to be returned via |return_focus_cb_| when it wraps. | 47 // True if focus needs to be returned via |return_focus_cb_| when it wraps. |
72 bool need_return_focus_; | 48 bool need_return_focus_; |
73 ReturnFocusCallback return_focus_cb_; | 49 ReturnFocusCallback return_focus_cb_; |
74 | 50 |
| 51 std::vector<StatusAreaButton*> buttons_; |
| 52 |
75 // Clears focus and calls |return_focus_cb_|. | 53 // Clears focus and calls |return_focus_cb_|. |
76 void ReturnFocus(bool reverse); | 54 void ReturnFocus(bool reverse); |
77 | 55 |
78 DISALLOW_COPY_AND_ASSIGN(StatusAreaView); | 56 DISALLOW_COPY_AND_ASSIGN(StatusAreaView); |
79 }; | 57 }; |
80 | 58 |
81 } // namespace chromeos | |
82 | |
83 #endif // CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_VIEW_H_ | 59 #endif // CHROME_BROWSER_CHROMEOS_STATUS_STATUS_AREA_VIEW_H_ |
OLD | NEW |