LibreOffice Module vcl (master)  1
scrbar.hxx
Go to the documentation of this file.
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 <vcl/dllapi.h>
24 #include <vcl/ctrl.hxx>
25 #include <memory>
26 
27 
28 enum class ScrollType
29 {
30  DontKnow,
33  Drag, Set
34 };
35 
36 
37 struct ImplScrollBarData;
38 
40 {
41 private:
48  std::unique_ptr<ImplScrollBarData> mpData;
49  long mnStartPos;
50  long mnMouseOff;
54  long mnMinRange;
55  long mnMaxRange;
56  long mnThumbPos;
58  long mnLineSize;
59  long mnPageSize;
60  long mnDelta;
61  sal_uInt16 mnStateFlags;
63  bool mbCalcSize;
64  bool mbFullDrag;
67 
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 );
86 
87 public:
88  explicit ScrollBar( vcl::Window* pParent, WinBits nStyle = WB_VERT );
89  virtual ~ScrollBar() override;
90  virtual void dispose() override;
91 
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;
105 
106  using Window::Scroll;
107  void Scroll();
108  virtual void EndScroll();
109 
110  long DoScroll( long nNewPos );
111  long DoScrollAction( ScrollType eScrollType );
112 
113  void EnableDrag() { mbFullDrag = true; }
114 
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; }
129 
130  long GetDelta() const { return mnDelta; }
131  ScrollType GetType() const { return meScrollType; }
132 
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; }
136 
137  virtual Size GetOptimalSize() const override;
138 };
139 
140 
142 {
143 private:
144  using Window::ImplInit;
145  SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
146 
147  virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
148 
149 public:
150  explicit ScrollBarBox( vcl::Window* pParent, WinBits nStyle = 0 );
151 
152  virtual void StateChanged( StateChangedType nType ) override;
153  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
154 };
155 
156 #endif // INCLUDED_VCL_SCRBAR_HXX
157 
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
long mnThumbPixRange
Definition: scrbar.hxx:51
virtual void Move()
Definition: window.cxx:1797
long GetVisibleSize() const
Definition: scrbar.hxx:128
Range GetRange() const
Definition: scrbar.hxx:120
DECL_DLLPRIVATE_LINK(ImplHandlePaintHdl, Timer *, void)
virtual void MouseButtonDown(const MouseEvent &rMEvt)
Definition: mouse.cxx:413
Link< ScrollBar *, void > maEndScrollHdl
Definition: scrbar.hxx:66
bool mbFullDrag
Definition: scrbar.hxx:64
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
virtual void StateChanged(StateChangedType nStateChange) override
Definition: ctrl.cxx:260
Link< ScrollBar *, void > maScrollHdl
Definition: scrbar.hxx:65
long GetThumbPos() const
Definition: scrbar.hxx:122
tools::Rectangle maPage2Rect
Definition: scrbar.hxx:45
long mnMouseOff
Definition: scrbar.hxx:50
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: ctrl.cxx:418
std::unique_ptr< ImplScrollBarData > mpData
Definition: scrbar.hxx:48
long mnVisibleSize
Definition: scrbar.hxx:57
long mnThumbPixSize
Definition: scrbar.hxx:53
StateChangedType
Definition: window.hxx:311
sal_Int64 WinBits
long mnStartPos
Definition: scrbar.hxx:49
long GetDelta() const
Definition: scrbar.hxx:130
tools::Rectangle maThumbRect
Definition: scrbar.hxx:46
virtual void Tracking(const TrackingEvent &rTEvt)
Definition: window.cxx:1896
tools::Rectangle maBtn1Rect
Definition: scrbar.hxx:42
ScrollType meScrollType
Definition: scrbar.hxx:62
tools::Rectangle maTrackRect
Definition: scrbar.hxx:47
virtual void Draw(::OutputDevice *pDev, const Point &rPos, const Size &rSize, DrawFlags nFlags)
Definition: window.cxx:1793
ScrollType GetType() const
Definition: scrbar.hxx:131
long mnThumbPixPos
Definition: scrbar.hxx:52
virtual bool PreNotify(NotifyEvent &rNEvt)
Definition: event.cxx:51
long mnMinRange
Definition: scrbar.hxx:54
long GetLineSize() const
Definition: scrbar.hxx:124
DrawFlags
Definition: window.hxx:354
virtual void ApplySettings(vcl::RenderContext &rRenderContext)
Definition: window.cxx:3805
QPRO_FUNC_TYPE const nType
ScrollType
Definition: scrbar.hxx:28
tools::Rectangle maPage1Rect
Definition: scrbar.hxx:44
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
void SetPageSize(long nNewSize)
Definition: scrbar.hxx:125
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: ctrl.cxx:59
long GetRangeMin() const
Definition: scrbar.hxx:116
long GetPageSize() const
Definition: scrbar.hxx:126
virtual void LoseFocus()
Definition: window.cxx:1819
long mnPageSize
Definition: scrbar.hxx:59
tools::Rectangle maBtn2Rect
Definition: scrbar.hxx:43
long mnLineSize
Definition: scrbar.hxx:58
void SetEndScrollHdl(const Link< ScrollBar *, void > &rLink)
Definition: scrbar.hxx:135
void SetLineSize(long nNewSize)
Definition: scrbar.hxx:123
const Link< ScrollBar *, void > & GetScrollHdl() const
Definition: scrbar.hxx:134
long mnThumbPos
Definition: scrbar.hxx:56
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1769
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:932
virtual Size GetOptimalSize() const override
Definition: ctrl.cxx:374
virtual void Scroll(long nHorzScroll, long nVertScroll, ScrollFlags nFlags=ScrollFlags::NONE)
Definition: window.cxx:2945
virtual void Resize() override
Definition: ctrl.cxx:74
long mnDelta
Definition: scrbar.hxx:60
Definition: ctrl.hxx:33
long GetRangeMax() const
Definition: scrbar.hxx:118
virtual void GetFocus()
Definition: window.cxx:1805
bool mbCalcSize
Definition: scrbar.hxx:63
SAL_DLLPRIVATE void ImplScroll(const tools::Rectangle &rRect, long nHorzScroll, long nVertScroll, ScrollFlags nFlags)
Definition: paint.cxx:1655
void SetScrollHdl(const Link< ScrollBar *, void > &rLink)
Definition: scrbar.hxx:133
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: paint.cxx:1013
sal_uInt16 mnStateFlags
Definition: scrbar.hxx:61
void EnableDrag()
Definition: scrbar.hxx:113
long mnMaxRange
Definition: scrbar.hxx:55
virtual void StateChanged(StateChangedType nStateChange)
Definition: window.cxx:1904
Definition: timer.hxx:26
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:35