Module: wine Branch: master Commit: b2486d41c73dbecc8ca05468ff12f47e67d6731d URL: http://source.winehq.org/git/wine.git/?a=commit;h=b2486d41c73dbecc8ca05468ff...
Author: Nikolay Sivov bunglehead@gmail.com Date: Wed Apr 15 09:27:07 2009 -0400
comctl32/listview: Implemented LVM_SORTITEMSEX.
---
dlls/comctl32/listview.c | 43 +++++++++++++++++++++++++++++++++++-------- include/commctrl.h | 4 ++++ 2 files changed, 39 insertions(+), 8 deletions(-)
diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index e73cb16..d594e51 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -137,7 +137,6 @@ * -- LVM_SETINFOTIP * -- LVM_SETTILEWIDTH * -- LVM_SORTGROUPS - * -- LVM_SORTITEMSEX * * Macros: * -- ListView_GetCheckSate, ListView_SetCheckState @@ -148,7 +147,6 @@ * -- ListView_GetTextBkColor * -- ListView_GetUnicodeFormat, ListView_SetUnicodeFormat * -- ListView_GetWorkAreas, ListView_SetWorkAreas - * -- ListView_SortItemsEx * * Functions: * -- LVGroupComparE @@ -422,7 +420,6 @@ static void LISTVIEW_SetSelection(LISTVIEW_INFO *, INT); static void LISTVIEW_UpdateSize(LISTVIEW_INFO *); static HWND LISTVIEW_EditLabelT(LISTVIEW_INFO *, INT, BOOL); static LRESULT LISTVIEW_Command(const LISTVIEW_INFO *, WPARAM, LPARAM); -static BOOL LISTVIEW_SortItems(LISTVIEW_INFO *, PFNLVCOMPARE, LPARAM); static INT LISTVIEW_GetStringWidthT(const LISTVIEW_INFO *, LPCWSTR, BOOL); static BOOL LISTVIEW_KeySelection(LISTVIEW_INFO *, INT, BOOL); static UINT LISTVIEW_GetItemState(const LISTVIEW_INFO *, INT, UINT); @@ -7835,7 +7832,7 @@ static BOOL LISTVIEW_SetUnicodeFormat( LISTVIEW_INFO *infoPtr, BOOL fUnicode)
/*** * DESCRIPTION: - * Callback internally used by LISTVIEW_SortItems() + * Callback internally used by LISTVIEW_SortItems() in response of LVM_SORTITEMS * * PARAMETER(S): * [I] first : pointer to first ITEM_INFO to compare @@ -7859,18 +7856,44 @@ static INT WINAPI LISTVIEW_CallBackCompare(LPVOID first, LPVOID second, LPARAM l
/*** * DESCRIPTION: + * Callback internally used by LISTVIEW_SortItems() in response of LVM_SORTITEMSEX + * + * PARAMETER(S): + * [I] first : pointer to first ITEM_INFO to compare + * [I] second : pointer to second ITEM_INFO to compare + * [I] lParam : HWND of control + * + * RETURN: + * if first comes before second : negative + * if first comes after second : positive + * if first and second are equivalent : zero + */ +static INT WINAPI LISTVIEW_CallBackCompareEx(LPVOID first, LPVOID second, LPARAM lParam) +{ + LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)lParam; + INT first_idx = DPA_GetPtrIndex( infoPtr->hdpaItems, first ); + INT second_idx = DPA_GetPtrIndex( infoPtr->hdpaItems, second ); + + /* Forward the call to the client defined callback */ + return (infoPtr->pfnCompare)( first_idx, second_idx, infoPtr->lParamSort ); +} + +/*** + * DESCRIPTION: * Sorts the listview items. * * PARAMETER(S): * [I] infoPtr : valid pointer to the listview structure * [I] pfnCompare : application-defined value * [I] lParamSort : pointer to comparison callback + * [I] IsEx : TRUE when LVM_SORTITEMSEX used * * RETURN: * SUCCESS : TRUE * FAILURE : FALSE */ -static BOOL LISTVIEW_SortItems(LISTVIEW_INFO *infoPtr, PFNLVCOMPARE pfnCompare, LPARAM lParamSort) +static BOOL LISTVIEW_SortItems(LISTVIEW_INFO *infoPtr, PFNLVCOMPARE pfnCompare, + LPARAM lParamSort, BOOL IsEx) { UINT uView = infoPtr->dwStyle & LVS_TYPEMASK; HDPA hdpaSubItems; @@ -7900,7 +7923,10 @@ static BOOL LISTVIEW_SortItems(LISTVIEW_INFO *infoPtr, PFNLVCOMPARE pfnCompare,
infoPtr->pfnCompare = pfnCompare; infoPtr->lParamSort = lParamSort; - DPA_Sort(infoPtr->hdpaItems, LISTVIEW_CallBackCompare, (LPARAM)infoPtr); + if (IsEx) + DPA_Sort(infoPtr->hdpaItems, LISTVIEW_CallBackCompareEx, (LPARAM)infoPtr); + else + DPA_Sort(infoPtr->hdpaItems, LISTVIEW_CallBackCompare, (LPARAM)infoPtr);
/* restore selection ranges */ for (i=0; i < infoPtr->nItemCount; i++) @@ -10022,9 +10048,10 @@ LISTVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) /* case LVM_SORTGROUPS: */
case LVM_SORTITEMS: - return LISTVIEW_SortItems(infoPtr, (PFNLVCOMPARE)lParam, (LPARAM)wParam); + return LISTVIEW_SortItems(infoPtr, (PFNLVCOMPARE)lParam, (LPARAM)wParam, FALSE);
- /* LVM_SORTITEMSEX: */ + case LVM_SORTITEMSEX: + return LISTVIEW_SortItems(infoPtr, (PFNLVCOMPARE)lParam, (LPARAM)wParam, TRUE);
case LVM_SUBITEMHITTEST: return LISTVIEW_HitTest(infoPtr, (LPLVHITTESTINFO)lParam, TRUE, FALSE); diff --git a/include/commctrl.h b/include/commctrl.h index bebdb27..a3ec513 100644 --- a/include/commctrl.h +++ b/include/commctrl.h @@ -3147,6 +3147,7 @@ static const WCHAR WC_LISTVIEWW[] = { 'S','y','s', #define LVM_SETITEMTEXT WINELIB_NAME_AW(LVM_SETITEMTEXT) #define LVM_SETITEMCOUNT (LVM_FIRST+47) #define LVM_SORTITEMS (LVM_FIRST+48) +#define LVM_SORTITEMSEX (LVM_FIRST+81) #define LVM_SETITEMPOSITION32 (LVM_FIRST+49) #define LVM_GETSELECTEDCOUNT (LVM_FIRST+50) #define LVM_GETITEMSPACING (LVM_FIRST+51) @@ -3772,6 +3773,9 @@ typedef struct NMLVSCROLL
#define ListView_SortItems(hwndLV,_pfnCompare,_lPrm) \ (BOOL)SNDMSGA((hwndLV),LVM_SORTITEMS,(WPARAM)(LPARAM)_lPrm,(LPARAM)(PFNLVCOMPARE)_pfnCompare) +#define ListView_SortItemsEx(hwndLV, _pfnCompare, _lPrm) \ + (BOOL)SNDMSGA((hwndLV), LVM_SORTITEMSEX, (WPARAM)(LPARAM)(_lPrm), (LPARAM)(PFNLVCOMPARE)(_pfnCompare)) + #define ListView_SetItemPosition(hwndLV, i, x, y) \ (BOOL)SNDMSGA((hwndLV),LVM_SETITEMPOSITION,(WPARAM)(INT)(i),MAKELPARAM((x),(y))) #define ListView_GetSelectedCount(hwndLV) \