Listview N5
Dimitrie O. Paun
dpaun at rogers.com
Thu Oct 10 12:49:30 CDT 2002
ChangeLog
Move custom draw notification into the DrawLargeIcon function.
--- dlls/comctl32/listview.c.N4 Thu Oct 10 13:20:49 2002
+++ dlls/comctl32/listview.c Thu Oct 10 13:45:51 2002
@@ -28,6 +28,7 @@
* -- Drawing optimizations.
* -- Hot item handling.
* -- Expand large item in ICON mode when the cursor is flying over the icon or text.
+ * -- Support CustonDraw options for _WIN32_IE >= 0x560 (see NMLVCUSTOMDRAW docs)
*
* Notifications:
* LISTVIEW_Notify : most notifications from children (editbox and header)
@@ -667,22 +668,10 @@
notify_hdr(infoPtr, LVN_ODCACHEHINT, &nmlv.hdr);
}
-static BOOL notify_customdraw (LISTVIEW_INFO *infoPtr, DWORD dwDrawStage, HDC hdc, RECT rc)
+static DWORD notify_customdraw (LISTVIEW_INFO *infoPtr, DWORD dwDrawStage, NMLVCUSTOMDRAW *nmlvcd)
{
- NMLVCUSTOMDRAW nmlvcd;
-
- TRACE("(dwDrawStage=%lx, hdc=%x, rc=?)\n", dwDrawStage, hdc);
-
- nmlvcd.nmcd.dwDrawStage = dwDrawStage;
- nmlvcd.nmcd.hdc = hdc;
- nmlvcd.nmcd.rc = rc;
- nmlvcd.nmcd.dwItemSpec = 0;
- nmlvcd.nmcd.uItemState = 0;
- nmlvcd.nmcd.lItemlParam = 0;
- nmlvcd.clrText = infoPtr->clrText;
- nmlvcd.clrTextBk = infoPtr->clrBk;
-
- return (BOOL)notify_hdr(infoPtr, NM_CUSTOMDRAW, &nmlvcd.nmcd.hdr);
+ nmlvcd->nmcd.dwDrawStage = dwDrawStage;
+ return notify_hdr(infoPtr, NM_CUSTOMDRAW, &nmlvcd->nmcd.hdr);
}
/* FIXME: we should inline this where it's called somehow
@@ -3215,9 +3204,10 @@
{
WCHAR szDispText[DISP_TEXT_SIZE] = { '\0' };
DWORD cditemmode = CDRF_DODEFAULT;
- RECT rcIcon, rcLabel, *lprcFocus;
+ RECT rcBounds, rcIcon, rcLabel, *lprcFocus;
+ NMLVCUSTOMDRAW nmlvcd;
LVITEMW lvItem;
- UINT uFormat;
+ UINT uFormat, uItemState;
TEXTATTR ta;
TRACE("(hdc=%x, nItem=%d)\n", hdc, nItem);
@@ -3235,12 +3225,30 @@
/* now check if we need to update the focus rectangle */
lprcFocus = infoPtr->bFocus && (lvItem.state & LVIS_FOCUSED) ? &infoPtr->rcFocus : 0;
- if (!LISTVIEW_GetItemMeasures(infoPtr, nItem, NULL, NULL, &rcIcon, &rcLabel)) return;
+ if (!LISTVIEW_GetItemMeasures(infoPtr, nItem, NULL, &rcBounds, &rcIcon, &rcLabel)) return;
+
+ uItemState = 0;
+ if (lvItem.state & LVIS_SELECTED) uItemState |= CDIS_SELECTED;
+ if (lvItem.state & LVIS_FOCUSED) uItemState |= CDIS_FOCUS;
+ if (nItem == infoPtr->nHotItem) uItemState |= CDIS_HOT;
+
+ ZeroMemory(&nmlvcd, sizeof(nmlvcd));
+ nmlvcd.nmcd.hdc = hdc;
+ nmlvcd.nmcd.rc = rcBounds;
+ nmlvcd.nmcd.dwItemSpec = nItem;
+ nmlvcd.nmcd.uItemState = uItemState;
+ nmlvcd.nmcd.lItemlParam = lvItem.lParam;
+ nmlvcd.clrText = infoPtr->clrText;
+ nmlvcd.clrTextBk = infoPtr->clrBk;
if (cdmode & CDRF_NOTIFYITEMDRAW)
- cditemmode = notify_customdrawitem (infoPtr, hdc, nItem, 0, CDDS_ITEMPREPAINT);
+ cditemmode = notify_customdraw (infoPtr, CDDS_ITEMPREPAINT, &nmlvcd);
if (cditemmode & CDRF_SKIPDEFAULT) goto postpaint;
+ /* FIXME: pass the mnlvcd to select text attr */
+ infoPtr->clrText = nmlvcd.clrText;
+ infoPtr->clrBk = nmlvcd.clrTextBk;
+
/* Set the item to the boundary box for now */
TRACE("rcIcon=%s, rcLabel=%s\n", debugrect(&rcIcon), debugrect(&rcLabel));
@@ -3295,7 +3303,7 @@
postpaint:
if (cditemmode & CDRF_NOTIFYPOSTPAINT)
- notify_customdrawitem(infoPtr, hdc, nItem, 0, CDDS_ITEMPOSTPAINT);
+ notify_customdraw(infoPtr, CDDS_ITEMPOSTPAINT, &nmlvcd);
}
/***
@@ -3611,25 +3619,34 @@
static void LISTVIEW_Refresh(LISTVIEW_INFO *infoPtr, HDC hdc)
{
UINT uView = LISTVIEW_GetType(infoPtr);
+ NMLVCUSTOMDRAW nmlvcd;
HFONT hOldFont;
DWORD cdmode;
RECT rcClient;
LISTVIEW_DUMP(infoPtr);
+ infoPtr->bIsDrawing = TRUE;
+
GetClientRect(infoPtr->hwndSelf, &rcClient);
-
- cdmode = notify_customdraw(infoPtr, CDDS_PREPAINT, hdc, rcClient);
- if (cdmode == CDRF_SKIPDEFAULT) return;
+
+ /* select font */
+ hOldFont = SelectObject(hdc, infoPtr->hFont);
- infoPtr->bIsDrawing = TRUE;
+ ZeroMemory(&nmlvcd, sizeof(nmlvcd));
+ nmlvcd.nmcd.hdc = hdc;
+ nmlvcd.nmcd.rc = rcClient;
+ nmlvcd.nmcd.dwItemSpec = 0;
+ nmlvcd.nmcd.uItemState = 0;
+ nmlvcd.nmcd.lItemlParam = 0;
+ nmlvcd.clrText = infoPtr->clrText;
+ nmlvcd.clrTextBk = infoPtr->clrBk;
+ cdmode = notify_customdraw(infoPtr, CDDS_PREPAINT, &nmlvcd);
+ if (cdmode & CDRF_SKIPDEFAULT) goto enddraw;
/* nothing to draw */
if(infoPtr->nItemCount == 0) goto enddraw;
- /* select font */
- hOldFont = SelectObject(hdc, infoPtr->hFont);
-
if (infoPtr->dwStyle & LVS_OWNERDRAWFIXED)
LISTVIEW_RefreshOwnerDraw(infoPtr, hdc);
else if (uView == LVS_ICON)
@@ -3643,12 +3660,12 @@
if (infoPtr->bFocus && !(infoPtr->dwStyle & LVS_OWNERDRAWFIXED))
DrawFocusRect(hdc, &infoPtr->rcFocus);
- /* unselect objects */
- SelectObject(hdc, hOldFont);
-
enddraw:
if (cdmode & CDRF_NOTIFYPOSTPAINT)
- notify_customdraw(infoPtr, CDDS_POSTPAINT, hdc, rcClient);
+ notify_customdraw(infoPtr, CDDS_POSTPAINT, &nmlvcd);
+
+ /* unselect objects */
+ SelectObject(hdc, hOldFont);
infoPtr->bIsDrawing = FALSE;
}
More information about the wine-patches
mailing list