xref: /AOO41X/main/vcl/inc/vcl/slider.hxx (revision 0d63794c5b3715d9f8da2f4b7b451b7426ee7897)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SV_SLIDER_HXX
25 #define _SV_SLIDER_HXX
26 
27 #include <vcl/sv.h>
28 #include <vcl/dllapi.h>
29 #include <vcl/ctrl.hxx>
30 // for enum ScrollType
31 #include <vcl/scrbar.hxx>
32 
33 // ----------
34 // - Slider -
35 // ----------
36 
37 class VCL_DLLPUBLIC Slider : public Control
38 {
39 private:
40     Rectangle       maChannel1Rect;
41     Rectangle       maChannel2Rect;
42     Rectangle       maThumbRect;
43     long            mnStartPos;
44     long            mnMouseOff;
45     long            mnThumbPixOffset;
46     long            mnThumbPixRange;
47     long            mnThumbPixPos;
48     long            mnChannelPixOffset;
49     long            mnChannelPixRange;
50     long            mnChannelPixTop;
51     long            mnChannelPixBottom;
52     long            mnMinRange;
53     long            mnMaxRange;
54     long            mnThumbPos;
55     long            mnLineSize;
56     long            mnPageSize;
57     long            mnDelta;
58     sal_uInt16          mnDragDraw;
59     sal_uInt16          mnStateFlags;
60     ScrollType      meScrollType;
61     sal_Bool            mbCalcSize;
62     sal_Bool            mbFullDrag;
63     Link            maSlideHdl;
64     Link            maEndSlideHdl;
65 
66     using Control::ImplInitSettings;
67     using Window::ImplInit;
68     SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
69     SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
70     SAL_DLLPRIVATE void ImplInitSettings();
71     SAL_DLLPRIVATE void ImplUpdateRects( sal_Bool bUpdate = sal_True );
72     SAL_DLLPRIVATE long ImplCalcThumbPos( long nPixPos );
73     SAL_DLLPRIVATE long ImplCalcThumbPosPix( long nPos );
74     SAL_DLLPRIVATE void ImplCalc( sal_Bool bUpdate = sal_True );
75     SAL_DLLPRIVATE void ImplDraw( sal_uInt16 nDrawFlags );
76     SAL_DLLPRIVATE sal_Bool ImplIsPageUp( const Point& rPos );
77     SAL_DLLPRIVATE sal_Bool ImplIsPageDown( const Point& rPos );
78     SAL_DLLPRIVATE long ImplSlide( long nNewPos, sal_Bool bCallEndSlide );
79     SAL_DLLPRIVATE long ImplDoAction( sal_Bool bCallEndSlide );
80     SAL_DLLPRIVATE void ImplDoMouseAction( const Point& rPos, sal_Bool bCallAction = sal_True );
81     SAL_DLLPRIVATE long ImplDoSlide( long nNewPos );
82     SAL_DLLPRIVATE long ImplDoSlideAction( ScrollType eScrollType );
83 
84 public:
85                     Slider( Window* pParent, WinBits nStyle = WB_HORZ );
86                     Slider( Window* pParent, const ResId& rResId );
87 
88     virtual void    MouseButtonDown( const MouseEvent& rMEvt );
89     virtual void    MouseButtonUp( const MouseEvent& rMEvt );
90     virtual void    Tracking( const TrackingEvent& rTEvt );
91     virtual void    KeyInput( const KeyEvent& rKEvt );
92     virtual void    Paint( const Rectangle& rRect );
93     virtual void    Resize();
94     virtual void    RequestHelp( const HelpEvent& rHEvt );
95     virtual void    StateChanged( StateChangedType nType );
96     virtual void    DataChanged( const DataChangedEvent& rDCEvt );
97 
98     virtual void    Slide();
99     virtual void    EndSlide();
100 
EnableDrag(sal_Bool bEnable=sal_True)101     void            EnableDrag( sal_Bool bEnable = sal_True )
102                         { mbFullDrag = bEnable; }
IsDragEnabled() const103     sal_Bool            IsDragEnabled() const { return mbFullDrag; }
104 
105     void            SetRangeMin( long nNewRange );
GetRangeMin() const106     long            GetRangeMin() const { return mnMinRange; }
107     void            SetRangeMax( long nNewRange );
GetRangeMax() const108     long            GetRangeMax() const { return mnMaxRange; }
109     void            SetRange( const Range& rRange );
GetRange() const110     Range           GetRange() const { return Range( GetRangeMin(), GetRangeMax() ); }
111     void            SetThumbPos( long nThumbPos );
GetThumbPos() const112     long            GetThumbPos() const { return mnThumbPos; }
SetLineSize(long nNewSize)113     void            SetLineSize( long nNewSize ) { mnLineSize = nNewSize; }
GetLineSize() const114     long            GetLineSize() const { return mnLineSize; }
SetPageSize(long nNewSize)115     void            SetPageSize( long nNewSize ) { mnPageSize = nNewSize; }
GetPageSize() const116     long            GetPageSize() const { return mnPageSize; }
117 
GetDelta() const118     long            GetDelta() const { return mnDelta; }
119 
120     Size            CalcWindowSizePixel();
121 
SetSlideHdl(const Link & rLink)122     void            SetSlideHdl( const Link& rLink ) { maSlideHdl = rLink; }
GetSlideHdl() const123     const Link&     GetSlideHdl() const { return maSlideHdl;    }
SetEndSlideHdl(const Link & rLink)124     void            SetEndSlideHdl( const Link& rLink ) { maEndSlideHdl = rLink; }
GetEndSlideHdl() const125     const Link&     GetEndSlideHdl() const { return maEndSlideHdl; }
126 };
127 
128 #endif // _SV_SLIDER_HXX
129