OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/system/tray_user.h" | 5 #include "ash/system/tray_user.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/system/tray/system_tray_delegate.h" | 8 #include "ash/system/tray/system_tray_delegate.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "grit/ui_resources.h" | 10 #include "grit/ash_strings.h" |
11 #include "ui/base/resource/resource_bundle.h" | 11 #include "ui/base/resource/resource_bundle.h" |
12 #include "ui/gfx/size.h" | 12 #include "ui/gfx/size.h" |
13 #include "ui/views/controls/button/button.h" | 13 #include "ui/views/controls/button/button.h" |
14 #include "ui/views/controls/button/text_button.h" | 14 #include "ui/views/controls/button/text_button.h" |
15 #include "ui/views/controls/image_view.h" | 15 #include "ui/views/controls/image_view.h" |
16 #include "ui/views/controls/label.h" | 16 #include "ui/views/controls/label.h" |
17 #include "ui/views/layout/box_layout.h" | 17 #include "ui/views/layout/box_layout.h" |
18 #include "ui/views/view.h" | 18 #include "ui/views/view.h" |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 // A custom textbutton with some extra vertical padding, and custom border, | 22 // A custom textbutton with some extra vertical padding, and custom border, |
23 // alignment and hover-effects. | 23 // alignment and hover-effects. |
24 class TrayButton : public views::TextButton { | 24 class TrayButton : public views::TextButton { |
25 public: | 25 public: |
26 TrayButton(views::ButtonListener* listener, std::string text) | 26 TrayButton(views::ButtonListener* listener, const string16& text) |
27 : views::TextButton(listener, ASCIIToUTF16(text)), | 27 : views::TextButton(listener, text), |
28 hover_(false), | 28 hover_(false), |
29 hover_bg_(views::Background::CreateSolidBackground(SkColorSetARGB( | 29 hover_bg_(views::Background::CreateSolidBackground(SkColorSetARGB( |
30 10, 0, 0, 0))) { | 30 10, 0, 0, 0))) { |
31 set_alignment(ALIGN_CENTER); | 31 set_alignment(ALIGN_CENTER); |
32 } | 32 } |
33 | 33 |
34 private: | 34 private: |
35 // Overridden from views::View. | 35 // Overridden from views::View. |
36 virtual gfx::Size GetPreferredSize() OVERRIDE { | 36 virtual gfx::Size GetPreferredSize() OVERRIDE { |
37 gfx::Size size = views::TextButton::GetPreferredSize(); | 37 gfx::Size size = views::TextButton::GetPreferredSize(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 user->AddChildView(email_); | 84 user->AddChildView(email_); |
85 | 85 |
86 AddChildView(user); | 86 AddChildView(user); |
87 | 87 |
88 views::View* button_container = new views::View; | 88 views::View* button_container = new views::View; |
89 views::BoxLayout *layout = new | 89 views::BoxLayout *layout = new |
90 views::BoxLayout(views::BoxLayout::kHorizontal, 0, 5, 0); | 90 views::BoxLayout(views::BoxLayout::kHorizontal, 0, 5, 0); |
91 layout->set_spread_blank_space(true); | 91 layout->set_spread_blank_space(true); |
92 button_container->SetLayoutManager(layout); | 92 button_container->SetLayoutManager(layout); |
93 | 93 |
94 shutdown_ = new TrayButton(this, std::string("Shut down")); | 94 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
95 signout_ = new TrayButton(this, std::string("Sign out")); | 95 |
96 lock_ = new TrayButton(this, std::string("Lock")); | 96 shutdown_ = new TrayButton(this, bundle.GetLocalizedString( |
| 97 IDS_ASH_STATUS_TRAY_SHUT_DOWN)); |
| 98 signout_ = new TrayButton(this, bundle.GetLocalizedString( |
| 99 IDS_ASH_STATUS_TRAY_SIGN_OUT)); |
| 100 lock_ = new TrayButton(this, bundle.GetLocalizedString( |
| 101 IDS_ASH_STATUS_TRAY_LOCK)); |
97 button_container->AddChildView(shutdown_); | 102 button_container->AddChildView(shutdown_); |
98 button_container->AddChildView(signout_); | 103 button_container->AddChildView(signout_); |
99 button_container->AddChildView(lock_); | 104 button_container->AddChildView(lock_); |
100 | 105 |
101 shutdown_->set_border(NULL); | 106 shutdown_->set_border(NULL); |
102 signout_->set_border(views::Border::CreateSolidSidedBorder( | 107 signout_->set_border(views::Border::CreateSolidSidedBorder( |
103 0, 1, 0, 1, SkColorSetARGB(25, 0, 0, 0))); | 108 0, 1, 0, 1, SkColorSetARGB(25, 0, 0, 0))); |
104 lock_->set_border(NULL); | 109 lock_->set_border(NULL); |
105 | 110 |
106 AddChildView(button_container); | 111 AddChildView(button_container); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 } | 164 } |
160 | 165 |
161 void TrayUser::DestroyDefaultView() { | 166 void TrayUser::DestroyDefaultView() { |
162 } | 167 } |
163 | 168 |
164 void TrayUser::DestroyDetailedView() { | 169 void TrayUser::DestroyDetailedView() { |
165 } | 170 } |
166 | 171 |
167 } // namespace internal | 172 } // namespace internal |
168 } // namespace ash | 173 } // namespace ash |
OLD | NEW |