From: Stefan Csomor Date: Sat, 26 Feb 2011 11:04:43 +0000 (+0000) Subject: making GetPosition 1:1 symmetrical to Move (respecting contentViews), fixing borderDr... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/7a69cf792b0beffc09bba9860504746d9d7793d8 making GetPosition 1:1 symmetrical to Move (respecting contentViews), fixing borderDrawing within NSBox git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67028 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index be8767bb72..3b200a4635 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -1179,6 +1179,12 @@ void wxWidgetCocoaImpl::drawRect(void* rect, WXWidget slf, void *WXUNUSED(_cmd)) CGContextRestoreGState( context ); CGContextSaveGState( context ); } + // as we called restore above, we have to flip again if necessary + if ( !m_isFlipped ) + { + CGContextTranslateCTM( context, 0, [m_osxView bounds].size.height ); + CGContextScaleCTM( context, 1, -1 ); + } wxpeer->MacPaintChildrenBorders(); wxpeer->MacSetCGContextRef( NULL ); CGContextRestoreGState( context ); @@ -1660,6 +1666,20 @@ void wxWidgetCocoaImpl::GetPosition( int &x, int &y ) const wxRect r = wxFromNSRect( [m_osxView superview], [m_osxView frame] ); x = r.GetLeft(); y = r.GetTop(); + + // under Cocoa we might have a contentView in the wxParent to which we have to + // adjust the coordinates + wxWindowMac* parent = GetWXPeer()->GetParent(); + if (parent && [m_osxView superview] != parent->GetHandle() ) + { + int cx = 0,cy = 0,cw = 0,ch = 0; + if ( parent->GetPeer() ) + { + parent->GetPeer()->GetContentArea(cx, cy, cw, ch); + x += cx; + y += cy; + } + } } void wxWidgetCocoaImpl::GetSize( int &width, int &height ) const