~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to intern/ghost/intern/GHOST_C-api.cpp

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
/** \file ghost/intern/GHOST_C-api.cpp
29
29
 *  \ingroup GHOST
30
 
 */
31
 
 
32
 
 
33
 
/*
34
 
 
35
 
 * GHOST_C-Api.cpp
36
30
 *
37
31
 * C Api for GHOST
38
 
 *
39
32
 */
40
33
 
41
34
#include <stdlib.h>
50
43
GHOST_SystemHandle GHOST_CreateSystem(void)
51
44
{
52
45
        GHOST_ISystem::createSystem();
53
 
        GHOST_ISystem* system = GHOST_ISystem::getSystem();
 
46
        GHOST_ISystem *system = GHOST_ISystem::getSystem();
54
47
 
55
48
        return (GHOST_SystemHandle)system;
56
49
}
59
52
 
60
53
GHOST_TSuccess GHOST_DisposeSystem(GHOST_SystemHandle systemhandle)
61
54
{
62
 
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
 
55
        GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
63
56
 
64
57
        return system->disposeSystem();
65
58
}
68
61
GHOST_EventConsumerHandle GHOST_CreateEventConsumer(GHOST_EventCallbackProcPtr eventCallback,
69
62
                                                    GHOST_TUserDataPtr userdata)
70
63
{
71
 
        return (GHOST_EventConsumerHandle) new GHOST_CallbackEventConsumer (eventCallback, userdata);
 
64
        return (GHOST_EventConsumerHandle) new GHOST_CallbackEventConsumer(eventCallback, userdata);
72
65
}
73
66
 
74
67
 
75
68
GHOST_TSuccess GHOST_DisposeEventConsumer(GHOST_EventConsumerHandle consumerhandle)
76
69
{
77
 
        delete ((GHOST_CallbackEventConsumer*)consumerhandle);
 
70
        delete ((GHOST_CallbackEventConsumer *)consumerhandle);
78
71
        return GHOST_kSuccess;
79
72
}
80
73
 
81
74
 
82
75
GHOST_TUns64 GHOST_GetMilliSeconds(GHOST_SystemHandle systemhandle)
83
76
{
84
 
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
 
77
        GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
85
78
 
86
79
        return system->getMilliSeconds();
87
80
}
89
82
 
90
83
 
91
84
GHOST_TimerTaskHandle GHOST_InstallTimer(GHOST_SystemHandle systemhandle,
92
 
                                                                                 GHOST_TUns64 delay,
93
 
                                                                                 GHOST_TUns64 interval,
94
 
                                                                                 GHOST_TimerProcPtr timerproc,
95
 
                                                                                 GHOST_TUserDataPtr userdata)
 
85
                                         GHOST_TUns64 delay,
 
86
                                         GHOST_TUns64 interval,
 
87
                                         GHOST_TimerProcPtr timerproc,
 
88
                                         GHOST_TUserDataPtr userdata)
96
89
{
97
 
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
 
90
        GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
98
91
 
99
92
        return (GHOST_TimerTaskHandle) system->installTimer(delay, interval, timerproc, userdata);
100
93
}
102
95
 
103
96
 
104
97
GHOST_TSuccess GHOST_RemoveTimer(GHOST_SystemHandle systemhandle,
105
 
                                                                 GHOST_TimerTaskHandle timertaskhandle)
 
98
                                 GHOST_TimerTaskHandle timertaskhandle)
106
99
{
107
 
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
108
 
        GHOST_ITimerTask* timertask = (GHOST_ITimerTask*) timertaskhandle;
 
100
        GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
 
101
        GHOST_ITimerTask *timertask = (GHOST_ITimerTask *) timertaskhandle;
109
102
 
110
103
        return system->removeTimer(timertask);
111
104
}
114
107
 
115
108
GHOST_TUns8 GHOST_GetNumDisplays(GHOST_SystemHandle systemhandle)
116
109
{
117
 
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
 
110
        GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
118
111
 
119
112
        return system->getNumDisplays();
120
113
}
122
115
 
123
116
 
124
117
void GHOST_GetMainDisplayDimensions(GHOST_SystemHandle systemhandle,
125
 
                                                                        GHOST_TUns32* width,
126
 
                                                                        GHOST_TUns32* height)
 
118
                                    GHOST_TUns32 *width,
 
119
                                    GHOST_TUns32 *height)
127
120
{
128
 
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
 
121
        GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
129
122
        
130
123
        system->getMainDisplayDimensions(*width, *height);
131
124
}
132
125
 
 
126
void GHOST_GetAllDisplayDimensions(GHOST_SystemHandle systemhandle,
 
127
                                    GHOST_TUns32 *width,
 
128
                                    GHOST_TUns32 *height)
 
129
{
 
130
        GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
133
131
 
 
132
        system->getAllDisplayDimensions(*width, *height);
 
133
}
134
134
 
