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