LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svx/source/sidebar/line - LineWidthValueSet.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 86 1.2 %
Date: 2013-07-09 Functions: 2 11 18.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * This file is part of the LibreOffice project.
       3             :  *
       4             :  * This Source Code Form is subject to the terms of the Mozilla Public
       5             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       6             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       7             :  *
       8             :  * This file incorporates work covered by the following license notice:
       9             :  *
      10             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      11             :  *   contributor license agreements. See the NOTICE file distributed
      12             :  *   with this work for additional information regarding copyright
      13             :  *   ownership. The ASF licenses this file to you under the Apache
      14             :  *   License, Version 2.0 (the "License"); you may not use this file
      15             :  *   except in compliance with the License. You may obtain a copy of
      16             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      17             :  */
      18             : #include "LineWidthValueSet.hxx"
      19             : 
      20             : #include <i18nlangtag/mslangid.hxx>
      21             : 
      22             : namespace svx { namespace sidebar {
      23             : 
      24             : 
      25           0 : LineWidthValueSet::LineWidthValueSet (
      26             :     Window* pParent, const ResId& rResId)
      27             :     : ValueSet( pParent, rResId ),
      28             :       pVDev(NULL),
      29             :       nSelItem(0),
      30           0 :       bCusEnable(false)
      31             : {
      32           0 :     strUnit = new XubString[9];
      33           0 :     SetColCount( 1 );
      34           0 :     SetLineCount( 9);
      35           0 : }
      36             : 
      37             : 
      38             : 
      39             : 
      40           0 : LineWidthValueSet::~LineWidthValueSet (void)
      41             : {
      42           0 :     delete pVDev;
      43           0 :     delete[] strUnit;
      44           0 : }
      45             : 
      46             : 
      47             : 
      48             : 
      49           0 : void LineWidthValueSet::SetUnit(XubString* str)
      50             : {
      51           0 :     for(int i = 0; i < 9; i++)
      52             :     {
      53           0 :         strUnit[i] = str[i];
      54             :     }
      55           0 : }
      56             : 
      57             : 
      58             : 
      59           0 : void LineWidthValueSet::SetSelItem(sal_uInt16 nSel)
      60             : {
      61           0 :     nSelItem = nSel;
      62           0 :     if(nSel == 0)
      63             :     {
      64           0 :         SelectItem(1); // ,false); // 'false' nut supported by AOO
      65           0 :         SetNoSelection();
      66             :     }
      67             :     else
      68             :     {
      69           0 :         SelectItem(nSelItem);
      70           0 :         GrabFocus();
      71             :     }
      72           0 : }
      73             : 
      74             : 
      75             : 
      76             : 
      77           0 : sal_uInt16 LineWidthValueSet::GetSelItem()
      78             : {
      79           0 :     return nSelItem;
      80             : }
      81             : 
      82             : 
      83             : 
      84             : 
      85           0 : void LineWidthValueSet::SetImage(Image img)
      86             : {
      87           0 :     imgCus = img;
      88           0 : }
      89             : 
      90             : 
      91             : 
      92             : 
      93           0 : void LineWidthValueSet::SetCusEnable(bool bEnable)
      94             : {
      95           0 :     bCusEnable = bEnable;
      96           0 : }
      97             : 
      98             : 
      99             : 
     100             : 
     101           0 : void  LineWidthValueSet::UserDraw( const UserDrawEvent& rUDEvt )
     102             : {
     103           0 :     Rectangle aRect = rUDEvt.GetRect();
     104           0 :     OutputDevice*  pDev = rUDEvt.GetDevice();
     105           0 :     sal_uInt16  nItemId = rUDEvt.GetItemId();
     106             : 
     107           0 :     long nRectHeight = aRect.GetHeight();
     108           0 :     long nRectWidth = aRect.GetWidth();
     109           0 :     Point aBLPos = aRect.TopLeft();
     110             : 
     111             :     //const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     112             :     //Color aBackColor(0,0,200);
     113             :     //const Color aTextColor = rStyleSettings.GetFieldTextColor();
     114           0 :     Font aOldFont = pDev->GetFont();
     115           0 :     Color aOldColor = pDev->GetLineColor();
     116           0 :     Color aOldFillColor = pDev->GetFillColor();
     117             : 
     118           0 :     Font aFont(OutputDevice::GetDefaultFont(DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE));
     119           0 :     Size aSize = aFont.GetSize();
     120           0 :     aSize.Height() = nRectHeight*3/5;
     121           0 :     aFont.SetSize( aSize );
     122             : 
     123           0 :     Point aLineStart(aBLPos.X() + 5,            aBLPos.Y() + ( nRectHeight - nItemId )/2);
     124           0 :     Point aLineEnd(aBLPos.X() + nRectWidth * 7 / 9 - 10, aBLPos.Y() + ( nRectHeight - nItemId )/2);
     125           0 :     if(nItemId == 9)
     126             :     {
     127           0 :         Point aImgStart(aBLPos.X() + 5,         aBLPos.Y() + ( nRectHeight - 23 ) / 2);
     128           0 :         pDev->DrawImage(aImgStart, imgCus);
     129             :     //  Point aStart(aImgStart.X() + 14 + 20 , aBLPos.Y() + nRectHeight/6);
     130           0 :         Rectangle aStrRect = aRect;
     131           0 :         aStrRect.Top() += nRectHeight/6;
     132           0 :         aStrRect.Bottom() -= nRectHeight/6;
     133           0 :         aStrRect.Left() += imgCus.GetSizePixel().Width() + 20;
     134           0 :         if(bCusEnable)
     135           0 :             aFont.SetColor(GetSettings().GetStyleSettings().GetFieldTextColor());
     136             :         else
     137           0 :             aFont.SetColor(GetSettings().GetStyleSettings().GetDisableColor());
     138             : 
     139           0 :         pDev->SetFont(aFont);
     140           0 :         pDev->DrawText(aStrRect, strUnit[ nItemId - 1 ], TEXT_DRAW_ENDELLIPSIS);
     141             :     }
     142             :     else
     143             :     {
     144           0 :         if( nSelItem ==  nItemId )
     145             :         {
     146           0 :             Color aBackColor(50,107,197);
     147           0 :             Rectangle aBackRect = aRect;
     148           0 :             aBackRect.Top() += 3;
     149           0 :             aBackRect.Bottom() -= 2;
     150           0 :             pDev->SetFillColor(aBackColor);
     151           0 :             pDev->DrawRect(aBackRect);
     152             :         }
     153             :         else
     154             :         {
     155           0 :             pDev->SetFillColor( COL_TRANSPARENT );
     156           0 :             pDev->DrawRect(aRect);
     157             :         }
     158             : 
     159             :         //draw text
     160           0 :         if(nSelItem ==  nItemId )
     161           0 :             aFont.SetColor(COL_WHITE);
     162             :         else
     163           0 :             aFont.SetColor(GetSettings().GetStyleSettings().GetFieldTextColor());
     164           0 :         pDev->SetFont(aFont);
     165           0 :         Point aStart(aBLPos.X() + nRectWidth * 7 / 9 , aBLPos.Y() + nRectHeight/6);
     166           0 :         pDev->DrawText(aStart, strUnit[ nItemId - 1 ]);  //can't set TEXT_DRAW_ENDELLIPSIS here ,or the text will disappear
     167             : 
     168             :         //draw line
     169           0 :         if( nSelItem ==  nItemId )
     170           0 :             pDev->SetLineColor(COL_WHITE);
     171             :         else
     172           0 :             pDev->SetLineColor(GetSettings().GetStyleSettings().GetFieldTextColor());
     173             : 
     174           0 :         for(sal_uInt16 i = 1; i <= nItemId; i++)
     175             :         {
     176           0 :             pDev->DrawLine(aLineStart,aLineEnd );
     177           0 :             aLineStart.setY(aLineStart.getY() + 1);
     178           0 :             aLineEnd.setY  (aLineEnd.getY() + 1);
     179             :         }
     180             :     }
     181             : 
     182           0 :     Invalidate( aRect );
     183           0 :     pDev->SetLineColor(aOldColor);
     184           0 :     pDev->SetFillColor(aOldFillColor);
     185           0 :     pDev->SetFont(aOldFont);
     186           0 : }
     187             : 
     188             : 
     189             : 
     190         216 : } } // end of namespace svx::sidebar
     191             : 
     192             : // eof

Generated by: LCOV version 1.10