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