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