wxPlatformInfo (patch 1532064)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40599 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
|
||||
#include "wx/filefn.h"
|
||||
#include "wx/filename.h" // for SplitPath()
|
||||
#include "wx/apptrait.h"
|
||||
#include "wx/platinfo.h"
|
||||
|
||||
#include "wx/arrimpl.cpp"
|
||||
|
||||
@@ -247,11 +247,7 @@ wxString wxDynamicLibrary::CanonicalizePluginName(const wxString& name,
|
||||
wxString suffix;
|
||||
if ( cat == wxDL_PLUGIN_GUI )
|
||||
{
|
||||
wxAppTraits *traits = wxAppConsole::GetInstance() ?
|
||||
wxAppConsole::GetInstance()->GetTraits() : NULL;
|
||||
wxCHECK_MSG( traits, wxEmptyString,
|
||||
_("can't query for GUI plugins name in console applications") );
|
||||
suffix = traits->GetToolkitInfo().shortName;
|
||||
suffix = wxPlatformInfo().GetPortIdShortName();
|
||||
}
|
||||
#if wxUSE_UNICODE
|
||||
suffix << _T('u');
|
||||
|
||||
@@ -1583,11 +1583,13 @@ bool wxLocale::Init(const wxChar *szName,
|
||||
|
||||
// there may be a catalog with toolkit specific overrides, it is not
|
||||
// an error if this does not exist
|
||||
if ( bOk && wxTheApp )
|
||||
if ( bOk )
|
||||
{
|
||||
wxAppTraits *traits = wxTheApp->GetTraits();
|
||||
if (traits)
|
||||
AddCatalog(traits->GetToolkitInfo().name.BeforeFirst(wxT('/')).MakeLower());
|
||||
wxString port(wxPlatformInfo().GetPortIdName());
|
||||
if ( !port.empty() )
|
||||
{
|
||||
AddCatalog(port.BeforeFirst(wxT('/')).MakeLower());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
297
src/common/platinfo.cpp
Normal file
297
src/common/platinfo.cpp
Normal file
@@ -0,0 +1,297 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/common/platinfo.cpp
|
||||
// Purpose: implements wxPlatformInfo class
|
||||
// Author: Francesco Montorsi
|
||||
// Modified by:
|
||||
// Created: 07.07.2006 (based on wxToolkitInfo)
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2006 Francesco Montorsi
|
||||
// License: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// for compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/utils.h"
|
||||
#endif //WX_PRECOMP
|
||||
|
||||
#include "wx/platinfo.h"
|
||||
#include "wx/apptrait.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static wxString wxOperatingSystemIdNames[] =
|
||||
{
|
||||
_T("Apple Mac OS"),
|
||||
_T("Apple Mac OS X"),
|
||||
|
||||
_T("Microsoft Windows 9X"),
|
||||
_T("Microsoft Windows NT"),
|
||||
_T("Microsoft Windows Micro"),
|
||||
_T("Microsoft Windows CE"),
|
||||
|
||||
_T("Linux"),
|
||||
_T("FreeBSD"),
|
||||
_T("OpenBSD"),
|
||||
_T("NetBSD"),
|
||||
|
||||
_T("SunOS"),
|
||||
_T("AIX"),
|
||||
_T("HPUX"),
|
||||
|
||||
_T("DOS"),
|
||||
_T("OS/2")
|
||||
};
|
||||
|
||||
static wxString wxPortIdNames[] =
|
||||
{
|
||||
_T("wxBase"),
|
||||
_T("wxMSW"),
|
||||
_T("wxMotif"),
|
||||
_T("wxGTK"),
|
||||
_T("wxMGL"),
|
||||
_T("wxX11"),
|
||||
_T("wxOS2"),
|
||||
_T("wxMac"),
|
||||
_T("wxCocoa"),
|
||||
_T("wxWinCE"),
|
||||
_T("wxPalmOS")
|
||||
};
|
||||
|
||||
static wxString wxArchitectureNames[] =
|
||||
{
|
||||
_T("32 bit"),
|
||||
_T("64 bit")
|
||||
};
|
||||
|
||||
static wxString wxEndiannessNames[] =
|
||||
{
|
||||
_T("Big endian"),
|
||||
_T("Little endian"),
|
||||
_T("PDP endian")
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// local functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// returns log in base 2 of the value, this maps the enum values to the
|
||||
// corresponding indices
|
||||
static int wxGetIndexFromEnumValue(int value)
|
||||
{
|
||||
wxCHECK_MSG( value, -1, _T("invalid enum value") );
|
||||
|
||||
int n = 0;
|
||||
while ( !(value & 1) )
|
||||
{
|
||||
value >>= 1;
|
||||
n++;
|
||||
}
|
||||
|
||||
wxASSERT_MSG( value == 1, _T("more than one bit set in enum value") );
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxPlatformInfo
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
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_tkVersionMajor =
|
||||
m_tkVersionMinor = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_port = traits->GetToolkitVersion(&m_tkVersionMajor, &m_tkVersionMinor);
|
||||
}
|
||||
|
||||
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,
|
||||
wxOperatingSystemId id, int osMajor, int osMinor,
|
||||
wxArchitecture arch,
|
||||
wxEndianness endian)
|
||||
{
|
||||
m_tkVersionMajor = tkMajor;
|
||||
m_tkVersionMinor = tkMinor;
|
||||
m_port = pid;
|
||||
|
||||
m_os = id;
|
||||
m_osVersionMajor = osMajor;
|
||||
m_osVersionMinor = osMinor;
|
||||
|
||||
m_endian = endian;
|
||||
m_arch = arch;
|
||||
}
|
||||
|
||||
bool wxPlatformInfo::operator==(const wxPlatformInfo &t) const
|
||||
{
|
||||
return m_tkVersionMajor == t.m_tkVersionMajor &&
|
||||
m_tkVersionMinor == t.m_tkVersionMinor &&
|
||||
m_osVersionMajor == t.m_osVersionMajor &&
|
||||
m_osVersionMinor == t.m_osVersionMinor &&
|
||||
m_os == t.m_os &&
|
||||
m_port == t.m_port &&
|
||||
m_arch == t.m_arch &&
|
||||
m_endian == t.m_endian;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxPlatformInfo - enum -> string conversions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxString wxPlatformInfo::GetOperatingSystemFamilyName(wxOperatingSystemId os)
|
||||
{
|
||||
if ( os & wxOS_MAC )
|
||||
return _T("Macintosh");
|
||||
else if ( os & wxOS_WINDOWS )
|
||||
return _T("Windows");
|
||||
else if ( os & wxOS_UNIX )
|
||||
return _T("Unix");
|
||||
else if ( os == wxOS_DOS )
|
||||
return _T("DOS");
|
||||
else if ( os == wxOS_OS2 )
|
||||
return _T("OS/2");
|
||||
|
||||
return _T("Unknown");
|
||||
}
|
||||
|
||||
wxString wxPlatformInfo::GetOperatingSystemIdName(wxOperatingSystemId os)
|
||||
{
|
||||
const int idx = wxGetIndexFromEnumValue(os);
|
||||
|
||||
wxCHECK_MSG( idx < WXSIZEOF(wxOperatingSystemIdNames), wxEmptyString,
|
||||
_T("invalid OS id") );
|
||||
|
||||
return wxOperatingSystemIdNames[idx];
|
||||
}
|
||||
|
||||
wxString wxPlatformInfo::GetPortIdName(wxPortId port)
|
||||
{
|
||||
const int idx = wxGetIndexFromEnumValue(port);
|
||||
|
||||
wxCHECK_MSG( idx < WXSIZEOF(wxPortIdNames), wxEmptyString,
|
||||
_T("invalid port id") );
|
||||
|
||||
wxString ret = wxPortIdNames[idx];
|
||||
|
||||
if ( IsUsingUniversalWidgets() )
|
||||
ret += wxT("/wxUniversal");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
wxString wxPlatformInfo::GetPortIdShortName(wxPortId port)
|
||||
{
|
||||
const int idx = wxGetIndexFromEnumValue(port);
|
||||
|
||||
wxCHECK_MSG( idx < WXSIZEOF(wxPortIdNames), wxEmptyString,
|
||||
_T("invalid port id") );
|
||||
|
||||
wxString ret = wxPortIdNames[idx];
|
||||
ret = ret.Mid(2).Lower(); // remove 'wx' prefix
|
||||
|
||||
if ( IsUsingUniversalWidgets() )
|
||||
ret += wxT("univ");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
wxString wxPlatformInfo::GetArchName(wxArchitecture arch)
|
||||
{
|
||||
wxCOMPILE_TIME_ASSERT( WXSIZEOF(wxArchitectureNames) == wxARCH_MAX,
|
||||
wxArchitectureNamesMismatch );
|
||||
|
||||
return wxArchitectureNames[arch];
|
||||
}
|
||||
|
||||
wxString wxPlatformInfo::GetEndiannessName(wxEndianness end)
|
||||
{
|
||||
wxCOMPILE_TIME_ASSERT( WXSIZEOF(wxEndiannessNames) == wxENDIAN_MAX,
|
||||
wxEndiannessNamesMismatch );
|
||||
|
||||
return wxEndiannessNames[end];
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxPlatformInfo - string -> enum conversions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxOperatingSystemId wxPlatformInfo::GetOperatingSystemId(const wxString &str)
|
||||
{
|
||||
for ( size_t i = 0; i < WXSIZEOF(wxOperatingSystemIdNames); i++ )
|
||||
{
|
||||
if ( wxOperatingSystemIdNames[i].CmpNoCase(str) == 0 )
|
||||
return (wxOperatingSystemId)(1 << i);
|
||||
}
|
||||
|
||||
return wxOS_UNKNOWN;
|
||||
}
|
||||
|
||||
wxPortId wxPlatformInfo::GetPortId(const wxString &str)
|
||||
{
|
||||
// recognize both short and long port names
|
||||
for ( size_t i = 0; i < WXSIZEOF(wxPortIdNames); i++ )
|
||||
{
|
||||
wxPortId current = (wxPortId)(1 << i);
|
||||
|
||||
if ( wxPortIdNames[i].CmpNoCase(str) == 0 )
|
||||
return current;
|
||||
if ( GetPortIdShortName(current).CmpNoCase(str) == 0 )
|
||||
return current;
|
||||
}
|
||||
|
||||
return wxPORT_UNKNOWN;
|
||||
}
|
||||
|
||||
wxArchitecture wxPlatformInfo::GetArch(const wxString &arch)
|
||||
{
|
||||
if ( arch.Contains(wxT("32")) )
|
||||
return wxARCH_32;
|
||||
|
||||
if ( arch.Contains(wxT("64")) )
|
||||
return wxARCH_64;
|
||||
|
||||
return wxARCH_INVALID;
|
||||
}
|
||||
|
||||
wxEndianness wxPlatformInfo::GetEndianness(const wxString& end)
|
||||
{
|
||||
wxString endl(end.Lower());
|
||||
if ( end.StartsWith(wxT("little")) )
|
||||
return wxENDIAN_LITTLE;
|
||||
|
||||
if ( end.StartsWith(wxT("big")) )
|
||||
return wxENDIAN_BIG;
|
||||
|
||||
return wxENDIAN_INVALID;
|
||||
}
|
||||
|
||||
@@ -287,22 +287,20 @@ wxString wxGetDataDir()
|
||||
return dir;
|
||||
}
|
||||
|
||||
int wxGetOsVersion(int *verMaj, int *verMin)
|
||||
bool wxIsPlatformLittleEndian()
|
||||
{
|
||||
// we want this function to work even if there is no wxApp
|
||||
wxConsoleAppTraits traitsConsole;
|
||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
||||
if ( ! traits )
|
||||
traits = &traitsConsole;
|
||||
// Are we little or big endian? This method is from Harbison & Steele.
|
||||
union
|
||||
{
|
||||
long l;
|
||||
char c[sizeof(long)];
|
||||
} u;
|
||||
u.l = 1;
|
||||
|
||||
wxToolkitInfo& info = traits->GetToolkitInfo();
|
||||
if ( verMaj )
|
||||
*verMaj = info.versionMajor;
|
||||
if ( verMin )
|
||||
*verMin = info.versionMinor;
|
||||
return info.os;
|
||||
return u.c[0] == 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class to make it easier to specify platform-dependent values
|
||||
*/
|
||||
|
||||
@@ -83,6 +83,8 @@
|
||||
extern const unsigned int gtk_micro_version;
|
||||
#endif
|
||||
|
||||
#include "wx/platinfo.h"
|
||||
|
||||
// Windows List
|
||||
WXDLLIMPEXP_DATA_CORE(wxWindowList) wxTopLevelWindows;
|
||||
|
||||
@@ -2164,69 +2166,35 @@ void wxWindowBase::OnMiddleClick( wxMouseEvent& event )
|
||||
#endif // __WXDEBUG__
|
||||
|
||||
#if wxUSE_MSGDLG
|
||||
// don't translate these strings
|
||||
wxString port;
|
||||
|
||||
#ifdef __WXUNIVERSAL__
|
||||
port = _T("Univ/");
|
||||
#endif // __WXUNIVERSAL__
|
||||
|
||||
switch ( wxGetOsVersion() )
|
||||
{
|
||||
case wxMOTIF_X: port += _T("Motif"); break;
|
||||
case wxMAC:
|
||||
case wxMAC_DARWIN: port += _T("Mac"); break;
|
||||
case wxBEOS: port += _T("BeOS"); break;
|
||||
case wxGTK:
|
||||
case wxGTK_WIN32:
|
||||
case wxGTK_OS2:
|
||||
case wxGTK_BEOS: port += _T("GTK"); break;
|
||||
case wxWINDOWS:
|
||||
case wxPENWINDOWS:
|
||||
case wxWINDOWS_NT:
|
||||
case wxWIN32S:
|
||||
case wxWIN95:
|
||||
case wxWIN386: port += _T("MS Windows"); break;
|
||||
case wxMGL_UNIX:
|
||||
case wxMGL_X:
|
||||
case wxMGL_WIN32:
|
||||
case wxMGL_OS2: port += _T("MGL"); break;
|
||||
case wxWINDOWS_OS2:
|
||||
case wxOS2_PM: port += _T("OS/2"); break;
|
||||
case wxPALMOS: port += _T("Palm OS"); break;
|
||||
case wxWINDOWS_CE: port += _T("Windows CE (generic)"); break;
|
||||
case wxWINDOWS_POCKETPC: port += _T("Windows CE PocketPC"); break;
|
||||
case wxWINDOWS_SMARTPHONE: port += _T("Windows CE Smartphone"); break;
|
||||
default: port += _T("unknown"); break;
|
||||
}
|
||||
|
||||
wxMessageBox(wxString::Format(
|
||||
_T(
|
||||
" wxWidgets Library (%s port)\nVersion %d.%d.%d%s%s, compiled at %s %s%s\n Copyright (c) 1995-2006 wxWidgets team"
|
||||
),
|
||||
port.c_str(),
|
||||
wxMAJOR_VERSION,
|
||||
wxMINOR_VERSION,
|
||||
wxRELEASE_NUMBER,
|
||||
// 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("Copyright (c) 1995-2006 wxWidgets team"),
|
||||
wxPlatformInfo().GetPortIdName().c_str(),
|
||||
wxMAJOR_VERSION,
|
||||
wxMINOR_VERSION,
|
||||
wxRELEASE_NUMBER,
|
||||
#if wxUSE_UNICODE
|
||||
L" (Unicode)",
|
||||
L" (Unicode)",
|
||||
#else
|
||||
"",
|
||||
wxEmptyString,
|
||||
#endif
|
||||
#ifdef __WXDEBUG__
|
||||
_T(" Debug build"),
|
||||
_T(" Debug build"),
|
||||
#else
|
||||
wxEmptyString,
|
||||
wxEmptyString,
|
||||
#endif
|
||||
__TDATE__,
|
||||
__TTIME__,
|
||||
__TDATE__,
|
||||
__TTIME__,
|
||||
#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("\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()
|
||||
#else
|
||||
""
|
||||
wxEmptyString
|
||||
#endif
|
||||
),
|
||||
_T("wxWidgets information"),
|
||||
);
|
||||
|
||||
wxMessageBox(msg, _T("wxWidgets information"),
|
||||
wxICON_INFORMATION | wxOK,
|
||||
(wxWindow *)this);
|
||||
}
|
||||
|
||||
@@ -163,21 +163,6 @@ int wxDisplayDepth()
|
||||
return gdk_drawable_get_visual( wxGetRootWindow()->window )->depth;
|
||||
}
|
||||
|
||||
wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo()
|
||||
{
|
||||
static wxToolkitInfo info;
|
||||
info.shortName = _T("gtk2");
|
||||
info.name = _T("wxGTK");
|
||||
#ifdef __WXUNIVERSAL__
|
||||
info.shortName << _T("univ");
|
||||
info.name << _T("/wxUniversal");
|
||||
#endif
|
||||
info.versionMajor = gtk_major_version;
|
||||
info.versionMinor = gtk_minor_version;
|
||||
info.os = wxGTK;
|
||||
return info;
|
||||
}
|
||||
|
||||
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
|
||||
{
|
||||
return wxGenericFindWindowAtPoint(pt);
|
||||
@@ -259,3 +244,19 @@ int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxPlatformInfo-related
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
|
||||
{
|
||||
if ( verMaj )
|
||||
*verMaj = gtk_major_version;
|
||||
if ( verMin )
|
||||
*verMin = gtk_minor_version;
|
||||
|
||||
return wxPORT_GTK;
|
||||
}
|
||||
|
||||
@@ -129,21 +129,6 @@ int wxDisplayDepth()
|
||||
return gdk_window_get_visual( wxGetRootWindow()->window )->depth;
|
||||
}
|
||||
|
||||
wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo()
|
||||
{
|
||||
static wxToolkitInfo info;
|
||||
info.shortName = _T("gtk");
|
||||
info.name = _T("wxGTK");
|
||||
#ifdef __WXUNIVERSAL__
|
||||
info.shortName << _T("univ");
|
||||
info.name << _T("/wxUniversal");
|
||||
#endif
|
||||
info.versionMajor = gtk_major_version;
|
||||
info.versionMinor = gtk_minor_version;
|
||||
info.os = wxGTK;
|
||||
return info;
|
||||
}
|
||||
|
||||
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
|
||||
{
|
||||
return wxGenericFindWindowAtPoint(pt);
|
||||
@@ -197,3 +182,17 @@ int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxPlatformInfo-related
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
|
||||
{
|
||||
if ( verMaj )
|
||||
*verMaj = gtk_major_version;
|
||||
if ( verMin )
|
||||
*verMin = gtk_minor_version;
|
||||
|
||||
return wxPORT_GTK;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// our OS version is the same in non GUI and GUI cases
|
||||
static int DoGetOSVersion(int *majorVsn, int *minorVsn)
|
||||
wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin)
|
||||
{
|
||||
long theSystem;
|
||||
|
||||
@@ -85,14 +85,15 @@ static int DoGetOSVersion(int *majorVsn, int *minorVsn)
|
||||
if (majorVsn != NULL)
|
||||
*majorVsn = (theSystem >> 8);
|
||||
|
||||
#ifdef __DARWIN__
|
||||
return wxMAC_DARWIN;
|
||||
#if defined( __DARWIN__ )
|
||||
return wxOS_MAC_OSX_DARWIN;
|
||||
#else
|
||||
return wxMAC;
|
||||
return wxOS_MAC_OS;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if wxUSE_BASE
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -370,34 +371,17 @@ void wxBell()
|
||||
SysBeep(30);
|
||||
}
|
||||
|
||||
wxToolkitInfo& wxConsoleAppTraits::GetToolkitInfo()
|
||||
{
|
||||
static wxToolkitInfo info;
|
||||
|
||||
info.os = DoGetOSVersion(&info.versionMajor, &info.versionMinor);
|
||||
info.name = _T("wxBase");
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
#endif // wxUSE_BASE
|
||||
|
||||
#if wxUSE_GUI
|
||||
|
||||
wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo()
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
|
||||
{
|
||||
static wxToolkitInfo info;
|
||||
// We suppose that toolkit version is the same as OS version under Mac
|
||||
wxGetOsVersion(verMaj, verMin);
|
||||
|
||||
info.os = DoGetOSVersion(&info.versionMajor, &info.versionMinor);
|
||||
info.shortName = _T("mac");
|
||||
info.name = _T("wxMac");
|
||||
|
||||
#ifdef __WXUNIVERSAL__
|
||||
info.shortName << _T("univ");
|
||||
info.name << _T("/wxUniversal");
|
||||
#endif
|
||||
|
||||
return info;
|
||||
return wxPORT_MAC;
|
||||
}
|
||||
|
||||
// Reading and writing resources (eg WIN.INI, .Xdefaults)
|
||||
@@ -1151,7 +1135,7 @@ void wxMacControl::SetRect( Rect *r )
|
||||
HIViewSetFrame ( m_controlRef , &hir );
|
||||
// eventuall we might have to do a SetVisibility( false , true );
|
||||
// before and a SetVisibility( true , true ); after
|
||||
}
|
||||
}
|
||||
|
||||
void wxMacControl::GetRect( Rect *r )
|
||||
{
|
||||
|
||||
@@ -61,23 +61,23 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// our OS version is the same in non GUI and GUI cases
|
||||
static int DoGetOSVersion(int *majorVsn, int *minorVsn)
|
||||
wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin)
|
||||
{
|
||||
long theSystem ;
|
||||
long theSystem;
|
||||
|
||||
// are there x-platform conventions ?
|
||||
|
||||
Gestalt(gestaltSystemVersion, &theSystem) ;
|
||||
if (minorVsn != NULL) {
|
||||
*minorVsn = (theSystem & 0xFF ) ;
|
||||
}
|
||||
if (majorVsn != NULL) {
|
||||
*majorVsn = (theSystem >> 8 ) ;
|
||||
}
|
||||
#ifdef __DARWIN__
|
||||
return wxMAC_DARWIN;
|
||||
Gestalt(gestaltSystemVersion, &theSystem);
|
||||
if (minorVsn != NULL)
|
||||
*minorVsn = (theSystem & 0xFF);
|
||||
|
||||
if (majorVsn != NULL)
|
||||
*majorVsn = (theSystem >> 8);
|
||||
|
||||
#if defined( __DARWIN__ )
|
||||
return wxOS_MAC_OSX_DARWIN;
|
||||
#else
|
||||
return wxMAC;
|
||||
return wxOS_MAC_OS;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -224,29 +224,16 @@ void wxBell()
|
||||
SysBeep(30);
|
||||
}
|
||||
|
||||
wxToolkitInfo& wxConsoleAppTraits::GetToolkitInfo()
|
||||
{
|
||||
static wxToolkitInfo info;
|
||||
info.os = DoGetOSVersion(&info.versionMajor, &info.versionMinor);
|
||||
info.name = _T("wxBase");
|
||||
return info;
|
||||
}
|
||||
|
||||
#endif // wxUSE_BASE
|
||||
|
||||
#if wxUSE_GUI
|
||||
|
||||
wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo()
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
|
||||
{
|
||||
static wxToolkitInfo info;
|
||||
info.os = DoGetOSVersion(&info.versionMajor, &info.versionMinor);
|
||||
info.shortName = _T("mac");
|
||||
info.name = _T("wxMac");
|
||||
#ifdef __WXUNIVERSAL__
|
||||
info.shortName << _T("univ");
|
||||
info.name << _T("/wxUniversal");
|
||||
#endif
|
||||
return info;
|
||||
// We suppose that toolkit version is the same as OS version under Mac
|
||||
wxGetOsVersion(verMaj, verMin);
|
||||
|
||||
return wxPORT_MAC;
|
||||
}
|
||||
|
||||
// Reading and writing resources (eg WIN.INI, .Xdefaults)
|
||||
|
||||
@@ -103,55 +103,15 @@ int wxDisplayDepth()
|
||||
return g_displayDC->getBitsPerPixel();
|
||||
}
|
||||
|
||||
#if wxUSE_GUI
|
||||
|
||||
wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo()
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
|
||||
{
|
||||
static wxToolkitInfo info;
|
||||
info.shortName = _T("mgluniv");
|
||||
info.name = _T("wxMGL");
|
||||
info.versionMajor = MGL_RELEASE_MAJOR;
|
||||
info.versionMinor = MGL_RELEASE_MINOR;
|
||||
info.os = wxGTK;
|
||||
#if defined(__UNIX__)
|
||||
info.os = wxMGL_UNIX;
|
||||
#elif defined(__OS2__)
|
||||
info.os = wxMGL_OS2;
|
||||
#elif defined(__WIN32__)
|
||||
info.os = wxMGL_WIN32;
|
||||
#elif defined(__DOS__)
|
||||
info.os = wxMGL_DOS;
|
||||
#else
|
||||
#error Platform not supported by wxMGL!
|
||||
#endif
|
||||
return info;
|
||||
}
|
||||
if ( verMaj )
|
||||
*verMaj = MGL_RELEASE_MAJOR;
|
||||
if ( verMin )
|
||||
*verMin = MGL_RELEASE_MINOR;
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
wxToolkitInfo& wxConsoleAppTraits::GetToolkitInfo()
|
||||
{
|
||||
static wxToolkitInfo info;
|
||||
info.shortName = _T("mglbase");
|
||||
info.versionMajor = MGL_RELEASE_MAJOR;
|
||||
info.versionMinor = MGL_RELEASE_MINOR;
|
||||
info.name = _T("wxBase");
|
||||
info.os = wxGTK;
|
||||
#if defined(__UNIX__)
|
||||
info.os = wxMGL_UNIX;
|
||||
#elif defined(__OS2__)
|
||||
info.os = wxMGL_OS2;
|
||||
#elif defined(__WIN32__)
|
||||
info.os = wxMGL_WIN32;
|
||||
#elif defined(__DOS__)
|
||||
info.os = wxMGL_DOS;
|
||||
#else
|
||||
#error Platform not supported by wxMGL!
|
||||
#endif
|
||||
return info;
|
||||
return wxPORT_MGL;
|
||||
}
|
||||
#endif
|
||||
|
||||
void wxGetMousePosition(int* x, int* y)
|
||||
{
|
||||
|
||||
@@ -143,30 +143,18 @@ void wxBell()
|
||||
}
|
||||
#endif
|
||||
|
||||
wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo()
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
|
||||
{
|
||||
static wxToolkitInfo info;
|
||||
// XmVERSION and XmREVISION are defined in Xm/Xm.h
|
||||
if ( verMaj )
|
||||
*verMaj = XmVERSION;
|
||||
if ( verMin )
|
||||
*verMin = XmREVISION;
|
||||
|
||||
info.shortName = _T("motif");
|
||||
info.name = _T("wxMotif");
|
||||
#ifdef __WXUNIVERSAL__
|
||||
info.shortName << _T("univ");
|
||||
info.name << _T("/wxUniversal");
|
||||
#endif
|
||||
// FIXME TODO
|
||||
// This code is WRONG!! Does NOT return the
|
||||
// Motif version of the libs but the X protocol
|
||||
// version!
|
||||
Display *display = wxGlobalDisplay();
|
||||
if (display)
|
||||
{
|
||||
info.versionMajor = ProtocolVersion (display);
|
||||
info.versionMinor = ProtocolRevision (display);
|
||||
}
|
||||
info.os = wxMOTIF_X;
|
||||
return info;
|
||||
return wxPORT_MOTIF;
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Reading and writing resources (eg WIN.INI, .Xdefaults)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@@ -467,22 +467,9 @@ long wxExecute(wxChar **argv, int flags, wxProcess *process)
|
||||
return result;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Traits for console apps
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
wxToolkitInfo& wxConsoleAppTraits::GetToolkitInfo()
|
||||
{
|
||||
static wxToolkitInfo info;
|
||||
info.versionMajor = _osmajor;
|
||||
info.versionMinor = _osminor;
|
||||
info.name = _T("wxBase");
|
||||
info.os = wxDOS;
|
||||
return info;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// OS Description
|
||||
// OS-related
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
wxString wxGetOsDescription()
|
||||
@@ -490,3 +477,14 @@ wxString wxGetOsDescription()
|
||||
wxString osname(_T("DOS"));
|
||||
return osname;
|
||||
}
|
||||
|
||||
wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin)
|
||||
{
|
||||
if ( verMaj )
|
||||
*verMaj = _osmajor;
|
||||
if ( verMin )
|
||||
*verMin = _osminor;
|
||||
|
||||
return wxOS_DOS;
|
||||
}
|
||||
|
||||
|
||||
@@ -226,20 +226,27 @@ bool wxGUIAppTraits::DoMessageFromThreadWait()
|
||||
return evtLoop->Dispatch();
|
||||
}
|
||||
|
||||
wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo()
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *majVer, int *minVer) const
|
||||
{
|
||||
static wxToolkitInfo info;
|
||||
wxToolkitInfo& baseInfo = wxAppTraits::GetToolkitInfo();
|
||||
info.versionMajor = baseInfo.versionMajor;
|
||||
info.versionMinor = baseInfo.versionMinor;
|
||||
info.os = baseInfo.os;
|
||||
info.shortName = _T("msw");
|
||||
info.name = _T("wxMSW");
|
||||
#ifdef __WXUNIVERSAL__
|
||||
info.shortName << _T("univ");
|
||||
info.name << _T("/wxUniversal");
|
||||
OSVERSIONINFO info;
|
||||
wxZeroMemory(info);
|
||||
|
||||
// on Windows, the toolkit version is the same of the OS version
|
||||
// as Windows integrates the OS kernel with the GUI toolkit.
|
||||
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
if ( ::GetVersionEx(&info) )
|
||||
{
|
||||
if ( majVer )
|
||||
*majVer = info.dwMajorVersion;
|
||||
if ( minVer )
|
||||
*minVer = info.dwMinorVersion;
|
||||
}
|
||||
|
||||
#if defined(__WXHANDHELD__) || defined(__WXWINCE__)
|
||||
return wxPORT_WINCE;
|
||||
#else
|
||||
return wxPORT_MSW;
|
||||
#endif
|
||||
return info;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
@@ -1162,61 +1162,49 @@ wxString wxGetOsDescription()
|
||||
return str;
|
||||
}
|
||||
|
||||
wxToolkitInfo& wxAppTraits::GetToolkitInfo()
|
||||
// taken from http://blogs.msdn.com/oldnewthing/archive/2005/02/01/364563.aspx
|
||||
bool wxIsPlatform64Bit()
|
||||
{
|
||||
// cache the version info, it's not going to change
|
||||
//
|
||||
// NB: this is MT-safe, we may use these static vars from different threads
|
||||
// but as they always have the same value it doesn't matter
|
||||
static int s_ver = -1,
|
||||
s_major = -1,
|
||||
s_minor = -1;
|
||||
|
||||
if ( s_ver == -1 )
|
||||
{
|
||||
OSVERSIONINFO info;
|
||||
wxZeroMemory(info);
|
||||
|
||||
s_ver = wxWINDOWS;
|
||||
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
if ( ::GetVersionEx(&info) )
|
||||
{
|
||||
s_major = info.dwMajorVersion;
|
||||
s_minor = info.dwMinorVersion;
|
||||
|
||||
#ifdef __SMARTPHONE__
|
||||
s_ver = wxWINDOWS_SMARTPHONE;
|
||||
#elif defined(__POCKETPC__)
|
||||
s_ver = wxWINDOWS_POCKETPC;
|
||||
#if defined(_WIN64)
|
||||
return true; // 64-bit programs run only on Win64
|
||||
#elif defined(_WIN32)
|
||||
// 32-bit programs run on both 32-bit and 64-bit Windows
|
||||
// so must sniff
|
||||
BOOL f64 = FALSE;
|
||||
return IsWow64Process(GetCurrentProcess(), &f64) && f64;
|
||||
#else
|
||||
switch ( info.dwPlatformId )
|
||||
{
|
||||
case VER_PLATFORM_WIN32s:
|
||||
s_ver = wxWIN32S;
|
||||
break;
|
||||
|
||||
case VER_PLATFORM_WIN32_WINDOWS:
|
||||
s_ver = wxWIN95;
|
||||
break;
|
||||
|
||||
case VER_PLATFORM_WIN32_NT:
|
||||
s_ver = wxWINDOWS_NT;
|
||||
break;
|
||||
#ifdef __WXWINCE__
|
||||
case VER_PLATFORM_WIN32_CE:
|
||||
s_ver = wxWINDOWS_CE;
|
||||
return false; // Win64 does not support Win16
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin)
|
||||
{
|
||||
OSVERSIONINFO info;
|
||||
wxZeroMemory(info);
|
||||
|
||||
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
if ( ::GetVersionEx(&info) )
|
||||
{
|
||||
if (verMaj) *verMaj = info.dwMajorVersion;
|
||||
if (verMin) *verMin = info.dwMinorVersion;
|
||||
}
|
||||
|
||||
static wxToolkitInfo info;
|
||||
info.versionMajor = s_major;
|
||||
info.versionMinor = s_minor;
|
||||
info.os = s_ver;
|
||||
info.name = _T("wxBase");
|
||||
return info;
|
||||
#if defined(__WXHANDHELD__) || defined( __WXWINCE__ )
|
||||
return wxOS_WINDOWS_WINCE;
|
||||
#elif defined( __WXMICROWIN__ )
|
||||
return wxOS_WINDOWS_MICRO;
|
||||
#else
|
||||
switch ( info.dwPlatformId )
|
||||
{
|
||||
case VER_PLATFORM_WIN32_NT:
|
||||
return wxOS_WINDOWS_NT;
|
||||
|
||||
case VER_PLATFORM_WIN32_WINDOWS:
|
||||
return wxOS_WINDOWS_9X;
|
||||
}
|
||||
|
||||
return wxOS_UNKNOWN;
|
||||
#endif
|
||||
}
|
||||
|
||||
wxWinVersion wxGetWinVersion()
|
||||
|
||||
@@ -326,27 +326,30 @@ void wxAppTraits::TerminateGui(unsigned long WXUNUSED(ulHab))
|
||||
{
|
||||
}
|
||||
|
||||
wxToolkitInfo & wxConsoleAppTraits::GetToolkitInfo()
|
||||
wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin)
|
||||
{
|
||||
static wxToolkitInfo vInfo;
|
||||
ULONG ulSysInfo[QSV_MAX] = {0};
|
||||
APIRET ulrc;
|
||||
|
||||
vInfo.name = _T("wxBase");
|
||||
ulrc = ::DosQuerySysInfo( 1L
|
||||
,QSV_MAX
|
||||
,(PVOID)ulSysInfo
|
||||
,sizeof(ULONG) * QSV_MAX
|
||||
);
|
||||
|
||||
if (ulrc == 0L)
|
||||
{
|
||||
vInfo.versionMajor = ulSysInfo[QSV_VERSION_MAJOR] / 10;
|
||||
vInfo.versionMinor = ulSysInfo[QSV_VERSION_MINOR];
|
||||
if ( verMaj )
|
||||
*verMaj = ulSysInfo[QSV_VERSION_MAJOR] / 10;
|
||||
if ( verMin )
|
||||
*verMin = ulSysInfo[QSV_VERSION_MINOR];
|
||||
}
|
||||
vInfo.os = wxOS2_PM;
|
||||
return vInfo;
|
||||
|
||||
return wxOS_OS2;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
const wxChar* wxGetHomeDir(
|
||||
wxString* pStr
|
||||
|
||||
@@ -437,32 +437,13 @@ void wxGUIAppTraits::TerminateGui(unsigned long ulHab)
|
||||
::WinTerminate(ulHab);
|
||||
}
|
||||
|
||||
wxToolkitInfo & wxGUIAppTraits::GetToolkitInfo()
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
|
||||
{
|
||||
static wxToolkitInfo vInfo;
|
||||
ULONG ulSysInfo[QSV_MAX] = {0};
|
||||
APIRET ulrc;
|
||||
|
||||
vInfo.shortName = _T("PM");
|
||||
vInfo.name = _T("wxOS2");
|
||||
#ifdef __WXUNIVERSAL__
|
||||
vInfo.shortName << _T("univ");
|
||||
vInfo.name << _T("/wxUniversal");
|
||||
#endif
|
||||
ulrc = ::DosQuerySysInfo( 1L
|
||||
,QSV_MAX
|
||||
,(PVOID)ulSysInfo
|
||||
,sizeof(ULONG) * QSV_MAX
|
||||
);
|
||||
if (ulrc == 0L)
|
||||
{
|
||||
vInfo.versionMajor = ulSysInfo[QSV_VERSION_MAJOR] / 10;
|
||||
vInfo.versionMinor = ulSysInfo[QSV_VERSION_MINOR];
|
||||
}
|
||||
vInfo.os = wxOS2_PM;
|
||||
return vInfo;
|
||||
// TODO: how to get version of PM ?
|
||||
return wxPORT_OS2;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// window information functions
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -113,20 +113,10 @@ bool wxGUIAppTraits::DoMessageFromThreadWait()
|
||||
return false;
|
||||
}
|
||||
|
||||
wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo()
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *majVer, int *minVer) const
|
||||
{
|
||||
static wxToolkitInfo info;
|
||||
wxToolkitInfo& baseInfo = wxAppTraits::GetToolkitInfo();
|
||||
info.versionMajor = baseInfo.versionMajor;
|
||||
info.versionMinor = baseInfo.versionMinor;
|
||||
info.os = baseInfo.os;
|
||||
info.shortName = _T("palmos");
|
||||
info.name = _T("wxPalmOS");
|
||||
#ifdef __WXUNIVERSAL__
|
||||
info.shortName << _T("univ");
|
||||
info.name << _T("/wxUniversal");
|
||||
#endif
|
||||
return info;
|
||||
// TODO: how to get PalmOS GUI system version ?
|
||||
return wxPORT_PALMOS;
|
||||
}
|
||||
|
||||
// ===========================================================================
|
||||
|
||||
@@ -215,12 +215,11 @@ wxString wxGetOsDescription()
|
||||
return strOS;
|
||||
}
|
||||
|
||||
wxToolkitInfo& wxAppTraits::GetToolkitInfo()
|
||||
wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin)
|
||||
{
|
||||
static wxToolkitInfo info;
|
||||
info.os = wxPALMOS;
|
||||
info.name = _T("wxBase");
|
||||
return info;
|
||||
// TODO
|
||||
|
||||
return wxOS_UNKNOWN;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@@ -81,45 +81,3 @@ wxConsoleAppTraits::WaitForChild(wxExecuteData& execData)
|
||||
return exitcode;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// misc other stuff
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// this is in mac/utils.cpp under Mac
|
||||
#if !defined(__WXMAC__)
|
||||
|
||||
wxToolkitInfo& wxConsoleAppTraits::GetToolkitInfo()
|
||||
{
|
||||
static wxToolkitInfo info;
|
||||
int major, minor;
|
||||
|
||||
FILE *f = popen("uname -r", "r");
|
||||
if (f)
|
||||
{
|
||||
char buf[32];
|
||||
size_t c = fread(buf, 1, sizeof(buf) - 1, f);
|
||||
pclose(f);
|
||||
buf[c] = '\0';
|
||||
if ( sscanf(buf, "%d.%d", &major, &minor) != 2 )
|
||||
{
|
||||
// unrecognized uname string format
|
||||
major =
|
||||
minor = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// failed to run uname
|
||||
major =
|
||||
minor = -1;
|
||||
}
|
||||
|
||||
info.versionMajor = major;
|
||||
info.versionMinor = minor;
|
||||
info.name = _T("wxBase");
|
||||
info.os = wxUNIX;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
#endif // __WXMAC__
|
||||
|
||||
@@ -746,6 +746,35 @@ char *wxGetUserHome( const wxString &user )
|
||||
// network and user id routines
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// private utility function which returns output of the given command, removing
|
||||
// the trailing newline
|
||||
static wxString wxGetCommandOutput(const wxString &cmd)
|
||||
{
|
||||
FILE *f = popen(cmd.ToAscii(), "r");
|
||||
if ( !f )
|
||||
{
|
||||
wxLogSysError(_T("Executing \"%s\" failed"), cmd.c_str());
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
wxString s;
|
||||
char buf[256];
|
||||
while ( !feof(f) )
|
||||
{
|
||||
if ( !fgets(buf, sizeof(buf), f) )
|
||||
break;
|
||||
|
||||
s += wxString::FromAscii(buf);
|
||||
}
|
||||
|
||||
pclose(f);
|
||||
|
||||
if ( !s.empty() && s.Last() == _T('\n') )
|
||||
s.RemoveLast();
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// retrieve either the hostname or FQDN depending on platform (caller must
|
||||
// check whether it's one or the other, this is why this function is for
|
||||
// private use only)
|
||||
@@ -862,25 +891,54 @@ bool wxGetUserName(wxChar *buf, int sz)
|
||||
return false;
|
||||
}
|
||||
|
||||
wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin)
|
||||
{
|
||||
// get OS version
|
||||
int major, minor;
|
||||
wxString release = wxGetCommandOutput(wxT("uname -r"));
|
||||
if ( !release.empty() && wxSscanf(release, "%d.%d", &major, &minor) != 2 )
|
||||
{
|
||||
// unrecognized uname string format
|
||||
major =
|
||||
minor = -1;
|
||||
}
|
||||
|
||||
if ( verMaj )
|
||||
*verMaj = major;
|
||||
if ( verMin )
|
||||
*verMin = minor;
|
||||
|
||||
// try to understand which OS are we running
|
||||
wxString kernel = wxGetCommandOutput(wxT("uname -s"));
|
||||
if ( kernel.empty() )
|
||||
kernel = wxGetCommandOutput(wxT("uname -o"));
|
||||
|
||||
if ( kernel.empty() )
|
||||
return wxOS_UNKNOWN;
|
||||
|
||||
return wxPlatformInfo::GetOperatingSystemId(kernel);
|
||||
}
|
||||
|
||||
bool wxIsPlatform64Bit()
|
||||
{
|
||||
wxString machine = wxGetCommandOutput(wxT("uname -m"));
|
||||
|
||||
// NOTE: these tests are not 100% reliable!
|
||||
return machine.Contains(wxT("AMD64")) ||
|
||||
machine.Contains(wxT("IA64")) ||
|
||||
machine.Contains(wxT("x64")) ||
|
||||
machine.Contains(wxT("X64")) ||
|
||||
machine.Contains(wxT("alpha")) ||
|
||||
machine.Contains(wxT("hppa64")) ||
|
||||
machine.Contains(wxT("ppc64"));
|
||||
}
|
||||
|
||||
// this function is in mac/utils.cpp for wxMac
|
||||
#ifndef __WXMAC__
|
||||
|
||||
wxString wxGetOsDescription()
|
||||
{
|
||||
FILE *f = popen("uname -s -r -m", "r");
|
||||
if (f)
|
||||
{
|
||||
char buf[256];
|
||||
size_t c = fread(buf, 1, sizeof(buf) - 1, f);
|
||||
pclose(f);
|
||||
// Trim newline from output.
|
||||
if (c && buf[c - 1] == '\n')
|
||||
--c;
|
||||
buf[c] = '\0';
|
||||
return wxString::FromAscii( buf );
|
||||
}
|
||||
wxFAIL_MSG( _T("uname failed") );
|
||||
return wxEmptyString;
|
||||
return wxGetCommandOutput(wxT("uname -s -r -m"));
|
||||
}
|
||||
|
||||
#endif // !__WXMAC__
|
||||
|
||||
@@ -153,17 +153,22 @@ void wxBell()
|
||||
}
|
||||
#endif
|
||||
|
||||
wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo()
|
||||
wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const
|
||||
{
|
||||
static wxToolkitInfo info;
|
||||
info.shortName = _T("x11univ");
|
||||
info.name = _T("wxX11");
|
||||
info.versionMajor = 0;
|
||||
info.versionMinor = 0;
|
||||
info.os = wxX11;
|
||||
return info;
|
||||
// get X protocol version
|
||||
Display *display = wxGlobalDisplay();
|
||||
if (display)
|
||||
{
|
||||
if ( verMaj )
|
||||
*verMaj = ProtocolVersion (display);
|
||||
if ( verMin )
|
||||
*verMin = ProtocolRevision (display);
|
||||
}
|
||||
|
||||
return wxPORT_X11;
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// display info
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user