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

Generated by: LCOV version 1.10