135
135
GHOST_WindowHandle GHOST_CreateWindow(GHOST_SystemHandle systemhandle,
136
 
                                                                          const char* title,
137
 
                                                                          GHOST_TInt32 left,
138
 
                                                                          GHOST_TInt32 top,
139
 
                                                                          GHOST_TUns32 width,
140
 
                                                                          GHOST_TUns32 height,
141
 
                                                                          GHOST_TWindowState state,
142
 
                                                                          GHOST_TDrawingContextType type,
143
 
                                                                          const int stereoVisual,
144
 
                                                                          const GHOST_TUns16 numOfAASamples)
 
136
                                      const char *title,
 
137
                                      GHOST_TInt32 left,
 
138
                                      GHOST_TInt32 top,
 
139
                                      GHOST_TUns32 width,
 
140
                                      GHOST_TUns32 height,
 
141
                                      GHOST_TWindowState state,
 
142
                                      GHOST_TDrawingContextType type,
 
143
                                      const int stereoVisual,
 
144
                                      const GHOST_TUns16 numOfAASamples)
145
145
{
146
 
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
 
146
        GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
147
147
        bool bstereoVisual;
148
148
 
149
 
        if(stereoVisual)
 
149
        if (stereoVisual)
150
150
                bstereoVisual = true;
151
151
        else
152
152
                bstereoVisual = false;
153
153
 
154
154
        return (GHOST_WindowHandle) system->createWindow(title, left, top, width, height,
155
 
                state, type, bstereoVisual, numOfAASamples);
 
155
                                                         state, type, bstereoVisual, numOfAASamples);
156
156
}
157
157
 
158
158
GHOST_TUserDataPtr GHOST_GetWindowUserData(GHOST_WindowHandle windowhandle)
159
159
{
160
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
160
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
161
161
 
162
162
        return window->getUserData();
163
163
}
164
164
void GHOST_SetWindowUserData(GHOST_WindowHandle windowhandle, GHOST_TUserDataPtr userdata)
165
165
{
166
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
166
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
167
167
 
168
168
        window->setUserData(userdata);
169
169
}
170
170
 
171
171
GHOST_TSuccess GHOST_DisposeWindow(GHOST_SystemHandle systemhandle,
172
 
                                                                   GHOST_WindowHandle windowhandle)
 
172
                                   GHOST_WindowHandle windowhandle)
173
173
{
174
 
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
175
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
174
        GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
 
175
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
176
176
        
177
177
        return system->disposeWindow(window);
178
178
}
180
180
 
181
181
 
182
182
int GHOST_ValidWindow(GHOST_SystemHandle systemhandle,
183
 
                                                                 GHOST_WindowHandle windowhandle)
 
183
                      GHOST_WindowHandle windowhandle)
184
184
{
185
 
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
186
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
185
        GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
 
186
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
187
187
        
188
188
        return (int) system->validWindow(window);
189
189
}
191
191
 
192
192
 
193
193
GHOST_WindowHandle GHOST_BeginFullScreen(GHOST_SystemHandle systemhandle,
194
 
                                                                                 GHOST_DisplaySetting* setting,
195
 
                                                                                 const int stereoVisual)
 
194
                                         GHOST_DisplaySetting *setting,
 
195
                                         const int stereoVisual)
196
196
{
197
 
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
198
 
        GHOST_IWindow* window = NULL;
 
197
        GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
 
198
        GHOST_IWindow *window = NULL;
199
199
        bool bstereoVisual;
200
200
 
201
 
        if(stereoVisual)
 
201
        if (stereoVisual)
202
202
                bstereoVisual = true;
203
203
        else
204
204
                bstereoVisual = false;
212
212
 
213
213
GHOST_TSuccess GHOST_EndFullScreen(GHOST_SystemHandle systemhandle)
214
214
{
215
 
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
 
215
        GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
216
216
 
217
217
        return system->endFullScreen();
218
218
}
221
221
 
222
222
int GHOST_GetFullScreen(GHOST_SystemHandle systemhandle)
223
223
{
224
 
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
 
224
        GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
225
225
 
226
226
        return (int) system->getFullScreen();
227
227
}
230
230
 
231
231
int GHOST_ProcessEvents(GHOST_SystemHandle systemhandle, int waitForEvent)
232
232
{
233
 
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
 
233
        GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
234
234
        
235
 
        return (int) system->processEvents(waitForEvent?true:false);
 
235
        return (int) system->processEvents(waitForEvent ? true : false);
236
236
}
237
237
 
238
238
 
239
239
 
240
240
int GHOST_DispatchEvents(GHOST_SystemHandle systemhandle)
241
241
{
242
 
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
 
242
        GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
243
243
        
244
244
        return (int) system->dispatchEvents();
245
245
}
247
247
 
248
248
GHOST_TSuccess GHOST_AddEventConsumer(GHOST_SystemHandle systemhandle, GHOST_EventConsumerHandle consumerhandle)
249
249
{
250
 
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
 
250
        GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
251
251
        
252
 
        return system->addEventConsumer((GHOST_CallbackEventConsumer*)consumerhandle);
 
252
        return system->addEventConsumer((GHOST_CallbackEventConsumer *)consumerhandle);
253
253
}
254
254
 
255
255
GHOST_TSuccess GHOST_RemoveEventConsumer(GHOST_SystemHandle systemhandle, GHOST_EventConsumerHandle consumerhandle)
256
256
{
257
 
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
 
257
        GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
258
258
 
259
 
        return system->removeEventConsumer((GHOST_CallbackEventConsumer*)consumerhandle);
 
259
        return system->removeEventConsumer((GHOST_CallbackEventConsumer *)consumerhandle);
260
260
}
261
261
 
262
 
GHOST_TSuccess GHOST_SetProgressBar(GHOST_WindowHandle windowhandle,float progress)
 
262
GHOST_TSuccess GHOST_SetProgressBar(GHOST_WindowHandle windowhandle, float progress)
263
263
{
264
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
264
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
265
265
 
266
266
        return window->setProgressBar(progress);
267
267
}
268
268
 
269
269
GHOST_TSuccess GHOST_EndProgressBar(GHOST_WindowHandle windowhandle)
270
270
{
271
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
271
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
272
272
 
273
273
        return window->endProgressBar();
274
274
}
276
276
 
277
277
GHOST_TStandardCursor GHOST_GetCursorShape(GHOST_WindowHandle windowhandle)
278
278
{
279
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
279
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
280
280
 
281
281
        return window->getCursorShape();
282
282
}
284
284
 
285
285
 
286
286
GHOST_TSuccess GHOST_SetCursorShape(GHOST_WindowHandle windowhandle,
287
 
                                                                        GHOST_TStandardCursor cursorshape)
 
287
                                    GHOST_TStandardCursor cursorshape)
