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
34 };
35 
36 
37 struct ImplScrollBarData;
38 
40 {
41 private:
48  std::unique_ptr<ImplScrollBarData> mpData;
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 tools::Long ImplCalcThumbPos( tools::Long nPixPos );
74  SAL_DLLPRIVATE tools::Long ImplCalcThumbPosPix( tools::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 tools::Long ImplScroll( tools::Long nNewPos, bool bCallEndScroll );
79  SAL_DLLPRIVATE tools::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 SystemTextColorFlags);
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, SystemTextColorFlags 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  tools::Long DoScroll( tools::Long nNewPos );
111  tools::Long DoScrollAction( ScrollType eScrollType );
112 
113  void EnableDrag() { mbFullDrag = true; }
114 
115  void SetRangeMin( tools::Long nNewRange );
116  tools::Long GetRangeMin() const { return mnMinRange; }
117  void SetRangeMax( tools::Long nNewRange );
118  tools::Long GetRangeMax() const { return mnMaxRange; }
119  void SetRange( const Range& rRange );
120  Range GetRange() const { return Range( GetRangeMin(), GetRangeMax() ); }
121  void SetThumbPos( tools::Long nThumbPos );
122  tools::Long GetThumbPos() const { return mnThumbPos; }
123  void SetLineSize( tools::Long nNewSize ) { mnLineSize = nNewSize; }
124  tools::Long GetLineSize() const { return mnLineSize; }
125  void SetPageSize( tools::Long nNewSize ) { mnPageSize = nNewSize; }
126  tools::Long GetPageSize() const { return mnPageSize; }
127  void SetVisibleSize( tools::Long nNewSize );
128  tools::Long GetVisibleSize() const { return mnVisibleSize; }
129 
130  tools::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: */
tools::Long mnMaxRange
Definition: scrbar.hxx:55
virtual void Move()
Definition: window.cxx:1830
tools::Long mnStartPos
Definition: scrbar.hxx:49
tools::Long GetRangeMax() const
Definition: scrbar.hxx:118
Range GetRange() const
Definition: scrbar.hxx:120
DECL_DLLPRIVATE_LINK(ImplHandlePaintHdl, Timer *, void)
virtual void MouseButtonDown(const MouseEvent &rMEvt)
Definition: mouse.cxx:419
Link< ScrollBar *, void > maEndScrollHdl
Definition: scrbar.hxx:66
bool mbFullDrag
Definition: scrbar.hxx:64
tools::Long mnLineSize
Definition: scrbar.hxx:58
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
long Long
tools::Long mnVisibleSize
Definition: scrbar.hxx:57
virtual void StateChanged(StateChangedType nStateChange) override
Definition: ctrl.cxx:255
Link< ScrollBar *, void > maScrollHdl
Definition: scrbar.hxx:65
tools::Rectangle maPage2Rect
Definition: scrbar.hxx:45
tools::Long GetLineSize() const
Definition: scrbar.hxx:124
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: ctrl.cxx:412
tools::Long mnPageSize
Definition: scrbar.hxx:59
std::unique_ptr< ImplScrollBarData > mpData
Definition: scrbar.hxx:48
tools::Long mnDelta
Definition: scrbar.hxx:60
StateChangedType
Definition: window.hxx:289
virtual void Draw(::OutputDevice *pDev, const Point &rPos, SystemTextColorFlags nFlags)
Definition: window.cxx:1826
sal_Int64 WinBits
tools::Long mnThumbPixRange
Definition: scrbar.hxx:51
void SetPageSize(tools::Long nNewSize)
Definition: scrbar.hxx:125
tools::Rectangle maThumbRect
Definition: scrbar.hxx:46
virtual void Tracking(const TrackingEvent &rTEvt)
Definition: window.cxx:1929
tools::Rectangle maBtn1Rect
Definition: scrbar.hxx:42
tools::Long GetRangeMin() const
Definition: scrbar.hxx:116
SystemTextColorFlags
ScrollType meScrollType
Definition: scrbar.hxx:62
tools::Rectangle maTrackRect
Definition: scrbar.hxx:47
void SetLineSize(tools::Long nNewSize)
Definition: scrbar.hxx:123
tools::Long mnThumbPixPos
Definition: scrbar.hxx:52
tools::Long GetPageSize() const
Definition: scrbar.hxx:126
ScrollType GetType() const
Definition: scrbar.hxx:131
tools::Long mnThumbPos
Definition: scrbar.hxx:56
virtual bool PreNotify(NotifyEvent &rNEvt)
Definition: event.cxx:52
virtual void ApplySettings(vcl::RenderContext &rRenderContext)
Definition: window.cxx:3840
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:168
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: ctrl.cxx:57
SAL_DLLPRIVATE void ImplScroll(const tools::Rectangle &rRect, tools::Long nHorzScroll, tools::Long nVertScroll, ScrollFlags nFlags)
Definition: paint.cxx:1656
virtual void LoseFocus()
Definition: window.cxx:1852
tools::Rectangle maBtn2Rect
Definition: scrbar.hxx:43
void SetEndScrollHdl(const Link< ScrollBar *, void > &rLink)
Definition: scrbar.hxx:135
tools::Long GetThumbPos() const
Definition: scrbar.hxx:122
const Link< ScrollBar *, void > & GetScrollHdl() const
Definition: scrbar.hxx:134
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1802
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:935
tools::Long mnMinRange
Definition: scrbar.hxx:54
virtual Size GetOptimalSize() const override
Definition: ctrl.cxx:368
virtual void Resize() override
Definition: ctrl.cxx:73
virtual void Scroll(tools::Long nHorzScroll, tools::Long nVertScroll, ScrollFlags nFlags=ScrollFlags::NONE)
Definition: window.cxx:2941
Definition: ctrl.hxx:81
virtual void GetFocus()
Definition: window.cxx:1838
bool mbCalcSize
Definition: scrbar.hxx:63
void SetScrollHdl(const Link< ScrollBar *, void > &rLink)
Definition: scrbar.hxx:133
QPRO_FUNC_TYPE nType
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: paint.cxx:1041
sal_uInt16 mnStateFlags
Definition: scrbar.hxx:61
tools::Long mnThumbPixSize
Definition: scrbar.hxx:53
void EnableDrag()
Definition: scrbar.hxx:113
tools::Long GetDelta() const
Definition: scrbar.hxx:130
virtual void StateChanged(StateChangedType nStateChange)
Definition: window.cxx:1937
tools::Long GetVisibleSize() const
Definition: scrbar.hxx:128
Definition: timer.hxx:26
tools::Long mnMouseOff
Definition: scrbar.hxx:50
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:36