forgot return value in C-api
[blender-staging.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 int GHOST_OpenNDOF(GHOST_SystemHandle systemhandle, GHOST_WindowHandle windowhandle,
263    GHOST_NDOFLibraryInit_fp setNdofLibraryInit, 
264     GHOST_NDOFLibraryShutdown_fp setNdofLibraryShutdown,
265     GHOST_NDOFDeviceOpen_fp setNdofDeviceOpen)
266   //original patch only
267   /*  GHOST_NDOFEventHandler_fp setNdofEventHandler)*/
268 {
269         GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
270
271     return system->openNDOF((GHOST_IWindow*) windowhandle,
272         setNdofLibraryInit, setNdofLibraryShutdown, setNdofDeviceOpen);
273 //      original patch
274 //        setNdofLibraryInit, setNdofLibraryShutdown, setNdofDeviceOpen, setNdofEventHandler);
275 }
276
277
278
279 GHOST_TStandardCursor GHOST_GetCursorShape(GHOST_WindowHandle windowhandle)
280 {
281         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
282
283         return window->getCursorShape();
284 }
285
286
287
288 GHOST_TSuccess GHOST_SetCursorShape(GHOST_WindowHandle windowhandle,
289                                                                         GHOST_TStandardCursor cursorshape)
290 {
291         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
292
293         return window->setCursorShape(cursorshape);
294 }
295
296 GHOST_TSuccess GHOST_SetCustomCursorShape(GHOST_WindowHandle windowhandle,
297                                                                                   GHOST_TUns8 bitmap[16][2], 
298                                                                                   GHOST_TUns8 mask[16][2], 
299                                                                                   int hotX, 
300                                                                                   int hotY)
301 {
302         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
303
304         return window->setCustomCursorShape(bitmap, mask, hotX, hotY);
305 }
306
307 GHOST_TSuccess GHOST_SetCustomCursorShapeEx(GHOST_WindowHandle windowhandle,
308                                                                                   GHOST_TUns8 *bitmap, 
309                                                                                   GHOST_TUns8 *mask, 
310                                                                                   int sizex, 
311                                                                                   int sizey,
312                                                                                   int hotX, 
313                                                                                   int hotY, 
314                                                                                   int fg_color, 
315                                                                                   int bg_color)
316 {
317         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
318
319         return window->setCustomCursorShape(bitmap, mask, sizex, sizey, 
320                                                                                                 hotX, hotY, fg_color, bg_color);
321 }
322
323
324
325 int GHOST_GetCursorVisibility(GHOST_WindowHandle windowhandle)
326 {
327         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
328
329         return (int) window->getCursorVisibility();
330 }
331
332
333
334 GHOST_TSuccess GHOST_SetCursorVisibility(GHOST_WindowHandle windowhandle,
335                                                                                  int visible)
336 {
337         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
338
339         return window->setCursorVisibility(visible?true:false);
340 }
341
342
343
344 GHOST_TSuccess GHOST_GetCursorPosition(GHOST_SystemHandle systemhandle,
345                                                                            GHOST_TInt32* x,
346                                                                            GHOST_TInt32* y)
347 {
348         GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
349         
350         return system->getCursorPosition(*x, *y);
351 }
352
353
354
355 GHOST_TSuccess GHOST_SetCursorPosition(GHOST_SystemHandle systemhandle,
356                                                                            GHOST_TInt32 x,
357                                                                            GHOST_TInt32 y)
358 {
359         GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
360         
361         return system->setCursorPosition(x, y);
362 }
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
633 GHOST_TSuccess GHOST_SetWindowOrder(GHOST_WindowHandle windowhandle,
634                                                                         GHOST_TWindowOrder order)
635 {
636         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
637         
638         return window->setOrder(order);
639 }
640
641
642
643 GHOST_TSuccess GHOST_SwapWindowBuffers(GHOST_WindowHandle windowhandle)
644 {
645         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
646
647         return window->swapBuffers();
648 }
649
650
651
652 GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandle)
653 {
654         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
655         
656         return window->activateDrawingContext();
657 }
658
659
660
661 GHOST_TSuccess GHOST_InvalidateWindow(GHOST_WindowHandle windowhandle)
662 {
663         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
664
665         return window->invalidate();
666 }
667
668
669 extern const GHOST_TabletData* GHOST_GetTabletData(GHOST_WindowHandle windowhandle)
670 {
671         return ((GHOST_IWindow*)windowhandle)->GetTabletData();
672 }
673
674
675 GHOST_TInt32 GHOST_GetWidthRectangle(GHOST_RectangleHandle rectanglehandle)
676 {
677         return ((GHOST_Rect*)rectanglehandle)->getWidth();
678 }
679
680
681
682 GHOST_TInt32 GHOST_GetHeightRectangle(GHOST_RectangleHandle rectanglehandle)
683 {
684         return ((GHOST_Rect*)rectanglehandle)->getHeight();
685 }
686
687
688
689 void GHOST_GetRectangle(GHOST_RectangleHandle rectanglehandle,
690                                                            GHOST_TInt32* l,
691                                                            GHOST_TInt32* t,
692                                                            GHOST_TInt32* r,
693                                                            GHOST_TInt32* b)
694 {
695         GHOST_Rect *rect= (GHOST_Rect*) rectanglehandle;
696         
697         *l= rect->m_l;
698         *t= rect->m_t;
699         *r= rect->m_r;
700         *b= rect->m_b;
701 }
702
703
704 void GHOST_SetRectangle(GHOST_RectangleHandle rectanglehandle,
705                                                 GHOST_TInt32 l,
706                                                 GHOST_TInt32 t,
707                                                 GHOST_TInt32 r,
708                                                 GHOST_TInt32 b)
709 {
710         ((GHOST_Rect*)rectanglehandle)->set(l, t, r, b);
711 }
712
713
714
715 GHOST_TSuccess GHOST_IsEmptyRectangle(GHOST_RectangleHandle rectanglehandle)
716 {
717         GHOST_TSuccess result = GHOST_kFailure;
718
719         if (((GHOST_Rect*)rectanglehandle)->isEmpty())
720                 result = GHOST_kSuccess;
721
722         return result;
723 }
724
725
726
727 GHOST_TSuccess GHOST_IsValidRectangle(GHOST_RectangleHandle rectanglehandle)
728 {
729         GHOST_TSuccess result = GHOST_kFailure;
730
731         if(((GHOST_Rect*)rectanglehandle)->isValid())
732                 result = GHOST_kSuccess;
733
734         return result;
735 }
736
737
738
739 void GHOST_InsetRectangle(GHOST_RectangleHandle rectanglehandle,
740                                                   GHOST_TInt32 i)
741 {
742         ((GHOST_Rect*)rectanglehandle)->inset(i);
743 }
744
745
746
747 void GHOST_UnionRectangle(GHOST_RectangleHandle rectanglehandle,
748                                                   GHOST_RectangleHandle anotherrectanglehandle)
749 {
750         ((GHOST_Rect*)rectanglehandle)->unionRect(*(GHOST_Rect*)anotherrectanglehandle);
751 }
752
753
754
755 void GHOST_UnionPointRectangle(GHOST_RectangleHandle rectanglehandle,
756                                                            GHOST_TInt32 x,
757                                                            GHOST_TInt32 y)
758 {
759         ((GHOST_Rect*)rectanglehandle)->unionPoint(x, y);
760 }
761
762
763
764 GHOST_TSuccess GHOST_IsInsideRectangle(GHOST_RectangleHandle rectanglehandle,
765                                                                            GHOST_TInt32 x,
766                                                                            GHOST_TInt32 y)
767 {
768         GHOST_TSuccess result = GHOST_kFailure;
769
770         if (((GHOST_Rect*)rectanglehandle)->isInside(x, y))
771                 result = GHOST_kSuccess;
772
773         return result;
774 }
775
776
777
778 GHOST_TVisibility GHOST_GetRectangleVisibility(GHOST_RectangleHandle rectanglehandle,
779                                                                                            GHOST_RectangleHandle anotherrectanglehandle)
780 {
781         GHOST_TVisibility visible = GHOST_kNotVisible;
782
783         visible = ((GHOST_Rect*)rectanglehandle)->getVisibility(*(GHOST_Rect*)anotherrectanglehandle);
784
785         return visible;
786 }
787
788
789
790 void GHOST_SetCenterRectangle(GHOST_RectangleHandle rectanglehandle,
791                                                           GHOST_TInt32 cx,
792                                                           GHOST_TInt32 cy)
793 {
794         ((GHOST_Rect*)rectanglehandle)->setCenter(cx, cy);
795 }
796
797
798
799 void GHOST_SetRectangleCenter(GHOST_RectangleHandle rectanglehandle,
800                                                           GHOST_TInt32 cx,
801                                                           GHOST_TInt32 cy,
802                                                           GHOST_TInt32 w,
803                                                           GHOST_TInt32 h)
804 {
805         ((GHOST_Rect*)rectanglehandle)->setCenter(cx, cy, w, h);
806 }
807
808
809
810 GHOST_TSuccess GHOST_ClipRectangle(GHOST_RectangleHandle rectanglehandle,
811                                                                    GHOST_RectangleHandle anotherrectanglehandle)
812 {
813         GHOST_TSuccess result = GHOST_kFailure;
814
815         if (((GHOST_Rect*)rectanglehandle)->clip(*(GHOST_Rect*)anotherrectanglehandle))
816                 result = GHOST_kSuccess;
817
818         return result;
819 }
820
821 GHOST_TUns8* GHOST_getClipboard(int flag)
822 {
823         GHOST_ISystem* system = GHOST_ISystem::getSystem();
824         return system->getClipboard(flag);
825 }
826
827 void GHOST_putClipboard(GHOST_TInt8 *buffer, int flag)
828 {
829         GHOST_ISystem* system = GHOST_ISystem::getSystem();
830         system->putClipboard(buffer, flag);
831 }
832