1*0d63794cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*0d63794cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*0d63794cSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*0d63794cSAndrew Rist * distributed with this work for additional information 6*0d63794cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*0d63794cSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*0d63794cSAndrew Rist * "License"); you may not use this file except in compliance 9*0d63794cSAndrew Rist * with the License. You may obtain a copy of the License at 10*0d63794cSAndrew Rist * 11*0d63794cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*0d63794cSAndrew Rist * 13*0d63794cSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*0d63794cSAndrew Rist * software distributed under the License is distributed on an 15*0d63794cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*0d63794cSAndrew Rist * KIND, either express or implied. See the License for the 17*0d63794cSAndrew Rist * specific language governing permissions and limitations 18*0d63794cSAndrew Rist * under the License. 19*0d63794cSAndrew Rist * 20*0d63794cSAndrew Rist *************************************************************/ 21*0d63794cSAndrew Rist 22*0d63794cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _SV_SLIDER_HXX 25cdf0e10cSrcweir #define _SV_SLIDER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <vcl/sv.h> 28cdf0e10cSrcweir #include <vcl/dllapi.h> 29cdf0e10cSrcweir #include <vcl/ctrl.hxx> 30cdf0e10cSrcweir // for enum ScrollType 31cdf0e10cSrcweir #include <vcl/scrbar.hxx> 32cdf0e10cSrcweir 33cdf0e10cSrcweir // ---------- 34cdf0e10cSrcweir // - Slider - 35cdf0e10cSrcweir // ---------- 36cdf0e10cSrcweir 37cdf0e10cSrcweir class VCL_DLLPUBLIC Slider : public Control 38cdf0e10cSrcweir { 39cdf0e10cSrcweir private: 40cdf0e10cSrcweir Rectangle maChannel1Rect; 41cdf0e10cSrcweir Rectangle maChannel2Rect; 42cdf0e10cSrcweir Rectangle maThumbRect; 43cdf0e10cSrcweir long mnStartPos; 44cdf0e10cSrcweir long mnMouseOff; 45cdf0e10cSrcweir long mnThumbPixOffset; 46cdf0e10cSrcweir long mnThumbPixRange; 47cdf0e10cSrcweir long mnThumbPixPos; 48cdf0e10cSrcweir long mnChannelPixOffset; 49cdf0e10cSrcweir long mnChannelPixRange; 50cdf0e10cSrcweir long mnChannelPixTop; 51cdf0e10cSrcweir long mnChannelPixBottom; 52cdf0e10cSrcweir long mnMinRange; 53cdf0e10cSrcweir long mnMaxRange; 54cdf0e10cSrcweir long mnThumbPos; 55cdf0e10cSrcweir long mnLineSize; 56cdf0e10cSrcweir long mnPageSize; 57cdf0e10cSrcweir long mnDelta; 58cdf0e10cSrcweir sal_uInt16 mnDragDraw; 59cdf0e10cSrcweir sal_uInt16 mnStateFlags; 60cdf0e10cSrcweir ScrollType meScrollType; 61cdf0e10cSrcweir sal_Bool mbCalcSize; 62cdf0e10cSrcweir sal_Bool mbFullDrag; 63cdf0e10cSrcweir Link maSlideHdl; 64cdf0e10cSrcweir Link maEndSlideHdl; 65cdf0e10cSrcweir 66cdf0e10cSrcweir using Control::ImplInitSettings; 67cdf0e10cSrcweir using Window::ImplInit; 68cdf0e10cSrcweir SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); 69cdf0e10cSrcweir SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); 70cdf0e10cSrcweir SAL_DLLPRIVATE void ImplInitSettings(); 71cdf0e10cSrcweir SAL_DLLPRIVATE void ImplUpdateRects( sal_Bool bUpdate = sal_True ); 72cdf0e10cSrcweir SAL_DLLPRIVATE long ImplCalcThumbPos( long nPixPos ); 73cdf0e10cSrcweir SAL_DLLPRIVATE long ImplCalcThumbPosPix( long nPos ); 74cdf0e10cSrcweir SAL_DLLPRIVATE void ImplCalc( sal_Bool bUpdate = sal_True ); 75cdf0e10cSrcweir SAL_DLLPRIVATE void ImplDraw( sal_uInt16 nDrawFlags ); 76cdf0e10cSrcweir SAL_DLLPRIVATE sal_Bool ImplIsPageUp( const Point& rPos ); 77cdf0e10cSrcweir SAL_DLLPRIVATE sal_Bool ImplIsPageDown( const Point& rPos ); 78cdf0e10cSrcweir SAL_DLLPRIVATE long ImplSlide( long nNewPos, sal_Bool bCallEndSlide ); 79cdf0e10cSrcweir SAL_DLLPRIVATE long ImplDoAction( sal_Bool bCallEndSlide ); 80cdf0e10cSrcweir SAL_DLLPRIVATE void ImplDoMouseAction( const Point& rPos, sal_Bool bCallAction = sal_True ); 81cdf0e10cSrcweir SAL_DLLPRIVATE long ImplDoSlide( long nNewPos ); 82cdf0e10cSrcweir SAL_DLLPRIVATE long ImplDoSlideAction( ScrollType eScrollType ); 83cdf0e10cSrcweir 84cdf0e10cSrcweir public: 85cdf0e10cSrcweir Slider( Window* pParent, WinBits nStyle = WB_HORZ ); 86cdf0e10cSrcweir Slider( Window* pParent, const ResId& rResId ); 87cdf0e10cSrcweir 88cdf0e10cSrcweir virtual void MouseButtonDown( const MouseEvent& rMEvt ); 89cdf0e10cSrcweir virtual void MouseButtonUp( const MouseEvent& rMEvt ); 90cdf0e10cSrcweir virtual void Tracking( const TrackingEvent& rTEvt ); 91cdf0e10cSrcweir virtual void KeyInput( const KeyEvent& rKEvt ); 92cdf0e10cSrcweir virtual void Paint( const Rectangle& rRect ); 93cdf0e10cSrcweir virtual void Resize(); 94cdf0e10cSrcweir virtual void RequestHelp( const HelpEvent& rHEvt ); 95cdf0e10cSrcweir virtual void StateChanged( StateChangedType nType ); 96cdf0e10cSrcweir virtual void DataChanged( const DataChangedEvent& rDCEvt ); 97cdf0e10cSrcweir 98cdf0e10cSrcweir virtual void Slide(); 99cdf0e10cSrcweir virtual void EndSlide(); 100cdf0e10cSrcweir EnableDrag(sal_Bool bEnable=sal_True)101cdf0e10cSrcweir void EnableDrag( sal_Bool bEnable = sal_True ) 102cdf0e10cSrcweir { mbFullDrag = bEnable; } IsDragEnabled() const103cdf0e10cSrcweir sal_Bool IsDragEnabled() const { return mbFullDrag; } 104cdf0e10cSrcweir 105cdf0e10cSrcweir void SetRangeMin( long nNewRange ); GetRangeMin() const106cdf0e10cSrcweir long GetRangeMin() const { return mnMinRange; } 107cdf0e10cSrcweir void SetRangeMax( long nNewRange ); GetRangeMax() const108cdf0e10cSrcweir long GetRangeMax() const { return mnMaxRange; } 109cdf0e10cSrcweir void SetRange( const Range& rRange ); GetRange() const110cdf0e10cSrcweir Range GetRange() const { return Range( GetRangeMin(), GetRangeMax() ); } 111cdf0e10cSrcweir void SetThumbPos( long nThumbPos ); GetThumbPos() const112cdf0e10cSrcweir long GetThumbPos() const { return mnThumbPos; } SetLineSize(long nNewSize)113cdf0e10cSrcweir void SetLineSize( long nNewSize ) { mnLineSize = nNewSize; } GetLineSize() const114cdf0e10cSrcweir long GetLineSize() const { return mnLineSize; } SetPageSize(long nNewSize)115cdf0e10cSrcweir void SetPageSize( long nNewSize ) { mnPageSize = nNewSize; } GetPageSize() const116cdf0e10cSrcweir long GetPageSize() const { return mnPageSize; } 117cdf0e10cSrcweir GetDelta() const118cdf0e10cSrcweir long GetDelta() const { return mnDelta; } 119cdf0e10cSrcweir 120cdf0e10cSrcweir Size CalcWindowSizePixel(); 121cdf0e10cSrcweir SetSlideHdl(const Link & rLink)122cdf0e10cSrcweir void SetSlideHdl( const Link& rLink ) { maSlideHdl = rLink; } GetSlideHdl() const123cdf0e10cSrcweir const Link& GetSlideHdl() const { return maSlideHdl; } SetEndSlideHdl(const Link & rLink)124cdf0e10cSrcweir void SetEndSlideHdl( const Link& rLink ) { maEndSlideHdl = rLink; } GetEndSlideHdl() const125cdf0e10cSrcweir const Link& GetEndSlideHdl() const { return maEndSlideHdl; } 126cdf0e10cSrcweir }; 127cdf0e10cSrcweir 128cdf0e10cSrcweir #endif // _SV_SLIDER_HXX 129