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