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