30 wc.hInstance =
nullptr;
31 wc.hIcon = LoadIcon(0, IDI_APPLICATION);
32 wc.hCursor = LoadCursor(0, IDC_ARROW);
33 wc.hbrBackground =
static_cast<HBRUSH
>(GetStockObject(WHITE_BRUSH));
35 wc.lpszMenuName =
nullptr;
36 mAtom = RegisterClass(&wc);
40 DWORD style, RECT& windowRectangle)
42 windowRectangle.left = 0;
43 windowRectangle.top = 0;
44 windowRectangle.right =
static_cast<LONG
>(xClientSize) - 1;
45 windowRectangle.bottom =
static_cast<LONG
>(yClientSize) - 1;
46 return AdjustWindowRect(&windowRectangle, style, FALSE) != FALSE;
54 style = WS_OVERLAPPEDWINDOW;
60 style = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
78 int adjustedXSize = (
int)rectangle.right - (
int)rectangle.left + 1;
79 int adjustedYSize = (
int)rectangle.bottom - (
int)rectangle.top + 1;
82 parameters.
yOrigin, adjustedXSize, adjustedYSize,
nullptr,
83 nullptr,
nullptr,
nullptr);
90 GetClientRect(parameters.
handle, &rectangle);
91 int clientXSize = (
int)rectangle.right - (
int)rectangle.left;
92 int clientYSize = (
int)rectangle.bottom - (
int)rectangle.top;
93 if (clientXSize != parameters.
xSize 94 || clientYSize != parameters.
ySize)
96 DestroyWindow(parameters.
handle);
97 adjustedXSize += parameters.
xSize - clientXSize;
98 adjustedYSize += parameters.
ySize - clientYSize;
101 parameters.
yOrigin, adjustedXSize, adjustedYSize,
103 GetClientRect(parameters.
handle, &rectangle);
111 LogError(
"AdjustWindowRect failed.");
112 parameters.
handle =
nullptr;
113 parameters.
engine =
nullptr;
120 x =
static_cast<int>(
static_cast<short>(lParam & 0xFFFF));
121 y =
static_cast<int>(
static_cast<short>((lParam & 0xFFFF0000) >> 16));
126 x =
static_cast<int>(
static_cast<short>(wParam & 0xFFFF));
127 y =
static_cast<int>(
static_cast<short>((wParam & 0xFFFF0000) >> 16));
131 WPARAM wParam, LPARAM lParam)
136 return DefWindowProc(handle, message, wParam, lParam);
146 BeginPaint(handle, &ps);
148 EndPaint(handle, &ps);
172 if (wParam == SIZE_MINIMIZED)
177 else if (wParam == SIZE_MAXIMIZED)
182 else if (wParam == SIZE_RESTORED)
192 unsigned char key =
static_cast<unsigned char>(
static_cast<char>(wParam));
196 GetCursorPos(&point);
197 ScreenToClient(handle, &point);
198 int x =
static_cast<int>(point.x);
199 int y =
static_cast<int>(point.y);
207 int key =
static_cast<int>(wParam);
211 GetCursorPos(&point);
212 ScreenToClient(handle, &point);
213 int x =
static_cast<int>(point.x);
214 int y =
static_cast<int>(point.y);
222 int key =
static_cast<int>(wParam);
226 GetCursorPos(&point);
227 ScreenToClient(handle, &point);
228 int x =
static_cast<int>(point.x);
229 int y =
static_cast<int>(point.y);
237 unsigned int modifiers =
static_cast<unsigned int>(wParam);
250 unsigned int modifiers =
static_cast<unsigned int>(wParam);
263 unsigned int modifiers =
static_cast<unsigned int>(wParam);
276 unsigned int modifiers =
static_cast<unsigned int>(wParam);
289 unsigned int modifiers =
static_cast<unsigned int>(wParam);
302 unsigned int modifiers =
static_cast<unsigned int>(wParam);
315 unsigned int modifiers =
static_cast<unsigned int>(wParam);
322 if (wParam & MK_LBUTTON)
326 else if (wParam & MK_MBUTTON)
330 else if (wParam & MK_RBUTTON)
345 int modifiers, delta;
346 Extract(wParam, modifiers, delta);
350 GetCursorPos(&point);
351 ScreenToClient(handle, &point);
352 int x =
static_cast<int>(point.x);
353 int y =
static_cast<int>(point.y);
355 window.
OnMouseWheel(delta, x, y, (
unsigned int)modifiers);
361 int bar = message - WM_HSCROLL;
362 switch (LOWORD(wParam))
376 case SB_THUMBPOSITION:
395 return DefWindowProc(handle, message, wParam, lParam);
virtual void OnMaximize()
virtual void OnMove(int x, int y)
virtual bool OnMouseClick(int button, int state, int x, int y, unsigned int modifiers)
static int const MOUSE_MIDDLE
virtual void CreateEngineAndProgramFactory(MSWWindow::Parameters ¶meters)=0
int OnScrollEndTracking(int bar)
std::map< HWND, std::shared_ptr< MSWWindow > > mHandleMap
virtual bool OnKeyDown(int key, int x, int y)
int OnScrollIncrementHiRes(int bar)
static LRESULT CALLBACK WindowProcedure(HWND handle, UINT message, WPARAM wParam, LPARAM lParam)
static int const MOUSE_RIGHT
static int const MOUSE_UP
virtual ~MSWWindowSystem()
int OnScrollDecrementHiRes(int bar)
static int const MOUSE_DOWN
static int const MOUSE_NONE
virtual void OnMinimize()
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
static bool GetWindowRectangle(int xClientSize, int yClientSize, DWORD style, RECT &windowRectangle)
#define LogError(message)
static void Extract(LPARAM lParam, int &x, int &y)
int OnScrollDecrementLoRes(int bar)
int OnScrollTracking(int bar)
GLuint GLsizei const GLchar * message
static int const MOUSE_LEFT
virtual bool OnKeyUp(int key, int x, int y)
virtual bool OnMouseWheel(int delta, int x, int y, unsigned int modifiers)
int OnScrollIncrementLoRes(int bar)
void CreateFrom(MSWWindow::Parameters ¶meters)
virtual bool OnResize(int xSize, int ySize)
virtual void OnClose() override
virtual bool OnMouseMotion(int button, int x, int y, unsigned int modifiers)
wchar_t const * mWindowClassName
typedef UINT(WINAPI *PFNWGLGETGPUIDSAMDPROC)(UINT maxCount
std::shared_ptr< BaseEngine > engine
GTE_IMPEXP WindowSystem TheWindowSystem
virtual bool OnCharPress(unsigned char key, int x, int y)