Blender  V2.93
GHOST_SystemWin32.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
25 #pragma once
26 
27 #ifndef WIN32
28 # error WIN32 only!
29 #endif // WIN32
30 
31 #define WIN32_LEAN_AND_MEAN
32 #include <ole2.h> // for drag-n-drop
33 #include <windows.h>
34 
35 #include "GHOST_System.h"
36 
37 class GHOST_EventButton;
38 class GHOST_EventCursor;
39 class GHOST_EventKey;
40 class GHOST_EventWheel;
41 class GHOST_EventWindow;
43 
44 class GHOST_ContextD3D;
45 class GHOST_WindowWin32;
46 
52  public:
57 
62 
63  /***************************************************************************************
64  ** Time(r) functionality
65  ***************************************************************************************/
66 
72  GHOST_TUns64 performanceCounterToMillis(__int64 perf_ticks) const;
73 
79  GHOST_TUns64 tickCountToMillis(__int64 ticks) const;
80 
88 
89  /***************************************************************************************
90  ** Display/window management functionality
91  ***************************************************************************************/
92 
98 
104 
110 
128  GHOST_IWindow *createWindow(const char *title,
135  GHOST_GLSettings glSettings,
136  const bool exclusive = false,
137  const bool is_dialog = false,
138  const GHOST_IWindow *parentWindow = 0);
139 
146 
153 
162 
170 
171  /***************************************************************************************
172  ** Event management functionality
173  ***************************************************************************************/
174 
180  bool processEvents(bool waitForEvent);
181 
182  /***************************************************************************************
183  ** Cursor management functionality
184  ***************************************************************************************/
185 
193 
201 
202  /***************************************************************************************
203  ** Access to mouse button and keyboard states.
204  ***************************************************************************************/
205 
212 
218  GHOST_TSuccess getButtons(GHOST_Buttons &buttons) const;
219 
225  GHOST_TUns8 *getClipboard(bool selection) const;
226 
232  void putClipboard(GHOST_TInt8 *buffer, bool selection) const;
233 
243  GHOST_TSuccess showMessageBox(const char *title,
244  const char *message,
245  const char *help_label,
246  const char *continue_label,
247  const char *link,
248  GHOST_DialogOptions dialog_options) const;
249 
262  GHOST_TDragnDropTypes draggedObjectType,
263  GHOST_WindowWin32 *window,
264  int mouseX,
265  int mouseY,
266  void *data);
267 
268  protected:
275 
281 
289  GHOST_TKey convertKey(short vKey, short ScanCode, short extend) const;
290 
298  GHOST_TKey hardKey(RAWINPUT const &raw, bool *r_keyDown, bool *r_is_repeated_modifier);
299 
308  GHOST_WindowWin32 *window,
310 
319  static void processPointerEvent(
320  UINT type, GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam, bool &eventhandled);
321 
328 
335  static void processWheelEvent(GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam);
336 
344  static GHOST_EventKey *processKeyEvent(GHOST_WindowWin32 *window, RAWINPUT const &raw);
345 
352  GHOST_TKey processSpecialKey(short vKey, short scanCode) const;
353 
361 
362 #ifdef WITH_INPUT_IME
370  static GHOST_Event *processImeEvent(GHOST_TEventType type,
371  GHOST_WindowWin32 *window,
373 #endif // WITH_INPUT_IME
374 
379  static void processMinMaxInfo(MINMAXINFO *minmax);
380 
381 #ifdef WITH_INPUT_NDOF
389  bool processNDOF(RAWINPUT const &raw);
390 #endif
391 
396  inline void retrieveModifierKeys(GHOST_ModifierKeys &keys) const;
397 
403  inline void storeModifierKeys(const GHOST_ModifierKeys &keys);
404 
408  inline void handleKeyboardChange(void);
409 
413  static LRESULT WINAPI s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
414 
425  int toggleConsole(int action);
426 
434  __int64 m_freq;
436  __int64 m_start;
438  __int64 m_lfstart;
442  WORD m_langId;
445 
448 
451 };
452 
454 {
455  keys = m_modifierKeys;
456 }
457 
459 {
460  m_modifierKeys = keys;
461 }
462 
464 {
465  m_keylayout = GetKeyboardLayout(0); // get keylayout for current thread
466  int i;
467  SHORT s;
468 
469  // save the language identifier.
470  m_langId = LOWORD(m_keylayout);
471 
472  for (m_hasAltGr = false, i = 32; i < 256; ++i) {
473  s = VkKeyScanEx((char)i, m_keylayout);
474  // s == -1 means no key that translates passed char code
475  // high byte contains shift state. bit 2 ctrl pressed, bit 4 alt pressed
476  // if both are pressed, we have AltGr keycombo on keylayout
477  if (s != -1 && (s & 0x600) == 0x600) {
478  m_hasAltGr = true;
479  break;
480  }
481  }
482 }
GHOST_TWindowState
Definition: GHOST_Types.h:144
unsigned int GHOST_TUns32
Definition: GHOST_Types.h:64
unsigned long long GHOST_TUns64
Definition: GHOST_Types.h:86
GHOST_TEventType
Definition: GHOST_Types.h:177
int GHOST_TInt32
Definition: GHOST_Types.h:63
GHOST_TKey
Definition: GHOST_Types.h:267
GHOST_TDrawingContextType
Definition: GHOST_Types.h:156
GHOST_TButtonMask
Definition: GHOST_Types.h:164
char GHOST_TInt8
Definition: GHOST_Types.h:59
GHOST_TSuccess
Definition: GHOST_Types.h:91
GHOST_TDragnDropTypes
Definition: GHOST_Types.h:477
unsigned char GHOST_TUns8
Definition: GHOST_Types.h:60
GHOST_DialogOptions
Definition: GHOST_Types.h:76
typedef UINT
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble top
GHOST_TUns64 tickCountToMillis(__int64 ticks) const
GHOST_TKey hardKey(RAWINPUT const &raw, bool *r_keyDown, bool *r_is_repeated_modifier)
static void processWheelEvent(GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam)
GHOST_TUns64 getMilliSeconds() const
GHOST_IContext * createOffscreenContext(GHOST_GLSettings glSettings)
unsigned short m_keycode_last_repeat_key
GHOST_TUns8 * getClipboard(bool selection) const
GHOST_TKey processSpecialKey(short vKey, short scanCode) const
static GHOST_EventButton * processButtonEvent(GHOST_TEventType type, GHOST_WindowWin32 *window, GHOST_TButtonMask mask)
GHOST_TKey convertKey(short vKey, short ScanCode, short extend) const
GHOST_TSuccess init()
int toggleConsole(int action)
void getMainDisplayDimensions(GHOST_TUns32 &width, GHOST_TUns32 &height) const
void getAllDisplayDimensions(GHOST_TUns32 &width, GHOST_TUns32 &height) const
GHOST_TUns8 getNumDisplays() const
GHOST_ModifierKeys m_modifierKeys
static GHOST_ContextD3D * createOffscreenContextD3D()
bool processEvents(bool waitForEvent)
static GHOST_TSuccess disposeContextD3D(GHOST_ContextD3D *context)
GHOST_TSuccess getButtons(GHOST_Buttons &buttons) const
void retrieveModifierKeys(GHOST_ModifierKeys &keys) const
static GHOST_EventKey * processKeyEvent(GHOST_WindowWin32 *window, RAWINPUT const &raw)
GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys &keys) const
static void processMinMaxInfo(MINMAXINFO *minmax)
void storeModifierKeys(const GHOST_ModifierKeys &keys)
GHOST_TSuccess setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y)
static GHOST_Event * processWindowEvent(GHOST_TEventType type, GHOST_WindowWin32 *window)
GHOST_TSuccess getCursorPosition(GHOST_TInt32 &x, GHOST_TInt32 &y) const
GHOST_IWindow * createWindow(const char *title, GHOST_TInt32 left, GHOST_TInt32 top, GHOST_TUns32 width, GHOST_TUns32 height, GHOST_TWindowState state, GHOST_TDrawingContextType type, GHOST_GLSettings glSettings, const bool exclusive=false, const bool is_dialog=false, const GHOST_IWindow *parentWindow=0)
static GHOST_EventCursor * processCursorEvent(GHOST_WindowWin32 *window)
void handleKeyboardChange(void)
static void processPointerEvent(UINT type, GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam, bool &eventhandled)
GHOST_TSuccess disposeContext(GHOST_IContext *context)
void putClipboard(GHOST_TInt8 *buffer, bool selection) const
GHOST_TUns64 performanceCounterToMillis(__int64 perf_ticks) const
GHOST_TSuccess showMessageBox(const char *title, const char *message, const char *help_label, const char *continue_label, const char *link, GHOST_DialogOptions dialog_options) const
static LRESULT WINAPI s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
static GHOST_TSuccess pushDragDropEvent(GHOST_TEventType eventType, GHOST_TDragnDropTypes draggedObjectType, GHOST_WindowWin32 *window, int mouseX, int mouseY, void *data)
GHOST_TSuccess exit()
__kernel void ccl_constant KernelData ccl_global void ccl_global char ccl_global int ccl_global char ccl_global unsigned int ccl_global float * buffer
static ulong state[N]
static int left
struct SELECTID_Context context
Definition: select_engine.c:47
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)