Avoid potential negative array index access to cached text.
[LibreOffice.git] / vcl / inc / slider.hxx
blob73a0dc0a2008f444514682689b63b4d90b46f60c
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/ctrl.hxx>
25 class Slider final : public Control
27 private:
28 tools::Rectangle maChannel1Rect;
29 tools::Rectangle maChannel2Rect;
30 tools::Rectangle maThumbRect;
31 tools::Long mnStartPos;
32 tools::Long mnMouseOff;
33 tools::Long mnThumbPixOffset;
34 tools::Long mnThumbPixRange;
35 tools::Long mnThumbPixPos;
36 tools::Long mnThumbSize;
37 tools::Long mnChannelPixRange;
38 tools::Long mnChannelPixTop;
39 tools::Long mnChannelPixBottom;
40 tools::Long mnMinRange;
41 tools::Long mnMaxRange;
42 tools::Long mnThumbPos;
43 tools::Long mnLineSize;
44 tools::Long mnPageSize;
45 sal_uInt16 mnStateFlags;
46 ScrollType meScrollType;
47 bool mbCalcSize;
49 Link<Slider*,void> maSlideHdl;
51 using Control::ImplInitSettings;
52 using Window::ImplInit;
53 void ImplInit( vcl::Window* pParent, WinBits nStyle );
54 void ImplInitSettings();
55 void ImplUpdateRects( bool bUpdate = true );
56 tools::Long ImplCalcThumbPos( tools::Long nPixPos ) const;
57 tools::Long ImplCalcThumbPosPix( tools::Long nPos ) const;
58 void ImplCalc( bool bUpdate = true );
59 void ImplDraw(vcl::RenderContext& rRenderContext);
60 bool ImplIsPageUp( const Point& rPos ) const;
61 bool ImplIsPageDown( const Point& rPos ) const;
62 tools::Long ImplSlide( tools::Long nNewPos );
63 tools::Long ImplDoAction( );
64 void ImplDoMouseAction( const Point& rPos, bool bCallAction );
65 void ImplDoSlide( tools::Long nNewPos );
66 void ImplDoSlideAction( ScrollType eScrollType );
68 public:
69 Slider( vcl::Window* pParent, WinBits nStyle);
70 virtual ~Slider() override;
71 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
72 virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
73 virtual void Tracking( const TrackingEvent& rTEvt ) override;
74 virtual void KeyInput( const KeyEvent& rKEvt ) override;
75 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
76 virtual void Resize() override;
77 virtual void StateChanged( StateChangedType nType ) override;
78 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
80 void Slide();
82 void SetRangeMin(tools::Long nNewRange);
83 tools::Long GetRangeMin() const { return mnMinRange; }
84 void SetRangeMax(tools::Long nNewRange);
85 tools::Long GetRangeMax() const { return mnMaxRange; }
86 void SetRange( const Range& rRange );
87 void SetThumbPos( tools::Long nThumbPos );
88 tools::Long GetThumbPos() const { return mnThumbPos; }
89 void SetLineSize( tools::Long nNewSize ) { mnLineSize = nNewSize; }
90 tools::Long GetLineSize() const { return mnLineSize; }
91 void SetPageSize( tools::Long nNewSize ) { mnPageSize = nNewSize; }
92 tools::Long GetPageSize() const { return mnPageSize; }
94 Size CalcWindowSizePixel() const;
96 void SetSlideHdl( const Link<Slider*,void>& rLink ) { maSlideHdl = rLink; }
99 #endif // INCLUDED_VCL_SLIDER_HXX
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */