Changeset 10448 for trunk/src


Ignore:
Timestamp:
Feb 10, 2004, 4:47:01 PM (22 years ago)
Author:
sandervl
Message:

KSO: synced listview with current wine code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comctl32/listview.c

    r10127 r10448  
    55 * Copyright 1999 Luc Tourangeau
    66 * Copyright 2000 Jason Mawdsley
    7  * Copyright 2001 Codeweavers Inc.
     7 * Copyright 2001 CodeWeavers Inc.
    88 * Copyright 2002 Dimitrie O. Paun
    99 *
     
    2626 * This code was audited for completeness against the documented features
    2727 * of Comctl32.dll version 6.0 on Oct. 21, 2002, by Dimitrie O. Paun.
    28  * 
     28 *
    2929 * Unless otherwise noted, we belive this code to be complete, as per
    3030 * the specification mentioned above.
    3131 * If you discover missing features, or bugs, please note them below.
    32  * 
     32 *
    3333 * TODO:
    3434 *
     
    4242 *   -- Expand large item in ICON mode when the cursor is flying over the icon or text.
    4343 *   -- Support CustonDraw options for _WIN32_IE >= 0x560 (see NMLVCUSTOMDRAW docs.
    44  *   -- in LISTVIEW_AddGroupSelection, se whould send LVN_ODSTATECHANGED 
     44 *   -- in LISTVIEW_AddGroupSelection, se whould send LVN_ODSTATECHANGED
    4545 *   -- LVA_SNAPTOGRID not implemented
    4646 *   -- LISTVIEW_ApproximateViewRect partially implemented
     
    9494 *   -- LVS_EX_UNDERLINECOLD
    9595 *   -- LVS_EX_UNDERLINEHOT
    96  *   
     96 *
    9797 * Notifications:
    98  *   -- LVN_BEGINDRAG, LVN_BEGINRDRAG
     98 *   -- LVN_BEGINRDRAG
    9999 *   -- LVN_BEGINSCROLL, LVN_ENDSCROLL
    100100 *   -- LVN_GETINFOTIP
     
    235235  SHORT notifyFormat;
    236236  RECT rcList;                 /* This rectangle is really the window
    237                                 * client rectangle possibly reduced by the 
    238                                 * horizontal scroll bar and/or header - see 
     237                                * client rectangle possibly reduced by the
     238                                * horizontal scroll bar and/or header - see
    239239                                * LISTVIEW_UpdateSize. This rectangle offset
    240240                                * by the LISTVIEW_GetOrigin value is in
     
    273273  HWND hwndToolTip;
    274274
     275  /* __WIN32OS2__: this might be sligtly fishy as the merge with wine is only partially done ... */
     276  DWORD cditemmode;             /* Keep the custom draw flags for an item/row */
     277
    275278  DWORD lastKeyPressTimestamp;
    276279  WPARAM charCode;
     
    278281  WCHAR szSearchParam[ MAX_PATH ];
    279282  BOOL bIsDrawing;
    280 #ifdef __WIN32OS2__
    281   BOOL              bDragInProcess;
    282 #endif
    283283} LISTVIEW_INFO;
    284284
     
    460460{
    461461    BOOL bResult = TRUE;
    462    
     462
    463463    if (src == LPSTR_TEXTCALLBACKW)
    464464    {
     
    491491        textfreeT(bw, isW);
    492492        return r;
    493     }      
    494            
     493    }   
     494       
    495495    return 1;
    496496}
    497    
     497
    498498static inline int lstrncmpiW(LPCWSTR s1, LPCWSTR s2, int n)
    499499{
     
    535535}
    536536
     537#ifdef __WIN32OS2__
     538static char* debug_getbuf(void)
     539#else
    537540static char* debug_getbuf()
     541#endif
    538542{
    539543    static int index = 0;
     
    544548static inline char* debugrange(const RANGE *lprng)
    545549{
    546     if (lprng) 
     550    if (lprng)
    547551    {
    548552        char* buf = debug_getbuf();
     
    554558static inline char* debugpoint(const POINT *lppt)
    555559{
    556     if (lppt) 
     560    if (lppt)
    557561    {
    558562        char* buf = debug_getbuf();
     
    564568static inline char* debugrect(const RECT *rect)
    565569{
    566     if (rect) 
     570    if (rect)
    567571    {
    568572        char* buf = debug_getbuf();
     
    577581    char* buf = debug_getbuf(), *text = buf;
    578582    int len, size = DEBUG_BUFFER_SIZE;
    579    
     583
    580584    if (pScrollInfo == NULL) return "(null)";
    581585    len = snprintf(buf, size, "{cbSize=%d, ", pScrollInfo->cbSize);
     
    603607    if (buf - text > 2) { buf[-2] = '}'; buf[-1] = 0; }
    604608    return text;
    605 } 
     609}
    606610
    607611static char* debugnmlistview(const NMLISTVIEW *plvnm)
     
    622626    char* buf = debug_getbuf(), *text = buf;
    623627    int len, size = DEBUG_BUFFER_SIZE;
    624    
     628
    625629    if (lpLVItem == NULL) return "(null)";
    626630    len = snprintf(buf, size, "{iItem=%d, iSubItem=%d, ", lpLVItem->iItem, lpLVItem->iSubItem);
     
    658662    char* buf = debug_getbuf(), *text = buf;
    659663    int len, size = DEBUG_BUFFER_SIZE;
    660    
     664
    661665    if (lpColumn == NULL) return "(null)";
    662666    len = snprintf(buf, size, "{");
     
    696700static char* debuglvhittestinfo(const LVHITTESTINFO *lpht)
    697701{
    698     if (lpht) 
     702    if (lpht)
    699703    {
    700704        char* buf = debug_getbuf();
     
    728732{
    729733    LRESULT result;
    730    
     734
    731735    TRACE("(code=%d)\n", code);
    732736
     
    763767    NMLISTVIEW nmlv;
    764768    LVITEMW item;
    765    
    766     TRACE("code=%d, lvht=%s\n", code, debuglvhittestinfo(lvht)); 
     769
     770    TRACE("code=%d, lvht=%s\n", code, debuglvhittestinfo(lvht));
    767771    ZeroMemory(&nmlv, sizeof(nmlv));
    768772    nmlv.iItem = lvht->iItem;
     
    780784    NMLISTVIEW nmlv;
    781785    LVITEMW item;
    782    
     786
    783787    ZeroMemory(&nmlv, sizeof (NMLISTVIEW));
    784788    nmlv.iItem = nItem;
     
    869873}
    870874
    871 static void customdraw_fill(NMLVCUSTOMDRAW *lpnmlvcd, LISTVIEW_INFO *infoPtr, HDC hdc, 
     875static void customdraw_fill(NMLVCUSTOMDRAW *lpnmlvcd, LISTVIEW_INFO *infoPtr, HDC hdc,
    872876                            const RECT *rcBounds, const LVITEMW *lplvItem)
    873877{
     
    892896
    893897    lpnmlvcd->nmcd.dwDrawStage = dwDrawStage;
    894     if (isForItem) lpnmlvcd->nmcd.dwDrawStage |= CDDS_ITEM; 
     898    if (isForItem) lpnmlvcd->nmcd.dwDrawStage |= CDDS_ITEM;
    895899    if (lpnmlvcd->iSubItem) lpnmlvcd->nmcd.dwDrawStage |= CDDS_SUBITEM;
    896900    if (isForItem) lpnmlvcd->nmcd.dwItemSpec--;
     
    984988 * after it's done with it, as the creation of the iterator may
    985989 * allocate memory, which thus needs to be freed.
    986  * 
     990 *
    987991 * You can iterate both forwards, and backwards through the list,
    988992 * by using iterator_next or iterator_prev respectively.
    989  * 
     993 *
    990994 * Lower numbered items are draw on top of higher number items in
    991995 * LVS_ICON, and LVS_SMALLICON (which are the only modes where
     
    10111015 * LVS_ICON, and LVS_SMALLICON mode to handle the focused item,
    10121016 * which needs to be first, as it may overlap other items.
    1013  *           
     1017 *
    10141018 * The code is a bit messy because we have:
    10151019 *   - a special item to deal with
     
    11611165    RECT frame = *lprc, rcItem, rcTemp;
    11621166    POINT Origin;
    1163    
     1167
    11641168    /* in case we fail, we want to return an empty iterator */
    11651169    if (!iterator_empty(i)) return FALSE;
     
    12461250    RECT rcItem, rcClip;
    12471251    INT rgntype;
    1248    
     1252
    12491253    rgntype = GetClipBox(hdc, &rcClip);
    12501254    if (rgntype == NULLREGION) return iterator_empty(i);
     
    12581262        if (!RectVisible(hdc, &rcItem)) i->nSpecial = -1;
    12591263    }
    1260    
     1264
    12611265    /* if we can't deal with the region, we'll just go with the simple range */
    12621266    LISTVIEW_GetOrigin(infoPtr, &Origin);
     
    12861290    /* the iterator should restart on the next iterator_next */
    12871291    TRACE("done\n");
    1288    
     1292
    12891293    return TRUE;
    12901294}
     
    13021306{
    13031307    UINT uView = infoPtr->dwStyle & LVS_TYPEMASK;
    1304    
     1308
    13051309    return ((infoPtr->dwStyle & LVS_AUTOARRANGE) || infoPtr->bAutoarrange) &&
    13061310           (uView == LVS_ICON || uView == LVS_SMALLICON);
     
    13371341static inline void LISTVIEW_InvalidateRect(LISTVIEW_INFO *infoPtr, const RECT* rect)
    13381342{
    1339     if(!is_redrawing(infoPtr)) return; 
     1343    if(!is_redrawing(infoPtr)) return;
    13401344    TRACE(" invalidating rect=%s\n", debugrect(rect));
    13411345    InvalidateRect(infoPtr->hwndSelf, rect, TRUE);
     
    13461350    RECT rcBox;
    13471351
    1348     if(!is_redrawing(infoPtr)) return; 
     1352    if(!is_redrawing(infoPtr)) return;
    13491353    LISTVIEW_GetItemBox(infoPtr, nItem, &rcBox);
    13501354    LISTVIEW_InvalidateRect(infoPtr, &rcBox);
     
    13551359    POINT Origin, Position;
    13561360    RECT rcBox;
    1357    
    1358     if(!is_redrawing(infoPtr)) return; 
     1361
     1362    if(!is_redrawing(infoPtr)) return;
    13591363    assert ((infoPtr->dwStyle & LVS_TYPEMASK) == LVS_REPORT);
    13601364    LISTVIEW_GetOrigin(infoPtr, &Origin);
     
    13751379{
    13761380    RECT rcCol;
    1377    
    1378     if(!is_redrawing(infoPtr)) return; 
     1381
     1382    if(!is_redrawing(infoPtr)) return;
    13791383    LISTVIEW_GetHeaderRect(infoPtr, nColumn, &rcCol);
    13801384    rcCol.top = infoPtr->rcList.top;
     
    16271631        if (LISTVIEW_GetViewRect(infoPtr, &rcView)) horzInfo.nMax = rcView.right - rcView.left;
    16281632    }
    1629  
     1633
    16301634    horzInfo.fMask = SIF_RANGE | SIF_PAGE;
    16311635    horzInfo.nMax = max(horzInfo.nMax - 1, 0);
     
    16761680/***
    16771681 * DESCRIPTION:
    1678  * Shows/hides the focus rectangle. 
     1682 * Shows/hides the focus rectangle.
    16791683 *
    16801684 * PARAMETER(S):
     
    16991703        RECT rcBox;
    17001704
    1701         LISTVIEW_GetItemBox(infoPtr, infoPtr->nFocusedItem, &rcBox); 
     1705        LISTVIEW_GetItemBox(infoPtr, infoPtr->nFocusedItem, &rcBox);
    17021706        if ((rcBox.bottom - rcBox.top) > infoPtr->nItemHeight)
    17031707        {
     
    17191723        item.mask = LVIF_PARAM;
    17201724        if (!LISTVIEW_GetItemW(infoPtr, &item)) goto done;
    1721            
    1722         ZeroMemory(&dis, sizeof(dis)); 
     1725       
     1726        ZeroMemory(&dis, sizeof(dis));
    17231727        dis.CtlType = ODT_LISTVIEW;
    17241728        dis.CtlID = GetWindowLongW(infoPtr->hwndSelf, GWL_ID);
     
    17461750static void LISTVIEW_InvalidateSelectedItems(LISTVIEW_INFO *infoPtr)
    17471751{
    1748     ITERATOR i; 
    1749    
    1750     iterator_frameditems(&i, infoPtr, &infoPtr->rcList); 
     1752    ITERATOR i;
     1753
     1754    iterator_frameditems(&i, infoPtr, &infoPtr->rcList);
    17511755    while(iterator_next(&i))
    17521756    {
     
    17571761}
    17581762
    1759            
     1763       
    17601764/***
    17611765 * DESCRIPTION:            [INTERNAL]
     
    17661770 * one ca factor the computation of the Origin before the loop,
    17671771 * and offset the value retured by this function, on every iteration.
    1768  * 
     1772 *
    17691773 * PARAMETER(S):
    17701774 * [I] infoPtr : valid pointer to the listview structure
     
    17981802    }
    17991803}
    1800    
     1804
    18011805/***
    18021806 * DESCRIPTION:            [INTERNAL]
     
    18411845 */
    18421846static void LISTVIEW_GetItemMetrics(LISTVIEW_INFO *infoPtr, const LVITEMW *lpLVItem,
    1843                                     LPRECT lprcBox, LPRECT lprcState, 
     1847                                    LPRECT lprcBox, LPRECT lprcState,
    18441848                                    LPRECT lprcIcon, LPRECT lprcLabel)
    18451849{
     
    18611865    if (doLabel || lprcIcon) doIcon = TRUE;
    18621866    if (doIcon || lprcState) doState = TRUE;
    1863    
     1867
    18641868    /************************************************************/
    18651869    /* compute the box rectangle (it should be cheap to do)     */
     
    18681872        lpColumnInfo = LISTVIEW_GetColumnInfo(infoPtr, lpLVItem->iSubItem);
    18691873
    1870     if (lpLVItem->iSubItem)   
     1874    if (lpLVItem->iSubItem)
    18711875    {
    18721876        Box = lpColumnInfo->rcHeader;
     
    18881892        {
    18891893            State.left = Box.left - infoPtr->iconStateSize.cx - 2;
    1890             if (infoPtr->himlNormal) 
     1894            if (infoPtr->himlNormal)
    18911895                State.left += (infoPtr->nItemWidth - infoPtr->iconSize.cx) / 2;
    18921896            State.top  = Box.top + infoPtr->iconSize.cy - infoPtr->iconStateSize.cy + 4;
     
    18961900            /* we need the ident in report mode, if we don't have it, we fail */
    18971901            State.left = Box.left;
    1898             if (uView == LVS_REPORT) 
     1902            if (uView == LVS_REPORT)
    18991903            {
    19001904                if (lpLVItem->iSubItem == 0)
     
    19261930        {
    19271931            Icon.left   = Box.left;
    1928             if (infoPtr->himlNormal) 
     1932            if (infoPtr->himlNormal)
    19291933                Icon.left += (infoPtr->nItemWidth - infoPtr->iconSize.cx) / 2;
    19301934            Icon.top    = Box.top + ICON_TOP_PADDING;
     
    19851989            rcText.right = infoPtr->nItemWidth - TRAILING_LABEL_PADDING;
    19861990            rcText.bottom = infoPtr->nItemHeight;
    1987             if (uView == LVS_ICON) 
     1991            if (uView == LVS_ICON)
    19881992                rcText.bottom -= ICON_TOP_PADDING + infoPtr->iconSize.cy + ICON_BOTTOM_PADDING;
    19891993
     
    19931997            else
    19941998                uFormat = LV_SL_DT_FLAGS;
    1995            
     1999       
    19962000            DrawTextW (hdc, lpLVItem->pszText, -1, &rcText, uFormat | DT_CALCRECT);
    19972001
     
    20272031            Label.bottom = Label.top + infoPtr->nItemHeight;
    20282032        }
    2029  
     2033
    20302034        if (lprcLabel) *lprcLabel = Label;
    20312035        TRACE("    - label=%s\n", debugrect(&Label));
     
    20982102{
    20992103    INT nListWidth = infoPtr->rcList.right - infoPtr->rcList.left;
    2100    
     2104
    21012105    *lpPos = infoPtr->currIconPos;
    2102    
     2106
    21032107    infoPtr->currIconPos.x += infoPtr->nItemWidth;
    21042108    if (infoPtr->currIconPos.x + infoPtr->nItemWidth <= nListWidth) return;
     
    21082112}
    21092113
    2110    
     2114
    21112115/***
    21122116 * DESCRIPTION:
     
    21242128{
    21252129    INT nListHeight = infoPtr->rcList.bottom - infoPtr->rcList.top;
    2126    
     2130
    21272131    *lpPos = infoPtr->currIconPos;
    2128    
     2132
    21292133    infoPtr->currIconPos.y += infoPtr->nItemHeight;
    21302134    if (infoPtr->currIconPos.y + infoPtr->nItemHeight <= nListHeight) return;
     
    21342138}
    21352139
    2136    
     2140
    21372141/***
    21382142 * DESCRIPTION:
     
    21532157{
    21542158    POINT old;
    2155    
     2159
    21562160    if (!isNew)
    2157     { 
     2161    {
    21582162        old.x = (LONG)DPA_GetPtr(infoPtr->hdpaPosX, nItem);
    21592163        old.y = (LONG)DPA_GetPtr(infoPtr->hdpaPosY, nItem);
    2160    
     2164
    21612165        if (lppt->x == old.x && lppt->y == old.y) return TRUE;
    21622166        LISTVIEW_InvalidateItem(infoPtr, nItem);
     
    21932197
    21942198    if (uView != LVS_ICON && uView != LVS_SMALLICON) return FALSE;
    2195  
     2199
    21962200    TRACE("nAlignCode=%d\n", nAlignCode);
    21972201
     
    22012205        else nAlignCode = LVA_ALIGNTOP;
    22022206    }
    2203    
     2207
    22042208    switch (nAlignCode)
    22052209    {
     
    22092213    default: return FALSE;
    22102214    }
    2211    
     2215
    22122216    infoPtr->bAutoarrange = TRUE;
    22132217    infoPtr->currIconPos.x = infoPtr->currIconPos.y = 0;
     
    22202224    return TRUE;
    22212225}
    2222  
     2226
    22232227/***
    22242228 * DESCRIPTION:
     
    22652269        break;
    22662270       
    2267     case LVS_REPORT:       
     2271    case LVS_REPORT:   
    22682272        lprcView->right = infoPtr->nItemWidth;
    22692273        lprcView->bottom = infoPtr->nItemCount * infoPtr->nItemHeight;
     
    22912295
    22922296    if (!lprcView) return FALSE;
    2293  
     2297
    22942298    LISTVIEW_GetOrigin(infoPtr, &ptOrigin);
    2295     LISTVIEW_GetAreaRect(infoPtr, lprcView); 
    2296     OffsetRect(lprcView, ptOrigin.x, ptOrigin.y); 
     2299    LISTVIEW_GetAreaRect(infoPtr, lprcView);
     2300    OffsetRect(lprcView, ptOrigin.x, ptOrigin.y);
    22972301
    22982302    TRACE("lprcView=%s\n", debugrect(lprcView));
     
    23662370            nItemWidth = max(LISTVIEW_GetLabelWidth(infoPtr, i), nItemWidth);
    23672371
    2368         if (infoPtr->himlSmall) nItemWidth += infoPtr->iconSize.cx; 
     2372        if (infoPtr->himlSmall) nItemWidth += infoPtr->iconSize.cx;
    23692373        if (infoPtr->himlState) nItemWidth += infoPtr->iconStateSize.cx;
    23702374
     
    23962400    else
    23972401    {
    2398         nItemHeight = infoPtr->ntmHeight; 
     2402        nItemHeight = infoPtr->ntmHeight;
    23992403        if (infoPtr->himlState)
    24002404            nItemHeight = max(nItemHeight, infoPtr->iconStateSize.cy);
     
    24652469    SelectObject(hdc, hOldFont);
    24662470    ReleaseDC(infoPtr->hwndSelf, hdc);
    2467    
     2471
    24682472    TRACE("tmHeight=%d\n", infoPtr->ntmHeight);
    24692473}
     
    24862490{
    24872491    INT cmp;
    2488    
    2489     if (((RANGE*)range1)->upper <= ((RANGE*)range2)->lower) 
     2492
     2493    if (((RANGE*)range1)->upper <= ((RANGE*)range2)->lower)
    24902494        cmp = -1;
    2491     else if (((RANGE*)range2)->upper <= ((RANGE*)range1)->lower) 
     2495    else if (((RANGE*)range2)->upper <= ((RANGE*)range1)->lower)
    24922496        cmp = 1;
    2493     else 
     2497    else
    24942498        cmp = 0;
    2495    
     2499
    24962500    TRACE("range1=%s, range2=%s, cmp=%d\n", debugrange((RANGE*)range1), debugrange((RANGE*)range2), cmp);
    24972501
     
    25092513    INT i;
    25102514    RANGE *prev, *curr;
    2511    
     2515
    25122516    TRACE("*** Checking %s:%d:%s ***\n", func, line, desc);
    25132517    assert (ranges);
     
    25592563    RANGES clone;
    25602564    INT i;
    2561            
     2565       
    25622566    if (!(clone = ranges_create(ranges->hdpa->nItemCount))) goto fail;
    25632567
     
    25702574    }
    25712575    return clone;
    2572    
     2576
    25732577fail:
    25742578    TRACE ("clone failed\n");
     
    26072611{
    26082612    INT i, count = 0;
    2609    
     2613
    26102614    for (i = 0; i < ranges->hdpa->nItemCount; i++)
    26112615    {
     
    26482652    srchrgn.upper = range.upper + 1;
    26492653    index = DPA_Search(ranges->hdpa, &srchrgn, 0, ranges_cmp, 0, DPAS_SORTED);
    2650    
     2654
    26512655    if (index == -1)
    26522656    {
     
    26892693        srchrgn.lower = chkrgn->lower - 1;
    26902694        srchrgn.upper = chkrgn->upper + 1;
    2691            
     2695       
    26922696        do
    26932697        {
    26942698            mergeindex = DPA_Search(ranges->hdpa, &srchrgn, fromindex, ranges_cmp, 0, 0);
    26952699            if (mergeindex == -1) break;
    2696             if (mergeindex == index) 
     2700            if (mergeindex == index)
    26972701            {
    26982702                fromindex = index + 1;
    26992703                continue;
    27002704            }
    2701          
     2705       
    27022706            TRACE("Merge with index %i\n", mergeindex);
    2703            
     2707       
    27042708            mrgrgn = DPA_GetPtr(ranges->hdpa, mergeindex);
    27052709            chkrgn->lower = min(chkrgn->lower, mrgrgn->lower);
     
    27132717    ranges_check(ranges, "after add");
    27142718    return TRUE;
    2715    
     2719
    27162720fail:
    27172721    ranges_check(ranges, "failed add");
     
    27262730    TRACE("(%s)\n", debugrange(&range));
    27272731    ranges_check(ranges, "before del");
    2728    
     2732
    27292733    /* we don't use DPAS_SORTED here, since we need *
    27302734     * to find the first overlapping range          */
    27312735    index = DPA_Search(ranges->hdpa, &range, 0, ranges_cmp, 0, 0);
    2732     while(index != -1) 
     2736    while(index != -1)
    27332737    {
    27342738        chkrgn = DPA_GetPtr(ranges->hdpa, index);
    27352739       
    2736         TRACE("Matches range %s @%d\n", debugrange(chkrgn), index); 
     2740        TRACE("Matches range %s @%d\n", debugrange(chkrgn), index);
    27372741
    27382742        /* case 1: Same range */
     
    27452749        /* case 2: engulf */
    27462750        else if ( (chkrgn->upper <= range.upper) &&
    2747                   (chkrgn->lower >= range.lower) ) 
     2751                  (chkrgn->lower >= range.lower) )
    27482752        {
    27492753            DPA_DeletePtr(ranges->hdpa, index);
     
    28132817    lvItem.state = 0;
    28142818    lvItem.stateMask = LVIS_SELECTED;
    2815    
     2819
    28162820    /* need to clone the DPA because callbacks can change it */
    28172821    if (!(clone = ranges_clone(infoPtr->selectionRanges))) return FALSE;
     
    28282832{
    28292833    RANGES toSkip;
    2830    
     2834
    28312835    if (!(toSkip = ranges_create(1))) return FALSE;
    28322836    if (nItem != -1) ranges_additem(toSkip, nItem);
     
    28892893
    28902894    if (nItem == infoPtr->nFocusedItem) return FALSE;
    2891    
     2895
    28922896    lvItem.state =  nItem == -1 ? 0 : LVIS_FOCUSED;
    28932897    lvItem.stateMask = LVIS_FOCUSED;
     
    29412945    if (nNewFocus != infoPtr->nFocusedItem)
    29422946        LISTVIEW_SetItemFocus(infoPtr, nNewFocus);
    2943    
     2947
    29442948    /* But we are not supposed to modify nHotItem! */
    29452949
     
    30023006    if (!(selection = ranges_create(100))) return;
    30033007
    3004     item.state = LVIS_SELECTED; 
     3008    item.state = LVIS_SELECTED;
    30053009    item.stateMask = LVIS_SELECTED;
    30063010
     
    30153019        {
    30163020            RANGE sel;
    3017            
     3021       
    30183022            sel.lower = min(infoPtr->nSelectionMark, nItem);
    30193023            sel.upper = max(infoPtr->nSelectionMark, nItem) + 1;
     
    30463050    /* this will also destroy the selection */
    30473051    iterator_destroy(&i);
    3048    
     3052
    30493053    LISTVIEW_SetItemFocus(infoPtr, nItem);
    30503054}
     
    30663070
    30673071    TRACE("nItem=%d\n", nItem);
    3068    
     3072
    30693073    LISTVIEW_DeselectAllSkipItem(infoPtr, nItem);
    30703074
     
    31883192    }
    31893193  }
    3190 #ifdef __WIN32OS2__
    3191   else
    3192   if(!infoPtr->bDragInProcess && (infoPtr->bLButtonDown || infoPtr->bRButtonDown) && infoPtr->nSelectionMark != -1) {
    3193       NMLISTVIEW nml = {0};
    3194       nml.iItem = infoPtr->nSelectionMark;
    3195       notify_listview(infoPtr, (infoPtr->bLButtonDown) ? LVN_BEGINDRAG : LVN_BEGINRDRAG, &nml);
    3196       infoPtr->bDragInProcess = TRUE;
    3197   }
    3198 #endif 
    31993194  return 0;
    32003195}
     
    32023197
    32033198/***
    3204  * Tests wheather the item is assignable to a list with style lStyle 
     3199 * Tests wheather the item is assignable to a list with style lStyle
    32053200 */
    32063201static inline BOOL is_assignable_item(const LVITEMW *lpLVItem, LONG lStyle)
    32073202{
    3208     if ( (lpLVItem->mask & LVIF_TEXT) && 
     3203    if ( (lpLVItem->mask & LVIF_TEXT) &&
    32093204        (lpLVItem->pszText == LPSTR_TEXTCALLBACKW) &&
    32103205        (lStyle & (LVS_SORTASCENDING | LVS_SORTDESCENDING)) ) return FALSE;
    3211    
     3206
    32123207    return TRUE;
    32133208}
     
    32403235
    32413236    assert(lpLVItem->iItem >= 0 && lpLVItem->iItem < infoPtr->nItemCount);
    3242    
    3243     if (lpLVItem->mask == 0) return TRUE;   
     3237
     3238    if (lpLVItem->mask == 0) return TRUE;
    32443239
    32453240    if (infoPtr->dwStyle & LVS_OWNERDATA)
     
    32673262
    32683263    TRACE("oldState=%x, newState=%x\n", item.state, lpLVItem->state);
    3269     /* determine what fields will change */   
     3264    /* determine what fields will change */
    32703265    if ((lpLVItem->mask & LVIF_STATE) && ((item.state ^ lpLVItem->state) & lpLVItem->stateMask & ~infoPtr->uCallbackMask))
    32713266        uChanged |= LVIF_STATE;
     
    32823277    if ((lpLVItem->mask & LVIF_TEXT) && textcmpWT(lpItem->hdr.pszText, lpLVItem->pszText, isW))
    32833278        uChanged |= LVIF_TEXT;
    3284    
    3285     TRACE("uChanged=0x%x\n", uChanged); 
     3279
     3280    TRACE("uChanged=0x%x\n", uChanged);
    32863281    if (!uChanged) return TRUE;
    32873282    *bChanged = TRUE;
    3288    
     3283
    32893284    ZeroMemory(&nmlv, sizeof(NMLISTVIEW));
    32903285    nmlv.iItem = lpLVItem->iItem;
     
    32933288    nmlv.uChanged = uChanged;
    32943289    nmlv.lParam = item.lParam;
    3295    
     3290
    32963291    /* send LVN_ITEMCHANGING notification, if the item is not being inserted */
    32973292    /* and we are _NOT_ virtual (LVS_OWERNDATA), and change notifications */
     
    33453340    /* if we're inserting the item, we're done */
    33463341    if (isNew) return TRUE;
    3347    
     3342
    33483343    /* send LVN_ITEMCHANGED notification */
    33493344    if (lpLVItem->mask & LVIF_PARAM) nmlv.lParam = lpLVItem->lParam;
     
    33743369    /* we do not support subitems for virtual listviews */
    33753370    if (infoPtr->dwStyle & LVS_OWNERDATA) return FALSE;
    3376    
     3371
    33773372    /* set subitem only if column is present */
    33783373    if (lpLVItem->iSubItem >= infoPtr->hdpaColumns->nItemCount) return FALSE;
    3379    
     3374
    33803375    /* First do some sanity checks */
    33813376    if (lpLVItem->mask & ~(LVIF_TEXT | LVIF_IMAGE)) return FALSE;
    33823377    if (!(lpLVItem->mask & (LVIF_TEXT | LVIF_IMAGE))) return TRUE;
    3383    
     3378
    33843379    /* get the subitem structure, and create it if not there */
    33853380    hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, lpLVItem->iItem);
    33863381    assert (hdpaSubItems);
    3387    
     3382
    33883383    lpSubItem = LISTVIEW_GetSubItemPtr(hdpaSubItems, lpLVItem->iSubItem);
    33893384    if (!lpSubItem)
     
    34083403        *bChanged = TRUE;
    34093404    }
    3410    
     3405
    34113406    if (lpLVItem->mask & LVIF_IMAGE)
    34123407        if (lpSubItem->hdr.iImage != lpLVItem->iImage)
     
    34443439    LPWSTR pszText = NULL;
    34453440    BOOL bResult, bChanged = FALSE;
    3446    
     3441
    34473442    TRACE("(lpLVItem=%s, isW=%d)\n", debuglvitem_t(lpLVItem, isW), isW);
    34483443
     
    34563451        ((LVITEMW *)lpLVItem)->pszText = textdupTtoW(lpLVItem->pszText, isW);
    34573452    }
    3458    
     3453
    34593454    /* actually set the fields */
    34603455    if (!is_assignable_item(lpLVItem, infoPtr->dwStyle)) return FALSE;
    3461    
     3456
    34623457    if (lpLVItem->iSubItem)
    34633458        bResult = set_sub_item(infoPtr, lpLVItem, TRUE, &bChanged);
     
    35143509        if ((lStyle & WS_VSCROLL) && GetScrollInfo(infoPtr->hwndSelf, SB_VERT, &scrollInfo))
    35153510            nItem = scrollInfo.nPos;
    3516     } 
     3511    }
    35173512    else
    35183513    {
     
    35223517
    35233518    TRACE("nItem=%d\n", nItem);
    3524    
     3519
    35253520    return nItem;
    35263521}
     
    35983593    lvItem.pszText = szDispText;
    35993594    if (!LISTVIEW_GetItemW(infoPtr, &lvItem)) return FALSE;
    3600     if (nSubItem > 0 && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT)) 
     3595    if (nSubItem > 0 && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT))
    36013596        lvItem.state = LISTVIEW_GetItemState(infoPtr, nItem, LVIS_SELECTED);
    36023597    if (lvItem.pszText == LPSTR_TEXTCALLBACKW) lvItem.pszText = szCallback;
     
    36053600    /* now check if we need to update the focus rectangle */
    36063601    lprcFocus = infoPtr->bFocus && (lvItem.state & LVIS_FOCUSED) ? &infoPtr->rcFocus : 0;
    3607    
     3602
    36083603    if (!lprcFocus) lvItem.state &= ~LVIS_FOCUSED;
    36093604    LISTVIEW_GetItemMetrics(infoPtr, &lvItem, &rcBox, &rcState, &rcIcon, &rcLabel);
     
    36123607    OffsetRect(&rcIcon, pos.x, pos.y);
    36133608    OffsetRect(&rcLabel, pos.x, pos.y);
    3614     TRACE("    rcBox=%s, rcState=%s, rcIcon=%s. rcLabel=%s\n", 
     3609    TRACE("    rcBox=%s, rcState=%s, rcIcon=%s. rcLabel=%s\n",
    36153610        debugrect(&rcBox), debugrect(&rcState), debugrect(&rcIcon), debugrect(&rcLabel));
    36163611
     
    36203615    if (cdmode & CDRF_NOTIFYITEMDRAW)
    36213616        cditemmode = notify_prepaint (infoPtr, hdc, &nmlvcd);
     3617    if (nSubItem == 0) infoPtr->cditemmode = cditemmode;
    36223618    if (cditemmode & CDRF_SKIPDEFAULT) goto postpaint;
    36233619
     
    36253621    if (nSubItem && uView == LVS_REPORT && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT))
    36263622        nmlvcd.clrTextBk = CLR_NONE;
    3627    
     3623
    36283624    /* state icons */
    36293625    if (infoPtr->himlState && !IsRectEmpty(&rcState))
     
    36533649    if ((lvItem.state & LVIS_SELECTED) && (infoPtr->bFocus != FALSE))
    36543650    {
    3655       /* set item colors */ 
     3651      /* set item colors */
    36563652      dwBkColor = SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT));
    36573653      dwTextColor = SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
     
    36593655      nMixMode = SetROP2(hdc, R2_XORPEN);
    36603656    }
    3661     else if ((infoPtr->dwStyle & LVS_SHOWSELALWAYS) && 
     3657    else if ((infoPtr->dwStyle & LVS_SHOWSELALWAYS) &&
    36623658           (lvItem.state & LVIS_SELECTED) && (infoPtr->bFocus == FALSE))
    36633659    {
     
    36943690        if (uView == LVS_REPORT && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT))
    36953691            rcSelect.right = rcBox.right;
    3696    
    3697         if (nmlvcd.clrTextBk != CLR_NONE) 
     3692
     3693        if (nmlvcd.clrTextBk != CLR_NONE)
    36983694#ifdef __WIN32OS2__
    36993695            ExtTextOutW(hdc, rcSelect.left, rcSelect.top, textoutOptions, &rcSelect, 0, 0, 0);
     
    37033699        if(lprcFocus) *lprcFocus = rcSelect;
    37043700    }
    3705    
     3701
    37063702    /* figure out the text drawing flags */
    37073703    uFormat = (uView == LVS_ICON ? (lprcFocus ? LV_FL_DT_FLAGS : LV_ML_DT_FLAGS) : LV_SL_DT_FLAGS);
     
    37633759    DRAWITEMSTRUCT dis;
    37643760    LVITEMW item;
    3765    
     3761
    37663762    TRACE("()\n");
    37673763
    37683764    ZeroMemory(&dis, sizeof(dis));
    3769    
     3765
    37703766    /* Get scroll info once before loop */
    37713767    LISTVIEW_GetOrigin(infoPtr, &Origin);
    3772    
     3768
    37733769    /* iterate through the invalidated rows */
    37743770    while(iterator_next(i))
     
    37793775        item.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
    37803776        if (!LISTVIEW_GetItemW(infoPtr, &item)) continue;
    3781            
     3777       
    37823778        dis.CtlType = ODT_LISTVIEW;
    37833779        dis.CtlID = uID;
     
    38033799            cditemmode = notify_prepaint (infoPtr, hdc, &nmlvcd);
    38043800        }
    3805    
     3801
    38063802        if (!(cditemmode & CDRF_SKIPDEFAULT))
    38073803            SendMessageW(hwndParent, WM_DRAWITEM, dis.CtlID, (LPARAM)&dis);
     
    38373833    rgntype = GetClipBox(hdc, &rcClip);
    38383834    if (rgntype == NULLREGION) return;
    3839    
     3835
    38403836    /* Get scroll info once before loop */
    38413837    LISTVIEW_GetOrigin(infoPtr, &Origin);
    3842    
     3838
    38433839    /* narrow down the columns we need to paint */
    38443840    for(colRange.lower = 0; colRange.lower < infoPtr->hdpaColumns->nItemCount; colRange.lower++)
     
    39013897    /* Get scroll info once before loop */
    39023898    LISTVIEW_GetOrigin(infoPtr, &Origin);
    3903    
     3899
    39043900    while(iterator_prev(i))
    39053901    {
     
    39363932
    39373933    LISTVIEW_DUMP(infoPtr);
    3938  
     3934
    39393935    infoPtr->bIsDrawing = TRUE;
    39403936
     
    39473943    oldClrTextBk = infoPtr->clrTextBk;
    39483944    oldClrText   = infoPtr->clrText;
    3949    
     3945
     3946    infoPtr->cditemmode = CDRF_DODEFAULT;
     3947
    39503948    GetClientRect(infoPtr->hwndSelf, &rcClient);
    39513949    customdraw_fill(&nmlvcd, infoPtr, hdc, &rcClient, 0);
     
    39623960    /* figure out what we need to draw */
    39633961    iterator_visibleitems(&i, infoPtr, hdc);
    3964    
     3962
    39653963    /* send cache hint notification */
    39663964    if (infoPtr->dwStyle & LVS_OWNERDATA)
     
    39893987    }
    39903988    iterator_destroy(&i);
    3991    
     3989
    39923990enddraw:
    39933991    if (cdmode & CDRF_NOTIFYPOSTPAINT)
     
    40984096    wWidth = nColumnCount * infoPtr->nItemWidth + 2;
    40994097
    4100     dwViewRect = MAKELONG(wWidth, wHeight); 
     4098    dwViewRect = MAKELONG(wWidth, wHeight);
    41014099  }
    41024100#else
     
    41114109}
    41124110
    4113 /* << LISTVIEW_CreateDragImage >> */
     4111
     4112/***
     4113 * DESCRIPTION:
     4114 * Create a drag image list for the specified item.
     4115 *
     4116 * PARAMETER(S):
     4117 * [I] infoPtr : valid pointer to the listview structure
     4118 * [I] iItem   : index of item
     4119 * [O] lppt    : Upperr-left corner of the image
     4120 *
     4121 * RETURN:
     4122 * Returns a handle to the image list if successful, NULL otherwise.
     4123 */
     4124static HIMAGELIST LISTVIEW_CreateDragImage(LISTVIEW_INFO *infoPtr, INT iItem, LPPOINT lppt)
     4125{
     4126    RECT rcItem;
     4127    SIZE size;
     4128    POINT pos;
     4129    HDC hdc, hdcOrig;
     4130    HBITMAP hbmp, hOldbmp;
     4131    HIMAGELIST dragList = 0;
     4132    TRACE("iItem=%d Count=%d \n", iItem, infoPtr->nItemCount);
     4133
     4134    if (iItem < 0 || iItem >= infoPtr->nItemCount)
     4135        return 0;
     4136
     4137    rcItem.left = LVIR_BOUNDS;
     4138    if (!LISTVIEW_GetItemRect(infoPtr, iItem, &rcItem))
     4139        return 0;
     4140
     4141    lppt->x = rcItem.left;
     4142    lppt->y = rcItem.top;
     4143
     4144    size.cx = rcItem.right - rcItem.left;
     4145    size.cy = rcItem.bottom - rcItem.top;
     4146
     4147    hdcOrig = GetDC(infoPtr->hwndSelf);
     4148    hdc = CreateCompatibleDC(hdcOrig);
     4149    hbmp = CreateCompatibleBitmap(hdcOrig, size.cx, size.cy);
     4150    hOldbmp = SelectObject(hdc, hbmp);
     4151
     4152    rcItem.left = rcItem.top = 0;
     4153    rcItem.right = size.cx;
     4154    rcItem.bottom = size.cy;
     4155    FillRect(hdc, &rcItem, infoPtr->hBkBrush);
     4156
     4157    pos.x = pos.y = 0;
     4158    if (LISTVIEW_DrawItem(infoPtr, hdc, iItem, 0, pos, infoPtr->cditemmode))
     4159    {
     4160        dragList = ImageList_Create(size.cx, size.cy, ILC_COLOR, 10, 10);
     4161        SelectObject(hdc, hOldbmp);
     4162        ImageList_Add(dragList, hbmp, 0);
     4163    }
     4164    else
     4165        SelectObject(hdc, hOldbmp);
     4166
     4167    DeleteObject(hbmp);
     4168    DeleteDC(hdc);
     4169    ReleaseDC(infoPtr->hwndSelf, hdcOrig);
     4170
     4171    TRACE("ret=%p\n", dragList);
     4172
     4173    return dragList;
     4174}
    41144175
    41154176
     
    41684229        infoPtr->nItemCount --;
    41694230    }
    4170    
     4231
    41714232    LISTVIEW_UpdateScroll(infoPtr);
    41724233
    41734234    LISTVIEW_InvalidateList(infoPtr);
    4174    
     4235
    41754236    return TRUE;
    41764237}
     
    41934254    RECT rcOld, rcCol;
    41944255    INT nCol;
    4195    
     4256
    41964257    lpColumnInfo = LISTVIEW_GetColumnInfo(infoPtr, min(nColumn, infoPtr->hdpaColumns->nItemCount - 1));
    41974258    rcCol = lpColumnInfo->rcHeader;
    41984259    if (nColumn >= infoPtr->hdpaColumns->nItemCount)
    41994260        rcCol.left = rcCol.right;
    4200    
     4261
    42014262    /* ajust the other columns */
    42024263    for (nCol = nColumn; nCol < infoPtr->hdpaColumns->nItemCount; nCol++)
     
    42094270    /* do not update screen if not in report mode */
    42104271    if (!is_redrawing(infoPtr) || (infoPtr->dwStyle & LVS_TYPEMASK) != LVS_REPORT) return;
    4211    
     4272
    42124273    /* if we have a focus, must first erase the focus rect */
    42134274    if (infoPtr->bFocus) LISTVIEW_ShowFocusRect(infoPtr, FALSE);
    4214    
     4275
    42154276    /* Need to reset the item width when inserting a new column */
    42164277    infoPtr->nItemWidth += dx;
     
    42224283    rcOld.left = rcCol.left;
    42234284    ScrollWindowEx(infoPtr->hwndSelf, dx, 0, &rcOld, &rcOld, 0, 0, SW_ERASE | SW_INVALIDATE);
    4224    
     4285
    42254286    /* we can restore focus now */
    42264287    if (infoPtr->bFocus) LISTVIEW_ShowFocusRect(infoPtr, TRUE);
     
    42424303{
    42434304    RECT rcCol;
    4244    
     4305
    42454306    TRACE("nColumn=%d\n", nColumn);
    42464307
     
    42514312       it does in fact work on WinNT, and at least one app depends on it. On
    42524313       WinNT, deleting column zero deletes the last column of items but the
    4253        first header. Since no app will ever depend on that bizarre behavior, 
     4314       first header. Since no app will ever depend on that bizarre behavior,
    42544315       we just delete the last column including the header.
    42554316     */
     
    42584319
    42594320    LISTVIEW_GetHeaderRect(infoPtr, nColumn, &rcCol);
    4260    
     4321
    42614322    if (!Header_DeleteItem(infoPtr->hwndHeader, nColumn))
    42624323        return FALSE;
     
    42644325    COMCTL32_Free(DPA_GetPtr(infoPtr->hdpaColumns, nColumn));
    42654326    DPA_DeletePtr(infoPtr->hdpaColumns, nColumn);
    4266  
     4327
    42674328    if (!(infoPtr->dwStyle & LVS_OWNERDATA))
    42684329    {
     
    42734334        if (nColumn == 0)
    42744335            return LISTVIEW_DeleteAllItems(infoPtr);
    4275            
     4336       
    42764337        for (nItem = 0; nItem < infoPtr->nItemCount; nItem++)
    42774338        {
     
    42874348                    lpDelItem = lpSubItem;
    42884349                }
    4289                 else if (lpSubItem->iSubItem > nColumn) 
     4350                else if (lpSubItem->iSubItem > nColumn)
    42904351                {
    42914352                    lpSubItem->iSubItem--;
     
    43364397    /* if we don't refresh, what's the point of scrolling? */
    43374398    if (!is_redrawing(infoPtr)) return;
    4338    
     4399
    43394400    assert (abs(dir) == 1);
    43404401
     
    43514412    LISTVIEW_UpdateScroll(infoPtr);
    43524413
    4353     /* figure out the item's position */ 
     4414    /* figure out the item's position */
    43544415    if (uView == LVS_REPORT)
    43554416        nPerCol = infoPtr->nItemCount + 1;
     
    43584419    else /* LVS_ICON, or LVS_SMALLICON */
    43594420        return;
    4360    
     4421
    43614422    nItemCol = nItem / nPerCol;
    43624423    nItemRow = nItem % nPerCol;
     
    43734434    {
    43744435        TRACE("Scrolling rcScroll=%s, rcList=%s\n", debugrect(&rcScroll), debugrect(&infoPtr->rcList));
    4375         ScrollWindowEx(infoPtr->hwndSelf, 0, dir * infoPtr->nItemHeight, 
     4436        ScrollWindowEx(infoPtr->hwndSelf, 0, dir * infoPtr->nItemHeight,
    43764437                       &rcScroll, &rcScroll, 0, 0, SW_ERASE | SW_INVALIDATE);
    43774438    }
     
    44114472
    44124473    if (nItem < 0 || nItem >= infoPtr->nItemCount) return FALSE;
    4413    
     4474
    44144475    /* remove selection, and focus */
    44154476    item.state = 0;
    44164477    item.stateMask = LVIS_SELECTED | LVIS_FOCUSED;
    44174478    LISTVIEW_SetItemState(infoPtr, nItem, &item);
    4418            
     4479       
    44194480    /* send LVN_DELETEITEM notification. */
    44204481    notify_deleteitem(infoPtr, nItem);
    44214482
    4422     /* we need to do this here, because we'll be deleting stuff */ 
     4483    /* we need to do this here, because we'll be deleting stuff */
    44234484    if (uView == LVS_SMALLICON || uView == LVS_ICON)
    44244485        LISTVIEW_InvalidateItem(infoPtr, nItem);
    4425    
     4486
    44264487    if (!(infoPtr->dwStyle & LVS_OWNERDATA))
    44274488    {
     
    45374598    rect.left = LVIR_LABEL;
    45384599    if (!LISTVIEW_GetItemRect(infoPtr, nItem, &rect)) return 0;
    4539    
     4600
    45404601    ZeroMemory(&dispInfo, sizeof(dispInfo));
    45414602    dispInfo.item.mask = LVIF_PARAM | LVIF_STATE | LVIF_TEXT;
     
    45504611                    rect.left-2, rect.top-1, 0, rect.bottom - rect.top+2, isW);
    45514612    if (!infoPtr->hwndEdit) return 0;
    4552    
     4613
    45534614    if (notify_dispinfoT(infoPtr, LVN_BEGINLABELEDITW, &dispInfo, isW))
    45544615    {
     
    45934654
    45944655    if (bPartial && IntersectRect(&rcTemp, &infoPtr->rcList, &rcItem)) return TRUE;
    4595    
     4656
    45964657    if (rcItem.left < infoPtr->rcList.left || rcItem.right > infoPtr->rcList.right)
    45974658    {
     
    46784739
    46794740    if (!lpFindInfo || nItem < 0) return -1;
    4680    
     4741
    46814742    lvItem.mask = 0;
    46824743    if (lpFindInfo->flags & (LVFI_STRING | LVFI_PARTIAL))
     
    46904751        bWrap = TRUE;
    46914752
    4692     if ((lpFindInfo->flags & LVFI_NEARESTXY) && 
     4753    if ((lpFindInfo->flags & LVFI_NEARESTXY) &&
    46934754        (uView == LVS_ICON || uView ==LVS_SMALLICON))
    46944755    {
     
    47104771        case VK_END:
    47114772            LISTVIEW_GetAreaRect(infoPtr, &rcArea);
    4712             Destination.x = rcArea.right; 
    4713             Destination.y = rcArea.bottom; 
     4773            Destination.x = rcArea.right;
     4774            Destination.y = rcArea.bottom;
    47144775            break;
    47154776        default: ERR("Unknown vkDirection=%d\n", lpFindInfo->vkDirection);
     
    50915152
    50925153        /* if focus is handled by us, report it */
    5093         if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_FOCUSED ) 
     5154        if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_FOCUSED )
    50945155        {
    50955156            lpLVItem->state &= ~LVIS_FOCUSED;
     
    50995160
    51005161        /* and do the same for selection, if we handle it */
    5101         if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_SELECTED ) 
     5162        if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_SELECTED )
    51025163        {
    51035164            lpLVItem->state &= ~LVIS_SELECTED;
     
    51285189        dispInfo.item.stateMask = infoPtr->uCallbackMask;
    51295190    }
    5130  
     5191
    51315192    /* Do we need to enquire about the image? */
    51325193    if ((lpLVItem->mask & LVIF_IMAGE) && pItemHdr->iImage == I_IMAGECALLBACK)
     
    51825243    /* if this is a subitem, we're done */
    51835244    if (lpLVItem->iSubItem) return TRUE;
    5184  
     5245
    51855246    /* Next is the lParam field */
    51865247    if (dispInfo.item.mask & LVIF_PARAM)
     
    51945255
    51955256    /* ... the state field (this one is different due to uCallbackmask) */
    5196     if (lpLVItem->mask & LVIF_STATE) 
     5257    if (lpLVItem->mask & LVIF_STATE)
    51975258    {
    51985259        lpLVItem->state = lpItem->state;
     
    52025263            lpLVItem->state |= (dispInfo.item.state & dispInfo.item.stateMask);
    52035264        }
    5204         if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_FOCUSED ) 
     5265        if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_FOCUSED )
    52055266        {
    52065267            lpLVItem->state &= ~LVIS_FOCUSED;
     
    52085269                lpLVItem->state |= LVIS_FOCUSED;
    52095270        }
    5210         if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_SELECTED ) 
     5271        if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_SELECTED )
    52115272        {
    52125273            lpLVItem->state &= ~LVIS_SELECTED;
    52135274            if (ranges_contain(infoPtr->selectionRanges, lpLVItem->iItem))
    52145275                lpLVItem->state |= LVIS_SELECTED;
    5215         }          
     5276        }       
    52165277    }
    52175278
     
    52935354    lpptPosition->x += Origin.x;
    52945355    lpptPosition->y += Origin.y;
    5295    
     5356
    52965357    TRACE ("  lpptPosition=%s\n", debugpoint(lpptPosition));
    52975358    return TRUE;
     
    54445505 *             on input, lprc->top = nSubItem
    54455506 *                       lprc->left = LVIR_ICON | LVIR_BOUNDS | LVIR_LABEL
    5446  * 
     5507 *
    54475508 * NOTE: for subItem = 0, we should return the bounds of the _entire_ item,
    54485509 *       not only those of the first column.
    54495510 *       Fortunately, LISTVIEW_GetItemMetrics does the right thing.
    5450  * 
     5511 *
    54515512 * RETURN:
    54525513 *     TRUE: success
     
    54575518    POINT Position;
    54585519    LVITEMW lvItem;
    5459    
     5520
    54605521    if (!lprc || (infoPtr->dwStyle & LVS_TYPEMASK) != LVS_REPORT) return FALSE;
    5461    
     5522
    54625523    TRACE("(nItem=%d, nSubItem=%ld)\n", nItem, lprc->top);
    54635524    /* On WinNT, a subitem of '0' calls LISTVIEW_GetItemRect */
     
    54705531    lvItem.iItem = nItem;
    54715532    lvItem.iSubItem = lprc->top;
    5472    
     5533
    54735534    if (lvItem.mask && !LISTVIEW_GetItemW(infoPtr, &lvItem)) return FALSE;
    54745535    switch(lprc->left)
     
    55175578    lvItem.cchTextMax = DISP_TEXT_SIZE;
    55185579    if (!LISTVIEW_GetItemW(infoPtr, &lvItem)) return 0;
    5519  
     5580
    55205581    return LISTVIEW_GetStringWidthT(infoPtr, lvItem.pszText, TRUE);
    55215582}
     
    56415702      uMask |= LVIS_SELECTED;
    56425703
    5643     /* if we're asked for the focused item, that's only one, 
     5704    /* if we're asked for the focused item, that's only one,
    56445705     * so it's worth optimizing */
    56455706    if (uFlags & LVNI_FOCUSED)
     
    56485709        return (infoPtr->nFocusedItem == nItem) ? -1 : infoPtr->nFocusedItem;
    56495710    }
    5650    
     5711
    56515712    if (uFlags & LVNI_ABOVE)
    56525713    {
     
    58255886    SCROLLINFO scrollInfo;
    58265887
    5827     scrollInfo.cbSize = sizeof(SCROLLINFO);   
     5888    scrollInfo.cbSize = sizeof(SCROLLINFO);
    58285889    scrollInfo.fMask = SIF_POS;
    5829    
     5890
    58305891    if ((infoPtr->dwStyle & WS_HSCROLL) && GetScrollInfo(infoPtr->hwndSelf, SB_HORZ, &scrollInfo))
    58315892        nHorzPos = scrollInfo.nPos;
     
    58415902    else if (uView == LVS_REPORT)
    58425903        nVertPos *= infoPtr->nItemHeight;
    5843    
     5904
    58445905    lpptOrigin->x -= nHorzPos;
    58455906    lpptOrigin->y -= nVertPos;
     
    58645925{
    58655926    SIZE stringSize;
    5866    
    5867     stringSize.cx = 0;   
     5927
     5928    stringSize.cx = 0;
    58685929    if (is_textT(lpszText, isW))
    58695930    {
     
    58905951        mis.itemHeight = 0;
    58915952        mis.itemWidth  = 0;
    5892         if (isW) 
     5953        if (isW)
    58935954         SendMessageW(GetParent(infoPtr->hwndSelf), WM_MEASUREITEM, id, (LPARAM)&mis );
    58945955        else
     
    59155976 * an app might pass only a structure with space up to iItem!
    59165977 * (MS Office 97 does that for instance in the file open dialog)
    5917  * 
     5978 *
    59185979 * RETURN:
    59195980 *   SUCCESS : item index
     
    59285989    LVITEMW lvItem;
    59295990    ITERATOR i;
    5930    
     5991
    59315992    TRACE("(pt=%s, subitem=%d, select=%d)\n", debugpoint(&lpht->pt), subitem, select);
    5932    
     5993
    59335994    lpht->flags = 0;
    59345995    lpht->iItem = -1;
     
    59396000    else if (infoPtr->rcList.right < lpht->pt.x)
    59406001        lpht->flags |= LVHT_TORIGHT;
    5941    
     6002
    59426003    if (infoPtr->rcList.top > lpht->pt.y)
    59436004        lpht->flags |= LVHT_ABOVE;
     
    59516012
    59526013    LISTVIEW_GetOrigin(infoPtr, &Origin);
    5953    
     6014
    59546015    /* first deal with the large items */
    59556016    rcSearch.left = lpht->pt.x;
     
    59576018    rcSearch.right = rcSearch.left + 1;
    59586019    rcSearch.bottom = rcSearch.top + 1;
    5959    
     6020
    59606021    iterator_frameditems(&i, infoPtr, &rcSearch);
    59616022    iterator_next(&i); /* go to first item in the sequence */
    59626023    lpht->iItem = i.nItem;
    59636024    iterator_destroy(&i);
    5964    
    5965     TRACE("lpht->iItem=%d\n", lpht->iItem); 
     6025
     6026    TRACE("lpht->iItem=%d\n", lpht->iItem);
    59666027    if (lpht->iItem == -1) return -1;
    59676028
     
    59756036    lvItem.cchTextMax = DISP_TEXT_SIZE;
    59766037    if (!LISTVIEW_GetItemW(infoPtr, &lvItem)) return -1;
    5977     if (!infoPtr->bFocus) lvItem.state &= ~LVIS_FOCUSED; 
    5978    
     6038    if (!infoPtr->bFocus) lvItem.state &= ~LVIS_FOCUSED;
     6039
    59796040    LISTVIEW_GetItemMetrics(infoPtr, &lvItem, &rcBox, &rcState, &rcIcon, &rcLabel);
    59806041    LISTVIEW_GetItemOrigin(infoPtr, lpht->iItem, &Position);
    59816042    opt.x = lpht->pt.x - Position.x - Origin.x;
    59826043    opt.y = lpht->pt.y - Position.y - Origin.y;
    5983    
     6044
    59846045    if (uView == LVS_REPORT && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT))
    59856046        rcBounds = rcBox;
     
    59976058    if (lpht->flags & LVHT_ONITEM)
    59986059        lpht->flags &= ~LVHT_NOWHERE;
    5999    
    6000     TRACE("lpht->flags=0x%x\n", lpht->flags); 
     6060
     6061    TRACE("lpht->flags=0x%x\n", lpht->flags);
    60016062    if (uView == LVS_REPORT && lpht->iItem != -1 && subitem)
    60026063    {
     
    60196080
    60206081    if (uView == LVS_REPORT && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT)) return lpht->iItem;
    6021    
     6082
    60226083    if (uView == LVS_REPORT) UnionRect(&rcBounds, &rcIcon, &rcLabel);
    60236084    return PtInRect(&rcBounds, opt) ? lpht->iItem : -1;
     
    60456106    ITEM_INFO* lv_first = (ITEM_INFO*) DPA_GetPtr( (HDPA)first, 0 );
    60466107    ITEM_INFO* lv_second = (ITEM_INFO*) DPA_GetPtr( (HDPA)second, 0 );
    6047     INT cmpv = textcmpWT(lv_first->hdr.pszText, lv_second->hdr.pszText, TRUE); 
     6108    INT cmpv = textcmpWT(lv_first->hdr.pszText, lv_second->hdr.pszText, TRUE);
    60486109
    60496110    /* if we're sorting descending, negate the return value */
     
    60856146    if ( !(lpItem = (ITEM_INFO *)COMCTL32_Alloc(sizeof(ITEM_INFO))) )
    60866147        return -1;
    6087    
     6148
    60886149    /* insert item in listview control data structure */
    60896150    if ( !(hdpaSubItems = DPA_Create(8)) ) goto fail;
     
    61386199        }
    61396200    }
    6140    
     6201
    61416202    /* Add the subitem list to the items array. Do this last in case we go to
    61426203     * fail during the above.
    61436204     */
    61446205    LISTVIEW_ShiftIndices(infoPtr, nItem, 1);
    6145    
     6206
    61466207    /* send LVN_INSERTITEM notification */
    61476208    ZeroMemory(&nmlv, sizeof(NMLISTVIEW));
     
    61936254{
    61946255    INT i;
    6195  
    6196     if (nLast < nFirst || min(nFirst, nLast) < 0 || 
     6256
     6257    if (nLast < nFirst || min(nFirst, nLast) < 0 ||
    61976258        max(nFirst, nLast) >= infoPtr->nItemCount)
    61986259        return FALSE;
    6199    
     6260
    62006261    for (i = nFirst; i <= nLast; i++)
    62016262        LISTVIEW_InvalidateItem(infoPtr, i);
     
    62546315    if (dx != 0) LISTVIEW_HScroll(infoPtr, SB_INTERNAL, dx, 0);
    62556316    if (dy != 0) LISTVIEW_VScroll(infoPtr, SB_INTERNAL, dy, 0);
    6256  
     6317
    62576318    return TRUE;
    62586319}
     
    63876448    if (!lpColumn || nColumn < 0) return -1;
    63886449    nColumn = min(nColumn, infoPtr->hdpaColumns->nItemCount);
    6389    
     6450
    63906451    ZeroMemory(&hdi, sizeof(HDITEMW));
    63916452    column_fill_hditem(infoPtr, &hdi, nColumn, lpColumn, isW);
    63926453
    63936454    /* insert item in header control */
    6394     nNewColumn = SendMessageW(infoPtr->hwndHeader, 
     6455    nNewColumn = SendMessageW(infoPtr->hwndHeader,
    63956456                              isW ? HDM_INSERTITEMW : HDM_INSERTITEMA,
    63966457                              (WPARAM)nColumn, (LPARAM)&hdi);
    63976458    if (nNewColumn == -1) return -1;
    63986459    if (nNewColumn != nColumn) ERR("nColumn=%d, nNewColumn=%d\n", nColumn, nNewColumn);
    6399    
    6400     /* create our own column info */ 
     6460
     6461    /* create our own column info */
    64016462    if (!(lpColumnInfo = COMCTL32_Alloc(sizeof(COLUMN_INFO)))) goto fail;
    64026463    if (DPA_InsertPtr(infoPtr->hdpaColumns, nNewColumn, lpColumnInfo) == -1) goto fail;
     
    64556516    /* make space for the new column */
    64566517    LISTVIEW_ScrollColumns(infoPtr, nNewColumn + 1, lpColumnInfo->rcHeader.right - lpColumnInfo->rcHeader.left);
    6457    
     6518
    64586519    return nNewColumn;
    64596520
     
    64896550
    64906551    TRACE("(nColumn=%d, lpColumn=%s, isW=%d)\n", nColumn, debuglvcolumn_t(lpColumn, isW), isW);
    6491    
     6552
    64926553    if (!lpColumn || nColumn < 0 || nColumn >= infoPtr->hdpaColumns->nItemCount) return FALSE;
    64936554
     
    65766637
    65776638    /* resize all columns if in LVS_LIST mode */
    6578     if(uView == LVS_LIST) 
     6639    if(uView == LVS_LIST)
    65796640    {
    65806641        infoPtr->nItemWidth = cx;
     
    66126673    {
    66136674        /* if iCol is the last column make it fill the remainder of the controls width */
    6614         if(nColumn == infoPtr->hdpaColumns->nItemCount - 1) 
     6675        if(nColumn == infoPtr->hdpaColumns->nItemCount - 1)
    66156676        {
    66166677            RECT rcHeader;
     
    67006761{
    67016762    HCURSOR oldCursor = infoPtr->hHotCursor;
    6702    
     6763
    67036764    infoPtr->hHotCursor = hCursor;
    67046765
     
    67226783{
    67236784    INT iOldIndex = infoPtr->nHotItem;
    6724    
     6785
    67256786    infoPtr->nHotItem = iIndex;
    6726    
     6787
    67276788    return iOldIndex;
    67286789}
     
    67436804{
    67446805    DWORD oldHoverTime = infoPtr->dwHoverTime;
    6745    
     6806
    67466807    infoPtr->dwHoverTime = dwHoverTime;
    6747    
     6808
    67486809    return oldHoverTime;
    67496810}
     
    67676828
    67686829    TRACE("requested=(%d,%d)\n", cx, cy);
    6769    
     6830
    67706831    /* this is supported only for LVS_ICON style */
    67716832    if (uView != LVS_ICON) return oldspacing;
    6772  
     6833
    67736834    /* set to defaults, if instructed to */
    67746835    if (cx == -1) cx = GetSystemMetrics(SM_CXICONSPACING);
     
    67826843
    67836844    /* if 0 then compute height */
    6784     if (cy == 0) 
     6845    if (cy == 0)
    67856846        cy = infoPtr->iconSize.cy + 2 * infoPtr->ntmHeight +
    67866847             ICON_BOTTOM_PADDING + ICON_TOP_PADDING + LABEL_VERT_PADDING;
    6787    
     6848
    67886849
    67896850    infoPtr->iconSpacing.cx = cx;
     
    67916852
    67926853    TRACE("old=(%d,%d), new=(%d,%d), iconSize=(%ld,%ld), ntmH=%d\n",
    6793           LOWORD(oldspacing), HIWORD(oldspacing), cx, cy, 
     6854          LOWORD(oldspacing), HIWORD(oldspacing), cx, cy,
    67946855          infoPtr->iconSize.cx, infoPtr->iconSize.cy,
    67956856          infoPtr->ntmHeight);
     
    68046865{
    68056866    INT cx, cy;
    6806    
     6867
    68076868    if (himl && ImageList_GetIconSize(himl, &cx, &cy))
    68086869    {
     
    69216982            POINT Origin;
    69226983            RECT rcErase;
    6923            
     6984       
    69246985            LISTVIEW_GetOrigin(infoPtr, &Origin);
    69256986            nFrom = min(nOldCount, nItems);
    69266987            nTo = max(nOldCount, nItems);
    6927    
     6988
    69286989            if (uView == LVS_REPORT)
    69296990            {
     
    69987059
    69997060    /* This point value seems to be an undocumented feature.
    7000      * The best guess is that it means either at the origin, 
     7061     * The best guess is that it means either at the origin,
    70017062     * or at true beginning of the list. I will assume the origin. */
    70027063    if ((pt.x == -1) && (pt.y == -1))
    70037064        pt = Origin;
    7004    
     7065
    70057066    if (uView == LVS_ICON)
    70067067    {
     
    70727133
    70737134    if (nItem < 0 && nItem >= infoPtr->nItemCount) return FALSE;
    7074    
     7135
    70757136    lvItem.iItem = nItem;
    70767137    lvItem.iSubItem = lpLVItem->iSubItem;
     
    70787139    lvItem.pszText = lpLVItem->pszText;
    70797140    lvItem.cchTextMax = lpLVItem->cchTextMax;
    7080    
     7141
    70817142    TRACE("(nItem=%d, lpLVItem=%s, isW=%d)\n", nItem, debuglvitem_t(&lvItem, isW), isW);
    70827143
    7083     return LISTVIEW_SetItemT(infoPtr, &lvItem, isW); 
     7144    return LISTVIEW_SetItemT(infoPtr, &lvItem, isW);
    70847145}
    70857146
     
    71277188        LISTVIEW_InvalidateList(infoPtr);
    71287189    }
    7129    
     7190
    71307191  return TRUE;
    71317192}
     
    72417302    /*        clear the lpItem->state for non-selected ones */
    72427303    /*        remove the selection ranges */
    7243    
     7304
    72447305    infoPtr->pfnCompare = pfnCompare;
    72457306    infoPtr->lParamSort = lParamSort;
     
    73917452  /* init item size to avoid division by 0 */
    73927453  LISTVIEW_UpdateItemSize (infoPtr);
    7393  
     7454
    73947455  if (uView == LVS_REPORT)
    73957456  {
     
    74567517{
    74577518    /* now we can scroll the list */
    7458     ScrollWindowEx(infoPtr->hwndSelf, dx, dy, &infoPtr->rcList, 
     7519    ScrollWindowEx(infoPtr->hwndSelf, dx, dy, &infoPtr->rcList,
    74597520                   &infoPtr->rcList, 0, 0, SW_ERASE | SW_INVALIDATE);
    74607521    /* if we have focus, adjust rect */
     
    74837544 *
    74847545 */
    7485 static LRESULT LISTVIEW_VScroll(LISTVIEW_INFO *infoPtr, INT nScrollCode, 
     7546static LRESULT LISTVIEW_VScroll(LISTVIEW_INFO *infoPtr, INT nScrollCode,
    74867547                                INT nScrollDiff, HWND hScrollWnd)
    74877548{
     
    74917552    BOOL is_an_icon;
    74927553
    7493     TRACE("(nScrollCode=%d(%s), nScrollDiff=%d)\n", nScrollCode, 
     7554    TRACE("(nScrollCode=%d(%s), nScrollDiff=%d)\n", nScrollCode,
    74947555        debugscrollcode(nScrollCode), nScrollDiff);
    74957556
     
    75367597    /* quit right away if pos isn't changing */
    75377598    if (nScrollDiff == 0) return 0;
    7538    
     7599
    75397600    /* calculate new position, and handle overflows */
    75407601    nNewScrollPos = scrollInfo.nPos + nScrollDiff;
     
    75537614    scrollInfo.nPos = nNewScrollPos;
    75547615    nNewScrollPos = SetScrollInfo(infoPtr->hwndSelf, SB_VERT, &scrollInfo, TRUE);
    7555    
     7616
    75567617    /* carry on only if it really changed */
    75577618    if (nNewScrollPos == nOldScrollPos) return 0;
    7558    
     7619
    75597620    /* now adjust to client coordinates */
    75607621    nScrollDiff = nOldScrollPos - nNewScrollPos;
    75617622    if (uView == LVS_REPORT) nScrollDiff *= infoPtr->nItemHeight;
    7562    
    7563     /* and scroll the window */ 
     7623
     7624    /* and scroll the window */
    75647625    scroll_list(infoPtr, 0, nScrollDiff);
    75657626
     
    75957656    SCROLLINFO scrollInfo;
    75967657
    7597     TRACE("(nScrollCode=%d(%s), nScrollDiff=%d)\n", nScrollCode, 
     7658    TRACE("(nScrollCode=%d(%s), nScrollDiff=%d)\n", nScrollCode,
    75987659        debugscrollcode(nScrollCode), nScrollDiff);
    75997660
     
    76397700    /* quit right away if pos isn't changing */
    76407701    if (nScrollDiff == 0) return 0;
    7641    
     7702
    76427703    /* calculate new position, and handle overflows */
    76437704    nNewScrollPos = scrollInfo.nPos + nScrollDiff;
     
    76567717    scrollInfo.nPos = nNewScrollPos;
    76577718    nNewScrollPos = SetScrollInfo(infoPtr->hwndSelf, SB_HORZ, &scrollInfo, TRUE);
    7658    
     7719
    76597720    /* carry on only if it really changed */
    76607721    if (nNewScrollPos == nOldScrollPos) return 0;
    7661    
     7722
    76627723    if(uView == LVS_REPORT)
    76637724        LISTVIEW_UpdateHeaderSize(infoPtr, nNewScrollPos);
    7664      
     7725
    76657726    /* now adjust to client coordinates */
    76667727    nScrollDiff = nOldScrollPos - nNewScrollPos;
    76677728    if (uView == LVS_LIST) nScrollDiff *= infoPtr->nItemWidth;
    7668    
     7729
    76697730    /* and scroll the window */
    76707731    scroll_list(infoPtr, nScrollDiff, 0);
     
    77407801  nmKeyDown.flags = 0;
    77417802#ifdef __WIN32OS2__
    7742   if(notify_hdr(infoPtr, LVN_KEYDOWN, &nmKeyDown.hdr) == TRUE) 
     7803  if(notify_hdr(infoPtr, LVN_KEYDOWN, &nmKeyDown.hdr) == TRUE)
    77437804    return 0;    //application processed this key press
    77447805#else
     
    78237884    /* if we did not have the focus, there's nothing to do */
    78247885    if (!infoPtr->bFocus) return 0;
    7825    
     7886
    78267887    /* send NM_KILLFOCUS notification */
    78277888    notify(infoPtr, NM_KILLFOCUS);
     
    78297890    /* if we have a focus rectagle, get rid of it */
    78307891    LISTVIEW_ShowFocusRect(infoPtr, FALSE);
    7831    
     7892
    78327893    /* set window focus flag */
    78337894    infoPtr->bFocus = FALSE;
     
    78357896    /* invalidate the selected items before reseting focus flag */
    78367897    LISTVIEW_InvalidateSelectedItems(infoPtr);
    7837    
     7898
    78387899    return 0;
    78397900}
     7901
     7902
     7903/***
     7904 * DESCRIPTION:
     7905 * Track mouse/dragging
     7906 *
     7907 * PARAMETER(S):
     7908 * [I] infoPtr : valid pointer to the listview structure
     7909 * [I] pt : mouse coordinate
     7910 *
     7911 * RETURN:
     7912 * Zero
     7913 */
     7914static LRESULT LISTVIEW_TrackMouse(LISTVIEW_INFO *infoPtr, POINT pt)
     7915{
     7916    INT cxDrag = GetSystemMetrics(SM_CXDRAG);
     7917    INT cyDrag = GetSystemMetrics(SM_CYDRAG);
     7918    RECT r;
     7919    MSG msg;
     7920
     7921    TRACE("\n");
     7922
     7923    r.top = pt.y - cyDrag;
     7924    r.left = pt.x - cxDrag;
     7925    r.bottom = pt.y + cyDrag;
     7926    r.right = pt.x + cxDrag;
     7927
     7928    SetCapture(infoPtr->hwndSelf);
     7929
     7930    while (1)
     7931    {
     7932        if (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE | PM_NOYIELD))
     7933        {
     7934            if (msg.message == WM_MOUSEMOVE)
     7935            {
     7936                pt.x = (short)LOWORD(msg.lParam);
     7937                pt.y = (short)HIWORD(msg.lParam);
     7938                if (PtInRect(&r, pt))
     7939                    continue;
     7940                else
     7941                {
     7942                    ReleaseCapture();
     7943                    return 1;
     7944                }
     7945            }
     7946            else if (msg.message >= WM_LBUTTONDOWN &&
     7947                     msg.message <= WM_RBUTTONDBLCLK)
     7948            {
     7949                break;
     7950            }
     7951
     7952            DispatchMessageW(&msg);
     7953        }
     7954
     7955        if (GetCapture() != infoPtr->hwndSelf)
     7956            return 0;
     7957    }
     7958
     7959    ReleaseCapture();
     7960    return 0;
     7961}
     7962
    78407963
    78417964/***
     
    79108033  if ((nItem >= 0) && (nItem < infoPtr->nItemCount))
    79118034  {
     8035    if ((infoPtr->dwLvExStyle & LVS_EX_CHECKBOXES) && (lvHitTestInfo.flags & LVHT_ONITEMSTATEICON))
     8036    {
     8037        DWORD state = LISTVIEW_GetItemState(infoPtr, nItem, LVIS_STATEIMAGEMASK) >> 12;
     8038        if(state == 1 || state == 2)
     8039        {
     8040            LVITEMW lvitem;
     8041            state ^= 3;
     8042            lvitem.state = state << 12;
     8043            lvitem.stateMask = LVIS_STATEIMAGEMASK;
     8044            LISTVIEW_SetItemState(infoPtr, nItem, &lvitem);
     8045        }
     8046        return 0;
     8047    }
     8048    if (LISTVIEW_TrackMouse(infoPtr, lvHitTestInfo.pt))
     8049    {
     8050        NMLISTVIEW nmlv;
     8051
     8052        ZeroMemory(&nmlv, sizeof(nmlv));
     8053        nmlv.iItem = nItem;
     8054        nmlv.ptAction.x = lvHitTestInfo.pt.x;
     8055        nmlv.ptAction.y = lvHitTestInfo.pt.y;
     8056
     8057        notify_listview(infoPtr, LVN_BEGINDRAG, &nmlv);
     8058
     8059        return 0;
     8060    }
     8061
    79128062    if (infoPtr->dwStyle & LVS_SINGLESEL)
    79138063    {
     
    79678117    /* remove all selections */
    79688118    LISTVIEW_DeselectAll(infoPtr);
     8119    ReleaseCapture();
    79698120  }
    79708121
     
    79928143{
    79938144    LVHITTESTINFO lvHitTestInfo;
    7994    
     8145
    79958146    TRACE("(key=%hu, X=%hu, Y=%hu)\n", wKey, pts.x, pts.y);
    79968147
     
    80108161    if(lvHitTestInfo.iItem == infoPtr->nEditLabelItem && (lvHitTestInfo.flags & LVHT_ONITEMLABEL))
    80118162        LISTVIEW_EditLabelT(infoPtr, lvHitTestInfo.iItem, TRUE);
    8012 
    8013 #ifdef __WIN32OS2__
    8014   if(infoPtr->bDragInProcess) {
    8015       infoPtr->bDragInProcess = FALSE;
    8016   }
    8017 #endif 
    80188163
    80198164    return 0;
     
    80838228{
    80848229    UINT uView =  infoPtr->dwStyle & LVS_TYPEMASK;
    8085    
     8230
    80868231    TRACE("(lpnmh=%p)\n", lpnmh);
    80878232
    80888233    if (!lpnmh || lpnmh->iItem < 0 || lpnmh->iItem >= infoPtr->hdpaColumns->nItemCount) return 0;
    8089    
     8234
    80908235    switch (lpnmh->hdr.code)
    8091     {   
     8236    {
    80928237        case HDN_TRACKW:
    80938238        case HDN_TRACKA:
     
    81018246            {
    81028247                HDITEMW hdi;
    8103    
     8248
    81048249                hdi.mask = HDI_WIDTH;
    81058250                if (!Header_GetItemW(infoPtr->hwndHeader, lpnmh->iItem, (LPARAM)&hdi)) return 0;
     
    81088253            else
    81098254                cxy = lpnmh->pitem->cxy;
    8110            
     8255       
    81118256            /* determine how much we change since the last know position */
    81128257            lpColumnInfo = LISTVIEW_GetColumnInfo(infoPtr, lpnmh->iItem);
     
    81688313
    81698314    if (nCommand != NF_REQUERY) return 0;
    8170    
     8315
    81718316    infoPtr->notifyFormat = SendMessageW(hwndFrom, WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
    8172    
     8317
    81738318    return 0;
    81748319}
     
    82008345        LISTVIEW_UpdateScroll(infoPtr);
    82018346    }
    8202     if (hdc) 
     8347    if (hdc)
    82038348        LISTVIEW_Refresh(infoPtr, hdc);
    82048349    else
     
    82318376{
    82328377    LVHITTESTINFO lvHitTestInfo;
    8233    
     8378
    82348379    TRACE("(key=%hu,X=%hu,Y=%hu)\n", wKey, pts.x, pts.y);
    82358380
     
    82788423    lvHitTestInfo.pt.y = pts.y;
    82798424    nItem = LISTVIEW_HitTest(infoPtr, &lvHitTestInfo, TRUE, TRUE);
    8280  
     8425
    82818426    if ((nItem >= 0) && (nItem < infoPtr->nItemCount))
    82828427    {
     
    83148459
    83158460    if (!infoPtr->bRButtonDown) return 0;
    8316  
     8461
    83178462    /* set button flag */
    83188463    infoPtr->bRButtonDown = FALSE;
     
    83838528    /* if we have the focus already, there's nothing to do */
    83848529    if (infoPtr->bFocus) return 0;
    8385    
     8530
    83868531    /* send NM_SETFOCUS notification */
    83878532    notify(infoPtr, NM_SETFOCUS);
     
    84198564    infoPtr->hFont = hFont ? hFont : infoPtr->hDefaultFont;
    84208565    if (infoPtr->hFont == oldFont) return 0;
    8421    
     8566
    84228567    LISTVIEW_SaveTextMetrics(infoPtr);
    84238568
     
    84528597
    84538598    if(!bRedraw) return 0;
    8454    
     8599
    84558600    if (is_autoarrange(infoPtr))
    84568601        LISTVIEW_Arrange(infoPtr, LVA_DEFAULT);
     
    84858630    LISTVIEW_UpdateSize(infoPtr);
    84868631    if (EqualRect(&rcOld, &infoPtr->rcList)) return 0;
    8487  
    8488     /* do not bother with display related stuff if we're not redrawing */ 
     8632
     8633    /* do not bother with display related stuff if we're not redrawing */
    84898634    if (!is_redrawing(infoPtr)) return 0;
    8490    
    8491     if (is_autoarrange(infoPtr)) 
     8635
     8636    if (is_autoarrange(infoPtr))
    84928637        LISTVIEW_Arrange(infoPtr, LVA_DEFAULT);
    84938638
     
    84958640
    84968641    /* refresh all only for lists whose height changed significantly */
    8497     if ((infoPtr->dwStyle & LVS_TYPEMASK) == LVS_LIST && 
     8642    if ((infoPtr->dwStyle & LVS_TYPEMASK) == LVS_LIST &&
    84988643        (rcOld.bottom - rcOld.top) / infoPtr->nItemHeight !=
    84998644        (infoPtr->rcList.bottom - infoPtr->rcList.top) / infoPtr->nItemHeight)
     
    85188663
    85198664    TRACE("uView=%d, rcList(old)=%s\n", uView, debugrect(&infoPtr->rcList));
    8520    
     8665
    85218666    GetClientRect(infoPtr->hwndSelf, &infoPtr->rcList);
    85228667
     
    85738718
    85748719    if (wStyleType != GWL_STYLE) return 0;
    8575  
     8720
    85768721    /* FIXME: if LVS_NOSORTHEADER changed, update header */
    85778722    /*        what if LVS_OWNERDATA changed? */
     
    85938738        SIZE oldIconSize = infoPtr->iconSize;
    85948739        HIMAGELIST himl;
    8595    
     8740
    85968741        SendMessageW(infoPtr->hwndEdit, WM_KILLFOCUS, 0, 0);
    85978742        ShowWindow(infoPtr->hwndHeader, SW_HIDE);
     
    86028747        himl = (uNewView == LVS_ICON ? infoPtr->himlNormal : infoPtr->himlSmall);
    86038748        set_icon_size(&infoPtr->iconSize, himl, uNewView != LVS_ICON);
    8604    
     8749
    86058750        if (uNewView == LVS_ICON)
    86068751        {
     
    86288773    if (uNewView == LVS_REPORT)
    86298774        ShowWindow(infoPtr->hwndHeader, (lpss->styleNew & LVS_NOCOLUMNHEADER) ? SW_HIDE : SW_SHOWNORMAL);
    8630      
     8775
    86318776    if ( (uNewView == LVS_ICON || uNewView == LVS_SMALLICON) &&
    86328777         (uNewView != uOldView || ((lpss->styleNew ^ lpss->styleOld) & LVS_ALIGNMASK)) )
     
    89589103/* case LVM_CANCELEDITLABEL: */
    89599104
    8960 /* case LVM_CREATEDRAGIMAGE: */
     9105  case LVM_CREATEDRAGIMAGE:
     9106    return (LRESULT)LISTVIEW_CreateDragImage(infoPtr, (INT)wParam, (LPPOINT)lParam);
    89619107
    89629108  case LVM_DELETEALLITEMS:
     
    93939539
    93949540  case WM_WINDOWPOSCHANGED:
    9395       if (!(((WINDOWPOS *)lParam)->flags & SWP_NOSIZE)) 
     9541      if (!(((WINDOWPOS *)lParam)->flags & SWP_NOSIZE))
    93969542      {
    93979543          SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE |
Note: See TracChangeset for help on using the changeset viewer.