1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/cocoa/utils.mm
3 // Purpose: various cocoa utility functions
4 // Author: Stefan Csomor
7 // RCS-ID: $Id: utils.mm 48805 2007-09-19 14:52:25Z SC $
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
14 #include "wx/wxprec.h"
22 #include "wx/toplevel.h"
27 #include "wx/apptrait.h"
29 #include "wx/osx/private.h"
32 #if wxOSX_USE_COCOA_OR_CARBON
33 #include "wx/osx/uma.h"
34 #include <CoreServices/CoreServices.h>
35 #include <Carbon/Carbon.h>
36 #include "wx/osx/private/timer.h"
50 // ----------------------------------------------------------------------------
51 // Common Event Support
52 // ----------------------------------------------------------------------------
63 void wxClientDisplayRect(int *x, int *y, int *width, int *height)
65 NSRect displayRect = [[NSScreen mainScreen] visibleFrame];
66 wxRect r = wxFromNSRect( NULL, displayRect );
72 *width = r.GetWidth();
74 *height = r.GetHeight();
78 void wxGetMousePosition( int* x, int* y )
80 wxPoint pt = wxFromNSPoint(NULL, [NSEvent mouseLocation]);
83 wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer *timer)
85 return new wxCarbonTimerImpl(timer);
88 int gs_wxBusyCursorCount = 0;
89 extern wxCursor gMacCurrentCursor;
90 wxCursor gMacStoredActiveCursor;
92 // Set the cursor to the busy cursor for all windows
93 void wxBeginBusyCursor(const wxCursor *cursor)
95 if (gs_wxBusyCursorCount++ == 0)
97 gMacStoredActiveCursor = gMacCurrentCursor;
100 wxSetCursor(*cursor);
102 //else: nothing to do, already set
105 // Restore cursor to normal
106 void wxEndBusyCursor()
108 wxCHECK_RET( gs_wxBusyCursorCount > 0,
109 wxT("no matching wxBeginBusyCursor() for wxEndBusyCursor()") );
111 if (--gs_wxBusyCursorCount == 0)
113 gMacStoredActiveCursor.MacInstall();
114 gMacStoredActiveCursor = wxNullCursor;
116 wxSetCursor(wxNullCursor);
120 // true if we're between the above two calls
123 return (gs_wxBusyCursorCount > 0);
126 void wxMacGlobalToLocal( WindowRef window , Point*pt )
130 void wxMacLocalToGlobal( WindowRef window , Point*pt )
138 #endif // wxOSX_USE_COCOA