Use Cocoa native layout inset method
Don't hardcode inset sizes any longer. This improves various issues under macOS 12, see #22134 and #22135 (but doesn't fully fix the former problem yet). Closes #22351.
This commit is contained in:
committed by
Vadim Zeitlin
parent
5d5591816d
commit
d9ec9ab1f1
@@ -111,7 +111,7 @@ public :
|
||||
virtual void GetPosition( int &x, int &y ) const wxOVERRIDE;
|
||||
virtual void GetSize( int &width, int &height ) const wxOVERRIDE;
|
||||
virtual void SetControlSize( wxWindowVariant variant ) wxOVERRIDE;
|
||||
|
||||
virtual void GetLayoutInset(int &left , int &top , int &right, int &bottom) const wxOVERRIDE;
|
||||
virtual void SetNeedsDisplay( const wxRect* where = NULL ) wxOVERRIDE;
|
||||
virtual bool GetNeedsDisplay() const wxOVERRIDE;
|
||||
|
||||
@@ -368,7 +368,6 @@ public:
|
||||
#endif // wxUSE_MARKUP
|
||||
|
||||
void SetPressedBitmap( const wxBitmapBundle& bitmap ) wxOVERRIDE;
|
||||
void GetLayoutInset(int &left, int &top, int &right, int &bottom) const wxOVERRIDE;
|
||||
void SetAcceleratorFromLabel(const wxString& label);
|
||||
|
||||
NSButton *GetNSButton() const;
|
||||
|
||||
@@ -140,50 +140,6 @@ void wxButtonCocoaImpl::SetPressedBitmap( const wxBitmapBundle& bitmap )
|
||||
}
|
||||
}
|
||||
|
||||
void wxButtonCocoaImpl::GetLayoutInset(int &left , int &top , int &right, int &bottom) const
|
||||
{
|
||||
left = top = right = bottom = 0;
|
||||
NSControlSize size = NSRegularControlSize;
|
||||
if ( [m_osxView respondsToSelector:@selector(controlSize)] )
|
||||
size = [m_osxView controlSize];
|
||||
else if ([m_osxView respondsToSelector:@selector(cell)])
|
||||
{
|
||||
id cell = [(id)m_osxView cell];
|
||||
if ([cell respondsToSelector:@selector(controlSize)])
|
||||
size = [cell controlSize];
|
||||
}
|
||||
|
||||
if ( [GetNSButton() bezelStyle] == NSRoundedBezelStyle )
|
||||
{
|
||||
switch( size )
|
||||
{
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_16
|
||||
case NSControlSizeLarge:
|
||||
#endif
|
||||
case NSRegularControlSize:
|
||||
left = right = 6;
|
||||
top = 4;
|
||||
bottom = 7;
|
||||
break;
|
||||
case NSSmallControlSize:
|
||||
left = right = 5;
|
||||
top = 4;
|
||||
bottom = 6;
|
||||
break;
|
||||
case NSMiniControlSize:
|
||||
left = right = 1;
|
||||
top = 0;
|
||||
bottom = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ( [GetNSButton() bezelStyle] == NSSmallSquareBezelStyle )
|
||||
{
|
||||
left = right = 0;
|
||||
top = bottom = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void wxButtonCocoaImpl::SetAcceleratorFromLabel(const wxString& label)
|
||||
{
|
||||
const int accelPos = wxControl::FindAccelIndex(label);
|
||||
|
||||
@@ -73,43 +73,6 @@ public:
|
||||
delete m_popUpMenu;
|
||||
}
|
||||
|
||||
void GetLayoutInset(int &left , int &top , int &right, int &bottom) const wxOVERRIDE
|
||||
{
|
||||
left = top = right = bottom = 0;
|
||||
NSControlSize size = NSRegularControlSize;
|
||||
if ( [m_osxView respondsToSelector:@selector(controlSize)] )
|
||||
size = [m_osxView controlSize];
|
||||
else if ([m_osxView respondsToSelector:@selector(cell)])
|
||||
{
|
||||
id cell = [(id)m_osxView cell];
|
||||
if ([cell respondsToSelector:@selector(controlSize)])
|
||||
size = [cell controlSize];
|
||||
}
|
||||
|
||||
switch( size )
|
||||
{
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_16
|
||||
case NSControlSizeLarge:
|
||||
#endif
|
||||
case NSRegularControlSize:
|
||||
left = right = 3;
|
||||
top = 2;
|
||||
bottom = 3;
|
||||
break;
|
||||
case NSSmallControlSize:
|
||||
left = right = 3;
|
||||
top = 1;
|
||||
bottom = 3;
|
||||
break;
|
||||
case NSMiniControlSize:
|
||||
left = 1;
|
||||
right = 2;
|
||||
top = 0;
|
||||
bottom = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void InsertItem( size_t pos, int itemid, const wxString& text) wxOVERRIDE
|
||||
{
|
||||
m_popUpMenu->Insert( pos, itemid, text );
|
||||
|
||||
@@ -71,29 +71,6 @@ public :
|
||||
}
|
||||
}
|
||||
|
||||
void GetLayoutInset(int &left , int &top , int &right, int &bottom) const wxOVERRIDE
|
||||
{
|
||||
left = top = right = bottom = 0;
|
||||
NSControlSize size = [(wxNSProgressIndicator*)m_osxView controlSize];
|
||||
|
||||
switch( size )
|
||||
{
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_16
|
||||
case NSControlSizeLarge:
|
||||
#endif
|
||||
case NSRegularControlSize:
|
||||
left = right = 2;
|
||||
top = 0;
|
||||
bottom = 3;
|
||||
break;
|
||||
case NSMiniControlSize:
|
||||
case NSSmallControlSize:
|
||||
left = right = 1;
|
||||
top = 0;
|
||||
bottom = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
protected:
|
||||
void SetDeterminateMode()
|
||||
{
|
||||
|
||||
@@ -3112,6 +3112,15 @@ void wxWidgetCocoaImpl::GetContentArea( int&left, int &top, int &width, int &hei
|
||||
}
|
||||
}
|
||||
|
||||
void wxWidgetCocoaImpl::GetLayoutInset(int &left , int &top , int &right, int &bottom) const
|
||||
{
|
||||
NSEdgeInsets insets = [m_osxView alignmentRectInsets];
|
||||
left = insets.left;
|
||||
top = insets.top;
|
||||
right = insets.right;
|
||||
bottom = insets.bottom;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user