Merge pull request #62 from TcT2k/version_fixes
OS version checks improvements and updates. Remove code for the no longer supported OS versions (MSW < XP, OS X < 10.7). Add new `wxCheckOsVersion()` which should be used when testing for the OS version instead of comparing the versions directly which may not work reliably because of compatibility shims.
This commit is contained in:
@@ -22,13 +22,13 @@ Platforms
|
||||
|
||||
wxWidgets currently supports the following primary platforms:
|
||||
|
||||
- Windows XP, Vista, 7 and 8 (32/64 bits).
|
||||
- Windows XP, Vista, 7, 8 and 10 (32/64 bits).
|
||||
- Most Unix variants using the GTK+ toolkit (version 2.6 or newer or 3.x).
|
||||
- Mac OS X (10.7 or newer) using Cocoa (32/64 bits) or Carbon (32 only).
|
||||
|
||||
Most popular C++ compilers are supported including but not limited to:
|
||||
|
||||
- Microsoft Visual C++ 2003 or later (up to 2013).
|
||||
- Microsoft Visual C++ 2003 or later (up to 2015).
|
||||
- g++ 3.4 or later, including MinGW/MinGW-64/TDM under Windows.
|
||||
- Clang under OS X and Linux.
|
||||
- Intel icc compiler.
|
||||
|
@@ -45,9 +45,9 @@ Platforms supported
|
||||
|
||||
wxWidgets currently supports the following primary platforms:
|
||||
|
||||
- Windows XP, Vista, 7 and 8 (32/64 bits).
|
||||
- Windows XP, Vista, 7, 8 and 10 (32/64 bits).
|
||||
- Most Unix variants using the GTK+ toolkit (version 2.6 or newer)
|
||||
- Mac OS X (10.6 or newer) using Cocoa (32/64 bits) or Carbon (32 only)
|
||||
- Mac OS X (10.7 or newer) using Cocoa (32/64 bits) or Carbon (32 only)
|
||||
|
||||
There is some support for the following platforms:
|
||||
|
||||
|
@@ -249,7 +249,7 @@ private:
|
||||
// owned by the set. Furthermore, children of the last parent are stored
|
||||
// in a linear list.
|
||||
//
|
||||
@interface wxCocoaOutlineDataSource : NSObject wxOSX_10_6_AND_LATER(<NSOutlineViewDataSource>)
|
||||
@interface wxCocoaOutlineDataSource : NSObject <NSOutlineViewDataSource>
|
||||
{
|
||||
// descriptors specifying the sorting (currently the array only holds one
|
||||
// object only)
|
||||
@@ -395,7 +395,7 @@ private:
|
||||
// wxCocoaOutlineView
|
||||
// ============================================================================
|
||||
|
||||
@interface wxCocoaOutlineView : NSOutlineView wxOSX_10_6_AND_LATER(<NSOutlineViewDelegate>)
|
||||
@interface wxCocoaOutlineView : NSOutlineView <NSOutlineViewDelegate>
|
||||
{
|
||||
@private
|
||||
// column and row of the cell being edited or -1 if none
|
||||
|
@@ -336,7 +336,7 @@ public:
|
||||
- (void) setTextField:(NSTextField*) field;
|
||||
@end
|
||||
|
||||
@interface wxNSTextField : NSTextField wxOSX_10_6_AND_LATER(<NSTextFieldDelegate>)
|
||||
@interface wxNSTextField : NSTextField <NSTextFieldDelegate>
|
||||
{
|
||||
wxNSTextFieldEditor* fieldEditor;
|
||||
}
|
||||
@@ -346,14 +346,14 @@ public:
|
||||
|
||||
@end
|
||||
|
||||
@interface wxNSSecureTextField : NSSecureTextField wxOSX_10_6_AND_LATER(<NSTextFieldDelegate>)
|
||||
@interface wxNSSecureTextField : NSSecureTextField <NSTextFieldDelegate>
|
||||
{
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface wxNSTextView : NSTextView wxOSX_10_6_AND_LATER(<NSTextViewDelegate>)
|
||||
@interface wxNSTextView : NSTextView <NSTextViewDelegate>
|
||||
{
|
||||
}
|
||||
|
||||
@@ -432,7 +432,7 @@ public:
|
||||
#ifdef __LP64__
|
||||
WXEXPORT
|
||||
#endif // 64 bit builds
|
||||
@interface wxNSAppController : NSObject wxOSX_10_6_AND_LATER(<NSApplicationDelegate>)
|
||||
@interface wxNSAppController : NSObject <NSApplicationDelegate>
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -20,17 +20,6 @@
|
||||
#include "wx/osx/core/cfstring.h"
|
||||
#include "wx/osx/core/cfdataref.h"
|
||||
|
||||
// Define helper macros allowing to insert small snippets of code to be
|
||||
// compiled for high enough OS X version only: this shouldn't be abused for
|
||||
// anything big but it's handy for e.g. specifying OS X 10.6-only protocols in
|
||||
// the Objective C classes declarations when they're not supported under the
|
||||
// previous versions
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
|
||||
#define wxOSX_10_6_AND_LATER(x) x
|
||||
#else
|
||||
#define wxOSX_10_6_AND_LATER(x)
|
||||
#endif
|
||||
|
||||
// platform specific Clang analyzer support
|
||||
#ifndef NS_RETURNS_RETAINED
|
||||
# if WX_HAS_CLANG_FEATURE(attribute_ns_returns_retained)
|
||||
|
@@ -35,6 +35,9 @@
|
||||
# ifndef MAC_OS_X_VERSION_10_9
|
||||
# define MAC_OS_X_VERSION_10_9 1090
|
||||
# endif
|
||||
# ifndef MAC_OS_X_VERSION_10_10
|
||||
# define MAC_OS_X_VERSION_10_10 101000
|
||||
# endif
|
||||
# include "wx/osx/config_xcode.h"
|
||||
# ifndef __WXOSX__
|
||||
# define __WXOSX__ 1
|
||||
@@ -534,6 +537,9 @@
|
||||
# ifndef MAC_OS_X_VERSION_10_9
|
||||
# define MAC_OS_X_VERSION_10_9 1090
|
||||
# endif
|
||||
# ifndef MAC_OS_X_VERSION_10_10
|
||||
# define MAC_OS_X_VERSION_10_10 101000
|
||||
# endif
|
||||
# else
|
||||
# error "only mach-o configurations are supported"
|
||||
# endif
|
||||
|
@@ -190,13 +190,7 @@ public:
|
||||
{ return m_osVersionMinor; }
|
||||
|
||||
// return true if the OS version >= major.minor
|
||||
bool CheckOSVersion(int major, int minor) const
|
||||
{
|
||||
return DoCheckVersion(GetOSMajorVersion(),
|
||||
GetOSMinorVersion(),
|
||||
major,
|
||||
minor);
|
||||
}
|
||||
bool CheckOSVersion(int major, int minor) const;
|
||||
|
||||
int GetToolkitMajorVersion() const
|
||||
{ return m_tkVersionMajor; }
|
||||
@@ -300,6 +294,8 @@ protected:
|
||||
return majorCur > major || (majorCur == major && minorCur >= minor);
|
||||
}
|
||||
|
||||
bool m_initializedForCurrentPlatform;
|
||||
|
||||
void InitForCurrentPlatform();
|
||||
|
||||
|
||||
|
@@ -143,6 +143,9 @@ WXDLLIMPEXP_BASE wxString wxGetOsDescription();
|
||||
WXDLLIMPEXP_BASE wxOperatingSystemId wxGetOsVersion(int *majorVsn = NULL,
|
||||
int *minorVsn = NULL);
|
||||
|
||||
// Check is OS version is at least the specified major and minor version
|
||||
WXDLLIMPEXP_BASE bool wxCheckOsVersion(int majorVsn, int minorVsn = 0);
|
||||
|
||||
// Get platform endianness
|
||||
WXDLLIMPEXP_BASE bool wxIsPlatformLittleEndian();
|
||||
|
||||
|
@@ -733,10 +733,6 @@ wxString wxGetHomeDir();
|
||||
note that the returned name is @e not fully qualified, i.e. it does not
|
||||
include the domain name.
|
||||
|
||||
Under Windows or NT, this function first looks in the environment variable
|
||||
SYSTEM_NAME; if this is not found, the entry @b HostName in the wxWidgets
|
||||
section of the WIN.INI file is tried.
|
||||
|
||||
@return The hostname if successful or an empty string otherwise.
|
||||
|
||||
@see wxGetFullHostName()
|
||||
@@ -835,7 +831,7 @@ bool wxGetUserName(char* buf, int sz);
|
||||
/**
|
||||
Returns the string containing the description of the current platform in a
|
||||
user-readable form. For example, this function may return strings like
|
||||
"Windows NT Version 4.0" or "Linux 2.2.2 i386".
|
||||
"Windows 10 (build 10240), 64-bit edition" or "Linux 4.1.4 i386".
|
||||
|
||||
@see wxGetOsVersion()
|
||||
|
||||
@@ -851,16 +847,21 @@ wxString wxGetOsDescription();
|
||||
|
||||
For Unix-like systems (@c wxOS_UNIX) the major and minor version integers will
|
||||
contain the kernel major and minor version numbers (as returned by the
|
||||
'uname -r' command); e.g. "2" and "6" if the machine is using kernel 2.6.19.
|
||||
'uname -r' command); e.g. "4" and "1" if the machine is using kernel 4.1.4.
|
||||
|
||||
For Mac OS X systems (@c wxOS_MAC) the major and minor version integers are the
|
||||
natural version numbers associated with the OS; e.g. "10" and "6" if the machine
|
||||
is using Mac OS X Snow Leopard.
|
||||
natural version numbers associated with the OS; e.g. "10" and "11" if the machine
|
||||
is using Mac OS X El Capitan.
|
||||
|
||||
For Windows-like systems (@c wxOS_WINDOWS) the major and minor version integers will
|
||||
contain the following values:
|
||||
@beginTable
|
||||
@row3col{<b>Windows OS name</b>, <b>Major version</b>, <b>Minor version</b>}
|
||||
@row3col{Windows 10, 10, 0}
|
||||
@row3col{Windows 8.1, 6, 3}
|
||||
@row3col{Windows Server 2012 R2, 6, 3}
|
||||
@row3col{Windows 8, 6, 2}
|
||||
@row3col{Windows Server 2012, 6, 2}
|
||||
@row3col{Windows 7, 6, 1}
|
||||
@row3col{Windows Server 2008 R2, 6, 1}
|
||||
@row3col{Windows Server 2008, 6, 0}
|
||||
@@ -868,7 +869,6 @@ wxString wxGetOsDescription();
|
||||
@row3col{Windows Server 2003 R2, 5, 2}
|
||||
@row3col{Windows Server 2003, 5, 2}
|
||||
@row3col{Windows XP, 5, 1}
|
||||
@row3col{Windows 2000, 5, 0}
|
||||
@endDefList
|
||||
See the <a href="http://msdn.microsoft.com/en-us/library/ms724832(VS.85).aspx">MSDN</a>
|
||||
for more info about the values above.
|
||||
@@ -879,6 +879,18 @@ wxString wxGetOsDescription();
|
||||
*/
|
||||
wxOperatingSystemId wxGetOsVersion(int* major = NULL, int* minor = NULL);
|
||||
|
||||
/**
|
||||
Returns @true the version of the operating system on which the program
|
||||
is running under is the same or later than the given version.
|
||||
|
||||
@since 3.1.0
|
||||
|
||||
@see wxGetOsVersion(), wxPlatformInfo
|
||||
|
||||
@header{wx/utils.h}
|
||||
*/
|
||||
bool wxCheckOsVersion(int majorVsn, int minorVsn = 0);
|
||||
|
||||
/**
|
||||
Returns @true if the operating system the program is running under is 64
|
||||
bit. The check is performed at run-time and may differ from the value
|
||||
|
@@ -1679,15 +1679,6 @@ static bool wxCheckWin32Permission(const wxString& path, DWORD access)
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( wxGetOsVersion() == wxOS_WINDOWS_9X )
|
||||
{
|
||||
// FAT directories always allow all access, even if they have the
|
||||
// readonly flag set, and FAT files can only be read-only
|
||||
return (dwAttr & FILE_ATTRIBUTE_DIRECTORY) ||
|
||||
(access != GENERIC_WRITE ||
|
||||
!(dwAttr & FILE_ATTRIBUTE_READONLY));
|
||||
}
|
||||
|
||||
HANDLE h = ::CreateFile
|
||||
(
|
||||
path.t_str(),
|
||||
|
@@ -2606,13 +2606,6 @@ bool wxFileName::SetTimes(const wxDateTime *dtAccess,
|
||||
int flags;
|
||||
if ( IsDir() )
|
||||
{
|
||||
if ( wxGetOsVersion() == wxOS_WINDOWS_9X )
|
||||
{
|
||||
wxLogError(_("Setting directory access times is not supported "
|
||||
"under this OS version"));
|
||||
return false;
|
||||
}
|
||||
|
||||
path = GetPath();
|
||||
flags = FILE_FLAG_BACKUP_SEMANTICS;
|
||||
}
|
||||
|
@@ -135,6 +135,8 @@ wxPlatformInfo::wxPlatformInfo(wxPortId pid, int tkMajor, int tkMinor,
|
||||
wxEndianness endian,
|
||||
bool usingUniversal)
|
||||
{
|
||||
m_initializedForCurrentPlatform = false;
|
||||
|
||||
m_tkVersionMajor = tkMajor;
|
||||
m_tkVersionMinor = tkMinor;
|
||||
m_port = pid;
|
||||
@@ -166,6 +168,8 @@ bool wxPlatformInfo::operator==(const wxPlatformInfo &t) const
|
||||
|
||||
void wxPlatformInfo::InitForCurrentPlatform()
|
||||
{
|
||||
m_initializedForCurrentPlatform = true;
|
||||
|
||||
// autodetect all informations
|
||||
const wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
|
||||
if ( !traits )
|
||||
@@ -294,6 +298,19 @@ wxString wxPlatformInfo::GetEndiannessName(wxEndianness end)
|
||||
return wxEndiannessNames[end];
|
||||
}
|
||||
|
||||
bool wxPlatformInfo::CheckOSVersion(int major, int minor) const
|
||||
{
|
||||
// If this instance of wxPlatformInfo has been initialized by InitForCurrentPlatform()
|
||||
// this check gets forwarded to the wxCheckOsVersion which might do more than a simple
|
||||
// number check if supported by the platform
|
||||
if (m_initializedForCurrentPlatform)
|
||||
return wxCheckOsVersion(major, minor);
|
||||
else
|
||||
return DoCheckVersion(GetOSMajorVersion(),
|
||||
GetOSMinorVersion(),
|
||||
major,
|
||||
minor);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxPlatformInfo - string -> enum conversions
|
||||
|
@@ -996,12 +996,6 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent,
|
||||
const wxString& name )
|
||||
{
|
||||
#ifdef __WXMAC__
|
||||
int major, minor;
|
||||
wxGetOsVersion(&major, &minor);
|
||||
|
||||
if (major < 10)
|
||||
style |= wxTR_ROW_LINES;
|
||||
|
||||
if (style & wxTR_HAS_BUTTONS)
|
||||
style |= wxTR_NO_LINES;
|
||||
#endif // __WXMAC__
|
||||
|
@@ -300,19 +300,6 @@ bool wxPenRefData::Alloc()
|
||||
const COLORREF col = m_colour.GetPixel();
|
||||
|
||||
#ifdef wxHAVE_EXT_CREATE_PEN
|
||||
// Only NT can display dashed or dotted lines with width > 1
|
||||
static const int os = wxGetOsVersion();
|
||||
if ( os != wxOS_WINDOWS_NT &&
|
||||
(m_style == wxPENSTYLE_DOT ||
|
||||
m_style == wxPENSTYLE_LONG_DASH ||
|
||||
m_style == wxPENSTYLE_SHORT_DASH ||
|
||||
m_style == wxPENSTYLE_DOT_DASH ||
|
||||
m_style == wxPENSTYLE_USER_DASH) &&
|
||||
m_width > 1 )
|
||||
{
|
||||
m_width = 1;
|
||||
}
|
||||
|
||||
// check if it's a standard kind of pen which can be created with just
|
||||
// CreatePen()
|
||||
if ( m_join == wxJOIN_ROUND &&
|
||||
|
@@ -1341,15 +1341,7 @@ bool wxTopLevelWindowMSW::SetTransparent(wxByte alpha)
|
||||
|
||||
bool wxTopLevelWindowMSW::CanSetTransparent()
|
||||
{
|
||||
// The API is available on win2k and above
|
||||
|
||||
static int os_type = -1;
|
||||
static int ver_major = -1;
|
||||
|
||||
if (os_type == -1)
|
||||
os_type = ::wxGetOsVersion(&ver_major);
|
||||
|
||||
return (os_type == wxOS_WINDOWS_NT && ver_major >= 5);
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxTopLevelWindowMSW::DoFreeze()
|
||||
|
@@ -891,36 +891,33 @@ bool wxShutdown(int WXUNUSED_IN_WINCE(flags))
|
||||
#else
|
||||
bool bOK = true;
|
||||
|
||||
if ( wxGetOsVersion(NULL, NULL) == wxOS_WINDOWS_NT ) // if is NT or 2K
|
||||
// Get a token for this process.
|
||||
HANDLE hToken;
|
||||
bOK = ::OpenProcessToken(GetCurrentProcess(),
|
||||
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
|
||||
&hToken) != 0;
|
||||
if ( bOK )
|
||||
{
|
||||
// Get a token for this process.
|
||||
HANDLE hToken;
|
||||
bOK = ::OpenProcessToken(GetCurrentProcess(),
|
||||
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
|
||||
&hToken) != 0;
|
||||
TOKEN_PRIVILEGES tkp;
|
||||
|
||||
// Get the LUID for the shutdown privilege.
|
||||
bOK = ::LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
|
||||
&tkp.Privileges[0].Luid) != 0;
|
||||
|
||||
if ( bOK )
|
||||
{
|
||||
TOKEN_PRIVILEGES tkp;
|
||||
tkp.PrivilegeCount = 1; // one privilege to set
|
||||
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
|
||||
// Get the LUID for the shutdown privilege.
|
||||
bOK = ::LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
|
||||
&tkp.Privileges[0].Luid) != 0;
|
||||
// Get the shutdown privilege for this process.
|
||||
::AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
|
||||
(PTOKEN_PRIVILEGES)NULL, 0);
|
||||
|
||||
if ( bOK )
|
||||
{
|
||||
tkp.PrivilegeCount = 1; // one privilege to set
|
||||
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
|
||||
|
||||
// Get the shutdown privilege for this process.
|
||||
::AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
|
||||
(PTOKEN_PRIVILEGES)NULL, 0);
|
||||
|
||||
// Cannot test the return value of AdjustTokenPrivileges.
|
||||
bOK = ::GetLastError() == ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
::CloseHandle(hToken);
|
||||
// Cannot test the return value of AdjustTokenPrivileges.
|
||||
bOK = ::GetLastError() == ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
::CloseHandle(hToken);
|
||||
}
|
||||
|
||||
if ( bOK )
|
||||
@@ -1330,6 +1327,21 @@ wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin)
|
||||
return s_version.os;
|
||||
}
|
||||
|
||||
bool wxCheckOsVersion(int majorVsn, int minorVsn)
|
||||
{
|
||||
OSVERSIONINFOEX osvi = { sizeof(osvi), 0, 0, 0, 0, { 0 }, 0, 0 };
|
||||
DWORDLONG const dwlConditionMask =
|
||||
::VerSetConditionMask(
|
||||
::VerSetConditionMask(
|
||||
0, VER_MAJORVERSION, VER_GREATER_EQUAL),
|
||||
VER_MINORVERSION, VER_GREATER_EQUAL);
|
||||
|
||||
osvi.dwMajorVersion = majorVsn;
|
||||
osvi.dwMinorVersion = minorVsn;
|
||||
|
||||
return ::VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION, dwlConditionMask) != FALSE;
|
||||
}
|
||||
|
||||
wxWinVersion wxGetWinVersion()
|
||||
{
|
||||
int verMaj,
|
||||
|
@@ -761,8 +761,7 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler,
|
||||
DWORD dwFlags = CREATE_SUSPENDED;
|
||||
|
||||
#ifndef __WXWINCE__
|
||||
if ( (flags & wxEXEC_MAKE_GROUP_LEADER) &&
|
||||
(wxGetOsVersion() == wxOS_WINDOWS_NT) )
|
||||
if ( (flags & wxEXEC_MAKE_GROUP_LEADER) )
|
||||
dwFlags |= CREATE_NEW_PROCESS_GROUP;
|
||||
|
||||
dwFlags |= CREATE_DEFAULT_ERROR_MODE ;
|
||||
|
@@ -917,22 +917,9 @@ void wxWindowMSW::WarpPointer(int x, int y)
|
||||
|
||||
void wxWindowMSW::MSWUpdateUIState(int action, int state)
|
||||
{
|
||||
// WM_CHANGEUISTATE only appeared in Windows 2000 so it can do us no good
|
||||
// to use it on older systems -- and could possibly do some harm
|
||||
static int s_needToUpdate = -1;
|
||||
if ( s_needToUpdate == -1 )
|
||||
{
|
||||
int verMaj, verMin;
|
||||
s_needToUpdate = wxGetOsVersion(&verMaj, &verMin) == wxOS_WINDOWS_NT &&
|
||||
verMaj >= 5;
|
||||
}
|
||||
|
||||
if ( s_needToUpdate )
|
||||
{
|
||||
// we send WM_CHANGEUISTATE so if nothing needs changing then the system
|
||||
// won't send WM_UPDATEUISTATE
|
||||
::SendMessage(GetHwnd(), WM_CHANGEUISTATE, MAKEWPARAM(action, state), 0);
|
||||
}
|
||||
// we send WM_CHANGEUISTATE so if nothing needs changing then the system
|
||||
// won't send WM_UPDATEUISTATE
|
||||
::SendMessage(GetHwnd(), WM_CHANGEUISTATE, MAKEWPARAM(action, state), 0);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@@ -41,7 +41,7 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog);
|
||||
// wxCPWCDelegate - Window Closed delegate
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@interface wxCPWCDelegate : NSObject wxOSX_10_6_AND_LATER(<NSWindowDelegate>)
|
||||
@interface wxCPWCDelegate : NSObject <NSWindowDelegate>
|
||||
{
|
||||
bool m_bIsClosed;
|
||||
}
|
||||
|
@@ -494,12 +494,7 @@ CGContextRef WXDLLIMPEXP_CORE wxOSXCreateBitmapContextFromNSImage( WX_NSImage ns
|
||||
|
||||
double wxOSXGetMainScreenContentScaleFactor()
|
||||
{
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
|
||||
if ( [ [NSScreen mainScreen] respondsToSelector:@selector(backingScaleFactor)] )
|
||||
return [[NSScreen mainScreen] backingScaleFactor];
|
||||
else
|
||||
#endif
|
||||
return 1.0;
|
||||
return [[NSScreen mainScreen] backingScaleFactor];
|
||||
}
|
||||
|
||||
CGImageRef wxOSXCreateCGImageFromNSImage( WX_NSImage nsimage, double *scaleptr )
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
// work in progress
|
||||
|
||||
@interface wxNSTableDataSource : NSObject wxOSX_10_6_AND_LATER(<NSComboBoxDataSource>)
|
||||
@interface wxNSTableDataSource : NSObject <NSComboBoxDataSource>
|
||||
{
|
||||
wxNSComboBoxControl* impl;
|
||||
}
|
||||
|
@@ -52,33 +52,7 @@
|
||||
// then the delegate method - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename will have to
|
||||
// be implemented
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
bool HasAppKit_10_6()
|
||||
{
|
||||
// Even if we require 10.6, we might be loaded by an application that
|
||||
// was linked against 10.5. setAllowedFileTypes will still be ignored
|
||||
// in this case. From NSSavePanel.h:
|
||||
// NSOpenPanel: On versions less than 10.6, this property is ignored.
|
||||
// For applications that link against 10.6 and higher, this property will
|
||||
// determine which files should be enabled in the open panel.
|
||||
int32_t version = NSVersionOfLinkTimeLibrary("AppKit");
|
||||
if (version == -1)
|
||||
{
|
||||
// If we're loaded by an application that doesn't link against AppKit,
|
||||
// use the runtime version instead. This check will not work for the
|
||||
// case above.
|
||||
version = NSVersionOfRunTimeLibrary("AppKit");
|
||||
}
|
||||
|
||||
// Notice that this still works correctly even if version is -1.
|
||||
return version >= 0x40e2400 /* version of 10.6 AppKit */;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
@interface wxOpenPanelDelegate : NSObject wxOSX_10_6_AND_LATER(<NSOpenSavePanelDelegate>)
|
||||
@interface wxOpenPanelDelegate : NSObject <NSOpenSavePanelDelegate>
|
||||
{
|
||||
wxFileDialog* _dialog;
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@
|
||||
|
||||
class wxListWidgetCocoaImpl;
|
||||
|
||||
@interface wxNSTableDataSource : NSObject wxOSX_10_6_AND_LATER(<NSTableViewDataSource>)
|
||||
@interface wxNSTableDataSource : NSObject <NSTableViewDataSource>
|
||||
{
|
||||
wxListWidgetCocoaImpl* impl;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ class wxListWidgetCocoaImpl;
|
||||
|
||||
@end
|
||||
|
||||
@interface wxNSTableView : NSTableView wxOSX_10_6_AND_LATER(<NSTableViewDelegate>)
|
||||
@interface wxNSTableView : NSTableView <NSTableViewDelegate>
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -58,7 +58,7 @@
|
||||
// and under 10.4, we are not getting a 'close' event however...
|
||||
#define wxOSX_USE_NEEDSUPDATE_HOOK 1
|
||||
|
||||
@interface wxNSMenuController : NSObject wxOSX_10_6_AND_LATER(<NSMenuDelegate>)
|
||||
@interface wxNSMenuController : NSObject <NSMenuDelegate>
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -91,19 +91,11 @@ bool shouldHandleSelector(SEL selector)
|
||||
|
||||
}
|
||||
|
||||
|
||||
#define wxHAS_FULL_SCREEN_API (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
|
||||
|
||||
#if wxHAS_FULL_SCREEN_API
|
||||
|
||||
static bool IsUsingFullScreenApi(WXWindow macWindow)
|
||||
{
|
||||
return [macWindow respondsToSelector:@selector(toggleFullScreen:)]
|
||||
&& ([macWindow collectionBehavior] & NSWindowCollectionBehaviorFullScreenPrimary);
|
||||
return ([macWindow collectionBehavior] & NSWindowCollectionBehaviorFullScreenPrimary);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// wx category for NSWindow (our own and wrapped instances)
|
||||
//
|
||||
@@ -313,7 +305,7 @@ static NSResponder* s_formerFirstResponder = NULL;
|
||||
// controller
|
||||
//
|
||||
|
||||
@interface wxNonOwnedWindowController : NSObject wxOSX_10_6_AND_LATER(<NSWindowDelegate>)
|
||||
@interface wxNonOwnedWindowController : NSObject <NSWindowDelegate>
|
||||
{
|
||||
}
|
||||
|
||||
@@ -326,9 +318,7 @@ static NSResponder* s_formerFirstResponder = NULL;
|
||||
- (void)windowDidDeminiaturize:(NSNotification *)notification;
|
||||
- (BOOL)windowShouldClose:(id)window;
|
||||
- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame;
|
||||
#if wxHAS_FULL_SCREEN_API
|
||||
- (void)windowWillEnterFullScreen:(NSNotification *)notification;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
@@ -585,8 +575,6 @@ extern int wxOSXGetIdFromSelector(SEL action );
|
||||
return true;
|
||||
}
|
||||
|
||||
#if wxHAS_FULL_SCREEN_API
|
||||
|
||||
// work around OS X bug, on a secondary monitor an already fully sized window
|
||||
// (eg maximized) will not be correctly put to full screen size and keeps a 22px
|
||||
// title band at the top free, therefore we force the correct content size
|
||||
@@ -607,8 +595,6 @@ extern int wxOSXGetIdFromSelector(SEL action );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
wxIMPLEMENT_DYNAMIC_CLASS(wxNonOwnedWindowCocoaImpl , wxNonOwnedWindowImpl);
|
||||
@@ -1000,44 +986,32 @@ typedef struct
|
||||
|
||||
bool wxNonOwnedWindowCocoaImpl::IsFullScreen() const
|
||||
{
|
||||
#if wxHAS_FULL_SCREEN_API
|
||||
if ( IsUsingFullScreenApi(m_macWindow) )
|
||||
{
|
||||
return [m_macWindow styleMask] & NSFullScreenWindowMask;
|
||||
}
|
||||
#endif
|
||||
|
||||
return m_macFullScreenData != NULL ;
|
||||
}
|
||||
|
||||
bool wxNonOwnedWindowCocoaImpl::EnableFullScreenView(bool enable)
|
||||
{
|
||||
#if wxHAS_FULL_SCREEN_API
|
||||
if ( [ m_macWindow respondsToSelector:@selector(setCollectionBehavior:) ] )
|
||||
NSUInteger collectionBehavior = [m_macWindow collectionBehavior];
|
||||
if (enable)
|
||||
{
|
||||
NSUInteger collectionBehavior = [m_macWindow collectionBehavior];
|
||||
if (enable)
|
||||
{
|
||||
collectionBehavior |= NSWindowCollectionBehaviorFullScreenPrimary;
|
||||
}
|
||||
else
|
||||
{
|
||||
collectionBehavior &= ~NSWindowCollectionBehaviorFullScreenPrimary;
|
||||
}
|
||||
[m_macWindow setCollectionBehavior: collectionBehavior];
|
||||
|
||||
return true;
|
||||
collectionBehavior |= NSWindowCollectionBehaviorFullScreenPrimary;
|
||||
}
|
||||
#else
|
||||
wxUnusedVar(enable);
|
||||
#endif
|
||||
else
|
||||
{
|
||||
collectionBehavior &= ~NSWindowCollectionBehaviorFullScreenPrimary;
|
||||
}
|
||||
[m_macWindow setCollectionBehavior: collectionBehavior];
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxNonOwnedWindowCocoaImpl::ShowFullScreen(bool show, long WXUNUSED(style))
|
||||
{
|
||||
#if wxHAS_FULL_SCREEN_API
|
||||
if ( IsUsingFullScreenApi(m_macWindow) )
|
||||
{
|
||||
if ( show != IsFullScreen() )
|
||||
@@ -1047,7 +1021,6 @@ bool wxNonOwnedWindowCocoaImpl::ShowFullScreen(bool show, long WXUNUSED(style))
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( show )
|
||||
{
|
||||
|
@@ -29,7 +29,7 @@
|
||||
// controller
|
||||
//
|
||||
|
||||
@interface wxTabViewController : NSObject wxOSX_10_6_AND_LATER(<NSTabViewDelegate>)
|
||||
@interface wxTabViewController : NSObject <NSTabViewDelegate>
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -827,7 +827,7 @@ wxNSTextFieldControl::wxNSTextFieldControl(wxWindow *wxPeer,
|
||||
|
||||
void wxNSTextFieldControl::Init(WXWidget w)
|
||||
{
|
||||
NSTextField wxOSX_10_6_AND_LATER(<NSTextFieldDelegate>) *tf = (NSTextField wxOSX_10_6_AND_LATER(<NSTextFieldDelegate>)*) w;
|
||||
NSTextField <NSTextFieldDelegate> *tf = (NSTextField <NSTextFieldDelegate>*) w;
|
||||
m_textField = tf;
|
||||
[m_textField setDelegate: tf];
|
||||
m_selStart = m_selEnd = 0;
|
||||
|
@@ -301,7 +301,7 @@ private:
|
||||
@end
|
||||
|
||||
|
||||
@interface wxNSToolbarDelegate : NSObject wxOSX_10_6_AND_LATER(<NSToolbarDelegate>)
|
||||
@interface wxNSToolbarDelegate : NSObject <NSToolbarDelegate>
|
||||
{
|
||||
bool m_isSelectable;
|
||||
}
|
||||
|
@@ -412,7 +412,7 @@ bool wxApp::DoInitGui()
|
||||
}
|
||||
|
||||
appcontroller = OSXCreateAppController();
|
||||
[[NSApplication sharedApplication] setDelegate:(id wxOSX_10_6_AND_LATER(<NSApplicationDelegate>))appcontroller];
|
||||
[[NSApplication sharedApplication] setDelegate:(id <NSApplicationDelegate>)appcontroller];
|
||||
[NSColor setIgnoresAlpha:NO];
|
||||
|
||||
// calling finishLaunching so early before running the loop seems to trigger some 'MenuManager compatibility' which leads
|
||||
@@ -618,4 +618,67 @@ wxBitmap wxWindowDCImpl::DoGetAsBitmap(const wxRect *subrect) const
|
||||
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
// our OS version is the same in non GUI and GUI cases
|
||||
wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn)
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10
|
||||
if ([NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)])
|
||||
{
|
||||
NSOperatingSystemVersion osVer = [NSProcessInfo processInfo].operatingSystemVersion;
|
||||
|
||||
if ( majorVsn != NULL )
|
||||
*majorVsn = osVer.majorVersion;
|
||||
|
||||
if ( minorVsn != NULL )
|
||||
*minorVsn = osVer.minorVersion;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// On OS X versions prior to 10.10 NSProcessInfo does not provide the OS version
|
||||
SInt32 maj, min;
|
||||
Gestalt(gestaltSystemVersionMajor, &maj);
|
||||
Gestalt(gestaltSystemVersionMinor, &min);
|
||||
|
||||
if ( majorVsn != NULL )
|
||||
*majorVsn = maj;
|
||||
|
||||
if ( minorVsn != NULL )
|
||||
*minorVsn = min;
|
||||
}
|
||||
|
||||
return wxOS_MAC_OSX_DARWIN;
|
||||
}
|
||||
|
||||
bool wxCheckOsVersion(int majorVsn, int minorVsn)
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10
|
||||
if ([NSProcessInfo instancesRespondToSelector:@selector(isOperatingSystemAtLeastVersion:)])
|
||||
{
|
||||
NSOperatingSystemVersion osVer;
|
||||
osVer.majorVersion = majorVsn;
|
||||
osVer.minorVersion = minorVsn;
|
||||
osVer.patchVersion = 0;
|
||||
|
||||
return [[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:osVer] != NO;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
int majorCur, minorCur;
|
||||
wxGetOsVersion(&majorCur, &minorCur);
|
||||
|
||||
return majorCur > majorVsn || (majorCur == majorVsn && minorCur >= minorVsn);
|
||||
}
|
||||
}
|
||||
|
||||
wxString wxGetOsDescription()
|
||||
{
|
||||
NSString* osDesc = [NSProcessInfo processInfo].operatingSystemVersionString;
|
||||
wxCFStringRef cf(wxCFRetain(osDesc));
|
||||
|
||||
return wxString::Format(wxT("Mac OS X %s"),
|
||||
cf.AsString());
|
||||
}
|
||||
|
||||
#endif // wxOSX_USE_COCOA
|
||||
|
@@ -1755,9 +1755,7 @@ void wxOSXCocoaClassAddWXMethods(Class c)
|
||||
wxOSX_CLASS_ADD_METHOD(c, @selector(mouseEntered:), (IMP) wxOSX_mouseEvent, "v@:@" )
|
||||
wxOSX_CLASS_ADD_METHOD(c, @selector(mouseExited:), (IMP) wxOSX_mouseEvent, "v@:@" )
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
wxOSX_CLASS_ADD_METHOD(c, @selector(magnifyWithEvent:), (IMP)wxOSX_mouseEvent, "v@:@")
|
||||
#endif
|
||||
|
||||
wxOSX_CLASS_ADD_METHOD(c, @selector(cursorUpdate:), (IMP) wxOSX_cursorUpdate, "v@:@" )
|
||||
|
||||
@@ -1870,13 +1868,8 @@ void wxWidgetCocoaImpl::SetVisibility( bool visible )
|
||||
|
||||
double wxWidgetCocoaImpl::GetContentScaleFactor() const
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
NSWindow* tlw = [m_osxView window];
|
||||
if ( [ tlw respondsToSelector:@selector(backingScaleFactor) ] )
|
||||
return [tlw backingScaleFactor];
|
||||
else
|
||||
#endif
|
||||
return 1.0;
|
||||
return [tlw backingScaleFactor];
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -1884,7 +1877,7 @@ double wxWidgetCocoaImpl::GetContentScaleFactor() const
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// define a delegate used to refresh the window during animation
|
||||
@interface wxNSAnimationDelegate : NSObject wxOSX_10_6_AND_LATER(<NSAnimationDelegate>)
|
||||
@interface wxNSAnimationDelegate : NSObject <NSAnimationDelegate>
|
||||
{
|
||||
wxWindow *m_win;
|
||||
bool m_isDone;
|
||||
|
@@ -53,7 +53,7 @@ extern WXDLLIMPEXP_BASE wxSocketManager *wxOSXSocketManagerCF;
|
||||
wxSocketManager *wxOSXSocketManagerCF = NULL;
|
||||
#endif // wxUSE_SOCKETS
|
||||
|
||||
#if ( !wxUSE_GUI && !wxOSX_USE_IPHONE ) || wxOSX_USE_COCOA_OR_CARBON
|
||||
#if ( !wxUSE_GUI && !wxOSX_USE_IPHONE ) || wxOSX_USE_CARBON
|
||||
|
||||
// our OS version is the same in non GUI and GUI cases
|
||||
wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn)
|
||||
@@ -70,16 +70,6 @@ wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn)
|
||||
if ( minorVsn != NULL )
|
||||
*minorVsn = min;
|
||||
|
||||
#if 0
|
||||
SInt32 theSystem;
|
||||
Gestalt(gestaltSystemVersion, &theSystem);
|
||||
|
||||
if ( majorVsn != NULL )
|
||||
*majorVsn = (theSystem >> 8);
|
||||
|
||||
if ( minorVsn != NULL )
|
||||
*minorVsn = (theSystem & 0xFF);
|
||||
#endif
|
||||
return wxOS_MAC_OSX_DARWIN;
|
||||
}
|
||||
|
||||
@@ -95,6 +85,10 @@ wxString wxGetOsDescription()
|
||||
wxString::FromAscii(name.machine).c_str());
|
||||
}
|
||||
|
||||
#endif // wxOSX_USE_CARBON
|
||||
|
||||
#if ( !wxUSE_GUI && !wxOSX_USE_IPHONE ) || wxOSX_USE_COCOA_OR_CARBON
|
||||
|
||||
//===========================================================================
|
||||
// IMPLEMENTATION
|
||||
//===========================================================================
|
||||
|
@@ -1148,6 +1148,14 @@ wxString wxGetOsDescription()
|
||||
return wxGetCommandOutput(wxT("uname -s -r -m"));
|
||||
}
|
||||
|
||||
bool wxCheckOsVersion(int majorVsn, int minorVsn)
|
||||
{
|
||||
int majorCur, minorCur;
|
||||
wxGetOsVersion(&majorCur, &minorCur);
|
||||
|
||||
return majorCur > majorVsn || (majorCur == majorVsn && minorCur >= minorVsn);
|
||||
}
|
||||
|
||||
#endif // !__DARWIN__
|
||||
|
||||
unsigned long wxGetProcessId()
|
||||
|
Reference in New Issue
Block a user