LCOV - code coverage report
Current view: top level - sc/source/ui/sidebar - CellLineStyleValueSet.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 79 0.0 %
Date: 2014-04-11 Functions: 0 6 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 <CellLineStyleValueSet.hxx>
      21             : #include <i18nlangtag/mslangid.hxx>
      22             : #include <vcl/settings.hxx>
      23             : 
      24             : namespace sc { namespace sidebar {
      25             : 
      26           0 : CellLineStyleValueSet::CellLineStyleValueSet( Window* pParent, const ResId& rResId)
      27             : :   ValueSet( pParent, rResId ),
      28             :     pVDev(NULL),
      29           0 :     nSelItem(0)
      30             : {
      31           0 :     SetColCount( 1 );
      32           0 :     SetLineCount( 9);
      33           0 : }
      34             : 
      35           0 : CellLineStyleValueSet::~CellLineStyleValueSet()
      36             : {
      37           0 :     delete pVDev;
      38           0 : }
      39             : 
      40           0 : void CellLineStyleValueSet::SetUnit(const OUString* str)
      41             : {
      42           0 :     for (int i = 0; i < CELL_LINE_STYLE_ENTRIES; ++i)
      43             :     {
      44           0 :         maStrUnit[i] = str[i];
      45             :     }
      46           0 : }
      47             : 
      48           0 : void CellLineStyleValueSet::SetSelItem(sal_uInt16 nSel)
      49             : {
      50           0 :     nSelItem = nSel;
      51           0 :     if(nSel == 0)
      52             :     {
      53           0 :         SelectItem(1);
      54           0 :         SetNoSelection();
      55             :     }
      56             :     else
      57             :     {
      58           0 :         SelectItem(nSelItem);
      59           0 :         GrabFocus();
      60             :     }
      61           0 : }
      62             : 
      63           0 : void CellLineStyleValueSet::UserDraw( const UserDrawEvent& rUDEvt )
      64             : {
      65           0 :     Rectangle aRect = rUDEvt.GetRect();
      66           0 :     OutputDevice*  pDev = rUDEvt.GetDevice();
      67           0 :     sal_uInt16  nItemId = rUDEvt.GetItemId();
      68             : 
      69           0 :     long nRectHeight = aRect.GetHeight();
      70           0 :     long nRectWidth = aRect.GetWidth();
      71           0 :     Point aBLPos = aRect.TopLeft();
      72             : 
      73           0 :     Font aOldFont = pDev->GetFont();
      74           0 :     Color aOldColor = pDev->GetLineColor();
      75           0 :     Color aOldFillColor = pDev->GetFillColor();
      76             : 
      77           0 :     Font aFont(OutputDevice::GetDefaultFont(DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE));
      78           0 :     Size aSize = aFont.GetSize();
      79           0 :     aSize.Height() = nRectHeight*3/5;
      80           0 :     aFont.SetSize( aSize );
      81             : 
      82           0 :     long  nTLX = aBLPos.X() + 5,  nTLY = aBLPos.Y() + ( nRectHeight - nItemId )/2;
      83           0 :     long  nTRX = aBLPos.X() + nRectWidth * 7 / 9 - 15, nTRY = aBLPos.Y() + ( nRectHeight - nItemId )/2;
      84             : 
      85           0 :     if( nSelItem ==  nItemId )
      86             :     {
      87           0 :         Color aBackColor(50,107,197);
      88           0 :         Rectangle aBackRect = aRect;
      89           0 :         aBackRect.Top() += 3;
      90           0 :         aBackRect.Bottom() -= 2;
      91           0 :         pDev->SetFillColor(aBackColor);
      92           0 :         pDev->DrawRect(aBackRect);
      93             :     }
      94             :     else
      95             :     {
      96           0 :         pDev->SetFillColor( COL_TRANSPARENT );
      97           0 :         pDev->DrawRect(aRect);
      98             :     }
      99             : 
     100             :     //draw text
     101           0 :     if(nSelItem ==  nItemId )
     102           0 :         aFont.SetColor(COL_WHITE);
     103             :     else
     104           0 :         aFont.SetColor(GetSettings().GetStyleSettings().GetFieldTextColor()); //high contrast
     105             : 
     106           0 :     pDev->SetFont(aFont);
     107           0 :     Point aStart(aBLPos.X() + nRectWidth * 7 / 9 - 5 , aBLPos.Y() + nRectHeight/6);
     108           0 :     pDev->DrawText(aStart, maStrUnit[nItemId - 1]); //can't set TEXT_DRAW_ENDELLIPSIS here, or the text will disapear
     109             : 
     110             :     //draw line
     111           0 :     if( nSelItem ==  nItemId )
     112             :     {
     113           0 :         pDev->SetFillColor(COL_WHITE);
     114           0 :         pDev->SetLineColor(COL_WHITE);
     115             :     }
     116             :     else
     117             :     {
     118           0 :         pDev->SetFillColor(GetSettings().GetStyleSettings().GetFieldTextColor());   //high contrast
     119           0 :         pDev->SetLineColor(GetSettings().GetStyleSettings().GetFieldTextColor());   //high contrast
     120             :     }
     121             : 
     122           0 :     switch( nItemId )
     123             :     {
     124             :         case 1:
     125             :         case 2:
     126             :         case 3:
     127             :         case 4:
     128           0 :             pDev->DrawRect(Rectangle(nTLX, nTLY , nTRX, nTRY + nItemId * 2 - 1 ));
     129           0 :             break;
     130             :         case 5:
     131           0 :             pDev->DrawRect(Rectangle(nTLX, nTLY , nTRX, nTRY + 1 ));
     132           0 :             pDev->DrawRect(Rectangle(nTLX, nTLY + 3 , nTRX, nTRY + 4 ));
     133           0 :             break;
     134             :         case 6:
     135           0 :             pDev->DrawRect(Rectangle(nTLX, nTLY , nTRX, nTRY + 1 ));
     136           0 :             pDev->DrawRect(Rectangle(nTLX, nTLY + 5 , nTRX, nTRY + 6 ));
     137           0 :             break;
     138             :         case 7:
     139           0 :             pDev->DrawRect(Rectangle(nTLX, nTLY , nTRX, nTRY + 1 ));
     140           0 :             pDev->DrawRect(Rectangle(nTLX, nTLY + 3 , nTRX, nTRY + 6 ));
     141           0 :             break;
     142             :         case 8:
     143           0 :             pDev->DrawRect(Rectangle(nTLX, nTLY , nTRX, nTRY + 3 ));
     144           0 :             pDev->DrawRect(Rectangle(nTLX, nTLY + 5 , nTRX, nTRY + 6 ));
     145           0 :             break;
     146             :         case 9:
     147           0 :             pDev->DrawRect(Rectangle(nTLX, nTLY , nTRX, nTRY + 3 ));
     148           0 :             pDev->DrawRect(Rectangle(nTLX, nTLY + 5 , nTRX, nTRY + 8 ));
     149           0 :             break;
     150             :     }
     151             : 
     152           0 :     Invalidate( aRect );
     153           0 :     pDev->SetLineColor(aOldColor);
     154           0 :     pDev->SetFillColor(aOldFillColor);
     155           0 :     pDev->SetFont(aOldFont);
     156             : 
     157           0 : }
     158             : 
     159             : } } // end of namespace svx::sidebar
     160             : 
     161             : // eof
     162             : 
     163             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10