| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #include "views/controls/combobox/native_combobox_win.h" | 5 #include "views/controls/combobox/native_combobox_win.h" |
| 6 | 6 |
| 7 #include "app/combobox_model.h" | 7 #include "app/combobox_model.h" |
| 8 #include "app/gfx/font.h" | 8 #include "app/gfx/font.h" |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| 11 #include "base/i18n/rtl.h" |
| 11 #include "gfx/native_theme_win.h" | 12 #include "gfx/native_theme_win.h" |
| 12 #include "views/controls/combobox/combobox.h" | 13 #include "views/controls/combobox/combobox.h" |
| 13 #include "views/widget/widget.h" | 14 #include "views/widget/widget.h" |
| 14 | 15 |
| 15 namespace views { | 16 namespace views { |
| 16 | 17 |
| 17 // Limit how small a combobox can be. | 18 // Limit how small a combobox can be. |
| 18 static const int kMinComboboxWidth = 148; | 19 static const int kMinComboboxWidth = 148; |
| 19 | 20 |
| 20 // Add a couple extra pixels to the widths of comboboxes and combobox | 21 // Add a couple extra pixels to the widths of comboboxes and combobox |
| (...skipping 24 matching lines...) Expand all Loading... |
| 45 ResourceBundle::BaseFont); | 46 ResourceBundle::BaseFont); |
| 46 int max_width = 0; | 47 int max_width = 0; |
| 47 int num_items = combobox_->model()->GetItemCount(); | 48 int num_items = combobox_->model()->GetItemCount(); |
| 48 for (int i = 0; i < num_items; ++i) { | 49 for (int i = 0; i < num_items; ++i) { |
| 49 const std::wstring& text = combobox_->model()->GetItemAt(i); | 50 const std::wstring& text = combobox_->model()->GetItemAt(i); |
| 50 | 51 |
| 51 // Inserting the Unicode formatting characters if necessary so that the | 52 // Inserting the Unicode formatting characters if necessary so that the |
| 52 // text is displayed correctly in right-to-left UIs. | 53 // text is displayed correctly in right-to-left UIs. |
| 53 std::wstring localized_text; | 54 std::wstring localized_text; |
| 54 const wchar_t* text_ptr = text.c_str(); | 55 const wchar_t* text_ptr = text.c_str(); |
| 55 if (l10n_util::AdjustStringForLocaleDirection(text, &localized_text)) | 56 if (base::i18n::AdjustStringForLocaleDirection(text, &localized_text)) |
| 56 text_ptr = localized_text.c_str(); | 57 text_ptr = localized_text.c_str(); |
| 57 | 58 |
| 58 SendMessage(native_view(), CB_ADDSTRING, 0, | 59 SendMessage(native_view(), CB_ADDSTRING, 0, |
| 59 reinterpret_cast<LPARAM>(text_ptr)); | 60 reinterpret_cast<LPARAM>(text_ptr)); |
| 60 max_width = std::max(max_width, font.GetStringWidth(text)); | 61 max_width = std::max(max_width, font.GetStringWidth(text)); |
| 61 } | 62 } |
| 62 content_width_ = max_width; | 63 content_width_ = max_width; |
| 63 | 64 |
| 64 if (num_items > 0) { | 65 if (num_items > 0) { |
| 65 SendMessage(native_view(), CB_SETCURSEL, combobox_->selected_item(), 0); | 66 SendMessage(native_view(), CB_SETCURSEL, combobox_->selected_item(), 0); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 //////////////////////////////////////////////////////////////////////////////// | 190 //////////////////////////////////////////////////////////////////////////////// |
| 190 // NativeComboboxWrapper, public: | 191 // NativeComboboxWrapper, public: |
| 191 | 192 |
| 192 // static | 193 // static |
| 193 NativeComboboxWrapper* NativeComboboxWrapper::CreateWrapper( | 194 NativeComboboxWrapper* NativeComboboxWrapper::CreateWrapper( |
| 194 Combobox* combobox) { | 195 Combobox* combobox) { |
| 195 return new NativeComboboxWin(combobox); | 196 return new NativeComboboxWin(combobox); |
| 196 } | 197 } |
| 197 | 198 |
| 198 } // namespace views | 199 } // namespace views |
| OLD | NEW |