2014-08-14 09:42:10 -05:00
|
|
|
// 28 july 2014
|
2014-07-28 19:52:32 -05:00
|
|
|
|
|
|
|
#include "winapi_windows.h"
|
2014-07-28 23:47:09 -05:00
|
|
|
#include "_cgo_export.h"
|
2014-07-28 19:52:32 -05:00
|
|
|
|
2015-02-17 19:46:10 -06:00
|
|
|
#include "wintable/main.h"
|
2014-08-25 01:36:32 -05:00
|
|
|
|
2015-02-17 19:46:10 -06:00
|
|
|
// provided for cgo's benefit
|
|
|
|
LPWSTR xtableWindowClass = tableWindowClass;
|
2014-08-25 10:51:38 -05:00
|
|
|
|
2015-02-17 20:43:32 -06:00
|
|
|
void doInitTable(void)
|
|
|
|
{
|
|
|
|
initTable(xpanic, fv__TrackMouseEvent);
|
|
|
|
}
|
|
|
|
|
2014-07-28 19:52:32 -05:00
|
|
|
static LRESULT CALLBACK tableSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR id, DWORD_PTR data)
|
|
|
|
{
|
2014-07-28 22:29:06 -05:00
|
|
|
NMHDR *nmhdr = (NMHDR *) lParam;
|
2015-02-17 20:29:41 -06:00
|
|
|
tableNM *tnm = (tableNM *) lParam;
|
2015-02-17 19:46:10 -06:00
|
|
|
void *gotable = (void *) data;
|
2014-07-28 22:29:06 -05:00
|
|
|
|
2014-07-28 19:52:32 -05:00
|
|
|
switch (uMsg) {
|
|
|
|
case msgNOTIFY:
|
2014-07-28 22:29:06 -05:00
|
|
|
switch (nmhdr->code) {
|
2015-02-17 20:29:41 -06:00
|
|
|
case tableNotificationGetCellData:
|
|
|
|
return tableGetCell(gotable, tnm);
|
|
|
|
case tableNotificationFinishedWithCellData:
|
|
|
|
tableFreeCellData(gotable, tnm->data);
|
2014-08-20 20:21:45 -05:00
|
|
|
return 0;
|
2015-02-17 20:29:41 -06:00
|
|
|
case tableNotificationCellCheckboxToggled:
|
2015-02-17 21:00:16 -06:00
|
|
|
tableToggled(gotable, tnm->row, tnm->column);
|
|
|
|
return 0;
|
2015-02-19 21:33:44 -06:00
|
|
|
case tableNotificationSelectionChanged:
|
|
|
|
tableSelectionChanged(gotable);
|
|
|
|
return 0;
|
2014-07-28 22:29:06 -05:00
|
|
|
}
|
2014-07-28 19:52:32 -05:00
|
|
|
return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
|
2015-02-17 19:46:10 -06:00
|
|
|
/* TODO
|
2014-08-14 09:42:10 -05:00
|
|
|
// see table.autoresize() in table_windows.go for the column autosize policy
|
|
|
|
case WM_NOTIFY: // from the contained header control
|
2014-08-06 09:42:26 -05:00
|
|
|
if (nmhdr->code == HDN_BEGINTRACK)
|
2014-08-25 01:36:32 -05:00
|
|
|
tableStopColumnAutosize(t->gotable);
|
2014-08-06 09:42:26 -05:00
|
|
|
return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
|
2015-02-17 19:46:10 -06:00
|
|
|
*/
|
2014-07-28 19:52:32 -05:00
|
|
|
case WM_NCDESTROY:
|
|
|
|
if ((*fv_RemoveWindowSubclass)(hwnd, tableSubProc, id) == FALSE)
|
|
|
|
xpanic("error removing Table subclass (which was for its own event handler)", GetLastError());
|
|
|
|
return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
|
|
|
|
default:
|
|
|
|
return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam);
|
|
|
|
}
|
2015-02-17 19:46:10 -06:00
|
|
|
xmissedmsg("Table", "tableSubProc()", uMsg);
|
2014-08-14 09:42:10 -05:00
|
|
|
return 0; // unreached
|
2014-07-28 19:52:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void setTableSubclass(HWND hwnd, void *data)
|
|
|
|
{
|
2015-02-17 19:46:10 -06:00
|
|
|
if ((*fv_SetWindowSubclass)(hwnd, tableSubProc, 0, (DWORD_PTR) data) == FALSE)
|
2014-07-28 19:52:32 -05:00
|
|
|
xpanic("error subclassing Table to give it its own event handler", GetLastError());
|
|
|
|
}
|
|
|
|
|
2015-02-18 00:51:57 -06:00
|
|
|
// TODO rename all of these functions to start with gotable, and all the exported ones in Go too
|
|
|
|
void gotableSetRowCount(HWND hwnd, intptr_t count)
|
|
|
|
{
|
|
|
|
SendMessageW(hwnd, tableSetRowCount, 0, (LPARAM) (&count));
|
|
|
|
}
|
|
|
|
|
2014-08-14 08:20:20 -05:00
|
|
|
void tableAutosizeColumns(HWND hwnd, int nColumns)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < nColumns; i++)
|
|
|
|
if (SendMessageW(hwnd, LVM_SETCOLUMNWIDTH, (WPARAM) i, (LPARAM) LVSCW_AUTOSIZE_USEHEADER) == FALSE)
|
|
|
|
xpanic("error resizing columns of results list view", GetLastError());
|
|
|
|
}
|
2014-08-17 14:30:10 -05:00
|
|
|
|
2014-08-18 01:22:27 -05:00
|
|
|
intptr_t tableSelectedItem(HWND hwnd)
|
|
|
|
{
|
2015-02-19 21:58:17 -06:00
|
|
|
intptr_t row;
|
|
|
|
|
|
|
|
SendMessageW(hwnd, tableGetSelection, (WPARAM) (&row), (LPARAM) NULL);
|
|
|
|
return row;
|
2014-08-18 01:22:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void tableSelectItem(HWND hwnd, intptr_t index)
|
|
|
|
{
|
2015-02-19 22:25:51 -06:00
|
|
|
SendMessageW(hwnd, tableSetSelection, (WPARAM) (&index), (LPARAM) NULL);
|
2014-08-18 01:22:27 -05:00
|
|
|
}
|