Add convenient wxDCImpl::CalcBoundingBox() overloads and use them
No real changes, just make the code updating the bounding box slightly shorter by providing convenient and slightly higher-level overloads. For now these functions are only in wxDCImpl, it's not clear if we really need them in wxDC, so don't add them to the public API.
This commit is contained in:
@@ -277,8 +277,7 @@ void wxGCDCImpl::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y,
|
||||
m_graphicContext->DrawBitmap( bmpCopy, x, y, w, h );
|
||||
}
|
||||
|
||||
CalcBoundingBox(x, y);
|
||||
CalcBoundingBox(x + w, y + h);
|
||||
CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )
|
||||
@@ -291,8 +290,7 @@ void wxGCDCImpl::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )
|
||||
|
||||
m_graphicContext->DrawIcon( icon , x, y, w, h );
|
||||
|
||||
CalcBoundingBox(x, y);
|
||||
CalcBoundingBox(x + w, y + h);
|
||||
CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
|
||||
}
|
||||
|
||||
bool wxGCDCImpl::StartDoc( const wxString& message )
|
||||
@@ -685,8 +683,7 @@ void wxGCDCImpl::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
|
||||
|
||||
m_graphicContext->StrokeLine(x1,y1,x2,y2);
|
||||
|
||||
CalcBoundingBox(x1, y1);
|
||||
CalcBoundingBox(x2, y2);
|
||||
CalcBoundingBox(x1, y1, x2, y2);
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoCrossHair( wxCoord x, wxCoord y )
|
||||
@@ -703,8 +700,7 @@ void wxGCDCImpl::DoCrossHair( wxCoord x, wxCoord y )
|
||||
m_graphicContext->StrokeLine(0,y,w,y);
|
||||
m_graphicContext->StrokeLine(x,0,x,h);
|
||||
|
||||
CalcBoundingBox(0, 0);
|
||||
CalcBoundingBox(w, h);
|
||||
CalcBoundingBox(0, 0, w, h);
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoDrawArc( wxCoord x1, wxCoord y1,
|
||||
@@ -752,10 +748,7 @@ void wxGCDCImpl::DoDrawArc( wxCoord x1, wxCoord y1,
|
||||
path.AddLineToPoint( xc, yc );
|
||||
m_graphicContext->DrawPath(path);
|
||||
|
||||
wxRect2DDouble box = path.GetBox();
|
||||
CalcBoundingBox(wxRound(box.m_x), wxRound(box.m_y));
|
||||
CalcBoundingBox(wxRound(box.m_x + box.m_width),
|
||||
wxRound(box.m_y + box.m_height));
|
||||
CalcBoundingBoxForBox(path.GetBox());
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
||||
@@ -805,9 +798,7 @@ void wxGCDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
||||
box.m_x += dx;
|
||||
box.m_y += dy;
|
||||
|
||||
CalcBoundingBox(wxRound(box.m_x), wxRound(box.m_y));
|
||||
CalcBoundingBox(wxRound(box.m_x + box.m_width),
|
||||
wxRound(box.m_y + box.m_height));
|
||||
CalcBoundingBoxForBox(box);
|
||||
|
||||
m_graphicContext->PopState();
|
||||
}
|
||||
@@ -858,8 +849,8 @@ void wxGCDCImpl::DoDrawLines(int n, const wxPoint points[],
|
||||
m_graphicContext->StrokeLines( n , pointsD);
|
||||
delete[] pointsD;
|
||||
|
||||
CalcBoundingBox(minX + xoffset, minY + yoffset);
|
||||
CalcBoundingBox(maxX + xoffset, maxY + yoffset);
|
||||
CalcBoundingBox(minX + xoffset, minY + yoffset,
|
||||
maxX + xoffset, maxY + yoffset);
|
||||
}
|
||||
|
||||
#if wxUSE_SPLINES
|
||||
@@ -898,10 +889,7 @@ void wxGCDCImpl::DoDrawSpline(const wxPointList *points)
|
||||
|
||||
m_graphicContext->StrokePath( path );
|
||||
|
||||
wxRect2DDouble box = path.GetBox();
|
||||
CalcBoundingBox(wxRound(box.m_x), wxRound(box.m_y));
|
||||
CalcBoundingBox(wxRound(box.m_x + box.m_width),
|
||||
wxRound(box.m_y + box.m_height));
|
||||
CalcBoundingBoxForBox(path.GetBox());
|
||||
}
|
||||
#endif // wxUSE_SPLINES
|
||||
|
||||
@@ -945,8 +933,8 @@ void wxGCDCImpl::DoDrawPolygon( int n, const wxPoint points[],
|
||||
m_graphicContext->DrawLines( n+(closeIt?1:0) , pointsD, fillStyle);
|
||||
delete[] pointsD;
|
||||
|
||||
CalcBoundingBox(minX + xoffset, minY + yoffset);
|
||||
CalcBoundingBox(maxX + xoffset, maxY + yoffset);
|
||||
CalcBoundingBox(minX + xoffset, minY + yoffset,
|
||||
maxX + xoffset, maxY + yoffset);
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoDrawPolyPolygon(int n,
|
||||
@@ -977,10 +965,7 @@ void wxGCDCImpl::DoDrawPolyPolygon(int n,
|
||||
}
|
||||
m_graphicContext->DrawPath( path , fillStyle);
|
||||
|
||||
wxRect2DDouble box = path.GetBox();
|
||||
CalcBoundingBox(wxRound(box.m_x), wxRound(box.m_y));
|
||||
CalcBoundingBox(wxRound(box.m_x + box.m_width),
|
||||
wxRound(box.m_y + box.m_height));
|
||||
CalcBoundingBoxForBox(path.GetBox());
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
|
||||
@@ -994,8 +979,7 @@ void wxGCDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
|
||||
if (w == 0 || h == 0)
|
||||
return;
|
||||
|
||||
CalcBoundingBox(x, y);
|
||||
CalcBoundingBox(x + w, y + h);
|
||||
CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
|
||||
|
||||
if (m_pen.IsOk() && m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT && m_pen.GetWidth() > 0)
|
||||
{
|
||||
@@ -1022,8 +1006,7 @@ void wxGCDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y,
|
||||
if (w == 0 || h == 0)
|
||||
return;
|
||||
|
||||
CalcBoundingBox(x, y);
|
||||
CalcBoundingBox(x + w, y + h);
|
||||
CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
|
||||
|
||||
if (m_pen.IsOk() && m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT && m_pen.GetWidth() > 0)
|
||||
{
|
||||
@@ -1041,8 +1024,7 @@ void wxGCDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
|
||||
if ( !m_logicalFunctionSupported )
|
||||
return;
|
||||
|
||||
CalcBoundingBox(x, y);
|
||||
CalcBoundingBox(x + w, y + h);
|
||||
CalcBoundingBox(wxPoint(x, y), wxSize(w, h));
|
||||
|
||||
m_graphicContext->DrawEllipse(x,y,w,h);
|
||||
}
|
||||
@@ -1148,8 +1130,7 @@ bool wxGCDCImpl::DoStretchBlit(
|
||||
// reset composition
|
||||
m_graphicContext->SetCompositionMode(formerMode);
|
||||
|
||||
CalcBoundingBox(xdest, ydest);
|
||||
CalcBoundingBox(xdest + dstWidth, ydest + dstHeight);
|
||||
CalcBoundingBox(wxPoint(xdest, ydest), wxSize(dstWidth, dstHeight));
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -1202,14 +1183,12 @@ void wxGCDCImpl::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y,
|
||||
// determining which of them is really topmost/leftmost/...)
|
||||
|
||||
// "upper left" and "upper right"
|
||||
CalcBoundingBox(x, y);
|
||||
CalcBoundingBox(x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
|
||||
CalcBoundingBox(x, y, x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
|
||||
|
||||
// "bottom left" and "bottom right"
|
||||
x += (wxCoord)(h*sin(rad));
|
||||
y += (wxCoord)(h*cos(rad));
|
||||
CalcBoundingBox(x, y);
|
||||
CalcBoundingBox(x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
|
||||
CalcBoundingBox(x, y, x + wxCoord(w*cos(rad)), y - wxCoord(w*sin(rad)));
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoDrawText(const wxString& str, wxCoord x, wxCoord y)
|
||||
@@ -1245,10 +1224,7 @@ void wxGCDCImpl::DoDrawText(const wxString& str, wxCoord x, wxCoord y)
|
||||
|
||||
m_graphicContext->SetCompositionMode(curMode);
|
||||
|
||||
wxCoord w, h;
|
||||
GetOwner()->GetTextExtent(str, &w, &h);
|
||||
CalcBoundingBox(x, y);
|
||||
CalcBoundingBox(x + w, y + h);
|
||||
CalcBoundingBox(wxPoint(x, y), GetOwner()->GetTextExtent(str));
|
||||
}
|
||||
|
||||
bool wxGCDCImpl::CanGetTextExtent() const
|
||||
@@ -1410,8 +1386,7 @@ void wxGCDCImpl::DoGradientFillLinear(const wxRect& rect,
|
||||
m_graphicContext->SetPen(m_pen);
|
||||
m_graphicContext->SetBrush(m_brush);
|
||||
|
||||
CalcBoundingBox(rect.x, rect.y);
|
||||
CalcBoundingBox(rect.x + rect.width, rect.y + rect.height);
|
||||
CalcBoundingBox(rect);
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoGradientFillConcentric(const wxRect& rect,
|
||||
@@ -1442,8 +1417,7 @@ void wxGCDCImpl::DoGradientFillConcentric(const wxRect& rect,
|
||||
m_graphicContext->SetPen(m_pen);
|
||||
m_graphicContext->SetBrush(m_brush);
|
||||
|
||||
CalcBoundingBox(rect.x, rect.y);
|
||||
CalcBoundingBox(rect.x + rect.width, rect.y + rect.height);
|
||||
CalcBoundingBox(rect);
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoDrawCheckMark(wxCoord x, wxCoord y,
|
||||
|
||||
Reference in New Issue
Block a user