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