1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Various utilities
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 // Note: this is done in utilscmn.cpp now.
14 // #pragma implementation
15 // #pragma implementation "utils.h"
29 // Get full hostname (eg. DoDo.BSn-Germany.crg.de)
30 bool wxGetHostName(char *buf
, int maxSize
)
36 // Get user ID e.g. jacs
37 bool wxGetUserId(char *buf
, int maxSize
)
43 // Get user name e.g. AUTHOR
44 bool wxGetUserName(char *buf
, int maxSize
)
50 int wxKill(long pid
, int sig
)
57 // Execute a program in an Interactive Shell
59 bool wxShell(const wxString
& command
)
65 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
66 long wxGetFreeMemory()
72 void wxSleep(int nSecs
)
77 // Consume all events until no more left
82 // Output a debug message, in a system dependent fashion.
83 void wxDebugMsg(const char *fmt
...)
86 static char buffer
[512];
88 if (!wxTheApp
->GetWantDebugOutput())
93 // wvsprintf(buffer,fmt,ap) ;
94 // TODO: output buffer
99 // Non-fatal error: pop up message box and (possibly) continue
100 void wxError(const wxString
& msg
, const wxString
& title
)
106 // Fatal error: pop up message box and abort
107 void wxFatalError(const wxString
& msg
, const wxString
& title
)
118 int wxGetOsVersion(int *majorVsn
, int *minorVsn
)
124 // Reading and writing resources (eg WIN.INI, .Xdefaults)
126 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, const wxString
& value
, const wxString
& file
)
132 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, float value
, const wxString
& file
)
135 sprintf(buf
, "%.4f", value
);
136 return wxWriteResource(section
, entry
, buf
, file
);
139 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, long value
, const wxString
& file
)
142 sprintf(buf
, "%ld", value
);
143 return wxWriteResource(section
, entry
, buf
, file
);
146 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, int value
, const wxString
& file
)
149 sprintf(buf
, "%d", value
);
150 return wxWriteResource(section
, entry
, buf
, file
);
153 bool wxGetResource(const wxString
& section
, const wxString
& entry
, char **value
, const wxString
& file
)
159 bool wxGetResource(const wxString
& section
, const wxString
& entry
, float *value
, const wxString
& file
)
162 bool succ
= wxGetResource(section
, entry
, (char **)&s
, file
);
165 *value
= (float)strtod(s
, NULL
);
172 bool wxGetResource(const wxString
& section
, const wxString
& entry
, long *value
, const wxString
& file
)
175 bool succ
= wxGetResource(section
, entry
, (char **)&s
, file
);
178 *value
= strtol(s
, NULL
, 10);
185 bool wxGetResource(const wxString
& section
, const wxString
& entry
, int *value
, const wxString
& file
)
188 bool succ
= wxGetResource(section
, entry
, (char **)&s
, file
);
191 *value
= (int)strtol(s
, NULL
, 10);
197 #endif // wxUSE_RESOURCES
199 int wxBusyCursorCount
= 0;
200 extern CursHandle gMacCurrentCursor
;
201 CursHandle gMacStoredActiveCursor
= NULL
;
203 // Set the cursor to the busy cursor for all windows
204 void wxBeginBusyCursor(wxCursor
*cursor
)
206 wxBusyCursorCount
++;
207 if (wxBusyCursorCount
== 1)
209 gMacStoredActiveCursor
= gMacCurrentCursor
;
210 ::SetCursor( *::GetCursor( watchCursor
) ) ;
218 // Restore cursor to normal
219 void wxEndBusyCursor()
221 if (wxBusyCursorCount
== 0)
224 wxBusyCursorCount
--;
225 if (wxBusyCursorCount
== 0)
227 if ( gMacStoredActiveCursor
)
228 ::SetCursor( *gMacStoredActiveCursor
) ;
230 ::SetCursor( &qd
.arrow
) ;
231 gMacStoredActiveCursor
= NULL
;
235 // TRUE if we're between the above two calls
238 return (wxBusyCursorCount
> 0);
241 char *wxGetUserHome (const wxString
& user
)
247 // Check whether this window wants to process messages, e.g. Stop button
248 // in long calculations.
249 bool wxCheckForInterrupt(wxWindow
*wnd
)
255 void wxGetMousePosition( int* x
, int* y
)
260 LocalToGlobal( &pt
) ;
265 // Return TRUE if we have a colour display
266 bool wxColourDisplay()
271 // Returns depth of screen
274 // get max pixel depth
276 GetCWMgrPort( &port
) ;
279 maxDevice
= GetMaxDevice( &port
->portRect
) ;
281 return (**((**maxDevice
).gdPMap
)).pixelSize
;
286 // Get size of display
287 void wxDisplaySize(int *width
, int *height
)
289 *width
= qd
.screenBits
.bounds
.right
- qd
.screenBits
.bounds
.left
;
290 *height
= qd
.screenBits
.bounds
.bottom
- qd
.screenBits
.bounds
.top
;
291 *height
-= LMGetMBarHeight() ;