1 QNumberBox : QAbstractStepValue {
2 var <scroll, <scroll_step;
3 var <align, <buttonsVisible = false;
4 var <normalColor, <typingColor;
5 var <object, <>setBoth = true;
7 *qtClass { ^"QcNumberBox" }
9 *new { arg aParent, aBounds;
10 var obj = super.new( aParent, aBounds );
18 normalColor = Color.black;
19 typingColor = Color.red;
24 if( obj.isNumber ) { this.value = obj } { this.string = obj.asString }
30 var type = this.getProperty( \valueType );
33 0 /* Number */, { val = this.getProperty( \value ) },
34 1 /* Inf */, { val = inf },
35 2 /* -Inf */, { val = -inf },
36 3 /* NaN */, { val = 0 },
37 4 /* Text */, { val = 0 }
44 // isNaN has to be on the first plase, because a NaN is also equal to inf and -inf
45 { value.isNaN } { this.invokeMethod( \setNaN ); }
46 { value == inf } { this.invokeMethod( \setInfinite, true ); }
47 { value == -inf } { this.invokeMethod( \setInfinite, false ); }
48 { this.setProperty( \value, value.asFloat ); }
52 valueAction_ { arg val;
57 string { ^this.getProperty( \text ); }
59 string_ { arg string; this.setProperty( \text, string ); }
61 clipLo { ^this.getProperty(\minimum) }
62 clipLo_ { arg aFloat; this.setProperty( \minimum, aFloat ) }
64 clipHi { ^this.getProperty(\maximum) }
65 clipHi_ { arg aFloat; this.setProperty( \maximum, aFloat ) }
69 this.setProperty( \scroll, aBool );
72 scroll_step_ { arg aFloat;
74 this.setProperty( \scrollStep, aFloat );
77 decimals { ^this.getProperty(\decimals); }
78 minDecimals { ^this.getProperty(\minDecimals); }
79 maxDecimals { ^this.getProperty(\maxDecimals); }
81 decimals_ { arg decimals; this.setProperty( \decimals, decimals ); }
82 minDecimals_ { arg decimals; this.setProperty( \minDecimals, decimals ); }
83 maxDecimals_ { arg decimals; this.setProperty( \maxDecimals, decimals ); }
85 align_ { arg alignment;
87 this.setProperty( \alignment, QAlignment(alignment));
91 ^this.palette.baseTextColor;
94 stringColor_ { arg color;
95 this.setProperty( \palette, this.palette.baseTextColor_(color) );
98 normalColor_ { arg aColor;
100 this.setProperty( \normalColor, aColor );
103 typingColor_ { arg aColor;
104 typingColor = aColor;
105 this.setProperty( \editingColor, aColor );
109 ^this.palette.baseColor;
112 background_ { arg color;
113 this.setProperty( \palette, this.palette.baseColor_(color) )
116 buttonsVisible_ { arg aBool;
117 buttonsVisible = aBool;
118 this.setProperty( \buttonsVisible, aBool );
121 defaultGetDrag { ^this.value; }
122 defaultCanReceiveDrag { ^QView.currentDrag.isNumber; }
124 this.valueAction = QView.currentDrag;