288
288
{
289
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
289
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
290
290
 
291
291
        return window->setCursorShape(cursorshape);
292
292
}
293
293
 
294
294
GHOST_TSuccess GHOST_SetCustomCursorShape(GHOST_WindowHandle windowhandle,
295
 
                                                                                  GHOST_TUns8 bitmap[16][2], 
296
 
                                                                                  GHOST_TUns8 mask[16][2], 
297
 
                                                                                  int hotX, 
298
 
                                                                                  int hotY)
 
295
                                          GHOST_TUns8 bitmap[16][2],
 
296
                                          GHOST_TUns8 mask[16][2],
 
297
                                          int hotX,
 
298
                                          int hotY)
299
299
{
300
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
300
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
301
301
 
302
302
        return window->setCustomCursorShape(bitmap, mask, hotX, hotY);
303
303
}
304
304
 
305
305
GHOST_TSuccess GHOST_SetCustomCursorShapeEx(GHOST_WindowHandle windowhandle,
306
 
                                                                                  GHOST_TUns8 *bitmap, 
307
 
                                                                                  GHOST_TUns8 *mask, 
308
 
                                                                                  int sizex, 
309
 
                                                                                  int sizey,
310
 
                                                                                  int hotX, 
311
 
                                                                                  int hotY, 
312
 
                                                                                  int fg_color, 
313
 
                                                                                  int bg_color)
 
306
                                            GHOST_TUns8 *bitmap,
 
307
                                            GHOST_TUns8 *mask,
 
308
                                            int sizex,
 
309
                                            int sizey,
 
310
                                            int hotX,
 
311
                                            int hotY,
 
312
                                            int fg_color,
 
313
                                            int bg_color)
314
314
{
315
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
315
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
316
316
 
317
 
        return window->setCustomCursorShape(bitmap, mask, sizex, sizey, 
318
 
                                                                                                hotX, hotY, fg_color, bg_color);
 
317
        return window->setCustomCursorShape(bitmap, mask, sizex, sizey,
 
318
                                            hotX, hotY, fg_color, bg_color);
319
319
}
320
320
 
321
321
 
322
322
 
323
323
int GHOST_GetCursorVisibility(GHOST_WindowHandle windowhandle)
324
324
{
325
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
325
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
326
326
 
327
327
        return (int) window->getCursorVisibility();
328
328
}
330
330
 
331
331
 
332
332
GHOST_TSuccess GHOST_SetCursorVisibility(GHOST_WindowHandle windowhandle,
333
 
                                                                                 int visible)
 
333
                                         int visible)
334
334
{
335
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
335
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
336
336
 
337
 
        return window->setCursorVisibility(visible?true:false);
 
337
        return window->setCursorVisibility(visible ? true : false);
338
338
}
339
339
 
340
340
 
341
341
 
342
342
GHOST_TSuccess GHOST_GetCursorPosition(GHOST_SystemHandle systemhandle,
343
 
                                                                           GHOST_TInt32* x,
344
 
                                                                           GHOST_TInt32* y)
 
343
                                       GHOST_TInt32 *x,
 
344
                                       GHOST_TInt32 *y)
345
345
{
346
 
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
 
346
        GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
347
347
        
348
348
        return system->getCursorPosition(*x, *y);
349
349
}
351
351
 
352
352
 
353
353
GHOST_TSuccess GHOST_SetCursorPosition(GHOST_SystemHandle systemhandle,
354
 
                                                                           GHOST_TInt32 x,
355
 
                                                                           GHOST_TInt32 y)
 
354
                                       GHOST_TInt32 x,
 
355
                                       GHOST_TInt32 y)
356
356
{
357
 
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
 
357
        GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
358
358
        
359
359
        return system->setCursorPosition(x, y);
360
360
}
361
361
 
