summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2014-11-11 21:51:58 +0000
committerMichael Meeks <michael.meeks@collabora.com>2014-11-11 21:54:48 +0000
commit880310280901f7fc2966724265b7ba331244c07e (patch)
treedfe8bbc1eb8285f0b77392299338cbdc1bd3923e
parent355770eff40acc07e9cd46fa4dcfb39e6a86166e (diff)
vcldemo: click to invalidate bits and bounce a floatwin around.
Change-Id: I0c417842393eb32132fd430b8bf31e93e7ec3b27
-rw-r--r--vcl/workben/vcldemo.cxx61
1 files changed, 61 insertions, 0 deletions
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 354c4b3894c0..00bab53eb611 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -23,6 +23,8 @@
#include <vcl/wrkwin.hxx>
#include <vcl/virdev.hxx>
#include <vcl/graphicfilter.hxx>
+#include <vcl/button.hxx>
+#include <vcl/floatwin.hxx>
#if 0
# define FIXME_SELF_INTERSECTING_WORKING
@@ -47,6 +49,8 @@ class DemoWin : public DemoBase
public:
DemoWin() : DemoBase()
+ , mpButton(NULL)
+ , mpButtonWin(NULL)
{
if (!Application::LoadBrandBitmap("intro", maIntro))
Application::Abort("Failed to load intro image");
@@ -54,6 +58,15 @@ public:
maIntroBW.Filter( BMP_FILTER_EMBOSS_GREY );
}
+ // Bouncing windows on click ...
+ PushButton *mpButton;
+ FloatingWindow *mpButtonWin;
+ AutoTimer maBounce;
+ int mnBounceX, mnBounceY;
+ DECL_LINK(BounceTimerCb, void *);
+
+ virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
+
void drawToDevice(OutputDevice &r, bool bVdev);
virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE
@@ -272,6 +285,54 @@ public:
}
};
+IMPL_LINK_NOARG(DemoWin,BounceTimerCb)
+{
+ mpButton->Check(mnBounceX>0);
+ mpButton->SetPressed(mnBounceY>0);
+
+ Point aCur = mpButtonWin->GetPosPixel();
+ static const int nMovePix = 10;
+ aCur.Move(mnBounceX * nMovePix, mnBounceX * nMovePix);
+ Size aWinSize = GetSizePixel();
+ if (aCur.X() <= 0 || aCur.X() >= aWinSize.Width())
+ mnBounceX *= -1;
+ if (aCur.Y() <= 0 || aCur.Y() >= aWinSize.Height())
+ mnBounceX *= -1;
+ mpButtonWin->SetPosPixel(aCur);
+
+ // All smoke and mirrors to test sub-region invalidation underneath
+ Rectangle aRect(aCur, mpButtonWin->GetSizePixel());
+ Invalidate(aRect);
+ return 0;
+}
+
+void DemoWin::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ (void) rMEvt;
+ if (!mpButton)
+ {
+ mpButtonWin = new FloatingWindow(this);
+ mpButton = new PushButton(mpButtonWin);
+ mpButton->SetSymbol(SymbolType::HELP);
+ mpButton->SetText("PushButton demo");
+ mpButton->SetPosSizePixel(Point(0,0), mpButton->GetOptimalSize());
+ mpButton->Show();
+ mpButtonWin->SetPosSizePixel(Point(0,0), mpButton->GetOptimalSize());
+ mpButtonWin->Show();
+ mnBounceX = 1; mnBounceX = 1;
+ maBounce.SetTimeoutHdl(LINK(this,DemoWin,BounceTimerCb));
+ maBounce.SetTimeout(55);
+ maBounce.Start();
+ }
+ else
+ {
+ maBounce.Stop();
+ delete mpButtonWin;
+ mpButtonWin = NULL;
+ mpButton = NULL;
+ }
+}
+
std::vector<Rectangle> DemoWin::partitionAndClear(OutputDevice &rDev, int nX, int nY)
{
Rectangle r;