update credits
[LibreOffice.git] / include / vcl / scrbar.hxx
blob78ef0c2c588bdaa6c04f3be1226b51b4aa7e7c79
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef _SV_SCRBAR_HXX
21 #define _SV_SCRBAR_HXX
23 #include <tools/solar.h>
24 #include <vcl/dllapi.h>
25 #include <vcl/ctrl.hxx>
27 class AutoTimer;
29 // -------------------
30 // - ScrollBar-Types -
31 // -------------------
33 enum ScrollType { SCROLL_DONTKNOW, SCROLL_LINEUP, SCROLL_LINEDOWN,
34 SCROLL_PAGEUP, SCROLL_PAGEDOWN, SCROLL_DRAG, SCROLL_SET };
36 // -------------
37 // - ScrollBar -
38 // -------------
39 struct ImplScrollBarData;
41 class VCL_DLLPUBLIC ScrollBar : public Control
43 private:
44 Rectangle maBtn1Rect;
45 Rectangle maBtn2Rect;
46 Rectangle maPage1Rect;
47 Rectangle maPage2Rect;
48 Rectangle maThumbRect;
49 ImplScrollBarData* mpData;
50 long mnStartPos;
51 long mnMouseOff;
52 long mnThumbPixRange;
53 long mnThumbPixPos;
54 long mnThumbPixSize;
55 long mnMinRange;
56 long mnMaxRange;
57 long mnThumbPos;
58 long mnVisibleSize;
59 long mnLineSize;
60 long mnPageSize;
61 long mnDelta;
62 sal_uInt16 mnDragDraw;
63 sal_uInt16 mnStateFlags;
64 ScrollType meScrollType;
65 ScrollType meDDScrollType;
66 sal_Bool mbCalcSize;
67 sal_Bool mbFullDrag;
68 Link maScrollHdl;
69 Link maEndScrollHdl;
71 SAL_DLLPRIVATE Rectangle* ImplFindPartRect( const Point& rPt );
72 using Window::ImplInit;
73 SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
74 SAL_DLLPRIVATE void ImplInitStyle( WinBits nStyle );
75 SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId );
76 SAL_DLLPRIVATE void ImplUpdateRects( sal_Bool bUpdate = sal_True );
77 SAL_DLLPRIVATE long ImplCalcThumbPos( long nPixPos );
78 SAL_DLLPRIVATE long ImplCalcThumbPosPix( long nPos );
79 SAL_DLLPRIVATE void ImplCalc( sal_Bool bUpdate = sal_True );
80 SAL_DLLPRIVATE void ImplDraw( sal_uInt16 nDrawFlags, OutputDevice* pOutDev );
81 using Window::ImplScroll;
82 SAL_DLLPRIVATE long ImplScroll( long nNewPos, sal_Bool bCallEndScroll );
83 SAL_DLLPRIVATE long ImplDoAction( sal_Bool bCallEndScroll );
84 SAL_DLLPRIVATE void ImplDoMouseAction( const Point& rPos, sal_Bool bCallAction = sal_True );
85 SAL_DLLPRIVATE void ImplInvert();
86 SAL_DLLPRIVATE sal_Bool ImplDrawNative( sal_uInt16 nDrawFlags );
87 SAL_DLLPRIVATE void ImplDragThumb( const Point& rMousePos );
88 SAL_DLLPRIVATE Size getCurrentCalcSize() const;
89 DECL_DLLPRIVATE_LINK( ImplTimerHdl, Timer* );
90 DECL_DLLPRIVATE_LINK( ImplAutoTimerHdl, void* );
92 public:
93 explicit ScrollBar( Window* pParent, WinBits nStyle = WB_VERT );
94 explicit ScrollBar( Window* pParent, const ResId& );
95 virtual ~ScrollBar();
97 virtual void MouseButtonDown( const MouseEvent& rMEvt );
98 virtual void Tracking( const TrackingEvent& rTEvt );
99 virtual void KeyInput( const KeyEvent& rKEvt );
100 virtual void Paint( const Rectangle& rRect );
101 virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
102 virtual void Resize();
103 virtual void StateChanged( StateChangedType nType );
104 virtual void DataChanged( const DataChangedEvent& rDCEvt );
105 virtual long PreNotify( NotifyEvent& rNEvt );
106 virtual void GetFocus();
107 virtual void LoseFocus();
109 using Window::Scroll;
110 virtual void Scroll();
111 virtual void EndScroll();
113 long DoScroll( long nNewPos );
114 long DoScrollAction( ScrollType eScrollType );
116 void EnableDrag( sal_Bool bEnable = sal_True )
117 { mbFullDrag = bEnable; }
118 sal_Bool IsDragEnabled() const { return mbFullDrag; }
120 void SetRangeMin( long nNewRange );
121 long GetRangeMin() const { return mnMinRange; }
122 void SetRangeMax( long nNewRange );
123 long GetRangeMax() const { return mnMaxRange; }
124 void SetRange( const Range& rRange );
125 Range GetRange() const { return Range( GetRangeMin(), GetRangeMax() ); }
126 void SetThumbPos( long nThumbPos );
127 long GetThumbPos() const { return mnThumbPos; }
128 void SetLineSize( long nNewSize ) { mnLineSize = nNewSize; }
129 long GetLineSize() const { return mnLineSize; }
130 void SetPageSize( long nNewSize ) { mnPageSize = nNewSize; }
131 long GetPageSize() const { return mnPageSize; }
132 void SetVisibleSize( long nNewSize );
133 long GetVisibleSize() const { return mnVisibleSize; }
135 long GetDelta() const { return mnDelta; }
136 ScrollType GetType() const { return meScrollType; }
138 void SetScrollHdl( const Link& rLink ) { maScrollHdl = rLink; }
139 const Link& GetScrollHdl() const { return maScrollHdl; }
140 void SetEndScrollHdl( const Link& rLink ) { maEndScrollHdl = rLink; }
141 const Link& GetEndScrollHdl() const { return maEndScrollHdl; }
143 virtual Size GetOptimalSize() const;
146 // ----------------
147 // - ScrollBarBox -
148 // ----------------
150 class VCL_DLLPUBLIC ScrollBarBox : public Window
152 private:
153 using Window::ImplInit;
154 SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
155 SAL_DLLPRIVATE void ImplInitSettings();
157 public:
158 explicit ScrollBarBox( Window* pParent, WinBits nStyle = 0 );
160 virtual void StateChanged( StateChangedType nType );
161 virtual void DataChanged( const DataChangedEvent& rDCEvt );
164 #endif // _SV_SCRBAR_HXX
166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */