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