Merge pull request #506 from andrewcsmith/patch-2
[supercollider.git] / SCClassLibrary / QtCollider / viewExtensionsQt.sc
blob17a23c26c1768b20716ab203737294d9139e29fa
3 + QWindow {
5         asFlowView { arg bounds;
6                 ^FlowView(this,bounds)
7         }
8         flow { arg func,bounds;
9                 var f;
10                 f = FlowView(this,bounds ?? { this.bounds.moveTo(0,0) });
11                 func.value(f);
12                 if(bounds.isNil,{ f.resizeToFit });
13                 ^f
14         }
15         comp { arg func,bounds;
16                 var f;
17                 f = QView(this,bounds ?? { this.bounds.moveTo(0,0) });
18                 func.value(f);
19                 ^f
20         }
24 + QView {
26         asFlowView { arg bounds;
27                 ^FlowView(this,bounds ?? {this.bounds})
28         }
29         deepDo { arg function;
30                 // includes self
31                 function.value(this);
32                 this.children.do({arg child;
33                         child.deepDo(function);
34                 });
35         }
36         allChildren {
37                 // includes self
38                 var all;
39                 all = Array.new;
40                 this.deepDo({ arg child; all = all.add(child) });
41                 ^all
42         }
43         flow { arg func,bounds;
44                 var f,comp;
45                 f = FlowView(this,bounds); // flow view intellegently calc defaults bounds
46                 func.value(f);
47                 if(bounds.isNil,{ f.resizeToFit });
48                 ^f
49         }
50         horz { arg func,bounds;
51                 var comp;
52                 comp = QHLayoutView(this,bounds ?? { this.bounds });
53                 func.value(comp);
54                 ^comp
55         }
56         vert { arg func,bounds;
57                 var comp;
58                 comp = QVLayoutView(this,bounds ?? { this.bounds });
59                 func.value(comp);
60                 ^comp
61         }
62         comp { arg func,bounds;
63                 var comp;
64                 comp = QView(this,bounds ?? { this.bounds });
65                 func.value(comp);
66                 ^comp
67         }
68         scroll { arg func,bounds,autohidesScrollers=true,autoScrolls=true,
69                                         hasHorizontalScroller=true,hasVerticalScroller=true;
70                 var comp;
71                 comp = QScrollView(this,bounds ?? { this.bounds });
72                 comp.autohidesScrollers = autohidesScrollers;
73                 comp.hasHorizontalScroller = hasHorizontalScroller;
74                 comp.hasVerticalScroller = hasVerticalScroller;
75                 func.value(comp);
76                 ^comp
77         }