xref: /AOO41X/main/vcl/source/window/scrwnd.cxx (revision 9f62ea84a806e17e6f2bbff75724a7257a0eb5d9)
1*9f62ea84SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9f62ea84SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9f62ea84SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9f62ea84SAndrew Rist  * distributed with this work for additional information
6*9f62ea84SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9f62ea84SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9f62ea84SAndrew Rist  * "License"); you may not use this file except in compliance
9*9f62ea84SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*9f62ea84SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*9f62ea84SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9f62ea84SAndrew Rist  * software distributed under the License is distributed on an
15*9f62ea84SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9f62ea84SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9f62ea84SAndrew Rist  * specific language governing permissions and limitations
18*9f62ea84SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*9f62ea84SAndrew Rist  *************************************************************/
21*9f62ea84SAndrew Rist 
22*9f62ea84SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // #include <math.h>
28cdf0e10cSrcweir #include <limits.h>
29cdf0e10cSrcweir #include <tools/time.hxx>
30cdf0e10cSrcweir #include <tools/debug.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <svids.hrc>
33cdf0e10cSrcweir #include <svdata.hxx>
34cdf0e10cSrcweir #include <scrwnd.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include <vcl/timer.hxx>
37cdf0e10cSrcweir #include <vcl/event.hxx>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #include <math.h>
40cdf0e10cSrcweir #include <limits.h>
41cdf0e10cSrcweir 
42cdf0e10cSrcweir // -----------
43cdf0e10cSrcweir // - Defines -
44cdf0e10cSrcweir // -----------
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #define WHEEL_WIDTH     25
47cdf0e10cSrcweir #define WHEEL_RADIUS    ((WHEEL_WIDTH) >> 1 )
48cdf0e10cSrcweir #define MAX_TIME        300
49cdf0e10cSrcweir #define MIN_TIME        20
50cdf0e10cSrcweir #define DEF_TIMEOUT     50
51cdf0e10cSrcweir 
52cdf0e10cSrcweir // -------------------
53cdf0e10cSrcweir // - ImplWheelWindow -
54cdf0e10cSrcweir // -------------------
55cdf0e10cSrcweir 
ImplWheelWindow(Window * pParent)56cdf0e10cSrcweir ImplWheelWindow::ImplWheelWindow( Window* pParent ) :
57cdf0e10cSrcweir             FloatingWindow  ( pParent, 0 ),
58cdf0e10cSrcweir             mnRepaintTime   ( 1UL ),
59cdf0e10cSrcweir             mnTimeout       ( DEF_TIMEOUT ),
60cdf0e10cSrcweir             mnWheelMode     ( WHEELMODE_NONE ),
61cdf0e10cSrcweir             mnActDist       ( 0UL ),
62cdf0e10cSrcweir             mnActDeltaX     ( 0L ),
63cdf0e10cSrcweir             mnActDeltaY     ( 0L )
64cdf0e10cSrcweir {
65cdf0e10cSrcweir     // we need a parent
66cdf0e10cSrcweir     DBG_ASSERT( pParent, "ImplWheelWindow::ImplWheelWindow(): Parent not set!" );
67cdf0e10cSrcweir 
68cdf0e10cSrcweir     const Size      aSize( pParent->GetOutputSizePixel() );
69cdf0e10cSrcweir     const sal_uInt16    nFlags = ImplGetSVData()->maWinData.mnAutoScrollFlags;
70cdf0e10cSrcweir     const sal_Bool      bHorz = ( nFlags & AUTOSCROLL_HORZ ) != 0;
71cdf0e10cSrcweir     const sal_Bool      bVert = ( nFlags & AUTOSCROLL_VERT ) != 0;
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     // calculate maximum speed distance
74cdf0e10cSrcweir     mnMaxWidth = (sal_uLong) ( 0.4 * hypot( (double) aSize.Width(), aSize.Height() ) );
75cdf0e10cSrcweir 
76cdf0e10cSrcweir     // create wheel window
77cdf0e10cSrcweir     SetTitleType( FLOATWIN_TITLE_NONE );
78cdf0e10cSrcweir     ImplCreateImageList();
79cdf0e10cSrcweir     ResMgr* pResMgr = ImplGetResMgr();
80cdf0e10cSrcweir     Bitmap aBmp;
81cdf0e10cSrcweir     if( pResMgr )
82cdf0e10cSrcweir         aBmp = Bitmap( ResId( SV_RESID_BITMAP_SCROLLMSK, *pResMgr ) );
83cdf0e10cSrcweir     ImplSetRegion( aBmp );
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     // set wheel mode
86cdf0e10cSrcweir     if( bHorz && bVert )
87cdf0e10cSrcweir         ImplSetWheelMode( WHEELMODE_VH );
88cdf0e10cSrcweir     else if( bHorz )
89cdf0e10cSrcweir         ImplSetWheelMode( WHEELMODE_H );
90cdf0e10cSrcweir     else
91cdf0e10cSrcweir         ImplSetWheelMode( WHEELMODE_V );
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     // init timer
94cdf0e10cSrcweir     mpTimer = new Timer;
95cdf0e10cSrcweir     mpTimer->SetTimeoutHdl( LINK( this, ImplWheelWindow, ImplScrollHdl ) );
96cdf0e10cSrcweir     mpTimer->SetTimeout( mnTimeout );
97cdf0e10cSrcweir     mpTimer->Start();
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     CaptureMouse();
100cdf0e10cSrcweir }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir // ------------------------------------------------------------------------
103cdf0e10cSrcweir 
~ImplWheelWindow()104cdf0e10cSrcweir ImplWheelWindow::~ImplWheelWindow()
105cdf0e10cSrcweir {
106cdf0e10cSrcweir 	ImplStop();
107cdf0e10cSrcweir     delete mpTimer;
108cdf0e10cSrcweir }
109cdf0e10cSrcweir 
110cdf0e10cSrcweir // ------------------------------------------------------------------------
111cdf0e10cSrcweir 
ImplStop()112cdf0e10cSrcweir void ImplWheelWindow::ImplStop()
113cdf0e10cSrcweir {
114cdf0e10cSrcweir     ReleaseMouse();
115cdf0e10cSrcweir     mpTimer->Stop();
116cdf0e10cSrcweir 	Show(sal_False);
117cdf0e10cSrcweir }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir // ------------------------------------------------------------------------
120cdf0e10cSrcweir 
ImplSetRegion(const Bitmap & rRegionBmp)121cdf0e10cSrcweir void ImplWheelWindow::ImplSetRegion( const Bitmap& rRegionBmp )
122cdf0e10cSrcweir {
123cdf0e10cSrcweir     Point           aPos( GetPointerPosPixel() );
124cdf0e10cSrcweir     const Size      aSize( rRegionBmp.GetSizePixel() );
125cdf0e10cSrcweir     Point           aPoint;
126cdf0e10cSrcweir     const Rectangle aRect( aPoint, aSize );
127cdf0e10cSrcweir 
128cdf0e10cSrcweir     maCenter = maLastMousePos = aPos;
129cdf0e10cSrcweir     aPos.X() -= aSize.Width() >> 1;
130cdf0e10cSrcweir     aPos.Y() -= aSize.Height() >> 1;
131cdf0e10cSrcweir 
132cdf0e10cSrcweir     SetPosSizePixel( aPos, aSize );
133cdf0e10cSrcweir     SetWindowRegionPixel( rRegionBmp.CreateRegion( COL_BLACK, aRect ) );
134cdf0e10cSrcweir }
135cdf0e10cSrcweir 
136cdf0e10cSrcweir // ------------------------------------------------------------------------
137cdf0e10cSrcweir 
ImplCreateImageList()138cdf0e10cSrcweir void ImplWheelWindow::ImplCreateImageList()
139cdf0e10cSrcweir {
140cdf0e10cSrcweir     ResMgr* pResMgr = ImplGetResMgr();
141cdf0e10cSrcweir     if( pResMgr )
142cdf0e10cSrcweir         maImgList.InsertFromHorizontalBitmap
143cdf0e10cSrcweir             ( ResId( SV_RESID_BITMAP_SCROLLBMP, *pResMgr ), 6, NULL );
144cdf0e10cSrcweir }
145cdf0e10cSrcweir 
146cdf0e10cSrcweir // ------------------------------------------------------------------------
147cdf0e10cSrcweir 
ImplSetWheelMode(sal_uLong nWheelMode)148cdf0e10cSrcweir void ImplWheelWindow::ImplSetWheelMode( sal_uLong nWheelMode )
149cdf0e10cSrcweir {
150cdf0e10cSrcweir     if( nWheelMode != mnWheelMode )
151cdf0e10cSrcweir     {
152cdf0e10cSrcweir         mnWheelMode = nWheelMode;
153cdf0e10cSrcweir 
154cdf0e10cSrcweir         if( WHEELMODE_NONE == mnWheelMode )
155cdf0e10cSrcweir         {
156cdf0e10cSrcweir             if( IsVisible() )
157cdf0e10cSrcweir                 Hide();
158cdf0e10cSrcweir         }
159cdf0e10cSrcweir         else
160cdf0e10cSrcweir         {
161cdf0e10cSrcweir             if( !IsVisible() )
162cdf0e10cSrcweir                 Show();
163cdf0e10cSrcweir 
164cdf0e10cSrcweir             ImplDrawWheel();
165cdf0e10cSrcweir         }
166cdf0e10cSrcweir     }
167cdf0e10cSrcweir }
168cdf0e10cSrcweir 
169cdf0e10cSrcweir // ------------------------------------------------------------------------
170cdf0e10cSrcweir 
ImplDrawWheel()171cdf0e10cSrcweir void ImplWheelWindow::ImplDrawWheel()
172cdf0e10cSrcweir {
173cdf0e10cSrcweir     sal_uInt16 nId;
174cdf0e10cSrcweir 
175cdf0e10cSrcweir     switch( mnWheelMode )
176cdf0e10cSrcweir     {
177cdf0e10cSrcweir         case( WHEELMODE_VH ):       nId = 1; break;
178cdf0e10cSrcweir         case( WHEELMODE_V    ):     nId = 2; break;
179cdf0e10cSrcweir         case( WHEELMODE_H    ):     nId = 3; break;
180cdf0e10cSrcweir         case( WHEELMODE_SCROLL_VH ):nId = 4; break;
181cdf0e10cSrcweir         case( WHEELMODE_SCROLL_V ): nId = 5; break;
182cdf0e10cSrcweir         case( WHEELMODE_SCROLL_H ): nId = 6; break;
183cdf0e10cSrcweir         default:                    nId = 0; break;
184cdf0e10cSrcweir     }
185cdf0e10cSrcweir 
186cdf0e10cSrcweir     if( nId )
187cdf0e10cSrcweir         DrawImage( Point(), maImgList.GetImage( nId ) );
188cdf0e10cSrcweir }
189cdf0e10cSrcweir 
190cdf0e10cSrcweir // ------------------------------------------------------------------------
191cdf0e10cSrcweir 
ImplRecalcScrollValues()192cdf0e10cSrcweir void ImplWheelWindow::ImplRecalcScrollValues()
193cdf0e10cSrcweir {
194cdf0e10cSrcweir     if( mnActDist < WHEEL_RADIUS )
195cdf0e10cSrcweir     {
196cdf0e10cSrcweir         mnActDeltaX = mnActDeltaY = 0L;
197cdf0e10cSrcweir         mnTimeout = DEF_TIMEOUT;
198cdf0e10cSrcweir     }
199cdf0e10cSrcweir     else
200cdf0e10cSrcweir     {
201cdf0e10cSrcweir         sal_uLong nCurTime;
202cdf0e10cSrcweir 
203cdf0e10cSrcweir         // calc current time
204cdf0e10cSrcweir         if( mnMaxWidth )
205cdf0e10cSrcweir         {
206cdf0e10cSrcweir             const double fExp = ( (double) mnActDist / mnMaxWidth ) * log10( (double) MAX_TIME / MIN_TIME );
207cdf0e10cSrcweir             nCurTime = (sal_uLong) ( MAX_TIME / pow( 10., fExp ) );
208cdf0e10cSrcweir         }
209cdf0e10cSrcweir         else
210cdf0e10cSrcweir             nCurTime = MAX_TIME;
211cdf0e10cSrcweir 
212cdf0e10cSrcweir         if( !nCurTime )
213cdf0e10cSrcweir             nCurTime = 1UL;
214cdf0e10cSrcweir 
215cdf0e10cSrcweir         if( mnRepaintTime <= nCurTime )
216cdf0e10cSrcweir             mnTimeout = nCurTime - mnRepaintTime;
217cdf0e10cSrcweir         else
218cdf0e10cSrcweir         {
219cdf0e10cSrcweir             long nMult = mnRepaintTime / nCurTime;
220cdf0e10cSrcweir 
221cdf0e10cSrcweir             if( !( mnRepaintTime % nCurTime ) )
222cdf0e10cSrcweir                 mnTimeout = 0UL;
223cdf0e10cSrcweir             else
224cdf0e10cSrcweir                 mnTimeout = ++nMult * nCurTime - mnRepaintTime;
225cdf0e10cSrcweir 
226cdf0e10cSrcweir             double fValX = (double) mnActDeltaX * nMult;
227cdf0e10cSrcweir             double fValY = (double) mnActDeltaY * nMult;
228cdf0e10cSrcweir 
229cdf0e10cSrcweir             if( fValX > LONG_MAX )
230cdf0e10cSrcweir                 mnActDeltaX = LONG_MAX;
231cdf0e10cSrcweir             else if( fValX < LONG_MIN )
232cdf0e10cSrcweir                 mnActDeltaX = LONG_MIN;
233cdf0e10cSrcweir             else
234cdf0e10cSrcweir                 mnActDeltaX = (long) fValX;
235cdf0e10cSrcweir 
236cdf0e10cSrcweir             if( fValY > LONG_MAX )
237cdf0e10cSrcweir                 mnActDeltaY = LONG_MAX;
238cdf0e10cSrcweir             else if( fValY < LONG_MIN )
239cdf0e10cSrcweir                 mnActDeltaY = LONG_MIN;
240cdf0e10cSrcweir             else
241cdf0e10cSrcweir                 mnActDeltaY = (long) fValY;
242cdf0e10cSrcweir         }
243cdf0e10cSrcweir     }
244cdf0e10cSrcweir }
245cdf0e10cSrcweir 
246cdf0e10cSrcweir // ------------------------------------------------------------------------
247cdf0e10cSrcweir 
ImplGetMousePointer(long nDistX,long nDistY)248cdf0e10cSrcweir PointerStyle ImplWheelWindow::ImplGetMousePointer( long nDistX, long nDistY )
249cdf0e10cSrcweir {
250cdf0e10cSrcweir     PointerStyle    eStyle;
251cdf0e10cSrcweir     const sal_uInt16    nFlags = ImplGetSVData()->maWinData.mnAutoScrollFlags;
252cdf0e10cSrcweir     const sal_Bool      bHorz = ( nFlags & AUTOSCROLL_HORZ ) != 0;
253cdf0e10cSrcweir     const sal_Bool      bVert = ( nFlags & AUTOSCROLL_VERT ) != 0;
254cdf0e10cSrcweir 
255cdf0e10cSrcweir     if( bHorz || bVert )
256cdf0e10cSrcweir     {
257cdf0e10cSrcweir         if( mnActDist < WHEEL_RADIUS )
258cdf0e10cSrcweir         {
259cdf0e10cSrcweir             if( bHorz && bVert )
260cdf0e10cSrcweir                 eStyle = POINTER_AUTOSCROLL_NSWE;
261cdf0e10cSrcweir             else if( bHorz )
262cdf0e10cSrcweir                 eStyle = POINTER_AUTOSCROLL_WE;
263cdf0e10cSrcweir             else
264cdf0e10cSrcweir                 eStyle = POINTER_AUTOSCROLL_NS;
265cdf0e10cSrcweir         }
266cdf0e10cSrcweir         else
267cdf0e10cSrcweir         {
268cdf0e10cSrcweir             double fAngle = atan2( (double) -nDistY, nDistX ) / F_PI180;
269cdf0e10cSrcweir 
270cdf0e10cSrcweir             if( fAngle < 0.0 )
271cdf0e10cSrcweir                 fAngle += 360.;
272cdf0e10cSrcweir 
273cdf0e10cSrcweir             if( bHorz && bVert )
274cdf0e10cSrcweir             {
275cdf0e10cSrcweir                 if( fAngle >= 22.5 && fAngle <= 67.5 )
276cdf0e10cSrcweir                     eStyle = POINTER_AUTOSCROLL_NE;
277cdf0e10cSrcweir                 else if( fAngle >= 67.5 && fAngle <= 112.5 )
278cdf0e10cSrcweir                     eStyle = POINTER_AUTOSCROLL_N;
279cdf0e10cSrcweir                 else if( fAngle >= 112.5 && fAngle <= 157.5 )
280cdf0e10cSrcweir                     eStyle = POINTER_AUTOSCROLL_NW;
281cdf0e10cSrcweir                 else if( fAngle >= 157.5 && fAngle <= 202.5 )
282cdf0e10cSrcweir                     eStyle = POINTER_AUTOSCROLL_W;
283cdf0e10cSrcweir                 else if( fAngle >= 202.5 && fAngle <= 247.5 )
284cdf0e10cSrcweir                     eStyle = POINTER_AUTOSCROLL_SW;
285cdf0e10cSrcweir                 else if( fAngle >= 247.5 && fAngle <= 292.5 )
286cdf0e10cSrcweir                     eStyle = POINTER_AUTOSCROLL_S;
287cdf0e10cSrcweir                 else if( fAngle >= 292.5 && fAngle <= 337.5 )
288cdf0e10cSrcweir                     eStyle = POINTER_AUTOSCROLL_SE;
289cdf0e10cSrcweir                 else
290cdf0e10cSrcweir                     eStyle = POINTER_AUTOSCROLL_E;
291cdf0e10cSrcweir             }
292cdf0e10cSrcweir             else if( bHorz )
293cdf0e10cSrcweir             {
294cdf0e10cSrcweir                 if( fAngle >= 270. || fAngle <= 90. )
295cdf0e10cSrcweir                     eStyle = POINTER_AUTOSCROLL_E;
296cdf0e10cSrcweir                 else
297cdf0e10cSrcweir                     eStyle = POINTER_AUTOSCROLL_W;
298cdf0e10cSrcweir             }
299cdf0e10cSrcweir             else
300cdf0e10cSrcweir             {
301cdf0e10cSrcweir                 if( fAngle >= 0. && fAngle <= 180. )
302cdf0e10cSrcweir                     eStyle = POINTER_AUTOSCROLL_N;
303cdf0e10cSrcweir                 else
304cdf0e10cSrcweir                     eStyle = POINTER_AUTOSCROLL_S;
305cdf0e10cSrcweir             }
306cdf0e10cSrcweir         }
307cdf0e10cSrcweir     }
308cdf0e10cSrcweir     else
309cdf0e10cSrcweir         eStyle = POINTER_ARROW;
310cdf0e10cSrcweir 
311cdf0e10cSrcweir     return eStyle;
312cdf0e10cSrcweir }
313cdf0e10cSrcweir 
314cdf0e10cSrcweir // ------------------------------------------------------------------------
315cdf0e10cSrcweir 
Paint(const Rectangle &)316cdf0e10cSrcweir void ImplWheelWindow::Paint( const Rectangle& )
317cdf0e10cSrcweir {
318cdf0e10cSrcweir     ImplDrawWheel();
319cdf0e10cSrcweir }
320cdf0e10cSrcweir 
321cdf0e10cSrcweir // ------------------------------------------------------------------------
322cdf0e10cSrcweir 
MouseMove(const MouseEvent & rMEvt)323cdf0e10cSrcweir void ImplWheelWindow::MouseMove( const MouseEvent& rMEvt )
324cdf0e10cSrcweir {
325cdf0e10cSrcweir     FloatingWindow::MouseMove( rMEvt );
326cdf0e10cSrcweir 
327cdf0e10cSrcweir     const Point aMousePos( OutputToScreenPixel( rMEvt.GetPosPixel() ) );
328cdf0e10cSrcweir     const long  nDistX = aMousePos.X() - maCenter.X();
329cdf0e10cSrcweir     const long  nDistY = aMousePos.Y() - maCenter.Y();
330cdf0e10cSrcweir 
331cdf0e10cSrcweir     mnActDist = (sal_uLong) hypot( (double) nDistX, nDistY );
332cdf0e10cSrcweir 
333cdf0e10cSrcweir     const PointerStyle  eActStyle = ImplGetMousePointer( nDistX, nDistY );
334cdf0e10cSrcweir     const sal_uInt16        nFlags = ImplGetSVData()->maWinData.mnAutoScrollFlags;
335cdf0e10cSrcweir     const sal_Bool          bHorz = ( nFlags & AUTOSCROLL_HORZ ) != 0;
336cdf0e10cSrcweir     const sal_Bool          bVert = ( nFlags & AUTOSCROLL_VERT ) != 0;
337cdf0e10cSrcweir     const sal_Bool          bOuter = mnActDist > WHEEL_RADIUS;
338cdf0e10cSrcweir 
339cdf0e10cSrcweir     if( bOuter && ( maLastMousePos != aMousePos ) )
340cdf0e10cSrcweir     {
341cdf0e10cSrcweir         switch( eActStyle )
342cdf0e10cSrcweir         {
343cdf0e10cSrcweir             case( POINTER_AUTOSCROLL_N ):   mnActDeltaX = +0L, mnActDeltaY = +1L; break;
344cdf0e10cSrcweir             case( POINTER_AUTOSCROLL_S ):   mnActDeltaX = +0L, mnActDeltaY = -1L; break;
345cdf0e10cSrcweir             case( POINTER_AUTOSCROLL_W ):   mnActDeltaX = +1L, mnActDeltaY = +0L; break;
346cdf0e10cSrcweir             case( POINTER_AUTOSCROLL_E ):   mnActDeltaX = -1L, mnActDeltaY = +0L; break;
347cdf0e10cSrcweir             case( POINTER_AUTOSCROLL_NW ):  mnActDeltaX = +1L, mnActDeltaY = +1L; break;
348cdf0e10cSrcweir             case( POINTER_AUTOSCROLL_NE ):  mnActDeltaX = -1L, mnActDeltaY = +1L; break;
349cdf0e10cSrcweir             case( POINTER_AUTOSCROLL_SW ):  mnActDeltaX = +1L, mnActDeltaY = -1L; break;
350cdf0e10cSrcweir             case( POINTER_AUTOSCROLL_SE ):  mnActDeltaX = -1L, mnActDeltaY = -1L; break;
351cdf0e10cSrcweir 
352cdf0e10cSrcweir             default:
353cdf0e10cSrcweir             break;
354cdf0e10cSrcweir         }
355cdf0e10cSrcweir     }
356cdf0e10cSrcweir 
357cdf0e10cSrcweir     ImplRecalcScrollValues();
358cdf0e10cSrcweir     maLastMousePos = aMousePos;
359cdf0e10cSrcweir     SetPointer( eActStyle );
360cdf0e10cSrcweir 
361cdf0e10cSrcweir     if( bHorz && bVert )
362cdf0e10cSrcweir         ImplSetWheelMode( bOuter ? WHEELMODE_SCROLL_VH : WHEELMODE_VH );
363cdf0e10cSrcweir     else if( bHorz )
364cdf0e10cSrcweir         ImplSetWheelMode( bOuter ? WHEELMODE_SCROLL_H : WHEELMODE_H );
365cdf0e10cSrcweir     else
366cdf0e10cSrcweir         ImplSetWheelMode( bOuter ? WHEELMODE_SCROLL_V : WHEELMODE_V );
367cdf0e10cSrcweir }
368cdf0e10cSrcweir 
369cdf0e10cSrcweir // ------------------------------------------------------------------------
370cdf0e10cSrcweir 
MouseButtonUp(const MouseEvent & rMEvt)371cdf0e10cSrcweir void ImplWheelWindow::MouseButtonUp( const MouseEvent& rMEvt )
372cdf0e10cSrcweir {
373cdf0e10cSrcweir     if( mnActDist > WHEEL_RADIUS )
374cdf0e10cSrcweir         GetParent()->EndAutoScroll();
375cdf0e10cSrcweir     else
376cdf0e10cSrcweir         FloatingWindow::MouseButtonUp( rMEvt );
377cdf0e10cSrcweir }
378cdf0e10cSrcweir 
379cdf0e10cSrcweir // ------------------------------------------------------------------------
380cdf0e10cSrcweir 
IMPL_LINK(ImplWheelWindow,ImplScrollHdl,Timer *,EMPTYARG)381cdf0e10cSrcweir IMPL_LINK( ImplWheelWindow, ImplScrollHdl, Timer*, EMPTYARG )
382cdf0e10cSrcweir {
383cdf0e10cSrcweir     if ( mnActDeltaX || mnActDeltaY )
384cdf0e10cSrcweir     {
385cdf0e10cSrcweir         Window*             pWindow = GetParent();
386cdf0e10cSrcweir         const Point         aMousePos( pWindow->OutputToScreenPixel( pWindow->GetPointerPosPixel() ) );
387cdf0e10cSrcweir         Point               aCmdMousePos( pWindow->ImplFrameToOutput( aMousePos ) );
388cdf0e10cSrcweir         CommandScrollData   aScrollData( mnActDeltaX, mnActDeltaY );
389cdf0e10cSrcweir         CommandEvent        aCEvt( aCmdMousePos, COMMAND_AUTOSCROLL, sal_True, &aScrollData );
390cdf0e10cSrcweir         NotifyEvent         aNCmdEvt( EVENT_COMMAND, pWindow, &aCEvt );
391cdf0e10cSrcweir 
392cdf0e10cSrcweir         if ( !ImplCallPreNotify( aNCmdEvt ) )
393cdf0e10cSrcweir         {
394cdf0e10cSrcweir             const sal_uLong nTime = Time::GetSystemTicks();
395cdf0e10cSrcweir 			ImplDelData aDel( this );
396cdf0e10cSrcweir             pWindow->Command( aCEvt );
397cdf0e10cSrcweir 			if( aDel.IsDead() )
398cdf0e10cSrcweir 				return 0;
399cdf0e10cSrcweir             mnRepaintTime = Max( Time::GetSystemTicks() - nTime, 1UL );
400cdf0e10cSrcweir             ImplRecalcScrollValues();
401cdf0e10cSrcweir         }
402cdf0e10cSrcweir     }
403cdf0e10cSrcweir 
404cdf0e10cSrcweir     if ( mnTimeout != mpTimer->GetTimeout() )
405cdf0e10cSrcweir         mpTimer->SetTimeout( mnTimeout );
406cdf0e10cSrcweir     mpTimer->Start();
407cdf0e10cSrcweir 
408cdf0e10cSrcweir     return 0L;
409cdf0e10cSrcweir }
410