Wrote up toItemContentRect() and used that in drawCell(). More TODOs.

This commit is contained in:
Pietro Gagliardi 2014-12-20 21:09:01 -05:00
parent 7713c91387
commit 3cb96de162
3 changed files with 17 additions and 6 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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"