Implement bounding box computations for wxGDDC.
Update the bounding box in all the methods drawing something. This wasn't done before in many of them, resulting in the bounding box remaining empty, but it is updated now and a new test checking that it is was added. Closes #12904. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76953 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
be0dcf769f
commit
2098cafcad
@ -25,6 +25,7 @@
|
||||
#include "wx/dcclient.h"
|
||||
#include "wx/dcmemory.h"
|
||||
#include "wx/math.h"
|
||||
#include "wx/geometry.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -300,6 +301,9 @@ 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);
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )
|
||||
@ -311,6 +315,9 @@ void wxGCDCImpl::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )
|
||||
wxCoord h = icon.GetHeight();
|
||||
|
||||
m_graphicContext->DrawIcon( icon , x, y, w, h );
|
||||
|
||||
CalcBoundingBox(x, y);
|
||||
CalcBoundingBox(x + w, y + h);
|
||||
}
|
||||
|
||||
bool wxGCDCImpl::StartDoc( const wxString& WXUNUSED(message) )
|
||||
@ -566,7 +573,7 @@ void wxGCDCImpl::DoCrossHair( wxCoord x, wxCoord y )
|
||||
m_graphicContext->StrokeLine(x,0,x,h);
|
||||
|
||||
CalcBoundingBox(0, 0);
|
||||
CalcBoundingBox(0+w, 0+h);
|
||||
CalcBoundingBox(w, h);
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoDrawArc( wxCoord x1, wxCoord y1,
|
||||
@ -613,6 +620,11 @@ void wxGCDCImpl::DoDrawArc( wxCoord x1, wxCoord y1,
|
||||
if ( fill && ((x1!=x2)||(y1!=y2)) )
|
||||
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));
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
||||
@ -623,16 +635,19 @@ void wxGCDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
||||
if ( !m_logicalFunctionSupported )
|
||||
return;
|
||||
|
||||
m_graphicContext->PushState();
|
||||
m_graphicContext->Translate(x+w/2.0,y+h/2.0);
|
||||
wxCoord dx = x + w / 2.0;
|
||||
wxCoord dy = y + h / 2.0;
|
||||
wxDouble factor = ((wxDouble) w) / h;
|
||||
m_graphicContext->Scale( factor , 1.0);
|
||||
m_graphicContext->PushState();
|
||||
m_graphicContext->Translate(dx, dy);
|
||||
m_graphicContext->Scale(factor, 1.0);
|
||||
wxGraphicsPath path;
|
||||
|
||||
// since these angles (ea,sa) are measured counter-clockwise, we invert them to
|
||||
// get clockwise angles
|
||||
if ( m_brush.GetStyle() != wxBRUSHSTYLE_TRANSPARENT )
|
||||
{
|
||||
wxGraphicsPath path = m_graphicContext->CreatePath();
|
||||
path = m_graphicContext->CreatePath();
|
||||
path.MoveToPoint( 0, 0 );
|
||||
path.AddArc( 0, 0, h/2.0, wxDegToRad(-sa), wxDegToRad(-ea), sa > ea );
|
||||
path.AddLineToPoint( 0, 0 );
|
||||
@ -644,11 +659,22 @@ void wxGCDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
||||
}
|
||||
else
|
||||
{
|
||||
wxGraphicsPath path = m_graphicContext->CreatePath();
|
||||
path = m_graphicContext->CreatePath();
|
||||
path.AddArc( 0, 0, h/2.0, wxDegToRad(-sa), wxDegToRad(-ea), sa > ea );
|
||||
m_graphicContext->DrawPath( path );
|
||||
}
|
||||
|
||||
wxRect2DDouble box = path.GetBox();
|
||||
// apply the transformation to the box
|
||||
box.m_x *= factor;
|
||||
box.m_width *= factor;
|
||||
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));
|
||||
|
||||
m_graphicContext->PopState();
|
||||
}
|
||||
|
||||
@ -663,19 +689,34 @@ void wxGCDCImpl::DoDrawLines(int n, const wxPoint points[],
|
||||
wxCoord xoffset, wxCoord yoffset)
|
||||
{
|
||||
wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawLines - invalid DC") );
|
||||
wxASSERT_MSG( n > 0, wxT("wxGCDC(cg)::DoDrawLines - number of points too small") );
|
||||
|
||||
if ( !m_logicalFunctionSupported )
|
||||
return;
|
||||
|
||||
int minX = points[0].x;
|
||||
int minY = points[0].y;
|
||||
int maxX = minX;
|
||||
int maxY = minY;
|
||||
|
||||
wxPoint2DDouble* pointsD = new wxPoint2DDouble[n];
|
||||
for( int i = 0; i < n; ++i)
|
||||
{
|
||||
pointsD[i].m_x = points[i].x + xoffset;
|
||||
pointsD[i].m_y = points[i].y + yoffset;
|
||||
wxPoint p = points[i];
|
||||
pointsD[i].m_x = p.x + xoffset;
|
||||
pointsD[i].m_y = p.y + yoffset;
|
||||
|
||||
if (p.x < minX) minX = p.x;
|
||||
else if (p.x > maxX) maxX = p.x;
|
||||
if (p.y < minY) minY = p.y;
|
||||
else if (p.y > maxY) maxY = p.y;
|
||||
}
|
||||
|
||||
m_graphicContext->StrokeLines( n , pointsD);
|
||||
delete[] pointsD;
|
||||
|
||||
CalcBoundingBox(minX + xoffset, minY + yoffset);
|
||||
CalcBoundingBox(maxX + xoffset, maxY + yoffset);
|
||||
}
|
||||
|
||||
#if wxUSE_SPLINES
|
||||
@ -734,6 +775,11 @@ void wxGCDCImpl::DoDrawSpline(const wxPointList *points)
|
||||
path.AddLineToPoint( x2 , y2 );
|
||||
|
||||
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));
|
||||
}
|
||||
#endif // wxUSE_SPLINES
|
||||
|
||||
@ -754,17 +800,31 @@ void wxGCDCImpl::DoDrawPolygon( int n, const wxPoint points[],
|
||||
if (points[n-1] != points[0])
|
||||
closeIt = true;
|
||||
|
||||
int minX = points[0].x;
|
||||
int minY = points[0].y;
|
||||
int maxX = minX;
|
||||
int maxY = minY;
|
||||
|
||||
wxPoint2DDouble* pointsD = new wxPoint2DDouble[n+(closeIt?1:0)];
|
||||
for( int i = 0; i < n; ++i)
|
||||
{
|
||||
pointsD[i].m_x = points[i].x + xoffset;
|
||||
pointsD[i].m_y = points[i].y + yoffset;
|
||||
wxPoint p = points[i];
|
||||
pointsD[i].m_x = p.x + xoffset;
|
||||
pointsD[i].m_y = p.y + yoffset;
|
||||
|
||||
if (p.x < minX) minX = p.x;
|
||||
else if (p.x > maxX) maxX = p.x;
|
||||
if (p.y < minY) minY = p.y;
|
||||
else if (p.y > maxY) maxY = p.y;
|
||||
}
|
||||
if ( closeIt )
|
||||
pointsD[n] = pointsD[0];
|
||||
|
||||
m_graphicContext->DrawLines( n+(closeIt?1:0) , pointsD, fillStyle);
|
||||
delete[] pointsD;
|
||||
|
||||
CalcBoundingBox(minX + xoffset, minY + yoffset);
|
||||
CalcBoundingBox(maxX + xoffset, maxY + yoffset);
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoDrawPolyPolygon(int n,
|
||||
@ -794,6 +854,11 @@ void wxGCDCImpl::DoDrawPolyPolygon(int n,
|
||||
path.AddLineToPoint( start.x+ xoffset, start.y+ yoffset);
|
||||
}
|
||||
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));
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
|
||||
@ -807,6 +872,9 @@ 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);
|
||||
|
||||
if ( m_graphicContext->ShouldOffset() )
|
||||
{
|
||||
// if we are offsetting the entire rectangle is moved 0.5, so the
|
||||
@ -833,6 +901,9 @@ void wxGCDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y,
|
||||
if (w == 0 || h == 0)
|
||||
return;
|
||||
|
||||
CalcBoundingBox(x, y);
|
||||
CalcBoundingBox(x + w, y + h);
|
||||
|
||||
if ( m_graphicContext->ShouldOffset() )
|
||||
{
|
||||
// if we are offsetting the entire rectangle is moved 0.5, so the
|
||||
@ -850,6 +921,9 @@ void wxGCDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
|
||||
if ( !m_logicalFunctionSupported )
|
||||
return;
|
||||
|
||||
CalcBoundingBox(x, y);
|
||||
CalcBoundingBox(x + w, y + h);
|
||||
|
||||
if ( m_graphicContext->ShouldOffset() )
|
||||
{
|
||||
// if we are offsetting the entire rectangle is moved 0.5, so the
|
||||
@ -959,6 +1033,9 @@ bool wxGCDCImpl::DoStretchBlit(
|
||||
// reset composition
|
||||
m_graphicContext->SetCompositionMode(formerMode);
|
||||
|
||||
CalcBoundingBox(xdest, ydest);
|
||||
CalcBoundingBox(xdest + dstWidth, ydest + dstHeight);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -1046,6 +1123,11 @@ void wxGCDCImpl::DoDrawText(const wxString& str, wxCoord x, wxCoord y)
|
||||
m_graphicContext->DrawText( str, x ,y);
|
||||
else
|
||||
m_graphicContext->DrawText( str, x ,y , m_graphicContext->CreateBrush(m_textBackgroundColour) );
|
||||
|
||||
wxCoord w, h;
|
||||
GetOwner()->GetTextExtent(str, &w, &h);
|
||||
CalcBoundingBox(x, y);
|
||||
CalcBoundingBox(x + w, y + h);
|
||||
}
|
||||
|
||||
bool wxGCDCImpl::CanGetTextExtent() const
|
||||
@ -1189,6 +1271,9 @@ void wxGCDCImpl::DoGradientFillLinear(const wxRect& rect,
|
||||
m_graphicContext->DrawRectangle(rect.x,rect.y,rect.width,rect.height);
|
||||
m_graphicContext->SetPen(m_pen);
|
||||
m_graphicContext->SetBrush(m_brush);
|
||||
|
||||
CalcBoundingBox(rect.x, rect.y);
|
||||
CalcBoundingBox(rect.x + rect.width, rect.y + rect.height);
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoGradientFillConcentric(const wxRect& rect,
|
||||
@ -1218,6 +1303,9 @@ void wxGCDCImpl::DoGradientFillConcentric(const wxRect& rect,
|
||||
m_graphicContext->DrawRectangle(rect.x,rect.y,rect.width,rect.height);
|
||||
m_graphicContext->SetPen(m_pen);
|
||||
m_graphicContext->SetBrush(m_brush);
|
||||
|
||||
CalcBoundingBox(rect.x, rect.y);
|
||||
CalcBoundingBox(rect.x + rect.width, rect.y + rect.height);
|
||||
}
|
||||
|
||||
void wxGCDCImpl::DoDrawCheckMark(wxCoord x, wxCoord y,
|
||||
|
@ -179,6 +179,7 @@ TEST_GUI_OBJECTS = \
|
||||
test_gui_ellipsization.o \
|
||||
test_gui_measuring.o \
|
||||
test_gui_affinematrix.o \
|
||||
test_gui_boundingbox.o \
|
||||
test_gui_config.o \
|
||||
test_gui_bitmapcomboboxtest.o \
|
||||
test_gui_bitmaptogglebuttontest.o \
|
||||
@ -801,6 +802,9 @@ test_gui_measuring.o: $(srcdir)/graphics/measuring.cpp $(TEST_GUI_ODEP)
|
||||
test_gui_affinematrix.o: $(srcdir)/graphics/affinematrix.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/graphics/affinematrix.cpp
|
||||
|
||||
test_gui_boundingbox.o: $(srcdir)/graphics/boundingbox.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/graphics/boundingbox.cpp
|
||||
|
||||
test_gui_config.o: $(srcdir)/config/config.cpp $(TEST_GUI_ODEP)
|
||||
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/config/config.cpp
|
||||
|
||||
|
335
tests/graphics/boundingbox.cpp
Normal file
335
tests/graphics/boundingbox.cpp
Normal file
@ -0,0 +1,335 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/graphics/gcdc_boundingbox.cpp
|
||||
// Purpose: wxGCDC bounding box unit tests
|
||||
// Author: Vadim Zeitlin / Maarten Spoek / Toni Ruža
|
||||
// Created: 2011-01-36
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// (c) 2014 Toni Ruža <toni.ruza@gmail.com>
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "testprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/dcmemory.h"
|
||||
#include "wx/dcgraph.h"
|
||||
#include "wx/icon.h"
|
||||
#include "wx/colour.h"
|
||||
#include "wx/gdicmn.h"
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class GCDCBoundingBoxTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
GCDCBoundingBoxTestCase()
|
||||
{
|
||||
m_bmp.Create(100, 100);
|
||||
m_dc.SelectObject(m_bmp);
|
||||
m_gcdc = new wxGCDC(m_dc);
|
||||
}
|
||||
|
||||
~GCDCBoundingBoxTestCase()
|
||||
{
|
||||
delete m_gcdc;
|
||||
m_dc.SelectObject(wxNullBitmap);
|
||||
m_bmp = wxNullBitmap;
|
||||
}
|
||||
|
||||
virtual void setUp()
|
||||
{
|
||||
m_gcdc->ResetBoundingBox();
|
||||
}
|
||||
|
||||
private:
|
||||
wxBitmap m_bmp;
|
||||
wxMemoryDC m_dc;
|
||||
wxGCDC *m_gcdc;
|
||||
|
||||
void AssertBox(int minX, int minY, int width, int height, int margin = 0)
|
||||
{
|
||||
int maxX = minX + width;
|
||||
int maxY = minY + height;
|
||||
|
||||
// Allow for a margin of error due to different implementation
|
||||
// specificities regarding drawing paths.
|
||||
if ( margin )
|
||||
{
|
||||
#define WX_ASSERT_CLOSE(expected, actual, delta) \
|
||||
WX_ASSERT_MESSAGE(("%d != %d", actual, expected), \
|
||||
abs(actual - expected) <= delta)
|
||||
|
||||
WX_ASSERT_CLOSE(minX, m_gcdc->MinX(), margin);
|
||||
WX_ASSERT_CLOSE(minY, m_gcdc->MinY(), margin);
|
||||
WX_ASSERT_CLOSE(maxX, m_gcdc->MaxX(), margin);
|
||||
WX_ASSERT_CLOSE(maxY, m_gcdc->MaxY(), margin);
|
||||
|
||||
#undef WX_ASSERT_CLOSE
|
||||
}
|
||||
else
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL(minX, m_gcdc->MinX());
|
||||
CPPUNIT_ASSERT_EQUAL(minY, m_gcdc->MinY());
|
||||
CPPUNIT_ASSERT_EQUAL(maxX, m_gcdc->MaxX());
|
||||
CPPUNIT_ASSERT_EQUAL(maxY, m_gcdc->MaxY());
|
||||
}
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_SUITE( GCDCBoundingBoxTestCase );
|
||||
CPPUNIT_TEST( DrawBitmap );
|
||||
CPPUNIT_TEST( DrawIcon );
|
||||
CPPUNIT_TEST( DrawLine );
|
||||
CPPUNIT_TEST( CrossHair );
|
||||
CPPUNIT_TEST( DrawArc );
|
||||
CPPUNIT_TEST( DrawEllipticArc );
|
||||
CPPUNIT_TEST( DrawPoint );
|
||||
CPPUNIT_TEST( DrawLines );
|
||||
#if wxUSE_SPLINES
|
||||
CPPUNIT_TEST( DrawSpline );
|
||||
#endif
|
||||
CPPUNIT_TEST( DrawPolygon );
|
||||
CPPUNIT_TEST( DrawPolyPolygon );
|
||||
CPPUNIT_TEST( DrawRectangle );
|
||||
CPPUNIT_TEST( DrawRoundedRectangle );
|
||||
CPPUNIT_TEST( DrawEllipse );
|
||||
CPPUNIT_TEST( Blit );
|
||||
CPPUNIT_TEST( StretchBlit );
|
||||
CPPUNIT_TEST( DrawRotatedText );
|
||||
CPPUNIT_TEST( DrawText );
|
||||
CPPUNIT_TEST( GradientFillLinear );
|
||||
CPPUNIT_TEST( GradientFillConcentric );
|
||||
CPPUNIT_TEST( DrawCheckMark );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void DrawBitmap();
|
||||
void DrawIcon();
|
||||
void DrawLine();
|
||||
void CrossHair();
|
||||
void DrawArc();
|
||||
void DrawEllipticArc();
|
||||
void DrawPoint();
|
||||
void DrawLines();
|
||||
#if wxUSE_SPLINES
|
||||
void DrawSpline();
|
||||
#endif
|
||||
void DrawPolygon();
|
||||
void DrawPolyPolygon();
|
||||
void DrawRectangle();
|
||||
void DrawRoundedRectangle();
|
||||
void DrawEllipse();
|
||||
void Blit();
|
||||
void StretchBlit();
|
||||
void DrawRotatedText();
|
||||
void DrawText();
|
||||
void GradientFillLinear();
|
||||
void GradientFillConcentric();
|
||||
void DrawCheckMark();
|
||||
|
||||
DECLARE_NO_COPY_CLASS(GCDCBoundingBoxTestCase)
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( GCDCBoundingBoxTestCase );
|
||||
|
||||
// also include in it's own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( GCDCBoundingBoxTestCase, "GCDCBoundingBoxTestCase" );
|
||||
|
||||
|
||||
void GCDCBoundingBoxTestCase::DrawBitmap()
|
||||
{
|
||||
wxBitmap bitmap;
|
||||
bitmap.Create(12, 12);
|
||||
|
||||
m_gcdc->DrawBitmap(bitmap, 5, 5);
|
||||
AssertBox(5, 5, 12, 12);
|
||||
}
|
||||
|
||||
void GCDCBoundingBoxTestCase::DrawIcon()
|
||||
{
|
||||
wxBitmap bitmap;
|
||||
bitmap.Create(16, 16);
|
||||
wxIcon icon;
|
||||
icon.CopyFromBitmap(bitmap);
|
||||
|
||||
m_gcdc->DrawIcon(icon, 42, 42);
|
||||
AssertBox(42, 42, 16, 16);
|
||||
}
|
||||
|
||||
void GCDCBoundingBoxTestCase::DrawLine()
|
||||
{
|
||||
m_gcdc->DrawLine(10, 10, 20, 15);
|
||||
AssertBox(10, 10, 10, 5);
|
||||
}
|
||||
|
||||
void GCDCBoundingBoxTestCase::CrossHair()
|
||||
{
|
||||
int w, h;
|
||||
m_gcdc->GetSize(&w, &h);
|
||||
|
||||
m_gcdc->CrossHair(33, 33);
|
||||
AssertBox(0, 0, w, h);
|
||||
}
|
||||
|
||||
void GCDCBoundingBoxTestCase::DrawArc()
|
||||
{
|
||||
m_gcdc->DrawArc(25, 30, 15, 40, 25, 40); // quarter circle
|
||||
AssertBox(15, 30, 10, 10, 3);
|
||||
}
|
||||
|
||||
void GCDCBoundingBoxTestCase::DrawEllipticArc()
|
||||
{
|
||||
m_gcdc->DrawEllipticArc(40, 50, 30, 20, 0, 180); // half circle
|
||||
AssertBox(40, 50, 30, 10, 3);
|
||||
}
|
||||
|
||||
void GCDCBoundingBoxTestCase::DrawPoint()
|
||||
{
|
||||
m_gcdc->DrawPoint(20, 20);
|
||||
AssertBox(20, 20, 1, 1);
|
||||
}
|
||||
|
||||
void GCDCBoundingBoxTestCase::DrawLines()
|
||||
{
|
||||
wxPoint points[4];
|
||||
points[0] = wxPoint(10, 20);
|
||||
points[1] = wxPoint(20, 10);
|
||||
points[2] = wxPoint(30, 20);
|
||||
points[3] = wxPoint(20, 30);
|
||||
|
||||
m_gcdc->DrawLines(4, points, 7, 8);
|
||||
AssertBox(17, 18, 20, 20);
|
||||
}
|
||||
|
||||
#if wxUSE_SPLINES
|
||||
void GCDCBoundingBoxTestCase::DrawSpline()
|
||||
{
|
||||
wxPoint points[3];
|
||||
points[0] = wxPoint(10, 30);
|
||||
points[1] = wxPoint(20, 20);
|
||||
points[2] = wxPoint(40, 50);
|
||||
|
||||
m_gcdc->DrawSpline(3, points);
|
||||
AssertBox(10, 20, 30, 30, 5);
|
||||
}
|
||||
#endif // wxUSE_SPLINES
|
||||
|
||||
void GCDCBoundingBoxTestCase::DrawPolygon()
|
||||
{
|
||||
wxPoint points[3];
|
||||
points[0] = wxPoint(10, 30);
|
||||
points[1] = wxPoint(20, 10);
|
||||
points[2] = wxPoint(30, 30);
|
||||
|
||||
m_gcdc->DrawPolygon(3, points, -5, -7);
|
||||
AssertBox(5, 3, 20, 20);
|
||||
}
|
||||
|
||||
void GCDCBoundingBoxTestCase::DrawPolyPolygon()
|
||||
{
|
||||
int lenghts[2];
|
||||
lenghts[0] = 3;
|
||||
lenghts[1] = 3;
|
||||
wxPoint points[6];
|
||||
points[0] = wxPoint(10, 30);
|
||||
points[1] = wxPoint(20, 10);
|
||||
points[2] = wxPoint(30, 30);
|
||||
points[3] = wxPoint(20, 60);
|
||||
points[4] = wxPoint(30, 40);
|
||||
points[5] = wxPoint(40, 60);
|
||||
|
||||
m_gcdc->DrawPolyPolygon(2, lenghts, points, 12, 5);
|
||||
AssertBox(22, 15, 30, 50, 4);
|
||||
}
|
||||
|
||||
void GCDCBoundingBoxTestCase::DrawRectangle()
|
||||
{
|
||||
m_gcdc->DrawRectangle(2, 2, 12, 12);
|
||||
AssertBox(2, 2, 12, 12);
|
||||
}
|
||||
|
||||
void GCDCBoundingBoxTestCase::DrawRoundedRectangle()
|
||||
{
|
||||
m_gcdc->DrawRoundedRectangle(27, 27, 12, 12, 2);
|
||||
AssertBox(27, 27, 12, 12);
|
||||
}
|
||||
|
||||
void GCDCBoundingBoxTestCase::DrawEllipse()
|
||||
{
|
||||
m_gcdc->DrawEllipse(54, 45, 23, 12);
|
||||
AssertBox(54, 45, 23, 12);
|
||||
}
|
||||
|
||||
void GCDCBoundingBoxTestCase::Blit()
|
||||
{
|
||||
wxBitmap bitmap;
|
||||
bitmap.Create(20, 20);
|
||||
wxMemoryDC dc(bitmap);
|
||||
|
||||
m_gcdc->Blit(20, 10, 12, 7, &dc, 0, 0);
|
||||
AssertBox(20, 10, 12, 7);
|
||||
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
}
|
||||
|
||||
void GCDCBoundingBoxTestCase::StretchBlit()
|
||||
{
|
||||
wxBitmap bitmap;
|
||||
bitmap.Create(20, 20);
|
||||
wxMemoryDC dc(bitmap);
|
||||
|
||||
m_gcdc->StretchBlit(30, 50, 5, 5, &dc, 0, 0, 12, 4);
|
||||
AssertBox(30, 50, 5, 5);
|
||||
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
}
|
||||
|
||||
void GCDCBoundingBoxTestCase::DrawRotatedText()
|
||||
{
|
||||
wxString text("vertical");
|
||||
wxCoord w, h;
|
||||
m_gcdc->GetTextExtent(text, &w, &h);
|
||||
|
||||
m_gcdc->DrawRotatedText(text, 43, 22, -90);
|
||||
AssertBox(43 - h, 22, h, w, 3);
|
||||
}
|
||||
|
||||
void GCDCBoundingBoxTestCase::DrawText()
|
||||
{
|
||||
wxString text("H");
|
||||
wxCoord w, h;
|
||||
m_gcdc->GetTextExtent(text, &w, &h);
|
||||
|
||||
m_gcdc->DrawText(text, 3, 3);
|
||||
AssertBox(3, 3, w, h, 3);
|
||||
}
|
||||
|
||||
void GCDCBoundingBoxTestCase::GradientFillLinear()
|
||||
{
|
||||
wxRect rect(16, 16, 30, 40);
|
||||
m_gcdc->GradientFillLinear(rect, *wxWHITE, *wxBLACK, wxNORTH);
|
||||
AssertBox(16, 16, 30, 40);
|
||||
}
|
||||
|
||||
void GCDCBoundingBoxTestCase::GradientFillConcentric()
|
||||
{
|
||||
wxRect rect(6, 6, 30, 40);
|
||||
m_gcdc->GradientFillConcentric(rect, *wxWHITE, *wxBLACK, wxPoint(10, 10));
|
||||
AssertBox(6, 6, 30, 40);
|
||||
}
|
||||
|
||||
void GCDCBoundingBoxTestCase::DrawCheckMark()
|
||||
{
|
||||
m_gcdc->DrawCheckMark(32, 24, 16, 16);
|
||||
AssertBox(32, 24, 16, 16);
|
||||
}
|
@ -165,6 +165,7 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_ellipsization.obj \
|
||||
$(OBJS)\test_gui_measuring.obj \
|
||||
$(OBJS)\test_gui_affinematrix.obj \
|
||||
$(OBJS)\test_gui_boundingbox.obj \
|
||||
$(OBJS)\test_gui_config.obj \
|
||||
$(OBJS)\test_gui_bitmapcomboboxtest.obj \
|
||||
$(OBJS)\test_gui_bitmaptogglebuttontest.obj \
|
||||
@ -847,6 +848,9 @@ $(OBJS)\test_gui_measuring.obj: .\graphics\measuring.cpp
|
||||
$(OBJS)\test_gui_affinematrix.obj: .\graphics\affinematrix.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\graphics\affinematrix.cpp
|
||||
|
||||
$(OBJS)\test_gui_boundingbox.obj: .\graphics\boundingbox.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\graphics\boundingbox.cpp
|
||||
|
||||
$(OBJS)\test_gui_config.obj: .\config\config.cpp
|
||||
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\config\config.cpp
|
||||
|
||||
|
@ -159,6 +159,7 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_ellipsization.o \
|
||||
$(OBJS)\test_gui_measuring.o \
|
||||
$(OBJS)\test_gui_affinematrix.o \
|
||||
$(OBJS)\test_gui_boundingbox.o \
|
||||
$(OBJS)\test_gui_config.o \
|
||||
$(OBJS)\test_gui_bitmapcomboboxtest.o \
|
||||
$(OBJS)\test_gui_bitmaptogglebuttontest.o \
|
||||
@ -823,6 +824,9 @@ $(OBJS)\test_gui_measuring.o: ./graphics/measuring.cpp
|
||||
$(OBJS)\test_gui_affinematrix.o: ./graphics/affinematrix.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_gui_boundingbox.o: ./graphics/boundingbox.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\test_gui_config.o: ./config/config.cpp
|
||||
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
|
@ -169,6 +169,7 @@ TEST_GUI_OBJECTS = \
|
||||
$(OBJS)\test_gui_ellipsization.obj \
|
||||
$(OBJS)\test_gui_measuring.obj \
|
||||
$(OBJS)\test_gui_affinematrix.obj \
|
||||
$(OBJS)\test_gui_boundingbox.obj \
|
||||
$(OBJS)\test_gui_config.obj \
|
||||
$(OBJS)\test_gui_bitmapcomboboxtest.obj \
|
||||
$(OBJS)\test_gui_bitmaptogglebuttontest.obj \
|
||||
@ -1024,6 +1025,9 @@ $(OBJS)\test_gui_measuring.obj: .\graphics\measuring.cpp
|
||||
$(OBJS)\test_gui_affinematrix.obj: .\graphics\affinematrix.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\graphics\affinematrix.cpp
|
||||
|
||||
$(OBJS)\test_gui_boundingbox.obj: .\graphics\boundingbox.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\graphics\boundingbox.cpp
|
||||
|
||||
$(OBJS)\test_gui_config.obj: .\config\config.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\config\config.cpp
|
||||
|
||||
|
@ -179,6 +179,7 @@
|
||||
graphics/ellipsization.cpp
|
||||
graphics/measuring.cpp
|
||||
graphics/affinematrix.cpp
|
||||
graphics/boundingbox.cpp
|
||||
config/config.cpp
|
||||
controls/bitmapcomboboxtest.cpp
|
||||
controls/bitmaptogglebuttontest.cpp
|
||||
|
@ -316,6 +316,9 @@
|
||||
<File
|
||||
RelativePath=".\controls\bookctrlbasetest.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\graphics\boundingbox.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\sizers\boxsizer.cpp">
|
||||
</File>
|
||||
|
@ -858,6 +858,10 @@
|
||||
RelativePath=".\controls\bookctrlbasetest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\graphics\boundingbox.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\sizers\boxsizer.cpp"
|
||||
>
|
||||
|
@ -830,6 +830,10 @@
|
||||
RelativePath=".\controls\bookctrlbasetest.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\graphics\boundingbox.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\sizers\boxsizer.cpp"
|
||||
>
|
||||
|
Loading…
Reference in New Issue
Block a user