Blender V4.3
GHOST_SystemWin32.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10#pragma once
11
12#ifndef WIN32
13# error WIN32 only!
14#endif /* WIN32 */
15
16#ifndef NOMINMAX
17# define NOMINMAX
18#endif
19
20#define WIN32_LEAN_AND_MEAN
21#include <ole2.h> /* For drag-n-drop. */
22#include <windows.h>
23
24#include "GHOST_System.hh"
25
28class GHOST_EventKey;
30class GHOST_EventWindow;
32
35
41 public:
46
51
52 /***************************************************************************************
53 ** Time(r) functionality
54 ***************************************************************************************/
55
61 uint64_t performanceCounterToMillis(__int64 perf_ticks) const;
62
70
71 /***************************************************************************************
72 ** Display/window management functionality
73 ***************************************************************************************/
74
79 uint8_t getNumDisplays() const;
80
85 void getMainDisplayDimensions(uint32_t &width, uint32_t &height) const;
86
91 void getAllDisplayDimensions(uint32_t &width, uint32_t &height) const;
92
109 GHOST_IWindow *createWindow(const char *title,
110 int32_t left,
111 int32_t top,
112 uint32_t width,
113 uint32_t height,
115 GHOST_GPUSettings gpuSettings,
116 const bool exclusive = false,
117 const bool is_dialog = false,
118 const GHOST_IWindow *parentWindow = 0);
119
126
133
142
150
156
157 /***************************************************************************************
158 ** Event management functionality
159 ***************************************************************************************/
160
166 bool processEvents(bool waitForEvent);
167
168 /***************************************************************************************
169 ** Cursor management functionality
170 ***************************************************************************************/
171
179
187
193 GHOST_TSuccess getPixelAtCursor(float r_color[3]) const;
194
195 /***************************************************************************************
196 ** Access to mouse button and keyboard states.
197 ***************************************************************************************/
198
205
212
214
220 char *getClipboard(bool selection) const;
221
227 void putClipboard(const char *buffer, bool selection) const;
228
233
240 uint *getClipboardImage(int *r_width, int *r_height) const;
241
248 GHOST_TSuccess putClipboardImage(uint *rgba, int width, int height) const;
249
259 GHOST_TSuccess showMessageBox(const char *title,
260 const char *message,
261 const char *help_label,
262 const char *continue_label,
263 const char *link,
264 GHOST_DialogOptions dialog_options) const;
265
278 GHOST_TDragnDropTypes draggedObjectType,
279 GHOST_WindowWin32 *window,
280 int mouseX,
281 int mouseY,
282 void *data);
283
284 /***************************************************************************************
285 ** Modify tablet API
286 ***************************************************************************************/
287
292 void setTabletAPI(GHOST_TTabletAPI api) override;
293
294 /***************************************************************************************
295 ** Debug Info
296 ***************************************************************************************/
297
302 void initDebug(GHOST_Debug debug) override;
303
304 protected:
311
317
325 GHOST_TKey convertKey(short vKey, short ScanCode, short extend) const;
326
333 GHOST_TKey hardKey(RAWINPUT const &raw, bool *r_key_down);
334
343 GHOST_WindowWin32 *window,
344 GHOST_TButton mask);
345
350 static void processWintabEvent(GHOST_WindowWin32 *window);
351
360 static void processPointerEvent(
361 UINT type, GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam, bool &eventhandled);
362
369 const int32_t screen_co[2]);
370
377 static void processWheelEvent(GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam);
378
386 static GHOST_EventKey *processKeyEvent(GHOST_WindowWin32 *window, RAWINPUT const &raw);
387
394 GHOST_TKey processSpecialKey(short vKey, short scanCode) const;
395
402
410
411#ifdef WITH_INPUT_IME
419 static GHOST_Event *processImeEvent(GHOST_TEventType type,
420 GHOST_WindowWin32 *window,
421 GHOST_TEventImeData *data);
422#endif /* WITH_INPUT_IME */
423
428 static void processMinMaxInfo(MINMAXINFO *minmax);
429
430#ifdef WITH_INPUT_NDOF
438 bool processNDOF(RAWINPUT const &raw);
439#endif
440
444 void driveTrackpad();
445
449 void processTrackpad();
450
454 inline void handleKeyboardChange();
455
459 static LRESULT WINAPI s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
460
467
471 __int64 m_freq;
478
481
484};
485
487{
488 m_keylayout = GetKeyboardLayout(0); /* Get keylayout for current thread. */
489 int i;
490 SHORT s;
491
492 /* Save the language identifier. */
493 m_langId = LOWORD(m_keylayout);
494
495 for (m_hasAltGr = false, i = 32; i < 256; ++i) {
496 s = VkKeyScanEx((char)i, m_keylayout);
497 /* `s == -1` means no key that translates passed char code high byte contains shift state.
498 * bit 2 Control pressed, bit 4 `Alt` pressed if both are pressed,
499 * we have `AltGr` key-combination on key-layout. */
500 if (s != -1 && (s & 0x600) == 0x600) {
501 m_hasAltGr = true;
502 break;
503 }
504 }
505}
unsigned int uint
GHOST_TWindowState
GHOST_TEventType
GHOST_TCapabilityFlag
Definition GHOST_Types.h:96
GHOST_TKey
GHOST_TSuccess
Definition GHOST_Types.h:87
GHOST_TDragnDropTypes
GHOST_TButton
GHOST_TConsoleWindowState
GHOST_TTabletAPI
GHOST_DialogOptions
Definition GHOST_Types.h:80
GHOST_TSuccess setCursorPosition(int32_t x, int32_t y)
uint64_t getMilliSeconds() const
void getMainDisplayDimensions(uint32_t &width, uint32_t &height) const
GHOST_TKey hardKey(RAWINPUT const &raw, bool *r_key_down)
uint * getClipboardImage(int *r_width, int *r_height) const
void setTabletAPI(GHOST_TTabletAPI api) override
static void processWheelEvent(GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam)
static GHOST_EventButton * processButtonEvent(GHOST_TEventType type, GHOST_WindowWin32 *window, GHOST_TButton mask)
GHOST_TSuccess getCursorPosition(int32_t &x, int32_t &y) const
GHOST_TKey processSpecialKey(short vKey, short scanCode) const
GHOST_TSuccess hasClipboardImage() const
static GHOST_Event * processWindowSizeEvent(GHOST_WindowWin32 *window)
GHOST_TKey convertKey(short vKey, short ScanCode, short extend) const
GHOST_TSuccess init()
GHOST_IContext * createOffscreenContext(GHOST_GPUSettings gpuSettings)
void putClipboard(const char *buffer, bool selection) const
static GHOST_EventCursor * processCursorEvent(GHOST_WindowWin32 *window, const int32_t screen_co[2])
GHOST_IWindow * createWindow(const char *title, int32_t left, int32_t top, uint32_t width, uint32_t height, GHOST_TWindowState state, GHOST_GPUSettings gpuSettings, const bool exclusive=false, const bool is_dialog=false, const GHOST_IWindow *parentWindow=0)
static GHOST_ContextD3D * createOffscreenContextD3D()
bool processEvents(bool waitForEvent)
char * getClipboard(bool selection) const
static GHOST_TSuccess disposeContextD3D(GHOST_ContextD3D *context)
static void processWintabEvent(GHOST_WindowWin32 *window)
uint64_t performanceCounterToMillis(__int64 perf_ticks) const
GHOST_TSuccess getButtons(GHOST_Buttons &buttons) const
GHOST_TSuccess putClipboardImage(uint *rgba, int width, int height) const
static GHOST_EventKey * processKeyEvent(GHOST_WindowWin32 *window, RAWINPUT const &raw)
void initDebug(GHOST_Debug debug) override
void getAllDisplayDimensions(uint32_t &width, uint32_t &height) const
GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys &keys) const
static void processMinMaxInfo(MINMAXINFO *minmax)
bool setConsoleWindowState(GHOST_TConsoleWindowState action)
GHOST_TSuccess getPixelAtCursor(float r_color[3]) const
static GHOST_Event * processWindowEvent(GHOST_TEventType type, GHOST_WindowWin32 *window)
uint8_t getNumDisplays() const
static void processPointerEvent(UINT type, GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam, bool &eventhandled)
GHOST_TSuccess disposeContext(GHOST_IContext *context)
GHOST_TCapabilityFlag getCapabilities() 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()
GHOST_IWindow * getWindowUnderCursor(int32_t, int32_t)
static ulong state[N]
unsigned int uint32_t
Definition stdint.h:80
signed int int32_t
Definition stdint.h:77
unsigned char uint8_t
Definition stdint.h:78
unsigned __int64 uint64_t
Definition stdint.h:90