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

Generated by: LCOV version 1.10