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