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