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

Generated by: LCOV version 1.11