Guard macOS 26 checks with __MAC_OS_X_VERSION_MAX_ALLOWED

Wrap uses of WX_IS_MACOS_AVAILABLE(26, 0) with compile-time
__MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_26_0 checks so that
code compiled with older versions of Xcode 26 is not affects.

macOS 26 doesn't apply its new appearance to applications that weren't
compiled with Xcode 26+, so this is the correct thing to do: we do not
want any adjustments to apply to 26-unaware code.
This commit is contained in:
Václav Slavík
2025-09-08 14:28:41 +02:00
parent de9c85f2b8
commit 5c97a29797
6 changed files with 38 additions and 5 deletions
+3
View File
@@ -470,6 +470,9 @@
# ifndef MAC_OS_VERSION_14_0
# define MAC_OS_VERSION_14_0 140000
# endif
# ifndef MAC_OS_VERSION_26_0
# define MAC_OS_VERSION_26_0 260000
# endif
# if __MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_13
# ifndef NSAppKitVersionNumber10_10
# define NSAppKitVersionNumber10_10 1343
+3
View File
@@ -128,11 +128,14 @@ wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id,
void wxFrame::SetStatusBar(wxStatusBar *statbar)
{
wxFrameBase::SetStatusBar(statbar);
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0
if ( WX_IS_MACOS_AVAILABLE(11, 0) )
{
// textured borders are unwanted, statusbar renders w/o them
}
else
#endif
{
m_nowpeer->SetBottomBorderThickness(statbar ? GetMacStatusbarHeight() : 0);
}
+26 -5
View File
@@ -73,6 +73,7 @@ bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
void wxStatusBarMac::InitColours()
{
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_26_0
if ( WX_IS_MACOS_AVAILABLE(26, 0) )
{
if ( wxSystemSettings::GetAppearance().IsDark() )
@@ -90,7 +91,10 @@ void wxStatusBarMac::InitColours()
m_separator = wxColour(0xD9, 0xD9, 0xD9);
}
}
else if ( WX_IS_MACOS_AVAILABLE(11, 0) )
else
#endif // MAC_OS_VERSION_26_0
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0
if ( WX_IS_MACOS_AVAILABLE(11, 0) )
{
if ( wxSystemSettings::GetAppearance().IsDark() )
{
@@ -111,7 +115,10 @@ void wxStatusBarMac::InitColours()
m_separator = wxColour(0xCC, 0xCC, 0xCC);
}
}
else if ( WX_IS_MACOS_AVAILABLE(10, 14) )
else
#endif // MAC_OS_VERSION_11_0
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14
if ( WX_IS_MACOS_AVAILABLE(10, 14) )
{
if ( wxSystemSettings::GetAppearance().IsDark() )
{
@@ -124,7 +131,9 @@ void wxStatusBarMac::InitColours()
m_textInactive = wxColour(0xB1, 0xB1, 0xB1);
}
}
else // 10.10 Yosemite to 10.13:
else
#endif // MAC_OS_X_VERSION_10_14
// 10.10 Yosemite to 10.13:
{
m_textActive = wxColour(0x40, 0x40, 0x40);
m_textInactive = wxColour(0x4B, 0x4B, 0x4B);
@@ -153,11 +162,15 @@ void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event))
break;
}
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_26_0
if ( WX_IS_MACOS_AVAILABLE(26, 0) )
{
// don't paint the background, handled by the OS
}
else if ( WX_IS_MACOS_AVAILABLE(11, 0) )
else
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0
if ( WX_IS_MACOS_AVAILABLE(11, 0) )
{
// we _do_ need to paint the background on Big Sur up to Tahoe
// to match Finder's appearance:
@@ -165,13 +178,16 @@ void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event))
dc.Clear();
}
// else: background is rendered by OS, it is part of NSWindow border
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0
// Draw horizontal separator above the status bar:
if ( WX_IS_MACOS_AVAILABLE(11, 0) )
{
dc.SetPen(m_separator);
dc.DrawLine(0, 0, GetSize().x, 0);
}
#endif
// Draw the text:
@@ -188,11 +204,16 @@ void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event))
void wxStatusBarMac::InitCornerInset()
{
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_26_0
if ( WX_IS_MACOS_AVAILABLE(26, 0) )
m_cornerInset = 8;
else if ( WX_IS_MACOS_AVAILABLE(11, 0) )
else
#endif
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0
if ( WX_IS_MACOS_AVAILABLE(11, 0) )
m_cornerInset = 4;
else
#endif
m_cornerInset = 0;
}
+2
View File
@@ -91,11 +91,13 @@
// On macOS 26 Tahoe, the mere presence of drawRect: in derived class,
// even if it just calls super's implementation, triggers legacy
// rendering of NSTabView.
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_26_0
if (WX_IS_MACOS_AVAILABLE(26, 0))
{
wxOSXCocoaClassAddWXMethods(self, wxOSXSKIP_DRAW);
}
else
#endif
{
wxOSXCocoaClassAddWXMethods(self);
}
+2
View File
@@ -81,11 +81,13 @@ bool wxSpinButton::OSXHandleClicked( double WXUNUSED(timestampsec) )
wxSize wxSpinButton::DoGetBestSize() const
{
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_26_0
if ( WX_IS_MACOS_AVAILABLE(26, 0) )
{
return wxSize(21, 28);
}
else
#endif
{
return wxSize(13, 22);
}
+2
View File
@@ -232,8 +232,10 @@ wxSize wxTextCtrl::DoGetSizeFromTextSize(int xlen, int ylen) const
break ;
}
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_26_0
if ( WX_IS_MACOS_AVAILABLE(26, 0) )
hText += 3;
#endif
// the numbers above include the border size, so subtract it before
// possibly adding it back below