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