Split drawItems() into drawItems() and drawItem() in the Windows Table reimplementation. This will make rewriting drawItem() easier.
This commit is contained in:
parent
b40c1acab0
commit
fdd3720821
|
@ -309,47 +309,8 @@ static void resize(struct table *t)
|
||||||
recomputeHScroll(t);
|
recomputeHScroll(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawItems(struct table *t, HDC dc, RECT cliprect)
|
static void drawItem(struct table *t, HDC dc, intptr_t i, LONG y, LONG height, RECT controlSize)
|
||||||
{
|
{
|
||||||
HFONT thisfont, prevfont;
|
|
||||||
LONG height;
|
|
||||||
LONG y;
|
|
||||||
intptr_t i;
|
|
||||||
RECT controlSize; // for filling the entire selected row
|
|
||||||
intptr_t first, last;
|
|
||||||
POINT prevOrigin, prevViewportOrigin;
|
|
||||||
|
|
||||||
if (GetClientRect(t->hwnd, &controlSize) == 0)
|
|
||||||
abort();
|
|
||||||
|
|
||||||
height = rowHeight(t);
|
|
||||||
|
|
||||||
thisfont = t->font; // in case WM_SETFONT happens before we return
|
|
||||||
prevfont = (HFONT) SelectObject(dc, thisfont);
|
|
||||||
if (prevfont == NULL)
|
|
||||||
abort();
|
|
||||||
|
|
||||||
// adjust the clip rect and the window so that (0, 0) is always the first item
|
|
||||||
// adjust the viewport so that everything is shifted down t->headerHeight pixels
|
|
||||||
if (OffsetRect(&cliprect, 0, t->firstVisible * height) == 0)
|
|
||||||
abort();
|
|
||||||
if (GetWindowOrgEx(dc, &prevOrigin) == 0)
|
|
||||||
abort();
|
|
||||||
if (SetWindowOrgEx(dc, prevOrigin.x, prevOrigin.y + (t->firstVisible * height), NULL) == 0)
|
|
||||||
abort();
|
|
||||||
if (SetViewportOrgEx(dc, 0, t->headerHeight, &prevViewportOrigin) == 0)
|
|
||||||
abort();
|
|
||||||
|
|
||||||
// see http://blogs.msdn.com/b/oldnewthing/archive/2003/07/29/54591.aspx and http://blogs.msdn.com/b/oldnewthing/archive/2003/07/30/54600.aspx
|
|
||||||
first = cliprect.top / height;
|
|
||||||
if (first < 0)
|
|
||||||
first = 0;
|
|
||||||
last = (cliprect.bottom + height - 1) / height;
|
|
||||||
if (last >= t->count)
|
|
||||||
last = t->count;
|
|
||||||
|
|
||||||
y = first * height;
|
|
||||||
for (i = first; i < last; i++) {
|
|
||||||
RECT rsel;
|
RECT rsel;
|
||||||
HBRUSH background;
|
HBRUSH background;
|
||||||
int textColor;
|
int textColor;
|
||||||
|
@ -420,6 +381,50 @@ static void drawItems(struct table *t, HDC dc, RECT cliprect)
|
||||||
if (DrawTextExW(dc, msg, wsprintf(msg, L"Item %d", i), &rsel, DT_END_ELLIPSIS | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE, NULL) == 0)
|
if (DrawTextExW(dc, msg, wsprintf(msg, L"Item %d", i), &rsel, DT_END_ELLIPSIS | DT_LEFT | DT_NOPREFIX | DT_SINGLELINE, NULL) == 0)
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void drawItems(struct table *t, HDC dc, RECT cliprect)
|
||||||
|
{
|
||||||
|
HFONT thisfont, prevfont;
|
||||||
|
LONG height;
|
||||||
|
LONG y;
|
||||||
|
intptr_t i;
|
||||||
|
RECT controlSize; // for filling the entire selected row
|
||||||
|
intptr_t first, last;
|
||||||
|
POINT prevOrigin, prevViewportOrigin;
|
||||||
|
|
||||||
|
if (GetClientRect(t->hwnd, &controlSize) == 0)
|
||||||
|
abort();
|
||||||
|
|
||||||
|
height = rowHeight(t);
|
||||||
|
|
||||||
|
thisfont = t->font; // in case WM_SETFONT happens before we return
|
||||||
|
prevfont = (HFONT) SelectObject(dc, thisfont);
|
||||||
|
if (prevfont == NULL)
|
||||||
|
abort();
|
||||||
|
|
||||||
|
// adjust the clip rect and the window so that (0, 0) is always the first item
|
||||||
|
// adjust the viewport so that everything is shifted down t->headerHeight pixels
|
||||||
|
if (OffsetRect(&cliprect, 0, t->firstVisible * height) == 0)
|
||||||
|
abort();
|
||||||
|
if (GetWindowOrgEx(dc, &prevOrigin) == 0)
|
||||||
|
abort();
|
||||||
|
if (SetWindowOrgEx(dc, prevOrigin.x, prevOrigin.y + (t->firstVisible * height), NULL) == 0)
|
||||||
|
abort();
|
||||||
|
if (SetViewportOrgEx(dc, 0, t->headerHeight, &prevViewportOrigin) == 0)
|
||||||
|
abort();
|
||||||
|
|
||||||
|
// see http://blogs.msdn.com/b/oldnewthing/archive/2003/07/29/54591.aspx and http://blogs.msdn.com/b/oldnewthing/archive/2003/07/30/54600.aspx
|
||||||
|
first = cliprect.top / height;
|
||||||
|
if (first < 0)
|
||||||
|
first = 0;
|
||||||
|
last = (cliprect.bottom + height - 1) / height;
|
||||||
|
if (last >= t->count)
|
||||||
|
last = t->count;
|
||||||
|
|
||||||
|
y = first * height;
|
||||||
|
for (i = first; i < last; i++) {
|
||||||
|
drawItem(t, dc, i, y, height, controlSize);
|
||||||
y += height;
|
y += height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue