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 );
161 ^this.getProperty( \visibleOrigin );
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" }
267 ^this.getProperty( \value );
271 this.setProperty( \value, argVal );
274 valueAction_ { arg anInt;
275 this.value_( anInt );
279 states_ { arg stateArray;
281 super.setProperty( \states, stateArray );
285 this.manageMethodConnection( action, func, 'action(int)', \prDoAction );
289 doAction { arg modifiers;
290 action.value(this, modifiers);
293 defaultGetDrag { ^this.value; }
294 defaultCanReceiveDrag { ^true; }
296 if( QView.currentDrag.isNumber )
297 { this.valueAction = QView.currentDrag; }
298 { this.action = QView.currentDrag; };
301 prDoAction { arg mods;
302 this.doAction(QKeyModifiers.toCocoa(mods));
308 *qtClass { ^"QcCheckBox" }
310 *new{ |parent,bounds,text|
311 ^super.new(parent,bounds).init(text)
319 ^this.getProperty(\value)
323 this.setProperty(\value,val)
332 this.setProperty(\text,string)
336 ^this.getProperty(\text)
339 defaultGetDrag { ^this.value; }
340 defaultCanReceiveDrag { ^((QView.currentDrag == true) || (QView.currentDrag == false)); }
342 this.valueAction = QView.currentDrag;
346 QPopUpMenu : QItemViewBase {
348 *qtClass { ^"QcPopUpMenu" }
350 allowsReselection { ^this.getProperty( \signalReactivation ) }
352 allowsReselection_ { arg flag; ^this.setProperty( \signalReactivation, flag ) }
355 var v = this.getProperty( \currentIndex );
356 if( v < 0 ) { ^nil } { ^v };
360 this.setProperty( \currentIndex, val ? -1 );
364 ^this.palette.buttonTextColor;
367 stringColor_ { arg color;
368 this.setProperty( \palette, this.palette.buttonTextColor_(color) );
371 defaultGetDrag { ^this.value; }
372 defaultCanReceiveDrag { ^QView.currentDrag.isNumber; }
374 this.valueAction = QView.currentDrag;