OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/browser/chromeos/status/clock_menu_button.h" | 5 #include "chrome/browser/chromeos/status/clock_menu_button.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/i18n/time_formatting.h" | 9 #include "base/i18n/time_formatting.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/time.h" | 11 #include "base/time.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "chrome/browser/chromeos/cros/cros_library.h" | 13 #include "chrome/browser/chromeos/cros/cros_library.h" |
14 #include "chrome/browser/chromeos/status/status_area_host.h" | 14 #include "chrome/browser/chromeos/status/status_area_host.h" |
15 #include "chrome/browser/profile.h" | 15 #include "chrome/browser/profile.h" |
16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
18 #include "gfx/canvas.h" | 18 #include "gfx/canvas.h" |
19 #include "gfx/font.h" | 19 #include "gfx/font.h" |
20 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
21 | 21 |
22 namespace chromeos { | 22 namespace chromeos { |
23 | 23 |
24 // Amount of slop to add into the timer to make sure we're into the next minute | 24 // Amount of slop to add into the timer to make sure we're into the next minute |
25 // when the timer goes off. | 25 // when the timer goes off. |
26 const int kTimerSlopSeconds = 1; | 26 const int kTimerSlopSeconds = 1; |
27 | 27 |
| 28 #if defined(CROS_FONTS_USING_BCI) |
| 29 const int kFontSizeDelta = 0; |
| 30 #else |
| 31 const int kFontSizeDelta = 1; |
| 32 #endif |
| 33 |
28 ClockMenuButton::ClockMenuButton(StatusAreaHost* host) | 34 ClockMenuButton::ClockMenuButton(StatusAreaHost* host) |
29 : StatusAreaButton(this), | 35 : StatusAreaButton(this), |
30 host_(host) { | 36 host_(host) { |
31 // Add as SystemLibrary observer. We update the clock if timezone changes. | 37 // Add as SystemLibrary observer. We update the clock if timezone changes. |
32 CrosLibrary::Get()->GetSystemLibrary()->AddObserver(this); | 38 CrosLibrary::Get()->GetSystemLibrary()->AddObserver(this); |
33 | 39 |
34 set_border(NULL); | 40 set_border(NULL); |
35 set_use_menu_button_paint(true); | 41 set_use_menu_button_paint(true); |
36 SetFont(ResourceBundle::GetSharedInstance().GetFont( | 42 SetFont(ResourceBundle::GetSharedInstance().GetFont( |
37 ResourceBundle::BaseFont).DeriveFont(1)); | 43 ResourceBundle::BaseFont).DeriveFont(kFontSizeDelta)); |
38 SetEnabledColor(0xB3FFFFFF); // White with 70% Alpha | 44 SetEnabledColor(0xB3FFFFFF); // White with 70% Alpha |
39 SetShowMultipleIconStates(false); | 45 SetShowMultipleIconStates(false); |
40 set_alignment(TextButton::ALIGN_CENTER); | 46 set_alignment(TextButton::ALIGN_CENTER); |
41 UpdateTextAndSetNextTimer(); | 47 UpdateTextAndSetNextTimer(); |
42 } | 48 } |
43 | 49 |
44 ClockMenuButton::~ClockMenuButton() { | 50 ClockMenuButton::~ClockMenuButton() { |
45 CrosLibrary::Get()->GetSystemLibrary()->RemoveObserver(this); | 51 CrosLibrary::Get()->GetSystemLibrary()->RemoveObserver(this); |
46 } | 52 } |
47 | 53 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 void ClockMenuButton::RunMenu(views::View* source, const gfx::Point& pt) { | 126 void ClockMenuButton::RunMenu(views::View* source, const gfx::Point& pt) { |
121 if (!clock_menu_.get()) | 127 if (!clock_menu_.get()) |
122 clock_menu_.reset(new views::Menu2(this)); | 128 clock_menu_.reset(new views::Menu2(this)); |
123 else | 129 else |
124 clock_menu_->Rebuild(); | 130 clock_menu_->Rebuild(); |
125 clock_menu_->UpdateStates(); | 131 clock_menu_->UpdateStates(); |
126 clock_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); | 132 clock_menu_->RunMenuAt(pt, views::Menu2::ALIGN_TOPRIGHT); |
127 } | 133 } |
128 | 134 |
129 } // namespace chromeos | 135 } // namespace chromeos |
OLD | NEW |