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/listbox/native_listbox_win.h" | 5 #include "views/controls/listbox/native_listbox_win.h" |
6 | 6 |
7 #include <commctrl.h> | 7 #include <commctrl.h> |
8 #include <windowsx.h> | 8 #include <windowsx.h> |
9 | 9 |
10 #include "app/l10n_util_win.h" | 10 #include "app/l10n_util_win.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // If there's only one column and the title string is empty, don't show a | 98 // If there's only one column and the title string is empty, don't show a |
99 // header. | 99 // header. |
100 HWND hwnd = ::CreateWindowEx(WS_EX_CLIENTEDGE | GetAdditionalRTLStyle(), | 100 HWND hwnd = ::CreateWindowEx(WS_EX_CLIENTEDGE | GetAdditionalRTLStyle(), |
101 WC_LISTBOX, | 101 WC_LISTBOX, |
102 L"", | 102 L"", |
103 style, | 103 style, |
104 0, 0, width(), height(), | 104 0, 0, width(), height(), |
105 listbox_->GetWidget()->GetNativeView(), | 105 listbox_->GetWidget()->GetNativeView(), |
106 NULL, NULL, NULL); | 106 NULL, NULL, NULL); |
107 HFONT font = ResourceBundle::GetSharedInstance(). | 107 HFONT font = ResourceBundle::GetSharedInstance(). |
108 GetFont(ResourceBundle::BaseFont).hfont(); | 108 GetFont(ResourceBundle::BaseFont).GetNativeFont(); |
109 SendMessage(hwnd, WM_SETFONT, reinterpret_cast<WPARAM>(font), FALSE); | 109 SendMessage(hwnd, WM_SETFONT, reinterpret_cast<WPARAM>(font), FALSE); |
110 l10n_util::AdjustUIFontForWindow(hwnd); | 110 l10n_util::AdjustUIFontForWindow(hwnd); |
111 | 111 |
112 for (size_t i = 0; i < strings_.size(); ++i) | 112 for (size_t i = 0; i < strings_.size(); ++i) |
113 ListBox_AddString(hwnd, UTF16ToWide(strings_[i]).c_str()); | 113 ListBox_AddString(hwnd, UTF16ToWide(strings_[i]).c_str()); |
114 | 114 |
115 NativeControlCreated(hwnd); | 115 NativeControlCreated(hwnd); |
116 | 116 |
117 // Bug 964884: detach the IME attached to this window. | 117 // Bug 964884: detach the IME attached to this window. |
118 // We should attach IMEs only when we need to input CJK strings. | 118 // We should attach IMEs only when we need to input CJK strings. |
119 ::ImmAssociateContextEx(hwnd, NULL, 0); | 119 ::ImmAssociateContextEx(hwnd, NULL, 0); |
120 } | 120 } |
121 | 121 |
122 //////////////////////////////////////////////////////////////////////////////// | 122 //////////////////////////////////////////////////////////////////////////////// |
123 // NativeListboxWrapper, public: | 123 // NativeListboxWrapper, public: |
124 | 124 |
125 // static | 125 // static |
126 NativeListboxWrapper* NativeListboxWrapper::CreateNativeWrapper( | 126 NativeListboxWrapper* NativeListboxWrapper::CreateNativeWrapper( |
127 Listbox* listbox, | 127 Listbox* listbox, |
128 const std::vector<string16>& strings, | 128 const std::vector<string16>& strings, |
129 Listbox::Listener* listener) { | 129 Listbox::Listener* listener) { |
130 return new NativeListboxWin(listbox, strings, listener); | 130 return new NativeListboxWin(listbox, strings, listener); |
131 } | 131 } |
132 | 132 |
133 } // namespace views | 133 } // namespace views |
OLD | NEW |