Cocoa port :
[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 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
155         GHOST_kEventNDOFMotion,         /// N degree of freedom device motion event
156         GHOST_kEventNDOFButton,         /// N degree of freedom device button event
157
158         GHOST_kEventKeyDown,
159         GHOST_kEventKeyUp,
160 //      GHOST_kEventKeyAuto,
161
162         GHOST_kEventQuit,
163
164         GHOST_kEventWindowClose,
165         GHOST_kEventWindowActivate,
166         GHOST_kEventWindowDeactivate,
167         GHOST_kEventWindowUpdate,
168         GHOST_kEventWindowSize,
169         GHOST_kEventWindowMove,
170
171         GHOST_kEventTimer,
172
173         GHOST_kNumEventTypes
174 } GHOST_TEventType;
175
176
177 typedef enum {
178         GHOST_kStandardCursorFirstCursor = 0,
179         GHOST_kStandardCursorDefault = 0,
180         GHOST_kStandardCursorRightArrow,
181         GHOST_kStandardCursorLeftArrow,
182         GHOST_kStandardCursorInfo, 
183         GHOST_kStandardCursorDestroy,
184         GHOST_kStandardCursorHelp,    
185         GHOST_kStandardCursorCycle,
186         GHOST_kStandardCursorSpray,
187         GHOST_kStandardCursorWait,
188         GHOST_kStandardCursorText,
189         GHOST_kStandardCursorCrosshair,
190         GHOST_kStandardCursorUpDown,
191         GHOST_kStandardCursorLeftRight,
192         GHOST_kStandardCursorTopSide,
193         GHOST_kStandardCursorBottomSide,
194         GHOST_kStandardCursorLeftSide,
195         GHOST_kStandardCursorRightSide,
196         GHOST_kStandardCursorTopLeftCorner,
197         GHOST_kStandardCursorTopRightCorner,
198         GHOST_kStandardCursorBottomRightCorner,
199         GHOST_kStandardCursorBottomLeftCorner,
200         GHOST_kStandardCursorCustom, 
201         GHOST_kStandardCursorNumCursors, 
202         GHOST_kStandardCursorPencil
203 } GHOST_TStandardCursor;
204
205
206 typedef enum {
207         GHOST_kKeyUnknown = -1,
208         GHOST_kKeyBackSpace,
209         GHOST_kKeyTab,
210         GHOST_kKeyLinefeed,
211         GHOST_kKeyClear,
212         GHOST_kKeyEnter  = 0x0D,
213         
214         GHOST_kKeyEsc    = 0x1B,
215         GHOST_kKeySpace  = ' ',
216         GHOST_kKeyQuote  = 0x27,
217         GHOST_kKeyComma  = ',',
218         GHOST_kKeyMinus  = '-',
219         GHOST_kKeyPeriod = '.',
220         GHOST_kKeySlash  = '/',
221
222         // Number keys
223         GHOST_kKey0 = '0',
224         GHOST_kKey1,
225         GHOST_kKey2,
226         GHOST_kKey3,
227         GHOST_kKey4,
228         GHOST_kKey5,
229         GHOST_kKey6,
230         GHOST_kKey7,
231         GHOST_kKey8,
232         GHOST_kKey9,
233
234         GHOST_kKeySemicolon = ';',
235         GHOST_kKeyEqual     = '=',
236
237         // Character keys
238         GHOST_kKeyA = 'A',
239         GHOST_kKeyB,
240         GHOST_kKeyC,
241         GHOST_kKeyD,
242         GHOST_kKeyE,
243         GHOST_kKeyF,
244         GHOST_kKeyG,
245         GHOST_kKeyH,
246         GHOST_kKeyI,
247         GHOST_kKeyJ,
248         GHOST_kKeyK,
249         GHOST_kKeyL,
250         GHOST_kKeyM,
251         GHOST_kKeyN,
252         GHOST_kKeyO,
253         GHOST_kKeyP,
254         GHOST_kKeyQ,
255         GHOST_kKeyR,
256         GHOST_kKeyS,
257         GHOST_kKeyT,
258         GHOST_kKeyU,
259         GHOST_kKeyV,
260         GHOST_kKeyW,
261         GHOST_kKeyX,
262         GHOST_kKeyY,
263         GHOST_kKeyZ,
264
265         GHOST_kKeyLeftBracket  = '[',
266         GHOST_kKeyRightBracket = ']',
267         GHOST_kKeyBackslash    = 0x5C,
268         GHOST_kKeyAccentGrave  = '`',
269
270         
271         GHOST_kKeyLeftShift = 0x100,
272         GHOST_kKeyRightShift,
273         GHOST_kKeyLeftControl,
274         GHOST_kKeyRightControl,
275         GHOST_kKeyLeftAlt,
276         GHOST_kKeyRightAlt,
277     GHOST_kKeyCommand,                          // APPLE only!
278     GHOST_kKeyGrLess ,          // German PC only!
279
280         GHOST_kKeyCapsLock,
281         GHOST_kKeyNumLock,
282         GHOST_kKeyScrollLock,
283
284         GHOST_kKeyLeftArrow,
285         GHOST_kKeyRightArrow,
286         GHOST_kKeyUpArrow,
287         GHOST_kKeyDownArrow,
288
289         GHOST_kKeyPrintScreen,
290         GHOST_kKeyPause,
291
292         GHOST_kKeyInsert,
293         GHOST_kKeyDelete,
294         GHOST_kKeyHome,
295         GHOST_kKeyEnd,
296         GHOST_kKeyUpPage,
297         GHOST_kKeyDownPage,
298
299         // Numpad keys
300         GHOST_kKeyNumpad0,
301         GHOST_kKeyNumpad1,
302         GHOST_kKeyNumpad2,
303         GHOST_kKeyNumpad3,
304         GHOST_kKeyNumpad4,
305         GHOST_kKeyNumpad5,
306         GHOST_kKeyNumpad6,
307         GHOST_kKeyNumpad7,
308         GHOST_kKeyNumpad8,
309         GHOST_kKeyNumpad9,
310         GHOST_kKeyNumpadPeriod,
311         GHOST_kKeyNumpadEnter,
312         GHOST_kKeyNumpadPlus,
313         GHOST_kKeyNumpadMinus,
314         GHOST_kKeyNumpadAsterisk,
315         GHOST_kKeyNumpadSlash,
316
317         // Function keys
318         GHOST_kKeyF1,
319         GHOST_kKeyF2,
320         GHOST_kKeyF3,
321         GHOST_kKeyF4,
322         GHOST_kKeyF5,
323         GHOST_kKeyF6,
324         GHOST_kKeyF7,
325         GHOST_kKeyF8,
326         GHOST_kKeyF9,
327         GHOST_kKeyF10,
328         GHOST_kKeyF11,
329         GHOST_kKeyF12,
330         GHOST_kKeyF13,
331         GHOST_kKeyF14,
332         GHOST_kKeyF15,
333         GHOST_kKeyF16,
334         GHOST_kKeyF17,
335         GHOST_kKeyF18,
336         GHOST_kKeyF19,
337         GHOST_kKeyF20,
338         GHOST_kKeyF21,
339         GHOST_kKeyF22,
340         GHOST_kKeyF23,
341         GHOST_kKeyF24
342 } GHOST_TKey;
343
344
345 typedef void* GHOST_TEventDataPtr;
346
347 typedef struct {
348         /** The x-coordinate of the cursor position. */
349         GHOST_TInt32 x;
350         /** The y-coordinate of the cursor position. */
351         GHOST_TInt32 y;
352 } GHOST_TEventCursorData;
353
354 typedef struct {
355         /** The mask of the mouse button. */
356         GHOST_TButtonMask button;
357 } GHOST_TEventButtonData;
358
359 typedef struct {
360         /** Displacement of a mouse wheel. */
361         GHOST_TInt32 z; 
362 } GHOST_TEventWheelData;
363
364
365 /* original patch used floats, but the driver return ints and uns. We will calibrate in view, no sense on doing conversions twice */
366 /* as all USB device controls are likely to use ints, this is also more future proof */
367 //typedef struct {
368 //   /** N-degree of freedom device data */
369 //   float tx, ty, tz;   /** -x left, +y up, +z forward */
370 //   float rx, ry, rz;
371 //   float dt;
372 //} GHOST_TEventNDOFData;
373
374 typedef struct {
375    /** N-degree of freedom device data v2*/
376    int changed;
377    GHOST_TUns64 client;
378    GHOST_TUns64 address;
379    GHOST_TInt16 tx, ty, tz;   /** -x left, +y up, +z forward */
380    GHOST_TInt16 rx, ry, rz;
381    GHOST_TInt16 buttons;
382    GHOST_TUns64 time;
383    GHOST_TUns64 delta;
384 } GHOST_TEventNDOFData;
385
386 typedef int     (*GHOST_NDOFLibraryInit_fp)();
387 typedef void    (*GHOST_NDOFLibraryShutdown_fp)(void* deviceHandle);
388 typedef void*   (*GHOST_NDOFDeviceOpen_fp)(void* platformData);
389
390 // original patch windows callback. In mac os X version the callback is internal to the plug-in and post an event to main thead.
391 // not necessary faster, but better integration with other events. 
392
393 //typedef int     (*GHOST_NDOFEventHandler_fp)(float* result7, void* deviceHandle, unsigned int message, unsigned int* wParam, unsigned long* lParam);
394 //typedef void     (*GHOST_NDOFCallBack_fp)(GHOST_TEventNDOFDataV2 *VolDatas);
395
396 typedef struct {
397         /** The key code. */
398         GHOST_TKey              key;
399         /** The ascii code for the key event ('\0' if none). */
400         char                    ascii;
401 } GHOST_TEventKeyData;
402
403 typedef struct {
404         /** Number of pixels on a line. */
405         GHOST_TUns32    xPixels;
406         /** Number of lines. */
407         GHOST_TUns32    yPixels;
408         /** Numberof bits per pixel. */
409         GHOST_TUns32    bpp;
410         /** Refresh rate (in Hertz). */
411         GHOST_TUns32    frequency;
412 } GHOST_DisplaySetting;
413
414
415 #ifdef _WIN32
416 typedef long GHOST_TEmbedderWindowID;
417 #endif // _WIN32
418
419 #ifndef _WIN32
420 // I can't use "Window" from "<X11/Xlib.h>" because it conflits with Window defined in winlay.h
421 typedef int GHOST_TEmbedderWindowID;
422 #endif // _WIN32
423
424 /**
425  * A timer task callback routine.
426  * @param task The timer task object.
427  * @param time The current time.
428  */
429 #ifdef __cplusplus
430 class GHOST_ITimerTask;
431 typedef void (*GHOST_TimerProcPtr)(GHOST_ITimerTask* task, GHOST_TUns64 time);
432 #else
433 struct GHOST_TimerTaskHandle__;
434 typedef void (*GHOST_TimerProcPtr)(struct GHOST_TimerTaskHandle__* task, GHOST_TUns64 time);
435 #endif
436
437 #endif // _GHOST_TYPES_H_
438