diff --git a/wintable/new/coord.h b/wintable/new/coord.h index 6de4f2b..39517d3 100644 --- a/wintable/new/coord.h +++ b/wintable/new/coord.h @@ -148,3 +148,17 @@ static BOOL rowColumnToClientRect(struct table *t, struct rowcol rc, RECT *r) } // TODO idealCoordToRowColumn/rowColumnToIdealCoord? + +static void toItemContentRect(struct table *t, RECT *r, LRESULT xoff, intptr_t width, intptr_t height) +{ + if (xoff == 0) + xoff = SendMessageW(t->header, HDM_GETBITMAPMARGIN, 0, 0); + r->left += xoff; + if (width != 0) + r->right = r->left + width; + if (height != 0) + // TODO vertical center + r->bottom = r->top + height; +} + +#define toCheckboxRect(t, r) toItemContentRect(t, r, 0, t->checkboxWidth, t->checkboxHeight) diff --git a/wintable/new/draw.h b/wintable/new/draw.h index 0659f54..a4bd22d 100644 --- a/wintable/new/draw.h +++ b/wintable/new/draw.h @@ -41,13 +41,10 @@ static void drawCell(struct table *t, HDC dc, struct drawCellParams *p) if (FillRect(dc, &r, background) == 0) panic("error filling Table cell background"); - // now offset the content to where inside the cell it should be - r.left += p->xoff; - // TODO vertical center content too - switch (t->columnTypes[p->column]) { case tableColumnText: case tableColumnImage: // TODO + toItemContentRect(t, &r, p->xoff, 0, 0); // TODO get the text height if (SetTextColor(dc, GetSysColor(textColor)) == CLR_INVALID) panic("error setting Table cell text color"); if (SetBkMode(dc, TRANSPARENT) == 0) @@ -57,8 +54,7 @@ static void drawCell(struct table *t, HDC dc, struct drawCellParams *p) panic("error drawing Table cell text"); break; case tableColumnCheckbox: - r.right = r.left + t->checkboxWidth; - r.bottom = r.top + t->checkboxHeight; + toCheckboxRect(t, &r); SetDCBrushColor(dc, RGB(255, 0, 0)); FillRect(dc, &r, GetStockObject(DC_BRUSH)); break; diff --git a/wintable/new/main.c b/wintable/new/main.c index 75cf723..f3ffec8 100644 --- a/wintable/new/main.c +++ b/wintable/new/main.c @@ -31,6 +31,7 @@ // - do we maintain the scrolling metaphor? // - WM_THEMECHANGED, etc. // - see if vertical centering is really what we want or if we just want to offset by a few pixels or so +// - going right from column 0 to column 2 with the right arrow key deselects #define tableWindowClass L"gouitable"