1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/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 <CoreServices/CoreServices.h>
34 #include "wx/osx/private/timer.h"
48 // ----------------------------------------------------------------------------
49 // Common Event Support
50 // ----------------------------------------------------------------------------
61 bool wxApp::DoInitGui()
63 [NSApplication sharedApplication];
64 [NSApp finishLaunching];
68 void wxApp::DoCleanUp()
72 void wxClientDisplayRect(int *x, int *y, int *width, int *height)
74 NSRect displayRect = [[NSScreen mainScreen] visibleFrame];
75 wxRect r = wxFromNSRect( NULL, displayRect );
81 *width = r.GetWidth();
83 *height = r.GetHeight();
87 void wxGetMousePosition( int* x, int* y )
89 wxPoint pt = wxFromNSPoint(NULL, [NSEvent mouseLocation]);
92 wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer *timer)
94 return new wxOSXTimerImpl(timer);
97 int gs_wxBusyCursorCount = 0;
98 extern wxCursor gMacCurrentCursor;
99 wxCursor gMacStoredActiveCursor;
101 // Set the cursor to the busy cursor for all windows
102 void wxBeginBusyCursor(const wxCursor *cursor)
104 if (gs_wxBusyCursorCount++ == 0)
106 gMacStoredActiveCursor = gMacCurrentCursor;
107 cursor->MacInstall();
109 wxSetCursor(*cursor);
111 //else: nothing to do, already set
114 // Restore cursor to normal
115 void wxEndBusyCursor()
117 wxCHECK_RET( gs_wxBusyCursorCount > 0,
118 wxT("no matching wxBeginBusyCursor() for wxEndBusyCursor()") );
120 if (--gs_wxBusyCursorCount == 0)
122 gMacStoredActiveCursor.MacInstall();
123 gMacStoredActiveCursor = wxNullCursor;
125 wxSetCursor(wxNullCursor);
129 // true if we're between the above two calls
132 return (gs_wxBusyCursorCount > 0);
135 void wxMacGlobalToLocal( WindowRef window , Point*pt )
139 void wxMacLocalToGlobal( WindowRef window , Point*pt )
147 #endif // wxOSX_USE_COCOA