OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_POWER_MENU_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POWER_MENU_BUTTON_H_ |
6 #define CHROME_BROWSER_CHROMEOS_POWER_MENU_BUTTON_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POWER_MENU_BUTTON_H_ |
7 | 7 |
8 #include "chrome/browser/chromeos/cros_power_library.h" | 8 #include "chrome/browser/chromeos/power_library.h" |
9 #include "chrome/browser/chromeos/status_area_button.h" | 9 #include "chrome/browser/chromeos/status_area_button.h" |
10 #include "views/controls/menu/menu_2.h" | 10 #include "views/controls/menu/menu_2.h" |
11 #include "views/controls/menu/view_menu_delegate.h" | 11 #include "views/controls/menu/view_menu_delegate.h" |
12 | 12 |
13 class CrosPowerLibrary; | |
14 class SkBitmap; | 13 class SkBitmap; |
15 | 14 |
| 15 namespace chromeos { |
| 16 |
16 // The power menu button in the status area. | 17 // The power menu button in the status area. |
17 // This class will handle getting the power status and populating the menu. | 18 // This class will handle getting the power status and populating the menu. |
18 class PowerMenuButton : public StatusAreaButton, | 19 class PowerMenuButton : public StatusAreaButton, |
19 public views::ViewMenuDelegate, | 20 public views::ViewMenuDelegate, |
20 public views::Menu2Model, | 21 public views::Menu2Model, |
21 public CrosPowerLibrary::Observer { | 22 public PowerLibrary::Observer { |
22 public: | 23 public: |
23 PowerMenuButton(); | 24 PowerMenuButton(); |
24 virtual ~PowerMenuButton(); | 25 virtual ~PowerMenuButton(); |
25 | 26 |
26 // views::Menu2Model implementation. | 27 // views::Menu2Model implementation. |
27 virtual bool HasIcons() const { return false; } | 28 virtual bool HasIcons() const { return false; } |
28 virtual int GetItemCount() const; | 29 virtual int GetItemCount() const; |
29 virtual views::Menu2Model::ItemType GetTypeAt(int index) const; | 30 virtual views::Menu2Model::ItemType GetTypeAt(int index) const; |
30 virtual int GetCommandIdAt(int index) const { return index; } | 31 virtual int GetCommandIdAt(int index) const { return index; } |
31 virtual string16 GetLabelAt(int index) const; | 32 virtual string16 GetLabelAt(int index) const; |
32 virtual bool IsLabelDynamicAt(int index) const { return true; } | 33 virtual bool IsLabelDynamicAt(int index) const { return true; } |
33 virtual bool GetAcceleratorAt(int index, | 34 virtual bool GetAcceleratorAt(int index, |
34 views::Accelerator* accelerator) const { return false; } | 35 views::Accelerator* accelerator) const { return false; } |
35 virtual bool IsItemCheckedAt(int index) const { return false; } | 36 virtual bool IsItemCheckedAt(int index) const { return false; } |
36 virtual int GetGroupIdAt(int index) const { return 0; } | 37 virtual int GetGroupIdAt(int index) const { return 0; } |
37 virtual bool GetIconAt(int index, SkBitmap* icon) const { return false; } | 38 virtual bool GetIconAt(int index, SkBitmap* icon) const { return false; } |
38 virtual bool IsEnabledAt(int index) const { return false; } | 39 virtual bool IsEnabledAt(int index) const { return false; } |
39 virtual Menu2Model* GetSubmenuModelAt(int index) const { return NULL; } | 40 virtual Menu2Model* GetSubmenuModelAt(int index) const { return NULL; } |
40 virtual void HighlightChangedTo(int index) {} | 41 virtual void HighlightChangedTo(int index) {} |
41 virtual void ActivatedAt(int index) {} | 42 virtual void ActivatedAt(int index) {} |
42 virtual void MenuWillShow() {} | 43 virtual void MenuWillShow() {} |
43 | 44 |
44 // CrosPowerLibrary::Observer implementation. | 45 // PowerLibrary::Observer implementation. |
45 virtual void PowerChanged(CrosPowerLibrary* obj); | 46 virtual void PowerChanged(PowerLibrary* obj); |
46 | 47 |
47 private: | 48 private: |
48 // views::ViewMenuDelegate implementation. | 49 // views::ViewMenuDelegate implementation. |
49 virtual void RunMenu(views::View* source, const gfx::Point& pt); | 50 virtual void RunMenu(views::View* source, const gfx::Point& pt); |
50 | 51 |
51 // Update the power icon depending on the power status. | 52 // Update the power icon depending on the power status. |
52 void UpdateIcon(); | 53 void UpdateIcon(); |
53 | 54 |
54 // The number of power images. | 55 // The number of power images. |
55 static const int kNumPowerImages; | 56 static const int kNumPowerImages; |
56 | 57 |
57 // The power menu. | 58 // The power menu. |
58 views::Menu2 power_menu_; | 59 views::Menu2 power_menu_; |
59 | 60 |
60 DISALLOW_COPY_AND_ASSIGN(PowerMenuButton); | 61 DISALLOW_COPY_AND_ASSIGN(PowerMenuButton); |
61 }; | 62 }; |
62 | 63 |
| 64 } // namespace chromeos |
| 65 |
63 #endif // CHROME_BROWSER_CHROMEOS_POWER_MENU_BUTTON_H_ | 66 #endif // CHROME_BROWSER_CHROMEOS_POWER_MENU_BUTTON_H_ |
OLD | NEW |