style cleanup
[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) {
533                 return NULL;
534         }
535
536         strcpy(ctitle, title.Ptr());
537
538         return ctitle;
539 }
540
541
542
543 GHOST_RectangleHandle GHOST_GetWindowBounds(GHOST_WindowHandle windowhandle) 
544 {
545         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
546         GHOST_Rect *rectangle = NULL;
547
548         rectangle = new GHOST_Rect();
549         window->getWindowBounds(*rectangle);
550
551         return (GHOST_RectangleHandle)rectangle;
552 }
553
554
555
556 GHOST_RectangleHandle GHOST_GetClientBounds(GHOST_WindowHandle windowhandle) 
557 {
558         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
559         GHOST_Rect *rectangle = NULL;
560
561         rectangle = new GHOST_Rect();
562         window->getClientBounds(*rectangle);
563
564         return (GHOST_RectangleHandle)rectangle;
565 }
566
567
568
569 void GHOST_DisposeRectangle(GHOST_RectangleHandle rectanglehandle)
570 {
571         delete (GHOST_Rect *) rectanglehandle;
572 }
573
574
575
576 GHOST_TSuccess GHOST_SetClientWidth(GHOST_WindowHandle windowhandle,
577                                     GHOST_TUns32 width)
578 {
579         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
580
581         return window->setClientWidth(width);
582 }
583
584
585
586 GHOST_TSuccess GHOST_SetClientHeight(GHOST_WindowHandle windowhandle,
587                                      GHOST_TUns32 height)
588 {
589         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
590
591         return window->setClientHeight(height);
592 }
593
594
595
596 GHOST_TSuccess GHOST_SetClientSize(GHOST_WindowHandle windowhandle,
597                                    GHOST_TUns32 width,
598                                    GHOST_TUns32 height)
599 {
600         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
601
602         return window->setClientSize(width, height);
603 }
604
605
606
607 void GHOST_ScreenToClient(GHOST_WindowHandle windowhandle,
608                           GHOST_TInt32 inX,
609                           GHOST_TInt32 inY,
610                           GHOST_TInt32 *outX,
611                           GHOST_TInt32 *outY)
612 {
613         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
614
615         window->screenToClient(inX, inY, *outX, *outY);
616 }
617
618
619
620 void GHOST_ClientToScreen(GHOST_WindowHandle windowhandle,
621                           GHOST_TInt32 inX,
622                           GHOST_TInt32 inY,
623                           GHOST_TInt32 *outX,
624                           GHOST_TInt32 *outY)
625 {
626         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
627
628         window->clientToScreen(inX, inY, *outX, *outY);
629 }
630
631
632
633 GHOST_TWindowState GHOST_GetWindowState(GHOST_WindowHandle windowhandle)
634 {
635         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
636
637         return window->getState();
638 }
639
640
641
642 GHOST_TSuccess GHOST_SetWindowState(GHOST_WindowHandle windowhandle,
643                                     GHOST_TWindowState state)
644 {
645         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
646
647         return window->setState(state);
648 }
649
650
651 GHOST_TSuccess GHOST_SetWindowModifiedState(GHOST_WindowHandle windowhandle, GHOST_TUns8 isUnsavedChanges)
652 {
653         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
654         
655         return window->setModifiedState(isUnsavedChanges);
656 }       
657
658
659 GHOST_TSuccess GHOST_SetWindowOrder(GHOST_WindowHandle windowhandle,
660                                     GHOST_TWindowOrder order)
661 {
662         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
663         
664         return window->setOrder(order);
665 }
666
667
668
669 GHOST_TSuccess GHOST_SwapWindowBuffers(GHOST_WindowHandle windowhandle)
670 {
671         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
672
673         return window->swapBuffers();
674 }
675
676
677
678 GHOST_TSuccess GHOST_ActivateWindowDrawingContext(GHOST_WindowHandle windowhandle)
679 {
680         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
681         
682         return window->activateDrawingContext();
683 }
684
685
686
687 GHOST_TSuccess GHOST_InvalidateWindow(GHOST_WindowHandle windowhandle)
688 {
689         GHOST_IWindow *window = (GHOST_IWindow *) windowhandle;
690
691         return window->invalidate();
692 }
693
694
695 extern const GHOST_TabletData *GHOST_GetTabletData(GHOST_WindowHandle windowhandle)
696 {
697         return ((GHOST_IWindow *)windowhandle)->GetTabletData();
698 }
699
700
701 GHOST_TInt32 GHOST_GetWidthRectangle(GHOST_RectangleHandle rectanglehandle)
702 {
703         return ((GHOST_Rect *)rectanglehandle)->getWidth();
704 }
705
706
707
708 GHOST_TInt32 GHOST_GetHeightRectangle(GHOST_RectangleHandle rectanglehandle)
709 {
710         return ((GHOST_Rect *)rectanglehandle)->getHeight();
711 }
712
713
714
715 void GHOST_GetRectangle(GHOST_RectangleHandle rectanglehandle,
716                         GHOST_TInt32 *l,
717                         GHOST_TInt32 *t,
718                         GHOST_TInt32 *r,
719                         GHOST_TInt32 *b)
720 {
721         GHOST_Rect *rect = (GHOST_Rect *) rectanglehandle;
722
723         *l = rect->m_l;
724         *t = rect->m_t;
725         *r = rect->m_r;
726         *b = rect->m_b;
727 }
728
729
730 void GHOST_SetRectangle(GHOST_RectangleHandle rectanglehandle,
731                         GHOST_TInt32 l,
732                         GHOST_TInt32 t,
733                         GHOST_TInt32 r,
734                         GHOST_TInt32 b)
735 {
736         ((GHOST_Rect *)rectanglehandle)->set(l, t, r, b);
737 }
738
739
740
741 GHOST_TSuccess GHOST_IsEmptyRectangle(GHOST_RectangleHandle rectanglehandle)
742 {
743         GHOST_TSuccess result = GHOST_kFailure;
744
745         if (((GHOST_Rect *)rectanglehandle)->isEmpty())
746                 result = GHOST_kSuccess;
747
748         return result;
749 }
750
751
752
753 GHOST_TSuccess GHOST_IsValidRectangle(GHOST_RectangleHandle rectanglehandle)
754 {
755         GHOST_TSuccess result = GHOST_kFailure;
756
757         if (((GHOST_Rect *)rectanglehandle)->isValid())
758                 result = GHOST_kSuccess;
759
760         return result;
761 }
762
763
764
765 void GHOST_InsetRectangle(GHOST_RectangleHandle rectanglehandle,
766                           GHOST_TInt32 i)
767 {
768         ((GHOST_Rect *)rectanglehandle)->inset(i);
769 }
770
771
772
773 void GHOST_UnionRectangle(GHOST_RectangleHandle rectanglehandle,
774                           GHOST_RectangleHandle anotherrectanglehandle)
775 {
776         ((GHOST_Rect *)rectanglehandle)->unionRect(*(GHOST_Rect *)anotherrectanglehandle);
777 }
778
779
780
781 void GHOST_UnionPointRectangle(GHOST_RectangleHandle rectanglehandle,
782                                GHOST_TInt32 x,
783                                GHOST_TInt32 y)
784 {
785         ((GHOST_Rect *)rectanglehandle)->unionPoint(x, y);
786 }
787
788
789
790 GHOST_TSuccess GHOST_IsInsideRectangle(GHOST_RectangleHandle rectanglehandle,
791                                        GHOST_TInt32 x,
792                                        GHOST_TInt32 y)
793 {
794         GHOST_TSuccess result = GHOST_kFailure;
795
796         if (((GHOST_Rect *)rectanglehandle)->isInside(x, y))
797                 result = GHOST_kSuccess;
798
799         return result;
800 }
801
802
803
804 GHOST_TVisibility GHOST_GetRectangleVisibility(GHOST_RectangleHandle rectanglehandle,
805                                                GHOST_RectangleHandle anotherrectanglehandle)
806 {
807         GHOST_TVisibility visible = GHOST_kNotVisible;
808
809         visible = ((GHOST_Rect *)rectanglehandle)->getVisibility(*(GHOST_Rect *)anotherrectanglehandle);
810
811         return visible;
812 }
813
814
815
816 void GHOST_SetCenterRectangle(GHOST_RectangleHandle rectanglehandle,
817                               GHOST_TInt32 cx,
818                               GHOST_TInt32 cy)
819 {
820         ((GHOST_Rect *)rectanglehandle)->setCenter(cx, cy);
821 }
822
823
824
825 void GHOST_SetRectangleCenter(GHOST_RectangleHandle rectanglehandle,
826                               GHOST_TInt32 cx,
827                               GHOST_TInt32 cy,
828                               GHOST_TInt32 w,
829                               GHOST_TInt32 h)
830 {
831         ((GHOST_Rect *)rectanglehandle)->setCenter(cx, cy, w, h);
832 }
833
834
835
836 GHOST_TSuccess GHOST_ClipRectangle(GHOST_RectangleHandle rectanglehandle,
837                                    GHOST_RectangleHandle anotherrectanglehandle)
838 {
839         GHOST_TSuccess result = GHOST_kFailure;
840
841         if (((GHOST_Rect *)rectanglehandle)->clip(*(GHOST_Rect *)anotherrectanglehandle))
842                 result = GHOST_kSuccess;
843
844         return result;
845 }
846
847 GHOST_TUns8 *GHOST_getClipboard(int selection)
848 {
849         GHOST_ISystem *system = GHOST_ISystem::getSystem();
850         return system->getClipboard(selection);
851 }
852
853 void GHOST_putClipboard(GHOST_TInt8 *buffer, int selection)
854 {
855         GHOST_ISystem *system = GHOST_ISystem::getSystem();
856         system->putClipboard(buffer, selection);
857 }
858
859 int GHOST_toggleConsole(int action)
860 {
861         GHOST_ISystem *system = GHOST_ISystem::getSystem();
862         return system->toggleConsole(action);
863 }
864
865
866 int GHOST_confirmQuit(GHOST_WindowHandle windowhandle)
867 {
868         GHOST_ISystem *system = GHOST_ISystem::getSystem();
869         return system->confirmQuit((GHOST_IWindow *) windowhandle);
870 }