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_SLIDER_HXX
21 : #define INCLUDED_VCL_SLIDER_HXX
22 :
23 : #include <vcl/dllapi.h>
24 : #include <vcl/ctrl.hxx>
25 : // for enum ScrollType
26 : #include <vcl/scrbar.hxx>
27 :
28 0 : class VCL_DLLPUBLIC Slider : public Control
29 : {
30 : private:
31 : Rectangle maChannel1Rect;
32 : Rectangle maChannel2Rect;
33 : Rectangle maThumbRect;
34 : long mnStartPos;
35 : long mnMouseOff;
36 : long mnThumbPixOffset;
37 : long mnThumbPixRange;
38 : long mnThumbPixPos;
39 : long mnChannelPixOffset;
40 : long mnChannelPixRange;
41 : long mnChannelPixTop;
42 : long mnChannelPixBottom;
43 : long mnMinRange;
44 : long mnMaxRange;
45 : long mnThumbPos;
46 : long mnLineSize;
47 : long mnPageSize;
48 : long mnDelta;
49 : sal_uInt16 mnDragDraw;
50 : sal_uInt16 mnStateFlags;
51 : ScrollType meScrollType;
52 : bool mbCalcSize;
53 : bool mbFullDrag;
54 : Link maSlideHdl;
55 : Link maEndSlideHdl;
56 :
57 : using Control::ImplInitSettings;
58 : using Window::ImplInit;
59 : SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
60 : SAL_DLLPRIVATE void ImplInitSettings();
61 : SAL_DLLPRIVATE void ImplUpdateRects( bool bUpdate = true );
62 : SAL_DLLPRIVATE long ImplCalcThumbPos( long nPixPos );
63 : SAL_DLLPRIVATE long ImplCalcThumbPosPix( long nPos );
64 : SAL_DLLPRIVATE void ImplCalc( bool bUpdate = true );
65 : SAL_DLLPRIVATE void ImplDraw( sal_uInt16 nDrawFlags );
66 : SAL_DLLPRIVATE bool ImplIsPageUp( const Point& rPos );
67 : SAL_DLLPRIVATE bool ImplIsPageDown( const Point& rPos );
68 : SAL_DLLPRIVATE long ImplSlide( long nNewPos, bool bCallEndSlide );
69 : SAL_DLLPRIVATE long ImplDoAction( bool bCallEndSlide );
70 : SAL_DLLPRIVATE void ImplDoMouseAction( const Point& rPos, bool bCallAction = true );
71 : SAL_DLLPRIVATE long ImplDoSlide( long nNewPos );
72 : SAL_DLLPRIVATE long ImplDoSlideAction( ScrollType eScrollType );
73 :
74 : public:
75 : Slider( Window* pParent, WinBits nStyle = WB_HORZ );
76 :
77 : virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
78 : virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
79 : virtual void Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
80 : virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
81 : virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
82 : virtual void Resize() SAL_OVERRIDE;
83 : virtual void RequestHelp( const HelpEvent& rHEvt ) SAL_OVERRIDE;
84 : virtual void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
85 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
86 :
87 : virtual void Slide();
88 : virtual void EndSlide();
89 :
90 : void EnableDrag( bool bEnable = true )
91 : { mbFullDrag = bEnable; }
92 : bool IsDragEnabled() const { return mbFullDrag; }
93 :
94 0 : long GetRangeMin() const { return mnMinRange; }
95 0 : long GetRangeMax() const { return mnMaxRange; }
96 : void SetRange( const Range& rRange );
97 : Range GetRange() const { return Range( GetRangeMin(), GetRangeMax() ); }
98 : void SetThumbPos( long nThumbPos );
99 0 : long GetThumbPos() const { return mnThumbPos; }
100 0 : void SetLineSize( long nNewSize ) { mnLineSize = nNewSize; }
101 0 : long GetLineSize() const { return mnLineSize; }
102 0 : void SetPageSize( long nNewSize ) { mnPageSize = nNewSize; }
103 0 : long GetPageSize() const { return mnPageSize; }
104 :
105 : long GetDelta() const { return mnDelta; }
106 :
107 : Size CalcWindowSizePixel();
108 :
109 0 : void SetSlideHdl( const Link& rLink ) { maSlideHdl = rLink; }
110 : const Link& GetSlideHdl() const { return maSlideHdl; }
111 0 : void SetEndSlideHdl( const Link& rLink ) { maEndSlideHdl = rLink; }
112 : const Link& GetEndSlideHdl() const { return maEndSlideHdl; }
113 : };
114 :
115 : #endif // INCLUDED_VCL_SLIDER_HXX
116 :
117 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|