bb6c90cd4314e96febbfa8726e864df0e6c0ab78
[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)
359 {
360         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
361         GHOST_Rect bounds_rect, bounds_win;
362
363         if (bounds) {
364                 /* if this is X11 specific we need a function that converts */
365                 window->getClientBounds(bounds_win);
366                 window->clientToScreen(bounds[0], bounds_win.getHeight() - bounds[1], bounds_rect.m_l, bounds_rect.m_t);
367                 window->clientToScreen(bounds[2], bounds_win.getHeight() - bounds[3], bounds_rect.m_r, bounds_rect.m_b);
368
369         }
370         
371         return window->setCursorGrab(mode, bounds ? &bounds_rect : NULL);
372 }
373
374
375 GHOST_TSuccess GHOST_GetModifierKeyState(GHOST_SystemHandle systemhandle,
376                                          GHOST_TModifierKeyMask mask,
377                                          int *isDown)
378 {
379         GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
380         GHOST_TSuccess result;
381         bool isdown = false;
382         
383         result = system->getModifierKeyState(mask, isdown);
384         *isDown = (int) isdown;
385
386         return result;
387 }
388
389
390
391 GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle,
392                                     GHOST_TButtonMask mask,
393                                     int *isDown)
394 {
395         GHOST_ISystem *system = (GHOST_ISystem *) systemhandle;
396         GHOST_TSuccess result;
397         bool isdown = false;
398         
399         result = system->getButtonState(mask, isdown);
400         *isDown = (int) isdown;
401
402         return result;
403 }
404
405
406 void GHOST_setAcceptDragOperation(GHOST_WindowHandle windowhandle, GHOST_TInt8 canAccept)
407 {
408         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
409
410         window->setAcceptDragOperation(canAccept);
411 }
412
413
414 GHOST_TEventType GHOST_GetEventType(GHOST_EventHandle eventhandle)
415 {
416         GHOST_IEvent *event = (GHOST_IEvent *) eventhandle;
417         
418         return event->getType();
419 }
420
421
422
423 GHOST_TUns64 GHOST_GetEventTime(GHOST_EventHandle eventhandle)
424 {
425         GHOST_IEvent *event = (GHOST_IEvent *) eventhandle;
426
427         return event->getTime();
428 }
429
430
431 GHOST_WindowHandle GHOST_GetEventWindow(GHOST_EventHandle eventhandle)
432 {
433         GHOST_IEvent *event = (GHOST_IEvent *) eventhandle;
434
435         return (GHOST_WindowHandle) event->getWindow();
436 }
437
438
439 GHOST_TEventDataPtr GHOST_GetEventData(GHOST_EventHandle eventhandle)
440 {
441         GHOST_IEvent *event = (GHOST_IEvent *) eventhandle;
442         
443         return event->getData();
444 }
445
446
447
448 GHOST_TimerProcPtr GHOST_GetTimerProc(GHOST_TimerTaskHandle timertaskhandle)
449 {
450         GHOST_ITimerTask *timertask = (GHOST_ITimerTask *) timertaskhandle;
451         
452         return timertask->getTimerProc();
453 }
454
455
456
457 void GHOST_SetTimerProc(GHOST_TimerTaskHandle timertaskhandle,
458                         GHOST_TimerProcPtr timerproc)
459 {
460         GHOST_ITimerTask *timertask = (GHOST_ITimerTask *) timertaskhandle;
461         
462         timertask->setTimerProc(timerproc);
463 }
464
465
466
467 GHOST_TUserDataPtr GHOST_GetTimerTaskUserData(GHOST_TimerTaskHandle timertaskhandle)
468 {
469         GHOST_ITimerTask *timertask = (GHOST_ITimerTask *) timertaskhandle;
470
471         return timertask->getUserData();
472 }
473
474
475
476 void GHOST_SetTimerTaskUserData(GHOST_TimerTaskHandle timertaskhandle,
477                                 GHOST_TUserDataPtr userdata)
478 {
479         GHOST_ITimerTask *timertask = (GHOST_ITimerTask *) timertaskhandle;
480         
481         timertask->setUserData(userdata);
482 }
483
484
485
486 int GHOST_GetValid(GHOST_WindowHandle windowhandle) 
487 {
488         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
489
490         return (int) window->getValid();
491 }
492
493
494
495 GHOST_TDrawingContextType GHOST_GetDrawingContextType(GHOST_WindowHandle windowhandle)
496 {
497         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
498
499         return window->getDrawingContextType();
500 }
501
502
503
504 GHOST_TSuccess GHOST_SetDrawingContextType(GHOST_WindowHandle windowhandle,
505                                            GHOST_TDrawingContextType type)
506 {
507         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
508
509         return window->setDrawingContextType(type);
510 }
511
512
513
514 void GHOST_SetTitle(GHOST_WindowHandle windowhandle,
515                     const char *title)
516 {
517         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
518         
519         window->setTitle(title);
520 }
521
522
523 char *GHOST_GetTitle(GHOST_WindowHandle windowhandle)
524 {
525         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
526         STR_String title;
527
528         window->getTitle(title);
529
530         char *ctitle = (char *) malloc(title.Length() + 1);
531
532         if (ctitle == NULL) return NULL;
533         strcpy(ctitle, title.Ptr());
534
535         return ctitle;
536 }
537
538
539
540 GHOST_RectangleHandle GHOST_GetWindowBounds(GHOST_WindowHandle windowhandle) 
541 {
542         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
543         GHOST_Rect *rectangle = NULL;
544
545         rectangle = new GHOST_Rect();
546         window->getWindowBounds(*rectangle);
547
548         return (GHOST_RectangleHandle)rectangle;
549 }
550
551
552
553 GHOST_RectangleHandle GHOST_GetClientBounds(GHOST_WindowHandle windowhandle) 
554 {
555         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
556         GHOST_Rect *rectangle = NULL;
557
558         rectangle = new GHOST_Rect();
559         window->getClientBounds(*rectangle);
560
561         return (GHOST_RectangleHandle)rectangle;
562 }
563
564
565
566 void GHOST_DisposeRectangle(GHOST_RectangleHandle rectanglehandle)
567 {
568         delete (GHOST_Rect *) rectanglehandle;
569 }
570
571
572
573 GHOST_TSuccess GHOST_SetClientWidth(GHOST_WindowHandle windowhandle,
574                                     GHOST_TUns32 width)
575 {
576         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
577
578         return window->setClientWidth(width);
579 }
580
581
582
583 GHOST_TSuccess GHOST_SetClientHeight(GHOST_WindowHandle windowhandle,
584                                      GHOST_TUns32 height)
585 {
586         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
587
588         return window->setClientHeight(height);
589 }
590
591
592
593 GHOST_TSuccess GHOST_SetClientSize(GHOST_WindowHandle windowhandle,
594                                    GHOST_TUns32 width,
595                                    GHOST_TUns32 height)
596 {
597         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
598
599         return window->setClientSize(width, height);
600 }
601
602
603
604 void GHOST_ScreenToClient(GHOST_WindowHandle windowhandle,
605                           GHOST_TInt32 inX,
606                           GHOST_TInt32 inY,
607                           GHOST_TInt32 *outX,
608                           GHOST_TInt32 *outY)
609 {
610         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
611
612         window->screenToClient(inX, inY, *outX, *outY);
613 }
614
615
616
617 void GHOST_ClientToScreen(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->clientToScreen(inX, inY, *outX, *outY);
626 }
627
628
629
630 GHOST_TWindowState GHOST_GetWindowState(GHOST_WindowHandle windowhandle)
631 {
632         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
633
634         return window->getState();
635 }
636
637
638
639 GHOST_TSuccess GHOST_SetWindowState(GHOST_WindowHandle windowhandle,
640                                     GHOST_TWindowState state)
641 {
642         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
643
644         return window->setState(state);
645 }
646
647
648 GHOST_TSuccess GHOST_SetWindowModifiedState(GHOST_WindowHandle windowhandle, GHOST_TUns8 isUnsavedChanges)
649 {
650         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
651         
652         return window->setModifiedState(isUnsavedChanges);
653 }       
654
655
656 GHOST_TSuccess GHOST_SetWindowOrder(GHOST_WindowHandle windowhandle,
657                                     GHOST_TWindowOrder order)
658 {
659         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
660         
661         return window->setOrder(order);
662 }
663
664
665
666 GHOST_TSuccess GHOST_SwapWindowBuffers(GHOST_WindowHandle windowhandle)
667 {
668         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
669
670         return window->swapBuffers();
671 }
672
673
674
675 GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandle)
676 {
677         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
678         
679         return window->activateDrawingContext();
680 }
681
682
683
684 GHOST_TSuccess GHOST_InvalidateWindow(GHOST_WindowHandle windowhandle)
685 {
686         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
687
688         return window->invalidate();
689 }
690
691
692 extern const GHOST_TabletData *GHOST_GetTabletData(GHOST_WindowHandle windowhandle)
693 {
694         return ((GHOST_IWindow *)windowhandle)->GetTabletData();
695 }
696
697
698 GHOST_TInt32 GHOST_GetWidthRectangle(GHOST_RectangleHandle rectanglehandle)
699 {
700         return ((GHOST_Rect *)rectanglehandle)->getWidth();
701 }
702
703
704
705 GHOST_TInt32 GHOST_GetHeightRectangle(GHOST_RectangleHandle rectanglehandle)
706 {
707         return ((GHOST_Rect *)rectanglehandle)->getHeight();
708 }
709
710
711
712 void GHOST_GetRectangle(GHOST_RectangleHandle rectanglehandle,
713                         GHOST_TInt32 *l,
714                         GHOST_TInt32 *t,
715                         GHOST_TInt32 *r,
716                         GHOST_TInt32 *b)
717 {
718         GHOST_Rect *rect = (GHOST_Rect *) rectanglehandle;
719
720         *l = rect->m_l;
721         *t = rect->m_t;
722         *r = rect->m_r;
723         *b = rect->m_b;
724 }
725
726
727 void GHOST_SetRectangle(GHOST_RectangleHandle rectanglehandle,
728                         GHOST_TInt32 l,
729                         GHOST_TInt32 t,
730                         GHOST_TInt32 r,
731                         GHOST_TInt32 b)
732 {
733         ((GHOST_Rect *)rectanglehandle)->set(l, t, r, b);
734 }
735
736
737
738 GHOST_TSuccess GHOST_IsEmptyRectangle(GHOST_RectangleHandle rectanglehandle)
739 {
740         GHOST_TSuccess result = GHOST_kFailure;
741
742         if (((GHOST_Rect *)rectanglehandle)->isEmpty())
743                 result = GHOST_kSuccess;
744
745         return result;
746 }
747
748
749
750 GHOST_TSuccess GHOST_IsValidRectangle(GHOST_RectangleHandle rectanglehandle)
751 {
752         GHOST_TSuccess result = GHOST_kFailure;
753
754         if (((GHOST_Rect *)rectanglehandle)->isValid())
755                 result = GHOST_kSuccess;
756
757         return result;
758 }
759
760
761
762 void GHOST_InsetRectangle(GHOST_RectangleHandle rectanglehandle,
763                           GHOST_TInt32 i)
764 {
765         ((GHOST_Rect *)rectanglehandle)->inset(i);
766 }
767
768
769
770 void GHOST_UnionRectangle(GHOST_RectangleHandle rectanglehandle,
771                           GHOST_RectangleHandle anotherrectanglehandle)
772 {
773         ((GHOST_Rect *)rectanglehandle)->unionRect(*(GHOST_Rect *)anotherrectanglehandle);
774 }
775
776
777
778 void GHOST_UnionPointRectangle(GHOST_RectangleHandle rectanglehandle,
779                                GHOST_TInt32 x,
780                                GHOST_TInt32 y)
781 {
782         ((GHOST_Rect *)rectanglehandle)->unionPoint(x, y);
783 }
784
785
786
787 GHOST_TSuccess GHOST_IsInsideRectangle(GHOST_RectangleHandle rectanglehandle,
788                                        GHOST_TInt32 x,
789                                        GHOST_TInt32 y)
790 {
791         GHOST_TSuccess result = GHOST_kFailure;
792
793         if (((GHOST_Rect *)rectanglehandle)->isInside(x, y))
794                 result = GHOST_kSuccess;
795
796         return result;
797 }
798
799
800
801 GHOST_TVisibility GHOST_GetRectangleVisibility(GHOST_RectangleHandle rectanglehandle,
802                                                GHOST_RectangleHandle anotherrectanglehandle)
803 {
804         GHOST_TVisibility visible = GHOST_kNotVisible;
805
806         visible = ((GHOST_Rect *)rectanglehandle)->getVisibility(*(GHOST_Rect *)anotherrectanglehandle);
807
808         return visible;
809 }
810
811
812
813 void GHOST_SetCenterRectangle(GHOST_RectangleHandle rectanglehandle,
814                               GHOST_TInt32 cx,
815                               GHOST_TInt32 cy)
816 {
817         ((GHOST_Rect *)rectanglehandle)->setCenter(cx, cy);
818 }
819
820
821
822 void GHOST_SetRectangleCenter(GHOST_RectangleHandle rectanglehandle,
823                               GHOST_TInt32 cx,
824                               GHOST_TInt32 cy,
825                               GHOST_TInt32 w,
826                               GHOST_TInt32 h)
827 {
828         ((GHOST_Rect *)rectanglehandle)->setCenter(cx, cy, w, h);
829 }
830
831
832
833 GHOST_TSuccess GHOST_ClipRectangle(GHOST_RectangleHandle rectanglehandle,
834                                    GHOST_RectangleHandle anotherrectanglehandle)
835 {
836         GHOST_TSuccess result = GHOST_kFailure;
837
838         if (((GHOST_Rect *)rectanglehandle)->clip(*(GHOST_Rect *)anotherrectanglehandle))
839                 result = GHOST_kSuccess;
840
841         return result;
842 }
843
844 GHOST_TUns8 *GHOST_getClipboard(int selection)
845 {
846         GHOST_ISystem *system = GHOST_ISystem::getSystem();
847         return system->getClipboard(selection);
848 }
849
850 void GHOST_putClipboard(GHOST_TInt8 *buffer, int selection)
851 {
852         GHOST_ISystem *system = GHOST_ISystem::getSystem();
853         system->putClipboard(buffer, selection);
854 }
855
856 int GHOST_toggleConsole(int action)
857 {
858         GHOST_ISystem *system = GHOST_ISystem::getSystem();
859         return system->toggleConsole(action);
860 }
861
862
863 int GHOST_confirmQuit(GHOST_WindowHandle windowhandle)
864 {
865         GHOST_ISystem *system = GHOST_ISystem::getSystem();
866         return system->confirmQuit((GHOST_IWindow *) windowhandle);
867 }