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