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_SCRBAR_HXX
21 : #define INCLUDED_VCL_SCRBAR_HXX
22 :
23 : #include <tools/solar.h>
24 : #include <vcl/dllapi.h>
25 : #include <vcl/ctrl.hxx>
26 :
27 : class AutoTimer;
28 :
29 :
30 : // - ScrollBar-Types -
31 :
32 :
33 : enum ScrollType { SCROLL_DONTKNOW, SCROLL_LINEUP, SCROLL_LINEDOWN,
34 : SCROLL_PAGEUP, SCROLL_PAGEDOWN, SCROLL_DRAG, SCROLL_SET };
35 :
36 :
37 : // - ScrollBar -
38 :
39 : struct ImplScrollBarData;
40 :
41 : class VCL_DLLPUBLIC ScrollBar : public Control
42 : {
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 : bool mbCalcSize;
67 : bool mbFullDrag;
68 : Link<> maScrollHdl;
69 : Link<> maEndScrollHdl;
70 :
71 : SAL_DLLPRIVATE Rectangle* ImplFindPartRect( const Point& rPt );
72 : using Window::ImplInit;
73 : SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
74 : SAL_DLLPRIVATE void ImplInitStyle( WinBits nStyle );
75 : SAL_DLLPRIVATE void ImplUpdateRects( bool bUpdate = true );
76 : SAL_DLLPRIVATE long ImplCalcThumbPos( long nPixPos );
77 : SAL_DLLPRIVATE long ImplCalcThumbPosPix( long nPos );
78 : SAL_DLLPRIVATE void ImplCalc( bool bUpdate = true );
79 : SAL_DLLPRIVATE void ImplDraw(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags);
80 : using Window::ImplScroll;
81 : SAL_DLLPRIVATE long ImplScroll( long nNewPos, bool bCallEndScroll );
82 : SAL_DLLPRIVATE long ImplDoAction( bool bCallEndScroll );
83 : SAL_DLLPRIVATE void ImplDoMouseAction( const Point& rPos, bool bCallAction = true );
84 : SAL_DLLPRIVATE void ImplInvert();
85 : SAL_DLLPRIVATE bool ImplDrawNative(vcl::RenderContext& rRenderContext, sal_uInt16 nDrawFlags);
86 : SAL_DLLPRIVATE void ImplDragThumb( const Point& rMousePos );
87 : SAL_DLLPRIVATE Size getCurrentCalcSize() const;
88 : DECL_DLLPRIVATE_LINK( ImplTimerHdl, Timer* );
89 : DECL_DLLPRIVATE_LINK_TYPED( ImplAutoTimerHdl, Timer*, void );
90 :
91 : public:
92 : explicit ScrollBar( vcl::Window* pParent, WinBits nStyle = WB_VERT );
93 : virtual ~ScrollBar();
94 : virtual void dispose() SAL_OVERRIDE;
95 :
96 : virtual void MouseButtonDown(const MouseEvent& rMEvt) SAL_OVERRIDE;
97 : virtual void Tracking(const TrackingEvent& rTEvt) SAL_OVERRIDE;
98 : virtual void KeyInput(const KeyEvent& rKEvt) SAL_OVERRIDE;
99 : virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
100 : virtual void Draw(OutputDevice* pDev, const Point& rPos, const Size& rSize, DrawFlags nFlags) SAL_OVERRIDE;
101 : virtual void Resize() SAL_OVERRIDE;
102 : virtual void StateChanged(StateChangedType nType) SAL_OVERRIDE;
103 : virtual void DataChanged(const DataChangedEvent& rDCEvt) SAL_OVERRIDE;
104 : virtual bool PreNotify(NotifyEvent& rNEvt) SAL_OVERRIDE;
105 : virtual void GetFocus() SAL_OVERRIDE;
106 : virtual void LoseFocus() SAL_OVERRIDE;
107 : virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE;
108 :
109 : using Window::Scroll;
110 : void Scroll();
111 : virtual void EndScroll();
112 :
113 : long DoScroll( long nNewPos );
114 : long DoScrollAction( ScrollType eScrollType );
115 :
116 5656 : void EnableDrag( bool bEnable = true )
117 5656 : { mbFullDrag = bEnable; }
118 : bool IsDragEnabled() const { return mbFullDrag; }
119 :
120 : void SetRangeMin( long nNewRange );
121 41323 : long GetRangeMin() const { return mnMinRange; }
122 : void SetRangeMax( long nNewRange );
123 40544 : long GetRangeMax() const { return mnMaxRange; }
124 : void SetRange( const Range& rRange );
125 36390 : Range GetRange() const { return Range( GetRangeMin(), GetRangeMax() ); }
126 : void SetThumbPos( long nThumbPos );
127 16229 : long GetThumbPos() const { return mnThumbPos; }
128 65740 : void SetLineSize( long nNewSize ) { mnLineSize = nNewSize; }
129 0 : long GetLineSize() const { return mnLineSize; }
130 77150 : void SetPageSize( long nNewSize ) { mnPageSize = nNewSize; }
131 0 : long GetPageSize() const { return mnPageSize; }
132 : void SetVisibleSize( long nNewSize );
133 98126 : long GetVisibleSize() const { return mnVisibleSize; }
134 :
135 2 : long GetDelta() const { return mnDelta; }
136 0 : ScrollType GetType() const { return meScrollType; }
137 :
138 18354 : void SetScrollHdl( const Link<>& rLink ) { maScrollHdl = rLink; }
139 : const Link<>& GetScrollHdl() const { return maScrollHdl; }
140 7108 : void SetEndScrollHdl( const Link<>& rLink ) { maEndScrollHdl = rLink; }
141 0 : const Link<>& GetEndScrollHdl() const { return maEndScrollHdl; }
142 :
143 : virtual Size GetOptimalSize() const SAL_OVERRIDE;
144 : };
145 :
146 :
147 : // - ScrollBarBox -
148 :
149 :
150 13448 : class VCL_DLLPUBLIC ScrollBarBox : public vcl::Window
151 : {
152 : private:
153 : using Window::ImplInit;
154 : SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
155 :
156 : virtual void ApplySettings(vcl::RenderContext& rRenderContext) SAL_OVERRIDE;
157 :
158 : public:
159 : explicit ScrollBarBox( vcl::Window* pParent, WinBits nStyle = 0 );
160 :
161 : virtual void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
162 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
163 : };
164 :
165 : #endif // INCLUDED_VCL_SCRBAR_HXX
166 :
167 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|