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