LRESULT Display::ReceivedMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { // Get the window. Window *myWindow = GetWindow(hwnd); // If not polling, send to the default window proc. if(!currentEvent || !myWindow) return DefWindowProc(hwnd, msg, wParam, lParam); // Read the common data. Event *ev = currentEvent; bool &done = processedMessage; ev->window = myWindow; ev->type = Event::EVT_Unknown; // Handle the messages according to their type. switch(msg) { // Window destruction. case WM_DESTROY: { Window *window = CurrentDisplay->GetWindow(hwnd); if(window) delete window; else return DefWindowProc(hwnd, msg, wParam, lParam); } break; case WM_CLOSE: ev->type = Event::EVT_Close; done = true; break; case WM_ERASEBKGND: // Always return 1 for erase background, we want to manage // everything in the paint event return 1; break; case WM_PAINT: { // Get the update rect. RECT rect; GetUpdateRect(hwnd, &rect, false); // Set the event parameters. ev->type = Event::EVT_Expose; ev->expose.x = rect.left; ev->expose.y = rect.top; ev->expose.width = rect.right - rect.left; ev->expose.height = rect.bottom - rect.top; ev->expose.count = 0; done = true; } break; case WM_SIZE: ev->type = Event::EVT_Size; myWindow->UpdateSize(LOWORD(lParam), HIWORD(lParam)); done = true; break; case WM_MOVE: myWindow->UpdatePosition(LOWORD(lParam), HIWORD(lParam)); break; case WM_SETFOCUS: ev->type = Event::EVT_GotFocus; done = true; break; case WM_KILLFOCUS: ev->type = Event::EVT_LostFocus; done = true; break; case WM_MOUSEMOVE: { if(!myWindow->IsMouseOver()) { ev->type = Event::EVT_MouseEnter; myWindow->SetMouseOver(true); // Request mouse leave tracking. TRACKMOUSEEVENT tracking; memset(&tracking, 0, sizeof(tracking)); tracking.cbSize = sizeof(tracking); tracking.dwFlags = TME_LEAVE; tracking.hwndTrack = hwnd; tracking.dwHoverTime = HOVER_DEFAULT; TrackMouseEvent(&tracking); } else { ev->type = Event::EVT_MouseMotion; ev->motion.x = GET_X_LPARAM(lParam); ev->motion.y = GET_Y_LPARAM(lParam); ev->motion.modifiers = ReadModifiers(wParam); } done = true; } break; case WM_MOUSELEAVE: ev->type = Event::EVT_MouseLeave; myWindow->SetMouseOver(false); done = true; break; case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: case WM_MBUTTONDOWN: case WM_XBUTTONDOWN: ev->type = Event::EVT_ButtonPressed; ev->button.x = GET_X_LPARAM(lParam); ev->button.y = GET_Y_LPARAM(lParam); ev->button.modifiers = ReadModifiers(wParam); ev->button.button = ReadMouseButton(msg, wParam); done = true; return TRUE; case WM_LBUTTONUP: case WM_RBUTTONUP: case WM_MBUTTONUP: case WM_XBUTTONUP: ev->type = Event::EVT_ButtonReleased; ev->button.x = GET_X_LPARAM(lParam); ev->button.y = GET_Y_LPARAM(lParam); ev->button.modifiers = ReadModifiers(wParam); ev->button.button = ReadMouseButton(msg, wParam); done = true; break; // Some messages are required to be handled by the default window processor. default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; }
void ReadLeaders() { ReadFlags(); ReadWidth(); if (*format_ == '.') ReadPrecision(); ReadModifiers(); }