LCOV - code coverage report
Current view: top level - sfx2/source/sidebar - DrawHelper.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 50 0.0 %
Date: 2014-04-14 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             :  * This file is part of the LibreOffice project.
       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             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "DrawHelper.hxx"
      21             : #include "Paint.hxx"
      22             : 
      23             : #include <vcl/lineinfo.hxx>
      24             : 
      25             : namespace sfx2 { namespace sidebar {
      26             : 
      27           0 : void DrawHelper::DrawBorder (
      28             :     OutputDevice& rDevice,
      29             :     const Rectangle rBox,
      30             :     const SvBorder aBorderSize,
      31             :     const Paint& rHorizontalPaint,
      32             :     const Paint& rVerticalPaint)
      33             : {
      34             :     // Draw top line.
      35             :     DrawHorizontalLine(
      36             :         rDevice,
      37             :         rBox.Left(),
      38             :         rBox.Right(),
      39             :         rBox.Top(),
      40             :         aBorderSize.Top(),
      41           0 :         rHorizontalPaint);
      42             :     // Draw bottom line.
      43             :     DrawHorizontalLine(
      44             :         rDevice,
      45           0 :         rBox.Left()+aBorderSize.Left(),
      46             :         rBox.Right(),
      47           0 :         rBox.Bottom()-aBorderSize.Bottom()+1,
      48             :         aBorderSize.Bottom(),
      49           0 :         rHorizontalPaint);
      50             :     // Draw left line.
      51             :     DrawVerticalLine(
      52             :         rDevice,
      53           0 :         rBox.Top()+aBorderSize.Top(),
      54             :         rBox.Bottom(),
      55             :         rBox.Left(),
      56             :         aBorderSize.Left(),
      57           0 :         rVerticalPaint);
      58             :     // Draw right line.
      59             :     DrawVerticalLine(
      60             :         rDevice,
      61           0 :         rBox.Top()+aBorderSize.Top(),
      62           0 :         rBox.Bottom()-aBorderSize.Bottom(),
      63           0 :         rBox.Right()-aBorderSize.Right()+1,
      64             :         aBorderSize.Right(),
      65           0 :         rVerticalPaint);
      66           0 : }
      67             : 
      68           0 : void DrawHelper::DrawHorizontalLine(
      69             :     OutputDevice& rDevice,
      70             :     const sal_Int32 nLeft,
      71             :     const sal_Int32 nRight,
      72             :     const sal_Int32 nY,
      73             :     const sal_Int32 nHeight,
      74             :     const Paint& rPaint)
      75             : {
      76           0 :     switch (rPaint.GetType())
      77             :     {
      78             :         case Paint::NoPaint:
      79             :         default:
      80           0 :             break;
      81             : 
      82             :         case Paint::ColorPaint:
      83             :         {
      84           0 :             const Color aColor (rPaint.GetColor());
      85           0 :             rDevice.SetLineColor(aColor);
      86           0 :             for (sal_Int32 nYOffset=0; nYOffset<nHeight; ++nYOffset)
      87             :                 rDevice.DrawLine(
      88             :                     Point(nLeft,nY+nYOffset),
      89           0 :                     Point(nRight,nY+nYOffset));
      90           0 :             break;
      91             :         }
      92             :         case Paint::GradientPaint:
      93             :             rDevice.DrawGradient(
      94             :                 Rectangle(
      95             :                     nLeft,
      96             :                     nY,
      97             :                     nRight,
      98           0 :                     nY+nHeight-1),
      99           0 :                 rPaint.GetGradient());
     100           0 :             break;
     101             :     }
     102           0 : }
     103             : 
     104           0 : void DrawHelper::DrawVerticalLine(
     105             :     OutputDevice& rDevice,
     106             :     const sal_Int32 nTop,
     107             :     const sal_Int32 nBottom,
     108             :     const sal_Int32 nX,
     109             :     const sal_Int32 nWidth,
     110             :     const Paint& rPaint)
     111             : {
     112           0 :     switch (rPaint.GetType())
     113             :     {
     114             :         case Paint::NoPaint:
     115             :         default:
     116           0 :             break;
     117             : 
     118             :         case Paint::ColorPaint:
     119             :         {
     120           0 :             const Color aColor (rPaint.GetColor());
     121           0 :             rDevice.SetLineColor(aColor);
     122           0 :             for (sal_Int32 nXOffset=0; nXOffset<nWidth; ++nXOffset)
     123             :                 rDevice.DrawLine(
     124             :                     Point(nX+nXOffset, nTop),
     125           0 :                     Point(nX+nXOffset, nBottom));
     126           0 :             break;
     127             :         }
     128             :         case Paint::GradientPaint:
     129             :             rDevice.DrawGradient(
     130             :                 Rectangle(
     131             :                     nX,
     132             :                     nTop,
     133           0 :                     nX+nWidth-1,
     134             :                     nBottom),
     135           0 :                 rPaint.GetGradient());
     136           0 :             break;
     137             :     }
     138           0 : }
     139             : 
     140           0 : void DrawHelper::DrawRoundedRectangle (
     141             :     OutputDevice& rDevice,
     142             :     const Rectangle& rBox,
     143             :     const sal_Int32 nCornerRadius,
     144             :     const Color& rBorderColor,
     145             :     const Paint& rFillPaint)
     146             : {
     147           0 :     rDevice.SetLineColor(rBorderColor);
     148           0 :     switch(rFillPaint.GetType())
     149             :     {
     150             :         case Paint::NoPaint:
     151             :         default:
     152           0 :             rDevice.SetFillColor();
     153           0 :             rDevice.DrawRect(rBox, nCornerRadius, nCornerRadius);
     154           0 :             break;
     155             : 
     156             :         case Paint::ColorPaint:
     157           0 :             rDevice.SetFillColor(rFillPaint.GetColor());
     158           0 :             rDevice.DrawRect(rBox, nCornerRadius, nCornerRadius);
     159           0 :             break;
     160             : 
     161             :         case Paint::GradientPaint:
     162             :             rDevice.DrawGradient(
     163             :                 rBox,
     164           0 :                 rFillPaint.GetGradient());
     165           0 :             rDevice.SetFillColor();
     166           0 :             rDevice.DrawRect(rBox, nCornerRadius, nCornerRadius);
     167           0 :             break;
     168             :     }
     169           0 : }
     170             : 
     171             : } } // end of namespace sfx2::sidebar
     172             : 
     173             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10