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_SCRBAR_HXX
30 : : #define _SV_SCRBAR_HXX
31 : :
32 : : #include <tools/solar.h>
33 : : #include <vcl/dllapi.h>
34 : : #include <vcl/ctrl.hxx>
35 : :
36 : : class AutoTimer;
37 : :
38 : : // -------------------
39 : : // - ScrollBar-Types -
40 : : // -------------------
41 : :
42 : : enum ScrollType { SCROLL_DONTKNOW, SCROLL_LINEUP, SCROLL_LINEDOWN,
43 : : SCROLL_PAGEUP, SCROLL_PAGEDOWN, SCROLL_DRAG, SCROLL_SET };
44 : :
45 : : // -------------
46 : : // - ScrollBar -
47 : : // -------------
48 : : struct ImplScrollBarData;
49 : :
50 : : class VCL_DLLPUBLIC ScrollBar : public Control
51 : : {
52 : : private:
53 : : Rectangle maBtn1Rect;
54 : : Rectangle maBtn2Rect;
55 : : Rectangle maPage1Rect;
56 : : Rectangle maPage2Rect;
57 : : Rectangle maThumbRect;
58 : : ImplScrollBarData* mpData;
59 : : long mnStartPos;
60 : : long mnMouseOff;
61 : : long mnThumbPixRange;
62 : : long mnThumbPixPos;
63 : : long mnThumbPixSize;
64 : : long mnMinRange;
65 : : long mnMaxRange;
66 : : long mnThumbPos;
67 : : long mnVisibleSize;
68 : : long mnLineSize;
69 : : long mnPageSize;
70 : : long mnDelta;
71 : : sal_uInt16 mnDragDraw;
72 : : sal_uInt16 mnStateFlags;
73 : : ScrollType meScrollType;
74 : : ScrollType meDDScrollType;
75 : : sal_Bool mbCalcSize;
76 : : sal_Bool mbFullDrag;
77 : : Link maScrollHdl;
78 : : Link maEndScrollHdl;
79 : :
80 : : SAL_DLLPRIVATE Rectangle* ImplFindPartRect( const Point& rPt );
81 : : using Window::ImplInit;
82 : : SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
83 : : SAL_DLLPRIVATE void ImplInitStyle( WinBits nStyle );
84 : : SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
85 : : SAL_DLLPRIVATE void ImplUpdateRects( sal_Bool bUpdate = sal_True );
86 : : SAL_DLLPRIVATE long ImplCalcThumbPos( long nPixPos );
87 : : SAL_DLLPRIVATE long ImplCalcThumbPosPix( long nPos );
88 : : SAL_DLLPRIVATE void ImplCalc( sal_Bool bUpdate = sal_True );
89 : : SAL_DLLPRIVATE void ImplDraw( sal_uInt16 nDrawFlags, OutputDevice* pOutDev );
90 : : using Window::ImplScroll;
91 : : SAL_DLLPRIVATE long ImplScroll( long nNewPos, sal_Bool bCallEndScroll );
92 : : SAL_DLLPRIVATE long ImplDoAction( sal_Bool bCallEndScroll );
93 : : SAL_DLLPRIVATE void ImplDoMouseAction( const Point& rPos, sal_Bool bCallAction = sal_True );
94 : : SAL_DLLPRIVATE void ImplInvert();
95 : : SAL_DLLPRIVATE sal_Bool ImplDrawNative( sal_uInt16 nDrawFlags );
96 : : SAL_DLLPRIVATE void ImplDragThumb( const Point& rMousePos );
97 : : DECL_DLLPRIVATE_LINK( ImplTimerHdl, Timer* );
98 : : DECL_DLLPRIVATE_LINK( ImplAutoTimerHdl, void* );
99 : :
100 : : public:
101 : : ScrollBar( Window* pParent, WinBits nStyle = WB_VERT );
102 : : ScrollBar( Window* pParent, const ResId& rResId );
103 : : ~ScrollBar();
104 : :
105 : : virtual void MouseButtonDown( const MouseEvent& rMEvt );
106 : : virtual void Tracking( const TrackingEvent& rTEvt );
107 : : virtual void KeyInput( const KeyEvent& rKEvt );
108 : : virtual void Paint( const Rectangle& rRect );
109 : : virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
110 : : virtual void Resize();
111 : : virtual void StateChanged( StateChangedType nType );
112 : : virtual void DataChanged( const DataChangedEvent& rDCEvt );
113 : : virtual long PreNotify( NotifyEvent& rNEvt );
114 : : virtual void GetFocus();
115 : : virtual void LoseFocus();
116 : :
117 : : using Window::Scroll;
118 : : virtual void Scroll();
119 : : virtual void EndScroll();
120 : :
121 : : long DoScroll( long nNewPos );
122 : : long DoScrollAction( ScrollType eScrollType );
123 : :
124 : 2752 : void EnableDrag( sal_Bool bEnable = sal_True )
125 : 2752 : { mbFullDrag = bEnable; }
126 : : sal_Bool IsDragEnabled() const { return mbFullDrag; }
127 : :
128 : : void SetRangeMin( long nNewRange );
129 : 11241 : long GetRangeMin() const { return mnMinRange; }
130 : : void SetRangeMax( long nNewRange );
131 : 12199 : long GetRangeMax() const { return mnMaxRange; }
132 : : void SetRange( const Range& rRange );
133 : 10734 : Range GetRange() const { return Range( GetRangeMin(), GetRangeMax() ); }
134 : : void SetThumbPos( long nThumbPos );
135 : 6958 : long GetThumbPos() const { return mnThumbPos; }
136 : 16205 : void SetLineSize( long nNewSize ) { mnLineSize = nNewSize; }
137 : 0 : long GetLineSize() const { return mnLineSize; }
138 : 19936 : void SetPageSize( long nNewSize ) { mnPageSize = nNewSize; }
139 : 0 : long GetPageSize() const { return mnPageSize; }
140 : : void SetVisibleSize( long nNewSize );
141 : 23063 : long GetVisibleSize() const { return mnVisibleSize; }
142 : :
143 : 4 : long GetDelta() const { return mnDelta; }
144 : 0 : ScrollType GetType() const { return meScrollType; }
145 : :
146 : 13780 : void SetScrollHdl( const Link& rLink ) { maScrollHdl = rLink; }
147 : : const Link& GetScrollHdl() const { return maScrollHdl; }
148 : 4056 : void SetEndScrollHdl( const Link& rLink ) { maEndScrollHdl = rLink; }
149 : 0 : const Link& GetEndScrollHdl() const { return maEndScrollHdl; }
150 : : };
151 : :
152 : : // ----------------
153 : : // - ScrollBarBox -
154 : : // ----------------
155 : :
156 [ - + ]: 11347 : class VCL_DLLPUBLIC ScrollBarBox : public Window
157 : : {
158 : : private:
159 : : using Window::ImplInit;
160 : : SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
161 : : SAL_DLLPRIVATE void ImplInitSettings();
162 : :
163 : : public:
164 : : ScrollBarBox( Window* pParent, WinBits nStyle = 0 );
165 : :
166 : : virtual void StateChanged( StateChangedType nType );
167 : : virtual void DataChanged( const DataChangedEvent& rDCEvt );
168 : : };
169 : :
170 : : #endif // _SV_SCRBAR_HXX
171 : :
172 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|