File: NSTableView.scd

package info (click to toggle)
supercollider 1%3A3.4.5-1wheezy1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 26,972 kB
  • sloc: cpp: 116,645; lisp: 64,914; ansic: 10,725; python: 3,548; perl: 766; ruby: 487; sh: 152; makefile: 117; xml: 13
file content (65 lines) | stat: -rw-r--r-- 1,679 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

// a simple NSTableView example - blackrain
(
	w = SCWindow.new("NSTableView", Rect(200,500,400,220));
	w.onClose_({ t.release; v.release; h.release; k.release; l.release; c.release; });
	p = w.dataptr.asNSReturn;

	t = SCNSObject("NSTableView", "initWithFrame:", [ Rect(10,10,380,200) ]);
	t.invoke("setUsesAlternatingRowBackgroundColors:", [ true ]);

	v = SCNSObject("NSScrollView", "initWithFrame:", [ Rect(10,10,380,200) ]);

	v.invoke("setHasVerticalScroller:", [ true ]);
	v.invoke("setHasHorizontalScroller:", [ true ]);
	
	k = v.invoke("verticalScroller");
	k.invoke("setControlSize:",[1]);

	l = v.invoke("horizontalScroller");
	l.invoke("setControlSize:",[1]);
	
	v.invoke("setAutoresizingMask:", [18]);
	v.invoke("setDocumentView:", [t]);

	p.invoke("addSubview:", [v], true);

	c = SCNSObject("NSTableColumn", "initWithIdentifier:", [ "column_1" ]);
	c.invoke("setEditable:", [ true ]);
	c.invoke("setWidth:", [ 200 ]);
	c.invoke("setResizingMask:", [ 2 ]);
	
	h = c.invoke("headerCell");
	h.invoke("setStringValue:", ["Items"]);
	h.invoke("setAlignment:", [2]);

	t.invoke("addTableColumn:", [c], true);

	t.invoke("setFocusRingType:", [ 1 ]); //NSFocusRingTypeNone
	w.front;
)


(
i = ["Zero", "One", "Two", "Three", "Four", "Five", "Six"];
t.initAction("doAction:");
t.setDelegate;

t.nsDelegate.addMethod("tableView:objectValueForTableColumn:row:", "@", "@@i", { arg method, args;
	[method, args].postln;
	
	^i[ args[2] ]
});

t.nsDelegate.addMethod("numberOfRowsInTableView:", 'i', "@", { arg method, args;
	[method, args].postln;
	
	^i.size
});
)

t.invoke("setDataSource:", [ t.nsDelegate ], true);

t.invoke("reloadData", defer:true);

SCNSObject.dumpPool;