LCOV - code coverage report
Current view: top level - libreoffice/sfx2/source/control - templatecontaineritem.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 67 0.0 %
Date: 2012-12-27 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * Copyright 2012 LibreOffice contributors.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #include <sfx2/templatecontaineritem.hxx>
      11             : 
      12             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      13             : #include <basegfx/polygon/b2dpolygon.hxx>
      14             : #include <drawinglayer/attribute/fillbitmapattribute.hxx>
      15             : #include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx>
      16             : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
      17             : #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
      18             : #include <drawinglayer/primitive2d/textlayoutdevice.hxx>
      19             : #include <drawinglayer/primitive2d/textprimitive2d.hxx>
      20             : #include <drawinglayer/processor2d/baseprocessor2d.hxx>
      21             : #include <sfx2/templateviewitem.hxx>
      22             : #include <vcl/button.hxx>
      23             : 
      24             : using namespace basegfx;
      25             : using namespace basegfx::tools;
      26             : using namespace drawinglayer::attribute;
      27             : using namespace drawinglayer::primitive2d;
      28             : 
      29           0 : TemplateContainerItem::TemplateContainerItem (ThumbnailView &rView)
      30           0 :     : ThumbnailViewItem(rView)
      31             : {
      32           0 : }
      33             : 
      34           0 : TemplateContainerItem::~TemplateContainerItem ()
      35             : {
      36           0 : }
      37             : 
      38           0 : void TemplateContainerItem::Paint (drawinglayer::processor2d::BaseProcessor2D *pProcessor,
      39             :                                     const ThumbnailItemAttributes *pAttrs)
      40             : {
      41           0 :     int nCount = 0;
      42           0 :     int nSeqSize = 2;
      43             : 
      44           0 :     if (!maPreview1.IsEmpty())
      45           0 :         nSeqSize += 3;
      46             : 
      47           0 :     if (!maPreview2.IsEmpty())
      48           0 :         nSeqSize += 3;
      49             : 
      50           0 :     BColor aFillColor = pAttrs->aFillColor;
      51           0 :     Primitive2DSequence aSeq(nSeqSize);
      52             : 
      53             :     // Draw background
      54           0 :     if ( mbSelected || mbHover )
      55           0 :         aFillColor = pAttrs->aHighlightColor;
      56             : 
      57           0 :     aSeq[nCount++] = Primitive2DReference( new PolyPolygonColorPrimitive2D(
      58             :                                                B2DPolyPolygon(Polygon(maDrawArea,5,5).getB2DPolygon()),
      59           0 :                                                aFillColor));
      60             : 
      61             :     // Draw thumbnail
      62           0 :     Point aPos = maPrev1Pos;
      63           0 :     Size aImageSize = maPreview1.GetSizePixel();
      64             : 
      65           0 :     float fScaleX = 1.0f;
      66           0 :     float fScaleY = 1.0f;
      67             : 
      68           0 :     if (!maPreview2.IsEmpty())
      69             :     {
      70           0 :         fScaleX = 0.8f;
      71           0 :         fScaleY = 0.8f;
      72             : 
      73           0 :         float fWidth = aImageSize.Width()*fScaleX;
      74           0 :         float fHeight = aImageSize.Height()*fScaleY;
      75           0 :         float fPosX = aPos.getX()+35*fScaleX;
      76           0 :         float fPosY = aPos.getY()+20*fScaleY;
      77             : 
      78           0 :         B2DPolygon aBounds;
      79           0 :         aBounds.append(B2DPoint(fPosX,fPosY));
      80           0 :         aBounds.append(B2DPoint(fPosX+fWidth,fPosY));
      81           0 :         aBounds.append(B2DPoint(fPosX+fWidth,fPosY+fHeight));
      82           0 :         aBounds.append(B2DPoint(fPosX,fPosY+fHeight));
      83           0 :         aBounds.setClosed(true);
      84             : 
      85           0 :         aSeq[nCount++] = Primitive2DReference( new PolyPolygonColorPrimitive2D(
      86           0 :                                             B2DPolyPolygon(aBounds), Color(COL_WHITE).getBColor()));
      87           0 :         aSeq[nCount++] = Primitive2DReference( new FillBitmapPrimitive2D(
      88           0 :                                             createScaleTranslateB2DHomMatrix(fScaleX,fScaleY,aPos.X(),aPos.Y()),
      89             :                                             FillBitmapAttribute(maPreview2,
      90             :                                                                 B2DPoint(35,20),
      91           0 :                                                                 B2DVector(aImageSize.Width(),aImageSize.Height()),
      92             :                                                                 false)
      93           0 :                                             ));
      94             : 
      95             :         // draw thumbnail borders
      96           0 :         aSeq[nCount++] = Primitive2DReference(createBorderLine(aBounds));
      97             :     }
      98             : 
      99           0 :     if (!maPreview1.IsEmpty())
     100             :     {
     101             :         // draw thumbnail borders
     102           0 :         float fWidth = aImageSize.Width()*fScaleX;
     103           0 :         float fHeight = aImageSize.Height()*fScaleY;
     104           0 :         float fPosX = aPos.getX();
     105           0 :         float fPosY = aPos.getY();
     106             : 
     107           0 :         B2DPolygon aBounds;
     108           0 :         aBounds.append(B2DPoint(fPosX,fPosY));
     109           0 :         aBounds.append(B2DPoint(fPosX+fWidth,fPosY));
     110           0 :         aBounds.append(B2DPoint(fPosX+fWidth,fPosY+fHeight));
     111           0 :         aBounds.append(B2DPoint(fPosX,fPosY+fHeight));
     112           0 :         aBounds.setClosed(true);
     113             : 
     114           0 :         aSeq[nCount++] = Primitive2DReference( new PolyPolygonColorPrimitive2D(
     115           0 :                                             B2DPolyPolygon(aBounds), Color(COL_WHITE).getBColor()));
     116           0 :         aSeq[nCount++] = Primitive2DReference( new FillBitmapPrimitive2D(
     117           0 :                                             createScaleTranslateB2DHomMatrix(fScaleX,fScaleY,aPos.X(),aPos.Y()),
     118             :                                             FillBitmapAttribute(maPreview1,
     119             :                                                                 B2DPoint(0,0),
     120           0 :                                                                 B2DVector(aImageSize.Width(),aImageSize.Height()),
     121             :                                                                 false)
     122           0 :                                             ));
     123             : 
     124           0 :         aSeq[nCount++] = Primitive2DReference(createBorderLine(aBounds));
     125             :     }
     126             : 
     127             :     // Draw centered text below thumbnail
     128           0 :     aPos = maTextPos;
     129             : 
     130             :     // Create the text primitive
     131             :     basegfx::B2DHomMatrix aTextMatrix( createScaleTranslateB2DHomMatrix(
     132             :                 pAttrs->aFontSize.getX(), pAttrs->aFontSize.getY(),
     133           0 :                 double( aPos.X() ), double( aPos.Y() ) ) );
     134             : 
     135           0 :     aSeq[nCount++] = Primitive2DReference(
     136             :                 new TextSimplePortionPrimitive2D(aTextMatrix,
     137           0 :                                                  maTitle,0,maTitle.getLength(),
     138             :                                                  std::vector< double >( ),
     139             :                                                  pAttrs->aFontAttr,
     140             :                                                  com::sun::star::lang::Locale(),
     141           0 :                                                  Color(COL_BLACK).getBColor() ) );
     142             : 
     143           0 :     pProcessor->process(aSeq);
     144           0 : }
     145             : 
     146             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
     147             : 
     148             : 

Generated by: LCOV version 1.10