diff options
| author | Pietro Gagliardi <[email protected]> | 2014-12-12 10:47:23 -0500 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-12-12 10:47:23 -0500 |
| commit | 9e11c36f63c04e16f1d1a42a05ec545b2793ce65 (patch) | |
| tree | 563ed4cccde98a0ce0e65e73738e354caacf0f0c /wintable/new/draw.h | |
| parent | 6173857ee79a1ab1296f5278dde9d57f72d7d53c (diff) | |
Started tying all the threads together in the drawing loop for real.
Diffstat (limited to 'wintable/new/draw.h')
| -rw-r--r-- | wintable/new/draw.h | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/wintable/new/draw.h b/wintable/new/draw.h index 2081581..2624b6c 100644 --- a/wintable/new/draw.h +++ b/wintable/new/draw.h @@ -10,51 +10,66 @@ struct drawCellParams { LRESULT xoff; // result of HDM_GETBITMAPMARGIN }; +//TODO delete when done +static int current = 0; + static void drawCell(struct table *t, HDC dc, struct drawCellParams *p) { RECT r; WCHAR msg[200]; int n; - r.left = p->x + p->xoff; + r.left = p->x;//TODO + p->xoff; 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); + + FillRect(dc, &r, (HBRUSH) (current + 1)); + current++; + if (current >= 31) + current = 0; + + r.left += p->xoff; if (DrawTextExW(dc, msg, n, &r, DT_END_ELLIPSIS | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE, NULL) == 0) panic("error drawing Table cell text"); } static void draw(struct table *t, HDC dc, RECT cliprect, RECT client) { - intptr_t i; + intptr_t i, j; RECT r; int x = 0; HFONT prevfont, newfont; struct drawCellParams p; - for (i = 0; i < t->nColumns; i++) { - SendMessage(t->header, HDM_GETITEMRECT, (WPARAM) i, (LPARAM) (&r)); - r.left -= t->hscrollpos; - r.right -= t->hscrollpos; - r.top = client.top; - r.bottom = client.bottom; - FillRect(dc, &r, GetSysColorBrush(x)); - x++; - } - prevfont = selectFont(t, dc, &newfont); + +current = 0; + + client.top += t->headerHeight; + ZeroMemory(&p, sizeof (struct drawCellParams)); - p.row = 0; - p.column = 0; - p.x = r.left; - p.y = 100; - p.width = r.right - r.left; p.height = rowHeight(t, dc, FALSE); p.xoff = SendMessageW(t->header, HDM_GETBITMAPMARGIN, 0, 0); - drawCell(t, dc, &p); + + p.y = client.top; + for (i = 0; i < t->count; i++) { + p.row = i; + p.x = client.left - t->hscrollpos; + for (j = 0; j < t->nColumns; j++) { + p.column = j; + // TODO error check + SendMessage(t->header, HDM_GETITEMRECT, (WPARAM) j, (LPARAM) (&r)); + p.width = r.right - r.left; + drawCell(t, dc, &p); + p.x += p.width; + } + p.y += p.height; + } + deselectFont(dc, prevfont, newfont); } |
