| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 ::DestroyWindow(*container_); | 188 ::DestroyWindow(*container_); |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 | 191 |
| 192 void NativeControl::ValidateNativeControl() { | 192 void NativeControl::ValidateNativeControl() { |
| 193 if (hwnd_view_ == NULL) { | 193 if (hwnd_view_ == NULL) { |
| 194 hwnd_view_ = new NativeViewHost; | 194 hwnd_view_ = new NativeViewHost; |
| 195 AddChildView(hwnd_view_); | 195 AddChildView(hwnd_view_); |
| 196 } | 196 } |
| 197 | 197 |
| 198 if (!container_ && IsVisible()) { | 198 if (!container_ && visible()) { |
| 199 container_ = new NativeControlContainer(this); | 199 container_ = new NativeControlContainer(this); |
| 200 container_->Init(); | 200 container_->Init(); |
| 201 hwnd_view_->Attach(*container_); | 201 hwnd_view_->Attach(*container_); |
| 202 if (!enabled_) | 202 if (!enabled_) |
| 203 EnableWindow(GetNativeControlHWND(), enabled_); | 203 EnableWindow(GetNativeControlHWND(), enabled_); |
| 204 | 204 |
| 205 // This message ensures that the focus border is shown. | 205 // This message ensures that the focus border is shown. |
| 206 ::SendMessage(container_->GetControl(), | 206 ::SendMessage(container_->GetControl(), |
| 207 WM_CHANGEUISTATE, | 207 WM_CHANGEUISTATE, |
| 208 MAKELPARAM(UIS_CLEAR, UISF_HIDEFOCUS), | 208 MAKELPARAM(UIS_CLEAR, UISF_HIDEFOCUS), |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 return NULL; | 295 return NULL; |
| 296 } | 296 } |
| 297 | 297 |
| 298 void NativeControl::NativeControlDestroyed() { | 298 void NativeControl::NativeControlDestroyed() { |
| 299 if (hwnd_view_) | 299 if (hwnd_view_) |
| 300 hwnd_view_->Detach(); | 300 hwnd_view_->Detach(); |
| 301 container_ = NULL; | 301 container_ = NULL; |
| 302 } | 302 } |
| 303 | 303 |
| 304 void NativeControl::SetVisible(bool f) { | 304 void NativeControl::SetVisible(bool f) { |
| 305 if (f != IsVisible()) { | 305 if (f != visible()) { |
| 306 View::SetVisible(f); | 306 View::SetVisible(f); |
| 307 if (!f && container_) { | 307 if (!f && container_) { |
| 308 ::DestroyWindow(*container_); | 308 ::DestroyWindow(*container_); |
| 309 } else if (f && !container_) { | 309 } else if (f && !container_) { |
| 310 ValidateNativeControl(); | 310 ValidateNativeControl(); |
| 311 } | 311 } |
| 312 } | 312 } |
| 313 } | 313 } |
| 314 | 314 |
| 315 void NativeControl::SetEnabled(bool enabled) { | 315 void NativeControl::SetEnabled(bool enabled) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 } else if (message == WM_DESTROY) { | 387 } else if (message == WM_DESTROY) { |
| 388 ui::SetWindowProc(window, reinterpret_cast<WNDPROC>(original_handler)); | 388 ui::SetWindowProc(window, reinterpret_cast<WNDPROC>(original_handler)); |
| 389 native_control->container_->prop_.reset(); | 389 native_control->container_->prop_.reset(); |
| 390 } | 390 } |
| 391 | 391 |
| 392 return CallWindowProc(reinterpret_cast<WNDPROC>(original_handler), window, | 392 return CallWindowProc(reinterpret_cast<WNDPROC>(original_handler), window, |
| 393 message, w_param, l_param); | 393 message, w_param, l_param); |
| 394 } | 394 } |
| 395 | 395 |
| 396 } // namespace views | 396 } // namespace views |
| OLD | NEW |