summaryrefslogtreecommitdiff
path: root/cocoalists
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-03-02 17:19:25 -0500
committerPietro Gagliardi <[email protected]>2014-03-02 17:19:25 -0500
commit01e587174144ed4b6b5383346fdf2697f86f9423 (patch)
tree5d92cf706dd8c2dff231678bad875f4d2e07cb1b /cocoalists
parentdb1c6c5c17efa0aa160de1bdf8193f984197f658 (diff)
Added the beginning of the Mac OS X implementation of Combobox; also added a file to plan out how lists will be implemented/are being implemented.
Diffstat (limited to 'cocoalists')
-rw-r--r--cocoalists78
1 files changed, 78 insertions, 0 deletions
diff --git a/cocoalists b/cocoalists
new file mode 100644
index 0000000..ee7283c
--- /dev/null
+++ b/cocoalists
@@ -0,0 +1,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]