X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c94f845b1602d44ccd7c7542afffde666adbb2f0..d2e66707deb10dea6f92e3e4092f8a43ef942a5d:/src/mgl/dc.cpp?ds=sidebyside diff --git a/src/mgl/dc.cpp b/src/mgl/dc.cpp index 08c78c6a1d..40766b5af5 100644 --- a/src/mgl/dc.cpp +++ b/src/mgl/dc.cpp @@ -205,7 +205,7 @@ void wxDC::InitializeMGLDC() void wxDC::DoSetClippingRegion(wxCoord cx, wxCoord cy, wxCoord cw, wxCoord ch) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); wxRect rect(XLOG2DEV(cx), YLOG2DEV(cy), XLOG2DEVREL(cw), YLOG2DEVREL(ch)); @@ -220,9 +220,9 @@ void wxDC::DoSetClippingRegion(wxCoord cx, wxCoord cy, wxCoord cw, wxCoord ch) DO_SET_CLIPPING_BOX(m_currentClippingRegion) } -void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region) +void wxDC::DoSetDeviceClippingRegion(const wxRegion& region) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); if ( region.IsEmpty() ) { @@ -262,7 +262,7 @@ void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region) void wxDC::DestroyClippingRegion() { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); if ( !m_globalClippingRegion.IsNull() ) { @@ -303,7 +303,7 @@ int wxDC::GetDepth() const void wxDC::Clear() { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); m_MGLDC->makeCurrent(); // will go away with MGL6.0 if ( m_backgroundBrush.GetStyle() != wxTRANSPARENT ) @@ -319,17 +319,17 @@ void wxDC::Clear() } extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, - const wxColour & col, int style); + const wxColour & col, wxFloodFillStyle style); bool wxDC::DoFloodFill(wxCoord x, wxCoord y, - const wxColour& col, int style) + const wxColour& col, wxFloodFillStyle style) { return wxDoFloodFill(this, x, y, col, style); } bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const { - wxCHECK_MSG( col, false, _T("NULL colour parameter in wxDC::GetPixel")); + wxCHECK_MSG( col, false, wxT("NULL colour parameter in wxDC::GetPixel")); uchar r, g, b; m_MGLDC->unpackColorFast(m_MGLDC->getPixel(XLOG2DEV(x), YLOG2DEV(y)), @@ -340,7 +340,7 @@ bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const void wxDC::DoCrossHair(wxCoord x, wxCoord y) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); if ( m_pen.GetStyle() != wxTRANSPARENT ) { @@ -361,7 +361,7 @@ void wxDC::DoCrossHair(wxCoord x, wxCoord y) void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); if ( m_pen.GetStyle() != wxTRANSPARENT ) { @@ -381,7 +381,7 @@ void wxDC::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); wxCoord xx1 = XLOG2DEV(x1); wxCoord yy1 = YLOG2DEV(y1); @@ -440,7 +440,7 @@ void wxDC::DoDrawArc(wxCoord x1, wxCoord y1, void wxDC::DoDrawPoint(wxCoord x, wxCoord y) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); if ( m_pen.GetStyle() != wxTRANSPARENT ) { @@ -452,9 +452,9 @@ void wxDC::DoDrawPoint(wxCoord x, wxCoord y) } } -void wxDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset,int WXUNUSED(fillStyle)) +void wxDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset,wxPolygonFillMode WXUNUSED(fillStyle)) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); wxCoord xxoffset = XLOG2DEVREL(xoffset), yyoffset = YLOG2DEVREL(yoffset); @@ -495,7 +495,7 @@ void wxDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffs void wxDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); if ( m_pen.GetStyle() != wxTRANSPARENT ) { @@ -516,7 +516,7 @@ void wxDC::DoDrawLines(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); wxCoord xx = XLOG2DEV(x); wxCoord yy = YLOG2DEV(y); @@ -559,7 +559,7 @@ void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); if ( radius < 0.0 ) radius = -radius * ((width < height) ? width : height); @@ -635,7 +635,7 @@ void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord h void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); wxCoord x2 = (x+width); wxCoord y2 = (y+height); @@ -664,7 +664,7 @@ void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) void wxDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,double sa,double ea) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); wxCoord x2 = (x+w); wxCoord y2 = (y+h); @@ -736,7 +736,7 @@ bool wxDC::SelectMGLFont() void wxDC::DrawAnyText(const wxString& text, wxCoord x, wxCoord y) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); SelectMGLFont(); @@ -983,7 +983,7 @@ void wxDC::SelectMGLFatPen(int style, int flag) pixPattern->p[x][y][2]); break; default: - wxFAIL_MSG(_T("invalid DC depth")); + wxFAIL_MSG(wxT("invalid DC depth")); break; } m_MGLDC->setPenPixmapPattern(slot, &pix); @@ -999,7 +999,7 @@ void wxDC::SelectMGLFatPen(int style, int flag) void wxDC::SelectPen() { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); wxColour& clr = m_pen.GetColour(); m_MGLDC->makeCurrent(); // will go away with MGL6.0 @@ -1045,7 +1045,7 @@ void wxDC::SelectPen() void wxDC::SelectBrush() { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); wxColour fg, bg; m_MGLDC->makeCurrent(); // will go away with MGL6.0 @@ -1071,7 +1071,7 @@ void wxDC::SelectBrush() void wxDC::SetPen(const wxPen& pen) { - if ( !pen.Ok() ) return; + if ( !pen.IsOk() ) return; if ( m_pen == pen ) return; m_pen = pen; m_penSelected = false; @@ -1080,7 +1080,7 @@ void wxDC::SetPen(const wxPen& pen) void wxDC::SetBrush(const wxBrush& brush) { - if ( !brush.Ok() ) return; + if ( !brush.IsOk() ) return; if ( m_brush == brush ) return; m_brush = brush; m_brushSelected = false; @@ -1089,11 +1089,11 @@ void wxDC::SetBrush(const wxBrush& brush) void wxDC::SetPalette(const wxPalette& palette) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); - if ( !palette.Ok() ) + if ( !palette.IsOk() ) { - if ( m_oldPalette.Ok() ) + if ( m_oldPalette.IsOk() ) SetPalette(m_oldPalette); return; } @@ -1112,7 +1112,7 @@ void wxDC::SetPalette(const wxPalette& palette) void wxDC::SetFont(const wxFont& font) { - if ( font.Ok() ) + if ( font.IsOk() ) { m_font = font; m_mglFont = NULL; @@ -1121,9 +1121,9 @@ void wxDC::SetFont(const wxFont& font) void wxDC::SetBackground(const wxBrush& brush) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); - if (!brush.Ok()) return; + if (!brush.IsOk()) return; m_backgroundBrush = brush; wxColour &clr = m_backgroundBrush.GetColour(); @@ -1141,9 +1141,9 @@ void wxDC::SetBackgroundMode(int mode) m_MGLDC->setBackMode(MGL_TRANSPARENT_BACKGROUND); } -void wxDC::SetLogicalFunction(int function) +void wxDC::SetLogicalFunction(wxRasterOperationMode function) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); m_logicalFunction = function; @@ -1237,7 +1237,7 @@ void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, if ( x ) // VS: YDEV is corrent, it should *not* be XDEV, because font's are // only scaled according to m_scaleY - *x = YDEV2LOGREL(m_MGLDC->textWidth(string.c_str())); + *x = YDEV2LOGREL(m_MGLDC->textWidth(string.wc_str())); if ( y ) *y = YDEV2LOGREL(m_MGLDC->textHeight()); if ( descent ) @@ -1250,7 +1250,6 @@ void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, } - // --------------------------------------------------------------------------- // mapping modes // --------------------------------------------------------------------------- @@ -1270,114 +1269,6 @@ void wxDC::ComputeScaleAndOrigin() m_scaleX = newX, m_scaleY = newY; } -void wxDC::SetMapMode(int mode) -{ - switch (mode) - { - case wxMM_TWIPS: - SetLogicalScale(twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y); - break; - case wxMM_POINTS: - SetLogicalScale(pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y); - break; - case wxMM_METRIC: - SetLogicalScale(m_mm_to_pix_x, m_mm_to_pix_y); - break; - case wxMM_LOMETRIC: - SetLogicalScale(m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0); - break; - default: - case wxMM_TEXT: - SetLogicalScale(1.0, 1.0); - break; - } - m_mappingMode = mode; -} - -void wxDC::SetUserScale( double x, double y ) -{ - // allow negative ? -> no - m_userScaleX = x; - m_userScaleY = y; - ComputeScaleAndOrigin(); -} - -void wxDC::SetLogicalScale( double x, double y ) -{ - // allow negative ? - m_logicalScaleX = x; - m_logicalScaleY = y; - ComputeScaleAndOrigin(); -} - -void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y ) -{ - m_logicalOriginX = x * m_signX; // is this still correct ? - m_logicalOriginY = y * m_signY; - ComputeScaleAndOrigin(); -} - -void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y ) -{ - // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there - m_deviceOriginX = x; - m_deviceOriginY = y; - ComputeScaleAndOrigin(); -} - -void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) -{ - // only wxPostScripDC has m_signX = -1, we override SetAxisOrientation there - m_signX = (xLeftRight ? 1 : -1); - m_signY = (yBottomUp ? -1 : 1); - ComputeScaleAndOrigin(); -} - -// --------------------------------------------------------------------------- -// coordinates transformations -// --------------------------------------------------------------------------- - -wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const -{ - return ((wxDC *)this)->XDEV2LOG(x); -} - -wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const -{ - return ((wxDC *)this)->YDEV2LOG(y); -} - -wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const -{ - return ((wxDC *)this)->XDEV2LOGREL(x); -} - -wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const -{ - return ((wxDC *)this)->YDEV2LOGREL(y); -} - -wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const -{ - return ((wxDC *)this)->XLOG2DEV(x); -} - -wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const -{ - return ((wxDC *)this)->YLOG2DEV(y); -} - -wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const -{ - return ((wxDC *)this)->XLOG2DEVREL(x); -} - -wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const -{ - return ((wxDC *)this)->YLOG2DEVREL(y); -} - - void wxDC::DoGetSize(int *w, int *h) const { if (w) *w = m_MGLDC->sizex()+1; @@ -1407,10 +1298,10 @@ wxSize wxDC::GetPPI() const bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, - int rop, bool useMask, + wxRasterOperationMode rop, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask) { - wxCHECK_MSG( Ok(), false, wxT("invalid dc") ); + wxCHECK_MSG( IsOk(), false, wxT("invalid dc") ); wxCHECK_MSG( source, false, wxT("invalid source dc") ); // transform the source DC coords to the device ones @@ -1458,8 +1349,8 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, void wxDC::DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); - wxCHECK_RET( bmp.Ok(), wxT("invalid bitmap") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); + wxCHECK_RET( bmp.IsOk(), wxT("invalid bitmap") ); wxCoord w = bmp.GetWidth(); wxCoord h = bmp.GetHeight(); @@ -1501,8 +1392,8 @@ void wxDC::DoDrawSubBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, wxCoord w, wxCoord h, wxCoord destx, wxCoord desty, int rop, bool useMask) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); - wxCHECK_RET( bmp.Ok(), wxT("invalid bitmap") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); + wxCHECK_RET( bmp.IsOk(), wxT("invalid bitmap") ); CalcBoundingBox(x, y); CalcBoundingBox(x + w, y + h);