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

Generated by: LCOV version 1.10