Kaydet (Commit) 0d4233ef authored tarafından Michael Meeks's avatar Michael Meeks Kaydeden (comit) Jan Holesovsky

vcl: improve vcldemo & outdev test.

Change-Id: I1ebc3c3b3cffabc8ba446ecd45ac2d9b0d45aff1
üst 2b433d87
......@@ -15,6 +15,9 @@
#include <vcl/bmpacc.hxx>
#include <vcl/wrkwin.hxx>
#include <tools/stream.hxx>
#include <vcl/pngwrite.hxx>
class VclOutdevTest : public test::BootstrapFixture
{
public:
......@@ -36,18 +39,30 @@ void VclOutdevTest::testVirtualDevice()
aVDev.DrawPixel(Point(1,2),COL_GREEN);
aVDev.DrawPixel(Point(31,30),COL_RED);
CPPUNIT_ASSERT(aVDev.GetPixel(Point(0,0)) == COL_WHITE);
CPPUNIT_ASSERT(aVDev.GetPixel(Point(1,2)) == COL_GREEN);
CPPUNIT_ASSERT(aVDev.GetPixel(Point(31,30)) == COL_RED);
CPPUNIT_ASSERT(aVDev.GetPixel(Point(30,31)) == COL_WHITE);
Size aSize = aVDev.GetOutputSizePixel();
CPPUNIT_ASSERT(aSize == Size(32,32));
Bitmap aBmp = aVDev.GetBitmap(Point(),aSize);
Bitmap::ScopedReadAccess pAcc(aBmp);
#if 0
OUString rFileName("/tmp/foo-unx.png");
try {
vcl::PNGWriter aWriter( aBmp );
SvFileStream sOutput( rFileName, STREAM_WRITE );
aWriter.Write( sOutput );
sOutput.Close();
} catch (...) {
SAL_WARN("vcl", "Error writing png to " << rFileName);
}
#endif
CPPUNIT_ASSERT(aVDev.GetPixel(Point(0,0)) == COL_WHITE);
CPPUNIT_ASSERT(aVDev.GetPixel(Point(1,2)) == COL_GREEN);
CPPUNIT_ASSERT(aVDev.GetPixel(Point(31,30)) == COL_RED);
CPPUNIT_ASSERT(aVDev.GetPixel(Point(30,31)) == COL_WHITE);
// Gotcha: y and x swap for BitmapReadAccess: deep joy.
Bitmap::ScopedReadAccess pAcc(aBmp);
CPPUNIT_ASSERT(pAcc->GetPixel(0,0) == Color(COL_WHITE));
CPPUNIT_ASSERT(pAcc->GetPixel(2,1) == Color(COL_GREEN));
CPPUNIT_ASSERT(pAcc->GetPixel(30,31) == Color(COL_RED));
......
......@@ -15,6 +15,7 @@
#include <com/sun/star/ucb/UniversalContentBroker.hpp>
#include <vcl/vclmain.hxx>
#include <vcl/layout.hxx>
#include <tools/urlobj.hxx>
#include <tools/stream.hxx>
......@@ -1251,6 +1252,55 @@ public:
}
};
class DemoWidgets : public WorkWindow
{
VclBox *mpBox;
public:
DemoWidgets() :
WorkWindow(NULL, WB_STDWORK)
{
SetText("VCL widget demo");
mpBox = new VclVBox(this, false, 3);
Wallpaper aWallpaper(BitmapEx("sfx2/res/startcenter-logo.png"));
aWallpaper.SetStyle(WALLPAPER_BOTTOMRIGHT);
aWallpaper.SetColor(COL_RED);
mpBox->SetBackground(aWallpaper);
mpBox->Show();
Show();
}
virtual ~DemoWidgets()
{
}
virtual void Paint(const Rectangle&)
{
Rectangle aWholeSize(Point(0, 0),GetOutputSizePixel());
vcl::Region aClip(aWholeSize);
Rectangle aExclude(Rectangle(Point(50,50),Size(100,100)));
aClip.Exclude(aExclude);
Wallpaper aWallpaper(COL_GREEN);
Push(PushFlags::CLIPREGION);
IntersectClipRegion(aClip);
DrawWallpaper(aWholeSize, aWallpaper);
Pop();
VirtualDevice aDev(*this);
aDev.EnableRTL(IsRTLEnabled());
aDev.SetOutputSizePixel(aExclude.GetSize());
Rectangle aSubRect(aWholeSize);
aSubRect.Move(-aExclude.Left(), -aExclude.Top());
aDev.DrawWallpaper(aSubRect, aWallpaper );
DrawOutDev(aExclude.TopLeft(), aExclude.GetSize(),
Point( 0, 0 ), aExclude.GetSize(), aDev );
}
};
class DemoApp : public Application
{
......@@ -1262,7 +1312,9 @@ class DemoApp : public Application
OUString aRenderers(rRenderer.getRendererList());
fprintf(stderr," %s\n",
rtl::OUStringToOString(aRenderers, RTL_TEXTENCODING_UTF8).getStr());
fprintf(stderr," --test <iterCount> - create benchmark data\n\n");
fprintf(stderr," --test <iterCount> - create benchmark data\n");
fprintf(stderr, " --widgets - launch the widget test.\n");
fprintf(stderr, "\n");
return 0;
}
......@@ -1273,6 +1325,7 @@ public:
{
try
{
bool bWidgets = false;
DemoRenderer aRenderer;
for (sal_Int32 i = 0; i < GetCommandLineParamCount(); i++)
......@@ -1288,19 +1341,26 @@ public:
else
aRenderer.selectRenderer(GetCommandLineParam(++i));
}
if (aArg == "--test")
else if (aArg == "--test")
{
if (bLast)
return showHelp(aRenderer);
else
aRenderer.setIterCount(GetCommandLineParam(++i).toInt32());
}
else if (aArg == "--widgets")
bWidgets = true;
}
DemoWin aMainWin(aRenderer);
boost::scoped_ptr<DemoWidgets> aWidgets;
aMainWin.SetText("Interactive VCL demo #1");
aMainWin.Show();
if (bWidgets)
aWidgets.reset(new DemoWidgets());
else
aMainWin.Show();
Application::Execute();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment