-
-void wxDC::DoCrossHair( wxCoord x, wxCoord y )
-{
-}
-
-void wxDC::DoDrawArc( wxCoord x1, wxCoord y1,
- wxCoord x2, wxCoord y2,
- wxCoord xc, wxCoord yc )
-{
-}
-
-void wxDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
- double sa, double ea )
-{
-}
-
-void wxDC::DoDrawPoint( wxCoord x, wxCoord y )
-{
- if (!Ok())
- return;
-
- wxMacPortSetter helper(this) ;
-
- if (m_pen.GetStyle() != wxTRANSPARENT)
- {
- MacInstallPen() ;
- long xx1 = XLOG2DEV(x);
- long yy1 = YLOG2DEV(y);
-
- ::MoveTo(xx1,yy1);
- ::LineTo(xx1+1, yy1+1);
- };
-}
-
-void wxDC::DoDrawLines(int n, wxPoint points[],
- wxCoord xoffset, wxCoord yoffset)
-{
- if (!Ok())
- return;
- wxMacPortSetter helper(this) ;
-
- if (m_pen.GetStyle() == wxTRANSPARENT)
- return;
-
- MacInstallPen() ;
-
- int offset = (m_pen.GetWidth() - 1 ) / 2 ;
- long x1, x2 , y1 , y2 ;
- x1 = XLOG2DEV(points[0].x + xoffset);
- y1 = YLOG2DEV(points[0].y + yoffset);
- ::MoveTo(x1 - offset ,y1 - offset );
-
- for (int i = 0; i < n-1; i++)
- {
- x2 = XLOG2DEV(points[i+1].x + xoffset);
- y2 = YLOG2DEV(points[i+1].y + yoffset);
- ::LineTo(x2 - offset , y2 - offset );
- }
-}
-
-void wxDC::DoDrawPolygon(int n, wxPoint points[],
- wxCoord xoffset, wxCoord yoffset,
- int fillStyle )
-{
- if (!Ok())
- return;
- wxMacPortSetter helper(this) ;
-
- PolyHandle polygon = OpenPoly() ;
- long x1, x2 , y1 , y2 ;
- x1 = XLOG2DEV(points[0].x + xoffset);
- y1 = YLOG2DEV(points[0].y + yoffset);
- ::MoveTo(x1,y1);
-
- for (int i = 0; i < n-1; i++)
- {
- x2 = XLOG2DEV(points[i+1].x + xoffset);
- y2 = YLOG2DEV(points[i+1].y + yoffset);
- ::LineTo(x2, y2);
- }
-
- ClosePoly() ;
- if (m_brush.GetStyle() != wxTRANSPARENT)
- {
- MacInstallBrush() ;
- ::PaintPoly( polygon ) ;
- };
-
- if (m_pen.GetStyle() != wxTRANSPARENT)
- {
- MacInstallPen() ;
- ::FramePoly( polygon ) ;
- };
- KillPoly( polygon ) ;
-}
-
-void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
-{
- if (!Ok())
- return;
- wxMacPortSetter helper(this) ;
-
- long xx = XLOG2DEV(x);
- long yy = YLOG2DEV(y);
- long ww = m_signX * XLOG2DEVREL(width);
- long hh = m_signY * YLOG2DEVREL(height);
-
- // CMB: draw nothing if transformed w or h is 0
- if (ww == 0 || hh == 0)
- return;
-
- // CMB: handle -ve width and/or height
- if (ww < 0)
- {
- ww = -ww;
- xx = xx - ww;
- }
-
- if (hh < 0)
- {
- hh = -hh;
- yy = yy - hh;
- }
-
- Rect rect = { yy , xx , yy + hh , xx + ww } ;
-
- if (m_brush.GetStyle() != wxTRANSPARENT)
- {
- MacInstallBrush() ;
- ::PaintRect( &rect ) ;
- };
-
- if (m_pen.GetStyle() != wxTRANSPARENT)
- {
- MacInstallPen() ;
- ::FrameRect( &rect ) ;
- };
-}
-
-void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y,
- wxCoord width, wxCoord height,
- double radius)
-{
- if (!Ok())
- return;
- wxMacPortSetter helper(this) ;
-
- if (radius < 0.0)
- radius = - radius * ((width < height) ? width : height);
-
- long xx = XLOG2DEV(x);
- long yy = YLOG2DEV(y);
- long ww = m_signX * XLOG2DEVREL(width);
- long hh = m_signY * YLOG2DEVREL(height);
-
- // CMB: draw nothing if transformed w or h is 0
- if (ww == 0 || hh == 0)
- return;
-
- // CMB: handle -ve width and/or height
- if (ww < 0)
- {
- ww = -ww;
- xx = xx - ww;
- }
-
- if (hh < 0)
- {
- hh = -hh;
- yy = yy - hh;
- }
-
- Rect rect = { yy , xx , yy + hh , xx + ww } ;
-
- if (m_brush.GetStyle() != wxTRANSPARENT)
- {
- MacInstallBrush() ;
- ::PaintRoundRect( &rect , int(radius * 2) , int(radius * 2) ) ;
- };
-
- if (m_pen.GetStyle() != wxTRANSPARENT)
- {
- MacInstallPen() ;
- ::FrameRoundRect( &rect , int(radius * 2) , int(radius * 2) ) ;
- };
-}
-
-void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
-{
- if (!Ok())
- return;
- wxMacPortSetter helper(this) ;
-
- long xx = XLOG2DEV(x);
- long yy = YLOG2DEV(y);
- long ww = m_signX * XLOG2DEVREL(width);
- long hh = m_signY * YLOG2DEVREL(height);
-
- // CMB: draw nothing if transformed w or h is 0
- if (ww == 0 || hh == 0)
- return;
-
- // CMB: handle -ve width and/or height
- if (ww < 0)
- {
- ww = -ww;
- xx = xx - ww;
- }
-
- if (hh < 0)
- {
- hh = -hh;
- yy = yy - hh;
- }
-
- Rect rect = { yy , xx , yy + hh , xx + ww } ;
-
- if (m_brush.GetStyle() != wxTRANSPARENT)
- {
- MacInstallBrush() ;
- ::PaintOval( &rect ) ;
- };
-
- if (m_pen.GetStyle() != wxTRANSPARENT)
- {
- MacInstallPen() ;
- ::FrameOval( &rect ) ;
- };
-}
-
-
-
-bool wxDC::CanDrawBitmap(void) const
-{
- return true ;
-}
-
-
-bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
- wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func , bool useMask )
-{
- if (!Ok()) return FALSE;
- wxMacPortSetter helper(this) ;
-
- CGrafPtr sourcePort = (CGrafPtr) source->m_macPort ;
- PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ;
- RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ;
- RGBColor black = { 0,0,0} ;
- RGBColor forecolor = m_textForegroundColour.GetPixel();
- RGBColor backcolor = m_textBackgroundColour.GetPixel();
- RGBForeColor( &forecolor ) ;
- RGBBackColor( &backcolor ) ;
-
- if ( LockPixels(bmappixels) )
- {
- Rect srcrect , dstrect ;
- srcrect.top = source->YLOG2DEV(ysrc) ;
- srcrect.left = source->XLOG2DEV(xsrc) ;
- srcrect.right = source->XLOG2DEV(xsrc + width ) ;
- srcrect.bottom = source->YLOG2DEV(ysrc + height) ;
- dstrect.top = YLOG2DEV(ydest) ;
- dstrect.left = XLOG2DEV(xdest) ;
- dstrect.bottom = YLOG2DEV(ydest + height ) ;
- dstrect.right = XLOG2DEV(xdest + width ) ;
-
- 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( GetPortBitMapForCopyBits( sourcePort ) , GetPortBitMapForCopyBits( source->m_macMask ) ,
- GetPortBitMapForCopyBits( m_macPort ) ,
- &srcrect, &srcrect , &dstrect ) ;
- UnlockPixels( GetGWorldPixMap( source->m_macMask ) ) ;
- }
- }
- else
- {
- CopyBits( GetPortBitMapForCopyBits( sourcePort ) , GetPortBitMapForCopyBits( m_macPort ) ,
- &srcrect, &dstrect, mode, NULL ) ;
- }
- UnlockPixels( bmappixels ) ;
- }
-
- m_macPenInstalled = false ;
- m_macBrushInstalled = false ;
- m_macFontInstalled = false ;
-
- return TRUE;
-}
-
-void wxDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
- double angle)
-{
-}
-void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y)
-{
- if (!Ok())
- return;
- wxMacPortSetter helper(this) ;
-
- long xx = XLOG2DEV(x);
- long yy = YLOG2DEV(y);
-
-// if (m_pen.GetStyle() != wxTRANSPARENT)
- {
- MacInstallFont() ;
- /*
- Rect clip = { -32000 , -32000 , 32000 , 32000 } ;
-
- ::ClipRect( &clip ) ;
- */
-
- FontInfo fi ;
- ::GetFontInfo( &fi ) ;
-
- yy += fi.ascent ;
- ::MoveTo( xx , yy );
- if ( m_backgroundMode == wxTRANSPARENT )
- {
- ::TextMode( srcOr) ;
- }
- else
- {
- ::TextMode( srcCopy ) ;
- }
-
- const char *text = NULL ;
- int length = 0 ;
- wxString macText ;
-
- if ( wxApp::s_macDefaultEncodingIsPC )
- {
- macText = wxMacMakeMacStringFromPC( strtext ) ;
- text = macText ;
- length = macText.Length() ;
- }
- else
- {
- text = strtext ;
- length = strtext.Length() ;
- }
-
- int laststop = 0 ;
- int i = 0 ;
- int line = 0 ;
-
- while( i < length )
- {
- if( text[i] == 13 || text[i] == 10)
- {
- ::DrawText( text , laststop , i - laststop ) ;
- line++ ;
- ::MoveTo( xx , yy + line*(fi.descent + fi.ascent + fi.leading) );
- laststop = i+1 ;
- }
- i++ ;
- }
-
- ::DrawText( text , laststop , i - laststop ) ;
- ::TextMode( srcOr ) ;
- }
-}
-
-bool wxDC::CanGetTextExtent(void) const
-{
- if ( !Ok() )
- return false ;
-
- return true ;
-}
-
-void wxDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *height,
- wxCoord *descent, wxCoord *externalLeading ,
- wxFont *theFont ) const
-{
- if (!Ok())
- return;
-
- wxMacPortSetter helper(this) ;
-
- wxFont formerFont = m_font ;
-
- 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() ;
- }
-
- FontInfo fi ;
- ::GetFontInfo( &fi ) ;
-
- if ( height )
- *height = YDEV2LOGREL( fi.descent + fi.ascent ) ;
- if ( descent )
- *descent =YDEV2LOGREL( fi.descent );
- if ( externalLeading )
- *externalLeading = YDEV2LOGREL( fi.leading ) ;
-
- const char *text = NULL ;
- int length = 0 ;
- wxString macText ;
- if ( wxApp::s_macDefaultEncodingIsPC )
- {
- macText = wxMacMakeMacStringFromPC( string ) ;
- text = macText ;
- length = macText.Length() ;
- }
- else
- {
- text = string ;
- length = string.Length() ;
- }
-
- int laststop = 0 ;
- int i = 0 ;
- int curwidth = 0 ;
- if ( width )
- {
- *width = 0 ;
-
- while( i < length )
- {
- if( text[i] == 13 || text[i] == 10)
- {
- if ( height )
- *height += YDEV2LOGREL( fi.descent + fi.ascent + fi.leading ) ;
- curwidth = ::TextWidth( text , laststop , i - laststop ) ;
- if ( curwidth > *width )
- *width = XDEV2LOGREL( curwidth ) ;
- laststop = i+1 ;
- }
- i++ ;
- }
-
- curwidth = ::TextWidth( text , laststop , i - laststop ) ;
- if ( curwidth > *width )
- *width = XDEV2LOGREL( curwidth ) ;
- }
-
- if ( theFont )
- {
- m_macFontInstalled = false ;
- }
-}
-
-wxCoord wxDC::GetCharWidth(void) const
-{
- if (!Ok())
- return 1;
-
- wxMacPortSetter helper(this) ;
-
- MacInstallFont() ;
-
- FontInfo fi ;
- ::GetFontInfo( &fi ) ;
-
- return YDEV2LOGREL((fi.descent + fi.ascent) / 2) ;
-}
-
-wxCoord wxDC::GetCharHeight(void) const
-{
- if (!Ok())
- return 1;
-
- wxMacPortSetter helper(this) ;
-
- MacInstallFont() ;
-
- FontInfo fi ;
- ::GetFontInfo( &fi ) ;
-
- return YDEV2LOGREL( fi.descent + fi.ascent );
-}
-
-void wxDC::Clear(void)
-{
- if (!Ok())
- return;
- wxMacPortSetter helper(this) ;
- Rect rect = { -32767 , -32767 , 32767 , 32767 } ;
-
- if (m_backgroundBrush.GetStyle() != wxTRANSPARENT)
- {
- MacInstallBrush() ;
- ::EraseRect( &rect ) ;
- };