]> git.saurik.com Git - wxWidgets.git/blame - include/wx/utils.h
Update configuration for OpenVMS
[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
162e998c
PC
12#ifndef _WX_UTILS_H_
13#define _WX_UTILS_H_
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"
0e097789 22
f516d986
VZ
23#if wxUSE_GUI
24 #include "wx/gdicmn.h"
0e097789 25 #include "wx/mousestate.h"
f516d986 26#endif
2da2f941 27
b5dbe15d
VS
28class WXDLLIMPEXP_FWD_BASE wxArrayString;
29class WXDLLIMPEXP_FWD_BASE wxArrayInt;
c801d85f 30
eadd7bd2
VZ
31// need this for wxGetDiskSpace() as we can't, unfortunately, forward declare
32// wxLongLong
33#include "wx/longlong.h"
34
8bb6b2c0
VZ
35// need for wxOperatingSystemId
36#include "wx/platinfo.h"
37
55034339
WS
38#ifdef __WATCOMC__
39 #include <direct.h>
40#elif defined(__X__)
d6b9496a
VZ
41 #include <dirent.h>
42 #include <unistd.h>
c801d85f
KB
43#endif
44
45#include <stdio.h>
46
d6b9496a
VZ
47// ----------------------------------------------------------------------------
48// Forward declaration
49// ----------------------------------------------------------------------------
50
4f7d425f 51class WXDLLIMPEXP_FWD_BASE wxProcess;
b5dbe15d
VS
52class WXDLLIMPEXP_FWD_CORE wxFrame;
53class WXDLLIMPEXP_FWD_CORE wxWindow;
54class WXDLLIMPEXP_FWD_CORE wxWindowList;
d6b9496a 55
d6b9496a
VZ
56// ----------------------------------------------------------------------------
57// Macros
58// ----------------------------------------------------------------------------
c801d85f 59
d6b9496a
VZ
60#define wxMax(a,b) (((a) > (b)) ? (a) : (b))
61#define wxMin(a,b) (((a) < (b)) ? (a) : (b))
e8ee8f27 62#define wxClip(a,b,c) (((a) < (b)) ? (b) : (((a) > (c)) ? (c) : (a)))
c801d85f 63
9ad34f61
VZ
64// wxGetFreeMemory can return huge amount of memory on 32-bit platforms as well
65// so to always use long long for its result type on all platforms which
66// support it
67#if wxUSE_LONGLONG
68 typedef wxLongLong wxMemorySize;
9d8aca48 69#else
9ad34f61 70 typedef long wxMemorySize;
9d8aca48
WS
71#endif
72
d6b9496a
VZ
73// ----------------------------------------------------------------------------
74// String functions (deprecated, use wxString)
75// ----------------------------------------------------------------------------
76
d6b9496a 77// A shorter way of using strcmp
9d2f3c71 78#define wxStringEq(s1, s2) (s1 && s2 && (wxStrcmp(s1, s2) == 0))
d6b9496a
VZ
79
80// ----------------------------------------------------------------------------
81// Miscellaneous functions
82// ----------------------------------------------------------------------------
83
84// Sound the bell
968eb2ef
MW
85#if !defined __EMX__ && \
86 (defined __WXMOTIF__ || defined __WXGTK__ || defined __WXX11__)
87WXDLLIMPEXP_CORE void wxBell();
88#else
bddd7a8d 89WXDLLIMPEXP_BASE void wxBell();
968eb2ef 90#endif
d6b9496a 91
8cf304f8
VZ
92#if wxUSE_MSGDLG
93// Show wxWidgets information
94WXDLLIMPEXP_CORE void wxInfoMessageBox(wxWindow* parent);
95#endif // wxUSE_MSGDLG
96
bdc72a22 97// Get OS description as a user-readable string
bddd7a8d 98WXDLLIMPEXP_BASE wxString wxGetOsDescription();
bdc72a22 99
d6b9496a 100// Get OS version
8bb6b2c0
VZ
101WXDLLIMPEXP_BASE wxOperatingSystemId wxGetOsVersion(int *majorVsn = (int *) NULL,
102 int *minorVsn = (int *) NULL);
103
104// Get platform endianness
105WXDLLIMPEXP_BASE bool wxIsPlatformLittleEndian();
106
107// Get platform architecture
108WXDLLIMPEXP_BASE bool wxIsPlatform64Bit();
d6b9496a
VZ
109
110// Return a string with the current date/time
bddd7a8d 111WXDLLIMPEXP_BASE wxString wxNow();
d6b9496a 112
77ffb593 113// Return path where wxWidgets is installed (mostly useful in Unices)
bddd7a8d 114WXDLLIMPEXP_BASE const wxChar *wxGetInstallPrefix();
2c18f21d 115// Return path to wxWin data (/usr/share/wx/%{version}) (Unices)
bddd7a8d 116WXDLLIMPEXP_BASE wxString wxGetDataDir();
134677bd 117
230c9077
JS
118/*
119 * Class to make it easier to specify platform-dependent values
120 *
121 * Examples:
4bfec179
JS
122 * long val = wxPlatform::If(wxMac, 1).ElseIf(wxGTK, 2).ElseIf(stPDA, 5).Else(3);
123 * wxString strVal = wxPlatform::If(wxMac, wxT("Mac")).ElseIf(wxMSW, wxT("MSW")).Else(wxT("Other"));
230c9077
JS
124 *
125 * A custom platform symbol:
126 *
127 * #define stPDA 100
128 * #ifdef __WXWINCE__
129 * wxPlatform::AddPlatform(stPDA);
130 * #endif
131 *
4bfec179 132 * long windowStyle = wxCAPTION | (long) wxPlatform::IfNot(stPDA, wxRESIZE_BORDER);
230c9077
JS
133 *
134 */
135
136class WXDLLIMPEXP_BASE wxPlatform
137{
138public:
4bfec179
JS
139 wxPlatform() { Init(); }
140 wxPlatform(const wxPlatform& platform) { Copy(platform); }
162e998c 141 void operator = (const wxPlatform& platform) { if (&platform != this) Copy(platform); }
4bfec179 142 void Copy(const wxPlatform& platform);
230c9077
JS
143
144 // Specify an optional default value
25a9f291
WS
145 wxPlatform(int defValue) { Init(); m_longValue = (long)defValue; }
146 wxPlatform(long defValue) { Init(); m_longValue = defValue; }
147 wxPlatform(const wxString& defValue) { Init(); m_stringValue = defValue; }
148 wxPlatform(double defValue) { Init(); m_doubleValue = defValue; }
230c9077 149
4bfec179
JS
150 static wxPlatform If(int platform, long value);
151 static wxPlatform IfNot(int platform, long value);
152 wxPlatform& ElseIf(int platform, long value);
153 wxPlatform& ElseIfNot(int platform, long value);
154 wxPlatform& Else(long value);
155
25a9f291 156 static wxPlatform If(int platform, int value) { return If(platform, (long)value); }
4bfec179
JS
157 static wxPlatform IfNot(int platform, int value) { return IfNot(platform, (long)value); }
158 wxPlatform& ElseIf(int platform, int value) { return ElseIf(platform, (long) value); }
159 wxPlatform& ElseIfNot(int platform, int value) { return ElseIfNot(platform, (long) value); }
160 wxPlatform& Else(int value) { return Else((long) value); }
161
162 static wxPlatform If(int platform, double value);
163 static wxPlatform IfNot(int platform, double value);
164 wxPlatform& ElseIf(int platform, double value);
165 wxPlatform& ElseIfNot(int platform, double value);
166 wxPlatform& Else(double value);
167
168 static wxPlatform If(int platform, const wxString& value);
169 static wxPlatform IfNot(int platform, const wxString& value);
170 wxPlatform& ElseIf(int platform, const wxString& value);
171 wxPlatform& ElseIfNot(int platform, const wxString& value);
172 wxPlatform& Else(const wxString& value);
230c9077
JS
173
174 long GetInteger() const { return m_longValue; }
175 const wxString& GetString() const { return m_stringValue; }
176 double GetDouble() const { return m_doubleValue; }
177
178 operator int() const { return (int) GetInteger(); }
179 operator long() const { return GetInteger(); }
180 operator double() const { return GetDouble(); }
f8087c0d 181 operator const wxString&() const { return GetString(); }
230c9077
JS
182
183 static void AddPlatform(int platform);
4bfec179 184 static bool Is(int platform);
230c9077
JS
185 static void ClearPlatforms();
186
187private:
25a9f291
WS
188
189 void Init() { m_longValue = 0; m_doubleValue = 0.0; }
190
230c9077
JS
191 long m_longValue;
192 double m_doubleValue;
193 wxString m_stringValue;
194 static wxArrayInt* sm_customPlatforms;
195};
196
197/// Function for testing current platform
4bfec179 198inline bool wxPlatformIs(int platform) { return wxPlatform::Is(platform); }
134677bd 199
e90c1d2a 200#if wxUSE_GUI
97698dc4
RD
201
202// Get the state of a key (true if pressed, false if not)
203// This is generally most useful getting the state of
204// the modifier or toggle keys.
53a2db12 205WXDLLIMPEXP_CORE bool wxGetKeyState(wxKeyCode key);
97698dc4 206
14dfb3d2 207
63cc5d9d
RR
208// Don't synthesize KeyUp events holding down a key and producing
209// KeyDown events with autorepeat. On by default and always on
210// in wxMSW.
53a2db12 211WXDLLIMPEXP_CORE bool wxSetDetectableAutoRepeat( bool flag );
f0492f7d 212
7dd40b6f 213// Returns the current state of the mouse position, buttons and modifers
53a2db12 214WXDLLIMPEXP_CORE wxMouseState wxGetMouseState();
7dd40b6f 215
c2ca375c 216#endif // wxUSE_GUI
7dd40b6f 217
d6b9496a
VZ
218// ----------------------------------------------------------------------------
219// Window ID management
220// ----------------------------------------------------------------------------
221
c801d85f 222// Ensure subsequent IDs don't clash with this one
c2ca375c 223WXDLLIMPEXP_BASE void wxRegisterId(long id);
c801d85f
KB
224
225// Return the current ID
c2ca375c 226WXDLLIMPEXP_BASE long wxGetCurrentId();
c801d85f 227
c2ca375c
VZ
228// Generate a unique ID
229WXDLLIMPEXP_BASE long wxNewId();
e90c1d2a 230
d6b9496a
VZ
231// ----------------------------------------------------------------------------
232// Various conversions
233// ----------------------------------------------------------------------------
c801d85f 234
c801d85f 235// Convert 2-digit hex number to decimal
bddd7a8d 236WXDLLIMPEXP_BASE int wxHexToDec(const wxString& buf);
c801d85f
KB
237
238// Convert decimal integer to 2-character hex string
bddd7a8d 239WXDLLIMPEXP_BASE void wxDecToHex(int dec, wxChar *buf);
f728025e 240WXDLLIMPEXP_BASE void wxDecToHex(int dec, char* ch1, char* ch2);
bddd7a8d 241WXDLLIMPEXP_BASE wxString wxDecToHex(int dec);
c801d85f 242
d6b9496a
VZ
243// ----------------------------------------------------------------------------
244// Process management
245// ----------------------------------------------------------------------------
246
e0f6b731 247// NB: for backwards compatibility reasons the values of wxEXEC_[A]SYNC *must*
fbf456aa
VZ
248// be 0 and 1, don't change!
249
250enum
251{
e1082c9f
VZ
252 // execute the process asynchronously
253 wxEXEC_ASYNC = 0,
254
255 // execute it synchronously, i.e. wait until it finishes
256 wxEXEC_SYNC = 1,
257
258 // under Windows, don't hide the child even if it's IO is redirected (this
259 // is done by default)
260 wxEXEC_NOHIDE = 2,
261
e0f6b731
JS
262 // under Unix, if the process is the group leader then passing wxKILL_CHILDREN to wxKill
263 // kills all children as well as pid
f38f6899
VZ
264 wxEXEC_MAKE_GROUP_LEADER = 4,
265
266 // by default synchronous execution disables all program windows to avoid
267 // that the user interacts with the program while the child process is
268 // running, you can use this flag to prevent this from happening
bc855d09
VZ
269 wxEXEC_NODISABLE = 8,
270
271 // by default, the event loop is run while waiting for synchronous execution
272 // to complete and this flag can be used to simply block the main process
273 // until the child process finishes
274 wxEXEC_NOEVENTS = 16,
275
276 // convenient synonym for flags given system()-like behaviour
277 wxEXEC_BLOCK = wxEXEC_SYNC | wxEXEC_NOEVENTS
fbf456aa
VZ
278};
279
280// Execute another program.
281//
282// If flags contain wxEXEC_SYNC, return -1 on failure and the exit code of the
283// process if everything was ok. Otherwise (i.e. if wxEXEC_ASYNC), return 0 on
284// failure and the PID of the launched process if ok.
d7ef641d 285WXDLLIMPEXP_BASE long wxExecute(const wxString& command,
05718a98
VZ
286 int flags = wxEXEC_ASYNC,
287 wxProcess *process = NULL);
288WXDLLIMPEXP_BASE long wxExecute(char **argv,
289 int flags = wxEXEC_ASYNC,
290 wxProcess *process = NULL);
d7ef641d
VZ
291#if wxUSE_UNICODE
292WXDLLIMPEXP_BASE long wxExecute(wchar_t **argv,
05718a98
VZ
293 int flags = wxEXEC_ASYNC,
294 wxProcess *process = NULL);
d7ef641d 295#endif // wxUSE_UNICODE
c801d85f 296
fbf456aa
VZ
297// execute the command capturing its output into an array line by line, this is
298// always synchronous
bddd7a8d 299WXDLLIMPEXP_BASE long wxExecute(const wxString& command,
4d172154
VZ
300 wxArrayString& output,
301 int flags = 0);
f6bcfd97 302
fbf456aa 303// also capture stderr (also synchronous)
bddd7a8d 304WXDLLIMPEXP_BASE long wxExecute(const wxString& command,
4d172154
VZ
305 wxArrayString& output,
306 wxArrayString& error,
307 int flags = 0);
cd6ce4a9 308
5ccb95f6 309#if defined(__WXMSW__) && wxUSE_IPC
42d0df00
VZ
310// ask a DDE server to execute the DDE request with given parameters
311WXDLLIMPEXP_BASE bool wxExecuteDDE(const wxString& ddeServer,
312 const wxString& ddeTopic,
313 const wxString& ddeCommand);
5ccb95f6 314#endif // __WXMSW__ && wxUSE_IPC
42d0df00 315
d6b9496a
VZ
316enum wxSignal
317{
318 wxSIGNONE = 0, // verify if the process exists under Unix
319 wxSIGHUP,
320 wxSIGINT,
321 wxSIGQUIT,
322 wxSIGILL,
323 wxSIGTRAP,
324 wxSIGABRT,
325 wxSIGIOT = wxSIGABRT, // another name
326 wxSIGEMT,
327 wxSIGFPE,
328 wxSIGKILL,
329 wxSIGBUS,
330 wxSIGSEGV,
331 wxSIGSYS,
332 wxSIGPIPE,
333 wxSIGALRM,
334 wxSIGTERM
335
336 // further signals are different in meaning between different Unix systems
337};
c801d85f 338
50567b69
VZ
339enum wxKillError
340{
341 wxKILL_OK, // no error
342 wxKILL_BAD_SIGNAL, // no such signal
343 wxKILL_ACCESS_DENIED, // permission denied
344 wxKILL_NO_PROCESS, // no such process
345 wxKILL_ERROR // another, unspecified error
346};
347
e0f6b731
JS
348enum wxKillFlags
349{
350 wxKILL_NOCHILDREN = 0, // don't kill children
351 wxKILL_CHILDREN = 1 // kill children
352};
353
f6ba47d9
VZ
354enum wxShutdownFlags
355{
118a41d9
VZ
356 wxSHUTDOWN_FORCE = 1,// can be combined with other flags (MSW-only)
357 wxSHUTDOWN_POWEROFF = 2,// power off the computer
358 wxSHUTDOWN_REBOOT = 4,// shutdown and reboot
359 wxSHUTDOWN_LOGOFF = 8 // close session (currently MSW-only)
f6ba47d9
VZ
360};
361
c1cb4153 362// Shutdown or reboot the PC
118a41d9 363WXDLLIMPEXP_BASE bool wxShutdown(int flags = wxSHUTDOWN_POWEROFF);
f6ba47d9 364
50567b69
VZ
365// send the given signal to the process (only NONE and KILL are supported under
366// Windows, all others mean TERM), return 0 if ok and -1 on error
367//
368// return detailed error in rc if not NULL
bddd7a8d 369WXDLLIMPEXP_BASE int wxKill(long pid,
50567b69 370 wxSignal sig = wxSIGTERM,
e0f6b731
JS
371 wxKillError *rc = NULL,
372 int flags = wxKILL_NOCHILDREN);
c801d85f 373
2c8e4738 374// Execute a command in an interactive shell window (always synchronously)
c801d85f 375// If no command then just the shell
bddd7a8d 376WXDLLIMPEXP_BASE bool wxShell(const wxString& command = wxEmptyString);
c801d85f 377
2c8e4738
VZ
378// As wxShell(), but must give a (non interactive) command and its output will
379// be returned in output array
bddd7a8d 380WXDLLIMPEXP_BASE bool wxShell(const wxString& command, wxArrayString& output);
2c8e4738 381
b568d04f 382// Sleep for nSecs seconds
bddd7a8d 383WXDLLIMPEXP_BASE void wxSleep(int nSecs);
c801d85f 384
afb74891 385// Sleep for a given amount of milliseconds
08873d36
VZ
386WXDLLIMPEXP_BASE void wxMilliSleep(unsigned long milliseconds);
387
388// Sleep for a given amount of microseconds
389WXDLLIMPEXP_BASE void wxMicroSleep(unsigned long microseconds);
390
391// Sleep for a given amount of milliseconds (old, bad name), use wxMilliSleep
392wxDEPRECATED( WXDLLIMPEXP_BASE void wxUsleep(unsigned long milliseconds) );
afb74891 393
c1cb4153 394// Get the process id of the current process
bddd7a8d 395WXDLLIMPEXP_BASE unsigned long wxGetProcessId();
c1cb4153 396
c801d85f 397// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
9d8aca48 398WXDLLIMPEXP_BASE wxMemorySize wxGetFreeMemory();
c801d85f 399
a76d8a29
VZ
400#if wxUSE_ON_FATAL_EXCEPTION
401
a37a5a73 402// should wxApp::OnFatalException() be called?
cb719f2e 403WXDLLIMPEXP_BASE bool wxHandleFatalExceptions(bool doit = true);
a37a5a73 404
a76d8a29
VZ
405#endif // wxUSE_ON_FATAL_EXCEPTION
406
8fd0d89b
VZ
407// ----------------------------------------------------------------------------
408// Environment variables
409// ----------------------------------------------------------------------------
410
cb719f2e 411// returns true if variable exists (value may be NULL if you just want to check
308978f6 412// for this)
bddd7a8d 413WXDLLIMPEXP_BASE bool wxGetEnv(const wxString& var, wxString *value);
8fd0d89b 414
cb719f2e 415// set the env var name to the given value, return true on success
90a77e64 416WXDLLIMPEXP_BASE bool wxSetEnv(const wxString& var, const wxString& value);
8fd0d89b
VZ
417
418// remove the env var from environment
90a77e64
VS
419WXDLLIMPEXP_BASE bool wxUnsetEnv(const wxString& var);
420
421#if WXWIN_COMPATIBILITY_2_8
422inline bool wxSetEnv(const wxString& var, const char *value)
423 { return wxSetEnv(var, wxString(value)); }
424inline bool wxSetEnv(const wxString& var, const wchar_t *value)
425 { return wxSetEnv(var, wxString(value)); }
426template<typename T>
427inline bool wxSetEnv(const wxString& var, const wxCharTypeBuffer<T>& value)
428 { return wxSetEnv(var, wxString(value)); }
429inline bool wxSetEnv(const wxString& var, const wxCStrData& value)
430 { return wxSetEnv(var, wxString(value)); }
431
432// this one is for passing NULL directly - don't use it, use wxUnsetEnv instead
433wxDEPRECATED( inline bool wxSetEnv(const wxString& var, int value) );
434inline bool wxSetEnv(const wxString& var, int value)
435{
436 wxASSERT_MSG( value == 0, "using non-NULL integer as string?" );
a43bd048
VZ
437
438 wxUnusedVar(value); // fix unused parameter warning in release build
439
90a77e64
VS
440 return wxUnsetEnv(var);
441}
442#endif // WXWIN_COMPATIBILITY_2_8
8fd0d89b 443
d6b9496a
VZ
444// ----------------------------------------------------------------------------
445// Network and username functions.
446// ----------------------------------------------------------------------------
c801d85f 447
d6b9496a 448// NB: "char *" functions are deprecated, use wxString ones!
c801d85f
KB
449
450// Get eMail address
bddd7a8d
VZ
451WXDLLIMPEXP_BASE bool wxGetEmailAddress(wxChar *buf, int maxSize);
452WXDLLIMPEXP_BASE wxString wxGetEmailAddress();
c801d85f
KB
453
454// Get hostname.
bddd7a8d
VZ
455WXDLLIMPEXP_BASE bool wxGetHostName(wxChar *buf, int maxSize);
456WXDLLIMPEXP_BASE wxString wxGetHostName();
d6b9496a
VZ
457
458// Get FQDN
bddd7a8d
VZ
459WXDLLIMPEXP_BASE wxString wxGetFullHostName();
460WXDLLIMPEXP_BASE bool wxGetFullHostName(wxChar *buf, int maxSize);
c801d85f 461
d6b9496a 462// Get user ID e.g. jacs (this is known as login name under Unix)
bddd7a8d
VZ
463WXDLLIMPEXP_BASE bool wxGetUserId(wxChar *buf, int maxSize);
464WXDLLIMPEXP_BASE wxString wxGetUserId();
c801d85f
KB
465
466// Get user name e.g. Julian Smart
bddd7a8d
VZ
467WXDLLIMPEXP_BASE bool wxGetUserName(wxChar *buf, int maxSize);
468WXDLLIMPEXP_BASE wxString wxGetUserName();
d6b9496a
VZ
469
470// Get current Home dir and copy to dest (returns pstr->c_str())
bddd7a8d
VZ
471WXDLLIMPEXP_BASE wxString wxGetHomeDir();
472WXDLLIMPEXP_BASE const wxChar* wxGetHomeDir(wxString *pstr);
d6b9496a 473
14d63513
VZ
474// Get the user's (by default use the current user name) home dir,
475// return empty string on error
476WXDLLIMPEXP_BASE wxString wxGetUserHome(const wxString& user = wxEmptyString);
477
d6b9496a 478
7ba7c4e6
VZ
479#if wxUSE_LONGLONG
480 typedef wxLongLong wxDiskspaceSize_t;
481#else
482 typedef long wxDiskspaceSize_t;
483#endif
484
eadd7bd2 485// get number of total/free bytes on the disk where path belongs
bddd7a8d 486WXDLLIMPEXP_BASE bool wxGetDiskSpace(const wxString& path,
7ba7c4e6
VZ
487 wxDiskspaceSize_t *pTotal = NULL,
488 wxDiskspaceSize_t *pFree = NULL);
eadd7bd2 489
fe5f448f
RR
490
491
492extern "C"
493{
494typedef int (wxCMPFUNC_CONV *CMPFUNCDATA)(const void* pItem1, const void* pItem2, const void* user_data);
495}
496
497
498WXDLLIMPEXP_BASE void wxQsort(void *const pbase, size_t total_elems,
14d63513 499 size_t size, CMPFUNCDATA cmp, const void* user_data);
fe5f448f
RR
500
501
e90c1d2a
VZ
502#if wxUSE_GUI // GUI only things from now on
503
d6b9496a 504// ----------------------------------------------------------------------------
c5f0d1f9
DE
505// Launch default browser
506// ----------------------------------------------------------------------------
507
508// flags for wxLaunchDefaultBrowser
509enum
510{
f75e0c15
VZ
511 wxBROWSER_NEW_WINDOW = 0x01,
512 wxBROWSER_NOBUSYCURSOR = 0x02
c5f0d1f9
DE
513};
514
515// Launch url in the user's default internet browser
516WXDLLIMPEXP_CORE bool wxLaunchDefaultBrowser(const wxString& url, int flags = 0);
517
1dea1566
RR
518// Launch document in the user's default application
519WXDLLIMPEXP_CORE bool wxLaunchDefaultApplication(const wxString& path, int flags = 0);
520
c5f0d1f9 521// ----------------------------------------------------------------------------
974e8d94 522// Menu accelerators related things
d6b9496a 523// ----------------------------------------------------------------------------
c801d85f 524
74639764
VZ
525// flags for wxStripMenuCodes
526enum
527{
528 // strip '&' characters
529 wxStrip_Mnemonics = 1,
530
531 // strip everything after '\t'
532 wxStrip_Accel = 2,
533
534 // strip everything (this is the default)
535 wxStrip_All = wxStrip_Mnemonics | wxStrip_Accel
536};
537
538// strip mnemonics and/or accelerators from the label
53a2db12 539WXDLLIMPEXP_CORE wxString
74639764
VZ
540wxStripMenuCodes(const wxString& str, int flags = wxStrip_All);
541
74639764 542#if WXWIN_COMPATIBILITY_2_6
90527a50 543// obsolete and deprecated version, do not use, use the above overload instead
74639764 544wxDEPRECATED(
53a2db12 545 WXDLLIMPEXP_CORE wxChar* wxStripMenuCodes(const wxChar *in, wxChar *out = NULL)
74639764 546);
c801d85f 547
974e8d94 548#if wxUSE_ACCEL
b5dbe15d 549class WXDLLIMPEXP_FWD_CORE wxAcceleratorEntry;
90527a50
VZ
550
551// use wxAcceleratorEntry::Create() or FromString() methods instead
ee0a94cf 552wxDEPRECATED(
53a2db12 553 WXDLLIMPEXP_CORE wxAcceleratorEntry *wxGetAccelFromString(const wxString& label)
ee0a94cf 554);
974e8d94
VZ
555#endif // wxUSE_ACCEL
556
90527a50
VZ
557#endif // WXWIN_COMPATIBILITY_2_6
558
d6b9496a
VZ
559// ----------------------------------------------------------------------------
560// Window search
561// ----------------------------------------------------------------------------
562
cb719f2e 563// Returns menu item id or wxNOT_FOUND if none.
53a2db12 564WXDLLIMPEXP_CORE int wxFindMenuItemId(wxFrame *frame, const wxString& menuString, const wxString& itemString);
c801d85f 565
57591e0e
JS
566// Find the wxWindow at the given point. wxGenericFindWindowAtPoint
567// is always present but may be less reliable than a native version.
53a2db12
FM
568WXDLLIMPEXP_CORE wxWindow* wxGenericFindWindowAtPoint(const wxPoint& pt);
569WXDLLIMPEXP_CORE wxWindow* wxFindWindowAtPoint(const wxPoint& pt);
59a12e90 570
146ba0fe
VZ
571// NB: this function is obsolete, use wxWindow::FindWindowByLabel() instead
572//
573// Find the window/widget with the given title or label.
574// Pass a parent to begin the search from, or NULL to look through
575// all windows.
53a2db12 576WXDLLIMPEXP_CORE wxWindow* wxFindWindowByLabel(const wxString& title, wxWindow *parent = (wxWindow *) NULL);
146ba0fe
VZ
577
578// NB: this function is obsolete, use wxWindow::FindWindowByName() instead
579//
580// Find window by name, and if that fails, by label.
53a2db12 581WXDLLIMPEXP_CORE wxWindow* wxFindWindowByName(const wxString& name, wxWindow *parent = (wxWindow *) NULL);
146ba0fe 582
d6b9496a
VZ
583// ----------------------------------------------------------------------------
584// Message/event queue helpers
585// ----------------------------------------------------------------------------
c801d85f 586
ead7ce10 587// Yield to other apps/messages and disable user input
53a2db12 588WXDLLIMPEXP_CORE bool wxSafeYield(wxWindow *win = NULL, bool onlyIfNeeded = false);
ead7ce10 589
95dee651 590// Enable or disable input to all top level windows
53a2db12 591WXDLLIMPEXP_CORE void wxEnableTopLevelWindows(bool enable = true);
95dee651 592
d6b9496a
VZ
593// Check whether this window wants to process messages, e.g. Stop button
594// in long calculations.
53a2db12 595WXDLLIMPEXP_CORE bool wxCheckForInterrupt(wxWindow *wnd);
d6b9496a
VZ
596
597// Consume all events until no more left
53a2db12 598WXDLLIMPEXP_CORE void wxFlushEvents();
d6b9496a 599
2ecd1756 600// a class which disables all windows (except, may be, the given one) in its
cd6ce4a9 601// ctor and enables them back in its dtor
53a2db12 602class WXDLLIMPEXP_CORE wxWindowDisabler
cd6ce4a9
VZ
603{
604public:
2ecd1756
VZ
605 // this ctor conditionally disables all windows: if the argument is false,
606 // it doesn't do anything
607 wxWindowDisabler(bool disable = true);
608
609 // ctor disables all windows except winToSkip
610 wxWindowDisabler(wxWindow *winToSkip);
611
612 // dtor enables back all windows disabled by the ctor
cd6ce4a9
VZ
613 ~wxWindowDisabler();
614
615private:
2ecd1756
VZ
616 // disable all windows except the given one (used by both ctors)
617 void DoDisable(wxWindow *winToSkip = NULL);
618
619
cd6ce4a9 620 wxWindowList *m_winDisabled;
2ecd1756 621 bool m_disabled;
c1cb4153
VZ
622
623 DECLARE_NO_COPY_CLASS(wxWindowDisabler)
cd6ce4a9
VZ
624};
625
d6b9496a
VZ
626// ----------------------------------------------------------------------------
627// Cursors
628// ----------------------------------------------------------------------------
c801d85f
KB
629
630// Set the cursor to the busy cursor for all windows
f516d986 631WXDLLIMPEXP_CORE void wxBeginBusyCursor(const wxCursor *cursor = wxHOURGLASS_CURSOR);
e2a6f233 632
c801d85f 633// Restore cursor to normal
53a2db12 634WXDLLIMPEXP_CORE void wxEndBusyCursor();
d6b9496a 635
cb719f2e 636// true if we're between the above two calls
53a2db12 637WXDLLIMPEXP_CORE bool wxIsBusy();
c801d85f 638
e2a6f233 639// Convenience class so we can just create a wxBusyCursor object on the stack
53a2db12 640class WXDLLIMPEXP_CORE wxBusyCursor
e2a6f233 641{
afb74891 642public:
f516d986 643 wxBusyCursor(const wxCursor* cursor = wxHOURGLASS_CURSOR)
afb74891 644 { wxBeginBusyCursor(cursor); }
f6bcfd97 645 ~wxBusyCursor()
afb74891 646 { wxEndBusyCursor(); }
e2a6f233 647
f6bcfd97
BP
648 // FIXME: These two methods are currently only implemented (and needed?)
649 // in wxGTK. BusyCursor handling should probably be moved to
650 // common code since the wxGTK and wxMSW implementations are very
651 // similar except for wxMSW using HCURSOR directly instead of
652 // wxCursor.. -- RL.
653 static const wxCursor &GetStoredCursor();
654 static const wxCursor GetBusyCursor();
655};
c801d85f 656
53a2db12 657void WXDLLIMPEXP_CORE wxGetMousePosition( int* x, int* y );
c801d85f
KB
658
659// MSW only: get user-defined resource from the .res file.
660// Returns NULL or newly-allocated memory, so use delete[] to clean up.
2049ba38 661#ifdef __WXMSW__
53a2db12
FM
662 extern WXDLLIMPEXP_CORE const wxChar* wxUserResourceStr;
663 WXDLLIMPEXP_CORE wxChar* wxLoadUserResource(const wxString& resourceName, const wxString& resourceType = wxUserResourceStr);
d6b9496a
VZ
664#endif // MSW
665
666// ----------------------------------------------------------------------------
dc281933 667// X11 Display access
d6b9496a 668// ----------------------------------------------------------------------------
c801d85f 669
dc281933
VZ
670#if defined(__X__) || defined(__WXGTK__)
671
d111a89a 672#ifdef __WXGTK__
033bf67c 673 WXDLLIMPEXP_CORE void *wxGetDisplay();
d111a89a
VZ
674#endif
675
c801d85f 676#ifdef __X__
968eb2ef
MW
677 WXDLLIMPEXP_CORE WXDisplay *wxGetDisplay();
678 WXDLLIMPEXP_CORE bool wxSetDisplay(const wxString& display_name);
679 WXDLLIMPEXP_CORE wxString wxGetDisplayName();
d111a89a 680#endif // X or GTK+
c801d85f 681
e4e83f38
VZ
682// use this function instead of the functions above in implementation code
683inline struct _XDisplay *wxGetX11Display()
684{
685 return (_XDisplay *)wxGetDisplay();
686}
c801d85f 687
dc281933
VZ
688#endif // X11 || wxGTK
689
e90c1d2a
VZ
690#endif // wxUSE_GUI
691
886dd7d2
VZ
692// ----------------------------------------------------------------------------
693// wxYield(): these functions are obsolete, please use wxApp methods instead!
694// ----------------------------------------------------------------------------
695
a131b460
VZ
696// avoid redeclaring this function here if it had been already declated by
697// wx/app.h, this results in warnings from g++ with -Wredundant-decls
698#ifndef wx_YIELD_DECLARED
699#define wx_YIELD_DECLARED
700
886dd7d2 701// Yield to other apps/messages
bddd7a8d 702WXDLLIMPEXP_BASE bool wxYield();
886dd7d2 703
a131b460
VZ
704#endif // wx_YIELD_DECLARED
705
886dd7d2 706// Like wxYield, but fails silently if the yield is recursive.
bddd7a8d 707WXDLLIMPEXP_BASE bool wxYieldIfNeeded();
886dd7d2 708
f6bcfd97 709// ----------------------------------------------------------------------------
77ffb593 710// Error message functions used by wxWidgets (deprecated, use wxLog)
f6bcfd97
BP
711// ----------------------------------------------------------------------------
712
c801d85f 713#endif
34138703 714 // _WX_UTILSH__