| 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 #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/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 //////////////////////////////////////////////////////////////////////////////// | 40 //////////////////////////////////////////////////////////////////////////////// |
| 41 // NativeComboboxWin, NativeComboboxWrapper implementation: | 41 // NativeComboboxWin, NativeComboboxWrapper implementation: |
| 42 | 42 |
| 43 void NativeComboboxWin::UpdateFromModel() { | 43 void NativeComboboxWin::UpdateFromModel() { |
| 44 SendMessage(native_view(), CB_RESETCONTENT, 0, 0); | 44 SendMessage(native_view(), CB_RESETCONTENT, 0, 0); |
| 45 gfx::Font font = ResourceBundle::GetSharedInstance().GetFont( | 45 gfx::Font font = ResourceBundle::GetSharedInstance().GetFont( |
| 46 ResourceBundle::BaseFont); | 46 ResourceBundle::BaseFont); |
| 47 int max_width = 0; | 47 int max_width = 0; |
| 48 int num_items = combobox_->model()->GetItemCount(); | 48 int num_items = combobox_->model()->GetItemCount(); |
| 49 for (int i = 0; i < num_items; ++i) { | 49 for (int i = 0; i < num_items; ++i) { |
| 50 const std::wstring& text = UTF16ToWide(combobox_->model()->GetItemAt(i)); | 50 std::wstring text = UTF16ToWide(combobox_->model()->GetItemAt(i)); |
| 51 | 51 |
| 52 // Inserting the Unicode formatting characters if necessary so that the | 52 // Inserting the Unicode formatting characters if necessary so that the |
| 53 // text is displayed correctly in right-to-left UIs. | 53 // text is displayed correctly in right-to-left UIs. |
| 54 std::wstring localized_text; | 54 base::i18n::AdjustStringForLocaleDirection(&text); |
| 55 const wchar_t* text_ptr = text.c_str(); | 55 const wchar_t* text_ptr = text.c_str(); |
| 56 if (base::i18n::AdjustStringForLocaleDirection(text, &localized_text)) | |
| 57 text_ptr = localized_text.c_str(); | |
| 58 | 56 |
| 59 SendMessage(native_view(), CB_ADDSTRING, 0, | 57 SendMessage(native_view(), CB_ADDSTRING, 0, |
| 60 reinterpret_cast<LPARAM>(text_ptr)); | 58 reinterpret_cast<LPARAM>(text_ptr)); |
| 61 max_width = std::max(max_width, font.GetStringWidth(text)); | 59 max_width = std::max(max_width, font.GetStringWidth(text)); |
| 62 } | 60 } |
| 63 content_width_ = max_width; | 61 content_width_ = max_width; |
| 64 | 62 |
| 65 if (num_items > 0) { | 63 if (num_items > 0) { |
| 66 SendMessage(native_view(), CB_SETCURSEL, combobox_->selected_item(), 0); | 64 SendMessage(native_view(), CB_SETCURSEL, combobox_->selected_item(), 0); |
| 67 | 65 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 //////////////////////////////////////////////////////////////////////////////// | 188 //////////////////////////////////////////////////////////////////////////////// |
| 191 // NativeComboboxWrapper, public: | 189 // NativeComboboxWrapper, public: |
| 192 | 190 |
| 193 // static | 191 // static |
| 194 NativeComboboxWrapper* NativeComboboxWrapper::CreateWrapper( | 192 NativeComboboxWrapper* NativeComboboxWrapper::CreateWrapper( |
| 195 Combobox* combobox) { | 193 Combobox* combobox) { |
| 196 return new NativeComboboxWin(combobox); | 194 return new NativeComboboxWin(combobox); |
| 197 } | 195 } |
| 198 | 196 |
| 199 } // namespace views | 197 } // namespace views |
| OLD | NEW |