ServerOptions: different input & output device names only works on osx
[supercollider.git] / examples / CocoaBridge / NSTableView.scd
blob01a4eb9a87160a4e4f437e01de97654e4002768b
2 // a simple NSTableView example - blackrain
4         w = SCWindow.new("NSTableView", Rect(200,500,400,220));
5         w.onClose_({ t.release; v.release; h.release; k.release; l.release; c.release; });
6         p = w.dataptr.asNSReturn;
8         t = SCNSObject("NSTableView", "initWithFrame:", [ Rect(10,10,380,200) ]);
9         t.invoke("setUsesAlternatingRowBackgroundColors:", [ true ]);
11         v = SCNSObject("NSScrollView", "initWithFrame:", [ Rect(10,10,380,200) ]);
13         v.invoke("setHasVerticalScroller:", [ true ]);
14         v.invoke("setHasHorizontalScroller:", [ true ]);
15         
16         k = v.invoke("verticalScroller");
17         k.invoke("setControlSize:",[1]);
19         l = v.invoke("horizontalScroller");
20         l.invoke("setControlSize:",[1]);
21         
22         v.invoke("setAutoresizingMask:", [18]);
23         v.invoke("setDocumentView:", [t]);
25         p.invoke("addSubview:", [v], true);
27         c = SCNSObject("NSTableColumn", "initWithIdentifier:", [ "column_1" ]);
28         c.invoke("setEditable:", [ true ]);
29         c.invoke("setWidth:", [ 200 ]);
30         c.invoke("setResizingMask:", [ 2 ]);
31         
32         h = c.invoke("headerCell");
33         h.invoke("setStringValue:", ["Items"]);
34         h.invoke("setAlignment:", [2]);
36         t.invoke("addTableColumn:", [c], true);
38         t.invoke("setFocusRingType:", [ 1 ]); //NSFocusRingTypeNone
39         w.front;
44 i = ["Zero", "One", "Two", "Three", "Four", "Five", "Six"];
45 t.initAction("doAction:");
46 t.setDelegate;
48 t.nsDelegate.addMethod("tableView:objectValueForTableColumn:row:", "@", "@@i", { arg method, args;
49         [method, args].postln;
50         
51         ^i[ args[2] ]
52 });
54 t.nsDelegate.addMethod("numberOfRowsInTableView:", 'i', "@", { arg method, args;
55         [method, args].postln;
56         
57         ^i.size
58 });
61 t.invoke("setDataSource:", [ t.nsDelegate ], true);
63 t.invoke("reloadData", defer:true);
65 SCNSObject.dumpPool;