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