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 "ui/views/controls/native_control_win.h" | 5 #include "ui/views/controls/native_control_win.h" |
6 | 6 |
7 #include <windowsx.h> | 7 #include <windowsx.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ui/base/accessibility/accessibility_types.h" | 10 #include "ui/base/accessibility/accessibility_types.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 } | 55 } |
56 return false; | 56 return false; |
57 } | 57 } |
58 | 58 |
59 //////////////////////////////////////////////////////////////////////////////// | 59 //////////////////////////////////////////////////////////////////////////////// |
60 // NativeControlWin, View overrides: | 60 // NativeControlWin, View overrides: |
61 | 61 |
62 void NativeControlWin::OnEnabledChanged() { | 62 void NativeControlWin::OnEnabledChanged() { |
63 View::OnEnabledChanged(); | 63 View::OnEnabledChanged(); |
64 if (native_view()) | 64 if (native_view()) |
65 EnableWindow(native_view(), IsEnabled()); | 65 EnableWindow(native_view(), enabled()); |
66 } | 66 } |
67 | 67 |
68 void NativeControlWin::ViewHierarchyChanged(bool is_add, View* parent, | 68 void NativeControlWin::ViewHierarchyChanged(bool is_add, View* parent, |
69 View* child) { | 69 View* child) { |
70 // Call the base class to hide the view if we're being removed. | 70 // Call the base class to hide the view if we're being removed. |
71 NativeViewHost::ViewHierarchyChanged(is_add, parent, child); | 71 NativeViewHost::ViewHierarchyChanged(is_add, parent, child); |
72 | 72 |
73 // Create the HWND when we're added to a valid Widget. Many controls need a | 73 // Create the HWND when we're added to a valid Widget. Many controls need a |
74 // parent HWND to function properly. | 74 // parent HWND to function properly. |
75 if (is_add && GetWidget() && !native_view()) | 75 if (is_add && GetWidget() && !native_view()) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 props_.push_back(ChildWindowMessageProcessor::Register(native_control, this)); | 139 props_.push_back(ChildWindowMessageProcessor::Register(native_control, this)); |
140 | 140 |
141 // Subclass so we get WM_KEYDOWN and WM_SETFOCUS messages. | 141 // Subclass so we get WM_KEYDOWN and WM_SETFOCUS messages. |
142 original_wndproc_ = ui::SetWindowProc( | 142 original_wndproc_ = ui::SetWindowProc( |
143 native_control, &NativeControlWin::NativeControlWndProc); | 143 native_control, &NativeControlWin::NativeControlWndProc); |
144 | 144 |
145 Attach(native_control); | 145 Attach(native_control); |
146 // native_view() is now valid. | 146 // native_view() is now valid. |
147 | 147 |
148 // Update the newly created HWND with any resident enabled state. | 148 // Update the newly created HWND with any resident enabled state. |
149 EnableWindow(native_view(), IsEnabled()); | 149 EnableWindow(native_view(), enabled()); |
150 | 150 |
151 // This message ensures that the focus border is shown. | 151 // This message ensures that the focus border is shown. |
152 SendMessage(native_view(), WM_CHANGEUISTATE, | 152 SendMessage(native_view(), WM_CHANGEUISTATE, |
153 MAKEWPARAM(UIS_CLEAR, UISF_HIDEFOCUS), 0); | 153 MAKEWPARAM(UIS_CLEAR, UISF_HIDEFOCUS), 0); |
154 } | 154 } |
155 | 155 |
156 DWORD NativeControlWin::GetAdditionalExStyle() const { | 156 DWORD NativeControlWin::GetAdditionalExStyle() const { |
157 // If the UI for the view is mirrored, we should make sure we add the | 157 // If the UI for the view is mirrored, we should make sure we add the |
158 // extended window style for a right-to-left layout so the subclass creates | 158 // extended window style for a right-to-left layout so the subclass creates |
159 // a mirrored HWND for the underlying control. | 159 // a mirrored HWND for the underlying control. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 } else if (message == WM_DESTROY) { | 217 } else if (message == WM_DESTROY) { |
218 native_control->props_.reset(); | 218 native_control->props_.reset(); |
219 ui::SetWindowProc(window, native_control->original_wndproc_); | 219 ui::SetWindowProc(window, native_control->original_wndproc_); |
220 } | 220 } |
221 | 221 |
222 return CallWindowProc(native_control->original_wndproc_, window, message, | 222 return CallWindowProc(native_control->original_wndproc_, window, message, |
223 w_param, l_param); | 223 w_param, l_param); |
224 } | 224 } |
225 | 225 |
226 } // namespace views | 226 } // namespace views |
OLD | NEW |