X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/99030bdf57b8d590066092d2f466626f9bdef172..06e8a59de37ba9f42b224c4e2c58f1de7c4fbd26:/src/mac/dc.cpp diff --git a/src/mac/dc.cpp b/src/mac/dc.cpp index 2acff5c48a..206e960450 100644 --- a/src/mac/dc.cpp +++ b/src/mac/dc.cpp @@ -66,6 +66,39 @@ wxMacPortSetter::~wxMacPortSetter() m_dc->MacCleanupPort(&m_ph) ; } +wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) +{ + m_formerClip = NewRgn() ; + m_newClip = NewRgn() ; + GetClip( m_formerClip ) ; + + if ( win ) + { + RgnHandle insidergn = NewRgn() ; + int x = 0 , y = 0; + wxWindow *parent = win->GetParent() ; + parent->MacWindowToRootWindow( &x,&y ) ; + + wxSize size = parent->GetSize() ; + SetRectRgn( insidergn , parent->MacGetLeftBorderSize() , parent->MacGetTopBorderSize() , + size.x - parent->MacGetLeftBorderSize() - parent->MacGetRightBorderSize(), + size.y - parent->MacGetTopBorderSize() - parent->MacGetBottomBorderSize()) ; + + CopyRgn( (RgnHandle) parent->MacGetVisibleRegion(false).GetWXHRGN() , m_newClip ) ; + SectRgn( m_newClip , insidergn , m_newClip ) ; + OffsetRgn( m_newClip , x , y ) ; + SetClip( m_newClip ) ; + DisposeRgn( insidergn ) ; + } +} + +wxMacWindowClipper::~wxMacWindowClipper() +{ + SetClip( m_formerClip ) ; + DisposeRgn( m_newClip ) ; + DisposeRgn( m_formerClip ) ; +} + //----------------------------------------------------------------------------- // Local functions //----------------------------------------------------------------------------- @@ -721,6 +754,7 @@ void wxDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) void wxDC::DoCrossHair( wxCoord x, wxCoord y ) { wxCHECK_RET( Ok(), wxT("wxDC::DoCrossHair Invalid window dc") ); + wxMacPortSetter helper(this) ; if (m_pen.GetStyle() != wxTRANSPARENT) { @@ -782,6 +816,7 @@ void wxDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord xc, wxCoord yc ) { wxCHECK_RET(Ok(), wxT("wxDC::DoDrawArc Invalid DC")); + wxMacPortSetter helper(this) ; wxCoord xx1 = XLOG2DEVMAC(x1); wxCoord yy1 = YLOG2DEVMAC(y1); @@ -835,6 +870,7 @@ void wxDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea ) { wxCHECK_RET(Ok(), wxT("wxDC::DoDrawEllepticArc Invalid DC")); + wxMacPortSetter helper(this) ; Rect r; double angle = sa - ea; // Order important Mac in opposite direction to wx @@ -1464,6 +1500,7 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) long yy = YLOG2DEVMAC(y); #if TARGET_CARBON bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ; + useDrawThemeText = false ; #endif MacInstallFont() ; if ( 0 ) @@ -1525,7 +1562,7 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) ::DrawThemeTextBox( mString, kThemeCurrentPortFont, kThemeStateActive, - true, + false, &frame, teJustLeft, nil ); @@ -1551,7 +1588,7 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) ::DrawThemeTextBox( mString, kThemeCurrentPortFont, kThemeStateActive, - true, + false, &frame, teJustLeft, nil ); @@ -1584,22 +1621,18 @@ void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *he if ( theFont ) { - wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; - - if ( font ) - { - ::TextFont( font->m_macFontNum ) ; - ::TextSize( YLOG2DEVREL( font->m_macFontSize) ) ; - ::TextFace( font->m_macFontStyle ) ; - } - } - else - { - MacInstallFont() ; + // work around the constness + *((wxFont*)(&m_font)) = *theFont ; } + MacInstallFont() ; + FontInfo fi ; ::GetFontInfo( &fi ) ; +#if TARGET_CARBON + bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ; + useGetThemeText = false ; +#endif if ( height ) *height = YDEV2LOGREL( fi.descent + fi.ascent ) ; @@ -1636,21 +1669,61 @@ void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *he { if ( height ) *height += YDEV2LOGREL( fi.descent + fi.ascent + fi.leading ) ; - curwidth = ::TextWidth( text , laststop , i - laststop ) ; +#if TARGET_CARBON + if ( useGetThemeText ) + { + Point bounds={0,0} ; + SInt16 baseline ; + CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; + ::GetThemeTextDimensions( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &bounds, + &baseline ); + CFRelease( mString ) ; + curwidth = bounds.h ; + } + else +#endif + { + curwidth = ::TextWidth( text , laststop , i - laststop ) ; + } if ( curwidth > *width ) *width = XDEV2LOGREL( curwidth ) ; laststop = i+1 ; } i++ ; } - - curwidth = ::TextWidth( text , laststop , i - laststop ) ; + +#if TARGET_CARBON + if ( useGetThemeText ) + { + Point bounds={0,0} ; + SInt16 baseline ; + CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text + laststop , i - laststop , CFStringGetSystemEncoding(), false ) ; + ::GetThemeTextDimensions( mString, + kThemeCurrentPortFont, + kThemeStateActive, + false, + &bounds, + &baseline ); + CFRelease( mString ) ; + curwidth = bounds.h ; + } + else +#endif + { + curwidth = ::TextWidth( text , laststop , i - laststop ) ; + } if ( curwidth > *width ) *width = XDEV2LOGREL( curwidth ) ; } if ( theFont ) { + // work around the constness + *((wxFont*)(&m_font)) = formerFont ; m_macFontInstalled = false ; } }