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
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
put in given pointers the versions of the GTK library in use.
wxPORT_MAC = 1 << 7, // wxMac, using Carbon or Classic Mac API
wxPORT_COCOA = 1 << 8, // wxCocoa, using Cocoa NextStep/Mac 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}
\func{}{wxPlatformInfo}{}
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}}
+\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}
\func{static wxArchitecture}{GetArch}{\param{const wxString\& }{arch}}
\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}
\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}
\constfunc{int}{GetToolkitMajorVersion}{\void}
-Returns the 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.
+Returns the run-time major version of the toolkit associated with this wxPlatformInfo instance.
+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}
\constfunc{int}{GetToolkitMinorVersion}{\void}
-Returns the 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.
+Returns the run-time minor version of the toolkit associated with this wxPlatformInfo instance.
+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}
\helpref{CheckToolkitVersion}{wxplatforminfochecktoolkitversion}
virtual GSocketGUIFunctionsTable* GetSocketGUIFunctionsTable() = 0;
#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
// wxPORT_* values for GUI applications.
virtual wxPortId GetToolkitVersion(int *majVer, int *minVer) const = 0;
bool operator!=(const wxPlatformInfo &t) const
{ return !(*this == t); }
+ // Gets a wxPlatformInfo already initialized with the values for
+ // the currently running platform.
+ static const wxPlatformInfo& Get();
+
+
// string -> enum conversions
// ---------------------------------
return majorCur > major || (majorCur == major && minorCur >= minor);
}
+ void InitForCurrentPlatform();
+
+
// OS stuff
// -----------------
wxString suffix;
if ( cat == wxDL_PLUGIN_GUI )
{
- suffix = wxPlatformInfo().GetPortIdShortName();
+ suffix = wxPlatformInfo::Get().GetPortIdShortName();
}
#if wxUSE_UNICODE
suffix << _T('u');
// an error if this does not exist
if ( bOk )
{
- wxString port(wxPlatformInfo().GetPortIdName());
+ wxString port(wxPlatformInfo::Get().GetPortIdName());
if ( !port.empty() )
{
AddCatalog(port.BeforeFirst(wxT('/')).MakeLower());
#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
// ----------------------------------------------------------------------------
wxPlatformInfo::wxPlatformInfo()
{
- // 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;
+ // just copy platform info for currently running platform
+ *this = Get();
}
wxPlatformInfo::wxPlatformInfo(wxPortId pid, int tkMajor, int tkMinor,
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
// ----------------------------------------------------------------------------
// don't translate these strings, they're for diagnostics purposes only
wxString msg;
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"),
- wxPlatformInfo().GetPortIdName().c_str(),
+ wxPlatformInfo::Get().GetPortIdName().c_str(),
wxMAJOR_VERSION,
wxMINOR_VERSION,
wxRELEASE_NUMBER,
#endif
__TDATE__,
__TTIME__,
+ wxPlatformInfo::Get().GetToolkitMajorVersion(),
+ wxPlatformInfo::Get().GetToolkitMinorVersion(),
#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
wxEmptyString
#endif