Added tableSetSelection to the new Windows Table and hooked it up to the package ui Table.
This commit is contained in:
parent
cab2d93449
commit
924352d76a
|
@ -82,31 +82,7 @@ intptr_t tableSelectedItem(HWND hwnd)
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
TODO
|
|
||||||
void tableSelectItem(HWND hwnd, intptr_t index)
|
void tableSelectItem(HWND hwnd, intptr_t index)
|
||||||
{
|
{
|
||||||
LVITEMW item;
|
SendMessageW(hwnd, tableSetSelection, (WPARAM) (&index), (LPARAM) NULL);
|
||||||
LRESULT current;
|
|
||||||
|
|
||||||
// via http://support.microsoft.com/kb/131284
|
|
||||||
// we don't need to clear the other bits; Tables don't support cutting or drag/drop
|
|
||||||
current = SendMessageW(hwnd, LVM_GETNEXTITEM, (WPARAM) -1, LVNI_SELECTED);
|
|
||||||
if (current != (LRESULT) -1) {
|
|
||||||
ZeroMemory(&item, sizeof (LVITEMW));
|
|
||||||
item.mask = LVIF_STATE;
|
|
||||||
item.state = 0;
|
|
||||||
item.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
|
|
||||||
if (SendMessageW(hwnd, LVM_SETITEMSTATE, (WPARAM) current, (LPARAM) (&item)) == FALSE)
|
|
||||||
xpanic("error deselecting current Table item", GetLastError());
|
|
||||||
}
|
|
||||||
if (index == -1) // select nothing
|
|
||||||
return;
|
|
||||||
ZeroMemory(&item, sizeof (LVITEMW));
|
|
||||||
item.mask = LVIF_STATE;
|
|
||||||
item.state = LVIS_FOCUSED | LVIS_SELECTED;
|
|
||||||
item.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
|
|
||||||
if (SendMessageW(hwnd, LVM_SETITEMSTATE, (WPARAM) index, (LPARAM) (&item)) == FALSE)
|
|
||||||
xpanic("error selecting new Table item", GetLastError());
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ func (t *table) Selected() int {
|
||||||
func (t *table) Select(index int) {
|
func (t *table) Select(index int) {
|
||||||
t.RLock()
|
t.RLock()
|
||||||
defer t.RUnlock()
|
defer t.RUnlock()
|
||||||
//TODO C.tableSelectItem(t.hwnd, C.intptr_t(index))
|
C.tableSelectItem(t.hwnd, C.intptr_t(index))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *table) OnSelected(f func()) {
|
func (t *table) OnSelected(f func()) {
|
||||||
|
|
|
@ -115,9 +115,7 @@ extern void gotableSetRowCount(HWND, intptr_t);
|
||||||
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);
|
||||||
*/
|
|
||||||
|
|
||||||
// container_windows.c
|
// container_windows.c
|
||||||
extern RECT containerBounds(HWND);
|
extern RECT containerBounds(HWND);
|
||||||
|
|
|
@ -38,6 +38,7 @@ static void setRowCount(struct table *t, intptr_t rc)
|
||||||
HANDLER(apiHandlers)
|
HANDLER(apiHandlers)
|
||||||
{
|
{
|
||||||
intptr_t *rcp;
|
intptr_t *rcp;
|
||||||
|
intptr_t row;
|
||||||
|
|
||||||
switch (uMsg) {
|
switch (uMsg) {
|
||||||
case WM_SETFONT:
|
case WM_SETFONT:
|
||||||
|
@ -72,6 +73,20 @@ HANDLER(apiHandlers)
|
||||||
*rcp = t->selectedColumn;
|
*rcp = t->selectedColumn;
|
||||||
*lResult = 0;
|
*lResult = 0;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
case tableSetSelection:
|
||||||
|
// TODO does doselect() do validation?
|
||||||
|
rcp = (intptr_t *) wParam;
|
||||||
|
row = *rcp;
|
||||||
|
rcp = (intptr_t *) lParam;
|
||||||
|
if (rcp == NULL)
|
||||||
|
if (row == -1)
|
||||||
|
doselect(t, -1, -1);
|
||||||
|
else // select column 0, just like keyboard selections; TODO what if there aren't any columns?
|
||||||
|
doselect(t, row, 0);
|
||||||
|
else
|
||||||
|
doselect(t, row, *rcp);
|
||||||
|
*lResult = 0;
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,12 @@ enum {
|
||||||
// both will be -1 for no selection
|
// both will be -1 for no selection
|
||||||
// if either is NULL, that value is not written
|
// if either is NULL, that value is not written
|
||||||
tableGetSelection,
|
tableGetSelection,
|
||||||
|
// wParam - pointer to intptr_t containing selected row
|
||||||
|
// lParam - pointer to intptr_t containing selected column
|
||||||
|
// if lParam is NULL, do not change selected column (selects column 0 if nothing previously selected; TODO explicitly document this?)
|
||||||
|
// TODO allow wParam to be NULL too; should both being NULL select nothing or keep the current selection?
|
||||||
|
// this WILL result in a selection changed notification (TODO work into the package ui Table)
|
||||||
|
tableSetSelection,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
|
Loading…
Reference in New Issue