Changeset 10530
- Timestamp:
- Mar 16, 2004, 6:17:31 PM (21 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/include/win/commctrl.h ¶
r10447 r10530 1130 1130 #define TB_UNKWN45E (WM_USER+94) 1131 1131 #define TB_UNKWN460 (WM_USER+96) 1132 #define TB_UNKWN462 (WM_USER+98) 1132 1133 #define TB_UNKWN463 (WM_USER+99) 1133 1134 #define TB_UNKWN464 (WM_USER+100) -
TabularUnified trunk/src/comctl32/comctl32.h ¶
r10097 r10530 346 346 347 347 348 /* undocumented functions */ 349 350 LPVOID WINAPI COMCTL32_Alloc (DWORD); 351 #define Alloc(a) COMCTL32_Alloc(a) 352 353 LPVOID WINAPI COMCTL32_ReAlloc (LPVOID, DWORD); 354 BOOL WINAPI COMCTL32_Free (LPVOID); 355 #define Free(a) COMCTL32_Free(a) 356 DWORD WINAPI COMCTL32_GetSize (LPVOID); 357 348 358 #ifdef __cplusplus 349 359 } -
TabularUnified trunk/src/comctl32/listview.c ¶
r10448 r10530 26 26 * This code was audited for completeness against the documented features 27 27 * of Comctl32.dll version 6.0 on Oct. 21, 2002, by Dimitrie O. Paun. 28 * 29 * Unless otherwise noted, we beli ve this code to be complete, as per28 * 29 * Unless otherwise noted, we believe this code to be complete, as per 30 30 * the specification mentioned above. 31 31 * If you discover missing features, or bugs, please note them below. 32 * 32 * 33 33 * TODO: 34 34 * … … 42 42 * -- Expand large item in ICON mode when the cursor is flying over the icon or text. 43 43 * -- 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 45 45 * -- LVA_SNAPTOGRID not implemented 46 46 * -- LISTVIEW_ApproximateViewRect partially implemented … … 79 79 * Extended Styles 80 80 * -- LVS_EX_BORDERSELECT 81 * -- LVS_EX_CHECKBOXES82 81 * -- LVS_EX_FLATSB 83 82 * -- LVS_EX_GRIDLINES … … 89 88 * -- LVS_EX_REGIONAL 90 89 * -- LVS_EX_SIMPLESELECT 91 * -- LVS_EX_SUBITEMIMAGES92 90 * -- LVS_EX_TRACKSELECT 93 91 * -- LVS_EX_TWOCLICKACTIVATE 94 92 * -- LVS_EX_UNDERLINECOLD 95 93 * -- LVS_EX_UNDERLINEHOT 96 * 94 * 97 95 * Notifications: 98 * -- LVN_BEGINRDRAG99 96 * -- LVN_BEGINSCROLL, LVN_ENDSCROLL 100 97 * -- LVN_GETINFOTIP … … 108 105 * Messages: 109 106 * -- LVM_CANCELEDITLABEL 110 * -- LVM_CREATEDRAGIMAGE111 107 * -- LVM_ENABLEGROUPVIEW 112 108 * -- LVM_GETBKIMAGE, LVM_SETBKIMAGE … … 153 149 #include <string.h> 154 150 #include <stdlib.h> 151 #include <stdarg.h> 155 152 #include <stdio.h> 156 153 154 #include "windef.h" 157 155 #include "winbase.h" 158 156 #include "winnt.h" 157 #include "wingdi.h" 158 #include "winuser.h" 159 #include "winnls.h" 159 160 #include "commctrl.h" 160 161 #include "comctl32.h" … … 234 235 INT nHotItem; 235 236 SHORT notifyFormat; 237 HWND hwndNotify; 236 238 RECT rcList; /* This rectangle is really the window 237 * client rectangle possibly reduced by the 238 * horizontal scroll bar and/or header - see 239 * client rectangle possibly reduced by the 240 * horizontal scroll bar and/or header - see 239 241 * LISTVIEW_UpdateSize. This rectangle offset 240 242 * by the LISTVIEW_GetOrigin value is in … … 251 253 INT ntmAveCharWidth; /* by the listview to draw items */ 252 254 BOOL bRedraw; /* Turns on/off repaints & invalidations */ 253 BOOL bFirstPaint; /* Flags if the control has never painted before */254 255 BOOL bAutoarrange; /* Autoarrange flag when NOT in LVS_AUTOARRANGE */ 255 256 BOOL bFocus; … … 273 274 HWND hwndToolTip; 274 275 275 /* __WIN32OS2__: this might be sligtly fishy as the merge with wine is only partially done ... */276 276 DWORD cditemmode; /* Keep the custom draw flags for an item/row */ 277 277 … … 349 349 #define LV_ML_DT_FLAGS (DT_TOP | DT_NOPREFIX | DT_EDITCONTROL | DT_CENTER | DT_WORDBREAK | DT_WORD_ELLIPSIS | DT_END_ELLIPSIS) 350 350 #define LV_FL_DT_FLAGS (DT_TOP | DT_NOPREFIX | DT_EDITCONTROL | DT_CENTER | DT_WORDBREAK | DT_NOCLIP) 351 #define LV_SL_DT_FLAGS (DT_ TOP| DT_EDITCONTROL | DT_SINGLELINE | DT_WORD_ELLIPSIS | DT_END_ELLIPSIS)351 #define LV_SL_DT_FLAGS (DT_VCENTER | DT_EDITCONTROL | DT_SINGLELINE | DT_WORD_ELLIPSIS | DT_END_ELLIPSIS) 352 352 353 353 /* The time in milliseconds to reset the search in the list */ … … 396 396 static BOOL LISTVIEW_EnsureVisible(LISTVIEW_INFO *, INT, BOOL); 397 397 static HWND CreateEditLabelT(LISTVIEW_INFO *, LPCWSTR, DWORD, INT, INT, INT, INT, BOOL); 398 static HIMAGELIST LISTVIEW_SetImageList(LISTVIEW_INFO *, INT, HIMAGELIST); 398 399 399 400 /******** Text handling functions *************************************/ … … 460 461 { 461 462 BOOL bResult = TRUE; 462 463 463 464 if (src == LPSTR_TEXTCALLBACKW) 464 465 { 465 if (is_textW(*dest)) COMCTL32_Free(*dest);466 if (is_textW(*dest)) Free(*dest); 466 467 *dest = LPSTR_TEXTCALLBACKW; 467 468 } … … 491 492 textfreeT(bw, isW); 492 493 return r; 493 } 494 494 } 495 495 496 return 1; 496 497 } 497 498 498 499 static inline int lstrncmpiW(LPCWSTR s1, LPCWSTR s2, int n) 499 500 { … … 506 507 507 508 /******** Debugging functions *****************************************/ 508 509 509 #if defined(__WIN32OS2__) && !defined(DEBUG) 510 510 //can be removed when switching to GCC … … 522 522 #define debugscrollcode(nScrollCode) 0 523 523 #else 524 524 525 static inline LPCSTR debugtext_t(LPCWSTR text, BOOL isW) 525 526 { … … 546 547 } 547 548 548 static inline c har* debugrange(const RANGE *lprng)549 { 550 if (lprng) 549 static inline const char* debugrange(const RANGE *lprng) 550 { 551 if (lprng) 551 552 { 552 553 char* buf = debug_getbuf(); … … 556 557 } 557 558 558 static inline c har* debugpoint(const POINT *lppt)559 { 560 if (lppt) 559 static inline const char* debugpoint(const POINT *lppt) 560 { 561 if (lppt) 561 562 { 562 563 char* buf = debug_getbuf(); … … 566 567 } 567 568 568 static inline c har* debugrect(const RECT *rect)569 { 570 if (rect) 569 static inline const char* debugrect(const RECT *rect) 570 { 571 if (rect) 571 572 { 572 573 char* buf = debug_getbuf(); … … 577 578 } 578 579 579 static c har * debugscrollinfo(const SCROLLINFO *pScrollInfo)580 static const char * debugscrollinfo(const SCROLLINFO *pScrollInfo) 580 581 { 581 582 char* buf = debug_getbuf(), *text = buf; 582 583 int len, size = DEBUG_BUFFER_SIZE; 583 584 584 585 if (pScrollInfo == NULL) return "(null)"; 585 586 len = snprintf(buf, size, "{cbSize=%d, ", pScrollInfo->cbSize); … … 607 608 if (buf - text > 2) { buf[-2] = '}'; buf[-1] = 0; } 608 609 return text; 609 } 610 611 static c har* debugnmlistview(const NMLISTVIEW *plvnm)610 } 611 612 static const char* debugnmlistview(const NMLISTVIEW *plvnm) 612 613 { 613 614 if (plvnm) … … 622 623 } 623 624 624 static c har* debuglvitem_t(const LVITEMW *lpLVItem, BOOL isW)625 static const char* debuglvitem_t(const LVITEMW *lpLVItem, BOOL isW) 625 626 { 626 627 char* buf = debug_getbuf(), *text = buf; 627 628 int len, size = DEBUG_BUFFER_SIZE; 628 629 629 630 if (lpLVItem == NULL) return "(null)"; 630 631 len = snprintf(buf, size, "{iItem=%d, iSubItem=%d, ", lpLVItem->iItem, lpLVItem->iSubItem); … … 658 659 } 659 660 660 static c har* debuglvcolumn_t(const LVCOLUMNW *lpColumn, BOOL isW)661 static const char* debuglvcolumn_t(const LVCOLUMNW *lpColumn, BOOL isW) 661 662 { 662 663 char* buf = debug_getbuf(), *text = buf; 663 664 int len, size = DEBUG_BUFFER_SIZE; 664 665 665 666 if (lpColumn == NULL) return "(null)"; 666 667 len = snprintf(buf, size, "{"); … … 698 699 } 699 700 700 static c har* debuglvhittestinfo(const LVHITTESTINFO *lpht)701 { 702 if (lpht) 701 static const char* debuglvhittestinfo(const LVHITTESTINFO *lpht) 702 { 703 if (lpht) 703 704 { 704 705 char* buf = debug_getbuf(); … … 725 726 } 726 727 } 727 #endif 728 #endif /* __WIN32OS2__ */ 729 728 730 729 731 /******** Notification functions i************************************/ … … 732 734 { 733 735 LRESULT result; 734 736 735 737 TRACE("(code=%d)\n", code); 736 738 … … 738 740 pnmh->idFrom = GetWindowLongW(infoPtr->hwndSelf, GWL_ID); 739 741 pnmh->code = code; 740 result = SendMessageW( GetParent(infoPtr->hwndSelf), WM_NOTIFY,742 result = SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, 741 743 (WPARAM)pnmh->idFrom, (LPARAM)pnmh); 742 744 … … 752 754 } 753 755 754 static inline void notify_itemactivate(LISTVIEW_INFO *infoPtr) 755 { 756 notify(infoPtr, LVN_ITEMACTIVATE); 756 static inline void notify_itemactivate(LISTVIEW_INFO *infoPtr, LVHITTESTINFO *htInfo) 757 { 758 NMITEMACTIVATE nmia; 759 LVITEMW item; 760 761 if (htInfo) { 762 nmia.uNewState = 0; 763 nmia.uOldState = 0; 764 nmia.uChanged = 0; 765 nmia.uKeyFlags = 0; 766 767 item.mask = LVIF_PARAM|LVIF_STATE; 768 item.iItem = htInfo->iItem; 769 item.iSubItem = 0; 770 if (LISTVIEW_GetItemT(infoPtr, &item, TRUE)) { 771 nmia.lParam = item.lParam; 772 nmia.uOldState = item.state; 773 nmia.uNewState = item.state | LVIS_ACTIVATING; 774 nmia.uChanged = LVIF_STATE; 775 } 776 777 nmia.iItem = htInfo->iItem; 778 nmia.iSubItem = htInfo->iSubItem; 779 nmia.ptAction = htInfo->pt; 780 781 if (GetKeyState(VK_SHIFT) & 0x8000) nmia.uKeyFlags |= LVKF_SHIFT; 782 if (GetKeyState(VK_CONTROL) & 0x8000) nmia.uKeyFlags |= LVKF_CONTROL; 783 if (GetKeyState(VK_MENU) & 0x8000) nmia.uKeyFlags |= LVKF_ALT; 784 } 785 notify_hdr(infoPtr, LVN_ITEMACTIVATE, (LPNMHDR)&nmia); 757 786 } 758 787 … … 767 796 NMLISTVIEW nmlv; 768 797 LVITEMW item; 769 770 TRACE("code=%d, lvht=%s\n", code, debuglvhittestinfo(lvht)); 798 799 TRACE("code=%d, lvht=%s\n", code, debuglvhittestinfo(lvht)); 771 800 ZeroMemory(&nmlv, sizeof(nmlv)); 772 801 nmlv.iItem = lvht->iItem; … … 784 813 NMLISTVIEW nmlv; 785 814 LVITEMW item; 786 815 787 816 ZeroMemory(&nmlv, sizeof (NMLISTVIEW)); 788 817 nmlv.iItem = nItem; … … 873 902 } 874 903 875 static void customdraw_fill(NMLVCUSTOMDRAW *lpnmlvcd, LISTVIEW_INFO *infoPtr, HDC hdc, 904 static void customdraw_fill(NMLVCUSTOMDRAW *lpnmlvcd, LISTVIEW_INFO *infoPtr, HDC hdc, 876 905 const RECT *rcBounds, const LVITEMW *lplvItem) 877 906 { … … 896 925 897 926 lpnmlvcd->nmcd.dwDrawStage = dwDrawStage; 898 if (isForItem) lpnmlvcd->nmcd.dwDrawStage |= CDDS_ITEM; 927 if (isForItem) lpnmlvcd->nmcd.dwDrawStage |= CDDS_ITEM; 899 928 if (lpnmlvcd->iSubItem) lpnmlvcd->nmcd.dwDrawStage |= CDDS_SUBITEM; 900 929 if (isForItem) lpnmlvcd->nmcd.dwItemSpec--; … … 904 933 } 905 934 906 static DWORD notify_prepaint (LISTVIEW_INFO *infoPtr, HDC hdc, NMLVCUSTOMDRAW *lpnmlvcd) 907 { 908 BOOL isSelected = lpnmlvcd->nmcd.uItemState & CDIS_SELECTED; 909 DWORD cditemmode = notify_customdraw(infoPtr, CDDS_PREPAINT, lpnmlvcd); 910 911 if (cditemmode & CDRF_SKIPDEFAULT) return cditemmode; 912 935 static void prepaint_setup (LISTVIEW_INFO *infoPtr, HDC hdc, NMLVCUSTOMDRAW *lpnmlvcd) 936 { 913 937 /* apprently, for selected items, we have to override the returned values */ 914 if ( isSelected)938 if (lpnmlvcd->nmcd.uItemState & CDIS_SELECTED) 915 939 { 916 940 if (infoPtr->bFocus) … … 938 962 SetBkMode(hdc, TRANSPARENT); 939 963 SetTextColor(hdc, lpnmlvcd->clrText); 940 941 return cditemmode;942 964 } 943 965 … … 988 1010 * after it's done with it, as the creation of the iterator may 989 1011 * allocate memory, which thus needs to be freed. 990 * 1012 * 991 1013 * You can iterate both forwards, and backwards through the list, 992 1014 * by using iterator_next or iterator_prev respectively. 993 * 1015 * 994 1016 * Lower numbered items are draw on top of higher number items in 995 1017 * LVS_ICON, and LVS_SMALLICON (which are the only modes where … … 1015 1037 * LVS_ICON, and LVS_SMALLICON mode to handle the focused item, 1016 1038 * which needs to be first, as it may overlap other items. 1017 * 1039 * 1018 1040 * The code is a bit messy because we have: 1019 1041 * - a special item to deal with … … 1051 1073 if (i->ranges) 1052 1074 { 1053 if (i->index < i->ranges->hdpa->nItemCount)1075 if (i->index < DPA_GetPtrCount(i->ranges->hdpa)) 1054 1076 i->range = *(RANGE*)DPA_GetPtr(i->ranges->hdpa, i->index++); 1055 1077 else goto end; … … 1077 1099 { 1078 1100 start = TRUE; 1079 if (i->ranges) i->index = i->ranges->hdpa->nItemCount;1101 if (i->ranges) i->index = DPA_GetPtrCount(i->ranges->hdpa); 1080 1102 goto pickarange; 1081 1103 } … … 1113 1135 1114 1136 range.lower = (*(RANGE*)DPA_GetPtr(i->ranges->hdpa, 0)).lower; 1115 range.upper = (*(RANGE*)DPA_GetPtr(i->ranges->hdpa, i->ranges->hdpa->nItemCount- 1)).upper;1137 range.upper = (*(RANGE*)DPA_GetPtr(i->ranges->hdpa, DPA_GetPtrCount(i->ranges->hdpa) - 1)).upper; 1116 1138 return range; 1117 1139 } … … 1165 1187 RECT frame = *lprc, rcItem, rcTemp; 1166 1188 POINT Origin; 1167 1189 1168 1190 /* in case we fail, we want to return an empty iterator */ 1169 1191 if (!iterator_empty(i)) return FALSE; … … 1250 1272 RECT rcItem, rcClip; 1251 1273 INT rgntype; 1252 1274 1253 1275 rgntype = GetClipBox(hdc, &rcClip); 1254 1276 if (rgntype == NULLREGION) return iterator_empty(i); … … 1262 1284 if (!RectVisible(hdc, &rcItem)) i->nSpecial = -1; 1263 1285 } 1264 1286 1265 1287 /* if we can't deal with the region, we'll just go with the simple range */ 1266 1288 LISTVIEW_GetOrigin(infoPtr, &Origin); … … 1290 1312 /* the iterator should restart on the next iterator_next */ 1291 1313 TRACE("done\n"); 1292 1314 1293 1315 return TRUE; 1294 1316 } … … 1306 1328 { 1307 1329 UINT uView = infoPtr->dwStyle & LVS_TYPEMASK; 1308 1330 1309 1331 return ((infoPtr->dwStyle & LVS_AUTOARRANGE) || infoPtr->bAutoarrange) && 1310 1332 (uView == LVS_ICON || uView == LVS_SMALLICON); … … 1317 1339 static COLUMN_INFO mainItem; 1318 1340 1319 if (nSubItem == 0 && infoPtr->hdpaColumns->nItemCount== 0) return &mainItem;1320 assert (nSubItem >= 0 && nSubItem < infoPtr->hdpaColumns->nItemCount);1341 if (nSubItem == 0 && DPA_GetPtrCount(infoPtr->hdpaColumns) == 0) return &mainItem; 1342 assert (nSubItem >= 0 && nSubItem < DPA_GetPtrCount(infoPtr->hdpaColumns)); 1321 1343 return (COLUMN_INFO *)DPA_GetPtr(infoPtr->hdpaColumns, nSubItem); 1322 1344 } … … 1336 1358 static inline BOOL is_redrawing(LISTVIEW_INFO *infoPtr) 1337 1359 { 1338 return infoPtr->bRedraw && !infoPtr->bFirstPaint;1360 return infoPtr->bRedraw; 1339 1361 } 1340 1362 1341 1363 static inline void LISTVIEW_InvalidateRect(LISTVIEW_INFO *infoPtr, const RECT* rect) 1342 1364 { 1343 if(!is_redrawing(infoPtr)) return; 1365 if(!is_redrawing(infoPtr)) return; 1344 1366 TRACE(" invalidating rect=%s\n", debugrect(rect)); 1345 1367 InvalidateRect(infoPtr->hwndSelf, rect, TRUE); … … 1350 1372 RECT rcBox; 1351 1373 1352 if(!is_redrawing(infoPtr)) return; 1374 if(!is_redrawing(infoPtr)) return; 1353 1375 LISTVIEW_GetItemBox(infoPtr, nItem, &rcBox); 1354 1376 LISTVIEW_InvalidateRect(infoPtr, &rcBox); … … 1359 1381 POINT Origin, Position; 1360 1382 RECT rcBox; 1361 1362 if(!is_redrawing(infoPtr)) return; 1383 1384 if(!is_redrawing(infoPtr)) return; 1363 1385 assert ((infoPtr->dwStyle & LVS_TYPEMASK) == LVS_REPORT); 1364 1386 LISTVIEW_GetOrigin(infoPtr, &Origin); … … 1379 1401 { 1380 1402 RECT rcCol; 1381 1382 if(!is_redrawing(infoPtr)) return; 1403 1404 if(!is_redrawing(infoPtr)) return; 1383 1405 LISTVIEW_GetHeaderRect(infoPtr, nColumn, &rcCol); 1384 1406 rcCol.top = infoPtr->rcList.top; … … 1631 1653 if (LISTVIEW_GetViewRect(infoPtr, &rcView)) horzInfo.nMax = rcView.right - rcView.left; 1632 1654 } 1633 1655 1634 1656 horzInfo.fMask = SIF_RANGE | SIF_PAGE; 1635 1657 horzInfo.nMax = max(horzInfo.nMax - 1, 0); … … 1680 1702 /*** 1681 1703 * DESCRIPTION: 1682 * Shows/hides the focus rectangle. 1704 * Shows/hides the focus rectangle. 1683 1705 * 1684 1706 * PARAMETER(S): … … 1703 1725 RECT rcBox; 1704 1726 1705 LISTVIEW_GetItemBox(infoPtr, infoPtr->nFocusedItem, &rcBox); 1727 LISTVIEW_GetItemBox(infoPtr, infoPtr->nFocusedItem, &rcBox); 1706 1728 if ((rcBox.bottom - rcBox.top) > infoPtr->nItemHeight) 1707 1729 { … … 1723 1745 item.mask = LVIF_PARAM; 1724 1746 if (!LISTVIEW_GetItemW(infoPtr, &item)) goto done; 1725 1726 ZeroMemory(&dis, sizeof(dis)); 1747 1748 ZeroMemory(&dis, sizeof(dis)); 1727 1749 dis.CtlType = ODT_LISTVIEW; 1728 1750 dis.CtlID = GetWindowLongW(infoPtr->hwndSelf, GWL_ID); … … 1735 1757 dis.itemData = item.lParam; 1736 1758 1737 SendMessageW( GetParent(infoPtr->hwndSelf), WM_DRAWITEM, dis.CtlID, (LPARAM)&dis);1759 SendMessageW(infoPtr->hwndNotify, WM_DRAWITEM, dis.CtlID, (LPARAM)&dis); 1738 1760 } 1739 1761 else … … 1750 1772 static void LISTVIEW_InvalidateSelectedItems(LISTVIEW_INFO *infoPtr) 1751 1773 { 1752 ITERATOR i; 1753 1754 iterator_frameditems(&i, infoPtr, &infoPtr->rcList); 1774 ITERATOR i; 1775 1776 iterator_frameditems(&i, infoPtr, &infoPtr->rcList); 1755 1777 while(iterator_next(&i)) 1756 1778 { … … 1761 1783 } 1762 1784 1763 1785 1764 1786 /*** 1765 1787 * DESCRIPTION: [INTERNAL] … … 1770 1792 * one ca factor the computation of the Origin before the loop, 1771 1793 * and offset the value retured by this function, on every iteration. 1772 * 1794 * 1773 1795 * PARAMETER(S): 1774 1796 * [I] infoPtr : valid pointer to the listview structure … … 1802 1824 } 1803 1825 } 1804 1826 1805 1827 /*** 1806 1828 * DESCRIPTION: [INTERNAL] … … 1845 1867 */ 1846 1868 static void LISTVIEW_GetItemMetrics(LISTVIEW_INFO *infoPtr, const LVITEMW *lpLVItem, 1847 LPRECT lprcBox, LPRECT lprcState, 1869 LPRECT lprcBox, LPRECT lprcState, 1848 1870 LPRECT lprcIcon, LPRECT lprcLabel) 1849 1871 { … … 1865 1887 if (doLabel || lprcIcon) doIcon = TRUE; 1866 1888 if (doIcon || lprcState) doState = TRUE; 1867 1889 1868 1890 /************************************************************/ 1869 1891 /* compute the box rectangle (it should be cheap to do) */ … … 1872 1894 lpColumnInfo = LISTVIEW_GetColumnInfo(infoPtr, lpLVItem->iSubItem); 1873 1895 1874 if (lpLVItem->iSubItem) 1896 if (lpLVItem->iSubItem) 1875 1897 { 1876 1898 Box = lpColumnInfo->rcHeader; … … 1892 1914 { 1893 1915 State.left = Box.left - infoPtr->iconStateSize.cx - 2; 1894 if (infoPtr->himlNormal) 1916 if (infoPtr->himlNormal) 1895 1917 State.left += (infoPtr->nItemWidth - infoPtr->iconSize.cx) / 2; 1896 1918 State.top = Box.top + infoPtr->iconSize.cy - infoPtr->iconStateSize.cy + 4; … … 1900 1922 /* we need the ident in report mode, if we don't have it, we fail */ 1901 1923 State.left = Box.left; 1902 if (uView == LVS_REPORT) 1924 if (uView == LVS_REPORT) 1903 1925 { 1904 1926 if (lpLVItem->iSubItem == 0) … … 1930 1952 { 1931 1953 Icon.left = Box.left; 1932 if (infoPtr->himlNormal) 1954 if (infoPtr->himlNormal) 1933 1955 Icon.left += (infoPtr->nItemWidth - infoPtr->iconSize.cx) / 2; 1934 1956 Icon.top = Box.top + ICON_TOP_PADDING; … … 1946 1968 Icon.top = Box.top; 1947 1969 Icon.right = Icon.left; 1948 if (infoPtr->himlSmall && (!lpColumnInfo || lpLVItem->iSubItem == 0 || (lpColumnInfo->fmt & LVCFMT_IMAGE))) 1970 if (infoPtr->himlSmall && 1971 (!lpColumnInfo || lpLVItem->iSubItem == 0 || (lpColumnInfo->fmt & LVCFMT_IMAGE) || 1972 ((infoPtr->dwLvExStyle & LVS_EX_SUBITEMIMAGES) && lpLVItem->iImage != I_IMAGECALLBACK))) 1949 1973 Icon.right += infoPtr->iconSize.cx; 1950 1974 Icon.bottom = Icon.top + infoPtr->nItemHeight; … … 1989 2013 rcText.right = infoPtr->nItemWidth - TRAILING_LABEL_PADDING; 1990 2014 rcText.bottom = infoPtr->nItemHeight; 1991 if (uView == LVS_ICON) 2015 if (uView == LVS_ICON) 1992 2016 rcText.bottom -= ICON_TOP_PADDING + infoPtr->iconSize.cy + ICON_BOTTOM_PADDING; 1993 2017 … … 1997 2021 else 1998 2022 uFormat = LV_SL_DT_FLAGS; 1999 2023 2000 2024 DrawTextW (hdc, lpLVItem->pszText, -1, &rcText, uFormat | DT_CALCRECT); 2001 2025 … … 2031 2055 Label.bottom = Label.top + infoPtr->nItemHeight; 2032 2056 } 2033 2057 2034 2058 if (lprcLabel) *lprcLabel = Label; 2035 2059 TRACE(" - label=%s\n", debugrect(&Label)); … … 2102 2126 { 2103 2127 INT nListWidth = infoPtr->rcList.right - infoPtr->rcList.left; 2104 2128 2105 2129 *lpPos = infoPtr->currIconPos; 2106 2130 2107 2131 infoPtr->currIconPos.x += infoPtr->nItemWidth; 2108 2132 if (infoPtr->currIconPos.x + infoPtr->nItemWidth <= nListWidth) return; … … 2112 2136 } 2113 2137 2114 2138 2115 2139 /*** 2116 2140 * DESCRIPTION: … … 2128 2152 { 2129 2153 INT nListHeight = infoPtr->rcList.bottom - infoPtr->rcList.top; 2130 2154 2131 2155 *lpPos = infoPtr->currIconPos; 2132 2156 2133 2157 infoPtr->currIconPos.y += infoPtr->nItemHeight; 2134 2158 if (infoPtr->currIconPos.y + infoPtr->nItemHeight <= nListHeight) return; … … 2138 2162 } 2139 2163 2140 2164 2141 2165 /*** 2142 2166 * DESCRIPTION: … … 2157 2181 { 2158 2182 POINT old; 2159 2183 2160 2184 if (!isNew) 2161 { 2185 { 2162 2186 old.x = (LONG)DPA_GetPtr(infoPtr->hdpaPosX, nItem); 2163 2187 old.y = (LONG)DPA_GetPtr(infoPtr->hdpaPosY, nItem); 2164 2188 2165 2189 if (lppt->x == old.x && lppt->y == old.y) return TRUE; 2166 2190 LISTVIEW_InvalidateItem(infoPtr, nItem); … … 2197 2221 2198 2222 if (uView != LVS_ICON && uView != LVS_SMALLICON) return FALSE; 2199 2223 2200 2224 TRACE("nAlignCode=%d\n", nAlignCode); 2201 2225 … … 2205 2229 else nAlignCode = LVA_ALIGNTOP; 2206 2230 } 2207 2231 2208 2232 switch (nAlignCode) 2209 2233 { … … 2213 2237 default: return FALSE; 2214 2238 } 2215 2239 2216 2240 infoPtr->bAutoarrange = TRUE; 2217 2241 infoPtr->currIconPos.x = infoPtr->currIconPos.y = 0; … … 2224 2248 return TRUE; 2225 2249 } 2226 2250 2227 2251 /*** 2228 2252 * DESCRIPTION: … … 2269 2293 break; 2270 2294 2271 case LVS_REPORT: 2295 case LVS_REPORT: 2272 2296 lprcView->right = infoPtr->nItemWidth; 2273 2297 lprcView->bottom = infoPtr->nItemCount * infoPtr->nItemHeight; … … 2295 2319 2296 2320 if (!lprcView) return FALSE; 2297 2321 2298 2322 LISTVIEW_GetOrigin(infoPtr, &ptOrigin); 2299 LISTVIEW_GetAreaRect(infoPtr, lprcView); 2300 OffsetRect(lprcView, ptOrigin.x, ptOrigin.y); 2323 LISTVIEW_GetAreaRect(infoPtr, lprcView); 2324 OffsetRect(lprcView, ptOrigin.x, ptOrigin.y); 2301 2325 2302 2326 TRACE("lprcView=%s\n", debugrect(lprcView)); … … 2323 2347 2324 2348 /* we should binary search here if need be */ 2325 for (i = 1; i < hdpaSubItems->nItemCount; i++)2349 for (i = 1; i < DPA_GetPtrCount(hdpaSubItems); i++) 2326 2350 { 2327 2351 lpSubItem = (SUBITEM_INFO *)DPA_GetPtr(hdpaSubItems, i); … … 2357 2381 RECT rcHeader; 2358 2382 2359 if ( infoPtr->hdpaColumns->nItemCount> 0)2383 if (DPA_GetPtrCount(infoPtr->hdpaColumns) > 0) 2360 2384 { 2361 LISTVIEW_GetHeaderRect(infoPtr, infoPtr->hdpaColumns->nItemCount- 1, &rcHeader);2385 LISTVIEW_GetHeaderRect(infoPtr, DPA_GetPtrCount(infoPtr->hdpaColumns) - 1, &rcHeader); 2362 2386 nItemWidth = rcHeader.right; 2363 2387 } … … 2370 2394 nItemWidth = max(LISTVIEW_GetLabelWidth(infoPtr, i), nItemWidth); 2371 2395 2372 if (infoPtr->himlSmall) nItemWidth += infoPtr->iconSize.cx; 2396 if (infoPtr->himlSmall) nItemWidth += infoPtr->iconSize.cx; 2373 2397 if (infoPtr->himlState) nItemWidth += infoPtr->iconStateSize.cx; 2374 2398 … … 2400 2424 else 2401 2425 { 2402 nItemHeight = infoPtr->ntmHeight; 2426 nItemHeight = infoPtr->ntmHeight; 2403 2427 if (infoPtr->himlState) 2404 2428 nItemHeight = max(nItemHeight, infoPtr->iconStateSize.cy); … … 2424 2448 } 2425 2449 #endif 2450 2426 2451 } 2427 2452 … … 2469 2494 SelectObject(hdc, hOldFont); 2470 2495 ReleaseDC(infoPtr->hwndSelf, hdc); 2471 2496 2472 2497 TRACE("tmHeight=%d\n", infoPtr->ntmHeight); 2473 2498 } … … 2490 2515 { 2491 2516 INT cmp; 2492 2493 if (((RANGE*)range1)->upper <= ((RANGE*)range2)->lower) 2517 2518 if (((RANGE*)range1)->upper <= ((RANGE*)range2)->lower) 2494 2519 cmp = -1; 2495 else if (((RANGE*)range2)->upper <= ((RANGE*)range1)->lower) 2520 else if (((RANGE*)range2)->upper <= ((RANGE*)range1)->lower) 2496 2521 cmp = 1; 2497 else 2522 else 2498 2523 cmp = 0; 2499 2524 2500 2525 TRACE("range1=%s, range2=%s, cmp=%d\n", debugrange((RANGE*)range1), debugrange((RANGE*)range2), cmp); 2501 2526 … … 2513 2538 INT i; 2514 2539 RANGE *prev, *curr; 2515 2540 2516 2541 TRACE("*** Checking %s:%d:%s ***\n", func, line, desc); 2517 2542 assert (ranges); 2518 assert ( ranges->hdpa->nItemCount>= 0);2543 assert (DPA_GetPtrCount(ranges->hdpa) >= 0); 2519 2544 ranges_dump(ranges); 2520 2545 prev = (RANGE *)DPA_GetPtr(ranges->hdpa, 0); 2521 if ( ranges->hdpa->nItemCount> 0)2546 if (DPA_GetPtrCount(ranges->hdpa) > 0) 2522 2547 assert (prev->lower >= 0 && prev->lower < prev->upper); 2523 for (i = 1; i < ranges->hdpa->nItemCount; i++)2548 for (i = 1; i < DPA_GetPtrCount(ranges->hdpa); i++) 2524 2549 { 2525 2550 curr = (RANGE *)DPA_GetPtr(ranges->hdpa, i); … … 2533 2558 static RANGES ranges_create(int count) 2534 2559 { 2535 RANGES ranges = (RANGES) COMCTL32_Alloc(sizeof(struct tagRANGES));2560 RANGES ranges = (RANGES)Alloc(sizeof(struct tagRANGES)); 2536 2561 if (!ranges) return NULL; 2537 2562 ranges->hdpa = DPA_Create(count); 2538 2563 if (ranges->hdpa) return ranges; 2539 COMCTL32_Free(ranges);2564 Free(ranges); 2540 2565 return NULL; 2541 2566 } … … 2545 2570 INT i; 2546 2571 2547 for(i = 0; i < ranges->hdpa->nItemCount; i++)2548 COMCTL32_Free(DPA_GetPtr(ranges->hdpa, i));2572 for(i = 0; i < DPA_GetPtrCount(ranges->hdpa); i++) 2573 Free(DPA_GetPtr(ranges->hdpa, i)); 2549 2574 DPA_DeleteAllPtrs(ranges->hdpa); 2550 2575 } … … 2556 2581 ranges_clear(ranges); 2557 2582 DPA_Destroy(ranges->hdpa); 2558 COMCTL32_Free(ranges);2583 Free(ranges); 2559 2584 } 2560 2585 … … 2563 2588 RANGES clone; 2564 2589 INT i; 2565 2566 if (!(clone = ranges_create( ranges->hdpa->nItemCount))) goto fail;2567 2568 for (i = 0; i < ranges->hdpa->nItemCount; i++)2569 { 2570 RANGE *newrng = (RANGE *) COMCTL32_Alloc(sizeof(RANGE));2590 2591 if (!(clone = ranges_create(DPA_GetPtrCount(ranges->hdpa)))) goto fail; 2592 2593 for (i = 0; i < DPA_GetPtrCount(ranges->hdpa); i++) 2594 { 2595 RANGE *newrng = (RANGE *)Alloc(sizeof(RANGE)); 2571 2596 if (!newrng) goto fail; 2572 2597 *newrng = *((RANGE*)DPA_GetPtr(ranges->hdpa, i)); … … 2574 2599 } 2575 2600 return clone; 2576 2601 2577 2602 fail: 2578 2603 TRACE ("clone failed\n"); … … 2585 2610 INT i; 2586 2611 2587 for (i = 0; i < sub->hdpa->nItemCount; i++)2612 for (i = 0; i < DPA_GetPtrCount(sub->hdpa); i++) 2588 2613 ranges_del(ranges, *((RANGE *)DPA_GetPtr(sub->hdpa, i))); 2589 2614 … … 2595 2620 INT i; 2596 2621 2597 for (i = 0; i < ranges->hdpa->nItemCount; i++)2622 for (i = 0; i < DPA_GetPtrCount(ranges->hdpa); i++) 2598 2623 TRACE(" %s\n", debugrange(DPA_GetPtr(ranges->hdpa, i))); 2599 2624 } … … 2611 2636 { 2612 2637 INT i, count = 0; 2613 2614 for (i = 0; i < ranges->hdpa->nItemCount; i++)2638 2639 for (i = 0; i < DPA_GetPtrCount(ranges->hdpa); i++) 2615 2640 { 2616 2641 RANGE *sel = DPA_GetPtr(ranges->hdpa, i); … … 2629 2654 if (index == -1) return TRUE; 2630 2655 2631 for (; index < ranges->hdpa->nItemCount; index++)2656 for (; index < DPA_GetPtrCount(ranges->hdpa); index++) 2632 2657 { 2633 2658 chkrng = DPA_GetPtr(ranges->hdpa, index); … … 2652 2677 srchrgn.upper = range.upper + 1; 2653 2678 index = DPA_Search(ranges->hdpa, &srchrgn, 0, ranges_cmp, 0, DPAS_SORTED); 2654 2679 2655 2680 if (index == -1) 2656 2681 { … … 2660 2685 2661 2686 /* create the brand new range to insert */ 2662 newrgn = (RANGE *) COMCTL32_Alloc(sizeof(RANGE));2687 newrgn = (RANGE *)Alloc(sizeof(RANGE)); 2663 2688 if(!newrgn) goto fail; 2664 2689 *newrgn = range; … … 2672 2697 if (DPA_InsertPtr(ranges->hdpa, index, newrgn) == -1) 2673 2698 { 2674 COMCTL32_Free(newrgn);2699 Free(newrgn); 2675 2700 goto fail; 2676 2701 } … … 2693 2718 srchrgn.lower = chkrgn->lower - 1; 2694 2719 srchrgn.upper = chkrgn->upper + 1; 2695 2720 2696 2721 do 2697 2722 { 2698 2723 mergeindex = DPA_Search(ranges->hdpa, &srchrgn, fromindex, ranges_cmp, 0, 0); 2699 2724 if (mergeindex == -1) break; 2700 if (mergeindex == index) 2725 if (mergeindex == index) 2701 2726 { 2702 2727 fromindex = index + 1; 2703 2728 continue; 2704 2729 } 2705 2730 2706 2731 TRACE("Merge with index %i\n", mergeindex); 2707 2732 2708 2733 mrgrgn = DPA_GetPtr(ranges->hdpa, mergeindex); 2709 2734 chkrgn->lower = min(chkrgn->lower, mrgrgn->lower); 2710 2735 chkrgn->upper = max(chkrgn->upper, mrgrgn->upper); 2711 COMCTL32_Free(mrgrgn);2736 Free(mrgrgn); 2712 2737 DPA_DeletePtr(ranges->hdpa, mergeindex); 2713 2738 if (mergeindex < index) index --; … … 2717 2742 ranges_check(ranges, "after add"); 2718 2743 return TRUE; 2719 2744 2720 2745 fail: 2721 2746 ranges_check(ranges, "failed add"); … … 2730 2755 TRACE("(%s)\n", debugrange(&range)); 2731 2756 ranges_check(ranges, "before del"); 2732 2757 2733 2758 /* we don't use DPAS_SORTED here, since we need * 2734 2759 * to find the first overlapping range */ 2735 2760 index = DPA_Search(ranges->hdpa, &range, 0, ranges_cmp, 0, 0); 2736 while(index != -1) 2761 while(index != -1) 2737 2762 { 2738 2763 chkrgn = DPA_GetPtr(ranges->hdpa, index); 2739 2764 2740 TRACE("Matches range %s @%d\n", debugrange(chkrgn), index); 2765 TRACE("Matches range %s @%d\n", debugrange(chkrgn), index); 2741 2766 2742 2767 /* case 1: Same range */ … … 2749 2774 /* case 2: engulf */ 2750 2775 else if ( (chkrgn->upper <= range.upper) && 2751 (chkrgn->lower >= range.lower) ) 2776 (chkrgn->lower >= range.lower) ) 2752 2777 { 2753 2778 DPA_DeletePtr(ranges->hdpa, index); … … 2771 2796 RANGE tmprgn = *chkrgn, *newrgn; 2772 2797 2773 if (!(newrgn = (RANGE *) COMCTL32_Alloc(sizeof(RANGE)))) goto fail;2798 if (!(newrgn = (RANGE *)Alloc(sizeof(RANGE)))) goto fail; 2774 2799 newrgn->lower = chkrgn->lower; 2775 2800 newrgn->upper = range.lower; … … 2777 2802 if (DPA_InsertPtr(ranges->hdpa, index, newrgn) == -1) 2778 2803 { 2779 COMCTL32_Free(newrgn);2804 Free(newrgn); 2780 2805 goto fail; 2781 2806 } … … 2817 2842 lvItem.state = 0; 2818 2843 lvItem.stateMask = LVIS_SELECTED; 2819 2844 2820 2845 /* need to clone the DPA because callbacks can change it */ 2821 2846 if (!(clone = ranges_clone(infoPtr->selectionRanges))) return FALSE; … … 2832 2857 { 2833 2858 RANGES toSkip; 2834 2859 2835 2860 if (!(toSkip = ranges_create(1))) return FALSE; 2836 2861 if (nItem != -1) ranges_additem(toSkip, nItem); … … 2893 2918 2894 2919 if (nItem == infoPtr->nFocusedItem) return FALSE; 2895 2920 2896 2921 lvItem.state = nItem == -1 ? 0 : LVIS_FOCUSED; 2897 2922 lvItem.stateMask = LVIS_FOCUSED; … … 2945 2970 if (nNewFocus != infoPtr->nFocusedItem) 2946 2971 LISTVIEW_SetItemFocus(infoPtr, nNewFocus); 2947 2972 2948 2973 /* But we are not supposed to modify nHotItem! */ 2949 2974 … … 3006 3031 if (!(selection = ranges_create(100))) return; 3007 3032 3008 item.state = LVIS_SELECTED; 3033 item.state = LVIS_SELECTED; 3009 3034 item.stateMask = LVIS_SELECTED; 3010 3035 … … 3019 3044 { 3020 3045 RANGE sel; 3021 3046 3022 3047 sel.lower = min(infoPtr->nSelectionMark, nItem); 3023 3048 sel.upper = max(infoPtr->nSelectionMark, nItem) + 1; … … 3050 3075 /* this will also destroy the selection */ 3051 3076 iterator_destroy(&i); 3052 3077 3053 3078 LISTVIEW_SetItemFocus(infoPtr, nItem); 3054 3079 } … … 3070 3095 3071 3096 TRACE("nItem=%d\n", nItem); 3072 3097 3073 3098 LISTVIEW_DeselectAllSkipItem(infoPtr, nItem); 3074 3099 … … 3192 3217 } 3193 3218 } 3219 3194 3220 return 0; 3195 3221 } … … 3197 3223 3198 3224 /*** 3199 * Tests wheather the item is assignable to a list with style lStyle 3225 * Tests wheather the item is assignable to a list with style lStyle 3200 3226 */ 3201 3227 static inline BOOL is_assignable_item(const LVITEMW *lpLVItem, LONG lStyle) 3202 3228 { 3203 if ( (lpLVItem->mask & LVIF_TEXT) && 3229 if ( (lpLVItem->mask & LVIF_TEXT) && 3204 3230 (lpLVItem->pszText == LPSTR_TEXTCALLBACKW) && 3205 3231 (lStyle & (LVS_SORTASCENDING | LVS_SORTDESCENDING)) ) return FALSE; 3206 3232 3207 3233 return TRUE; 3208 3234 } … … 3235 3261 3236 3262 assert(lpLVItem->iItem >= 0 && lpLVItem->iItem < infoPtr->nItemCount); 3237 3238 if (lpLVItem->mask == 0) return TRUE; 3263 3264 if (lpLVItem->mask == 0) return TRUE; 3239 3265 3240 3266 if (infoPtr->dwStyle & LVS_OWNERDATA) … … 3262 3288 3263 3289 TRACE("oldState=%x, newState=%x\n", item.state, lpLVItem->state); 3264 /* determine what fields will change */ 3290 /* determine what fields will change */ 3265 3291 if ((lpLVItem->mask & LVIF_STATE) && ((item.state ^ lpLVItem->state) & lpLVItem->stateMask & ~infoPtr->uCallbackMask)) 3266 3292 uChanged |= LVIF_STATE; … … 3277 3303 if ((lpLVItem->mask & LVIF_TEXT) && textcmpWT(lpItem->hdr.pszText, lpLVItem->pszText, isW)) 3278 3304 uChanged |= LVIF_TEXT; 3279 3280 TRACE("uChanged=0x%x\n", uChanged); 3305 3306 TRACE("uChanged=0x%x\n", uChanged); 3281 3307 if (!uChanged) return TRUE; 3282 3308 *bChanged = TRUE; 3283 3309 3284 3310 ZeroMemory(&nmlv, sizeof(NMLISTVIEW)); 3285 3311 nmlv.iItem = lpLVItem->iItem; … … 3288 3314 nmlv.uChanged = uChanged; 3289 3315 nmlv.lParam = item.lParam; 3290 3316 3291 3317 /* send LVN_ITEMCHANGING notification, if the item is not being inserted */ 3292 3318 /* and we are _NOT_ virtual (LVS_OWERNDATA), and change notifications */ … … 3340 3366 /* if we're inserting the item, we're done */ 3341 3367 if (isNew) return TRUE; 3342 3368 3343 3369 /* send LVN_ITEMCHANGED notification */ 3344 3370 if (lpLVItem->mask & LVIF_PARAM) nmlv.lParam = lpLVItem->lParam; … … 3369 3395 /* we do not support subitems for virtual listviews */ 3370 3396 if (infoPtr->dwStyle & LVS_OWNERDATA) return FALSE; 3371 3397 3372 3398 /* set subitem only if column is present */ 3373 if (lpLVItem->iSubItem >= infoPtr->hdpaColumns->nItemCount) return FALSE;3374 3399 if (lpLVItem->iSubItem >= DPA_GetPtrCount(infoPtr->hdpaColumns)) return FALSE; 3400 3375 3401 /* First do some sanity checks */ 3376 3402 if (lpLVItem->mask & ~(LVIF_TEXT | LVIF_IMAGE)) return FALSE; 3377 3403 if (!(lpLVItem->mask & (LVIF_TEXT | LVIF_IMAGE))) return TRUE; 3378 3404 3379 3405 /* get the subitem structure, and create it if not there */ 3380 3406 hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, lpLVItem->iItem); 3381 3407 assert (hdpaSubItems); 3382 3408 3383 3409 lpSubItem = LISTVIEW_GetSubItemPtr(hdpaSubItems, lpLVItem->iSubItem); 3384 3410 if (!lpSubItem) … … 3387 3413 INT i; 3388 3414 3389 lpSubItem = (SUBITEM_INFO *) COMCTL32_Alloc(sizeof(SUBITEM_INFO));3415 lpSubItem = (SUBITEM_INFO *)Alloc(sizeof(SUBITEM_INFO)); 3390 3416 if (!lpSubItem) return FALSE; 3391 3417 /* we could binary search here, if need be...*/ 3392 for (i = 1; i < hdpaSubItems->nItemCount; i++)3418 for (i = 1; i < DPA_GetPtrCount(hdpaSubItems); i++) 3393 3419 { 3394 3420 tmpSubItem = (SUBITEM_INFO *)DPA_GetPtr(hdpaSubItems, i); … … 3397 3423 if (DPA_InsertPtr(hdpaSubItems, i, lpSubItem) == -1) 3398 3424 { 3399 COMCTL32_Free(lpSubItem);3425 Free(lpSubItem); 3400 3426 return FALSE; 3401 3427 } 3402 3428 lpSubItem->iSubItem = lpLVItem->iSubItem; 3429 lpSubItem->hdr.iImage = I_IMAGECALLBACK; 3403 3430 *bChanged = TRUE; 3404 3431 } 3405 3432 3406 3433 if (lpLVItem->mask & LVIF_IMAGE) 3407 3434 if (lpSubItem->hdr.iImage != lpLVItem->iImage) … … 3439 3466 LPWSTR pszText = NULL; 3440 3467 BOOL bResult, bChanged = FALSE; 3441 3468 3442 3469 TRACE("(lpLVItem=%s, isW=%d)\n", debuglvitem_t(lpLVItem, isW), isW); 3443 3470 … … 3451 3478 ((LVITEMW *)lpLVItem)->pszText = textdupTtoW(lpLVItem->pszText, isW); 3452 3479 } 3453 3480 3454 3481 /* actually set the fields */ 3455 3482 if (!is_assignable_item(lpLVItem, infoPtr->dwStyle)) return FALSE; 3456 3483 3457 3484 if (lpLVItem->iSubItem) 3458 3485 bResult = set_sub_item(infoPtr, lpLVItem, TRUE, &bChanged); … … 3509 3536 if ((lStyle & WS_VSCROLL) && GetScrollInfo(infoPtr->hwndSelf, SB_VERT, &scrollInfo)) 3510 3537 nItem = scrollInfo.nPos; 3511 } 3538 } 3512 3539 else 3513 3540 { … … 3517 3544 3518 3545 TRACE("nItem=%d\n", nItem); 3519 3546 3520 3547 return nItem; 3521 3548 } … … 3565 3592 WCHAR szDispText[DISP_TEXT_SIZE] = { '\0' }; 3566 3593 WCHAR szCallback[] = { '(', 'c', 'a', 'l', 'l', 'b', 'a', 'c', 'k', ')', 0 }; 3567 DWORD cd itemmode = CDRF_DODEFAULT;3594 DWORD cdsubitemmode = CDRF_DODEFAULT; 3568 3595 RECT* lprcFocus, rcSelect, rcBox, rcState, rcIcon, rcLabel; 3569 3596 NMLVCUSTOMDRAW nmlvcd; 3570 3597 HIMAGELIST himl; 3571 3598 LVITEMW lvItem; 3572 3573 3599 #ifdef __WIN32OS2__ 3574 3600 DWORD dwBkColor; … … 3593 3619 lvItem.pszText = szDispText; 3594 3620 if (!LISTVIEW_GetItemW(infoPtr, &lvItem)) return FALSE; 3595 if (nSubItem > 0 && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT)) 3621 if (nSubItem > 0 && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT)) 3596 3622 lvItem.state = LISTVIEW_GetItemState(infoPtr, nItem, LVIS_SELECTED); 3597 3623 if (lvItem.pszText == LPSTR_TEXTCALLBACKW) lvItem.pszText = szCallback; … … 3600 3626 /* now check if we need to update the focus rectangle */ 3601 3627 lprcFocus = infoPtr->bFocus && (lvItem.state & LVIS_FOCUSED) ? &infoPtr->rcFocus : 0; 3602 3628 3603 3629 if (!lprcFocus) lvItem.state &= ~LVIS_FOCUSED; 3604 3630 LISTVIEW_GetItemMetrics(infoPtr, &lvItem, &rcBox, &rcState, &rcIcon, &rcLabel); … … 3607 3633 OffsetRect(&rcIcon, pos.x, pos.y); 3608 3634 OffsetRect(&rcLabel, pos.x, pos.y); 3609 TRACE(" rcBox=%s, rcState=%s, rcIcon=%s. rcLabel=%s\n", 3635 TRACE(" rcBox=%s, rcState=%s, rcIcon=%s. rcLabel=%s\n", 3610 3636 debugrect(&rcBox), debugrect(&rcState), debugrect(&rcIcon), debugrect(&rcLabel)); 3611 3637 … … 3613 3639 customdraw_fill(&nmlvcd, infoPtr, hdc, &rcBox, &lvItem); 3614 3640 3641 if (nSubItem > 0) cdmode = infoPtr->cditemmode; 3615 3642 if (cdmode & CDRF_NOTIFYITEMDRAW) 3616 cditemmode = notify_prepaint (infoPtr, hdc, &nmlvcd); 3617 if (nSubItem == 0) infoPtr->cditemmode = cditemmode; 3618 if (cditemmode & CDRF_SKIPDEFAULT) goto postpaint; 3643 cdsubitemmode = notify_customdraw(infoPtr, CDDS_PREPAINT, &nmlvcd); 3644 if (nSubItem == 0) infoPtr->cditemmode = cdsubitemmode; 3645 if (cdsubitemmode & CDRF_SKIPDEFAULT) goto postpaint; 3646 /* we have to send a CDDS_SUBITEM customdraw explicitly for subitem 0 */ 3647 if (nSubItem == 0 && cdsubitemmode == CDRF_NOTIFYITEMDRAW) 3648 { 3649 cdsubitemmode = notify_customdraw(infoPtr, CDDS_SUBITEM | CDDS_ITEMPREPAINT, &nmlvcd); 3650 if (cdsubitemmode & CDRF_SKIPDEFAULT) goto postpaint; 3651 } 3652 if (nSubItem == 0 || (cdmode & CDRF_NOTIFYITEMDRAW)) 3653 prepaint_setup(infoPtr, hdc, &nmlvcd); 3619 3654 3620 3655 /* in full row select, subitems, will just use main item's colors */ 3621 3656 if (nSubItem && uView == LVS_REPORT && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT)) 3622 3657 nmlvcd.clrTextBk = CLR_NONE; 3623 3658 3624 3659 /* state icons */ 3625 3660 if (infoPtr->himlState && !IsRectEmpty(&rcState)) … … 3690 3725 if (uView == LVS_REPORT && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT)) 3691 3726 rcSelect.right = rcBox.right; 3692 3693 if (nmlvcd.clrTextBk != CLR_NONE) 3727 3728 if (nmlvcd.clrTextBk != CLR_NONE) 3694 3729 #ifdef __WIN32OS2__ 3695 3730 ExtTextOutW(hdc, rcSelect.left, rcSelect.top, textoutOptions, &rcSelect, 0, 0, 0); … … 3699 3734 if(lprcFocus) *lprcFocus = rcSelect; 3700 3735 } 3701 3736 3702 3737 /* figure out the text drawing flags */ 3703 3738 uFormat = (uView == LVS_ICON ? (lprcFocus ? LV_FL_DT_FLAGS : LV_ML_DT_FLAGS) : LV_SL_DT_FLAGS); … … 3722 3757 3723 3758 postpaint: 3724 if (cd itemmode & CDRF_NOTIFYPOSTPAINT)3759 if (cdsubitemmode & CDRF_NOTIFYPOSTPAINT) 3725 3760 notify_postpaint(infoPtr, &nmlvcd); 3761 3726 3762 3727 3763 #ifdef __WIN32OS2__ … … 3735 3771 } 3736 3772 #endif 3737 3738 3773 return TRUE; 3739 3774 } … … 3753 3788 { 3754 3789 UINT uID = GetWindowLongW(infoPtr->hwndSelf, GWL_ID); 3755 HWND hwndParent = GetParent(infoPtr->hwndSelf);3756 3790 DWORD cditemmode = CDRF_DODEFAULT; 3757 3791 NMLVCUSTOMDRAW nmlvcd; … … 3759 3793 DRAWITEMSTRUCT dis; 3760 3794 LVITEMW item; 3761 3795 3762 3796 TRACE("()\n"); 3763 3797 3764 3798 ZeroMemory(&dis, sizeof(dis)); 3765 3799 3766 3800 /* Get scroll info once before loop */ 3767 3801 LISTVIEW_GetOrigin(infoPtr, &Origin); 3768 3802 3769 3803 /* iterate through the invalidated rows */ 3770 3804 while(iterator_next(i)) … … 3775 3809 item.stateMask = LVIS_SELECTED | LVIS_FOCUSED; 3776 3810 if (!LISTVIEW_GetItemW(infoPtr, &item)) continue; 3777 3811 3778 3812 dis.CtlType = ODT_LISTVIEW; 3779 3813 dis.CtlID = uID; … … 3794 3828 TRACE("item=%s, rcItem=%s\n", debuglvitem_t(&item, TRUE), debugrect(&dis.rcItem)); 3795 3829 3830 /* 3831 * Even if we do not send the CDRF_NOTIFYITEMDRAW we need to fill the nmlvcd 3832 * structure for the rest. of the paint cycle 3833 */ 3834 customdraw_fill(&nmlvcd, infoPtr, hdc, &dis.rcItem, &item); 3796 3835 if (cdmode & CDRF_NOTIFYITEMDRAW) 3836 cditemmode = notify_customdraw(infoPtr, CDDS_PREPAINT, &nmlvcd); 3837 3838 if (!(cditemmode & CDRF_SKIPDEFAULT)) 3797 3839 { 3798 customdraw_fill(&nmlvcd, infoPtr, hdc, &dis.rcItem, &item);3799 cditemmode = notify_prepaint (infoPtr, hdc, &nmlvcd);3840 prepaint_setup (infoPtr, hdc, &nmlvcd); 3841 SendMessageW(infoPtr->hwndNotify, WM_DRAWITEM, dis.CtlID, (LPARAM)&dis); 3800 3842 } 3801 3802 if (!(cditemmode & CDRF_SKIPDEFAULT))3803 SendMessageW(hwndParent, WM_DRAWITEM, dis.CtlID, (LPARAM)&dis);3804 3843 3805 3844 if (cditemmode & CDRF_NOTIFYPOSTPAINT) … … 3833 3872 rgntype = GetClipBox(hdc, &rcClip); 3834 3873 if (rgntype == NULLREGION) return; 3835 3874 3836 3875 /* Get scroll info once before loop */ 3837 3876 LISTVIEW_GetOrigin(infoPtr, &Origin); 3838 3877 3839 3878 /* narrow down the columns we need to paint */ 3840 for(colRange.lower = 0; colRange.lower < infoPtr->hdpaColumns->nItemCount; colRange.lower++)3879 for(colRange.lower = 0; colRange.lower < DPA_GetPtrCount(infoPtr->hdpaColumns); colRange.lower++) 3841 3880 { 3842 3881 LISTVIEW_GetHeaderRect(infoPtr, colRange.lower, &rcItem); 3843 3882 if (rcItem.right + Origin.x >= rcClip.left) break; 3844 3883 } 3845 for(colRange.upper = infoPtr->hdpaColumns->nItemCount; colRange.upper > 0; colRange.upper--)3884 for(colRange.upper = DPA_GetPtrCount(infoPtr->hdpaColumns); colRange.upper > 0; colRange.upper--) 3846 3885 { 3847 3886 LISTVIEW_GetHeaderRect(infoPtr, colRange.upper - 1, &rcItem); … … 3897 3936 /* Get scroll info once before loop */ 3898 3937 LISTVIEW_GetOrigin(infoPtr, &Origin); 3899 3938 3900 3939 while(iterator_prev(i)) 3901 3940 { … … 3932 3971 3933 3972 LISTVIEW_DUMP(infoPtr); 3934 3973 3935 3974 infoPtr->bIsDrawing = TRUE; 3936 3975 … … 3943 3982 oldClrTextBk = infoPtr->clrTextBk; 3944 3983 oldClrText = infoPtr->clrText; 3945 3984 3946 3985 infoPtr->cditemmode = CDRF_DODEFAULT; 3947 3986 3948 3987 GetClientRect(infoPtr->hwndSelf, &rcClient); 3949 3988 customdraw_fill(&nmlvcd, infoPtr, hdc, &rcClient, 0); 3950 cdmode = notify_ prepaint(infoPtr, hdc, &nmlvcd);3989 cdmode = notify_customdraw(infoPtr, CDDS_PREPAINT, &nmlvcd); 3951 3990 if (cdmode & CDRF_SKIPDEFAULT) goto enddraw; 3991 prepaint_setup(infoPtr, hdc, &nmlvcd); 3952 3992 3953 3993 /* Use these colors to draw the items */ … … 3960 4000 /* figure out what we need to draw */ 3961 4001 iterator_visibleitems(&i, infoPtr, hdc); 3962 4002 3963 4003 /* send cache hint notification */ 3964 4004 if (infoPtr->dwStyle & LVS_OWNERDATA) … … 3987 4027 } 3988 4028 iterator_destroy(&i); 3989 4029 3990 4030 enddraw: 3991 4031 if (cdmode & CDRF_NOTIFYPOSTPAINT) … … 4060 4100 } 4061 4101 else if (uView == LVS_REPORT) 4102 { 4062 4103 #ifdef __WIN32OS2__ 4063 4104 { … … 4099 4140 } 4100 4141 #else 4101 FIXME("uView == LVS_REPORT: not implemented\n"); 4142 RECT rcBox; 4143 4144 if (infoPtr->nItemCount > 0) 4145 { 4146 LISTVIEW_GetItemBox(infoPtr, 0, &rcBox); 4147 wWidth = rcBox.right - rcBox.left; 4148 wHeight = (rcBox.bottom - rcBox.top) * nItemCount; 4149 } 4150 else 4151 { 4152 /* use current height and width */ 4153 if (wHeight == 0xffff) 4154 wHeight = infoPtr->rcList.bottom - infoPtr->rcList.top; 4155 if (wWidth == 0xffff) 4156 wWidth = infoPtr->rcList.right - infoPtr->rcList.left; 4157 } 4158 4159 dwViewRect = MAKELONG(wWidth, wHeight); 4102 4160 #endif 4161 } 4103 4162 else if (uView == LVS_SMALLICON) 4104 4163 FIXME("uView == LVS_SMALLICON: not implemented\n"); … … 4154 4213 rcItem.bottom = size.cy; 4155 4214 FillRect(hdc, &rcItem, infoPtr->hBkBrush); 4156 4215 4157 4216 pos.x = pos.y = 0; 4158 4217 if (LISTVIEW_DrawItem(infoPtr, hdc, iItem, 0, pos, infoPtr->cditemmode)) … … 4216 4275 { 4217 4276 hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, i); 4218 for (j = 0; j < hdpaSubItems->nItemCount; j++)4277 for (j = 0; j < DPA_GetPtrCount(hdpaSubItems); j++) 4219 4278 { 4220 4279 hdrItem = (ITEMHDR *)DPA_GetPtr(hdpaSubItems, j); 4221 if (is_textW(hdrItem->pszText)) COMCTL32_Free(hdrItem->pszText);4222 COMCTL32_Free(hdrItem);4280 if (is_textW(hdrItem->pszText)) Free(hdrItem->pszText); 4281 Free(hdrItem); 4223 4282 } 4224 4283 DPA_Destroy(hdpaSubItems); … … 4229 4288 infoPtr->nItemCount --; 4230 4289 } 4231 4290 4232 4291 LISTVIEW_UpdateScroll(infoPtr); 4233 4292 4234 4293 LISTVIEW_InvalidateList(infoPtr); 4235 4294 4236 4295 return TRUE; 4237 4296 } … … 4254 4313 RECT rcOld, rcCol; 4255 4314 INT nCol; 4256 4257 lpColumnInfo = LISTVIEW_GetColumnInfo(infoPtr, min(nColumn, infoPtr->hdpaColumns->nItemCount - 1)); 4315 4316 if (nColumn < 0 || DPA_GetPtrCount(infoPtr->hdpaColumns) < 1) return; 4317 lpColumnInfo = LISTVIEW_GetColumnInfo(infoPtr, min(nColumn, DPA_GetPtrCount(infoPtr->hdpaColumns) - 1)); 4258 4318 rcCol = lpColumnInfo->rcHeader; 4259 if (nColumn >= infoPtr->hdpaColumns->nItemCount)4319 if (nColumn >= DPA_GetPtrCount(infoPtr->hdpaColumns)) 4260 4320 rcCol.left = rcCol.right; 4261 4321 4262 4322 /* ajust the other columns */ 4263 for (nCol = nColumn; nCol < infoPtr->hdpaColumns->nItemCount; nCol++)4323 for (nCol = nColumn; nCol < DPA_GetPtrCount(infoPtr->hdpaColumns); nCol++) 4264 4324 { 4265 4325 lpColumnInfo = LISTVIEW_GetColumnInfo(infoPtr, nCol); … … 4270 4330 /* do not update screen if not in report mode */ 4271 4331 if (!is_redrawing(infoPtr) || (infoPtr->dwStyle & LVS_TYPEMASK) != LVS_REPORT) return; 4272 4332 4273 4333 /* if we have a focus, must first erase the focus rect */ 4274 4334 if (infoPtr->bFocus) LISTVIEW_ShowFocusRect(infoPtr, FALSE); 4275 4335 4276 4336 /* Need to reset the item width when inserting a new column */ 4277 4337 infoPtr->nItemWidth += dx; … … 4283 4343 rcOld.left = rcCol.left; 4284 4344 ScrollWindowEx(infoPtr->hwndSelf, dx, 0, &rcOld, &rcOld, 0, 0, SW_ERASE | SW_INVALIDATE); 4285 4345 4286 4346 /* we can restore focus now */ 4287 4347 if (infoPtr->bFocus) LISTVIEW_ShowFocusRect(infoPtr, TRUE); … … 4303 4363 { 4304 4364 RECT rcCol; 4305 4365 4306 4366 TRACE("nColumn=%d\n", nColumn); 4307 4367 4308 if (nColumn < 0 || infoPtr->hdpaColumns->nItemCount== 04309 || nColumn >= infoPtr->hdpaColumns->nItemCount) return FALSE;4368 if (nColumn < 0 || DPA_GetPtrCount(infoPtr->hdpaColumns) == 0 4369 || nColumn >= DPA_GetPtrCount(infoPtr->hdpaColumns)) return FALSE; 4310 4370 4311 4371 /* While the MSDN specifically says that column zero should not be deleted, 4312 4372 it does in fact work on WinNT, and at least one app depends on it. On 4313 4373 WinNT, deleting column zero deletes the last column of items but the 4314 first header. Since no app will ever depend on that bizarre behavior, 4374 first header. Since no app will ever depend on that bizarre behavior, 4315 4375 we just delete the last column including the header. 4316 4376 */ 4317 4377 if (nColumn == 0) 4318 nColumn = infoPtr->hdpaColumns->nItemCount- 1;4378 nColumn = DPA_GetPtrCount(infoPtr->hdpaColumns) - 1; 4319 4379 4320 4380 LISTVIEW_GetHeaderRect(infoPtr, nColumn, &rcCol); 4321 4381 4322 4382 if (!Header_DeleteItem(infoPtr->hwndHeader, nColumn)) 4323 4383 return FALSE; 4324 4384 4325 COMCTL32_Free(DPA_GetPtr(infoPtr->hdpaColumns, nColumn));4385 Free(DPA_GetPtr(infoPtr->hdpaColumns, nColumn)); 4326 4386 DPA_DeletePtr(infoPtr->hdpaColumns, nColumn); 4327 4387 4328 4388 if (!(infoPtr->dwStyle & LVS_OWNERDATA)) 4329 4389 { … … 4334 4394 if (nColumn == 0) 4335 4395 return LISTVIEW_DeleteAllItems(infoPtr); 4336 4396 4337 4397 for (nItem = 0; nItem < infoPtr->nItemCount; nItem++) 4338 4398 { … … 4340 4400 nSubItem = 0; 4341 4401 lpDelItem = 0; 4342 for (i = 1; i < hdpaSubItems->nItemCount; i++)4402 for (i = 1; i < DPA_GetPtrCount(hdpaSubItems); i++) 4343 4403 { 4344 4404 lpSubItem = (SUBITEM_INFO *)DPA_GetPtr(hdpaSubItems, i); … … 4348 4408 lpDelItem = lpSubItem; 4349 4409 } 4350 else if (lpSubItem->iSubItem > nColumn) 4410 else if (lpSubItem->iSubItem > nColumn) 4351 4411 { 4352 4412 lpSubItem->iSubItem--; … … 4359 4419 /* free string */ 4360 4420 if (is_textW(lpDelItem->hdr.pszText)) 4361 COMCTL32_Free(lpDelItem->hdr.pszText);4421 Free(lpDelItem->hdr.pszText); 4362 4422 4363 4423 /* free item */ 4364 COMCTL32_Free(lpDelItem);4424 Free(lpDelItem); 4365 4425 4366 4426 /* free dpa memory */ … … 4397 4457 /* if we don't refresh, what's the point of scrolling? */ 4398 4458 if (!is_redrawing(infoPtr)) return; 4399 4459 4400 4460 assert (abs(dir) == 1); 4401 4461 … … 4412 4472 LISTVIEW_UpdateScroll(infoPtr); 4413 4473 4414 /* figure out the item's position */ 4474 /* figure out the item's position */ 4415 4475 if (uView == LVS_REPORT) 4416 4476 nPerCol = infoPtr->nItemCount + 1; … … 4419 4479 else /* LVS_ICON, or LVS_SMALLICON */ 4420 4480 return; 4421 4481 4422 4482 nItemCol = nItem / nPerCol; 4423 4483 nItemRow = nItem % nPerCol; … … 4434 4494 { 4435 4495 TRACE("Scrolling rcScroll=%s, rcList=%s\n", debugrect(&rcScroll), debugrect(&infoPtr->rcList)); 4436 ScrollWindowEx(infoPtr->hwndSelf, 0, dir * infoPtr->nItemHeight, 4496 ScrollWindowEx(infoPtr->hwndSelf, 0, dir * infoPtr->nItemHeight, 4437 4497 &rcScroll, &rcScroll, 0, 0, SW_ERASE | SW_INVALIDATE); 4438 4498 } … … 4472 4532 4473 4533 if (nItem < 0 || nItem >= infoPtr->nItemCount) return FALSE; 4474 4534 4475 4535 /* remove selection, and focus */ 4476 4536 item.state = 0; 4477 4537 item.stateMask = LVIS_SELECTED | LVIS_FOCUSED; 4478 4538 LISTVIEW_SetItemState(infoPtr, nItem, &item); 4479 4539 4480 4540 /* send LVN_DELETEITEM notification. */ 4481 4541 notify_deleteitem(infoPtr, nItem); 4482 4542 4483 /* we need to do this here, because we'll be deleting stuff */ 4543 /* we need to do this here, because we'll be deleting stuff */ 4484 4544 if (uView == LVS_SMALLICON || uView == LVS_ICON) 4485 4545 LISTVIEW_InvalidateItem(infoPtr, nItem); 4486 4546 4487 4547 if (!(infoPtr->dwStyle & LVS_OWNERDATA)) 4488 4548 { … … 4492 4552 4493 4553 hdpaSubItems = (HDPA)DPA_DeletePtr(infoPtr->hdpaItems, nItem); 4494 for (i = 0; i < hdpaSubItems->nItemCount; i++)4554 for (i = 0; i < DPA_GetPtrCount(hdpaSubItems); i++) 4495 4555 { 4496 4556 hdrItem = (ITEMHDR *)DPA_GetPtr(hdpaSubItems, i); 4497 if (is_textW(hdrItem->pszText)) COMCTL32_Free(hdrItem->pszText);4498 COMCTL32_Free(hdrItem);4557 if (is_textW(hdrItem->pszText)) Free(hdrItem->pszText); 4558 Free(hdrItem); 4499 4559 } 4500 4560 DPA_Destroy(hdpaSubItems); … … 4598 4658 rect.left = LVIR_LABEL; 4599 4659 if (!LISTVIEW_GetItemRect(infoPtr, nItem, &rect)) return 0; 4600 4660 4601 4661 ZeroMemory(&dispInfo, sizeof(dispInfo)); 4602 4662 dispInfo.item.mask = LVIF_PARAM | LVIF_STATE | LVIF_TEXT; … … 4611 4671 rect.left-2, rect.top-1, 0, rect.bottom - rect.top+2, isW); 4612 4672 if (!infoPtr->hwndEdit) return 0; 4613 4673 4614 4674 if (notify_dispinfoT(infoPtr, LVN_BEGINLABELEDITW, &dispInfo, isW)) 4615 4675 { … … 4654 4714 4655 4715 if (bPartial && IntersectRect(&rcTemp, &infoPtr->rcList, &rcItem)) return TRUE; 4656 4716 4657 4717 if (rcItem.left < infoPtr->rcList.left || rcItem.right > infoPtr->rcList.right) 4658 4718 { … … 4739 4799 4740 4800 if (!lpFindInfo || nItem < 0) return -1; 4741 4801 4742 4802 lvItem.mask = 0; 4743 4803 if (lpFindInfo->flags & (LVFI_STRING | LVFI_PARTIAL)) … … 4751 4811 bWrap = TRUE; 4752 4812 4753 if ((lpFindInfo->flags & LVFI_NEARESTXY) && 4813 if ((lpFindInfo->flags & LVFI_NEARESTXY) && 4754 4814 (uView == LVS_ICON || uView ==LVS_SMALLICON)) 4755 4815 { … … 4771 4831 case VK_END: 4772 4832 LISTVIEW_GetAreaRect(infoPtr, &rcArea); 4773 Destination.x = rcArea.right; 4774 Destination.y = rcArea.bottom; 4833 Destination.x = rcArea.right; 4834 Destination.y = rcArea.bottom; 4775 4835 break; 4776 4836 default: ERR("Unknown vkDirection=%d\n", lpFindInfo->vkDirection); … … 4909 4969 HDITEMW hdi; 4910 4970 4911 if (!lpColumn || nColumn < 0 || nColumn >= infoPtr->hdpaColumns->nItemCount) return FALSE;4971 if (!lpColumn || nColumn < 0 || nColumn >= DPA_GetPtrCount(infoPtr->hdpaColumns)) return FALSE; 4912 4972 lpColumnInfo = LISTVIEW_GetColumnInfo(infoPtr, nColumn); 4913 4973 … … 4986 5046 break; 4987 5047 case LVS_REPORT: 4988 if (nColumn < 0 || nColumn >= infoPtr->hdpaColumns->nItemCount) return 0;5048 if (nColumn < 0 || nColumn >= DPA_GetPtrCount(infoPtr->hdpaColumns)) return 0; 4989 5049 LISTVIEW_GetHeaderRect(infoPtr, nColumn, &rcHeader); 4990 5050 nColumnWidth = rcHeader.right - rcHeader.left; … … 5070 5130 * that, so it's not a problem. 5071 5131 * For the two cases when the text must be copied (that is, 5072 * for LVM_GETITEM, and LVM GETITEMTEXT), use LISTVIEW_GetItemExtT.5132 * for LVM_GETITEM, and LVM_GETITEMTEXT), use LISTVIEW_GetItemExtT. 5073 5133 * 5074 5134 * RETURN: … … 5083 5143 ITEMHDR* pItemHdr; 5084 5144 HDPA hdpaSubItems; 5145 INT isubitem; 5085 5146 5086 5147 TRACE("(lpLVItem=%s, isW=%d)\n", debuglvitem_t(lpLVItem, isW), isW); … … 5090 5151 5091 5152 if (lpLVItem->mask == 0) return TRUE; 5153 5154 /* make a local copy */ 5155 isubitem = lpLVItem->iSubItem; 5092 5156 5093 5157 /* a quick optimization if all we're asked is the focus state … … 5117 5181 dispInfo.item.mask = lpLVItem->mask & ~LVIF_PARAM; 5118 5182 dispInfo.item.iItem = lpLVItem->iItem; 5119 dispInfo.item.iSubItem = lpLVItem->iSubItem;5183 dispInfo.item.iSubItem = isubitem; 5120 5184 if (lpLVItem->mask & LVIF_TEXT) 5121 5185 { … … 5149 5213 5150 5214 /* we store only a little state, so if we're not asked, we're done */ 5151 if (!(lpLVItem->mask & LVIF_STATE) || lpLVItem->iSubItem) return TRUE;5215 if (!(lpLVItem->mask & LVIF_STATE) || isubitem) return TRUE; 5152 5216 5153 5217 /* if focus is handled by us, report it */ 5154 if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_FOCUSED ) 5218 if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_FOCUSED ) 5155 5219 { 5156 5220 lpLVItem->state &= ~LVIS_FOCUSED; … … 5160 5224 5161 5225 /* and do the same for selection, if we handle it */ 5162 if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_SELECTED ) 5226 if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_SELECTED ) 5163 5227 { 5164 5228 lpLVItem->state &= ~LVIS_SELECTED; … … 5175 5239 assert (lpItem); 5176 5240 5177 if ( lpLVItem->iSubItem)5178 { 5179 SUBITEM_INFO *lpSubItem = LISTVIEW_GetSubItemPtr(hdpaSubItems, lpLVItem->iSubItem);5241 if (isubitem) 5242 { 5243 SUBITEM_INFO *lpSubItem = LISTVIEW_GetSubItemPtr(hdpaSubItems, isubitem); 5180 5244 pItemHdr = lpSubItem ? &lpSubItem->hdr : &callbackHdr; 5245 if (!lpSubItem) 5246 { 5247 WARN(" iSubItem invalid (%08x), ignored.\n", isubitem); 5248 isubitem = 0; 5249 } 5181 5250 } 5182 5251 else … … 5184 5253 5185 5254 /* Do we need to query the state from the app? */ 5186 if ((lpLVItem->mask & LVIF_STATE) && infoPtr->uCallbackMask && lpLVItem->iSubItem == 0)5255 if ((lpLVItem->mask & LVIF_STATE) && infoPtr->uCallbackMask && isubitem == 0) 5187 5256 { 5188 5257 dispInfo.item.mask |= LVIF_STATE; 5189 5258 dispInfo.item.stateMask = infoPtr->uCallbackMask; 5190 5259 } 5191 5260 5192 5261 /* Do we need to enquire about the image? */ 5193 if ((lpLVItem->mask & LVIF_IMAGE) && pItemHdr->iImage == I_IMAGECALLBACK) 5262 if ((lpLVItem->mask & LVIF_IMAGE) && pItemHdr->iImage == I_IMAGECALLBACK && 5263 (isubitem == 0 || (infoPtr->dwLvExStyle & LVS_EX_SUBITEMIMAGES))) 5264 { 5194 5265 dispInfo.item.mask |= LVIF_IMAGE; 5266 dispInfo.item.iImage = I_IMAGECALLBACK; 5267 } 5195 5268 5196 5269 /* Apps depend on calling back for text if it is NULL or LPSTR_TEXTCALLBACKW */ … … 5208 5281 { 5209 5282 dispInfo.item.iItem = lpLVItem->iItem; 5210 dispInfo.item.iSubItem = lpLVItem->iSubItem; 5283 dispInfo.item.iSubItem = lpLVItem->iSubItem; /* yes: the original subitem */ 5211 5284 dispInfo.item.lParam = lpItem->lParam; 5212 5285 notify_dispinfoT(infoPtr, LVN_GETDISPINFOW, &dispInfo, isW); … … 5215 5288 5216 5289 /* we should not store values for subitems */ 5217 if ( lpLVItem->iSubItem) dispInfo.item.mask &= ~LVIF_DI_SETITEM;5290 if (isubitem) dispInfo.item.mask &= ~LVIF_DI_SETITEM; 5218 5291 5219 5292 /* Now, handle the iImage field */ … … 5225 5298 } 5226 5299 else if (lpLVItem->mask & LVIF_IMAGE) 5227 lpLVItem->iImage = pItemHdr->iImage; 5300 { 5301 if(isubitem == 0 || (infoPtr->dwLvExStyle & LVS_EX_SUBITEMIMAGES)) 5302 lpLVItem->iImage = pItemHdr->iImage; 5303 else 5304 lpLVItem->iImage = 0; 5305 } 5228 5306 5229 5307 /* The pszText field */ … … 5242 5320 5243 5321 /* if this is a subitem, we're done */ 5244 if ( lpLVItem->iSubItem) return TRUE;5245 5322 if (isubitem) return TRUE; 5323 5246 5324 /* Next is the lParam field */ 5247 5325 if (dispInfo.item.mask & LVIF_PARAM) … … 5255 5333 5256 5334 /* ... the state field (this one is different due to uCallbackmask) */ 5257 if (lpLVItem->mask & LVIF_STATE) 5335 if (lpLVItem->mask & LVIF_STATE) 5258 5336 { 5259 5337 lpLVItem->state = lpItem->state; … … 5263 5341 lpLVItem->state |= (dispInfo.item.state & dispInfo.item.stateMask); 5264 5342 } 5265 if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_FOCUSED ) 5343 if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_FOCUSED ) 5266 5344 { 5267 5345 lpLVItem->state &= ~LVIS_FOCUSED; … … 5269 5347 lpLVItem->state |= LVIS_FOCUSED; 5270 5348 } 5271 if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_SELECTED ) 5349 if ( lpLVItem->stateMask & ~infoPtr->uCallbackMask & LVIS_SELECTED ) 5272 5350 { 5273 5351 lpLVItem->state &= ~LVIS_SELECTED; 5274 5352 if (ranges_contain(infoPtr->selectionRanges, lpLVItem->iItem)) 5275 5353 lpLVItem->state |= LVIS_SELECTED; 5276 } 5354 } 5277 5355 } 5278 5356 … … 5354 5432 lpptPosition->x += Origin.x; 5355 5433 lpptPosition->y += Origin.y; 5356 5434 5357 5435 TRACE (" lpptPosition=%s\n", debugpoint(lpptPosition)); 5358 5436 return TRUE; … … 5505 5583 * on input, lprc->top = nSubItem 5506 5584 * lprc->left = LVIR_ICON | LVIR_BOUNDS | LVIR_LABEL 5507 * 5585 * 5508 5586 * NOTE: for subItem = 0, we should return the bounds of the _entire_ item, 5509 5587 * not only those of the first column. 5510 5588 * Fortunately, LISTVIEW_GetItemMetrics does the right thing. 5511 * 5589 * 5512 5590 * RETURN: 5513 5591 * TRUE: success … … 5518 5596 POINT Position; 5519 5597 LVITEMW lvItem; 5520 5521 if (!lprc || (infoPtr->dwStyle & LVS_TYPEMASK) != LVS_REPORT) return FALSE;5598 5599 if (!lprc) return FALSE; 5522 5600 5523 5601 TRACE("(nItem=%d, nSubItem=%ld)\n", nItem, lprc->top); … … 5526 5604 return LISTVIEW_GetItemRect(infoPtr, nItem, lprc); 5527 5605 5606 if ((infoPtr->dwStyle & LVS_TYPEMASK) != LVS_REPORT) return FALSE; 5607 5528 5608 if (!LISTVIEW_GetItemPosition(infoPtr, nItem, &Position)) return FALSE; 5529 5609 5530 lvItem.mask = lprc->top == 0 ? LVIF_INDENT :0;5610 lvItem.mask = 0; 5531 5611 lvItem.iItem = nItem; 5532 5612 lvItem.iSubItem = lprc->top; 5533 5613 5534 5614 if (lvItem.mask && !LISTVIEW_GetItemW(infoPtr, &lvItem)) return FALSE; 5535 5615 switch(lprc->left) … … 5578 5658 lvItem.cchTextMax = DISP_TEXT_SIZE; 5579 5659 if (!LISTVIEW_GetItemW(infoPtr, &lvItem)) return 0; 5580 5660 5581 5661 return LISTVIEW_GetStringWidthT(infoPtr, lvItem.pszText, TRUE); 5582 5662 } … … 5702 5782 uMask |= LVIS_SELECTED; 5703 5783 5704 /* if we're asked for the focused item, that's only one, 5784 /* if we're asked for the focused item, that's only one, 5705 5785 * so it's worth optimizing */ 5706 5786 if (uFlags & LVNI_FOCUSED) … … 5709 5789 return (infoPtr->nFocusedItem == nItem) ? -1 : infoPtr->nFocusedItem; 5710 5790 } 5711 5791 5712 5792 if (uFlags & LVNI_ABOVE) 5713 5793 { … … 5886 5966 SCROLLINFO scrollInfo; 5887 5967 5888 scrollInfo.cbSize = sizeof(SCROLLINFO); 5968 scrollInfo.cbSize = sizeof(SCROLLINFO); 5889 5969 scrollInfo.fMask = SIF_POS; 5890 5970 5891 5971 if ((infoPtr->dwStyle & WS_HSCROLL) && GetScrollInfo(infoPtr->hwndSelf, SB_HORZ, &scrollInfo)) 5892 5972 nHorzPos = scrollInfo.nPos; … … 5902 5982 else if (uView == LVS_REPORT) 5903 5983 nVertPos *= infoPtr->nItemHeight; 5904 5984 5905 5985 lpptOrigin->x -= nHorzPos; 5906 5986 lpptOrigin->y -= nVertPos; … … 5925 6005 { 5926 6006 SIZE stringSize; 5927 5928 stringSize.cx = 0; 6007 6008 stringSize.cx = 0; 5929 6009 if (is_textT(lpszText, isW)) 5930 6010 { … … 5939 6019 SelectObject(hdc, hOldFont); 5940 6020 ReleaseDC(infoPtr->hwndSelf, hdc); 6021 5941 6022 #ifdef __WIN32OS2__ 5942 6023 if(infoPtr->dwStyle & LVS_OWNERDRAWFIXED) { 5943 /* Get item width */5944 5945 MEASUREITEMSTRUCT mis;5946 UINT id = GetWindowLongA(infoPtr->hwndSelf,GWL_ID);5947 mis.CtlType = ODT_LISTVIEW;5948 mis.CtlID = id;5949 mis.itemID = 0;5950 mis.itemData = 0; //TODO:!!!!5951 mis.itemHeight = 0;5952 mis.itemWidth = 0;5953 if (isW)5954 SendMessageW(GetParent(infoPtr->hwndSelf), WM_MEASUREITEM, id, (LPARAM)&mis );5955 else5956 SendMessageA(GetParent(infoPtr->hwndSelf), WM_MEASUREITEM, id, (LPARAM)&mis );5957 stringSize.cx = (mis.itemWidth) ? mis.itemWidth : infoPtr->nItemWidth;5958 }6024 /* Get item width */ 6025 6026 MEASUREITEMSTRUCT mis; 6027 UINT id = GetWindowLongA(infoPtr->hwndSelf,GWL_ID); 6028 mis.CtlType = ODT_LISTVIEW; 6029 mis.CtlID = id; 6030 mis.itemID = 0; 6031 mis.itemData = 0; //TODO:!!!! 6032 mis.itemHeight = 0; 6033 mis.itemWidth = 0; 6034 if (isW) 6035 SendMessageW(GetParent(infoPtr->hwndSelf), WM_MEASUREITEM, id, (LPARAM)&mis ); 6036 else 6037 SendMessageA(GetParent(infoPtr->hwndSelf), WM_MEASUREITEM, id, (LPARAM)&mis ); 6038 stringSize.cx = (mis.itemWidth) ? mis.itemWidth : infoPtr->nItemWidth; 6039 } 5959 6040 #endif 5960 6041 } … … 5976 6057 * an app might pass only a structure with space up to iItem! 5977 6058 * (MS Office 97 does that for instance in the file open dialog) 5978 * 6059 * 5979 6060 * RETURN: 5980 6061 * SUCCESS : item index … … 5989 6070 LVITEMW lvItem; 5990 6071 ITERATOR i; 5991 6072 INT iItem; 6073 5992 6074 TRACE("(pt=%s, subitem=%d, select=%d)\n", debugpoint(&lpht->pt), subitem, select); 5993 6075 5994 6076 lpht->flags = 0; 5995 6077 lpht->iItem = -1; … … 6000 6082 else if (infoPtr->rcList.right < lpht->pt.x) 6001 6083 lpht->flags |= LVHT_TORIGHT; 6002 6084 6003 6085 if (infoPtr->rcList.top > lpht->pt.y) 6004 6086 lpht->flags |= LVHT_ABOVE; … … 6012 6094 6013 6095 LISTVIEW_GetOrigin(infoPtr, &Origin); 6014 6096 6015 6097 /* first deal with the large items */ 6016 6098 rcSearch.left = lpht->pt.x; … … 6018 6100 rcSearch.right = rcSearch.left + 1; 6019 6101 rcSearch.bottom = rcSearch.top + 1; 6020 6102 6021 6103 iterator_frameditems(&i, infoPtr, &rcSearch); 6022 6104 iterator_next(&i); /* go to first item in the sequence */ 6023 lpht->iItem = i.nItem;6105 iItem = i.nItem; 6024 6106 iterator_destroy(&i); 6025 6026 TRACE("lpht->iItem=%d\n", lpht->iItem);6027 if ( lpht->iItem == -1) return -1;6107 6108 TRACE("lpht->iItem=%d\n", iItem); 6109 if (iItem == -1) return -1; 6028 6110 6029 6111 lvItem.mask = LVIF_STATE | LVIF_TEXT; … … 6031 6113 lvItem.stateMask = LVIS_STATEIMAGEMASK; 6032 6114 if (uView == LVS_ICON) lvItem.stateMask |= LVIS_FOCUSED; 6033 lvItem.iItem = lpht->iItem;6115 lvItem.iItem = iItem; 6034 6116 lvItem.iSubItem = 0; 6035 6117 lvItem.pszText = szDispText; 6036 6118 lvItem.cchTextMax = DISP_TEXT_SIZE; 6037 6119 if (!LISTVIEW_GetItemW(infoPtr, &lvItem)) return -1; 6038 if (!infoPtr->bFocus) lvItem.state &= ~LVIS_FOCUSED; 6039 6120 if (!infoPtr->bFocus) lvItem.state &= ~LVIS_FOCUSED; 6121 6040 6122 LISTVIEW_GetItemMetrics(infoPtr, &lvItem, &rcBox, &rcState, &rcIcon, &rcLabel); 6041 LISTVIEW_GetItemOrigin(infoPtr, lpht->iItem, &Position);6123 LISTVIEW_GetItemOrigin(infoPtr, iItem, &Position); 6042 6124 opt.x = lpht->pt.x - Position.x - Origin.x; 6043 6125 opt.y = lpht->pt.y - Position.y - Origin.y; 6044 6045 if (uView == LVS_REPORT && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT))6126 6127 if (uView == LVS_REPORT) 6046 6128 rcBounds = rcBox; 6047 6129 else … … 6058 6140 if (lpht->flags & LVHT_ONITEM) 6059 6141 lpht->flags &= ~LVHT_NOWHERE; 6060 6061 TRACE("lpht->flags=0x%x\n", lpht->flags); 6062 if (uView == LVS_REPORT && lpht->iItem != -1 &&subitem)6142 6143 TRACE("lpht->flags=0x%x\n", lpht->flags); 6144 if (uView == LVS_REPORT && subitem) 6063 6145 { 6064 6146 INT j; 6065 6147 6066 6148 rcBounds.right = rcBounds.left; 6067 for (j = 0; j < infoPtr->hdpaColumns->nItemCount; j++)6149 for (j = 0; j < DPA_GetPtrCount(infoPtr->hdpaColumns); j++) 6068 6150 { 6069 6151 rcBounds.left = rcBounds.right; … … 6077 6159 } 6078 6160 6079 if (!select || lpht->iItem == -1) return lpht->iItem; 6080 6081 if (uView == LVS_REPORT && (infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT)) return lpht->iItem; 6082 6083 if (uView == LVS_REPORT) UnionRect(&rcBounds, &rcIcon, &rcLabel); 6084 return PtInRect(&rcBounds, opt) ? lpht->iItem : -1; 6161 if (select && !(uView == LVS_REPORT && 6162 ((infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT) || 6163 (infoPtr->dwStyle & LVS_OWNERDRAWFIXED)))) 6164 { 6165 if (uView == LVS_REPORT) 6166 { 6167 UnionRect(&rcBounds, &rcIcon, &rcLabel); 6168 UnionRect(&rcBounds, &rcBounds, &rcState); 6169 } 6170 if (!PtInRect(&rcBounds, opt)) iItem = -1; 6171 } 6172 return lpht->iItem = iItem; 6085 6173 } 6086 6174 … … 6106 6194 ITEM_INFO* lv_first = (ITEM_INFO*) DPA_GetPtr( (HDPA)first, 0 ); 6107 6195 ITEM_INFO* lv_second = (ITEM_INFO*) DPA_GetPtr( (HDPA)second, 0 ); 6108 INT cmpv = textcmpWT(lv_first->hdr.pszText, lv_second->hdr.pszText, TRUE); 6196 INT cmpv = textcmpWT(lv_first->hdr.pszText, lv_second->hdr.pszText, TRUE); 6109 6197 6110 6198 /* if we're sorting descending, negate the return value */ … … 6144 6232 if (!is_assignable_item(lpLVItem, infoPtr->dwStyle)) return -1; 6145 6233 6146 if ( !(lpItem = (ITEM_INFO *) COMCTL32_Alloc(sizeof(ITEM_INFO))) )6234 if ( !(lpItem = (ITEM_INFO *)Alloc(sizeof(ITEM_INFO))) ) 6147 6235 return -1; 6148 6236 6149 6237 /* insert item in listview control data structure */ 6150 6238 if ( !(hdpaSubItems = DPA_Create(8)) ) goto fail; … … 6159 6247 if (nItem == -1) goto fail; 6160 6248 infoPtr->nItemCount++; 6249 6250 /* shift indices first so they don't get tangled */ 6251 LISTVIEW_ShiftIndices(infoPtr, nItem, 1); 6161 6252 6162 6253 /* set the item attributes */ … … 6199 6290 } 6200 6291 } 6201 6202 /* Add the subitem list to the items array. Do this last in case we go to 6203 * fail during the above. 6204 */ 6205 LISTVIEW_ShiftIndices(infoPtr, nItem, 1); 6206 6292 6207 6293 /* send LVN_INSERTITEM notification */ 6208 6294 ZeroMemory(&nmlv, sizeof(NMLISTVIEW)); … … 6229 6315 6230 6316 undo: 6317 LISTVIEW_ShiftIndices(infoPtr, nItem, -1); 6231 6318 DPA_DeletePtr(infoPtr->hdpaItems, nItem); 6232 6319 infoPtr->nItemCount--; … … 6234 6321 DPA_DeletePtr(hdpaSubItems, 0); 6235 6322 DPA_Destroy (hdpaSubItems); 6236 COMCTL32_Free (lpItem);6323 Free (lpItem); 6237 6324 return -1; 6238 6325 } … … 6254 6341 { 6255 6342 INT i; 6256 6257 if (nLast < nFirst || min(nFirst, nLast) < 0 || 6343 6344 if (nLast < nFirst || min(nFirst, nLast) < 0 || 6258 6345 max(nFirst, nLast) >= infoPtr->nItemCount) 6259 6346 return FALSE; 6260 6347 6261 6348 for (i = nFirst; i <= nLast; i++) 6262 6349 LISTVIEW_InvalidateItem(infoPtr, i); … … 6315 6402 if (dx != 0) LISTVIEW_HScroll(infoPtr, SB_INTERNAL, dx, 0); 6316 6403 if (dy != 0) LISTVIEW_VScroll(infoPtr, SB_INTERNAL, dy, 0); 6317 6404 6318 6405 return TRUE; 6319 6406 } … … 6447 6534 6448 6535 if (!lpColumn || nColumn < 0) return -1; 6449 nColumn = min(nColumn, infoPtr->hdpaColumns->nItemCount);6450 6536 nColumn = min(nColumn, DPA_GetPtrCount(infoPtr->hdpaColumns)); 6537 6451 6538 ZeroMemory(&hdi, sizeof(HDITEMW)); 6452 6539 column_fill_hditem(infoPtr, &hdi, nColumn, lpColumn, isW); 6453 6540 6454 6541 /* insert item in header control */ 6455 nNewColumn = SendMessageW(infoPtr->hwndHeader, 6542 nNewColumn = SendMessageW(infoPtr->hwndHeader, 6456 6543 isW ? HDM_INSERTITEMW : HDM_INSERTITEMA, 6457 6544 (WPARAM)nColumn, (LPARAM)&hdi); 6458 6545 if (nNewColumn == -1) return -1; 6459 6546 if (nNewColumn != nColumn) ERR("nColumn=%d, nNewColumn=%d\n", nColumn, nNewColumn); 6460 6461 /* create our own column info */ 6462 if (!(lpColumnInfo = COMCTL32_Alloc(sizeof(COLUMN_INFO)))) goto fail;6547 6548 /* create our own column info */ 6549 if (!(lpColumnInfo = Alloc(sizeof(COLUMN_INFO)))) goto fail; 6463 6550 if (DPA_InsertPtr(infoPtr->hdpaColumns, nNewColumn, lpColumnInfo) == -1) goto fail; 6464 6551 … … 6469 6556 if (!(infoPtr->dwStyle & LVS_OWNERDATA) && infoPtr->nItemCount > 0) 6470 6557 { 6471 SUBITEM_INFO *lpSubItem , *lpMainItem, **lpNewItems = 0;6558 SUBITEM_INFO *lpSubItem; 6472 6559 HDPA hdpaSubItems; 6473 6560 INT nItem, i; 6474 6475 /* preallocate memory, so we can fail gracefully */6476 if (nNewColumn == 0)6477 {6478 lpNewItems = COMCTL32_Alloc(sizeof(SUBITEM_INFO *) * infoPtr->nItemCount);6479 if (!lpNewItems) goto fail;6480 for (i = 0; i < infoPtr->nItemCount; i++)6481 if (!(lpNewItems[i] = COMCTL32_Alloc(sizeof(SUBITEM_INFO)))) break;6482 if (i != infoPtr->nItemCount)6483 {6484 for(; i >=0; i--) COMCTL32_Free(lpNewItems[i]);6485 COMCTL32_Free(lpNewItems);6486 goto fail;6487 }6488 }6489 6561 6490 6562 for (nItem = 0; nItem < infoPtr->nItemCount; nItem++) 6491 6563 { 6492 6564 hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, nItem); 6493 for (i = 1; i < hdpaSubItems->nItemCount; i++)6565 for (i = 1; i < DPA_GetPtrCount(hdpaSubItems); i++) 6494 6566 { 6495 6567 lpSubItem = (SUBITEM_INFO *)DPA_GetPtr(hdpaSubItems, i); … … 6497 6569 lpSubItem->iSubItem++; 6498 6570 } 6499 6500 /* for inserting column 0, we have to special-case the main item */6501 if (nNewColumn == 0)6502 {6503 lpMainItem = (SUBITEM_INFO *)DPA_GetPtr(hdpaSubItems, 0);6504 lpSubItem = lpNewItems[nItem];6505 lpSubItem->hdr = lpMainItem->hdr;6506 lpSubItem->iSubItem = 1;6507 ZeroMemory(&lpMainItem->hdr, sizeof(lpMainItem->hdr));6508 lpMainItem->iSubItem = 0;6509 DPA_InsertPtr(hdpaSubItems, 1, lpSubItem);6510 }6511 6571 } 6512 6513 COMCTL32_Free(lpNewItems);6514 6572 } 6515 6573 6516 6574 /* make space for the new column */ 6517 6575 LISTVIEW_ScrollColumns(infoPtr, nNewColumn + 1, lpColumnInfo->rcHeader.right - lpColumnInfo->rcHeader.left); 6518 6576 6519 6577 return nNewColumn; 6520 6578 … … 6524 6582 { 6525 6583 DPA_DeletePtr(infoPtr->hdpaColumns, nNewColumn); 6526 COMCTL32_Free(lpColumnInfo);6584 Free(lpColumnInfo); 6527 6585 } 6528 6586 return -1; … … 6550 6608 6551 6609 TRACE("(nColumn=%d, lpColumn=%s, isW=%d)\n", nColumn, debuglvcolumn_t(lpColumn, isW), isW); 6552 6553 if (!lpColumn || nColumn < 0 || nColumn >= infoPtr->hdpaColumns->nItemCount) return FALSE;6610 6611 if (!lpColumn || nColumn < 0 || nColumn >= DPA_GetPtrCount(infoPtr->hdpaColumns)) return FALSE; 6554 6612 6555 6613 ZeroMemory(&hdi, sizeof(HDITEMW)); … … 6637 6695 6638 6696 /* resize all columns if in LVS_LIST mode */ 6639 if(uView == LVS_LIST) 6697 if(uView == LVS_LIST) 6640 6698 { 6641 6699 infoPtr->nItemWidth = cx; … … 6644 6702 } 6645 6703 6646 if (nColumn < 0 || nColumn >= infoPtr->hdpaColumns->nItemCount) return FALSE;6647 6648 if (cx == LVSCW_AUTOSIZE || (cx == LVSCW_AUTOSIZE_USEHEADER && nColumn < infoPtr->hdpaColumns->nItemCount-1))6704 if (nColumn < 0 || nColumn >= DPA_GetPtrCount(infoPtr->hdpaColumns)) return FALSE; 6705 6706 if (cx == LVSCW_AUTOSIZE || (cx == LVSCW_AUTOSIZE_USEHEADER && nColumn < DPA_GetPtrCount(infoPtr->hdpaColumns) -1)) 6649 6707 { 6650 6708 INT nLabelWidth; … … 6673 6731 { 6674 6732 /* if iCol is the last column make it fill the remainder of the controls width */ 6675 if(nColumn == infoPtr->hdpaColumns->nItemCount - 1)6733 if(nColumn == DPA_GetPtrCount(infoPtr->hdpaColumns) - 1) 6676 6734 { 6677 6735 RECT rcHeader; … … 6722 6780 6723 6781 /*** 6782 * Creates the checkbox imagelist. Helper for LISTVIEW_SetExtendedListViewStyle 6783 * 6784 */ 6785 static HIMAGELIST LISTVIEW_CreateCheckBoxIL(LISTVIEW_INFO *infoPtr) 6786 { 6787 HDC hdc_wnd, hdc; 6788 HBITMAP hbm_im, hbm_mask, hbm_orig; 6789 RECT rc; 6790 HBRUSH hbr_white = GetStockObject(WHITE_BRUSH); 6791 HBRUSH hbr_black = GetStockObject(BLACK_BRUSH); 6792 HIMAGELIST himl; 6793 6794 himl = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 6795 ILC_COLOR | ILC_MASK, 2, 2); 6796 hdc_wnd = GetDC(infoPtr->hwndSelf); 6797 hdc = CreateCompatibleDC(hdc_wnd); 6798 hbm_im = CreateCompatibleBitmap(hdc_wnd, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)); 6799 hbm_mask = CreateBitmap(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 1, 1, NULL); 6800 ReleaseDC(infoPtr->hwndSelf, hdc_wnd); 6801 6802 rc.left = rc.top = 0; 6803 rc.right = GetSystemMetrics(SM_CXSMICON); 6804 rc.bottom = GetSystemMetrics(SM_CYSMICON); 6805 6806 hbm_orig = SelectObject(hdc, hbm_mask); 6807 FillRect(hdc, &rc, hbr_white); 6808 InflateRect(&rc, -3, -3); 6809 FillRect(hdc, &rc, hbr_black); 6810 6811 SelectObject(hdc, hbm_im); 6812 DrawFrameControl(hdc, &rc, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_MONO); 6813 SelectObject(hdc, hbm_orig); 6814 ImageList_Add(himl, hbm_im, hbm_mask); 6815 6816 SelectObject(hdc, hbm_im); 6817 DrawFrameControl(hdc, &rc, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_MONO | DFCS_CHECKED); 6818 SelectObject(hdc, hbm_orig); 6819 ImageList_Add(himl, hbm_im, hbm_mask); 6820 6821 DeleteObject(hbm_mask); 6822 DeleteObject(hbm_im); 6823 DeleteDC(hdc); 6824 6825 return himl; 6826 } 6827 6828 /*** 6724 6829 * DESCRIPTION: 6725 6830 * Sets the extended listview style. … … 6744 6849 infoPtr->dwLvExStyle = dwStyle; 6745 6850 6851 if((infoPtr->dwLvExStyle ^ dwOldStyle) & LVS_EX_CHECKBOXES) 6852 { 6853 HIMAGELIST himl = 0; 6854 if(infoPtr->dwLvExStyle & LVS_EX_CHECKBOXES) 6855 himl = LISTVIEW_CreateCheckBoxIL(infoPtr); 6856 LISTVIEW_SetImageList(infoPtr, LVSIL_STATE, himl); 6857 } 6858 6746 6859 return dwOldStyle; 6747 6860 } … … 6761 6874 { 6762 6875 HCURSOR oldCursor = infoPtr->hHotCursor; 6763 6876 6764 6877 infoPtr->hHotCursor = hCursor; 6765 6878 … … 6783 6896 { 6784 6897 INT iOldIndex = infoPtr->nHotItem; 6785 6898 6786 6899 infoPtr->nHotItem = iIndex; 6787 6900 6788 6901 return iOldIndex; 6789 6902 } … … 6804 6917 { 6805 6918 DWORD oldHoverTime = infoPtr->dwHoverTime; 6806 6919 6807 6920 infoPtr->dwHoverTime = dwHoverTime; 6808 6921 6809 6922 return oldHoverTime; 6810 6923 } … … 6828 6941 6829 6942 TRACE("requested=(%d,%d)\n", cx, cy); 6830 6943 6831 6944 /* this is supported only for LVS_ICON style */ 6832 6945 if (uView != LVS_ICON) return oldspacing; 6833 6946 6834 6947 /* set to defaults, if instructed to */ 6835 6948 if (cx == -1) cx = GetSystemMetrics(SM_CXICONSPACING); … … 6843 6956 6844 6957 /* if 0 then compute height */ 6845 if (cy == 0) 6958 if (cy == 0) 6846 6959 cy = infoPtr->iconSize.cy + 2 * infoPtr->ntmHeight + 6847 6960 ICON_BOTTOM_PADDING + ICON_TOP_PADDING + LABEL_VERT_PADDING; 6848 6961 6849 6962 6850 6963 infoPtr->iconSpacing.cx = cx; … … 6852 6965 6853 6966 TRACE("old=(%d,%d), new=(%d,%d), iconSize=(%ld,%ld), ntmH=%d\n", 6854 LOWORD(oldspacing), HIWORD(oldspacing), cx, cy, 6967 LOWORD(oldspacing), HIWORD(oldspacing), cx, cy, 6855 6968 infoPtr->iconSize.cx, infoPtr->iconSize.cy, 6856 6969 infoPtr->ntmHeight); … … 6865 6978 { 6866 6979 INT cx, cy; 6867 6980 6868 6981 if (himl && ImageList_GetIconSize(himl, &cx, &cy)) 6869 6982 { … … 6982 7095 POINT Origin; 6983 7096 RECT rcErase; 6984 7097 6985 7098 LISTVIEW_GetOrigin(infoPtr, &Origin); 6986 7099 nFrom = min(nOldCount, nItems); 6987 7100 nTo = max(nOldCount, nItems); 6988 7101 6989 7102 if (uView == LVS_REPORT) 6990 7103 { … … 7059 7172 7060 7173 /* This point value seems to be an undocumented feature. 7061 * The best guess is that it means either at the origin, 7174 * The best guess is that it means either at the origin, 7062 7175 * or at true beginning of the list. I will assume the origin. */ 7063 7176 if ((pt.x == -1) && (pt.y == -1)) 7064 7177 pt = Origin; 7065 7178 7066 7179 if (uView == LVS_ICON) 7067 7180 { … … 7111 7224 bResult = LISTVIEW_SetItemT(infoPtr, &lvItem, TRUE); 7112 7225 7226 /* 7227 *update selection mark 7228 * 7229 * Investigation on windows 2k showed that selection mark was updated 7230 * whenever a new selection was made, but if the selected item was 7231 * unselected it was not updated. 7232 * 7233 * we are probably still not 100% accurate, but this at least sets the 7234 * proper selection mark when it is needed 7235 */ 7236 7237 if (bResult && (lvItem.state & lvItem.stateMask & LVIS_SELECTED) && 7238 ((infoPtr->nSelectionMark == -1) || (lvItem.iItem <= infoPtr->nSelectionMark))) 7239 { 7240 int i; 7241 infoPtr->nSelectionMark = -1; 7242 for (i = 0; i < infoPtr->nItemCount; i++) 7243 { 7244 if (infoPtr->uCallbackMask & LVIS_SELECTED) 7245 { 7246 if (LISTVIEW_GetItemState(infoPtr, i, LVIS_SELECTED)) 7247 { 7248 infoPtr->nSelectionMark = i; 7249 break; 7250 } 7251 } 7252 else if (ranges_contain(infoPtr->selectionRanges, i)) 7253 { 7254 infoPtr->nSelectionMark = i; 7255 break; 7256 } 7257 } 7258 } 7259 7113 7260 return bResult; 7114 7261 } … … 7133 7280 7134 7281 if (nItem < 0 && nItem >= infoPtr->nItemCount) return FALSE; 7135 7282 7136 7283 lvItem.iItem = nItem; 7137 7284 lvItem.iSubItem = lpLVItem->iSubItem; … … 7139 7286 lvItem.pszText = lpLVItem->pszText; 7140 7287 lvItem.cchTextMax = lpLVItem->cchTextMax; 7141 7288 7142 7289 TRACE("(nItem=%d, lpLVItem=%s, isW=%d)\n", nItem, debuglvitem_t(&lvItem, isW), isW); 7143 7290 7144 return LISTVIEW_SetItemT(infoPtr, &lvItem, isW); 7291 return LISTVIEW_SetItemT(infoPtr, &lvItem, isW); 7145 7292 } 7146 7293 … … 7188 7335 LISTVIEW_InvalidateList(infoPtr); 7189 7336 } 7190 7337 7191 7338 return TRUE; 7192 7339 } … … 7254 7401 static INT WINAPI LISTVIEW_CallBackCompare(LPVOID first, LPVOID second, LPARAM lParam) 7255 7402 { 7256 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *) GetWindowLongW((HWND)lParam, 0);7403 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)lParam; 7257 7404 ITEM_INFO* lv_first = (ITEM_INFO*) DPA_GetPtr( (HDPA)first, 0 ); 7258 7405 ITEM_INFO* lv_second = (ITEM_INFO*) DPA_GetPtr( (HDPA)second, 0 ); … … 7302 7449 /* clear the lpItem->state for non-selected ones */ 7303 7450 /* remove the selection ranges */ 7304 7451 7305 7452 infoPtr->pfnCompare = pfnCompare; 7306 7453 infoPtr->lParamSort = lParamSort; 7307 DPA_Sort(infoPtr->hdpaItems, LISTVIEW_CallBackCompare, (LPARAM)infoPtr ->hwndSelf);7454 DPA_Sort(infoPtr->hdpaItems, LISTVIEW_CallBackCompare, (LPARAM)infoPtr); 7308 7455 7309 7456 /* Adjust selections and indices so that they are the way they should … … 7390 7537 7391 7538 /* initialize info pointer */ 7392 infoPtr = (LISTVIEW_INFO *) COMCTL32_Alloc(sizeof(LISTVIEW_INFO));7539 infoPtr = (LISTVIEW_INFO *)Alloc(sizeof(LISTVIEW_INFO)); 7393 7540 if (!infoPtr) return -1; 7394 7541 … … 7398 7545 infoPtr->dwStyle = lpcs->style; 7399 7546 /* determine the type of structures to use */ 7400 infoPtr->notifyFormat = SendMessageW(GetParent(infoPtr->hwndSelf), WM_NOTIFYFORMAT, 7547 infoPtr->hwndNotify = lpcs->hwndParent; 7548 infoPtr->notifyFormat = SendMessageW(infoPtr->hwndNotify, WM_NOTIFYFORMAT, 7401 7549 (WPARAM)infoPtr->hwndSelf, (LPARAM)NF_QUERY); 7402 7550 … … 7412 7560 infoPtr->nHotItem = -1; 7413 7561 infoPtr->bRedraw = TRUE; 7414 infoPtr->bFirstPaint = TRUE;7415 7562 infoPtr->bNoItemMetrics = TRUE; 7416 7563 infoPtr->bDoChangeNotify = TRUE; … … 7452 7599 /* init item size to avoid division by 0 */ 7453 7600 LISTVIEW_UpdateItemSize (infoPtr); 7454 7601 7455 7602 if (uView == LVS_REPORT) 7456 7603 { … … 7476 7623 DPA_Destroy(infoPtr->hdpaPosY); 7477 7624 DPA_Destroy(infoPtr->hdpaColumns); 7478 COMCTL32_Free(infoPtr);7625 Free(infoPtr); 7479 7626 return -1; 7480 7627 } … … 7517 7664 { 7518 7665 /* now we can scroll the list */ 7519 ScrollWindowEx(infoPtr->hwndSelf, dx, dy, &infoPtr->rcList, 7666 ScrollWindowEx(infoPtr->hwndSelf, dx, dy, &infoPtr->rcList, 7520 7667 &infoPtr->rcList, 0, 0, SW_ERASE | SW_INVALIDATE); 7521 7668 /* if we have focus, adjust rect */ … … 7544 7691 * 7545 7692 */ 7546 static LRESULT LISTVIEW_VScroll(LISTVIEW_INFO *infoPtr, INT nScrollCode, 7693 static LRESULT LISTVIEW_VScroll(LISTVIEW_INFO *infoPtr, INT nScrollCode, 7547 7694 INT nScrollDiff, HWND hScrollWnd) 7548 7695 { … … 7552 7699 BOOL is_an_icon; 7553 7700 7554 TRACE("(nScrollCode=%d(%s), nScrollDiff=%d)\n", nScrollCode, 7701 TRACE("(nScrollCode=%d(%s), nScrollDiff=%d)\n", nScrollCode, 7555 7702 debugscrollcode(nScrollCode), nScrollDiff); 7556 7703 … … 7597 7744 /* quit right away if pos isn't changing */ 7598 7745 if (nScrollDiff == 0) return 0; 7599 7746 7600 7747 /* calculate new position, and handle overflows */ 7601 7748 nNewScrollPos = scrollInfo.nPos + nScrollDiff; … … 7614 7761 scrollInfo.nPos = nNewScrollPos; 7615 7762 nNewScrollPos = SetScrollInfo(infoPtr->hwndSelf, SB_VERT, &scrollInfo, TRUE); 7616 7763 7617 7764 /* carry on only if it really changed */ 7618 7765 if (nNewScrollPos == nOldScrollPos) return 0; 7619 7766 7620 7767 /* now adjust to client coordinates */ 7621 7768 nScrollDiff = nOldScrollPos - nNewScrollPos; 7622 7769 if (uView == LVS_REPORT) nScrollDiff *= infoPtr->nItemHeight; 7623 7624 /* and scroll the window */ 7770 7771 /* and scroll the window */ 7625 7772 scroll_list(infoPtr, 0, nScrollDiff); 7626 7773 … … 7656 7803 SCROLLINFO scrollInfo; 7657 7804 7658 TRACE("(nScrollCode=%d(%s), nScrollDiff=%d)\n", nScrollCode, 7805 TRACE("(nScrollCode=%d(%s), nScrollDiff=%d)\n", nScrollCode, 7659 7806 debugscrollcode(nScrollCode), nScrollDiff); 7660 7807 … … 7700 7847 /* quit right away if pos isn't changing */ 7701 7848 if (nScrollDiff == 0) return 0; 7702 7849 7703 7850 /* calculate new position, and handle overflows */ 7704 7851 nNewScrollPos = scrollInfo.nPos + nScrollDiff; … … 7717 7864 scrollInfo.nPos = nNewScrollPos; 7718 7865 nNewScrollPos = SetScrollInfo(infoPtr->hwndSelf, SB_HORZ, &scrollInfo, TRUE); 7719 7866 7720 7867 /* carry on only if it really changed */ 7721 7868 if (nNewScrollPos == nOldScrollPos) return 0; 7722 7869 7723 7870 if(uView == LVS_REPORT) 7724 7871 LISTVIEW_UpdateHeaderSize(infoPtr, nNewScrollPos); 7725 7872 7726 7873 /* now adjust to client coordinates */ 7727 7874 nScrollDiff = nOldScrollPos - nNewScrollPos; 7728 7875 if (uView == LVS_LIST) nScrollDiff *= infoPtr->nItemWidth; 7729 7876 7730 7877 /* and scroll the window */ 7731 7878 scroll_list(infoPtr, nScrollDiff, 0); … … 7884 8031 /* if we did not have the focus, there's nothing to do */ 7885 8032 if (!infoPtr->bFocus) return 0; 7886 8033 7887 8034 /* send NM_KILLFOCUS notification */ 7888 8035 notify(infoPtr, NM_KILLFOCUS); … … 7890 8037 /* if we have a focus rectagle, get rid of it */ 7891 8038 LISTVIEW_ShowFocusRect(infoPtr, FALSE); 7892 8039 7893 8040 /* set window focus flag */ 7894 8041 infoPtr->bFocus = FALSE; … … 7896 8043 /* invalidate the selected items before reseting focus flag */ 7897 8044 LISTVIEW_InvalidateSelectedItems(infoPtr); 7898 8045 7899 8046 return 0; 7900 8047 } … … 7991 8138 7992 8139 /* To send the LVN_ITEMACTIVATE, it must be on an Item */ 7993 if(htInfo.iItem != -1) notify (infoPtr, LVN_ITEMACTIVATE);8140 if(htInfo.iItem != -1) notify_itemactivate(infoPtr,&htInfo); 7994 8141 7995 8142 return 0; … … 8122 8269 #ifdef __WIN32OS2__ 8123 8270 //SvL: Send WM_COMMAND as well. (also done by NT's comctl32) 8124 SendMessageA( GetParent(infoPtr->hwndSelf), WM_COMMAND, (1<<16) | GetWindowLongW(infoPtr->hwndSelf, GWL_ID), infoPtr->hwndSelf);8271 SendMessageA(infoPtr->hwndNotify, WM_COMMAND, (1<<16) | GetWindowLongW(infoPtr->hwndSelf, GWL_ID), infoPtr->hwndSelf); 8125 8272 #endif 8126 8127 8273 return 0; 8128 8274 } … … 8143 8289 { 8144 8290 LVHITTESTINFO lvHitTestInfo; 8145 8291 8146 8292 TRACE("(key=%hu, X=%hu, Y=%hu)\n", wKey, pts.x, pts.y); 8147 8293 … … 8208 8354 8209 8355 /* free listview info pointer*/ 8210 COMCTL32_Free(infoPtr);8356 Free(infoPtr); 8211 8357 8212 8358 return 0; … … 8228 8374 { 8229 8375 UINT uView = infoPtr->dwStyle & LVS_TYPEMASK; 8230 8376 8231 8377 TRACE("(lpnmh=%p)\n", lpnmh); 8232 8378 8233 if (!lpnmh || lpnmh->iItem < 0 || lpnmh->iItem >= infoPtr->hdpaColumns->nItemCount) return 0;8234 8379 if (!lpnmh || lpnmh->iItem < 0 || lpnmh->iItem >= DPA_GetPtrCount(infoPtr->hdpaColumns)) return 0; 8380 8235 8381 switch (lpnmh->hdr.code) 8236 { 8382 { 8237 8383 case HDN_TRACKW: 8238 8384 case HDN_TRACKA: … … 8246 8392 { 8247 8393 HDITEMW hdi; 8248 8394 8249 8395 hdi.mask = HDI_WIDTH; 8250 8396 if (!Header_GetItemW(infoPtr->hwndHeader, lpnmh->iItem, (LPARAM)&hdi)) return 0; … … 8253 8399 else 8254 8400 cxy = lpnmh->pitem->cxy; 8255 8401 8256 8402 /* determine how much we change since the last know position */ 8257 8403 lpColumnInfo = LISTVIEW_GetColumnInfo(infoPtr, lpnmh->iItem); … … 8313 8459 8314 8460 if (nCommand != NF_REQUERY) return 0; 8315 8461 8316 8462 infoPtr->notifyFormat = SendMessageW(hwndFrom, WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY); 8317 8463 8318 8464 return 0; 8319 8465 } … … 8334 8480 TRACE("(hdc=%p)\n", hdc); 8335 8481 8336 infoPtr->bFirstPaint = FALSE;8337 8482 if (infoPtr->bNoItemMetrics && infoPtr->nItemCount) 8338 8483 { … … 8345 8490 LISTVIEW_UpdateScroll(infoPtr); 8346 8491 } 8347 if (hdc) 8492 if (hdc) 8348 8493 LISTVIEW_Refresh(infoPtr, hdc); 8349 8494 else … … 8376 8521 { 8377 8522 LVHITTESTINFO lvHitTestInfo; 8378 8523 8379 8524 TRACE("(key=%hu,X=%hu,Y=%hu)\n", wKey, pts.x, pts.y); 8380 8525 … … 8423 8568 lvHitTestInfo.pt.y = pts.y; 8424 8569 nItem = LISTVIEW_HitTest(infoPtr, &lvHitTestInfo, TRUE, TRUE); 8425 8570 8426 8571 if ((nItem >= 0) && (nItem < infoPtr->nItemCount)) 8427 8572 { … … 8459 8604 8460 8605 if (!infoPtr->bRButtonDown) return 0; 8461 8606 8462 8607 /* set button flag */ 8463 8608 infoPtr->bRButtonDown = FALSE; … … 8528 8673 /* if we have the focus already, there's nothing to do */ 8529 8674 if (infoPtr->bFocus) return 0; 8530 8675 8531 8676 /* send NM_SETFOCUS notification */ 8532 8677 notify(infoPtr, NM_SETFOCUS); … … 8564 8709 infoPtr->hFont = hFont ? hFont : infoPtr->hDefaultFont; 8565 8710 if (infoPtr->hFont == oldFont) return 0; 8566 8711 8567 8712 LISTVIEW_SaveTextMetrics(infoPtr); 8568 8713 … … 8597 8742 8598 8743 if(!bRedraw) return 0; 8599 8744 8600 8745 if (is_autoarrange(infoPtr)) 8601 8746 LISTVIEW_Arrange(infoPtr, LVA_DEFAULT); … … 8630 8775 LISTVIEW_UpdateSize(infoPtr); 8631 8776 if (EqualRect(&rcOld, &infoPtr->rcList)) return 0; 8632 8633 /* do not bother with display related stuff if we're not redrawing */ 8777 8778 /* do not bother with display related stuff if we're not redrawing */ 8634 8779 if (!is_redrawing(infoPtr)) return 0; 8635 8636 if (is_autoarrange(infoPtr)) 8780 8781 if (is_autoarrange(infoPtr)) 8637 8782 LISTVIEW_Arrange(infoPtr, LVA_DEFAULT); 8638 8783 … … 8640 8785 8641 8786 /* refresh all only for lists whose height changed significantly */ 8642 if ((infoPtr->dwStyle & LVS_TYPEMASK) == LVS_LIST && 8787 if ((infoPtr->dwStyle & LVS_TYPEMASK) == LVS_LIST && 8643 8788 (rcOld.bottom - rcOld.top) / infoPtr->nItemHeight != 8644 8789 (infoPtr->rcList.bottom - infoPtr->rcList.top) / infoPtr->nItemHeight) … … 8663 8808 8664 8809 TRACE("uView=%d, rcList(old)=%s\n", uView, debugrect(&infoPtr->rcList)); 8665 8810 8666 8811 GetClientRect(infoPtr->hwndSelf, &infoPtr->rcList); 8667 8812 … … 8718 8863 8719 8864 if (wStyleType != GWL_STYLE) return 0; 8720 8865 8721 8866 /* FIXME: if LVS_NOSORTHEADER changed, update header */ 8722 8867 /* what if LVS_OWNERDATA changed? */ … … 8738 8883 SIZE oldIconSize = infoPtr->iconSize; 8739 8884 HIMAGELIST himl; 8740 8885 8741 8886 SendMessageW(infoPtr->hwndEdit, WM_KILLFOCUS, 0, 0); 8742 8887 ShowWindow(infoPtr->hwndHeader, SW_HIDE); … … 8747 8892 himl = (uNewView == LVS_ICON ? infoPtr->himlNormal : infoPtr->himlSmall); 8748 8893 set_icon_size(&infoPtr->iconSize, himl, uNewView != LVS_ICON); 8749 8894 8750 8895 if (uNewView == LVS_ICON) 8751 8896 { … … 8773 8918 if (uNewView == LVS_REPORT) 8774 8919 ShowWindow(infoPtr->hwndHeader, (lpss->styleNew & LVS_NOCOLUMNHEADER) ? SW_HIDE : SW_SHOWNORMAL); 8775 8920 8776 8921 if ( (uNewView == LVS_ICON || uNewView == LVS_SMALLICON) && 8777 8922 (uNewView != uOldView || ((lpss->styleNew ^ lpss->styleOld) & LVS_ALIGNMASK)) ) … … 9085 9230 TRACE("(uMsg=%x wParam=%x lParam=%lx)\n", uMsg, wParam, lParam); 9086 9231 #endif 9232 9087 9233 if (!infoPtr && (uMsg != WM_CREATE)) 9088 9234 return DefWindowProcW(hwnd, uMsg, wParam, lParam); … … 9340 9486 9341 9487 case LVM_SETCOLUMNWIDTH: 9342 return LISTVIEW_SetColumnWidth(infoPtr, (INT)wParam, SLOWORD(lParam));9488 return LISTVIEW_SetColumnWidth(infoPtr, (INT)wParam, (short)LOWORD(lParam)); 9343 9489 9344 9490 case LVM_SETEXTENDEDLISTVIEWSTYLE: … … 9359 9505 9360 9506 case LVM_SETICONSPACING: 9361 return LISTVIEW_SetIconSpacing(infoPtr, SLOWORD(lParam), SHIWORD(lParam));9507 return LISTVIEW_SetIconSpacing(infoPtr, (short)LOWORD(lParam), (short)HIWORD(lParam)); 9362 9508 9363 9509 case LVM_SETIMAGELIST: … … 9381 9527 case LVM_SETITEMPOSITION: 9382 9528 { 9383 POINT pt = { SLOWORD(lParam), SHIWORD(lParam) }; 9529 POINT pt; 9530 pt.x = (short)LOWORD(lParam); 9531 pt.y = (short)HIWORD(lParam); 9384 9532 return LISTVIEW_SetItemPosition(infoPtr, (INT)wParam, pt); 9385 9533 } … … 9519 9667 9520 9668 case WM_SIZE: 9521 return LISTVIEW_Size(infoPtr, ( int)SLOWORD(lParam), (int)SHIWORD(lParam));9669 return LISTVIEW_Size(infoPtr, (short)LOWORD(lParam), (short)HIWORD(lParam)); 9522 9670 9523 9671 case WM_STYLECHANGED: … … 9539 9687 9540 9688 case WM_WINDOWPOSCHANGED: 9541 if (!(((WINDOWPOS *)lParam)->flags & SWP_NOSIZE)) 9689 if (!(((WINDOWPOS *)lParam)->flags & SWP_NOSIZE)) 9542 9690 { 9543 9691 SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | … … 9581 9729 wndClass.cbClsExtra = 0; 9582 9730 wndClass.cbWndExtra = sizeof(LISTVIEW_INFO *); 9583 wndClass.hCursor = LoadCursorW(0, IDC_ARROWW);9731 wndClass.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROWW); 9584 9732 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 9585 9733 wndClass.lpszClassName = WC_LISTVIEWW; … … 9667 9815 9668 9816 default: 9669 return SendMessageW ( GetParent (infoPtr->hwndSelf), WM_COMMAND, wParam, lParam);9817 return SendMessageW (infoPtr->hwndNotify, WM_COMMAND, wParam, lParam); 9670 9818 } 9671 9819 … … 9737 9885 if (len) 9738 9886 { 9739 if ( (buffer = COMCTL32_Alloc((len+1) * (isW ? sizeof(WCHAR) : sizeof(CHAR)))) )9887 if ( (buffer = Alloc((len+1) * (isW ? sizeof(WCHAR) : sizeof(CHAR)))) ) 9740 9888 { 9741 9889 if (isW) GetWindowTextW(hwnd, buffer, len+1); … … 9746 9894 LISTVIEW_EndEditLabelT(infoPtr, buffer, isW); 9747 9895 9748 if (buffer) COMCTL32_Free(buffer);9896 if (buffer) Free(buffer); 9749 9897 9750 9898 } … … 9820 9968 hOldFont = SelectObject(hdc, infoPtr->hFont); 9821 9969 9822 /*Get String Leng htin pixels */9970 /*Get String Length in pixels */ 9823 9971 GetTextExtentPoint32W(hdc, text, lstrlenW(text), &sz); 9824 9972
Note:
See TracChangeset
for help on using the changeset viewer.