]> git.saurik.com Git - wxWidgets.git/blob - src/mac/utils.cpp
Various compiler changes
[wxWidgets.git] / src / mac / utils.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: utils.cpp
3 // Purpose: Various utilities
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 // Note: this is done in utilscmn.cpp now.
14 // #pragma implementation
15 // #pragma implementation "utils.h"
16 #endif
17
18 #include "wx/setup.h"
19 #include "wx/utils.h"
20 #include "wx/app.h"
21
22 #include <ctype.h>
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include <stdarg.h>
28
29 // Get full hostname (eg. DoDo.BSn-Germany.crg.de)
30 bool wxGetHostName(char *buf, int maxSize)
31 {
32 // TODO
33 return FALSE;
34 }
35
36 // Get user ID e.g. jacs
37 bool wxGetUserId(char *buf, int maxSize)
38 {
39 // TODO
40 return FALSE;
41 }
42
43 // Get user name e.g. AUTHOR
44 bool wxGetUserName(char *buf, int maxSize)
45 {
46 // TODO
47 return FALSE;
48 }
49
50 int wxKill(long pid, int sig)
51 {
52 // TODO
53 return 0;
54 }
55
56 //
57 // Execute a program in an Interactive Shell
58 //
59 bool wxShell(const wxString& command)
60 {
61 // TODO
62 return FALSE;
63 }
64
65 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
66 long wxGetFreeMemory()
67 {
68 // TODO
69 return 0;
70 }
71
72 void wxSleep(int nSecs)
73 {
74 // TODO
75 }
76
77 // Consume all events until no more left
78 void wxFlushEvents()
79 {
80 }
81
82 // Output a debug message, in a system dependent fashion.
83 void wxDebugMsg(const char *fmt ...)
84 {
85 va_list ap;
86 static char buffer[512];
87
88 if (!wxTheApp->GetWantDebugOutput())
89 return ;
90
91 va_start(ap, fmt);
92
93 // wvsprintf(buffer,fmt,ap) ;
94 // TODO: output buffer
95
96 va_end(ap);
97 }
98
99 // Non-fatal error: pop up message box and (possibly) continue
100 void wxError(const wxString& msg, const wxString& title)
101 {
102 // TODO
103 wxExit();
104 }
105
106 // Fatal error: pop up message box and abort
107 void wxFatalError(const wxString& msg, const wxString& title)
108 {
109 // TODO
110 }
111
112 // Emit a beeeeeep
113 void wxBell()
114 {
115 // TODO
116 }
117
118 int wxGetOsVersion(int *majorVsn, int *minorVsn)
119 {
120 // TODO
121 return 0;
122 }
123
124 // Reading and writing resources (eg WIN.INI, .Xdefaults)
125 #if wxUSE_RESOURCES
126 bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file)
127 {
128 // TODO
129 return FALSE;
130 }
131
132 bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file)
133 {
134 char buf[50];
135 sprintf(buf, "%.4f", value);
136 return wxWriteResource(section, entry, buf, file);
137 }
138
139 bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file)
140 {
141 char buf[50];
142 sprintf(buf, "%ld", value);
143 return wxWriteResource(section, entry, buf, file);
144 }
145
146 bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file)
147 {
148 char buf[50];
149 sprintf(buf, "%d", value);
150 return wxWriteResource(section, entry, buf, file);
151 }
152
153 bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file)
154 {
155 // TODO
156 return FALSE;
157 }
158
159 bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file)
160 {
161 char *s = NULL;
162 bool succ = wxGetResource(section, entry, (char **)&s, file);
163 if (succ)
164 {
165 *value = (float)strtod(s, NULL);
166 delete[] s;
167 return TRUE;
168 }
169 else return FALSE;
170 }
171
172 bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file)
173 {
174 char *s = NULL;
175 bool succ = wxGetResource(section, entry, (char **)&s, file);
176 if (succ)
177 {
178 *value = strtol(s, NULL, 10);
179 delete[] s;
180 return TRUE;
181 }
182 else return FALSE;
183 }
184
185 bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file)
186 {
187 char *s = NULL;
188 bool succ = wxGetResource(section, entry, (char **)&s, file);
189 if (succ)
190 {
191 *value = (int)strtol(s, NULL, 10);
192 delete[] s;
193 return TRUE;
194 }
195 else return FALSE;
196 }
197 #endif // wxUSE_RESOURCES
198
199 int wxBusyCursorCount = 0;
200 extern CursHandle gMacCurrentCursor ;
201 CursHandle gMacStoredActiveCursor = NULL ;
202
203 // Set the cursor to the busy cursor for all windows
204 void wxBeginBusyCursor(wxCursor *cursor)
205 {
206 wxBusyCursorCount ++;
207 if (wxBusyCursorCount == 1)
208 {
209 gMacStoredActiveCursor = gMacCurrentCursor ;
210 ::SetCursor( *::GetCursor( watchCursor ) ) ;
211 }
212 else
213 {
214 // TODO
215 }
216 }
217
218 // Restore cursor to normal
219 void wxEndBusyCursor()
220 {
221 if (wxBusyCursorCount == 0)
222 return;
223
224 wxBusyCursorCount --;
225 if (wxBusyCursorCount == 0)
226 {
227 if ( gMacStoredActiveCursor )
228 ::SetCursor( *gMacStoredActiveCursor ) ;
229 else
230 ::SetCursor( &qd.arrow ) ;
231 gMacStoredActiveCursor = NULL ;
232 }
233 }
234
235 // TRUE if we're between the above two calls
236 bool wxIsBusy()
237 {
238 return (wxBusyCursorCount > 0);
239 }
240
241 char *wxGetUserHome (const wxString& user)
242 {
243 // TODO
244 return NULL;
245 }
246
247 // Check whether this window wants to process messages, e.g. Stop button
248 // in long calculations.
249 bool wxCheckForInterrupt(wxWindow *wnd)
250 {
251 // TODO
252 return FALSE;
253 }
254
255 void wxGetMousePosition( int* x, int* y )
256 {
257 Point pt ;
258
259 GetMouse( &pt ) ;
260 LocalToGlobal( &pt ) ;
261 *x = pt.h ;
262 *y = pt.v ;
263 };
264
265 // Return TRUE if we have a colour display
266 bool wxColourDisplay()
267 {
268 return TRUE;
269 }
270
271 // Returns depth of screen
272 int wxDisplayDepth()
273 {
274 // get max pixel depth
275 CGrafPtr port ;
276 GetCWMgrPort( &port ) ;
277 GDHandle maxDevice ;
278
279 maxDevice = GetMaxDevice( &port->portRect ) ;
280 if ( maxDevice )
281 return (**((**maxDevice).gdPMap)).pixelSize ;
282 else
283 return 8 ;
284 }
285
286 // Get size of display
287 void wxDisplaySize(int *width, int *height)
288 {
289 *width = qd.screenBits.bounds.right - qd.screenBits.bounds.left ;
290 *height = qd.screenBits.bounds.bottom - qd.screenBits.bounds.top ;
291 *height -= LMGetMBarHeight() ;
292 }
293