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