diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2014-11-11 22:55:38 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2014-11-11 23:35:05 +0000 |
commit | c3eab4a893a4cde7c23ad06e4090283775b1e49b (patch) | |
tree | 692bc29d035516b72ae5df5b62777253232debe7 /vcl/workben | |
parent | 1c526c9ddda5d52f7a4db5655a4ec60b8c62835c (diff) |
vcldemo: render an enlarged view on mouse click.
Change-Id: I9021ab4744b16f967eaa5006128d30621b421d7a
Diffstat (limited to 'vcl/workben')
-rw-r--r-- | vcl/workben/vcldemo.cxx | 53 |
1 files changed, 44 insertions, 9 deletions
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index 57eecfa3b2b0..b5c2ddf2a2f5 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -52,6 +52,9 @@ class DemoWin : public DemoBase Bitmap maIntroBW; BitmapEx maIntro; + int mnSegmentsX; + int mnSegmentsY; + struct RenderContext { RenderStyle meStyle; bool mbVDev; @@ -65,11 +68,15 @@ class DemoWin : public DemoBase }; std::vector< RegionRenderer * > maRenderers; + sal_Int32 mnSelectedRenderer; void InitRenderers(); public: DemoWin() : DemoBase() + , mnSegmentsX(4) + , mnSegmentsY(3) + , mnSelectedRenderer(-1) , mpButton(NULL) , mpButtonWin(NULL) { @@ -99,14 +106,12 @@ public: std::vector<Rectangle> partitionAndClear(OutputDevice &rDev, int nX, int nY); - void drawBackground(OutputDevice &rDev) + void drawBackground(OutputDevice &rDev, Rectangle r) { - Rectangle r(Point(0,0), rDev.GetOutputSizePixel()); Gradient aGradient; aGradient.SetStartColor(COL_BLUE); aGradient.SetEndColor(COL_GREEN); aGradient.SetStyle(GradientStyle_LINEAR); -// aGradient.SetBorder(r.GetSize().Width()/20); rDev.DrawGradient(r, aGradient); } @@ -358,15 +363,25 @@ public: void drawToDevice(OutputDevice &rDev, bool bVdev) { RenderContext aCtx; - aCtx.meStyle = RENDER_THUMB; aCtx.mbVDev = bVdev; aCtx.mpDemoWin = this; - drawBackground(rDev); + Rectangle aWholeWin(Point(0,0), rDev.GetOutputSizePixel()); + + drawBackground(rDev, aWholeWin); - std::vector<Rectangle> aRegions(partitionAndClear(rDev, 4, 3)); - for (size_t i = 0; i < maRenderers.size(); i++) - maRenderers[i]->RenderRegion(rDev, aRegions[i], aCtx); + if (mnSelectedRenderer >= 0) + { + aCtx.meStyle = RENDER_EXPANDED; + maRenderers[mnSelectedRenderer]->RenderRegion(rDev, aWholeWin, aCtx); + } + else + { + aCtx.meStyle = RENDER_THUMB; + std::vector<Rectangle> aRegions(partitionAndClear(rDev, mnSegmentsX, mnSegmentsY)); + for (size_t i = 0; i < maRenderers.size(); i++) + maRenderers[i]->RenderRegion(rDev, aRegions[i], aCtx); + } } }; @@ -393,7 +408,27 @@ IMPL_LINK_NOARG(DemoWin,BounceTimerCb) void DemoWin::MouseButtonDown( const MouseEvent& rMEvt ) { - (void) rMEvt; + // click to zoom out + if (mnSelectedRenderer >= 0) + { + mnSelectedRenderer = -1; + Invalidate(); + return; + } + + // click on a region to zoom into it + std::vector<Rectangle> aRegions(partitionAndClear(*this, mnSegmentsX, mnSegmentsY)); + for (size_t i = 0; i < aRegions.size(); i++) + { + if (aRegions[i].IsInside(rMEvt.GetPosPixel())) + { + mnSelectedRenderer = i; + Invalidate(); + return; + } + } + + // otherwise bounce floating windows if (!mpButton) { mpButtonWin = new FloatingWindow(this); |