1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _SV_SCRBAR_HXX 25 #define _SV_SCRBAR_HXX 26 27 #include <vcl/sv.h> 28 #include <vcl/dllapi.h> 29 #include <vcl/ctrl.hxx> 30 31 class AutoTimer; 32 33 // ------------------- 34 // - ScrollBar-Types - 35 // ------------------- 36 37 enum ScrollType { SCROLL_DONTKNOW, SCROLL_LINEUP, SCROLL_LINEDOWN, 38 SCROLL_PAGEUP, SCROLL_PAGEDOWN, SCROLL_DRAG, SCROLL_SET }; 39 40 // ------------- 41 // - ScrollBar - 42 // ------------- 43 struct ImplScrollBarData; 44 45 class VCL_DLLPUBLIC ScrollBar : public Control 46 { 47 private: 48 Rectangle maBtn1Rect; 49 Rectangle maBtn2Rect; 50 Rectangle maPage1Rect; 51 Rectangle maPage2Rect; 52 Rectangle maThumbRect; 53 ImplScrollBarData* mpData; 54 long mnStartPos; 55 long mnMouseOff; 56 long mnThumbPixRange; 57 long mnThumbPixPos; 58 long mnThumbPixSize; 59 long mnMinRange; 60 long mnMaxRange; 61 long mnThumbPos; 62 long mnVisibleSize; 63 long mnLineSize; 64 long mnPageSize; 65 long mnDelta; 66 sal_uInt16 mnDragDraw; 67 sal_uInt16 mnStateFlags; 68 ScrollType meScrollType; 69 ScrollType meDDScrollType; 70 sal_Bool mbCalcSize; 71 sal_Bool mbFullDrag; 72 Link maScrollHdl; 73 Link maEndScrollHdl; 74 75 SAL_DLLPRIVATE Rectangle* ImplFindPartRect( const Point& rPt ); 76 using Window::ImplInit; 77 SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); 78 SAL_DLLPRIVATE void ImplInitStyle( WinBits nStyle ); 79 SAL_DLLPRIVATE void ImplLoadRes( const ResId& rResId ); 80 SAL_DLLPRIVATE void ImplUpdateRects( sal_Bool bUpdate = sal_True ); 81 SAL_DLLPRIVATE long ImplCalcThumbPos( long nPixPos ); 82 SAL_DLLPRIVATE long ImplCalcThumbPosPix( long nPos ); 83 SAL_DLLPRIVATE void ImplCalc( sal_Bool bUpdate = sal_True ); 84 SAL_DLLPRIVATE void ImplDraw( sal_uInt16 nDrawFlags, OutputDevice* pOutDev ); 85 using Window::ImplScroll; 86 SAL_DLLPRIVATE long ImplScroll( long nNewPos, sal_Bool bCallEndScroll ); 87 SAL_DLLPRIVATE long ImplDoAction( sal_Bool bCallEndScroll ); 88 SAL_DLLPRIVATE void ImplDoMouseAction( const Point& rPos, sal_Bool bCallAction = sal_True ); 89 SAL_DLLPRIVATE void ImplInvert(); 90 SAL_DLLPRIVATE sal_Bool ImplDrawNative( sal_uInt16 nDrawFlags ); 91 SAL_DLLPRIVATE void ImplDragThumb( const Point& rMousePos ); 92 DECL_DLLPRIVATE_LINK( ImplTimerHdl, Timer* ); 93 DECL_DLLPRIVATE_LINK( ImplAutoTimerHdl, AutoTimer* ); 94 95 public: 96 explicit ScrollBar( Window* pParent, WinBits nStyle = WB_VERT ); 97 explicit ScrollBar( Window* pParent, const ResId& ); 98 virtual ~ScrollBar(); 99 100 virtual void MouseButtonDown( const MouseEvent& rMEvt ); 101 virtual void Tracking( const TrackingEvent& rTEvt ); 102 virtual void KeyInput( const KeyEvent& rKEvt ); 103 virtual void Paint( const Rectangle& rRect ); 104 virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ); 105 virtual void Resize(); 106 virtual void StateChanged( StateChangedType nType ); 107 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 108 virtual long PreNotify( NotifyEvent& rNEvt ); 109 virtual void GetFocus(); 110 virtual void LoseFocus(); 111 112 using Window::Scroll; 113 virtual void Scroll(); 114 virtual void EndScroll(); 115 116 long DoScroll( long nNewPos ); 117 long DoScrollAction( ScrollType eScrollType ); 118 EnableDrag(sal_Bool bEnable=sal_True)119 void EnableDrag( sal_Bool bEnable = sal_True ) 120 { mbFullDrag = bEnable; } IsDragEnabled() const121 sal_Bool IsDragEnabled() const { return mbFullDrag; } 122 123 void SetRangeMin( long nNewRange ); GetRangeMin() const124 long GetRangeMin() const { return mnMinRange; } 125 void SetRangeMax( long nNewRange ); GetRangeMax() const126 long GetRangeMax() const { return mnMaxRange; } 127 void SetRange( const Range& rRange ); GetRange() const128 Range GetRange() const { return Range( GetRangeMin(), GetRangeMax() ); } 129 void SetThumbPos( long nThumbPos ); GetThumbPos() const130 long GetThumbPos() const { return mnThumbPos; } SetLineSize(long nNewSize)131 void SetLineSize( long nNewSize ) { mnLineSize = nNewSize; } GetLineSize() const132 long GetLineSize() const { return mnLineSize; } SetPageSize(long nNewSize)133 void SetPageSize( long nNewSize ) { mnPageSize = nNewSize; } GetPageSize() const134 long GetPageSize() const { return mnPageSize; } 135 void SetVisibleSize( long nNewSize ); GetVisibleSize() const136 long GetVisibleSize() const { return mnVisibleSize; } 137 GetDelta() const138 long GetDelta() const { return mnDelta; } GetType() const139 ScrollType GetType() const { return meScrollType; } 140 SetScrollHdl(const Link & rLink)141 void SetScrollHdl( const Link& rLink ) { maScrollHdl = rLink; } GetScrollHdl() const142 const Link& GetScrollHdl() const { return maScrollHdl; } SetEndScrollHdl(const Link & rLink)143 void SetEndScrollHdl( const Link& rLink ) { maEndScrollHdl = rLink; } GetEndScrollHdl() const144 const Link& GetEndScrollHdl() const { return maEndScrollHdl; } 145 }; 146 147 // ---------------- 148 // - ScrollBarBox - 149 // ---------------- 150 151 class VCL_DLLPUBLIC ScrollBarBox : public Window 152 { 153 private: 154 using Window::ImplInit; 155 SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle ); 156 SAL_DLLPRIVATE void ImplInitSettings(); 157 158 public: 159 explicit ScrollBarBox( Window* pParent, WinBits nStyle = 0 ); 160 explicit ScrollBarBox( Window* pParent, const ResId& ); 161 162 virtual void StateChanged( StateChangedType nType ); 163 virtual void DataChanged( const DataChangedEvent& rDCEvt ); 164 }; 165 166 #endif // _SV_SCRBAR_HXX 167 168