adding support for layout coordinates via insets from framecoordinates

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66360 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2010-12-07 15:46:12 +00:00
parent 2a2064f895
commit 54ea28348c
4 changed files with 101 additions and 9 deletions

View File

@@ -235,6 +235,13 @@ public :
virtual void GetSize( int &width, int &height ) const = 0;
virtual void SetControlSize( wxWindowVariant variant ) = 0;
// the native coordinates may have an 'aura' for shadows etc, if this is the case the layout
// inset indicates on which insets the real control is drawn
virtual void GetLayoutInset(int &left , int &top , int &right, int &bottom) const
{
left = top = right = bottom = 0;
}
// native view coordinates are topleft to bottom right (flipped regarding CoreGraphics origin)
virtual bool IsFlipped() const { return true; }

View File

@@ -182,6 +182,7 @@ public:
WXWindow MacGetTopLevelWindowRef() const ;
wxNonOwnedWindow* MacGetTopLevelWindow() const ;
virtual long MacGetWXBorderSize() const;
virtual long MacGetLeftBorderSize() const ;
virtual long MacGetRightBorderSize() const ;
virtual long MacGetTopBorderSize() const ;

View File

@@ -30,6 +30,10 @@ wxSize wxButton::DoGetBestSize() const
m_peer->GetBestRect(&r);
wxSize sz = r.GetSize();
sz.x = sz.x + MacGetLeftBorderSize() +
MacGetRightBorderSize();
sz.y = sz.y + MacGetTopBorderSize() +
MacGetBottomBorderSize();
const int wBtnStd = GetDefaultSize().x;
@@ -41,7 +45,7 @@ wxSize wxButton::DoGetBestSize() const
wxSize wxButton::GetDefaultSize()
{
return wxSize(84, 23);
return wxSize(84, 20);
}
@implementation wxNSButton
@@ -124,6 +128,43 @@ public:
[button setButtonType:NSMomentaryChangeButton];
}
void 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 = (NSControlSize) [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 )
{
case NSRegularControlSize:
left = right = 6;
top = 4;
bottom = 8;
break;
case NSSmallControlSize:
left = right = 5;
top = 4;
bottom = 7;
break;
case NSMiniControlSize:
left = right = 1;
top = 0;
bottom = 2;
break;
}
}
}
private:
NSButton *GetNSButton() const
{

View File

@@ -2263,7 +2263,7 @@ void wxWindowMac::MacTopLevelWindowChangedPosition()
}
}
long wxWindowMac::MacGetLeftBorderSize() const
long wxWindowMac::MacGetWXBorderSize() const
{
if ( IsTopLevel() )
return 0 ;
@@ -2297,22 +2297,65 @@ long wxWindowMac::MacGetLeftBorderSize() const
return border ;
}
long wxWindowMac::MacGetLeftBorderSize() const
{
// the wx borders are all symmetric in mac themes
long border = MacGetWXBorderSize() ;
if ( m_peer )
{
int left, top, right, bottom;
m_peer->GetLayoutInset( left, top, right, bottom );
border -= left;
}
return border;
}
long wxWindowMac::MacGetRightBorderSize() const
{
// they are all symmetric in mac themes
return MacGetLeftBorderSize() ;
// the wx borders are all symmetric in mac themes
long border = MacGetWXBorderSize() ;
if ( m_peer )
{
int left, top, right, bottom;
m_peer->GetLayoutInset( left, top, right, bottom );
border -= right;
}
return border;
}
long wxWindowMac::MacGetTopBorderSize() const
{
// they are all symmetric in mac themes
return MacGetLeftBorderSize() ;
// the wx borders are all symmetric in mac themes
long border = MacGetWXBorderSize() ;
if ( m_peer )
{
int left, top, right, bottom;
m_peer->GetLayoutInset( left, top, right, bottom );
border -= top;
}
return border;
}
long wxWindowMac::MacGetBottomBorderSize() const
{
// they are all symmetric in mac themes
return MacGetLeftBorderSize() ;
// the wx borders are all symmetric in mac themes
long border = MacGetWXBorderSize() ;
if ( m_peer )
{
int left, top, right, bottom;
m_peer->GetLayoutInset( left, top, right, bottom );
border -= bottom;
}
return border;
}
long wxWindowMac::MacRemoveBordersFromStyle( long style )