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_win.h" | 5 #include "views/controls/native_control_win.h" |
6 | 6 |
7 #include <windowsx.h> | 7 #include <windowsx.h> |
8 | 8 |
9 #include "app/l10n_util_win.h" | 9 #include "app/l10n_util_win.h" |
10 #include "app/win/hwnd_util.h" | |
11 #include "app/view_prop.h" | 10 #include "app/view_prop.h" |
12 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "ui/base/win/hwnd_util.h" |
13 #include "views/focus/focus_manager.h" | 13 #include "views/focus/focus_manager.h" |
14 | 14 |
15 using app::ViewProp; | 15 using app::ViewProp; |
16 | 16 |
17 namespace views { | 17 namespace views { |
18 | 18 |
19 static const char* const kNativeControlWinKey = "__NATIVE_CONTROL_WIN__"; | 19 static const char* const kNativeControlWinKey = "__NATIVE_CONTROL_WIN__"; |
20 | 20 |
21 //////////////////////////////////////////////////////////////////////////////// | 21 //////////////////////////////////////////////////////////////////////////////// |
22 // NativeControlWin, public: | 22 // NativeControlWin, public: |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 View::ShowContextMenu(location, true); | 129 View::ShowContextMenu(location, true); |
130 } | 130 } |
131 | 131 |
132 void NativeControlWin::NativeControlCreated(HWND native_control) { | 132 void NativeControlWin::NativeControlCreated(HWND native_control) { |
133 // Associate this object with the control's HWND so that WidgetWin can find | 133 // Associate this object with the control's HWND so that WidgetWin can find |
134 // this object when it receives messages from it. | 134 // this object when it receives messages from it. |
135 props_.push_back(new ViewProp(native_control, kNativeControlWinKey, this)); | 135 props_.push_back(new ViewProp(native_control, kNativeControlWinKey, this)); |
136 props_.push_back(ChildWindowMessageProcessor::Register(native_control, this)); | 136 props_.push_back(ChildWindowMessageProcessor::Register(native_control, this)); |
137 | 137 |
138 // Subclass so we get WM_KEYDOWN and WM_SETFOCUS messages. | 138 // Subclass so we get WM_KEYDOWN and WM_SETFOCUS messages. |
139 original_wndproc_ = app::win::SetWindowProc( | 139 original_wndproc_ = ui::SetWindowProc( |
140 native_control, &NativeControlWin::NativeControlWndProc); | 140 native_control, &NativeControlWin::NativeControlWndProc); |
141 | 141 |
142 Attach(native_control); | 142 Attach(native_control); |
143 // native_view() is now valid. | 143 // native_view() is now valid. |
144 | 144 |
145 // Update the newly created HWND with any resident enabled state. | 145 // Update the newly created HWND with any resident enabled state. |
146 EnableWindow(native_view(), IsEnabled()); | 146 EnableWindow(native_view(), IsEnabled()); |
147 | 147 |
148 // This message ensures that the focus border is shown. | 148 // This message ensures that the focus border is shown. |
149 SendMessage(native_view(), WM_CHANGEUISTATE, | 149 SendMessage(native_view(), WM_CHANGEUISTATE, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 } else if (message == WM_SETFOCUS) { | 206 } else if (message == WM_SETFOCUS) { |
207 // Let the focus manager know that the focus changed. | 207 // Let the focus manager know that the focus changed. |
208 FocusManager* focus_manager = native_control->GetFocusManager(); | 208 FocusManager* focus_manager = native_control->GetFocusManager(); |
209 if (focus_manager) { | 209 if (focus_manager) { |
210 focus_manager->SetFocusedView(native_control->focus_view()); | 210 focus_manager->SetFocusedView(native_control->focus_view()); |
211 } else { | 211 } else { |
212 NOTREACHED(); | 212 NOTREACHED(); |
213 } | 213 } |
214 } else if (message == WM_DESTROY) { | 214 } else if (message == WM_DESTROY) { |
215 native_control->props_.reset(); | 215 native_control->props_.reset(); |
216 app::win::SetWindowProc(window, native_control->original_wndproc_); | 216 ui::SetWindowProc(window, native_control->original_wndproc_); |
217 } | 217 } |
218 | 218 |
219 return CallWindowProc(native_control->original_wndproc_, window, message, | 219 return CallWindowProc(native_control->original_wndproc_, window, message, |
220 w_param, l_param); | 220 w_param, l_param); |
221 } | 221 } |
222 | 222 |
223 } // namespace views | 223 } // namespace views |
OLD | NEW |