X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4b1f989890d64f90b7948ce64ea837e13493d0f9..9154a136d5e1d79a4be2cf012e4a815fdc6df3ff:/src/mac/carbon/dccg.cpp diff --git a/src/mac/carbon/dccg.cpp b/src/mac/carbon/dccg.cpp index 8eed3dd6c9..abd909dede 100755 --- a/src/mac/carbon/dccg.cpp +++ b/src/mac/carbon/dccg.cpp @@ -17,16 +17,12 @@ #ifndef WX_PRECOMP #include "wx/log.h" - #include "wx/app.h" #include "wx/dcmemory.h" - #include "wx/dcprint.h" #include "wx/region.h" - #include "wx/image.h" #endif #include "wx/mac/uma.h" - #ifdef __MSL__ #if __MSL__ >= 0x6000 #include "math.h" @@ -38,7 +34,6 @@ #include "wx/mac/private.h" -IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) #ifndef wxMAC_USE_CORE_GRAPHICS_BLEND_MODES #define wxMAC_USE_CORE_GRAPHICS_BLEND_MODES 0 @@ -58,12 +53,9 @@ const double M_PI = 3.14159265358979 ; #endif #endif -const double RAD2DEG = 180.0 / M_PI; -const short kEmulatedMode = -1 ; -const short kUnsupportedMode = -2 ; - -extern TECObjectRef s_TECNativeCToUnicode ; +static const double RAD2DEG = 180.0 / M_PI; +#ifndef __LP64__ // TODO: update // The textctrl implementation still needs that (needs what?) for the non-HIView implementation @@ -118,6 +110,7 @@ wxMacWindowStateSaver::~wxMacWindowStateSaver() // minimal implementation only used for appearance drawing < 10.3 +#ifndef wxMAC_USE_CORE_GRAPHICS wxMacPortSetter::wxMacPortSetter( const wxDC* dc ) : m_ph( (GrafPtr) dc->m_macPort ) { @@ -132,12 +125,14 @@ wxMacPortSetter::~wxMacPortSetter() // m_dc->MacCleanupPort(&m_ph) ; } +#endif + +#endif + //----------------------------------------------------------------------------- // Local functions //----------------------------------------------------------------------------- -static inline double dmin(double a, double b) { return a < b ? a : b; } -static inline double dmax(double a, double b) { return a > b ? a : b; } static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; } //----------------------------------------------------------------------------- @@ -156,6 +151,10 @@ static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; } // wxGraphicPath implementation //----------------------------------------------------------------------------- +#if !wxUSE_GRAPHICS_CONTEXT + +IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) + wxMacCGPath::wxMacCGPath() { m_path = CGPathCreateMutable() ; @@ -204,14 +203,14 @@ CGPathRef wxMacCGPath::GetPath() const return m_path ; } -void wxMacCGPath::AddArcToPoint( wxCoord x1, wxCoord y1 , wxCoord x2, wxCoord y2, wxCoord r ) +void wxMacCGPath::AddArcToPoint( wxCoord x1, wxCoord y1 , wxCoord x2, wxCoord y2, wxCoord r ) { - CGPathAddArcToPoint( m_path, NULL , x1, y1, x2, y2, r); + CGPathAddArcToPoint( m_path, NULL , x1, y1, x2, y2, r); } -void wxMacCGPath::AddArc( wxCoord x, wxCoord y, wxCoord r, double startAngle, double endAngle, bool clockwise ) +void wxMacCGPath::AddArc( wxCoord x, wxCoord y, wxCoord r, double startAngle, double endAngle, bool clockwise ) { - CGPathAddArc( m_path, NULL , x, y, r, startAngle, endAngle, clockwise); + CGPathAddArc( m_path, NULL , x, y, r, startAngle, endAngle, clockwise); } //----------------------------------------------------------------------------- @@ -252,9 +251,10 @@ wxMacCGContext::~wxMacCGContext() CGContextRestoreGState( m_cgContext ) ; CGContextRestoreGState( m_cgContext ) ; } - +#ifndef __LP64__ if ( m_qdPort ) QDEndCGContext( m_qdPort, &m_cgContext ) ; +#endif } @@ -272,8 +272,8 @@ void wxMacCGContext::StrokePath( const wxGraphicPath *p ) width = 1 ; if ( m_pen.GetStyle() == wxTRANSPARENT ) width = 0 ; - - bool offset = ( width % 2 ) == 1 ; + + bool offset = ( width % 2 ) == 1 ; if ( offset ) CGContextTranslateCTM( m_cgContext, 0.5, 0.5 ); @@ -303,8 +303,8 @@ void wxMacCGContext::DrawPath( const wxGraphicPath *p , int fillStyle ) width = 1 ; if ( m_pen.GetStyle() == wxTRANSPARENT ) width = 0 ; - - bool offset = ( width % 2 ) == 1 ; + + bool offset = ( width % 2 ) == 1 ; if ( offset ) CGContextTranslateCTM( m_cgContext, 0.5, 0.5 ); @@ -353,8 +353,11 @@ CGContextRef wxMacCGContext::GetNativeContext() if ( m_cgContext == NULL ) { Rect bounds ; + OSStatus status = noErr; +#ifndef __LP64__ GetPortBounds( (CGrafPtr) m_qdPort , &bounds ) ; - OSStatus status = QDBeginCGContext((CGrafPtr) m_qdPort , &m_cgContext) ; + status = QDBeginCGContext((CGrafPtr) m_qdPort , &m_cgContext) ; +#endif CGContextSaveGState( m_cgContext ) ; wxASSERT_MSG( status == noErr , wxT("Cannot nest wxDCs on the same window") ) ; @@ -380,7 +383,7 @@ void wxMacCGContext::SetNativeContext( CGContextRef cg ) m_cgContext = cg ; } -void wxMacCGContext::Translate( wxCoord dx , wxCoord dy ) +void wxMacCGContext::Translate( wxCoord dx , wxCoord dy ) { CGContextTranslateCTM( m_cgContext, dx, dy ); } @@ -390,17 +393,17 @@ void wxMacCGContext::Scale( wxCoord xScale , wxCoord yScale ) CGContextScaleCTM( m_cgContext , xScale , yScale ) ; } -void wxMacCGContext::DrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, wxCoord w, wxCoord h ) +void wxMacCGContext::DrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, wxCoord w, wxCoord h ) { CGImageRef image = (CGImageRef)( bmp.CGImageCreate() ) ; - HIRect r = CGRectMake( 0 , 0 , w , h ); + HIRect r = CGRectMake( 0 , 0 , w , h ); CGContextSaveGState( m_cgContext ); CGContextTranslateCTM( m_cgContext, x , y + h ); CGContextScaleCTM( m_cgContext, 1, -1 ); - + // in case image is a mask, set the foreground color - CGContextSetRGBFillColor( m_cgContext , m_textForegroundColor.Red() / 255.0 , m_textForegroundColor.Green() / 255.0 , + CGContextSetRGBFillColor( m_cgContext , m_textForegroundColor.Red() / 255.0 , m_textForegroundColor.Green() / 255.0 , m_textForegroundColor.Blue() / 255.0 , m_textForegroundColor.Alpha() / 255.0 ) ; CGContextDrawImage( m_cgContext, r, image ); CGContextRestoreGState( m_cgContext ); @@ -408,7 +411,7 @@ void wxMacCGContext::DrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, wxCo CGImageRelease( image ) ; } -void wxMacCGContext::DrawIcon( const wxIcon &icon, wxCoord x, wxCoord y, wxCoord w, wxCoord h ) +void wxMacCGContext::DrawIcon( const wxIcon &icon, wxCoord x, wxCoord y, wxCoord w, wxCoord h ) { CGRect r = CGRectMake( 0 , 0 , w , h ) ; CGContextSaveGState( m_cgContext ); @@ -424,12 +427,12 @@ void wxMacCGContext::PushState() CGContextSaveGState( m_cgContext ); } -void wxMacCGContext::PopState() +void wxMacCGContext::PopState() { CGContextRestoreGState( m_cgContext ); } -void wxMacCGContext::SetTextColor( const wxColour &col ) +void wxMacCGContext::SetTextColor( const wxColour &col ) { m_textForegroundColor = col ; } @@ -479,7 +482,7 @@ const CGPatternCallbacks wxMacCGPattern::ms_Callbacks = { 0, &wxMacCGPattern::_R class ImagePattern : public wxMacCGPattern { public : - ImagePattern( const wxBitmap* bmp , CGAffineTransform transform ) + ImagePattern( const wxBitmap* bmp , const CGAffineTransform& transform ) { wxASSERT( bmp && bmp->Ok() ) ; @@ -487,7 +490,7 @@ public : } // ImagePattern takes ownership of CGImageRef passed in - ImagePattern( CGImageRef image , CGAffineTransform transform ) + ImagePattern( CGImageRef image , const CGAffineTransform& transform ) { if ( image ) CFRetain( image ) ; @@ -502,7 +505,7 @@ public : } protected : - void Init( CGImageRef image, CGAffineTransform transform ) + void Init( CGImageRef image, const CGAffineTransform& transform ) { m_image = image ; if ( m_image ) @@ -528,7 +531,7 @@ protected : class HatchPattern : public wxMacCGPattern { public : - HatchPattern( int hatchstyle, CGAffineTransform transform ) + HatchPattern( int hatchstyle, const CGAffineTransform& transform ) { m_hatch = hatchstyle ; m_imageBounds = CGRectMake( 0.0, 0.0, 8.0 , 8.0 ) ; @@ -652,14 +655,14 @@ void wxMacCGContext::SetPen( const wxPen &pen ) CGContextSetShouldAntialias( m_cgContext , false ) ; #endif - if ( fill | stroke ) + if ( fill || stroke ) { // set up brushes m_mode = kCGPathFill ; // just a default if ( stroke ) { - CGContextSetRGBStrokeColor( m_cgContext , pen.GetColour().Red() / 255.0 , pen.GetColour().Green() / 255.0 , + CGContextSetRGBStrokeColor( m_cgContext , pen.GetColour().Red() / 255.0 , pen.GetColour().Green() / 255.0 , pen.GetColour().Blue() / 255.0 , pen.GetColour().Alpha() / 255.0 ) ; // TODO: * m_dc->m_scaleX @@ -785,7 +788,7 @@ void wxMacCGContext::SetPen( const wxPen &pen ) CGContextSetStrokeColorSpace( m_cgContext , patternSpace ) ; wxMacCFRefHolder pattern( *( new HatchPattern( pen.GetStyle() , CGContextGetCTM( m_cgContext ) ) ) ); - CGFloat colorArray[4] = { pen.GetColour().Red() / 255.0 , pen.GetColour().Green() / 255.0 , + CGFloat colorArray[4] = { pen.GetColour().Red() / 255.0 , pen.GetColour().Green() / 255.0 , pen.GetColour().Blue() / 255.0 , pen.GetColour().Alpha() / 255.0 } ; CGContextSetStrokePattern( m_cgContext, pattern , colorArray ) ; @@ -829,7 +832,7 @@ void wxMacCGContext::SetBrush( const wxBrush &brush ) CGContextSetShouldAntialias( m_cgContext , false ) ; #endif - if ( fill | stroke ) + if ( fill || stroke ) { // setup brushes m_mode = kCGPathFill ; // just a default @@ -838,7 +841,7 @@ void wxMacCGContext::SetBrush( const wxBrush &brush ) { if ( brush.GetStyle() == wxSOLID ) { - CGContextSetRGBFillColor( m_cgContext , brush.GetColour().Red() / 255.0 , brush.GetColour().Green() / 255.0 , + CGContextSetRGBFillColor( m_cgContext , brush.GetColour().Red() / 255.0 , brush.GetColour().Green() / 255.0 , brush.GetColour().Blue() / 255.0 , brush.GetColour().Alpha() / 255.0 ) ; } else if ( brush.IsHatch() ) @@ -847,7 +850,7 @@ void wxMacCGContext::SetBrush( const wxBrush &brush ) CGContextSetFillColorSpace( m_cgContext , patternSpace ) ; wxMacCFRefHolder pattern( *( new HatchPattern( brush.GetStyle() , CGContextGetCTM( m_cgContext ) ) ) ); - CGFloat colorArray[4] = { brush.GetColour().Red() / 255.0 , brush.GetColour().Green() / 255.0 , + CGFloat colorArray[4] = { brush.GetColour().Red() / 255.0 , brush.GetColour().Green() / 255.0 , brush.GetColour().Blue() / 255.0 , brush.GetColour().Alpha() / 255.0 } ; CGContextSetFillPattern( m_cgContext, pattern , colorArray ) ; @@ -876,7 +879,7 @@ void wxMacCGContext::SetBrush( const wxBrush &brush ) } } -void wxMacCGContext::DrawText( const wxString &str, wxCoord x, wxCoord y, double angle ) +void wxMacCGContext::DrawText( const wxString &str, wxCoord x, wxCoord y, double angle ) { OSStatus status = noErr ; ATSUTextLayout atsuLayout ; @@ -1003,14 +1006,14 @@ void wxMacCGContext::DrawText( const wxString &str, wxCoord x, wxCoord y, double free( ubuf ) ; #endif } - + void wxMacCGContext::GetTextExtent( const wxString &str, wxCoord *width, wxCoord *height, wxCoord *descent, wxCoord *externalLeading ) const { wxCHECK_RET( m_macATSUIStyle != NULL, wxT("wxDC(cg)::DoGetTextExtent - no valid font set") ) ; OSStatus status = noErr ; - + ATSUTextLayout atsuLayout ; UniCharCount chars = str.length() ; UniChar* ubuf = NULL ; @@ -1061,7 +1064,7 @@ void wxMacCGContext::GetTextExtent( const wxString &str, wxCoord *width, wxCoord ::ATSUDisposeTextLayout(atsuLayout); } -void wxMacCGContext::GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const +void wxMacCGContext::GetPartialTextExtents(const wxString& text, wxArrayInt& widths) const { widths.Empty(); widths.Add(0, text.length()); @@ -1096,8 +1099,7 @@ void wxMacCGContext::GetPartialTextExtents(const wxString& text, wxArrayInt& wid #endif #endif - OSStatus status; - status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) ubuf , 0 , chars , chars , 1 , + ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) ubuf , 0 , chars , chars , 1 , &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ; for ( int pos = 0; pos < (int)chars; pos ++ ) @@ -1119,7 +1121,7 @@ void wxMacCGContext::GetPartialTextExtents(const wxString& text, wxArrayInt& wid ::ATSUDisposeTextLayout(atsuLayout); } -void wxMacCGContext::SetFont( const wxFont &font ) +void wxMacCGContext::SetFont( const wxFont &font ) { if ( m_macATSUIStyle ) { @@ -1312,13 +1314,6 @@ void wxDC::DoSetClippingRegionAsRegion( const wxRegion ®ion ) } else { -#if 0 - CopyRgn( (RgnHandle) region.GetWXHRGN() , (RgnHandle) m_macCurrentClipRgn ) ; - if ( xx != x || yy != y ) - OffsetRgn( (RgnHandle) m_macCurrentClipRgn , xx - x , yy - y ) ; - SectRgn( (RgnHandle)m_macCurrentClipRgn , (RgnHandle)m_macBoundaryClipRgn , (RgnHandle)m_macCurrentClipRgn ) ; -#endif - if ( m_clipping ) { m_clipX1 = wxMax( m_clipX1, xx ); @@ -1340,8 +1335,6 @@ void wxDC::DoSetClippingRegionAsRegion( const wxRegion ®ion ) void wxDC::DestroyClippingRegion() { -// CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; - CGContextRef cgContext = ((wxMacCGContext*)(m_graphicContext))->GetNativeContext() ; CGContextRestoreGState( cgContext ); CGContextSaveGState( cgContext ); @@ -1505,7 +1498,7 @@ void wxDC::SetPen( const wxPen &pen ) { if ( m_pen == pen ) return ; - + m_pen = pen; if ( m_graphicContext ) { @@ -1591,16 +1584,16 @@ bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const { wxCHECK_MSG( Ok(), false, wxT("wxDC(cg)::DoGetPixel - invalid DC") ); - wxMacPortSaver helper((CGrafPtr)m_macPort) ; RGBColor colour; - +#ifndef __LP64__ + wxMacPortSaver helper((CGrafPtr)m_macPort) ; // NB: GetCPixel is a deprecated QD call, and a slow one at that GetCPixel( XLOG2DEVMAC(x) + m_macLocalOriginInPort.x - m_macLocalOrigin.x, YLOG2DEVMAC(y) + m_macLocalOriginInPort.y - m_macLocalOrigin.y, &colour ); - +#endif // convert from Mac colour to wx - col->Set( colour.red >> 8, colour.green >> 8, colour.blue >> 8 ); + *col = colour; return true ; } @@ -1698,7 +1691,7 @@ void wxDC::DoDrawArc( wxCoord x1, wxCoord y1, } bool fill = m_brush.GetStyle() != wxTRANSPARENT ; - + wxGraphicPath* path = m_graphicContext->CreatePath() ; m_graphicContext->PushState() ; m_graphicContext->Translate( xxc, yyc ) ; @@ -1910,8 +1903,21 @@ void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) yy = yy - hh; } + int penwidth = m_pen.GetWidth(); + if ( penwidth == 0 ) + penwidth = 1 ; + if ( m_pen.GetStyle() == wxTRANSPARENT ) + penwidth = 0 ; + + bool offset = ( penwidth % 2 ) == 1 ; + wxGraphicPath* path = m_graphicContext->CreatePath() ; - path->AddRectangle( xx , yy , ww , hh ) ; + // if we are offsetting the entire rectangle is moved 0.5, so the border line gets off by 1 + if ( offset ) + path->AddRectangle( xx , yy , ww-1 , hh-1 ) ; + else + path->AddRectangle( xx , yy , ww , hh ) ; + m_graphicContext->DrawPath( path ) ; delete path ; } @@ -1956,19 +1962,13 @@ void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, } else { - m_graphicContext->PushState() ; - m_graphicContext->Translate( xx , yy ) ; - m_graphicContext->Scale( radius , radius ) ; - double fw = ww / radius ; - double fh = hh / radius; - path->MoveToPoint(fw, fh / 2); - path->AddArcToPoint(fw, fh, fw / 2, fh, 1); - path->AddArcToPoint(0, fh, 0, fh / 2, 1); - path->AddArcToPoint(0, 0, fw / 2, 0, 1); - path->AddArcToPoint(fw, 0, fw, fh / 2, 1); + path->MoveToPoint( xx + ww, yy + hh / 2); + path->AddArcToPoint(xx + ww, yy + hh, xx + ww / 2,yy + hh, radius); + path->AddArcToPoint(xx , yy + hh, xx , yy + hh / 2, radius); + path->AddArcToPoint(xx , yy , xx + ww / 2, yy , radius); + path->AddArcToPoint(xx + ww, yy , xx + ww, yy + hh / 2, radius); path->CloseSubpath(); m_graphicContext->DrawPath( path ) ; - m_graphicContext->PopState() ; } delete path ; } @@ -2000,7 +2000,7 @@ void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) hh = -hh; yy = yy - hh; } - + wxGraphicPath* path = m_graphicContext->CreatePath() ; m_graphicContext->PushState() ; m_graphicContext->Translate(xx + ww / 2, yy + hh / 2); @@ -2021,8 +2021,22 @@ bool wxDC::DoBlit( wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func , bool useMask, wxCoord xsrcMask, wxCoord ysrcMask ) { - wxCHECK_MSG( Ok(), false, wxT("wxDC(cg)::DoBlit - invalid DC") ); - wxCHECK_MSG( source->Ok(), false, wxT("wxDC(cg)::DoBlit - invalid source DC") ); + return DoStretchBlit( xdest, ydest, width, height, + source, xsrc, ysrc, width, height, + logical_func, useMask, + xsrcMask, ysrcMask ); +} + +bool wxDC::DoStretchBlit(wxCoord xdest, wxCoord ydest, + wxCoord dstWidth, wxCoord dstHeight, + wxDC *source, + wxCoord xsrc, wxCoord ysrc, + wxCoord srcWidth, wxCoord srcHeight, + int logical_func = wxCOPY, bool useMask = false, + wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord); +{ + wxCHECK_MSG( Ok(), false, wxT("wxDC(cg)::DoStretchBlit - invalid DC") ); + wxCHECK_MSG( source->Ok(), false, wxT("wxDC(cg)::DoStretchBlit - invalid source DC") ); if ( logical_func == wxNO_OP ) return true ; @@ -2035,13 +2049,13 @@ bool wxDC::DoBlit( wxCoord yysrc = source->YLOG2DEVMAC(ysrc) ; wxCoord xxsrc = source->XLOG2DEVMAC(xsrc) ; - wxCoord wwsrc = source->XLOG2DEVREL(width) ; - wxCoord hhsrc = source->YLOG2DEVREL(height) ; + wxCoord wwsrc = source->XLOG2DEVREL(srcWidth) ; + wxCoord hhsrc = source->YLOG2DEVREL(srcHeight) ; wxCoord yydest = YLOG2DEVMAC(ydest) ; wxCoord xxdest = XLOG2DEVMAC(xdest) ; - wxCoord wwdest = XLOG2DEVREL(width) ; - wxCoord hhdest = YLOG2DEVREL(height) ; + wxCoord wwdest = XLOG2DEVREL(dstWidth) ; + wxCoord hhdest = YLOG2DEVREL(dstHeight) ; wxMemoryDC* memdc = dynamic_cast(source) ; if ( memdc && logical_func == wxCOPY ) @@ -2086,7 +2100,7 @@ bool wxDC::DoBlit( else { wxFAIL_MSG( wxT("Blitting is only supported from bitmap contexts, and only with wxCOPY logical operation.") ) ; - return false ; + return false ; } return true; @@ -2129,14 +2143,13 @@ void wxDC::DoGetTextExtent( const wxString &str, wxCoord *width, wxCoord *height { wxCHECK_RET( Ok(), wxT("wxDC(cg)::DoGetTextExtent - invalid DC") ); - wxFont formerFont = m_font ; if ( theFont ) { m_graphicContext->SetFont( *theFont ) ; } wxCoord h , d , e , w ; - + m_graphicContext->GetTextExtent( str, &w, &h, &d, &e ) ; if ( height ) @@ -2259,50 +2272,70 @@ void wxDC::Clear(void) } } +#endif + #pragma mark - // --------------------------------------------------------------------------- // coordinates transformations // --------------------------------------------------------------------------- +/* + wxCoord XLOG2DEVMAC(wxCoord x) const + { + long new_x = x - m_logicalOriginX; + if (new_x > 0) + return (wxCoord)((double)new_x * m_scaleX + 0.5) * m_signX + m_deviceOriginX + m_macLocalOrigin.x; + else + return (wxCoord)((double)new_x * m_scaleX - 0.5) * m_signX + m_deviceOriginX + m_macLocalOrigin.x; + } + wxCoord YLOG2DEVMAC(wxCoord y) const + { + long new_y = y - m_logicalOriginY; + if (new_y > 0) + return (wxCoord)((double)new_y * m_scaleY + 0.5) * m_signY + m_deviceOriginY + m_macLocalOrigin.y; + else + return (wxCoord)((double)new_y * m_scaleY - 0.5) * m_signY + m_deviceOriginY + m_macLocalOrigin.y; + } +*/ // TODO wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const { - return ((wxDC *)this)->XDEV2LOG(x); + return wxRound((double)(x - m_deviceOriginX) / m_scaleX) * m_signX + m_logicalOriginX; } wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const { - return ((wxDC *)this)->YDEV2LOG(y); + return wxRound((double)(y - m_deviceOriginY) / m_scaleY) * m_signY + m_logicalOriginY; } wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const { - return ((wxDC *)this)->XDEV2LOGREL(x); + return wxRound((double)(x) / m_scaleX); } wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const { - return ((wxDC *)this)->YDEV2LOGREL(y); + return wxRound((double)(y) / m_scaleY); } wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const { - return ((wxDC *)this)->XLOG2DEV(x); + return wxRound((double)(x - m_logicalOriginX) * m_scaleX) * m_signX + m_deviceOriginX; } wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const { - return ((wxDC *)this)->YLOG2DEV(y); + return wxRound((double)(y - m_logicalOriginY) * m_scaleY) * m_signY + m_deviceOriginY; } wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const { - return ((wxDC *)this)->XLOG2DEVREL(x); + return wxRound((double)(x) * m_scaleX); } wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const { - return ((wxDC *)this)->YLOG2DEVREL(y); + return wxRound((double)(y) * m_scaleY); } #endif // wxMAC_USE_CORE_GRAPHICS