| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/language_menu_button.h" | 5 #include "chrome/browser/chromeos/status/language_menu_button.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 input_method_descriptors_(CrosLibrary::Get()->GetLanguageLibrary()-> | 125 input_method_descriptors_(CrosLibrary::Get()->GetLanguageLibrary()-> |
| 126 GetActiveInputMethods()), | 126 GetActiveInputMethods()), |
| 127 model_(NULL), | 127 model_(NULL), |
| 128 // Be aware that the constructor of |language_menu_| calls GetItemCount() | 128 // Be aware that the constructor of |language_menu_| calls GetItemCount() |
| 129 // in this class. Therefore, GetItemCount() have to return 0 when | 129 // in this class. Therefore, GetItemCount() have to return 0 when |
| 130 // |model_| is NULL. | 130 // |model_| is NULL. |
| 131 ALLOW_THIS_IN_INITIALIZER_LIST(language_menu_(this)), | 131 ALLOW_THIS_IN_INITIALIZER_LIST(language_menu_(this)), |
| 132 host_(host) { | 132 host_(host) { |
| 133 DCHECK(input_method_descriptors_.get() && | 133 DCHECK(input_method_descriptors_.get() && |
| 134 !input_method_descriptors_->empty()); | 134 !input_method_descriptors_->empty()); |
| 135 set_border(NULL); |
| 136 SetFont(ResourceBundle::GetSharedInstance().GetFont( |
| 137 ResourceBundle::BaseFont).DeriveFont(1, gfx::Font::BOLD)); |
| 138 SetEnabledColor(0xB3FFFFFF); // White with 70% Alpha |
| 139 SetShowHighlighted(false); |
| 135 // Update the model | 140 // Update the model |
| 136 RebuildModel(); | 141 RebuildModel(); |
| 137 // Grab the real estate. | 142 // Grab the real estate. |
| 138 UpdateIcon(kSpacer); | 143 UpdateIcon(kSpacer); |
| 139 // Display the default input method name. | 144 // Display the default input method name. |
| 140 const std::wstring name | 145 const std::wstring name |
| 141 = FormatInputLanguage(input_method_descriptors_->at(0), false); | 146 = FormatInputLanguage(input_method_descriptors_->at(0), false); |
| 142 UpdateIcon(name); | 147 UpdateIcon(name); |
| 143 CrosLibrary::Get()->GetLanguageLibrary()->AddObserver(this); | 148 CrosLibrary::Get()->GetLanguageLibrary()->AddObserver(this); |
| 144 } | 149 } |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 // language is switched to XKB. | 361 // language is switched to XKB. |
| 357 // TODO(yusukes): remove this call? | 362 // TODO(yusukes): remove this call? |
| 358 RebuildModel(); | 363 RebuildModel(); |
| 359 } | 364 } |
| 360 | 365 |
| 361 void LanguageMenuButton::ImePropertiesChanged(LanguageLibrary* obj) { | 366 void LanguageMenuButton::ImePropertiesChanged(LanguageLibrary* obj) { |
| 362 RebuildModel(); | 367 RebuildModel(); |
| 363 } | 368 } |
| 364 | 369 |
| 365 void LanguageMenuButton::UpdateIcon(const std::wstring& name) { | 370 void LanguageMenuButton::UpdateIcon(const std::wstring& name) { |
| 366 set_border(NULL); | |
| 367 SetFont(ResourceBundle::GetSharedInstance().GetFont( | |
| 368 ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD)); | |
| 369 SetEnabledColor(SK_ColorWHITE); | |
| 370 SetShowHighlighted(false); | |
| 371 SetText(name); | 371 SetText(name); |
| 372 set_alignment(TextButton::ALIGN_RIGHT); | 372 set_alignment(TextButton::ALIGN_RIGHT); |
| 373 SchedulePaint(); | 373 SchedulePaint(); |
| 374 } | 374 } |
| 375 | 375 |
| 376 void LanguageMenuButton::RebuildModel() { | 376 void LanguageMenuButton::RebuildModel() { |
| 377 model_.reset(new menus::SimpleMenuModel(NULL)); | 377 model_.reset(new menus::SimpleMenuModel(NULL)); |
| 378 string16 dummy_label = UTF8ToUTF16(""); | 378 string16 dummy_label = UTF8ToUTF16(""); |
| 379 // Indicates if separator's needed before each section. | 379 // Indicates if separator's needed before each section. |
| 380 bool need_separator = false; | 380 bool need_separator = false; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 | 433 |
| 434 bool LanguageMenuButton::IndexPointsToConfigureImeMenuItem(int index) const { | 434 bool LanguageMenuButton::IndexPointsToConfigureImeMenuItem(int index) const { |
| 435 DCHECK_GE(index, 0); | 435 DCHECK_GE(index, 0); |
| 436 DCHECK(model_.get()); | 436 DCHECK(model_.get()); |
| 437 | 437 |
| 438 return ((model_->GetTypeAt(index) == menus::MenuModel::TYPE_RADIO) && | 438 return ((model_->GetTypeAt(index) == menus::MenuModel::TYPE_RADIO) && |
| 439 (model_->GetCommandIdAt(index) == COMMAND_ID_CONFIGURE_IME)); | 439 (model_->GetCommandIdAt(index) == COMMAND_ID_CONFIGURE_IME)); |
| 440 } | 440 } |
| 441 | 441 |
| 442 } // namespace chromeos | 442 } // namespace chromeos |
| OLD | NEW |