bump product version to 4.2.0.1
[LibreOffice.git] / include / vcl / spin.hxx
blobc7b50b2ae1389eb586e22ab43b3c94ae50ff9612
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_SPIN_HXX
21 #define INCLUDED_VCL_SPIN_HXX
23 #include <tools/solar.h>
24 #include <vcl/dllapi.h>
25 #include <vcl/ctrl.hxx>
26 #include <vcl/timer.hxx>
28 // --------------
29 // - SpinButton -
30 // --------------
32 class VCL_DLLPUBLIC SpinButton : public Control
34 private:
35 AutoTimer maRepeatTimer;
36 Rectangle maUpperRect;
37 Rectangle maLowerRect;
38 Rectangle maFocusRect;
39 sal_Bool mbRepeat : 1;
40 sal_Bool mbUpperIn : 1;
41 sal_Bool mbLowerIn : 1;
42 sal_Bool mbInitialUp : 1;
43 sal_Bool mbInitialDown : 1;
44 sal_Bool mbHorz : 1;
45 sal_Bool mbUpperIsFocused : 1;
46 Link maUpHdlLink;
47 Link maDownHdlLink;
48 long mnMinRange;
49 long mnMaxRange;
50 long mnValue;
51 long mnValueStep;
53 SAL_DLLPRIVATE Rectangle* ImplFindPartRect( const Point& rPt );
54 using Window::ImplInit;
55 SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
56 DECL_DLLPRIVATE_LINK( ImplTimeout, Timer* );
58 public:
59 explicit SpinButton( Window* pParent, WinBits nStyle = 0 );
60 virtual ~SpinButton();
62 virtual void Up();
63 virtual void Down();
65 virtual void Resize();
66 virtual void Paint( const Rectangle& rRect );
67 virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
68 virtual void MouseButtonDown( const MouseEvent& rMEvt );
69 virtual void MouseButtonUp( const MouseEvent& rMEvt );
70 virtual void MouseMove( const MouseEvent& rMEvt );
71 virtual void KeyInput( const KeyEvent& rKEvt );
72 virtual void StateChanged( StateChangedType nStateChange );
73 virtual void GetFocus();
74 virtual void LoseFocus();
76 void SetRangeMin( long nNewRange );
77 long GetRangeMin() const { return mnMinRange; }
78 void SetRangeMax( long nNewRange );
79 long GetRangeMax() const { return mnMaxRange; }
80 void SetRange( const Range& rRange );
81 Range GetRange() const { return Range( GetRangeMin(), GetRangeMax() ); }
82 void SetValue( long nValue );
83 long GetValue() const { return mnValue; }
84 void SetValueStep( long nNewStep ) { mnValueStep = nNewStep; }
85 long GetValueStep() const { return mnValueStep; }
86 virtual long PreNotify( NotifyEvent& rNEvt );
88 void SetUpHdl( const Link& rLink ) { maUpHdlLink = rLink; }
89 const Link& GetUpHdl() const { return maUpHdlLink; }
90 void SetDownHdl( const Link& rLink ) { maDownHdlLink = rLink; }
91 const Link& GetDownHdl() const { return maDownHdlLink; }
93 private:
94 // moves the focus to the upper or lower rect. Return sal_True if the focus rect actually changed.
95 SAL_DLLPRIVATE sal_Bool ImplMoveFocus( sal_Bool _bUpper );
96 SAL_DLLPRIVATE void ImplCalcFocusRect( sal_Bool _bUpper );
98 SAL_DLLPRIVATE inline sal_Bool ImplIsUpperEnabled( ) const
100 return mnValue + mnValueStep <= mnMaxRange;
102 SAL_DLLPRIVATE inline sal_Bool ImplIsLowerEnabled( ) const
104 return mnValue >= mnMinRange + mnValueStep;
108 #endif // INCLUDED_VCL_SPIN_HXX
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */