fix bug #1546
[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
59 typedef enum {
60         GHOST_kNotVisible = 0,
61         GHOST_kPartiallyVisible,
62         GHOST_kFullyVisible
63 } GHOST_TVisibility;
64
65
66 typedef enum {
67         GHOST_kFireTimeNever = 0xFFFFFFFF
68 } GHOST_TFireTimeConstant;
69
70 typedef enum {
71     GHOST_kModifierKeyLeftShift = 0,
72     GHOST_kModifierKeyRightShift,
73     GHOST_kModifierKeyLeftAlt,
74     GHOST_kModifierKeyRightAlt,
75     GHOST_kModifierKeyLeftControl,
76     GHOST_kModifierKeyRightControl,
77     GHOST_kModifierKeyCommand,          // APPLE only
78     GHOST_kModifierKeyNumMasks
79 } GHOST_TModifierKeyMask;
80
81
82 typedef enum {
83         GHOST_kWindowStateNormal = 0,
84         GHOST_kWindowStateMaximized,
85         GHOST_kWindowStateMinimized,
86         GHOST_kWindowStateFullScreen
87 } GHOST_TWindowState;
88
89
90 typedef enum {
91         GHOST_kWindowOrderTop = 0,
92         GHOST_kWindowOrderBottom
93 } GHOST_TWindowOrder;
94
95
96 typedef enum {
97         GHOST_kDrawingContextTypeNone = 0,
98         GHOST_kDrawingContextTypeOpenGL
99 } GHOST_TDrawingContextType;
100
101
102 typedef enum {
103         GHOST_kButtonMaskLeft = 0,
104         GHOST_kButtonMaskMiddle,
105         GHOST_kButtonMaskRight,
106         GHOST_kButtonNumMasks
107 } GHOST_TButtonMask;
108
109
110 typedef enum {
111         GHOST_kEventUnknown = 0,
112
113         GHOST_kEventCursorMove,         /// Mouse move event
114         GHOST_kEventButtonDown,         /// Mouse button event
115         GHOST_kEventButtonUp,           /// Mouse button event
116         GHOST_kEventWheel,                      /// Mouse wheel event
117
118         GHOST_kEventKeyDown,
119         GHOST_kEventKeyUp,
120 //      GHOST_kEventKeyAuto,
121
122         GHOST_kEventQuit,
123
124         GHOST_kEventWindowClose,
125         GHOST_kEventWindowActivate,
126         GHOST_kEventWindowDeactivate,
127         GHOST_kEventWindowUpdate,
128         GHOST_kEventWindowSize,
129
130         GHOST_kNumEventTypes
131 } GHOST_TEventType;
132
133
134 typedef enum {
135         GHOST_kStandardCursorFirstCursor = 0,
136         GHOST_kStandardCursorDefault = 0,
137         GHOST_kStandardCursorRightArrow,
138         GHOST_kStandardCursorLeftArrow,
139         GHOST_kStandardCursorInfo, 
140         GHOST_kStandardCursorDestroy,
141         GHOST_kStandardCursorHelp,    
142         GHOST_kStandardCursorCycle,
143         GHOST_kStandardCursorSpray,
144         GHOST_kStandardCursorWait,
145         GHOST_kStandardCursorText,
146         GHOST_kStandardCursorCrosshair,
147         GHOST_kStandardCursorUpDown,
148         GHOST_kStandardCursorLeftRight,
149         GHOST_kStandardCursorTopSide,
150         GHOST_kStandardCursorBottomSide,
151         GHOST_kStandardCursorLeftSide,
152         GHOST_kStandardCursorRightSide,
153         GHOST_kStandardCursorTopLeftCorner,
154         GHOST_kStandardCursorTopRightCorner,
155         GHOST_kStandardCursorBottomRightCorner,
156         GHOST_kStandardCursorBottomLeftCorner,
157         GHOST_kStandardCursorCustom, 
158         GHOST_kStandardCursorNumCursors, 
159         GHOST_kStandardCursorPencil
160 } GHOST_TStandardCursor;
161
162
163 typedef enum {
164         GHOST_kKeyUnknown = -1,
165         GHOST_kKeyBackSpace,
166         GHOST_kKeyTab,
167         GHOST_kKeyLinefeed,
168         GHOST_kKeyClear,
169         GHOST_kKeyEnter  = 0x0D,
170         
171         GHOST_kKeyEsc    = 0x1B,
172         GHOST_kKeySpace  = ' ',
173         GHOST_kKeyQuote  = 0x27,
174         GHOST_kKeyComma  = ',',
175         GHOST_kKeyMinus  = '-',
176         GHOST_kKeyPeriod = '.',
177         GHOST_kKeySlash  = '/',
178
179         // Number keys
180         GHOST_kKey0 = '0',
181         GHOST_kKey1,
182         GHOST_kKey2,
183         GHOST_kKey3,
184         GHOST_kKey4,
185         GHOST_kKey5,
186         GHOST_kKey6,
187         GHOST_kKey7,
188         GHOST_kKey8,
189         GHOST_kKey9,
190
191         GHOST_kKeySemicolon = ';',
192         GHOST_kKeyEqual     = '=',
193
194         // Character keys
195         GHOST_kKeyA = 'A',
196         GHOST_kKeyB,
197         GHOST_kKeyC,
198         GHOST_kKeyD,
199         GHOST_kKeyE,
200         GHOST_kKeyF,
201         GHOST_kKeyG,
202         GHOST_kKeyH,
203         GHOST_kKeyI,
204         GHOST_kKeyJ,
205         GHOST_kKeyK,
206         GHOST_kKeyL,
207         GHOST_kKeyM,
208         GHOST_kKeyN,
209         GHOST_kKeyO,
210         GHOST_kKeyP,
211         GHOST_kKeyQ,
212         GHOST_kKeyR,
213         GHOST_kKeyS,
214         GHOST_kKeyT,
215         GHOST_kKeyU,
216         GHOST_kKeyV,
217         GHOST_kKeyW,
218         GHOST_kKeyX,
219         GHOST_kKeyY,
220         GHOST_kKeyZ,
221
222         GHOST_kKeyLeftBracket  = '[',
223         GHOST_kKeyRightBracket = ']',
224         GHOST_kKeyBackslash    = 0x5C,
225         GHOST_kKeyAccentGrave  = '`',
226
227         
228         GHOST_kKeyLeftShift = 0x100,
229         GHOST_kKeyRightShift,
230         GHOST_kKeyLeftControl,
231         GHOST_kKeyRightControl,
232         GHOST_kKeyLeftAlt,
233         GHOST_kKeyRightAlt,
234     GHOST_kKeyCommand,                          // APPLE only!
235     GHOST_kKeyGrLess ,          // German PC only!
236
237         GHOST_kKeyCapsLock,
238         GHOST_kKeyNumLock,
239         GHOST_kKeyScrollLock,
240
241         GHOST_kKeyLeftArrow,
242         GHOST_kKeyRightArrow,
243         GHOST_kKeyUpArrow,
244         GHOST_kKeyDownArrow,
245
246         GHOST_kKeyPrintScreen,
247         GHOST_kKeyPause,
248
249         GHOST_kKeyInsert,
250         GHOST_kKeyDelete,
251         GHOST_kKeyHome,
252         GHOST_kKeyEnd,
253         GHOST_kKeyUpPage,
254         GHOST_kKeyDownPage,
255
256         // Numpad keys
257         GHOST_kKeyNumpad0,
258         GHOST_kKeyNumpad1,
259         GHOST_kKeyNumpad2,
260         GHOST_kKeyNumpad3,
261         GHOST_kKeyNumpad4,
262         GHOST_kKeyNumpad5,
263         GHOST_kKeyNumpad6,
264         GHOST_kKeyNumpad7,
265         GHOST_kKeyNumpad8,
266         GHOST_kKeyNumpad9,
267         GHOST_kKeyNumpadPeriod,
268         GHOST_kKeyNumpadEnter,
269         GHOST_kKeyNumpadPlus,
270         GHOST_kKeyNumpadMinus,
271         GHOST_kKeyNumpadAsterisk,
272         GHOST_kKeyNumpadSlash,
273
274         // Function keys
275         GHOST_kKeyF1,
276         GHOST_kKeyF2,
277         GHOST_kKeyF3,
278         GHOST_kKeyF4,
279         GHOST_kKeyF5,
280         GHOST_kKeyF6,
281         GHOST_kKeyF7,
282         GHOST_kKeyF8,
283         GHOST_kKeyF9,
284         GHOST_kKeyF10,
285         GHOST_kKeyF11,
286         GHOST_kKeyF12,
287         GHOST_kKeyF13,
288         GHOST_kKeyF14,
289         GHOST_kKeyF15,
290         GHOST_kKeyF16,
291         GHOST_kKeyF17,
292         GHOST_kKeyF18,
293         GHOST_kKeyF19,
294         GHOST_kKeyF20,
295         GHOST_kKeyF21,
296         GHOST_kKeyF22,
297         GHOST_kKeyF23,
298         GHOST_kKeyF24
299 } GHOST_TKey;
300
301
302 typedef void* GHOST_TEventDataPtr;
303
304 typedef struct {
305         /** The x-coordinate of the cursor position. */
306         GHOST_TInt32 x;
307         /** The y-coordinate of the cursor position. */
308         GHOST_TInt32 y;
309 } GHOST_TEventCursorData;
310
311 typedef struct {
312         /** The mask of the mouse button. */
313         GHOST_TButtonMask button;
314 } GHOST_TEventButtonData;
315
316 typedef struct {
317         /** Displacement of a mouse wheel. */
318         GHOST_TInt32 z; 
319 } GHOST_TEventWheelData;
320
321 typedef struct {
322         /** The key code. */
323         GHOST_TKey              key;
324         /** The ascii code for the key event ('\0' if none). */
325         char                    ascii;
326 } GHOST_TEventKeyData;
327
328 typedef struct {
329         /** Number of pixels on a line. */
330         GHOST_TUns32    xPixels;
331         /** Number of lines. */
332         GHOST_TUns32    yPixels;
333         /** Numberof bits per pixel. */
334         GHOST_TUns32    bpp;
335         /** Refresh rate (in Hertz). */
336         GHOST_TUns32    frequency;
337 } GHOST_DisplaySetting;
338
339
340 /**
341  * A timer task callback routine.
342  * @param task The timer task object.
343  * @param time The current time.
344  */
345 #ifdef __cplusplus
346 class GHOST_ITimerTask;
347 typedef void (*GHOST_TimerProcPtr)(GHOST_ITimerTask* task, GHOST_TUns64 time);
348 #else
349 struct GHOST_TimerTaskHandle__;
350 typedef void (*GHOST_TimerProcPtr)(struct GHOST_TimerTaskHandle__* task, GHOST_TUns64 time);
351 #endif
352
353 #endif // _GHOST_TYPES_H_
354