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 <tools/solar.h>
24 #include <vcl/dllapi.h>
25 #include <vcl/ctrl.hxx>
39 struct ImplScrollBarData
;
41 class VCL_DLLPUBLIC ScrollBar
: public Control
44 tools::Rectangle maBtn1Rect
;
45 tools::Rectangle maBtn2Rect
;
46 tools::Rectangle maPage1Rect
;
47 tools::Rectangle maPage2Rect
;
48 tools::Rectangle maThumbRect
;
49 tools::Rectangle maTrackRect
;
50 ImplScrollBarData
* mpData
;
63 sal_uInt16 mnDragDraw
;
64 sal_uInt16 mnStateFlags
;
65 ScrollType meScrollType
;
68 Link
<ScrollBar
*,void> maScrollHdl
;
69 Link
<ScrollBar
*,void> maEndScrollHdl
;
71 SAL_DLLPRIVATE
tools::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
);
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( ImplAutoTimerHdl
, Timer
*, void );
91 explicit ScrollBar( vcl::Window
* pParent
, WinBits nStyle
= WB_VERT
);
92 virtual ~ScrollBar() override
;
93 virtual void dispose() override
;
95 virtual void MouseButtonDown(const MouseEvent
& rMEvt
) override
;
96 virtual void Tracking(const TrackingEvent
& rTEvt
) override
;
97 virtual void KeyInput(const KeyEvent
& rKEvt
) override
;
98 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
99 virtual void Draw(OutputDevice
* pDev
, const Point
& rPos
, const Size
& rSize
, DrawFlags nFlags
) override
;
100 virtual void Resize() override
;
101 virtual void StateChanged(StateChangedType nType
) override
;
102 virtual void DataChanged(const DataChangedEvent
& rDCEvt
) override
;
103 virtual bool PreNotify(NotifyEvent
& rNEvt
) override
;
104 virtual void GetFocus() override
;
105 virtual void LoseFocus() override
;
106 virtual void ApplySettings(vcl::RenderContext
& rRenderContext
) override
;
108 using Window::Scroll
;
110 virtual void EndScroll();
112 long DoScroll( long nNewPos
);
113 long DoScrollAction( ScrollType eScrollType
);
115 void EnableDrag() { mbFullDrag
= true; }
117 void SetRangeMin( long nNewRange
);
118 long GetRangeMin() const { return mnMinRange
; }
119 void SetRangeMax( long nNewRange
);
120 long GetRangeMax() const { return mnMaxRange
; }
121 void SetRange( const Range
& rRange
);
122 Range
GetRange() const { return Range( GetRangeMin(), GetRangeMax() ); }
123 void SetThumbPos( long nThumbPos
);
124 long GetThumbPos() const { return mnThumbPos
; }
125 void SetLineSize( long nNewSize
) { mnLineSize
= nNewSize
; }
126 long GetLineSize() const { return mnLineSize
; }
127 void SetPageSize( long nNewSize
) { mnPageSize
= nNewSize
; }
128 long GetPageSize() const { return mnPageSize
; }
129 void SetVisibleSize( long nNewSize
);
130 long GetVisibleSize() const { return mnVisibleSize
; }
132 long GetDelta() const { return mnDelta
; }
133 ScrollType
GetType() const { return meScrollType
; }
135 void SetScrollHdl( const Link
<ScrollBar
*,void>& rLink
) { maScrollHdl
= rLink
; }
136 void SetEndScrollHdl( const Link
<ScrollBar
*,void>& rLink
) { maEndScrollHdl
= rLink
; }
137 const Link
<ScrollBar
*,void>& GetEndScrollHdl() const { return maEndScrollHdl
; }
139 virtual Size
GetOptimalSize() const override
;
143 class VCL_DLLPUBLIC ScrollBarBox
: public vcl::Window
146 using Window::ImplInit
;
147 SAL_DLLPRIVATE
void ImplInit( vcl::Window
* pParent
, WinBits nStyle
);
149 virtual void ApplySettings(vcl::RenderContext
& rRenderContext
) override
;
152 explicit ScrollBarBox( vcl::Window
* pParent
, WinBits nStyle
= 0 );
154 virtual void StateChanged( StateChangedType nType
) override
;
155 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
158 #endif // INCLUDED_VCL_SCRBAR_HXX
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */