| 211 | } |
| 212 | |
| 213 | LRESULT CALLBACK WindowSystem::WindowProcedure(HWND handle, UINT message, |
| 214 | WPARAM wParam, LPARAM lParam) |
| 215 | { |
| 216 | auto iter = TheWindowSystem.mHandleMap.find(handle); |
| 217 | if (iter == TheWindowSystem.mHandleMap.end()) |
| 218 | { |
| 219 | return DefWindowProc(handle, message, wParam, lParam); |
| 220 | } |
| 221 | |
| 222 | Window& window = *iter->second; |
| 223 | |
| 224 | LRESULT lResult = 0; |
| 225 | if (window.OnWindowsMessage(handle, message, wParam, lParam, lResult)) |
| 226 | { |
| 227 | // The 'window' does not want the message interpreted by the switch |
| 228 | // statement below. |
| 229 | return lResult; |
| 230 | } |
| 231 | |
| 232 | switch (message) |
| 233 | { |
| 234 | case WM_PAINT: |
| 235 | { |
| 236 | PAINTSTRUCT ps; |
| 237 | BeginPaint(handle, &ps); |
| 238 | window.OnDisplay(); |
| 239 | EndPaint(handle, &ps); |
| 240 | return 0; |
| 241 | } |
| 242 | case WM_ERASEBKGND: |
| 243 | { |
| 244 | // This tells Windows not to erase the background (and that the |
| 245 | // application is doing so). |
| 246 | return 1; |
| 247 | } |
| 248 | case WM_MOVE: |
| 249 | { |
| 250 | // Get the origin of the moved window. The y-value for window |
| 251 | // moves is left-handed. |
| 252 | int32_t x, y; |
| 253 | Extract(lParam, x, y); |
| 254 | window.OnMove(x, y); |
| 255 | return 0; |
| 256 | } |
| 257 | case WM_SIZE: |
| 258 | { |
| 259 | // Get the new size of the window. |
| 260 | int32_t xSize, ySize; |
| 261 | Extract(lParam, xSize, ySize); |
| 262 | |
| 263 | if (wParam == SIZE_MINIMIZED) |
| 264 | { |
| 265 | // assert: xSize == 0 and ySize == 0 |
| 266 | window.OnMinimize(); |
| 267 | } |
| 268 | else if (wParam == SIZE_MAXIMIZED) |
| 269 | { |
| 270 | window.OnMaximize(); |
nothing calls this directly
no test coverage detected