#define twips2mm 0.0176388888889
#define mm2pt 2.83464566929
#define pt2mm 0.352777777778
+#ifndef __UNIX__
const double M_PI = 3.14159265358979 ;
+#endif
const double RAD2DEG = 180.0 / M_PI;
//-----------------------------------------------------------------------------
wxCHECK_RET(icon.Ok(), wxT("Invalid icon wxDC::DoDrawIcon"));
- DoDrawBitmap( icon , x , y ) ;
+ DoDrawBitmap( icon , x , y , icon.GetMask() != NULL ) ;
}
void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
{
wxCoord offset = ( (m_pen.GetWidth() == 0 ? 1 :
m_pen.GetWidth() ) * (wxCoord)m_scaleX - 1) / 2;
- wxCoord xx1 = XLOG2DEV(x1);
- wxCoord yy1 = YLOG2DEV(y1);
- wxCoord xx2 = XLOG2DEV(x2);
- wxCoord yy2 = YLOG2DEV(y2);
-
- ::MoveTo(xx1 - offset, yy1 - offset);
- ::LineTo(xx2 - offset, yy2 - offset);
+ wxCoord xx1 = XLOG2DEV(x1) - offset;
+ wxCoord yy1 = YLOG2DEV(y1) - offset;
+ wxCoord xx2 = XLOG2DEV(x2) - offset;
+ wxCoord yy2 = YLOG2DEV(y2) - offset;
+
+ if ((m_pen.GetCap() == wxCAP_ROUND) &&
+ (m_pen.GetWidth() <= 1))
+ {
+ // Implement LAST_NOT for MAC at least for
+ // orthogonal lines. RR.
+ if (xx1 == xx2)
+ {
+ if (yy1 < yy2)
+ yy2--;
+ if (yy1 > yy2)
+ yy2++;
+ }
+ if (yy1 == yy2)
+ {
+ if (xx1 < xx2)
+ xx2--;
+ if (xx1 > xx2)
+ xx2++;
+ }
+ }
+
+ ::MoveTo(xx1, yy1);
+ ::LineTo(xx2, yy2);
}
}
wxCoord xoffset, wxCoord yoffset,
int fillStyle )
{
- wxCHECK_RET(Ok(), wxT("Invalid DC"));
- wxMacPortSetter helper(this) ;
+ wxCHECK_RET(Ok(), wxT("Invalid DC"));
+ wxMacPortSetter helper(this) ;
+
+ wxCoord x1, x2 , y1 , y2 ;
- PolyHandle polygon = OpenPoly() ;
- wxCoord x1, x2 , y1 , y2 ;
- x1 = XLOG2DEV(points[0].x + xoffset);
- y1 = YLOG2DEV(points[0].y + yoffset);
- ::MoveTo(x1,y1);
+ if (m_brush.GetStyle() != wxTRANSPARENT)
+ {
+ PolyHandle polygon = OpenPoly();
+
+ 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);
- }
+ 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 ) ;
+ ClosePoly();
+
+ MacInstallBrush();
+ ::PaintPoly( polygon );
+
+ KillPoly( polygon );
}
if (m_pen.GetStyle() != wxTRANSPARENT)
{
+ PolyHandle polygon = OpenPoly();
+
+ 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);
+ }
+
+ // return to origin to close path
+ ::LineTo(x1,y1);
+
+ ClosePoly();
+
MacInstallPen() ;
::FramePoly( polygon ) ;
+
+ KillPoly( polygon );
}
- KillPoly( polygon ) ;
}
void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
- wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func , bool useMask )
+ wxDC *source, wxCoord xsrc, wxCoord ysrc, int logical_func , bool useMask,
+ wxCoord xsrcMask, wxCoord ysrcMask )
{
wxCHECK_MSG(Ok(), false, wxT("wxDC::DoBlit Illegal dc"));
wxCHECK_MSG(source->Ok(), false, wxT("wxDC::DoBlit Illegal source DC"));
wxMacPortSetter helper(this) ;
+ /* TODO: use the mask origin when drawing transparently */
+ if (xsrcMask == -1 && ysrcMask == -1)
+ {
+ xsrcMask = xsrc; ysrcMask = ysrc;
+ }
+
CGrafPtr sourcePort = (CGrafPtr) source->m_macPort ;
PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ;
RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ;
MacInstallFont() ;
- FontInfo fi ;
- ::GetFontInfo( &fi ) ;
+ int width = ::TextWidth( "n" , 0 , 1 ) ;
- return YDEV2LOGREL((fi.descent + fi.ascent) / 2) ;
+ return YDEV2LOGREL(width) ;
}
wxCoord wxDC::GetCharHeight(void) const