moved GetOSVersion() to the base traits class; implement it in platform-specific files
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21437 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
18f0a2c5aa
commit
2739d4f052
@ -81,6 +81,15 @@ public:
|
|||||||
// remove this object from the pending delete list in GUI, do nothing in
|
// remove this object from the pending delete list in GUI, do nothing in
|
||||||
// wxBase
|
// wxBase
|
||||||
virtual void RemoveFromPendingDelete(wxObject *object) = 0;
|
virtual void RemoveFromPendingDelete(wxObject *object) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
// other miscellaneous helpers
|
||||||
|
// ---------------------------
|
||||||
|
|
||||||
|
// wxGetOsVersion() behaves differently in GUI and non-GUI builds under
|
||||||
|
// Unix: in the former case it returns the information about the toolkit
|
||||||
|
// and in the latter -- about the OS, so we need to virtualize it
|
||||||
|
virtual int GetOSVersion(int *verMaj, int *verMin) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -40,6 +40,13 @@ public:
|
|||||||
// process a message while waiting for a(nother) thread, should return
|
// process a message while waiting for a(nother) thread, should return
|
||||||
// false if and only if we have to exit the application
|
// false if and only if we have to exit the application
|
||||||
virtual bool DoMessageFromThreadWait() = 0;
|
virtual bool DoMessageFromThreadWait() = 0;
|
||||||
|
|
||||||
|
// other miscellaneous helpers
|
||||||
|
// ---------------------------
|
||||||
|
|
||||||
|
// under MSW this function does the same thing for console and GUI
|
||||||
|
// applications so we can implement it directly in the base class
|
||||||
|
virtual int GetOSVersion(int *verMaj, int *verMin);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _WX_MSW_APPTBASE_H_
|
#endif // _WX_MSW_APPTBASE_H_
|
||||||
|
@ -48,15 +48,6 @@ public:
|
|||||||
// ----------------
|
// ----------------
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
|
|
||||||
// other miscellaneous helpers
|
|
||||||
// ---------------------------
|
|
||||||
|
|
||||||
// wxGetOsVersion() behaves differently in GUI and non-GUI builds udner
|
|
||||||
// Unix: in the former case it returns the information about the toolkit
|
|
||||||
// and in the latter -- about the OS, so we need to virtualize it
|
|
||||||
virtual int GetOSVersion(int *verMaj, int *verMin) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _WX_UNIX_APPTBASE_H_
|
#endif // _WX_UNIX_APPTBASE_H_
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
|
|
||||||
#if wxUSE_GUI
|
#if wxUSE_GUI
|
||||||
#include "wx/app.h"
|
|
||||||
#include "wx/window.h"
|
#include "wx/window.h"
|
||||||
#include "wx/frame.h"
|
#include "wx/frame.h"
|
||||||
#include "wx/menu.h"
|
#include "wx/menu.h"
|
||||||
@ -50,10 +49,10 @@
|
|||||||
#endif // wxUSE_GUI
|
#endif // wxUSE_GUI
|
||||||
#endif // WX_PRECOMP
|
#endif // WX_PRECOMP
|
||||||
|
|
||||||
#ifndef __WIN16__
|
#include "wx/apptrait.h"
|
||||||
|
|
||||||
#include "wx/process.h"
|
#include "wx/process.h"
|
||||||
#include "wx/txtstrm.h"
|
#include "wx/txtstrm.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -292,6 +291,16 @@ wxString wxGetDataDir()
|
|||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int wxGetOsVersion(int *verMaj, int *verMin)
|
||||||
|
{
|
||||||
|
// we want this function to work even if there is no wxApp
|
||||||
|
wxConsoleAppTraits traitsConsole;
|
||||||
|
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
||||||
|
if ( ! traits )
|
||||||
|
traits = &traitsConsole;
|
||||||
|
|
||||||
|
return traits->GetOSVersion(verMaj, verMin);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// network and user id functions
|
// network and user id functions
|
||||||
@ -472,11 +481,6 @@ static long wxDoExecuteWithCapture(const wxString& command,
|
|||||||
wxArrayString& output,
|
wxArrayString& output,
|
||||||
wxArrayString* error)
|
wxArrayString* error)
|
||||||
{
|
{
|
||||||
#ifdef __WIN16__
|
|
||||||
wxFAIL_MSG("Sorry, this version of wxExecute not implemented on WIN16.");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
#else // !Win16
|
|
||||||
// create a wxProcess which will capture the output
|
// create a wxProcess which will capture the output
|
||||||
wxProcess *process = new wxProcess;
|
wxProcess *process = new wxProcess;
|
||||||
process->Redirect();
|
process->Redirect();
|
||||||
@ -501,7 +505,6 @@ static long wxDoExecuteWithCapture(const wxString& command,
|
|||||||
delete process;
|
delete process;
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
#endif // IO redirection supported
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long wxExecute(const wxString& command, wxArrayString& output)
|
long wxExecute(const wxString& command, wxArrayString& output)
|
||||||
|
@ -31,6 +31,8 @@
|
|||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
#endif //WX_PRECOMP
|
#endif //WX_PRECOMP
|
||||||
|
|
||||||
|
#include "wx/apptrait.h"
|
||||||
|
|
||||||
#include "wx/msw/private.h" // includes <windows.h>
|
#include "wx/msw/private.h" // includes <windows.h>
|
||||||
|
|
||||||
#ifdef __GNUWIN32_OLD__
|
#ifdef __GNUWIN32_OLD__
|
||||||
@ -974,64 +976,51 @@ wxString wxGetOsDescription()
|
|||||||
#endif // Win32/16
|
#endif // Win32/16
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxGetOsVersion(int *majorVsn, int *minorVsn)
|
int wxAppTraits::GetOSVersion(int *verMaj, int *verMin)
|
||||||
{
|
{
|
||||||
#if defined(__WIN32__)
|
// cache the version info, it's not going to change
|
||||||
static int ver = -1, major = -1, minor = -1;
|
//
|
||||||
|
// 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 ( ver == -1 )
|
if ( s_ver == -1 )
|
||||||
{
|
{
|
||||||
OSVERSIONINFO info;
|
OSVERSIONINFO info;
|
||||||
wxZeroMemory(info);
|
wxZeroMemory(info);
|
||||||
|
|
||||||
ver = wxWINDOWS;
|
s_ver = wxWINDOWS;
|
||||||
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||||
if ( ::GetVersionEx(&info) )
|
if ( ::GetVersionEx(&info) )
|
||||||
{
|
{
|
||||||
major = info.dwMajorVersion;
|
s_major = info.dwMajorVersion;
|
||||||
minor = info.dwMinorVersion;
|
s_minor = info.dwMinorVersion;
|
||||||
|
|
||||||
switch ( info.dwPlatformId )
|
switch ( info.dwPlatformId )
|
||||||
{
|
{
|
||||||
case VER_PLATFORM_WIN32s:
|
case VER_PLATFORM_WIN32s:
|
||||||
ver = wxWIN32S;
|
s_ver = wxWIN32S;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VER_PLATFORM_WIN32_WINDOWS:
|
case VER_PLATFORM_WIN32_WINDOWS:
|
||||||
ver = wxWIN95;
|
s_ver = wxWIN95;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VER_PLATFORM_WIN32_NT:
|
case VER_PLATFORM_WIN32_NT:
|
||||||
ver = wxWINDOWS_NT;
|
s_ver = wxWINDOWS_NT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (majorVsn && major != -1)
|
if ( verMaj )
|
||||||
*majorVsn = major;
|
*verMaj = s_major;
|
||||||
if (minorVsn && minor != -1)
|
if ( verMin )
|
||||||
*minorVsn = minor;
|
*verMin = s_minor;
|
||||||
|
|
||||||
return ver;
|
return s_ver;
|
||||||
#else // Win16
|
|
||||||
int retValue = wxWINDOWS;
|
|
||||||
#ifdef __WINDOWS_386__
|
|
||||||
retValue = wxWIN386;
|
|
||||||
#else
|
|
||||||
#if !defined(__WATCOMC__) && !defined(GNUWIN32) && wxUSE_PENWINDOWS
|
|
||||||
extern HANDLE g_hPenWin;
|
|
||||||
retValue = g_hPenWin ? wxPENWINDOWS : wxWINDOWS;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (majorVsn)
|
|
||||||
*majorVsn = 3;
|
|
||||||
if (minorVsn)
|
|
||||||
*minorVsn = 1;
|
|
||||||
|
|
||||||
return retValue;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -94,7 +94,7 @@ int wxConsoleAppTraits::GetOSVersion(int *verMaj, int *verMin)
|
|||||||
int major, minor;
|
int major, minor;
|
||||||
char name[256];
|
char name[256];
|
||||||
|
|
||||||
if ( sscanf(WXWIN_OS_DESCRIPTION, "%s %d.%d", name, &major, &minor) != 3 )
|
if ( sscanf(WXWIN_OS_DESCRIPTION, "%.255s %d.%d", name, &major, &minor) != 3 )
|
||||||
{
|
{
|
||||||
// unreckognized uname string format
|
// unreckognized uname string format
|
||||||
major =
|
major =
|
||||||
|
@ -817,17 +817,6 @@ wxString wxGetOsDescription()
|
|||||||
|
|
||||||
#endif // !__WXMAC__
|
#endif // !__WXMAC__
|
||||||
|
|
||||||
int wxGetOsVersion(int *verMaj, int *verMin)
|
|
||||||
{
|
|
||||||
// we want this function to work even if there is no wxApp
|
|
||||||
wxConsoleAppTraits traitsConsole;
|
|
||||||
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
|
||||||
if ( ! traits )
|
|
||||||
traits = &traitsConsole;
|
|
||||||
|
|
||||||
return traits->GetOSVersion(verMaj, verMin);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long wxGetProcessId()
|
unsigned long wxGetProcessId()
|
||||||
{
|
{
|
||||||
return (unsigned long)getpid();
|
return (unsigned long)getpid();
|
||||||
|
Loading…
Reference in New Issue
Block a user