| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/controls/combobox/native_combobox_win.h" | 5 #include "ui/views/controls/combobox/native_combobox_win.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "ui/base/events/event.h" | 9 #include "ui/base/events/event.h" |
| 10 #include "ui/base/models/combobox_model.h" | 10 #include "ui/base/models/combobox_model.h" |
| 11 #include "ui/base/resource/resource_bundle.h" | 11 #include "ui/base/resource/resource_bundle.h" |
| 12 #include "ui/base/win/hwnd_util.h" | |
| 13 #include "ui/gfx/font.h" | 12 #include "ui/gfx/font.h" |
| 13 #include "ui/gfx/win/hwnd_util.h" |
| 14 #include "ui/native_theme/native_theme_win.h" | 14 #include "ui/native_theme/native_theme_win.h" |
| 15 #include "ui/views/controls/combobox/combobox.h" | 15 #include "ui/views/controls/combobox/combobox.h" |
| 16 #include "ui/views/controls/combobox/native_combobox_views.h" | 16 #include "ui/views/controls/combobox/native_combobox_views.h" |
| 17 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 // Limit how small a combobox can be. | 21 // Limit how small a combobox can be. |
| 22 const int kMinComboboxWidth = 148; | 22 const int kMinComboboxWidth = 148; |
| 23 | 23 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 void NativeComboboxWin::CreateNativeControl() { | 181 void NativeComboboxWin::CreateNativeControl() { |
| 182 // It's ok to add WS_VSCROLL. The scrollbar will show up only when necessary | 182 // It's ok to add WS_VSCROLL. The scrollbar will show up only when necessary |
| 183 // as long as we don't use CBS_DISABLENOSCROLL. | 183 // as long as we don't use CBS_DISABLENOSCROLL. |
| 184 // See http://msdn.microsoft.com/en-us/library/7h63bxbe(VS.80).aspx | 184 // See http://msdn.microsoft.com/en-us/library/7h63bxbe(VS.80).aspx |
| 185 DWORD flags = WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | | 185 DWORD flags = WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | |
| 186 CBS_DROPDOWNLIST | WS_VSCROLL; | 186 CBS_DROPDOWNLIST | WS_VSCROLL; |
| 187 HWND control_hwnd = ::CreateWindowEx(GetAdditionalExStyle(), L"COMBOBOX", L"", | 187 HWND control_hwnd = ::CreateWindowEx(GetAdditionalExStyle(), L"COMBOBOX", L"", |
| 188 flags, 0, 0, width(), height(), | 188 flags, 0, 0, width(), height(), |
| 189 GetWidget()->GetNativeView(), NULL, NULL, | 189 GetWidget()->GetNativeView(), NULL, NULL, |
| 190 NULL); | 190 NULL); |
| 191 ui::CheckWindowCreated(control_hwnd); | 191 gfx::CheckWindowCreated(control_hwnd); |
| 192 NativeControlCreated(control_hwnd); | 192 NativeControlCreated(control_hwnd); |
| 193 } | 193 } |
| 194 | 194 |
| 195 void NativeComboboxWin::NativeControlCreated(HWND native_control) { | 195 void NativeComboboxWin::NativeControlCreated(HWND native_control) { |
| 196 NativeControlWin::NativeControlCreated(native_control); | 196 NativeControlWin::NativeControlCreated(native_control); |
| 197 | 197 |
| 198 UpdateFont(); | 198 UpdateFont(); |
| 199 } | 199 } |
| 200 | 200 |
| 201 //////////////////////////////////////////////////////////////////////////////// | 201 //////////////////////////////////////////////////////////////////////////////// |
| 202 // NativeComboboxWin, private: | 202 // NativeComboboxWin, private: |
| 203 | 203 |
| 204 void NativeComboboxWin::UpdateFont() { | 204 void NativeComboboxWin::UpdateFont() { |
| 205 HFONT font = Combobox::GetFont().GetNativeFont(); | 205 HFONT font = Combobox::GetFont().GetNativeFont(); |
| 206 SendMessage(native_view(), WM_SETFONT, reinterpret_cast<WPARAM>(font), FALSE); | 206 SendMessage(native_view(), WM_SETFONT, reinterpret_cast<WPARAM>(font), FALSE); |
| 207 } | 207 } |
| 208 | 208 |
| 209 //////////////////////////////////////////////////////////////////////////////// | 209 //////////////////////////////////////////////////////////////////////////////// |
| 210 // NativeComboboxWrapper, public: | 210 // NativeComboboxWrapper, public: |
| 211 | 211 |
| 212 // static | 212 // static |
| 213 NativeComboboxWrapper* NativeComboboxWrapper::CreateWrapper( | 213 NativeComboboxWrapper* NativeComboboxWrapper::CreateWrapper( |
| 214 Combobox* combobox) { | 214 Combobox* combobox) { |
| 215 return new NativeComboboxViews(combobox); | 215 return new NativeComboboxViews(combobox); |
| 216 } | 216 } |
| 217 | 217 |
| 218 } // namespace views | 218 } // namespace views |
| OLD | NEW |