LCOV - code coverage report
Current view: top level - include/vcl - spin.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 8 10 80.0 %
Date: 2015-06-13 12:38:46 Functions: 7 9 77.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_VCL_SPIN_HXX
      21             : #define INCLUDED_VCL_SPIN_HXX
      22             : 
      23             : #include <tools/solar.h>
      24             : #include <vcl/dllapi.h>
      25             : #include <vcl/ctrl.hxx>
      26             : #include <vcl/timer.hxx>
      27             : 
      28             : 
      29             : // - SpinButton -
      30             : 
      31             : 
      32           2 : class VCL_DLLPUBLIC SpinButton : public Control
      33             : {
      34             : private:
      35             :     AutoTimer       maRepeatTimer;
      36             :     Rectangle       maUpperRect;
      37             :     Rectangle       maLowerRect;
      38             :     Rectangle       maFocusRect;
      39             :     bool            mbRepeat         : 1;
      40             :     bool            mbUpperIn        : 1;
      41             :     bool            mbLowerIn        : 1;
      42             :     bool            mbInitialUp      : 1;
      43             :     bool            mbInitialDown    : 1;
      44             :     bool            mbHorz           : 1;
      45             :     bool            mbUpperIsFocused : 1;
      46             :     Link<>          maUpHdlLink;
      47             :     Link<>          maDownHdlLink;
      48             :     long            mnMinRange;
      49             :     long            mnMaxRange;
      50             :     long            mnValue;
      51             :     long            mnValueStep;
      52             : 
      53             :     SAL_DLLPRIVATE Rectangle* ImplFindPartRect( const Point& rPt );
      54             :     using Window::ImplInit;
      55             :     SAL_DLLPRIVATE void       ImplInit( vcl::Window* pParent, WinBits nStyle );
      56             :     DECL_DLLPRIVATE_LINK_TYPED( ImplTimeout, Timer*, void );
      57             : 
      58             : public:
      59             :     explicit        SpinButton( vcl::Window* pParent, WinBits nStyle = 0 );
      60             : 
      61             :     void            Up();
      62             :     void            Down();
      63             : 
      64             :     virtual void    Resize() SAL_OVERRIDE;
      65             :     virtual void    Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
      66             :     virtual void    Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawFlags nFlags ) SAL_OVERRIDE;
      67             :     virtual void    MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
      68             :     virtual void    MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
      69             :     virtual void    MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
      70             :     virtual void    KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
      71             :     virtual void    StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
      72             :     virtual void    GetFocus() SAL_OVERRIDE;
      73             :     virtual void    LoseFocus() SAL_OVERRIDE;
      74             : 
      75             :     void            SetRangeMin( long nNewRange );
      76           1 :     long            GetRangeMin() const { return mnMinRange; }
      77             :     void            SetRangeMax( long nNewRange );
      78           1 :     long            GetRangeMax() const { return mnMaxRange; }
      79             :     void            SetRange( const Range& rRange );
      80             :     Range           GetRange() const { return Range( GetRangeMin(), GetRangeMax() ); }
      81             :     void            SetValue( long nValue );
      82           0 :     long            GetValue() const { return mnValue; }
      83           1 :     void            SetValueStep( long nNewStep ) { mnValueStep = nNewStep; }
      84           0 :     long            GetValueStep() const { return mnValueStep; }
      85             :     virtual bool    PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
      86             : 
      87             :     void            SetUpHdl( const Link<>& rLink ) { maUpHdlLink = rLink; }
      88             :     const Link<>&   GetUpHdl() const   { return maUpHdlLink;   }
      89             :     void            SetDownHdl( const Link<>& rLink ) { maDownHdlLink = rLink; }
      90             :     const Link<>&   GetDownHdl() const { return maDownHdlLink; }
      91             : 
      92             : private:
      93             :     // moves the focus to the upper or lower rect. Return sal_True if the focus rect actually changed.
      94             :     SAL_DLLPRIVATE bool        ImplMoveFocus( bool _bUpper );
      95             :     SAL_DLLPRIVATE void        ImplCalcFocusRect( bool _bUpper );
      96             : 
      97           6 :     SAL_DLLPRIVATE inline bool ImplIsUpperEnabled( ) const
      98             :     {
      99           6 :         return mnValue + mnValueStep <= mnMaxRange;
     100             :     }
     101           4 :     SAL_DLLPRIVATE inline bool ImplIsLowerEnabled( ) const
     102             :     {
     103           4 :         return mnValue >= mnMinRange + mnValueStep;
     104             :     }
     105             : };
     106             : 
     107             : #endif // INCLUDED_VCL_SPIN_HXX
     108             : 
     109             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11