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