diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2014-12-01 13:45:03 +0000 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2014-12-02 15:47:33 +0100 |
commit | 44239d8002792c1f6d9373db46382ac9f4d27466 (patch) | |
tree | 3f6071418fd13741c2e480137a68e4b5438474fd | |
parent | b78e0c05ba3490b595807dbc4ea6b21f2a88a1c6 (diff) |
vcl: improve vcldemo & outdev test.
Change-Id: I1ebc3c3b3cffabc8ba446ecd45ac2d9b0d45aff1
-rw-r--r-- | vcl/qa/cppunit/outdev.cxx | 27 | ||||
-rw-r--r-- | vcl/workben/vcldemo.cxx | 66 |
2 files changed, 84 insertions, 9 deletions
diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx index 47e8dcfece70..de02ffc04f37 100644 --- a/vcl/qa/cppunit/outdev.cxx +++ b/vcl/qa/cppunit/outdev.cxx @@ -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)); diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index 4485a0e43493..d65ea20f832c 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -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(); } |