| 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/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 "app/win/hwnd_util.h" | |
| 15 #include "app/view_prop.h" | 14 #include "app/view_prop.h" |
| 16 #include "base/logging.h" | 15 #include "base/logging.h" |
| 17 #include "base/scoped_ptr.h" | 16 #include "base/scoped_ptr.h" |
| 18 #include "gfx/native_theme_win.h" | 17 #include "gfx/native_theme_win.h" |
| 19 #include "ui/base/keycodes/keyboard_codes.h" | 18 #include "ui/base/keycodes/keyboard_codes.h" |
| 20 #include "ui/base/keycodes/keyboard_code_conversion_win.h" | 19 #include "ui/base/keycodes/keyboard_code_conversion_win.h" |
| 20 #include "ui/base/win/hwnd_util.h" |
| 21 #include "views/background.h" | 21 #include "views/background.h" |
| 22 #include "views/border.h" | 22 #include "views/border.h" |
| 23 #include "views/controls/native/native_view_host.h" | 23 #include "views/controls/native/native_view_host.h" |
| 24 #include "views/focus/focus_manager.h" | 24 #include "views/focus/focus_manager.h" |
| 25 #include "views/widget/widget.h" | 25 #include "views/widget/widget.h" |
| 26 | 26 |
| 27 using app::ViewProp; | 27 using app::ViewProp; |
| 28 | 28 |
| 29 namespace views { | 29 namespace views { |
| 30 | 30 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 delete this; | 82 delete this; |
| 83 } | 83 } |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 friend class NativeControl; | 86 friend class NativeControl; |
| 87 | 87 |
| 88 LRESULT OnCreate(LPCREATESTRUCT create_struct) { | 88 LRESULT OnCreate(LPCREATESTRUCT create_struct) { |
| 89 control_ = parent_->CreateNativeControl(m_hWnd); | 89 control_ = parent_->CreateNativeControl(m_hWnd); |
| 90 | 90 |
| 91 // We subclass the control hwnd so we get the WM_KEYDOWN messages. | 91 // We subclass the control hwnd so we get the WM_KEYDOWN messages. |
| 92 original_handler_ = app::win::SetWindowProc( | 92 original_handler_ = ui::SetWindowProc( |
| 93 control_, &NativeControl::NativeControlWndProc); | 93 control_, &NativeControl::NativeControlWndProc); |
| 94 prop_.reset(new ViewProp(control_, kNativeControlKey , parent_)); | 94 prop_.reset(new ViewProp(control_, kNativeControlKey , parent_)); |
| 95 | 95 |
| 96 ::ShowWindow(control_, SW_SHOW); | 96 ::ShowWindow(control_, SW_SHOW); |
| 97 return 1; | 97 return 1; |
| 98 } | 98 } |
| 99 | 99 |
| 100 LRESULT OnEraseBkgnd(HDC dc) { | 100 LRESULT OnEraseBkgnd(HDC dc) { |
| 101 return 1; | 101 return 1; |
| 102 } | 102 } |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 return 0; | 375 return 0; |
| 376 } else if (message == WM_SETFOCUS) { | 376 } else if (message == WM_SETFOCUS) { |
| 377 // Let the focus manager know that the focus changed. | 377 // Let the focus manager know that the focus changed. |
| 378 FocusManager* focus_manager = native_control->GetFocusManager(); | 378 FocusManager* focus_manager = native_control->GetFocusManager(); |
| 379 if (focus_manager) { | 379 if (focus_manager) { |
| 380 focus_manager->SetFocusedView(native_control); | 380 focus_manager->SetFocusedView(native_control); |
| 381 } else { | 381 } else { |
| 382 NOTREACHED(); | 382 NOTREACHED(); |
| 383 } | 383 } |
| 384 } else if (message == WM_DESTROY) { | 384 } else if (message == WM_DESTROY) { |
| 385 app::win::SetWindowProc(window, | 385 ui::SetWindowProc(window, reinterpret_cast<WNDPROC>(original_handler)); |
| 386 reinterpret_cast<WNDPROC>(original_handler)); | |
| 387 native_control->container_->prop_.reset(); | 386 native_control->container_->prop_.reset(); |
| 388 } | 387 } |
| 389 | 388 |
| 390 return CallWindowProc(reinterpret_cast<WNDPROC>(original_handler), window, | 389 return CallWindowProc(reinterpret_cast<WNDPROC>(original_handler), window, |
| 391 message, w_param, l_param); | 390 message, w_param, l_param); |
| 392 } | 391 } |
| 393 | 392 |
| 394 } // namespace views | 393 } // namespace views |
| OLD | NEW |