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