X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7c74e7fe1de14f32dcd6f3c9cdd727de540bbd0e..f3979fcc3bf1395de08fb9a43cabd7de772f5309:/src/mac/dc.cpp diff --git a/src/mac/dc.cpp b/src/mac/dc.cpp index fe34b61a97..ecbb3ca703 100644 --- a/src/mac/dc.cpp +++ b/src/mac/dc.cpp @@ -15,9 +15,7 @@ #include "wx/dc.h" -#if !USE_SHARED_LIBRARY IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) -#endif //----------------------------------------------------------------------------- // constants @@ -86,6 +84,7 @@ wxDC::wxDC(void) // m_palette = wxAPP_COLOURMAP; m_macPort = NULL ; + m_macMask = NULL ; m_ok = FALSE ; m_macFontInstalled = false ; @@ -155,8 +154,6 @@ void wxDC::DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask ) RGBColor black = { 0,0,0} ; RGBForeColor( &black ) ; RGBBackColor( &white ) ; - // RGBForeColor( &m_textForegroundColour.GetPixel() ) ; - // RGBBackColor( &m_textBackgroundColour.GetPixel() ) ; bmappixels = GetGWorldPixMap( bmapworld ) ; if ( LockPixels(bmappixels) ) @@ -170,21 +167,20 @@ void wxDC::DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask ) dest.left = XLOG2DEV(x) ; dest.bottom = YLOG2DEV(y + bmap->m_height ) ; dest.right = XLOG2DEV(x + bmap->m_width ) ; - // ::ClipRect(&m_macClipRect); - CopyBits( &GrafPtr( bmapworld )->portBits , &GrafPtr( m_macPort )->portBits , - &source, &dest, srcCopy, NULL ) ; - /* - if ( m_clipping ) - { - long x1 = XLOG2DEV(m_clipX1); - long y1 = YLOG2DEV(m_clipY1); - long x2 = XLOG2DEV(m_clipX2); - long y2 = YLOG2DEV(m_clipY2); - Rect clip = { y1 , x1 , y2 , x2 } ; - ::ClipRect(&clip); + if ( useMask && bmp.GetMask() ) + { + if ( LockPixels( GetGWorldPixMap( bmp.GetMask()->GetMaskBitmap( ) ) ) ) + { + CopyMask( &GrafPtr( bmapworld )->portBits , &GrafPtr( bmp.GetMask()->GetMaskBitmap( ) )->portBits , &GrafPtr( m_macPort )->portBits , + &source, &source , &dest ) ; + UnlockPixels( GetGWorldPixMap( bmp.GetMask()->GetMaskBitmap( ) ) ) ; + } } - */ + else + CopyBits( &GrafPtr( bmapworld )->portBits , &GrafPtr( m_macPort )->portBits , + &source, &dest, srcCopy, NULL ) ; + UnlockPixels( bmappixels ) ; } m_macPenInstalled = false ; @@ -277,7 +273,7 @@ void wxDC::DrawSpline( int n, wxPoint points[] ) DrawSpline( &list ); }; -void wxDC::SetClippingRegion( long x, long y, long width, long height ) +void wxDC::SetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) { MacVerifySetup() ; if( m_clipping ) @@ -308,6 +304,11 @@ void wxDC::SetClippingRegion( long x, long y, long width, long height ) }; +void wxDC::SetClippingRegion(const wxRect& rect) +{ + SetClippingRegion(rect.x, rect.y, rect.width, rect.height); +} + void wxDC::DestroyClippingRegion(void) { MacVerifySetup() ; @@ -316,6 +317,19 @@ void wxDC::DestroyClippingRegion(void) ::ClipRect(&m_macClipRect); }; +void wxDC::GetClippingBox( wxCoord *x, wxCoord *y, wxCoord *width, wxCoord *height ) const +{ + if (m_clipping) + { + if (x) *x = m_clipX1; + if (y) *y = m_clipY1; + if (width) *width = (m_clipX2 - m_clipX1); + if (height) *height = (m_clipY2 - m_clipY1); + } + else + *x = *y = *width = *height = 0; +}; + void wxDC::GetClippingBox( long *x, long *y, long *width, long *height ) const { if (m_clipping) @@ -329,6 +343,14 @@ void wxDC::GetClippingBox( long *x, long *y, long *width, long *height ) const *x = *y = *width = *height = 0; }; +void wxDC::GetClippingBox(wxRect& rect) const +{ + // Necessary to use intermediate variables for 16-bit compilation + wxCoord x, y, w, h; + GetClippingBox(&x, &y, &w, &h); + rect.x = x; rect.y = y; rect.width = w; rect.height = h; +} + void wxDC::GetSize( int* width, int* height ) const { *width = m_maxX-m_minX; @@ -1047,8 +1069,6 @@ bool wxDC::Blit( long xdest, long ydest, long width, long height, PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ; RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ; RGBColor black = { 0,0,0} ; -// RGBForeColor( &black ) ; -// RGBBackColor( &white ) ; RGBForeColor( &m_textForegroundColour.GetPixel() ) ; RGBBackColor( &m_textBackgroundColour.GetPixel() ) ; @@ -1063,21 +1083,36 @@ bool wxDC::Blit( long xdest, long ydest, long width, long height, dstrect.left = XLOG2DEV(xdest) ; dstrect.bottom = YLOG2DEV(ydest + height ) ; dstrect.right = XLOG2DEV(xdest + width ) ; -// ::ClipRect(&m_macClipRect); + + short mode = (logical_func == wxCOPY ? srcCopy : + // logical_func == wxCLEAR ? WHITENESS : + // logical_func == wxSET ? BLACKNESS : + logical_func == wxINVERT ? hilite : + // logical_func == wxAND ? MERGECOPY : + logical_func == wxOR ? srcOr : + logical_func == wxSRC_INVERT ? notSrcCopy : + logical_func == wxXOR ? srcXor : + // logical_func == wxOR_REVERSE ? MERGEPAINT : + // logical_func == wxAND_REVERSE ? SRCERASE : + logical_func == wxSRC_OR ? srcOr : + // logical_func == wxSRC_AND ? SRCAND : + srcCopy ); + + if ( useMask && source->m_macMask ) + { + wxASSERT( mode == srcCopy ) ; + if ( LockPixels( GetGWorldPixMap( source->m_macMask ) ) ) + { + CopyMask( &GrafPtr( sourcePort )->portBits , &GrafPtr( source->m_macMask )->portBits , &GrafPtr( m_macPort )->portBits , + &srcrect, &srcrect , &dstrect ) ; + UnlockPixels( GetGWorldPixMap( source->m_macMask ) ) ; + } + } + else + { CopyBits( &GrafPtr( sourcePort )->portBits , &GrafPtr( m_macPort )->portBits , - &srcrect, &dstrect, srcCopy, NULL ) ; -/* - if ( m_clipping ) - { - long x1 = XLOG2DEV(m_clipX1); - long y1 = YLOG2DEV(m_clipY1); - long x2 = XLOG2DEV(m_clipX2); - long y2 = YLOG2DEV(m_clipY2); - - Rect clip = { y1 , x1 , y2 , x2 } ; - ::ClipRect(&clip); - } -*/ + &srcrect, &dstrect, mode, NULL ) ; + } UnlockPixels( bmappixels ) ; } @@ -1245,7 +1280,7 @@ void wxDC::GetTextExtent( const wxString &string, long *width, long *height, } } -long wxDC::GetCharWidth(void) +wxCoord wxDC::GetCharWidth(void) const { if (!Ok()) return 1; @@ -1260,7 +1295,7 @@ long wxDC::GetCharWidth(void) return (fi.descent + fi.ascent) / 2 ; } -long wxDC::GetCharHeight(void) +wxCoord wxDC::GetCharHeight(void) const { if (!Ok()) return 1;