LCOV - code coverage report
Current view: top level - vcl/source/control - slider.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 514 0.0 %
Date: 2012-08-25 Functions: 0 29 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 529 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <tools/rc.h>
      31                 :            : #include <vcl/event.hxx>
      32                 :            : #include <vcl/decoview.hxx>
      33                 :            : #include <vcl/slider.hxx>
      34                 :            : #include "thumbpos.hxx"
      35                 :            : 
      36                 :            : // =======================================================================
      37                 :            : 
      38                 :            : #define SLIDER_DRAW_THUMB           ((sal_uInt16)0x0001)
      39                 :            : #define SLIDER_DRAW_CHANNEL1        ((sal_uInt16)0x0002)
      40                 :            : #define SLIDER_DRAW_CHANNEL2        ((sal_uInt16)0x0004)
      41                 :            : #define SLIDER_DRAW_CHANNEL         (SLIDER_DRAW_CHANNEL1 | SLIDER_DRAW_CHANNEL2)
      42                 :            : #define SLIDER_DRAW_ALL             (SLIDER_DRAW_THUMB | SLIDER_DRAW_CHANNEL)
      43                 :            : 
      44                 :            : #define SLIDER_STATE_CHANNEL1_DOWN  ((sal_uInt16)0x0001)
      45                 :            : #define SLIDER_STATE_CHANNEL2_DOWN  ((sal_uInt16)0x0002)
      46                 :            : #define SLIDER_STATE_THUMB_DOWN     ((sal_uInt16)0x0004)
      47                 :            : 
      48                 :            : #define SLIDER_THUMB_SIZE           9
      49                 :            : #define SLIDER_THUMB_HALFSIZE       4
      50                 :            : #define SLIDER_CHANNEL_OFFSET       0
      51                 :            : #define SLIDER_CHANNEL_SIZE         4
      52                 :            : #define SLIDER_CHANNEL_HALFSIZE     2
      53                 :            : 
      54                 :            : #define SLIDER_HEIGHT               16
      55                 :            : 
      56                 :            : #define SLIDER_VIEW_STYLE           (WB_3DLOOK | WB_HORZ | WB_VERT)
      57                 :            : 
      58                 :            : // =======================================================================
      59                 :            : 
      60                 :          0 : void Slider::ImplInit( Window* pParent, WinBits nStyle )
      61                 :            : {
      62                 :          0 :     mnThumbPixOffset    = 0;
      63                 :          0 :     mnThumbPixRange     = 0;
      64                 :          0 :     mnThumbPixPos       = 0;    // between mnThumbPixOffset and mnThumbPixOffset+mnThumbPixRange
      65                 :          0 :     mnChannelPixOffset  = 0;
      66                 :          0 :     mnChannelPixRange   = 0;
      67                 :          0 :     mnChannelPixTop     = 0;
      68                 :          0 :     mnChannelPixBottom  = 0;
      69                 :            : 
      70                 :          0 :     mnMinRange          = 0;
      71                 :          0 :     mnMaxRange          = 100;
      72                 :          0 :     mnThumbPos          = 0;
      73                 :          0 :     mnLineSize          = 1;
      74                 :          0 :     mnPageSize          = 1;
      75                 :          0 :     mnDelta             = 0;
      76                 :          0 :     mnDragDraw          = 0;
      77                 :          0 :     mnStateFlags        = 0;
      78                 :          0 :     meScrollType        = SCROLL_DONTKNOW;
      79                 :          0 :     mbCalcSize          = sal_True;
      80                 :          0 :     mbFullDrag          = sal_True;
      81                 :            : 
      82                 :          0 :     Control::ImplInit( pParent, nStyle, NULL );
      83                 :            : 
      84                 :          0 :     ImplInitSettings();
      85         [ #  # ]:          0 :     SetSizePixel( CalcWindowSizePixel() );
      86                 :          0 : }
      87                 :            : 
      88                 :            : // -----------------------------------------------------------------------
      89                 :            : 
      90                 :          0 : Slider::Slider( Window* pParent, WinBits nStyle ) :
      91 [ #  # ][ #  # ]:          0 :     Control( WINDOW_SLIDER )
         [ #  # ][ #  # ]
                 [ #  # ]
      92                 :            : {
      93         [ #  # ]:          0 :     ImplInit( pParent, nStyle );
      94                 :          0 : }
      95                 :            : 
      96                 :            : // -----------------------------------------------------------------------
      97                 :            : 
      98                 :          0 : void Slider::ImplInitSettings()
      99                 :            : {
     100                 :          0 :     Window* pParent = GetParent();
     101 [ #  # ][ #  # ]:          0 :     if ( pParent->IsChildTransparentModeEnabled() && !IsControlBackground() )
                 [ #  # ]
     102                 :            :     {
     103                 :          0 :         EnableChildTransparentMode( sal_True );
     104                 :          0 :         SetParentClipMode( PARENTCLIPMODE_NOCLIP );
     105                 :          0 :         SetPaintTransparent( sal_True );
     106                 :          0 :         SetBackground();
     107                 :            :     }
     108                 :            :     else
     109                 :            :     {
     110                 :          0 :         EnableChildTransparentMode( sal_False );
     111                 :          0 :         SetParentClipMode( 0 );
     112                 :          0 :         SetPaintTransparent( sal_False );
     113                 :            : 
     114         [ #  # ]:          0 :         if ( IsControlBackground() )
     115 [ #  # ][ #  # ]:          0 :             SetBackground( GetControlBackground() );
                 [ #  # ]
     116                 :            :         else
     117                 :          0 :             SetBackground( pParent->GetBackground() );
     118                 :            :     }
     119                 :          0 : }
     120                 :            : 
     121                 :            : // -----------------------------------------------------------------------
     122                 :            : 
     123                 :          0 : void Slider::ImplUpdateRects( sal_Bool bUpdate )
     124                 :            : {
     125                 :          0 :     Rectangle aOldThumbRect = maThumbRect;
     126                 :          0 :     bool bInvalidateAll = false;
     127                 :            : 
     128         [ #  # ]:          0 :     if ( mnThumbPixRange )
     129                 :            :     {
     130 [ #  # ][ #  # ]:          0 :         if ( GetStyle() & WB_HORZ )
     131                 :            :         {
     132                 :          0 :             maThumbRect.Left()      = mnThumbPixPos-SLIDER_THUMB_HALFSIZE;
     133                 :          0 :             maThumbRect.Right()     = maThumbRect.Left()+SLIDER_THUMB_SIZE-1;
     134         [ #  # ]:          0 :             if ( mnChannelPixOffset < maThumbRect.Left() )
     135                 :            :             {
     136                 :          0 :                 maChannel1Rect.Left()   = mnChannelPixOffset;
     137                 :          0 :                 maChannel1Rect.Right()  = maThumbRect.Left()-1;
     138                 :          0 :                 maChannel1Rect.Top()    = mnChannelPixTop;
     139                 :          0 :                 maChannel1Rect.Bottom() = mnChannelPixBottom;
     140                 :            :             }
     141                 :            :             else
     142                 :          0 :                 maChannel1Rect.SetEmpty();
     143         [ #  # ]:          0 :             if ( mnChannelPixOffset+mnChannelPixRange-1 > maThumbRect.Right() )
     144                 :            :             {
     145                 :          0 :                 maChannel2Rect.Left()   = maThumbRect.Right()+1;
     146                 :          0 :                 maChannel2Rect.Right()  = mnChannelPixOffset+mnChannelPixRange-1;
     147                 :          0 :                 maChannel2Rect.Top()    = mnChannelPixTop;
     148                 :          0 :                 maChannel2Rect.Bottom() = mnChannelPixBottom;
     149                 :            :             }
     150                 :            :             else
     151                 :          0 :                 maChannel2Rect.SetEmpty();
     152                 :            : 
     153         [ #  # ]:          0 :             const Rectangle aControlRegion( Rectangle( Point(0,0), Size( SLIDER_THUMB_SIZE, 10 ) ) );
     154 [ #  # ][ #  # ]:          0 :             Rectangle aThumbBounds, aThumbContent;
     155         [ #  # ]:          0 :             if ( GetNativeControlRegion( CTRL_SLIDER, PART_THUMB_HORZ,
     156                 :            :                                          aControlRegion, 0, ImplControlValue(), rtl::OUString(),
     157 [ #  # ][ #  # ]:          0 :                                          aThumbBounds, aThumbContent ) )
     158                 :            :             {
     159         [ #  # ]:          0 :                 maThumbRect.Left() = mnThumbPixPos - aThumbBounds.GetWidth()/2;
     160         [ #  # ]:          0 :                 maThumbRect.Right() = maThumbRect.Left() + aThumbBounds.GetWidth() - 1;
     161                 :          0 :                 bInvalidateAll = true;
     162                 :            :             }
     163                 :            :         }
     164                 :            :         else
     165                 :            :         {
     166                 :          0 :             maThumbRect.Top()       = mnThumbPixPos-SLIDER_THUMB_HALFSIZE;
     167                 :          0 :             maThumbRect.Bottom()    = maThumbRect.Top()+SLIDER_THUMB_SIZE-1;
     168         [ #  # ]:          0 :             if ( mnChannelPixOffset < maThumbRect.Top() )
     169                 :            :             {
     170                 :          0 :                 maChannel1Rect.Top()    = mnChannelPixOffset;
     171                 :          0 :                 maChannel1Rect.Bottom() = maThumbRect.Top()-1;
     172                 :          0 :                 maChannel1Rect.Left()   = mnChannelPixTop;
     173                 :          0 :                 maChannel1Rect.Right()  = mnChannelPixBottom;
     174                 :            :             }
     175                 :            :             else
     176                 :          0 :                 maChannel1Rect.SetEmpty();
     177         [ #  # ]:          0 :             if ( mnChannelPixOffset+mnChannelPixRange-1 > maThumbRect.Bottom() )
     178                 :            :             {
     179                 :          0 :                 maChannel2Rect.Top()    = maThumbRect.Bottom()+1;
     180                 :          0 :                 maChannel2Rect.Bottom() = mnChannelPixOffset+mnChannelPixRange-1;
     181                 :          0 :                 maChannel2Rect.Left()   = mnChannelPixTop;
     182                 :          0 :                 maChannel2Rect.Right()  = mnChannelPixBottom;
     183                 :            :             }
     184                 :            :             else
     185                 :          0 :                 maChannel2Rect.SetEmpty();
     186                 :            : 
     187         [ #  # ]:          0 :             const Rectangle aControlRegion( Rectangle( Point(0,0), Size( 10, SLIDER_THUMB_SIZE ) ) );
     188 [ #  # ][ #  # ]:          0 :             Rectangle aThumbBounds, aThumbContent;
     189         [ #  # ]:          0 :             if ( GetNativeControlRegion( CTRL_SLIDER, PART_THUMB_VERT,
     190                 :            :                                          aControlRegion, 0, ImplControlValue(), rtl::OUString(),
     191 [ #  # ][ #  # ]:          0 :                                          aThumbBounds, aThumbContent ) )
     192                 :            :             {
     193         [ #  # ]:          0 :                 maThumbRect.Top() = mnThumbPixPos - aThumbBounds.GetHeight()/2;
     194         [ #  # ]:          0 :                 maThumbRect.Bottom() = maThumbRect.Top() + aThumbBounds.GetHeight() - 1;
     195                 :          0 :                 bInvalidateAll = true;
     196                 :            :             }
     197                 :            :         }
     198                 :            :     }
     199                 :            :     else
     200                 :            :     {
     201                 :          0 :         maChannel1Rect.SetEmpty();
     202                 :          0 :         maChannel2Rect.SetEmpty();
     203                 :          0 :         maThumbRect.SetEmpty();
     204                 :            :     }
     205                 :            : 
     206         [ #  # ]:          0 :     if ( bUpdate )
     207                 :            :     {
     208 [ #  # ][ #  # ]:          0 :         if ( aOldThumbRect != maThumbRect )
     209                 :            :         {
     210         [ #  # ]:          0 :             if( bInvalidateAll )
     211         [ #  # ]:          0 :                 Invalidate();
     212                 :            :             else
     213                 :            :             {
     214         [ #  # ]:          0 :                 Region aInvalidRegion( aOldThumbRect );
     215         [ #  # ]:          0 :                 aInvalidRegion.Union( maThumbRect );
     216                 :            : 
     217 [ #  # ][ #  # ]:          0 :                 if( !IsBackground() && GetParent() )
         [ #  # ][ #  # ]
     218                 :            :                 {
     219         [ #  # ]:          0 :                     const Point aPos( GetPosPixel() );
     220         [ #  # ]:          0 :                     aInvalidRegion.Move( aPos.X(), aPos.Y() );
     221 [ #  # ][ #  # ]:          0 :                     GetParent()->Invalidate( aInvalidRegion, INVALIDATE_TRANSPARENT | INVALIDATE_UPDATE );
     222                 :            :                 }
     223                 :            :                 else
     224 [ #  # ][ #  # ]:          0 :                     Invalidate( aInvalidRegion );
     225                 :            :             }
     226                 :            :         }
     227                 :            :     }
     228                 :          0 : }
     229                 :            : 
     230                 :            : // -----------------------------------------------------------------------
     231                 :            : 
     232                 :          0 : long Slider::ImplCalcThumbPos( long nPixPos )
     233                 :            : {
     234                 :            :     // Position berechnen
     235                 :            :     long nCalcThumbPos;
     236                 :          0 :     nCalcThumbPos = ImplMulDiv( nPixPos-mnThumbPixOffset, mnMaxRange-mnMinRange, mnThumbPixRange-1 );
     237                 :          0 :     nCalcThumbPos += mnMinRange;
     238                 :          0 :     return nCalcThumbPos;
     239                 :            : }
     240                 :            : 
     241                 :            : // -----------------------------------------------------------------------
     242                 :            : 
     243                 :          0 : long Slider::ImplCalcThumbPosPix( long nPos )
     244                 :            : {
     245                 :            :     // Position berechnen
     246                 :            :     long nCalcThumbPos;
     247                 :          0 :     nCalcThumbPos = ImplMulDiv( nPos-mnMinRange, mnThumbPixRange-1, mnMaxRange-mnMinRange );
     248                 :            :     // Am Anfang und Ende des Sliders versuchen wir die Anzeige korrekt
     249                 :            :     // anzuzeigen
     250 [ #  # ][ #  # ]:          0 :     if ( !nCalcThumbPos && (mnThumbPos > mnMinRange) )
     251                 :          0 :         nCalcThumbPos = 1;
     252 [ #  # ][ #  # ]:          0 :     if ( nCalcThumbPos &&
                 [ #  # ]
     253                 :            :          (nCalcThumbPos == mnThumbPixRange-1) &&
     254                 :            :          (mnThumbPos < mnMaxRange) )
     255                 :          0 :         nCalcThumbPos--;
     256                 :          0 :     return nCalcThumbPos+mnThumbPixOffset;
     257                 :            : }
     258                 :            : 
     259                 :            : // -----------------------------------------------------------------------
     260                 :            : 
     261                 :          0 : void Slider::ImplCalc( sal_Bool bUpdate )
     262                 :            : {
     263                 :          0 :     sal_Bool bInvalidateAll = sal_False;
     264                 :            : 
     265         [ #  # ]:          0 :     if ( mbCalcSize )
     266                 :            :     {
     267                 :          0 :         long nOldChannelPixOffset   = mnChannelPixOffset;
     268                 :          0 :         long nOldChannelPixRange    = mnChannelPixRange;
     269                 :          0 :         long nOldChannelPixTop      = mnChannelPixTop;
     270                 :          0 :         long nOldChannelPixBottom   = mnChannelPixBottom;
     271                 :            :         long nCalcWidth;
     272                 :            :         long nCalcHeight;
     273                 :            : 
     274                 :          0 :         maChannel1Rect.SetEmpty();
     275                 :          0 :         maChannel2Rect.SetEmpty();
     276                 :          0 :         maThumbRect.SetEmpty();
     277                 :            : 
     278                 :          0 :         Size aSize = GetOutputSizePixel();
     279 [ #  # ][ #  # ]:          0 :         if ( GetStyle() & WB_HORZ )
     280                 :            :         {
     281                 :          0 :             nCalcWidth          = aSize.Width();
     282                 :          0 :             nCalcHeight         = aSize.Height();
     283                 :          0 :             maThumbRect.Top()   = 0;
     284                 :          0 :             maThumbRect.Bottom()= aSize.Height()-1;
     285                 :            :         }
     286                 :            :         else
     287                 :            :         {
     288                 :          0 :             nCalcWidth          = aSize.Height();
     289                 :          0 :             nCalcHeight         = aSize.Width();
     290                 :          0 :             maThumbRect.Left()  = 0;
     291                 :          0 :             maThumbRect.Right() = aSize.Width()-1;
     292                 :            :         }
     293                 :            : 
     294         [ #  # ]:          0 :         if ( nCalcWidth >= SLIDER_THUMB_SIZE )
     295                 :            :         {
     296                 :          0 :             mnThumbPixOffset    = SLIDER_THUMB_HALFSIZE;
     297                 :          0 :             mnThumbPixRange     = nCalcWidth-(SLIDER_THUMB_HALFSIZE*2);
     298                 :          0 :             mnThumbPixPos       = 0;
     299                 :          0 :             mnChannelPixOffset  = SLIDER_CHANNEL_OFFSET;
     300                 :          0 :             mnChannelPixRange   = nCalcWidth-(SLIDER_CHANNEL_OFFSET*2);
     301                 :          0 :             mnChannelPixTop     = (nCalcHeight/2)-SLIDER_CHANNEL_HALFSIZE;
     302                 :          0 :             mnChannelPixBottom  = mnChannelPixTop+SLIDER_CHANNEL_SIZE-1;
     303                 :            :         }
     304                 :            :         else
     305                 :            :         {
     306                 :          0 :             mnThumbPixRange = 0;
     307                 :          0 :             mnChannelPixRange = 0;
     308                 :            :         }
     309                 :            : 
     310 [ #  # ][ #  # ]:          0 :         if ( (nOldChannelPixOffset != mnChannelPixOffset) ||
         [ #  # ][ #  # ]
     311                 :            :              (nOldChannelPixRange != mnChannelPixRange) ||
     312                 :            :              (nOldChannelPixTop != mnChannelPixTop) ||
     313                 :            :              (nOldChannelPixBottom != mnChannelPixBottom) )
     314                 :          0 :             bInvalidateAll = sal_True;
     315                 :            : 
     316                 :          0 :         mbCalcSize = sal_False;
     317                 :            :     }
     318                 :            : 
     319         [ #  # ]:          0 :     if ( mnThumbPixRange )
     320                 :          0 :         mnThumbPixPos = ImplCalcThumbPosPix( mnThumbPos );
     321                 :            : 
     322 [ #  # ][ #  # ]:          0 :     if ( bUpdate && bInvalidateAll )
     323                 :            :     {
     324                 :          0 :         Invalidate();
     325                 :          0 :         bUpdate = sal_False;
     326                 :            :     }
     327                 :          0 :     ImplUpdateRects( bUpdate );
     328                 :          0 : }
     329                 :            : 
     330                 :            : // -----------------------------------------------------------------------
     331                 :            : 
     332                 :          0 : void Slider::ImplDraw( sal_uInt16 nDrawFlags )
     333                 :            : {
     334                 :          0 :     DecorationView          aDecoView( this );
     335                 :            :     sal_uInt16                  nStyle;
     336                 :          0 :     const StyleSettings&    rStyleSettings = GetSettings().GetStyleSettings();
     337         [ #  # ]:          0 :     sal_Bool                    bEnabled = IsEnabled();
     338                 :            : 
     339                 :            :     // Evt. noch offene Berechnungen nachholen
     340         [ #  # ]:          0 :     if ( mbCalcSize )
     341         [ #  # ]:          0 :         ImplCalc( sal_False );
     342                 :            : 
     343 [ #  # ][ #  # ]:          0 :     ControlPart nPart = (GetStyle() & WB_HORZ) ? PART_TRACK_HORZ_AREA : PART_TRACK_VERT_AREA;
     344 [ #  # ][ #  # ]:          0 :     ControlState   nState = ( IsEnabled() ? CTRL_STATE_ENABLED : 0 ) | ( HasFocus() ? CTRL_STATE_FOCUSED : 0 );
         [ #  # ][ #  # ]
     345         [ #  # ]:          0 :     SliderValue    sldValue;
     346                 :            : 
     347                 :          0 :     sldValue.mnMin       = mnMinRange;
     348                 :          0 :     sldValue.mnMax       = mnMaxRange;
     349                 :          0 :     sldValue.mnCur       = mnThumbPos;
     350                 :          0 :     sldValue.maThumbRect = maThumbRect;
     351                 :            : 
     352 [ #  # ][ #  # ]:          0 :     if( IsMouseOver() )
     353                 :            :     {
     354 [ #  # ][ #  # ]:          0 :         if( maThumbRect.IsInside( GetPointerPosPixel() ) )
                 [ #  # ]
     355                 :          0 :             sldValue.mnThumbState |= CTRL_STATE_ROLLOVER;
     356                 :            :     }
     357                 :            : 
     358         [ #  # ]:          0 :     const Rectangle aCtrlRegion( Point(0,0), GetOutputSizePixel() );
     359                 :            :     bool bNativeOK = DrawNativeControl( CTRL_SLIDER, nPart,
     360         [ #  # ]:          0 :                                         aCtrlRegion, nState, sldValue, rtl::OUString() );
     361         [ #  # ]:          0 :     if( bNativeOK )
     362                 :          0 :         return;
     363                 :            : 
     364 [ #  # ][ #  # ]:          0 :     if ( (nDrawFlags & SLIDER_DRAW_CHANNEL1) && !maChannel1Rect.IsEmpty() )
         [ #  # ][ #  # ]
     365                 :            :     {
     366                 :            :         long        nRectSize;
     367                 :          0 :         Rectangle   aRect = maChannel1Rect;
     368         [ #  # ]:          0 :         SetLineColor( rStyleSettings.GetShadowColor() );
     369 [ #  # ][ #  # ]:          0 :         if ( GetStyle() & WB_HORZ )
     370                 :            :         {
     371         [ #  # ]:          0 :             DrawLine( aRect.TopLeft(), Point( aRect.Left(), aRect.Bottom()-1 ) );
     372 [ #  # ][ #  # ]:          0 :             DrawLine( aRect.TopLeft(), aRect.TopRight() );
     373                 :            :         }
     374                 :            :         else
     375                 :            :         {
     376         [ #  # ]:          0 :             DrawLine( aRect.TopLeft(), Point( aRect.Right()-1, aRect.Top() ) );
     377 [ #  # ][ #  # ]:          0 :             DrawLine( aRect.TopLeft(), aRect.BottomLeft() );
     378                 :            :         }
     379         [ #  # ]:          0 :         SetLineColor( rStyleSettings.GetLightColor() );
     380 [ #  # ][ #  # ]:          0 :         if ( GetStyle() & WB_HORZ )
     381                 :            :         {
     382 [ #  # ][ #  # ]:          0 :             DrawLine( aRect.BottomLeft(), aRect.BottomRight() );
                 [ #  # ]
     383         [ #  # ]:          0 :             nRectSize = aRect.GetWidth();
     384                 :            :         }
     385                 :            :         else
     386                 :            :         {
     387 [ #  # ][ #  # ]:          0 :             DrawLine( aRect.TopRight(), aRect.BottomRight() );
                 [ #  # ]
     388         [ #  # ]:          0 :             nRectSize = aRect.GetHeight();
     389                 :            :         }
     390                 :            : 
     391         [ #  # ]:          0 :         if ( nRectSize > 1 )
     392                 :            :         {
     393                 :          0 :             aRect.Left()++;
     394                 :          0 :             aRect.Top()++;
     395 [ #  # ][ #  # ]:          0 :             if ( GetStyle() & WB_HORZ )
     396                 :          0 :                 aRect.Bottom()--;
     397                 :            :             else
     398                 :          0 :                 aRect.Right()--;
     399         [ #  # ]:          0 :             SetLineColor();
     400         [ #  # ]:          0 :             if ( mnStateFlags & SLIDER_STATE_CHANNEL1_DOWN )
     401         [ #  # ]:          0 :                 SetFillColor( rStyleSettings.GetShadowColor() );
     402                 :            :             else
     403         [ #  # ]:          0 :                 SetFillColor( rStyleSettings.GetCheckedColor() );
     404         [ #  # ]:          0 :             DrawRect( aRect );
     405                 :            :         }
     406                 :            :     }
     407                 :            : 
     408 [ #  # ][ #  # ]:          0 :     if ( (nDrawFlags & SLIDER_DRAW_CHANNEL2) && !maChannel2Rect.IsEmpty() )
         [ #  # ][ #  # ]
     409                 :            :     {
     410                 :            :         long        nRectSize;
     411                 :          0 :         Rectangle   aRect = maChannel2Rect;
     412         [ #  # ]:          0 :         SetLineColor( rStyleSettings.GetLightColor() );
     413 [ #  # ][ #  # ]:          0 :         if ( GetStyle() & WB_HORZ )
     414                 :            :         {
     415 [ #  # ][ #  # ]:          0 :             DrawLine( aRect.TopRight(), aRect.BottomRight() );
                 [ #  # ]
     416 [ #  # ][ #  # ]:          0 :             DrawLine( aRect.BottomLeft(), aRect.BottomRight() );
                 [ #  # ]
     417         [ #  # ]:          0 :             nRectSize = aRect.GetWidth();
     418                 :            :         }
     419                 :            :         else
     420                 :            :         {
     421 [ #  # ][ #  # ]:          0 :             DrawLine( aRect.BottomLeft(), aRect.BottomRight() );
                 [ #  # ]
     422 [ #  # ][ #  # ]:          0 :             DrawLine( aRect.TopRight(), aRect.BottomRight() );
                 [ #  # ]
     423         [ #  # ]:          0 :             nRectSize = aRect.GetHeight();
     424                 :            :         }
     425                 :            : 
     426         [ #  # ]:          0 :         if ( nRectSize > 1 )
     427                 :            :         {
     428         [ #  # ]:          0 :             SetLineColor( rStyleSettings.GetShadowColor() );
     429 [ #  # ][ #  # ]:          0 :             if ( GetStyle() & WB_HORZ )
     430         [ #  # ]:          0 :                 DrawLine( aRect.TopLeft(), Point( aRect.Right()-1, aRect.Top() ) );
     431                 :            :             else
     432         [ #  # ]:          0 :                 DrawLine( aRect.TopLeft(), Point( aRect.Left(), aRect.Bottom()-1 ) );
     433                 :            : 
     434                 :          0 :             aRect.Right()--;
     435                 :          0 :             aRect.Bottom()--;
     436 [ #  # ][ #  # ]:          0 :             if ( GetStyle() & WB_HORZ )
     437                 :          0 :                 aRect.Top()++;
     438                 :            :             else
     439                 :          0 :                 aRect.Left()++;
     440         [ #  # ]:          0 :             SetLineColor();
     441         [ #  # ]:          0 :             if ( mnStateFlags & SLIDER_STATE_CHANNEL2_DOWN )
     442         [ #  # ]:          0 :                 SetFillColor( rStyleSettings.GetShadowColor() );
     443                 :            :             else
     444         [ #  # ]:          0 :                 SetFillColor( rStyleSettings.GetCheckedColor() );
     445         [ #  # ]:          0 :             DrawRect( aRect );
     446                 :            :         }
     447                 :            :     }
     448                 :            : 
     449         [ #  # ]:          0 :     if ( nDrawFlags & SLIDER_DRAW_THUMB )
     450                 :            :     {
     451 [ #  # ][ #  # ]:          0 :         if ( !maThumbRect.IsEmpty() )
     452                 :            :         {
     453         [ #  # ]:          0 :             if ( bEnabled )
     454                 :            :             {
     455                 :          0 :                 nStyle = 0;
     456         [ #  # ]:          0 :                 if ( mnStateFlags & SLIDER_STATE_THUMB_DOWN )
     457                 :          0 :                     nStyle |= BUTTON_DRAW_PRESSED;
     458         [ #  # ]:          0 :                 aDecoView.DrawButton( maThumbRect, nStyle );
     459                 :            :             }
     460                 :            :             else
     461                 :            :             {
     462         [ #  # ]:          0 :                 SetLineColor( rStyleSettings.GetShadowColor() );
     463         [ #  # ]:          0 :                 SetFillColor( rStyleSettings.GetCheckedColor() );
     464         [ #  # ]:          0 :                 DrawRect( maThumbRect );
     465                 :            :             }
     466                 :            :         }
     467 [ #  # ][ #  # ]:          0 :     }
     468                 :            : }
     469                 :            : 
     470                 :            : // -----------------------------------------------------------------------
     471                 :            : 
     472                 :          0 : sal_Bool Slider::ImplIsPageUp( const Point& rPos )
     473                 :            : {
     474                 :          0 :     Size aSize = GetOutputSizePixel();
     475                 :          0 :     Rectangle aRect = maChannel1Rect;
     476 [ #  # ][ #  # ]:          0 :     if ( GetStyle() & WB_HORZ )
     477                 :            :     {
     478                 :          0 :         aRect.Top()     = 0;
     479                 :          0 :         aRect.Bottom()  = aSize.Height()-1;
     480                 :            :     }
     481                 :            :     else
     482                 :            :     {
     483                 :          0 :         aRect.Left()    = 0;
     484                 :          0 :         aRect.Right()   = aSize.Width()-1;
     485                 :            :     }
     486         [ #  # ]:          0 :     return aRect.IsInside( rPos );
     487                 :            : }
     488                 :            : 
     489                 :            : // -----------------------------------------------------------------------
     490                 :            : 
     491                 :          0 : sal_Bool Slider::ImplIsPageDown( const Point& rPos )
     492                 :            : {
     493                 :          0 :     Size aSize = GetOutputSizePixel();
     494                 :          0 :     Rectangle aRect = maChannel2Rect;
     495 [ #  # ][ #  # ]:          0 :     if ( GetStyle() & WB_HORZ )
     496                 :            :     {
     497                 :          0 :         aRect.Top()     = 0;
     498                 :          0 :         aRect.Bottom()  = aSize.Height()-1;
     499                 :            :     }
     500                 :            :     else
     501                 :            :     {
     502                 :          0 :         aRect.Left()    = 0;
     503                 :          0 :         aRect.Right()   = aSize.Width()-1;
     504                 :            :     }
     505         [ #  # ]:          0 :     return aRect.IsInside( rPos );
     506                 :            : }
     507                 :            : 
     508                 :            : // -----------------------------------------------------------------------
     509                 :            : 
     510                 :          0 : long Slider::ImplSlide( long nNewPos, sal_Bool bCallEndSlide )
     511                 :            : {
     512                 :          0 :     long nOldPos = mnThumbPos;
     513                 :          0 :     SetThumbPos( nNewPos );
     514                 :          0 :     long nDelta = mnThumbPos-nOldPos;
     515         [ #  # ]:          0 :     if ( nDelta )
     516                 :            :     {
     517                 :          0 :         mnDelta = nDelta;
     518                 :          0 :         Slide();
     519         [ #  # ]:          0 :         if ( bCallEndSlide )
     520                 :          0 :             EndSlide();
     521                 :          0 :         mnDelta = 0;
     522                 :            :     }
     523                 :          0 :     return nDelta;
     524                 :            : }
     525                 :            : 
     526                 :            : // -----------------------------------------------------------------------
     527                 :            : 
     528                 :          0 : long Slider::ImplDoAction( sal_Bool bCallEndSlide )
     529                 :            : {
     530                 :          0 :     long nDelta = 0;
     531                 :            : 
     532   [ #  #  #  #  :          0 :     switch ( meScrollType )
                   #  # ]
     533                 :            :     {
     534                 :            :         case SCROLL_LINEUP:
     535                 :          0 :             nDelta = ImplSlide( mnThumbPos-mnLineSize, bCallEndSlide );
     536                 :          0 :             break;
     537                 :            : 
     538                 :            :         case SCROLL_LINEDOWN:
     539                 :          0 :             nDelta = ImplSlide( mnThumbPos+mnLineSize, bCallEndSlide );
     540                 :          0 :             break;
     541                 :            : 
     542                 :            :         case SCROLL_PAGEUP:
     543                 :          0 :             nDelta = ImplSlide( mnThumbPos-mnPageSize, bCallEndSlide );
     544                 :          0 :             break;
     545                 :            : 
     546                 :            :         case SCROLL_PAGEDOWN:
     547                 :          0 :             nDelta = ImplSlide( mnThumbPos+mnPageSize, bCallEndSlide );
     548                 :          0 :             break;
     549                 :            : 
     550                 :            :         case SCROLL_SET:
     551         [ #  # ]:          0 :             nDelta = ImplSlide( ImplCalcThumbPos( GetPointerPosPixel().X() ), bCallEndSlide );
     552                 :          0 :             break;
     553                 :            :         default:
     554                 :          0 :             break;
     555                 :            :     }
     556                 :            : 
     557                 :          0 :     return nDelta;
     558                 :            : }
     559                 :            : 
     560                 :            : // -----------------------------------------------------------------------
     561                 :            : 
     562                 :          0 : void Slider::ImplDoMouseAction( const Point& rMousePos, sal_Bool bCallAction )
     563                 :            : {
     564                 :          0 :     sal_uInt16  nOldStateFlags = mnStateFlags;
     565                 :          0 :     sal_Bool    bAction = sal_False;
     566                 :            : 
     567   [ #  #  #  # ]:          0 :     switch ( meScrollType )
     568                 :            :     {
     569                 :            :         case( SCROLL_SET ):
     570                 :            :         {
     571                 :          0 :             const bool bUp = ImplIsPageUp( rMousePos ), bDown = ImplIsPageDown( rMousePos );
     572                 :            : 
     573 [ #  # ][ #  # ]:          0 :             if ( bUp || bDown )
     574                 :            :             {
     575                 :          0 :                 bAction = bCallAction;
     576         [ #  # ]:          0 :                 mnStateFlags |= ( bUp ? SLIDER_STATE_CHANNEL1_DOWN : SLIDER_STATE_CHANNEL2_DOWN );
     577                 :            :             }
     578                 :            :             else
     579                 :          0 :                 mnStateFlags &= ~( SLIDER_STATE_CHANNEL1_DOWN | SLIDER_STATE_CHANNEL2_DOWN );
     580                 :          0 :             break;
     581                 :            :         }
     582                 :            : 
     583                 :            :         case SCROLL_PAGEUP:
     584         [ #  # ]:          0 :             if ( ImplIsPageUp( rMousePos ) )
     585                 :            :             {
     586                 :          0 :                 bAction = bCallAction;
     587                 :          0 :                 mnStateFlags |= SLIDER_STATE_CHANNEL1_DOWN;
     588                 :            :             }
     589                 :            :             else
     590                 :          0 :                 mnStateFlags &= ~SLIDER_STATE_CHANNEL1_DOWN;
     591                 :          0 :             break;
     592                 :            : 
     593                 :            :         case SCROLL_PAGEDOWN:
     594         [ #  # ]:          0 :             if ( ImplIsPageDown( rMousePos ) )
     595                 :            :             {
     596                 :          0 :                 bAction = bCallAction;
     597                 :          0 :                 mnStateFlags |= SLIDER_STATE_CHANNEL2_DOWN;
     598                 :            :             }
     599                 :            :             else
     600                 :          0 :                 mnStateFlags &= ~SLIDER_STATE_CHANNEL2_DOWN;
     601                 :          0 :             break;
     602                 :            :         default:
     603                 :          0 :             break;
     604                 :            :     }
     605                 :            : 
     606         [ #  # ]:          0 :     if ( bAction )
     607                 :            :     {
     608         [ #  # ]:          0 :         if ( ImplDoAction( sal_False ) )
     609                 :            :         {
     610                 :            :             // Update the channel complete
     611         [ #  # ]:          0 :             if ( mnDragDraw & SLIDER_DRAW_CHANNEL )
     612                 :            :             {
     613                 :          0 :                 Update();
     614                 :          0 :                 ImplDraw( mnDragDraw );
     615                 :            :             }
     616                 :            :         }
     617                 :            :     }
     618         [ #  # ]:          0 :     else if ( nOldStateFlags != mnStateFlags )
     619                 :          0 :         ImplDraw( mnDragDraw );
     620                 :          0 : }
     621                 :            : 
     622                 :            : // -----------------------------------------------------------------------
     623                 :            : 
     624                 :          0 : long Slider::ImplDoSlide( long nNewPos )
     625                 :            : {
     626         [ #  # ]:          0 :     if ( meScrollType != SCROLL_DONTKNOW )
     627                 :          0 :         return 0;
     628                 :            : 
     629                 :          0 :     meScrollType = SCROLL_DRAG;
     630                 :          0 :     long nDelta = ImplSlide( nNewPos, sal_True );
     631                 :          0 :     meScrollType = SCROLL_DONTKNOW;
     632                 :          0 :     return nDelta;
     633                 :            : }
     634                 :            : 
     635                 :            : // -----------------------------------------------------------------------
     636                 :            : 
     637                 :          0 : long Slider::ImplDoSlideAction( ScrollType eScrollType )
     638                 :            : {
     639 [ #  # ][ #  # ]:          0 :     if ( (meScrollType != SCROLL_DONTKNOW) ||
                 [ #  # ]
     640                 :            :          (eScrollType == SCROLL_DONTKNOW) ||
     641                 :            :          (eScrollType == SCROLL_DRAG) )
     642                 :          0 :         return 0;
     643                 :            : 
     644                 :          0 :     meScrollType = eScrollType;
     645                 :          0 :     long nDelta = ImplDoAction( sal_True );
     646                 :          0 :     meScrollType = SCROLL_DONTKNOW;
     647                 :          0 :     return nDelta;
     648                 :            : }
     649                 :            : 
     650                 :            : // -----------------------------------------------------------------------
     651                 :            : 
     652                 :          0 : void Slider::MouseButtonDown( const MouseEvent& rMEvt )
     653                 :            : {
     654         [ #  # ]:          0 :     if ( rMEvt.IsLeft() )
     655                 :            :     {
     656                 :          0 :         const Point&    rMousePos = rMEvt.GetPosPixel();
     657                 :          0 :         sal_uInt16          nTrackFlags = 0;
     658                 :            : 
     659         [ #  # ]:          0 :         if ( maThumbRect.IsInside( rMousePos ) )
     660                 :            :         {
     661                 :          0 :             nTrackFlags     = 0;
     662                 :          0 :             meScrollType    = SCROLL_DRAG;
     663                 :          0 :             mnDragDraw      = SLIDER_DRAW_THUMB;
     664                 :            : 
     665                 :            :             // Zusaetzliche Daten berechnen
     666         [ #  # ]:          0 :             Point aCenterPos = maThumbRect.Center();
     667 [ #  # ][ #  # ]:          0 :             if ( GetStyle() & WB_HORZ )
     668                 :          0 :                 mnMouseOff = rMousePos.X()-aCenterPos.X();
     669                 :            :             else
     670                 :          0 :                 mnMouseOff = rMousePos.Y()-aCenterPos.Y();
     671                 :            :         }
     672         [ #  # ]:          0 :         else if ( ImplIsPageUp( rMousePos ) )
     673                 :            :         {
     674         [ #  # ]:          0 :             if( GetStyle() & WB_SLIDERSET )
     675                 :          0 :                 meScrollType = SCROLL_SET;
     676                 :            :             else
     677                 :            :             {
     678                 :          0 :                 nTrackFlags = STARTTRACK_BUTTONREPEAT;
     679                 :          0 :                 meScrollType = SCROLL_PAGEUP;
     680                 :            :             }
     681                 :            : 
     682                 :          0 :             mnDragDraw = SLIDER_DRAW_CHANNEL;
     683                 :            :         }
     684         [ #  # ]:          0 :         else if ( ImplIsPageDown( rMousePos ) )
     685                 :            :         {
     686         [ #  # ]:          0 :             if( GetStyle() & WB_SLIDERSET )
     687                 :          0 :                 meScrollType = SCROLL_SET;
     688                 :            :             else
     689                 :            :             {
     690                 :          0 :                 nTrackFlags = STARTTRACK_BUTTONREPEAT;
     691                 :          0 :                 meScrollType = SCROLL_PAGEDOWN;
     692                 :            :             }
     693                 :            : 
     694                 :          0 :             mnDragDraw = SLIDER_DRAW_CHANNEL;
     695                 :            :         }
     696                 :            : 
     697                 :            :         // Soll Tracking gestartet werden
     698         [ #  # ]:          0 :         if( meScrollType != SCROLL_DONTKNOW )
     699                 :            :         {
     700                 :            :             // Startposition merken fuer Abbruch und EndScroll-Delta
     701                 :          0 :             mnStartPos = mnThumbPos;
     702                 :          0 :             ImplDoMouseAction( rMousePos, meScrollType != SCROLL_SET );
     703                 :          0 :             Update();
     704                 :            : 
     705         [ #  # ]:          0 :             if( meScrollType != SCROLL_SET )
     706                 :          0 :                 StartTracking( nTrackFlags );
     707                 :            :         }
     708                 :            :     }
     709                 :          0 : }
     710                 :            : 
     711                 :            : // -----------------------------------------------------------------------
     712                 :            : 
     713                 :          0 : void Slider::MouseButtonUp( const MouseEvent& )
     714                 :            : {
     715         [ #  # ]:          0 :     if( SCROLL_SET == meScrollType )
     716                 :            :     {
     717                 :            :         // Button und PageRect-Status wieder herstellen
     718                 :          0 :         const sal_uInt16 nOldStateFlags = mnStateFlags;
     719                 :            : 
     720                 :          0 :         mnStateFlags &= ~( SLIDER_STATE_CHANNEL1_DOWN | SLIDER_STATE_CHANNEL2_DOWN | SLIDER_STATE_THUMB_DOWN );
     721                 :            : 
     722         [ #  # ]:          0 :         if ( nOldStateFlags != mnStateFlags )
     723                 :          0 :             ImplDraw( mnDragDraw );
     724                 :            : 
     725                 :          0 :         mnDragDraw = 0;
     726                 :          0 :         ImplDoAction( sal_True );
     727                 :          0 :         meScrollType = SCROLL_DONTKNOW;
     728                 :            :     }
     729                 :          0 : }
     730                 :            : 
     731                 :            : // -----------------------------------------------------------------------
     732                 :            : 
     733                 :          0 : void Slider::Tracking( const TrackingEvent& rTEvt )
     734                 :            : {
     735         [ #  # ]:          0 :     if ( rTEvt.IsTrackingEnded() )
     736                 :            :     {
     737                 :            :         // Button und PageRect-Status wieder herstellen
     738                 :          0 :         sal_uInt16 nOldStateFlags = mnStateFlags;
     739                 :            :         mnStateFlags &= ~(SLIDER_STATE_CHANNEL1_DOWN | SLIDER_STATE_CHANNEL2_DOWN |
     740                 :          0 :                           SLIDER_STATE_THUMB_DOWN);
     741         [ #  # ]:          0 :         if ( nOldStateFlags != mnStateFlags )
     742                 :          0 :             ImplDraw( mnDragDraw );
     743                 :          0 :         mnDragDraw = 0;
     744                 :            : 
     745                 :            :         // Bei Abbruch, die alte ThumbPosition wieder herstellen
     746         [ #  # ]:          0 :         if ( rTEvt.IsTrackingCanceled() )
     747                 :            :         {
     748                 :          0 :             long nOldPos = mnThumbPos;
     749                 :          0 :             SetThumbPos( mnStartPos );
     750                 :          0 :             mnDelta = mnThumbPos-nOldPos;
     751                 :          0 :             Slide();
     752                 :            :         }
     753                 :            : 
     754         [ #  # ]:          0 :         if ( meScrollType == SCROLL_DRAG )
     755                 :            :         {
     756                 :            :             // Wenn gedragt wurde, berechnen wir den Thumb neu, damit
     757                 :            :             // er wieder auf einer gerundeten ThumbPosition steht
     758                 :          0 :             ImplCalc();
     759                 :          0 :             Update();
     760                 :            : 
     761 [ #  # ][ #  # ]:          0 :             if ( !mbFullDrag && (mnStartPos != mnThumbPos) )
     762                 :            :             {
     763                 :          0 :                 mnDelta = mnThumbPos-mnStartPos;
     764                 :          0 :                 Slide();
     765                 :          0 :                 mnDelta = 0;
     766                 :            :             }
     767                 :            :         }
     768                 :            : 
     769                 :          0 :         mnDelta = mnThumbPos-mnStartPos;
     770                 :          0 :         EndSlide();
     771                 :          0 :         mnDelta = 0;
     772                 :          0 :         meScrollType = SCROLL_DONTKNOW;
     773                 :            :     }
     774                 :            :     else
     775                 :            :     {
     776                 :          0 :         const Point rMousePos = rTEvt.GetMouseEvent().GetPosPixel();
     777                 :            : 
     778                 :            :         // Dragging wird speziell behandelt
     779         [ #  # ]:          0 :         if ( meScrollType == SCROLL_DRAG )
     780                 :            :         {
     781                 :            :             long nMovePix;
     782         [ #  # ]:          0 :             Point aCenterPos = maThumbRect.Center();
     783 [ #  # ][ #  # ]:          0 :             if ( GetStyle() & WB_HORZ )
     784                 :          0 :                 nMovePix = rMousePos.X()-(aCenterPos.X()+mnMouseOff);
     785                 :            :             else
     786                 :          0 :                 nMovePix = rMousePos.Y()-(aCenterPos.Y()+mnMouseOff);
     787                 :            :             // Nur wenn sich Maus in die Scrollrichtung bewegt, muessen
     788                 :            :             // wir etwas tun
     789         [ #  # ]:          0 :             if ( nMovePix )
     790                 :            :             {
     791                 :          0 :                 mnThumbPixPos += nMovePix;
     792         [ #  # ]:          0 :                 if ( mnThumbPixPos < mnThumbPixOffset )
     793                 :          0 :                     mnThumbPixPos = mnThumbPixOffset;
     794         [ #  # ]:          0 :                 if ( mnThumbPixPos > (mnThumbPixOffset+mnThumbPixRange-1) )
     795                 :          0 :                     mnThumbPixPos = mnThumbPixOffset+mnThumbPixRange-1;
     796                 :          0 :                 long nOldPos = mnThumbPos;
     797                 :          0 :                 mnThumbPos = ImplCalcThumbPos( mnThumbPixPos );
     798         [ #  # ]:          0 :                 if ( nOldPos != mnThumbPos )
     799                 :            :                 {
     800         [ #  # ]:          0 :                     ImplUpdateRects();
     801         [ #  # ]:          0 :                     Update();
     802 [ #  # ][ #  # ]:          0 :                     if ( mbFullDrag && (nOldPos != mnThumbPos) )
     803                 :            :                     {
     804                 :          0 :                         mnDelta = mnThumbPos-nOldPos;
     805         [ #  # ]:          0 :                         Slide();
     806                 :          0 :                         mnDelta = 0;
     807                 :            :                     }
     808                 :            :                 }
     809                 :            :             }
     810                 :            :         }
     811                 :            :         else
     812         [ #  # ]:          0 :             ImplDoMouseAction( rMousePos, rTEvt.IsTrackingRepeat() );
     813                 :            : 
     814                 :            :         // Wenn Slider-Werte so umgesetzt wurden, das es nichts
     815                 :            :         // mehr zum Tracking gibt, dann berechen wir hier ab
     816 [ #  # ][ #  # ]:          0 :         if ( !IsVisible() )
     817         [ #  # ]:          0 :             EndTracking();
     818                 :            :     }
     819                 :          0 : }
     820                 :            : 
     821                 :            : // -----------------------------------------------------------------------
     822                 :            : 
     823                 :          0 : void Slider::KeyInput( const KeyEvent& rKEvt )
     824                 :            : {
     825         [ #  # ]:          0 :     if ( !rKEvt.GetKeyCode().GetModifier() )
     826                 :            :     {
     827   [ #  #  #  #  :          0 :         switch ( rKEvt.GetKeyCode().GetCode() )
                #  #  # ]
     828                 :            :         {
     829                 :            :             case KEY_HOME:
     830                 :          0 :                 ImplDoSlide( GetRangeMin() );
     831                 :          0 :                 break;
     832                 :            :             case KEY_END:
     833                 :          0 :                 ImplDoSlide( GetRangeMax() );
     834                 :          0 :                 break;
     835                 :            : 
     836                 :            :             case KEY_LEFT:
     837                 :            :             case KEY_UP:
     838                 :          0 :                 ImplDoSlideAction( SCROLL_LINEUP );
     839                 :          0 :                 break;
     840                 :            : 
     841                 :            :             case KEY_RIGHT:
     842                 :            :             case KEY_DOWN:
     843                 :          0 :                 ImplDoSlideAction( SCROLL_LINEDOWN );
     844                 :          0 :                 break;
     845                 :            : 
     846                 :            :             case KEY_PAGEUP:
     847                 :          0 :                 ImplDoSlideAction( SCROLL_PAGEUP );
     848                 :          0 :                 break;
     849                 :            : 
     850                 :            :             case KEY_PAGEDOWN:
     851                 :          0 :                 ImplDoSlideAction( SCROLL_PAGEDOWN );
     852                 :          0 :                 break;
     853                 :            : 
     854                 :            :             default:
     855                 :          0 :                 Control::KeyInput( rKEvt );
     856                 :          0 :                 break;
     857                 :            :         }
     858                 :            :     }
     859                 :            :     else
     860                 :          0 :         Control::KeyInput( rKEvt );
     861                 :          0 : }
     862                 :            : 
     863                 :            : // -----------------------------------------------------------------------
     864                 :            : 
     865                 :          0 : void Slider::Paint( const Rectangle& )
     866                 :            : {
     867                 :          0 :     ImplDraw( SLIDER_DRAW_ALL );
     868                 :          0 : }
     869                 :            : 
     870                 :            : // -----------------------------------------------------------------------
     871                 :            : 
     872                 :          0 : void Slider::Resize()
     873                 :            : {
     874                 :          0 :     Control::Resize();
     875                 :          0 :     mbCalcSize = sal_True;
     876         [ #  # ]:          0 :     if ( IsReallyVisible() )
     877                 :          0 :         ImplCalc( sal_False );
     878                 :          0 :     Invalidate();
     879                 :          0 : }
     880                 :            : 
     881                 :            : // -----------------------------------------------------------------------
     882                 :            : 
     883                 :          0 : void Slider::RequestHelp( const HelpEvent& rHEvt )
     884                 :            : {
     885                 :          0 :     Control::RequestHelp( rHEvt );
     886                 :          0 : }
     887                 :            : 
     888                 :            : // -----------------------------------------------------------------------
     889                 :            : 
     890                 :          0 : void Slider::StateChanged( StateChangedType nType )
     891                 :            : {
     892                 :          0 :     Control::StateChanged( nType );
     893                 :            : 
     894         [ #  # ]:          0 :     if ( nType == STATE_CHANGE_INITSHOW )
     895                 :          0 :         ImplCalc( sal_False );
     896         [ #  # ]:          0 :     else if ( nType == STATE_CHANGE_DATA )
     897                 :            :     {
     898 [ #  # ][ #  # ]:          0 :         if ( IsReallyVisible() && IsUpdateMode() )
                 [ #  # ]
     899                 :          0 :             ImplCalc( sal_True );
     900                 :            :     }
     901         [ #  # ]:          0 :     else if ( nType == STATE_CHANGE_UPDATEMODE )
     902                 :            :     {
     903 [ #  # ][ #  # ]:          0 :         if ( IsReallyVisible() && IsUpdateMode() )
                 [ #  # ]
     904                 :            :         {
     905                 :          0 :             ImplCalc( sal_False );
     906                 :          0 :             Invalidate();
     907                 :            :         }
     908                 :            :     }
     909         [ #  # ]:          0 :     else if ( nType == STATE_CHANGE_ENABLE )
     910                 :            :     {
     911 [ #  # ][ #  # ]:          0 :         if ( IsReallyVisible() && IsUpdateMode() )
                 [ #  # ]
     912                 :          0 :             Invalidate();
     913                 :            :     }
     914         [ #  # ]:          0 :     else if ( nType == STATE_CHANGE_STYLE )
     915                 :            :     {
     916 [ #  # ][ #  # ]:          0 :         if ( IsReallyVisible() && IsUpdateMode() )
                 [ #  # ]
     917                 :            :         {
     918         [ #  # ]:          0 :             if ( (GetPrevStyle() & SLIDER_VIEW_STYLE) !=
     919                 :          0 :                  (GetStyle() & SLIDER_VIEW_STYLE) )
     920                 :            :             {
     921                 :          0 :                 mbCalcSize = sal_True;
     922                 :          0 :                 ImplCalc( sal_False );
     923                 :          0 :                 Invalidate();
     924                 :            :             }
     925                 :            :         }
     926                 :            :     }
     927         [ #  # ]:          0 :     else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
     928                 :            :     {
     929                 :          0 :         ImplInitSettings();
     930                 :          0 :         Invalidate();
     931                 :            :     }
     932                 :          0 : }
     933                 :            : 
     934                 :            : // -----------------------------------------------------------------------
     935                 :            : 
     936                 :          0 : void Slider::DataChanged( const DataChangedEvent& rDCEvt )
     937                 :            : {
     938                 :          0 :     Control::DataChanged( rDCEvt );
     939                 :            : 
     940         [ #  # ]:          0 :     if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
           [ #  #  #  # ]
     941                 :          0 :          (rDCEvt.GetFlags() & SETTINGS_STYLE) )
     942                 :            :     {
     943                 :          0 :         ImplInitSettings();
     944                 :          0 :         Invalidate();
     945                 :            :     }
     946                 :          0 : }
     947                 :            : 
     948                 :            : // -----------------------------------------------------------------------
     949                 :            : 
     950                 :          0 : void Slider::Slide()
     951                 :            : {
     952                 :          0 :     maSlideHdl.Call( this );
     953                 :          0 : }
     954                 :            : 
     955                 :            : // -----------------------------------------------------------------------
     956                 :            : 
     957                 :          0 : void Slider::EndSlide()
     958                 :            : {
     959                 :          0 :     maEndSlideHdl.Call( this );
     960                 :          0 : }
     961                 :            : 
     962                 :            : // -----------------------------------------------------------------------
     963                 :            : 
     964                 :          0 : void Slider::SetRange( const Range& rRange )
     965                 :            : {
     966                 :            :     // Range einpassen
     967                 :          0 :     Range aRange = rRange;
     968                 :          0 :     aRange.Justify();
     969                 :          0 :     long nNewMinRange = aRange.Min();
     970                 :          0 :     long nNewMaxRange = aRange.Max();
     971                 :            : 
     972                 :            :     // Wenn Range sich unterscheidet, dann neuen setzen
     973 [ #  # ][ #  # ]:          0 :     if ( (mnMinRange != nNewMinRange) ||
     974                 :            :          (mnMaxRange != nNewMaxRange) )
     975                 :            :     {
     976                 :          0 :         mnMinRange = nNewMinRange;
     977                 :          0 :         mnMaxRange = nNewMaxRange;
     978                 :            : 
     979                 :            :         // Thumb einpassen
     980         [ #  # ]:          0 :         if ( mnThumbPos > mnMaxRange )
     981                 :          0 :             mnThumbPos = mnMaxRange;
     982         [ #  # ]:          0 :         if ( mnThumbPos < mnMinRange )
     983                 :          0 :             mnThumbPos = mnMinRange;
     984                 :            : 
     985         [ #  # ]:          0 :         StateChanged( STATE_CHANGE_DATA );
     986                 :            :     }
     987                 :          0 : }
     988                 :            : 
     989                 :            : // -----------------------------------------------------------------------
     990                 :            : 
     991                 :          0 : void Slider::SetThumbPos( long nNewThumbPos )
     992                 :            : {
     993         [ #  # ]:          0 :     if ( nNewThumbPos < mnMinRange )
     994                 :          0 :         nNewThumbPos = mnMinRange;
     995         [ #  # ]:          0 :     if ( nNewThumbPos > mnMaxRange )
     996                 :          0 :         nNewThumbPos = mnMaxRange;
     997                 :            : 
     998         [ #  # ]:          0 :     if ( mnThumbPos != nNewThumbPos )
     999                 :            :     {
    1000                 :          0 :         mnThumbPos = nNewThumbPos;
    1001                 :          0 :         StateChanged( STATE_CHANGE_DATA );
    1002                 :            :     }
    1003                 :          0 : }
    1004                 :            : 
    1005                 :            : // -----------------------------------------------------------------------
    1006                 :            : 
    1007                 :          0 : Size Slider::CalcWindowSizePixel()
    1008                 :            : {
    1009                 :          0 :     long nWidth = mnMaxRange-mnMinRange+(SLIDER_THUMB_HALFSIZE*2)+1;
    1010                 :          0 :     long nHeight = SLIDER_HEIGHT;
    1011                 :          0 :     Size aSize;
    1012         [ #  # ]:          0 :     if ( GetStyle() & WB_HORZ )
    1013                 :            :     {
    1014                 :          0 :         aSize.Width()   = nWidth;
    1015                 :          0 :         aSize.Height()  = nHeight;
    1016                 :            :     }
    1017                 :            :     else
    1018                 :            :     {
    1019                 :          0 :         aSize.Height()  = nWidth;
    1020                 :          0 :         aSize.Width()   = nHeight;
    1021                 :            :     }
    1022                 :          0 :     return aSize;
    1023                 :            : }
    1024                 :            : 
    1025                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10