LCOV - code coverage report
Current view: top level - sc/source/ui/cctrl - cbuttonw.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 71 74 95.9 %
Date: 2015-06-13 12:38:46 Functions: 6 6 100.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 <vcl/outdev.hxx>
      21             : #include <vcl/window.hxx>
      22             : #include <vcl/decoview.hxx>
      23             : #include <vcl/svapp.hxx>
      24             : #include <vcl/settings.hxx>
      25             : #include "cbutton.hxx"
      26             : 
      27             : //  class ScDDComboBoxButton
      28             : 
      29         352 : ScDDComboBoxButton::ScDDComboBoxButton( OutputDevice* pOutputDevice )
      30         352 :     :   pOut( pOutputDevice )
      31             : {
      32         352 :     SetOptSizePixel();
      33         352 : }
      34             : 
      35           1 : ScDDComboBoxButton::~ScDDComboBoxButton()
      36             : {
      37           1 : }
      38             : 
      39        5928 : void ScDDComboBoxButton::SetOutputDevice( OutputDevice* pOutputDevice )
      40             : {
      41        5928 :     pOut = pOutputDevice;
      42        5928 : }
      43             : 
      44         353 : void ScDDComboBoxButton::SetOptSizePixel()
      45             : {
      46         353 :     aBtnSize = pOut->LogicToPixel( Size(0,11), MAP_APPFONT );
      47             :     //aBtnSize.Width() = GetSystemMetrics( SM_CXVSCROLL ) - 1; // Win SDK-Funktion
      48         353 :     aBtnSize.Width() = pOut->GetSettings().GetStyleSettings().GetScrollBarSize();
      49         353 : }
      50             : 
      51           1 : void ScDDComboBoxButton::Draw( const Point& rAt,
      52             :                                const Size&  rSize,
      53             :                                bool         bState,
      54             :                                bool         bBtnIn  /* = false */ )
      55             : {
      56           1 :     if ( rSize.Width() == 0 || rSize.Height() == 0 )
      57           1 :         return;     // #i43092# rectangle with size 0 would have RECT_EMPTY as end position
      58             : 
      59             :     // save old state
      60           1 :     bool        bHadFill   = pOut->IsFillColor();
      61           1 :     Color       aOldFill   = pOut->GetFillColor();
      62           1 :     bool        bHadLine   = pOut->IsLineColor();
      63           1 :     Color       aOldLine   = pOut->GetLineColor();
      64           1 :     bool        bOldEnable = pOut->IsMapModeEnabled();
      65             : 
      66           1 :     Rectangle   aBtnRect( rAt, rSize );
      67           1 :     Rectangle   aInnerRect = aBtnRect;
      68             : 
      69           1 :     pOut->EnableMapMode( false );
      70             : 
      71           1 :     DecorationView aDecoView( pOut);
      72             : 
      73           1 :     DrawButtonFlags nButtonStyle = DrawButtonFlags::Default;
      74           1 :     if( bBtnIn )    // gedrueckt?
      75             :     {
      76           0 :         nButtonStyle = DrawButtonFlags::Pressed;
      77             :     }
      78             : 
      79           1 :     aInnerRect=aDecoView.DrawButton( aBtnRect, nButtonStyle );
      80             : 
      81           1 :     aInnerRect.Left()   += 1;
      82           1 :     aInnerRect.Top()    += 1;
      83           1 :     aInnerRect.Right()  -= 1;
      84           1 :     aInnerRect.Bottom() -= 1;
      85             : 
      86           1 :     Size  aInnerSize   = aInnerRect.GetSize();
      87           1 :     Point aInnerCenter = aInnerRect.Center();
      88             : 
      89           1 :     aInnerRect.Top()   = aInnerCenter.Y() - (aInnerSize.Width()>>1);
      90           1 :     aInnerRect.Bottom()= aInnerCenter.Y() + (aInnerSize.Width()>>1);
      91             : 
      92           1 :     ImpDrawArrow( aInnerRect, bState );
      93             : 
      94             :     // restore old state
      95           1 :     pOut->EnableMapMode( bOldEnable );
      96           1 :     if (bHadLine)
      97           0 :         pOut->SetLineColor(aOldLine);
      98             :     else
      99           1 :         pOut->SetLineColor();
     100           1 :     if (bHadFill)
     101           1 :         pOut->SetFillColor(aOldFill);
     102             :     else
     103           0 :         pOut->SetFillColor();
     104             : }
     105             : 
     106           1 : void ScDDComboBoxButton::ImpDrawArrow( const Rectangle& rRect,
     107             :                                        bool             bState )
     108             : {
     109             :     // no need to save old line and fill color here (is restored after the call)
     110             : 
     111           1 :     Rectangle   aPixRect = rRect;
     112           1 :     Point       aCenter  = aPixRect.Center();
     113           1 :     Size        aSize    = aPixRect.GetSize();
     114             : 
     115           1 :     Size aSize3;
     116           1 :     aSize3.Width() = aSize.Width() >> 1;
     117           1 :     aSize3.Height() = aSize.Height() >> 1;
     118             : 
     119           1 :     Size aSize4;
     120           1 :     aSize4.Width() = aSize.Width() >> 2;
     121           1 :     aSize4.Height() = aSize.Height() >> 2;
     122             : 
     123           1 :     Rectangle aTempRect = aPixRect;
     124             : 
     125           1 :     const StyleSettings& rSett = Application::GetSettings().GetStyleSettings();
     126           1 :     Color aColor( bState ? COL_LIGHTBLUE : rSett.GetButtonTextColor().GetColor() );
     127           1 :     pOut->SetFillColor( aColor );
     128           1 :     pOut->SetLineColor( aColor );
     129             : 
     130           1 :     aTempRect.Left()   = aCenter.X() - aSize4.Width();
     131           1 :     aTempRect.Right()  = aCenter.X() + aSize4.Width();
     132           1 :     aTempRect.Top()    = aCenter.Y() - aSize3.Height();
     133           1 :     aTempRect.Bottom() = aCenter.Y() - 1;
     134             : 
     135           1 :     pOut->DrawRect( aTempRect );
     136             : 
     137           1 :     Point aPos1( aCenter.X()-aSize3.Width(), aCenter.Y() );
     138           1 :     Point aPos2( aCenter.X()+aSize3.Width(), aCenter.Y() );
     139           6 :     while( aPos1.X() <= aPos2.X() )
     140             :     {
     141           4 :         pOut->DrawLine( aPos1, aPos2 );
     142           4 :         aPos1.X()++; aPos2.X()--;
     143           4 :         aPos1.Y()++; aPos2.Y()++;
     144             :     }
     145             : 
     146           3 :     pOut->DrawLine( Point( aCenter.X() - aSize3.Width(), aPos1.Y()+1 ),
     147           4 :                     Point( aCenter.X() + aSize3.Width(), aPos1.Y()+1 ) );
     148           1 : }
     149             : 
     150             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11