Avoid division by 0 by initializing the item size in on creation.
Rename update_icon_size to set_icon_size, fix parameters order. Assorted cleanups.
This commit is contained in:
parent
5ffde298fe
commit
89ab25a737
|
@ -6400,7 +6400,7 @@ static DWORD LISTVIEW_SetIconSpacing(LISTVIEW_INFO *infoPtr, DWORD spacing)
|
||||||
return oldspacing;
|
return oldspacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void update_icon_size(HIMAGELIST himl, BOOL small, SIZE *size)
|
inline void set_icon_size(SIZE *size, HIMAGELIST himl, BOOL small)
|
||||||
{
|
{
|
||||||
INT cx, cy;
|
INT cx, cy;
|
||||||
|
|
||||||
|
@ -6440,20 +6440,20 @@ static HIMAGELIST LISTVIEW_SetImageList(LISTVIEW_INFO *infoPtr, INT nType, HIMAG
|
||||||
case LVSIL_NORMAL:
|
case LVSIL_NORMAL:
|
||||||
himlOld = infoPtr->himlNormal;
|
himlOld = infoPtr->himlNormal;
|
||||||
infoPtr->himlNormal = himl;
|
infoPtr->himlNormal = himl;
|
||||||
if (uView == LVS_ICON) update_icon_size(himl, FALSE, &infoPtr->iconSize);
|
if (uView == LVS_ICON) set_icon_size(&infoPtr->iconSize, himl, FALSE);
|
||||||
LISTVIEW_SetIconSpacing(infoPtr, 0);
|
LISTVIEW_SetIconSpacing(infoPtr, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LVSIL_SMALL:
|
case LVSIL_SMALL:
|
||||||
himlOld = infoPtr->himlSmall;
|
himlOld = infoPtr->himlSmall;
|
||||||
infoPtr->himlSmall = himl;
|
infoPtr->himlSmall = himl;
|
||||||
if (uView != LVS_ICON) update_icon_size(himl, TRUE, &infoPtr->iconSize);
|
if (uView != LVS_ICON) set_icon_size(&infoPtr->iconSize, himl, TRUE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LVSIL_STATE:
|
case LVSIL_STATE:
|
||||||
himlOld = infoPtr->himlState;
|
himlOld = infoPtr->himlState;
|
||||||
infoPtr->himlState = himl;
|
infoPtr->himlState = himl;
|
||||||
update_icon_size(himl, TRUE, &infoPtr->iconStateSize);
|
set_icon_size(&infoPtr->iconStateSize, himl, TRUE);
|
||||||
ImageList_SetBkColor(infoPtr->himlState, CLR_NONE);
|
ImageList_SetBkColor(infoPtr->himlState, CLR_NONE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -6892,6 +6892,7 @@ static LRESULT LISTVIEW_Create(HWND hwnd, LPCREATESTRUCTW lpcs)
|
||||||
infoPtr->iconSpacing.cx = GetSystemMetrics(SM_CXICONSPACING);
|
infoPtr->iconSpacing.cx = GetSystemMetrics(SM_CXICONSPACING);
|
||||||
infoPtr->iconSpacing.cy = GetSystemMetrics(SM_CYICONSPACING);
|
infoPtr->iconSpacing.cy = GetSystemMetrics(SM_CYICONSPACING);
|
||||||
infoPtr->nEditLabelItem = -1;
|
infoPtr->nEditLabelItem = -1;
|
||||||
|
infoPtr->dwHoverTime = -1; /* default system hover time */
|
||||||
|
|
||||||
/* get default font (icon title) */
|
/* get default font (icon title) */
|
||||||
SystemParametersInfoW(SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
|
SystemParametersInfoW(SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
|
||||||
|
@ -6914,14 +6915,21 @@ static LRESULT LISTVIEW_Create(HWND hwnd, LPCREATESTRUCTW lpcs)
|
||||||
/* allocate memory for the selection ranges */
|
/* allocate memory for the selection ranges */
|
||||||
if (!(infoPtr->selectionRanges = ranges_create(10))) return -1;
|
if (!(infoPtr->selectionRanges = ranges_create(10))) return -1;
|
||||||
|
|
||||||
|
/* allocate memory for the data structure */
|
||||||
|
/* FIXME: what if we fail? */
|
||||||
|
infoPtr->hdpaItems = DPA_Create(10);
|
||||||
|
infoPtr->hdpaPosX = DPA_Create(10);
|
||||||
|
infoPtr->hdpaPosY = DPA_Create(10);
|
||||||
infoPtr->hdpaColumns = DPA_Create(10);
|
infoPtr->hdpaColumns = DPA_Create(10);
|
||||||
|
|
||||||
if (uView == LVS_ICON)
|
/* initialize the icon sizes */
|
||||||
{
|
set_icon_size(&infoPtr->iconSize, infoPtr->himlNormal, uView != LVS_ICON);
|
||||||
infoPtr->iconSize.cx = GetSystemMetrics(SM_CXICON);
|
set_icon_size(&infoPtr->iconStateSize, infoPtr->himlState, TRUE);
|
||||||
infoPtr->iconSize.cy = GetSystemMetrics(SM_CYICON);
|
|
||||||
}
|
/* init item size to avoid division by 0 */
|
||||||
else if (uView == LVS_REPORT)
|
LISTVIEW_UpdateItemSize (infoPtr);
|
||||||
|
|
||||||
|
if (uView == LVS_REPORT)
|
||||||
{
|
{
|
||||||
if (!(LVS_NOCOLUMNHEADER & lpcs->style))
|
if (!(LVS_NOCOLUMNHEADER & lpcs->style))
|
||||||
{
|
{
|
||||||
|
@ -6933,27 +6941,7 @@ static LRESULT LISTVIEW_Create(HWND hwnd, LPCREATESTRUCTW lpcs)
|
||||||
SetWindowLongW(infoPtr->hwndHeader, GWL_STYLE,
|
SetWindowLongW(infoPtr->hwndHeader, GWL_STYLE,
|
||||||
GetWindowLongW(infoPtr->hwndHeader, GWL_STYLE) | HDS_HIDDEN);
|
GetWindowLongW(infoPtr->hwndHeader, GWL_STYLE) | HDS_HIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
infoPtr->iconSize.cx = GetSystemMetrics(SM_CXSMICON);
|
|
||||||
infoPtr->iconSize.cy = GetSystemMetrics(SM_CYSMICON);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
infoPtr->iconSize.cx = GetSystemMetrics(SM_CXSMICON);
|
|
||||||
infoPtr->iconSize.cy = GetSystemMetrics(SM_CYSMICON);
|
|
||||||
}
|
|
||||||
|
|
||||||
infoPtr->iconStateSize.cx = GetSystemMetrics(SM_CXSMICON);
|
|
||||||
infoPtr->iconStateSize.cy = GetSystemMetrics(SM_CYSMICON);
|
|
||||||
|
|
||||||
/* allocate memory for the data structure */
|
|
||||||
infoPtr->hdpaItems = DPA_Create(10);
|
|
||||||
infoPtr->hdpaPosX = DPA_Create(10);
|
|
||||||
infoPtr->hdpaPosY = DPA_Create(10);
|
|
||||||
|
|
||||||
/* initialize the hover time to -1(indicating the default system hover time) */
|
|
||||||
infoPtr->dwHoverTime = -1;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -8102,7 +8090,7 @@ static INT LISTVIEW_StyleChanged(LISTVIEW_INFO *infoPtr, WPARAM wStyleType,
|
||||||
SetRectEmpty(&infoPtr->rcFocus);
|
SetRectEmpty(&infoPtr->rcFocus);
|
||||||
|
|
||||||
himl = (uNewView == LVS_ICON ? infoPtr->himlNormal : infoPtr->himlSmall);
|
himl = (uNewView == LVS_ICON ? infoPtr->himlNormal : infoPtr->himlSmall);
|
||||||
update_icon_size(himl, uNewView != LVS_ICON, &infoPtr->iconSize);
|
set_icon_size(&infoPtr->iconSize, himl, uNewView != LVS_ICON);
|
||||||
|
|
||||||
if (uNewView == LVS_ICON)
|
if (uNewView == LVS_ICON)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue