[Libreoffice-commits] core.git: vcl/workben

Michael Meeks michael.meeks at collabora.com
Tue Nov 11 16:07:05 PST 2014


 vcl/workben/vcldemo.cxx |   55 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 53 insertions(+), 2 deletions(-)

New commits:
commit 98f9baa5253f7bb8034f148519f31f548b1452fa
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Wed Nov 12 00:02:03 2014 +0000

    vcldemo: add some clipping tests under the checkerboard tile.
    
    Change-Id: I801931055aeba38e9173fb04dcc44b220cd3f17e

diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 4bf7993a..0aae845 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -195,9 +195,60 @@ public:
     struct DrawCheckered : public RegionRenderer
     {
         virtual void RenderRegion(OutputDevice &rDev, Rectangle r,
-                                  const RenderContext &) SAL_OVERRIDE
+                                  const RenderContext &rCtx) SAL_OVERRIDE
         {
-            rDev.DrawCheckered(r.TopLeft(), r.GetSize());
+            if (rCtx.meStyle == RENDER_EXPANDED)
+            {
+                std::vector<Rectangle> aRegions(DemoWin::partition(rDev, 2, 2));
+                for (size_t i = 0; i < aRegions.size(); i++)
+                {
+                    vcl::Region aRegion;
+                    Rectangle aSub(aRegions[i]);
+                    Rectangle aSmaller(aSub);
+                    aSmaller.Move(10,10);
+                    aSmaller.setWidth(aSmaller.getWidth()-20);
+                    aSmaller.setHeight(aSmaller.getHeight()-24);
+                    switch (i) {
+                    case 0:
+                        aRegion = vcl::Region(aSub);
+                        break;
+                    case 1:
+                        aRegion = vcl::Region(aSmaller);
+                        aRegion.XOr(aSub);
+                        break;
+                    case 2:
+                    {
+                        Polygon aPoly(aSub);
+                        aPoly.Rotate(aSub.Center(), 450);
+                        aPoly.Clip(aSmaller);
+                        aRegion = vcl::Region(aPoly);
+                        break;
+                    }
+                    case 3:
+                    {
+                        tools::PolyPolygon aPolyPoly;
+                        sal_Int32 nTW = aSub.GetWidth()/6;
+                        sal_Int32 nTH = aSub.GetHeight()/6;
+                        Rectangle aTiny(Point(4, 4), Size(nTW*2, nTH*2));
+                        aPolyPoly.Insert(Polygon(aTiny));
+                        aTiny.Move(nTW*3, nTH*3);
+                        aPolyPoly.Insert(Polygon(aTiny));
+                        aTiny.Move(nTW, nTH);
+                        aPolyPoly.Insert(Polygon(aTiny));
+
+                        aRegion = vcl::Region(aPolyPoly);
+                        break;
+                    }
+                    } // switch
+                    rDev.SetClipRegion(aRegion);
+                    rDev.DrawCheckered(aSub.TopLeft(), aSub.GetSize());
+                    rDev.SetClipRegion();
+                }
+            }
+            else
+            {
+                rDev.DrawCheckered(r.TopLeft(), r.GetSize());
+            }
         }
     };
 


More information about the Libreoffice-commits mailing list