Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SV_SLIDER_HXX
30 : : #define _SV_SLIDER_HXX
31 : :
32 : : #include <tools/solar.h>
33 : : #include <vcl/dllapi.h>
34 : : #include <vcl/ctrl.hxx>
35 : : // for enum ScrollType
36 : : #include <vcl/scrbar.hxx>
37 : :
38 : : // ----------
39 : : // - Slider -
40 : : // ----------
41 : :
42 [ # # ]: 0 : class VCL_DLLPUBLIC Slider : public Control
43 : : {
44 : : private:
45 : : Rectangle maChannel1Rect;
46 : : Rectangle maChannel2Rect;
47 : : Rectangle maThumbRect;
48 : : long mnStartPos;
49 : : long mnMouseOff;
50 : : long mnThumbPixOffset;
51 : : long mnThumbPixRange;
52 : : long mnThumbPixPos;
53 : : long mnChannelPixOffset;
54 : : long mnChannelPixRange;
55 : : long mnChannelPixTop;
56 : : long mnChannelPixBottom;
57 : : long mnMinRange;
58 : : long mnMaxRange;
59 : : long mnThumbPos;
60 : : long mnLineSize;
61 : : long mnPageSize;
62 : : long mnDelta;
63 : : sal_uInt16 mnDragDraw;
64 : : sal_uInt16 mnStateFlags;
65 : : ScrollType meScrollType;
66 : : sal_Bool mbCalcSize;
67 : : sal_Bool mbFullDrag;
68 : : Link maSlideHdl;
69 : : Link maEndSlideHdl;
70 : :
71 : : using Control::ImplInitSettings;
72 : : using Window::ImplInit;
73 : : SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
74 : : SAL_DLLPRIVATE void ImplInitSettings();
75 : : SAL_DLLPRIVATE void ImplUpdateRects( sal_Bool bUpdate = sal_True );
76 : : SAL_DLLPRIVATE long ImplCalcThumbPos( long nPixPos );
77 : : SAL_DLLPRIVATE long ImplCalcThumbPosPix( long nPos );
78 : : SAL_DLLPRIVATE void ImplCalc( sal_Bool bUpdate = sal_True );
79 : : SAL_DLLPRIVATE void ImplDraw( sal_uInt16 nDrawFlags );
80 : : SAL_DLLPRIVATE sal_Bool ImplIsPageUp( const Point& rPos );
81 : : SAL_DLLPRIVATE sal_Bool ImplIsPageDown( const Point& rPos );
82 : : SAL_DLLPRIVATE long ImplSlide( long nNewPos, sal_Bool bCallEndSlide );
83 : : SAL_DLLPRIVATE long ImplDoAction( sal_Bool bCallEndSlide );
84 : : SAL_DLLPRIVATE void ImplDoMouseAction( const Point& rPos, sal_Bool bCallAction = sal_True );
85 : : SAL_DLLPRIVATE long ImplDoSlide( long nNewPos );
86 : : SAL_DLLPRIVATE long ImplDoSlideAction( ScrollType eScrollType );
87 : :
88 : : public:
89 : : Slider( Window* pParent, WinBits nStyle = WB_HORZ );
90 : :
91 : : virtual void MouseButtonDown( const MouseEvent& rMEvt );
92 : : virtual void MouseButtonUp( const MouseEvent& rMEvt );
93 : : virtual void Tracking( const TrackingEvent& rTEvt );
94 : : virtual void KeyInput( const KeyEvent& rKEvt );
95 : : virtual void Paint( const Rectangle& rRect );
96 : : virtual void Resize();
97 : : virtual void RequestHelp( const HelpEvent& rHEvt );
98 : : virtual void StateChanged( StateChangedType nType );
99 : : virtual void DataChanged( const DataChangedEvent& rDCEvt );
100 : :
101 : : virtual void Slide();
102 : : virtual void EndSlide();
103 : :
104 : : void EnableDrag( sal_Bool bEnable = sal_True )
105 : : { mbFullDrag = bEnable; }
106 : : sal_Bool IsDragEnabled() const { return mbFullDrag; }
107 : :
108 : 0 : long GetRangeMin() const { return mnMinRange; }
109 : 0 : long GetRangeMax() const { return mnMaxRange; }
110 : : void SetRange( const Range& rRange );
111 : : Range GetRange() const { return Range( GetRangeMin(), GetRangeMax() ); }
112 : : void SetThumbPos( long nThumbPos );
113 : 0 : long GetThumbPos() const { return mnThumbPos; }
114 : 0 : void SetLineSize( long nNewSize ) { mnLineSize = nNewSize; }
115 : 0 : long GetLineSize() const { return mnLineSize; }
116 : 0 : void SetPageSize( long nNewSize ) { mnPageSize = nNewSize; }
117 : 0 : long GetPageSize() const { return mnPageSize; }
118 : :
119 : : long GetDelta() const { return mnDelta; }
120 : :
121 : : Size CalcWindowSizePixel();
122 : :
123 : 0 : void SetSlideHdl( const Link& rLink ) { maSlideHdl = rLink; }
124 : : const Link& GetSlideHdl() const { return maSlideHdl; }
125 : 0 : void SetEndSlideHdl( const Link& rLink ) { maEndSlideHdl = rLink; }
126 : : const Link& GetEndSlideHdl() const { return maEndSlideHdl; }
127 : : };
128 : :
129 : : #endif // _SV_SLIDER_HXX
130 : :
131 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|