LCOV - code coverage report
Current view: top level - svx/source/sidebar/line - LineWidthValueSet.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 84 1.2 %
Date: 2014-11-03 Functions: 2 10 20.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             : #include "LineWidthValueSet.hxx"
      20             : 
      21             : #include <i18nlangtag/mslangid.hxx>
      22             : #include <vcl/settings.hxx>
      23             : 
      24             : namespace svx { namespace sidebar {
      25             : 
      26             : 
      27           0 : LineWidthValueSet::LineWidthValueSet (
      28             :     vcl::Window* pParent, const ResId& rResId)
      29             :     : ValueSet( pParent, rResId ),
      30             :       pVDev(NULL),
      31             :       nSelItem(0),
      32           0 :       bCusEnable(false)
      33             : {
      34           0 :     strUnit = new OUString[9];
      35           0 :     SetColCount( 1 );
      36           0 :     SetLineCount( 9);
      37           0 : }
      38             : 
      39             : 
      40             : 
      41             : 
      42           0 : LineWidthValueSet::~LineWidthValueSet (void)
      43             : {
      44           0 :     delete pVDev;
      45           0 :     delete[] strUnit;
      46           0 : }
      47             : 
      48             : 
      49             : 
      50             : 
      51           0 : void LineWidthValueSet::SetUnit(OUString* str)
      52             : {
      53           0 :     for(int i = 0; i < 9; i++)
      54             :     {
      55           0 :         strUnit[i] = str[i];
      56             :     }
      57           0 : }
      58             : 
      59             : 
      60             : 
      61           0 : void LineWidthValueSet::SetSelItem(sal_uInt16 nSel)
      62             : {
      63           0 :     nSelItem = nSel;
      64           0 :     if(nSel == 0)
      65             :     {
      66           0 :         SelectItem(1); // ,false); // 'false' nut supported by AOO
      67           0 :         SetNoSelection();
      68             :     }
      69             :     else
      70             :     {
      71           0 :         SelectItem(nSelItem);
      72           0 :         GrabFocus();
      73             :     }
      74           0 : }
      75             : 
      76             : 
      77             : 
      78             : 
      79             : 
      80             : 
      81             : 
      82             : 
      83           0 : void LineWidthValueSet::SetImage(Image img)
      84             : {
      85           0 :     imgCus = img;
      86           0 : }
      87             : 
      88             : 
      89             : 
      90             : 
      91           0 : void LineWidthValueSet::SetCusEnable(bool bEnable)
      92             : {
      93           0 :     bCusEnable = bEnable;
      94           0 : }
      95             : 
      96             : 
      97             : 
      98             : 
      99           0 : void  LineWidthValueSet::UserDraw( const UserDrawEvent& rUDEvt )
     100             : {
     101           0 :     Rectangle aRect = rUDEvt.GetRect();
     102           0 :     OutputDevice*  pDev = rUDEvt.GetDevice();
     103           0 :     sal_uInt16  nItemId = rUDEvt.GetItemId();
     104             : 
     105           0 :     long nRectHeight = aRect.GetHeight();
     106           0 :     long nRectWidth = aRect.GetWidth();
     107           0 :     Point aBLPos = aRect.TopLeft();
     108             : 
     109             :     //const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     110             :     //Color aBackColor(0,0,200);
     111             :     //const Color aTextColor = rStyleSettings.GetFieldTextColor();
     112           0 :     vcl::Font aOldFont = pDev->GetFont();
     113           0 :     Color aOldColor = pDev->GetLineColor();
     114           0 :     Color aOldFillColor = pDev->GetFillColor();
     115             : 
     116           0 :     vcl::Font aFont(OutputDevice::GetDefaultFont(DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE));
     117           0 :     Size aSize = aFont.GetSize();
     118           0 :     aSize.Height() = nRectHeight*3/5;
     119           0 :     aFont.SetSize( aSize );
     120             : 
     121           0 :     Point aLineStart(aBLPos.X() + 5,            aBLPos.Y() + ( nRectHeight - nItemId )/2);
     122           0 :     Point aLineEnd(aBLPos.X() + nRectWidth * 7 / 9 - 10, aBLPos.Y() + ( nRectHeight - nItemId )/2);
     123           0 :     if(nItemId == 9)
     124             :     {
     125           0 :         Point aImgStart(aBLPos.X() + 5,         aBLPos.Y() + ( nRectHeight - 23 ) / 2);
     126           0 :         pDev->DrawImage(aImgStart, imgCus);
     127             :     //  Point aStart(aImgStart.X() + 14 + 20 , aBLPos.Y() + nRectHeight/6);
     128           0 :         Rectangle aStrRect = aRect;
     129           0 :         aStrRect.Top() += nRectHeight/6;
     130           0 :         aStrRect.Bottom() -= nRectHeight/6;
     131           0 :         aStrRect.Left() += imgCus.GetSizePixel().Width() + 20;
     132           0 :         if(bCusEnable)
     133           0 :             aFont.SetColor(GetSettings().GetStyleSettings().GetFieldTextColor());
     134             :         else
     135           0 :             aFont.SetColor(GetSettings().GetStyleSettings().GetDisableColor());
     136             : 
     137           0 :         pDev->SetFont(aFont);
     138           0 :         pDev->DrawText(aStrRect, strUnit[ nItemId - 1 ], TEXT_DRAW_ENDELLIPSIS);
     139             :     }
     140             :     else
     141             :     {
     142           0 :         if( nSelItem ==  nItemId )
     143             :         {
     144           0 :             Color aBackColor(50,107,197);
     145           0 :             Rectangle aBackRect = aRect;
     146           0 :             aBackRect.Top() += 3;
     147           0 :             aBackRect.Bottom() -= 2;
     148           0 :             pDev->SetFillColor(aBackColor);
     149           0 :             pDev->DrawRect(aBackRect);
     150             :         }
     151             :         else
     152             :         {
     153           0 :             pDev->SetFillColor( COL_TRANSPARENT );
     154           0 :             pDev->DrawRect(aRect);
     155             :         }
     156             : 
     157             :         //draw text
     158           0 :         if(nSelItem ==  nItemId )
     159           0 :             aFont.SetColor(COL_WHITE);
     160             :         else
     161           0 :             aFont.SetColor(GetSettings().GetStyleSettings().GetFieldTextColor());
     162           0 :         pDev->SetFont(aFont);
     163           0 :         Point aStart(aBLPos.X() + nRectWidth * 7 / 9 , aBLPos.Y() + nRectHeight/6);
     164           0 :         pDev->DrawText(aStart, strUnit[ nItemId - 1 ]);  //can't set TEXT_DRAW_ENDELLIPSIS here ,or the text will disappear
     165             : 
     166             :         //draw line
     167           0 :         if( nSelItem ==  nItemId )
     168           0 :             pDev->SetLineColor(COL_WHITE);
     169             :         else
     170           0 :             pDev->SetLineColor(GetSettings().GetStyleSettings().GetFieldTextColor());
     171             : 
     172           0 :         for(sal_uInt16 i = 1; i <= nItemId; i++)
     173             :         {
     174           0 :             pDev->DrawLine(aLineStart,aLineEnd );
     175           0 :             aLineStart.setY(aLineStart.getY() + 1);
     176           0 :             aLineEnd.setY  (aLineEnd.getY() + 1);
     177             :         }
     178             :     }
     179             : 
     180           0 :     Invalidate( aRect );
     181           0 :     pDev->SetLineColor(aOldColor);
     182           0 :     pDev->SetFillColor(aOldFillColor);
     183           0 :     pDev->SetFont(aOldFont);
     184           0 : }
     185             : 
     186             : 
     187             : 
     188         594 : } } // end of namespace svx::sidebar
     189             : 
     190             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10