X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4bfec1790f526d462f8f2ce107f8a83f725d9192..8120bbc9166a16f95c03d0ee50974117429be9e0:/include/wx/utils.h?ds=sidebyside diff --git a/include/wx/utils.h b/include/wx/utils.h index b84f78f44f..91863a219a 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -19,6 +19,9 @@ #include "wx/object.h" #include "wx/list.h" #include "wx/filefn.h" +#if wxUSE_GUI + #include "wx/gdicmn.h" +#endif class WXDLLIMPEXP_BASE wxArrayString; class WXDLLIMPEXP_BASE wxArrayInt; @@ -27,6 +30,9 @@ class WXDLLIMPEXP_BASE wxArrayInt; // wxLongLong #include "wx/longlong.h" +// need for wxOperatingSystemId +#include "wx/platinfo.h" + #ifdef __WATCOMC__ #include #elif defined(__X__) @@ -44,7 +50,6 @@ class WXDLLIMPEXP_CORE wxProcess; class WXDLLIMPEXP_CORE wxFrame; class WXDLLIMPEXP_CORE wxWindow; class WXDLLIMPEXP_CORE wxWindowList; -class WXDLLIMPEXP_CORE wxPoint; // ---------------------------------------------------------------------------- // Macros @@ -52,6 +57,7 @@ class WXDLLIMPEXP_CORE wxPoint; #define wxMax(a,b) (((a) > (b)) ? (a) : (b)) #define wxMin(a,b) (((a) < (b)) ? (a) : (b)) +#define wxClip(a,b,c) (((a) < (b)) ? (b) : (((a) > (c)) ? (c) : (a))) // wxGetFreeMemory can return huge amount of memory on 32-bit platforms as well // so to always use long long for its result type on all platforms which @@ -90,8 +96,14 @@ WXDLLIMPEXP_BASE void wxBell(); WXDLLIMPEXP_BASE wxString wxGetOsDescription(); // Get OS version -WXDLLIMPEXP_BASE int wxGetOsVersion(int *majorVsn = (int *) NULL, - int *minorVsn = (int *) NULL); +WXDLLIMPEXP_BASE wxOperatingSystemId wxGetOsVersion(int *majorVsn = (int *) NULL, + int *minorVsn = (int *) NULL); + +// Get platform endianness +WXDLLIMPEXP_BASE bool wxIsPlatformLittleEndian(); + +// Get platform architecture +WXDLLIMPEXP_BASE bool wxIsPlatform64Bit(); // Return a string with the current date/time WXDLLIMPEXP_BASE wxString wxNow(); @@ -126,12 +138,12 @@ public: wxPlatform(const wxPlatform& platform) { Copy(platform); } void operator = (const wxPlatform& platform) { Copy(platform); } void Copy(const wxPlatform& platform); - void Init() { m_longValue = 0; m_doubleValue = 0.0; } // Specify an optional default value - wxPlatform(long defValue) { m_longValue = defValue; m_doubleValue = 0.0; } - wxPlatform(const wxString& defValue) { m_stringValue = defValue; m_longValue = 0; m_doubleValue = 0.0; } - wxPlatform(double defValue) { m_longValue = 0; m_doubleValue = defValue; } + wxPlatform(int defValue) { Init(); m_longValue = (long)defValue; } + wxPlatform(long defValue) { Init(); m_longValue = defValue; } + wxPlatform(const wxString& defValue) { Init(); m_stringValue = defValue; } + wxPlatform(double defValue) { Init(); m_doubleValue = defValue; } static wxPlatform If(int platform, long value); static wxPlatform IfNot(int platform, long value); @@ -139,7 +151,7 @@ public: wxPlatform& ElseIfNot(int platform, long value); wxPlatform& Else(long value); - static wxPlatform If(int platform, int value); + static wxPlatform If(int platform, int value) { return If(platform, (long)value); } static wxPlatform IfNot(int platform, int value) { return IfNot(platform, (long)value); } wxPlatform& ElseIf(int platform, int value) { return ElseIf(platform, (long) value); } wxPlatform& ElseIfNot(int platform, int value) { return ElseIfNot(platform, (long) value); } @@ -172,6 +184,9 @@ public: static void ClearPlatforms(); private: + + void Init() { m_longValue = 0; m_doubleValue = 0.0; } + long m_longValue; double m_doubleValue; wxString m_stringValue; @@ -213,12 +228,12 @@ public: bool LeftDown() { return m_leftDown; } bool MiddleDown() { return m_middleDown; } bool RightDown() { return m_rightDown; } - + bool ControlDown() { return m_controlDown; } bool ShiftDown() { return m_shiftDown; } bool AltDown() { return m_altDown; } bool MetaDown() { return m_metaDown; } - bool CmdDown() + bool CmdDown() { #if defined(__WXMAC__) || defined(__WXCOCOA__) return MetaDown(); @@ -238,19 +253,19 @@ public: void SetShiftDown(bool down) { m_shiftDown = down; } void SetAltDown(bool down) { m_altDown = down; } void SetMetaDown(bool down) { m_metaDown = down; } - + private: wxCoord m_x; wxCoord m_y; - bool m_leftDown; - bool m_middleDown; - bool m_rightDown; + bool m_leftDown : 1; + bool m_middleDown : 1; + bool m_rightDown : 1; - bool m_controlDown; - bool m_shiftDown; - bool m_altDown; - bool m_metaDown; + bool m_controlDown : 1; + bool m_shiftDown : 1; + bool m_altDown : 1; + bool m_metaDown : 1; }; @@ -406,26 +421,6 @@ enum wxShutdownFlags // Shutdown or reboot the PC WXDLLIMPEXP_BASE bool wxShutdown(wxShutdownFlags wFlags); -enum wxPowerType -{ - wxPOWER_SOCKET, - wxPOWER_BATTERY, - wxPOWER_UNKNOWN -}; - -WXDLLIMPEXP_BASE wxPowerType wxGetPowerType(); - -enum wxBatteryState -{ - wxBATTERY_NORMAL_STATE, // system is fully usable - wxBATTERY_LOW_STATE, // start to worry - wxBATTERY_CRITICAL_STATE, // save quickly - wxBATTERY_SHUTDOWN_STATE, // too late - wxBATTERY_UNKNOWN_STATE -}; - -WXDLLIMPEXP_BASE wxBatteryState wxGetBatteryState(); - // send the given signal to the process (only NONE and KILL are supported under // Windows, all others mean TERM), return 0 if ok and -1 on error // @@ -523,7 +518,7 @@ WXDLLIMPEXP_BASE const wxChar* wxGetHomeDir(wxString *pstr); // Get the user's home dir (caller must copy --- volatile) // returns NULL is no HOME dir is known -#if defined(__UNIX__) && wxUSE_UNICODE +#if defined(__UNIX__) && wxUSE_UNICODE && !defined(__WINE__) WXDLLIMPEXP_BASE const wxMB2WXbuf wxGetUserHome(const wxString& user = wxEmptyString); #else WXDLLIMPEXP_BASE wxChar* wxGetUserHome(const wxString& user = wxEmptyString); @@ -546,14 +541,40 @@ WXDLLIMPEXP_BASE bool wxGetDiskSpace(const wxString& path, // Menu accelerators related things // ---------------------------------------------------------------------------- -WXDLLEXPORT wxChar* wxStripMenuCodes(const wxChar *in, wxChar *out = (wxChar *) NULL); -WXDLLEXPORT wxString wxStripMenuCodes(const wxString& str); +// flags for wxStripMenuCodes +enum +{ + // strip '&' characters + wxStrip_Mnemonics = 1, + + // strip everything after '\t' + wxStrip_Accel = 2, + + // strip everything (this is the default) + wxStrip_All = wxStrip_Mnemonics | wxStrip_Accel +}; + +// strip mnemonics and/or accelerators from the label +WXDLLEXPORT wxString +wxStripMenuCodes(const wxString& str, int flags = wxStrip_All); + +#if WXWIN_COMPATIBILITY_2_6 +// obsolete and deprecated version, do not use, use the above overload instead +wxDEPRECATED( + WXDLLEXPORT wxChar* wxStripMenuCodes(const wxChar *in, wxChar *out = NULL) +); #if wxUSE_ACCEL class WXDLLEXPORT wxAcceleratorEntry; -WXDLLEXPORT wxAcceleratorEntry *wxGetAccelFromString(const wxString& label); + +// use wxAcceleratorEntry::Create() or FromString() methods instead +wxDEPRECATED( + WXDLLEXPORT wxAcceleratorEntry *wxGetAccelFromString(const wxString& label) +); #endif // wxUSE_ACCEL +#endif // WXWIN_COMPATIBILITY_2_6 + // ---------------------------------------------------------------------------- // Window search // ---------------------------------------------------------------------------- @@ -614,9 +635,7 @@ private: // ---------------------------------------------------------------------------- // Set the cursor to the busy cursor for all windows -class WXDLLEXPORT wxCursor; -extern WXDLLEXPORT_DATA(wxCursor*) wxHOURGLASS_CURSOR; -WXDLLEXPORT void wxBeginBusyCursor(wxCursor *cursor = wxHOURGLASS_CURSOR); +WXDLLIMPEXP_CORE void wxBeginBusyCursor(const wxCursor *cursor = wxHOURGLASS_CURSOR); // Restore cursor to normal WXDLLEXPORT void wxEndBusyCursor(); @@ -628,7 +647,7 @@ WXDLLEXPORT bool wxIsBusy(); class WXDLLEXPORT wxBusyCursor { public: - wxBusyCursor(wxCursor* cursor = wxHOURGLASS_CURSOR) + wxBusyCursor(const wxCursor* cursor = wxHOURGLASS_CURSOR) { wxBeginBusyCursor(cursor); } ~wxBusyCursor() { wxEndBusyCursor(); }