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