| 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> |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 72 } |
| 73 | 73 |
| 74 void OnFinalMessage(HWND hwnd) { | 74 void OnFinalMessage(HWND hwnd) { |
| 75 if (parent_) | 75 if (parent_) |
| 76 parent_->NativeControlDestroyed(); | 76 parent_->NativeControlDestroyed(); |
| 77 delete this; | 77 delete this; |
| 78 } | 78 } |
| 79 private: | 79 private: |
| 80 | 80 |
| 81 LRESULT OnCreate(LPCREATESTRUCT create_struct) { | 81 LRESULT OnCreate(LPCREATESTRUCT create_struct) { |
| 82 TRACK_HWND_CREATION(m_hWnd); | |
| 83 | |
| 84 control_ = parent_->CreateNativeControl(m_hWnd); | 82 control_ = parent_->CreateNativeControl(m_hWnd); |
| 85 TRACK_HWND_CREATION(control_); | |
| 86 | 83 |
| 87 FocusManager::InstallFocusSubclass(control_, parent_); | 84 FocusManager::InstallFocusSubclass(control_, parent_); |
| 88 | 85 |
| 89 // We subclass the control hwnd so we get the WM_KEYDOWN messages. | 86 // We subclass the control hwnd so we get the WM_KEYDOWN messages. |
| 90 WNDPROC original_handler = | 87 WNDPROC original_handler = |
| 91 win_util::SetWindowProc(control_, | 88 win_util::SetWindowProc(control_, |
| 92 &NativeControl::NativeControlWndProc); | 89 &NativeControl::NativeControlWndProc); |
| 93 SetProp(control_, kHandlerKey, original_handler); | 90 SetProp(control_, kHandlerKey, original_handler); |
| 94 SetProp(control_, kNativeControlKey , parent_); | 91 SetProp(control_, kNativeControlKey , parent_); |
| 95 | 92 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 118 LRESULT OnNotify(int w_param, LPNMHDR l_param) { | 115 LRESULT OnNotify(int w_param, LPNMHDR l_param) { |
| 119 if (parent_) | 116 if (parent_) |
| 120 return parent_->OnNotify(w_param, l_param); | 117 return parent_->OnNotify(w_param, l_param); |
| 121 else | 118 else |
| 122 return 0; | 119 return 0; |
| 123 } | 120 } |
| 124 | 121 |
| 125 void OnDestroy() { | 122 void OnDestroy() { |
| 126 if (parent_) | 123 if (parent_) |
| 127 parent_->OnDestroy(); | 124 parent_->OnDestroy(); |
| 128 TRACK_HWND_DESTRUCTION(m_hWnd); | |
| 129 } | 125 } |
| 130 | 126 |
| 131 void OnContextMenu(HWND window, const WTL::CPoint& location) { | 127 void OnContextMenu(HWND window, const WTL::CPoint& location) { |
| 132 if (parent_) | 128 if (parent_) |
| 133 parent_->OnContextMenu(location); | 129 parent_->OnContextMenu(location); |
| 134 } | 130 } |
| 135 | 131 |
| 136 // We need to find an ancestor with a non-null background, and | 132 // We need to find an ancestor with a non-null background, and |
| 137 // ask it for a (solid color) brush that approximates | 133 // ask it for a (solid color) brush that approximates |
| 138 // the background. The caller will use this when drawing | 134 // the background. The caller will use this when drawing |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 DCHECK(native_control); | 365 DCHECK(native_control); |
| 370 | 366 |
| 371 if (message == WM_KEYDOWN && native_control->NotifyOnKeyDown()) { | 367 if (message == WM_KEYDOWN && native_control->NotifyOnKeyDown()) { |
| 372 if (native_control->OnKeyDown(static_cast<int>(w_param))) | 368 if (native_control->OnKeyDown(static_cast<int>(w_param))) |
| 373 return 0; | 369 return 0; |
| 374 } else if (message == WM_DESTROY) { | 370 } else if (message == WM_DESTROY) { |
| 375 win_util::SetWindowProc(window, | 371 win_util::SetWindowProc(window, |
| 376 reinterpret_cast<WNDPROC>(original_handler)); | 372 reinterpret_cast<WNDPROC>(original_handler)); |
| 377 RemoveProp(window, kHandlerKey); | 373 RemoveProp(window, kHandlerKey); |
| 378 RemoveProp(window, kNativeControlKey); | 374 RemoveProp(window, kNativeControlKey); |
| 379 TRACK_HWND_DESTRUCTION(window); | |
| 380 } | 375 } |
| 381 | 376 |
| 382 return CallWindowProc(reinterpret_cast<WNDPROC>(original_handler), window, | 377 return CallWindowProc(reinterpret_cast<WNDPROC>(original_handler), window, |
| 383 message, w_param, l_param); | 378 message, w_param, l_param); |
| 384 } | 379 } |
| 385 | 380 |
| 386 } // namespace views | 381 } // namespace views |
| OLD | NEW |