summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-12-12 10:47:23 -0500
committerPietro Gagliardi <[email protected]>2014-12-12 10:47:23 -0500
commit9e11c36f63c04e16f1d1a42a05ec545b2793ce65 (patch)
tree563ed4cccde98a0ce0e65e73738e354caacf0f0c
parent6173857ee79a1ab1296f5278dde9d57f72d7d53c (diff)
Started tying all the threads together in the drawing loop for real.
-rw-r--r--wintable/new/draw.h51
-rw-r--r--wintable/new/main.c7
2 files changed, 38 insertions, 20 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);
}
diff --git a/wintable/new/main.c b/wintable/new/main.c
index e2f85d9..9fd705e 100644
--- a/wintable/new/main.c
+++ b/wintable/new/main.c
@@ -26,6 +26,7 @@
// TODO
// - should tablePanic be CALLBACK or some other equivalent macro? and definitely export initTable somehow, but which alias macro to use?
// - make panic messages grammatically correct ("Table error: adding...")
+// - make access to column widths consistent; see whether HDITEMW.cxy == (ITEMRECT.right - ITEMRECT.left)
#define tableWindowClass L"gouitable"
@@ -55,9 +56,11 @@ struct table {
int *columnTypes;
intptr_t width;
intptr_t headerHeight;
- intptr_t hscrollpos;
- intptr_t hpagesize;
+ intptr_t hscrollpos; // in logical units
+ intptr_t hpagesize; // in logical units
intptr_t count;
+ intptr_t vscrollpos; // in rows
+ intptr_t vpagesize; // in rows
};
#include "util.h"