mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-09-22 14:20:35 +08:00
Improve wxSpinCtrl sizing and appearance on macOS
Multiple improvements to wxSpinCtrl/wxSpinButton appearance: - fixes broken rendering on macOS 26 (clipped borders) - corrects wxSpinButton sizes (note that NSStepper doesn't dynamically adjust to the size it is set to, but renders at a constant size) - adds typically used margin between the stepper and the text field - removes unreachable code in wxWindowMac::DoGetBestSize
This commit is contained in:
@@ -49,11 +49,15 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxSpinDoubleEvent, wxNotifyEvent);
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// The margin between the text control and the spin: the value here is the same
|
||||
// as the margin between the spin button and its "buddy" text control in wxMSW
|
||||
// so the generic control looks similarly to the native one there, we might
|
||||
// need to use different value for the other platforms (and maybe even
|
||||
// determine it dynamically?).
|
||||
// as the margin between the spin button and its "buddy" text control in wxMSW,
|
||||
// and the commonly used spacing on macOS, so the generic control looks
|
||||
// similarly to the native one there, we might need to use different value for
|
||||
// other platforms (and maybe even determine it dynamically?).
|
||||
#ifdef __WXOSX__
|
||||
static const wxCoord MARGIN = 4;
|
||||
#else
|
||||
static const wxCoord MARGIN = 1;
|
||||
#endif
|
||||
|
||||
#define SPINCTRLBUT_MAX 32000 // large to avoid wrap around trouble
|
||||
|
||||
@@ -241,6 +245,10 @@ bool wxSpinCtrlGenericBase::Create(wxWindow *parent,
|
||||
m_value = AdjustAndSnap(d);
|
||||
}
|
||||
|
||||
#ifdef __WXOSX__
|
||||
MacClipsToBounds(false);
|
||||
#endif
|
||||
|
||||
m_textCtrl = new wxSpinCtrlTextGeneric(this, DoValueToText(m_value), style);
|
||||
m_spinButton = new wxSpinCtrlButtonGeneric(this, style);
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "wx/spinbutt.h"
|
||||
#include "wx/osx/private.h"
|
||||
#include "wx/osx/private/available.h"
|
||||
|
||||
|
||||
wxSpinButton::wxSpinButton()
|
||||
@@ -80,7 +81,14 @@ bool wxSpinButton::OSXHandleClicked( double WXUNUSED(timestampsec) )
|
||||
|
||||
wxSize wxSpinButton::DoGetBestSize() const
|
||||
{
|
||||
return wxSize( 16, 24 );
|
||||
if ( WX_IS_MACOS_AVAILABLE(26, 0) )
|
||||
{
|
||||
return wxSize(21, 28);
|
||||
}
|
||||
else
|
||||
{
|
||||
return wxSize(13, 22);
|
||||
}
|
||||
}
|
||||
|
||||
void wxSpinButton::TriggerScrollEvent(wxEventType scrollEvent)
|
||||
|
||||
@@ -1061,13 +1061,6 @@ wxSize wxWindowMac::DoGetBestSize() const
|
||||
r.height = 16 ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if wxUSE_SPINBTN
|
||||
if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )
|
||||
{
|
||||
r.height = 24 ;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// return wxWindowBase::DoGetBestSize() ;
|
||||
|
||||
Reference in New Issue
Block a user