362
362
 
363
363
GHOST_TSuccess GHOST_SetCursorGrab(GHOST_WindowHandle windowhandle,
364
 
                                                                                GHOST_TGrabCursorMode mode,
365
 
                                                                                int *bounds)
 
364
                                   GHOST_TGrabCursorMode mode,
 
365
                                   int bounds[4], int mouse_ungrab_xy[2])
366
366
{
367
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
367
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
368
368
        GHOST_Rect bounds_rect, bounds_win;
 
369
        GHOST_TInt32 mouse_ungrab_xy_global[2];
369
370
 
370
 
        if(bounds) {
 
371
        if (bounds) {
371
372
                /* if this is X11 specific we need a function that converts */
372
373
                window->getClientBounds(bounds_win);
373
374
                window->clientToScreen(bounds[0], bounds_win.getHeight() - bounds[1], bounds_rect.m_l, bounds_rect.m_t);
375
376
 
376
377
        }
377
378
        
378
 
        return window->setCursorGrab(mode, bounds ? &bounds_rect:NULL);
 
379
        if (mouse_ungrab_xy) {
 
380
                if (bounds == NULL)
 
381
                        window->getClientBounds(bounds_win);
 
382
                window->clientToScreen(mouse_ungrab_xy[0], bounds_win.getHeight() - mouse_ungrab_xy[1],
 
383
                                       mouse_ungrab_xy_global[0], mouse_ungrab_xy_global[1]);
 
384
        }
 
385
 
 
386
        return window->setCursorGrab(mode,
 
387
                                     bounds ? &bounds_rect : NULL,
 
388
                                     mouse_ungrab_xy ? mouse_ungrab_xy_global : NULL);
379
389
}
380
390
 
381
391
 
382
392
GHOST_TSuccess GHOST_GetModifierKeyState(GHOST_SystemHandle systemhandle,
383
 
                                                                                 GHOST_TModifierKeyMask mask,
384
 
                                                                                 int* isDown)
 
393
                                         GHOST_TModifierKeyMask mask,
 
394
                                         int *isDown)
385
395
{
386
 
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
 
396
        GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
387
397
        GHOST_TSuccess result;
388
 
        bool isdown= false;
 
398
        bool isdown = false;
389
399
        
390
400
        result = system->getModifierKeyState(mask, isdown);
391
401
        *isDown = (int) isdown;
396
406
 
397
407
 
398
408
GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle,
399
 
                                                                        GHOST_TButtonMask mask,
400
 
                                                                        int* isDown)
 
409
                                    GHOST_TButtonMask mask,
 
410
                                    int *isDown)
401
411
{
402
 
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
 
412
        GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
403
413
        GHOST_TSuccess result;
404
 
        bool isdown= false;
 
414
        bool isdown = false;
405
415
        
406
416
        result = system->getButtonState(mask, isdown);
407
417
        *isDown = (int) isdown;
412
422
 
413
423
void GHOST_setAcceptDragOperation(GHOST_WindowHandle windowhandle, GHOST_TInt8 canAccept)
414
424
{
415
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
425
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
416
426
 
417
427
        window->setAcceptDragOperation(canAccept);
418
428
}
420
430
 
421
431
GHOST_TEventType GHOST_GetEventType(GHOST_EventHandle eventhandle)
422
432
{
423
 
        GHOST_IEvent* event = (GHOST_IEvent*) eventhandle;
 
433
        GHOST_IEvent *event = (GHOST_IEvent *) eventhandle;
424
434
        
425
435
        return event->getType();
426
436
}
429
439
 
430
440
GHOST_TUns64 GHOST_GetEventTime(GHOST_EventHandle eventhandle)
431
441
{
432
 
        GHOST_IEvent* event = (GHOST_IEvent*) eventhandle;
 
442
        GHOST_IEvent *event = (GHOST_IEvent *) eventhandle;
433
443
 
434
444
        return event->getTime();
435
445
}
437
447
 
438
448
GHOST_WindowHandle GHOST_GetEventWindow(GHOST_EventHandle eventhandle)
439
449
{
440
 
        GHOST_IEvent* event = (GHOST_IEvent*) eventhandle;
 
450
        GHOST_IEvent *event = (GHOST_IEvent *) eventhandle;
441
451
 
442
452
        return (GHOST_WindowHandle) event->getWindow();
443
453
}
445
455
 
446
456
GHOST_TEventDataPtr GHOST_GetEventData(GHOST_EventHandle eventhandle)
447
457
{
448
 
        GHOST_IEvent* event = (GHOST_IEvent*) eventhandle;
 
458
        GHOST_IEvent *event = (GHOST_IEvent *) eventhandle;
449
459
        
450
460
        return event->getData();
451
461
}
454
464
 
455
465
GHOST_TimerProcPtr GHOST_GetTimerProc(GHOST_TimerTaskHandle timertaskhandle)
456
466
{
457
 
        GHOST_ITimerTask* timertask = (GHOST_ITimerTask*) timertaskhandle;
 
467
        GHOST_ITimerTask *timertask = (GHOST_ITimerTask *) timertaskhandle;
458
468
        
459
469
        return timertask->getTimerProc();
460
470
}
462
472
 
463
473
 
464
474
void GHOST_SetTimerProc(GHOST_TimerTaskHandle timertaskhandle,
465
 
                                                GHOST_TimerProcPtr timerproc)
 
475
                        GHOST_TimerProcPtr timerproc)
