]> git.saurik.com Git - wxWidgets.git/blob - src/osx/cocoa/utils.mm
osx-cocoa updates
[wxWidgets.git] / src / osx / cocoa / utils.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/utils.mm
3 // Purpose: various cocoa utility functions
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id: utils.mm 48805 2007-09-19 14:52:25Z SC $
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #include "wx/wxprec.h"
15
16 #include "wx/utils.h"
17
18 #ifndef WX_PRECOMP
19 #include "wx/intl.h"
20 #include "wx/app.h"
21 #if wxUSE_GUI
22 #include "wx/toplevel.h"
23 #include "wx/font.h"
24 #endif
25 #endif
26
27 #include "wx/apptrait.h"
28
29 #include "wx/osx/private.h"
30
31 #if wxUSE_GUI
32 #if wxOSX_USE_COCOA_OR_CARBON
33 #include <CoreServices/CoreServices.h>
34 #include "wx/osx/private/timer.h"
35 #endif
36 #endif // wxUSE_GUI
37
38 #if wxOSX_USE_COCOA
39
40 #if wxUSE_BASE
41
42 // Emit a beeeeeep
43 void wxBell()
44 {
45 NSBeep();
46 }
47
48 // ----------------------------------------------------------------------------
49 // Common Event Support
50 // ----------------------------------------------------------------------------
51
52 void wxMacWakeUp()
53 {
54 // TODO
55 }
56
57 #endif // wxUSE_BASE
58
59 bool wxApp::DoInitGui()
60 {
61 [NSApplication sharedApplication];
62 [NSApp finishLaunching];
63 return true;
64 }
65
66 void wxApp::DoCleanUp()
67 {
68 }
69
70 #if wxUSE_GUI
71
72 void wxClientDisplayRect(int *x, int *y, int *width, int *height)
73 {
74 NSRect displayRect = [[NSScreen mainScreen] visibleFrame];
75 wxRect r = wxFromNSRect( NULL, displayRect );
76 if ( x )
77 *x = r.x;
78 if ( y )
79 *y = r.y;
80 if ( width )
81 *width = r.GetWidth();
82 if ( height )
83 *height = r.GetHeight();
84
85 }
86
87 void wxGetMousePosition( int* x, int* y )
88 {
89 wxPoint pt = wxFromNSPoint(NULL, [NSEvent mouseLocation]);
90 };
91
92 wxTimerImpl* wxGUIAppTraits::CreateTimerImpl(wxTimer *timer)
93 {
94 return new wxOSXTimerImpl(timer);
95 }
96
97 int gs_wxBusyCursorCount = 0;
98 extern wxCursor gMacCurrentCursor;
99 wxCursor gMacStoredActiveCursor;
100
101 // Set the cursor to the busy cursor for all windows
102 void wxBeginBusyCursor(const wxCursor *cursor)
103 {
104 if (gs_wxBusyCursorCount++ == 0)
105 {
106 gMacStoredActiveCursor = gMacCurrentCursor;
107 cursor->MacInstall();
108
109 wxSetCursor(*cursor);
110 }
111 //else: nothing to do, already set
112 }
113
114 // Restore cursor to normal
115 void wxEndBusyCursor()
116 {
117 wxCHECK_RET( gs_wxBusyCursorCount > 0,
118 wxT("no matching wxBeginBusyCursor() for wxEndBusyCursor()") );
119
120 if (--gs_wxBusyCursorCount == 0)
121 {
122 gMacStoredActiveCursor.MacInstall();
123 gMacStoredActiveCursor = wxNullCursor;
124
125 wxSetCursor(wxNullCursor);
126 }
127 }
128
129 // true if we're between the above two calls
130 bool wxIsBusy()
131 {
132 return (gs_wxBusyCursorCount > 0);
133 }
134
135 void wxMacGlobalToLocal( WindowRef window , Point*pt )
136 {
137 }
138
139 void wxMacLocalToGlobal( WindowRef window , Point*pt )
140 {
141 }
142
143 #endif // wxUSE_GUI
144
145
146
147 #endif // wxOSX_USE_COCOA