summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wintable/new/draw.h38
-rw-r--r--wintable/new/main.c6
2 files changed, 35 insertions, 9 deletions
diff --git a/wintable/new/draw.h b/wintable/new/draw.h
index dce90a7..761c133 100644
--- a/wintable/new/draw.h
+++ b/wintable/new/draw.h
@@ -18,21 +18,41 @@ static void drawCell(struct table *t, HDC dc, struct drawCellParams *p)
RECT r;
WCHAR msg[200];
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.top = p->y;
r.bottom = p->y + p->height;
- // TODO fill this rect with the appropriate background color
- // TODO then vertical center content
- n = wsprintf(msg, L"(%d,%d)", p->row, p->column);
+ if (FillRect(dc, &r, background) == 0)
+ panic("error filling Table cell background");
-/* FillRect(dc, &r, (HBRUSH) (current + 1));
- current++;
- if (current >= 31)
- current = 0;
-*/
+ // now offset the content to where inside the cell it should be
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)
panic("error drawing Table cell text");
}
diff --git a/wintable/new/main.c b/wintable/new/main.c
index 00bc5fb..9a806b6 100644
--- a/wintable/new/main.c
+++ b/wintable/new/main.c
@@ -64,6 +64,8 @@ struct table {
intptr_t vpagesize; // in rows
int hwheelCarry;
int vwheelCarry;
+ intptr_t selectedRow;
+ intptr_t selectedColumn;
};
#include "util.h"
@@ -92,6 +94,8 @@ static const handlerfunc handlers[] = {
static void initDummyTableStuff(struct table *t)
{
t->count = 100;
+ t->selectedRow = 2;
+ t->selectedColumn = 1;
}
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->hwnd = hwnd;
makeHeader(t, cs->hInstance);
+ t->selectedRow = -1;
+ t->selectedColumn = -1;
initDummyTableStuff(t);
SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) t);
}