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