OLD | NEW |
1 // Copyright (c) 2010 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 "app/win/window_impl.h" | 5 #include "ui/base/win/window_impl.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "app/win/hwnd_util.h" | 9 #include "ui/base/win/hwnd_util.h" |
10 #include "base/singleton.h" | 10 #include "base/singleton.h" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 | 12 |
13 namespace app { | 13 namespace ui { |
14 namespace win { | |
15 | 14 |
16 static const DWORD kWindowDefaultChildStyle = | 15 static const DWORD kWindowDefaultChildStyle = |
17 WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; | 16 WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; |
18 static const DWORD kWindowDefaultStyle = WS_OVERLAPPEDWINDOW; | 17 static const DWORD kWindowDefaultStyle = WS_OVERLAPPEDWINDOW; |
19 static const DWORD kWindowDefaultExStyle = 0; | 18 static const DWORD kWindowDefaultExStyle = 0; |
20 | 19 |
21 /////////////////////////////////////////////////////////////////////////////// | 20 /////////////////////////////////////////////////////////////////////////////// |
22 // WindowImpl class tracking. | 21 // WindowImpl class tracking. |
23 | 22 |
24 // Several external scripts rely explicitly on this base class name for | 23 // Several external scripts rely explicitly on this base class name for |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 width = bounds.width(); | 142 width = bounds.width(); |
144 height = bounds.height(); | 143 height = bounds.height(); |
145 } | 144 } |
146 | 145 |
147 hwnd_ = CreateWindowEx(window_ex_style_, GetWindowClassName().c_str(), NULL, | 146 hwnd_ = CreateWindowEx(window_ex_style_, GetWindowClassName().c_str(), NULL, |
148 window_style_, x, y, width, height, | 147 window_style_, x, y, width, height, |
149 parent, NULL, NULL, this); | 148 parent, NULL, NULL, this); |
150 DCHECK(hwnd_); | 149 DCHECK(hwnd_); |
151 | 150 |
152 // The window procedure should have set the data for us. | 151 // The window procedure should have set the data for us. |
153 DCHECK(app::win::GetWindowUserData(hwnd_) == this); | 152 DCHECK(ui::GetWindowUserData(hwnd_) == this); |
154 } | 153 } |
155 | 154 |
156 HICON WindowImpl::GetDefaultWindowIcon() const { | 155 HICON WindowImpl::GetDefaultWindowIcon() const { |
157 return NULL; | 156 return NULL; |
158 } | 157 } |
159 | 158 |
160 // static | 159 // static |
161 bool WindowImpl::IsWindowImpl(HWND hwnd) { | 160 bool WindowImpl::IsWindowImpl(HWND hwnd) { |
162 wchar_t tmp[128]; | 161 wchar_t tmp[128]; |
163 if (!::GetClassName(hwnd, tmp, 128)) | 162 if (!::GetClassName(hwnd, tmp, 128)) |
(...skipping 16 matching lines...) Expand all Loading... |
180 | 179 |
181 // static | 180 // static |
182 LRESULT CALLBACK WindowImpl::WndProc(HWND hwnd, | 181 LRESULT CALLBACK WindowImpl::WndProc(HWND hwnd, |
183 UINT message, | 182 UINT message, |
184 WPARAM w_param, | 183 WPARAM w_param, |
185 LPARAM l_param) { | 184 LPARAM l_param) { |
186 if (message == WM_NCCREATE) { | 185 if (message == WM_NCCREATE) { |
187 CREATESTRUCT* cs = reinterpret_cast<CREATESTRUCT*>(l_param); | 186 CREATESTRUCT* cs = reinterpret_cast<CREATESTRUCT*>(l_param); |
188 WindowImpl* window = reinterpret_cast<WindowImpl*>(cs->lpCreateParams); | 187 WindowImpl* window = reinterpret_cast<WindowImpl*>(cs->lpCreateParams); |
189 DCHECK(window); | 188 DCHECK(window); |
190 app::win::SetWindowUserData(hwnd, window); | 189 ui::SetWindowUserData(hwnd, window); |
191 window->hwnd_ = hwnd; | 190 window->hwnd_ = hwnd; |
192 return TRUE; | 191 return TRUE; |
193 } | 192 } |
194 | 193 |
195 WindowImpl* window = reinterpret_cast<WindowImpl*>( | 194 WindowImpl* window = reinterpret_cast<WindowImpl*>( |
196 app::win::GetWindowUserData(hwnd)); | 195 ui::GetWindowUserData(hwnd)); |
197 if (!window) | 196 if (!window) |
198 return 0; | 197 return 0; |
199 | 198 |
200 return window->OnWndProc(message, w_param, l_param); | 199 return window->OnWndProc(message, w_param, l_param); |
201 } | 200 } |
202 | 201 |
203 std::wstring WindowImpl::GetWindowClassName() { | 202 std::wstring WindowImpl::GetWindowClassName() { |
204 ClassInfo class_info(initial_class_style()); | 203 ClassInfo class_info(initial_class_style()); |
205 std::wstring name; | 204 std::wstring name; |
206 if (ClassRegistrar::GetInstance()->RetrieveClassName(class_info, &name)) | 205 if (ClassRegistrar::GetInstance()->RetrieveClassName(class_info, &name)) |
(...skipping 14 matching lines...) Expand all Loading... |
221 class_ex.lpszClassName = name.c_str(); | 220 class_ex.lpszClassName = name.c_str(); |
222 class_ex.hIconSm = class_ex.hIcon; | 221 class_ex.hIconSm = class_ex.hIcon; |
223 ATOM atom = RegisterClassEx(&class_ex); | 222 ATOM atom = RegisterClassEx(&class_ex); |
224 DCHECK(atom); | 223 DCHECK(atom); |
225 | 224 |
226 ClassRegistrar::GetInstance()->RegisterClass(class_info, name, atom); | 225 ClassRegistrar::GetInstance()->RegisterClass(class_info, name, atom); |
227 | 226 |
228 return name; | 227 return name; |
229 } | 228 } |
230 | 229 |
231 } // namespace win | 230 } // namespace ui |
232 } // namespace app | |
OLD | NEW |