1 QTopScrollWidget : QScrollCanvas {
3 doDrawFunc { win.drawFunc.value(win); }
6 QScrollTopView : QScrollView {
9 *qtClass {^'QcScrollWindow'}
11 *new { arg win, name, bounds, resizable, border;
12 ^super.newCustom([name, bounds, resizable, border])
13 .initQScrollTopView(win);
16 initQScrollTopView { arg win;
19 // NOTE: The canvas widget must not be a QView, so that asking its
20 // children for parent will skip it and hit this view instead.
21 cnv = QTopScrollWidget.new;
28 r = this.getProperty( \geometry );
33 var rNew = rect.asRect;
34 var rOld = this.getProperty( \geometry );
35 this.setProperty( \geometry, rOld.resizeTo( rNew.width, rNew.height ) );
38 drawingEnabled_ { arg bool; canvas.setProperty( \drawingEnabled, bool ); }
40 findWindow { ^window; }
46 *qtClass {^'QcWindow'}
48 *new { arg win, name, bounds, resizable, border;
49 ^super.newCustom([name, bounds, resizable, border])
53 initQTopView { arg win; window = win; }
57 r = this.getProperty( \geometry );
62 var rNew = rect.asRect;
63 var rOld = this.getProperty( \geometry );
64 this.setProperty( \geometry, rOld.resizeTo( rNew.width, rNew.height ) );
67 background_ { arg color;
68 // Do not autoFillBackground; the widget will paint it if necessary.
69 this.palette = this.palette.window_(color);
72 drawingEnabled_ { arg bool; this.setProperty( \drawingEnabled, bool ); }
74 findWindow { ^window; }
76 doDrawFunc { window.drawFunc.value(window) }
81 classvar <allWindows, <>initAction;
83 var resizable, <drawFunc, <onClose;
87 var <>acceptsClickThrough=false;
91 ShutDown.add( { QWindow.closeAll } );
99 _QWindow_AvailableGeometry
103 allWindows.copy.do { |win| win.close };
107 - 'server' is only for compatibility with SwingOSC
108 - all args have to be of correct type for QWidget constructor to match!
118 bounds = Rect(0,0,400,400).center_( QWindow.availableBounds.center );
120 bounds = QWindow.flipY( bounds.asRect );
122 ^super.new.initQWindow( name, bounds, resizable, border, scroll );
125 //------------------------ QWindow specific -----------------------//
127 initQWindow { arg name, bounds, resize, border, scroll;
129 { view = QScrollTopView.new(this,name,bounds,resize,border); }
130 { view = QTopView.new(this,name,bounds,resize,border); };
132 // set some necessary object vars
133 resizable = resize == true;
135 // allWindows array management
136 QWindow.addWindow( this );
137 view.connectFunction( 'destroyed()', { QWindow.removeWindow(this); }, false );
139 // action to call whenever a window is created
140 QWindow.initAction.value( this );
148 var r = QWindow.flipY( aRect.asRect );
149 view.setProperty( \geometry, r );
150 if( resizable.not ) { view.fixedSize = r.size }
154 ^QWindow.flipY( view.getProperty( \geometry ) );
157 setInnerExtent { arg w, h;
158 // bypass this.bounds, to avoid QWindow flipping the y coordinate
159 var r = view.getProperty(\geometry );
160 view.setProperty(\geometry, r.resizeTo( w, h ); )
163 background { ^view.background; }
165 background_ { arg aColor; view.background = aColor; }
167 drawFunc_ { arg aFunction;
168 view.drawingEnabled = aFunction.notNil;
169 drawFunc = aFunction;
172 setTopLeftBounds{ arg rect, menuSpacer=45;
173 view.setProperty( \geometry, rect.moveBy( 0, menuSpacer ) );
177 view.manageFunctionConnection( onClose, func, 'destroyed()', false );
182 addToOnClose{ arg function; }
183 removeFromOnClose{ arg function; }
185 //------------------- simply redirected to QView ---------------------//
187 sizeHint { ^view.sizeHint }
188 minSizeHint { ^view.minSizeHint }
189 alpha_ { arg value; view.alpha_(value); }
190 addFlowLayout { arg margin, gap; ^view.addFlowLayout( margin, gap ); }
191 close { view.close; }
192 isClosed { ^view.isClosed; }
193 visible { ^view.visible; }
194 visible_ { arg boolean; view.visible_(boolean); }
195 front { view.front; }
196 fullScreen { view.fullScreen; }
197 endFullScreen { view.endFullScreen; }
198 minimize { view.minimize; }
199 unminimize { view.unminimize; }
201 name_ { arg string; view.name_(string); }
202 refresh { view.refresh; }
203 userCanClose { ^view.userCanClose; }
204 userCanClose_ { arg boolean; view.userCanClose_( boolean ); }
205 alwaysOnTop { ^view.alwaysOnTop; }
206 alwaysOnTop_ { arg boolean; view.alwaysOnTop_(boolean); }
207 layout { ^view.layout; }
208 layout_ { arg layout; view.layout_(layout); }
209 toFrontAction_ { arg action; view.toFrontAction_(action) }
210 toFrontAction { ^view.toFrontAction }
211 endFrontAction_ { arg action; view.endFrontAction_(action) }
212 endFrontAction { ^view.endFrontAction }
213 acceptsMouseOver { ^view.acceptsMouseOver }
214 acceptsMouseOver_ { arg flag; view.acceptsMouseOver_(flag) }
216 // ---------------------- private ------------------------------------
219 var flippedTop = QWindow.screenBounds.height - aRect.top - aRect.height;
220 ^Rect( aRect.left, flippedTop, aRect.width, aRect.height );
223 *addWindow { arg window;
224 allWindows = allWindows.add( window );
227 *removeWindow { arg window;
228 allWindows.remove( window );