LibreOffice Module vcl (master)  1
slider.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_SLIDER_HXX
21 #define INCLUDED_VCL_SLIDER_HXX
22 
23 #include <vcl/dllapi.h>
24 #include <vcl/ctrl.hxx>
25 #include <vcl/scrbar.hxx>
26 #include <vcl/field.hxx>
27 
28 class VCL_DLLPUBLIC Slider final : public Control
29 {
30 private:
34  long mnStartPos;
35  long mnMouseOff;
44  long mnMinRange;
45  long mnMaxRange;
46  long mnThumbPos;
47  long mnLineSize;
48  long mnPageSize;
49  sal_uInt16 mnStateFlags;
51  bool mbCalcSize;
53 
55 
58 
60  using Window::ImplInit;
61  SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
62  SAL_DLLPRIVATE void ImplInitSettings();
63  SAL_DLLPRIVATE void ImplUpdateRects( bool bUpdate = true );
64  SAL_DLLPRIVATE long ImplCalcThumbPos( long nPixPos );
65  SAL_DLLPRIVATE long ImplCalcThumbPosPix( long nPos );
66  SAL_DLLPRIVATE void ImplCalc( bool bUpdate = true );
67  SAL_DLLPRIVATE void ImplDraw(vcl::RenderContext& rRenderContext);
68  SAL_DLLPRIVATE bool ImplIsPageUp( const Point& rPos );
69  SAL_DLLPRIVATE bool ImplIsPageDown( const Point& rPos );
70  SAL_DLLPRIVATE long ImplSlide( long nNewPos, bool bCallEndSlide );
71  SAL_DLLPRIVATE long ImplDoAction( bool bCallEndSlide );
72  SAL_DLLPRIVATE void ImplDoMouseAction( const Point& rPos, bool bCallAction );
73  SAL_DLLPRIVATE void ImplDoSlide( long nNewPos );
74  SAL_DLLPRIVATE void ImplDoSlideAction( ScrollType eScrollType );
75  SAL_DLLPRIVATE void ImplUpdateLinkedField();
76 
77 public:
78  Slider( vcl::Window* pParent, WinBits nStyle);
79  virtual ~Slider() override;
80  virtual void dispose() override;
81  virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
82  virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
83  virtual void Tracking( const TrackingEvent& rTEvt ) override;
84  virtual void KeyInput( const KeyEvent& rKEvt ) override;
85  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
86  virtual void Resize() override;
87  virtual void StateChanged( StateChangedType nType ) override;
88  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
89 
90  void Slide();
91  void EndSlide();
92 
93  void SetRangeMin(long nNewRange);
94  long GetRangeMin() const { return mnMinRange; }
95  void SetRangeMax(long nNewRange);
96  long GetRangeMax() const { return mnMaxRange; }
97  void SetRange( const Range& rRange );
98  void SetThumbPos( long nThumbPos );
99  long GetThumbPos() const { return mnThumbPos; }
100  void SetLineSize( long nNewSize ) { mnLineSize = nNewSize; }
101  long GetLineSize() const { return mnLineSize; }
102  void SetPageSize( long nNewSize ) { mnPageSize = nNewSize; }
103  long GetPageSize() const { return mnPageSize; }
104  void SetScrollTypeSet(bool b) { mbScrollTypeSet = b; }
105 
106  Size CalcWindowSizePixel();
107 
108  void SetSlideHdl( const Link<Slider*,void>& rLink ) { maSlideHdl = rLink; }
109  void SetEndSlideHdl( const Link<Slider*,void>& rLink ) { maEndSlideHdl = rLink; }
110 };
111 
112 #endif // INCLUDED_VCL_SLIDER_HXX
113 
114 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
long mnStartPos
Definition: slider.hxx:34
void SetPageSize(long nNewSize)
Definition: slider.hxx:102
void SetSlideHdl(const Link< Slider *, void > &rLink)
Definition: slider.hxx:108
long GetLineSize() const
Definition: slider.hxx:101
long mnLineSize
Definition: slider.hxx:47
virtual void MouseButtonDown(const MouseEvent &rMEvt)
Definition: mouse.cxx:413
long GetRangeMin() const
Definition: slider.hxx:94
void SetEndSlideHdl(const Link< Slider *, void > &rLink)
Definition: slider.hxx:109
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
Link< Slider *, void > maSlideHdl
Definition: slider.hxx:56
virtual void StateChanged(StateChangedType nStateChange) override
Definition: ctrl.cxx:260
long mnThumbPixPos
Definition: slider.hxx:38
long GetThumbPos() const
Definition: slider.hxx:99
void SetLineSize(long nNewSize)
Definition: slider.hxx:100
virtual void MouseButtonUp(const MouseEvent &rMEvt)
Definition: mouse.cxx:420
long mnMouseOff
Definition: slider.hxx:35
StateChangedType
Definition: window.hxx:311
sal_Int64 WinBits
virtual void Tracking(const TrackingEvent &rTEvt)
Definition: window.cxx:1896
ScrollType meScrollType
Definition: slider.hxx:50
long mnPageSize
Definition: slider.hxx:48
long GetRangeMax() const
Definition: slider.hxx:96
VclPtr< NumericField > mpLinkedField
Definition: slider.hxx:54
tools::Rectangle maChannel1Rect
Definition: slider.hxx:31
long mnMinRange
Definition: slider.hxx:44
ScrollType
Definition: scrbar.hxx:28
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
long GetPageSize() const
Definition: slider.hxx:103
long mnThumbPixOffset
Definition: slider.hxx:36
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 mnChannelPixRange
Definition: slider.hxx:41
long mnThumbPos
Definition: slider.hxx:46
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
long mnThumbPixRange
Definition: slider.hxx:37
virtual void Resize() override
Definition: ctrl.cxx:74
Definition: ctrl.hxx:33
long mnThumbSize
Definition: slider.hxx:39
long mnChannelPixTop
Definition: slider.hxx:42
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
Definition: paint.cxx:1017
long mnMaxRange
Definition: slider.hxx:45
tools::Rectangle maThumbRect
Definition: slider.hxx:33
bool mbScrollTypeSet
Definition: slider.hxx:52
void ImplInitSettings()
Definition: ctrl.cxx:428
Slide
void SetScrollTypeSet(bool b)
Definition: slider.hxx:104
Link< Slider *, void > maEndSlideHdl
Definition: slider.hxx:57
tools::Rectangle maChannel2Rect
Definition: slider.hxx:32
sal_uInt16 mnStateFlags
Definition: slider.hxx:49
long mnChannelPixOffset
Definition: slider.hxx:40
bool mbCalcSize
Definition: slider.hxx:51
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:35
long mnChannelPixBottom
Definition: slider.hxx:43