BugFix [#18597] Blender's text editor cant paste from SciTE in linux
[blender.git] / intern / ghost / GHOST_Types.h
1 /**
2  * $Id$
3  * ***** BEGIN GPL LICENSE BLOCK *****
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software Foundation,
17  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18  *
19  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
20  * All rights reserved.
21  *
22  * The Original Code is: all of this file.
23  *
24  * Contributor(s): none yet.
25  *
26  * ***** END GPL LICENSE BLOCK *****
27  */
28
29 #ifndef _GHOST_TYPES_H_
30 #define _GHOST_TYPES_H_
31
32 typedef char                            GHOST_TInt8;
33 typedef unsigned char           GHOST_TUns8;
34 typedef short                           GHOST_TInt16;
35 typedef unsigned short          GHOST_TUns16;
36 typedef int                                     GHOST_TInt32;
37 typedef unsigned int            GHOST_TUns32;
38
39 #ifdef WIN32
40 #define WM_BLND_NDOF_AXIS       WM_USER + 1
41 #define WM_BLND_NDOF_BTN        WM_USER + 2
42 #endif
43
44 #if defined(WIN32) && !defined(FREE_WINDOWS)
45 typedef __int64                         GHOST_TInt64;
46 typedef unsigned __int64        GHOST_TUns64;
47 #else
48 typedef long long                       GHOST_TInt64;
49 typedef unsigned long long      GHOST_TUns64;
50 #endif
51
52 typedef void*                           GHOST_TUserDataPtr;
53
54 typedef enum
55 {
56         GHOST_kFailure = 0,
57         GHOST_kSuccess
58 } GHOST_TSuccess;
59
60 /* Xtilt and Ytilt represent how much the pen is tilted away from 
61  * vertically upright in either the X or Y direction, with X and Y the
62  * axes of the tablet surface.
63  * In other words, Xtilt and Ytilt are components of a vector created by projecting
64  * the pen's angle in 3D space vertically downwards on to the XY plane
65  * --Matt
66  */
67 typedef struct GHOST_TabletData {
68         char Active; /* 0=None, 1=Stylus, 2=Eraser */
69         float Pressure; /* range 0.0 (not touching) to 1.0 (full pressure) */
70         float Xtilt;    /* range 0.0 (upright) to 1.0 (tilted fully against the tablet surface) */
71         float Ytilt;    /* as above */
72 } GHOST_TabletData;
73
74
75 typedef enum {
76         GHOST_kNotVisible = 0,
77         GHOST_kPartiallyVisible,
78         GHOST_kFullyVisible
79 } GHOST_TVisibility;
80
81
82 typedef enum {
83         GHOST_kFireTimeNever = 0xFFFFFFFF
84 } GHOST_TFireTimeConstant;
85
86 typedef enum {
87     GHOST_kModifierKeyLeftShift = 0,
88     GHOST_kModifierKeyRightShift,
89     GHOST_kModifierKeyLeftAlt,
90     GHOST_kModifierKeyRightAlt,
91     GHOST_kModifierKeyLeftControl,
92     GHOST_kModifierKeyRightControl,
93     GHOST_kModifierKeyCommand,          // APPLE only
94     GHOST_kModifierKeyNumMasks
95 } GHOST_TModifierKeyMask;
96
97
98 typedef enum {
99         GHOST_kWindowStateNormal = 0,
100         GHOST_kWindowStateMaximized,
101         GHOST_kWindowStateMinimized,
102         GHOST_kWindowStateFullScreen,
103         GHOST_kWindowStateEmbedded,
104         GHOST_kWindowState8Normal = 8,
105         GHOST_kWindowState8Maximized,
106         GHOST_kWindowState8Minimized,
107         GHOST_kWindowState8FullScreen
108 } GHOST_TWindowState;
109
110
111 typedef enum {
112         GHOST_kWindowOrderTop = 0,
113         GHOST_kWindowOrderBottom
114 } GHOST_TWindowOrder;
115
116
117 typedef enum {
118         GHOST_kDrawingContextTypeNone = 0,
119         GHOST_kDrawingContextTypeOpenGL
120 } GHOST_TDrawingContextType;
121
122
123 typedef enum {
124         GHOST_kButtonMaskLeft = 0,
125         GHOST_kButtonMaskMiddle,
126         GHOST_kButtonMaskRight,
127         GHOST_kButtonNumMasks
128 } GHOST_TButtonMask;
129
130
131 typedef enum {
132         GHOST_kEventUnknown = 0,
133
134         GHOST_kEventCursorMove,         /// Mouse move event
135         GHOST_kEventButtonDown,         /// Mouse button event
136         GHOST_kEventButtonUp,           /// Mouse button event
137         GHOST_kEventWheel,                      /// Mouse wheel event
138
139         GHOST_kEventNDOFMotion,         /// N degree of freedom device motion event
140         GHOST_kEventNDOFButton,         /// N degree of freedom device button event
141
142         GHOST_kEventKeyDown,
143         GHOST_kEventKeyUp,
144 //      GHOST_kEventKeyAuto,
145
146         GHOST_kEventQuit,
147
148         GHOST_kEventWindowClose,
149         GHOST_kEventWindowActivate,
150         GHOST_kEventWindowDeactivate,
151         GHOST_kEventWindowUpdate,
152         GHOST_kEventWindowSize,
153
154         GHOST_kNumEventTypes
155 } GHOST_TEventType;
156
157
158 typedef enum {
159         GHOST_kStandardCursorFirstCursor = 0,
160         GHOST_kStandardCursorDefault = 0,
161         GHOST_kStandardCursorRightArrow,
162         GHOST_kStandardCursorLeftArrow,
163         GHOST_kStandardCursorInfo, 
164         GHOST_kStandardCursorDestroy,
165         GHOST_kStandardCursorHelp,    
166         GHOST_kStandardCursorCycle,
167         GHOST_kStandardCursorSpray,
168         GHOST_kStandardCursorWait,
169         GHOST_kStandardCursorText,
170         GHOST_kStandardCursorCrosshair,
171         GHOST_kStandardCursorUpDown,
172         GHOST_kStandardCursorLeftRight,
173         GHOST_kStandardCursorTopSide,
174         GHOST_kStandardCursorBottomSide,
175         GHOST_kStandardCursorLeftSide,
176         GHOST_kStandardCursorRightSide,
177         GHOST_kStandardCursorTopLeftCorner,
178         GHOST_kStandardCursorTopRightCorner,
179         GHOST_kStandardCursorBottomRightCorner,
180         GHOST_kStandardCursorBottomLeftCorner,
181         GHOST_kStandardCursorCustom, 
182         GHOST_kStandardCursorNumCursors, 
183         GHOST_kStandardCursorPencil
184 } GHOST_TStandardCursor;
185
186
187 typedef enum {
188         GHOST_kKeyUnknown = -1,
189         GHOST_kKeyBackSpace,
190         GHOST_kKeyTab,
191         GHOST_kKeyLinefeed,
192         GHOST_kKeyClear,
193         GHOST_kKeyEnter  = 0x0D,
194         
195         GHOST_kKeyEsc    = 0x1B,
196         GHOST_kKeySpace  = ' ',
197         GHOST_kKeyQuote  = 0x27,
198         GHOST_kKeyComma  = ',',
199         GHOST_kKeyMinus  = '-',
200         GHOST_kKeyPeriod = '.',
201         GHOST_kKeySlash  = '/',
202
203         // Number keys
204         GHOST_kKey0 = '0',
205         GHOST_kKey1,
206         GHOST_kKey2,
207         GHOST_kKey3,
208         GHOST_kKey4,
209         GHOST_kKey5,
210         GHOST_kKey6,
211         GHOST_kKey7,
212         GHOST_kKey8,
213         GHOST_kKey9,
214
215         GHOST_kKeySemicolon = ';',
216         GHOST_kKeyEqual     = '=',
217
218         // Character keys
219         GHOST_kKeyA = 'A',
220         GHOST_kKeyB,
221         GHOST_kKeyC,
222         GHOST_kKeyD,
223         GHOST_kKeyE,
224         GHOST_kKeyF,
225         GHOST_kKeyG,
226         GHOST_kKeyH,
227         GHOST_kKeyI,
228         GHOST_kKeyJ,
229         GHOST_kKeyK,
230         GHOST_kKeyL,
231         GHOST_kKeyM,
232         GHOST_kKeyN,
233         GHOST_kKeyO,
234         GHOST_kKeyP,
235         GHOST_kKeyQ,
236         GHOST_kKeyR,
237         GHOST_kKeyS,
238         GHOST_kKeyT,
239         GHOST_kKeyU,
240         GHOST_kKeyV,
241         GHOST_kKeyW,
242         GHOST_kKeyX,
243         GHOST_kKeyY,
244         GHOST_kKeyZ,
245
246         GHOST_kKeyLeftBracket  = '[',
247         GHOST_kKeyRightBracket = ']',
248         GHOST_kKeyBackslash    = 0x5C,
249         GHOST_kKeyAccentGrave  = '`',
250
251         
252         GHOST_kKeyLeftShift = 0x100,
253         GHOST_kKeyRightShift,
254         GHOST_kKeyLeftControl,
255         GHOST_kKeyRightControl,
256         GHOST_kKeyLeftAlt,
257         GHOST_kKeyRightAlt,
258     GHOST_kKeyCommand,                          // APPLE only!
259     GHOST_kKeyGrLess ,          // German PC only!
260
261         GHOST_kKeyCapsLock,
262         GHOST_kKeyNumLock,
263         GHOST_kKeyScrollLock,
264
265         GHOST_kKeyLeftArrow,
266         GHOST_kKeyRightArrow,
267         GHOST_kKeyUpArrow,
268         GHOST_kKeyDownArrow,
269
270         GHOST_kKeyPrintScreen,
271         GHOST_kKeyPause,
272
273         GHOST_kKeyInsert,
274         GHOST_kKeyDelete,
275         GHOST_kKeyHome,
276         GHOST_kKeyEnd,
277         GHOST_kKeyUpPage,
278         GHOST_kKeyDownPage,
279
280         // Numpad keys
281         GHOST_kKeyNumpad0,
282         GHOST_kKeyNumpad1,
283         GHOST_kKeyNumpad2,
284         GHOST_kKeyNumpad3,
285         GHOST_kKeyNumpad4,
286         GHOST_kKeyNumpad5,
287         GHOST_kKeyNumpad6,
288         GHOST_kKeyNumpad7,
289         GHOST_kKeyNumpad8,
290         GHOST_kKeyNumpad9,
291         GHOST_kKeyNumpadPeriod,
292         GHOST_kKeyNumpadEnter,
293         GHOST_kKeyNumpadPlus,
294         GHOST_kKeyNumpadMinus,
295         GHOST_kKeyNumpadAsterisk,
296         GHOST_kKeyNumpadSlash,
297
298         // Function keys
299         GHOST_kKeyF1,
300         GHOST_kKeyF2,
301         GHOST_kKeyF3,
302         GHOST_kKeyF4,
303         GHOST_kKeyF5,
304         GHOST_kKeyF6,
305         GHOST_kKeyF7,
306         GHOST_kKeyF8,
307         GHOST_kKeyF9,
308         GHOST_kKeyF10,
309         GHOST_kKeyF11,
310         GHOST_kKeyF12,
311         GHOST_kKeyF13,
312         GHOST_kKeyF14,
313         GHOST_kKeyF15,
314         GHOST_kKeyF16,
315         GHOST_kKeyF17,
316         GHOST_kKeyF18,
317         GHOST_kKeyF19,
318         GHOST_kKeyF20,
319         GHOST_kKeyF21,
320         GHOST_kKeyF22,
321         GHOST_kKeyF23,
322         GHOST_kKeyF24
323 } GHOST_TKey;
324
325
326 typedef void* GHOST_TEventDataPtr;
327
328 typedef struct {
329         /** The x-coordinate of the cursor position. */
330         GHOST_TInt32 x;
331         /** The y-coordinate of the cursor position. */
332         GHOST_TInt32 y;
333 } GHOST_TEventCursorData;
334
335 typedef struct {
336         /** The mask of the mouse button. */
337         GHOST_TButtonMask button;
338 } GHOST_TEventButtonData;
339
340 typedef struct {
341         /** Displacement of a mouse wheel. */
342         GHOST_TInt32 z; 
343 } GHOST_TEventWheelData;
344
345
346 /* original patch used floats, but the driver return ints and uns. We will calibrate in view, no sense on doing conversions twice */
347 /* as all USB device controls are likely to use ints, this is also more future proof */
348 //typedef struct {
349 //   /** N-degree of freedom device data */
350 //   float tx, ty, tz;   /** -x left, +y up, +z forward */
351 //   float rx, ry, rz;
352 //   float dt;
353 //} GHOST_TEventNDOFData;
354
355 typedef struct {
356    /** N-degree of freedom device data v2*/
357    int changed;
358    GHOST_TUns64 client;
359    GHOST_TUns64 address;
360    GHOST_TInt16 tx, ty, tz;   /** -x left, +y up, +z forward */
361    GHOST_TInt16 rx, ry, rz;
362    GHOST_TInt16 buttons;
363    GHOST_TUns64 time;
364    GHOST_TUns64 delta;
365 } GHOST_TEventNDOFData;
366
367 typedef int     (*GHOST_NDOFLibraryInit_fp)();
368 typedef void    (*GHOST_NDOFLibraryShutdown_fp)(void* deviceHandle);
369 typedef void*   (*GHOST_NDOFDeviceOpen_fp)(void* platformData);
370
371 // original patch windows callback. In mac os X version the callback is internal to the plug-in and post an event to main thead.
372 // not necessary faster, but better integration with other events. 
373
374 //typedef int     (*GHOST_NDOFEventHandler_fp)(float* result7, void* deviceHandle, unsigned int message, unsigned int* wParam, unsigned long* lParam);
375 //typedef void     (*GHOST_NDOFCallBack_fp)(GHOST_TEventNDOFDataV2 *VolDatas);
376
377 typedef struct {
378         /** The key code. */
379         GHOST_TKey              key;
380         /** The ascii code for the key event ('\0' if none). */
381         char                    ascii;
382 } GHOST_TEventKeyData;
383
384 typedef struct {
385         /** Number of pixels on a line. */
386         GHOST_TUns32    xPixels;
387         /** Number of lines. */
388         GHOST_TUns32    yPixels;
389         /** Numberof bits per pixel. */
390         GHOST_TUns32    bpp;
391         /** Refresh rate (in Hertz). */
392         GHOST_TUns32    frequency;
393 } GHOST_DisplaySetting;
394
395
396 #ifdef _WIN32
397 typedef long GHOST_TEmbedderWindowID;
398 #endif // _WIN32
399
400 #ifndef _WIN32
401 // I can't use "Window" from "<X11/Xlib.h>" because it conflits with Window defined in winlay.h
402 typedef int GHOST_TEmbedderWindowID;
403 #endif // _WIN32
404
405 /**
406  * A timer task callback routine.
407  * @param task The timer task object.
408  * @param time The current time.
409  */
410 #ifdef __cplusplus
411 class GHOST_ITimerTask;
412 typedef void (*GHOST_TimerProcPtr)(GHOST_ITimerTask* task, GHOST_TUns64 time);
413 #else
414 struct GHOST_TimerTaskHandle__;
415 typedef void (*GHOST_TimerProcPtr)(struct GHOST_TimerTaskHandle__* task, GHOST_TUns64 time);
416 #endif
417
418 #endif // _GHOST_TYPES_H_
419