| 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 ben registered so far. | 99 // Counter of how many classes have been 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(), L"", | 139 hwnd_ = CreateWindowEx(window_ex_style_, GetWindowClassName().c_str(), NULL, |
| 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 | |
| 152 HICON WindowImpl::GetDefaultWindowIcon() const { | 148 HICON WindowImpl::GetDefaultWindowIcon() const { |
| 153 return NULL; | 149 return NULL; |
| 154 } | 150 } |
| 155 | 151 |
| 156 BOOL WindowImpl::DestroyWindow() { | |
| 157 DCHECK(::IsWindow(GetNativeView())); | |
| 158 return ::DestroyWindow(GetNativeView()); | |
| 159 } | |
| 160 | |
| 161 LRESULT WindowImpl::OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) { | 152 LRESULT WindowImpl::OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) { |
| 162 HWND window = GetNativeView(); | |
| 163 LRESULT result = 0; | 153 LRESULT result = 0; |
| 164 | 154 |
| 165 // Handle the message if it's in our message map; otherwise, let the system | 155 // Handle the message if it's in our message map; otherwise, let the system |
| 166 // handle it. | 156 // handle it. |
| 167 if (!ProcessWindowMessage(window, message, w_param, l_param, result)) | 157 if (!ProcessWindowMessage(hwnd_, message, w_param, l_param, result)) |
| 168 result = DefWindowProc(window, message, w_param, l_param); | 158 result = DefWindowProc(hwnd_, message, w_param, l_param); |
| 169 | 159 |
| 170 return result; | 160 return result; |
| 171 } | 161 } |
| 172 | 162 |
| 173 // static | 163 // static |
| 174 LRESULT CALLBACK WindowImpl::WndProc(HWND hwnd, | 164 LRESULT CALLBACK WindowImpl::WndProc(HWND hwnd, |
| 175 UINT message, | 165 UINT message, |
| 176 WPARAM w_param, | 166 WPARAM w_param, |
| 177 LPARAM l_param) { | 167 LPARAM l_param) { |
| 178 if (message == WM_NCCREATE) { | 168 if (message == WM_NCCREATE) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 class_ex.hIconSm = class_ex.hIcon; | 204 class_ex.hIconSm = class_ex.hIcon; |
| 215 ATOM atom = RegisterClassEx(&class_ex); | 205 ATOM atom = RegisterClassEx(&class_ex); |
| 216 DCHECK(atom); | 206 DCHECK(atom); |
| 217 | 207 |
| 218 Singleton<ClassRegistrar>()->RegisterClass(class_info, name, atom); | 208 Singleton<ClassRegistrar>()->RegisterClass(class_info, name, atom); |
| 219 | 209 |
| 220 return name; | 210 return name; |
| 221 } | 211 } |
| 222 | 212 |
| 223 } // namespace base | 213 } // namespace base |
| OLD | NEW |