Status & Roadmap
Authors & License
Funding U++
Search on this site

SourceForge.net Logo

SourceForge.net Logo

GitHub Logo

Discord Logo



template <class DataType, class Base, class IncType = DataType>

class WithSpin : public Base



This template adds spin buttons to the Base widget to increment and decrement its value. Base musts be descendant of Ctrl and must have defined methods MinMax(DataType, DataType), GetMin and GetMax. DataType is a type of Value contained in Base, IncType type of increment value.

There two global function templates that can be used to customize increment/decrement process:  WithSpin_DefaultIncValue defines the default increment value and WithSpin_Add defines a way how the value is incremented or decremented.


Public Method List


WithSpin& SetInc(IncType _inc = 1)

Sets the increment value.



DataType GetInc() const

Returns current increment value.



WithSpin& OnSides(bool b = true)

Instead of putting both buttons at the right side of widget, puts decrement button to the left and increment to the right.



bool IsOnSides() const

True is OnSides is active.



WithSpin& ShowSpin(bool s = true)

Shows/hides spin buttons.



bool IsSpinVisible() const

Returns true if spin buttons are shown.



WithSpin& RoundFromMin(bool b = true)

If this option is active, increments are rounded with respect to minimum value. E.g. normally (when not active) if minimum value is 3, going up from the minimum goes through values 3, 5, 10, ..., which when RoundFromMin is active, it goes through 3, 8, 13, ...



WithSpin& MouseWheelSpin(bool b = true)

If active, the value can be altered by mouse wheel - rolling the wheel is equivalent to pushing up/down arrows. Default is active.



WithSpin& NoMouseWheelSpin()

Same as MouseWheelSpin(false).



WithSpin& KeySpin(bool b = true)

If active, the value can be altered with Up and Down keys. Default is active.



WithSpin& NoKeySpin()

Same as KeySpin(false).


Predefined WithSpin widgets


typedef WithSpin<int, EditIntEditIntSpin

typedef WithSpin<int64, EditInt64EditInt64Spin

typedef WithSpin<double, EditDoubleEditDoubleSpin

typedef WithSpin<float, EditFloatEditFloatSpin

typedef WithSpin<Date, EditDate, intEditDateSpin

typedef WithSpin<Time, EditTime, intEditTimeSpin

typedef WithSpin<int, EditIntNotNullEditIntNotNullSpin

typedef WithSpin<int64, EditInt64NotNullEditInt64NotNullSpin

typedef WithSpin<double, EditDoubleNotNullEditDoubleNotNullSpin

typedef WithSpin<Date, EditDateNotNull, intEditDateNotNullSpin

typedef WithSpin<Time, EditTimeNotNull, intEditTimeNotNullSpin

These typedefs predefine common EditField based value editors with spin buttons.



Do you want to contribute?