| 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 #ifndef CHROME_BROWSER_CHROMEOS_OPTIONS_LANGUAGE_CONFIG_UTIL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_OPTIONS_LANGUAGE_CONFIG_UTIL_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_OPTIONS_LANGUAGE_CONFIG_UTIL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_OPTIONS_LANGUAGE_CONFIG_UTIL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "app/combobox_model.h" | 9 #include "app/combobox_model.h" |
| 10 #include "chrome/browser/chromeos/language_preferences.h" | 10 #include "chrome/browser/chromeos/language_preferences.h" |
| 11 #include "views/controls/combobox/combobox.h" | 11 #include "views/controls/combobox/combobox.h" |
| 12 | 12 |
| 13 namespace chromeos { | 13 namespace chromeos { |
| 14 | 14 |
| 15 // The combobox model for Language input method prefs. | 15 // The combobox model for Language input method prefs. |
| 16 template <typename DataType> | 16 template <typename DataType> |
| 17 class LanguageComboboxModel : public ComboboxModel { | 17 class LanguageComboboxModel : public ComboboxModel { |
| 18 public: | 18 public: |
| 19 explicit LanguageComboboxModel( | 19 explicit LanguageComboboxModel( |
| 20 const LanguageMultipleChoicePreference<DataType>* pref_data) | 20 const language_prefs::LanguageMultipleChoicePreference<DataType>* |
| 21 pref_data) |
| 21 : pref_data_(pref_data), num_items_(0) { | 22 : pref_data_(pref_data), num_items_(0) { |
| 22 // Check how many items are defined in the |pref_data->values_and_ids| | 23 // Check how many items are defined in the |pref_data->values_and_ids| |
| 23 // array. | 24 // array. |
| 24 for (size_t i = 0; | 25 for (size_t i = 0; |
| 25 i < LanguageMultipleChoicePreference<DataType>::kMaxItems; ++i) { | 26 i < language_prefs::LanguageMultipleChoicePreference<DataType>:: |
| 27 kMaxItems; ++i) { |
| 26 if ((pref_data_->values_and_ids)[i].item_message_id == 0) { | 28 if ((pref_data_->values_and_ids)[i].item_message_id == 0) { |
| 27 break; | 29 break; |
| 28 } | 30 } |
| 29 ++num_items_; | 31 ++num_items_; |
| 30 } | 32 } |
| 31 } | 33 } |
| 32 | 34 |
| 33 // Implements ComboboxModel interface. | 35 // Implements ComboboxModel interface. |
| 34 virtual int GetItemCount() { | 36 virtual int GetItemCount() { |
| 35 return num_items_; | 37 return num_items_; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 60 return (pref_data_->values_and_ids)[0].ibus_config_value; | 62 return (pref_data_->values_and_ids)[0].ibus_config_value; |
| 61 } | 63 } |
| 62 return (pref_data_->values_and_ids)[index].ibus_config_value; | 64 return (pref_data_->values_and_ids)[index].ibus_config_value; |
| 63 } | 65 } |
| 64 | 66 |
| 65 int num_items() { | 67 int num_items() { |
| 66 return num_items_; | 68 return num_items_; |
| 67 } | 69 } |
| 68 | 70 |
| 69 private: | 71 private: |
| 70 const LanguageMultipleChoicePreference<DataType>* pref_data_; | 72 const language_prefs::LanguageMultipleChoicePreference<DataType>* pref_data_; |
| 71 int num_items_; | 73 int num_items_; |
| 72 | 74 |
| 73 DISALLOW_COPY_AND_ASSIGN(LanguageComboboxModel); | 75 DISALLOW_COPY_AND_ASSIGN(LanguageComboboxModel); |
| 74 }; | 76 }; |
| 75 | 77 |
| 76 // The combobox for the dialog which has minimum width. | 78 // The combobox for the dialog which has minimum width. |
| 77 class LanguageCombobox : public views::Combobox { | 79 class LanguageCombobox : public views::Combobox { |
| 78 public: | 80 public: |
| 79 explicit LanguageCombobox(ComboboxModel* model) : Combobox(model) { | 81 explicit LanguageCombobox(ComboboxModel* model) : Combobox(model) { |
| 80 } | 82 } |
| 81 | 83 |
| 82 virtual gfx::Size GetPreferredSize() { | 84 virtual gfx::Size GetPreferredSize() { |
| 83 gfx::Size size = Combobox::GetPreferredSize(); | 85 gfx::Size size = Combobox::GetPreferredSize(); |
| 84 if (size.width() < kMinComboboxWidth) { | 86 if (size.width() < kMinComboboxWidth) { |
| 85 size.set_width(kMinComboboxWidth); | 87 size.set_width(kMinComboboxWidth); |
| 86 } | 88 } |
| 87 return size; | 89 return size; |
| 88 } | 90 } |
| 89 | 91 |
| 90 private: | 92 private: |
| 91 static const int kMinComboboxWidth = 250; | 93 static const int kMinComboboxWidth = 250; |
| 92 | 94 |
| 93 DISALLOW_COPY_AND_ASSIGN(LanguageCombobox); | 95 DISALLOW_COPY_AND_ASSIGN(LanguageCombobox); |
| 94 }; | 96 }; |
| 95 | 97 |
| 96 } // namespace chromeos | 98 } // namespace chromeos |
| 97 | 99 |
| 98 #endif // CHROME_BROWSER_CHROMEOS_OPTIONS_LANGUAGE_CONFIG_UTIL_H_ | 100 #endif // CHROME_BROWSER_CHROMEOS_OPTIONS_LANGUAGE_CONFIG_UTIL_H_ |
| OLD | NEW |