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 .
20 #ifndef INCLUDED_VCL_SCRBAR_HXX
21 #define INCLUDED_VCL_SCRBAR_HXX
23 #include <vcl/dllapi.h>
24 #include <vcl/ctrl.hxx>
37 struct ImplScrollBarData
;
39 class VCL_DLLPUBLIC ScrollBar
: public Control
42 tools::Rectangle maBtn1Rect
;
43 tools::Rectangle maBtn2Rect
;
44 tools::Rectangle maPage1Rect
;
45 tools::Rectangle maPage2Rect
;
46 tools::Rectangle maThumbRect
;
47 tools::Rectangle maTrackRect
;
48 std::unique_ptr
<ImplScrollBarData
> mpData
;
61 sal_uInt16 mnStateFlags
;
62 ScrollType meScrollType
;
65 Link
<ScrollBar
*,void> maScrollHdl
;
66 Link
<ScrollBar
*,void> maEndScrollHdl
;
68 SAL_DLLPRIVATE
tools::Rectangle
* ImplFindPartRect( const Point
& rPt
);
69 using Window::ImplInit
;
70 SAL_DLLPRIVATE
void ImplInit( vcl::Window
* pParent
, WinBits nStyle
);
71 SAL_DLLPRIVATE
void ImplInitStyle( WinBits nStyle
);
72 SAL_DLLPRIVATE
void ImplUpdateRects( bool bUpdate
= true );
73 SAL_DLLPRIVATE
long ImplCalcThumbPos( long nPixPos
);
74 SAL_DLLPRIVATE
long ImplCalcThumbPosPix( long nPos
);
75 SAL_DLLPRIVATE
void ImplCalc( bool bUpdate
= true );
76 SAL_DLLPRIVATE
void ImplDraw(vcl::RenderContext
& rRenderContext
);
77 using Window::ImplScroll
;
78 SAL_DLLPRIVATE
long ImplScroll( long nNewPos
, bool bCallEndScroll
);
79 SAL_DLLPRIVATE
long ImplDoAction( bool bCallEndScroll
);
80 SAL_DLLPRIVATE
void ImplDoMouseAction( const Point
& rPos
, bool bCallAction
= true );
81 SAL_DLLPRIVATE
void ImplInvert();
82 SAL_DLLPRIVATE
bool ImplDrawNative(vcl::RenderContext
& rRenderContext
, sal_uInt16 nDrawFlags
);
83 SAL_DLLPRIVATE
void ImplDragThumb( const Point
& rMousePos
);
84 SAL_DLLPRIVATE Size
getCurrentCalcSize() const;
85 DECL_DLLPRIVATE_LINK( ImplAutoTimerHdl
, Timer
*, void );
88 explicit ScrollBar( vcl::Window
* pParent
, WinBits nStyle
= WB_VERT
);
89 virtual ~ScrollBar() override
;
90 virtual void dispose() override
;
92 virtual void MouseButtonDown(const MouseEvent
& rMEvt
) override
;
93 virtual void Tracking(const TrackingEvent
& rTEvt
) override
;
94 virtual void KeyInput(const KeyEvent
& rKEvt
) override
;
95 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
96 virtual void Draw(OutputDevice
* pDev
, const Point
& rPos
, const Size
& rSize
, DrawFlags nFlags
) override
;
97 virtual void Move() override
;
98 virtual void Resize() override
;
99 virtual void StateChanged(StateChangedType nType
) override
;
100 virtual void DataChanged(const DataChangedEvent
& rDCEvt
) override
;
101 virtual bool PreNotify(NotifyEvent
& rNEvt
) override
;
102 virtual void GetFocus() override
;
103 virtual void LoseFocus() override
;
104 virtual void ApplySettings(vcl::RenderContext
& rRenderContext
) override
;
106 using Window::Scroll
;
108 virtual void EndScroll();
110 long DoScroll( long nNewPos
);
111 long DoScrollAction( ScrollType eScrollType
);
113 void EnableDrag() { mbFullDrag
= true; }
115 void SetRangeMin( long nNewRange
);
116 long GetRangeMin() const { return mnMinRange
; }
117 void SetRangeMax( long nNewRange
);
118 long GetRangeMax() const { return mnMaxRange
; }
119 void SetRange( const Range
& rRange
);
120 Range
GetRange() const { return Range( GetRangeMin(), GetRangeMax() ); }
121 void SetThumbPos( long nThumbPos
);
122 long GetThumbPos() const { return mnThumbPos
; }
123 void SetLineSize( long nNewSize
) { mnLineSize
= nNewSize
; }
124 long GetLineSize() const { return mnLineSize
; }
125 void SetPageSize( long nNewSize
) { mnPageSize
= nNewSize
; }
126 long GetPageSize() const { return mnPageSize
; }
127 void SetVisibleSize( long nNewSize
);
128 long GetVisibleSize() const { return mnVisibleSize
; }
130 long GetDelta() const { return mnDelta
; }
131 ScrollType
GetType() const { return meScrollType
; }
133 void SetScrollHdl( const Link
<ScrollBar
*,void>& rLink
) { maScrollHdl
= rLink
; }
134 const Link
<ScrollBar
*,void>& GetScrollHdl() const { return maScrollHdl
; }
135 void SetEndScrollHdl( const Link
<ScrollBar
*,void>& rLink
) { maEndScrollHdl
= rLink
; }
137 virtual Size
GetOptimalSize() const override
;
141 class VCL_DLLPUBLIC ScrollBarBox final
: public vcl::Window
144 using Window::ImplInit
;
145 SAL_DLLPRIVATE
void ImplInit( vcl::Window
* pParent
, WinBits nStyle
);
147 virtual void ApplySettings(vcl::RenderContext
& rRenderContext
) override
;
150 explicit ScrollBarBox( vcl::Window
* pParent
, WinBits nStyle
= 0 );
152 virtual void StateChanged( StateChangedType nType
) override
;
153 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
156 #endif // INCLUDED_VCL_SCRBAR_HXX
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */