Commit 216ca479 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/listview: Fix select rectangle calculation for empty text items.

parent 05c4d0a8
...@@ -360,6 +360,8 @@ typedef struct tagLISTVIEW_INFO ...@@ -360,6 +360,8 @@ typedef struct tagLISTVIEW_INFO
/* default label width for items in list and small icon display modes */ /* default label width for items in list and small icon display modes */
#define DEFAULT_LABEL_WIDTH 40 #define DEFAULT_LABEL_WIDTH 40
/* maximum select rectangle width for empty text item in LV_VIEW_DETAILS */
#define MAX_EMPTYTEXT_SELECT_WIDTH 80
/* default column width for items in list display mode */ /* default column width for items in list display mode */
#define DEFAULT_COLUMN_WIDTH 128 #define DEFAULT_COLUMN_WIDTH 128
...@@ -2235,7 +2237,9 @@ static void LISTVIEW_GetItemMetrics(const LISTVIEW_INFO *infoPtr, const LVITEMW ...@@ -2235,7 +2237,9 @@ static void LISTVIEW_GetItemMetrics(const LISTVIEW_INFO *infoPtr, const LVITEMW
DrawTextW (hdc, lpLVItem->pszText, -1, &rcText, uFormat | DT_CALCRECT); DrawTextW (hdc, lpLVItem->pszText, -1, &rcText, uFormat | DT_CALCRECT);
if (rcText.right != rcText.left)
labelSize.cx = min(rcText.right - rcText.left + TRAILING_LABEL_PADDING, infoPtr->nItemWidth); labelSize.cx = min(rcText.right - rcText.left + TRAILING_LABEL_PADDING, infoPtr->nItemWidth);
labelSize.cy = rcText.bottom - rcText.top; labelSize.cy = rcText.bottom - rcText.top;
SelectObject(hdc, hOldFont); SelectObject(hdc, hOldFont);
...@@ -2288,7 +2292,11 @@ calc_label: ...@@ -2288,7 +2292,11 @@ calc_label:
SelectBox.left = Icon.left; SelectBox.left = Icon.left;
SelectBox.top = Box.top; SelectBox.top = Box.top;
SelectBox.bottom = Box.bottom; SelectBox.bottom = Box.bottom;
if (labelSize.cx)
SelectBox.right = min(Label.left + labelSize.cx, Label.right); SelectBox.right = min(Label.left + labelSize.cx, Label.right);
else
SelectBox.right = min(Label.left + MAX_EMPTYTEXT_SELECT_WIDTH, Label.right);
} }
else else
{ {
......
...@@ -3067,7 +3067,7 @@ static void test_getitemrect(void) ...@@ -3067,7 +3067,7 @@ static void test_getitemrect(void)
expect(TRUE, r); expect(TRUE, r);
/* padding, column width */ /* padding, column width */
expect(2, rect.left); expect(2, rect.left);
todo_wine expect(50, rect.right); expect(50, rect.right);
/* try with indentation */ /* try with indentation */
item.mask = LVIF_INDENT; item.mask = LVIF_INDENT;
...@@ -3093,7 +3093,7 @@ static void test_getitemrect(void) ...@@ -3093,7 +3093,7 @@ static void test_getitemrect(void)
expect(TRUE, r); expect(TRUE, r);
/* padding + 1 icon width, column width */ /* padding + 1 icon width, column width */
expect(2 + 16, rect.left); expect(2 + 16, rect.left);
todo_wine expect(50, rect.right); expect(50, rect.right);
/* label bounds */ /* label bounds */
rect.left = LVIR_LABEL; rect.left = LVIR_LABEL;
......
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