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