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

Unify DrawLargeItem with DrawItem.

parent 0b93d5c4
...@@ -1439,9 +1439,9 @@ static BOOL LISTVIEW_GetItemMetrics(LISTVIEW_INFO *infoPtr, LVITEMW *lpLVItem, ...@@ -1439,9 +1439,9 @@ static BOOL LISTVIEW_GetItemMetrics(LISTVIEW_INFO *infoPtr, LVITEMW *lpLVItem,
{ {
if (uView == LVS_ICON) if (uView == LVS_ICON)
{ {
State.left = Box.left - infoPtr->iconStateSize.cx + 10; 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->iconSpacing.cx - infoPtr->iconSize.cx) / 2 + ICON_LR_HALF;
State.top = Box.top + infoPtr->iconSize.cy - infoPtr->iconStateSize.cy + 4; State.top = Box.top + infoPtr->iconSize.cy - infoPtr->iconStateSize.cy + 4;
} }
else else
...@@ -1472,14 +1472,14 @@ static BOOL LISTVIEW_GetItemMetrics(LISTVIEW_INFO *infoPtr, LVITEMW *lpLVItem, ...@@ -1472,14 +1472,14 @@ 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_LR_HALF; Icon.left += (infoPtr->iconSpacing.cx - infoPtr->iconSize.cx) / 2;
Icon.top = Box.top; Icon.top = Box.top + ICON_TOP_PADDING;
Icon.right = Icon.left; Icon.right = Icon.left;
Icon.bottom = Icon.top; Icon.bottom = Icon.top;
if (infoPtr->himlNormal) if (infoPtr->himlNormal)
{ {
Icon.right += infoPtr->iconSize.cx + ICON_LR_PADDING; Icon.right += infoPtr->iconSize.cx;
Icon.bottom += infoPtr->iconSize.cy + ICON_TOP_PADDING; Icon.bottom += infoPtr->iconSize.cy;
} }
} }
else /* LVS_SMALLICON, LVS_LIST or LVS_REPORT */ else /* LVS_SMALLICON, LVS_LIST or LVS_REPORT */
...@@ -3139,16 +3139,19 @@ postpaint: ...@@ -3139,16 +3139,19 @@ postpaint:
*/ */
static BOOL LISTVIEW_DrawItem(LISTVIEW_INFO *infoPtr, HDC hdc, INT nItem, POINT pos, DWORD cdmode) static BOOL LISTVIEW_DrawItem(LISTVIEW_INFO *infoPtr, HDC hdc, INT nItem, POINT pos, DWORD cdmode)
{ {
UINT uFormat, uView = infoPtr->dwStyle & LVS_TYPEMASK;
WCHAR szDispText[DISP_TEXT_SIZE] = { '\0' }; WCHAR szDispText[DISP_TEXT_SIZE] = { '\0' };
DWORD cditemmode = CDRF_DODEFAULT; DWORD cditemmode = CDRF_DODEFAULT;
RECT* lprcFocus, rcSelect, rcBox, rcState, rcIcon, rcLabel; RECT* lprcFocus, rcSelect, rcBox, rcState, rcIcon, rcLabel;
NMLVCUSTOMDRAW nmlvcd; NMLVCUSTOMDRAW nmlvcd;
HIMAGELIST himl;
LVITEMW lvItem; LVITEMW lvItem;
TRACE("(hdc=%x, nItem=%d)\n", hdc, nItem); TRACE("(hdc=%x, nItem=%d)\n", hdc, nItem);
/* get information needed for drawing the item */ /* get information needed for drawing the item */
lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_INDENT; lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
if (uView == LVS_REPORT) lvItem.mask |= LVIF_INDENT;
lvItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED | LVIS_STATEIMAGEMASK; lvItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED | LVIS_STATEIMAGEMASK;
lvItem.iItem = nItem; lvItem.iItem = nItem;
lvItem.iSubItem = 0; lvItem.iSubItem = 0;
...@@ -3160,6 +3163,7 @@ static BOOL LISTVIEW_DrawItem(LISTVIEW_INFO *infoPtr, HDC hdc, INT nItem, POINT ...@@ -3160,6 +3163,7 @@ static BOOL LISTVIEW_DrawItem(LISTVIEW_INFO *infoPtr, HDC hdc, INT nItem, POINT
/* now check if we need to update the focus rectangle */ /* now check if we need to update the focus rectangle */
lprcFocus = infoPtr->bFocus && (lvItem.state & LVIS_FOCUSED) ? &infoPtr->rcFocus : 0; lprcFocus = infoPtr->bFocus && (lvItem.state & LVIS_FOCUSED) ? &infoPtr->rcFocus : 0;
if (!lprcFocus) lvItem.state &= ~LVIS_FOCUSED;
if (!LISTVIEW_GetItemMetrics(infoPtr, &lvItem, &rcBox, NULL, &rcState, &rcIcon, &rcLabel)) return FALSE; if (!LISTVIEW_GetItemMetrics(infoPtr, &lvItem, &rcBox, NULL, &rcState, &rcIcon, &rcLabel)) return FALSE;
OffsetRect(&rcBox, pos.x, pos.y); OffsetRect(&rcBox, pos.x, pos.y);
OffsetRect(&rcState, pos.x, pos.y); OffsetRect(&rcState, pos.x, pos.y);
...@@ -3176,17 +3180,14 @@ static BOOL LISTVIEW_DrawItem(LISTVIEW_INFO *infoPtr, HDC hdc, INT nItem, POINT ...@@ -3176,17 +3180,14 @@ static BOOL LISTVIEW_DrawItem(LISTVIEW_INFO *infoPtr, HDC hdc, INT nItem, POINT
{ {
UINT uStateImage = (lvItem.state & LVIS_STATEIMAGEMASK) >> 12; UINT uStateImage = (lvItem.state & LVIS_STATEIMAGEMASK) >> 12;
if (uStateImage) if (uStateImage)
ImageList_Draw(infoPtr->himlState, uStateImage - 1, hdc, ImageList_Draw(infoPtr->himlState, uStateImage - 1, hdc, rcState.left, rcState.top, ILD_NORMAL);
rcState.left, rcState.top, ILD_NORMAL);
} }
/* small icons */ /* small icons */
if (infoPtr->himlSmall && lvItem.iImage >= 0) himl = (uView == LVS_ICON ? infoPtr->himlNormal : infoPtr->himlSmall);
{ if (himl && lvItem.iImage >= 0)
ImageList_SetBkColor(infoPtr->himlSmall, CLR_NONE); ImageList_Draw(himl, lvItem.iImage, hdc, rcIcon.left, rcIcon.top,
ImageList_Draw(infoPtr->himlSmall, lvItem.iImage, hdc, rcIcon.left, rcIcon.top,
(lvItem.state & LVIS_SELECTED) && (infoPtr->bFocus) ? ILD_SELECTED : ILD_NORMAL); (lvItem.state & LVIS_SELECTED) && (infoPtr->bFocus) ? ILD_SELECTED : ILD_NORMAL);
}
/* Don't bother painting item being edited */ /* Don't bother painting item being edited */
if (infoPtr->bEditing && lprcFocus) goto postpaint; if (infoPtr->bEditing && lprcFocus) goto postpaint;
...@@ -3194,14 +3195,15 @@ static BOOL LISTVIEW_DrawItem(LISTVIEW_INFO *infoPtr, HDC hdc, INT nItem, POINT ...@@ -3194,14 +3195,15 @@ static BOOL LISTVIEW_DrawItem(LISTVIEW_INFO *infoPtr, HDC hdc, INT nItem, POINT
select_text_attr(infoPtr, hdc, &nmlvcd); select_text_attr(infoPtr, hdc, &nmlvcd);
rcSelect = rcLabel; rcSelect = rcLabel;
if ((infoPtr->dwStyle & LVS_TYPEMASK) == LVS_REPORT && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT)) if (uView == LVS_REPORT && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT))
rcSelect.right = rcBox.right; rcSelect.right = rcBox.right;
if (lvItem.state & LVIS_SELECTED) if (lvItem.state & LVIS_SELECTED)
ExtTextOutW(hdc, rcSelect.left, rcSelect.top, ETO_OPAQUE, &rcSelect, 0, 0, 0); ExtTextOutW(hdc, rcSelect.left, rcSelect.top, ETO_OPAQUE, &rcSelect, 0, 0, 0);
if(lprcFocus) *lprcFocus = rcSelect; if(lprcFocus) *lprcFocus = rcSelect;
DrawTextW(hdc, lvItem.pszText, -1, &rcLabel, LV_SL_DT_FLAGS | DT_CENTER); uFormat = (uView == LVS_ICON ? (lprcFocus ? LV_FL_DT_FLAGS : LV_ML_DT_FLAGS) : LV_SL_DT_FLAGS | DT_CENTER);
DrawTextW(hdc, lvItem.pszText, -1, &rcLabel, uFormat);
postpaint: postpaint:
if (cditemmode & CDRF_NOTIFYPOSTPAINT) if (cditemmode & CDRF_NOTIFYPOSTPAINT)
...@@ -3211,112 +3213,6 @@ postpaint: ...@@ -3211,112 +3213,6 @@ postpaint:
/*** /***
* DESCRIPTION: * DESCRIPTION:
* Draws an item when in large icon display mode.
*
* PARAMETER(S):
* [I] infoPtr : valid pointer to the listview structure
* [I] hdc : device context handle
* [I] nItem : item index
* [I] pos : item position in client coordinates
* [I] cdmode : custom draw mode
*
* RETURN:
* Success: TRUE
* Failure: FALSE
*/
static BOOL LISTVIEW_DrawLargeItem(LISTVIEW_INFO *infoPtr, HDC hdc, INT nItem, POINT pos, DWORD cdmode)
{
WCHAR szDispText[DISP_TEXT_SIZE] = { '\0' };
DWORD cditemmode = CDRF_DODEFAULT;
RECT rcBox, rcState, rcIcon, rcLabel, *lprcFocus;
NMLVCUSTOMDRAW nmlvcd;
LVITEMW lvItem;
UINT uFormat;
TRACE("(hdc=%x, nItem=%d)\n", hdc, nItem);
/* get information needed for drawing the item */
lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
lvItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED | LVIS_STATEIMAGEMASK;
lvItem.iItem = nItem;
lvItem.iSubItem = 0;
lvItem.pszText = szDispText;
lvItem.cchTextMax = DISP_TEXT_SIZE;
if (!LISTVIEW_GetItemW(infoPtr, &lvItem)) return FALSE;
TRACE(" lvItem=%s\n", debuglvitem_t(&lvItem, TRUE));
/* now check if we need to update the focus rectangle */
lprcFocus = infoPtr->bFocus && (lvItem.state & LVIS_FOCUSED) ? &infoPtr->rcFocus : 0;
if (!lprcFocus) lvItem.state &= ~LVIS_FOCUSED;
if (!LISTVIEW_GetItemMetrics(infoPtr, &lvItem, &rcBox, NULL, &rcState, &rcIcon, &rcLabel)) return FALSE;
OffsetRect(&rcBox, pos.x, pos.y);
OffsetRect(&rcState, pos.x, pos.y);
OffsetRect(&rcIcon, pos.x, pos.y);
OffsetRect(&rcLabel, pos.x, pos.y);
customdraw_fill(&nmlvcd, infoPtr, hdc, &rcBox, &lvItem);
if (cdmode & CDRF_NOTIFYITEMDRAW)
cditemmode = notify_customdraw (infoPtr, CDDS_ITEMPREPAINT, &nmlvcd);
if (cditemmode & CDRF_SKIPDEFAULT) goto postpaint;
/* Set the item to the boundary box for now */
TRACE("rcIcon=%s, rcLabel=%s\n", debugrect(&rcIcon), debugrect(&rcLabel));
/* state icons */
if (infoPtr->himlState)
{
UINT uStateImage = (lvItem.state & LVIS_STATEIMAGEMASK) >> 12;
if (uStateImage > 0)
ImageList_Draw(infoPtr->himlState, uStateImage - 1, hdc, rcState.left, rcState.top, ILD_NORMAL);
}
/* draw the icon */
if (infoPtr->himlNormal && lvItem.iImage >=0)
ImageList_Draw (infoPtr->himlNormal, lvItem.iImage, hdc,
rcIcon.left + ICON_LR_HALF, rcIcon.top + ICON_TOP_PADDING,
(lvItem.state & LVIS_SELECTED) ? ILD_SELECTED : ILD_NORMAL);
/* Draw the text below the icon */
/* Don't bother painting item being edited */
if ((infoPtr->bEditing && lprcFocus) || !lvItem.pszText || !lstrlenW(lvItem.pszText))
{
if(lprcFocus) SetRectEmpty(lprcFocus);
goto postpaint;
}
select_text_attr(infoPtr, hdc, &nmlvcd);
uFormat = lprcFocus ? LV_FL_DT_FLAGS : LV_ML_DT_FLAGS;
/* draw label */
/* I am sure of most of the uFormat values. However I am not sure about
* whether we need or do not need the following:
* DT_EXTERNALLEADING, DT_INTERNAL, DT_CALCRECT, DT_NOFULLWIDTHCHARBREAK,
* DT_PATH_ELLIPSIS, DT_RTLREADING,
* We certainly do not need
* DT_BOTTOM, DT_VCENTER, DT_MODIFYSTRING, DT_LEFT, DT_RIGHT, DT_PREFIXONLY,
* DT_SINGLELINE, DT_TABSTOP, DT_EXPANDTABS
*/
if (lvItem.state & LVIS_SELECTED)
ExtTextOutW(hdc, rcLabel.left, rcLabel.top, ETO_OPAQUE, &rcLabel, 0, 0, 0);
DrawTextW (hdc, lvItem.pszText, -1, &rcLabel, uFormat);
if(lprcFocus) *lprcFocus = rcLabel;
postpaint:
if (cditemmode & CDRF_NOTIFYPOSTPAINT)
notify_customdraw(infoPtr, CDDS_ITEMPOSTPAINT, &nmlvcd);
return TRUE;
}
/***
* DESCRIPTION:
* Draws listview items when in owner draw mode. * Draws listview items when in owner draw mode.
* *
* PARAMETER(S): * PARAMETER(S):
...@@ -3554,7 +3450,7 @@ static void LISTVIEW_RefreshIcon(LISTVIEW_INFO *infoPtr, HDC hdc, DWORD cdmode) ...@@ -3554,7 +3450,7 @@ static void LISTVIEW_RefreshIcon(LISTVIEW_INFO *infoPtr, HDC hdc, DWORD cdmode)
if (!LISTVIEW_GetItemListOrigin(infoPtr, i.nItem, &Position)) continue; if (!LISTVIEW_GetItemListOrigin(infoPtr, i.nItem, &Position)) continue;
Position.x += Origin.x; Position.x += Origin.x;
Position.y += Origin.y; Position.y += Origin.y;
LISTVIEW_DrawLargeItem(infoPtr, hdc, i.nItem, Position, cdmode); LISTVIEW_DrawItem(infoPtr, hdc, i.nItem, Position, cdmode);
} }
iterator_destroy(&i); iterator_destroy(&i);
...@@ -3566,7 +3462,7 @@ static void LISTVIEW_RefreshIcon(LISTVIEW_INFO *infoPtr, HDC hdc, DWORD cdmode) ...@@ -3566,7 +3462,7 @@ static void LISTVIEW_RefreshIcon(LISTVIEW_INFO *infoPtr, HDC hdc, DWORD cdmode)
{ {
Position.x += Origin.x; Position.x += Origin.x;
Position.y += Origin.y; Position.y += Origin.y;
LISTVIEW_DrawLargeItem(infoPtr, hdc, infoPtr->nFocusedItem, Position, cdmode); LISTVIEW_DrawItem(infoPtr, hdc, infoPtr->nFocusedItem, Position, cdmode);
} }
} }
} }
......
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