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:
VZ
2015-08-08 00:44:28 +02:00
32 changed files with 201 additions and 223 deletions

View File

@@ -22,13 +22,13 @@ Platforms
wxWidgets currently supports the following primary 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). - 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). - 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: 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. - g++ 3.4 or later, including MinGW/MinGW-64/TDM under Windows.
- Clang under OS X and Linux. - Clang under OS X and Linux.
- Intel icc compiler. - Intel icc compiler.

View File

@@ -45,9 +45,9 @@ Platforms supported
wxWidgets currently supports the following primary 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) - 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: There is some support for the following platforms:

View File

@@ -249,7 +249,7 @@ private:
// owned by the set. Furthermore, children of the last parent are stored // owned by the set. Furthermore, children of the last parent are stored
// in a linear list. // 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 // descriptors specifying the sorting (currently the array only holds one
// object only) // object only)
@@ -395,7 +395,7 @@ private:
// wxCocoaOutlineView // wxCocoaOutlineView
// ============================================================================ // ============================================================================
@interface wxCocoaOutlineView : NSOutlineView wxOSX_10_6_AND_LATER(<NSOutlineViewDelegate>) @interface wxCocoaOutlineView : NSOutlineView <NSOutlineViewDelegate>
{ {
@private @private
// column and row of the cell being edited or -1 if none // column and row of the cell being edited or -1 if none

View File

@@ -336,7 +336,7 @@ public:
- (void) setTextField:(NSTextField*) field; - (void) setTextField:(NSTextField*) field;
@end @end
@interface wxNSTextField : NSTextField wxOSX_10_6_AND_LATER(<NSTextFieldDelegate>) @interface wxNSTextField : NSTextField <NSTextFieldDelegate>
{ {
wxNSTextFieldEditor* fieldEditor; wxNSTextFieldEditor* fieldEditor;
} }
@@ -346,14 +346,14 @@ public:
@end @end
@interface wxNSSecureTextField : NSSecureTextField wxOSX_10_6_AND_LATER(<NSTextFieldDelegate>) @interface wxNSSecureTextField : NSSecureTextField <NSTextFieldDelegate>
{ {
} }
@end @end
@interface wxNSTextView : NSTextView wxOSX_10_6_AND_LATER(<NSTextViewDelegate>) @interface wxNSTextView : NSTextView <NSTextViewDelegate>
{ {
} }
@@ -432,7 +432,7 @@ public:
#ifdef __LP64__ #ifdef __LP64__
WXEXPORT WXEXPORT
#endif // 64 bit builds #endif // 64 bit builds
@interface wxNSAppController : NSObject wxOSX_10_6_AND_LATER(<NSApplicationDelegate>) @interface wxNSAppController : NSObject <NSApplicationDelegate>
{ {
} }

View File

@@ -20,17 +20,6 @@
#include "wx/osx/core/cfstring.h" #include "wx/osx/core/cfstring.h"
#include "wx/osx/core/cfdataref.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 // platform specific Clang analyzer support
#ifndef NS_RETURNS_RETAINED #ifndef NS_RETURNS_RETAINED
# if WX_HAS_CLANG_FEATURE(attribute_ns_returns_retained) # if WX_HAS_CLANG_FEATURE(attribute_ns_returns_retained)

View File

@@ -35,6 +35,9 @@
# ifndef MAC_OS_X_VERSION_10_9 # ifndef MAC_OS_X_VERSION_10_9
# define MAC_OS_X_VERSION_10_9 1090 # define MAC_OS_X_VERSION_10_9 1090
# endif # endif
# ifndef MAC_OS_X_VERSION_10_10
# define MAC_OS_X_VERSION_10_10 101000
# endif
# include "wx/osx/config_xcode.h" # include "wx/osx/config_xcode.h"
# ifndef __WXOSX__ # ifndef __WXOSX__
# define __WXOSX__ 1 # define __WXOSX__ 1
@@ -534,6 +537,9 @@
# ifndef MAC_OS_X_VERSION_10_9 # ifndef MAC_OS_X_VERSION_10_9
# define MAC_OS_X_VERSION_10_9 1090 # define MAC_OS_X_VERSION_10_9 1090
# endif # endif
# ifndef MAC_OS_X_VERSION_10_10
# define MAC_OS_X_VERSION_10_10 101000
# endif
# else # else
# error "only mach-o configurations are supported" # error "only mach-o configurations are supported"
# endif # endif

View File

@@ -190,13 +190,7 @@ public:
{ return m_osVersionMinor; } { return m_osVersionMinor; }
// return true if the OS version >= major.minor // return true if the OS version >= major.minor
bool CheckOSVersion(int major, int minor) const bool CheckOSVersion(int major, int minor) const;
{
return DoCheckVersion(GetOSMajorVersion(),
GetOSMinorVersion(),
major,
minor);
}
int GetToolkitMajorVersion() const int GetToolkitMajorVersion() const
{ return m_tkVersionMajor; } { return m_tkVersionMajor; }
@@ -300,6 +294,8 @@ protected:
return majorCur > major || (majorCur == major && minorCur >= minor); return majorCur > major || (majorCur == major && minorCur >= minor);
} }
bool m_initializedForCurrentPlatform;
void InitForCurrentPlatform(); void InitForCurrentPlatform();

