Commit 00ea0868 authored by Dimitrie O. Paun's avatar Dimitrie O. Paun Committed by Alexandre Julliard

Rename GetItemHeight to CalculateMaxHeight, for consistency

Fix usage of nItemWidth vs. iconSpacing.cx Misc cleanups.
parent a1ca0122
...@@ -275,7 +275,7 @@ static BOOL LISTVIEW_GetItemBox(LISTVIEW_INFO *, INT, LPRECT); ...@@ -275,7 +275,7 @@ static BOOL LISTVIEW_GetItemBox(LISTVIEW_INFO *, INT, LPRECT);
static void LISTVIEW_AlignLeft(LISTVIEW_INFO *); static void LISTVIEW_AlignLeft(LISTVIEW_INFO *);
static void LISTVIEW_AlignTop(LISTVIEW_INFO *); static void LISTVIEW_AlignTop(LISTVIEW_INFO *);
static void LISTVIEW_AddGroupSelection(LISTVIEW_INFO *, INT); static void LISTVIEW_AddGroupSelection(LISTVIEW_INFO *, INT);
static INT LISTVIEW_GetItemHeight(LISTVIEW_INFO *); static INT LISTVIEW_CalculateMaxHeight(LISTVIEW_INFO *);
static BOOL LISTVIEW_GetItemListOrigin(LISTVIEW_INFO *, INT, LPPOINT); static BOOL LISTVIEW_GetItemListOrigin(LISTVIEW_INFO *, INT, LPPOINT);
static BOOL LISTVIEW_GetItemPosition(LISTVIEW_INFO *, INT, LPPOINT); static BOOL LISTVIEW_GetItemPosition(LISTVIEW_INFO *, INT, LPPOINT);
static BOOL LISTVIEW_GetItemRect(LISTVIEW_INFO *, INT, LPRECT); static BOOL LISTVIEW_GetItemRect(LISTVIEW_INFO *, INT, LPRECT);
...@@ -1440,7 +1440,7 @@ static BOOL LISTVIEW_GetItemMetrics(LISTVIEW_INFO *infoPtr, LVITEMW *lpLVItem, ...@@ -1440,7 +1440,7 @@ static BOOL LISTVIEW_GetItemMetrics(LISTVIEW_INFO *infoPtr, LVITEMW *lpLVItem,
{ {
State.left = Box.left - infoPtr->iconStateSize.cx - 2; State.left = Box.left - infoPtr->iconStateSize.cx - 2;
if (infoPtr->himlNormal) if (infoPtr->himlNormal)
State.left += (infoPtr->iconSpacing.cx - infoPtr->iconSize.cx) / 2 + ICON_LR_HALF; State.left += (infoPtr->nItemWidth - infoPtr->iconSize.cx) / 2;
State.top = Box.top + infoPtr->iconSize.cy - infoPtr->iconStateSize.cy + 4; State.top = Box.top + infoPtr->iconSize.cy - infoPtr->iconStateSize.cy + 4;
} }
else else
...@@ -1471,7 +1471,7 @@ static BOOL LISTVIEW_GetItemMetrics(LISTVIEW_INFO *infoPtr, LVITEMW *lpLVItem, ...@@ -1471,7 +1471,7 @@ static BOOL LISTVIEW_GetItemMetrics(LISTVIEW_INFO *infoPtr, LVITEMW *lpLVItem,
{ {
Icon.left = Box.left; Icon.left = Box.left;
if (infoPtr->himlNormal) if (infoPtr->himlNormal)
Icon.left += (infoPtr->iconSpacing.cx - infoPtr->iconSize.cx) / 2; Icon.left += (infoPtr->nItemWidth - infoPtr->iconSize.cx) / 2;
Icon.top = Box.top + ICON_TOP_PADDING; Icon.top = Box.top + ICON_TOP_PADDING;
Icon.right = Icon.left; Icon.right = Icon.left;
Icon.bottom = Icon.top; Icon.bottom = Icon.top;
...@@ -1542,7 +1542,7 @@ static BOOL LISTVIEW_GetItemMetrics(LISTVIEW_INFO *infoPtr, LVITEMW *lpLVItem, ...@@ -1542,7 +1542,7 @@ static BOOL LISTVIEW_GetItemMetrics(LISTVIEW_INFO *infoPtr, LVITEMW *lpLVItem,
calc_label: calc_label:
if (uView == LVS_ICON) if (uView == LVS_ICON)
{ {
Label.left = Box.left + (infoPtr->iconSpacing.cx - labelSize.cx) / 2; Label.left = Box.left + (infoPtr->nItemWidth - labelSize.cx) / 2;
Label.top = Box.top + ICON_TOP_PADDING_HITABLE + Label.top = Box.top + ICON_TOP_PADDING_HITABLE +
infoPtr->iconSize.cy + ICON_BOTTOM_PADDING; infoPtr->iconSize.cy + ICON_BOTTOM_PADDING;
Label.right = Label.left + labelSize.cx; Label.right = Label.left + labelSize.cx;
...@@ -1951,7 +1951,7 @@ static void LISTVIEW_SaveTextMetrics(LISTVIEW_INFO *infoPtr) ...@@ -1951,7 +1951,7 @@ static void LISTVIEW_SaveTextMetrics(LISTVIEW_INFO *infoPtr)
* RETURN: * RETURN:
* Returns item height. * Returns item height.
*/ */
static INT LISTVIEW_GetItemHeight(LISTVIEW_INFO *infoPtr) static INT LISTVIEW_CalculateMaxHeight(LISTVIEW_INFO *infoPtr)
{ {
INT nItemHeight; INT nItemHeight;
...@@ -4832,7 +4832,7 @@ static BOOL LISTVIEW_GetItemPosition(LISTVIEW_INFO *infoPtr, INT nItem, LPPOINT ...@@ -4832,7 +4832,7 @@ static BOOL LISTVIEW_GetItemPosition(LISTVIEW_INFO *infoPtr, INT nItem, LPPOINT
if (uView == LVS_ICON) if (uView == LVS_ICON)
{ {
lpptPosition->x += (infoPtr->iconSpacing.cx - infoPtr->iconSize.cx) / 2; lpptPosition->x += (infoPtr->nItemWidth - infoPtr->iconSize.cx) / 2;
lpptPosition->y += ICON_TOP_PADDING; lpptPosition->y += ICON_TOP_PADDING;
} }
lpptPosition->x += Origin.x; lpptPosition->x += Origin.x;
...@@ -6120,25 +6120,20 @@ static LRESULT LISTVIEW_SetColumnWidth(LISTVIEW_INFO *infoPtr, INT iCol, INT cx) ...@@ -6120,25 +6120,20 @@ static LRESULT LISTVIEW_SetColumnWidth(LISTVIEW_INFO *infoPtr, INT iCol, INT cx)
LVITEMW lvItem; LVITEMW lvItem;
WCHAR szDispText[DISP_TEXT_SIZE] = { 0 }; WCHAR szDispText[DISP_TEXT_SIZE] = { 0 };
if (!infoPtr->hwndHeader) /* make sure we have a header */ TRACE("(iCol=%d, cx=%d\n", iCol, cx);
return (FALSE);
/* set column width only if in report or list mode */ /* set column width only if in report or list mode */
if ((uView != LVS_REPORT) && (uView != LVS_LIST)) if (uView != LVS_REPORT && uView != LVS_LIST) return FALSE;
return (FALSE);
TRACE("(iCol=%d, cx=%d\n", iCol, cx);
/* take care of invalid cx values */ /* take care of invalid cx values */
if((uView == LVS_REPORT) && (cx < -2)) if(uView == LVS_REPORT && cx < -2) cx = LVSCW_AUTOSIZE;
cx = LVSCW_AUTOSIZE; else if (uView == LVS_LIST && cx < 1) return FALSE;
else if (uView == LVS_LIST && (cx < 1))
return FALSE;
/* resize all columns if in LVS_LIST mode */ /* resize all columns if in LVS_LIST mode */
if(uView == LVS_LIST) { if(uView == LVS_LIST)
{
infoPtr->nItemWidth = cx; infoPtr->nItemWidth = cx;
LISTVIEW_InvalidateList(infoPtr); /* FIXME: optimize */ LISTVIEW_InvalidateList(infoPtr);
return TRUE; return TRUE;
} }
...@@ -6386,7 +6381,7 @@ static LRESULT LISTVIEW_SetIconSpacing(LISTVIEW_INFO *infoPtr, DWORD spacing) ...@@ -6386,7 +6381,7 @@ static LRESULT LISTVIEW_SetIconSpacing(LISTVIEW_INFO *infoPtr, DWORD spacing)
/* these depend on the iconSpacing */ /* these depend on the iconSpacing */
infoPtr->nItemWidth = LISTVIEW_CalculateMaxWidth(infoPtr); infoPtr->nItemWidth = LISTVIEW_CalculateMaxWidth(infoPtr);
infoPtr->nItemHeight = LISTVIEW_GetItemHeight(infoPtr); infoPtr->nItemHeight = LISTVIEW_CalculateMaxHeight(infoPtr);
return oldspacing; return oldspacing;
} }
...@@ -6450,7 +6445,7 @@ static HIMAGELIST LISTVIEW_SetImageList(LISTVIEW_INFO *infoPtr, INT nType, HIMAG ...@@ -6450,7 +6445,7 @@ static HIMAGELIST LISTVIEW_SetImageList(LISTVIEW_INFO *infoPtr, INT nType, HIMAG
return NULL; return NULL;
} }
infoPtr->nItemHeight = LISTVIEW_GetItemHeight(infoPtr); infoPtr->nItemHeight = LISTVIEW_CalculateMaxHeight(infoPtr);
if (infoPtr->nItemHeight != oldHeight) if (infoPtr->nItemHeight != oldHeight)
LISTVIEW_UpdateScroll(infoPtr); LISTVIEW_UpdateScroll(infoPtr);
...@@ -6545,7 +6540,7 @@ static BOOL LISTVIEW_SetItemPosition(LISTVIEW_INFO *infoPtr, INT nItem, POINT pt ...@@ -6545,7 +6540,7 @@ static BOOL LISTVIEW_SetItemPosition(LISTVIEW_INFO *infoPtr, INT nItem, POINT pt
LISTVIEW_GetOrigin(infoPtr, &pt); LISTVIEW_GetOrigin(infoPtr, &pt);
else if (uView == LVS_ICON) else if (uView == LVS_ICON)
{ {
pt.x -= (infoPtr->iconSpacing.cx - infoPtr->iconSize.cx) / 2; pt.x -= (infoPtr->nItemWidth - infoPtr->iconSize.cx) / 2;
pt.y -= ICON_TOP_PADDING; pt.y -= ICON_TOP_PADDING;
} }
...@@ -6954,7 +6949,7 @@ static LRESULT LISTVIEW_Create(HWND hwnd, LPCREATESTRUCTW lpcs) ...@@ -6954,7 +6949,7 @@ static LRESULT LISTVIEW_Create(HWND hwnd, LPCREATESTRUCTW lpcs)
/* initialize size of items */ /* initialize size of items */
infoPtr->nItemWidth = LISTVIEW_CalculateMaxWidth(infoPtr); infoPtr->nItemWidth = LISTVIEW_CalculateMaxWidth(infoPtr);
infoPtr->nItemHeight = LISTVIEW_GetItemHeight(infoPtr); infoPtr->nItemHeight = LISTVIEW_CalculateMaxHeight(infoPtr);
/* initialize the hover time to -1(indicating the default system hover time) */ /* initialize the hover time to -1(indicating the default system hover time) */
infoPtr->dwHoverTime = -1; infoPtr->dwHoverTime = -1;
...@@ -8122,7 +8117,7 @@ static INT LISTVIEW_StyleChanged(LISTVIEW_INFO *infoPtr, WPARAM wStyleType, ...@@ -8122,7 +8117,7 @@ static INT LISTVIEW_StyleChanged(LISTVIEW_INFO *infoPtr, WPARAM wStyleType,
/* Now update the full item width and height */ /* Now update the full item width and height */
infoPtr->nItemWidth = LISTVIEW_CalculateMaxWidth(infoPtr); infoPtr->nItemWidth = LISTVIEW_CalculateMaxWidth(infoPtr);
infoPtr->nItemHeight = LISTVIEW_GetItemHeight(infoPtr); infoPtr->nItemHeight = LISTVIEW_CalculateMaxHeight(infoPtr);
if (lpss->styleNew & LVS_ALIGNLEFT) if (lpss->styleNew & LVS_ALIGNLEFT)
LISTVIEW_AlignLeft(infoPtr); LISTVIEW_AlignLeft(infoPtr);
else else
...@@ -8144,21 +8139,21 @@ static INT LISTVIEW_StyleChanged(LISTVIEW_INFO *infoPtr, WPARAM wStyleType, ...@@ -8144,21 +8139,21 @@ static INT LISTVIEW_StyleChanged(LISTVIEW_INFO *infoPtr, WPARAM wStyleType,
infoPtr->iconSize.cx = GetSystemMetrics(SM_CXSMICON); infoPtr->iconSize.cx = GetSystemMetrics(SM_CXSMICON);
infoPtr->iconSize.cy = GetSystemMetrics(SM_CYSMICON); infoPtr->iconSize.cy = GetSystemMetrics(SM_CYSMICON);
infoPtr->nItemWidth = LISTVIEW_CalculateMaxWidth(infoPtr); infoPtr->nItemWidth = LISTVIEW_CalculateMaxWidth(infoPtr);
infoPtr->nItemHeight = LISTVIEW_GetItemHeight(infoPtr); infoPtr->nItemHeight = LISTVIEW_CalculateMaxHeight(infoPtr);
} }
else if (uNewView == LVS_LIST) else if (uNewView == LVS_LIST)
{ {
infoPtr->iconSize.cx = GetSystemMetrics(SM_CXSMICON); infoPtr->iconSize.cx = GetSystemMetrics(SM_CXSMICON);
infoPtr->iconSize.cy = GetSystemMetrics(SM_CYSMICON); infoPtr->iconSize.cy = GetSystemMetrics(SM_CYSMICON);
infoPtr->nItemWidth = LISTVIEW_CalculateMaxWidth(infoPtr); infoPtr->nItemWidth = LISTVIEW_CalculateMaxWidth(infoPtr);
infoPtr->nItemHeight = LISTVIEW_GetItemHeight(infoPtr); infoPtr->nItemHeight = LISTVIEW_CalculateMaxHeight(infoPtr);
} }
else else
{ {
infoPtr->iconSize.cx = GetSystemMetrics(SM_CXSMICON); infoPtr->iconSize.cx = GetSystemMetrics(SM_CXSMICON);
infoPtr->iconSize.cy = GetSystemMetrics(SM_CYSMICON); infoPtr->iconSize.cy = GetSystemMetrics(SM_CYSMICON);
infoPtr->nItemWidth = LISTVIEW_CalculateMaxWidth(infoPtr); infoPtr->nItemWidth = LISTVIEW_CalculateMaxWidth(infoPtr);
infoPtr->nItemHeight = LISTVIEW_GetItemHeight(infoPtr); infoPtr->nItemHeight = LISTVIEW_CalculateMaxHeight(infoPtr);
if (lpss->styleNew & LVS_ALIGNLEFT) if (lpss->styleNew & LVS_ALIGNLEFT)
LISTVIEW_AlignLeft(infoPtr); LISTVIEW_AlignLeft(infoPtr);
else else
......
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