Commit 1da10fdc authored by Susan Farley's avatar Susan Farley Committed by Alexandre Julliard

More consistent calculation of line height, scrolls a full item on

line up/down.
parent 176cee7e
...@@ -62,6 +62,8 @@ DEFAULT_DEBUG_CHANNEL(treeview) ...@@ -62,6 +62,8 @@ DEFAULT_DEBUG_CHANNEL(treeview)
#define TREEVIEW_GetInfoPtr(hwnd) \ #define TREEVIEW_GetInfoPtr(hwnd) \
((TREEVIEW_INFO *) GetWindowLongA( hwnd, 0)) ((TREEVIEW_INFO *) GetWindowLongA( hwnd, 0))
#define FOCUS_BORDER 3
static BOOL static BOOL
TREEVIEW_SendSimpleNotify (HWND hwnd, UINT code); TREEVIEW_SendSimpleNotify (HWND hwnd, UINT code);
static BOOL static BOOL
...@@ -1062,6 +1064,8 @@ TREEVIEW_Refresh (HWND hwnd, HDC hdc) ...@@ -1062,6 +1064,8 @@ TREEVIEW_Refresh (HWND hwnd, HDC hdc)
TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
TEXTMETRICA tm; TEXTMETRICA tm;
HBRUSH hbrBk; HBRUSH hbrBk;
HFONT hOldFont;
RECT rect; RECT rect;
INT iItem, indent, x, y, height, itemHeight; INT iItem, indent, x, y, height, itemHeight;
INT viewtop,viewbottom,viewleft,viewright; INT viewtop,viewbottom,viewleft,viewright;
...@@ -1077,14 +1081,14 @@ TREEVIEW_Refresh (HWND hwnd, HDC hdc) ...@@ -1077,14 +1081,14 @@ TREEVIEW_Refresh (HWND hwnd, HDC hdc)
GetClientRect (hwnd, &rect); GetClientRect (hwnd, &rect);
if ((rect.left-rect.right ==0) || (rect.top-rect.bottom==0)) return; if ((rect.left >= rect.right) || (rect.top >= rect.bottom)) return;
infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify(hwnd,CDDS_PREPAINT,hdc,rect); infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify(hwnd,CDDS_PREPAINT,hdc,rect);
if (infoPtr->cdmode==CDRF_SKIPDEFAULT) return; if (infoPtr->cdmode==CDRF_SKIPDEFAULT) return;
infoPtr->uVisibleHeight= rect.bottom-rect.top; infoPtr->uVisibleHeight= rect.bottom-rect.top + 1;
infoPtr->uVisibleWidth= rect.right-rect.left; infoPtr->uVisibleWidth= rect.right-rect.left + 1;
viewtop=infoPtr->cy; viewtop=infoPtr->cy;
viewbottom=infoPtr->cy + rect.bottom-rect.top; viewbottom=infoPtr->cy + rect.bottom-rect.top;
...@@ -1103,9 +1107,12 @@ TREEVIEW_Refresh (HWND hwnd, HDC hdc) ...@@ -1103,9 +1107,12 @@ TREEVIEW_Refresh (HWND hwnd, HDC hdc)
if (infoPtr->uItemHeight>itemHeight) if (infoPtr->uItemHeight>itemHeight)
itemHeight=infoPtr->uItemHeight; itemHeight=infoPtr->uItemHeight;
// assume that bold and normal fonts have same height
hOldFont = SelectObject (hdc, infoPtr->hBoldFont);
GetTextMetricsA (hdc, &tm); GetTextMetricsA (hdc, &tm);
if ((tm.tmHeight + tm.tmExternalLeading) > itemHeight) if ((tm.tmHeight + tm.tmExternalLeading + FOCUS_BORDER) > itemHeight)
itemHeight=tm.tmHeight + tm.tmExternalLeading; itemHeight=tm.tmHeight + tm.tmExternalLeading + FOCUS_BORDER;
SelectObject (hdc, hOldFont);
infoPtr->uRealItemHeight=itemHeight; infoPtr->uRealItemHeight=itemHeight;
...@@ -1134,12 +1141,12 @@ TREEVIEW_Refresh (HWND hwnd, HDC hdc) ...@@ -1134,12 +1141,12 @@ TREEVIEW_Refresh (HWND hwnd, HDC hdc)
wineItem->rect.left, wineItem->rect.right); wineItem->rect.left, wineItem->rect.right);
*/ */
height=itemHeight * wineItem->iIntegral +1; height=itemHeight * wineItem->iIntegral;
if ((y >= viewtop) && (y <= viewbottom) && if ((y >= viewtop) && (y <= viewbottom) &&
(x >= viewleft ) && (x <= viewright)) { (x >= viewleft ) && (x <= viewright)) {
wineItem->visible = TRUE; wineItem->visible = TRUE;
wineItem->rect.top = y - infoPtr->cy + rect.top; wineItem->rect.top = y - infoPtr->cy + rect.top;
wineItem->rect.bottom = wineItem->rect.top + height ; wineItem->rect.bottom = wineItem->rect.top + height-1;
wineItem->rect.left = x - infoPtr->cx + rect.left; wineItem->rect.left = x - infoPtr->cx + rect.left;
wineItem->rect.right = rect.right; wineItem->rect.right = rect.right;
if (!infoPtr->firstVisible) if (!infoPtr->firstVisible)
...@@ -3651,7 +3658,7 @@ TREEVIEW_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -3651,7 +3658,7 @@ TREEVIEW_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
hdc = GetDC (0); hdc = GetDC (0);
hOldFont = SelectObject (hdc, hFont); hOldFont = SelectObject (hdc, hFont);
GetTextMetricsA (hdc, &tm); GetTextMetricsA (hdc, &tm);
height= tm.tmHeight + tm.tmExternalLeading; height= tm.tmHeight + tm.tmExternalLeading + FOCUS_BORDER;
if (height>infoPtr->uRealItemHeight) if (height>infoPtr->uRealItemHeight)
infoPtr->uRealItemHeight=height; infoPtr->uRealItemHeight=height;
SelectObject (hdc, hOldFont); SelectObject (hdc, hOldFont);
...@@ -3670,6 +3677,7 @@ TREEVIEW_VScroll (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -3670,6 +3677,7 @@ TREEVIEW_VScroll (HWND hwnd, WPARAM wParam, LPARAM lParam)
{ {
TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
WORD nVisibleItems;
int maxHeight; int maxHeight;
TRACE("wp %x, lp %lx\n", wParam, lParam); TRACE("wp %x, lp %lx\n", wParam, lParam);
...@@ -3682,10 +3690,11 @@ TREEVIEW_VScroll (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -3682,10 +3690,11 @@ TREEVIEW_VScroll (HWND hwnd, WPARAM wParam, LPARAM lParam)
if (infoPtr->cy < 0) infoPtr->cy=0; if (infoPtr->cy < 0) infoPtr->cy=0;
break; break;
case SB_LINEDOWN: case SB_LINEDOWN:
maxHeight=infoPtr->uTotalHeight-infoPtr->uVisibleHeight; nVisibleItems = infoPtr->uVisibleHeight / infoPtr->uRealItemHeight;
if (infoPtr->cy == maxHeight) return FALSE; maxHeight=infoPtr->uTotalHeight - nVisibleItems * infoPtr->uRealItemHeight;
if (infoPtr->cy >= maxHeight) return FALSE;
infoPtr->cy += infoPtr->uRealItemHeight; infoPtr->cy += infoPtr->uRealItemHeight;
if (infoPtr->cy > maxHeight) if (infoPtr->cy >= maxHeight)
infoPtr->cy = maxHeight; infoPtr->cy = maxHeight;
break; break;
case SB_PAGEUP: case SB_PAGEUP:
...@@ -3694,11 +3703,12 @@ TREEVIEW_VScroll (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -3694,11 +3703,12 @@ TREEVIEW_VScroll (HWND hwnd, WPARAM wParam, LPARAM lParam)
if (infoPtr->cy < 0) infoPtr->cy=0; if (infoPtr->cy < 0) infoPtr->cy=0;
break; break;
case SB_PAGEDOWN: case SB_PAGEDOWN:
maxHeight=infoPtr->uTotalHeight-infoPtr->uVisibleHeight; nVisibleItems = infoPtr->uVisibleHeight / infoPtr->uRealItemHeight;
maxHeight=infoPtr->uTotalHeight - nVisibleItems * infoPtr->uRealItemHeight;
if (infoPtr->cy == maxHeight) return FALSE; if (infoPtr->cy == maxHeight) return FALSE;
infoPtr->cy += infoPtr->uVisibleHeight; infoPtr->cy += infoPtr->uVisibleHeight;
if (infoPtr->cy > maxHeight) if (infoPtr->cy >= maxHeight)
infoPtr->cy = maxHeight; infoPtr->cy = maxHeight;
break; break;
case SB_THUMBTRACK: case SB_THUMBTRACK:
infoPtr->cy = HIWORD (wParam); infoPtr->cy = HIWORD (wParam);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment