Implemented Table.Selected()/Select() on Mac OS X. Also more TODOs.

This commit is contained in:
Pietro Gagliardi 2014-08-18 10:41:58 -04:00
parent a8f711dfad
commit 570f08a49c
4 changed files with 27 additions and 0 deletions

View File

@ -68,3 +68,4 @@ gtk+, mac os x
- once that is done, document the behavior of Areas
all
- make spaced settable somehow
- rename Selected to Selection?

View File

@ -93,6 +93,8 @@ extern void tableAppendColumn(id, intptr_t, char *, int, BOOL);
extern void tableUpdate(id);
extern void tableMakeDataSource(id, void *);
extern struct xsize tablePreferredSize(id);
extern intptr_t tableSelected(id);
extern void tableSelect(id, intptr_t);
/* control_darwin.m */
extern void parent(id, id);

View File

@ -62,6 +62,18 @@ func (t *table) LoadImageList(i ImageList) {
i.apply(&t.images)
}
func (t *table) Selected() int {
t.RLock()
defer t.RUnlock()
return int(C.tableSelected(t._id))
}
func (t *table) Select(index int) {
t.RLock()
defer t.RUnlock()
C.tableSelect(t._id, C.intptr_t(index))
}
//export goTableDataSource_getValue
func goTableDataSource_getValue(data unsafe.Pointer, row C.intptr_t, col C.intptr_t, outtype *C.int) unsafe.Pointer {
t := (*table)(data)

View File

@ -173,3 +173,15 @@ struct xsize tablePreferredSize(id control)
s.height += (intptr_t) [[t headerView] frame].size.height;
return s;
}
intptr_t tableSelected(id table)
{
return (intptr_t) [toNSTableView(table) selectedRow];
}
void tableSelect(id table, intptr_t row)
{
[toNSTableView(table) deselectAll:table];
if (row != -1)
[toNSTableView(table) selectRowIndexes:[NSIndexSet indexSetWithIndex:((NSUInteger) row)] byExtendingSelection:NO];
}