comctl32/listview: always use large icon size when calculating icon spacing
Daniel Jelinski
djelinski1 at gmail.com
Mon Feb 4 14:30:08 CST 2013
-------------- next part --------------
From b0d10f40209d01d889ef53783d2a2aa85ffed041 Mon Sep 17 00:00:00 2001
From: Daniel Jelinski <djelinski1 at gmail.com>
Date: Mon, 4 Feb 2013 20:46:30 +0100
Subject: comctl32/listview: always use large icon size when calculating icon
spacing
---
dlls/comctl32/listview.c | 35 ++++++++---------------------------
dlls/comctl32/tests/listview.c | 10 ++++++++++
2 files changed, 18 insertions(+), 27 deletions(-)
diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index cee1154..96863f9 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -8586,18 +8586,18 @@ static DWORD LISTVIEW_SetHoverTime(LISTVIEW_INFO *infoPtr, DWORD dwHoverTime)
*/
static DWORD LISTVIEW_SetIconSpacing(LISTVIEW_INFO *infoPtr, INT cx, INT cy)
{
+ INT iconWidth = 0, iconHeight = 0;
DWORD oldspacing = MAKELONG(infoPtr->iconSpacing.cx, infoPtr->iconSpacing.cy);
TRACE("requested=(%d,%d)\n", cx, cy);
-
- /* this is supported only for LVS_ICON style */
- if (infoPtr->uView != LV_VIEW_ICON) return oldspacing;
-
+
/* set to defaults, if instructed to */
if (cx == -1 && cy == -1)
{
- cx = GetSystemMetrics(SM_CXICONSPACING) - GetSystemMetrics(SM_CXICON) + infoPtr->iconSize.cx;
- cy = GetSystemMetrics(SM_CYICONSPACING) - GetSystemMetrics(SM_CYICON) + infoPtr->iconSize.cy;
+ if (infoPtr->himlNormal)
+ ImageList_GetIconSize(infoPtr->himlNormal, &iconWidth, &iconHeight);
+ cx = GetSystemMetrics(SM_CXICONSPACING) - GetSystemMetrics(SM_CXICON) + iconWidth;
+ cy = GetSystemMetrics(SM_CYICONSPACING) - GetSystemMetrics(SM_CYICON) + iconHeight;
}
/* if 0 then keep width */
if (cx != 0)
@@ -9054,7 +9054,6 @@ static BOOL LISTVIEW_SetUnicodeFormat( LISTVIEW_INFO *infoPtr, BOOL unicode)
*/
static INT LISTVIEW_SetView(LISTVIEW_INFO *infoPtr, DWORD nView)
{
- SIZE oldIconSize = infoPtr->iconSize;
HIMAGELIST himl;
if (infoPtr->uView == nView) return 1;
@@ -9080,14 +9079,6 @@ static INT LISTVIEW_SetView(LISTVIEW_INFO *infoPtr, DWORD nView)
switch (nView)
{
case LV_VIEW_ICON:
- if ((infoPtr->iconSize.cx != oldIconSize.cx) || (infoPtr->iconSize.cy != oldIconSize.cy))
- {
- TRACE("icon old size=(%d,%d), new size=(%d,%d)\n",
- oldIconSize.cx, oldIconSize.cy, infoPtr->iconSize.cx, infoPtr->iconSize.cy);
- LISTVIEW_SetIconSpacing(infoPtr, -1, -1);
- }
- LISTVIEW_Arrange(infoPtr, LVA_DEFAULT);
- break;
case LV_VIEW_SMALLICON:
LISTVIEW_Arrange(infoPtr, LVA_DEFAULT);
break;
@@ -11016,7 +11007,6 @@ static INT LISTVIEW_StyleChanged(LISTVIEW_INFO *infoPtr, WPARAM wStyleType,
if (uNewView != uOldView)
{
- SIZE oldIconSize = infoPtr->iconSize;
HIMAGELIST himl;
SendMessageW(infoPtr->hwndEdit, WM_KILLFOCUS, 0, 0);
@@ -11027,17 +11017,8 @@ static INT LISTVIEW_StyleChanged(LISTVIEW_INFO *infoPtr, WPARAM wStyleType,
himl = (uNewView == LVS_ICON ? infoPtr->himlNormal : infoPtr->himlSmall);
set_icon_size(&infoPtr->iconSize, himl, uNewView != LVS_ICON);
-
- if (uNewView == LVS_ICON)
- {
- if ((infoPtr->iconSize.cx != oldIconSize.cx) || (infoPtr->iconSize.cy != oldIconSize.cy))
- {
- TRACE("icon old size=(%d,%d), new size=(%d,%d)\n",
- oldIconSize.cx, oldIconSize.cy, infoPtr->iconSize.cx, infoPtr->iconSize.cy);
- LISTVIEW_SetIconSpacing(infoPtr, -1, -1);
- }
- }
- else if (uNewView == LVS_REPORT)
+
+ if (uNewView == LVS_REPORT)
{
HDLAYOUT hl;
WINDOWPOS wp;
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index 2347bfa..c46fe42 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -4656,6 +4656,16 @@ static void test_getitemspacing(void)
expect(cx, LOWORD(ret));
expect(cy, HIWORD(ret));
+ /* spacing does not depend on selected view type */
+ ret = SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_NORMAL, (LPARAM)himl40);
+ expect(0, ret);
+
+ ret = SendMessage(hwnd, LVM_GETITEMSPACING, FALSE, 0);
+ /* spacing + icon size returned */
+ expect(cx + 40, LOWORD(ret));
+ expect(cy + 40, HIWORD(ret));
+
+ SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_NORMAL, 0);
ImageList_Destroy(himl40);
DestroyWindow(hwnd);
/* LVS_REPORT */
--
1.7.5.4
More information about the wine-patches
mailing list