added static wxPlatformInfo::Get() and use it (patch 1549176)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41807 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -83,6 +83,8 @@ It's normally the same for wxBase and wxGUI except in the case of wxMac and wxCo
|
|||||||
Returns the wxWidgets port ID used by the running program and eventually
|
Returns the wxWidgets port ID used by the running program and eventually
|
||||||
fills the given pointers with the values of the major and minor digits
|
fills the given pointers with the values of the major and minor digits
|
||||||
of the native toolkit currently used.
|
of the native toolkit currently used.
|
||||||
|
The version numbers returned are thus detected at run-time and not compile-time
|
||||||
|
(except when this is not possible e.g. wxMotif).
|
||||||
|
|
||||||
E.g. if your program is using wxGTK port this function will return wxPORT\_GTK and
|
E.g. if your program is using wxGTK port this function will return wxPORT\_GTK and
|
||||||
put in given pointers the versions of the GTK library in use.
|
put in given pointers the versions of the GTK library in use.
|
||||||
|
@@ -92,7 +92,8 @@ enum wxPortId
|
|||||||
wxPORT_MAC = 1 << 7, // wxMac, using Carbon or Classic Mac API
|
wxPORT_MAC = 1 << 7, // wxMac, using Carbon or Classic Mac API
|
||||||
wxPORT_COCOA = 1 << 8, // wxCocoa, using Cocoa NextStep/Mac API
|
wxPORT_COCOA = 1 << 8, // wxCocoa, using Cocoa NextStep/Mac API
|
||||||
wxPORT_WINCE = 1 << 9, // wxWinCE, toolkit is WinCE SDK API
|
wxPORT_WINCE = 1 << 9, // wxWinCE, toolkit is WinCE SDK API
|
||||||
wxPORT_PALMOS = 1 << 10 // wxPalmOS, toolkit is PalmOS API
|
wxPORT_PALMOS = 1 << 10, // wxPalmOS, toolkit is PalmOS API
|
||||||
|
wxPORT_DFB = 1 << 11 // wxDFB, using wxUniversal
|
||||||
};
|
};
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
@@ -135,6 +136,8 @@ enum wxEndianness
|
|||||||
\func{}{wxPlatformInfo}{}
|
\func{}{wxPlatformInfo}{}
|
||||||
|
|
||||||
Initializes the instance with the values corresponding to the currently running platform.
|
Initializes the instance with the values corresponding to the currently running platform.
|
||||||
|
This is a fast operation because it only requires to copy the values internally cached for the
|
||||||
|
currently running platform (see also \helpref{Get}{wxplatforminfoget}).
|
||||||
|
|
||||||
\func{}{wxPlatformInfo}{\param{wxPortId }{pid = wxPORT\_UNKNOWN}, \param{int }{tkMajor = -1}, \param{int }{tkMinor = -1}, \param{wxOperatingSystemId }{id = wxOS\_UNKNOWN}, \param{int }{osMajor = -1}, \param{int }{osMinor = -1}, \param{wxArchitecture }{arch = wxARCH\_INVALID}, \param{wxEndianness }{endian = wxENDIAN\_INVALID}}
|
\func{}{wxPlatformInfo}{\param{wxPortId }{pid = wxPORT\_UNKNOWN}, \param{int }{tkMajor = -1}, \param{int }{tkMinor = -1}, \param{wxOperatingSystemId }{id = wxOS\_UNKNOWN}, \param{int }{osMajor = -1}, \param{int }{osMinor = -1}, \param{wxArchitecture }{arch = wxARCH\_INVALID}, \param{wxEndianness }{endian = wxENDIAN\_INVALID}}
|
||||||
|
|
||||||
@@ -169,6 +172,13 @@ Returns \true if the toolkit version is at least \texttt{major.minor}.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxPlatformInfo::Get}\label{wxplatforminfoget}
|
||||||
|
|
||||||
|
\func{static const wxPlatformInfo\& }{Get}{\void}
|
||||||
|
|
||||||
|
Returns the global wxPlatformInfo object, initialized with the values for the currently running platform.
|
||||||
|
|
||||||
|
|
||||||
\membersection{wxPlatformInfo::GetArch}\label{wxplatforminfogetarch}
|
\membersection{wxPlatformInfo::GetArch}\label{wxplatforminfogetarch}
|
||||||
|
|
||||||
\func{static wxArchitecture}{GetArch}{\param{const wxString\& }{arch}}
|
\func{static wxArchitecture}{GetArch}{\param{const wxString\& }{arch}}
|
||||||
@@ -228,7 +238,8 @@ Returns the name for the endianness of this wxPlatformInfo instance.
|
|||||||
|
|
||||||
\constfunc{int}{GetOSMajorVersion}{\void}
|
\constfunc{int}{GetOSMajorVersion}{\void}
|
||||||
|
|
||||||
Returns the major version of the OS associated with this wxPlatformInfo instance.
|
Returns the run-time major version of the OS associated with this wxPlatformInfo instance.
|
||||||
|
See \helpref{wxGetOsVersion}{wxgetosversion} for more info.
|
||||||
|
|
||||||
\wxheading{See also}
|
\wxheading{See also}
|
||||||
|
|
||||||
@@ -239,7 +250,10 @@ Returns the major version of the OS associated with this wxPlatformInfo instance
|
|||||||
|
|
||||||
\constfunc{int}{GetOSMinorVersion}{\void}
|
\constfunc{int}{GetOSMinorVersion}{\void}
|
||||||
|
|
||||||
Returns the minor version of the OS associated with this wxPlatformInfo instance.
|
Returns the run-time minor version of the OS associated with this wxPlatformInfo instance.
|
||||||
|
See \helpref{wxGetOsVersion}{wxgetosversion} for more info.
|
||||||
|
|
||||||
|
\wxheading{See also}
|
||||||
|
|
||||||
\helpref{CheckOSVersion}{wxplatforminfocheckosversion}
|
\helpref{CheckOSVersion}{wxplatforminfocheckosversion}
|
||||||
|
|
||||||
@@ -340,8 +354,11 @@ Returns the short name of the wxWidgets port ID associated with this wxPlatformI
|
|||||||
|
|
||||||
\constfunc{int}{GetToolkitMajorVersion}{\void}
|
\constfunc{int}{GetToolkitMajorVersion}{\void}
|
||||||
|
|
||||||
Returns the major version of the toolkit associated with this wxPlatformInfo instance.
|
Returns the run-time major version of the toolkit associated with this wxPlatformInfo instance.
|
||||||
Note that if {GetPortId}{wxplatforminfogetportid} returns wxPORT\_BASE, then this value is zero (unless externally modified with SetToolkitVersion); that is, no native toolkit is in use.
|
Note that if \helpref{GetPortId}{wxplatforminfogetportid} returns wxPORT\_BASE, then this value is zero (unless externally modified with \helpref{SetToolkitVersion}{wxplatforminfosettoolkitversion}); that is, no native toolkit is in use.
|
||||||
|
|
||||||
|
See \helpref{wxAppTraits::GetToolkitVersion}{wxapptraitsgettoolkitversion} for more info.
|
||||||
|
|
||||||
|
|
||||||
\wxheading{See also}
|
\wxheading{See also}
|
||||||
|
|
||||||
@@ -352,9 +369,10 @@ Note that if {GetPortId}{wxplatforminfogetportid} returns wxPORT\_BASE, then thi
|
|||||||
|
|
||||||
\constfunc{int}{GetToolkitMinorVersion}{\void}
|
\constfunc{int}{GetToolkitMinorVersion}{\void}
|
||||||
|
|
||||||
Returns the minor version of the toolkit associated with this wxPlatformInfo instance.
|
Returns the run-time minor version of the toolkit associated with this wxPlatformInfo instance.
|
||||||
Note that if {GetPortId}{wxplatforminfogetportid} returns wxPORT\_BASE, then this value is zero (unless externally modified with SetToolkitVersion); that is, no native toolkit is in use.
|
Note that if \helpref{GetPortId}{wxplatforminfogetportid} returns wxPORT\_BASE, then this value is zero (unless externally modified with \helpref{SetToolkitVersion}{wxplatforminfosettoolkitversion}); that is, no native toolkit is in use.
|
||||||
|
|
||||||
|
See \helpref{wxAppTraits::GetToolkitVersion}{wxapptraitsgettoolkitversion} for more info.
|
||||||
\wxheading{See also}
|
\wxheading{See also}
|
||||||
|
|
||||||
\helpref{CheckToolkitVersion}{wxplatforminfochecktoolkitversion}
|
\helpref{CheckToolkitVersion}{wxplatforminfochecktoolkitversion}
|
||||||
|
@@ -110,7 +110,8 @@ public:
|
|||||||
virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable() = 0;
|
virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable() = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// return information about the (native) toolkit currently used;
|
// return information about the (native) toolkit currently used and its
|
||||||
|
// runtime (not compile-time) version.
|
||||||
// returns wxPORT_BASE for console applications and one of the remaining
|
// returns wxPORT_BASE for console applications and one of the remaining
|
||||||
// wxPORT_* values for GUI applications.
|
// wxPORT_* values for GUI applications.
|
||||||
virtual wxPortId GetToolkitVersion(int *majVer, int *minVer) const = 0;
|
virtual wxPortId GetToolkitVersion(int *majVer, int *minVer) const = 0;
|
||||||
|
@@ -130,6 +130,11 @@ public:
|
|||||||
bool operator!=(const wxPlatformInfo &t) const
|
bool operator!=(const wxPlatformInfo &t) const
|
||||||
{ return !(*this == t); }
|
{ return !(*this == t); }
|
||||||
|
|
||||||
|
// Gets a wxPlatformInfo already initialized with the values for
|
||||||
|
// the currently running platform.
|
||||||
|
static const wxPlatformInfo& Get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// string -> enum conversions
|
// string -> enum conversions
|
||||||
// ---------------------------------
|
// ---------------------------------
|
||||||
@@ -246,6 +251,9 @@ protected:
|
|||||||
return majorCur > major || (majorCur == major && minorCur >= minor);
|
return majorCur > major || (majorCur == major && minorCur >= minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InitForCurrentPlatform();
|
||||||
|
|
||||||
|
|
||||||
// OS stuff
|
// OS stuff
|
||||||
// -----------------
|
// -----------------
|
||||||
|
|
||||||
|
@@ -247,7 +247,7 @@ wxString wxDynamicLibrary::CanonicalizePluginName(const wxString& name,
|
|||||||
wxString suffix;
|
wxString suffix;
|
||||||
if ( cat == wxDL_PLUGIN_GUI )
|
if ( cat == wxDL_PLUGIN_GUI )
|
||||||
{
|
{
|
||||||
suffix = wxPlatformInfo().GetPortIdShortName();
|
suffix = wxPlatformInfo::Get().GetPortIdShortName();
|
||||||
}
|
}
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
suffix << _T('u');
|
suffix << _T('u');
|
||||||
|
@@ -1591,7 +1591,7 @@ bool wxLocale::Init(const wxChar *szName,
|
|||||||
// an error if this does not exist
|
// an error if this does not exist
|
||||||
if ( bOk )
|
if ( bOk )
|
||||||
{
|
{
|
||||||
wxString port(wxPlatformInfo().GetPortIdName());
|
wxString port(wxPlatformInfo::Get().GetPortIdName());
|
||||||
if ( !port.empty() )
|
if ( !port.empty() )
|
||||||
{
|
{
|
||||||
AddCatalog(port.BeforeFirst(wxT('/')).MakeLower());
|
AddCatalog(port.BeforeFirst(wxT('/')).MakeLower());
|
||||||
|
@@ -33,6 +33,12 @@
|
|||||||
|
|
||||||
#include "wx/apptrait.h"
|
#include "wx/apptrait.h"
|
||||||
|
|
||||||
|
// global object
|
||||||
|
// VERY IMPORTANT: do not use the default constructor since it would
|
||||||
|
// try to init the wxPlatformInfo instance using
|
||||||
|
// gs_platInfo itself!
|
||||||
|
static wxPlatformInfo gs_platInfo(wxPORT_UNKNOWN);
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// constants
|
// constants
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -117,26 +123,8 @@ static unsigned wxGetIndexFromEnumValue(int value)
|
|||||||
|
|
||||||
wxPlatformInfo::wxPlatformInfo()
|
wxPlatformInfo::wxPlatformInfo()
|
||||||
{
|
{
|
||||||
// autodetect all informations
|
// just copy platform info for currently running platform
|
||||||
const wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
*this = Get();
|
||||||
if ( !traits )
|
|
||||||
{
|
|
||||||
wxFAIL_MSG( _T("failed to initialize wxPlatformInfo") );
|
|
||||||
|
|
||||||
m_port = wxPORT_UNKNOWN;
|
|
||||||
m_usingUniversal = false;
|
|
||||||
m_tkVersionMajor =
|
|
||||||
m_tkVersionMinor = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_port = traits->GetToolkitVersion(&m_tkVersionMajor, &m_tkVersionMinor);
|
|
||||||
m_usingUniversal = traits->IsUsingUniversalWidgets();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_os = wxGetOsVersion(&m_osVersionMajor, &m_osVersionMinor);
|
|
||||||
m_endian = wxIsPlatformLittleEndian() ? wxENDIAN_LITTLE : wxENDIAN_BIG;
|
|
||||||
m_arch = wxIsPlatform64Bit() ? wxARCH_64 : wxARCH_32;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPlatformInfo::wxPlatformInfo(wxPortId pid, int tkMajor, int tkMinor,
|
wxPlatformInfo::wxPlatformInfo(wxPortId pid, int tkMajor, int tkMinor,
|
||||||
@@ -171,6 +159,45 @@ bool wxPlatformInfo::operator==(const wxPlatformInfo &t) const
|
|||||||
m_endian == t.m_endian;
|
m_endian == t.m_endian;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxPlatformInfo::InitForCurrentPlatform()
|
||||||
|
{
|
||||||
|
// autodetect all informations
|
||||||
|
const wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
||||||
|
if ( !traits )
|
||||||
|
{
|
||||||
|
wxFAIL_MSG( _T("failed to initialize wxPlatformInfo") );
|
||||||
|
|
||||||
|
m_port = wxPORT_UNKNOWN;
|
||||||
|
m_usingUniversal = false;
|
||||||
|
m_tkVersionMajor =
|
||||||
|
m_tkVersionMinor = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_port = traits->GetToolkitVersion(&m_tkVersionMajor, &m_tkVersionMinor);
|
||||||
|
m_usingUniversal = traits->IsUsingUniversalWidgets();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_os = wxGetOsVersion(&m_osVersionMajor, &m_osVersionMinor);
|
||||||
|
m_endian = wxIsPlatformLittleEndian() ? wxENDIAN_LITTLE : wxENDIAN_BIG;
|
||||||
|
m_arch = wxIsPlatform64Bit() ? wxARCH_64 : wxARCH_32;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* static */
|
||||||
|
const wxPlatformInfo& wxPlatformInfo::Get()
|
||||||
|
{
|
||||||
|
static bool initialized = false;
|
||||||
|
if ( !initialized )
|
||||||
|
{
|
||||||
|
gs_platInfo.InitForCurrentPlatform();
|
||||||
|
initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return gs_platInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxPlatformInfo - enum -> string conversions
|
// wxPlatformInfo - enum -> string conversions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -2199,9 +2199,10 @@ void wxWindowBase::OnMiddleClick( wxMouseEvent& event )
|
|||||||
// don't translate these strings, they're for diagnostics purposes only
|
// don't translate these strings, they're for diagnostics purposes only
|
||||||
wxString msg;
|
wxString msg;
|
||||||
msg.Printf(_T("wxWidgets Library (%s port)\n")
|
msg.Printf(_T("wxWidgets Library (%s port)\n")
|
||||||
_T("Version %d.%d.%d%s%s, compiled at %s %s%s\n")
|
_T("Version %d.%d.%d%s%s, compiled at %s %s\n")
|
||||||
|
_T("Runtime version of toolkit used is %d.%d.%s\n")
|
||||||
_T("Copyright (c) 1995-2006 wxWidgets team"),
|
_T("Copyright (c) 1995-2006 wxWidgets team"),
|
||||||
wxPlatformInfo().GetPortIdName().c_str(),
|
wxPlatformInfo::Get().GetPortIdName().c_str(),
|
||||||
wxMAJOR_VERSION,
|
wxMAJOR_VERSION,
|
||||||
wxMINOR_VERSION,
|
wxMINOR_VERSION,
|
||||||
wxRELEASE_NUMBER,
|
wxRELEASE_NUMBER,
|
||||||
@@ -2217,8 +2218,10 @@ void wxWindowBase::OnMiddleClick( wxMouseEvent& event )
|
|||||||
#endif
|
#endif
|
||||||
__TDATE__,
|
__TDATE__,
|
||||||
__TTIME__,
|
__TTIME__,
|
||||||
|
wxPlatformInfo::Get().GetToolkitMajorVersion(),
|
||||||
|
wxPlatformInfo::Get().GetToolkitMinorVersion(),
|
||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK__
|
||||||
wxString::Format(_T("\nagainst GTK+ %d.%d.%d. Runtime GTK+ version: %d.%d.%d"), GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION, gtk_major_version, gtk_minor_version, gtk_micro_version).c_str()
|
wxString::Format(_T("\nThe compile-time GTK+ version is %d.%d.%d."), GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION).c_str()
|
||||||
#else
|
#else
|
||||||
wxEmptyString
|
wxEmptyString
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user