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