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' }
131 background { ^this.getProperty(\background); }
132 background_ { arg color; this.setProperty(\background, color); }
135 QScrollView : QAbstractScroll {
138 var actionConnected=false;
140 *new { arg parent, bounds;
141 ^super.new( parent, bounds ).initQScrollView;
144 *qtClass { ^'QcScrollArea' }
146 children { arg class = QView;
147 ^canvas.children( class );
150 background { ^canvas.background }
151 background_ { arg color; canvas.background = color }
153 hasBorder_ { arg aBool;
155 this.setProperty( \hasBorder, aBool );
159 ^this.getProperty( \innerBounds );
163 ^this.getProperty( \visibleOrigin );
166 visibleOrigin_ { arg point;
167 this.setProperty( \visibleOrigin, point );
173 this.invokeMethod( \setWidget, view, true );
176 action_ { arg handler;
178 if(actionConnected.not) { this.connectMethod( 'scrolled()', \doAction ) };
179 actionConnected = true;
183 // NOTE: The canvas widget must not be a QView, so that asking its
184 // children for parent will skip it and hit this view instead.
185 this.canvas = QScrollCanvas();
189 /////////////////////////// WIDGETS ///////////////////////////////
191 QStaticText : QTextViewBase {
192 *qtClass { ^'QLabel' }
194 *new { arg aParent, aBounds;
195 var obj = super.new( aParent, aBounds );
196 obj.setProperty(\wordWrap, true);
201 var p = this.palette;
202 ^if(p.hasColor(\window)) {p.window} {nil}
205 background_ { arg color;
206 var p = this.palette;
207 if(p.hasColor(\window).not)
208 { this.setProperty( \autoFillBackground, true) };
209 this.palette = p.window_(color);
212 string { ^this.getProperty(\text) }
213 string_ { arg text; this.setProperty( \text, text.asString ) }
216 ^this.palette.windowText;
219 stringColor_ { arg color;
220 this.palette = this.palette.windowText_(color);
224 QTextField : QTextViewBase {
225 *qtClass { ^'QcTextField' }
228 ^this.getProperty( \text );
232 this.setProperty( \text, text );
236 ^this.palette.baseText;
239 stringColor_ { arg color;
240 this.palette = this.palette.baseText_(color);
247 background_ { arg color;
248 this.palette = this.palette.base_(color);
256 this.string_( val.asString );
259 valueAction_ { arg val;
260 this.string_( val.asString );
264 defaultGetDrag { ^this.string; }
265 defaultCanReceiveDrag { ^true; }
267 this.valueAction = QView.currentDrag;
274 *qtClass { ^'QcButton' }
277 ^this.getProperty( \value );
281 this.setProperty( \value, argVal );
284 valueAction_ { arg anInt;
285 this.value_( anInt );
289 states_ { arg stateArray;
291 super.setProperty( \states, stateArray );
295 this.manageMethodConnection( action, func, 'action(int)', \prDoAction );
299 doAction { arg modifiers;
300 action.value(this, modifiers);
303 defaultGetDrag { ^this.value; }
304 defaultCanReceiveDrag { ^true; }
306 if( QView.currentDrag.isNumber )
307 { this.valueAction = QView.currentDrag; }
308 { this.action = QView.currentDrag; };
311 prDoAction { arg mods;
312 this.doAction(QKeyModifiers.toCocoa(mods));
318 *qtClass { ^'QcCheckBox' }
320 *new{ |parent,bounds,text|
321 ^super.new(parent,bounds).init(text)
329 ^this.getProperty(\value)
333 this.setProperty(\value,val)
342 this.setProperty(\text,string)
346 ^this.getProperty(\text)
349 defaultGetDrag { ^this.value; }
350 defaultCanReceiveDrag { ^((QView.currentDrag == true) || (QView.currentDrag == false)); }
352 this.valueAction = QView.currentDrag;
356 QPopUpMenu : QItemViewBase {
358 *qtClass { ^'QcPopUpMenu' }
360 allowsReselection { ^this.getProperty( \reactivationEnabled ) }
362 allowsReselection_ { arg flag; ^this.setProperty( \reactivationEnabled, flag ) }
365 var v = this.getProperty( \currentIndex );
366 if( v < 0 ) { ^nil } { ^v };
370 this.setProperty( \currentIndex, val ? -1 );
373 background { ^this.palette.button; }
375 background_ { arg color; this.palette = this.palette.button_(color); }
378 ^this.palette.buttonText;
381 stringColor_ { arg color;
382 this.palette = this.palette.buttonText_(color);
385 defaultGetDrag { ^this.value; }
386 defaultCanReceiveDrag { ^QView.currentDrag.isNumber; }
388 this.valueAction = QView.currentDrag;