Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: chrome/browser/chromeos/status/input_method_menu_button.cc

Issue 6904160: Implement new gray mock. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review nits Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/chromeos/status/input_method_menu_button.h" 5 #include "chrome/browser/chromeos/status/input_method_menu_button.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/chromeos/cros/cros_library.h" 10 #include "chrome/browser/chromeos/cros/cros_library.h"
11 #include "chrome/browser/chromeos/input_method/input_method_util.h" 11 #include "chrome/browser/chromeos/input_method/input_method_util.h"
12 #include "chrome/browser/chromeos/status/status_area_host.h" 12 #include "chrome/browser/chromeos/status/status_area_host.h"
13 #include "chrome/browser/prefs/pref_service.h" 13 #include "chrome/browser/prefs/pref_service.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_list.h" 16 #include "chrome/browser/ui/browser_list.h"
17 #include "chrome/browser/ui/browser_window.h" 17 #include "chrome/browser/ui/browser_window.h"
18 #include "ui/base/resource/resource_bundle.h"
19 #include "views/window/window.h" 18 #include "views/window/window.h"
20 19
21 namespace { 20 namespace {
22 21
23 // Returns PrefService object associated with |host|. Returns NULL if we are NOT 22 // Returns PrefService object associated with |host|. Returns NULL if we are NOT
24 // within a browser. 23 // within a browser.
25 PrefService* GetPrefService(chromeos::StatusAreaHost* host) { 24 PrefService* GetPrefService(chromeos::StatusAreaHost* host) {
26 if (host->GetProfile()) { 25 if (host->GetProfile()) {
27 return host->GetProfile()->GetPrefs(); 26 return host->GetProfile()->GetPrefs();
28 } 27 }
29 return NULL; 28 return NULL;
30 } 29 }
31 30
32 #if defined(CROS_FONTS_USING_BCI)
33 const int kFontSizeDelta = 0;
34 #else
35 const int kFontSizeDelta = 1;
36 #endif
37
38 // A class which implements interfaces of chromeos::InputMethodMenu. This class 31 // A class which implements interfaces of chromeos::InputMethodMenu. This class
39 // is just for avoiding multiple inheritance. 32 // is just for avoiding multiple inheritance.
40 class MenuImpl : public chromeos::InputMethodMenu { 33 class MenuImpl : public chromeos::InputMethodMenu {
41 public: 34 public:
42 MenuImpl(chromeos::InputMethodMenuButton* button, 35 MenuImpl(chromeos::InputMethodMenuButton* button,
43 PrefService* pref_service, 36 PrefService* pref_service,
44 chromeos::StatusAreaHost::ScreenMode screen_mode) 37 chromeos::StatusAreaHost::ScreenMode screen_mode)
45 : InputMethodMenu(pref_service, screen_mode, false), button_(button) {} 38 : InputMethodMenu(pref_service, screen_mode, false), button_(button) {}
46 39
47 private: 40 private:
(...skipping 17 matching lines...) Expand all
65 }; 58 };
66 59
67 } // namespace 60 } // namespace
68 61
69 namespace chromeos { 62 namespace chromeos {
70 63
71 //////////////////////////////////////////////////////////////////////////////// 64 ////////////////////////////////////////////////////////////////////////////////
72 // InputMethodMenuButton 65 // InputMethodMenuButton
73 66
74 InputMethodMenuButton::InputMethodMenuButton(StatusAreaHost* host) 67 InputMethodMenuButton::InputMethodMenuButton(StatusAreaHost* host)
75 : StatusAreaButton(this), 68 : StatusAreaButton(host, this),
76 menu_(new MenuImpl(this, GetPrefService(host), host->GetScreenMode())), 69 menu_(new MenuImpl(this, GetPrefService(host), host->GetScreenMode())) {
77 host_(host) {
78 set_border(NULL);
79 set_use_menu_button_paint(true);
80 SetFont(ResourceBundle::GetSharedInstance().GetFont(
81 ResourceBundle::BaseFont).DeriveFont(kFontSizeDelta));
82 SetEnabledColor(0xB3FFFFFF); // White with 70% Alpha
83 SetDisabledColor(0x00FFFFFF); // White with 00% Alpha (invisible)
84 SetShowMultipleIconStates(false);
85 set_alignment(TextButton::ALIGN_CENTER);
86
87 UpdateUIFromCurrentInputMethod(); 70 UpdateUIFromCurrentInputMethod();
88 } 71 }
89 72
90 //////////////////////////////////////////////////////////////////////////////// 73 ////////////////////////////////////////////////////////////////////////////////
91 // views::View implementation: 74 // views::View implementation:
92 75
93 gfx::Size InputMethodMenuButton::GetPreferredSize() { 76 gfx::Size InputMethodMenuButton::GetPreferredSize() {
94 // If not enabled, then hide this button. 77 // If not enabled, then hide this button.
95 if (!IsEnabled()) { 78 if (!IsEnabled()) {
96 return gfx::Size(0, 0); 79 return gfx::Size(0, 0);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 const InputMethodDescriptor& input_method = 160 const InputMethodDescriptor& input_method =
178 input_method_library->current_input_method(); 161 input_method_library->current_input_method();
179 const std::wstring name = InputMethodMenu::GetTextForIndicator(input_method); 162 const std::wstring name = InputMethodMenu::GetTextForIndicator(input_method);
180 const std::wstring tooltip = InputMethodMenu::GetTextForMenu(input_method); 163 const std::wstring tooltip = InputMethodMenu::GetTextForMenu(input_method);
181 const size_t num_active_input_methods = 164 const size_t num_active_input_methods =
182 input_method_library->GetNumActiveInputMethods(); 165 input_method_library->GetNumActiveInputMethods();
183 UpdateUI(input_method.id, name, tooltip, num_active_input_methods); 166 UpdateUI(input_method.id, name, tooltip, num_active_input_methods);
184 } 167 }
185 168
186 } // namespace chromeos 169 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/status/input_method_menu_button.h ('k') | chrome/browser/chromeos/status/network_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698