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"
24 #include "wx/gdicmn.h"
25 #include "wx/mousestate.h"
28 class WXDLLIMPEXP_FWD_BASE wxArrayString
;
29 class WXDLLIMPEXP_FWD_BASE wxArrayInt
;
31 // need this for wxGetDiskSpace() as we can't, unfortunately, forward declare
33 #include "wx/longlong.h"
35 // needed for wxOperatingSystemId, wxLinuxDistributionInfo
36 #include "wx/platinfo.h"
47 // ----------------------------------------------------------------------------
48 // Forward declaration
49 // ----------------------------------------------------------------------------
51 class WXDLLIMPEXP_FWD_BASE wxProcess
;
52 class WXDLLIMPEXP_FWD_CORE wxFrame
;
53 class WXDLLIMPEXP_FWD_CORE wxWindow
;
54 class WXDLLIMPEXP_FWD_CORE wxWindowList
;
56 // ----------------------------------------------------------------------------
58 // ----------------------------------------------------------------------------
60 #define wxMax(a,b) (((a) > (b)) ? (a) : (b))
61 #define wxMin(a,b) (((a) < (b)) ? (a) : (b))
62 #define wxClip(a,b,c) (((a) < (b)) ? (b) : (((a) > (c)) ? (c) : (a)))
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
68 typedef wxLongLong wxMemorySize
;
70 typedef long wxMemorySize
;
73 // ----------------------------------------------------------------------------
74 // String functions (deprecated, use wxString)
75 // ----------------------------------------------------------------------------
77 #ifdef WXWIN_COMPATIBILITY_2_8
78 // A shorter way of using strcmp
79 wxDEPRECATED_INLINE(inline bool wxStringEq(const char *s1
, const char *s2
),
80 return wxCRT_StrcmpA(s1
, s2
) == 0; )
83 wxDEPRECATED_INLINE(inline bool wxStringEq(const wchar_t *s1
, const wchar_t *s2
),
84 return wxCRT_StrcmpW(s1
, s2
) == 0; )
85 #endif // wxUSE_UNICODE
87 #endif // WXWIN_COMPATIBILITY_2_8
89 // ----------------------------------------------------------------------------
90 // Miscellaneous functions
91 // ----------------------------------------------------------------------------
94 #if !defined __EMX__ && \
95 (defined __WXMOTIF__ || defined __WXGTK__ || defined __WXX11__)
96 WXDLLIMPEXP_CORE
void wxBell();
98 WXDLLIMPEXP_BASE
void wxBell();
102 // Show wxWidgets information
103 WXDLLIMPEXP_CORE
void wxInfoMessageBox(wxWindow
* parent
);
104 #endif // wxUSE_MSGDLG
106 // Get OS description as a user-readable string
107 WXDLLIMPEXP_BASE wxString
wxGetOsDescription();
110 WXDLLIMPEXP_BASE wxOperatingSystemId
wxGetOsVersion(int *majorVsn
= NULL
,
111 int *minorVsn
= NULL
);
113 // Get platform endianness
114 WXDLLIMPEXP_BASE
bool wxIsPlatformLittleEndian();
116 // Get platform architecture
117 WXDLLIMPEXP_BASE
bool wxIsPlatform64Bit();
120 // Get linux-distro informations
121 WXDLLIMPEXP_BASE wxLinuxDistributionInfo
wxGetLinuxDistributionInfo();
124 // Return a string with the current date/time
125 WXDLLIMPEXP_BASE wxString
wxNow();
127 // Return path where wxWidgets is installed (mostly useful in Unices)
128 WXDLLIMPEXP_BASE
const wxChar
*wxGetInstallPrefix();
129 // Return path to wxWin data (/usr/share/wx/%{version}) (Unices)
130 WXDLLIMPEXP_BASE wxString
wxGetDataDir();
134 // Get the state of a key (true if pressed, false if not)
135 // This is generally most useful getting the state of
136 // the modifier or toggle keys.
137 WXDLLIMPEXP_CORE
bool wxGetKeyState(wxKeyCode key
);
139 // Don't synthesize KeyUp events holding down a key and producing
140 // KeyDown events with autorepeat. On by default and always on
142 WXDLLIMPEXP_CORE
bool wxSetDetectableAutoRepeat( bool flag
);
144 // Returns the current state of the mouse position, buttons and modifers
145 WXDLLIMPEXP_CORE wxMouseState
wxGetMouseState();
149 // ----------------------------------------------------------------------------
151 // ----------------------------------------------------------------------------
154 * Class to make it easier to specify platform-dependent values
157 * long val = wxPlatform::If(wxMac, 1).ElseIf(wxGTK, 2).ElseIf(stPDA, 5).Else(3);
158 * wxString strVal = wxPlatform::If(wxMac, wxT("Mac")).ElseIf(wxMSW, wxT("MSW")).Else(wxT("Other"));
160 * A custom platform symbol:
164 * wxPlatform::AddPlatform(stPDA);
167 * long windowStyle = wxCAPTION | (long) wxPlatform::IfNot(stPDA, wxRESIZE_BORDER);
171 class WXDLLIMPEXP_BASE wxPlatform
174 wxPlatform() { Init(); }
175 wxPlatform(const wxPlatform
& platform
) { Copy(platform
); }
176 void operator = (const wxPlatform
& platform
) { if (&platform
!= this) Copy(platform
); }
177 void Copy(const wxPlatform
& platform
);
179 // Specify an optional default value
180 wxPlatform(int defValue
) { Init(); m_longValue
= (long)defValue
; }
181 wxPlatform(long defValue
) { Init(); m_longValue
= defValue
; }
182 wxPlatform(const wxString
& defValue
) { Init(); m_stringValue
= defValue
; }
183 wxPlatform(double defValue
) { Init(); m_doubleValue
= defValue
; }
185 static wxPlatform
If(int platform
, long value
);
186 static wxPlatform
IfNot(int platform
, long value
);
187 wxPlatform
& ElseIf(int platform
, long value
);
188 wxPlatform
& ElseIfNot(int platform
, long value
);
189 wxPlatform
& Else(long value
);
191 static wxPlatform
If(int platform
, int value
) { return If(platform
, (long)value
); }
192 static wxPlatform
IfNot(int platform
, int value
) { return IfNot(platform
, (long)value
); }
193 wxPlatform
& ElseIf(int platform
, int value
) { return ElseIf(platform
, (long) value
); }
194 wxPlatform
& ElseIfNot(int platform
, int value
) { return ElseIfNot(platform
, (long) value
); }
195 wxPlatform
& Else(int value
) { return Else((long) value
); }
197 static wxPlatform
If(int platform
, double value
);
198 static wxPlatform
IfNot(int platform
, double value
);
199 wxPlatform
& ElseIf(int platform
, double value
);
200 wxPlatform
& ElseIfNot(int platform
, double value
);
201 wxPlatform
& Else(double value
);
203 static wxPlatform
If(int platform
, const wxString
& value
);
204 static wxPlatform
IfNot(int platform
, const wxString
& value
);
205 wxPlatform
& ElseIf(int platform
, const wxString
& value
);
206 wxPlatform
& ElseIfNot(int platform
, const wxString
& value
);
207 wxPlatform
& Else(const wxString
& value
);
209 long GetInteger() const { return m_longValue
; }
210 const wxString
& GetString() const { return m_stringValue
; }
211 double GetDouble() const { return m_doubleValue
; }
213 operator int() const { return (int) GetInteger(); }
214 operator long() const { return GetInteger(); }
215 operator double() const { return GetDouble(); }
216 operator const wxString
&() const { return GetString(); }
218 static void AddPlatform(int platform
);
219 static bool Is(int platform
);
220 static void ClearPlatforms();
224 void Init() { m_longValue
= 0; m_doubleValue
= 0.0; }
227 double m_doubleValue
;
228 wxString m_stringValue
;
229 static wxArrayInt
* sm_customPlatforms
;
232 /// Function for testing current platform
233 inline bool wxPlatformIs(int platform
) { return wxPlatform::Is(platform
); }
235 // ----------------------------------------------------------------------------
236 // Window ID management
237 // ----------------------------------------------------------------------------
239 // Ensure subsequent IDs don't clash with this one
240 WXDLLIMPEXP_BASE
void wxRegisterId(long id
);
242 // Return the current ID
243 WXDLLIMPEXP_BASE
long wxGetCurrentId();
245 // Generate a unique ID
246 WXDLLIMPEXP_BASE
long wxNewId();
248 // ----------------------------------------------------------------------------
249 // Various conversions
250 // ----------------------------------------------------------------------------
252 // Convert 2-digit hex number to decimal
253 WXDLLIMPEXP_BASE
int wxHexToDec(const wxString
& buf
);
255 // Convert decimal integer to 2-character hex string
256 WXDLLIMPEXP_BASE
void wxDecToHex(int dec
, wxChar
*buf
);
257 WXDLLIMPEXP_BASE
void wxDecToHex(int dec
, char* ch1
, char* ch2
);
258 WXDLLIMPEXP_BASE wxString
wxDecToHex(int dec
);
260 // ----------------------------------------------------------------------------
261 // Process management
262 // ----------------------------------------------------------------------------
264 // NB: for backwards compatibility reasons the values of wxEXEC_[A]SYNC *must*
265 // be 0 and 1, don't change!
269 // execute the process asynchronously
272 // execute it synchronously, i.e. wait until it finishes
275 // under Windows, don't hide the child even if it's IO is redirected (this
276 // is done by default)
279 // under Unix, if the process is the group leader then passing wxKILL_CHILDREN to wxKill
280 // kills all children as well as pid
281 wxEXEC_MAKE_GROUP_LEADER
= 4,
283 // by default synchronous execution disables all program windows to avoid
284 // that the user interacts with the program while the child process is
285 // running, you can use this flag to prevent this from happening
286 wxEXEC_NODISABLE
= 8,
288 // by default, the event loop is run while waiting for synchronous execution
289 // to complete and this flag can be used to simply block the main process
290 // until the child process finishes
291 wxEXEC_NOEVENTS
= 16,
293 // convenient synonym for flags given system()-like behaviour
294 wxEXEC_BLOCK
= wxEXEC_SYNC
| wxEXEC_NOEVENTS
297 // Execute another program.
299 // If flags contain wxEXEC_SYNC, return -1 on failure and the exit code of the
300 // process if everything was ok. Otherwise (i.e. if wxEXEC_ASYNC), return 0 on
301 // failure and the PID of the launched process if ok.
302 WXDLLIMPEXP_BASE
long wxExecute(const wxString
& command
,
303 int flags
= wxEXEC_ASYNC
,
304 wxProcess
*process
= NULL
);
305 WXDLLIMPEXP_BASE
long wxExecute(char **argv
,
306 int flags
= wxEXEC_ASYNC
,
307 wxProcess
*process
= NULL
);
309 WXDLLIMPEXP_BASE
long wxExecute(wchar_t **argv
,
310 int flags
= wxEXEC_ASYNC
,
311 wxProcess
*process
= NULL
);
312 #endif // wxUSE_UNICODE
314 // execute the command capturing its output into an array line by line, this is
315 // always synchronous
316 WXDLLIMPEXP_BASE
long wxExecute(const wxString
& command
,
317 wxArrayString
& output
,
320 // also capture stderr (also synchronous)
321 WXDLLIMPEXP_BASE
long wxExecute(const wxString
& command
,
322 wxArrayString
& output
,
323 wxArrayString
& error
,
326 #if defined(__WXMSW__) && wxUSE_IPC
327 // ask a DDE server to execute the DDE request with given parameters
328 WXDLLIMPEXP_BASE
bool wxExecuteDDE(const wxString
& ddeServer
,
329 const wxString
& ddeTopic
,
330 const wxString
& ddeCommand
);
331 #endif // __WXMSW__ && wxUSE_IPC
335 wxSIGNONE
= 0, // verify if the process exists under Unix
342 wxSIGIOT
= wxSIGABRT
, // another name
353 // further signals are different in meaning between different Unix systems
358 wxKILL_OK
, // no error
359 wxKILL_BAD_SIGNAL
, // no such signal
360 wxKILL_ACCESS_DENIED
, // permission denied
361 wxKILL_NO_PROCESS
, // no such process
362 wxKILL_ERROR
// another, unspecified error
367 wxKILL_NOCHILDREN
= 0, // don't kill children
368 wxKILL_CHILDREN
= 1 // kill children
373 wxSHUTDOWN_FORCE
= 1,// can be combined with other flags (MSW-only)
374 wxSHUTDOWN_POWEROFF
= 2,// power off the computer
375 wxSHUTDOWN_REBOOT
= 4,// shutdown and reboot
376 wxSHUTDOWN_LOGOFF
= 8 // close session (currently MSW-only)
379 // Shutdown or reboot the PC
380 WXDLLIMPEXP_BASE
bool wxShutdown(int flags
= wxSHUTDOWN_POWEROFF
);
382 // send the given signal to the process (only NONE and KILL are supported under
383 // Windows, all others mean TERM), return 0 if ok and -1 on error
385 // return detailed error in rc if not NULL
386 WXDLLIMPEXP_BASE
int wxKill(long pid
,
387 wxSignal sig
= wxSIGTERM
,
388 wxKillError
*rc
= NULL
,
389 int flags
= wxKILL_NOCHILDREN
);
391 // Execute a command in an interactive shell window (always synchronously)
392 // If no command then just the shell
393 WXDLLIMPEXP_BASE
bool wxShell(const wxString
& command
= wxEmptyString
);
395 // As wxShell(), but must give a (non interactive) command and its output will
396 // be returned in output array
397 WXDLLIMPEXP_BASE
bool wxShell(const wxString
& command
, wxArrayString
& output
);
399 // Sleep for nSecs seconds
400 WXDLLIMPEXP_BASE
void wxSleep(int nSecs
);
402 // Sleep for a given amount of milliseconds
403 WXDLLIMPEXP_BASE
void wxMilliSleep(unsigned long milliseconds
);
405 // Sleep for a given amount of microseconds
406 WXDLLIMPEXP_BASE
void wxMicroSleep(unsigned long microseconds
);
408 #if WXWIN_COMPATIBILITY_2_8
409 // Sleep for a given amount of milliseconds (old, bad name), use wxMilliSleep
410 wxDEPRECATED( WXDLLIMPEXP_BASE
void wxUsleep(unsigned long milliseconds
) );
413 // Get the process id of the current process
414 WXDLLIMPEXP_BASE
unsigned long wxGetProcessId();
416 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
417 WXDLLIMPEXP_BASE wxMemorySize
wxGetFreeMemory();
419 #if wxUSE_ON_FATAL_EXCEPTION
421 // should wxApp::OnFatalException() be called?
422 WXDLLIMPEXP_BASE
bool wxHandleFatalExceptions(bool doit
= true);
424 #endif // wxUSE_ON_FATAL_EXCEPTION
426 // ----------------------------------------------------------------------------
427 // Environment variables
428 // ----------------------------------------------------------------------------
430 // returns true if variable exists (value may be NULL if you just want to check
432 WXDLLIMPEXP_BASE
bool wxGetEnv(const wxString
& var
, wxString
*value
);
434 // set the env var name to the given value, return true on success
435 WXDLLIMPEXP_BASE
bool wxSetEnv(const wxString
& var
, const wxString
& value
);
437 // remove the env var from environment
438 WXDLLIMPEXP_BASE
bool wxUnsetEnv(const wxString
& var
);
440 #if WXWIN_COMPATIBILITY_2_8
441 inline bool wxSetEnv(const wxString
& var
, const char *value
)
442 { return wxSetEnv(var
, wxString(value
)); }
443 inline bool wxSetEnv(const wxString
& var
, const wchar_t *value
)
444 { return wxSetEnv(var
, wxString(value
)); }
446 inline bool wxSetEnv(const wxString
& var
, const wxScopedCharTypeBuffer
<T
>& value
)
447 { return wxSetEnv(var
, wxString(value
)); }
448 inline bool wxSetEnv(const wxString
& var
, const wxCStrData
& value
)
449 { return wxSetEnv(var
, wxString(value
)); }
451 // this one is for passing NULL directly - don't use it, use wxUnsetEnv instead
452 wxDEPRECATED( inline bool wxSetEnv(const wxString
& var
, int value
) );
453 inline bool wxSetEnv(const wxString
& var
, int value
)
455 wxASSERT_MSG( value
== 0, "using non-NULL integer as string?" );
457 wxUnusedVar(value
); // fix unused parameter warning in release build
459 return wxUnsetEnv(var
);
461 #endif // WXWIN_COMPATIBILITY_2_8
463 // ----------------------------------------------------------------------------
464 // Network and username functions.
465 // ----------------------------------------------------------------------------
467 // NB: "char *" functions are deprecated, use wxString ones!
470 WXDLLIMPEXP_BASE
bool wxGetEmailAddress(wxChar
*buf
, int maxSize
);
471 WXDLLIMPEXP_BASE wxString
wxGetEmailAddress();
474 WXDLLIMPEXP_BASE
bool wxGetHostName(wxChar
*buf
, int maxSize
);
475 WXDLLIMPEXP_BASE wxString
wxGetHostName();
478 WXDLLIMPEXP_BASE wxString
wxGetFullHostName();
479 WXDLLIMPEXP_BASE
bool wxGetFullHostName(wxChar
*buf
, int maxSize
);
481 // Get user ID e.g. jacs (this is known as login name under Unix)
482 WXDLLIMPEXP_BASE
bool wxGetUserId(wxChar
*buf
, int maxSize
);
483 WXDLLIMPEXP_BASE wxString
wxGetUserId();
485 // Get user name e.g. Julian Smart
486 WXDLLIMPEXP_BASE
bool wxGetUserName(wxChar
*buf
, int maxSize
);
487 WXDLLIMPEXP_BASE wxString
wxGetUserName();
489 // Get current Home dir and copy to dest (returns pstr->c_str())
490 WXDLLIMPEXP_BASE wxString
wxGetHomeDir();
491 WXDLLIMPEXP_BASE
const wxChar
* wxGetHomeDir(wxString
*pstr
);
493 // Get the user's (by default use the current user name) home dir,
494 // return empty string on error
495 WXDLLIMPEXP_BASE wxString
wxGetUserHome(const wxString
& user
= wxEmptyString
);
499 typedef wxLongLong wxDiskspaceSize_t
;
501 typedef long wxDiskspaceSize_t
;
504 // get number of total/free bytes on the disk where path belongs
505 WXDLLIMPEXP_BASE
bool wxGetDiskSpace(const wxString
& path
,
506 wxDiskspaceSize_t
*pTotal
= NULL
,
507 wxDiskspaceSize_t
*pFree
= NULL
);
513 typedef int (wxCMPFUNC_CONV
*CMPFUNCDATA
)(const void* pItem1
, const void* pItem2
, const void* user_data
);
517 WXDLLIMPEXP_BASE
void wxQsort(void *const pbase
, size_t total_elems
,
518 size_t size
, CMPFUNCDATA cmp
, const void* user_data
);
521 #if wxUSE_GUI // GUI only things from now on
523 // ----------------------------------------------------------------------------
524 // Launch default browser
525 // ----------------------------------------------------------------------------
527 // flags for wxLaunchDefaultBrowser
530 wxBROWSER_NEW_WINDOW
= 0x01,
531 wxBROWSER_NOBUSYCURSOR
= 0x02
534 // Launch url in the user's default internet browser
535 WXDLLIMPEXP_CORE
bool wxLaunchDefaultBrowser(const wxString
& url
, int flags
= 0);
537 // Launch document in the user's default application
538 WXDLLIMPEXP_CORE
bool wxLaunchDefaultApplication(const wxString
& path
, int flags
= 0);
540 // ----------------------------------------------------------------------------
541 // Menu accelerators related things
542 // ----------------------------------------------------------------------------
544 // flags for wxStripMenuCodes
547 // strip '&' characters
548 wxStrip_Mnemonics
= 1,
550 // strip everything after '\t'
553 // strip everything (this is the default)
554 wxStrip_All
= wxStrip_Mnemonics
| wxStrip_Accel
557 // strip mnemonics and/or accelerators from the label
558 WXDLLIMPEXP_CORE wxString
559 wxStripMenuCodes(const wxString
& str
, int flags
= wxStrip_All
);
561 #if WXWIN_COMPATIBILITY_2_6
562 // obsolete and deprecated version, do not use, use the above overload instead
564 WXDLLIMPEXP_CORE wxChar
* wxStripMenuCodes(const wxChar
*in
, wxChar
*out
= NULL
)
568 class WXDLLIMPEXP_FWD_CORE wxAcceleratorEntry
;
570 // use wxAcceleratorEntry::Create() or FromString() methods instead
572 WXDLLIMPEXP_CORE wxAcceleratorEntry
*wxGetAccelFromString(const wxString
& label
)
574 #endif // wxUSE_ACCEL
576 #endif // WXWIN_COMPATIBILITY_2_6
578 // ----------------------------------------------------------------------------
580 // ----------------------------------------------------------------------------
582 // Returns menu item id or wxNOT_FOUND if none.
583 WXDLLIMPEXP_CORE
int wxFindMenuItemId(wxFrame
*frame
, const wxString
& menuString
, const wxString
& itemString
);
585 // Find the wxWindow at the given point. wxGenericFindWindowAtPoint
586 // is always present but may be less reliable than a native version.
587 WXDLLIMPEXP_CORE wxWindow
* wxGenericFindWindowAtPoint(const wxPoint
& pt
);
588 WXDLLIMPEXP_CORE wxWindow
* wxFindWindowAtPoint(const wxPoint
& pt
);
590 // NB: this function is obsolete, use wxWindow::FindWindowByLabel() instead
592 // Find the window/widget with the given title or label.
593 // Pass a parent to begin the search from, or NULL to look through
595 WXDLLIMPEXP_CORE wxWindow
* wxFindWindowByLabel(const wxString
& title
, wxWindow
*parent
= NULL
);
597 // NB: this function is obsolete, use wxWindow::FindWindowByName() instead
599 // Find window by name, and if that fails, by label.
600 WXDLLIMPEXP_CORE wxWindow
* wxFindWindowByName(const wxString
& name
, wxWindow
*parent
= NULL
);
602 // ----------------------------------------------------------------------------
603 // Message/event queue helpers
604 // ----------------------------------------------------------------------------
606 // Yield to other apps/messages and disable user input
607 WXDLLIMPEXP_CORE
bool wxSafeYield(wxWindow
*win
= NULL
, bool onlyIfNeeded
= false);
609 // Enable or disable input to all top level windows
610 WXDLLIMPEXP_CORE
void wxEnableTopLevelWindows(bool enable
= true);
612 // Check whether this window wants to process messages, e.g. Stop button
613 // in long calculations.
614 WXDLLIMPEXP_CORE
bool wxCheckForInterrupt(wxWindow
*wnd
);
616 // Consume all events until no more left
617 WXDLLIMPEXP_CORE
void wxFlushEvents();
619 // a class which disables all windows (except, may be, the given one) in its
620 // ctor and enables them back in its dtor
621 class WXDLLIMPEXP_CORE wxWindowDisabler
624 // this ctor conditionally disables all windows: if the argument is false,
625 // it doesn't do anything
626 wxWindowDisabler(bool disable
= true);
628 // ctor disables all windows except winToSkip
629 wxWindowDisabler(wxWindow
*winToSkip
);
631 // dtor enables back all windows disabled by the ctor
635 // disable all windows except the given one (used by both ctors)
636 void DoDisable(wxWindow
*winToSkip
= NULL
);
639 wxWindowList
*m_winDisabled
;
642 wxDECLARE_NO_COPY_CLASS(wxWindowDisabler
);
645 // ----------------------------------------------------------------------------
647 // ----------------------------------------------------------------------------
649 // Set the cursor to the busy cursor for all windows
650 WXDLLIMPEXP_CORE
void wxBeginBusyCursor(const wxCursor
*cursor
= wxHOURGLASS_CURSOR
);
652 // Restore cursor to normal
653 WXDLLIMPEXP_CORE
void wxEndBusyCursor();
655 // true if we're between the above two calls
656 WXDLLIMPEXP_CORE
bool wxIsBusy();
658 // Convenience class so we can just create a wxBusyCursor object on the stack
659 class WXDLLIMPEXP_CORE wxBusyCursor
662 wxBusyCursor(const wxCursor
* cursor
= wxHOURGLASS_CURSOR
)
663 { wxBeginBusyCursor(cursor
); }
665 { wxEndBusyCursor(); }
667 // FIXME: These two methods are currently only implemented (and needed?)
668 // in wxGTK. BusyCursor handling should probably be moved to
669 // common code since the wxGTK and wxMSW implementations are very
670 // similar except for wxMSW using HCURSOR directly instead of
672 static const wxCursor
&GetStoredCursor();
673 static const wxCursor
GetBusyCursor();
676 void WXDLLIMPEXP_CORE
wxGetMousePosition( int* x
, int* y
);
678 // ----------------------------------------------------------------------------
679 // X11 Display access
680 // ----------------------------------------------------------------------------
682 #if defined(__X__) || defined(__WXGTK__)
685 WXDLLIMPEXP_CORE
void *wxGetDisplay();
689 WXDLLIMPEXP_CORE WXDisplay
*wxGetDisplay();
690 WXDLLIMPEXP_CORE
bool wxSetDisplay(const wxString
& display_name
);
691 WXDLLIMPEXP_CORE wxString
wxGetDisplayName();
694 // use this function instead of the functions above in implementation code
695 inline struct _XDisplay
*wxGetX11Display()
697 return (_XDisplay
*)wxGetDisplay();
700 #endif // X11 || wxGTK
704 // ----------------------------------------------------------------------------
705 // wxYield(): these functions are obsolete, please use wxApp methods instead!
706 // ----------------------------------------------------------------------------
708 // avoid redeclaring this function here if it had been already declated by
709 // wx/app.h, this results in warnings from g++ with -Wredundant-decls
710 #ifndef wx_YIELD_DECLARED
711 #define wx_YIELD_DECLARED
713 // Yield to other apps/messages
714 WXDLLIMPEXP_CORE
bool wxYield();
716 #endif // wx_YIELD_DECLARED
718 // Like wxYield, but fails silently if the yield is recursive.
719 WXDLLIMPEXP_CORE
bool wxYieldIfNeeded();
721 // ----------------------------------------------------------------------------
722 // Windows resources access
723 // ----------------------------------------------------------------------------
725 // MSW only: get user-defined resource from the .res file.
727 // default resource type for wxLoadUserResource()
728 extern WXDLLIMPEXP_DATA_BASE(const wxChar
*) wxUserResourceStr
;
730 // Return the pointer to the resource data. This pointer is read-only, use
731 // the overload below if you need to modify the data.
733 // Returns true on success, false on failure. Doesn't log an error message
734 // if the resource is not found (because this could be expected) but does
735 // log one if any other error occurs.
736 WXDLLIMPEXP_BASE
bool
737 wxLoadUserResource(const void **outData
,
739 const wxString
& resourceName
,
740 const wxString
& resourceType
= wxUserResourceStr
,
741 WXHINSTANCE
module = 0);
743 // This function allocates a new buffer and makes a copy of the resource
744 // data, remember to delete[] the buffer. And avoid using it entirely if
745 // the overload above can be used.
747 // Returns NULL on failure.
748 WXDLLIMPEXP_BASE
char*
749 wxLoadUserResource(const wxString
& resourceName
,
750 const wxString
& resourceType
= wxUserResourceStr
,
752 WXHINSTANCE
module = 0);