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