diff options
| author | Pietro Gagliardi <[email protected]> | 2014-10-21 12:13:26 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-10-21 12:13:26 -0400 |
| commit | 63df11929a726720e4f060662c7b979f7f2144b9 (patch) | |
| tree | b1ede80624dd41e05ae9954246777be1c05557f8 | |
| parent | 2fb625442057e8850819098a5ce0962130c5e6b9 (diff) | |
Started the work for horizontal scrolling.
| -rw-r--r-- | wintable/main.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/wintable/main.c b/wintable/main.c index 985f075..39e7242 100644 --- a/wintable/main.c +++ b/wintable/main.c @@ -82,6 +82,34 @@ static RECT realClientRect(struct table *t) return r; } +static void recomputeHScroll(struct table *t) +{ + HDITEMW item; + intptr_t i; + int width = 0; + RECT r; + SCROLLINFO si; + + // TODO count dividers + for (i = 0; i < t->nColumns; i++) { + ZeroMemory(&item, sizeof (HDITEMW)); + item.mask = HDI_WIDTH; + if (SendMessageW(t->header, HDM_GETITEM, (WPARAM) i, (LPARAM) (&item)) == FALSE) + abort(); + width += item.cxy; + } + + if (GetClientRect(t->hwnd, &r) == 0) + abort(); + ZeroMemory(&si, sizeof (SCROLLINFO)); + si.cbSize = sizeof (SCROLLINFO); + si.fMask = SIF_PAGE | SIF_RANGE; + si.nPage = r.right - r.left; + si.nMin = 0; + si.nMax = width - 1; // - 1 because endpoints inclusive + SetScrollInfo(t->hwnd, SB_HORZ, &si, TRUE); +} + static void finishSelect(struct table *t) { if (t->selected < 0) @@ -268,6 +296,8 @@ static void resize(struct table *t) si.nMax = t->count - 1; si.nPage = t->pagesize; SetScrollInfo(t->hwnd, SB_VERT, &si, TRUE); + + recomputeHScroll(t); } static void drawItems(struct table *t, HDC dc, RECT cliprect) @@ -475,6 +505,7 @@ t->nColumns=2;} // I could use HDN_TRACK but wine doesn't emit that case HDN_ITEMCHANGING: case HDN_ITEMCHANGED: // TODO needed? + recomputeHScroll(t); redrawAll(t); return FALSE; } |
