diff options
author | chocobo@google.com <chocobo@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-08 01:33:21 +0000 |
---|---|---|
committer | chocobo@google.com <chocobo@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-08 01:33:21 +0000 |
commit | 7598ab5ec8b6b9fe6bfaaa2ee07450747fd1ee01 (patch) | |
tree | 045a49a9bd5eb156517d391ff44d46a20f947a91 /chrome/browser/chromeos/clock_menu_button.h | |
parent | 13555c122fbc9ec2a6c1a4cbace288ec7892be6e (diff) | |
download | chromium_src-7598ab5ec8b6b9fe6bfaaa2ee07450747fd1ee01.zip chromium_src-7598ab5ec8b6b9fe6bfaaa2ee07450747fd1ee01.tar.gz chromium_src-7598ab5ec8b6b9fe6bfaaa2ee07450747fd1ee01.tar.bz2 |
Refactor cros library code into central location and have the UI elements observe changes.
- implemented power menu button showing remaining battery info.
- implemented clock menu button showing detailed clock info.
- also implemented monitoring of network status change.
- don't show highlighted state for these menu buttons
BUG=23923
TEST=none
Review URL: http://codereview.chromium.org/251099
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28366 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos/clock_menu_button.h')
-rw-r--r-- | chrome/browser/chromeos/clock_menu_button.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/chrome/browser/chromeos/clock_menu_button.h b/chrome/browser/chromeos/clock_menu_button.h new file mode 100644 index 0000000..8fca16e --- /dev/null +++ b/chrome/browser/chromeos/clock_menu_button.h @@ -0,0 +1,59 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_CLOCK_MENU_BUTTON_H_ +#define CHROME_BROWSER_CHROMEOS_CLOCK_MENU_BUTTON_H_ + +#include "base/timer.h" +#include "views/controls/button/menu_button.h" +#include "views/controls/menu/menu_2.h" +#include "views/controls/menu/view_menu_delegate.h" + +// The clock menu button in the status area. +// This button shows the current time. +class ClockMenuButton : public views::MenuButton, + public views::ViewMenuDelegate, + public views::Menu2Model { + public: + ClockMenuButton(); + virtual ~ClockMenuButton() {} + + // views::Menu2Model implementation. + virtual bool HasIcons() const { return false; } + virtual int GetItemCount() const; + virtual views::Menu2Model::ItemType GetTypeAt(int index) const; + virtual int GetCommandIdAt(int index) const { return index; } + virtual string16 GetLabelAt(int index) const; + virtual bool IsLabelDynamicAt(int index) const { return true; } + virtual bool GetAcceleratorAt(int index, + views::Accelerator* accelerator) const { return false; } + virtual bool IsItemCheckedAt(int index) const { return false; } + virtual int GetGroupIdAt(int index) const { return 0; } + virtual bool GetIconAt(int index, SkBitmap* icon) const { return false; } + virtual bool IsEnabledAt(int index) const { return false; } + virtual Menu2Model* GetSubmenuModelAt(int index) const { return NULL; } + virtual void HighlightChangedTo(int index) {} + virtual void ActivatedAt(int index) {} + virtual void MenuWillShow() {} + + private: + // views::ViewMenuDelegate implementation. + virtual void RunMenu(views::View* source, const gfx::Point& pt, + gfx::NativeView hwnd); + + // Schedules the timer to fire at the next minute interval. + void SetNextTimer(); + + // Updates the time on the menu button and sets the next timer. + void UpdateText(); + + base::OneShotTimer<ClockMenuButton> timer_; + + // The clock menu. + views::Menu2 clock_menu_; + + DISALLOW_COPY_AND_ASSIGN(ClockMenuButton); +}; + +#endif // CHROME_BROWSER_CHROMEOS_CLOCK_MENU_BUTTON_H_ |