View File

@@ -143,6 +143,9 @@ WXDLLIMPEXP_BASE wxString wxGetOsDescription();
WXDLLIMPEXP_BASE wxOperatingSystemId wxGetOsVersion(int *majorVsn = NULL, WXDLLIMPEXP_BASE wxOperatingSystemId wxGetOsVersion(int *majorVsn = NULL,
int *minorVsn = 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 // Get platform endianness
WXDLLIMPEXP_BASE bool wxIsPlatformLittleEndian(); WXDLLIMPEXP_BASE bool wxIsPlatformLittleEndian();

View File

@@ -733,10 +733,6 @@ wxString wxGetHomeDir();
note that the returned name is @e not fully qualified, i.e. it does not note that the returned name is @e not fully qualified, i.e. it does not
include the domain name. 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. @return The hostname if successful or an empty string otherwise.
@see wxGetFullHostName() @see wxGetFullHostName()
@@ -835,7 +831,7 @@ bool wxGetUserName(char* buf, int sz);
/** /**
Returns the string containing the description of the current platform in a Returns the string containing the description of the current platform in a
user-readable form. For example, this function may return strings like 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() @see wxGetOsVersion()
@@ -851,16 +847,21 @@ wxString wxGetOsDescription();
For Unix-like systems (@c wxOS_UNIX) the major and minor version integers will 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 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 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 natural version numbers associated with the OS; e.g. "10" and "11" if the machine
is using Mac OS X Snow Leopard. is using Mac OS X El Capitan.
For Windows-like systems (@c wxOS_WINDOWS) the major and minor version integers will For Windows-like systems (@c wxOS_WINDOWS) the major and minor version integers will
contain the following values: contain the following values:
@beginTable @beginTable
@row3col{<b>Windows OS name</b>, <b>Major version</b>, <b>Minor version</b>} @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 7, 6, 1}
@row3col{Windows Server 2008 R2, 6, 1} @row3col{Windows Server 2008 R2, 6, 1}
@row3col{Windows Server 2008, 6, 0} @row3col{Windows Server 2008, 6, 0}
@@ -868,7 +869,6 @@ wxString wxGetOsDescription();
@row3col{Windows Server 2003 R2, 5, 2} @row3col{Windows Server 2003 R2, 5, 2}
@row3col{Windows Server 2003, 5, 2} @row3col{Windows Server 2003, 5, 2}
@row3col{Windows XP, 5, 1} @row3col{Windows XP, 5, 1}
@row3col{Windows 2000, 5, 0}
@endDefList @endDefList
See the <a href="http://msdn.microsoft.com/en-us/library/ms724832(VS.85).aspx">MSDN</a> See the <a href="http://msdn.microsoft.com/en-us/library/ms724832(VS.85).aspx">MSDN</a>
for more info about the values above. for more info about the values above.
@@ -879,6 +879,18 @@ wxString wxGetOsDescription();
*/ */
wxOperatingSystemId wxGetOsVersion(int* major = NULL, int* minor = NULL); 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 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 bit. The check is performed at run-time and may differ from the value

View File

@@ -1679,15 +1679,6 @@ static bool wxCheckWin32Permission(const wxString& path, DWORD access)
return false; 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 HANDLE h = ::CreateFile
( (
path.t_str(), path.t_str(),

View File

@@ -2606,13 +2606,6 @@ bool wxFileName::SetTimes(const wxDateTime *dtAccess,
int flags; int flags;
if ( IsDir() ) if ( IsDir() )
{ {
if ( wxGetOsVersion() == wxOS_WINDOWS_9X )
{
wxLogError(_("Setting directory access times is not supported "
"under this OS version"));
return false;
}
path = GetPath(); path = GetPath();
flags = FILE_FLAG_BACKUP_SEMANTICS; flags = FILE_FLAG_BACKUP_SEMANTICS;
} }

View File

@@ -135,6 +135,8 @@ wxPlatformInfo::wxPlatformInfo(wxPortId pid, int tkMajor, int tkMinor,
wxEndianness endian, wxEndianness endian,
bool usingUniversal) bool usingUniversal)
{ {
m_initializedForCurrentPlatform = false;
m_tkVersionMajor = tkMajor; m_tkVersionMajor = tkMajor;
m_tkVersionMinor = tkMinor; m_tkVersionMinor = tkMinor;
m_port = pid; m_port = pid;
@@ -166,6 +168,8 @@ bool wxPlatformInfo::operator==(const wxPlatformInfo &t) const
void wxPlatformInfo::InitForCurrentPlatform() void wxPlatformInfo::InitForCurrentPlatform()
{ {
m_initializedForCurrentPlatform = true;
// autodetect all informations // autodetect all informations
const wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL; const wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
if ( !traits ) if ( !traits )
@@ -294,6 +298,19 @@ wxString wxPlatformInfo::GetEndiannessName(wxEndianness end)
return wxEndiannessNames[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 // wxPlatformInfo - string -> enum conversions

View File

@@ -996,12 +996,6 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent,
const wxString& name ) const wxString& name )
{ {
#ifdef __WXMAC__ #ifdef __WXMAC__
int major, minor;
wxGetOsVersion(&major, &minor);
if (major < 10)
style |= wxTR_ROW_LINES;
if (style & wxTR_HAS_BUTTONS) if (style & wxTR_HAS_BUTTONS)
style |= wxTR_NO_LINES; style |= wxTR_NO_LINES;
#endif // __WXMAC__ #endif // __WXMAC__

View File

@@ -300,19 +300,6 @@ bool wxPenRefData::Alloc()
const COLORREF col = m_colour.GetPixel(); const COLORREF col = m_colour.GetPixel();
#ifdef wxHAVE_EXT_CREATE_PEN #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 // check if it's a standard kind of pen which can be created with just
// CreatePen() // CreatePen()
if ( m_join == wxJOIN_ROUND && if ( m_join == wxJOIN_ROUND &&

View File

@@ -1341,15 +1341,7 @@ bool wxTopLevelWindowMSW::SetTransparent(wxByte alpha)
bool wxTopLevelWindowMSW::CanSetTransparent() bool wxTopLevelWindowMSW::CanSetTransparent()
{ {
// The API is available on win2k and above return true;
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);
} }
void wxTopLevelWindowMSW::DoFreeze() void wxTopLevelWindowMSW::DoFreeze()

View File

@@ -891,36 +891,33 @@ bool wxShutdown(int WXUNUSED_IN_WINCE(flags))
#else #else
bool bOK = true; 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. TOKEN_PRIVILEGES tkp;
HANDLE hToken;
bOK = ::OpenProcessToken(GetCurrentProcess(), // Get the LUID for the shutdown privilege.
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, bOK = ::LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
&hToken) != 0; &tkp.Privileges[0].Luid) != 0;
if ( bOK ) 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. // Get the shutdown privilege for this process.
bOK = ::LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, ::AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
&tkp.Privileges[0].Luid) != 0; (PTOKEN_PRIVILEGES)NULL, 0);
if ( bOK ) // Cannot test the return value of AdjustTokenPrivileges.
{ bOK = ::GetLastError() == ERROR_SUCCESS;
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);
} }
::CloseHandle(hToken);
} }
if ( bOK ) if ( bOK )
@@ -1330,6 +1327,21 @@ wxOperatingSystemId wxGetOsVersion(int *verMaj, int *verMin)
return s_version.os; 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() wxWinVersion wxGetWinVersion()
{ {
int verMaj, int verMaj,

View File

@@ -761,8 +761,7 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler,
DWORD dwFlags = CREATE_SUSPENDED; DWORD dwFlags = CREATE_SUSPENDED;
#ifndef __WXWINCE__ #ifndef __WXWINCE__
if ( (flags & wxEXEC_MAKE_GROUP_LEADER) && if ( (flags & wxEXEC_MAKE_GROUP_LEADER) )
(wxGetOsVersion() == wxOS_WINDOWS_NT) )
dwFlags |= CREATE_NEW_PROCESS_GROUP; dwFlags |= CREATE_NEW_PROCESS_GROUP;
dwFlags |= CREATE_DEFAULT_ERROR_MODE ; dwFlags |= CREATE_DEFAULT_ERROR_MODE ;

View File

@@ -917,22 +917,9 @@ void wxWindowMSW::WarpPointer(int x, int y)
void wxWindowMSW::MSWUpdateUIState(int action, int state) void wxWindowMSW::MSWUpdateUIState(int action, int state)
{ {
// WM_CHANGEUISTATE only appeared in Windows 2000 so it can do us no good // we send WM_CHANGEUISTATE so if nothing needs changing then the system
// to use it on older systems -- and could possibly do some harm // won't send WM_UPDATEUISTATE
static int s_needToUpdate = -1; ::SendMessage(GetHwnd(), WM_CHANGEUISTATE, MAKEWPARAM(action, state), 0);
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);
}
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@@ -41,7 +41,7 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog);
// wxCPWCDelegate - Window Closed delegate // wxCPWCDelegate - Window Closed delegate
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@interface wxCPWCDelegate : NSObject wxOSX_10_6_AND_LATER(<NSWindowDelegate>) @interface wxCPWCDelegate : NSObject <NSWindowDelegate>
{ {
bool m_bIsClosed; bool m_bIsClosed;
} }

View File

@@ -494,12 +494,7 @@ CGContextRef WXDLLIMPEXP_CORE wxOSXCreateBitmapContextFromNSImage( WX_NSImage ns
double wxOSXGetMainScreenContentScaleFactor() double wxOSXGetMainScreenContentScaleFactor()
{ {
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7) return [[NSScreen mainScreen] backingScaleFactor];
if ( [ [NSScreen mainScreen] respondsToSelector:@selector(backingScaleFactor)] )
return [[NSScreen mainScreen] backingScaleFactor];
else
#endif
return 1.0;
} }
CGImageRef wxOSXCreateCGImageFromNSImage( WX_NSImage nsimage, double *scaleptr ) CGImageRef wxOSXCreateCGImageFromNSImage( WX_NSImage nsimage, double *scaleptr )

View File

@@ -24,7 +24,7 @@
// work in progress // work in progress
@interface wxNSTableDataSource : NSObject wxOSX_10_6_AND_LATER(<NSComboBoxDataSource>) @interface wxNSTableDataSource : NSObject <NSComboBoxDataSource>
{ {
wxNSComboBoxControl* impl; wxNSComboBoxControl* impl;
} }

View File

@@ -52,33 +52,7 @@
// then the delegate method - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename will have to // then the delegate method - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename will have to
// be implemented // be implemented
namespace @interface wxOpenPanelDelegate : NSObject <NSOpenSavePanelDelegate>
{
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>)
{ {
wxFileDialog* _dialog; wxFileDialog* _dialog;
} }

View File

@@ -30,7 +30,7 @@
class wxListWidgetCocoaImpl; class wxListWidgetCocoaImpl;
@interface wxNSTableDataSource : NSObject wxOSX_10_6_AND_LATER(<NSTableViewDataSource>) @interface wxNSTableDataSource : NSObject <NSTableViewDataSource>
{ {
wxListWidgetCocoaImpl* impl; wxListWidgetCocoaImpl* impl;
} }
@@ -50,7 +50,7 @@ class wxListWidgetCocoaImpl;
@end @end
@interface wxNSTableView : NSTableView wxOSX_10_6_AND_LATER(<NSTableViewDelegate>) @interface wxNSTableView : NSTableView <NSTableViewDelegate>
{ {
} }

View File

@@ -58,7 +58,7 @@
// and under 10.4, we are not getting a 'close' event however... // and under 10.4, we are not getting a 'close' event however...
#define wxOSX_USE_NEEDSUPDATE_HOOK 1 #define wxOSX_USE_NEEDSUPDATE_HOOK 1
@interface wxNSMenuController : NSObject wxOSX_10_6_AND_LATER(<NSMenuDelegate>) @interface wxNSMenuController : NSObject <NSMenuDelegate>
{ {
} }

View File

@@ -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) static bool IsUsingFullScreenApi(WXWindow macWindow)
{ {
return [macWindow respondsToSelector:@selector(toggleFullScreen:)] return ([macWindow collectionBehavior] & NSWindowCollectionBehaviorFullScreenPrimary);
&& ([macWindow collectionBehavior] & NSWindowCollectionBehaviorFullScreenPrimary);
} }
#endif
// //
// wx category for NSWindow (our own and wrapped instances) // wx category for NSWindow (our own and wrapped instances)
// //
@@ -313,7 +305,7 @@ static NSResponder* s_formerFirstResponder = NULL;
// controller // 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; - (void)windowDidDeminiaturize:(NSNotification *)notification;
- (BOOL)windowShouldClose:(id)window; - (BOOL)windowShouldClose:(id)window;
- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame; - (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame;
#if wxHAS_FULL_SCREEN_API
- (void)windowWillEnterFullScreen:(NSNotification *)notification; - (void)windowWillEnterFullScreen:(NSNotification *)notification;
#endif
@end @end
@@ -585,8 +575,6 @@ extern int wxOSXGetIdFromSelector(SEL action );
return true; return true;
} }
#if wxHAS_FULL_SCREEN_API
// work around OS X bug, on a secondary monitor an already fully sized window // 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 // (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 // title band at the top free, therefore we force the correct content size
@@ -607,8 +595,6 @@ extern int wxOSXGetIdFromSelector(SEL action );
} }
} }
#endif
@end @end
wxIMPLEMENT_DYNAMIC_CLASS(wxNonOwnedWindowCocoaImpl , wxNonOwnedWindowImpl); wxIMPLEMENT_DYNAMIC_CLASS(wxNonOwnedWindowCocoaImpl , wxNonOwnedWindowImpl);
@@ -1000,44 +986,32 @@ typedef struct
bool wxNonOwnedWindowCocoaImpl::IsFullScreen() const bool wxNonOwnedWindowCocoaImpl::IsFullScreen() const
{ {
#if wxHAS_FULL_SCREEN_API
if ( IsUsingFullScreenApi(m_macWindow) ) if ( IsUsingFullScreenApi(m_macWindow) )
{ {
return [m_macWindow styleMask] & NSFullScreenWindowMask; return [m_macWindow styleMask] & NSFullScreenWindowMask;
} }
#endif
return m_macFullScreenData != NULL ; return m_macFullScreenData != NULL ;
} }
bool wxNonOwnedWindowCocoaImpl::EnableFullScreenView(bool enable) bool wxNonOwnedWindowCocoaImpl::EnableFullScreenView(bool enable)
{ {
#if wxHAS_FULL_SCREEN_API NSUInteger collectionBehavior = [m_macWindow collectionBehavior];
if ( [ m_macWindow respondsToSelector:@selector(setCollectionBehavior:) ] ) if (enable)
{ {
NSUInteger collectionBehavior = [m_macWindow collectionBehavior]; collectionBehavior |= NSWindowCollectionBehaviorFullScreenPrimary;
if (enable)
{
collectionBehavior |= NSWindowCollectionBehaviorFullScreenPrimary;
}
else
{
collectionBehavior &= ~NSWindowCollectionBehaviorFullScreenPrimary;
}
[m_macWindow setCollectionBehavior: collectionBehavior];
return true;
} }
#else else
wxUnusedVar(enable); {
#endif collectionBehavior &= ~NSWindowCollectionBehaviorFullScreenPrimary;
}
[m_macWindow setCollectionBehavior: collectionBehavior];
return false; return true;
} }
bool wxNonOwnedWindowCocoaImpl::ShowFullScreen(bool show, long WXUNUSED(style)) bool wxNonOwnedWindowCocoaImpl::ShowFullScreen(bool show, long WXUNUSED(style))
{ {
#if wxHAS_FULL_SCREEN_API
if ( IsUsingFullScreenApi(m_macWindow) ) if ( IsUsingFullScreenApi(m_macWindow) )
{ {
if ( show != IsFullScreen() ) if ( show != IsFullScreen() )
@@ -1047,7 +1021,6 @@ bool wxNonOwnedWindowCocoaImpl::ShowFullScreen(bool show, long WXUNUSED(style))
return true; return true;
} }
#endif
if ( show ) if ( show )
{ {

View File

@@ -29,7 +29,7 @@
// controller // controller
// //
@interface wxTabViewController : NSObject wxOSX_10_6_AND_LATER(<NSTabViewDelegate>) @interface wxTabViewController : NSObject <NSTabViewDelegate>
{ {
} }

View File

@@ -827,7 +827,7 @@ wxNSTextFieldControl::wxNSTextFieldControl(wxWindow *wxPeer,
void wxNSTextFieldControl::Init(WXWidget w) 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 = tf;
[m_textField setDelegate: tf]; [m_textField setDelegate: tf];
m_selStart = m_selEnd = 0; m_selStart = m_selEnd = 0;

View File

@@ -301,7 +301,7 @@ private:
@end @end
@interface wxNSToolbarDelegate : NSObject wxOSX_10_6_AND_LATER(<NSToolbarDelegate>) @interface wxNSToolbarDelegate : NSObject <NSToolbarDelegate>
{ {
bool m_isSelectable; bool m_isSelectable;
} }

View File

@@ -412,7 +412,7 @@ bool wxApp::DoInitGui()
} }
appcontroller = OSXCreateAppController(); appcontroller = OSXCreateAppController();
[[NSApplication sharedApplication] setDelegate:(id wxOSX_10_6_AND_LATER(<NSApplicationDelegate>))appcontroller]; [[NSApplication sharedApplication] setDelegate:(id <NSApplicationDelegate>)appcontroller];
[NSColor setIgnoresAlpha:NO]; [NSColor setIgnoresAlpha:NO];
// calling finishLaunching so early before running the loop seems to trigger some 'MenuManager compatibility' which leads // 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 #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 #endif // wxOSX_USE_COCOA

View File

@@ -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(mouseEntered:), (IMP) wxOSX_mouseEvent, "v@:@" )
wxOSX_CLASS_ADD_METHOD(c, @selector(mouseExited:), (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@:@") wxOSX_CLASS_ADD_METHOD(c, @selector(magnifyWithEvent:), (IMP)wxOSX_mouseEvent, "v@:@")
#endif
wxOSX_CLASS_ADD_METHOD(c, @selector(cursorUpdate:), (IMP) wxOSX_cursorUpdate, "v@:@" ) wxOSX_CLASS_ADD_METHOD(c, @selector(cursorUpdate:), (IMP) wxOSX_cursorUpdate, "v@:@" )
@@ -1870,13 +1868,8 @@ void wxWidgetCocoaImpl::SetVisibility( bool visible )
double wxWidgetCocoaImpl::GetContentScaleFactor() const double wxWidgetCocoaImpl::GetContentScaleFactor() const
{ {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
NSWindow* tlw = [m_osxView window]; NSWindow* tlw = [m_osxView window];
if ( [ tlw respondsToSelector:@selector(backingScaleFactor) ] ) return [tlw backingScaleFactor];
return [tlw backingScaleFactor];
else
#endif
return 1.0;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -1884,7 +1877,7 @@ double wxWidgetCocoaImpl::GetContentScaleFactor() const
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// define a delegate used to refresh the window during animation // 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; wxWindow *m_win;
bool m_isDone; bool m_isDone;

View File

@@ -53,7 +53,7 @@ extern WXDLLIMPEXP_BASE wxSocketManager *wxOSXSocketManagerCF;
wxSocketManager *wxOSXSocketManagerCF = NULL; wxSocketManager *wxOSXSocketManagerCF = NULL;
#endif // wxUSE_SOCKETS #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 // our OS version is the same in non GUI and GUI cases
wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn) wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn)
@@ -70,16 +70,6 @@ wxOperatingSystemId wxGetOsVersion(int *majorVsn, int *minorVsn)
if ( minorVsn != NULL ) if ( minorVsn != NULL )
*minorVsn = min; *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; return wxOS_MAC_OSX_DARWIN;
} }
@@ -95,6 +85,10 @@ wxString wxGetOsDescription()
wxString::FromAscii(name.machine).c_str()); wxString::FromAscii(name.machine).c_str());
} }
#endif // wxOSX_USE_CARBON
#if ( !wxUSE_GUI && !wxOSX_USE_IPHONE ) || wxOSX_USE_COCOA_OR_CARBON
//=========================================================================== //===========================================================================
// IMPLEMENTATION // IMPLEMENTATION
//=========================================================================== //===========================================================================

View File

@@ -1148,6 +1148,14 @@ wxString wxGetOsDescription()
return wxGetCommandOutput(wxT("uname -s -r -m")); 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__ #endif // !__DARWIN__
unsigned long wxGetProcessId() unsigned long wxGetProcessId()