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"
25 #include "wx/gdicmn.h"
26 #include "wx/mousestate.h"
29 class WXDLLIMPEXP_FWD_BASE wxArrayString
;
30 class WXDLLIMPEXP_FWD_BASE wxArrayInt
;
32 // need this for wxGetDiskSpace() as we can't, unfortunately, forward declare
34 #include "wx/longlong.h"
36 // needed for wxOperatingSystemId, wxLinuxDistributionInfo
37 #include "wx/platinfo.h"
48 // ----------------------------------------------------------------------------
49 // Forward declaration
50 // ----------------------------------------------------------------------------
52 class WXDLLIMPEXP_FWD_BASE wxProcess
;
53 class WXDLLIMPEXP_FWD_CORE wxFrame
;
54 class WXDLLIMPEXP_FWD_CORE wxWindow
;
55 class WXDLLIMPEXP_FWD_CORE wxWindowList
;
57 // ----------------------------------------------------------------------------
59 // ----------------------------------------------------------------------------
61 #define wxMax(a,b) (((a) > (b)) ? (a) : (b))
62 #define wxMin(a,b) (((a) < (b)) ? (a) : (b))
63 #define wxClip(a,b,c) (((a) < (b)) ? (b) : (((a) > (c)) ? (c) : (a)))
65 // wxGetFreeMemory can return huge amount of memory on 32-bit platforms as well
66 // so to always use long long for its result type on all platforms which
69 typedef wxLongLong wxMemorySize
;
71 typedef long wxMemorySize
;
74 // ----------------------------------------------------------------------------
75 // String functions (deprecated, use wxString)
76 // ----------------------------------------------------------------------------
78 #ifdef WXWIN_COMPATIBILITY_2_8
79 // A shorter way of using strcmp
80 wxDEPRECATED_INLINE(inline bool wxStringEq(const char *s1
, const char *s2
),
81 return wxCRT_StrcmpA(s1
, s2
) == 0; )
84 wxDEPRECATED_INLINE(inline bool wxStringEq(const wchar_t *s1
, const wchar_t *s2
),
85 return wxCRT_StrcmpW(s1
, s2
) == 0; )
86 #endif // wxUSE_UNICODE
88 #endif // WXWIN_COMPATIBILITY_2_8
90 // ----------------------------------------------------------------------------
91 // Miscellaneous functions
92 // ----------------------------------------------------------------------------
95 #if !defined __EMX__ && \
96 (defined __WXMOTIF__ || defined __WXGTK__ || defined __WXX11__)
97 WXDLLIMPEXP_CORE
void wxBell();
99 WXDLLIMPEXP_BASE
void wxBell();
103 // Show wxWidgets information
104 WXDLLIMPEXP_CORE
void wxInfoMessageBox(wxWindow
* parent
);
105 #endif // wxUSE_MSGDLG
107 // Get OS description as a user-readable string
108 WXDLLIMPEXP_BASE wxString
wxGetOsDescription();
111 WXDLLIMPEXP_BASE wxOperatingSystemId
wxGetOsVersion(int *majorVsn
= NULL
,
112 int *minorVsn
= NULL
);
114 // Get platform endianness
115 WXDLLIMPEXP_BASE
bool wxIsPlatformLittleEndian();
117 // Get platform architecture
118 WXDLLIMPEXP_BASE
bool wxIsPlatform64Bit();
121 // Get linux-distro informations
122 WXDLLIMPEXP_BASE wxLinuxDistributionInfo
wxGetLinuxDistributionInfo();
125 // Return a string with the current date/time
126 WXDLLIMPEXP_BASE wxString
wxNow();
128 // Return path where wxWidgets is installed (mostly useful in Unices)
129 WXDLLIMPEXP_BASE
const wxChar
*wxGetInstallPrefix();
130 // Return path to wxWin data (/usr/share/wx/%{version}) (Unices)
131 WXDLLIMPEXP_BASE wxString
wxGetDataDir();
135 // Get the state of a key (true if pressed, false if not)
136 // This is generally most useful getting the state of
137 // the modifier or toggle keys.
138 WXDLLIMPEXP_CORE
bool wxGetKeyState(wxKeyCode key
);
140 // Don't synthesize KeyUp events holding down a key and producing
141 // KeyDown events with autorepeat. On by default and always on
143 WXDLLIMPEXP_CORE
bool wxSetDetectableAutoRepeat( bool flag
);
145 // Returns the current state of the mouse position, buttons and modifers
146 WXDLLIMPEXP_CORE wxMouseState
wxGetMouseState();
150 // ----------------------------------------------------------------------------
152 // ----------------------------------------------------------------------------
155 * Class to make it easier to specify platform-dependent values
158 * long val = wxPlatform::If(wxMac, 1).ElseIf(wxGTK, 2).ElseIf(stPDA, 5).Else(3);
159 * wxString strVal = wxPlatform::If(wxMac, wxT("Mac")).ElseIf(wxMSW, wxT("MSW")).Else(wxT("Other"));
161 * A custom platform symbol:
165 * wxPlatform::AddPlatform(stPDA);
168 * long windowStyle = wxCAPTION | (long) wxPlatform::IfNot(stPDA, wxRESIZE_BORDER);
172 class WXDLLIMPEXP_BASE wxPlatform
175 wxPlatform() { Init(); }
176 wxPlatform(const wxPlatform
& platform
) { Copy(platform
); }
177 void operator = (const wxPlatform
& platform
) { if (&platform
!= this) Copy(platform
); }
178 void Copy(const wxPlatform
& platform
);
180 // Specify an optional default value
181 wxPlatform(int defValue
) { Init(); m_longValue
= (long)defValue
; }
182 wxPlatform(long defValue
) { Init(); m_longValue
= defValue
; }
183 wxPlatform(const wxString
& defValue
) { Init(); m_stringValue
= defValue
; }
184 wxPlatform(double defValue
) { Init(); m_doubleValue
= defValue
; }
186 static wxPlatform
If(int platform
, long value
);
187 static wxPlatform
IfNot(int platform
, long value
);
188 wxPlatform
& ElseIf(int platform
, long value
);
189 wxPlatform
& ElseIfNot(int platform
, long value
);
190 wxPlatform
& Else(long value
);
192 static wxPlatform
If(int platform
, int value
) { return If(platform
, (long)value
); }
193 static wxPlatform
IfNot(int platform
, int value
) { return IfNot(platform
, (long)value
); }
194 wxPlatform
& ElseIf(int platform
, int value
) { return ElseIf(platform
, (long) value
); }
195 wxPlatform
& ElseIfNot(int platform
, int value
) { return ElseIfNot(platform
, (long) value
); }
196 wxPlatform
& Else(int value
) { return Else((long) value
); }
198 static wxPlatform
If(int platform
, double value
);
199 static wxPlatform
IfNot(int platform
, double value
);
200 wxPlatform
& ElseIf(int platform
, double value
);
201 wxPlatform
& ElseIfNot(int platform
, double value
);
202 wxPlatform
& Else(double value
);
204 static wxPlatform
If(int platform
, const wxString
& value
);
205 static wxPlatform
IfNot(int platform
, const wxString
& value
);
206 wxPlatform
& ElseIf(int platform
, const wxString
& value
);
207 wxPlatform
& ElseIfNot(int platform
, const wxString
& value
);
208 wxPlatform
& Else(const wxString
& value
);
210 long GetInteger() const { return m_longValue
; }
211 const wxString
& GetString() const { return m_stringValue
; }
212 double GetDouble() const { return m_doubleValue
; }
214 operator int() const { return (int) GetInteger(); }
215 operator long() const { return GetInteger(); }
216 operator double() const { return GetDouble(); }
217 operator const wxString
&() const { return GetString(); }
219 static void AddPlatform(int platform
);
220 static bool Is(int platform
);
221 static void ClearPlatforms();
225 void Init() { m_longValue
= 0; m_doubleValue
= 0.0; }
228 double m_doubleValue
;
229 wxString m_stringValue
;
230 static wxArrayInt
* sm_customPlatforms
;
233 /// Function for testing current platform
234 inline bool wxPlatformIs(int platform
) { return wxPlatform::Is(platform
); }
236 // ----------------------------------------------------------------------------
237 // Window ID management
238 // ----------------------------------------------------------------------------
240 // Ensure subsequent IDs don't clash with this one
241 WXDLLIMPEXP_BASE
void wxRegisterId(long id
);
243 // Return the current ID
244 WXDLLIMPEXP_BASE
long wxGetCurrentId();
246 // Generate a unique ID
247 WXDLLIMPEXP_BASE
long wxNewId();
249 // ----------------------------------------------------------------------------
250 // Various conversions
251 // ----------------------------------------------------------------------------
253 // Convert 2-digit hex number to decimal
254 WXDLLIMPEXP_BASE
int wxHexToDec(const wxString
& buf
);
256 // Convert 2-digit hex number to decimal
257 inline int wxHexToDec(const char* buf
)
259 int firstDigit
, secondDigit
;
262 firstDigit
= buf
[0] - 'A' + 10;
264 firstDigit
= buf
[0] - '0';
267 secondDigit
= buf
[1] - 'A' + 10;
269 secondDigit
= buf
[1] - '0';
271 return (firstDigit
& 0xF) * 16 + (secondDigit
& 0xF );
275 // Convert decimal integer to 2-character hex string
276 WXDLLIMPEXP_BASE
void wxDecToHex(int dec
, wxChar
*buf
);
277 WXDLLIMPEXP_BASE
void wxDecToHex(int dec
, char* ch1
, char* ch2
);
278 WXDLLIMPEXP_BASE wxString
wxDecToHex(int dec
);
280 // ----------------------------------------------------------------------------
281 // Process management
282 // ----------------------------------------------------------------------------
284 // NB: for backwards compatibility reasons the values of wxEXEC_[A]SYNC *must*
285 // be 0 and 1, don't change!
289 // execute the process asynchronously
292 // execute it synchronously, i.e. wait until it finishes
295 // under Windows, don't hide the child even if it's IO is redirected (this
296 // is done by default)
299 // under Unix, if the process is the group leader then passing wxKILL_CHILDREN to wxKill
300 // kills all children as well as pid
301 wxEXEC_MAKE_GROUP_LEADER
= 4,
303 // by default synchronous execution disables all program windows to avoid
304 // that the user interacts with the program while the child process is
305 // running, you can use this flag to prevent this from happening
306 wxEXEC_NODISABLE
= 8,
308 // by default, the event loop is run while waiting for synchronous execution
309 // to complete and this flag can be used to simply block the main process
310 // until the child process finishes
311 wxEXEC_NOEVENTS
= 16,
313 // convenient synonym for flags given system()-like behaviour
314 wxEXEC_BLOCK
= wxEXEC_SYNC
| wxEXEC_NOEVENTS
317 // Map storing environment variables.
318 typedef wxStringToStringHashMap wxEnvVariableHashMap
;
320 // Used to pass additional parameters for child process to wxExecute(). Could
321 // be extended with other fields later.
324 wxString cwd
; // If empty, CWD is not changed.
325 wxEnvVariableHashMap env
; // If empty, environment is unchanged.
328 // Execute another program.
330 // If flags contain wxEXEC_SYNC, return -1 on failure and the exit code of the
331 // process if everything was ok. Otherwise (i.e. if wxEXEC_ASYNC), return 0 on
332 // failure and the PID of the launched process if ok.
333 WXDLLIMPEXP_BASE
long wxExecute(const wxString
& command
,
334 int flags
= wxEXEC_ASYNC
,
335 wxProcess
*process
= NULL
,
336 const wxExecuteEnv
*env
= NULL
);
337 WXDLLIMPEXP_BASE
long wxExecute(char **argv
,
338 int flags
= wxEXEC_ASYNC
,
339 wxProcess
*process
= NULL
,
340 const wxExecuteEnv
*env
= NULL
);
342 WXDLLIMPEXP_BASE
long wxExecute(wchar_t **argv
,
343 int flags
= wxEXEC_ASYNC
,
344 wxProcess
*process
= NULL
,
345 const wxExecuteEnv
*env
= NULL
);
346 #endif // wxUSE_UNICODE
348 // execute the command capturing its output into an array line by line, this is
349 // always synchronous
350 WXDLLIMPEXP_BASE
long wxExecute(const wxString
& command
,
351 wxArrayString
& output
,
353 const wxExecuteEnv
*env
= NULL
);
355 // also capture stderr (also synchronous)
356 WXDLLIMPEXP_BASE
long wxExecute(const wxString
& command
,
357 wxArrayString
& output
,
358 wxArrayString
& error
,
360 const wxExecuteEnv
*env
= NULL
);
362 #if defined(__WXMSW__) && wxUSE_IPC
363 // ask a DDE server to execute the DDE request with given parameters
364 WXDLLIMPEXP_BASE
bool wxExecuteDDE(const wxString
& ddeServer
,
365 const wxString
& ddeTopic
,
366 const wxString
& ddeCommand
);
367 #endif // __WXMSW__ && wxUSE_IPC
371 wxSIGNONE
= 0, // verify if the process exists under Unix
378 wxSIGIOT
= wxSIGABRT
, // another name
389 // further signals are different in meaning between different Unix systems
394 wxKILL_OK
, // no error
395 wxKILL_BAD_SIGNAL
, // no such signal
396 wxKILL_ACCESS_DENIED
, // permission denied
397 wxKILL_NO_PROCESS
, // no such process
398 wxKILL_ERROR
// another, unspecified error
403 wxKILL_NOCHILDREN
= 0, // don't kill children
404 wxKILL_CHILDREN
= 1 // kill children
409 wxSHUTDOWN_FORCE
= 1,// can be combined with other flags (MSW-only)
410 wxSHUTDOWN_POWEROFF
= 2,// power off the computer
411 wxSHUTDOWN_REBOOT
= 4,// shutdown and reboot
412 wxSHUTDOWN_LOGOFF
= 8 // close session (currently MSW-only)
415 // Shutdown or reboot the PC
416 WXDLLIMPEXP_BASE
bool wxShutdown(int flags
= wxSHUTDOWN_POWEROFF
);
418 // send the given signal to the process (only NONE and KILL are supported under
419 // Windows, all others mean TERM), return 0 if ok and -1 on error
421 // return detailed error in rc if not NULL
422 WXDLLIMPEXP_BASE
int wxKill(long pid
,
423 wxSignal sig
= wxSIGTERM
,
424 wxKillError
*rc
= NULL
,
425 int flags
= wxKILL_NOCHILDREN
);
427 // Execute a command in an interactive shell window (always synchronously)
428 // If no command then just the shell
429 WXDLLIMPEXP_BASE
bool wxShell(const wxString
& command
= wxEmptyString
);
431 // As wxShell(), but must give a (non interactive) command and its output will
432 // be returned in output array
433 WXDLLIMPEXP_BASE
bool wxShell(const wxString
& command
, wxArrayString
& output
);
435 // Sleep for nSecs seconds
436 WXDLLIMPEXP_BASE
void wxSleep(int nSecs
);
438 // Sleep for a given amount of milliseconds
439 WXDLLIMPEXP_BASE
void wxMilliSleep(unsigned long milliseconds
);
441 // Sleep for a given amount of microseconds
442 WXDLLIMPEXP_BASE
void wxMicroSleep(unsigned long microseconds
);
444 #if WXWIN_COMPATIBILITY_2_8
445 // Sleep for a given amount of milliseconds (old, bad name), use wxMilliSleep
446 wxDEPRECATED( WXDLLIMPEXP_BASE
void wxUsleep(unsigned long milliseconds
) );
449 // Get the process id of the current process
450 WXDLLIMPEXP_BASE
unsigned long wxGetProcessId();
452 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
453 WXDLLIMPEXP_BASE wxMemorySize
wxGetFreeMemory();
455 #if wxUSE_ON_FATAL_EXCEPTION
457 // should wxApp::OnFatalException() be called?
458 WXDLLIMPEXP_BASE
bool wxHandleFatalExceptions(bool doit
= true);
460 #endif // wxUSE_ON_FATAL_EXCEPTION
462 // ----------------------------------------------------------------------------
463 // Environment variables
464 // ----------------------------------------------------------------------------
466 // returns true if variable exists (value may be NULL if you just want to check
468 WXDLLIMPEXP_BASE
bool wxGetEnv(const wxString
& var
, wxString
*value
);
470 // set the env var name to the given value, return true on success
471 WXDLLIMPEXP_BASE
bool wxSetEnv(const wxString
& var
, const wxString
& value
);
473 // remove the env var from environment
474 WXDLLIMPEXP_BASE
bool wxUnsetEnv(const wxString
& var
);
476 #if WXWIN_COMPATIBILITY_2_8
477 inline bool wxSetEnv(const wxString
& var
, const char *value
)
478 { return wxSetEnv(var
, wxString(value
)); }
479 inline bool wxSetEnv(const wxString
& var
, const wchar_t *value
)
480 { return wxSetEnv(var
, wxString(value
)); }
482 inline bool wxSetEnv(const wxString
& var
, const wxScopedCharTypeBuffer
<T
>& value
)
483 { return wxSetEnv(var
, wxString(value
)); }
484 inline bool wxSetEnv(const wxString
& var
, const wxCStrData
& value
)
485 { return wxSetEnv(var
, wxString(value
)); }
487 // this one is for passing NULL directly - don't use it, use wxUnsetEnv instead
488 wxDEPRECATED( inline bool wxSetEnv(const wxString
& var
, int value
) );
489 inline bool wxSetEnv(const wxString
& var
, int value
)
491 wxASSERT_MSG( value
== 0, "using non-NULL integer as string?" );
493 wxUnusedVar(value
); // fix unused parameter warning in release build
495 return wxUnsetEnv(var
);
497 #endif // WXWIN_COMPATIBILITY_2_8
499 // Retrieve the complete environment by filling specified map.
500 // Returns true on success or false if an error occurred.
501 WXDLLIMPEXP_BASE
bool wxGetEnvMap(wxEnvVariableHashMap
*map
);
503 // ----------------------------------------------------------------------------
504 // Network and username functions.
505 // ----------------------------------------------------------------------------
507 // NB: "char *" functions are deprecated, use wxString ones!
510 WXDLLIMPEXP_BASE
bool wxGetEmailAddress(wxChar
*buf
, int maxSize
);
511 WXDLLIMPEXP_BASE wxString
wxGetEmailAddress();
514 WXDLLIMPEXP_BASE
bool wxGetHostName(wxChar
*buf
, int maxSize
);
515 WXDLLIMPEXP_BASE wxString
wxGetHostName();
518 WXDLLIMPEXP_BASE wxString
wxGetFullHostName();
519 WXDLLIMPEXP_BASE
bool wxGetFullHostName(wxChar
*buf
, int maxSize
);
521 // Get user ID e.g. jacs (this is known as login name under Unix)
522 WXDLLIMPEXP_BASE
bool wxGetUserId(wxChar
*buf
, int maxSize
);
523 WXDLLIMPEXP_BASE wxString
wxGetUserId();
525 // Get user name e.g. Julian Smart
526 WXDLLIMPEXP_BASE
bool wxGetUserName(wxChar
*buf
, int maxSize
);
527 WXDLLIMPEXP_BASE wxString
wxGetUserName();
529 // Get current Home dir and copy to dest (returns pstr->c_str())
530 WXDLLIMPEXP_BASE wxString
wxGetHomeDir();
531 WXDLLIMPEXP_BASE
const wxChar
* wxGetHomeDir(wxString
*pstr
);
533 // Get the user's (by default use the current user name) home dir,
534 // return empty string on error
535 WXDLLIMPEXP_BASE wxString
wxGetUserHome(const wxString
& user
= wxEmptyString
);
539 typedef wxLongLong wxDiskspaceSize_t
;
541 typedef long wxDiskspaceSize_t
;
544 // get number of total/free bytes on the disk where path belongs
545 WXDLLIMPEXP_BASE
bool wxGetDiskSpace(const wxString
& path
,
546 wxDiskspaceSize_t
*pTotal
= NULL
,
547 wxDiskspaceSize_t
*pFree
= NULL
);
553 typedef int (wxCMPFUNC_CONV
*CMPFUNCDATA
)(const void* pItem1
, const void* pItem2
, const void* user_data
);
557 WXDLLIMPEXP_BASE
void wxQsort(void *const pbase
, size_t total_elems
,
558 size_t size
, CMPFUNCDATA cmp
, const void* user_data
);
561 #if wxUSE_GUI // GUI only things from now on
563 // ----------------------------------------------------------------------------
564 // Launch default browser
565 // ----------------------------------------------------------------------------
567 // flags for wxLaunchDefaultBrowser
570 wxBROWSER_NEW_WINDOW
= 0x01,
571 wxBROWSER_NOBUSYCURSOR
= 0x02
574 // Launch url in the user's default internet browser
575 WXDLLIMPEXP_CORE
bool wxLaunchDefaultBrowser(const wxString
& url
, int flags
= 0);
577 // Launch document in the user's default application
578 WXDLLIMPEXP_CORE
bool wxLaunchDefaultApplication(const wxString
& path
, int flags
= 0);
580 // ----------------------------------------------------------------------------
581 // Menu accelerators related things
582 // ----------------------------------------------------------------------------
584 // flags for wxStripMenuCodes
587 // strip '&' characters
588 wxStrip_Mnemonics
= 1,
590 // strip everything after '\t'
593 // strip everything (this is the default)
594 wxStrip_All
= wxStrip_Mnemonics
| wxStrip_Accel
597 // strip mnemonics and/or accelerators from the label
598 WXDLLIMPEXP_CORE wxString
599 wxStripMenuCodes(const wxString
& str
, int flags
= wxStrip_All
);
601 #if WXWIN_COMPATIBILITY_2_6
602 // obsolete and deprecated version, do not use, use the above overload instead
604 WXDLLIMPEXP_CORE wxChar
* wxStripMenuCodes(const wxChar
*in
, wxChar
*out
= NULL
)
608 class WXDLLIMPEXP_FWD_CORE wxAcceleratorEntry
;
610 // use wxAcceleratorEntry::Create() or FromString() methods instead
612 WXDLLIMPEXP_CORE wxAcceleratorEntry
*wxGetAccelFromString(const wxString
& label
)
614 #endif // wxUSE_ACCEL
616 #endif // WXWIN_COMPATIBILITY_2_6
618 // ----------------------------------------------------------------------------
620 // ----------------------------------------------------------------------------
622 // Returns menu item id or wxNOT_FOUND if none.
623 WXDLLIMPEXP_CORE
int wxFindMenuItemId(wxFrame
*frame
, const wxString
& menuString
, const wxString
& itemString
);
625 // Find the wxWindow at the given point. wxGenericFindWindowAtPoint
626 // is always present but may be less reliable than a native version.
627 WXDLLIMPEXP_CORE wxWindow
* wxGenericFindWindowAtPoint(const wxPoint
& pt
);
628 WXDLLIMPEXP_CORE wxWindow
* wxFindWindowAtPoint(const wxPoint
& pt
);
630 // NB: this function is obsolete, use wxWindow::FindWindowByLabel() instead
632 // Find the window/widget with the given title or label.
633 // Pass a parent to begin the search from, or NULL to look through
635 WXDLLIMPEXP_CORE wxWindow
* wxFindWindowByLabel(const wxString
& title
, wxWindow
*parent
= NULL
);
637 // NB: this function is obsolete, use wxWindow::FindWindowByName() instead
639 // Find window by name, and if that fails, by label.
640 WXDLLIMPEXP_CORE wxWindow
* wxFindWindowByName(const wxString
& name
, wxWindow
*parent
= NULL
);
642 // ----------------------------------------------------------------------------
643 // Message/event queue helpers
644 // ----------------------------------------------------------------------------
646 // Yield to other apps/messages and disable user input
647 WXDLLIMPEXP_CORE
bool wxSafeYield(wxWindow
*win
= NULL
, bool onlyIfNeeded
= false);
649 // Enable or disable input to all top level windows
650 WXDLLIMPEXP_CORE
void wxEnableTopLevelWindows(bool enable
= true);
652 // Check whether this window wants to process messages, e.g. Stop button
653 // in long calculations.
654 WXDLLIMPEXP_CORE
bool wxCheckForInterrupt(wxWindow
*wnd
);
656 // Consume all events until no more left
657 WXDLLIMPEXP_CORE
void wxFlushEvents();
659 // a class which disables all windows (except, may be, the given one) in its
660 // ctor and enables them back in its dtor
661 class WXDLLIMPEXP_CORE wxWindowDisabler
664 // this ctor conditionally disables all windows: if the argument is false,
665 // it doesn't do anything
666 wxWindowDisabler(bool disable
= true);
668 // ctor disables all windows except winToSkip
669 wxWindowDisabler(wxWindow
*winToSkip
);
671 // dtor enables back all windows disabled by the ctor
675 // disable all windows except the given one (used by both ctors)
676 void DoDisable(wxWindow
*winToSkip
= NULL
);
679 wxWindowList
*m_winDisabled
;
682 wxDECLARE_NO_COPY_CLASS(wxWindowDisabler
);
685 // ----------------------------------------------------------------------------
687 // ----------------------------------------------------------------------------
689 // Set the cursor to the busy cursor for all windows
690 WXDLLIMPEXP_CORE
void wxBeginBusyCursor(const wxCursor
*cursor
= wxHOURGLASS_CURSOR
);
692 // Restore cursor to normal
693 WXDLLIMPEXP_CORE
void wxEndBusyCursor();
695 // true if we're between the above two calls
696 WXDLLIMPEXP_CORE
bool wxIsBusy();
698 // Convenience class so we can just create a wxBusyCursor object on the stack
699 class WXDLLIMPEXP_CORE wxBusyCursor
702 wxBusyCursor(const wxCursor
* cursor
= wxHOURGLASS_CURSOR
)
703 { wxBeginBusyCursor(cursor
); }
705 { wxEndBusyCursor(); }
707 // FIXME: These two methods are currently only implemented (and needed?)
708 // in wxGTK. BusyCursor handling should probably be moved to
709 // common code since the wxGTK and wxMSW implementations are very
710 // similar except for wxMSW using HCURSOR directly instead of
712 static const wxCursor
&GetStoredCursor();
713 static const wxCursor
GetBusyCursor();
716 void WXDLLIMPEXP_CORE
wxGetMousePosition( int* x
, int* y
);
718 // ----------------------------------------------------------------------------
719 // X11 Display access
720 // ----------------------------------------------------------------------------
722 #if defined(__X__) || defined(__WXGTK__)
725 WXDLLIMPEXP_CORE
void *wxGetDisplay();
729 WXDLLIMPEXP_CORE WXDisplay
*wxGetDisplay();
730 WXDLLIMPEXP_CORE
bool wxSetDisplay(const wxString
& display_name
);
731 WXDLLIMPEXP_CORE wxString
wxGetDisplayName();
734 // use this function instead of the functions above in implementation code
735 inline struct _XDisplay
*wxGetX11Display()
737 return (_XDisplay
*)wxGetDisplay();
740 #endif // X11 || wxGTK
744 // ----------------------------------------------------------------------------
745 // wxYield(): these functions are obsolete, please use wxApp methods instead!
746 // ----------------------------------------------------------------------------
748 // avoid redeclaring this function here if it had been already declated by
749 // wx/app.h, this results in warnings from g++ with -Wredundant-decls
750 #ifndef wx_YIELD_DECLARED
751 #define wx_YIELD_DECLARED
753 // Yield to other apps/messages
754 WXDLLIMPEXP_CORE
bool wxYield();
756 #endif // wx_YIELD_DECLARED
758 // Like wxYield, but fails silently if the yield is recursive.
759 WXDLLIMPEXP_CORE
bool wxYieldIfNeeded();
761 // ----------------------------------------------------------------------------
762 // Windows resources access
763 // ----------------------------------------------------------------------------
765 // MSW only: get user-defined resource from the .res file.
767 // default resource type for wxLoadUserResource()
768 extern WXDLLIMPEXP_DATA_BASE(const wxChar
*) wxUserResourceStr
;
770 // Return the pointer to the resource data. This pointer is read-only, use
771 // the overload below if you need to modify the data.
773 // Returns true on success, false on failure. Doesn't log an error message
774 // if the resource is not found (because this could be expected) but does
775 // log one if any other error occurs.
776 WXDLLIMPEXP_BASE
bool
777 wxLoadUserResource(const void **outData
,
779 const wxString
& resourceName
,
780 const wxString
& resourceType
= wxUserResourceStr
,
781 WXHINSTANCE
module = 0);
783 // This function allocates a new buffer and makes a copy of the resource
784 // data, remember to delete[] the buffer. And avoid using it entirely if
785 // the overload above can be used.
787 // Returns NULL on failure.
788 WXDLLIMPEXP_BASE
char*
789 wxLoadUserResource(const wxString
& resourceName
,
790 const wxString
& resourceType
= wxUserResourceStr
,
792 WXHINSTANCE
module = 0);