466
476
{
467
 
        GHOST_ITimerTask* timertask = (GHOST_ITimerTask*) timertaskhandle;
 
477
        GHOST_ITimerTask *timertask = (GHOST_ITimerTask *) timertaskhandle;
468
478
        
469
479
        timertask->setTimerProc(timerproc);
470
480
}
473
483
 
474
484
GHOST_TUserDataPtr GHOST_GetTimerTaskUserData(GHOST_TimerTaskHandle timertaskhandle)
475
485
{
476
 
        GHOST_ITimerTask* timertask = (GHOST_ITimerTask*) timertaskhandle;
 
486
        GHOST_ITimerTask *timertask = (GHOST_ITimerTask *) timertaskhandle;
477
487
 
478
488
        return timertask->getUserData();
479
489
}
480
490
 
481
 
        
 
491
 
482
492
 
483
493
void GHOST_SetTimerTaskUserData(GHOST_TimerTaskHandle timertaskhandle,
484
 
                                                                GHOST_TUserDataPtr userdata)
 
494
                                GHOST_TUserDataPtr userdata)
485
495
{
486
 
        GHOST_ITimerTask* timertask = (GHOST_ITimerTask*) timertaskhandle;
 
496
        GHOST_ITimerTask *timertask = (GHOST_ITimerTask *) timertaskhandle;
487
497
        
488
498
        timertask->setUserData(userdata);
489
499
}
492
502
 
493
503
int GHOST_GetValid(GHOST_WindowHandle windowhandle) 
494
504
{
495
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
505
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
496
506
 
497
507
        return (int) window->getValid();
498
508
}
501
511
 
502
512
GHOST_TDrawingContextType GHOST_GetDrawingContextType(GHOST_WindowHandle windowhandle)
503
513
{
504
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
514
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
505
515
 
506
516
        return window->getDrawingContextType();
507
517
}
509
519
 
510
520
 
511
521
GHOST_TSuccess GHOST_SetDrawingContextType(GHOST_WindowHandle windowhandle,
512
 
                                                                                   GHOST_TDrawingContextType type)
 
522
                                           GHOST_TDrawingContextType type)
513
523
{
514
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
524
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
515
525
 
516
526
        return window->setDrawingContextType(type);
517
527
}
519
529
 
520
530
 
521
531
void GHOST_SetTitle(GHOST_WindowHandle windowhandle,
522
 
                                        const char* title)
 
532
                    const char *title)
523
533
{
524
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
534
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
525
535
        
526
536
        window->setTitle(title);
527
537
}
528
538
 
529
539
 
530
 
char* GHOST_GetTitle(GHOST_WindowHandle windowhandle)
 
540
char *GHOST_GetTitle(GHOST_WindowHandle windowhandle)
531
541
{
532
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
542
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
533
543
        STR_String title;
534
544
 
535
545
        window->getTitle(title);
536
546
 
537
 
        char *ctitle = (char*) malloc(title.Length() + 1);
538
 
 
539
 
        if (ctitle == NULL) return NULL;
 
547
        char *ctitle = (char *) malloc(title.Length() + 1);
 
548
 
 
549
        if (ctitle == NULL) {
 
550
                return NULL;
 
551
        }
 
552
 
540
553
        strcpy(ctitle, title.Ptr());
541
 
                
 
554
 
542
555
        return ctitle;
543
556
}
544
557
 
546
559
 
547
560
GHOST_RectangleHandle GHOST_GetWindowBounds(GHOST_WindowHandle windowhandle) 
548
561
{
549
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
550
 
        GHOST_Rect* rectangle = NULL;
 
562
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
 
563
        GHOST_Rect *rectangle = NULL;
551
564
 
552
565
        rectangle = new GHOST_Rect();
553
566
        window->getWindowBounds(*rectangle);
559
572
 
560
573
GHOST_RectangleHandle GHOST_GetClientBounds(GHOST_WindowHandle windowhandle) 
561
574
{
562
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
563
 
        GHOST_Rect* rectangle = NULL;
 
575
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
 
576
        GHOST_Rect *rectangle = NULL;
564
577
 
565
578
        rectangle = new GHOST_Rect();
566
579
        window->getClientBounds(*rectangle);
572
585
 
573
586
void GHOST_DisposeRectangle(GHOST_RectangleHandle rectanglehandle)
574
587
{
575
 
        delete (GHOST_Rect*) rectanglehandle;
 
588
        delete (GHOST_Rect *) rectanglehandle;
576
589
}
577
590
 
578
591
 
579
592
 
580
593
GHOST_TSuccess GHOST_SetClientWidth(GHOST_WindowHandle windowhandle,
581
 
                                                                        GHOST_TUns32 width)
 
594
                                    GHOST_TUns32 width)
582
595
{
583
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
596
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
584
597
 
585
598
        return window->setClientWidth(width);
586
599
}
588
601
 
589
602
 
590
603
GHOST_TSuccess GHOST_SetClientHeight(GHOST_WindowHandle windowhandle,
591
 
                                                                         GHOST_TUns32 height)
 
604
                                     GHOST_TUns32 height)
