diff --git a/uppsrc/CtrlLib/EditCtrl.h b/uppsrc/CtrlLib/EditCtrl.h index 78e99d6bd..c1c8d93b0 100644 --- a/uppsrc/CtrlLib/EditCtrl.h +++ b/uppsrc/CtrlLib/EditCtrl.h @@ -339,12 +339,30 @@ public: template IncType WithSpin_DefaultIncValue() { return 1; } template <> inline double WithSpin_DefaultIncValue() { return 0.1; } +template IncType WithSpin_DefaultStartValue() { return 0; } +template <> inline Date WithSpin_DefaultStartValue() { return GetSysDate(); } +template <> inline Time WithSpin_DefaultStartValue() { return GetSysTime(); } + template void WithSpin_Add(DataType& value, IncType inc, DataType min, bool roundfrommin) { value += inc; } +template <> inline +void WithSpin_Add(int& value, int inc, int min, bool roundfrommin) { + if(roundfrommin) + value -= min; + if(inc < 0) { + inc = -inc; + value = (value - inc) / inc * inc; + } + else + value = (value + inc) / inc * inc; + if(roundfrommin) + value += min; +} + template <> inline void WithSpin_Add(double& value, double inc, double min, bool roundfrommin) { if(roundfrommin) @@ -447,7 +465,7 @@ void WithSpin::Inc() else { DataType min = Base::GetMin(); if(IsNull(min) || min <= Base::GetDefaultMin()) - Base::SetData(0); + Base::SetData(WithSpin_DefaultStartValue()); else Base::SetData(min); } @@ -472,7 +490,7 @@ void WithSpin::Dec() else { DataType max = Base::GetMax(); if(IsNull(max) || max >= Base::GetDefaultMax()) - Base::SetData(0); + Base::SetData(WithSpin_DefaultStartValue()); else Base::SetData(max); }