void wxDCBase::DrawLines(const wxList *list, wxCoord xoffset, wxCoord yoffset) { int n = list->GetCount(); wxPoint *points = new wxPoint[n]; int i = 0; for ( wxList::compatibility_iterator node = list->GetFirst(); node; node = node->GetNext(), i++ ) { wxPoint *point = (wxPoint *)node->GetData(); points[i].x = point->x; points[i].y = point->y; } DoDrawLines(n, points, xoffset, yoffset); delete [] points; }
void wxDCBase::DoDrawEllipticArcRot( wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea, double angle ) { wxList list; CalculateEllipticPoints( &list, x, y, w, h, sa, ea ); Rotate( &list, angle, wxPoint( x+w/2, y+h/2 ) ); // Add center (for polygon/pie) list.Append( (wxObject*) new wxPoint( x+w/2, y+h/2 ) ); // copy list into array and delete list elements int n = list.Number(); wxPoint *points = new wxPoint[n]; int i = 0; wxNode* node = 0; for ( node = list.First(); node; node = node->Next(), i++ ) { wxPoint *point = (wxPoint *)node->Data(); points[i].x = point->x; points[i].y = point->y; delete point; } // first draw the pie without pen, if necessary if( GetBrush() != *wxTRANSPARENT_BRUSH ) { wxPen tempPen( GetPen() ); SetPen( *wxTRANSPARENT_PEN ); DoDrawPolygon( n, points, 0, 0 ); SetPen( tempPen ); } // then draw the arc without brush, if necessary if( GetPen() != *wxTRANSPARENT_PEN ) { // without center DoDrawLines( n-1, points, 0, 0 ); } delete [] points; } // DrawEllipticArcRot
void wxDCBase::DoDrawPolyPolygon(int n, int count[], wxPoint points[], wxCoord xoffset, wxCoord yoffset, int fillStyle) { if ( n == 1 ) { DoDrawPolygon(count[0], points, xoffset, yoffset, fillStyle); return; } int i, j, lastOfs; wxPoint* pts; wxPen pen; for (i = j = lastOfs = 0; i < n; i++) { lastOfs = j; j += count[i]; } pts = new wxPoint[j+n-1]; for (i = 0; i < j; i++) pts[i] = points[i]; for (i = 2; i <= n; i++) { lastOfs -= count[n-i]; pts[j++] = pts[lastOfs]; } pen = GetPen(); SetPen(wxPen(*wxBLACK, 0, wxTRANSPARENT)); DoDrawPolygon(j, pts, xoffset, yoffset, fillStyle); SetPen(pen); for (i = j = 0; i < n; i++) { DoDrawLines(count[i], pts+j, xoffset, yoffset); j += count[i]; } delete[] pts; }
void wxSVGFileDCImpl::DoDrawPolyPolygon(int n, const int count[], const wxPoint points[], wxCoord xoffset, wxCoord yoffset, wxPolygonFillMode fillStyle) { if (n == 1) { DoDrawPolygon(count[0], points, xoffset, yoffset, fillStyle); return; } int i, j; int totalPts = 0; for (j = 0; j < n; ++j) totalPts += count[j]; wxScopedArray<wxPoint> pts(totalPts + n); int polyCounter = 0, polyIndex = 0; for (i = j = 0; i < totalPts; ++i) { pts[j++] = points[i]; ++polyCounter; if (polyCounter == count[polyIndex]) { pts[j++] = points[i - count[polyIndex] + 1]; ++polyIndex; polyCounter = 0; } } { wxDCPenChanger setTransp(*GetOwner(), *wxTRANSPARENT_PEN); DoDrawPolygon(j, pts.get(), xoffset, yoffset, fillStyle); } for (i = j = 0; i < n; i++) { DoDrawLines(count[i] + 1, pts.get() + j, xoffset, yoffset); j += count[i] + 1; } }
EXPORT_C void CHuiCanvasGc::DrawLines(RArray<THuiRealLine>& aLines) { if (!iGc) { return; } Setup(); EnableBlendingIfNeeded(); EnableDelayedClippingIfNeeded(aLines); while (ClipNext()) { DoDrawLines(aLines); } DisableDelayedClippingIfNeeded(); Cleanup(); }
EXPORT_C void CHuiCanvasGc::DoDrawRoundRect(const THuiRealRect& aDestinationRect, const THuiRealSize& aSize) { THuiRealSize cornerRectSize = THuiRealSize( 2*aSize.iWidth, 2*aSize.iHeight); THuiRealPoint topLeftCornerRectTL=aDestinationRect.iTl; THuiRealRect topLeftCornerRect = THuiRealRect(topLeftCornerRectTL,cornerRectSize); THuiRealPoint topRightCornerRectTL=THuiRealPoint (aDestinationRect.iTl.iX + aDestinationRect.Width()-2*(aSize.iWidth), aDestinationRect.iTl.iY); THuiRealRect topRightCornerRect = THuiRealRect(topRightCornerRectTL, cornerRectSize); THuiRealPoint bottomRightCornerRectTL = THuiRealPoint (aDestinationRect.iBr.iX-(2*aSize.iWidth),aDestinationRect.iBr.iY-(2*aSize.iHeight)); THuiRealRect bottomRightCornerRect = THuiRealRect(bottomRightCornerRectTL, cornerRectSize); THuiRealPoint bottomLeftCornerRectTL = THuiRealPoint(aDestinationRect.iTl.iX, aDestinationRect.iTl.iY + aDestinationRect.Height() -2*(aSize.iHeight)); THuiRealRect bottomLeftCornerRect = THuiRealRect(bottomLeftCornerRectTL,cornerRectSize); THuiRealPoint topLeftArcStart = THuiRealPoint(topLeftCornerRectTL.iX + aSize.iWidth, topLeftCornerRectTL.iY); THuiRealPoint topLeftArcEnd = THuiRealPoint(topLeftCornerRectTL.iX, topLeftCornerRectTL.iY + aSize.iHeight); DoDrawArc(topLeftCornerRect, topLeftArcStart,topLeftArcEnd); THuiRealPoint topRightArcStart = THuiRealPoint(topRightCornerRectTL.iX + 2*aSize.iWidth, topRightCornerRectTL.iY + aSize.iHeight); THuiRealPoint topRightArcEnd = THuiRealPoint(topRightCornerRectTL.iX + aSize.iWidth, topRightCornerRectTL.iY); DoDrawArc(topRightCornerRect, topRightArcStart, topRightArcEnd); THuiRealPoint bottomRightArcStart = THuiRealPoint(bottomRightCornerRectTL.iX + aSize.iWidth, bottomRightCornerRectTL.iY + 2*aSize.iHeight); THuiRealPoint bottomRightArcEnd = THuiRealPoint(bottomRightCornerRectTL.iX + 2*aSize.iWidth, bottomRightCornerRectTL.iY + aSize.iHeight); DoDrawArc(bottomRightCornerRect,bottomRightArcStart ,bottomRightArcEnd); THuiRealPoint bottomLeftArcStart = THuiRealPoint(bottomLeftCornerRectTL.iX, bottomLeftCornerRectTL.iY + aSize.iHeight); THuiRealPoint bottomLeftArcEnd = THuiRealPoint(bottomLeftCornerRectTL.iX + aSize.iWidth, bottomLeftCornerRectTL.iY + 2*aSize.iHeight); DoDrawArc(bottomLeftCornerRect, bottomLeftArcStart, bottomLeftArcEnd); if(iPolygonDrawMode) { RArray<THuiRealRect> rects; rects.Append(THuiRealRect(topLeftArcStart,bottomRightArcStart)); rects.Append(THuiRealRect(topLeftArcEnd, THuiRealSize(aSize.iWidth,aDestinationRect.Height()-(2*aSize.iHeight)))); rects.Append(THuiRealRect(THuiRealPoint(topRightArcStart.iX - aSize.iWidth,topRightArcStart.iY), THuiRealSize(aSize.iWidth,aDestinationRect.Height()-(2*aSize.iHeight)))); DoDrawRects(rects); rects.Close(); } else { RArray<THuiRealLine> lines; lines.Append(THuiRealLine(topLeftArcStart,topRightArcEnd)); lines.Append(THuiRealLine(topLeftArcEnd, bottomLeftArcStart)); lines.Append(THuiRealLine(bottomLeftArcEnd, bottomRightArcStart)); lines.Append(THuiRealLine(bottomRightArcEnd, topRightArcStart)); DoDrawLines(lines); lines.Close(); } }