Store the entire format bitmap in the column info.

Rewrite GetColumnT to take advantage of that.
Related cleanups, and simplifications.
This commit is contained in:
Dimitrie O. Paun 2002-10-19 19:25:41 +00:00 committed by Alexandre Julliard
parent 569de03864
commit 0613b7212a
1 changed files with 30 additions and 70 deletions

View File

@ -79,8 +79,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(listview);
typedef struct tagCOLUMN_INFO typedef struct tagCOLUMN_INFO
{ {
RECT rcHeader; /* tracks the header's rectangle */ RECT rcHeader; /* tracks the header's rectangle */
UINT align; /* one of DT_{LEFT,CENTER,RIGHT} */ int fmt; /* same as LVCOLUMN.fmt */
BOOL hasImage; /* on/off switch for column images */
} COLUMN_INFO; } COLUMN_INFO;
typedef struct tagITEMHDR typedef struct tagITEMHDR
@ -303,7 +302,6 @@ static LRESULT LISTVIEW_GetStringWidthT(LISTVIEW_INFO *, LPCWSTR, BOOL);
static BOOL LISTVIEW_KeySelection(LISTVIEW_INFO *, INT); static BOOL LISTVIEW_KeySelection(LISTVIEW_INFO *, INT);
static LRESULT LISTVIEW_GetItemState(LISTVIEW_INFO *, INT, UINT); static LRESULT LISTVIEW_GetItemState(LISTVIEW_INFO *, INT, UINT);
static LRESULT LISTVIEW_SetItemState(LISTVIEW_INFO *, INT, LPLVITEMW); static LRESULT LISTVIEW_SetItemState(LISTVIEW_INFO *, INT, LPLVITEMW);
static LRESULT LISTVIEW_GetColumnT(LISTVIEW_INFO *, INT, LPLVCOLUMNW, BOOL);
static LRESULT LISTVIEW_VScroll(LISTVIEW_INFO *, INT, INT, HWND); static LRESULT LISTVIEW_VScroll(LISTVIEW_INFO *, INT, INT, HWND);
static LRESULT LISTVIEW_HScroll(LISTVIEW_INFO *, INT, INT, HWND); static LRESULT LISTVIEW_HScroll(LISTVIEW_INFO *, INT, INT, HWND);
static INT LISTVIEW_GetTopIndex(LISTVIEW_INFO *); static INT LISTVIEW_GetTopIndex(LISTVIEW_INFO *);
@ -1734,7 +1732,7 @@ static BOOL LISTVIEW_GetItemMetrics(LISTVIEW_INFO *infoPtr, LVITEMW *lpLVItem,
if (!IsRectEmpty(&State)) Icon.left += IMAGE_PADDING; if (!IsRectEmpty(&State)) Icon.left += IMAGE_PADDING;
Icon.top = Box.top; Icon.top = Box.top;
Icon.right = Icon.left; Icon.right = Icon.left;
if (infoPtr->himlSmall && (!lpColumnInfo || lpColumnInfo->hasImage)) if (infoPtr->himlSmall && (!lpColumnInfo || lpLVItem->iSubItem == 0 || (lpColumnInfo->fmt & LVCFMT_IMAGE)))
Icon.right += infoPtr->iconSize.cx; Icon.right += infoPtr->iconSize.cx;
Icon.bottom = Icon.top + infoPtr->nItemHeight; Icon.bottom = Icon.top + infoPtr->nItemHeight;
} }
@ -3386,7 +3384,12 @@ static BOOL LISTVIEW_DrawItem(LISTVIEW_INFO *infoPtr, HDC hdc, INT nItem, INT nS
else if (nSubItem) else if (nSubItem)
{ {
COLUMN_INFO *lpColumnInfo = DPA_GetPtr(infoPtr->hdpaColumns, nSubItem); COLUMN_INFO *lpColumnInfo = DPA_GetPtr(infoPtr->hdpaColumns, nSubItem);
if (lpColumnInfo) uFormat |= lpColumnInfo->align; if (lpColumnInfo)
{
if (lpColumnInfo->fmt & LVCFMT_LEFT) uFormat |= DT_LEFT;
else if (lpColumnInfo->fmt & LVCFMT_RIGHT) uFormat |= DT_RIGHT;
else if (lpColumnInfo->fmt & LVCFMT_CENTER) uFormat |= DT_CENTER;
}
} }
if (!(uFormat & (DT_RIGHT | DT_CENTER))) rcLabel.left += 2; if (!(uFormat & (DT_RIGHT | DT_CENTER))) rcLabel.left += 2;
DrawTextW(hdc, lvItem.pszText, -1, &rcLabel, uFormat); DrawTextW(hdc, lvItem.pszText, -1, &rcLabel, uFormat);
@ -4471,7 +4474,7 @@ static LRESULT LISTVIEW_FindItemA(LISTVIEW_INFO *infoPtr, INT nStart,
* *
* PARAMETER(S): * PARAMETER(S):
* [I] infoPtr : valid pointer to the listview structure * [I] infoPtr : valid pointer to the listview structure
* [I] nItem : column index * [I] nColumn : column index
* [IO] lpColumn : column information * [IO] lpColumn : column information
* [I] isW : if TRUE, then lpColumn is a LPLVCOLUMNW * [I] isW : if TRUE, then lpColumn is a LPLVCOLUMNW
* otherwise it is in fact a LPLVCOLUMNA * otherwise it is in fact a LPLVCOLUMNA
@ -4480,77 +4483,45 @@ static LRESULT LISTVIEW_FindItemA(LISTVIEW_INFO *infoPtr, INT nStart,
* SUCCESS : TRUE * SUCCESS : TRUE
* FAILURE : FALSE * FAILURE : FALSE
*/ */
static LRESULT LISTVIEW_GetColumnT(LISTVIEW_INFO *infoPtr, INT nItem, LPLVCOLUMNW lpColumn, BOOL isW) static LRESULT LISTVIEW_GetColumnT(LISTVIEW_INFO *infoPtr, INT nColumn, LPLVCOLUMNW lpColumn, BOOL isW)
{ {
HDITEMW hdi; COLUMN_INFO *lpColumnInfo;
BOOL bResult = FALSE; HDITEMW hdi;
if (lpColumn != NULL) if (!lpColumn || nColumn < 0 || nColumn >= infoPtr->hdpaColumns->nItemCount) return FALSE;
{ if (!(lpColumnInfo = DPA_GetPtr(infoPtr->hdpaColumns, nColumn))) return FALSE;
/* initialize memory */ /* initialize memory */
ZeroMemory(&hdi, sizeof(hdi)); ZeroMemory(&hdi, sizeof(hdi));
if (lpColumn->mask & LVCF_FMT)
hdi.mask |= HDI_FORMAT;
if (lpColumn->mask & LVCF_WIDTH)
hdi.mask |= HDI_WIDTH;
if (lpColumn->mask & LVCF_TEXT) if (lpColumn->mask & LVCF_TEXT)
{ {
hdi.mask |= HDI_TEXT; hdi.mask |= HDI_TEXT;
hdi.cchTextMax = lpColumn->cchTextMax; hdi.pszText = lpColumn->pszText;
hdi.pszText = lpColumn->pszText; hdi.cchTextMax = lpColumn->cchTextMax;
} }
if (lpColumn->mask & LVCF_IMAGE) if (lpColumn->mask & LVCF_IMAGE)
hdi.mask |= HDI_IMAGE; hdi.mask |= HDI_IMAGE;
if (lpColumn->mask & LVCF_ORDER) if (lpColumn->mask & LVCF_ORDER)
hdi.mask |= HDI_ORDER; hdi.mask |= HDI_ORDER;
if (isW) if (!SendMessageW(infoPtr->hwndHeader, isW ? HDM_GETITEMW : HDM_GETITEMA, nColumn, (LPARAM)&hdi)) return FALSE;
bResult = Header_GetItemW(infoPtr->hwndHeader, nItem, &hdi);
else
bResult = Header_GetItemA(infoPtr->hwndHeader, nItem, &hdi);
if (bResult) if (lpColumn->mask & LVCF_FMT)
{ lpColumn->fmt = lpColumnInfo->fmt;
if (lpColumn->mask & LVCF_FMT)
{
lpColumn->fmt = 0;
if (hdi.fmt & HDF_LEFT) if (lpColumn->mask & LVCF_WIDTH)
lpColumn->fmt |= LVCFMT_LEFT; lpColumn->cx = lpColumnInfo->rcHeader.right - lpColumnInfo->rcHeader.left;
else if (hdi.fmt & HDF_RIGHT)
lpColumn->fmt |= LVCFMT_RIGHT;
else if (hdi.fmt & HDF_CENTER)
lpColumn->fmt |= LVCFMT_CENTER;
if (hdi.fmt & HDF_IMAGE) if (lpColumn->mask & LVCF_IMAGE)
lpColumn->fmt |= LVCFMT_COL_HAS_IMAGES; lpColumn->iImage = hdi.iImage;
if (hdi.fmt & HDF_BITMAP_ON_RIGHT) if (lpColumn->mask & LVCF_ORDER)
lpColumn->fmt |= LVCFMT_BITMAP_ON_RIGHT; lpColumn->iOrder = hdi.iOrder;
}
if (lpColumn->mask & LVCF_WIDTH) return TRUE;
lpColumn->cx = hdi.cxy;
if (lpColumn->mask & LVCF_IMAGE)
lpColumn->iImage = hdi.iImage;
if (lpColumn->mask & LVCF_ORDER)
lpColumn->iOrder = hdi.iOrder;
TRACE("(col=%d, lpColumn=%s, isW=%d)\n",
nItem, debuglvcolumn_t(lpColumn, isW), isW);
}
}
return bResult;
} }
@ -5961,18 +5932,7 @@ static BOOL column_fill_info(LISTVIEW_INFO *infoPtr, COLUMN_INFO *lpColumnInfo,
if (!Header_GetItemRect(infoPtr->hwndHeader, nColumn, &rcCol)) return FALSE; if (!Header_GetItemRect(infoPtr->hwndHeader, nColumn, &rcCol)) return FALSE;
lpColumnInfo->rcHeader = rcCol; lpColumnInfo->rcHeader = rcCol;
if (lpColumn->mask & LVCF_FMT) if (lpColumn->mask & LVCF_FMT)
{ lpColumnInfo->fmt = lpColumn->fmt;
if (nColumn == 0 || lpColumn->fmt & LVCFMT_LEFT) lpColumnInfo->align = DT_LEFT;
else if (lpColumn->fmt & LVCFMT_RIGHT) lpColumnInfo->align = DT_RIGHT;
else if (lpColumn->fmt & LVCFMT_CENTER) lpColumnInfo->align = DT_CENTER;
if (nColumn == 0 || (lpColumn->fmt & LVCFMT_IMAGE)) lpColumnInfo->hasImage = TRUE;
}
else
{
lpColumnInfo->align = DT_LEFT;
lpColumnInfo->hasImage = (nColumn == 0);
}
return TRUE; return TRUE;
} }