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