OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/native_control.h" | 5 #include "views/controls/native_control.h" |
6 | 6 |
7 #include <atlbase.h> | 7 #include <atlbase.h> |
8 #include <atlapp.h> | 8 #include <atlapp.h> |
9 #include <atlcrack.h> | 9 #include <atlcrack.h> |
10 #include <atlframe.h> | 10 #include <atlframe.h> |
11 #include <atlmisc.h> | 11 #include <atlmisc.h> |
12 | 12 |
13 #include "app/l10n_util_win.h" | 13 #include "app/l10n_util_win.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/win_util.h" | 15 #include "base/win_util.h" |
16 #include "views/background.h" | 16 #include "views/background.h" |
17 #include "views/border.h" | 17 #include "views/border.h" |
18 #include "views/controls/hwnd_view.h" | 18 #include "views/controls/native/native_view_host.h" |
19 #include "views/focus/focus_manager.h" | 19 #include "views/focus/focus_manager.h" |
20 #include "views/widget/widget.h" | 20 #include "views/widget/widget.h" |
21 #include "base/gfx/native_theme.h" | 21 #include "base/gfx/native_theme.h" |
22 | 22 |
23 namespace views { | 23 namespace views { |
24 | 24 |
25 // Maps to the original WNDPROC for the controller window before we subclassed | 25 // Maps to the original WNDPROC for the controller window before we subclassed |
26 // it. | 26 // it. |
27 static const wchar_t* const kHandlerKey = | 27 static const wchar_t* const kHandlerKey = |
28 L"__CONTROL_ORIGINAL_MESSAGE_HANDLER__"; | 28 L"__CONTROL_ORIGINAL_MESSAGE_HANDLER__"; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 | 175 |
176 NativeControl::~NativeControl() { | 176 NativeControl::~NativeControl() { |
177 if (container_) { | 177 if (container_) { |
178 container_->ResetParent(); | 178 container_->ResetParent(); |
179 ::DestroyWindow(*container_); | 179 ::DestroyWindow(*container_); |
180 } | 180 } |
181 } | 181 } |
182 | 182 |
183 void NativeControl::ValidateNativeControl() { | 183 void NativeControl::ValidateNativeControl() { |
184 if (hwnd_view_ == NULL) { | 184 if (hwnd_view_ == NULL) { |
185 hwnd_view_ = new HWNDView(); | 185 hwnd_view_ = new NativeViewHost; |
186 AddChildView(hwnd_view_); | 186 AddChildView(hwnd_view_); |
187 } | 187 } |
188 | 188 |
189 if (!container_ && IsVisible()) { | 189 if (!container_ && IsVisible()) { |
190 container_ = new NativeControlContainer(this); | 190 container_ = new NativeControlContainer(this); |
191 hwnd_view_->Attach(*container_); | 191 hwnd_view_->Attach(*container_); |
192 if (!enabled_) | 192 if (!enabled_) |
193 EnableWindow(GetNativeControlHWND(), enabled_); | 193 EnableWindow(GetNativeControlHWND(), enabled_); |
194 | 194 |
195 // This message ensures that the focus border is shown. | 195 // This message ensures that the focus border is shown. |
196 ::SendMessage(container_->GetControl(), | 196 ::SendMessage(container_->GetControl(), |
197 WM_CHANGEUISTATE, | 197 WM_CHANGEUISTATE, |
198 MAKELPARAM(UIS_CLEAR, UISF_HIDEFOCUS), | 198 MAKELPARAM(UIS_CLEAR, UISF_HIDEFOCUS), |
199 0); | 199 0); |
200 } | 200 } |
201 } | 201 } |
202 | 202 |
203 void NativeControl::ViewHierarchyChanged(bool is_add, View *parent, | 203 void NativeControl::ViewHierarchyChanged(bool is_add, View *parent, |
204 View *child) { | 204 View *child) { |
205 if (is_add && GetWidget()) { | 205 if (is_add && child == this && GetWidget()) { |
206 ValidateNativeControl(); | 206 ValidateNativeControl(); |
207 Layout(); | 207 Layout(); |
208 } | 208 } |
209 } | 209 } |
210 | 210 |
211 void NativeControl::Layout() { | 211 void NativeControl::Layout() { |
212 if (!container_ && GetWidget()) | 212 if (!container_ && GetWidget()) |
213 ValidateNativeControl(); | 213 ValidateNativeControl(); |
214 | 214 |
215 if (hwnd_view_) { | 215 if (hwnd_view_) { |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 reinterpret_cast<WNDPROC>(original_handler)); | 372 reinterpret_cast<WNDPROC>(original_handler)); |
373 RemoveProp(window, kHandlerKey); | 373 RemoveProp(window, kHandlerKey); |
374 RemoveProp(window, kNativeControlKey); | 374 RemoveProp(window, kNativeControlKey); |
375 } | 375 } |
376 | 376 |
377 return CallWindowProc(reinterpret_cast<WNDPROC>(original_handler), window, | 377 return CallWindowProc(reinterpret_cast<WNDPROC>(original_handler), window, |
378 message, w_param, l_param); | 378 message, w_param, l_param); |
379 } | 379 } |
380 | 380 |
381 } // namespace views | 381 } // namespace views |
OLD | NEW |