1 /////////////////////// ABSTRACT CLASSES ////////////////////////////
3 QTextViewBase : QView {
4 var <object, <>setBoth = true;
8 if( setBoth ) { this.string = obj.asString };
14 this.setProperty( \alignment, QAlignment(aSymbol) );
22 items_ { arg stringArray;
24 this.setProperty( \items, stringArray);
28 ^items.at( this.value );
31 valueAction_ { arg val;
37 QAbstractScroll : QView {
38 var <hasHorizontalScroller = true, <hasVerticalScroller = true;
39 var <autohidesScrollers = true;
41 autohidesScrollers_ { arg aBool;
43 if( hasHorizontalScroller ) {
44 this.setProperty( \horizontalScrollBarPolicy, 0 );
46 if( hasVerticalScroller ) {
47 this.setProperty( \verticalScrollBarPolicy, 0 );
50 if( hasHorizontalScroller ) {
51 this.setProperty( \horizontalScrollBarPolicy, 2 )
53 if( hasVerticalScroller ) {
54 this.setProperty( \verticalScrollBarPolicy, 2 );
57 autohidesScrollers = aBool;
60 hasHorizontalScroller_ { arg aBool;
63 if( autohidesScrollers ) { policy = 0 } { policy = 2 };
64 this.setProperty( \horizontalScrollBarPolicy, policy );
66 this.setProperty( \horizontalScrollBarPolicy, 1 );
68 hasHorizontalScroller = aBool;
71 hasVerticalScroller_ { arg aBool;
74 if( autohidesScrollers ) { policy = 0 } { policy = 2 };
75 this.setProperty( \verticalScrollBarPolicy, policy );
77 this.setProperty( \verticalScrollBarPolicy, 1 );
79 hasVerticalScroller = aBool;
83 QAbstractStepValue : QView {
84 var <step = 0.1, <shift_scale = 100.0, <ctrl_scale = 10.0, <alt_scale = 0.1;
88 this.setProperty( \step, aFloat );
91 shift_scale_ { arg aFloat;
93 this.setProperty( \shiftScale, aFloat );
96 ctrl_scale_ { arg aFloat;
98 this.setProperty( \ctrlScale, aFloat );
101 alt_scale_ { arg aFloat;
103 this.setProperty( \altScale, aFloat );
106 getScale { |modifiers|
108 { modifiers.isShift } { shift_scale }
109 { modifiers.isCtrl } { ctrl_scale }
110 { modifiers.isAlt } { alt_scale }
114 increment { arg factor = 1.0; this.invokeMethod( \increment, factor.asFloat ); }
115 decrement { arg factor = 1.0; this.invokeMethod( \decrement, factor.asFloat ); }
118 /////////////////////// CONTAINERS ////////////////////////////////
120 QHLayoutView : QView {
121 *qtClass { ^"QcHLayoutWidget" }
124 QVLayoutView : QView {
125 *qtClass { ^"QcVLayoutWidget" }
128 QScrollCanvas : QObject {
129 *qtClass { ^'QcScrollWidget' }
132 QScrollView : QAbstractScroll {
134 var <background, <hasBorder=true;
136 *new { arg parent, bounds;
137 ^super.new( parent, bounds ).initQScrollView;
140 *qtClass { ^"QcScrollArea" }
142 children { arg class = QView;
143 ^canvas.children( class );
146 background_ { arg aColor;
148 canvas.setProperty( \background, aColor, true );
151 hasBorder_ { arg aBool;
153 this.setProperty( \hasBorder, aBool );
157 ^this.getProperty( \innerBounds, Rect.new );
161 ^this.getProperty( \visibleOrigin, Point.new );
164 visibleOrigin_ { arg point;
165 this.setProperty( \visibleOrigin, point );
170 this.invokeMethod( \setWidget, view, true );
174 // NOTE: The canvas widget must not be a QView, so that asking its
175 // children for parent will skip it and hit this view instead.
176 this.canvas = QScrollCanvas();
180 /////////////////////////// WIDGETS ///////////////////////////////
182 QStaticText : QTextViewBase {
185 *qtClass { ^"QLabel" }
187 *new { arg aParent, aBounds;
188 var obj = super.new( aParent, aBounds );
189 obj.setProperty(\wordWrap, true);
193 background_ { arg aColor;
194 if( this.background.isNil ) {
195 this.setProperty( \autoFillBackground, true);
197 super.background_( aColor );
202 this.setProperty( \text, text );
206 ^this.palette.windowTextColor;
209 stringColor_ { arg color;
210 this.setProperty( \palette, this.palette.windowTextColor_(color) );
214 QTextField : QTextViewBase {
215 *qtClass { ^"QcTextField" }
218 ^this.getProperty( \text );
222 this.setProperty( \text, text );
226 ^this.palette.baseTextColor;
229 stringColor_ { arg color;
230 this.setProperty( \palette, this.palette.baseTextColor_(color) );
234 ^this.palette.baseColor;
237 background_ { arg color;
238 this.setProperty( \palette, this.palette.baseColor_(color) )
246 this.string_( val.asString );
249 valueAction_ { arg val;
250 this.string_( val.asString );
254 defaultGetDrag { ^this.string; }
255 defaultCanReceiveDrag { ^true; }
257 this.valueAction = QView.currentDrag;
264 *qtClass { ^"QcButton" }
271 ^this.getProperty( \value );
275 this.setProperty( \value, argVal );
278 valueAction_ { arg anInt;
279 this.value_( anInt );
283 states_ { arg stateArray;
285 super.setProperty( \states, stateArray );
288 defaultGetDrag { ^this.value; }
289 defaultCanReceiveDrag { ^true; }
291 if( QView.currentDrag.isNumber )
292 { this.valueAction = QView.currentDrag; }
293 { this.action = QView.currentDrag; };
299 *qtClass { ^"QcCheckBox" }
301 *new{ |parent,bounds,text|
302 ^super.new(parent,bounds).init(text)
310 ^this.getProperty(\value)
314 this.setProperty(\value,val)
323 this.setProperty(\text,string)
327 ^this.getProperty(\text)
330 defaultGetDrag { ^this.value; }
331 defaultCanReceiveDrag { ^((QView.currentDrag == true) || (QView.currentDrag == false)); }
333 this.valueAction = QView.currentDrag;
337 QPopUpMenu : QItemViewBase {
339 *qtClass { ^"QcPopUpMenu" }
341 allowsReselection { ^this.getProperty( \signalReactivation ) }
343 allowsReselection_ { arg flag; ^this.setProperty( \signalReactivation, flag ) }
346 var v = this.getProperty( \currentIndex );
347 if( v < 0 ) { ^nil } { ^v };
351 this.setProperty( \currentIndex, val ? -1 );
355 ^this.palette.buttonTextColor;
358 stringColor_ { arg color;
359 this.setProperty( \palette, this.palette.buttonTextColor_(color) );
362 defaultGetDrag { ^this.value; }
363 defaultCanReceiveDrag { ^QView.currentDrag.isNumber; }
365 this.valueAction = QView.currentDrag;