1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
23 #error "don't use this in new code"
26 #include <vcl/dllapi.h>
27 #include <vcl/ctrl.hxx>
28 #include <vcl/scrollable.hxx>
31 struct ImplScrollBarData
;
33 class VCL_DLLPUBLIC ScrollBar final
: public Control
37 tools::Rectangle maBtn1Rect
;
38 tools::Rectangle maBtn2Rect
;
39 tools::Rectangle maPage1Rect
;
40 tools::Rectangle maPage2Rect
;
41 tools::Rectangle maThumbRect
;
42 tools::Rectangle maTrackRect
;
43 std::unique_ptr
<ImplScrollBarData
> mpData
;
44 tools::Long mnStartPos
;
45 tools::Long mnMouseOff
;
46 tools::Long mnThumbPixRange
;
47 tools::Long mnThumbPixPos
;
48 tools::Long mnThumbPixSize
;
49 tools::Long mnMinRange
;
50 tools::Long mnMaxRange
;
51 tools::Long mnThumbPos
;
52 tools::Long mnVisibleSize
;
53 tools::Long mnLineSize
;
54 tools::Long mnPageSize
;
56 sal_uInt16 mnStateFlags
;
57 ScrollType meScrollType
;
60 Link
<ScrollBar
*,void> maScrollHdl
;
61 Link
<ScrollBar
*,void> maEndScrollHdl
;
63 SAL_DLLPRIVATE
tools::Rectangle
* ImplFindPartRect( const Point
& rPt
);
64 using Window::ImplInit
;
65 SAL_DLLPRIVATE
void ImplInit( vcl::Window
* pParent
, WinBits nStyle
);
66 SAL_DLLPRIVATE
void ImplInitStyle( WinBits nStyle
);
67 SAL_DLLPRIVATE
void ImplUpdateRects( bool bUpdate
= true );
68 SAL_DLLPRIVATE
tools::Long
ImplCalcThumbPos( tools::Long nPixPos
) const;
69 SAL_DLLPRIVATE
tools::Long
ImplCalcThumbPosPix( tools::Long nPos
) const;
70 SAL_DLLPRIVATE
void ImplCalc( bool bUpdate
= true );
71 SAL_DLLPRIVATE
void ImplDraw(vcl::RenderContext
& rRenderContext
);
72 using Window::ImplScroll
;
73 SAL_DLLPRIVATE
tools::Long
ImplScroll( tools::Long nNewPos
, bool bCallEndScroll
);
74 SAL_DLLPRIVATE
tools::Long
ImplDoAction( bool bCallEndScroll
);
75 SAL_DLLPRIVATE
void ImplDoMouseAction( const Point
& rPos
, bool bCallAction
= true );
76 SAL_DLLPRIVATE
void ImplInvert();
77 SAL_DLLPRIVATE
bool ImplDrawNative(vcl::RenderContext
& rRenderContext
, sal_uInt16 SystemTextColorFlags
);
78 SAL_DLLPRIVATE
void ImplDragThumb( const Point
& rMousePos
);
79 SAL_DLLPRIVATE Size
getCurrentCalcSize() const;
80 DECL_DLLPRIVATE_LINK( ImplAutoTimerHdl
, Timer
*, void );
83 explicit ScrollBar( vcl::Window
* pParent
, WinBits nStyle
= WB_VERT
);
84 virtual ~ScrollBar() override
;
85 virtual void dispose() override
;
87 virtual void MouseButtonDown(const MouseEvent
& rMEvt
) override
;
88 virtual void Tracking(const TrackingEvent
& rTEvt
) override
;
89 virtual void KeyInput(const KeyEvent
& rKEvt
) override
;
90 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
91 virtual void Draw(OutputDevice
* pDev
, const Point
& rPos
, SystemTextColorFlags nFlags
) override
;
92 virtual void Move() override
;
93 virtual void Resize() override
;
94 virtual void StateChanged(StateChangedType nType
) override
;
95 virtual void DataChanged(const DataChangedEvent
& rDCEvt
) override
;
96 virtual bool PreNotify(NotifyEvent
& rNEvt
) override
;
97 virtual void GetFocus() override
;
98 virtual void LoseFocus() override
;
99 virtual void ApplySettings(vcl::RenderContext
& rRenderContext
) override
;
101 using Window::Scroll
;
105 tools::Long
DoScroll( tools::Long nNewPos
) override
;
106 tools::Long
DoScrollAction( ScrollType eScrollType
);
108 void EnableDrag() { mbFullDrag
= true; }
110 void SetRangeMin( tools::Long nNewRange
) override
;
111 tools::Long
GetRangeMin() const override
{ return mnMinRange
; }
112 void SetRangeMax( tools::Long nNewRange
) override
;
113 tools::Long
GetRangeMax() const override
{ return mnMaxRange
; }
114 void SetRange( const Range
& rRange
) override
;
115 Range
GetRange() const override
{ return Range( GetRangeMin(), GetRangeMax() ); }
116 void SetThumbPos( tools::Long nThumbPos
) override
;
117 tools::Long
GetThumbPos() const override
{ return mnThumbPos
; }
118 void SetLineSize( tools::Long nNewSize
) override
{ mnLineSize
= nNewSize
; }
119 tools::Long
GetLineSize() const override
{ return mnLineSize
; }
120 void SetPageSize( tools::Long nNewSize
) override
{ mnPageSize
= nNewSize
; }
121 tools::Long
GetPageSize() const override
{ return mnPageSize
; }
122 void SetVisibleSize( tools::Long nNewSize
) override
;
123 tools::Long
GetVisibleSize() const override
{ return mnVisibleSize
; }
125 bool Inactive() const override
;
127 tools::Long
GetDelta() const { return mnDelta
; }
128 ScrollType
GetType() const { return meScrollType
; }
130 void SetScrollHdl( const Link
<ScrollBar
*,void>& rLink
) { maScrollHdl
= rLink
; }
131 const Link
<ScrollBar
*,void>& GetScrollHdl() const { return maScrollHdl
; }
132 void SetEndScrollHdl( const Link
<ScrollBar
*,void>& rLink
) { maEndScrollHdl
= rLink
; }
134 virtual Size
GetOptimalSize() const override
;
138 class VCL_DLLPUBLIC ScrollBarBox final
: public vcl::Window
141 using Window::ImplInit
;
142 SAL_DLLPRIVATE
void ImplInit( vcl::Window
* pParent
, WinBits nStyle
);
144 virtual void ApplySettings(vcl::RenderContext
& rRenderContext
) override
;
147 explicit ScrollBarBox( vcl::Window
* pParent
, WinBits nStyle
= 0 );
149 virtual void StateChanged( StateChangedType nType
) override
;
150 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */