Patch by Psy-Fi + my minor changes
[blender.git] / intern / ghost / intern / GHOST_C-api.cpp
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19  * All rights reserved.
20  *
21  * The Original Code is: all of this file.
22  *
23  * Contributor(s): none yet.
24  *
25  * ***** END GPL LICENSE BLOCK *****
26  */
27
28 /** \file ghost/intern/GHOST_C-api.cpp
29  *  \ingroup GHOST
30  */
31
32
33 /*
34
35  * GHOST_C-Api.cpp
36  *
37  * C Api for GHOST
38  *
39  */
40
41 #include <stdlib.h>
42
43 #include "intern/GHOST_Debug.h"
44 #include "GHOST_C-api.h"
45 #include "GHOST_ISystem.h"
46 #include "GHOST_IEvent.h"
47 #include "GHOST_IEventConsumer.h"
48 #include "intern/GHOST_CallbackEventConsumer.h"
49
50 GHOST_SystemHandle GHOST_CreateSystem(void)
51 {
52         GHOST_ISystem::createSystem();
53         GHOST_ISystem* system = GHOST_ISystem::getSystem();
54
55         return (GHOST_SystemHandle)system;
56 }
57
58
59
60 GHOST_TSuccess GHOST_DisposeSystem(GHOST_SystemHandle systemhandle)
61 {
62         GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
63
64         return system->disposeSystem();
65 }
66
67
68 GHOST_EventConsumerHandle GHOST_CreateEventConsumer(GHOST_EventCallbackProcPtr eventCallback,
69                                                     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                                                                           const 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 GHOST_TSuccess GHOST_RemoveEventConsumer(GHOST_SystemHandle systemhandle, GHOST_EventConsumerHandle consumerhandle)
256 {
257         GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
258
259         return system->removeEventConsumer((GHOST_CallbackEventConsumer*)consumerhandle);
260 }
261
262 GHOST_TSuccess GHOST_SetProgressBar(GHOST_WindowHandle windowhandle,float progress)
263 {
264         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
265
266         return window->setProgressBar(progress);
267 }
268
269 GHOST_TSuccess GHOST_EndProgressBar(GHOST_WindowHandle windowhandle)
270 {
271         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
272
273         return window->endProgressBar();
274 }
275
276
277 GHOST_TStandardCursor GHOST_GetCursorShape(GHOST_WindowHandle windowhandle)
278 {
279         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
280
281         return window->getCursorShape();
282 }
283
284
285
286 GHOST_TSuccess GHOST_SetCursorShape(GHOST_WindowHandle windowhandle,
287                                                                         GHOST_TStandardCursor cursorshape)
288 {
289         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
290
291         return window->setCursorShape(cursorshape);
292 }
293
294 GHOST_TSuccess GHOST_SetCustomCursorShape(GHOST_WindowHandle windowhandle,
295                                                                                   GHOST_TUns8 bitmap[16][2], 
296                                                                                   GHOST_TUns8 mask[16][2], 
297                                                                                   int hotX, 
298                                                                                   int hotY)
299 {
300         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
301
302         return window->setCustomCursorShape(bitmap, mask, hotX, hotY);
303 }
304
305 GHOST_TSuccess GHOST_SetCustomCursorShapeEx(GHOST_WindowHandle windowhandle,
306                                                                                   GHOST_TUns8 *bitmap, 
307                                                                                   GHOST_TUns8 *mask, 
308                                                                                   int sizex, 
309                                                                                   int sizey,
310                                                                                   int hotX, 
311                                                                                   int hotY, 
312                                                                                   int fg_color, 
313                                                                                   int bg_color)
314 {
315         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
316
317         return window->setCustomCursorShape(bitmap, mask, sizex, sizey, 
318                                                                                                 hotX, hotY, fg_color, bg_color);
319 }
320
321
322
323 int GHOST_GetCursorVisibility(GHOST_WindowHandle windowhandle)
324 {
325         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
326
327         return (int) window->getCursorVisibility();
328 }
329
330
331
332 GHOST_TSuccess GHOST_SetCursorVisibility(GHOST_WindowHandle windowhandle,
333                                                                                  int visible)
334 {
335         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
336
337         return window->setCursorVisibility(visible?true:false);
338 }
339
340
341
342 GHOST_TSuccess GHOST_GetCursorPosition(GHOST_SystemHandle systemhandle,
343                                                                            GHOST_TInt32* x,
344                                                                            GHOST_TInt32* y)
345 {
346         GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
347         
348         return system->getCursorPosition(*x, *y);
349 }
350
351
352
353 GHOST_TSuccess GHOST_SetCursorPosition(GHOST_SystemHandle systemhandle,
354                                                                            GHOST_TInt32 x,
355                                                                            GHOST_TInt32 y)
356 {
357         GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
358         
359         return system->setCursorPosition(x, y);
360 }
361
362
363 GHOST_TSuccess GHOST_SetCursorGrab(GHOST_WindowHandle windowhandle,
364                                                                                 GHOST_TGrabCursorMode mode,
365                                                                                 int *bounds)
366 {
367         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
368         GHOST_Rect bounds_rect, bounds_win;
369
370         if(bounds) {
371                 /* if this is X11 specific we need a function that converts */
372                 window->getClientBounds(bounds_win);
373                 window->clientToScreen(bounds[0], bounds_win.getHeight() - bounds[1], bounds_rect.m_l, bounds_rect.m_t);
374                 window->clientToScreen(bounds[2], bounds_win.getHeight() - bounds[3], bounds_rect.m_r, bounds_rect.m_b);
375
376         }
377         
378         return window->setCursorGrab(mode, bounds ? &bounds_rect:NULL);
379 }
380
381
382 GHOST_TSuccess GHOST_GetModifierKeyState(GHOST_SystemHandle systemhandle,
383                                                                                  GHOST_TModifierKeyMask mask,
384                                                                                  int* isDown)
385 {
386         GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
387         GHOST_TSuccess result;
388         bool isdown= false;
389         
390         result = system->getModifierKeyState(mask, isdown);
391         *isDown = (int) isdown;
392
393         return result;
394 }
395
396
397
398 GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle,
399                                                                         GHOST_TButtonMask mask,
400                                                                         int* isDown)
401 {
402         GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
403         GHOST_TSuccess result;
404         bool isdown= false;
405         
406         result = system->getButtonState(mask, isdown);
407         *isDown = (int) isdown;
408
409         return result;
410 }
411
412
413 void GHOST_setAcceptDragOperation(GHOST_WindowHandle windowhandle, GHOST_TInt8 canAccept)
414 {
415         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
416
417         window->setAcceptDragOperation(canAccept);
418 }
419
420
421 GHOST_TEventType GHOST_GetEventType(GHOST_EventHandle eventhandle)
422 {
423         GHOST_IEvent* event = (GHOST_IEvent*) eventhandle;
424         
425         return event->getType();
426 }
427
428
429
430 GHOST_TUns64 GHOST_GetEventTime(GHOST_EventHandle eventhandle)
431 {
432         GHOST_IEvent* event = (GHOST_IEvent*) eventhandle;
433
434         return event->getTime();
435 }
436
437
438 GHOST_WindowHandle GHOST_GetEventWindow(GHOST_EventHandle eventhandle)
439 {
440         GHOST_IEvent* event = (GHOST_IEvent*) eventhandle;
441
442         return (GHOST_WindowHandle) event->getWindow();
443 }
444
445
446 GHOST_TEventDataPtr GHOST_GetEventData(GHOST_EventHandle eventhandle)
447 {
448         GHOST_IEvent* event = (GHOST_IEvent*) eventhandle;
449         
450         return event->getData();
451 }
452
453
454
455 GHOST_TimerProcPtr GHOST_GetTimerProc(GHOST_TimerTaskHandle timertaskhandle)
456 {
457         GHOST_ITimerTask* timertask = (GHOST_ITimerTask*) timertaskhandle;
458         
459         return timertask->getTimerProc();
460 }
461
462
463
464 void GHOST_SetTimerProc(GHOST_TimerTaskHandle timertaskhandle,
465                                                 GHOST_TimerProcPtr timerproc)
466 {
467         GHOST_ITimerTask* timertask = (GHOST_ITimerTask*) timertaskhandle;
468         
469         timertask->setTimerProc(timerproc);
470 }
471
472
473
474 GHOST_TUserDataPtr GHOST_GetTimerTaskUserData(GHOST_TimerTaskHandle timertaskhandle)
475 {
476         GHOST_ITimerTask* timertask = (GHOST_ITimerTask*) timertaskhandle;
477
478         return timertask->getUserData();
479 }
480
481         
482
483 void GHOST_SetTimerTaskUserData(GHOST_TimerTaskHandle timertaskhandle,
484                                                                 GHOST_TUserDataPtr userdata)
485 {
486         GHOST_ITimerTask* timertask = (GHOST_ITimerTask*) timertaskhandle;
487         
488         timertask->setUserData(userdata);
489 }
490
491
492
493 int GHOST_GetValid(GHOST_WindowHandle windowhandle) 
494 {
495         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
496
497         return (int) window->getValid();
498 }
499
500
501
502 GHOST_TDrawingContextType GHOST_GetDrawingContextType(GHOST_WindowHandle windowhandle)
503 {
504         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
505
506         return window->getDrawingContextType();
507 }
508
509
510
511 GHOST_TSuccess GHOST_SetDrawingContextType(GHOST_WindowHandle windowhandle,
512                                                                                    GHOST_TDrawingContextType type)
513 {
514         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
515
516         return window->setDrawingContextType(type);
517 }
518
519
520
521 void GHOST_SetTitle(GHOST_WindowHandle windowhandle,
522                                         const char* title)
523 {
524         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
525         
526         window->setTitle(title);
527 }
528
529
530 char* GHOST_GetTitle(GHOST_WindowHandle windowhandle)
531 {
532         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
533         STR_String title;
534
535         window->getTitle(title);
536
537         char *ctitle = (char*) malloc(title.Length() + 1);
538
539         if (ctitle == NULL) return NULL;
540         strcpy(ctitle, title.Ptr());
541                 
542         return ctitle;
543 }
544
545
546
547 GHOST_RectangleHandle GHOST_GetWindowBounds(GHOST_WindowHandle windowhandle) 
548 {
549         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
550         GHOST_Rect* rectangle = NULL;
551
552         rectangle = new GHOST_Rect();
553         window->getWindowBounds(*rectangle);
554
555         return (GHOST_RectangleHandle)rectangle;
556 }
557
558
559
560 GHOST_RectangleHandle GHOST_GetClientBounds(GHOST_WindowHandle windowhandle) 
561 {
562         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
563         GHOST_Rect* rectangle = NULL;
564
565         rectangle = new GHOST_Rect();
566         window->getClientBounds(*rectangle);
567
568         return (GHOST_RectangleHandle)rectangle;
569 }
570
571
572
573 void GHOST_DisposeRectangle(GHOST_RectangleHandle rectanglehandle)
574 {
575         delete (GHOST_Rect*) rectanglehandle;
576 }
577
578
579
580 GHOST_TSuccess GHOST_SetClientWidth(GHOST_WindowHandle windowhandle,
581                                                                         GHOST_TUns32 width)
582 {
583         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
584
585         return window->setClientWidth(width);
586 }
587
588
589
590 GHOST_TSuccess GHOST_SetClientHeight(GHOST_WindowHandle windowhandle,
591                                                                          GHOST_TUns32 height)
592 {
593         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
594
595         return window->setClientHeight(height);
596 }
597
598
599
600 GHOST_TSuccess GHOST_SetClientSize(GHOST_WindowHandle windowhandle,
601                                                                    GHOST_TUns32 width,
602                                                                    GHOST_TUns32 height)
603 {
604         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
605
606         return window->setClientSize(width, height);
607 }
608
609
610
611 void GHOST_ScreenToClient(GHOST_WindowHandle windowhandle,
612                                                   GHOST_TInt32 inX,
613                                                   GHOST_TInt32 inY,
614                                                   GHOST_TInt32* outX,
615                                                   GHOST_TInt32* outY) 
616 {
617         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
618
619         window->screenToClient(inX, inY, *outX, *outY);
620 }
621
622
623
624 void GHOST_ClientToScreen(GHOST_WindowHandle windowhandle,
625                                                   GHOST_TInt32 inX,
626                                                   GHOST_TInt32 inY,
627                                                   GHOST_TInt32* outX,
628                                                   GHOST_TInt32* outY)
629 {
630         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
631
632         window->clientToScreen(inX, inY, *outX, *outY);
633 }
634
635
636
637 GHOST_TWindowState GHOST_GetWindowState(GHOST_WindowHandle windowhandle)
638 {
639         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
640
641         return window->getState();
642 }
643
644
645
646 GHOST_TSuccess GHOST_SetWindowState(GHOST_WindowHandle windowhandle,
647                                                                         GHOST_TWindowState state)
648 {
649         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
650
651         return window->setState(state);
652 }
653
654
655 GHOST_TSuccess GHOST_SetWindowModifiedState(GHOST_WindowHandle windowhandle, GHOST_TUns8 isUnsavedChanges)
656 {
657         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
658         
659         return window->setModifiedState(isUnsavedChanges);
660 }       
661
662
663 GHOST_TSuccess GHOST_SetWindowOrder(GHOST_WindowHandle windowhandle,
664                                                                         GHOST_TWindowOrder order)
665 {
666         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
667         
668         return window->setOrder(order);
669 }
670
671
672
673 GHOST_TSuccess GHOST_SwapWindowBuffers(GHOST_WindowHandle windowhandle)
674 {
675         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
676
677         return window->swapBuffers();
678 }
679
680
681
682 GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandle)
683 {
684         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
685         
686         return window->activateDrawingContext();
687 }
688
689
690
691 GHOST_TSuccess GHOST_InvalidateWindow(GHOST_WindowHandle windowhandle)
692 {
693         GHOST_IWindow* window = (GHOST_IWindow*) windowhandle;
694
695         return window->invalidate();
696 }
697
698
699 extern const GHOST_TabletData* GHOST_GetTabletData(GHOST_WindowHandle windowhandle)
700 {
701         return ((GHOST_IWindow*)windowhandle)->GetTabletData();
702 }
703
704
705 GHOST_TInt32 GHOST_GetWidthRectangle(GHOST_RectangleHandle rectanglehandle)
706 {
707         return ((GHOST_Rect*)rectanglehandle)->getWidth();
708 }
709
710
711
712 GHOST_TInt32 GHOST_GetHeightRectangle(GHOST_RectangleHandle rectanglehandle)
713 {
714         return ((GHOST_Rect*)rectanglehandle)->getHeight();
715 }
716
717
718
719 void GHOST_GetRectangle(GHOST_RectangleHandle rectanglehandle,
720                                                            GHOST_TInt32* l,
721                                                            GHOST_TInt32* t,
722                                                            GHOST_TInt32* r,
723                                                            GHOST_TInt32* b)
724 {
725         GHOST_Rect *rect= (GHOST_Rect*) rectanglehandle;
726         
727         *l= rect->m_l;
728         *t= rect->m_t;
729         *r= rect->m_r;
730         *b= rect->m_b;
731 }
732
733
734 void GHOST_SetRectangle(GHOST_RectangleHandle rectanglehandle,
735                                                 GHOST_TInt32 l,
736                                                 GHOST_TInt32 t,
737                                                 GHOST_TInt32 r,
738                                                 GHOST_TInt32 b)
739 {
740         ((GHOST_Rect*)rectanglehandle)->set(l, t, r, b);
741 }
742
743
744
745 GHOST_TSuccess GHOST_IsEmptyRectangle(GHOST_RectangleHandle rectanglehandle)
746 {
747         GHOST_TSuccess result = GHOST_kFailure;
748
749         if (((GHOST_Rect*)rectanglehandle)->isEmpty())
750                 result = GHOST_kSuccess;
751
752         return result;
753 }
754
755
756
757 GHOST_TSuccess GHOST_IsValidRectangle(GHOST_RectangleHandle rectanglehandle)
758 {
759         GHOST_TSuccess result = GHOST_kFailure;
760
761         if(((GHOST_Rect*)rectanglehandle)->isValid())
762                 result = GHOST_kSuccess;
763
764         return result;
765 }
766
767
768
769 void GHOST_InsetRectangle(GHOST_RectangleHandle rectanglehandle,
770                                                   GHOST_TInt32 i)
771 {
772         ((GHOST_Rect*)rectanglehandle)->inset(i);
773 }
774
775
776
777 void GHOST_UnionRectangle(GHOST_RectangleHandle rectanglehandle,
778                                                   GHOST_RectangleHandle anotherrectanglehandle)
779 {
780         ((GHOST_Rect*)rectanglehandle)->unionRect(*(GHOST_Rect*)anotherrectanglehandle);
781 }
782
783
784
785 void GHOST_UnionPointRectangle(GHOST_RectangleHandle rectanglehandle,
786                                                            GHOST_TInt32 x,
787                                                            GHOST_TInt32 y)
788 {
789         ((GHOST_Rect*)rectanglehandle)->unionPoint(x, y);
790 }
791
792
793
794 GHOST_TSuccess GHOST_IsInsideRectangle(GHOST_RectangleHandle rectanglehandle,
795                                                                            GHOST_TInt32 x,
796                                                                            GHOST_TInt32 y)
797 {
798         GHOST_TSuccess result = GHOST_kFailure;
799
800         if (((GHOST_Rect*)rectanglehandle)->isInside(x, y))
801                 result = GHOST_kSuccess;
802
803         return result;
804 }
805
806
807
808 GHOST_TVisibility GHOST_GetRectangleVisibility(GHOST_RectangleHandle rectanglehandle,
809                                                                                            GHOST_RectangleHandle anotherrectanglehandle)
810 {
811         GHOST_TVisibility visible = GHOST_kNotVisible;
812
813         visible = ((GHOST_Rect*)rectanglehandle)->getVisibility(*(GHOST_Rect*)anotherrectanglehandle);
814
815         return visible;
816 }
817
818
819
820 void GHOST_SetCenterRectangle(GHOST_RectangleHandle rectanglehandle,
821                                                           GHOST_TInt32 cx,
822                                                           GHOST_TInt32 cy)
823 {
824         ((GHOST_Rect*)rectanglehandle)->setCenter(cx, cy);
825 }
826
827
828
829 void GHOST_SetRectangleCenter(GHOST_RectangleHandle rectanglehandle,
830                                                           GHOST_TInt32 cx,
831                                                           GHOST_TInt32 cy,
832                                                           GHOST_TInt32 w,
833                                                           GHOST_TInt32 h)
834 {
835         ((GHOST_Rect*)rectanglehandle)->setCenter(cx, cy, w, h);
836 }
837
838
839
840 GHOST_TSuccess GHOST_ClipRectangle(GHOST_RectangleHandle rectanglehandle,
841                                                                    GHOST_RectangleHandle anotherrectanglehandle)
842 {
843         GHOST_TSuccess result = GHOST_kFailure;
844
845         if (((GHOST_Rect*)rectanglehandle)->clip(*(GHOST_Rect*)anotherrectanglehandle))
846                 result = GHOST_kSuccess;
847
848         return result;
849 }
850
851 GHOST_TUns8* GHOST_getClipboard(int selection)
852 {
853         GHOST_ISystem* system = GHOST_ISystem::getSystem();
854         return system->getClipboard(selection);
855 }
856
857 void GHOST_putClipboard(GHOST_TInt8 *buffer, int selection)
858 {
859         GHOST_ISystem* system = GHOST_ISystem::getSystem();
860         system->putClipboard(buffer, selection);
861 }
862
863 int GHOST_toggleConsole(int action)
864 {
865         GHOST_ISystem* system = GHOST_ISystem::getSystem();
866         return system->toggleConsole(action);
867 }
868
869
870 int GHOST_confirmQuit(GHOST_WindowHandle windowhandle){
871         GHOST_ISystem* system = GHOST_ISystem::getSystem();
872         return system->confirmQuit((GHOST_IWindow*) windowhandle);
873 }