Index: inc/spin.hxx =================================================================== RCS file: /cvs/gsl/vcl/inc/spin.hxx,v --- inc/spin.hxx 19 Sep 2000 10:23:07 -0000 1.1.1.1 +++ inc/spin.hxx 29 Oct 2003 07:45:13 -0000 @@ -91,6 +91,11 @@ Link maUpHdlLink; Link maDownHdlLink; + long mnMinRange; + long mnMaxRange; + long mnValue; + long mnValueStep; + #ifdef _SV_SPIN_CXX void ImplInit( Window* pParent, WinBits nStyle ); DECL_LINK( ImplTimeout, Timer* ); @@ -111,6 +116,17 @@ virtual void MouseMove( const MouseEvent& rMEvt ); virtual void KeyInput( const KeyEvent& rKEvt ); virtual void StateChanged( StateChangedType nStateChange ); + + void SetRangeMin( long nNewRange ); + long GetRangeMin() const { return mnMinRange; } + void SetRangeMax( long nNewRange ); + long GetRangeMax() const { return mnMaxRange; } + void SetRange( const Range& rRange ); + Range GetRange() const { return Range( GetRangeMin(), GetRangeMax() ); } + void SetValue( long nValue ); + long GetValue() const { return mnValue; } + void SetValueStep( long nNewStep ) { mnValueStep = nNewStep; } + long GetValueStep() const { return mnValueStep; } void SetUpHdl( const Link& rLink ) { maUpHdlLink = rLink; } const Link& GetUpHdl() const { return maUpHdlLink; } Index: source/control/spinbtn.cxx =================================================================== RCS file: /cvs/gsl/vcl/source/control/spinbtn.cxx,v --- source/control/spinbtn.cxx 8 May 2002 16:01:30 -0000 1.3 +++ source/control/spinbtn.cxx 29 Oct 2003 07:45:14 -0000 @@ -83,15 +83,15 @@ mbInitialUp = FALSE; mbInitialDown = FALSE; - if ( nStyle & WB_REPEAT ) - { - mbRepeat = TRUE; + mnMinRange = 0; + mnMaxRange = 100; + mnValue = 0; + mnValueStep = 1; - maRepeatTimer.SetTimeout( SPIN_DELAY ); - maRepeatTimer.SetTimeoutHdl( LINK( this, SpinButton, ImplTimeout ) ); - } - else - mbRepeat = FALSE; + maRepeatTimer.SetTimeout( GetSettings().GetMouseSettings().GetButtonStartRepeat() ); + maRepeatTimer.SetTimeoutHdl( LINK( this, SpinButton, ImplTimeout ) ); + + mbRepeat = 0 != ( nStyle & WB_REPEAT ); if ( nStyle & WB_HSCROLL ) mbHorz = TRUE; @@ -130,9 +130,9 @@ IMPL_LINK( SpinButton, ImplTimeout, Timer*, pTimer ) { - if ( pTimer->GetTimeout() == SPIN_DELAY ) + if ( pTimer->GetTimeout() == GetSettings().GetMouseSettings().GetButtonStartRepeat() ) { - pTimer->SetTimeout( SPIN_SPEED ); + pTimer->SetTimeout( GetSettings().GetMouseSettings().GetButtonRepeat() ); pTimer->Start(); } else @@ -150,6 +150,12 @@ void SpinButton::Up() { + if ( mnValue + mnValueStep <= mnMaxRange ) + { + mnValue += mnValueStep; + StateChanged( STATE_CHANGE_DATA ); + } + ImplCallEventListeners( VCLEVENT_SPINBUTTON_UP ); maUpHdlLink.Call( this ); } @@ -158,6 +164,12 @@ void SpinButton::Down() { + if ( mnValue >= mnMinRange + mnValueStep ) + { + mnValue -= mnValueStep; + StateChanged( STATE_CHANGE_DATA ); + } + ImplCallEventListeners( VCLEVENT_SPINBUTTON_DOWN ); maDownHdlLink.Call( this ); } @@ -173,8 +185,8 @@ Rectangle aRect( aTmpPoint, aSize ); if ( mbHorz ) { - maUpperRect = Rectangle( 0, 0, aSize.Width()/2, aSize.Height()-1 ); - maLowerRect = Rectangle( maUpperRect.TopRight(), aRect.BottomRight() ); + maLowerRect = Rectangle( 0, 0, aSize.Width()/2, aSize.Height()-1 ); + maUpperRect = Rectangle( maLowerRect.TopRight(), aRect.BottomRight() ); } else { @@ -191,20 +203,21 @@ { BOOL bEnable = IsEnabled(); ImplDrawSpinButton( this, maUpperRect, maLowerRect, mbUpperIn, mbLowerIn, - bEnable, bEnable, mbHorz ); + bEnable && ( mnValue + mnValueStep <= mnMaxRange ), + bEnable && ( mnValue >= mnMinRange + mnValueStep ), mbHorz ); } // ----------------------------------------------------------------------- void SpinButton::MouseButtonDown( const MouseEvent& rMEvt ) { - if ( maUpperRect.IsInside( rMEvt.GetPosPixel() ) ) + if ( maUpperRect.IsInside( rMEvt.GetPosPixel() ) && ( mnValue + mnValueStep <= mnMaxRange ) ) { mbUpperIn = TRUE; mbInitialUp = TRUE; Invalidate( maUpperRect ); } - else if ( maLowerRect.IsInside( rMEvt.GetPosPixel() ) ) + else if ( maLowerRect.IsInside( rMEvt.GetPosPixel() ) && ( mnValue >= mnMinRange + mnValueStep ) ) { mbLowerIn = TRUE; mbInitialDown = TRUE; @@ -246,7 +259,7 @@ if ( mbRepeat ) { maRepeatTimer.Stop(); - maRepeatTimer.SetTimeout( SPIN_DELAY ); + maRepeatTimer.SetTimeout( GetSettings().GetMouseSettings().GetButtonStartRepeat() ); } } @@ -311,7 +324,93 @@ void SpinButton::StateChanged( StateChangedType nType ) { - if ( nType == STATE_CHANGE_ENABLE ) + switch ( nType ) + { + case STATE_CHANGE_DATA: + case STATE_CHANGE_ENABLE: Invalidate(); + break; + + case STATE_CHANGE_STYLE: + { + BOOL bNewRepeat = 0 != ( GetStyle() & WB_REPEAT ); + if ( bNewRepeat != mbRepeat ) + { + if ( maRepeatTimer.IsActive() ) + { + maRepeatTimer.Stop(); + maRepeatTimer.SetTimeout( GetSettings().GetMouseSettings().GetButtonStartRepeat() ); + } + mbRepeat = bNewRepeat; + } + + BOOL bNewHorz = 0 != ( GetStyle() & WB_HSCROLL ); + if ( bNewHorz != mbHorz ) + { + mbHorz = bNewHorz; + Resize(); + } + } + break; + } + Control::StateChanged( nType ); +} + +// ----------------------------------------------------------------------- + +void SpinButton::SetRangeMin( long nNewRange ) +{ + SetRange( Range( nNewRange, GetRangeMax() ) ); +} + +// ----------------------------------------------------------------------- + +void SpinButton::SetRangeMax( long nNewRange ) +{ + SetRange( Range( GetRangeMin(), nNewRange ) ); +} + +// ----------------------------------------------------------------------- + +void SpinButton::SetRange( const Range& rRange ) +{ + // adjust rage + Range aRange = rRange; + aRange.Justify(); + long nNewMinRange = aRange.Min(); + long nNewMaxRange = aRange.Max(); + + // do something only if old and new range differ + if ( (mnMinRange != nNewMinRange) || + (mnMaxRange != nNewMaxRange) ) + { + mnMinRange = nNewMinRange; + mnMaxRange = nNewMaxRange; + + // adjust value to new range, if necessary + if ( mnValue > mnMaxRange ) + mnValue = mnMaxRange; + if ( mnValue < mnMinRange ) + mnValue = mnMinRange; + + StateChanged( STATE_CHANGE_DATA ); + } +} + +// ----------------------------------------------------------------------- + +void SpinButton::SetValue( long nValue ) +{ + // adjust, if necessary + if ( nValue > mnMaxRange ) + nValue = mnMaxRange; + if ( nValue < mnMinRange ) + nValue = mnMinRange; + + if ( mnValue != nValue ) + { + mnValue = nValue; + StateChanged( STATE_CHANGE_DATA ); + } } Index: source/control/spinfld.cxx =================================================================== RCS file: /cvs/gsl/vcl/source/control/spinfld.cxx,v --- source/control/spinfld.cxx 12 Sep 2002 08:35:13 -0000 1.10 +++ source/control/spinfld.cxx 29 Oct 2003 07:45:14 -0000 @@ -82,6 +82,8 @@ // ======================================================================= +// ----------------------------------------------------------------------- + void ImplDrawSpinButton( OutputDevice* pOutDev, const Rectangle& rUpperRect, const Rectangle& rLowerRect, @@ -100,8 +102,8 @@ { if ( bHorz ) { - eType1 = SYMBOL_ARROW_LEFT; - eType2 = SYMBOL_ARROW_RIGHT; + eType1 = SYMBOL_ARROW_RIGHT; + eType2 = SYMBOL_ARROW_LEFT; } else { @@ -113,8 +115,8 @@ { if ( bHorz ) { - eType1 = SYMBOL_SPIN_LEFT; - eType2 = SYMBOL_SPIN_RIGHT; + eType1 = SYMBOL_SPIN_RIGHT; + eType2 = SYMBOL_SPIN_LEFT; } else {