X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d16b634fa336d09050d01786fb420d32ef43d311..eea4d01c65f9b29baa1193db762b4c6b8144af24:/src/mgl/dc.cpp?ds=inline diff --git a/src/mgl/dc.cpp b/src/mgl/dc.cpp index 5b4101fd20..40766b5af5 100644 --- a/src/mgl/dc.cpp +++ b/src/mgl/dc.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: dc.cpp +// Name: src/mgl/dc.cpp // Purpose: wxDC class // Author: Vaclav Slavik // Created: 2001/03/09 @@ -16,10 +16,6 @@ // headers // --------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "dc.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -30,16 +26,15 @@ #ifndef WX_PRECOMP #include "wx/dc.h" #include "wx/dcmemory.h" + #include "wx/log.h" #endif #include "wx/fontutil.h" #include "wx/encinfo.h" #include "wx/fontmap.h" #include "wx/mgl/private.h" -#include "wx/log.h" #include -#include #include @@ -48,16 +43,6 @@ // constants //----------------------------------------------------------------------------- -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -const double mm2inches = 0.0393700787402; -const double inches2mm = 25.4; -const double mm2twips = 56.6929133859; -const double twips2mm = 0.0176388888889; -const double mm2pt = 2.83464566929; -const double pt2mm = 0.352777777778; const double RAD2DEG = 180.0 / M_PI; @@ -152,10 +137,10 @@ IMPLEMENT_ABSTRACT_CLASS(wxDC, wxDCBase) // Default constructor wxDC::wxDC() { - m_isMemDC = FALSE; + m_isMemDC = false; m_MGLDC = NULL; - m_OwnsMGLDC = FALSE; - m_ok = FALSE; // must call SetMGLDevCtx() before using it + m_OwnsMGLDC = false; + m_ok = false; // must call SetMGLDevCtx() before using it m_mm_to_pix_x = (double)wxGetDisplaySize().GetWidth() / (double)wxGetDisplaySizeMM().GetWidth(); @@ -167,8 +152,8 @@ wxDC::wxDC() m_brush = *wxWHITE_BRUSH; m_penOfsX = m_penOfsY = 0; - m_penSelected = m_brushSelected = FALSE; - m_downloadedPatterns[0] = m_downloadedPatterns[1] = FALSE; + m_penSelected = m_brushSelected = false; + m_downloadedPatterns[0] = m_downloadedPatterns[1] = false; m_mglFont = NULL; } @@ -186,7 +171,7 @@ void wxDC::SetMGLDC(MGLDevCtx *mgldc, bool OwnsMGLDC) delete m_MGLDC; m_MGLDC = mgldc; m_OwnsMGLDC = OwnsMGLDC; - m_ok = TRUE; + m_ok = true; if ( !m_globalClippingRegion.IsNull() ) SetClippingRegion(m_globalClippingRegion); @@ -220,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)); @@ -231,13 +216,13 @@ void wxDC::DoSetClippingRegion(wxCoord cx, wxCoord cy, wxCoord cw, wxCoord ch) m_MGLDC->setClipRegion(m_currentClippingRegion.GetMGLRegion()); - m_clipping = TRUE; + m_clipping = true; 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() ) { @@ -271,19 +256,19 @@ void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region) m_MGLDC->setClipRegion(m_currentClippingRegion.GetMGLRegion()); - m_clipping = TRUE; + m_clipping = true; DO_SET_CLIPPING_BOX(m_currentClippingRegion) } void wxDC::DestroyClippingRegion() { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); if ( !m_globalClippingRegion.IsNull() ) { m_MGLDC->setClipRegion(m_globalClippingRegion.GetMGLRegion()); m_currentClippingRegion = m_globalClippingRegion; - m_clipping = TRUE; + m_clipping = true; } else { @@ -299,12 +284,12 @@ void wxDC::DestroyClippingRegion() bool wxDC::CanDrawBitmap() const { - return TRUE; + return true; } bool wxDC::CanGetTextExtent() const { - return TRUE; + return true; } int wxDC::GetDepth() const @@ -318,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 ) @@ -334,28 +319,28 @@ 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)), r, g, b); col->Set(r, g, b); - return TRUE; + return true; } void wxDC::DoCrossHair(wxCoord x, wxCoord y) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); if ( m_pen.GetStyle() != wxTRANSPARENT ) { @@ -376,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 ) { @@ -396,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); @@ -455,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 ) { @@ -467,9 +452,9 @@ void wxDC::DoDrawPoint(wxCoord x, wxCoord y) } } -void wxDC::DoDrawPolygon(int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset,int 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); @@ -510,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 ) { @@ -531,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); @@ -574,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); @@ -650,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); @@ -679,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); @@ -725,7 +710,7 @@ bool wxDC::SelectMGLFont() bool antialiased = (GetDepth() > 8); m_mglFont = m_font.GetMGLfont_t(scale, antialiased); - wxCHECK_MSG( m_mglFont, FALSE, wxT("invalid font") ); + wxCHECK_MSG( m_mglFont, false, wxT("invalid font") ); m_MGLDC->useFont(m_mglFont); wxLogTrace("mgl_font", "useFont(%p)", m_mglFont); @@ -746,12 +731,12 @@ bool wxDC::SelectMGLFont() m_MGLDC->setTextEncoding(nativeEnc.mglEncoding); #endif } - return TRUE; + return true; } void wxDC::DrawAnyText(const wxString& text, wxCoord x, wxCoord y) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); SelectMGLFont(); @@ -810,7 +795,7 @@ void wxDC::DrawAnyText(const wxString& text, wxCoord x, wxCoord y) m_MGLDC->line(x1, y1, x2, y2); } - m_penSelected = m_brushSelected = FALSE; + m_penSelected = m_brushSelected = false; } void wxDC::DoDrawRotatedText(const wxString& text, @@ -952,7 +937,7 @@ void wxDC::SelectMGLFatPen(int style, int flag) if ( !m_downloadedPatterns[slot] ) { m_MGLDC->setPenBitmapPattern(slot, pattern); - m_downloadedPatterns[slot] = TRUE; + m_downloadedPatterns[slot] = true; } m_MGLDC->usePenBitmapPattern(slot); } @@ -969,7 +954,7 @@ void wxDC::SelectMGLFatPen(int style, int flag) case 8: for (y = 0; y < 8; y++) for (x = 0; x < 8; x++) - pix.b8.p[x][y] = m_MGLDC->packColorFast( + pix.b8.p[x][y] = (uchar)m_MGLDC->packColorFast( pixPattern->p[x][y][0], pixPattern->p[x][y][1], pixPattern->p[x][y][2]); @@ -978,7 +963,7 @@ void wxDC::SelectMGLFatPen(int style, int flag) case 16: for (y = 0; y < 8; y++) for (x = 0; x < 8; x++) - pix.b16.p[x][y] = m_MGLDC->packColorFast( + pix.b16.p[x][y] = (M_uint16)m_MGLDC->packColorFast( pixPattern->p[x][y][0], pixPattern->p[x][y][1], pixPattern->p[x][y][2]); @@ -998,11 +983,11 @@ 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); - m_downloadedPatterns[slot] = TRUE; + m_downloadedPatterns[slot] = true; } m_MGLDC->usePenPixmapPattern(slot); } @@ -1014,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 @@ -1054,13 +1039,13 @@ void wxDC::SelectPen() SelectMGLFatPen(wxSOLID, wxMGL_SELECT_FROM_PEN); break; } - m_penSelected = TRUE; - m_brushSelected = FALSE; + m_penSelected = true; + m_brushSelected = false; } 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 @@ -1078,43 +1063,44 @@ void wxDC::SelectBrush() m_MGLDC->setColorRGB(fg.Red(), fg.Green(), fg.Blue()); m_MGLDC->setBackColor(m_MGLDC->packColorFast(bg.Red(), bg.Green(), bg.Blue())); - m_penSelected = FALSE; - m_brushSelected = TRUE; + m_penSelected = false; + m_brushSelected = true; SelectMGLFatPen(m_brush.GetStyle(), wxMGL_SELECT_FROM_BRUSH); } 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; - m_downloadedPatterns[0] = FALSE; + m_penSelected = false; + m_downloadedPatterns[0] = false; } 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; - m_downloadedPatterns[1] = FALSE; + m_brushSelected = false; + m_downloadedPatterns[1] = false; } void wxDC::SetPalette(const wxPalette& palette) { - wxCHECK_RET( Ok(), wxT("invalid dc") ); + wxCHECK_RET( IsOk(), wxT("invalid dc") ); - if ( palette == wxNullPalette ) + if ( !palette.IsOk() ) { - if ( m_oldPalette.Ok() ) + if ( m_oldPalette.IsOk() ) SetPalette(m_oldPalette); return; } - if ( !palette.Ok() ) return; - if ( m_palette == palette ) return; + if ( palette.IsSameAs(m_palette) ) + return; + m_oldPalette = m_palette; m_palette = palette; @@ -1126,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; @@ -1135,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 (!m_backgroundBrush.Ok()) return; + if (!brush.IsOk()) return; m_backgroundBrush = brush; wxColour &clr = m_backgroundBrush.GetColour(); @@ -1155,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; @@ -1194,10 +1180,10 @@ int wxDC::LogicalFunctionToMGLRop(int logFunc) const return (int)rop; } -bool wxDC::StartDoc(const wxString& message) +bool wxDC::StartDoc(const wxString& WXUNUSED(message)) { - // We might be previewing, so return TRUE to let it continue. - return TRUE; + // We might be previewing, so return true to let it continue. + return true; } void wxDC::EndDoc() @@ -1235,7 +1221,7 @@ wxCoord wxDC::GetCharWidth() const void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, wxCoord *descent, wxCoord *externalLeading, - wxFont *theFont) const + const wxFont *theFont) const { wxFont oldFont; @@ -1251,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 ) @@ -1264,7 +1250,6 @@ void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, } - // --------------------------------------------------------------------------- // mapping modes // --------------------------------------------------------------------------- @@ -1279,119 +1264,11 @@ void wxDC::ComputeScaleAndOrigin() m_mglFont = NULL; // make sure m_penOfs{X,Y} will be reevaluated before drawing: if ( newY != m_scaleY || newX != m_scaleX ) - m_penSelected = FALSE; + m_penSelected = false; 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; @@ -1421,11 +1298,11 @@ 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( source, FALSE, wxT("invalid source 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 xsrc = source->LogicalToDeviceX(xsrc); @@ -1448,30 +1325,32 @@ bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, /* scale/translate size and position */ wxCoord xx = XLOG2DEV(xdest); wxCoord yy = YLOG2DEV(ydest); - wxCoord ww = XLOG2DEVREL(width); - wxCoord hh = YLOG2DEVREL(height); if ( source->m_isMemDC ) { wxMemoryDC *memDC = (wxMemoryDC*) source; - DoDrawSubBitmap(memDC->GetSelectedObject(), xsrc, ysrc, ww, hh, + DoDrawSubBitmap(memDC->GetSelectedObject(), + xsrc, ysrc, width, height, xdest, ydest, rop, useMask); } else { + wxCoord ww = XLOG2DEVREL(width); + wxCoord hh = YLOG2DEVREL(height); + m_MGLDC->makeCurrent(); // will go away with MGL6.0 m_MGLDC->bitBlt(*source->GetMGLDC(), xsrc, ysrc, xsrc + ww, ysrc + hh, xx, yy, LogicalFunctionToMGLRop(rop)); } - return TRUE; + return true; } 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(); @@ -1482,7 +1361,7 @@ void wxDC::DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask) void wxDC::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y) { // VZ: egcs 1.0.3 refuses to compile this without cast, no idea why - DoDrawBitmap((const wxBitmap&)icon, x, y, (bool)TRUE); + DoDrawBitmap((const wxBitmap&)icon, x, y, true); } @@ -1513,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); @@ -1560,7 +1439,7 @@ void wxDC::DoDrawSubBitmap(const wxBitmap &bmp, // This sequence of operations ensures that the source's transparent // area need not be black, and logical functions are supported. - wxBitmap *mask = bmp.GetMask()->GetBitmap(); + wxBitmap mask = bmp.GetMask()->GetBitmap(); MGLMemoryDC *temp; @@ -1568,7 +1447,7 @@ void wxDC::DoDrawSubBitmap(const wxBitmap &bmp, { temp = new MGLMemoryDC(dw, dh, GetDepth(), NULL); wxDC tempdc; - tempdc.SetMGLDC(temp, FALSE); + tempdc.SetMGLDC(temp, false); tempdc.SetPalette(m_palette); } else @@ -1585,10 +1464,10 @@ void wxDC::DoDrawSubBitmap(const wxBitmap &bmp, DoBitBlt(bmp, temp, x, y, w, h, 0, 0, dw, dh, mglRop, useStretching, putSection); - mask->SetMonoPalette(wxColour(0,0,0), wxColour(255,255,255)); - DoBitBlt(*mask, temp, x, y, w, h, 0, 0, dw, dh, MGL_R2_MASKSRC, + mask.SetMonoPalette(wxColour(0,0,0), wxColour(255,255,255)); + DoBitBlt(mask, temp, x, y, w, h, 0, 0, dw, dh, MGL_R2_MASKSRC, useStretching, putSection); - DoBitBlt(*mask, m_MGLDC, x, y, w, h, dx, dy, dw, dh, MGL_R2_MASKNOTSRC, + DoBitBlt(mask, m_MGLDC, x, y, w, h, dx, dy, dw, dh, MGL_R2_MASKNOTSRC, useStretching, putSection); m_MGLDC->bitBlt(*temp, 0, 0, dw, dh, dx, dy, MGL_OR_MODE);