Chromium Code Reviews| 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_CLOCK_MENU_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_STATUS_CLOCK_MENU_BUTTON_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_STATUS_CLOCK_MENU_BUTTON_H_ | 6 #define CHROME_BROWSER_CHROMEOS_STATUS_CLOCK_MENU_BUTTON_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/timer.h" | 10 #include "base/timer.h" |
| 11 #include "chrome/browser/chromeos/cros/power_library.h" | 11 #include "chrome/browser/chromeos/cros/power_library.h" |
| 12 #include "chrome/browser/chromeos/cros/system_library.h" | 12 #include "chrome/browser/chromeos/cros/system_library.h" |
| 13 #include "chrome/browser/chromeos/status/status_area_button.h" | 13 #include "chrome/browser/chromeos/status/status_area_button.h" |
| 14 #include "unicode/calendar.h" | 14 #include "unicode/calendar.h" |
| 15 #include "views/controls/button/menu_button.h" | 15 #include "views/controls/button/menu_button.h" |
| 16 #include "views/controls/menu/menu_2.h" | 16 #include "views/controls/menu/menu_delegate.h" |
| 17 #include "views/controls/menu/view_menu_delegate.h" | 17 #include "views/controls/menu/view_menu_delegate.h" |
| 18 | 18 |
| 19 namespace chromeos { | 19 namespace chromeos { |
| 20 | 20 |
| 21 class StatusAreaHost; | 21 class StatusAreaHost; |
| 22 | 22 |
| 23 // The clock menu button in the status area. | 23 // The clock menu button in the status area. |
| 24 // This button shows the current time. | 24 // This button shows the current time. |
| 25 class ClockMenuButton : public StatusAreaButton, | 25 class ClockMenuButton : public StatusAreaButton, |
| 26 public views::MenuDelegate, | |
| 26 public views::ViewMenuDelegate, | 27 public views::ViewMenuDelegate, |
| 27 public ui::MenuModel, | |
| 28 public PowerLibrary::Observer, | 28 public PowerLibrary::Observer, |
| 29 public SystemLibrary::Observer { | 29 public SystemLibrary::Observer { |
| 30 public: | 30 public: |
| 31 explicit ClockMenuButton(StatusAreaHost* host); | 31 explicit ClockMenuButton(StatusAreaHost* host); |
| 32 virtual ~ClockMenuButton(); | 32 virtual ~ClockMenuButton(); |
| 33 | 33 |
| 34 // ui::MenuModel implementation. | 34 // views::MenuDelegate implementation |
| 35 virtual bool HasIcons() const { return false; } | 35 virtual std::wstring GetLabel(int id) const; |
|
oshima
2011/04/14 17:27:31
include compiler_specific.h and add
OVERRIDE
(or
rhashimoto
2011/04/14 18:27:04
Done.
| |
| 36 virtual int GetItemCount() const; | 36 virtual bool IsCommandEnabled(int id) const; |
| 37 virtual ui::MenuModel::ItemType GetTypeAt(int index) const; | 37 virtual void ExecuteCommand(int id); |
| 38 virtual int GetCommandIdAt(int index) const { return index; } | |
| 39 virtual string16 GetLabelAt(int index) const; | |
| 40 virtual bool IsItemDynamicAt(int index) const { return true; } | |
| 41 virtual bool GetAcceleratorAt(int index, | |
| 42 ui::Accelerator* accelerator) const { return false; } | |
| 43 virtual bool IsItemCheckedAt(int index) const { return false; } | |
| 44 virtual int GetGroupIdAt(int index) const { return 0; } | |
| 45 virtual bool GetIconAt(int index, SkBitmap* icon) { return false; } | |
| 46 virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const { | |
| 47 return NULL; | |
| 48 } | |
| 49 virtual bool IsEnabledAt(int index) const; | |
| 50 virtual ui::MenuModel* GetSubmenuModelAt(int index) const { return NULL; } | |
| 51 virtual void HighlightChangedTo(int index) {} | |
| 52 virtual void ActivatedAt(int index); | |
| 53 virtual void MenuWillShow() {} | |
| 54 virtual void SetMenuModelDelegate(ui::MenuModelDelegate* delegate) {} | |
| 55 | 38 |
| 56 // Overridden from ResumeLibrary::Observer: | 39 // Overridden from ResumeLibrary::Observer: |
| 57 virtual void PowerChanged(PowerLibrary* obj) {} | 40 virtual void PowerChanged(PowerLibrary* obj) {} |
| 58 virtual void SystemResumed(); | 41 virtual void SystemResumed(); |
| 59 | 42 |
| 60 // Overridden from SystemLibrary::Observer: | 43 // Overridden from SystemLibrary::Observer: |
| 61 virtual void TimezoneChanged(const icu::TimeZone& timezone); | 44 virtual void TimezoneChanged(const icu::TimeZone& timezone); |
| 62 | 45 |
| 63 // Updates the time on the menu button. Can be called by host if timezone | 46 // Updates the time on the menu button. Can be called by host if timezone |
| 64 // changes. | 47 // changes. |
| 65 void UpdateText(); | 48 void UpdateText(); |
| 66 | 49 |
| 67 protected: | 50 protected: |
| 68 virtual int horizontal_padding() { return 3; } | 51 virtual int horizontal_padding() { return 3; } |
| 69 | 52 |
| 70 private: | 53 private: |
| 71 // views::ViewMenuDelegate implementation. | 54 // views::ViewMenuDelegate implementation. |
| 72 virtual void RunMenu(views::View* source, const gfx::Point& pt); | 55 virtual void RunMenu(views::View* source, const gfx::Point& pt); |
| 73 | 56 |
| 74 // Updates text and schedules the timer to fire at the next minute interval. | 57 // Updates text and schedules the timer to fire at the next minute interval. |
| 75 void UpdateTextAndSetNextTimer(); | 58 void UpdateTextAndSetNextTimer(); |
| 76 | 59 |
| 77 base::OneShotTimer<ClockMenuButton> timer_; | 60 base::OneShotTimer<ClockMenuButton> timer_; |
| 78 | 61 |
| 79 // The clock menu. | 62 // The clock menu. |
| 80 // NOTE: we use a scoped_ptr here as menu calls into 'this' from the | 63 // NOTE: we use a scoped_ptr here as menu calls into 'this' from the |
| 81 // constructor. | 64 // constructor. |
| 82 scoped_ptr<views::Menu2> clock_menu_; | 65 scoped_ptr<views::MenuItemView> menu_; |
| 83 | 66 |
| 84 StatusAreaHost* host_; | 67 StatusAreaHost* host_; |
| 85 | 68 |
| 86 DISALLOW_COPY_AND_ASSIGN(ClockMenuButton); | 69 DISALLOW_COPY_AND_ASSIGN(ClockMenuButton); |
| 87 }; | 70 }; |
| 88 | 71 |
| 89 } // namespace chromeos | 72 } // namespace chromeos |
| 90 | 73 |
| 91 #endif // CHROME_BROWSER_CHROMEOS_STATUS_CLOCK_MENU_BUTTON_H_ | 74 #endif // CHROME_BROWSER_CHROMEOS_STATUS_CLOCK_MENU_BUTTON_H_ |
| OLD | NEW |