Started to lay down the groundwork for handling selection.
This commit is contained in:
parent
980868ef0d
commit
7b9b41d6cc
|
@ -18,21 +18,41 @@ static void drawCell(struct table *t, HDC dc, struct drawCellParams *p)
|
||||||
RECT r;
|
RECT r;
|
||||||
WCHAR msg[200];
|
WCHAR msg[200];
|
||||||
int n;
|
int n;
|
||||||
|
HBRUSH background;
|
||||||
|
int textColor;
|
||||||
|
|
||||||
r.left = p->x;//TODO + p->xoff;
|
// TODO verify these two
|
||||||
|
background = (HBRUSH) (COLOR_WINDOW + 1);
|
||||||
|
textColor = COLOR_WINDOWTEXT;
|
||||||
|
// TODO get rid of the selectedRow/selectedColumn bits
|
||||||
|
if (t->selectedRow == p->row && t->selectedColumn == p->column) {
|
||||||
|
// these are the colors wine uses (http://source.winehq.org/source/dlls/comctl32/listview.c)
|
||||||
|
// the two for unfocused are also suggested by http://stackoverflow.com/questions/10428710/windows-forms-inactive-highlight-color
|
||||||
|
background = (HBRUSH) (COLOR_HIGHLIGHT + 1);
|
||||||
|
textColor = COLOR_HIGHLIGHTTEXT;
|
||||||
|
if (GetFocus() != t->hwnd) {
|
||||||
|
background = (HBRUSH) (COLOR_BTNFACE + 1);
|
||||||
|
textColor = COLOR_BTNTEXT;
|
||||||
|
}
|
||||||
|
// TODO disabled
|
||||||
|
}
|
||||||
|
|
||||||
|
r.left = p->x;
|
||||||
r.right = p->x + p->width;
|
r.right = p->x + p->width;
|
||||||
r.top = p->y;
|
r.top = p->y;
|
||||||
r.bottom = p->y + p->height;
|
r.bottom = p->y + p->height;
|
||||||
// TODO fill this rect with the appropriate background color
|
if (FillRect(dc, &r, background) == 0)
|
||||||
// TODO then vertical center content
|
panic("error filling Table cell background");
|
||||||
n = wsprintf(msg, L"(%d,%d)", p->row, p->column);
|
|
||||||
|
|
||||||
/* FillRect(dc, &r, (HBRUSH) (current + 1));
|
// now offset the content to where inside the cell it should be
|
||||||
current++;
|
|
||||||
if (current >= 31)
|
|
||||||
current = 0;
|
|
||||||
*/
|
|
||||||
r.left += p->xoff;
|
r.left += p->xoff;
|
||||||
|
// TODO vertical center content too
|
||||||
|
|
||||||
|
if (SetTextColor(dc, GetSysColor(textColor)) == CLR_INVALID)
|
||||||
|
panic("error setting Table cell text color");
|
||||||
|
if (SetBkMode(dc, TRANSPARENT) == 0)
|
||||||
|
panic("error setting transparent text drawing mode for Table cell");
|
||||||
|
n = wsprintf(msg, L"(%d,%d)", p->row, p->column);
|
||||||
if (DrawTextExW(dc, msg, n, &r, DT_END_ELLIPSIS | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE, NULL) == 0)
|
if (DrawTextExW(dc, msg, n, &r, DT_END_ELLIPSIS | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE, NULL) == 0)
|
||||||
panic("error drawing Table cell text");
|
panic("error drawing Table cell text");
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,8 @@ struct table {
|
||||||
intptr_t vpagesize; // in rows
|
intptr_t vpagesize; // in rows
|
||||||
int hwheelCarry;
|
int hwheelCarry;
|
||||||
int vwheelCarry;
|
int vwheelCarry;
|
||||||
|
intptr_t selectedRow;
|
||||||
|
intptr_t selectedColumn;
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
@ -92,6 +94,8 @@ static const handlerfunc handlers[] = {
|
||||||
static void initDummyTableStuff(struct table *t)
|
static void initDummyTableStuff(struct table *t)
|
||||||
{
|
{
|
||||||
t->count = 100;
|
t->count = 100;
|
||||||
|
t->selectedRow = 2;
|
||||||
|
t->selectedColumn = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LRESULT CALLBACK tableWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
static LRESULT CALLBACK tableWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
|
@ -110,6 +114,8 @@ static LRESULT CALLBACK tableWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
|
||||||
t = (struct table *) tableAlloc(sizeof (struct table), "error allocating internal Table data structure");
|
t = (struct table *) tableAlloc(sizeof (struct table), "error allocating internal Table data structure");
|
||||||
t->hwnd = hwnd;
|
t->hwnd = hwnd;
|
||||||
makeHeader(t, cs->hInstance);
|
makeHeader(t, cs->hInstance);
|
||||||
|
t->selectedRow = -1;
|
||||||
|
t->selectedColumn = -1;
|
||||||
initDummyTableStuff(t);
|
initDummyTableStuff(t);
|
||||||
SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) t);
|
SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) t);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue