Lines 83-97
Link Here
|
83 |
mbInitialUp = FALSE; |
83 |
mbInitialUp = FALSE; |
84 |
mbInitialDown = FALSE; |
84 |
mbInitialDown = FALSE; |
85 |
|
85 |
|
86 |
if ( nStyle & WB_REPEAT ) |
86 |
mnMinRange = 0; |
87 |
{ |
87 |
mnMaxRange = 100; |
88 |
mbRepeat = TRUE; |
88 |
mnValue = 0; |
|
|
89 |
mnValueStep = 1; |
89 |
|
90 |
|
90 |
maRepeatTimer.SetTimeout( SPIN_DELAY ); |
91 |
maRepeatTimer.SetTimeout( GetSettings().GetMouseSettings().GetButtonStartRepeat() ); |
91 |
maRepeatTimer.SetTimeoutHdl( LINK( this, SpinButton, ImplTimeout ) ); |
92 |
maRepeatTimer.SetTimeoutHdl( LINK( this, SpinButton, ImplTimeout ) ); |
92 |
} |
93 |
|
93 |
else |
94 |
mbRepeat = 0 != ( nStyle & WB_REPEAT ); |
94 |
mbRepeat = FALSE; |
|
|
95 |
|
95 |
|
96 |
if ( nStyle & WB_HSCROLL ) |
96 |
if ( nStyle & WB_HSCROLL ) |
97 |
mbHorz = TRUE; |
97 |
mbHorz = TRUE; |
Lines 130-138
Link Here
|
130 |
|
130 |
|
131 |
IMPL_LINK( SpinButton, ImplTimeout, Timer*, pTimer ) |
131 |
IMPL_LINK( SpinButton, ImplTimeout, Timer*, pTimer ) |
132 |
{ |
132 |
{ |
133 |
if ( pTimer->GetTimeout() == SPIN_DELAY ) |
133 |
if ( pTimer->GetTimeout() == GetSettings().GetMouseSettings().GetButtonStartRepeat() ) |
134 |
{ |
134 |
{ |
135 |
pTimer->SetTimeout( SPIN_SPEED ); |
135 |
pTimer->SetTimeout( GetSettings().GetMouseSettings().GetButtonRepeat() ); |
136 |
pTimer->Start(); |
136 |
pTimer->Start(); |
137 |
} |
137 |
} |
138 |
else |
138 |
else |
Lines 150-155
Link Here
|
150 |
|
150 |
|
151 |
void SpinButton::Up() |
151 |
void SpinButton::Up() |
152 |
{ |
152 |
{ |
|
|
153 |
if ( mnValue + mnValueStep <= mnMaxRange ) |
154 |
{ |
155 |
mnValue += mnValueStep; |
156 |
StateChanged( STATE_CHANGE_DATA ); |
157 |
} |
158 |
|
153 |
ImplCallEventListeners( VCLEVENT_SPINBUTTON_UP ); |
159 |
ImplCallEventListeners( VCLEVENT_SPINBUTTON_UP ); |
154 |
maUpHdlLink.Call( this ); |
160 |
maUpHdlLink.Call( this ); |
155 |
} |
161 |
} |
Lines 158-163
Link Here
|
158 |
|
164 |
|
159 |
void SpinButton::Down() |
165 |
void SpinButton::Down() |
160 |
{ |
166 |
{ |
|
|
167 |
if ( mnValue >= mnMinRange + mnValueStep ) |
168 |
{ |
169 |
mnValue -= mnValueStep; |
170 |
StateChanged( STATE_CHANGE_DATA ); |
171 |
} |
172 |
|
161 |
ImplCallEventListeners( VCLEVENT_SPINBUTTON_DOWN ); |
173 |
ImplCallEventListeners( VCLEVENT_SPINBUTTON_DOWN ); |
162 |
maDownHdlLink.Call( this ); |
174 |
maDownHdlLink.Call( this ); |
163 |
} |
175 |
} |
Lines 173-180
Link Here
|
173 |
Rectangle aRect( aTmpPoint, aSize ); |
185 |
Rectangle aRect( aTmpPoint, aSize ); |
174 |
if ( mbHorz ) |
186 |
if ( mbHorz ) |
175 |
{ |
187 |
{ |
176 |
maUpperRect = Rectangle( 0, 0, aSize.Width()/2, aSize.Height()-1 ); |
188 |
maLowerRect = Rectangle( 0, 0, aSize.Width()/2, aSize.Height()-1 ); |
177 |
maLowerRect = Rectangle( maUpperRect.TopRight(), aRect.BottomRight() ); |
189 |
maUpperRect = Rectangle( maLowerRect.TopRight(), aRect.BottomRight() ); |
178 |
} |
190 |
} |
179 |
else |
191 |
else |
180 |
{ |
192 |
{ |
Lines 191-210
Link Here
|
191 |
{ |
203 |
{ |
192 |
BOOL bEnable = IsEnabled(); |
204 |
BOOL bEnable = IsEnabled(); |
193 |
ImplDrawSpinButton( this, maUpperRect, maLowerRect, mbUpperIn, mbLowerIn, |
205 |
ImplDrawSpinButton( this, maUpperRect, maLowerRect, mbUpperIn, mbLowerIn, |
194 |
bEnable, bEnable, mbHorz ); |
206 |
bEnable && ( mnValue + mnValueStep <= mnMaxRange ), |
|
|
207 |
bEnable && ( mnValue >= mnMinRange + mnValueStep ), mbHorz, TRUE ); |
195 |
} |
208 |
} |
196 |
|
209 |
|
197 |
// ----------------------------------------------------------------------- |
210 |
// ----------------------------------------------------------------------- |
198 |
|
211 |
|
199 |
void SpinButton::MouseButtonDown( const MouseEvent& rMEvt ) |
212 |
void SpinButton::MouseButtonDown( const MouseEvent& rMEvt ) |
200 |
{ |
213 |
{ |
201 |
if ( maUpperRect.IsInside( rMEvt.GetPosPixel() ) ) |
214 |
if ( maUpperRect.IsInside( rMEvt.GetPosPixel() ) && ( mnValue + mnValueStep <= mnMaxRange ) ) |
202 |
{ |
215 |
{ |
203 |
mbUpperIn = TRUE; |
216 |
mbUpperIn = TRUE; |
204 |
mbInitialUp = TRUE; |
217 |
mbInitialUp = TRUE; |
205 |
Invalidate( maUpperRect ); |
218 |
Invalidate( maUpperRect ); |
206 |
} |
219 |
} |
207 |
else if ( maLowerRect.IsInside( rMEvt.GetPosPixel() ) ) |
220 |
else if ( maLowerRect.IsInside( rMEvt.GetPosPixel() ) && ( mnValue >= mnMinRange + mnValueStep ) ) |
208 |
{ |
221 |
{ |
209 |
mbLowerIn = TRUE; |
222 |
mbLowerIn = TRUE; |
210 |
mbInitialDown = TRUE; |
223 |
mbInitialDown = TRUE; |
Lines 246-252
Link Here
|
246 |
if ( mbRepeat ) |
259 |
if ( mbRepeat ) |
247 |
{ |
260 |
{ |
248 |
maRepeatTimer.Stop(); |
261 |
maRepeatTimer.Stop(); |
249 |
maRepeatTimer.SetTimeout( SPIN_DELAY ); |
262 |
maRepeatTimer.SetTimeout( GetSettings().GetMouseSettings().GetButtonStartRepeat() ); |
250 |
} |
263 |
} |
251 |
} |
264 |
} |
252 |
|
265 |
|
Lines 311-317
Link Here
|
311 |
|
324 |
|
312 |
void SpinButton::StateChanged( StateChangedType nType ) |
325 |
void SpinButton::StateChanged( StateChangedType nType ) |
313 |
{ |
326 |
{ |
314 |
if ( nType == STATE_CHANGE_ENABLE ) |
327 |
switch ( nType ) |
|
|
328 |
{ |
329 |
case STATE_CHANGE_DATA: |
330 |
case STATE_CHANGE_ENABLE: |
315 |
Invalidate(); |
331 |
Invalidate(); |
|
|
332 |
break; |
333 |
|
334 |
case STATE_CHANGE_STYLE: |
335 |
{ |
336 |
BOOL bNewRepeat = 0 != ( GetStyle() & WB_REPEAT ); |
337 |
if ( bNewRepeat != mbRepeat ) |
338 |
{ |
339 |
if ( maRepeatTimer.IsActive() ) |
340 |
{ |
341 |
maRepeatTimer.Stop(); |
342 |
maRepeatTimer.SetTimeout( GetSettings().GetMouseSettings().GetButtonStartRepeat() ); |
343 |
} |
344 |
mbRepeat = bNewRepeat; |
345 |
} |
346 |
|
347 |
BOOL bNewHorz = 0 != ( GetStyle() & WB_HSCROLL ); |
348 |
if ( bNewHorz != mbHorz ) |
349 |
{ |
350 |
mbHorz = bNewHorz; |
351 |
Resize(); |
352 |
} |
353 |
} |
354 |
break; |
355 |
} |
356 |
|
316 |
Control::StateChanged( nType ); |
357 |
Control::StateChanged( nType ); |
|
|
358 |
} |
359 |
|
360 |
// ----------------------------------------------------------------------- |
361 |
|
362 |
void SpinButton::SetRangeMin( long nNewRange ) |
363 |
{ |
364 |
SetRange( Range( nNewRange, GetRangeMax() ) ); |
365 |
} |
366 |
|
367 |
// ----------------------------------------------------------------------- |
368 |
|
369 |
void SpinButton::SetRangeMax( long nNewRange ) |
370 |
{ |
371 |
SetRange( Range( GetRangeMin(), nNewRange ) ); |
372 |
} |
373 |
|
374 |
// ----------------------------------------------------------------------- |
375 |
|
376 |
void SpinButton::SetRange( const Range& rRange ) |
377 |
{ |
378 |
// adjust rage |
379 |
Range aRange = rRange; |
380 |
aRange.Justify(); |
381 |
long nNewMinRange = aRange.Min(); |
382 |
long nNewMaxRange = aRange.Max(); |
383 |
|
384 |
// do something only if old and new range differ |
385 |
if ( (mnMinRange != nNewMinRange) || |
386 |
(mnMaxRange != nNewMaxRange) ) |
387 |
{ |
388 |
mnMinRange = nNewMinRange; |
389 |
mnMaxRange = nNewMaxRange; |
390 |
|
391 |
// adjust value to new range, if necessary |
392 |
if ( mnValue > mnMaxRange ) |
393 |
mnValue = mnMaxRange; |
394 |
if ( mnValue < mnMinRange ) |
395 |
mnValue = mnMinRange; |
396 |
|
397 |
StateChanged( STATE_CHANGE_DATA ); |
398 |
} |
399 |
} |
400 |
|
401 |
// ----------------------------------------------------------------------- |
402 |
|
403 |
void SpinButton::SetValue( long nValue ) |
404 |
{ |
405 |
// adjust, if necessary |
406 |
if ( nValue > mnMaxRange ) |
407 |
nValue = mnMaxRange; |
408 |
if ( nValue < mnMinRange ) |
409 |
nValue = mnMinRange; |
410 |
|
411 |
if ( mnValue != nValue ) |
412 |
{ |
413 |
mnValue = nValue; |
414 |
StateChanged( STATE_CHANGE_DATA ); |
415 |
} |
317 |
} |
416 |
} |