| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <list> | 5 #include <list> |
| 6 | 6 |
| 7 #include "base/singleton.h" | 7 #include "base/singleton.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/window_impl.h" | 9 #include "base/window_impl.h" |
| 10 #include "base/win_util.h" | 10 #include "base/win_util.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // The ATOM returned from creating the window. | 89 // The ATOM returned from creating the window. |
| 90 ATOM atom; | 90 ATOM atom; |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 ClassRegistrar() : registered_count_(0) { } | 93 ClassRegistrar() : registered_count_(0) { } |
| 94 friend struct DefaultSingletonTraits<ClassRegistrar>; | 94 friend struct DefaultSingletonTraits<ClassRegistrar>; |
| 95 | 95 |
| 96 typedef std::list<RegisteredClass> RegisteredClasses; | 96 typedef std::list<RegisteredClass> RegisteredClasses; |
| 97 RegisteredClasses registered_classes_; | 97 RegisteredClasses registered_classes_; |
| 98 | 98 |
| 99 // Counter of how many classes have been registered so far. | 99 // Counter of how many classes have ben registered so far. |
| 100 int registered_count_; | 100 int registered_count_; |
| 101 | 101 |
| 102 DISALLOW_COPY_AND_ASSIGN(ClassRegistrar); | 102 DISALLOW_COPY_AND_ASSIGN(ClassRegistrar); |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 /////////////////////////////////////////////////////////////////////////////// | 105 /////////////////////////////////////////////////////////////////////////////// |
| 106 // WindowImpl, public | 106 // WindowImpl, public |
| 107 | 107 |
| 108 WindowImpl::WindowImpl() | 108 WindowImpl::WindowImpl() |
| 109 : window_style_(0), | 109 : window_style_(0), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 129 int x, y, width, height; | 129 int x, y, width, height; |
| 130 if (bounds.IsEmpty()) { | 130 if (bounds.IsEmpty()) { |
| 131 x = y = width = height = CW_USEDEFAULT; | 131 x = y = width = height = CW_USEDEFAULT; |
| 132 } else { | 132 } else { |
| 133 x = bounds.x(); | 133 x = bounds.x(); |
| 134 y = bounds.y(); | 134 y = bounds.y(); |
| 135 width = bounds.width(); | 135 width = bounds.width(); |
| 136 height = bounds.height(); | 136 height = bounds.height(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 hwnd_ = CreateWindowEx(window_ex_style_, GetWindowClassName().c_str(), NULL, | 139 hwnd_ = CreateWindowEx(window_ex_style_, GetWindowClassName().c_str(), L"", |
| 140 window_style_, x, y, width, height, | 140 window_style_, x, y, width, height, |
| 141 parent, NULL, NULL, this); | 141 parent, NULL, NULL, this); |
| 142 DCHECK(hwnd_); | 142 DCHECK(hwnd_); |
| 143 | 143 |
| 144 // The window procedure should have set the data for us. | 144 // The window procedure should have set the data for us. |
| 145 DCHECK(win_util::GetWindowUserData(hwnd_) == this); | 145 DCHECK(win_util::GetWindowUserData(hwnd_) == this); |
| 146 } | 146 } |
| 147 | 147 |
| 148 gfx::NativeView WindowImpl::GetNativeView() const { |
| 149 return hwnd_; |
| 150 } |
| 151 |
| 148 HICON WindowImpl::GetDefaultWindowIcon() const { | 152 HICON WindowImpl::GetDefaultWindowIcon() const { |
| 149 return NULL; | 153 return NULL; |
| 150 } | 154 } |
| 151 | 155 |
| 156 BOOL WindowImpl::DestroyWindow() { |
| 157 DCHECK(::IsWindow(GetNativeView())); |
| 158 return ::DestroyWindow(GetNativeView()); |
| 159 } |
| 160 |
| 152 LRESULT WindowImpl::OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) { | 161 LRESULT WindowImpl::OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) { |
| 162 HWND window = GetNativeView(); |
| 153 LRESULT result = 0; | 163 LRESULT result = 0; |
| 154 | 164 |
| 155 // Handle the message if it's in our message map; otherwise, let the system | 165 // Handle the message if it's in our message map; otherwise, let the system |
| 156 // handle it. | 166 // handle it. |
| 157 if (!ProcessWindowMessage(hwnd_, message, w_param, l_param, result)) | 167 if (!ProcessWindowMessage(window, message, w_param, l_param, result)) |
| 158 result = DefWindowProc(hwnd_, message, w_param, l_param); | 168 result = DefWindowProc(window, message, w_param, l_param); |
| 159 | 169 |
| 160 return result; | 170 return result; |
| 161 } | 171 } |
| 162 | 172 |
| 163 // static | 173 // static |
| 164 LRESULT CALLBACK WindowImpl::WndProc(HWND hwnd, | 174 LRESULT CALLBACK WindowImpl::WndProc(HWND hwnd, |
| 165 UINT message, | 175 UINT message, |
| 166 WPARAM w_param, | 176 WPARAM w_param, |
| 167 LPARAM l_param) { | 177 LPARAM l_param) { |
| 168 if (message == WM_NCCREATE) { | 178 if (message == WM_NCCREATE) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 class_ex.hIconSm = class_ex.hIcon; | 214 class_ex.hIconSm = class_ex.hIcon; |
| 205 ATOM atom = RegisterClassEx(&class_ex); | 215 ATOM atom = RegisterClassEx(&class_ex); |
| 206 DCHECK(atom); | 216 DCHECK(atom); |
| 207 | 217 |
| 208 Singleton<ClassRegistrar>()->RegisterClass(class_info, name, atom); | 218 Singleton<ClassRegistrar>()->RegisterClass(class_info, name, atom); |
| 209 | 219 |
| 210 return name; | 220 return name; |
| 211 } | 221 } |
| 212 | 222 |
| 213 } // namespace base | 223 } // namespace base |
| OLD | NEW |