592
605
{
593
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
606
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
594
607
 
595
608
        return window->setClientHeight(height);
596
609
}
598
611
 
599
612
 
600
613
GHOST_TSuccess GHOST_SetClientSize(GHOST_WindowHandle windowhandle,
601
 
                                                                   GHOST_TUns32 width,
602
 
                                                                   GHOST_TUns32 height)
 
614
                                   GHOST_TUns32 width,
 
615
                                   GHOST_TUns32 height)
603
616
{
604
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
617
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
605
618
 
606
619
        return window->setClientSize(width, height);
607
620
}
609
622
 
610
623
 
611
624
void GHOST_ScreenToClient(GHOST_WindowHandle windowhandle,
612
 
                                                  GHOST_TInt32 inX,
613
 
                                                  GHOST_TInt32 inY,
614
 
                                                  GHOST_TInt32* outX,
615
 
                                                  GHOST_TInt32* outY) 
 
625
                          GHOST_TInt32 inX,
 
626
                          GHOST_TInt32 inY,
 
627
                          GHOST_TInt32 *outX,
 
628
                          GHOST_TInt32 *outY)
616
629
{
617
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
630
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
618
631
 
619
632
        window->screenToClient(inX, inY, *outX, *outY);
620
633
}
622
635
 
623
636
 
624
637
void GHOST_ClientToScreen(GHOST_WindowHandle windowhandle,
625
 
                                                  GHOST_TInt32 inX,
626
 
                                                  GHOST_TInt32 inY,
627
 
                                                  GHOST_TInt32* outX,
628
 
                                                  GHOST_TInt32* outY)
 
638
                          GHOST_TInt32 inX,
 
639
                          GHOST_TInt32 inY,
 
640
                          GHOST_TInt32 *outX,
 
641
                          GHOST_TInt32 *outY)
629
642
{
630
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
643
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
631
644
 
632
645
        window->clientToScreen(inX, inY, *outX, *outY);
633
646
}
636
649
 
637
650
GHOST_TWindowState GHOST_GetWindowState(GHOST_WindowHandle windowhandle)
638
651
{
639
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
652
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
640
653
 
641
654
        return window->getState();
642
655
}
644
657
 
645
658
 
646
659
GHOST_TSuccess GHOST_SetWindowState(GHOST_WindowHandle windowhandle,
647
 
                                                                        GHOST_TWindowState state)
 
660
                                    GHOST_TWindowState state)
648
661
{
649
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
662
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
650
663
 
651
664
        return window->setState(state);
652
665
}
654
667
 
655
668
GHOST_TSuccess GHOST_SetWindowModifiedState(GHOST_WindowHandle windowhandle, GHOST_TUns8 isUnsavedChanges)
656
669
{
657
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
670
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
658
671
        
659
672
        return window->setModifiedState(isUnsavedChanges);
660
673
}       
661
674
 
662
675
 
663
676
GHOST_TSuccess GHOST_SetWindowOrder(GHOST_WindowHandle windowhandle,
664
 
                                                                        GHOST_TWindowOrder order)
 
677
                                    GHOST_TWindowOrder order)
665
678
{
666
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
679
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
667
680
        
668
681
        return window->setOrder(order);
669
682
}
672
685
 
673
686
GHOST_TSuccess GHOST_SwapWindowBuffers(GHOST_WindowHandle windowhandle)
674
687
{
675
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
688
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
676
689
 
677
690
        return window->swapBuffers();
678
691
}
681
694
 
682
695
GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandle)
683
696
{
684
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
697
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
685
698
        
686
699
        return window->activateDrawingContext();
687
700
}
690
703
 
691
704
GHOST_TSuccess GHOST_InvalidateWindow(GHOST_WindowHandle windowhandle)
692
705
{
693
 
        GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
 
706
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
694
707
 
695
708
        return window->invalidate();
696
709
}
697
710
 
698
711
 
699
 
extern const GHOST_TabletData* GHOST_GetTabletData(GHOST_WindowHandle windowhandle)
 
712
extern const GHOST_TabletData *GHOST_GetTabletData(GHOST_WindowHandle windowhandle)
700
713
{
701
 
        return ((GHOST_IWindow*)windowhandle)->GetTabletData();
 
714
        return ((GHOST_IWindow *)windowhandle)->GetTabletData();
702
715
}
703
716
 
704
717
 
705
718
GHOST_TInt32 GHOST_GetWidthRectangle(GHOST_RectangleHandle rectanglehandle)
706
719
{
707
 
        return ((GHOST_Rect*)rectanglehandle)->getWidth();
 
720
        return ((GHOST_Rect *)rectanglehandle)->getWidth();
708
721
}
709
722
 
710
723
 
711
724
 
