LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/cctrl - tbzoomsliderctrl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 236 0.4 %
Date: 2012-12-27 Functions: 1 19 5.3 %
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             : #include "tbzoomsliderctrl.hxx"
      20             : #include <vcl/image.hxx>
      21             : #include <vcl/toolbox.hxx>
      22             : #include <vcl/virdev.hxx>
      23             : #include <vcl/svapp.hxx>
      24             : #include <vcl/gradient.hxx>
      25             : #include <svl/itemset.hxx>
      26             : #include <sfx2/viewfrm.hxx>
      27             : #include <sfx2/objsh.hxx>
      28             : #include <svx/zoomslideritem.hxx>
      29             : #include <svx/dialmgr.hxx>
      30             : #include <svx/dialogs.hrc>
      31             : #include <set>
      32             : #include "docsh.hxx"
      33             : #include "stlpool.hxx"
      34             : #include "scitems.hxx"
      35             : #include "printfun.hxx"
      36             : 
      37             : //========================================================================
      38             : // class ScZoomSliderControl ---------------------------------------
      39             : //========================================================================
      40             : 
      41             : // -----------------------------------------------------------------------
      42             : 
      43           5 : SFX_IMPL_TOOLBOX_CONTROL( ScZoomSliderControl, SvxZoomSliderItem );
      44             : 
      45             : // -----------------------------------------------------------------------
      46             : 
      47           0 : ScZoomSliderControl::ScZoomSliderControl(
      48             :     sal_uInt16     nSlotId,
      49             :     sal_uInt16     nId,
      50             :     ToolBox&   rTbx )
      51           0 :     :SfxToolBoxControl( nSlotId, nId, rTbx )
      52             : {
      53           0 :     rTbx.Invalidate();
      54           0 : }
      55             : 
      56             : // -----------------------------------------------------------------------
      57             : 
      58           0 : ScZoomSliderControl::~ScZoomSliderControl()
      59             : {
      60             : 
      61           0 : }
      62             : 
      63             : // -----------------------------------------------------------------------
      64             : 
      65           0 : void ScZoomSliderControl::StateChanged( sal_uInt16 /*nSID*/, SfxItemState eState,
      66             :                                        const SfxPoolItem* pState )
      67             : {
      68           0 :     sal_uInt16                  nId  = GetId();
      69           0 :     ToolBox&                rTbx = GetToolBox();
      70           0 :     ScZoomSliderWnd*        pBox = (ScZoomSliderWnd*)(rTbx.GetItemWindow( nId ));
      71             :     OSL_ENSURE( pBox ,"Control not found!" );
      72             : 
      73           0 :     if ( SFX_ITEM_AVAILABLE != eState || pState->ISA( SfxVoidItem ) )
      74             :     {
      75           0 :         SvxZoomSliderItem aZoomSliderItem( 100 );
      76           0 :         pBox->Disable();
      77           0 :         pBox->UpdateFromItem( &aZoomSliderItem );
      78             :     }
      79             :     else
      80             :     {
      81           0 :         pBox->Enable();
      82             :         OSL_ENSURE( pState->ISA( SvxZoomSliderItem ), "invalid item type" );
      83           0 :         const SvxZoomSliderItem* pZoomSliderItem = dynamic_cast< const SvxZoomSliderItem* >( pState );
      84             : 
      85             :         OSL_ENSURE( pZoomSliderItem, "Sc::ScZoomSliderControl::StateChanged(), wrong item type!" );
      86           0 :         if( pZoomSliderItem )
      87           0 :             pBox->UpdateFromItem( pZoomSliderItem );
      88             :     }
      89           0 : }
      90             : 
      91             : // -----------------------------------------------------------------------
      92             : 
      93           0 : Window* ScZoomSliderControl::CreateItemWindow( Window *pParent )
      94             : {
      95             :     // #i98000# Don't try to get a value via SfxViewFrame::Current here.
      96             :     // The view's value is always notified via StateChanged later.
      97             :     ScZoomSliderWnd* pSlider    = new ScZoomSliderWnd( pParent,
      98           0 :         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >( m_xFrame->getController(),
      99           0 :         ::com::sun::star::uno::UNO_QUERY ), m_xFrame, 100 );
     100           0 :     return  pSlider;
     101             : }
     102             : 
     103             : // -----------------------------------------------------------------------
     104             : 
     105           0 : struct ScZoomSliderWnd::ScZoomSliderWnd_Impl
     106             : {
     107             :     sal_uInt16                   mnCurrentZoom;
     108             :     sal_uInt16                   mnMinZoom;
     109             :     sal_uInt16                   mnMaxZoom;
     110             :     sal_uInt16                   mnSliderCenter;
     111             :     std::vector< long >      maSnappingPointOffsets;
     112             :     std::vector< sal_uInt16 >    maSnappingPointZooms;
     113             :     Image                    maSliderButton;
     114             :     Image                    maIncreaseButton;
     115             :     Image                    maDecreaseButton;
     116             :     bool                     mbValuesSet;
     117             :     bool                     mbOmitPaint;
     118             : 
     119           0 :     ScZoomSliderWnd_Impl( sal_uInt16 nCurrentZoom ) :
     120             :         mnCurrentZoom( nCurrentZoom ),
     121             :         mnMinZoom( 10 ),
     122             :         mnMaxZoom( 400 ),
     123             :         mnSliderCenter( 100 ),
     124             :         maSnappingPointOffsets(),
     125             :         maSnappingPointZooms(),
     126             :         maSliderButton(),
     127             :         maIncreaseButton(),
     128             :         maDecreaseButton(),
     129             :         mbValuesSet( true ),
     130           0 :         mbOmitPaint( false )
     131             :         {
     132             : 
     133           0 :         }
     134             : };
     135             : 
     136             : // -----------------------------------------------------------------------
     137             : 
     138             : const long nButtonWidth     = 10;
     139             : const long nButtonHeight    = 10;
     140             : const long nIncDecWidth     = 11;
     141             : const long nIncDecHeight    = 11;
     142             : const long nSliderHeight    = 2;      //
     143             : const long nSliderWidth     = 4;      //
     144             : const long nSnappingHeight  = 4;
     145             : const long nSliderXOffset   = 20;
     146             : const long nSnappingEpsilon = 5; // snapping epsilon in pixels
     147             : const long nSnappingPointsMinDist = nSnappingEpsilon; // minimum distance of two adjacent snapping points
     148             : 
     149             : 
     150             : // -----------------------------------------------------------------------
     151             : 
     152           0 : sal_uInt16 ScZoomSliderWnd::Offset2Zoom( long nOffset ) const
     153             : {
     154           0 :     Size aSliderWindowSize = GetOutputSizePixel();
     155           0 :     const long nControlWidth = aSliderWindowSize.Width();
     156           0 :     sal_uInt16 nRet = 0;
     157             : 
     158           0 :     if( nOffset < nSliderXOffset )
     159           0 :         return mpImpl->mnMinZoom;
     160           0 :     if( nOffset > nControlWidth - nSliderXOffset )
     161           0 :         return mpImpl->mnMaxZoom;
     162             : 
     163             :     // check for snapping points:
     164           0 :     sal_uInt16 nCount = 0;
     165           0 :     std::vector< long >::iterator aSnappingPointIter;
     166           0 :     for ( aSnappingPointIter = mpImpl->maSnappingPointOffsets.begin();
     167           0 :         aSnappingPointIter != mpImpl->maSnappingPointOffsets.end();
     168             :         ++aSnappingPointIter )
     169             :     {
     170           0 :         const long nCurrent = *aSnappingPointIter;
     171           0 :         if ( Abs(nCurrent - nOffset) < nSnappingEpsilon )
     172             :         {
     173           0 :             nOffset = nCurrent;
     174           0 :             nRet = mpImpl->maSnappingPointZooms[ nCount ];
     175           0 :             break;
     176             :         }
     177           0 :         ++nCount;
     178             :     }
     179             : 
     180           0 :     if( 0 == nRet )
     181             :     {
     182           0 :         if( nOffset < nControlWidth / 2 )
     183             :         {
     184             :             // first half of slider
     185           0 :             const long nFirstHalfRange      = mpImpl->mnSliderCenter - mpImpl->mnMinZoom;
     186           0 :             const long nHalfSliderWidth     = nControlWidth/2 - nSliderXOffset;
     187           0 :             const long nZoomPerSliderPixel  = (1000 * nFirstHalfRange) / nHalfSliderWidth;
     188           0 :             const long nOffsetToSliderLeft  = nOffset - nSliderXOffset;
     189           0 :             nRet = mpImpl->mnMinZoom + sal_uInt16( nOffsetToSliderLeft * nZoomPerSliderPixel / 1000 );
     190             :         }
     191             :         else
     192             :         {
     193             :             // second half of slider
     194           0 :             const long nSecondHalfRange         = mpImpl->mnMaxZoom - mpImpl->mnSliderCenter;
     195           0 :             const long nHalfSliderWidth         = nControlWidth/2 - nSliderXOffset;
     196           0 :             const long nZoomPerSliderPixel      = 1000 * nSecondHalfRange / nHalfSliderWidth;
     197           0 :             const long nOffsetToSliderCenter    = nOffset - nControlWidth/2;
     198           0 :             nRet = mpImpl->mnSliderCenter + sal_uInt16( nOffsetToSliderCenter * nZoomPerSliderPixel / 1000 );
     199             :         }
     200             :     }
     201             : 
     202           0 :     if( nRet < mpImpl->mnMinZoom )
     203           0 :         return mpImpl->mnMinZoom;
     204             : 
     205           0 :     else if( nRet > mpImpl->mnMaxZoom )
     206           0 :         return mpImpl->mnMaxZoom;
     207             : 
     208           0 :     return nRet;
     209             : }
     210             : 
     211             : // -----------------------------------------------------------------------
     212             : 
     213           0 : long ScZoomSliderWnd::Zoom2Offset( sal_uInt16 nCurrentZoom ) const
     214             : {
     215           0 :     Size aSliderWindowSize = GetOutputSizePixel();
     216           0 :     const long nControlWidth = aSliderWindowSize.Width();
     217           0 :     long  nRect = nSliderXOffset;
     218             : 
     219           0 :     const long nHalfSliderWidth = nControlWidth/2 - nSliderXOffset;
     220           0 :     if( nCurrentZoom <= mpImpl->mnSliderCenter )
     221             :     {
     222           0 :         nCurrentZoom = nCurrentZoom - mpImpl->mnMinZoom;
     223           0 :         const long nFirstHalfRange = mpImpl->mnSliderCenter - mpImpl->mnMinZoom;
     224           0 :         const long nSliderPixelPerZoomPercent = 1000 * nHalfSliderWidth  / nFirstHalfRange;
     225           0 :         const long nOffset = (nSliderPixelPerZoomPercent * nCurrentZoom) / 1000;
     226           0 :         nRect += nOffset;
     227             :     }
     228             :     else
     229             :     {
     230           0 :         nCurrentZoom = nCurrentZoom - mpImpl->mnSliderCenter;
     231           0 :         const long nSecondHalfRange = mpImpl->mnMaxZoom - mpImpl->mnSliderCenter;
     232           0 :         const long nSliderPixelPerZoomPercent = 1000 * nHalfSliderWidth  / nSecondHalfRange;
     233           0 :         const long nOffset = (nSliderPixelPerZoomPercent * nCurrentZoom) / 1000;
     234           0 :         nRect += nHalfSliderWidth + nOffset;
     235             :     }
     236           0 :     return nRect;
     237             : }
     238             : 
     239             : // -----------------------------------------------------------------------
     240             : 
     241             : 
     242           0 : ScZoomSliderWnd::ScZoomSliderWnd( Window* pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& rDispatchProvider,
     243             :                 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _xFrame , sal_uInt16 nCurrentZoom ):
     244             :                 Window( pParent ),
     245           0 :                 mpImpl( new ScZoomSliderWnd_Impl( nCurrentZoom ) ),
     246             :                 aLogicalSize( 115, 40 ),
     247             :                 m_xDispatchProvider( rDispatchProvider ),
     248           0 :                 m_xFrame( _xFrame )
     249             : {
     250           0 :     mpImpl->maSliderButton      = Image( SVX_RES( RID_SVXBMP_SLIDERBUTTON   ) );
     251           0 :     mpImpl->maIncreaseButton    = Image( SVX_RES( RID_SVXBMP_SLIDERINCREASE ) );
     252           0 :     mpImpl->maDecreaseButton    = Image( SVX_RES( RID_SVXBMP_SLIDERDECREASE ) );
     253           0 :     Size  aSliderSize           = LogicToPixel( Size( aLogicalSize), MapMode( MAP_10TH_MM ) );
     254           0 :     SetSizePixel( Size( aSliderSize.Width() * nSliderWidth-1, aSliderSize.Height() + nSliderHeight ) );
     255           0 : }
     256             : 
     257             : // -----------------------------------------------------------------------
     258             : 
     259           0 : ScZoomSliderWnd::~ScZoomSliderWnd()
     260             : {
     261           0 :     delete mpImpl;
     262           0 : }
     263             : 
     264             : // -----------------------------------------------------------------------
     265             : 
     266           0 : void ScZoomSliderWnd::MouseButtonDown( const MouseEvent& rMEvt )
     267             : {
     268           0 :     if ( !mpImpl->mbValuesSet )
     269             :         return ;
     270           0 :     Size aSliderWindowSize = GetOutputSizePixel();
     271             : 
     272           0 :     const Point aPoint = rMEvt.GetPosPixel();
     273             : 
     274           0 :     const long nButtonLeftOffset    = ( nSliderXOffset - nIncDecWidth )/2;
     275           0 :     const long nButtonRightOffset   = ( nSliderXOffset + nIncDecWidth )/2;
     276             : 
     277           0 :     const long nOldZoom = mpImpl->mnCurrentZoom;
     278             : 
     279             :     // click to - button
     280           0 :     if ( aPoint.X() >= nButtonLeftOffset && aPoint.X() <= nButtonRightOffset )
     281             :     {
     282           0 :         mpImpl->mnCurrentZoom = mpImpl->mnCurrentZoom - 5;
     283             :     }
     284             :     // click to + button
     285           0 :     else if ( aPoint.X() >= aSliderWindowSize.Width() - nSliderXOffset + nButtonLeftOffset &&
     286           0 :               aPoint.X() <= aSliderWindowSize.Width() - nSliderXOffset + nButtonRightOffset )
     287             :     {
     288           0 :         mpImpl->mnCurrentZoom = mpImpl->mnCurrentZoom + 5;
     289             :     }
     290           0 :     else if( aPoint.X() >= nSliderXOffset && aPoint.X() <= aSliderWindowSize.Width() - nSliderXOffset )
     291             :     {
     292           0 :         mpImpl->mnCurrentZoom = Offset2Zoom( aPoint.X() );
     293             :     }
     294             : 
     295           0 :     if( mpImpl->mnCurrentZoom < mpImpl->mnMinZoom )
     296           0 :         mpImpl->mnCurrentZoom = mpImpl->mnMinZoom;
     297           0 :     else if( mpImpl->mnCurrentZoom > mpImpl->mnMaxZoom )
     298           0 :         mpImpl->mnCurrentZoom = mpImpl->mnMaxZoom;
     299             : 
     300           0 :     if( nOldZoom == mpImpl->mnCurrentZoom )
     301             :         return ;
     302             : 
     303           0 :     Rectangle aRect( Point( 0, 0 ), aSliderWindowSize );
     304             : 
     305           0 :     Paint( aRect );
     306           0 :     mpImpl->mbOmitPaint = true;
     307             : 
     308           0 :     SvxZoomSliderItem   aZoomSliderItem( mpImpl->mnCurrentZoom );
     309             : 
     310           0 :     ::com::sun::star::uno::Any  a;
     311           0 :     aZoomSliderItem.QueryValue( a );
     312             : 
     313           0 :     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
     314           0 :     aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScalingFactor" ));
     315           0 :     aArgs[0].Value = a;
     316             : 
     317           0 :     SfxToolBoxControl::Dispatch( m_xDispatchProvider, rtl::OUString(".uno:ScalingFactor"), aArgs );
     318             : 
     319           0 :     mpImpl->mbOmitPaint = false;
     320             : }
     321             : 
     322             : // -----------------------------------------------------------------------
     323             : 
     324           0 : void ScZoomSliderWnd::MouseMove( const MouseEvent& rMEvt )
     325             : {
     326           0 :     if ( !mpImpl->mbValuesSet )
     327           0 :         return ;
     328             : 
     329           0 :     Size aSliderWindowSize   = GetOutputSizePixel();
     330           0 :     const long nControlWidth = aSliderWindowSize.Width();
     331           0 :     const short nButtons     = rMEvt.GetButtons();
     332             : 
     333             :     // check mouse move with button pressed
     334           0 :     if ( 1 == nButtons )
     335             :     {
     336           0 :         const Point aPoint = rMEvt.GetPosPixel();
     337             : 
     338           0 :         if ( aPoint.X() >= nSliderXOffset && aPoint.X() <= nControlWidth - nSliderXOffset )
     339             :         {
     340           0 :             mpImpl->mnCurrentZoom = Offset2Zoom( aPoint.X() );
     341             : 
     342           0 :             Rectangle aRect( Point( 0, 0 ), aSliderWindowSize  );
     343           0 :             Paint( aRect );
     344             : 
     345           0 :             mpImpl->mbOmitPaint = true; // optimization: paint before executing command,
     346             : 
     347             :             // commit state change
     348           0 :             SvxZoomSliderItem aZoomSliderItem( mpImpl->mnCurrentZoom );
     349             : 
     350           0 :             ::com::sun::star::uno::Any a;
     351           0 :             aZoomSliderItem.QueryValue( a );
     352             : 
     353           0 :             ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
     354           0 :             aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScalingFactor" ));
     355           0 :             aArgs[0].Value = a;
     356             : 
     357           0 :             SfxToolBoxControl::Dispatch( m_xDispatchProvider, rtl::OUString(".uno:ScalingFactor"), aArgs );
     358             : 
     359           0 :             mpImpl->mbOmitPaint = false;
     360             :         }
     361             :     }
     362             : }
     363             : 
     364             : // -----------------------------------------------------------------------
     365             : 
     366           0 : void ScZoomSliderWnd::UpdateFromItem( const SvxZoomSliderItem* pZoomSliderItem )
     367             : {
     368           0 :     if( pZoomSliderItem )
     369             :     {
     370           0 :         mpImpl->mnCurrentZoom = pZoomSliderItem->GetValue();
     371           0 :         mpImpl->mnMinZoom     = pZoomSliderItem->GetMinZoom();
     372           0 :         mpImpl->mnMaxZoom     = pZoomSliderItem->GetMaxZoom();
     373             : 
     374             :         OSL_ENSURE( mpImpl->mnMinZoom <= mpImpl->mnCurrentZoom &&
     375             :             mpImpl->mnMinZoom <  mpImpl->mnSliderCenter &&
     376             :             mpImpl->mnMaxZoom >= mpImpl->mnCurrentZoom &&
     377             :             mpImpl->mnMaxZoom > mpImpl->mnSliderCenter,
     378             :             "Looks like the zoom slider item is corrupted" );
     379           0 :        const com::sun::star::uno::Sequence < sal_Int32 > rSnappingPoints = pZoomSliderItem->GetSnappingPoints();
     380           0 :        mpImpl->maSnappingPointOffsets.clear();
     381           0 :        mpImpl->maSnappingPointZooms.clear();
     382             : 
     383             :        // get all snapping points:
     384           0 :        std::set< sal_uInt16 > aTmpSnappingPoints;
     385           0 :        for ( sal_uInt16 j = 0; j < rSnappingPoints.getLength(); ++j )
     386             :        {
     387           0 :            const sal_Int32 nSnappingPoint = rSnappingPoints[j];
     388           0 :            aTmpSnappingPoints.insert( (sal_uInt16)nSnappingPoint );
     389             :        }
     390             : 
     391             :        // remove snapping points that are to close to each other:
     392           0 :        std::set< sal_uInt16 >::iterator aSnappingPointIter;
     393           0 :        long nLastOffset = 0;
     394             : 
     395           0 :        for ( aSnappingPointIter = aTmpSnappingPoints.begin(); aSnappingPointIter != aTmpSnappingPoints.end(); ++aSnappingPointIter )
     396             :        {
     397           0 :            const sal_uInt16 nCurrent = *aSnappingPointIter;
     398           0 :            const long nCurrentOffset = Zoom2Offset( nCurrent );
     399             : 
     400           0 :            if ( nCurrentOffset - nLastOffset >= nSnappingPointsMinDist )
     401             :            {
     402           0 :                mpImpl->maSnappingPointOffsets.push_back( nCurrentOffset );
     403           0 :                mpImpl->maSnappingPointZooms.push_back( nCurrent );
     404           0 :                nLastOffset = nCurrentOffset;
     405             :            }
     406           0 :        }
     407             :     }
     408             : 
     409           0 :     Size aSliderWindowSize = GetOutputSizePixel();
     410           0 :     Rectangle aRect( Point( 0, 0 ), aSliderWindowSize );
     411             : 
     412           0 :     if ( !mpImpl->mbOmitPaint )
     413           0 :        Paint(aRect);
     414           0 : }
     415             : 
     416             : // -----------------------------------------------------------------------
     417             : 
     418           0 : void ScZoomSliderWnd::Paint( const Rectangle& rRect )
     419             : {
     420           0 :     DoPaint( rRect );
     421           0 : }
     422             : 
     423             : // -----------------------------------------------------------------------
     424             : 
     425           0 : void ScZoomSliderWnd::DoPaint( const Rectangle& /*rRect*/ )
     426             : {
     427           0 :     if( mpImpl->mbOmitPaint )
     428           0 :         return;
     429             : 
     430           0 :     Size aSliderWindowSize = GetOutputSizePixel();
     431           0 :     Rectangle aRect( Point( 0, 0 ), aSliderWindowSize );
     432             : 
     433           0 :     VirtualDevice* pVDev = new VirtualDevice( *this );
     434           0 :     pVDev->SetOutputSizePixel( aSliderWindowSize );
     435             : 
     436           0 :     Rectangle   aSlider = aRect;
     437             : 
     438           0 :     aSlider.Top()     += ( aSliderWindowSize.Height() - nSliderHeight )/2 - 1;
     439           0 :     aSlider.Bottom()   = aSlider.Top() + nSliderHeight;
     440           0 :     aSlider.Left()    += nSliderXOffset;
     441           0 :     aSlider.Right()   -= nSliderXOffset;
     442             : 
     443           0 :     Rectangle aFirstLine( aSlider );
     444           0 :     aFirstLine.Bottom() = aFirstLine.Top();
     445             : 
     446           0 :     Rectangle aSecondLine( aSlider );
     447           0 :     aSecondLine.Top() = aSecondLine.Bottom();
     448             : 
     449           0 :     Rectangle aLeft( aSlider );
     450           0 :     aLeft.Right() = aLeft.Left();
     451             : 
     452           0 :     Rectangle aRight( aSlider );
     453           0 :     aRight.Left() = aRight.Right();
     454             : 
     455             :     // draw VirtualDevice's background color
     456           0 :     Color  aStartColor,aEndColor;
     457           0 :     aStartColor = GetSettings().GetStyleSettings().GetFaceColor();
     458           0 :     aEndColor   = GetSettings().GetStyleSettings().GetFaceColor();
     459           0 :     if( aEndColor.IsDark() )
     460           0 :         aStartColor = aEndColor;
     461             : 
     462           0 :     Gradient g;
     463           0 :     g.SetAngle( 0 );
     464           0 :     g.SetStyle( GradientStyle_LINEAR );
     465             : 
     466           0 :     g.SetStartColor( aStartColor );
     467           0 :     g.SetEndColor( aEndColor );
     468           0 :     pVDev->DrawGradient( aRect, g );
     469             : 
     470             :     // draw slider
     471           0 :     pVDev->SetLineColor( Color ( COL_WHITE ) );
     472           0 :     pVDev->DrawRect( aSecondLine );
     473           0 :     pVDev->DrawRect( aRight );
     474             : 
     475           0 :     pVDev->SetLineColor( Color( COL_GRAY ) );
     476           0 :     pVDev->DrawRect( aFirstLine );
     477           0 :     pVDev->DrawRect( aLeft );
     478             : 
     479             :     // draw snapping points:
     480           0 :     std::vector< long >::iterator aSnappingPointIter;
     481           0 :     for ( aSnappingPointIter = mpImpl->maSnappingPointOffsets.begin();
     482           0 :         aSnappingPointIter != mpImpl->maSnappingPointOffsets.end();
     483             :         ++aSnappingPointIter )
     484             :     {
     485           0 :         pVDev->SetLineColor( Color( COL_GRAY ) );
     486           0 :         Rectangle aSnapping( aRect );
     487           0 :         aSnapping.Bottom()   = aSlider.Top();
     488           0 :         aSnapping.Top() = aSnapping.Bottom() - nSnappingHeight;
     489           0 :         aSnapping.Left() += *aSnappingPointIter;
     490           0 :         aSnapping.Right() = aSnapping.Left();
     491           0 :         pVDev->DrawRect( aSnapping );
     492             : 
     493           0 :         aSnapping.Top() += nSnappingHeight + nSliderHeight;
     494           0 :         aSnapping.Bottom() += nSnappingHeight + nSliderHeight;
     495           0 :         pVDev->DrawRect( aSnapping );
     496             :     }
     497             : 
     498             :     // draw slider button
     499           0 :     Point aImagePoint = aRect.TopLeft();
     500           0 :     aImagePoint.X() += Zoom2Offset( mpImpl->mnCurrentZoom );
     501           0 :     aImagePoint.X() -= nButtonWidth/2;
     502           0 :     aImagePoint.Y() += ( aSliderWindowSize.Height() - nButtonHeight)/2;
     503           0 :     pVDev->DrawImage( aImagePoint, mpImpl->maSliderButton );
     504             : 
     505             :     // draw decrease button
     506           0 :     aImagePoint = aRect.TopLeft();
     507           0 :     aImagePoint.X() += (nSliderXOffset - nIncDecWidth)/2;
     508           0 :     aImagePoint.Y() += ( aSliderWindowSize.Height() - nIncDecHeight)/2;
     509           0 :     pVDev->DrawImage( aImagePoint, mpImpl->maDecreaseButton );
     510             : 
     511             :     // draw increase button
     512           0 :     aImagePoint.X() = aRect.TopLeft().X() + aSliderWindowSize.Width() - nIncDecWidth - (nSliderXOffset - nIncDecWidth)/2;
     513           0 :     pVDev->DrawImage( aImagePoint, mpImpl->maIncreaseButton );
     514             : 
     515           0 :     DrawOutDev( Point(0, 0), aSliderWindowSize, Point(0, 0), aSliderWindowSize, *pVDev );
     516             : 
     517           0 :     delete pVDev;
     518             : 
     519             : }
     520             : 
     521             : // -----------------------------------------------------------------------
     522             : 
     523             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10