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