1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Miscellaneous utilities
4 // Author: Julian Smart
8 // Copyright: (c) 1998 Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 #include "wx/object.h"
21 #include "wx/filefn.h"
22 #include "wx/hashmap.h"
23 #include "wx/meta/implicitconversion.h"
26 #include "wx/gdicmn.h"
27 #include "wx/mousestate.h"
30 class WXDLLIMPEXP_FWD_BASE wxArrayString
;
31 class WXDLLIMPEXP_FWD_BASE wxArrayInt
;
33 // need this for wxGetDiskSpace() as we can't, unfortunately, forward declare
35 #include "wx/longlong.h"
37 // needed for wxOperatingSystemId, wxLinuxDistributionInfo
38 #include "wx/platinfo.h"
49 // ----------------------------------------------------------------------------
50 // Forward declaration
51 // ----------------------------------------------------------------------------
53 class WXDLLIMPEXP_FWD_BASE wxProcess
;
54 class WXDLLIMPEXP_FWD_CORE wxFrame
;
55 class WXDLLIMPEXP_FWD_CORE wxWindow
;
56 class WXDLLIMPEXP_FWD_CORE wxWindowList
;
58 // ----------------------------------------------------------------------------
59 // Arithmetic functions
60 // ----------------------------------------------------------------------------
62 template<typename T1
, typename T2
>
63 inline typename wxImplicitConversionType
<T1
,T2
>::value
66 return (a
> b
) ? a
: b
;
69 template<typename T1
, typename T2
>
70 inline typename wxImplicitConversionType
<T1
,T2
>::value
73 return (a
< b
) ? a
: b
;
76 template<typename T1
, typename T2
, typename T3
>
77 inline typename wxImplicitConversionType3
<T1
,T2
,T3
>::value
78 wxClip(T1 a
, T2 b
, T3 c
)
80 return (a
< b
) ? b
: ((a
> c
) ? c
: a
);
83 // ----------------------------------------------------------------------------
85 // ----------------------------------------------------------------------------
87 // wxGetFreeMemory can return huge amount of memory on 32-bit platforms as well
88 // so to always use long long for its result type on all platforms which
91 typedef wxLongLong wxMemorySize
;
93 typedef long wxMemorySize
;
96 // ----------------------------------------------------------------------------
97 // String functions (deprecated, use wxString)
98 // ----------------------------------------------------------------------------
100 #ifdef WXWIN_COMPATIBILITY_2_8
101 // A shorter way of using strcmp
102 wxDEPRECATED_INLINE(inline bool wxStringEq(const char *s1
, const char *s2
),
103 return wxCRT_StrcmpA(s1
, s2
) == 0; )
106 wxDEPRECATED_INLINE(inline bool wxStringEq(const wchar_t *s1
, const wchar_t *s2
),
107 return wxCRT_StrcmpW(s1
, s2
) == 0; )
108 #endif // wxUSE_UNICODE
110 #endif // WXWIN_COMPATIBILITY_2_8
112 // ----------------------------------------------------------------------------
113 // Miscellaneous functions
114 // ----------------------------------------------------------------------------
117 #if !defined __EMX__ && \
118 (defined __WXMOTIF__ || defined __WXGTK__ || defined __WXX11__)
119 WXDLLIMPEXP_CORE
void wxBell();
121 WXDLLIMPEXP_BASE
void wxBell();
125 // Show wxWidgets information
126 WXDLLIMPEXP_CORE
void wxInfoMessageBox(wxWindow
* parent
);
127 #endif // wxUSE_MSGDLG
129 // Get OS description as a user-readable string
130 WXDLLIMPEXP_BASE wxString
wxGetOsDescription();
133 WXDLLIMPEXP_BASE wxOperatingSystemId
wxGetOsVersion(int *majorVsn
= NULL
,
134 int *minorVsn
= NULL
);
136 // Get platform endianness
137 WXDLLIMPEXP_BASE
bool wxIsPlatformLittleEndian();
139 // Get platform architecture
140 WXDLLIMPEXP_BASE
bool wxIsPlatform64Bit();
143 // Get linux-distro informations
144 WXDLLIMPEXP_BASE wxLinuxDistributionInfo
wxGetLinuxDistributionInfo();
147 // Return a string with the current date/time
148 WXDLLIMPEXP_BASE wxString
wxNow();
150 // Return path where wxWidgets is installed (mostly useful in Unices)
151 WXDLLIMPEXP_BASE
const wxChar
*wxGetInstallPrefix();
152 // Return path to wxWin data (/usr/share/wx/%{version}) (Unices)
153 WXDLLIMPEXP_BASE wxString
wxGetDataDir();
157 // Get the state of a key (true if pressed, false if not)
158 // This is generally most useful getting the state of
159 // the modifier or toggle keys.
160 WXDLLIMPEXP_CORE
bool wxGetKeyState(wxKeyCode key
);
162 // Don't synthesize KeyUp events holding down a key and producing
163 // KeyDown events with autorepeat. On by default and always on
165 WXDLLIMPEXP_CORE
bool wxSetDetectableAutoRepeat( bool flag
);
167 // Returns the current state of the mouse position, buttons and modifers
168 WXDLLIMPEXP_CORE wxMouseState
wxGetMouseState();
172 // ----------------------------------------------------------------------------
174 // ----------------------------------------------------------------------------
177 * Class to make it easier to specify platform-dependent values
180 * long val = wxPlatform::If(wxMac, 1).ElseIf(wxGTK, 2).ElseIf(stPDA, 5).Else(3);
181 * wxString strVal = wxPlatform::If(wxMac, wxT("Mac")).ElseIf(wxMSW, wxT("MSW")).Else(wxT("Other"));
183 * A custom platform symbol:
187 * wxPlatform::AddPlatform(stPDA);
190 * long windowStyle = wxCAPTION | (long) wxPlatform::IfNot(stPDA, wxRESIZE_BORDER);
194 class WXDLLIMPEXP_BASE wxPlatform
197 wxPlatform() { Init(); }
198 wxPlatform(const wxPlatform
& platform
) { Copy(platform
); }
199 void operator = (const wxPlatform
& platform
) { if (&platform
!= this) Copy(platform
); }
200 void Copy(const wxPlatform
& platform
);
202 // Specify an optional default value
203 wxPlatform(int defValue
) { Init(); m_longValue
= (long)defValue
; }
204 wxPlatform(long defValue
) { Init(); m_longValue
= defValue
; }
205 wxPlatform(const wxString
& defValue
) { Init(); m_stringValue
= defValue
; }
206 wxPlatform(double defValue
) { Init(); m_doubleValue
= defValue
; }
208 static wxPlatform
If(int platform
, long value
);
209 static wxPlatform
IfNot(int platform
, long value
);
210 wxPlatform
& ElseIf(int platform
, long value
);
211 wxPlatform
& ElseIfNot(int platform
, long value
);
212 wxPlatform
& Else(long value
);
214 static wxPlatform
If(int platform
, int value
) { return If(platform
, (long)value
); }
215 static wxPlatform
IfNot(int platform
, int value
) { return IfNot(platform
, (long)value
); }
216 wxPlatform
& ElseIf(int platform
, int value
) { return ElseIf(platform
, (long) value
); }
217 wxPlatform
& ElseIfNot(int platform
, int value
) { return ElseIfNot(platform
, (long) value
); }
218 wxPlatform
& Else(int value
) { return Else((long) value
); }
220 static wxPlatform
If(int platform
, double value
);
221 static wxPlatform
IfNot(int platform
, double value
);
222 wxPlatform
& ElseIf(int platform
, double value
);
223 wxPlatform
& ElseIfNot(int platform
, double value
);
224 wxPlatform
& Else(double value
);
226 static wxPlatform
If(int platform
, const wxString
& value
);
227 static wxPlatform
IfNot(int platform
, const wxString
& value
);
228 wxPlatform
& ElseIf(int platform
, const wxString
& value
);
229 wxPlatform
& ElseIfNot(int platform
, const wxString
& value
);
230 wxPlatform
& Else(const wxString
& value
);
232 long GetInteger() const { return m_longValue
; }
233 const wxString
& GetString() const { return m_stringValue
; }
234 double GetDouble() const { return m_doubleValue
; }
236 operator int() const { return (int) GetInteger(); }
237 operator long() const { return GetInteger(); }
238 operator double() const { return GetDouble(); }
239 operator const wxString
&() const { return GetString(); }
241 static void AddPlatform(int platform
);
242 static bool Is(int platform
);
243 static void ClearPlatforms();
247 void Init() { m_longValue
= 0; m_doubleValue
= 0.0; }
250 double m_doubleValue
;
251 wxString m_stringValue
;
252 static wxArrayInt
* sm_customPlatforms
;
255 /// Function for testing current platform
256 inline bool wxPlatformIs(int platform
) { return wxPlatform::Is(platform
); }
258 // ----------------------------------------------------------------------------
259 // Window ID management
260 // ----------------------------------------------------------------------------
262 // Ensure subsequent IDs don't clash with this one
263 WXDLLIMPEXP_BASE
void wxRegisterId(long id
);
265 // Return the current ID
266 WXDLLIMPEXP_BASE
long wxGetCurrentId();
268 // Generate a unique ID
269 WXDLLIMPEXP_BASE
long wxNewId();
271 // ----------------------------------------------------------------------------
272 // Various conversions
273 // ----------------------------------------------------------------------------
275 // Convert 2-digit hex number to decimal
276 WXDLLIMPEXP_BASE
int wxHexToDec(const wxString
& buf
);
278 // Convert 2-digit hex number to decimal
279 inline int wxHexToDec(const char* buf
)
281 int firstDigit
, secondDigit
;
284 firstDigit
= buf
[0] - 'A' + 10;
286 firstDigit
= buf
[0] - '0';
289 secondDigit
= buf
[1] - 'A' + 10;
291 secondDigit
= buf
[1] - '0';
293 return (firstDigit
& 0xF) * 16 + (secondDigit
& 0xF );
297 // Convert decimal integer to 2-character hex string
298 WXDLLIMPEXP_BASE
void wxDecToHex(int dec
, wxChar
*buf
);
299 WXDLLIMPEXP_BASE
void wxDecToHex(int dec
, char* ch1
, char* ch2
);
300 WXDLLIMPEXP_BASE wxString
wxDecToHex(int dec
);
302 // ----------------------------------------------------------------------------
303 // Process management
304 // ----------------------------------------------------------------------------
306 // NB: for backwards compatibility reasons the values of wxEXEC_[A]SYNC *must*
307 // be 0 and 1, don't change!
311 // execute the process asynchronously
314 // execute it synchronously, i.e. wait until it finishes
317 // under Windows, don't hide the child even if it's IO is redirected (this
318 // is done by default)
321 // under Unix, if the process is the group leader then passing wxKILL_CHILDREN to wxKill
322 // kills all children as well as pid
323 wxEXEC_MAKE_GROUP_LEADER
= 4,
325 // by default synchronous execution disables all program windows to avoid
326 // that the user interacts with the program while the child process is
327 // running, you can use this flag to prevent this from happening
328 wxEXEC_NODISABLE
= 8,
330 // by default, the event loop is run while waiting for synchronous execution
331 // to complete and this flag can be used to simply block the main process
332 // until the child process finishes
333 wxEXEC_NOEVENTS
= 16,
335 // convenient synonym for flags given system()-like behaviour
336 wxEXEC_BLOCK
= wxEXEC_SYNC
| wxEXEC_NOEVENTS
339 // Map storing environment variables.
340 typedef wxStringToStringHashMap wxEnvVariableHashMap
;
342 // Used to pass additional parameters for child process to wxExecute(). Could
343 // be extended with other fields later.
346 wxString cwd
; // If empty, CWD is not changed.
347 wxEnvVariableHashMap env
; // If empty, environment is unchanged.
350 // Execute another program.
352 // If flags contain wxEXEC_SYNC, return -1 on failure and the exit code of the
353 // process if everything was ok. Otherwise (i.e. if wxEXEC_ASYNC), return 0 on
354 // failure and the PID of the launched process if ok.
355 WXDLLIMPEXP_BASE
long wxExecute(const wxString
& command
,
356 int flags
= wxEXEC_ASYNC
,
357 wxProcess
*process
= NULL
,
358 const wxExecuteEnv
*env
= NULL
);
359 WXDLLIMPEXP_BASE
long wxExecute(char **argv
,
360 int flags
= wxEXEC_ASYNC
,
361 wxProcess
*process
= NULL
,
362 const wxExecuteEnv
*env
= NULL
);
364 WXDLLIMPEXP_BASE
long wxExecute(wchar_t **argv
,
365 int flags
= wxEXEC_ASYNC
,
366 wxProcess
*process
= NULL
,
367 const wxExecuteEnv
*env
= NULL
);
368 #endif // wxUSE_UNICODE
370 // execute the command capturing its output into an array line by line, this is
371 // always synchronous
372 WXDLLIMPEXP_BASE
long wxExecute(const wxString
& command
,
373 wxArrayString
& output
,
375 const wxExecuteEnv
*env
= NULL
);
377 // also capture stderr (also synchronous)
378 WXDLLIMPEXP_BASE
long wxExecute(const wxString
& command
,
379 wxArrayString
& output
,
380 wxArrayString
& error
,
382 const wxExecuteEnv
*env
= NULL
);
384 #if defined(__WXMSW__) && wxUSE_IPC
385 // ask a DDE server to execute the DDE request with given parameters
386 WXDLLIMPEXP_BASE
bool wxExecuteDDE(const wxString
& ddeServer
,
387 const wxString
& ddeTopic
,
388 const wxString
& ddeCommand
);
389 #endif // __WXMSW__ && wxUSE_IPC
393 wxSIGNONE
= 0, // verify if the process exists under Unix
400 wxSIGIOT
= wxSIGABRT
, // another name
411 // further signals are different in meaning between different Unix systems
416 wxKILL_OK
, // no error
417 wxKILL_BAD_SIGNAL
, // no such signal
418 wxKILL_ACCESS_DENIED
, // permission denied
419 wxKILL_NO_PROCESS
, // no such process
420 wxKILL_ERROR
// another, unspecified error
425 wxKILL_NOCHILDREN
= 0, // don't kill children
426 wxKILL_CHILDREN
= 1 // kill children
431 wxSHUTDOWN_FORCE
= 1,// can be combined with other flags (MSW-only)
432 wxSHUTDOWN_POWEROFF
= 2,// power off the computer
433 wxSHUTDOWN_REBOOT
= 4,// shutdown and reboot
434 wxSHUTDOWN_LOGOFF
= 8 // close session (currently MSW-only)
437 // Shutdown or reboot the PC
438 WXDLLIMPEXP_BASE
bool wxShutdown(int flags
= wxSHUTDOWN_POWEROFF
);
440 // send the given signal to the process (only NONE and KILL are supported under
441 // Windows, all others mean TERM), return 0 if ok and -1 on error
443 // return detailed error in rc if not NULL
444 WXDLLIMPEXP_BASE
int wxKill(long pid
,
445 wxSignal sig
= wxSIGTERM
,
446 wxKillError
*rc
= NULL
,
447 int flags
= wxKILL_NOCHILDREN
);
449 // Execute a command in an interactive shell window (always synchronously)
450 // If no command then just the shell
451 WXDLLIMPEXP_BASE
bool wxShell(const wxString
& command
= wxEmptyString
);
453 // As wxShell(), but must give a (non interactive) command and its output will
454 // be returned in output array
455 WXDLLIMPEXP_BASE
bool wxShell(const wxString
& command
, wxArrayString
& output
);
457 // Sleep for nSecs seconds
458 WXDLLIMPEXP_BASE
void wxSleep(int nSecs
);
460 // Sleep for a given amount of milliseconds
461 WXDLLIMPEXP_BASE
void wxMilliSleep(unsigned long milliseconds
);
463 // Sleep for a given amount of microseconds
464 WXDLLIMPEXP_BASE
void wxMicroSleep(unsigned long microseconds
);
466 #if WXWIN_COMPATIBILITY_2_8
467 // Sleep for a given amount of milliseconds (old, bad name), use wxMilliSleep
468 wxDEPRECATED( WXDLLIMPEXP_BASE
void wxUsleep(unsigned long milliseconds
) );
471 // Get the process id of the current process
472 WXDLLIMPEXP_BASE
unsigned long wxGetProcessId();
474 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
475 WXDLLIMPEXP_BASE wxMemorySize
wxGetFreeMemory();
477 #if wxUSE_ON_FATAL_EXCEPTION
479 // should wxApp::OnFatalException() be called?
480 WXDLLIMPEXP_BASE
bool wxHandleFatalExceptions(bool doit
= true);
482 #endif // wxUSE_ON_FATAL_EXCEPTION
484 // ----------------------------------------------------------------------------
485 // Environment variables
486 // ----------------------------------------------------------------------------
488 // returns true if variable exists (value may be NULL if you just want to check
490 WXDLLIMPEXP_BASE
bool wxGetEnv(const wxString
& var
, wxString
*value
);
492 // set the env var name to the given value, return true on success
493 WXDLLIMPEXP_BASE
bool wxSetEnv(const wxString
& var
, const wxString
& value
);
495 // remove the env var from environment
496 WXDLLIMPEXP_BASE
bool wxUnsetEnv(const wxString
& var
);
498 #if WXWIN_COMPATIBILITY_2_8
499 inline bool wxSetEnv(const wxString
& var
, const char *value
)
500 { return wxSetEnv(var
, wxString(value
)); }
501 inline bool wxSetEnv(const wxString
& var
, const wchar_t *value
)
502 { return wxSetEnv(var
, wxString(value
)); }
504 inline bool wxSetEnv(const wxString
& var
, const wxScopedCharTypeBuffer
<T
>& value
)
505 { return wxSetEnv(var
, wxString(value
)); }
506 inline bool wxSetEnv(const wxString
& var
, const wxCStrData
& value
)
507 { return wxSetEnv(var
, wxString(value
)); }
509 // this one is for passing NULL directly - don't use it, use wxUnsetEnv instead
510 wxDEPRECATED( inline bool wxSetEnv(const wxString
& var
, int value
) );
511 inline bool wxSetEnv(const wxString
& var
, int value
)
513 wxASSERT_MSG( value
== 0, "using non-NULL integer as string?" );
515 wxUnusedVar(value
); // fix unused parameter warning in release build
517 return wxUnsetEnv(var
);
519 #endif // WXWIN_COMPATIBILITY_2_8
521 // Retrieve the complete environment by filling specified map.
522 // Returns true on success or false if an error occurred.
523 WXDLLIMPEXP_BASE
bool wxGetEnvMap(wxEnvVariableHashMap
*map
);
525 // ----------------------------------------------------------------------------
526 // Network and username functions.
527 // ----------------------------------------------------------------------------
529 // NB: "char *" functions are deprecated, use wxString ones!
532 WXDLLIMPEXP_BASE
bool wxGetEmailAddress(wxChar
*buf
, int maxSize
);
533 WXDLLIMPEXP_BASE wxString
wxGetEmailAddress();
536 WXDLLIMPEXP_BASE
bool wxGetHostName(wxChar
*buf
, int maxSize
);
537 WXDLLIMPEXP_BASE wxString
wxGetHostName();
540 WXDLLIMPEXP_BASE wxString
wxGetFullHostName();
541 WXDLLIMPEXP_BASE
bool wxGetFullHostName(wxChar
*buf
, int maxSize
);
543 // Get user ID e.g. jacs (this is known as login name under Unix)
544 WXDLLIMPEXP_BASE
bool wxGetUserId(wxChar
*buf
, int maxSize
);
545 WXDLLIMPEXP_BASE wxString
wxGetUserId();
547 // Get user name e.g. Julian Smart
548 WXDLLIMPEXP_BASE
bool wxGetUserName(wxChar
*buf
, int maxSize
);
549 WXDLLIMPEXP_BASE wxString
wxGetUserName();
551 // Get current Home dir and copy to dest (returns pstr->c_str())
552 WXDLLIMPEXP_BASE wxString
wxGetHomeDir();
553 WXDLLIMPEXP_BASE
const wxChar
* wxGetHomeDir(wxString
*pstr
);
555 // Get the user's (by default use the current user name) home dir,
556 // return empty string on error
557 WXDLLIMPEXP_BASE wxString
wxGetUserHome(const wxString
& user
= wxEmptyString
);
561 typedef wxLongLong wxDiskspaceSize_t
;
563 typedef long wxDiskspaceSize_t
;
566 // get number of total/free bytes on the disk where path belongs
567 WXDLLIMPEXP_BASE
bool wxGetDiskSpace(const wxString
& path
,
568 wxDiskspaceSize_t
*pTotal
= NULL
,
569 wxDiskspaceSize_t
*pFree
= NULL
);
575 typedef int (wxCMPFUNC_CONV
*CMPFUNCDATA
)(const void* pItem1
, const void* pItem2
, const void* user_data
);
579 WXDLLIMPEXP_BASE
void wxQsort(void *const pbase
, size_t total_elems
,
580 size_t size
, CMPFUNCDATA cmp
, const void* user_data
);
583 #if wxUSE_GUI // GUI only things from now on
585 // ----------------------------------------------------------------------------
586 // Launch default browser
587 // ----------------------------------------------------------------------------
589 // flags for wxLaunchDefaultBrowser
592 wxBROWSER_NEW_WINDOW
= 0x01,
593 wxBROWSER_NOBUSYCURSOR
= 0x02
596 // Launch url in the user's default internet browser
597 WXDLLIMPEXP_CORE
bool wxLaunchDefaultBrowser(const wxString
& url
, int flags
= 0);
599 // Launch document in the user's default application
600 WXDLLIMPEXP_CORE
bool wxLaunchDefaultApplication(const wxString
& path
, int flags
= 0);
602 // ----------------------------------------------------------------------------
603 // Menu accelerators related things
604 // ----------------------------------------------------------------------------
606 // flags for wxStripMenuCodes
609 // strip '&' characters
610 wxStrip_Mnemonics
= 1,
612 // strip everything after '\t'
615 // strip everything (this is the default)
616 wxStrip_All
= wxStrip_Mnemonics
| wxStrip_Accel
619 // strip mnemonics and/or accelerators from the label
620 WXDLLIMPEXP_CORE wxString
621 wxStripMenuCodes(const wxString
& str
, int flags
= wxStrip_All
);
623 #if WXWIN_COMPATIBILITY_2_6
624 // obsolete and deprecated version, do not use, use the above overload instead
626 WXDLLIMPEXP_CORE wxChar
* wxStripMenuCodes(const wxChar
*in
, wxChar
*out
= NULL
)
630 class WXDLLIMPEXP_FWD_CORE wxAcceleratorEntry
;
632 // use wxAcceleratorEntry::Create() or FromString() methods instead
634 WXDLLIMPEXP_CORE wxAcceleratorEntry
*wxGetAccelFromString(const wxString
& label
)
636 #endif // wxUSE_ACCEL
638 #endif // WXWIN_COMPATIBILITY_2_6
640 // ----------------------------------------------------------------------------
642 // ----------------------------------------------------------------------------
644 // Returns menu item id or wxNOT_FOUND if none.
645 WXDLLIMPEXP_CORE
int wxFindMenuItemId(wxFrame
*frame
, const wxString
& menuString
, const wxString
& itemString
);
647 // Find the wxWindow at the given point. wxGenericFindWindowAtPoint
648 // is always present but may be less reliable than a native version.
649 WXDLLIMPEXP_CORE wxWindow
* wxGenericFindWindowAtPoint(const wxPoint
& pt
);
650 WXDLLIMPEXP_CORE wxWindow
* wxFindWindowAtPoint(const wxPoint
& pt
);
652 // NB: this function is obsolete, use wxWindow::FindWindowByLabel() instead
654 // Find the window/widget with the given title or label.
655 // Pass a parent to begin the search from, or NULL to look through
657 WXDLLIMPEXP_CORE wxWindow
* wxFindWindowByLabel(const wxString
& title
, wxWindow
*parent
= NULL
);
659 // NB: this function is obsolete, use wxWindow::FindWindowByName() instead
661 // Find window by name, and if that fails, by label.
662 WXDLLIMPEXP_CORE wxWindow
* wxFindWindowByName(const wxString
& name
, wxWindow
*parent
= NULL
);
664 // ----------------------------------------------------------------------------
665 // Message/event queue helpers
666 // ----------------------------------------------------------------------------
668 // Yield to other apps/messages and disable user input
669 WXDLLIMPEXP_CORE
bool wxSafeYield(wxWindow
*win
= NULL
, bool onlyIfNeeded
= false);
671 // Enable or disable input to all top level windows
672 WXDLLIMPEXP_CORE
void wxEnableTopLevelWindows(bool enable
= true);
674 // Check whether this window wants to process messages, e.g. Stop button
675 // in long calculations.
676 WXDLLIMPEXP_CORE
bool wxCheckForInterrupt(wxWindow
*wnd
);
678 // Consume all events until no more left
679 WXDLLIMPEXP_CORE
void wxFlushEvents();
681 // a class which disables all windows (except, may be, the given one) in its
682 // ctor and enables them back in its dtor
683 class WXDLLIMPEXP_CORE wxWindowDisabler
686 // this ctor conditionally disables all windows: if the argument is false,
687 // it doesn't do anything
688 wxWindowDisabler(bool disable
= true);
690 // ctor disables all windows except winToSkip
691 wxWindowDisabler(wxWindow
*winToSkip
);
693 // dtor enables back all windows disabled by the ctor
697 // disable all windows except the given one (used by both ctors)
698 void DoDisable(wxWindow
*winToSkip
= NULL
);
701 wxWindowList
*m_winDisabled
;
704 wxDECLARE_NO_COPY_CLASS(wxWindowDisabler
);
707 // ----------------------------------------------------------------------------
709 // ----------------------------------------------------------------------------
711 // Set the cursor to the busy cursor for all windows
712 WXDLLIMPEXP_CORE
void wxBeginBusyCursor(const wxCursor
*cursor
= wxHOURGLASS_CURSOR
);
714 // Restore cursor to normal
715 WXDLLIMPEXP_CORE
void wxEndBusyCursor();
717 // true if we're between the above two calls
718 WXDLLIMPEXP_CORE
bool wxIsBusy();
720 // Convenience class so we can just create a wxBusyCursor object on the stack
721 class WXDLLIMPEXP_CORE wxBusyCursor
724 wxBusyCursor(const wxCursor
* cursor
= wxHOURGLASS_CURSOR
)
725 { wxBeginBusyCursor(cursor
); }
727 { wxEndBusyCursor(); }
729 // FIXME: These two methods are currently only implemented (and needed?)
730 // in wxGTK. BusyCursor handling should probably be moved to
731 // common code since the wxGTK and wxMSW implementations are very
732 // similar except for wxMSW using HCURSOR directly instead of
734 static const wxCursor
&GetStoredCursor();
735 static const wxCursor
GetBusyCursor();
738 void WXDLLIMPEXP_CORE
wxGetMousePosition( int* x
, int* y
);
740 // ----------------------------------------------------------------------------
741 // X11 Display access
742 // ----------------------------------------------------------------------------
744 #if defined(__X__) || defined(__WXGTK__)
747 WXDLLIMPEXP_CORE
void *wxGetDisplay();
751 WXDLLIMPEXP_CORE WXDisplay
*wxGetDisplay();
752 WXDLLIMPEXP_CORE
bool wxSetDisplay(const wxString
& display_name
);
753 WXDLLIMPEXP_CORE wxString
wxGetDisplayName();
756 // use this function instead of the functions above in implementation code
757 inline struct _XDisplay
*wxGetX11Display()
759 return (_XDisplay
*)wxGetDisplay();
762 #endif // X11 || wxGTK
766 // ----------------------------------------------------------------------------
767 // wxYield(): these functions are obsolete, please use wxApp methods instead!
768 // ----------------------------------------------------------------------------
770 // avoid redeclaring this function here if it had been already declated by
771 // wx/app.h, this results in warnings from g++ with -Wredundant-decls
772 #ifndef wx_YIELD_DECLARED
773 #define wx_YIELD_DECLARED
775 // Yield to other apps/messages
776 WXDLLIMPEXP_CORE
bool wxYield();
778 #endif // wx_YIELD_DECLARED
780 // Like wxYield, but fails silently if the yield is recursive.
781 WXDLLIMPEXP_CORE
bool wxYieldIfNeeded();
783 // ----------------------------------------------------------------------------
784 // Windows resources access
785 // ----------------------------------------------------------------------------
787 // MSW only: get user-defined resource from the .res file.
789 // default resource type for wxLoadUserResource()
790 extern WXDLLIMPEXP_DATA_BASE(const wxChar
*) wxUserResourceStr
;
792 // Return the pointer to the resource data. This pointer is read-only, use
793 // the overload below if you need to modify the data.
795 // Returns true on success, false on failure. Doesn't log an error message
796 // if the resource is not found (because this could be expected) but does
797 // log one if any other error occurs.
798 WXDLLIMPEXP_BASE
bool
799 wxLoadUserResource(const void **outData
,
801 const wxString
& resourceName
,
802 const wxString
& resourceType
= wxUserResourceStr
,
803 WXHINSTANCE
module = 0);
805 // This function allocates a new buffer and makes a copy of the resource
806 // data, remember to delete[] the buffer. And avoid using it entirely if
807 // the overload above can be used.
809 // Returns NULL on failure.
810 WXDLLIMPEXP_BASE
char*
811 wxLoadUserResource(const wxString
& resourceName
,
812 const wxString
& resourceType
= wxUserResourceStr
,
814 WXHINSTANCE
module = 0);