Added tableGetSelection to the new Windows Table and hooked it up to package ui's Table.

This commit is contained in:
Pietro Gagliardi 2015-02-19 22:58:17 -05:00
parent 6b9f1f282f
commit cab2d93449
5 changed files with 21 additions and 4 deletions

View File

@ -74,10 +74,12 @@ void tableAutosizeColumns(HWND hwnd, int nColumns)
xpanic("error resizing columns of results list view", GetLastError()); xpanic("error resizing columns of results list view", GetLastError());
} }
// because Go won't let me do C.WPARAM(-1)
intptr_t tableSelectedItem(HWND hwnd) intptr_t tableSelectedItem(HWND hwnd)
{ {
return (intptr_t) SendMessageW(hwnd, LVM_GETNEXTITEM, (WPARAM) -1, LVNI_SELECTED); intptr_t row;
SendMessageW(hwnd, tableGetSelection, (WPARAM) (&row), (LPARAM) NULL);
return row;
} }
/* /*

View File

@ -72,8 +72,7 @@ func (t *table) Unlock() {
func (t *table) Selected() int { func (t *table) Selected() int {
t.RLock() t.RLock()
defer t.RUnlock() defer t.RUnlock()
//TODO return int(C.tableSelectedItem(t.hwnd)) return int(C.tableSelectedItem(t.hwnd))
return -1
} }
func (t *table) Select(index int) { func (t *table) Select(index int) {

View File

@ -113,7 +113,9 @@ extern void setTableSubclass(HWND, void *);
extern void gotableSetRowCount(HWND, intptr_t); extern void gotableSetRowCount(HWND, intptr_t);
/* TODO /* TODO
extern void tableAutosizeColumns(HWND, int); extern void tableAutosizeColumns(HWND, int);
*/
extern intptr_t tableSelectedItem(HWND); extern intptr_t tableSelectedItem(HWND);
/* TODO
extern void tableSelectItem(HWND, intptr_t); extern void tableSelectItem(HWND, intptr_t);
*/ */

View File

@ -63,6 +63,15 @@ HANDLER(apiHandlers)
setRowCount(t, *rcp); setRowCount(t, *rcp);
*lResult = 0; *lResult = 0;
return TRUE; return TRUE;
case tableGetSelection:
rcp = (intptr_t *) wParam;
if (rcp != NULL)
*rcp = t->selectedRow;
rcp = (intptr_t *) lParam;
if (rcp != NULL)
*rcp = t->selectedColumn;
*lResult = 0;
return TRUE;
} }
return FALSE; return FALSE;
} }

View File

@ -14,6 +14,11 @@ enum {
// wParam - 0 // wParam - 0
// lParam - pointer to intptr_t containing new count // lParam - pointer to intptr_t containing new count
tableSetRowCount, tableSetRowCount,
// wParam - pointer to intptr_t where selected row will be stored
// lParam - pointer to intptr_t where selected column will be stored
// both will be -1 for no selection
// if either is NULL, that value is not written
tableGetSelection,
}; };
enum { enum {