xref: /aoo41x/main/vcl/source/control/slider.cxx (revision cdf0e10c)
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 #ifndef _SV_RC_H
32*cdf0e10cSrcweir #include <tools/rc.h>
33*cdf0e10cSrcweir #endif
34*cdf0e10cSrcweir #include <vcl/event.hxx>
35*cdf0e10cSrcweir #include <vcl/decoview.hxx>
36*cdf0e10cSrcweir #include <vcl/slider.hxx>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir // =======================================================================
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir static long ImplMulDiv( long nNumber, long nNumerator, long nDenominator )
43*cdf0e10cSrcweir {
44*cdf0e10cSrcweir 	double n = ((double)nNumber * (double)nNumerator) / (double)nDenominator;
45*cdf0e10cSrcweir 	return (long)n;
46*cdf0e10cSrcweir }
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir // =======================================================================
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir #define SLIDER_DRAW_THUMB			((sal_uInt16)0x0001)
51*cdf0e10cSrcweir #define SLIDER_DRAW_CHANNEL1		((sal_uInt16)0x0002)
52*cdf0e10cSrcweir #define SLIDER_DRAW_CHANNEL2		((sal_uInt16)0x0004)
53*cdf0e10cSrcweir #define SLIDER_DRAW_CHANNEL 		(SLIDER_DRAW_CHANNEL1 | SLIDER_DRAW_CHANNEL2)
54*cdf0e10cSrcweir #define SLIDER_DRAW_ALL 			(SLIDER_DRAW_THUMB | SLIDER_DRAW_CHANNEL)
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir #define SLIDER_STATE_CHANNEL1_DOWN	((sal_uInt16)0x0001)
57*cdf0e10cSrcweir #define SLIDER_STATE_CHANNEL2_DOWN	((sal_uInt16)0x0002)
58*cdf0e10cSrcweir #define SLIDER_STATE_THUMB_DOWN 	((sal_uInt16)0x0004)
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir #define SLIDER_THUMB_SIZE			9
61*cdf0e10cSrcweir #define SLIDER_THUMB_HALFSIZE		4
62*cdf0e10cSrcweir #define SLIDER_CHANNEL_OFFSET		0
63*cdf0e10cSrcweir #define SLIDER_CHANNEL_SIZE 		4
64*cdf0e10cSrcweir #define SLIDER_CHANNEL_HALFSIZE 	2
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir #define SLIDER_HEIGHT				16
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir #define SLIDER_VIEW_STYLE			(WB_3DLOOK | WB_HORZ | WB_VERT)
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir // =======================================================================
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir void Slider::ImplInit( Window* pParent, WinBits nStyle )
73*cdf0e10cSrcweir {
74*cdf0e10cSrcweir 	mnThumbPixOffset	= 0;
75*cdf0e10cSrcweir 	mnThumbPixRange 	= 0;
76*cdf0e10cSrcweir 	mnThumbPixPos		= 0;	// between mnThumbPixOffset and mnThumbPixOffset+mnThumbPixRange
77*cdf0e10cSrcweir 	mnChannelPixOffset	= 0;
78*cdf0e10cSrcweir 	mnChannelPixRange	= 0;
79*cdf0e10cSrcweir 	mnChannelPixTop 	= 0;
80*cdf0e10cSrcweir 	mnChannelPixBottom	= 0;
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir 	mnMinRange			= 0;
83*cdf0e10cSrcweir 	mnMaxRange			= 100;
84*cdf0e10cSrcweir 	mnThumbPos			= 0;
85*cdf0e10cSrcweir 	mnLineSize			= 1;
86*cdf0e10cSrcweir 	mnPageSize			= 1;
87*cdf0e10cSrcweir 	mnDelta 			= 0;
88*cdf0e10cSrcweir 	mnDragDraw			= 0;
89*cdf0e10cSrcweir 	mnStateFlags		= 0;
90*cdf0e10cSrcweir 	meScrollType		= SCROLL_DONTKNOW;
91*cdf0e10cSrcweir 	mbCalcSize			= sal_True;
92*cdf0e10cSrcweir 	mbFullDrag			= sal_True;
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir 	Control::ImplInit( pParent, nStyle, NULL );
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir 	ImplInitSettings();
97*cdf0e10cSrcweir 	SetSizePixel( CalcWindowSizePixel() );
98*cdf0e10cSrcweir }
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir // -----------------------------------------------------------------------
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir Slider::Slider( Window* pParent, WinBits nStyle ) :
103*cdf0e10cSrcweir 	Control( WINDOW_SLIDER )
104*cdf0e10cSrcweir {
105*cdf0e10cSrcweir 	ImplInit( pParent, nStyle );
106*cdf0e10cSrcweir }
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir // -----------------------------------------------------------------------
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir Slider::Slider( Window* pParent, const ResId& rResId ) :
111*cdf0e10cSrcweir 	Control( WINDOW_SLIDER )
112*cdf0e10cSrcweir {
113*cdf0e10cSrcweir 	rResId.SetRT( RSC_SCROLLBAR );
114*cdf0e10cSrcweir 	WinBits nStyle = ImplInitRes( rResId );
115*cdf0e10cSrcweir 	ImplInit( pParent, nStyle );
116*cdf0e10cSrcweir 	ImplLoadRes( rResId );
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir 	if ( !(nStyle & WB_HIDE) )
119*cdf0e10cSrcweir 		Show();
120*cdf0e10cSrcweir }
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir // -----------------------------------------------------------------------
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir void Slider::ImplLoadRes( const ResId& rResId )
125*cdf0e10cSrcweir {
126*cdf0e10cSrcweir 	Control::ImplLoadRes( rResId );
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir 	sal_Int16 nMin			= ReadShortRes();
129*cdf0e10cSrcweir 	sal_Int16 nMax			= ReadShortRes();
130*cdf0e10cSrcweir 	sal_Int16 nThumbPos		= ReadShortRes();
131*cdf0e10cSrcweir 	sal_Int16 nPage			= ReadShortRes();
132*cdf0e10cSrcweir 	sal_Int16 nStep			= ReadShortRes();
133*cdf0e10cSrcweir 	/* sal_Int16 nVisibleSize	= */ ReadShortRes();
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 	SetRange( Range( nMin, nMax ) );
136*cdf0e10cSrcweir 	SetLineSize( nStep );
137*cdf0e10cSrcweir 	SetPageSize( nPage );
138*cdf0e10cSrcweir 	SetThumbPos( nThumbPos );
139*cdf0e10cSrcweir }
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir // -----------------------------------------------------------------------
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir void Slider::ImplInitSettings()
144*cdf0e10cSrcweir {
145*cdf0e10cSrcweir 	Window* pParent = GetParent();
146*cdf0e10cSrcweir 	if ( pParent->IsChildTransparentModeEnabled() && !IsControlBackground() )
147*cdf0e10cSrcweir 	{
148*cdf0e10cSrcweir 		EnableChildTransparentMode( sal_True );
149*cdf0e10cSrcweir 		SetParentClipMode( PARENTCLIPMODE_NOCLIP );
150*cdf0e10cSrcweir 		SetPaintTransparent( sal_True );
151*cdf0e10cSrcweir 		SetBackground();
152*cdf0e10cSrcweir 	}
153*cdf0e10cSrcweir 	else
154*cdf0e10cSrcweir 	{
155*cdf0e10cSrcweir 		EnableChildTransparentMode( sal_False );
156*cdf0e10cSrcweir 		SetParentClipMode( 0 );
157*cdf0e10cSrcweir 		SetPaintTransparent( sal_False );
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 		if ( IsControlBackground() )
160*cdf0e10cSrcweir 			SetBackground( GetControlBackground() );
161*cdf0e10cSrcweir 		else
162*cdf0e10cSrcweir 			SetBackground( pParent->GetBackground() );
163*cdf0e10cSrcweir 	}
164*cdf0e10cSrcweir }
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir // -----------------------------------------------------------------------
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir void Slider::ImplUpdateRects( sal_Bool bUpdate )
169*cdf0e10cSrcweir {
170*cdf0e10cSrcweir 	Rectangle aOldThumbRect = maThumbRect;
171*cdf0e10cSrcweir 	bool bInvalidateAll = false;
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir 	if ( mnThumbPixRange )
174*cdf0e10cSrcweir 	{
175*cdf0e10cSrcweir 		if ( GetStyle() & WB_HORZ )
176*cdf0e10cSrcweir 		{
177*cdf0e10cSrcweir 			maThumbRect.Left()		= mnThumbPixPos-SLIDER_THUMB_HALFSIZE;
178*cdf0e10cSrcweir 			maThumbRect.Right() 	= maThumbRect.Left()+SLIDER_THUMB_SIZE-1;
179*cdf0e10cSrcweir 			if ( mnChannelPixOffset < maThumbRect.Left() )
180*cdf0e10cSrcweir 			{
181*cdf0e10cSrcweir 				maChannel1Rect.Left()	= mnChannelPixOffset;
182*cdf0e10cSrcweir 				maChannel1Rect.Right()	= maThumbRect.Left()-1;
183*cdf0e10cSrcweir 				maChannel1Rect.Top()	= mnChannelPixTop;
184*cdf0e10cSrcweir 				maChannel1Rect.Bottom() = mnChannelPixBottom;
185*cdf0e10cSrcweir 			}
186*cdf0e10cSrcweir 			else
187*cdf0e10cSrcweir 				maChannel1Rect.SetEmpty();
188*cdf0e10cSrcweir 			if ( mnChannelPixOffset+mnChannelPixRange-1 > maThumbRect.Right() )
189*cdf0e10cSrcweir 			{
190*cdf0e10cSrcweir 				maChannel2Rect.Left()	= maThumbRect.Right()+1;
191*cdf0e10cSrcweir 				maChannel2Rect.Right()	= mnChannelPixOffset+mnChannelPixRange-1;
192*cdf0e10cSrcweir 				maChannel2Rect.Top()	= mnChannelPixTop;
193*cdf0e10cSrcweir 				maChannel2Rect.Bottom() = mnChannelPixBottom;
194*cdf0e10cSrcweir 			}
195*cdf0e10cSrcweir 			else
196*cdf0e10cSrcweir 				maChannel2Rect.SetEmpty();
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir 			const Rectangle aControlRegion( Rectangle( Point(0,0), Size( SLIDER_THUMB_SIZE, 10 ) ) );
199*cdf0e10cSrcweir 			Rectangle aThumbBounds, aThumbContent;
200*cdf0e10cSrcweir             if ( GetNativeControlRegion( CTRL_SLIDER, PART_THUMB_HORZ,
201*cdf0e10cSrcweir                                          aControlRegion, 0, ImplControlValue(), rtl::OUString(),
202*cdf0e10cSrcweir                                          aThumbBounds, aThumbContent ) )
203*cdf0e10cSrcweir             {
204*cdf0e10cSrcweir                 maThumbRect.Left() = mnThumbPixPos - aThumbBounds.GetWidth()/2;
205*cdf0e10cSrcweir                 maThumbRect.Right() = maThumbRect.Left() + aThumbBounds.GetWidth() - 1;
206*cdf0e10cSrcweir                 bInvalidateAll = true;
207*cdf0e10cSrcweir             }
208*cdf0e10cSrcweir 		}
209*cdf0e10cSrcweir 		else
210*cdf0e10cSrcweir 		{
211*cdf0e10cSrcweir 			maThumbRect.Top()		= mnThumbPixPos-SLIDER_THUMB_HALFSIZE;
212*cdf0e10cSrcweir 			maThumbRect.Bottom()	= maThumbRect.Top()+SLIDER_THUMB_SIZE-1;
213*cdf0e10cSrcweir 			if ( mnChannelPixOffset < maThumbRect.Top() )
214*cdf0e10cSrcweir 			{
215*cdf0e10cSrcweir 				maChannel1Rect.Top()	= mnChannelPixOffset;
216*cdf0e10cSrcweir 				maChannel1Rect.Bottom() = maThumbRect.Top()-1;
217*cdf0e10cSrcweir 				maChannel1Rect.Left()	= mnChannelPixTop;
218*cdf0e10cSrcweir 				maChannel1Rect.Right()	= mnChannelPixBottom;
219*cdf0e10cSrcweir 			}
220*cdf0e10cSrcweir 			else
221*cdf0e10cSrcweir 				maChannel1Rect.SetEmpty();
222*cdf0e10cSrcweir 			if ( mnChannelPixOffset+mnChannelPixRange-1 > maThumbRect.Bottom() )
223*cdf0e10cSrcweir 			{
224*cdf0e10cSrcweir 				maChannel2Rect.Top()	= maThumbRect.Bottom()+1;
225*cdf0e10cSrcweir 				maChannel2Rect.Bottom() = mnChannelPixOffset+mnChannelPixRange-1;
226*cdf0e10cSrcweir 				maChannel2Rect.Left()	= mnChannelPixTop;
227*cdf0e10cSrcweir 				maChannel2Rect.Right()	= mnChannelPixBottom;
228*cdf0e10cSrcweir 			}
229*cdf0e10cSrcweir 			else
230*cdf0e10cSrcweir 				maChannel2Rect.SetEmpty();
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir 			const Rectangle aControlRegion( Rectangle( Point(0,0), Size( 10, SLIDER_THUMB_SIZE ) ) );
233*cdf0e10cSrcweir 			Rectangle aThumbBounds, aThumbContent;
234*cdf0e10cSrcweir             if ( GetNativeControlRegion( CTRL_SLIDER, PART_THUMB_VERT,
235*cdf0e10cSrcweir                                          aControlRegion, 0, ImplControlValue(), rtl::OUString(),
236*cdf0e10cSrcweir                                          aThumbBounds, aThumbContent ) )
237*cdf0e10cSrcweir             {
238*cdf0e10cSrcweir                 maThumbRect.Top() = mnThumbPixPos - aThumbBounds.GetHeight()/2;
239*cdf0e10cSrcweir                 maThumbRect.Bottom() = maThumbRect.Top() + aThumbBounds.GetHeight() - 1;
240*cdf0e10cSrcweir                 bInvalidateAll = true;
241*cdf0e10cSrcweir             }
242*cdf0e10cSrcweir 		}
243*cdf0e10cSrcweir 	}
244*cdf0e10cSrcweir 	else
245*cdf0e10cSrcweir 	{
246*cdf0e10cSrcweir 		maChannel1Rect.SetEmpty();
247*cdf0e10cSrcweir 		maChannel2Rect.SetEmpty();
248*cdf0e10cSrcweir 		maThumbRect.SetEmpty();
249*cdf0e10cSrcweir 	}
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir 	if ( bUpdate )
252*cdf0e10cSrcweir 	{
253*cdf0e10cSrcweir 		if ( aOldThumbRect != maThumbRect )
254*cdf0e10cSrcweir 		{
255*cdf0e10cSrcweir 		    if( bInvalidateAll )
256*cdf0e10cSrcweir 		        Invalidate();
257*cdf0e10cSrcweir 		    else
258*cdf0e10cSrcweir 		    {
259*cdf0e10cSrcweir                 Region aInvalidRegion( aOldThumbRect );
260*cdf0e10cSrcweir                 aInvalidRegion.Union( maThumbRect );
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir                 if( !IsBackground() && GetParent() )
263*cdf0e10cSrcweir                 {
264*cdf0e10cSrcweir                     const Point aPos( GetPosPixel() );
265*cdf0e10cSrcweir                     aInvalidRegion.Move( aPos.X(), aPos.Y() );
266*cdf0e10cSrcweir                     GetParent()->Invalidate( aInvalidRegion, INVALIDATE_TRANSPARENT | INVALIDATE_UPDATE );
267*cdf0e10cSrcweir                 }
268*cdf0e10cSrcweir                 else
269*cdf0e10cSrcweir                     Invalidate( aInvalidRegion );
270*cdf0e10cSrcweir             }
271*cdf0e10cSrcweir 		}
272*cdf0e10cSrcweir 	}
273*cdf0e10cSrcweir }
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir // -----------------------------------------------------------------------
276*cdf0e10cSrcweir 
277*cdf0e10cSrcweir long Slider::ImplCalcThumbPos( long nPixPos )
278*cdf0e10cSrcweir {
279*cdf0e10cSrcweir 	// Position berechnen
280*cdf0e10cSrcweir 	long nCalcThumbPos;
281*cdf0e10cSrcweir 	nCalcThumbPos = ImplMulDiv( nPixPos-mnThumbPixOffset, mnMaxRange-mnMinRange, mnThumbPixRange-1 );
282*cdf0e10cSrcweir 	nCalcThumbPos += mnMinRange;
283*cdf0e10cSrcweir 	return nCalcThumbPos;
284*cdf0e10cSrcweir }
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir // -----------------------------------------------------------------------
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir long Slider::ImplCalcThumbPosPix( long nPos )
289*cdf0e10cSrcweir {
290*cdf0e10cSrcweir 	// Position berechnen
291*cdf0e10cSrcweir 	long nCalcThumbPos;
292*cdf0e10cSrcweir 	nCalcThumbPos = ImplMulDiv( nPos-mnMinRange, mnThumbPixRange-1, mnMaxRange-mnMinRange );
293*cdf0e10cSrcweir 	// Am Anfang und Ende des Sliders versuchen wir die Anzeige korrekt
294*cdf0e10cSrcweir 	// anzuzeigen
295*cdf0e10cSrcweir 	if ( !nCalcThumbPos && (mnThumbPos > mnMinRange) )
296*cdf0e10cSrcweir 		nCalcThumbPos = 1;
297*cdf0e10cSrcweir 	if ( nCalcThumbPos &&
298*cdf0e10cSrcweir 		 (nCalcThumbPos == mnThumbPixRange-1) &&
299*cdf0e10cSrcweir 		 (mnThumbPos < mnMaxRange) )
300*cdf0e10cSrcweir 		nCalcThumbPos--;
301*cdf0e10cSrcweir 	return nCalcThumbPos+mnThumbPixOffset;
302*cdf0e10cSrcweir }
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir // -----------------------------------------------------------------------
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir void Slider::ImplCalc( sal_Bool bUpdate )
307*cdf0e10cSrcweir {
308*cdf0e10cSrcweir 	sal_Bool bInvalidateAll = sal_False;
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir 	if ( mbCalcSize )
311*cdf0e10cSrcweir 	{
312*cdf0e10cSrcweir 		long nOldChannelPixOffset	= mnChannelPixOffset;
313*cdf0e10cSrcweir 		long nOldChannelPixRange	= mnChannelPixRange;
314*cdf0e10cSrcweir 		long nOldChannelPixTop		= mnChannelPixTop;
315*cdf0e10cSrcweir 		long nOldChannelPixBottom	= mnChannelPixBottom;
316*cdf0e10cSrcweir 		long nCalcWidth;
317*cdf0e10cSrcweir 		long nCalcHeight;
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir 		maChannel1Rect.SetEmpty();
320*cdf0e10cSrcweir 		maChannel2Rect.SetEmpty();
321*cdf0e10cSrcweir 		maThumbRect.SetEmpty();
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir 		Size aSize = GetOutputSizePixel();
324*cdf0e10cSrcweir 		if ( GetStyle() & WB_HORZ )
325*cdf0e10cSrcweir 		{
326*cdf0e10cSrcweir 			nCalcWidth			= aSize.Width();
327*cdf0e10cSrcweir 			nCalcHeight 		= aSize.Height();
328*cdf0e10cSrcweir 			maThumbRect.Top()	= 0;
329*cdf0e10cSrcweir 			maThumbRect.Bottom()= aSize.Height()-1;
330*cdf0e10cSrcweir 		}
331*cdf0e10cSrcweir 		else
332*cdf0e10cSrcweir 		{
333*cdf0e10cSrcweir 			nCalcWidth			= aSize.Height();
334*cdf0e10cSrcweir 			nCalcHeight 		= aSize.Width();
335*cdf0e10cSrcweir 			maThumbRect.Left()	= 0;
336*cdf0e10cSrcweir 			maThumbRect.Right() = aSize.Width()-1;
337*cdf0e10cSrcweir 		}
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir 		if ( nCalcWidth >= SLIDER_THUMB_SIZE )
340*cdf0e10cSrcweir 		{
341*cdf0e10cSrcweir 			mnThumbPixOffset	= SLIDER_THUMB_HALFSIZE;
342*cdf0e10cSrcweir 			mnThumbPixRange 	= nCalcWidth-(SLIDER_THUMB_HALFSIZE*2);
343*cdf0e10cSrcweir 			mnThumbPixPos		= 0;
344*cdf0e10cSrcweir 			mnChannelPixOffset	= SLIDER_CHANNEL_OFFSET;
345*cdf0e10cSrcweir 			mnChannelPixRange	= nCalcWidth-(SLIDER_CHANNEL_OFFSET*2);
346*cdf0e10cSrcweir 			mnChannelPixTop 	= (nCalcHeight/2)-SLIDER_CHANNEL_HALFSIZE;
347*cdf0e10cSrcweir 			mnChannelPixBottom	= mnChannelPixTop+SLIDER_CHANNEL_SIZE-1;
348*cdf0e10cSrcweir 		}
349*cdf0e10cSrcweir 		else
350*cdf0e10cSrcweir 		{
351*cdf0e10cSrcweir 			mnThumbPixRange = 0;
352*cdf0e10cSrcweir 			mnChannelPixRange = 0;
353*cdf0e10cSrcweir 		}
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir 		if ( (nOldChannelPixOffset != mnChannelPixOffset) ||
356*cdf0e10cSrcweir 			 (nOldChannelPixRange != mnChannelPixRange) ||
357*cdf0e10cSrcweir 			 (nOldChannelPixTop != mnChannelPixTop) ||
358*cdf0e10cSrcweir 			 (nOldChannelPixBottom != mnChannelPixBottom) )
359*cdf0e10cSrcweir 			bInvalidateAll = sal_True;
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir 		mbCalcSize = sal_False;
362*cdf0e10cSrcweir 	}
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir 	if ( mnThumbPixRange )
365*cdf0e10cSrcweir 		mnThumbPixPos = ImplCalcThumbPosPix( mnThumbPos );
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir 	if ( bUpdate && bInvalidateAll )
368*cdf0e10cSrcweir 	{
369*cdf0e10cSrcweir 		Invalidate();
370*cdf0e10cSrcweir 		bUpdate = sal_False;
371*cdf0e10cSrcweir 	}
372*cdf0e10cSrcweir 	ImplUpdateRects( bUpdate );
373*cdf0e10cSrcweir }
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir // -----------------------------------------------------------------------
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir void Slider::ImplDraw( sal_uInt16 nDrawFlags )
378*cdf0e10cSrcweir {
379*cdf0e10cSrcweir 	DecorationView			aDecoView( this );
380*cdf0e10cSrcweir 	sal_uInt16					nStyle;
381*cdf0e10cSrcweir 	const StyleSettings&	rStyleSettings = GetSettings().GetStyleSettings();
382*cdf0e10cSrcweir 	sal_Bool					bEnabled = IsEnabled();
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir 	// Evt. noch offene Berechnungen nachholen
385*cdf0e10cSrcweir 	if ( mbCalcSize )
386*cdf0e10cSrcweir 		ImplCalc( sal_False );
387*cdf0e10cSrcweir 
388*cdf0e10cSrcweir     ControlPart nPart = (GetStyle() & WB_HORZ) ? PART_TRACK_HORZ_AREA : PART_TRACK_VERT_AREA;
389*cdf0e10cSrcweir     ControlState   nState = ( IsEnabled() ? CTRL_STATE_ENABLED : 0 ) | ( HasFocus() ? CTRL_STATE_FOCUSED : 0 );
390*cdf0e10cSrcweir     SliderValue    sldValue;
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir     sldValue.mnMin       = mnMinRange;
393*cdf0e10cSrcweir     sldValue.mnMax       = mnMaxRange;
394*cdf0e10cSrcweir     sldValue.mnCur       = mnThumbPos;
395*cdf0e10cSrcweir     sldValue.maThumbRect = maThumbRect;
396*cdf0e10cSrcweir 
397*cdf0e10cSrcweir     if( IsMouseOver() )
398*cdf0e10cSrcweir     {
399*cdf0e10cSrcweir         if( maThumbRect.IsInside( GetPointerPosPixel() ) )
400*cdf0e10cSrcweir             sldValue.mnThumbState |= CTRL_STATE_ROLLOVER;
401*cdf0e10cSrcweir     }
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir     const Rectangle aCtrlRegion( Point(0,0), GetOutputSizePixel() );
404*cdf0e10cSrcweir     bool bNativeOK = DrawNativeControl( CTRL_SLIDER, nPart,
405*cdf0e10cSrcweir                                         aCtrlRegion, nState, sldValue, rtl::OUString() );
406*cdf0e10cSrcweir     if( bNativeOK )
407*cdf0e10cSrcweir         return;
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir 	if ( (nDrawFlags & SLIDER_DRAW_CHANNEL1) && !maChannel1Rect.IsEmpty() )
410*cdf0e10cSrcweir 	{
411*cdf0e10cSrcweir 		long		nRectSize;
412*cdf0e10cSrcweir 		Rectangle	aRect = maChannel1Rect;
413*cdf0e10cSrcweir 		SetLineColor( rStyleSettings.GetShadowColor() );
414*cdf0e10cSrcweir 		if ( GetStyle() & WB_HORZ )
415*cdf0e10cSrcweir 		{
416*cdf0e10cSrcweir 			DrawLine( aRect.TopLeft(), Point( aRect.Left(), aRect.Bottom()-1 ) );
417*cdf0e10cSrcweir 			DrawLine( aRect.TopLeft(), aRect.TopRight() );
418*cdf0e10cSrcweir 		}
419*cdf0e10cSrcweir 		else
420*cdf0e10cSrcweir 		{
421*cdf0e10cSrcweir 			DrawLine( aRect.TopLeft(), Point( aRect.Right()-1, aRect.Top() ) );
422*cdf0e10cSrcweir 			DrawLine( aRect.TopLeft(), aRect.BottomLeft() );
423*cdf0e10cSrcweir 		}
424*cdf0e10cSrcweir 		SetLineColor( rStyleSettings.GetLightColor() );
425*cdf0e10cSrcweir 		if ( GetStyle() & WB_HORZ )
426*cdf0e10cSrcweir 		{
427*cdf0e10cSrcweir 			DrawLine( aRect.BottomLeft(), aRect.BottomRight() );
428*cdf0e10cSrcweir 			nRectSize = aRect.GetWidth();
429*cdf0e10cSrcweir 		}
430*cdf0e10cSrcweir 		else
431*cdf0e10cSrcweir 		{
432*cdf0e10cSrcweir 			DrawLine( aRect.TopRight(), aRect.BottomRight() );
433*cdf0e10cSrcweir 			nRectSize = aRect.GetHeight();
434*cdf0e10cSrcweir 		}
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir 		if ( nRectSize > 1 )
437*cdf0e10cSrcweir 		{
438*cdf0e10cSrcweir 			aRect.Left()++;
439*cdf0e10cSrcweir 			aRect.Top()++;
440*cdf0e10cSrcweir 			if ( GetStyle() & WB_HORZ )
441*cdf0e10cSrcweir 				aRect.Bottom()--;
442*cdf0e10cSrcweir 			else
443*cdf0e10cSrcweir 				aRect.Right()--;
444*cdf0e10cSrcweir 			SetLineColor();
445*cdf0e10cSrcweir 			if ( mnStateFlags & SLIDER_STATE_CHANNEL1_DOWN )
446*cdf0e10cSrcweir 				SetFillColor( rStyleSettings.GetShadowColor() );
447*cdf0e10cSrcweir 			else
448*cdf0e10cSrcweir 				SetFillColor( rStyleSettings.GetCheckedColor() );
449*cdf0e10cSrcweir 			DrawRect( aRect );
450*cdf0e10cSrcweir 		}
451*cdf0e10cSrcweir 	}
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir 	if ( (nDrawFlags & SLIDER_DRAW_CHANNEL2) && !maChannel2Rect.IsEmpty() )
454*cdf0e10cSrcweir 	{
455*cdf0e10cSrcweir 		long		nRectSize;
456*cdf0e10cSrcweir 		Rectangle	aRect = maChannel2Rect;
457*cdf0e10cSrcweir 		SetLineColor( rStyleSettings.GetLightColor() );
458*cdf0e10cSrcweir 		if ( GetStyle() & WB_HORZ )
459*cdf0e10cSrcweir 		{
460*cdf0e10cSrcweir 			DrawLine( aRect.TopRight(), aRect.BottomRight() );
461*cdf0e10cSrcweir 			DrawLine( aRect.BottomLeft(), aRect.BottomRight() );
462*cdf0e10cSrcweir 			nRectSize = aRect.GetWidth();
463*cdf0e10cSrcweir 		}
464*cdf0e10cSrcweir 		else
465*cdf0e10cSrcweir 		{
466*cdf0e10cSrcweir 			DrawLine( aRect.BottomLeft(), aRect.BottomRight() );
467*cdf0e10cSrcweir 			DrawLine( aRect.TopRight(), aRect.BottomRight() );
468*cdf0e10cSrcweir 			nRectSize = aRect.GetHeight();
469*cdf0e10cSrcweir 		}
470*cdf0e10cSrcweir 
471*cdf0e10cSrcweir 		if ( nRectSize > 1 )
472*cdf0e10cSrcweir 		{
473*cdf0e10cSrcweir 			SetLineColor( rStyleSettings.GetShadowColor() );
474*cdf0e10cSrcweir 			if ( GetStyle() & WB_HORZ )
475*cdf0e10cSrcweir 				DrawLine( aRect.TopLeft(), Point( aRect.Right()-1, aRect.Top() ) );
476*cdf0e10cSrcweir 			else
477*cdf0e10cSrcweir 				DrawLine( aRect.TopLeft(), Point( aRect.Left(), aRect.Bottom()-1 ) );
478*cdf0e10cSrcweir 
479*cdf0e10cSrcweir 			aRect.Right()--;
480*cdf0e10cSrcweir 			aRect.Bottom()--;
481*cdf0e10cSrcweir 			if ( GetStyle() & WB_HORZ )
482*cdf0e10cSrcweir 				aRect.Top()++;
483*cdf0e10cSrcweir 			else
484*cdf0e10cSrcweir 				aRect.Left()++;
485*cdf0e10cSrcweir 			SetLineColor();
486*cdf0e10cSrcweir 			if ( mnStateFlags & SLIDER_STATE_CHANNEL2_DOWN )
487*cdf0e10cSrcweir 				SetFillColor( rStyleSettings.GetShadowColor() );
488*cdf0e10cSrcweir 			else
489*cdf0e10cSrcweir 				SetFillColor( rStyleSettings.GetCheckedColor() );
490*cdf0e10cSrcweir 			DrawRect( aRect );
491*cdf0e10cSrcweir 		}
492*cdf0e10cSrcweir 	}
493*cdf0e10cSrcweir 
494*cdf0e10cSrcweir 	if ( nDrawFlags & SLIDER_DRAW_THUMB )
495*cdf0e10cSrcweir 	{
496*cdf0e10cSrcweir 		if ( !maThumbRect.IsEmpty() )
497*cdf0e10cSrcweir 		{
498*cdf0e10cSrcweir 			if ( bEnabled )
499*cdf0e10cSrcweir 			{
500*cdf0e10cSrcweir 				nStyle = 0;
501*cdf0e10cSrcweir 				if ( mnStateFlags & SLIDER_STATE_THUMB_DOWN )
502*cdf0e10cSrcweir 					nStyle |= BUTTON_DRAW_PRESSED;
503*cdf0e10cSrcweir 				aDecoView.DrawButton( maThumbRect, nStyle );
504*cdf0e10cSrcweir 			}
505*cdf0e10cSrcweir 			else
506*cdf0e10cSrcweir 			{
507*cdf0e10cSrcweir 				SetLineColor( rStyleSettings.GetShadowColor() );
508*cdf0e10cSrcweir 				SetFillColor( rStyleSettings.GetCheckedColor() );
509*cdf0e10cSrcweir 				DrawRect( maThumbRect );
510*cdf0e10cSrcweir 			}
511*cdf0e10cSrcweir 		}
512*cdf0e10cSrcweir 	}
513*cdf0e10cSrcweir }
514*cdf0e10cSrcweir 
515*cdf0e10cSrcweir // -----------------------------------------------------------------------
516*cdf0e10cSrcweir 
517*cdf0e10cSrcweir sal_Bool Slider::ImplIsPageUp( const Point& rPos )
518*cdf0e10cSrcweir {
519*cdf0e10cSrcweir 	Size aSize = GetOutputSizePixel();
520*cdf0e10cSrcweir 	Rectangle aRect = maChannel1Rect;
521*cdf0e10cSrcweir 	if ( GetStyle() & WB_HORZ )
522*cdf0e10cSrcweir 	{
523*cdf0e10cSrcweir 		aRect.Top() 	= 0;
524*cdf0e10cSrcweir 		aRect.Bottom()	= aSize.Height()-1;
525*cdf0e10cSrcweir 	}
526*cdf0e10cSrcweir 	else
527*cdf0e10cSrcweir 	{
528*cdf0e10cSrcweir 		aRect.Left()	= 0;
529*cdf0e10cSrcweir 		aRect.Right()	= aSize.Width()-1;
530*cdf0e10cSrcweir 	}
531*cdf0e10cSrcweir 	return aRect.IsInside( rPos );
532*cdf0e10cSrcweir }
533*cdf0e10cSrcweir 
534*cdf0e10cSrcweir // -----------------------------------------------------------------------
535*cdf0e10cSrcweir 
536*cdf0e10cSrcweir sal_Bool Slider::ImplIsPageDown( const Point& rPos )
537*cdf0e10cSrcweir {
538*cdf0e10cSrcweir 	Size aSize = GetOutputSizePixel();
539*cdf0e10cSrcweir 	Rectangle aRect = maChannel2Rect;
540*cdf0e10cSrcweir 	if ( GetStyle() & WB_HORZ )
541*cdf0e10cSrcweir 	{
542*cdf0e10cSrcweir 		aRect.Top() 	= 0;
543*cdf0e10cSrcweir 		aRect.Bottom()	= aSize.Height()-1;
544*cdf0e10cSrcweir 	}
545*cdf0e10cSrcweir 	else
546*cdf0e10cSrcweir 	{
547*cdf0e10cSrcweir 		aRect.Left()	= 0;
548*cdf0e10cSrcweir 		aRect.Right()	= aSize.Width()-1;
549*cdf0e10cSrcweir 	}
550*cdf0e10cSrcweir 	return aRect.IsInside( rPos );
551*cdf0e10cSrcweir }
552*cdf0e10cSrcweir 
553*cdf0e10cSrcweir // -----------------------------------------------------------------------
554*cdf0e10cSrcweir 
555*cdf0e10cSrcweir long Slider::ImplSlide( long nNewPos, sal_Bool bCallEndSlide )
556*cdf0e10cSrcweir {
557*cdf0e10cSrcweir 	long nOldPos = mnThumbPos;
558*cdf0e10cSrcweir 	SetThumbPos( nNewPos );
559*cdf0e10cSrcweir 	long nDelta = mnThumbPos-nOldPos;
560*cdf0e10cSrcweir 	if ( nDelta )
561*cdf0e10cSrcweir 	{
562*cdf0e10cSrcweir 		mnDelta = nDelta;
563*cdf0e10cSrcweir 		Slide();
564*cdf0e10cSrcweir 		if ( bCallEndSlide )
565*cdf0e10cSrcweir 			EndSlide();
566*cdf0e10cSrcweir 		mnDelta = 0;
567*cdf0e10cSrcweir 	}
568*cdf0e10cSrcweir 	return nDelta;
569*cdf0e10cSrcweir }
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir // -----------------------------------------------------------------------
572*cdf0e10cSrcweir 
573*cdf0e10cSrcweir long Slider::ImplDoAction( sal_Bool bCallEndSlide )
574*cdf0e10cSrcweir {
575*cdf0e10cSrcweir 	long nDelta = 0;
576*cdf0e10cSrcweir 
577*cdf0e10cSrcweir 	switch ( meScrollType )
578*cdf0e10cSrcweir 	{
579*cdf0e10cSrcweir 		case SCROLL_LINEUP:
580*cdf0e10cSrcweir 			nDelta = ImplSlide( mnThumbPos-mnLineSize, bCallEndSlide );
581*cdf0e10cSrcweir 			break;
582*cdf0e10cSrcweir 
583*cdf0e10cSrcweir 		case SCROLL_LINEDOWN:
584*cdf0e10cSrcweir 			nDelta = ImplSlide( mnThumbPos+mnLineSize, bCallEndSlide );
585*cdf0e10cSrcweir 			break;
586*cdf0e10cSrcweir 
587*cdf0e10cSrcweir 		case SCROLL_PAGEUP:
588*cdf0e10cSrcweir 			nDelta = ImplSlide( mnThumbPos-mnPageSize, bCallEndSlide );
589*cdf0e10cSrcweir 			break;
590*cdf0e10cSrcweir 
591*cdf0e10cSrcweir 		case SCROLL_PAGEDOWN:
592*cdf0e10cSrcweir 			nDelta = ImplSlide( mnThumbPos+mnPageSize, bCallEndSlide );
593*cdf0e10cSrcweir 			break;
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir 		case SCROLL_SET:
596*cdf0e10cSrcweir 		    nDelta = ImplSlide( ImplCalcThumbPos( GetPointerPosPixel().X() ), bCallEndSlide );
597*cdf0e10cSrcweir 		    break;
598*cdf0e10cSrcweir         default:
599*cdf0e10cSrcweir             break;
600*cdf0e10cSrcweir 	}
601*cdf0e10cSrcweir 
602*cdf0e10cSrcweir 	return nDelta;
603*cdf0e10cSrcweir }
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir // -----------------------------------------------------------------------
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir void Slider::ImplDoMouseAction( const Point& rMousePos, sal_Bool bCallAction )
608*cdf0e10cSrcweir {
609*cdf0e10cSrcweir 	sal_uInt16	nOldStateFlags = mnStateFlags;
610*cdf0e10cSrcweir 	sal_Bool	bAction = sal_False;
611*cdf0e10cSrcweir 
612*cdf0e10cSrcweir 	switch ( meScrollType )
613*cdf0e10cSrcweir 	{
614*cdf0e10cSrcweir     	case( SCROLL_SET ):
615*cdf0e10cSrcweir     	{
616*cdf0e10cSrcweir     	    const bool bUp = ImplIsPageUp( rMousePos ), bDown = ImplIsPageDown( rMousePos );
617*cdf0e10cSrcweir 
618*cdf0e10cSrcweir 			if ( bUp || bDown )
619*cdf0e10cSrcweir 			{
620*cdf0e10cSrcweir 				bAction = bCallAction;
621*cdf0e10cSrcweir 				mnStateFlags |= ( bUp ? SLIDER_STATE_CHANNEL1_DOWN : SLIDER_STATE_CHANNEL2_DOWN );
622*cdf0e10cSrcweir 			}
623*cdf0e10cSrcweir 			else
624*cdf0e10cSrcweir 				mnStateFlags &= ~( SLIDER_STATE_CHANNEL1_DOWN | SLIDER_STATE_CHANNEL2_DOWN );
625*cdf0e10cSrcweir 			break;
626*cdf0e10cSrcweir     	}
627*cdf0e10cSrcweir 
628*cdf0e10cSrcweir 		case SCROLL_PAGEUP:
629*cdf0e10cSrcweir 			if ( ImplIsPageUp( rMousePos ) )
630*cdf0e10cSrcweir 			{
631*cdf0e10cSrcweir 				bAction = bCallAction;
632*cdf0e10cSrcweir 				mnStateFlags |= SLIDER_STATE_CHANNEL1_DOWN;
633*cdf0e10cSrcweir 			}
634*cdf0e10cSrcweir 			else
635*cdf0e10cSrcweir 				mnStateFlags &= ~SLIDER_STATE_CHANNEL1_DOWN;
636*cdf0e10cSrcweir 			break;
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir 		case SCROLL_PAGEDOWN:
639*cdf0e10cSrcweir 			if ( ImplIsPageDown( rMousePos ) )
640*cdf0e10cSrcweir 			{
641*cdf0e10cSrcweir 				bAction = bCallAction;
642*cdf0e10cSrcweir 				mnStateFlags |= SLIDER_STATE_CHANNEL2_DOWN;
643*cdf0e10cSrcweir 			}
644*cdf0e10cSrcweir 			else
645*cdf0e10cSrcweir 				mnStateFlags &= ~SLIDER_STATE_CHANNEL2_DOWN;
646*cdf0e10cSrcweir 			break;
647*cdf0e10cSrcweir         default:
648*cdf0e10cSrcweir             break;
649*cdf0e10cSrcweir 	}
650*cdf0e10cSrcweir 
651*cdf0e10cSrcweir 	if ( bAction )
652*cdf0e10cSrcweir 	{
653*cdf0e10cSrcweir 		if ( ImplDoAction( sal_False ) )
654*cdf0e10cSrcweir 		{
655*cdf0e10cSrcweir 			// Update the channel complete
656*cdf0e10cSrcweir 			if ( mnDragDraw & SLIDER_DRAW_CHANNEL )
657*cdf0e10cSrcweir 			{
658*cdf0e10cSrcweir 				Update();
659*cdf0e10cSrcweir 				ImplDraw( mnDragDraw );
660*cdf0e10cSrcweir 			}
661*cdf0e10cSrcweir 		}
662*cdf0e10cSrcweir 	}
663*cdf0e10cSrcweir 	else if ( nOldStateFlags != mnStateFlags )
664*cdf0e10cSrcweir 		ImplDraw( mnDragDraw );
665*cdf0e10cSrcweir }
666*cdf0e10cSrcweir 
667*cdf0e10cSrcweir // -----------------------------------------------------------------------
668*cdf0e10cSrcweir 
669*cdf0e10cSrcweir long Slider::ImplDoSlide( long nNewPos )
670*cdf0e10cSrcweir {
671*cdf0e10cSrcweir 	if ( meScrollType != SCROLL_DONTKNOW )
672*cdf0e10cSrcweir 		return 0;
673*cdf0e10cSrcweir 
674*cdf0e10cSrcweir 	meScrollType = SCROLL_DRAG;
675*cdf0e10cSrcweir 	long nDelta = ImplSlide( nNewPos, sal_True );
676*cdf0e10cSrcweir 	meScrollType = SCROLL_DONTKNOW;
677*cdf0e10cSrcweir 	return nDelta;
678*cdf0e10cSrcweir }
679*cdf0e10cSrcweir 
680*cdf0e10cSrcweir // -----------------------------------------------------------------------
681*cdf0e10cSrcweir 
682*cdf0e10cSrcweir long Slider::ImplDoSlideAction( ScrollType eScrollType )
683*cdf0e10cSrcweir {
684*cdf0e10cSrcweir 	if ( (meScrollType != SCROLL_DONTKNOW) ||
685*cdf0e10cSrcweir 		 (eScrollType == SCROLL_DONTKNOW) ||
686*cdf0e10cSrcweir 		 (eScrollType == SCROLL_DRAG) )
687*cdf0e10cSrcweir 		return 0;
688*cdf0e10cSrcweir 
689*cdf0e10cSrcweir 	meScrollType = eScrollType;
690*cdf0e10cSrcweir 	long nDelta = ImplDoAction( sal_True );
691*cdf0e10cSrcweir 	meScrollType = SCROLL_DONTKNOW;
692*cdf0e10cSrcweir 	return nDelta;
693*cdf0e10cSrcweir }
694*cdf0e10cSrcweir 
695*cdf0e10cSrcweir // -----------------------------------------------------------------------
696*cdf0e10cSrcweir 
697*cdf0e10cSrcweir void Slider::MouseButtonDown( const MouseEvent& rMEvt )
698*cdf0e10cSrcweir {
699*cdf0e10cSrcweir 	if ( rMEvt.IsLeft() )
700*cdf0e10cSrcweir 	{
701*cdf0e10cSrcweir 		const Point&	rMousePos = rMEvt.GetPosPixel();
702*cdf0e10cSrcweir 		sal_uInt16			nTrackFlags = 0;
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir 		if ( maThumbRect.IsInside( rMousePos ) )
705*cdf0e10cSrcweir 		{
706*cdf0e10cSrcweir 			nTrackFlags 	= 0;
707*cdf0e10cSrcweir 			meScrollType	= SCROLL_DRAG;
708*cdf0e10cSrcweir 			mnDragDraw		= SLIDER_DRAW_THUMB;
709*cdf0e10cSrcweir 
710*cdf0e10cSrcweir 			// Zusaetzliche Daten berechnen
711*cdf0e10cSrcweir 			Point aCenterPos = maThumbRect.Center();
712*cdf0e10cSrcweir 			if ( GetStyle() & WB_HORZ )
713*cdf0e10cSrcweir 				mnMouseOff = rMousePos.X()-aCenterPos.X();
714*cdf0e10cSrcweir 			else
715*cdf0e10cSrcweir 				mnMouseOff = rMousePos.Y()-aCenterPos.Y();
716*cdf0e10cSrcweir 		}
717*cdf0e10cSrcweir 		else if ( ImplIsPageUp( rMousePos ) )
718*cdf0e10cSrcweir 		{
719*cdf0e10cSrcweir 		    if( GetStyle() & WB_SLIDERSET )
720*cdf0e10cSrcweir 		        meScrollType = SCROLL_SET;
721*cdf0e10cSrcweir 		    else
722*cdf0e10cSrcweir 		    {
723*cdf0e10cSrcweir 			    nTrackFlags = STARTTRACK_BUTTONREPEAT;
724*cdf0e10cSrcweir 			    meScrollType = SCROLL_PAGEUP;
725*cdf0e10cSrcweir 			}
726*cdf0e10cSrcweir 
727*cdf0e10cSrcweir 			mnDragDraw = SLIDER_DRAW_CHANNEL;
728*cdf0e10cSrcweir 		}
729*cdf0e10cSrcweir 		else if ( ImplIsPageDown( rMousePos ) )
730*cdf0e10cSrcweir 		{
731*cdf0e10cSrcweir 		    if( GetStyle() & WB_SLIDERSET )
732*cdf0e10cSrcweir 		        meScrollType = SCROLL_SET;
733*cdf0e10cSrcweir 		    else
734*cdf0e10cSrcweir 		    {
735*cdf0e10cSrcweir 			    nTrackFlags = STARTTRACK_BUTTONREPEAT;
736*cdf0e10cSrcweir 			    meScrollType = SCROLL_PAGEDOWN;
737*cdf0e10cSrcweir 			}
738*cdf0e10cSrcweir 
739*cdf0e10cSrcweir 			mnDragDraw = SLIDER_DRAW_CHANNEL;
740*cdf0e10cSrcweir 		}
741*cdf0e10cSrcweir 
742*cdf0e10cSrcweir 		// Soll Tracking gestartet werden
743*cdf0e10cSrcweir 		if( meScrollType != SCROLL_DONTKNOW )
744*cdf0e10cSrcweir 		{
745*cdf0e10cSrcweir 			// Startposition merken fuer Abbruch und EndScroll-Delta
746*cdf0e10cSrcweir 			mnStartPos = mnThumbPos;
747*cdf0e10cSrcweir 			ImplDoMouseAction( rMousePos, meScrollType != SCROLL_SET );
748*cdf0e10cSrcweir 			Update();
749*cdf0e10cSrcweir 
750*cdf0e10cSrcweir 			if( meScrollType != SCROLL_SET )
751*cdf0e10cSrcweir 		        StartTracking( nTrackFlags );
752*cdf0e10cSrcweir 		}
753*cdf0e10cSrcweir 	}
754*cdf0e10cSrcweir }
755*cdf0e10cSrcweir 
756*cdf0e10cSrcweir // -----------------------------------------------------------------------
757*cdf0e10cSrcweir 
758*cdf0e10cSrcweir void Slider::MouseButtonUp( const MouseEvent& )
759*cdf0e10cSrcweir {
760*cdf0e10cSrcweir     if( SCROLL_SET == meScrollType )
761*cdf0e10cSrcweir     {
762*cdf0e10cSrcweir 		// Button und PageRect-Status wieder herstellen
763*cdf0e10cSrcweir 		const sal_uInt16 nOldStateFlags = mnStateFlags;
764*cdf0e10cSrcweir 
765*cdf0e10cSrcweir 		mnStateFlags &= ~( SLIDER_STATE_CHANNEL1_DOWN | SLIDER_STATE_CHANNEL2_DOWN | SLIDER_STATE_THUMB_DOWN );
766*cdf0e10cSrcweir 
767*cdf0e10cSrcweir 		if ( nOldStateFlags != mnStateFlags )
768*cdf0e10cSrcweir 			ImplDraw( mnDragDraw );
769*cdf0e10cSrcweir 
770*cdf0e10cSrcweir 		mnDragDraw = 0;
771*cdf0e10cSrcweir     	ImplDoAction( sal_True );
772*cdf0e10cSrcweir     	meScrollType = SCROLL_DONTKNOW;
773*cdf0e10cSrcweir     }
774*cdf0e10cSrcweir }
775*cdf0e10cSrcweir 
776*cdf0e10cSrcweir // -----------------------------------------------------------------------
777*cdf0e10cSrcweir 
778*cdf0e10cSrcweir void Slider::Tracking( const TrackingEvent& rTEvt )
779*cdf0e10cSrcweir {
780*cdf0e10cSrcweir 	if ( rTEvt.IsTrackingEnded() )
781*cdf0e10cSrcweir 	{
782*cdf0e10cSrcweir 		// Button und PageRect-Status wieder herstellen
783*cdf0e10cSrcweir 		sal_uInt16 nOldStateFlags = mnStateFlags;
784*cdf0e10cSrcweir 		mnStateFlags &= ~(SLIDER_STATE_CHANNEL1_DOWN | SLIDER_STATE_CHANNEL2_DOWN |
785*cdf0e10cSrcweir 						  SLIDER_STATE_THUMB_DOWN);
786*cdf0e10cSrcweir 		if ( nOldStateFlags != mnStateFlags )
787*cdf0e10cSrcweir 			ImplDraw( mnDragDraw );
788*cdf0e10cSrcweir 		mnDragDraw = 0;
789*cdf0e10cSrcweir 
790*cdf0e10cSrcweir 		// Bei Abbruch, die alte ThumbPosition wieder herstellen
791*cdf0e10cSrcweir 		if ( rTEvt.IsTrackingCanceled() )
792*cdf0e10cSrcweir 		{
793*cdf0e10cSrcweir 			long nOldPos = mnThumbPos;
794*cdf0e10cSrcweir 			SetThumbPos( mnStartPos );
795*cdf0e10cSrcweir 			mnDelta = mnThumbPos-nOldPos;
796*cdf0e10cSrcweir 			Slide();
797*cdf0e10cSrcweir 		}
798*cdf0e10cSrcweir 
799*cdf0e10cSrcweir 		if ( meScrollType == SCROLL_DRAG )
800*cdf0e10cSrcweir 		{
801*cdf0e10cSrcweir 			// Wenn gedragt wurde, berechnen wir den Thumb neu, damit
802*cdf0e10cSrcweir 			// er wieder auf einer gerundeten ThumbPosition steht
803*cdf0e10cSrcweir 			ImplCalc();
804*cdf0e10cSrcweir 			Update();
805*cdf0e10cSrcweir 
806*cdf0e10cSrcweir 			if ( !mbFullDrag && (mnStartPos != mnThumbPos) )
807*cdf0e10cSrcweir 			{
808*cdf0e10cSrcweir 				mnDelta = mnThumbPos-mnStartPos;
809*cdf0e10cSrcweir 				Slide();
810*cdf0e10cSrcweir 				mnDelta = 0;
811*cdf0e10cSrcweir 			}
812*cdf0e10cSrcweir 		}
813*cdf0e10cSrcweir 
814*cdf0e10cSrcweir 		mnDelta = mnThumbPos-mnStartPos;
815*cdf0e10cSrcweir 		EndSlide();
816*cdf0e10cSrcweir 		mnDelta = 0;
817*cdf0e10cSrcweir 		meScrollType = SCROLL_DONTKNOW;
818*cdf0e10cSrcweir 	}
819*cdf0e10cSrcweir 	else
820*cdf0e10cSrcweir 	{
821*cdf0e10cSrcweir 		const Point rMousePos = rTEvt.GetMouseEvent().GetPosPixel();
822*cdf0e10cSrcweir 
823*cdf0e10cSrcweir 		// Dragging wird speziell behandelt
824*cdf0e10cSrcweir 		if ( meScrollType == SCROLL_DRAG )
825*cdf0e10cSrcweir 		{
826*cdf0e10cSrcweir 			long nMovePix;
827*cdf0e10cSrcweir 			Point aCenterPos = maThumbRect.Center();
828*cdf0e10cSrcweir 			if ( GetStyle() & WB_HORZ )
829*cdf0e10cSrcweir 				nMovePix = rMousePos.X()-(aCenterPos.X()+mnMouseOff);
830*cdf0e10cSrcweir 			else
831*cdf0e10cSrcweir 				nMovePix = rMousePos.Y()-(aCenterPos.Y()+mnMouseOff);
832*cdf0e10cSrcweir 			// Nur wenn sich Maus in die Scrollrichtung bewegt, muessen
833*cdf0e10cSrcweir 			// wir etwas tun
834*cdf0e10cSrcweir 			if ( nMovePix )
835*cdf0e10cSrcweir 			{
836*cdf0e10cSrcweir 				mnThumbPixPos += nMovePix;
837*cdf0e10cSrcweir 				if ( mnThumbPixPos < mnThumbPixOffset )
838*cdf0e10cSrcweir 					mnThumbPixPos = mnThumbPixOffset;
839*cdf0e10cSrcweir 				if ( mnThumbPixPos > (mnThumbPixOffset+mnThumbPixRange-1) )
840*cdf0e10cSrcweir 					mnThumbPixPos = mnThumbPixOffset+mnThumbPixRange-1;
841*cdf0e10cSrcweir 				long nOldPos = mnThumbPos;
842*cdf0e10cSrcweir 				mnThumbPos = ImplCalcThumbPos( mnThumbPixPos );
843*cdf0e10cSrcweir 				if ( nOldPos != mnThumbPos )
844*cdf0e10cSrcweir 				{
845*cdf0e10cSrcweir 					ImplUpdateRects();
846*cdf0e10cSrcweir 					Update();
847*cdf0e10cSrcweir 					if ( mbFullDrag && (nOldPos != mnThumbPos) )
848*cdf0e10cSrcweir 					{
849*cdf0e10cSrcweir 						mnDelta = mnThumbPos-nOldPos;
850*cdf0e10cSrcweir 						Slide();
851*cdf0e10cSrcweir 						mnDelta = 0;
852*cdf0e10cSrcweir 					}
853*cdf0e10cSrcweir 				}
854*cdf0e10cSrcweir 			}
855*cdf0e10cSrcweir 		}
856*cdf0e10cSrcweir 		else
857*cdf0e10cSrcweir 			ImplDoMouseAction( rMousePos, rTEvt.IsTrackingRepeat() );
858*cdf0e10cSrcweir 
859*cdf0e10cSrcweir 		// Wenn Slider-Werte so umgesetzt wurden, das es nichts
860*cdf0e10cSrcweir 		// mehr zum Tracking gibt, dann berechen wir hier ab
861*cdf0e10cSrcweir 		if ( !IsVisible() )
862*cdf0e10cSrcweir 			EndTracking();
863*cdf0e10cSrcweir 	}
864*cdf0e10cSrcweir }
865*cdf0e10cSrcweir 
866*cdf0e10cSrcweir // -----------------------------------------------------------------------
867*cdf0e10cSrcweir 
868*cdf0e10cSrcweir void Slider::KeyInput( const KeyEvent& rKEvt )
869*cdf0e10cSrcweir {
870*cdf0e10cSrcweir 	if ( !rKEvt.GetKeyCode().GetModifier() )
871*cdf0e10cSrcweir 	{
872*cdf0e10cSrcweir 		switch ( rKEvt.GetKeyCode().GetCode() )
873*cdf0e10cSrcweir 		{
874*cdf0e10cSrcweir 			case KEY_HOME:
875*cdf0e10cSrcweir 				ImplDoSlide( GetRangeMin() );
876*cdf0e10cSrcweir 				break;
877*cdf0e10cSrcweir 			case KEY_END:
878*cdf0e10cSrcweir 				ImplDoSlide( GetRangeMax() );
879*cdf0e10cSrcweir 				break;
880*cdf0e10cSrcweir 
881*cdf0e10cSrcweir 			case KEY_LEFT:
882*cdf0e10cSrcweir 			case KEY_UP:
883*cdf0e10cSrcweir 				ImplDoSlideAction( SCROLL_LINEUP );
884*cdf0e10cSrcweir 				break;
885*cdf0e10cSrcweir 
886*cdf0e10cSrcweir 			case KEY_RIGHT:
887*cdf0e10cSrcweir 			case KEY_DOWN:
888*cdf0e10cSrcweir 				ImplDoSlideAction( SCROLL_LINEDOWN );
889*cdf0e10cSrcweir 				break;
890*cdf0e10cSrcweir 
891*cdf0e10cSrcweir 			case KEY_PAGEUP:
892*cdf0e10cSrcweir 				ImplDoSlideAction( SCROLL_PAGEUP );
893*cdf0e10cSrcweir 				break;
894*cdf0e10cSrcweir 
895*cdf0e10cSrcweir 			case KEY_PAGEDOWN:
896*cdf0e10cSrcweir 				ImplDoSlideAction( SCROLL_PAGEDOWN );
897*cdf0e10cSrcweir 				break;
898*cdf0e10cSrcweir 
899*cdf0e10cSrcweir 			default:
900*cdf0e10cSrcweir 				Control::KeyInput( rKEvt );
901*cdf0e10cSrcweir 				break;
902*cdf0e10cSrcweir 		}
903*cdf0e10cSrcweir 	}
904*cdf0e10cSrcweir 	else
905*cdf0e10cSrcweir 		Control::KeyInput( rKEvt );
906*cdf0e10cSrcweir }
907*cdf0e10cSrcweir 
908*cdf0e10cSrcweir // -----------------------------------------------------------------------
909*cdf0e10cSrcweir 
910*cdf0e10cSrcweir void Slider::Paint( const Rectangle& )
911*cdf0e10cSrcweir {
912*cdf0e10cSrcweir 	ImplDraw( SLIDER_DRAW_ALL );
913*cdf0e10cSrcweir }
914*cdf0e10cSrcweir 
915*cdf0e10cSrcweir // -----------------------------------------------------------------------
916*cdf0e10cSrcweir 
917*cdf0e10cSrcweir void Slider::Resize()
918*cdf0e10cSrcweir {
919*cdf0e10cSrcweir     Control::Resize();
920*cdf0e10cSrcweir 	mbCalcSize = sal_True;
921*cdf0e10cSrcweir 	if ( IsReallyVisible() )
922*cdf0e10cSrcweir 		ImplCalc( sal_False );
923*cdf0e10cSrcweir 	Invalidate();
924*cdf0e10cSrcweir }
925*cdf0e10cSrcweir 
926*cdf0e10cSrcweir // -----------------------------------------------------------------------
927*cdf0e10cSrcweir 
928*cdf0e10cSrcweir void Slider::RequestHelp( const HelpEvent& rHEvt )
929*cdf0e10cSrcweir {
930*cdf0e10cSrcweir 	Control::RequestHelp( rHEvt );
931*cdf0e10cSrcweir }
932*cdf0e10cSrcweir 
933*cdf0e10cSrcweir // -----------------------------------------------------------------------
934*cdf0e10cSrcweir 
935*cdf0e10cSrcweir void Slider::StateChanged( StateChangedType nType )
936*cdf0e10cSrcweir {
937*cdf0e10cSrcweir 	Control::StateChanged( nType );
938*cdf0e10cSrcweir 
939*cdf0e10cSrcweir 	if ( nType == STATE_CHANGE_INITSHOW )
940*cdf0e10cSrcweir 		ImplCalc( sal_False );
941*cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_DATA )
942*cdf0e10cSrcweir 	{
943*cdf0e10cSrcweir 		if ( IsReallyVisible() && IsUpdateMode() )
944*cdf0e10cSrcweir 			ImplCalc( sal_True );
945*cdf0e10cSrcweir 	}
946*cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_UPDATEMODE )
947*cdf0e10cSrcweir 	{
948*cdf0e10cSrcweir 		if ( IsReallyVisible() && IsUpdateMode() )
949*cdf0e10cSrcweir 		{
950*cdf0e10cSrcweir 			ImplCalc( sal_False );
951*cdf0e10cSrcweir 			Invalidate();
952*cdf0e10cSrcweir 		}
953*cdf0e10cSrcweir 	}
954*cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_ENABLE )
955*cdf0e10cSrcweir 	{
956*cdf0e10cSrcweir 		if ( IsReallyVisible() && IsUpdateMode() )
957*cdf0e10cSrcweir 			Invalidate();
958*cdf0e10cSrcweir 	}
959*cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_STYLE )
960*cdf0e10cSrcweir 	{
961*cdf0e10cSrcweir 		if ( IsReallyVisible() && IsUpdateMode() )
962*cdf0e10cSrcweir 		{
963*cdf0e10cSrcweir 			if ( (GetPrevStyle() & SLIDER_VIEW_STYLE) !=
964*cdf0e10cSrcweir 				 (GetStyle() & SLIDER_VIEW_STYLE) )
965*cdf0e10cSrcweir 			{
966*cdf0e10cSrcweir 				mbCalcSize = sal_True;
967*cdf0e10cSrcweir 				ImplCalc( sal_False );
968*cdf0e10cSrcweir 				Invalidate();
969*cdf0e10cSrcweir 			}
970*cdf0e10cSrcweir 		}
971*cdf0e10cSrcweir 	}
972*cdf0e10cSrcweir 	else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
973*cdf0e10cSrcweir 	{
974*cdf0e10cSrcweir 		ImplInitSettings();
975*cdf0e10cSrcweir 		Invalidate();
976*cdf0e10cSrcweir 	}
977*cdf0e10cSrcweir }
978*cdf0e10cSrcweir 
979*cdf0e10cSrcweir // -----------------------------------------------------------------------
980*cdf0e10cSrcweir 
981*cdf0e10cSrcweir void Slider::DataChanged( const DataChangedEvent& rDCEvt )
982*cdf0e10cSrcweir {
983*cdf0e10cSrcweir 	Control::DataChanged( rDCEvt );
984*cdf0e10cSrcweir 
985*cdf0e10cSrcweir 	if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
986*cdf0e10cSrcweir 		 (rDCEvt.GetFlags() & SETTINGS_STYLE) )
987*cdf0e10cSrcweir 	{
988*cdf0e10cSrcweir 		ImplInitSettings();
989*cdf0e10cSrcweir 		Invalidate();
990*cdf0e10cSrcweir 	}
991*cdf0e10cSrcweir }
992*cdf0e10cSrcweir 
993*cdf0e10cSrcweir // -----------------------------------------------------------------------
994*cdf0e10cSrcweir 
995*cdf0e10cSrcweir void Slider::Slide()
996*cdf0e10cSrcweir {
997*cdf0e10cSrcweir 	maSlideHdl.Call( this );
998*cdf0e10cSrcweir }
999*cdf0e10cSrcweir 
1000*cdf0e10cSrcweir // -----------------------------------------------------------------------
1001*cdf0e10cSrcweir 
1002*cdf0e10cSrcweir void Slider::EndSlide()
1003*cdf0e10cSrcweir {
1004*cdf0e10cSrcweir 	maEndSlideHdl.Call( this );
1005*cdf0e10cSrcweir }
1006*cdf0e10cSrcweir 
1007*cdf0e10cSrcweir // -----------------------------------------------------------------------
1008*cdf0e10cSrcweir 
1009*cdf0e10cSrcweir void Slider::SetRangeMin( long nNewRange )
1010*cdf0e10cSrcweir {
1011*cdf0e10cSrcweir 	SetRange( Range( nNewRange, GetRangeMax() ) );
1012*cdf0e10cSrcweir }
1013*cdf0e10cSrcweir 
1014*cdf0e10cSrcweir // -----------------------------------------------------------------------
1015*cdf0e10cSrcweir 
1016*cdf0e10cSrcweir void Slider::SetRangeMax( long nNewRange )
1017*cdf0e10cSrcweir {
1018*cdf0e10cSrcweir 	SetRange( Range( GetRangeMin(), nNewRange ) );
1019*cdf0e10cSrcweir }
1020*cdf0e10cSrcweir 
1021*cdf0e10cSrcweir // -----------------------------------------------------------------------
1022*cdf0e10cSrcweir 
1023*cdf0e10cSrcweir void Slider::SetRange( const Range& rRange )
1024*cdf0e10cSrcweir {
1025*cdf0e10cSrcweir 	// Range einpassen
1026*cdf0e10cSrcweir 	Range aRange = rRange;
1027*cdf0e10cSrcweir 	aRange.Justify();
1028*cdf0e10cSrcweir 	long nNewMinRange = aRange.Min();
1029*cdf0e10cSrcweir 	long nNewMaxRange = aRange.Max();
1030*cdf0e10cSrcweir 
1031*cdf0e10cSrcweir 	// Wenn Range sich unterscheidet, dann neuen setzen
1032*cdf0e10cSrcweir 	if ( (mnMinRange != nNewMinRange) ||
1033*cdf0e10cSrcweir 		 (mnMaxRange != nNewMaxRange) )
1034*cdf0e10cSrcweir 	{
1035*cdf0e10cSrcweir 		mnMinRange = nNewMinRange;
1036*cdf0e10cSrcweir 		mnMaxRange = nNewMaxRange;
1037*cdf0e10cSrcweir 
1038*cdf0e10cSrcweir 		// Thumb einpassen
1039*cdf0e10cSrcweir 		if ( mnThumbPos > mnMaxRange )
1040*cdf0e10cSrcweir 			mnThumbPos = mnMaxRange;
1041*cdf0e10cSrcweir 		if ( mnThumbPos < mnMinRange )
1042*cdf0e10cSrcweir 			mnThumbPos = mnMinRange;
1043*cdf0e10cSrcweir 
1044*cdf0e10cSrcweir 		StateChanged( STATE_CHANGE_DATA );
1045*cdf0e10cSrcweir 	}
1046*cdf0e10cSrcweir }
1047*cdf0e10cSrcweir 
1048*cdf0e10cSrcweir // -----------------------------------------------------------------------
1049*cdf0e10cSrcweir 
1050*cdf0e10cSrcweir void Slider::SetThumbPos( long nNewThumbPos )
1051*cdf0e10cSrcweir {
1052*cdf0e10cSrcweir 	if ( nNewThumbPos < mnMinRange )
1053*cdf0e10cSrcweir 		nNewThumbPos = mnMinRange;
1054*cdf0e10cSrcweir 	if ( nNewThumbPos > mnMaxRange )
1055*cdf0e10cSrcweir 		nNewThumbPos = mnMaxRange;
1056*cdf0e10cSrcweir 
1057*cdf0e10cSrcweir 	if ( mnThumbPos != nNewThumbPos )
1058*cdf0e10cSrcweir 	{
1059*cdf0e10cSrcweir 		mnThumbPos = nNewThumbPos;
1060*cdf0e10cSrcweir 		StateChanged( STATE_CHANGE_DATA );
1061*cdf0e10cSrcweir 	}
1062*cdf0e10cSrcweir }
1063*cdf0e10cSrcweir 
1064*cdf0e10cSrcweir // -----------------------------------------------------------------------
1065*cdf0e10cSrcweir 
1066*cdf0e10cSrcweir Size Slider::CalcWindowSizePixel()
1067*cdf0e10cSrcweir {
1068*cdf0e10cSrcweir 	long nWidth = mnMaxRange-mnMinRange+(SLIDER_THUMB_HALFSIZE*2)+1;
1069*cdf0e10cSrcweir 	long nHeight = SLIDER_HEIGHT;
1070*cdf0e10cSrcweir 	Size aSize;
1071*cdf0e10cSrcweir 	if ( GetStyle() & WB_HORZ )
1072*cdf0e10cSrcweir 	{
1073*cdf0e10cSrcweir 		aSize.Width()	= nWidth;
1074*cdf0e10cSrcweir 		aSize.Height()	= nHeight;
1075*cdf0e10cSrcweir 	}
1076*cdf0e10cSrcweir 	else
1077*cdf0e10cSrcweir 	{
1078*cdf0e10cSrcweir 		aSize.Height()	= nWidth;
1079*cdf0e10cSrcweir 		aSize.Width()	= nHeight;
1080*cdf0e10cSrcweir 	}
1081*cdf0e10cSrcweir 	return aSize;
1082*cdf0e10cSrcweir }
1083