712
725
GHOST_TInt32 GHOST_GetHeightRectangle(GHOST_RectangleHandle rectanglehandle)
713
726
{
714
 
        return ((GHOST_Rect*)rectanglehandle)->getHeight();
 
727
        return ((GHOST_Rect *)rectanglehandle)->getHeight();
715
728
}
716
729
 
717
730
 
718
731
 
719
732
void GHOST_GetRectangle(GHOST_RectangleHandle rectanglehandle,
720
 
                                                           GHOST_TInt32* l,
721
 
                                                           GHOST_TInt32* t,
722
 
                                                           GHOST_TInt32* r,
723
 
                                                           GHOST_TInt32* b)
 
733
                        GHOST_TInt32 *l,
 
734
                        GHOST_TInt32 *t,
 
735
                        GHOST_TInt32 *r,
 
736
                        GHOST_TInt32 *b)
724
737
{
725
 
        GHOST_Rect *rect= (GHOST_Rect*) rectanglehandle;
726
 
        
727
 
        *l= rect->m_l;
728
 
        *t= rect->m_t;
729
 
        *r= rect->m_r;
730
 
        *b= rect->m_b;
 
738
        GHOST_Rect *rect = (GHOST_Rect *) rectanglehandle;
 
739
 
 
740
        *l = rect->m_l;
 
741
        *t = rect->m_t;
 
742
        *r = rect->m_r;
 
743
        *b = rect->m_b;
731
744
}
732
745
 
733
746
 
734
747
void GHOST_SetRectangle(GHOST_RectangleHandle rectanglehandle,
735
 
                                                GHOST_TInt32 l,
736
 
                                                GHOST_TInt32 t,
737
 
                                                GHOST_TInt32 r,
738
 
                                                GHOST_TInt32 b)
 
748
                        GHOST_TInt32 l,
 
749
                        GHOST_TInt32 t,
 
750
                        GHOST_TInt32 r,
 
751
                        GHOST_TInt32 b)
739
752
{
740
 
        ((GHOST_Rect*)rectanglehandle)->set(l, t, r, b);
 
753
        ((GHOST_Rect *)rectanglehandle)->set(l, t, r, b);
741
754
}
742
755
 
743
756
 
746
759
{
747
760
        GHOST_TSuccess result = GHOST_kFailure;
748
761
 
749
 
        if (((GHOST_Rect*)rectanglehandle)->isEmpty())
 
762
        if (((GHOST_Rect *)rectanglehandle)->isEmpty())
750
763
                result = GHOST_kSuccess;
751
764
 
752
765
        return result;
758
771
{
759
772
        GHOST_TSuccess result = GHOST_kFailure;
760
773
 
761
 
        if(((GHOST_Rect*)rectanglehandle)->isValid())
 
774
        if (((GHOST_Rect *)rectanglehandle)->isValid())
762
775
                result = GHOST_kSuccess;
763
776
 
764
777
        return result;
767
780
 
768
781
 
769
782
void GHOST_InsetRectangle(GHOST_RectangleHandle rectanglehandle,
770
 
                                                  GHOST_TInt32 i)
 
783
                          GHOST_TInt32 i)
771
784
{
772
 
        ((GHOST_Rect*)rectanglehandle)->inset(i);
 
785
        ((GHOST_Rect *)rectanglehandle)->inset(i);
773
786
}
774
787
 
775
788
 
776
789
 
777
790
void GHOST_UnionRectangle(GHOST_RectangleHandle rectanglehandle,
778
 
                                                  GHOST_RectangleHandle anotherrectanglehandle)
 
791
                          GHOST_RectangleHandle anotherrectanglehandle)
779
792
{
780
 
        ((GHOST_Rect*)rectanglehandle)->unionRect(*(GHOST_Rect*)anotherrectanglehandle);
 
793
        ((GHOST_Rect *)rectanglehandle)->unionRect(*(GHOST_Rect *)anotherrectanglehandle);
781
794
}
782
795
 
783
796
 
784
797
 
785
798
void GHOST_UnionPointRectangle(GHOST_RectangleHandle rectanglehandle,
786
 
                                                           GHOST_TInt32 x,
787
 
                                                           GHOST_TInt32 y)
 
799
                               GHOST_TInt32 x,
 
800
                               GHOST_TInt32 y)
788
801
{
789
 
        ((GHOST_Rect*)rectanglehandle)->unionPoint(x, y);
 
802
        ((GHOST_Rect *)rectanglehandle)->unionPoint(x, y);
790
803
}
791
804
 
792
805
 
793
806
 
794
807
GHOST_TSuccess GHOST_IsInsideRectangle(GHOST_RectangleHandle rectanglehandle,
795
 
                                                                           GHOST_TInt32 x,
796
 
                                                                           GHOST_TInt32 y)
 
808
                                       GHOST_TInt32 x,
 
809
                                       GHOST_TInt32 y)
