summaryrefslogtreecommitdiff
path: root/olddocs/cocoalists
blob: ee7283c448699eccf8cbc5da8ec3e8a938ceb6d5 (plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
NSPopUpButton (non-editable combo box)
	make:
		b = [[NSPopUpButton alloc]
			initWithFrame:(0, 0, 100, 100)
			pullsDown:NO]
	add:
		[b addItemWithTitle:toNSString(s)]
	insertBefore:
		[b insertItemWithTitle:toNSString(s)
			atIndex:index]		(NSInteger)
	remove:
		[b removeItemAtIndex:index]		(NSInteger)
	selection:
		fromNSString([b titleOfSelectedItem])
			(returns nil if nothing is selected; need to edit to return "" if so)
	selectedIndex:
		[b indexOfSelectedItem]		(NSInteger)
			(returns -1 if nothing is selected)
NSComboBox (editable combo box)
	make:
		b = [[NSComboBox alloc]
			initWithFrame:(0, 0, 100, 100)]
		[b setUsesDataSource:NO]		// internal data soruce
	add:
		[b addItemWithObjectValue:toNSString(s)]
	insertBefore:
		[b insertItemWithObjectValue:toNSString(s)
			atIndex:index]			(NSInteger)
	remove:
		[b removeItemAtIndex:index]		(NSInteger)
	selection:
		this depends on if the /user/ selecting an item changes the edit box
		this appears to be the case, so
			fromNSString([b stringValue])
		note that if we ever add Combobox.SetText(), we are responsible for managing both the edit field AND the list, as they are programmatically separate
	selectedIndex:
		[b indexOfSelectedItem]		(NSInteger)
			(returns -1 if nothing is selected)
			(TODO custom text?)
NSTableView (listbox)
	make:
		b = [[NSTableView alloc]
			initWithFrame:(0, 0, 100, 100)]
		col = [[NSTableColumn alloc]
			initWithIdentifier:@"listboxcolumn"]
		listDict = [NSMutableDictionary xxxx]
		listItems = [[xxx]]
		[listItems addObject:listDict]
		[col bind:@"value"
			toObject:listItems
			withKeyPath:@"xxxxx.listboxcolumn"
			options:nilid]
		[b addTableColumn:col]
		// TODO autoresizing
	add:
	insertBefore:
	remove:
	selection:
		idx = [b selectedRow]	(NSInteger)
		if idx == -1 {
			return ""
		}
		dataSource = [b dataSource]
	selectedIndex:
		[b selectedRow]		(NSInteger)
			(returns -1 if none selected)
	selectedIndices:
		nsidx = [b selectedRowIndexes]
		c = [nsidx count]		(NSUInteger)
		nsidxbuf = C.makeNSUIntegerArray(c)
		[nsidx getIndexes:nsidxbuf
			maxCont:c
			inIndexRange:nilid]
		// and just copy out of nsidxbuf somehow
		// I think this is going to have to make 2 temporary arrays; a better option will be needed! TODO
	selectedTexts:
		indices := selectedIndices()
		dataSource = [b dataSource]