Item height/expand button width must be >= than imagelist size.
Avoid a magic number, add FIXME for incorrect +/- drawing.
This commit is contained in:
parent
cd516fd185
commit
f479f10660
|
@ -1642,6 +1642,35 @@ TREEVIEW_GetImageList(TREEVIEW_INFO *infoPtr, WPARAM wParam)
|
|||
}
|
||||
}
|
||||
|
||||
#define TVHEIGHT_MIN 16
|
||||
#define TVHEIGHT_FONT_ADJUST 3 /* 2 for focus border + 1 for margin some apps assume */
|
||||
|
||||
/* Compute the natural height for items. */
|
||||
static UINT
|
||||
TREEVIEW_NaturalHeight(TREEVIEW_INFO *infoPtr)
|
||||
{
|
||||
TEXTMETRICW tm;
|
||||
HDC hdc = GetDC(0);
|
||||
HFONT hOldFont = SelectObject(hdc, infoPtr->hFont);
|
||||
UINT height;
|
||||
|
||||
/* Height is the maximum of:
|
||||
* 16 (a hack because our fonts are tiny), and
|
||||
* The text height + border & margin, and
|
||||
* The size of the normal image list
|
||||
*/
|
||||
GetTextMetricsW(hdc, &tm);
|
||||
SelectObject(hdc, hOldFont);
|
||||
ReleaseDC(0, hdc);
|
||||
|
||||
height = TVHEIGHT_MIN;
|
||||
if (height < tm.tmHeight + tm.tmExternalLeading + TVHEIGHT_FONT_ADJUST)
|
||||
height = tm.tmHeight + tm.tmExternalLeading + TVHEIGHT_FONT_ADJUST;
|
||||
if (height < infoPtr->normalImageHeight)
|
||||
height = infoPtr->normalImageHeight;
|
||||
return height;
|
||||
}
|
||||
|
||||
static LRESULT
|
||||
TREEVIEW_SetImageList(TREEVIEW_INFO *infoPtr, WPARAM wParam, HIMAGELIST himlNew)
|
||||
{
|
||||
|
@ -1688,6 +1717,25 @@ TREEVIEW_SetImageList(TREEVIEW_INFO *infoPtr, WPARAM wParam, HIMAGELIST himlNew)
|
|||
if (oldWidth != infoPtr->normalImageWidth ||
|
||||
oldHeight != infoPtr->normalImageHeight)
|
||||
{
|
||||
BOOL bRecalcVisable = FALSE;
|
||||
|
||||
if (oldHeight != infoPtr->normalImageHeight &&
|
||||
!infoPtr->bHeightSet)
|
||||
{
|
||||
infoPtr->uItemHeight = TREEVIEW_NaturalHeight(infoPtr);
|
||||
bRecalcVisable = TRUE;
|
||||
}
|
||||
|
||||
if (infoPtr->normalImageWidth > MINIMUM_INDENT &&
|
||||
infoPtr->normalImageWidth != infoPtr->uIndent)
|
||||
{
|
||||
infoPtr->uIndent = infoPtr->normalImageWidth;
|
||||
bRecalcVisable = TRUE;
|
||||
}
|
||||
|
||||
if (bRecalcVisable)
|
||||
TREEVIEW_RecalculateVisibleOrder(infoPtr, NULL);
|
||||
|
||||
TREEVIEW_UpdateSubTree(infoPtr, infoPtr->root);
|
||||
TREEVIEW_UpdateScrollBars(infoPtr);
|
||||
}
|
||||
|
@ -1697,24 +1745,6 @@ TREEVIEW_SetImageList(TREEVIEW_INFO *infoPtr, WPARAM wParam, HIMAGELIST himlNew)
|
|||
return (LRESULT)himlOld;
|
||||
}
|
||||
|
||||
/* Compute the natural height (based on the font size) for items. */
|
||||
static UINT
|
||||
TREEVIEW_NaturalHeight(TREEVIEW_INFO *infoPtr)
|
||||
{
|
||||
TEXTMETRICW tm;
|
||||
HDC hdc = GetDC(0);
|
||||
HFONT hOldFont = SelectObject(hdc, infoPtr->hFont);
|
||||
|
||||
GetTextMetricsW(hdc, &tm);
|
||||
|
||||
SelectObject(hdc, hOldFont);
|
||||
ReleaseDC(0, hdc);
|
||||
|
||||
/* The 16 is a hack because our fonts are tiny. */
|
||||
/* add 2 for the focus border and 1 more for margin some apps assume */
|
||||
return max(16, tm.tmHeight + tm.tmExternalLeading + 3);
|
||||
}
|
||||
|
||||
static LRESULT
|
||||
TREEVIEW_SetItemHeight(TREEVIEW_INFO *infoPtr, INT newHeight)
|
||||
{
|
||||
|
@ -2289,6 +2319,18 @@ TREEVIEW_DrawItemLines(TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *item)
|
|||
HBRUSH hbr = CreateSolidBrush(infoPtr->clrBk);
|
||||
HBRUSH hbrOld = SelectObject(hdc, hbr);
|
||||
|
||||
/* FIXME: Native actually draws:
|
||||
*
|
||||
* xxx
|
||||
* X x
|
||||
* xxx xxx xxxxxxx
|
||||
* x x or x x
|
||||
* xxx xxx xxxxxxx
|
||||
* x x
|
||||
* xxx
|
||||
*
|
||||
* This looks a lot better when the icon size is increased.
|
||||
*/
|
||||
Rectangle(hdc, centerx - rectsize - 1, centery - rectsize - 1,
|
||||
centerx + rectsize + 2, centery + rectsize + 2);
|
||||
|
||||
|
@ -4667,7 +4709,7 @@ TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
|
|||
infoPtr->treeWidth = 0;
|
||||
infoPtr->treeHeight = 0;
|
||||
|
||||
infoPtr->uIndent = 19;
|
||||
infoPtr->uIndent = MINIMUM_INDENT;
|
||||
infoPtr->selectedItem = 0;
|
||||
infoPtr->focusedItem = 0;
|
||||
/* hotItem? */
|
||||
|
|
Loading…
Reference in New Issue