]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: utils.h | |
3 | // Purpose: Miscellaneous utilities | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 29/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1998 Julian Smart | |
371a5b4e | 9 | // Licence: wxWindows licence |
c801d85f KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
34138703 JS |
12 | #ifndef _WX_UTILSH__ |
13 | #define _WX_UTILSH__ | |
c801d85f | 14 | |
d6b9496a VZ |
15 | // ---------------------------------------------------------------------------- |
16 | // headers | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
af49c4b8 | 19 | #if defined(__GNUG__) && !defined(__APPLE__) |
d6b9496a | 20 | #pragma interface "utils.h" |
c801d85f KB |
21 | #endif |
22 | ||
c801d85f KB |
23 | #include "wx/object.h" |
24 | #include "wx/list.h" | |
c801d85f | 25 | #include "wx/filefn.h" |
2da2f941 MB |
26 | |
27 | class WXDLLIMPEXP_BASE wxArrayString; | |
c801d85f | 28 | |
eadd7bd2 VZ |
29 | // need this for wxGetDiskSpace() as we can't, unfortunately, forward declare |
30 | // wxLongLong | |
31 | #include "wx/longlong.h" | |
32 | ||
c801d85f | 33 | #ifdef __X__ |
d6b9496a VZ |
34 | #include <dirent.h> |
35 | #include <unistd.h> | |
c801d85f KB |
36 | #endif |
37 | ||
38 | #include <stdio.h> | |
39 | ||
d6b9496a VZ |
40 | // ---------------------------------------------------------------------------- |
41 | // Forward declaration | |
42 | // ---------------------------------------------------------------------------- | |
43 | ||
bddd7a8d VZ |
44 | class WXDLLIMPEXP_BASE wxProcess; |
45 | class WXDLLIMPEXP_BASE wxFrame; | |
46 | class WXDLLIMPEXP_BASE wxWindow; | |
47 | class WXDLLIMPEXP_BASE wxWindowList; | |
48 | class WXDLLIMPEXP_BASE wxPoint; | |
d6b9496a | 49 | |
d6b9496a VZ |
50 | // ---------------------------------------------------------------------------- |
51 | // Macros | |
52 | // ---------------------------------------------------------------------------- | |
c801d85f | 53 | |
d6b9496a VZ |
54 | #define wxMax(a,b) (((a) > (b)) ? (a) : (b)) |
55 | #define wxMin(a,b) (((a) < (b)) ? (a) : (b)) | |
c801d85f | 56 | |
d6b9496a VZ |
57 | // ---------------------------------------------------------------------------- |
58 | // String functions (deprecated, use wxString) | |
59 | // ---------------------------------------------------------------------------- | |
60 | ||
c801d85f | 61 | // Make a copy of this string using 'new' |
f526f752 | 62 | #if WXWIN_COMPATIBILITY_2_4 |
bddd7a8d | 63 | WXDLLIMPEXP_BASE wxChar* copystring(const wxChar *s); |
f526f752 | 64 | #endif |
c801d85f | 65 | |
2b5f62a0 | 66 | #if WXWIN_COMPATIBILITY_2 |
d6b9496a | 67 | // Matches string one within string two regardless of case |
bddd7a8d | 68 | WXDLLIMPEXP_BASE bool StringMatch(const wxChar *one, const wxChar *two, bool subString = TRUE, bool exact = FALSE); |
2b5f62a0 | 69 | #endif |
d6b9496a VZ |
70 | |
71 | // A shorter way of using strcmp | |
9d2f3c71 | 72 | #define wxStringEq(s1, s2) (s1 && s2 && (wxStrcmp(s1, s2) == 0)) |
d6b9496a VZ |
73 | |
74 | // ---------------------------------------------------------------------------- | |
75 | // Miscellaneous functions | |
76 | // ---------------------------------------------------------------------------- | |
77 | ||
78 | // Sound the bell | |
bddd7a8d | 79 | WXDLLIMPEXP_BASE void wxBell(); |
d6b9496a | 80 | |
bdc72a22 | 81 | // Get OS description as a user-readable string |
bddd7a8d | 82 | WXDLLIMPEXP_BASE wxString wxGetOsDescription(); |
bdc72a22 | 83 | |
d6b9496a | 84 | // Get OS version |
bddd7a8d | 85 | WXDLLIMPEXP_BASE int wxGetOsVersion(int *majorVsn = (int *) NULL, |
bdc72a22 | 86 | int *minorVsn = (int *) NULL); |
d6b9496a VZ |
87 | |
88 | // Return a string with the current date/time | |
bddd7a8d | 89 | WXDLLIMPEXP_BASE wxString wxNow(); |
d6b9496a | 90 | |
134677bd | 91 | // Return path where wxWindows is installed (mostly useful in Unices) |
bddd7a8d | 92 | WXDLLIMPEXP_BASE const wxChar *wxGetInstallPrefix(); |
2c18f21d | 93 | // Return path to wxWin data (/usr/share/wx/%{version}) (Unices) |
bddd7a8d | 94 | WXDLLIMPEXP_BASE wxString wxGetDataDir(); |
134677bd VS |
95 | |
96 | ||
e90c1d2a | 97 | #if wxUSE_GUI |
63cc5d9d RR |
98 | // Don't synthesize KeyUp events holding down a key and producing |
99 | // KeyDown events with autorepeat. On by default and always on | |
100 | // in wxMSW. | |
f0492f7d RR |
101 | WXDLLEXPORT bool wxSetDetectableAutoRepeat( bool flag ); |
102 | ||
d6b9496a VZ |
103 | // ---------------------------------------------------------------------------- |
104 | // Window ID management | |
105 | // ---------------------------------------------------------------------------- | |
106 | ||
c801d85f | 107 | // Generate a unique ID |
afb74891 | 108 | WXDLLEXPORT long wxNewId(); |
d6b9496a VZ |
109 | #if !defined(NewId) && defined(WXWIN_COMPATIBILITY) |
110 | #define NewId wxNewId | |
111 | #endif | |
c801d85f KB |
112 | |
113 | // Ensure subsequent IDs don't clash with this one | |
184b5d99 | 114 | WXDLLEXPORT void wxRegisterId(long id); |
d6b9496a VZ |
115 | #if !defined(RegisterId) && defined(WXWIN_COMPATIBILITY) |
116 | #define RegisterId wxRegisterId | |
117 | #endif | |
c801d85f KB |
118 | |
119 | // Return the current ID | |
afb74891 | 120 | WXDLLEXPORT long wxGetCurrentId(); |
c801d85f | 121 | |
e90c1d2a VZ |
122 | #endif // wxUSE_GUI |
123 | ||
d6b9496a VZ |
124 | // ---------------------------------------------------------------------------- |
125 | // Various conversions | |
126 | // ---------------------------------------------------------------------------- | |
c801d85f | 127 | |
e12c92c2 VZ |
128 | // these functions are deprecated, use wxString methods instead! |
129 | #if WXWIN_COMPATIBILITY_2_4 | |
130 | ||
bddd7a8d VZ |
131 | WXDLLIMPEXP_DATA_BASE(extern const wxChar*) wxFloatToStringStr; |
132 | WXDLLIMPEXP_DATA_BASE(extern const wxChar*) wxDoubleToStringStr; | |
c801d85f | 133 | |
bddd7a8d VZ |
134 | WXDLLIMPEXP_BASE void StringToFloat(const wxChar *s, float *number); |
135 | WXDLLIMPEXP_BASE wxChar* FloatToString(float number, const wxChar *fmt = wxFloatToStringStr); | |
136 | WXDLLIMPEXP_BASE void StringToDouble(const wxChar *s, double *number); | |
137 | WXDLLIMPEXP_BASE wxChar* DoubleToString(double number, const wxChar *fmt = wxDoubleToStringStr); | |
138 | WXDLLIMPEXP_BASE void StringToInt(const wxChar *s, int *number); | |
139 | WXDLLIMPEXP_BASE void StringToLong(const wxChar *s, long *number); | |
140 | WXDLLIMPEXP_BASE wxChar* IntToString(int number); | |
141 | WXDLLIMPEXP_BASE wxChar* LongToString(long number); | |
c801d85f | 142 | |
e12c92c2 VZ |
143 | #endif // WXWIN_COMPATIBILITY_2_4 |
144 | ||
c801d85f | 145 | // Convert 2-digit hex number to decimal |
bddd7a8d | 146 | WXDLLIMPEXP_BASE int wxHexToDec(const wxString& buf); |
c801d85f KB |
147 | |
148 | // Convert decimal integer to 2-character hex string | |
bddd7a8d VZ |
149 | WXDLLIMPEXP_BASE void wxDecToHex(int dec, wxChar *buf); |
150 | WXDLLIMPEXP_BASE wxString wxDecToHex(int dec); | |
c801d85f | 151 | |
d6b9496a VZ |
152 | // ---------------------------------------------------------------------------- |
153 | // Process management | |
154 | // ---------------------------------------------------------------------------- | |
155 | ||
fbf456aa VZ |
156 | // NB: for backwars compatibility reasons the values of wxEXEC_[A]SYNC *must* |
157 | // be 0 and 1, don't change! | |
158 | ||
159 | enum | |
160 | { | |
e1082c9f VZ |
161 | // execute the process asynchronously |
162 | wxEXEC_ASYNC = 0, | |
163 | ||
164 | // execute it synchronously, i.e. wait until it finishes | |
165 | wxEXEC_SYNC = 1, | |
166 | ||
167 | // under Windows, don't hide the child even if it's IO is redirected (this | |
168 | // is done by default) | |
169 | wxEXEC_NOHIDE = 2, | |
170 | ||
171 | // under Unix, if the process is the group leader then killing -pid kills | |
172 | // all children as well as pid | |
173 | wxEXEC_MAKE_GROUP_LEADER = 4 | |
fbf456aa VZ |
174 | }; |
175 | ||
176 | // Execute another program. | |
177 | // | |
178 | // If flags contain wxEXEC_SYNC, return -1 on failure and the exit code of the | |
179 | // process if everything was ok. Otherwise (i.e. if wxEXEC_ASYNC), return 0 on | |
180 | // failure and the PID of the launched process if ok. | |
bddd7a8d | 181 | WXDLLIMPEXP_BASE long wxExecute(wxChar **argv, int flags = wxEXEC_ASYNC, |
c67daf87 | 182 | wxProcess *process = (wxProcess *) NULL); |
bddd7a8d | 183 | WXDLLIMPEXP_BASE long wxExecute(const wxString& command, int flags = wxEXEC_ASYNC, |
c67daf87 | 184 | wxProcess *process = (wxProcess *) NULL); |
c801d85f | 185 | |
fbf456aa VZ |
186 | // execute the command capturing its output into an array line by line, this is |
187 | // always synchronous | |
bddd7a8d | 188 | WXDLLIMPEXP_BASE long wxExecute(const wxString& command, |
f6bcfd97 BP |
189 | wxArrayString& output); |
190 | ||
fbf456aa | 191 | // also capture stderr (also synchronous) |
bddd7a8d | 192 | WXDLLIMPEXP_BASE long wxExecute(const wxString& command, |
f6bcfd97 BP |
193 | wxArrayString& output, |
194 | wxArrayString& error); | |
cd6ce4a9 | 195 | |
d6b9496a VZ |
196 | enum wxSignal |
197 | { | |
198 | wxSIGNONE = 0, // verify if the process exists under Unix | |
199 | wxSIGHUP, | |
200 | wxSIGINT, | |
201 | wxSIGQUIT, | |
202 | wxSIGILL, | |
203 | wxSIGTRAP, | |
204 | wxSIGABRT, | |
205 | wxSIGIOT = wxSIGABRT, // another name | |
206 | wxSIGEMT, | |
207 | wxSIGFPE, | |
208 | wxSIGKILL, | |
209 | wxSIGBUS, | |
210 | wxSIGSEGV, | |
211 | wxSIGSYS, | |
212 | wxSIGPIPE, | |
213 | wxSIGALRM, | |
214 | wxSIGTERM | |
215 | ||
216 | // further signals are different in meaning between different Unix systems | |
217 | }; | |
c801d85f | 218 | |
50567b69 VZ |
219 | enum wxKillError |
220 | { | |
221 | wxKILL_OK, // no error | |
222 | wxKILL_BAD_SIGNAL, // no such signal | |
223 | wxKILL_ACCESS_DENIED, // permission denied | |
224 | wxKILL_NO_PROCESS, // no such process | |
225 | wxKILL_ERROR // another, unspecified error | |
226 | }; | |
227 | ||
f6ba47d9 VZ |
228 | enum wxShutdownFlags |
229 | { | |
230 | wxSHUTDOWN_POWEROFF, // power off the computer | |
231 | wxSHUTDOWN_REBOOT // shutdown and reboot | |
232 | }; | |
233 | ||
c1cb4153 | 234 | // Shutdown or reboot the PC |
bddd7a8d | 235 | WXDLLIMPEXP_BASE bool wxShutdown(wxShutdownFlags wFlags); |
f6ba47d9 | 236 | |
50567b69 VZ |
237 | // send the given signal to the process (only NONE and KILL are supported under |
238 | // Windows, all others mean TERM), return 0 if ok and -1 on error | |
239 | // | |
240 | // return detailed error in rc if not NULL | |
bddd7a8d | 241 | WXDLLIMPEXP_BASE int wxKill(long pid, |
50567b69 VZ |
242 | wxSignal sig = wxSIGTERM, |
243 | wxKillError *rc = NULL); | |
c801d85f | 244 | |
2c8e4738 | 245 | // Execute a command in an interactive shell window (always synchronously) |
c801d85f | 246 | // If no command then just the shell |
bddd7a8d | 247 | WXDLLIMPEXP_BASE bool wxShell(const wxString& command = wxEmptyString); |
c801d85f | 248 | |
2c8e4738 VZ |
249 | // As wxShell(), but must give a (non interactive) command and its output will |
250 | // be returned in output array | |
bddd7a8d | 251 | WXDLLIMPEXP_BASE bool wxShell(const wxString& command, wxArrayString& output); |
2c8e4738 | 252 | |
b568d04f | 253 | // Sleep for nSecs seconds |
bddd7a8d | 254 | WXDLLIMPEXP_BASE void wxSleep(int nSecs); |
c801d85f | 255 | |
afb74891 | 256 | // Sleep for a given amount of milliseconds |
bddd7a8d | 257 | WXDLLIMPEXP_BASE void wxUsleep(unsigned long milliseconds); |
afb74891 | 258 | |
c1cb4153 | 259 | // Get the process id of the current process |
bddd7a8d | 260 | WXDLLIMPEXP_BASE unsigned long wxGetProcessId(); |
c1cb4153 | 261 | |
c801d85f | 262 | // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX) |
bddd7a8d | 263 | WXDLLIMPEXP_BASE long wxGetFreeMemory(); |
c801d85f | 264 | |
a37a5a73 | 265 | // should wxApp::OnFatalException() be called? |
bddd7a8d | 266 | WXDLLIMPEXP_BASE bool wxHandleFatalExceptions(bool doit = TRUE); |
a37a5a73 | 267 | |
8fd0d89b VZ |
268 | // ---------------------------------------------------------------------------- |
269 | // Environment variables | |
270 | // ---------------------------------------------------------------------------- | |
271 | ||
308978f6 VZ |
272 | // returns TRUE if variable exists (value may be NULL if you just want to check |
273 | // for this) | |
bddd7a8d | 274 | WXDLLIMPEXP_BASE bool wxGetEnv(const wxString& var, wxString *value); |
8fd0d89b VZ |
275 | |
276 | // set the env var name to the given value, return TRUE on success | |
bddd7a8d | 277 | WXDLLIMPEXP_BASE bool wxSetEnv(const wxString& var, const wxChar *value); |
8fd0d89b VZ |
278 | |
279 | // remove the env var from environment | |
280 | inline bool wxUnsetEnv(const wxString& var) { return wxSetEnv(var, NULL); } | |
281 | ||
d6b9496a VZ |
282 | // ---------------------------------------------------------------------------- |
283 | // Network and username functions. | |
284 | // ---------------------------------------------------------------------------- | |
c801d85f | 285 | |
d6b9496a | 286 | // NB: "char *" functions are deprecated, use wxString ones! |
c801d85f KB |
287 | |
288 | // Get eMail address | |
bddd7a8d VZ |
289 | WXDLLIMPEXP_BASE bool wxGetEmailAddress(wxChar *buf, int maxSize); |
290 | WXDLLIMPEXP_BASE wxString wxGetEmailAddress(); | |
c801d85f KB |
291 | |
292 | // Get hostname. | |
bddd7a8d VZ |
293 | WXDLLIMPEXP_BASE bool wxGetHostName(wxChar *buf, int maxSize); |
294 | WXDLLIMPEXP_BASE wxString wxGetHostName(); | |
d6b9496a VZ |
295 | |
296 | // Get FQDN | |
bddd7a8d VZ |
297 | WXDLLIMPEXP_BASE wxString wxGetFullHostName(); |
298 | WXDLLIMPEXP_BASE bool wxGetFullHostName(wxChar *buf, int maxSize); | |
c801d85f | 299 | |
d6b9496a | 300 | // Get user ID e.g. jacs (this is known as login name under Unix) |
bddd7a8d VZ |
301 | WXDLLIMPEXP_BASE bool wxGetUserId(wxChar *buf, int maxSize); |
302 | WXDLLIMPEXP_BASE wxString wxGetUserId(); | |
c801d85f KB |
303 | |
304 | // Get user name e.g. Julian Smart | |
bddd7a8d VZ |
305 | WXDLLIMPEXP_BASE bool wxGetUserName(wxChar *buf, int maxSize); |
306 | WXDLLIMPEXP_BASE wxString wxGetUserName(); | |
d6b9496a VZ |
307 | |
308 | // Get current Home dir and copy to dest (returns pstr->c_str()) | |
bddd7a8d VZ |
309 | WXDLLIMPEXP_BASE wxString wxGetHomeDir(); |
310 | WXDLLIMPEXP_BASE const wxChar* wxGetHomeDir(wxString *pstr); | |
d6b9496a VZ |
311 | |
312 | // Get the user's home dir (caller must copy --- volatile) | |
313 | // returns NULL is no HOME dir is known | |
61ef57fc | 314 | #if defined(__UNIX__) && wxUSE_UNICODE |
bddd7a8d | 315 | WXDLLIMPEXP_BASE const wxMB2WXbuf wxGetUserHome(const wxString& user = wxEmptyString); |
61ef57fc | 316 | #else |
bddd7a8d | 317 | WXDLLIMPEXP_BASE wxChar* wxGetUserHome(const wxString& user = wxEmptyString); |
61ef57fc | 318 | #endif |
d6b9496a | 319 | |
eadd7bd2 | 320 | // get number of total/free bytes on the disk where path belongs |
bddd7a8d | 321 | WXDLLIMPEXP_BASE bool wxGetDiskSpace(const wxString& path, |
eadd7bd2 VZ |
322 | wxLongLong *pTotal = NULL, |
323 | wxLongLong *pFree = NULL); | |
324 | ||
e90c1d2a VZ |
325 | #if wxUSE_GUI // GUI only things from now on |
326 | ||
d6b9496a | 327 | // ---------------------------------------------------------------------------- |
974e8d94 | 328 | // Menu accelerators related things |
d6b9496a | 329 | // ---------------------------------------------------------------------------- |
c801d85f | 330 | |
bc87fd68 | 331 | WXDLLEXPORT wxChar* wxStripMenuCodes(const wxChar *in, wxChar *out = (wxChar *) NULL); |
184b5d99 | 332 | WXDLLEXPORT wxString wxStripMenuCodes(const wxString& str); |
c801d85f | 333 | |
974e8d94 VZ |
334 | #if wxUSE_ACCEL |
335 | class WXDLLEXPORT wxAcceleratorEntry; | |
336 | WXDLLEXPORT wxAcceleratorEntry *wxGetAccelFromString(const wxString& label); | |
337 | #endif // wxUSE_ACCEL | |
338 | ||
d6b9496a VZ |
339 | // ---------------------------------------------------------------------------- |
340 | // Window search | |
341 | // ---------------------------------------------------------------------------- | |
342 | ||
c801d85f | 343 | // Returns menu item id or -1 if none. |
184b5d99 | 344 | WXDLLEXPORT int wxFindMenuItemId(wxFrame *frame, const wxString& menuString, const wxString& itemString); |
c801d85f | 345 | |
57591e0e JS |
346 | // Find the wxWindow at the given point. wxGenericFindWindowAtPoint |
347 | // is always present but may be less reliable than a native version. | |
348 | WXDLLEXPORT wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt); | |
59a12e90 JS |
349 | WXDLLEXPORT wxWindow* wxFindWindowAtPoint(const wxPoint& pt); |
350 | ||
146ba0fe VZ |
351 | // NB: this function is obsolete, use wxWindow::FindWindowByLabel() instead |
352 | // | |
353 | // Find the window/widget with the given title or label. | |
354 | // Pass a parent to begin the search from, or NULL to look through | |
355 | // all windows. | |
356 | WXDLLEXPORT wxWindow* wxFindWindowByLabel(const wxString& title, wxWindow *parent = (wxWindow *) NULL); | |
357 | ||
358 | // NB: this function is obsolete, use wxWindow::FindWindowByName() instead | |
359 | // | |
360 | // Find window by name, and if that fails, by label. | |
361 | WXDLLEXPORT wxWindow* wxFindWindowByName(const wxString& name, wxWindow *parent = (wxWindow *) NULL); | |
362 | ||
d6b9496a VZ |
363 | // ---------------------------------------------------------------------------- |
364 | // Message/event queue helpers | |
365 | // ---------------------------------------------------------------------------- | |
c801d85f | 366 | |
ead7ce10 | 367 | // Yield to other apps/messages and disable user input |
b829bf55 | 368 | WXDLLEXPORT bool wxSafeYield(wxWindow *win = NULL, bool onlyIfNeeded = FALSE); |
ead7ce10 | 369 | |
95dee651 KB |
370 | // Enable or disable input to all top level windows |
371 | WXDLLEXPORT void wxEnableTopLevelWindows(bool enable = TRUE); | |
372 | ||
d6b9496a VZ |
373 | // Check whether this window wants to process messages, e.g. Stop button |
374 | // in long calculations. | |
375 | WXDLLEXPORT bool wxCheckForInterrupt(wxWindow *wnd); | |
376 | ||
377 | // Consume all events until no more left | |
378 | WXDLLEXPORT void wxFlushEvents(); | |
379 | ||
cd6ce4a9 VZ |
380 | // a class which disables all windows (except, may be, thegiven one) in its |
381 | // ctor and enables them back in its dtor | |
382 | class WXDLLEXPORT wxWindowDisabler | |
383 | { | |
384 | public: | |
385 | wxWindowDisabler(wxWindow *winToSkip = (wxWindow *)NULL); | |
386 | ~wxWindowDisabler(); | |
387 | ||
388 | private: | |
389 | wxWindowList *m_winDisabled; | |
c1cb4153 VZ |
390 | |
391 | DECLARE_NO_COPY_CLASS(wxWindowDisabler) | |
cd6ce4a9 VZ |
392 | }; |
393 | ||
d6b9496a VZ |
394 | // ---------------------------------------------------------------------------- |
395 | // Cursors | |
396 | // ---------------------------------------------------------------------------- | |
c801d85f KB |
397 | |
398 | // Set the cursor to the busy cursor for all windows | |
399 | class WXDLLEXPORT wxCursor; | |
400 | WXDLLEXPORT_DATA(extern wxCursor*) wxHOURGLASS_CURSOR; | |
184b5d99 | 401 | WXDLLEXPORT void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR); |
e2a6f233 | 402 | |
c801d85f | 403 | // Restore cursor to normal |
afb74891 | 404 | WXDLLEXPORT void wxEndBusyCursor(); |
d6b9496a | 405 | |
c801d85f | 406 | // TRUE if we're between the above two calls |
afb74891 | 407 | WXDLLEXPORT bool wxIsBusy(); |
c801d85f | 408 | |
e2a6f233 JS |
409 | // Convenience class so we can just create a wxBusyCursor object on the stack |
410 | class WXDLLEXPORT wxBusyCursor | |
411 | { | |
afb74891 VZ |
412 | public: |
413 | wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR) | |
414 | { wxBeginBusyCursor(cursor); } | |
f6bcfd97 | 415 | ~wxBusyCursor() |
afb74891 | 416 | { wxEndBusyCursor(); } |
e2a6f233 | 417 | |
f6bcfd97 BP |
418 | // FIXME: These two methods are currently only implemented (and needed?) |
419 | // in wxGTK. BusyCursor handling should probably be moved to | |
420 | // common code since the wxGTK and wxMSW implementations are very | |
421 | // similar except for wxMSW using HCURSOR directly instead of | |
422 | // wxCursor.. -- RL. | |
423 | static const wxCursor &GetStoredCursor(); | |
424 | static const wxCursor GetBusyCursor(); | |
425 | }; | |
c801d85f | 426 | |
c801d85f | 427 | |
d6b9496a | 428 | // ---------------------------------------------------------------------------- |
c801d85f | 429 | // Reading and writing resources (eg WIN.INI, .Xdefaults) |
d6b9496a VZ |
430 | // ---------------------------------------------------------------------------- |
431 | ||
47d67540 | 432 | #if wxUSE_RESOURCES |
62448488 JS |
433 | WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file = wxEmptyString); |
434 | WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file = wxEmptyString); | |
435 | WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file = wxEmptyString); | |
436 | WXDLLEXPORT bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file = wxEmptyString); | |
437 | ||
9d2f3c71 | 438 | WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, wxChar **value, const wxString& file = wxEmptyString); |
62448488 JS |
439 | WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file = wxEmptyString); |
440 | WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file = wxEmptyString); | |
441 | WXDLLEXPORT bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file = wxEmptyString); | |
47d67540 | 442 | #endif // wxUSE_RESOURCES |
c801d85f | 443 | |
c801d85f KB |
444 | void WXDLLEXPORT wxGetMousePosition( int* x, int* y ); |
445 | ||
446 | // MSW only: get user-defined resource from the .res file. | |
447 | // Returns NULL or newly-allocated memory, so use delete[] to clean up. | |
2049ba38 | 448 | #ifdef __WXMSW__ |
373658eb VZ |
449 | WXDLLEXPORT extern const wxChar* wxUserResourceStr; |
450 | WXDLLEXPORT wxChar* wxLoadUserResource(const wxString& resourceName, const wxString& resourceType = wxUserResourceStr); | |
d6b9496a VZ |
451 | #endif // MSW |
452 | ||
453 | // ---------------------------------------------------------------------------- | |
454 | // Display and colorss (X only) | |
455 | // ---------------------------------------------------------------------------- | |
c801d85f | 456 | |
d111a89a VZ |
457 | #ifdef __WXGTK__ |
458 | void *wxGetDisplay(); | |
459 | #endif | |
460 | ||
c801d85f | 461 | #ifdef __X__ |
d6b9496a VZ |
462 | WXDisplay *wxGetDisplay(); |
463 | bool wxSetDisplay(const wxString& display_name); | |
464 | wxString wxGetDisplayName(); | |
d111a89a | 465 | #endif // X or GTK+ |
c801d85f KB |
466 | |
467 | #ifdef __X__ | |
468 | ||
338dd992 JJ |
469 | #ifdef __VMS__ // Xlib.h for VMS is not (yet) compatible with C++ |
470 | // The resulting warnings are switched off here | |
471 | #pragma message disable nosimpint | |
472 | #endif | |
7266b672 | 473 | // #include <X11/Xlib.h> |
338dd992 JJ |
474 | #ifdef __VMS__ |
475 | #pragma message enable nosimpint | |
476 | #endif | |
c801d85f | 477 | |
c801d85f KB |
478 | #endif //__X__ |
479 | ||
e90c1d2a VZ |
480 | #endif // wxUSE_GUI |
481 | ||
886dd7d2 VZ |
482 | // ---------------------------------------------------------------------------- |
483 | // wxYield(): these functions are obsolete, please use wxApp methods instead! | |
484 | // ---------------------------------------------------------------------------- | |
485 | ||
486 | // Yield to other apps/messages | |
bddd7a8d | 487 | WXDLLIMPEXP_BASE bool wxYield(); |
886dd7d2 VZ |
488 | |
489 | // Like wxYield, but fails silently if the yield is recursive. | |
bddd7a8d | 490 | WXDLLIMPEXP_BASE bool wxYieldIfNeeded(); |
886dd7d2 | 491 | |
f6bcfd97 BP |
492 | // ---------------------------------------------------------------------------- |
493 | // Error message functions used by wxWindows (deprecated, use wxLog) | |
494 | // ---------------------------------------------------------------------------- | |
495 | ||
73deed44 VZ |
496 | #if WXWIN_COMPATIBILITY_2_2 |
497 | ||
f6bcfd97 BP |
498 | // Format a message on the standard error (UNIX) or the debugging |
499 | // stream (Windows) | |
bddd7a8d | 500 | WXDLLIMPEXP_BASE void wxDebugMsg(const wxChar *fmt ...) ATTRIBUTE_PRINTF_1; |
f6bcfd97 BP |
501 | |
502 | // Non-fatal error (continues) | |
bddd7a8d VZ |
503 | WXDLLIMPEXP_DATA_BASE(extern const wxChar*) wxInternalErrorStr; |
504 | WXDLLIMPEXP_BASE void wxError(const wxString& msg, const wxString& title = wxInternalErrorStr); | |
f6bcfd97 BP |
505 | |
506 | // Fatal error (exits) | |
bddd7a8d VZ |
507 | WXDLLIMPEXP_DATA_BASE(extern const wxChar*) wxFatalErrorStr; |
508 | WXDLLIMPEXP_BASE void wxFatalError(const wxString& msg, const wxString& title = wxFatalErrorStr); | |
f6bcfd97 | 509 | |
73deed44 | 510 | #endif // WXWIN_COMPATIBILITY_2_2 |
f6bcfd97 | 511 | |
c801d85f | 512 | #endif |
34138703 | 513 | // _WX_UTILSH__ |