797
810
{
798
811
        GHOST_TSuccess result = GHOST_kFailure;
799
812
 
800
 
        if (((GHOST_Rect*)rectanglehandle)->isInside(x, y))
 
813
        if (((GHOST_Rect *)rectanglehandle)->isInside(x, y))
801
814
                result = GHOST_kSuccess;
802
815
 
803
816
        return result;
806
819
 
807
820
 
808
821
GHOST_TVisibility GHOST_GetRectangleVisibility(GHOST_RectangleHandle rectanglehandle,
809
 
                                                                                           GHOST_RectangleHandle anotherrectanglehandle)
 
822
                                               GHOST_RectangleHandle anotherrectanglehandle)
810
823
{
811
824
        GHOST_TVisibility visible = GHOST_kNotVisible;
812
825
 
813
 
        visible = ((GHOST_Rect*)rectanglehandle)->getVisibility(*(GHOST_Rect*)anotherrectanglehandle);
 
826
        visible = ((GHOST_Rect *)rectanglehandle)->getVisibility(*(GHOST_Rect *)anotherrectanglehandle);
814
827
 
815
828
        return visible;
816
829
}
818
831
 
819
832
 
820
833
void GHOST_SetCenterRectangle(GHOST_RectangleHandle rectanglehandle,
821
 
                                                          GHOST_TInt32 cx,
822
 
                                                          GHOST_TInt32 cy)
 
834
                              GHOST_TInt32 cx,
 
835
                              GHOST_TInt32 cy)
823
836
{
824
 
        ((GHOST_Rect*)rectanglehandle)->setCenter(cx, cy);
 
837
        ((GHOST_Rect *)rectanglehandle)->setCenter(cx, cy);
825
838
}
826
839
 
827
840
 
828
841
 
829
842
void GHOST_SetRectangleCenter(GHOST_RectangleHandle rectanglehandle,
830
 
                                                          GHOST_TInt32 cx,
831
 
                                                          GHOST_TInt32 cy,
832
 
                                                          GHOST_TInt32 w,
833
 
                                                          GHOST_TInt32 h)
 
843
                              GHOST_TInt32 cx,
 
844
                              GHOST_TInt32 cy,
 
845
                              GHOST_TInt32 w,
 
846
                              GHOST_TInt32 h)
834
847
{
835
 
        ((GHOST_Rect*)rectanglehandle)->setCenter(cx, cy, w, h);
 
848
        ((GHOST_Rect *)rectanglehandle)->setCenter(cx, cy, w, h);
836
849
}
837
850
 
838
851
 
839
852
 
840
853
GHOST_TSuccess GHOST_ClipRectangle(GHOST_RectangleHandle rectanglehandle,
841
 
                                                                   GHOST_RectangleHandle anotherrectanglehandle)
 
854
                                   GHOST_RectangleHandle anotherrectanglehandle)
842
855
{
843
856
        GHOST_TSuccess result = GHOST_kFailure;
844
857
 
845
 
        if (((GHOST_Rect*)rectanglehandle)->clip(*(GHOST_Rect*)anotherrectanglehandle))
 
858
        if (((GHOST_Rect *)rectanglehandle)->clip(*(GHOST_Rect *)anotherrectanglehandle))
846
859
                result = GHOST_kSuccess;
847
860
 
848
861
        return result;
849
862
}
850
863
 
851
 
GHOST_TUns8* GHOST_getClipboard(int selection)
 
864
GHOST_TUns8 *GHOST_getClipboard(int selection)
852
865
{
853
 
        GHOST_ISystem* system = GHOST_ISystem::getSystem();
 
866
        GHOST_ISystem *system = GHOST_ISystem::getSystem();
854
867
        return system->getClipboard(selection);
855
868
}
856
869
 
857
870
void GHOST_putClipboard(GHOST_TInt8 *buffer, int selection)
858
871
{
859
 
        GHOST_ISystem* system = GHOST_ISystem::getSystem();
 
872
        GHOST_ISystem *system = GHOST_ISystem::getSystem();
860
873
        system->putClipboard(buffer, selection);
861
874
}
862
875
 
863
876
int GHOST_toggleConsole(int action)
864
877
{
865
 
        GHOST_ISystem* system = GHOST_ISystem::getSystem();
 
878
        GHOST_ISystem *system = GHOST_ISystem::getSystem();
866
879
        return system->toggleConsole(action);
867
880
}
868
881
 
869
882
 
870
 
int GHOST_confirmQuit(GHOST_WindowHandle windowhandle){
871
 
        GHOST_ISystem* system = GHOST_ISystem::getSystem();
872
 
        return system->confirmQuit((GHOST_IWindow*) windowhandle);
873
 
}
 
883
int GHOST_confirmQuit(GHOST_WindowHandle windowhandle)
 
884
{
 
885
        GHOST_ISystem *system = GHOST_ISystem::getSystem();
 
886
        return system->confirmQuit((GHOST_IWindow *) windowhandle);
 
887
}
 
888
 
 
889
int GHOST_UseNativePixels(void)
 
890
{
 
891
        GHOST_ISystem *system = GHOST_ISystem::getSystem();
 
892
        return system->useNativePixel();
 
893
}
 
894
 
 
895
float GHOST_GetNativePixelSize(GHOST_WindowHandle windowhandle)
 
896
{
 
897
        GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
 
898
        if (window)
 
899
                return window->getNativePixelSize();
 
900
        return 1.0f;
 
901
}
 
902