Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / vcl / slider.hxx
blob996fc136b125b4bfaa811b3b8f298ae44a937d91
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 #ifndef INCLUDED_VCL_SLIDER_HXX
21 #define INCLUDED_VCL_SLIDER_HXX
23 #include <vcl/dllapi.h>
24 #include <vcl/ctrl.hxx>
25 #include <vcl/scrbar.hxx>
26 #include <vcl/field.hxx>
28 class VCL_DLLPUBLIC Slider : public Control
30 private:
31 tools::Rectangle maChannel1Rect;
32 tools::Rectangle maChannel2Rect;
33 tools::Rectangle maThumbRect;
34 long mnStartPos;
35 long mnMouseOff;
36 long mnThumbPixOffset;
37 long mnThumbPixRange;
38 long mnThumbPixPos;
39 long mnChannelPixOffset;
40 long mnChannelPixRange;
41 long mnChannelPixTop;
42 long mnChannelPixBottom;
43 long mnMinRange;
44 long mnMaxRange;
45 long mnThumbPos;
46 long mnLineSize;
47 long mnPageSize;
48 long mnDelta;
49 sal_uInt16 mnStateFlags;
50 ScrollType meScrollType;
51 bool mbCalcSize;
52 bool mbFullDrag;
54 VclPtr<NumericField> mpLinkedField;
56 Link<Slider*,void> maSlideHdl;
57 Link<Slider*,void> maEndSlideHdl;
59 DECL_LINK(LinkedFieldModifyHdl, Edit&, void);
60 DECL_LINK(LinkedFieldLoseFocusHdl, Control&, void);
61 DECL_LINK(LinkedFieldSpinnerHdl, SpinField&, void);
63 using Control::ImplInitSettings;
64 using Window::ImplInit;
65 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
66 SAL_DLLPRIVATE void ImplInitSettings();
67 SAL_DLLPRIVATE void ImplUpdateRects( bool bUpdate = true );
68 SAL_DLLPRIVATE long ImplCalcThumbPos( long nPixPos );
69 SAL_DLLPRIVATE long ImplCalcThumbPosPix( long nPos );
70 SAL_DLLPRIVATE void ImplCalc( bool bUpdate = true );
71 SAL_DLLPRIVATE void ImplDraw(vcl::RenderContext& rRenderContext);
72 SAL_DLLPRIVATE bool ImplIsPageUp( const Point& rPos );
73 SAL_DLLPRIVATE bool ImplIsPageDown( const Point& rPos );
74 SAL_DLLPRIVATE long ImplSlide( long nNewPos, bool bCallEndSlide );
75 SAL_DLLPRIVATE long ImplDoAction( bool bCallEndSlide );
76 SAL_DLLPRIVATE void ImplDoMouseAction( const Point& rPos, bool bCallAction );
77 SAL_DLLPRIVATE void ImplDoSlide( long nNewPos );
78 SAL_DLLPRIVATE void ImplDoSlideAction( ScrollType eScrollType );
79 SAL_DLLPRIVATE void ImplUpdateLinkedField();
81 public:
82 Slider( vcl::Window* pParent, WinBits nStyle);
83 virtual ~Slider() override;
84 virtual void dispose() override;
85 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
86 virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
87 virtual void Tracking( const TrackingEvent& rTEvt ) override;
88 virtual void KeyInput( const KeyEvent& rKEvt ) override;
89 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
90 virtual void Resize() override;
91 virtual void StateChanged( StateChangedType nType ) override;
92 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
94 void Slide();
95 void EndSlide();
97 void SetRangeMin(long nNewRange);
98 long GetRangeMin() const { return mnMinRange; }
99 void SetRangeMax(long nNewRange);
100 long GetRangeMax() const { return mnMaxRange; }
101 void SetRange( const Range& rRange );
102 void SetThumbPos( long nThumbPos );
103 long GetThumbPos() const { return mnThumbPos; }
104 void SetLineSize( long nNewSize ) { mnLineSize = nNewSize; }
105 long GetLineSize() const { return mnLineSize; }
106 void SetPageSize( long nNewSize ) { mnPageSize = nNewSize; }
107 long GetPageSize() const { return mnPageSize; }
109 Size CalcWindowSizePixel();
111 void SetLinkedField(VclPtr<NumericField> const & pField);
113 void SetSlideHdl( const Link<Slider*,void>& rLink ) { maSlideHdl = rLink; }
114 void SetEndSlideHdl( const Link<Slider*,void>& rLink ) { maEndSlideHdl = rLink; }
117 #endif // INCLUDED_VCL_SLIDER_HXX
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */