// remove this object from the pending delete list in GUI, do nothing in
// wxBase
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;
};
// ----------------------------------------------------------------------------
// process a message while waiting for a(nother) thread, should return
// false if and only if we have to exit the application
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_
// ----------------
// 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_
#include "wx/log.h"
#if wxUSE_GUI
- #include "wx/app.h"
#include "wx/window.h"
#include "wx/frame.h"
#include "wx/menu.h"
#endif // wxUSE_GUI
#endif // WX_PRECOMP
-#ifndef __WIN16__
+#include "wx/apptrait.h"
+
#include "wx/process.h"
#include "wx/txtstrm.h"
-#endif
#include <ctype.h>
#include <stdio.h>
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
wxArrayString& output,
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
wxProcess *process = new wxProcess;
process->Redirect();
delete process;
return rc;
-#endif // IO redirection supported
}
long wxExecute(const wxString& command, wxArrayString& output)
#include "wx/log.h"
#endif //WX_PRECOMP
+#include "wx/apptrait.h"
+
#include "wx/msw/private.h" // includes <windows.h>
#ifdef __GNUWIN32_OLD__
#endif // Win32/16
}
-int wxGetOsVersion(int *majorVsn, int *minorVsn)
+int wxAppTraits::GetOSVersion(int *verMaj, int *verMin)
{
-#if defined(__WIN32__)
- static int ver = -1, major = -1, minor = -1;
+ // 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 ( ver == -1 )
+ if ( s_ver == -1 )
{
OSVERSIONINFO info;
wxZeroMemory(info);
- ver = wxWINDOWS;
+ s_ver = wxWINDOWS;
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if ( ::GetVersionEx(&info) )
{
- major = info.dwMajorVersion;
- minor = info.dwMinorVersion;
+ s_major = info.dwMajorVersion;
+ s_minor = info.dwMinorVersion;
switch ( info.dwPlatformId )
{
case VER_PLATFORM_WIN32s:
- ver = wxWIN32S;
+ s_ver = wxWIN32S;
break;
case VER_PLATFORM_WIN32_WINDOWS:
- ver = wxWIN95;
+ s_ver = wxWIN95;
break;
case VER_PLATFORM_WIN32_NT:
- ver = wxWINDOWS_NT;
+ s_ver = wxWINDOWS_NT;
break;
}
}
}
- if (majorVsn && major != -1)
- *majorVsn = major;
- if (minorVsn && minor != -1)
- *minorVsn = minor;
-
- return 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;
+ if ( verMaj )
+ *verMaj = s_major;
+ if ( verMin )
+ *verMin = s_minor;
- return retValue;
-#endif
+ return s_ver;
}
// ----------------------------------------------------------------------------
int major, minor;
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
major =
#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()
{
return (unsigned long)getpid();