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