Otclient  14/8/2020
win32window.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2020 OTClient <https://github.com/edubart/otclient>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 
23 #ifdef WIN32
24 
25 #include "win32window.h"
29 
30 #define HSB_BIT_SET(p, n) (p[(n)/8] |= (128 >>((n)%8)))
31 
33 {
34  m_window = 0;
35  m_instance = 0;
36  m_deviceContext = 0;
37  m_cursor = 0;
38  m_minimumSize = Size(600,480);
39  m_size = Size(600,480);
40  m_hidden = true;
41 
42 #ifdef OPENGL_ES
43  m_eglConfig = 0;
44  m_eglContext = 0;
45  m_eglDisplay = 0;
46  m_eglSurface = 0;
47 #else
48  m_wglContext = 0;
49 #endif
50 
51  m_keyMap[VK_ESCAPE] = Fw::KeyEscape;
52  m_keyMap[VK_TAB] = Fw::KeyTab;
53  m_keyMap[VK_RETURN] = Fw::KeyEnter;
54  m_keyMap[VK_BACK] = Fw::KeyBackspace;
55  m_keyMap[VK_SPACE] = Fw::KeySpace;
56 
57  m_keyMap[VK_PRIOR] = Fw::KeyPageUp;
58  m_keyMap[VK_NEXT] = Fw::KeyPageDown;
59  m_keyMap[VK_HOME] = Fw::KeyHome;
60  m_keyMap[VK_END] = Fw::KeyEnd;
61  m_keyMap[VK_INSERT] = Fw::KeyInsert;
62  m_keyMap[VK_DELETE] = Fw::KeyDelete;
63 
64  m_keyMap[VK_UP] = Fw::KeyUp;
65  m_keyMap[VK_DOWN] = Fw::KeyDown;
66  m_keyMap[VK_LEFT] = Fw::KeyLeft;
67  m_keyMap[VK_RIGHT] = Fw::KeyRight;
68 
69  m_keyMap[VK_NUMLOCK] = Fw::KeyNumLock;
70  m_keyMap[VK_SCROLL] = Fw::KeyScrollLock;
71  m_keyMap[VK_CAPITAL] = Fw::KeyCapsLock;
72  m_keyMap[VK_SNAPSHOT] = Fw::KeyPrintScreen;
73  m_keyMap[VK_PAUSE] = Fw::KeyPause;
74 
75  m_keyMap[VK_CONTROL] = Fw::KeyCtrl;
76  m_keyMap[VK_LCONTROL] = Fw::KeyCtrl;
77  m_keyMap[VK_RCONTROL] = Fw::KeyCtrl;
78  m_keyMap[VK_SHIFT] = Fw::KeyShift;
79  m_keyMap[VK_LSHIFT] = Fw::KeyShift;
80  m_keyMap[VK_RSHIFT] = Fw::KeyShift;
81  m_keyMap[VK_MENU] = Fw::KeyAlt;
82  m_keyMap[VK_LMENU] = Fw::KeyAlt;
83  m_keyMap[VK_RMENU] = Fw::KeyAlt;
84  m_keyMap[VK_LWIN] = Fw::KeyMeta;
85  m_keyMap[VK_RWIN] = Fw::KeyMeta;
86  m_keyMap[VK_APPS] = Fw::KeyMenu;
87 
88  // ascii characters
89  /*
90  m_keyMap['!'] = Fw::KeyExclamation;
91  m_keyMap['"'] = Fw::KeyQuote;
92  m_keyMap['#'] = Fw::KeyNumberSign;
93  m_keyMap['$'] = Fw::KeyDollar;
94  m_keyMap['%'] = Fw::KeyPercent;
95  m_keyMap['$'] = Fw::KeyAmpersand;
96  m_keyMap['\''] = Fw::KeyApostrophe;
97  m_keyMap['('] = Fw::KeyLeftParen;
98  m_keyMap[')'] = Fw::KeyRightParen;
99  m_keyMap['*'] = Fw::KeyAsterisk;
100  m_keyMap['+'] = Fw::KeyPlus;
101  m_keyMap['.'] = Fw::KeyComma;
102  m_keyMap['-'] = Fw::KeyMinus;
103  m_keyMap['.'] = Fw::KeyPeriod;
104  m_keyMap['/'] = Fw::KeySlash;
105  */
106 
107  m_keyMap['0'] = Fw::Key0;
108  m_keyMap['1'] = Fw::Key1;
109  m_keyMap['2'] = Fw::Key2;
110  m_keyMap['3'] = Fw::Key3;
111  m_keyMap['4'] = Fw::Key4;
112  m_keyMap['5'] = Fw::Key5;
113  m_keyMap['6'] = Fw::Key6;
114  m_keyMap['7'] = Fw::Key7;
115  m_keyMap['8'] = Fw::Key8;
116  m_keyMap['9'] = Fw::Key9;
117 
118  /*
119  m_keyMap[':'] = Fw::KeyColon;
120  m_keyMap[';'] = Fw::KeySemicolon;
121  m_keyMap['<'] = Fw::KeyLess;
122  m_keyMap['='] = Fw::KeyEqual;
123  m_keyMap['>'] = Fw::KeyGreater;
124  m_keyMap['?'] = Fw::KeyQuestion;
125  m_keyMap['@'] = Fw::KeyAtSign;
126  */
127 
128  m_keyMap['A'] = Fw::KeyA;
129  m_keyMap['B'] = Fw::KeyB;
130  m_keyMap['C'] = Fw::KeyC;
131  m_keyMap['D'] = Fw::KeyD;
132  m_keyMap['E'] = Fw::KeyE;
133  m_keyMap['F'] = Fw::KeyF;
134  m_keyMap['G'] = Fw::KeyG;
135  m_keyMap['H'] = Fw::KeyH;
136  m_keyMap['I'] = Fw::KeyI;
137  m_keyMap['J'] = Fw::KeyJ;
138  m_keyMap['K'] = Fw::KeyK;
139  m_keyMap['L'] = Fw::KeyL;
140  m_keyMap['M'] = Fw::KeyM;
141  m_keyMap['N'] = Fw::KeyN;
142  m_keyMap['O'] = Fw::KeyO;
143  m_keyMap['P'] = Fw::KeyP;
144  m_keyMap['Q'] = Fw::KeyQ;
145  m_keyMap['R'] = Fw::KeyR;
146  m_keyMap['S'] = Fw::KeyS;
147  m_keyMap['T'] = Fw::KeyT;
148  m_keyMap['U'] = Fw::KeyU;
149  m_keyMap['V'] = Fw::KeyV;
150  m_keyMap['W'] = Fw::KeyW;
151  m_keyMap['X'] = Fw::KeyX;
152  m_keyMap['Y'] = Fw::KeyY;
153  m_keyMap['Z'] = Fw::KeyZ;
154 
155  /*
156  m_keyMap['['] = Fw::KeyLeftBracket;
157  m_keyMap['\\'] = Fw::KeyBackslash;
158  m_keyMap[']'] = Fw::KeyRightBracket;
159  m_keyMap['^'] = Fw::KeyCaret;
160  m_keyMap['_'] = Fw::KeyUnderscore;
161  m_keyMap['`'] = Fw::KeyGrave;
162  m_keyMap['{'] = Fw::KeyLeftCurly;
163  m_keyMap['|'] = Fw::KeyBar;
164  m_keyMap['}'] = Fw::KeyRightCurly;
165  m_keyMap['~'] = Fw::KeyTilde;
166  */
167 
168  // keypad
169  /*
170  m_keyMap[VK_ADD] = Fw::KeyPlus;
171  m_keyMap[VK_SUBTRACT] = Fw::KeyMinus;
172  m_keyMap[VK_DECIMAL] = Fw::KeyPeriod;
173  m_keyMap[VK_DIVIDE] = Fw::KeySlash;
174  m_keyMap[VK_MULTIPLY] = Fw::KeyAsterisk;
175  */
176 
177  m_keyMap[VK_OEM_1] = Fw::KeySemicolon;
178  m_keyMap[VK_OEM_2] = Fw::KeySlash;
179  m_keyMap[VK_OEM_3] = Fw::KeyGrave;
180  m_keyMap[VK_OEM_4] = Fw::KeyLeftBracket;
181  m_keyMap[VK_OEM_5] = Fw::KeyBackslash;
182  m_keyMap[VK_OEM_6] = Fw::KeyRightBracket;
183  m_keyMap[VK_OEM_7] = Fw::KeyApostrophe;
184  m_keyMap[VK_OEM_MINUS] = Fw::KeyMinus;
185  m_keyMap[VK_OEM_PLUS] = Fw::KeyEqual;
186  m_keyMap[VK_OEM_COMMA] = Fw::KeyComma;
187  m_keyMap[VK_OEM_PERIOD] = Fw::KeyPeriod;
188 
189  m_keyMap[VK_F1] = Fw::KeyF1;
190  m_keyMap[VK_F2] = Fw::KeyF2;
191  m_keyMap[VK_F3] = Fw::KeyF3;
192  m_keyMap[VK_F4] = Fw::KeyF4;
193  m_keyMap[VK_F5] = Fw::KeyF5;
194  m_keyMap[VK_F6] = Fw::KeyF6;
195  m_keyMap[VK_F7] = Fw::KeyF7;
196  m_keyMap[VK_F8] = Fw::KeyF8;
197  m_keyMap[VK_F9] = Fw::KeyF9;
198  m_keyMap[VK_F10] = Fw::KeyF10;
199  m_keyMap[VK_F11] = Fw::KeyF11;
200  m_keyMap[VK_F12] = Fw::KeyF12;
201 }
202 
203 void WIN32Window::init()
204 {
205  m_instance = GetModuleHandle(NULL);
206 
207 #ifdef DIRECTX
208  m_d3d = Direct3DCreate9(D3D_SDK_VERSION); // create the Direct3D interface
209 
210  D3DPRESENT_PARAMETERS d3dpp; // create a struct to hold various device information
211 
212  ZeroMemory(&d3dpp, sizeof(d3dpp)); // clear out the struct for use
213  d3dpp.Windowed = TRUE; // program windowed, not fullscreen
214  d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // discard old frames
215  d3dpp.hDeviceWindow = m_window; // set the window to be used by Direct3D
216 
217  // create a device class using this information and information from the d3dpp stuct
218  m_d3d->CreateDevice(D3DADAPTER_DEFAULT,
219  D3DDEVTYPE_HAL,
220  m_window,
221  D3DCREATE_SOFTWARE_VERTEXPROCESSING,
222  &d3dpp,
223  &m_d3ddev);
224 
225 #endif
226 
227  internalCreateWindow();
228  internalCreateGLContext();
229  internalRestoreGLContext();
230 }
231 
233 {
234  SetCursor(NULL);
235  if(m_defaultCursor) {
236  DestroyCursor(m_defaultCursor);
237  m_defaultCursor = NULL;
238  }
239 
240  for(HCURSOR& cursor : m_cursors)
241  DestroyCursor(cursor);
242  m_cursors.clear();
243 
244  internalDestroyGLContext();
245 
246  if(m_deviceContext) {
247  if(!ReleaseDC(m_window, m_deviceContext))
248  g_logger.error("Release device context failed.");
249  m_deviceContext = NULL;
250  }
251 
252  if(m_window) {
253  if(!DestroyWindow(m_window))
254  g_logger.error("ERROR: Destroy window failed.");
255  m_window = NULL;
256  }
257 
258  if(m_instance) {
259  if(!UnregisterClassA(g_app.getCompactName().c_str(), m_instance))
260  g_logger.error("UnregisterClassA failed");
261  m_instance = NULL;
262  }
263 }
264 
265 struct WindowProcProxy {
266  static LRESULT CALLBACK call(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
268  return window->windowProc(hWnd, uMsg, wParam, lParam);
269  }
270 };
271 
272 void WIN32Window::internalCreateWindow()
273 {
274  m_defaultCursor = LoadCursor(NULL, IDC_ARROW);
275  WNDCLASSA wc;
276  wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
277  wc.lpfnWndProc = (WNDPROC)WindowProcProxy::call;
278  wc.cbClsExtra = 0;
279  wc.cbWndExtra = 0;
280  wc.hInstance = m_instance;
281  wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
282  wc.hCursor = m_defaultCursor;
283  wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
284  wc.lpszMenuName = NULL;
285  wc.lpszClassName = g_app.getCompactName().c_str();
286 
287  if(!RegisterClassA(&wc))
288  g_logger.fatal("Failed to register the window class.");
289  DWORD dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
290  DWORD dwStyle = WS_OVERLAPPEDWINDOW;
291 
292  // initialize in the center of the screen
293  m_position = ((getDisplaySize() - m_size) / 2).toPoint();
294 
295  Rect screenRect = adjustWindowRect(Rect(m_position, m_size));
296 
298  m_window = CreateWindowExA(dwExStyle,
299  g_app.getCompactName().c_str(),
300  NULL,
301  dwStyle,
302  screenRect.left(),
303  screenRect.top(),
304  screenRect.width(),
305  screenRect.height(),
306  NULL,
307  NULL,
308  m_instance,
309  NULL);
310 
311  if(!m_window)
312  g_logger.fatal("Unable to create window");
313 
314  ShowWindow(m_window, SW_HIDE);
315 
316  m_deviceContext = GetDC(m_window);
317  if(!m_deviceContext)
318  g_logger.fatal("GetDC failed");
319 }
320 
321 void WIN32Window::internalCreateGLContext()
322 {
323 #ifdef OPENGL_ES
324  m_eglDisplay = eglGetDisplay(m_deviceContext);
325  if(m_eglDisplay == EGL_NO_DISPLAY)
326  g_logger.fatal("EGL not supported");
327 
328  if(!eglInitialize(m_eglDisplay, NULL, NULL))
329  g_logger.fatal("Unable to initialize EGL");
330 
331  static int configList[] = {
332 #if OPENGL_ES==2
333  EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
334 #else
335  EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
336 #endif
337  EGL_RED_SIZE, 4,
338  EGL_GREEN_SIZE, 4,
339  EGL_BLUE_SIZE, 4,
340  EGL_ALPHA_SIZE, 4,
341  EGL_NONE
342  };
343 
344  EGLint numConfig;
345 
346  if(!eglGetConfigs(m_eglDisplay, NULL, 0, &numConfig))
347  g_logger.fatal("No valid GL configurations");
348 
349  if(!eglChooseConfig(m_eglDisplay, configList, &m_eglConfig, 1, &numConfig))
350  g_logger.fatal("Failed to choose EGL config");
351 
352  if(numConfig != 1)
353  g_logger.warning("Didn't got the exact EGL config");
354 
355  EGLint contextAtrrList[] = {
356 #if OPENGL_ES==2
357  EGL_CONTEXT_CLIENT_VERSION, 2,
358 #else
359  EGL_CONTEXT_CLIENT_VERSION, 1,
360 #endif
361  EGL_NONE
362  };
363 
364  m_eglSurface = eglCreateWindowSurface(m_eglDisplay, m_eglConfig, m_window, NULL);
365  if(m_eglSurface == EGL_NO_SURFACE)
366  g_logger.fatal(stdext::format("Unable to create EGL surface: %s", eglGetError()));
367 
368  m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, EGL_NO_CONTEXT, contextAtrrList);
369  if(m_eglContext == EGL_NO_CONTEXT )
370  g_logger.fatal(stdext::format("Unable to create EGL context: %s", eglGetError()));
371 
372 #else
373  uint pixelFormat;
374  static PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR),
375  1,
376  PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
377  PFD_TYPE_RGBA,
378  32, // Select Our Color Depth
379  8, 0, 8, 0, 8, 0, // Color Bits Ignored
380  8, // Alpha Buffer Bits
381  0, // Shift Bit Ignored
382  0, // No Accumulation Buffer
383  0, 0, 0, 0, // Accumulation Bits Ignored
384  0, // Z-Buffer (Depth Buffer)
385  0, // No Stencil Buffer
386  0, // No Auxiliary Buffer
387  PFD_MAIN_PLANE, // Main Drawing Layer
388  0, // Reserved
389  0, 0, 0 }; // Layer Masks Ignored
390 
391  pixelFormat = ChoosePixelFormat(m_deviceContext, &pfd);
392  if(!pixelFormat)
393  g_logger.fatal("Could not find a suitable pixel format");
394 
395  if(!SetPixelFormat(m_deviceContext, pixelFormat, &pfd))
396  g_logger.fatal("Could not set the pixel format");
397 
398  if(!(m_wglContext = wglCreateContext(m_deviceContext)))
399  g_logger.fatal("Unable to create GL context");
400 #endif
401 }
402 
403 void WIN32Window::internalDestroyGLContext()
404 {
405 #ifdef OPENGL_ES
406  if(m_eglDisplay) {
407  if(m_eglContext) {
408  eglDestroyContext(m_eglDisplay, m_eglContext);
409  m_eglContext = 0;
410  }
411  if(m_eglSurface) {
412  eglDestroySurface(m_eglDisplay, m_eglSurface);
413  m_eglSurface = 0;
414  }
415  eglTerminate(m_eglDisplay);
416  m_eglDisplay = 0;
417  }
418 #else
419  if(m_wglContext) {
420  if(!wglMakeCurrent(NULL, NULL))
421  g_logger.error("Release of dc and rc failed.");
422  if(!wglDeleteContext(m_wglContext))
423  g_logger.error("Release rendering context failed.");
424  m_wglContext = NULL;
425  }
426 #endif
427 }
428 
429 void WIN32Window::internalRestoreGLContext()
430 {
431 #ifdef OPENGL_ES
432  if(!eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext))
433  g_logger.fatal("Unable to make current EGL context");
434 #else
435  if(!wglMakeCurrent(m_deviceContext, m_wglContext))
436  g_logger.fatal("Unable to make current WGL context");
437 #endif
438 }
439 
440 bool WIN32Window::isExtensionSupported(const char *ext)
441 {
442 #ifdef OPENGL_ES
443  //TODO
444  return false;
445 #else
446  typedef const char* (WINAPI * wglGetExtensionsStringProc)();
447  wglGetExtensionsStringProc wglGetExtensionsString = (wglGetExtensionsStringProc)getExtensionProcAddress("wglGetExtensionsStringEXT");
448  if(!wglGetExtensionsString)
449  return false;
450 
451  const char *exts = wglGetExtensionsString();
452  if(exts && strstr(exts, ext))
453  return true;
454 
455  return false;
456 #endif
457 }
458 
459 void *WIN32Window::getExtensionProcAddress(const char *ext)
460 {
461 #ifdef OPENGL_ES
462  //TODO
463  return NULL;
464 #else
465  return (void*)wglGetProcAddress(ext);
466 #endif
467 }
468 
469 void WIN32Window::move(const Point& pos)
470 {
471  Rect clientRect(pos, getClientRect().size());
472  Rect windowRect = adjustWindowRect(clientRect);
473  MoveWindow(m_window, windowRect.x(), windowRect.y(), windowRect.width(), windowRect.height(), TRUE);
474  if(m_hidden)
475  ShowWindow(m_window, SW_HIDE);
476 }
477 
478 void WIN32Window::resize(const Size& size)
479 {
480  if(size.width() < m_minimumSize.width() || size.height() < m_minimumSize.height())
481  return;
482  Rect clientRect(getClientRect().topLeft(), size);
483  Rect windowRect = adjustWindowRect(clientRect);
484  MoveWindow(m_window, windowRect.x(), windowRect.y(), windowRect.width(), windowRect.height(), TRUE);
485  if(m_hidden)
486  ShowWindow(m_window, SW_HIDE);
487 }
488 
489 void WIN32Window::show()
490 {
491  m_hidden = false;
492  if(m_maximized)
493  ShowWindow(m_window, SW_MAXIMIZE);
494  else
495  ShowWindow(m_window, SW_SHOW);
496 }
497 
498 void WIN32Window::hide()
499 {
500  m_hidden = true;
501  ShowWindow(m_window, SW_HIDE);
502 }
503 
505 {
506  if(!m_hidden)
507  ShowWindow(m_window, SW_MAXIMIZE);
508  else
509  m_maximized = true;
510 }
511 
512 void WIN32Window::poll()
513 {
514  fireKeysPress();
515 
516  MSG msg;
517  while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
518  TranslateMessage(&msg);
519  DispatchMessage(&msg);
520  }
521 
523 }
524 
525 Fw::Key WIN32Window::retranslateVirtualKey(WPARAM wParam, LPARAM lParam)
526 {
527  // ignore numpad keys when numlock is on
528  if((wParam >= VK_NUMPAD0 && wParam <= VK_NUMPAD9) || wParam == VK_SEPARATOR)
529  return Fw::KeyUnknown;
530 
531  // lParam will have this state when receiving insert,end,down,etc presses from numpad
532  if(!(((HIWORD(lParam) >> 8) & 0xFF) & 1)) {
533  bool numlockOn = GetKeyState(VK_NUMLOCK);
534  // retranslate numpad keys
535  switch(wParam) {
536  case VK_INSERT:
537  return numlockOn ? Fw::KeyUnknown : Fw::KeyNumpad0;
538  case VK_END:
539  return numlockOn ? Fw::KeyUnknown : Fw::KeyNumpad1;
540  case VK_DOWN:
541  return numlockOn ? Fw::KeyUnknown : Fw::KeyNumpad2;
542  case VK_NEXT:
543  return numlockOn ? Fw::KeyUnknown : Fw::KeyNumpad3;
544  case VK_LEFT:
545  return numlockOn ? Fw::KeyUnknown : Fw::KeyNumpad4;
546  case VK_CLEAR:
547  return numlockOn ? Fw::KeyUnknown : Fw::KeyNumpad5;
548  case VK_RIGHT:
549  return numlockOn ? Fw::KeyUnknown : Fw::KeyNumpad6;
550  case VK_HOME:
551  return numlockOn ? Fw::KeyUnknown : Fw::KeyNumpad7;
552  case VK_UP:
553  return numlockOn ? Fw::KeyUnknown : Fw::KeyNumpad8;
554  case VK_PRIOR:
555  return numlockOn ? Fw::KeyUnknown : Fw::KeyNumpad9;
556  }
557  }
558 
559  Fw::Key key = Fw::KeyUnknown;
560  if(m_keyMap.find(wParam) != m_keyMap.end())
561  key = m_keyMap[wParam];
562 
563  // actually ignore alt/ctrl/shift keys, they is states are already stored in m_inputEvent.keyboardModifiers
564  if(key == Fw::KeyAlt || key == Fw::KeyCtrl || key == Fw::KeyShift)
565  key = Fw::KeyUnknown;
566 
567  return key;
568 }
569 
570 #define IsKeyDown(a) (GetKeyState(a) & 0x80)
571 
572 LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
573 {
575  if(IsKeyDown(VK_CONTROL))
577  if(IsKeyDown(VK_SHIFT))
579  if(IsKeyDown(VK_MENU))
581 
582  switch(uMsg)
583  {
584  case WM_SETCURSOR: {
585  if(m_cursor)
586  SetCursor(m_cursor);
587  else
588  return DefWindowProc(hWnd, uMsg, wParam, lParam);
589  break;
590  }
591  case WM_ACTIVATE: {
592  m_focused = !(wParam == WA_INACTIVE);
593  releaseAllKeys();
594  break;
595  }
596  case WM_SETFOCUS:
597  case WM_KILLFOCUS: {
598  releaseAllKeys();
599  break;
600  }
601  case WM_CHAR: {
602  if(wParam >= 32 && wParam <= 255) {
604  m_inputEvent.keyText = wParam;
605  if(m_onInputEvent)
607  }
608  break;
609  }
610  case WM_CLOSE: {
611  m_onClose();
612  break;
613  }
614  case WM_KEYDOWN: {
615  processKeyDown(retranslateVirtualKey(wParam, lParam));
616  break;
617  }
618  case WM_KEYUP: {
619  processKeyUp(retranslateVirtualKey(wParam, lParam));
620  break;
621  }
622  case WM_SYSKEYUP: {
623  processKeyUp(retranslateVirtualKey(wParam, lParam));
624  break;
625  }
626  case WM_SYSKEYDOWN: {
628  return DefWindowProc(hWnd, uMsg, wParam, lParam);
629 
630  processKeyDown(retranslateVirtualKey(wParam, lParam));
631  break;
632  }
633  case WM_LBUTTONDOWN: {
634  SetCapture(m_window);
638  if(m_onInputEvent)
640  break;
641  }
642  case WM_LBUTTONUP: {
643  SetCapture(NULL);
647  if(m_onInputEvent)
649  break;
650  }
651  case WM_MBUTTONDOWN: {
652  SetCapture(m_window);
656  if(m_onInputEvent)
658  break;
659  }
660  case WM_MBUTTONUP: {
661  SetCapture(NULL);
665  if(m_onInputEvent)
667  break;
668  }
669  case WM_RBUTTONDOWN: {
670  SetCapture(m_window);
674  if(m_onInputEvent)
676  break;
677  }
678  case WM_RBUTTONUP: {
679  SetCapture(NULL);
683  if(m_onInputEvent)
685  break;
686  }
687  case WM_MOUSEMOVE: {
689 
690  Point newMousePos(LOWORD(lParam), HIWORD(lParam));
691  if(newMousePos.x >= 32767)
692  newMousePos.x = 0;
693  else
694  newMousePos.x = std::min<int32>(newMousePos.x, m_size.width());
695 
696  if(newMousePos.y >= 32767)
697  newMousePos.y = 0;
698  else
699  newMousePos.y = std::min<int32>(newMousePos.y, m_size.height());
700 
702  m_inputEvent.mousePos = newMousePos;
703  if(m_onInputEvent)
705  break;
706  }
707  case WM_MOUSEWHEEL: {
710  m_inputEvent.wheelDirection = ((short)HIWORD(wParam)) > 0 ? Fw::MouseWheelUp : Fw::MouseWheelDown;
711  if(m_onInputEvent)
713  break;
714  }
715  case WM_MOVE: {
716  m_position.x = (short)LOWORD(lParam);
717  m_position.y = (short)HIWORD(lParam);
718  break;
719  }
720  case WM_GETMINMAXINFO: {
721  LPMINMAXINFO pMMI = (LPMINMAXINFO)lParam;
722  Rect adjustedRect = adjustWindowRect(Rect(0, 0, m_minimumSize));
723  pMMI->ptMinTrackSize.x = adjustedRect.width();
724  pMMI->ptMinTrackSize.y = adjustedRect.height();
725  break;
726  }
727  case WM_SIZE: {
728  bool forceResize = false;
729  switch(wParam) {
730  case SIZE_MAXIMIZED:
731  m_maximized = true;
732  m_visible = true;
733  forceResize = true;
734  break;
735  case SIZE_RESTORED:
736  m_maximized = false;
737  m_visible = true;
738  forceResize = true;
739  break;
740  case SIZE_MINIMIZED:
741  m_visible = false;
742  break;
743  }
744 
745  if(m_visible && m_deviceContext)
746  internalRestoreGLContext();
747 
748  Size size = Size(LOWORD(lParam), HIWORD(lParam));
749  size.setWidth(std::max<int32>(std::min<int32>(size.width(), 7680), 32));
750  size.setHeight(std::max<int32>(std::min<int32>(size.height(), 4320), 32));
751 
752  if(m_visible && (forceResize || m_size != size)) {
753  m_size = size;
755  }
756 
757  break;
758  }
759  default:
760  return DefWindowProc(hWnd, uMsg, wParam, lParam);
761  }
762 
763  return 0;
764 }
765 
767 {
768 #ifdef OPENGL_ES
769  eglSwapBuffers(m_eglDisplay, m_eglSurface);
770 #else
771  SwapBuffers(m_deviceContext);
772 #endif
773 }
774 
776 {
777  ShowCursor(true);
778 }
779 
781 {
782  ShowCursor(false);
783 }
784 
785 void WIN32Window::displayFatalError(const std::string& message)
786 {
787  MessageBoxW(m_window, stdext::latin1_to_utf16(message).c_str(), L"FATAL ERROR", MB_OK | MB_ICONERROR);
788 }
789 
790 int WIN32Window::internalLoadMouseCursor(const ImagePtr& image, const Point& hotSpot)
791 {
792  int width = image->getWidth();
793  int height = image->getHeight();
794  int numbits = width * height;
795  int numbytes = (width * height)/8;
796 
797  std::vector<uchar> andMask(numbytes, 0);
798  std::vector<uchar> xorMask(numbytes, 0);
799 
800  for(int i=0;i<numbits;++i) {
801  uint32 rgba = stdext::readULE32(image->getPixelData() + i*4);
802  if(rgba == 0xffffffff) { //white
803  HSB_BIT_SET(xorMask, i);
804  } else if(rgba == 0x00000000) { //alpha
805  HSB_BIT_SET(andMask, i);
806  } // otherwise 0xff000000 => black
807  }
808 
809  HCURSOR cursor = CreateCursor(m_instance, hotSpot.x, hotSpot.y, width, height, &andMask[0], &xorMask[0]);
810  m_cursors.push_back(cursor);
811  return m_cursors.size()-1;
812 }
813 
814 void WIN32Window::setMouseCursor(int cursorId)
815 {
816  if(cursorId >= (int)m_cursors.size() || cursorId < 0)
817  return;
818 
819  m_cursor = m_cursors[cursorId];
820  SetCursor(m_cursor);
821  ShowCursor(true);
822 }
823 
825 {
826  if(m_cursor) {
827  m_cursor = NULL;
828  SetCursor(m_defaultCursor);
829  ShowCursor(true);
830  }
831 }
832 
833 void WIN32Window::setTitle(const std::string& title)
834 {
835  SetWindowTextW(m_window, stdext::latin1_to_utf16(title).c_str());
836 }
837 
838 void WIN32Window::setMinimumSize(const Size& minimumSize)
839 {
840  m_minimumSize = minimumSize;
841 }
842 
843 void WIN32Window::setFullscreen(bool fullscreen)
844 {
845  if(m_fullscreen == fullscreen)
846  return;
847 
848  m_fullscreen = fullscreen;
849 
850  DWORD dwStyle = GetWindowLong(m_window, GWL_STYLE);
851  static WINDOWPLACEMENT wpPrev;
852  wpPrev.length = sizeof(wpPrev);
853 
854  if(fullscreen) {
855  Size size = getDisplaySize();
856  GetWindowPlacement(m_window, &wpPrev);
857  SetWindowLong(m_window, GWL_STYLE, (dwStyle & ~WS_OVERLAPPEDWINDOW) | WS_POPUP | WS_EX_TOPMOST);
858  SetWindowPos(m_window, HWND_TOPMOST, 0, 0, size.width(), size.height(), SWP_FRAMECHANGED);
859  } else {
860  SetWindowLong(m_window, GWL_STYLE, (dwStyle & ~(WS_POPUP | WS_EX_TOPMOST)) | WS_OVERLAPPEDWINDOW);
861  SetWindowPlacement(m_window, &wpPrev);
862  SetWindowPos(m_window, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
863  }
864 }
865 
866 void WIN32Window::setVerticalSync(bool enable)
867 {
868 #ifdef OPENGL_ES
869  eglSwapInterval(m_eglDisplay, enable ? 1 : 0);
870 #else
871  if(!isExtensionSupported("WGL_EXT_swap_control"))
872  return;
873 
874  typedef BOOL (WINAPI * wglSwapIntervalProc)(int);
875  wglSwapIntervalProc wglSwapInterval = (wglSwapIntervalProc)getExtensionProcAddress("wglSwapIntervalEXT");
876  if(!wglSwapInterval)
877  return;
878 
879  wglSwapInterval(enable ? 1 : 0);
880 #endif
881 }
882 
883 void WIN32Window::setIcon(const std::string& file)
884 {
885  ImagePtr image = Image::load(file);
886 
887  if(!image) {
888  g_logger.traceError(stdext::format("unable to load icon file %s", file));
889  return;
890  }
891 
892  if(image->getBpp() != 4) {
893  g_logger.error("the app icon must have 4 channels");
894  return;
895  }
896 
897  int n = image->getWidth() * image->getHeight();
898  std::vector<uint32> iconData(n);
899  for(int i=0; i < n;++i) {
900  uint8 *pixel = (uint8*)&iconData[i];
901  pixel[2] = *(image->getPixelData() + (i * 4) + 0);
902  pixel[1] = *(image->getPixelData() + (i * 4) + 1);
903  pixel[0] = *(image->getPixelData() + (i * 4) + 2);
904  pixel[3] = *(image->getPixelData() + (i * 4) + 3);
905  }
906 
907  HBITMAP hbmColor = CreateBitmap(image->getWidth(), image->getHeight(), 1, 32, &iconData[0]);
908  HBITMAP hbmMask = CreateCompatibleBitmap(GetDC(NULL), image->getWidth(), image->getHeight());
909 
910  ICONINFO ii;
911  ii.fIcon = TRUE;
912  ii.hbmColor = hbmColor;
913  ii.hbmMask = hbmMask;
914  ii.xHotspot = 0;
915  ii.yHotspot = 0;
916 
917  HICON icon = CreateIconIndirect(&ii);
918  DeleteObject(hbmMask);
919  DeleteObject(hbmColor);
920 
921  SendMessage(m_window, WM_SETICON, ICON_SMALL, (LPARAM)icon);
922  SendMessage(m_window, WM_SETICON, ICON_BIG, (LPARAM)icon);
923 }
924 
925 void WIN32Window::setClipboardText(const std::string& text)
926 {
927  if(!OpenClipboard(m_window))
928  return;
929 
930  HGLOBAL hglb = GlobalAlloc(GMEM_MOVEABLE, (text.length() + 1) * sizeof(WCHAR));
931  if(!hglb)
932  return;
933 
934  std::wstring wtext = stdext::latin1_to_utf16(text);
935 
936  LPWSTR lpwstr = (LPWSTR)GlobalLock(hglb);
937  memcpy(lpwstr, (char*)&wtext[0], wtext.length() * sizeof(WCHAR));
938  lpwstr[text.length()] = (WCHAR)0;
939  GlobalUnlock(hglb);
940 
941  EmptyClipboard();
942  SetClipboardData(CF_UNICODETEXT, hglb);
943  CloseClipboard();
944 }
945 
947 {
948  return Size(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
949 }
950 
951 std::string WIN32Window::getClipboardText()
952 {
953  std::string text;
954 
955  if(!OpenClipboard(m_window))
956  return text;
957 
958  HGLOBAL hglb = GetClipboardData(CF_UNICODETEXT);
959  if(hglb) {
960  LPWSTR lpwstr = (LPWSTR)GlobalLock(hglb);
961  if(lpwstr) {
962  text = stdext::utf16_to_latin1(lpwstr);
963  GlobalUnlock(hglb);
964  }
965  }
966  CloseClipboard();
967  return text;
968 }
969 
970 
971 std::string WIN32Window::getPlatformType()
972 {
973 #ifndef OPENGL_ES
974  return "WIN32-WGL";
975 #else
976  return "WIN32-EGL";
977 #endif
978 }
979 
980 Rect WIN32Window::getClientRect()
981 {
982  if(m_window) {
983  RECT clientRect = {0,0,0,0};
984  int ret = GetClientRect(m_window, &clientRect);
985  assert(ret != 0);
986  return Rect(Point(clientRect.left, clientRect.top), Point(clientRect.right, clientRect.bottom));
987  } else {
988  return Rect(m_position, m_size);
989  }
990 }
991 
992 Rect WIN32Window::getWindowRect()
993 {
994  if(m_window) {
995  RECT windowRect = {0,0,0,0};
996  int ret = GetWindowRect(m_window, &windowRect);
997  assert(ret != 0);
998  return Rect(Point(windowRect.left, windowRect.top), Point(windowRect.right, windowRect.bottom));
999  } else {
1000  return adjustWindowRect(getClientRect());
1001  }
1002 }
1003 
1004 Rect WIN32Window::adjustWindowRect(const Rect& clientRect)
1005 {
1006  Rect rect;
1007  DWORD dwStyle;
1008  DWORD dwExStyle;
1009  RECT windowRect = { clientRect.left(), clientRect.top(), clientRect.right(), clientRect.bottom() };
1010  if(m_window) {
1011  dwStyle = GetWindowLong(m_window, GWL_STYLE);
1012  dwExStyle = GetWindowLong(m_window, GWL_EXSTYLE);
1013  } else {
1014  dwStyle = WS_OVERLAPPEDWINDOW;
1015  dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
1016  }
1017  if(AdjustWindowRectEx(&windowRect, dwStyle, FALSE, dwExStyle) != 0) {
1018  rect = Rect(Point(windowRect.left, windowRect.top), Point(windowRect.right, windowRect.bottom));
1019  } else {
1020  g_logger.traceError("AdjustWindowRectEx failed");
1021  rect = Rect(0,0, m_minimumSize);
1022  }
1023  return rect;
1024 }
1025 
1026 #endif
Fw::KeyUp
@ KeyUp
Definition: const.h:72
Fw::KeyComma
@ KeyComma
Definition: const.h:97
Fw::KeyNumpad9
@ KeyNumpad9
Definition: const.h:175
Fw::KeyUnknown
@ KeyUnknown
Definition: const.h:58
Fw::KeyEscape
@ KeyEscape
Definition: const.h:59
WIN32Window::setMinimumSize
void setMinimumSize(const Size &minimumSize)
Fw::KeyBackspace
@ KeyBackspace
Definition: const.h:61
Fw::KeyF10
@ KeyF10
Definition: const.h:163
PlatformWindow::m_position
Point m_position
Definition: platformwindow.h:115
Fw::KeyEnter
@ KeyEnter
Definition: const.h:63
Fw::KeyR
@ KeyR
Definition: const.h:135
Fw::KeyCapsLock
@ KeyCapsLock
Definition: const.h:78
Fw::KeyMenu
@ KeyMenu
Definition: const.h:84
Fw::KeyNumpad1
@ KeyNumpad1
Definition: const.h:167
Fw::KeyN
@ KeyN
Definition: const.h:131
Fw::KeyI
@ KeyI
Definition: const.h:126
TPoint::y
T y
Definition: point.h:83
Fw::KeyB
@ KeyB
Definition: const.h:119
Fw::MouseWheelInputEvent
@ MouseWheelInputEvent
Definition: const.h:243
Fw::KeyNumpad6
@ KeyNumpad6
Definition: const.h:172
Fw::KeyZ
@ KeyZ
Definition: const.h:143
TSize::setWidth
void setWidth(T w)
Definition: size.h:47
Fw::KeyNumpad3
@ KeyNumpad3
Definition: const.h:169
WIN32Window::terminate
void terminate()
Fw::Key7
@ Key7
Definition: const.h:108
WIN32Window::swapBuffers
void swapBuffers()
Fw::KeyW
@ KeyW
Definition: const.h:140
WIN32Window::setIcon
void setIcon(const std::string &file)
TRect< int >
TRect::x
T x() const
Definition: rect.h:58
Application::getCompactName
const std::string & getCompactName()
Definition: application.h:52
PlatformWindow::m_focused
stdext::boolean< false > m_focused
Definition: platformwindow.h:123
Image::load
static ImagePtr load(std::string file)
Definition: image.cpp:39
Fw::MouseMidButton
@ MouseMidButton
Definition: const.h:250
uint32
uint32_t uint32
Definition: types.h:35
Fw::KeyPeriod
@ KeyPeriod
Definition: const.h:99
Fw::KeyNumpad5
@ KeyNumpad5
Definition: const.h:171
Fw::KeyP
@ KeyP
Definition: const.h:133
Fw::KeyF9
@ KeyF9
Definition: const.h:162
Fw::Key3
@ Key3
Definition: const.h:104
Fw::KeyF2
@ KeyF2
Definition: const.h:155
TRect::left
T left() const
Definition: rect.h:52
resourcemanager.h
WIN32Window::WIN32Window
WIN32Window()
Fw::KeyRight
@ KeyRight
Definition: const.h:75
Logger::error
void error(const std::string &what)
Definition: logger.h:54
Fw::KeyInsert
@ KeyInsert
Definition: const.h:64
Fw::KeyT
@ KeyT
Definition: const.h:137
WIN32Window::resize
void resize(const Size &size)
Fw::KeyBackslash
@ KeyBackslash
Definition: const.h:145
Fw::KeyX
@ KeyX
Definition: const.h:141
Fw::KeyC
@ KeyC
Definition: const.h:120
Fw::KeyTextInputEvent
@ KeyTextInputEvent
Definition: const.h:236
Fw::Key
Key
Definition: const.h:57
Fw::KeyL
@ KeyL
Definition: const.h:129
TRect::bottom
T bottom() const
Definition: rect.h:55
Fw::KeyNumpad2
@ KeyNumpad2
Definition: const.h:168
WIN32Window::move
void move(const Point &pos)
WIN32Window::restoreMouseCursor
void restoreMouseCursor()
Point
TPoint< int > Point
Definition: point.h:86
Fw::KeyboardShiftModifier
@ KeyboardShiftModifier
Definition: const.h:263
Fw::KeyLeft
@ KeyLeft
Definition: const.h:74
WIN32Window::setMouseCursor
void setMouseCursor(int cursorId)
stdext::format
std::string format()
Definition: format.h:82
PlatformWindow::updateUnmaximizedCoords
void updateUnmaximizedCoords()
Definition: platformwindow.cpp:61
TSize::width
int width() const
Definition: size.h:43
PlatformWindow::m_inputEvent
InputEvent m_inputEvent
Definition: platformwindow.h:118
Fw::MousePressInputEvent
@ MousePressInputEvent
Definition: const.h:240
Fw::KeyNumpad8
@ KeyNumpad8
Definition: const.h:174
Fw::Key8
@ Key8
Definition: const.h:109
Fw::KeySemicolon
@ KeySemicolon
Definition: const.h:112
WIN32Window::setClipboardText
void setClipboardText(const std::string &text)
Fw::MouseLeftButton
@ MouseLeftButton
Definition: const.h:248
Fw::KeySlash
@ KeySlash
Definition: const.h:100
Fw::MouseMoveInputEvent
@ MouseMoveInputEvent
Definition: const.h:242
Fw::KeyScrollLock
@ KeyScrollLock
Definition: const.h:77
WIN32Window::show
void show()
PlatformWindow::releaseAllKeys
void releaseAllKeys()
Definition: platformwindow.cpp:139
WIN32Window::setVerticalSync
void setVerticalSync(bool enable)
Fw::KeyShift
@ KeyShift
Definition: const.h:80
window
X11Window window
Definition: platformwindow.cpp:31
PlatformWindow::m_fullscreen
stdext::boolean< false > m_fullscreen
Definition: platformwindow.h:124
Fw::KeyQ
@ KeyQ
Definition: const.h:134
Logger::fatal
void fatal(const std::string &what)
Definition: logger.h:55
Fw::Key2
@ Key2
Definition: const.h:103
Fw::KeyPause
@ KeyPause
Definition: const.h:66
Fw::KeyD
@ KeyD
Definition: const.h:121
Fw::KeyU
@ KeyU
Definition: const.h:138
Fw::KeyJ
@ KeyJ
Definition: const.h:127
InputEvent::keyboardModifiers
int keyboardModifiers
Definition: inputevent.h:49
Fw::KeyH
@ KeyH
Definition: const.h:125
g_window
PlatformWindow & g_window
Definition: platformwindow.cpp:37
Fw::KeyEnd
@ KeyEnd
Definition: const.h:69
uint
unsigned int uint
Definition: types.h:31
TSize::setHeight
void setHeight(T h)
Definition: size.h:48
Fw::KeyF12
@ KeyF12
Definition: const.h:165
PlatformWindow::m_onInputEvent
OnInputEventCallback m_onInputEvent
Definition: platformwindow.h:129
Fw::KeyAlt
@ KeyAlt
Definition: const.h:81
WIN32Window::hideMouse
void hideMouse()
g_logger
Logger g_logger
Definition: logger.cpp:35
PlatformWindow::m_mouseButtonStates
stdext::boolean< false > m_mouseButtonStates[4]
Definition: platformwindow.h:119
Fw::KeyF11
@ KeyF11
Definition: const.h:164
Fw::KeyF4
@ KeyF4
Definition: const.h:157
WIN32Window::init
void init()
WIN32Window::setFullscreen
void setFullscreen(bool fullscreen)
WIN32Window::getDisplaySize
Size getDisplaySize()
WIN32Window::showMouse
void showMouse()
Fw::KeyS
@ KeyS
Definition: const.h:136
TRect::y
T y() const
Definition: rect.h:59
Fw::KeyNumpad4
@ KeyNumpad4
Definition: const.h:170
PlatformWindow::processKeyDown
void processKeyDown(Fw::Key keyCode)
Definition: platformwindow.cpp:69
Fw::KeyO
@ KeyO
Definition: const.h:132
Fw::KeyHome
@ KeyHome
Definition: const.h:68
image.h
Size
TSize< int > Size
Definition: size.h:107
Fw::KeyA
@ KeyA
Definition: const.h:118
TPoint::x
T x
Definition: point.h:83
Fw::KeyGrave
@ KeyGrave
Definition: const.h:149
WIN32Window::getPlatformType
std::string getPlatformType()
Fw::KeyY
@ KeyY
Definition: const.h:142
Fw::KeyboardAltModifier
@ KeyboardAltModifier
Definition: const.h:262
PlatformWindow::m_visible
stdext::boolean< false > m_visible
Definition: platformwindow.h:122
Fw::KeyF7
@ KeyF7
Definition: const.h:160
Fw::KeyF
@ KeyF
Definition: const.h:123
g_app
ConsoleApplication g_app
Definition: consoleapplication.cpp:32
Fw::MouseRightButton
@ MouseRightButton
Definition: const.h:249
Fw::MouseWheelUp
@ MouseWheelUp
Definition: const.h:255
WIN32Window
Definition: win32window.h:41
Fw::Key9
@ Key9
Definition: const.h:110
PlatformWindow::m_size
Size m_size
Definition: platformwindow.h:113
Rect
TRect< int > Rect
Definition: rect.h:319
Fw::KeyRightBracket
@ KeyRightBracket
Definition: const.h:146
WIN32Window::maximize
void maximize()
Fw::KeyNumpad7
@ KeyNumpad7
Definition: const.h:173
Fw::KeyMinus
@ KeyMinus
Definition: const.h:98
InputEvent::keyText
std::string keyText
Definition: inputevent.h:48
Fw::Key0
@ Key0
Definition: const.h:101
Fw::KeyF8
@ KeyF8
Definition: const.h:161
WIN32Window::displayFatalError
void displayFatalError(const std::string &message)
PlatformWindow::m_onResize
OnResizeCallback m_onResize
Definition: platformwindow.h:128
PlatformWindow::m_onClose
std::function< void()> m_onClose
Definition: platformwindow.h:127
TSize::height
int height() const
Definition: size.h:44
Fw::KeyM
@ KeyM
Definition: const.h:130
Fw::KeyEqual
@ KeyEqual
Definition: const.h:114
TRect::right
T right() const
Definition: rect.h:54
Fw::KeyPrintScreen
@ KeyPrintScreen
Definition: const.h:67
Fw::KeyG
@ KeyG
Definition: const.h:124
WIN32Window::internalLoadMouseCursor
int internalLoadMouseCursor(const ImagePtr &image, const Point &hotSpot)
stdext::shared_object_ptr
Definition: shared_object.h:39
Fw::KeyV
@ KeyV
Definition: const.h:139
PlatformWindow::m_keyMap
std::map< int, Fw::Key > m_keyMap
Definition: platformwindow.h:107
Fw::KeyE
@ KeyE
Definition: const.h:122
WIN32Window::hide
void hide()
Fw::KeyNumpad0
@ KeyNumpad0
Definition: const.h:166
Fw::KeyF6
@ KeyF6
Definition: const.h:159
Fw::Key1
@ Key1
Definition: const.h:102
TRect::height
T height() const
Definition: rect.h:70
Fw::KeyDown
@ KeyDown
Definition: const.h:73
PlatformWindow::m_maximized
stdext::boolean< false > m_maximized
Definition: platformwindow.h:125
Fw::MouseReleaseInputEvent
@ MouseReleaseInputEvent
Definition: const.h:241
TRect::top
T top() const
Definition: rect.h:53
InputEvent::mousePos
Point mousePos
Definition: inputevent.h:50
Fw::KeyApostrophe
@ KeyApostrophe
Definition: const.h:92
Fw::KeyboardCtrlModifier
@ KeyboardCtrlModifier
Definition: const.h:261
Fw::Key5
@ Key5
Definition: const.h:106
Fw::KeyPageUp
@ KeyPageUp
Definition: const.h:70
Fw::Key4
@ Key4
Definition: const.h:105
TPoint< int >
Fw::KeyLeftBracket
@ KeyLeftBracket
Definition: const.h:144
win32window.h
PlatformWindow::processKeyUp
void processKeyUp(Fw::Key keyCode)
Definition: platformwindow.cpp:106
WIN32Window::poll
void poll()
TRect::width
T width() const
Definition: rect.h:69
WIN32Window::getClipboardText
std::string getClipboardText()
Fw::MouseWheelDown
@ MouseWheelDown
Definition: const.h:256
InputEvent::mouseButton
Fw::MouseButton mouseButton
Definition: inputevent.h:46
InputEvent::mouseMoved
Point mouseMoved
Definition: inputevent.h:51
TSize< int >
Fw::Key6
@ Key6
Definition: const.h:107
stdext::readULE32
uint32_t readULE32(const uchar *addr)
Definition: math.h:35
Fw::KeyMeta
@ KeyMeta
Definition: const.h:83
Fw::KeyF5
@ KeyF5
Definition: const.h:158
Fw::KeyF1
@ KeyF1
Definition: const.h:154
PlatformWindow::fireKeysPress
void fireKeysPress()
Definition: platformwindow.cpp:157
Fw::KeyCtrl
@ KeyCtrl
Definition: const.h:79
Fw::KeyF3
@ KeyF3
Definition: const.h:156
InputEvent::wheelDirection
Fw::MouseWheelDirection wheelDirection
Definition: inputevent.h:45
Fw::KeyK
@ KeyK
Definition: const.h:128
PlatformWindow::m_minimumSize
Size m_minimumSize
Definition: platformwindow.h:114
uint8
uint8_t uint8
Definition: types.h:37
Fw::KeyDelete
@ KeyDelete
Definition: const.h:65
Fw::KeyPageDown
@ KeyPageDown
Definition: const.h:71
InputEvent::reset
void reset(Fw::InputEventType eventType=Fw::NoInputEvent)
Definition: inputevent.h:34
Fw::KeyTab
@ KeyTab
Definition: const.h:60
WIN32Window::setTitle
void setTitle(const std::string &title)
application.h
Logger::warning
void warning(const std::string &what)
Definition: logger.h:53
Fw::KeyNumLock
@ KeyNumLock
Definition: const.h:76
Fw::KeySpace
@ KeySpace
Definition: const.h:85