doxygen: make sure license blocks don't interfere.
[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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 #ifdef WITH_CXX_GUARDEDALLOC
33 #include "MEM_guardedalloc.h"
34 #endif
35
36 #define GHOST_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
37
38 typedef char                            GHOST_TInt8;
39 typedef unsigned char           GHOST_TUns8;
40 typedef short                           GHOST_TInt16;
41 typedef unsigned short          GHOST_TUns16;
42 typedef int                                     GHOST_TInt32;
43 typedef unsigned int            GHOST_TUns32;
44
45 #ifdef WIN32
46 #define WM_BLND_NDOF_AXIS       WM_USER + 1
47 #define WM_BLND_NDOF_BTN        WM_USER + 2
48 #endif
49
50 #if defined(WIN32) && !defined(FREE_WINDOWS)
51 typedef __int64                         GHOST_TInt64;
52 typedef unsigned __int64        GHOST_TUns64;
53 #else
54 typedef long long                       GHOST_TInt64;
55 typedef unsigned long long      GHOST_TUns64;
56 #endif
57
58 typedef void*                           GHOST_TUserDataPtr;
59
60 typedef enum
61 {
62         GHOST_kFailure = 0,
63         GHOST_kSuccess
64 } GHOST_TSuccess;
65
66 /* Xtilt and Ytilt represent how much the pen is tilted away from 
67  * vertically upright in either the X or Y direction, with X and Y the
68  * axes of the tablet surface.
69  * In other words, Xtilt and Ytilt are components of a vector created by projecting
70  * the pen's angle in 3D space vertically downwards on to the XY plane
71  * --Matt
72  */
73 typedef enum {
74         GHOST_kTabletModeNone = 0,
75         GHOST_kTabletModeStylus,
76         GHOST_kTabletModeEraser
77 } GHOST_TTabletMode;
78
79 typedef struct GHOST_TabletData {
80         GHOST_TTabletMode Active; /* 0=None, 1=Stylus, 2=Eraser */
81         float Pressure; /* range 0.0 (not touching) to 1.0 (full pressure) */
82         float Xtilt;    /* range 0.0 (upright) to 1.0 (tilted fully against the tablet surface) */
83         float Ytilt;    /* as above */
84 } GHOST_TabletData;
85
86
87 typedef enum {
88         GHOST_kNotVisible = 0,
89         GHOST_kPartiallyVisible,
90         GHOST_kFullyVisible
91 } GHOST_TVisibility;
92
93
94 typedef enum {
95         GHOST_kFireTimeNever = 0xFFFFFFFF
96 } GHOST_TFireTimeConstant;
97
98 typedef enum {
99     GHOST_kModifierKeyLeftShift = 0,
100     GHOST_kModifierKeyRightShift,
101     GHOST_kModifierKeyLeftAlt,
102     GHOST_kModifierKeyRightAlt,
103     GHOST_kModifierKeyLeftControl,
104     GHOST_kModifierKeyRightControl,
105     GHOST_kModifierKeyOS,
106     GHOST_kModifierKeyNumMasks
107 } GHOST_TModifierKeyMask;
108
109
110 typedef enum {
111         GHOST_kWindowStateNormal = 0,
112         GHOST_kWindowStateMaximized,
113         GHOST_kWindowStateMinimized,
114         GHOST_kWindowStateFullScreen,
115         GHOST_kWindowStateEmbedded,
116         GHOST_kWindowState8Normal = 8,
117         GHOST_kWindowState8Maximized,
118         GHOST_kWindowState8Minimized,
119         GHOST_kWindowState8FullScreen,
120         GHOST_kWindowStateModified,
121         GHOST_kWindowStateUnModified
122 } GHOST_TWindowState;
123
124
125 /** Constants for the answer to the blender exit request */
126 typedef enum {
127         GHOST_kExitCancel = 0,
128         GHOST_kExitNow
129 } GHOST_TExitRequestResponse;
130
131 typedef enum {
132         GHOST_kWindowOrderTop = 0,
133         GHOST_kWindowOrderBottom
134 } GHOST_TWindowOrder;
135
136
137 typedef enum {
138         GHOST_kDrawingContextTypeNone = 0,
139         GHOST_kDrawingContextTypeOpenGL
140 } GHOST_TDrawingContextType;
141
142
143 typedef enum {
144         GHOST_kButtonMaskLeft = 0,
145         GHOST_kButtonMaskMiddle,
146         GHOST_kButtonMaskRight,
147         GHOST_kButtonMaskButton4,
148         GHOST_kButtonMaskButton5,
149         GHOST_kButtonNumMasks
150 } GHOST_TButtonMask;
151
152
153 typedef enum {
154         GHOST_kEventUnknown = 0,
155
156         GHOST_kEventCursorMove,         /// Mouse move event
157         GHOST_kEventButtonDown,         /// Mouse button event
158         GHOST_kEventButtonUp,           /// Mouse button event
159         GHOST_kEventWheel,                      /// Mouse wheel event
160         GHOST_kEventTrackpad,           /// Trackpad event
161
162         GHOST_kEventNDOFMotion,         /// N degree of freedom device motion event
163         GHOST_kEventNDOFButton,         /// N degree of freedom device button event
164
165         GHOST_kEventKeyDown,
166         GHOST_kEventKeyUp,
167 //      GHOST_kEventKeyAuto,
168
169         GHOST_kEventQuit,
170
171         GHOST_kEventWindowClose,
172         GHOST_kEventWindowActivate,
173         GHOST_kEventWindowDeactivate,
174         GHOST_kEventWindowUpdate,
175         GHOST_kEventWindowSize,
176         GHOST_kEventWindowMove,
177         
178         GHOST_kEventDraggingEntered,
179         GHOST_kEventDraggingUpdated,
180         GHOST_kEventDraggingExited,
181         GHOST_kEventDraggingDropDone,
182         
183         GHOST_kEventOpenMainFile, // Needed for Cocoa to open double-clicked .blend file at startup
184
185         GHOST_kEventTimer,
186
187         GHOST_kNumEventTypes
188 } GHOST_TEventType;
189
190
191 typedef enum {
192         GHOST_kStandardCursorFirstCursor = 0,
193         GHOST_kStandardCursorDefault = 0,
194         GHOST_kStandardCursorRightArrow,
195         GHOST_kStandardCursorLeftArrow,
196         GHOST_kStandardCursorInfo, 
197         GHOST_kStandardCursorDestroy,
198         GHOST_kStandardCursorHelp,    
199         GHOST_kStandardCursorCycle,
200         GHOST_kStandardCursorSpray,
201         GHOST_kStandardCursorWait,
202         GHOST_kStandardCursorText,
203         GHOST_kStandardCursorCrosshair,
204         GHOST_kStandardCursorUpDown,
205         GHOST_kStandardCursorLeftRight,
206         GHOST_kStandardCursorTopSide,
207         GHOST_kStandardCursorBottomSide,
208         GHOST_kStandardCursorLeftSide,
209         GHOST_kStandardCursorRightSide,
210         GHOST_kStandardCursorTopLeftCorner,
211         GHOST_kStandardCursorTopRightCorner,
212         GHOST_kStandardCursorBottomRightCorner,
213         GHOST_kStandardCursorBottomLeftCorner,
214         GHOST_kStandardCursorCopy,
215         GHOST_kStandardCursorCustom, 
216         GHOST_kStandardCursorNumCursors, 
217         GHOST_kStandardCursorPencil
218 } GHOST_TStandardCursor;
219
220
221 typedef enum {
222         GHOST_kKeyUnknown = -1,
223         GHOST_kKeyBackSpace,
224         GHOST_kKeyTab,
225         GHOST_kKeyLinefeed,
226         GHOST_kKeyClear,
227         GHOST_kKeyEnter  = 0x0D,
228         
229         GHOST_kKeyEsc    = 0x1B,
230         GHOST_kKeySpace  = ' ',
231         GHOST_kKeyQuote  = 0x27,
232         GHOST_kKeyComma  = ',',
233         GHOST_kKeyMinus  = '-',
234         GHOST_kKeyPeriod = '.',
235         GHOST_kKeySlash  = '/',
236
237         // Number keys
238         GHOST_kKey0 = '0',
239         GHOST_kKey1,
240         GHOST_kKey2,
241         GHOST_kKey3,
242         GHOST_kKey4,
243         GHOST_kKey5,
244         GHOST_kKey6,
245         GHOST_kKey7,
246         GHOST_kKey8,
247         GHOST_kKey9,
248
249         GHOST_kKeySemicolon = ';',
250         GHOST_kKeyEqual     = '=',
251
252         // Character keys
253         GHOST_kKeyA = 'A',
254         GHOST_kKeyB,
255         GHOST_kKeyC,
256         GHOST_kKeyD,
257         GHOST_kKeyE,
258         GHOST_kKeyF,
259         GHOST_kKeyG,
260         GHOST_kKeyH,
261         GHOST_kKeyI,
262         GHOST_kKeyJ,
263         GHOST_kKeyK,
264         GHOST_kKeyL,
265         GHOST_kKeyM,
266         GHOST_kKeyN,
267         GHOST_kKeyO,
268         GHOST_kKeyP,
269         GHOST_kKeyQ,
270         GHOST_kKeyR,
271         GHOST_kKeyS,
272         GHOST_kKeyT,
273         GHOST_kKeyU,
274         GHOST_kKeyV,
275         GHOST_kKeyW,
276         GHOST_kKeyX,
277         GHOST_kKeyY,
278         GHOST_kKeyZ,
279
280         GHOST_kKeyLeftBracket  = '[',
281         GHOST_kKeyRightBracket = ']',
282         GHOST_kKeyBackslash    = 0x5C,
283         GHOST_kKeyAccentGrave  = '`',
284
285         
286         GHOST_kKeyLeftShift = 0x100,
287         GHOST_kKeyRightShift,
288         GHOST_kKeyLeftControl,
289         GHOST_kKeyRightControl,
290         GHOST_kKeyLeftAlt,
291         GHOST_kKeyRightAlt,
292         GHOST_kKeyOS,           // Command key on Apple, Windows key(s) on Windows
293         GHOST_kKeyGrLess ,              // German PC only!
294
295         GHOST_kKeyCapsLock,
296         GHOST_kKeyNumLock,
297         GHOST_kKeyScrollLock,
298
299         GHOST_kKeyLeftArrow,
300         GHOST_kKeyRightArrow,
301         GHOST_kKeyUpArrow,
302         GHOST_kKeyDownArrow,
303
304         GHOST_kKeyPrintScreen,
305         GHOST_kKeyPause,
306
307         GHOST_kKeyInsert,
308         GHOST_kKeyDelete,
309         GHOST_kKeyHome,
310         GHOST_kKeyEnd,
311         GHOST_kKeyUpPage,
312         GHOST_kKeyDownPage,
313
314         // Numpad keys
315         GHOST_kKeyNumpad0,
316         GHOST_kKeyNumpad1,
317         GHOST_kKeyNumpad2,
318         GHOST_kKeyNumpad3,
319         GHOST_kKeyNumpad4,
320         GHOST_kKeyNumpad5,
321         GHOST_kKeyNumpad6,
322         GHOST_kKeyNumpad7,
323         GHOST_kKeyNumpad8,
324         GHOST_kKeyNumpad9,
325         GHOST_kKeyNumpadPeriod,
326         GHOST_kKeyNumpadEnter,
327         GHOST_kKeyNumpadPlus,
328         GHOST_kKeyNumpadMinus,
329         GHOST_kKeyNumpadAsterisk,
330         GHOST_kKeyNumpadSlash,
331
332         // Function keys
333         GHOST_kKeyF1,
334         GHOST_kKeyF2,
335         GHOST_kKeyF3,
336         GHOST_kKeyF4,
337         GHOST_kKeyF5,
338         GHOST_kKeyF6,
339         GHOST_kKeyF7,
340         GHOST_kKeyF8,
341         GHOST_kKeyF9,
342         GHOST_kKeyF10,
343         GHOST_kKeyF11,
344         GHOST_kKeyF12,
345         GHOST_kKeyF13,
346         GHOST_kKeyF14,
347         GHOST_kKeyF15,
348         GHOST_kKeyF16,
349         GHOST_kKeyF17,
350         GHOST_kKeyF18,
351         GHOST_kKeyF19,
352         GHOST_kKeyF20,
353         GHOST_kKeyF21,
354         GHOST_kKeyF22,
355         GHOST_kKeyF23,
356         GHOST_kKeyF24,
357         
358         // Multimedia keypad buttons
359         GHOST_kKeyMediaPlay,
360         GHOST_kKeyMediaStop,
361         GHOST_kKeyMediaFirst,
362         GHOST_kKeyMediaLast
363 } GHOST_TKey;
364
365 typedef enum {
366         GHOST_kGrabDisable = 0, /* grab not set */
367         GHOST_kGrabNormal,      /* no cursor adjustments */
368         GHOST_kGrabWrap,                /* wrap the mouse location to prevent limiting screen bounds */
369         GHOST_kGrabHide,                /* hide the mouse while grabbing and restore the original location on release (numbuts) */
370 } GHOST_TGrabCursorMode;
371
372 typedef void* GHOST_TEventDataPtr;
373
374 typedef struct {
375         /** The x-coordinate of the cursor position. */
376         GHOST_TInt32 x;
377         /** The y-coordinate of the cursor position. */
378         GHOST_TInt32 y;
379 } GHOST_TEventCursorData;
380
381 typedef struct {
382         /** The mask of the mouse button. */
383         GHOST_TButtonMask button;
384 } GHOST_TEventButtonData;
385
386 typedef struct {
387         /** Displacement of a mouse wheel. */
388         GHOST_TInt32 z; 
389 } GHOST_TEventWheelData;
390
391 typedef enum {
392         GHOST_kTrackpadEventUnknown =0,
393         GHOST_kTrackpadEventScroll,
394         GHOST_kTrackpadEventRotate,
395         GHOST_kTrackpadEventSwipe, /* Reserved, not used for now */
396         GHOST_kTrackpadEventMagnify
397 } GHOST_TTrackpadEventSubTypes;
398         
399
400 typedef struct {
401         /** The event subtype */
402         GHOST_TTrackpadEventSubTypes subtype;
403         /** The x-location of the trackpad event */
404         GHOST_TInt32 x;
405         /** The y-location of the trackpad event */
406         GHOST_TInt32 y;
407         /** The x-delta or value of the trackpad event */
408         GHOST_TInt32 deltaX;
409         /** The y-delta (currently only for scroll subtype) of the trackpad event */
410         GHOST_TInt32 deltaY;
411 } GHOST_TEventTrackpadData;
412
413
414 typedef enum {
415         GHOST_kDragnDropTypeUnknown =0,
416         GHOST_kDragnDropTypeFilenames, /*Array of strings representing file names (full path) */
417         GHOST_kDragnDropTypeString, /* Unformatted text UTF-8 string */
418         GHOST_kDragnDropTypeBitmap /*Bitmap image data */
419 } GHOST_TDragnDropTypes;
420
421 typedef struct {
422         /** The x-coordinate of the cursor position. */
423         GHOST_TInt32 x;
424         /** The y-coordinate of the cursor position. */
425         GHOST_TInt32 y;
426         /** The dropped item type */
427         GHOST_TDragnDropTypes dataType;
428         /** The "dropped content" */
429         GHOST_TEventDataPtr data;
430 } GHOST_TEventDragnDropData;
431
432 typedef struct {
433         int count;
434         GHOST_TUns8 **strings;
435 } GHOST_TStringArray;
436
437
438 /* original patch used floats, but the driver return ints and uns. We will calibrate in view, no sense on doing conversions twice */
439 /* as all USB device controls are likely to use ints, this is also more future proof */
440 //typedef struct {
441 //   /** N-degree of freedom device data */
442 //   float tx, ty, tz;   /** -x left, +y up, +z forward */
443 //   float rx, ry, rz;
444 //   float dt;
445 //} GHOST_TEventNDOFData;
446
447 typedef struct {
448    /** N-degree of freedom device data v2*/
449    int changed;
450    GHOST_TUns64 client;
451    GHOST_TUns64 address;
452    GHOST_TInt16 tx, ty, tz;   /** -x left, +y up, +z forward */
453    GHOST_TInt16 rx, ry, rz;
454    GHOST_TInt16 buttons;
455    GHOST_TUns64 time;
456    GHOST_TUns64 delta;
457 } GHOST_TEventNDOFData;
458
459 typedef int     (*GHOST_NDOFLibraryInit_fp)(void);
460 typedef void    (*GHOST_NDOFLibraryShutdown_fp)(void* deviceHandle);
461 typedef void*   (*GHOST_NDOFDeviceOpen_fp)(void* platformData);
462
463 // original patch windows callback. In mac os X version the callback is internal to the plug-in and post an event to main thead.
464 // not necessary faster, but better integration with other events. 
465
466 //typedef int     (*GHOST_NDOFEventHandler_fp)(float* result7, void* deviceHandle, unsigned int message, unsigned int* wParam, unsigned long* lParam);
467 //typedef void     (*GHOST_NDOFCallBack_fp)(GHOST_TEventNDOFDataV2 *VolDatas);
468
469 typedef struct {
470         /** The key code. */
471         GHOST_TKey              key;
472         /** The ascii code for the key event ('\0' if none). */
473         char                    ascii;
474 } GHOST_TEventKeyData;
475
476 typedef struct {
477         /** Number of pixels on a line. */
478         GHOST_TUns32    xPixels;
479         /** Number of lines. */
480         GHOST_TUns32    yPixels;
481         /** Numberof bits per pixel. */
482         GHOST_TUns32    bpp;
483         /** Refresh rate (in Hertz). */
484         GHOST_TUns32    frequency;
485 } GHOST_DisplaySetting;
486
487
488 #ifdef _WIN32
489 typedef long GHOST_TEmbedderWindowID;
490 #endif // _WIN32
491
492 #ifndef _WIN32
493 // I can't use "Window" from "<X11/Xlib.h>" because it conflits with Window defined in winlay.h
494 typedef int GHOST_TEmbedderWindowID;
495 #endif // _WIN32
496
497 /**
498  * A timer task callback routine.
499  * @param task The timer task object.
500  * @param time The current time.
501  */
502 #ifdef __cplusplus
503 class GHOST_ITimerTask;
504 typedef void (*GHOST_TimerProcPtr)(GHOST_ITimerTask* task, GHOST_TUns64 time);
505 #else
506 struct GHOST_TimerTaskHandle__;
507 typedef void (*GHOST_TimerProcPtr)(struct GHOST_TimerTaskHandle__* task, GHOST_TUns64 time);
508 #endif
509
510 #endif // _GHOST_TYPES_H_
511