- Timestamp:
- Jun 23, 1999, 9:45:02 PM (26 years ago)
- Location:
- trunk/src/comctl32
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/comctl32.c
r94 r164 1 /* $Id: comctl32.c,v 1. 5 1999-06-10 16:21:58achimha Exp $ */1 /* $Id: comctl32.c,v 1.6 1999-06-23 19:45:00 achimha Exp $ */ 2 2 /* 3 3 * Win32 common controls implementation … … 313 313 UINT border = BDR_SUNKENOUTER; 314 314 315 if (style ==SBT_POPOUT)315 if (style & SBT_POPOUT) 316 316 border = BDR_RAISEDOUTER; 317 else if (style ==SBT_NOBORDERS)317 else if (style & SBT_NOBORDERS) 318 318 border = 0; 319 319 -
trunk/src/comctl32/comctl32undoc.c
r94 r164 1 /* $Id: comctl32undoc.c,v 1. 6 1999-06-10 16:21:58achimha Exp $ */1 /* $Id: comctl32undoc.c,v 1.7 1999-06-23 19:45:00 achimha Exp $ */ 2 2 /* 3 3 * Undocumented functions from COMCTL32.DLL … … 618 618 LPVOID pDest, lpTemp; 619 619 620 // TRACE (commctrl,"(%p %d %p)\n", hdsa, nIndex, pSrc);620 // TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc); 621 621 622 622 if ((!hdsa) || nIndex < 0) … … 627 627 if (hdsa->nMaxCount > nIndex) { 628 628 /* within the allocated space, set a new boundary */ 629 hdsa->nItemCount = nIndex ;629 hdsa->nItemCount = nIndex + 1; 630 630 } 631 631 else { … … 640 640 641 641 hdsa->nMaxCount = nNewItems; 642 hdsa->nItemCount = nIndex + 1; 642 643 hdsa->pData = lpTemp; 643 644 } … … 646 647 /* put the new entry in */ 647 648 pDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); 648 // TRACE (commctrl,"-- move dest=%p src=%p size=%d\n",649 // TRACE("-- move dest=%p src=%p size=%d\n", 649 650 // pDest, pSrc, hdsa->nItemSize); 650 651 memmove (pDest, pSrc, hdsa->nItemSize); … … 674 675 LPDWORD p; 675 676 676 // TRACE( commctrl,"(%p %d %p)\n", hdsa, nIndex, pSrc);677 // TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc); 677 678 678 679 if ((!hdsa) || nIndex < 0) … … 682 683 p = *(DWORD**)((char *) pSrc + i); 683 684 // if (IsBadStringPtrA ((char*)p, 256)) 684 // TRACE (commctrl,"-- %d=%p\n", i, (DWORD*)p);685 // TRACE("-- %d=%p\n", i, (DWORD*)p); 685 686 // else 686 // TRACE (commctrl,"-- %d=%p [%s]\n", i, p, debugstr_a((char*)p));687 // TRACE("-- %d=%p [%s]\n", i, p, debugstr_a((char*)p)); 687 688 } 688 689 … … 709 710 lpDest = (char *) lpTemp + hdsa->nItemSize; 710 711 nSize = (hdsa->nItemCount - nIndex) * hdsa->nItemSize; 711 // TRACE (commctrl,"-- move dest=%p src=%p size=%d\n",712 // TRACE("-- move dest=%p src=%p size=%d\n", 712 713 // lpDest, lpTemp, nSize); 713 714 memmove (lpDest, lpTemp, nSize); … … 717 718 hdsa->nItemCount++; 718 719 lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex); 719 // TRACE (commctrl,"-- move dest=%p src=%p size=%d\n",720 // TRACE("-- move dest=%p src=%p size=%d\n", 720 721 // lpDest, pSrc, hdsa->nItemSize); 721 722 memmove (lpDest, pSrc, hdsa->nItemSize); -
trunk/src/comctl32/imagelist.c
r94 r164 1 /* $Id: imagelist.c,v 1. 3 1999-06-10 16:21:59achimha Exp $ */1 /* $Id: imagelist.c,v 1.4 1999-06-23 19:45:00 achimha Exp $ */ 2 2 /* 3 3 * ImageList implementation … … 1207 1207 HICON hIcon; 1208 1208 HDC hdcSrc, hdcDst; 1209 INT nWidth, nHeight;1210 1209 1211 1210 if ((himl == NULL) || (i < 0) || (i >= himl->cCurImage)) 1212 1211 return 0; 1213 1212 1214 nWidth = GetSystemMetrics (SM_CXICON);1215 nHeight = GetSystemMetrics (SM_CYICON);1216 1217 1213 hdcSrc = CreateCompatibleDC(0); 1218 1214 hdcDst = CreateCompatibleDC(0); 1219 1215 1220 1216 ii.fIcon = TRUE; 1221 ii.xHotspot = nWidth / 2; 1222 ii.yHotspot = nHeight / 2; 1223 ii.hbmMask = CreateCompatibleBitmap (hdcDst, nWidth, nHeight); 1224 ii.hbmColor = CreateCompatibleBitmap (hdcDst, nWidth, nHeight); 1217 ii.hbmMask = CreateCompatibleBitmap (hdcDst, himl->cx, himl->cy); 1218 ii.hbmColor = CreateCompatibleBitmap (hdcDst, himl->cx, himl->cy); 1225 1219 1226 1220 … … 1229 1223 if (himl->hbmMask) { 1230 1224 SelectObject (hdcSrc, himl->hbmMask); 1231 BitBlt (hdcDst, 0, 0, nWidth, nHeight,1225 BitBlt (hdcDst, 0, 0, himl->cx, himl->cy, 1232 1226 hdcSrc, i * himl->cx, 0, SRCCOPY); 1233 1227 } 1234 1228 else 1235 PatBlt (hdcDst, 0, 0, nWidth, nHeight, BLACKNESS);1229 PatBlt (hdcDst, 0, 0, himl->cx, himl->cy, BLACKNESS); 1236 1230 1237 1231 /* draw image*/ 1238 1232 SelectObject (hdcDst, ii.hbmColor); 1239 1233 SelectObject (hdcSrc, himl->hbmImage); 1240 BitBlt (hdcDst, 0, 0, nWidth, nHeight,1234 BitBlt (hdcDst, 0, 0, himl->cx, himl->cy, 1241 1235 hdcSrc, i * himl->cx, 0, SRCCOPY); 1242 1236 -
trunk/src/comctl32/listview.c
r94 r164 1 /* $Id: listview.c,v 1.3 1999-06-10 16:22:00 achimha Exp $ */2 1 /* 3 2 * Listview control … … 11 10 * 12 11 * TODO: 13 * 14 * 1. Multiple selections in icon or small icon display modes DO NOT 15 * behave like the Microsoft control. 16 * 2. No horizontal scrolling when header is larger than the client area. 17 * 3. Implement LVM_FINDITEM for key selections. 18 * 4. Drawing optimizations. 12 * 1. No horizontal scrolling when header is larger than the client area. 13 * 2. Drawing optimizations. 19 14 * 20 15 * Notifications: … … 22 17 * 23 18 * Data structure: 24 * LISTVIEW_SortItems : empty stub25 19 * LISTVIEW_SetItemCount : empty stub 26 20 * … … 41 35 * LISTVIEW_GetColumnOrderArray : not implemented 42 36 * LISTVIEW_Arrange : empty stub 43 * LISTVIEW_FindItem : empty stub44 37 * LISTVIEW_ApproximateViewRect : incomplete 45 38 * LISTVIEW_Scroll : not implemented 46 * LISTVIEW_KeyDown : page up and page down + redo small icon and icon47 39 * LISTVIEW_RedrawItems : empty stub 48 40 * LISTVIEW_Update : not completed … … 53 45 #include "commctrl.h" 54 46 #include "listview.h" 47 #include "debugtools.h" 55 48 56 49 /* … … 86 79 * macros 87 80 */ 88 89 /* retrieve the number of items in the listview */90 81 #define GETITEMCOUNT(infoPtr) ((infoPtr)->hdpaItems->nItemCount) 91 82 #define ListView_LVNotify(hwnd,lCtrlId,plvnm) \ … … 93 84 #define ListView_Notify(hwnd,lCtrlId,pnmh) \ 94 85 (BOOL)SendMessageA((hwnd),WM_NOTIFY,(WPARAM)(INT)lCtrlId,(LPARAM)(LPNMHDR)(pnmh)) 86 /* retrieve the number of items in the listview */ 87 #define GETITEMCOUNT(infoPtr) ((infoPtr)->hdpaItems->nItemCount) 95 88 96 89 /* 97 90 * forward declarations 98 91 */ 99 92 static INT LISTVIEW_HitTestItem(HWND, LPLVHITTESTINFO); 93 static INT LISTVIEW_GetCountPerRow(HWND); 94 static INT LISTVIEW_GetCountPerColumn(HWND); 100 95 static VOID LISTVIEW_AlignLeft(HWND); 101 96 static VOID LISTVIEW_AlignTop(HWND); … … 104 99 static BOOL LISTVIEW_AddSubItem(HWND, LPLVITEMA); 105 100 static INT LISTVIEW_FindInsertPosition(HDPA, INT); 106 static VOID LISTVIEW_GetItemDispInfo(HWND, INT, LISTVIEW_ITEM *lpItem, INT *, 107 UINT *, CHAR **, INT); 108 static INT LISTVIEW_GetItemHeight(HWND, LONG); 101 static INT LISTVIEW_GetItemHeight(HWND); 109 102 static BOOL LISTVIEW_GetItemPosition(HWND, INT, LPPOINT); 110 103 static LRESULT LISTVIEW_GetItemRect(HWND, INT, LPRECT); 111 static INT LISTVIEW_GetItemWidth(HWND , LONG);104 static INT LISTVIEW_GetItemWidth(HWND); 112 105 static INT LISTVIEW_GetLabelWidth(HWND, INT); 113 106 static LRESULT LISTVIEW_GetOrigin(HWND, LPPOINT); 114 107 static LISTVIEW_SUBITEM* LISTVIEW_GetSubItem(HDPA, INT); 115 static VOID LISTVIEW_GetSubItemDispInfo(HWND hwnd, INT, LPARAM,116 LISTVIEW_SUBITEM *, INT, INT *,117 CHAR **, INT);118 108 static LRESULT LISTVIEW_GetViewRect(HWND, LPRECT); 119 109 static BOOL LISTVIEW_InitItem(HWND, LISTVIEW_ITEM *, LPLVITEMA); 120 110 static BOOL LISTVIEW_InitSubItem(HWND, LISTVIEW_SUBITEM *, LPLVITEMA); 121 static LRESULT LISTVIEW_MouseSelection(HWND, INT,INT);111 static LRESULT LISTVIEW_MouseSelection(HWND, POINT); 122 112 static BOOL LISTVIEW_RemoveColumn(HDPA, INT); 123 113 static VOID LISTVIEW_RemoveSelections(HWND, INT, INT); 124 114 static BOOL LISTVIEW_RemoveSubItem(HDPA, INT); 125 static BOOL LISTVIEW_ScrollView(HWND, INT, INT);126 115 static VOID LISTVIEW_SetGroupSelection(HWND, INT); 127 116 static BOOL LISTVIEW_SetItem(HWND, LPLVITEMA); 128 static VOIDLISTVIEW_SetItemFocus(HWND, INT);117 static BOOL LISTVIEW_SetItemFocus(HWND, INT); 129 118 static BOOL LISTVIEW_SetItemPosition(HWND, INT, INT, INT); 130 static VOID LISTVIEW_ SetScroll(HWND, LONG);119 static VOID LISTVIEW_UpdateScroll(HWND); 131 120 static VOID LISTVIEW_SetSelection(HWND, INT); 132 static VOID LISTVIEW_ SetSize(HWND, LONG, LONG, LONG);121 static VOID LISTVIEW_UpdateSize(HWND); 133 122 static BOOL LISTVIEW_SetSubItem(HWND, LPLVITEMA); 134 static VOID LISTVIEW_SetViewInfo(HWND, LONG);135 123 static LRESULT LISTVIEW_SetViewRect(HWND, LPRECT); 136 124 static BOOL LISTVIEW_ToggleSelection(HWND, INT); … … 139 127 /*** 140 128 * DESCRIPTION: 141 * Scrolls the content of the listview. 142 * 143 * PARAMETER(S): 144 * [I] HWND : window handle 145 * [I] INT : number of horizontal scroll positions 146 * (relative to the current scroll postioon) 147 * [I] INT : number of vertical scroll positions 148 * (relative to the current scroll postioon) 149 * 150 * RETURN: 151 * SUCCESS : TRUE 152 * FAILURE : FALSE 153 */ 154 static BOOL LISTVIEW_ScrollView(HWND hwnd, INT nHScroll, INT nVScroll) 129 * Update the scrollbars. This functions should be called whenever 130 * the content, size or view changes. 131 * 132 * PARAMETER(S): 133 * [I] HWND : window handle 134 * 135 * RETURN: 136 * None 137 */ 138 static VOID LISTVIEW_UpdateScroll(HWND hwnd) 155 139 { 156 140 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 157 141 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 142 UINT uView = lStyle & LVS_TYPEMASK; 143 INT nListHeight = infoPtr->rcList.bottom - infoPtr->rcList.top; 158 144 INT nListWidth = infoPtr->rcList.right - infoPtr->rcList.left; 159 INT nListHeight = infoPtr->rcList.bottom - infoPtr->rcList.top; 160 INT nHScrollPos = 0; 161 INT nVScrollPos = 0; 162 INT nHScrollInc = 0; 163 INT nVScrollInc = 0; 164 BOOL bResult = FALSE; 165 166 if (((lStyle & WS_HSCROLL) != 0) && (nHScroll != 0)) 167 { 168 switch (LVS_TYPEMASK & lStyle) 169 { 170 case LVS_LIST: 171 nHScrollInc = nHScroll * infoPtr->nItemWidth; 172 break; 173 174 case LVS_REPORT: 175 /* TO DO : not implemented at this point. I experiences some 176 problems when performing child window scrolling. */ 177 break; 178 179 case LVS_SMALLICON: 180 case LVS_ICON: 181 nHScrollInc = nHScroll * max(nListWidth, nListWidth / 10); 182 break; 183 } 184 185 nHScrollPos = GetScrollPos(hwnd, SB_HORZ) + nHScroll; 186 } 187 188 if (((lStyle & WS_VSCROLL) != 0) & (nVScroll != 0)) 189 { 190 switch (LVS_TYPEMASK & lStyle) 191 { 192 case LVS_REPORT: 193 nVScrollInc = nVScroll * infoPtr->nItemHeight; 194 nVScrollPos = GetScrollPos(hwnd, SB_VERT) + nVScroll; 195 break; 145 SCROLLINFO scrollInfo; 146 147 ZeroMemory(&scrollInfo, sizeof(SCROLLINFO)); 148 scrollInfo.cbSize = sizeof(SCROLLINFO); 149 150 if (uView == LVS_LIST) 151 { 152 INT nCountPerColumn = LISTVIEW_GetCountPerColumn(hwnd); 153 INT nCountPerPage = LISTVIEW_GetCountPerRow(hwnd) * nCountPerColumn; 154 if (nCountPerPage < GETITEMCOUNT(infoPtr)) 155 { 156 /* calculate new scrollbar range */ 157 INT nHiddenItemCount = GETITEMCOUNT(infoPtr) - nCountPerPage; 158 if (nHiddenItemCount % nCountPerColumn == 0) 159 { 160 scrollInfo.nMax = nHiddenItemCount / nCountPerColumn; 161 } 162 else 163 { 164 scrollInfo.nMax = nHiddenItemCount / nCountPerColumn + 1; 165 } 196 166 197 case LVS_SMALLICON: 198 case LVS_ICON: 199 nVScrollInc = nVScroll * max(nListHeight, nListHeight / 10); 200 nVScrollPos = GetScrollPos(hwnd, SB_VERT) + nVScroll; 201 break; 202 } 203 } 204 205 /* perform scroll operation & set new scroll position */ 206 if ((nHScrollInc != 0) || (nVScrollInc != 0)) 207 { 208 RECT rc; 209 HDC hdc = GetDC(hwnd); 210 ScrollDC(hdc, -nHScrollInc, -nVScrollInc, &infoPtr->rcList, NULL, 211 (HRGN) NULL, &rc); 212 InvalidateRect(hwnd, &rc, TRUE); 213 SetScrollPos(hwnd, SB_HORZ, nHScrollPos, TRUE); 214 SetScrollPos(hwnd, SB_VERT, nVScrollPos, TRUE); 215 ReleaseDC(hwnd, hdc); 216 bResult = TRUE; 217 } 218 219 return bResult; 167 scrollInfo.nPos = ListView_GetTopIndex(hwnd) / nCountPerColumn; 168 /*scrollInfo.nPage = LISTVIEW_GetCountPerRow(hwnd);*/ 169 scrollInfo.fMask = SIF_RANGE | SIF_POS /*| SIF_PAGE*/; 170 SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE); 171 } 172 else 173 { 174 /* hide scrollbar */ 175 if (lStyle & WS_HSCROLL) 176 { 177 ShowScrollBar(hwnd, SB_HORZ, FALSE); 178 } 179 } 180 } 181 else if (uView == LVS_REPORT) 182 { 183 /* update vertical scrollbar */ 184 scrollInfo.nMin = 0; 185 scrollInfo.nMax = GETITEMCOUNT(infoPtr) - LISTVIEW_GetCountPerColumn(hwnd); 186 scrollInfo.nPos = ListView_GetTopIndex(hwnd); 187 /*scrollInfo.nPage = nCountPerColumn;*/ 188 scrollInfo.fMask = SIF_RANGE | SIF_POS /*| SIF_PAGE*/; 189 SetScrollInfo(hwnd, SB_VERT, &scrollInfo, TRUE); 190 191 /* update horizontal scrollbar */ 192 /* if (infoPtr->nItemWidth > nListWidth) */ 193 /* { */ 194 /* scrollInfo.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; */ 195 /* SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE); */ 196 /* } */ 197 198 /* horizontal scrolling has not been implemented yet! I experienced some 199 problems when performing child window scrolling. */ 200 } 201 else 202 { 203 RECT rcView; 204 205 if (LISTVIEW_GetViewRect(hwnd, &rcView) != FALSE) 206 { 207 INT nViewWidth = rcView.right - rcView.left; 208 INT nViewHeight = rcView.bottom - rcView.top; 209 210 if (nViewWidth > nListWidth) 211 { 212 INT nHiddenWidth; 213 INT nScrollPosWidth = nListWidth / 10; 214 215 if (nScrollPosWidth == 0) 216 { 217 nScrollPosWidth = 1; 218 nHiddenWidth = nViewWidth - nListWidth; 219 } 220 else 221 { 222 nHiddenWidth = nViewWidth - nScrollPosWidth * 10; 223 } 224 225 scrollInfo.fMask = SIF_POS; 226 if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) == FALSE) 227 { 228 scrollInfo.nPos = 0; 229 } 230 231 if (nHiddenWidth % nScrollPosWidth == 0) 232 { 233 scrollInfo.nMax = nHiddenWidth / nScrollPosWidth; 234 } 235 else 236 { 237 scrollInfo.nMax = nHiddenWidth / nScrollPosWidth + 1; 238 } 239 240 scrollInfo.nMin = 0; 241 /*scrollInfo.nPage = 10;*/ 242 scrollInfo.fMask = SIF_RANGE | SIF_POS /*| SIF_PAGE*/; 243 SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE); 244 } 245 else 246 { 247 if (lStyle & WS_HSCROLL) 248 { 249 ShowScrollBar(hwnd, SB_HORZ, FALSE); 250 } 251 } 252 253 if (nViewHeight > nListHeight) 254 { 255 INT nHiddenHeight; 256 INT nScrollPosHeight = nListHeight / 10; 257 258 if (nScrollPosHeight == 0) 259 { 260 nScrollPosHeight = 1; 261 nHiddenHeight = nViewHeight - nListHeight; 262 } 263 else 264 { 265 nHiddenHeight = nViewHeight - nScrollPosHeight * 10; 266 } 267 268 scrollInfo.fMask = SIF_POS; 269 if (GetScrollInfo(hwnd, SB_VERT, &scrollInfo) == FALSE) 270 { 271 scrollInfo.nPos = 0; 272 } 273 274 if (nHiddenHeight % nScrollPosHeight == 0) 275 { 276 scrollInfo.nMax = nHiddenHeight / nScrollPosHeight; 277 } 278 else 279 { 280 scrollInfo.nMax = nHiddenHeight / nScrollPosHeight + 1; 281 } 282 283 scrollInfo.nMin = 0; 284 /*scrollInfo.nPage = 10;*/ 285 scrollInfo.fMask = SIF_RANGE | SIF_POS /*| SIF_PAGE*/; 286 SetScrollInfo(hwnd, SB_VERT, &scrollInfo, TRUE); 287 } 288 else 289 { 290 if (lStyle & WS_VSCROLL) 291 { 292 ShowScrollBar(hwnd, SB_VERT, FALSE); 293 } 294 } 295 } 296 } 220 297 } 221 298 … … 235 312 if ((LVS_TYPEMASK & lStyle) == LVS_EDITLABELS) 236 313 { 237 // FIXME( listview, " LVS_EDITLABELS\n"); 238 } 239 240 if ((LVS_TYPEMASK & lStyle) == LVS_NOCOLUMNHEADER) 241 { 242 // FIXME( listview, " LVS_SORTDESCENDING\n"); 314 FIXME(" LVS_EDITLABELS\n"); 243 315 } 244 316 245 317 if ((LVS_TYPEMASK & lStyle) == LVS_NOLABELWRAP) 246 318 { 247 // FIXME( listview," LVS_NOLABELWRAP\n");319 FIXME(" LVS_NOLABELWRAP\n"); 248 320 } 249 321 250 322 if ((LVS_TYPEMASK & lStyle) == LVS_NOSCROLL) 251 323 { 252 // FIXME( listview," LVS_NOSCROLL\n");324 FIXME(" LVS_NOSCROLL\n"); 253 325 } 254 326 255 327 if ((LVS_TYPEMASK & lStyle) == LVS_NOSORTHEADER) 256 328 { 257 // FIXME( listview," LVS_NOSORTHEADER\n");329 FIXME(" LVS_NOSORTHEADER\n"); 258 330 } 259 331 260 332 if ((LVS_TYPEMASK & lStyle) == LVS_OWNERDRAWFIXED) 261 333 { 262 // FIXME( listview," LVS_OWNERDRAWFIXED\n");334 FIXME(" LVS_OWNERDRAWFIXED\n"); 263 335 } 264 336 265 337 if ((LVS_TYPEMASK & lStyle) == LVS_SHAREIMAGELISTS) 266 338 { 267 // FIXME( listview, " LVS_SHAREIMAGELISTS\n"); 268 } 269 270 if ((LVS_TYPEMASK & lStyle) == LVS_SHOWSELALWAYS) 271 { 272 // FIXME( listview, " LVS_SHOWSELALWAYS\n"); 273 } 274 275 if ((LVS_TYPEMASK & lStyle) == LVS_SINGLESEL) 276 { 277 // FIXME( listview, " LVS_SINGLESEL\n"); 339 FIXME(" LVS_SHAREIMAGELISTS\n"); 278 340 } 279 341 280 342 if ((LVS_TYPEMASK & lStyle) == LVS_SORTASCENDING) 281 343 { 282 // FIXME( listview," LVS_SORTASCENDING\n");344 FIXME(" LVS_SORTASCENDING\n"); 283 345 } 284 346 285 347 if ((LVS_TYPEMASK & lStyle) == LVS_SORTDESCENDING) 286 348 { 287 // FIXME( listview," LVS_SORTDESCENDING\n");349 FIXME(" LVS_SORTDESCENDING\n"); 288 350 } 289 351 } … … 302 364 { 303 365 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 304 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);366 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 305 367 INT nListWidth = infoPtr->rcList.right - infoPtr->rcList.left; 306 368 POINT ptItem; … … 308 370 INT i; 309 371 310 switch (LVS_TYPEMASK & lStyle) 311 { 312 case LVS_SMALLICON: 313 case LVS_ICON: 372 if ((uView == LVS_SMALLICON) || (uView == LVS_ICON)) 373 { 314 374 ZeroMemory(&ptItem, sizeof(POINT)); 315 375 ZeroMemory(&rcView, sizeof(RECT)); 376 316 377 if (nListWidth > infoPtr->nItemWidth) 317 378 { … … 324 385 } 325 386 326 L ISTVIEW_SetItemPosition(hwnd, i, ptItem.x, ptItem.y);387 ListView_SetItemPosition(hwnd, i, ptItem.x, ptItem.y); 327 388 ptItem.x += infoPtr->nItemWidth; 328 389 rcView.right = max(rcView.right, ptItem.x); 329 390 } 391 392 rcView.bottom = ptItem.y + infoPtr->nItemHeight; 330 393 } 331 394 else … … 333 396 for (i = 0; i < GETITEMCOUNT(infoPtr); i++) 334 397 { 335 L ISTVIEW_SetItemPosition(hwnd, i, ptItem.x, ptItem.y);336 ptItem. x += infoPtr->nItemWidth;337 } 338 rcView.right = ptItem.x; 339 rcView. bottom = infoPtr->nItemHeight;340 }341 342 rcView.bottom = ptItem.y + infoPtr->nItemHeight; 398 ListView_SetItemPosition(hwnd, i, ptItem.x, ptItem.y); 399 ptItem.y += infoPtr->nItemHeight; 400 } 401 402 rcView.right = infoPtr->nItemWidth; 403 rcView.bottom = ptItem.y; 404 } 405 343 406 LISTVIEW_SetViewRect(hwnd, &rcView); 344 407 } … … 358 421 { 359 422 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 360 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);423 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 361 424 INT nListHeight = infoPtr->rcList.bottom - infoPtr->rcList.top; 362 425 POINT ptItem; … … 364 427 INT i; 365 428 366 switch (LVS_TYPEMASK & lStyle) 367 { 368 case LVS_SMALLICON: 369 case LVS_ICON: 429 if ((uView == LVS_SMALLICON) || (uView == LVS_ICON)) 430 { 370 431 ZeroMemory(&ptItem, sizeof(POINT)); 371 432 ZeroMemory(&rcView, sizeof(RECT)); 433 372 434 if (nListHeight > infoPtr->nItemHeight) 373 435 { … … 380 442 } 381 443 382 L ISTVIEW_SetItemPosition(hwnd, i, ptItem.x, ptItem.y);444 ListView_SetItemPosition(hwnd, i, ptItem.x, ptItem.y); 383 445 ptItem.y += infoPtr->nItemHeight; 384 446 rcView.bottom = max(rcView.bottom, ptItem.y); 385 447 } 448 449 rcView.right = ptItem.x + infoPtr->nItemWidth; 386 450 } 387 451 else … … 389 453 for (i = 0; i < GETITEMCOUNT(infoPtr); i++) 390 454 { 391 L ISTVIEW_SetItemPosition(hwnd, i, ptItem.x, ptItem.y);392 ptItem. y += infoPtr->nItemHeight;393 } 394 rcView.bottom = ptItem.y; 395 rcView. right = infoPtr->nItemWidth;396 }397 398 rcView.right = ptItem.x + infoPtr->nItemWidth; 455 ListView_SetItemPosition(hwnd, i, ptItem.x, ptItem.y); 456 ptItem.x += infoPtr->nItemWidth; 457 } 458 459 rcView.bottom = infoPtr->nItemHeight; 460 rcView.right = ptItem.x; 461 } 462 399 463 LISTVIEW_SetViewRect(hwnd, &rcView); 400 break; 401 } 402 } 403 404 /*** 405 * DESCRIPTION: 406 * Retrieves display information. 407 * 408 * PARAMETER(S): 409 * [I] HWND : window handle 410 * [I] INT : item index 411 * [I] LISTVIEW_ITEM* : listview control item 412 * [O] INT : image index 413 * [O] UINT : state value 414 * [O] CHAR** : string 415 * [I] INT : size of string 416 * 417 * RETURN: 418 * None 419 */ 420 static VOID LISTVIEW_GetItemDispInfo(HWND hwnd, INT nItem, 421 LISTVIEW_ITEM *lpItem, INT *pnDispImage, 422 UINT *puState, CHAR **ppszDispText, 423 INT nDispTextSize) 424 { 425 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 426 LONG lCtrlId = GetWindowLongA(hwnd, GWL_ID); 427 NMLVDISPINFOA dispInfo; 428 ZeroMemory(&dispInfo, sizeof(NMLVDISPINFOA)); 429 430 if ((pnDispImage != NULL) && (lpItem->iImage == I_IMAGECALLBACK)) 431 { 432 dispInfo.item.mask |= LVIF_IMAGE; 433 } 434 435 if ((ppszDispText != NULL) && (lpItem->pszText == LPSTR_TEXTCALLBACKA)) 436 { 437 ZeroMemory(*ppszDispText, sizeof(CHAR)*nDispTextSize); 438 dispInfo.item.mask |= LVIF_TEXT; 439 dispInfo.item.pszText = *ppszDispText; 440 dispInfo.item.cchTextMax = nDispTextSize; 441 } 442 443 if ((puState != NULL) && (infoPtr->uCallbackMask != 0)) 444 { 445 dispInfo.item.mask |= LVIF_STATE; 446 dispInfo.item.stateMask = infoPtr->uCallbackMask; 447 } 448 449 if (dispInfo.item.mask != 0) 450 { 451 dispInfo.hdr.hwndFrom = hwnd; 452 dispInfo.hdr.idFrom = lCtrlId; 453 dispInfo.hdr.code = LVN_GETDISPINFOA; 454 dispInfo.item.iItem = nItem; 455 dispInfo.item.iSubItem = 0; 456 dispInfo.item.lParam = lpItem->lParam; 457 ListView_Notify(GetParent(hwnd), lCtrlId, &dispInfo); 458 } 459 460 if (pnDispImage != NULL) 461 { 462 if (dispInfo.item.mask & LVIF_IMAGE) 463 { 464 *pnDispImage = dispInfo.item.iImage; 465 } 466 else 467 { 468 *pnDispImage = lpItem->iImage; 469 } 470 } 471 472 if (ppszDispText != NULL) 473 { 474 if (dispInfo.item.mask & LVIF_TEXT) 475 { 476 if (dispInfo.item.mask & LVIF_DI_SETITEM) 477 { 478 Str_SetPtrA(&lpItem->pszText, dispInfo.item.pszText); 479 } 480 *ppszDispText = dispInfo.item.pszText; 481 } 482 else 483 { 484 *ppszDispText = lpItem->pszText; 485 } 486 } 487 488 if (puState != NULL) 489 { 490 if (dispInfo.item.mask & LVIF_STATE) 491 { 492 *puState = lpItem->state; 493 *puState &= ~dispInfo.item.stateMask; 494 *puState |= (dispInfo.item.state & dispInfo.item.stateMask); 495 } 496 else 497 { 498 *puState = lpItem->state; 499 } 500 } 501 } 502 503 /*** 504 * DESCRIPTION: 505 * Retrieves subitem display information. 506 * 507 * PARAMETER(S): 508 * [I] HWND : window handle 509 * [I] INT : item index 510 * [I] LONG : LPARAM of item 511 * [I] LISTVIEW_SUBITEM* : listview control subitem 512 * [I] INT : subitem position/order 513 * [O] INT : image index 514 * [O] UINT : state value 515 * [O] CHAR** : display string 516 * [I] INT : size of string 517 * 518 * RETURN: 519 * None 520 */ 521 static VOID LISTVIEW_GetSubItemDispInfo(HWND hwnd, INT nItem, LPARAM lParam, 522 LISTVIEW_SUBITEM *lpSubItem, 523 INT nSubItemPos, INT *pnDispImage, 524 CHAR **ppszDispText, INT nDispTextSize) 525 { 526 LONG lCtrlId = GetWindowLongA(hwnd, GWL_ID); 527 NMLVDISPINFOA dispInfo; 528 ZeroMemory(&dispInfo, sizeof(NMLVDISPINFOA)); 529 530 if (lpSubItem == NULL) 531 { 532 ZeroMemory(*ppszDispText, sizeof(CHAR)*nDispTextSize); 533 dispInfo.item.mask |= LVIF_TEXT; 534 dispInfo.item.pszText = *ppszDispText; 535 dispInfo.item.cchTextMax = nDispTextSize; 536 dispInfo.hdr.hwndFrom = hwnd; 537 dispInfo.hdr.idFrom = lCtrlId; 538 dispInfo.hdr.code = LVN_GETDISPINFOA; 539 dispInfo.item.iItem = nItem; 540 dispInfo.item.iSubItem = nSubItemPos; 541 dispInfo.item.lParam = lParam; 542 ListView_Notify(GetParent(hwnd), lCtrlId, &dispInfo); 543 if (dispInfo.item.mask & LVIF_DI_SETITEM) 544 { 545 Str_SetPtrA(&lpSubItem->pszText, dispInfo.item.pszText); 546 } 547 *ppszDispText = dispInfo.item.pszText; 548 } 549 else 550 { 551 if ((pnDispImage != NULL) && (lpSubItem->iImage == I_IMAGECALLBACK)) 552 { 553 dispInfo.item.mask |= LVIF_IMAGE; 554 } 555 556 if ((ppszDispText != NULL) && (lpSubItem->pszText == LPSTR_TEXTCALLBACKA)) 557 { 558 ZeroMemory(*ppszDispText, sizeof(CHAR)*nDispTextSize); 559 dispInfo.item.mask |= LVIF_TEXT; 560 dispInfo.item.pszText = *ppszDispText; 561 dispInfo.item.cchTextMax = nDispTextSize; 562 } 563 564 if (dispInfo.item.mask != 0) 565 { 566 dispInfo.hdr.hwndFrom = hwnd; 567 dispInfo.hdr.idFrom = lCtrlId; 568 dispInfo.hdr.code = LVN_GETDISPINFOA; 569 dispInfo.item.iItem = nItem; 570 dispInfo.item.iSubItem = lpSubItem->iSubItem; 571 dispInfo.item.lParam = lParam; 572 ListView_Notify(GetParent(hwnd), lCtrlId, &dispInfo); 573 } 574 575 if (pnDispImage != NULL) 576 { 577 if (dispInfo.item.mask & LVIF_IMAGE) 578 { 579 *pnDispImage = dispInfo.item.iImage; 580 } 581 else 582 { 583 *pnDispImage = lpSubItem->iImage; 584 } 585 } 586 587 if (ppszDispText != NULL) 588 { 589 if (dispInfo.item.mask & LVIF_TEXT) 590 { 591 if (dispInfo.item.mask & LVIF_DI_SETITEM) 592 { 593 Str_SetPtrA(&lpSubItem->pszText, dispInfo.item.pszText); 594 } 595 *ppszDispText = dispInfo.item.pszText; 596 } 597 else 598 { 599 *ppszDispText = lpSubItem->pszText; 600 } 601 } 602 } 464 } 465 } 466 467 /*** 468 * DESCRIPTION: 469 * Set the bounding rectangle of all the items. 470 * 471 * PARAMETER(S): 472 * [I] HWND : window handle 473 * [I] LPRECT : bounding rectangle 474 * 475 * RETURN: 476 * SUCCESS : TRUE 477 * FAILURE : FALSE 478 */ 479 static LRESULT LISTVIEW_SetViewRect(HWND hwnd, LPRECT lprcView) 480 { 481 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongA(hwnd, 0); 482 BOOL bResult = FALSE; 483 484 // TRACE("(hwnd=%x, left=%d, top=%d, right=%d, bottom=%d)\n", hwnd, 485 // lprcView->left, lprcView->top, lprcView->right, lprcView->bottom); 486 487 if (lprcView != NULL) 488 { 489 bResult = TRUE; 490 infoPtr->rcView.left = lprcView->left; 491 infoPtr->rcView.top = lprcView->top; 492 infoPtr->rcView.right = lprcView->right; 493 infoPtr->rcView.bottom = lprcView->bottom; 494 } 495 496 return bResult; 497 } 498 499 /*** 500 * DESCRIPTION: 501 * Retrieves the bounding rectangle of all the items. 502 * 503 * PARAMETER(S): 504 * [I] HWND : window handle 505 * [O] LPRECT : bounding rectangle 506 * 507 * RETURN: 508 * SUCCESS : TRUE 509 * FAILURE : FALSE 510 */ 511 static LRESULT LISTVIEW_GetViewRect(HWND hwnd, LPRECT lprcView) 512 { 513 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongA(hwnd, 0); 514 BOOL bResult = FALSE; 515 POINT ptOrigin; 516 517 // TRACE("(hwnd=%x, lprcView=%p)\n", hwnd, lprcView); 518 519 if (lprcView != NULL) 520 { 521 bResult = LISTVIEW_GetOrigin(hwnd, &ptOrigin); 522 if (bResult != FALSE) 523 { 524 lprcView->left = infoPtr->rcView.left + ptOrigin.x; 525 lprcView->top = infoPtr->rcView.top + ptOrigin.y; 526 lprcView->right = infoPtr->rcView.right + ptOrigin.x; 527 lprcView->bottom = infoPtr->rcView.bottom + ptOrigin.y; 528 } 529 530 // TRACE("(left=%d, top=%d, right=%d, bottom=%d)\n", 531 // lprcView->left, lprcView->top, lprcView->right, lprcView->bottom); 532 } 533 534 return bResult; 535 } 536 537 /*** 538 * DESCRIPTION: 539 * Retrieves the subitem pointer associated with the subitem index. 540 * 541 * PARAMETER(S): 542 * [I] HDPA : DPA handle for a specific item 543 * [I] INT : index of subitem 544 * 545 * RETURN: 546 * SUCCESS : subitem pointer 547 * FAILURE : NULL 548 */ 549 static LISTVIEW_SUBITEM* LISTVIEW_GetSubItemPtr(HDPA hdpaSubItems, 550 INT nSubItem) 551 { 552 LISTVIEW_SUBITEM *lpSubItem; 553 INT i; 554 555 for (i = 1; i < hdpaSubItems->nItemCount; i++) 556 { 557 lpSubItem = (LISTVIEW_SUBITEM *) DPA_GetPtr(hdpaSubItems, i); 558 if (lpSubItem != NULL) 559 { 560 if (lpSubItem->iSubItem == nSubItem) 561 { 562 return lpSubItem; 563 } 564 } 565 } 566 567 return NULL; 603 568 } 604 569 … … 614 579 * Returns item width. 615 580 */ 616 static INT LISTVIEW_GetItemWidth(HWND hwnd, LONG lStyle) 617 { 618 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 581 static INT LISTVIEW_GetItemWidth(HWND hwnd) 582 { 583 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 584 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 619 585 INT nHeaderItemCount; 620 586 RECT rcHeaderItem; … … 623 589 INT i; 624 590 625 // TRACE(listview, "(hwnd=%x,lStyle=%lx)\n", hwnd, lStyle); 626 627 switch (LVS_TYPEMASK & lStyle) 628 { 629 case LVS_ICON: 591 // TRACE("(hwnd=%x)\n", hwnd); 592 593 if (uView == LVS_ICON) 594 { 630 595 nItemWidth = infoPtr->iconSpacing.cx; 631 break;632 633 case LVS_REPORT:596 } 597 else if (uView == LVS_REPORT) 598 { 634 599 /* calculate width of header */ 635 600 nHeaderItemCount = Header_GetItemCount(infoPtr->hwndHeader); … … 641 606 } 642 607 } 643 break; 644 645 case LVS_SMALLICON: 646 case LVS_LIST: 608 } 609 else 610 { 647 611 for (i = 0; i < GETITEMCOUNT(infoPtr); i++) 648 612 { … … 650 614 nItemWidth = max(nItemWidth, nLabelWidth); 651 615 } 652 616 653 617 /* default label size */ 654 618 if (GETITEMCOUNT(infoPtr) == 0) … … 678 642 } 679 643 } 680 break; 681 682 } 683 644 } 645 684 646 return nItemWidth; 685 647 } … … 694 656 * 695 657 * RETURN: 696 * Returns item width. 697 */ 698 static INT LISTVIEW_GetItemHeight(HWND hwnd, LONG lStyle) 699 { 700 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 658 * Returns item height. 659 */ 660 static INT LISTVIEW_GetItemHeight(HWND hwnd) 661 { 662 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 663 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 701 664 INT nItemHeight = 0; 702 TEXTMETRICA tm; 703 HFONT hOldFont; 704 HDC hdc; 705 706 switch (LVS_TYPEMASK & lStyle) 707 { 708 case LVS_ICON: 665 666 if (uView == LVS_ICON) 667 { 709 668 nItemHeight = infoPtr->iconSpacing.cy; 710 break; 711 712 case LVS_SMALLICON: 713 case LVS_REPORT: 714 case LVS_LIST: 715 hdc = GetDC(hwnd); 716 hOldFont = SelectObject(hdc, infoPtr->hFont); 669 } 670 else 671 { 672 TEXTMETRICA tm; 673 HDC hdc = GetDC(hwnd); 674 HFONT hOldFont = SelectObject(hdc, infoPtr->hFont); 717 675 GetTextMetricsA(hdc, &tm); 718 676 nItemHeight = max(tm.tmHeight, infoPtr->iconSize.cy) + HEIGHT_PADDING; 719 677 SelectObject(hdc, hOldFont); 720 678 ReleaseDC(hwnd, hdc); 721 break;722 679 } 723 680 724 681 return nItemHeight; 725 }726 727 /***728 * DESCRIPTION:729 * Sets diplay information (needed for drawing operations).730 *731 * PARAMETER(S):732 * [I] HWND : window handle733 *734 * RETURN:735 * None736 */737 static VOID LISTVIEW_SetViewInfo(HWND hwnd, LONG lStyle)738 {739 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);740 INT nListHeight = infoPtr->rcList.bottom - infoPtr->rcList.top;741 INT nListWidth = infoPtr->rcList.right - infoPtr->rcList.left;742 743 switch (LVS_TYPEMASK & lStyle)744 {745 case LVS_REPORT:746 /* get number of fully visible items per column */747 infoPtr->nCountPerColumn = max(1, nListHeight / infoPtr->nItemHeight);748 break;749 750 case LVS_LIST:751 /* get number of fully visible items per column */752 infoPtr->nCountPerColumn = max(1, nListHeight / infoPtr->nItemHeight);753 754 /* get number of fully visible items per row */755 infoPtr->nCountPerRow = max(1, nListWidth / infoPtr->nItemWidth);756 break;757 }758 682 } 759 683 … … 855 779 /*** 856 780 * DESCRIPTION: 781 * Selects items based on view coorddiantes. 782 * 783 * PARAMETER(S): 784 * [I] HWND : window handle 785 * [I] RECT : selection rectangle 786 * 787 * RETURN: 788 * None 789 */ 790 static VOID LISTVIEW_SetSelectionRect(HWND hwnd, RECT rcSelRect) 791 { 792 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 793 LVITEMA lvItem; 794 POINT ptItem; 795 INT i; 796 797 lvItem.stateMask = LVIS_SELECTED; 798 799 for (i = 0; i < GETITEMCOUNT(infoPtr); i++) 800 { 801 LISTVIEW_GetItemPosition(hwnd, i, &ptItem); 802 if (PtInRect(&rcSelRect, ptItem) != FALSE) 803 { 804 lvItem.state = LVIS_SELECTED; 805 } 806 else 807 { 808 lvItem.state = 0; 809 } 810 811 ListView_SetItemState(hwnd, i, &lvItem); 812 } 813 } 814 815 /*** 816 * DESCRIPTION: 857 817 * Sets a single group selection. 858 818 * … … 867 827 { 868 828 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 869 INT nFirst = min(infoPtr->nSelectionMark, nItem); 870 INT nLast = max(infoPtr->nSelectionMark, nItem); 829 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 871 830 LVITEMA lvItem; 872 INT i; 873 874 if (nFirst > 0) 875 { 876 LISTVIEW_RemoveSelections(hwnd, 0, nFirst - 1); 877 } 878 879 if (nLast < GETITEMCOUNT(infoPtr)) 880 { 881 LISTVIEW_RemoveSelections(hwnd, nLast + 1, GETITEMCOUNT(infoPtr)); 882 } 883 884 lvItem.state = LVIS_SELECTED; 885 lvItem.stateMask = LVIS_SELECTED; 886 887 for (i = nFirst; i <= nLast; i++) 888 { 889 ListView_SetItemState(hwnd, i, &lvItem); 831 832 if ((uView == LVS_LIST) || (uView == LVS_REPORT)) 833 { 834 INT i; 835 INT nFirst = min(infoPtr->nSelectionMark, nItem); 836 INT nLast = max(infoPtr->nSelectionMark, nItem); 837 lvItem.stateMask = LVIS_SELECTED; 838 839 for (i = 0; i <= GETITEMCOUNT(infoPtr); i++) 840 { 841 if ((i < nFirst) || (i > nLast)) 842 { 843 lvItem.state = 0; 844 } 845 else 846 { 847 lvItem.state = LVIS_SELECTED; 848 } 849 850 ListView_SetItemState(hwnd, i, &lvItem); 851 } 852 } 853 else 854 { 855 POINT ptItem; 856 POINT ptSelMark; 857 RECT rcSel; 858 LISTVIEW_GetItemPosition(hwnd, nItem, &ptItem); 859 LISTVIEW_GetItemPosition(hwnd, infoPtr->nSelectionMark, &ptSelMark); 860 rcSel.left = min(ptSelMark.x, ptItem.x); 861 rcSel.top = min(ptSelMark.y, ptItem.y); 862 rcSel.right = max(ptSelMark.x, ptItem.x) + infoPtr->nItemWidth; 863 rcSel.bottom = max(ptSelMark.y, ptItem.y) + infoPtr->nItemHeight; 864 LISTVIEW_SetSelectionRect(hwnd, rcSel); 890 865 } 891 866 … … 902 877 * 903 878 * RETURN: 879 * TRUE : focused item changed 880 * FALSE : focused item has NOT changed 881 */ 882 static BOOL LISTVIEW_SetItemFocus(HWND hwnd, INT nItem) 883 { 884 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 885 BOOL bResult = FALSE; 886 LVITEMA lvItem; 887 888 if (infoPtr->nFocusedItem != nItem) 889 { 890 bResult = TRUE; 891 ZeroMemory(&lvItem, sizeof(LVITEMA)); 892 lvItem.stateMask = LVIS_FOCUSED; 893 ListView_SetItemState(hwnd, infoPtr->nFocusedItem, &lvItem); 894 895 lvItem.state = LVIS_FOCUSED; 896 lvItem.stateMask = LVIS_FOCUSED; 897 ListView_SetItemState(hwnd, nItem, &lvItem); 898 899 infoPtr->nFocusedItem = nItem; 900 ListView_EnsureVisible(hwnd, nItem, FALSE); 901 } 902 903 return bResult; 904 } 905 906 /*** 907 * DESCRIPTION: 908 * Sets a single selection. 909 * 910 * PARAMETER(S): 911 * [I] HWND : window handle 912 * [I] INT : item index 913 * 914 * RETURN: 904 915 * None 905 916 */ 906 static VOID LISTVIEW_Set ItemFocus(HWND hwnd, INT nItem)917 static VOID LISTVIEW_SetSelection(HWND hwnd, INT nItem) 907 918 { 908 919 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 909 920 LVITEMA lvItem; 910 921 911 lvItem.state = 0;912 lvItem.stateMask = LVIS_FOCUSED;913 ListView_SetItemState(hwnd, infoPtr->nFocusedItem, &lvItem);914 915 lvItem.state = LVIS_FOCUSED;916 lvItem.stateMask = LVIS_FOCUSED;917 ListView_SetItemState(hwnd, nItem, &lvItem);918 919 infoPtr->nFocusedItem = nItem;920 921 /* if multiple selection is allowed */922 ListView_EnsureVisible(hwnd, nItem, FALSE);923 }924 925 /***926 * DESCRIPTION:927 * Sets a single selection.928 *929 * PARAMETER(S):930 * [I] HWND : window handle931 * [I] INT : item index932 *933 * RETURN:934 * None935 */936 static VOID LISTVIEW_SetSelection(HWND hwnd, INT nItem)937 {938 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);939 LVITEMA lvItem;940 941 922 if (nItem > 0) 942 923 { … … 949 930 } 950 931 951 lvItem.state = 0;932 ZeroMemory(&lvItem, sizeof(LVITEMA)); 952 933 lvItem.stateMask = LVIS_FOCUSED; 953 934 ListView_SetItemState(hwnd, infoPtr->nFocusedItem, &lvItem); … … 970 951 * 971 952 * RETURN: 972 * None 973 */ 974 static VOID LISTVIEW_KeySelection(HWND hwnd, INT nItem) 975 { 953 * SUCCESS : TRUE (needs to be repainted) 954 * FAILURE : FALSE (nothing has changed) 955 */ 956 static BOOL LISTVIEW_KeySelection(HWND hwnd, INT nItem) 957 { 958 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 959 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 976 960 WORD wShift = HIWORD(GetKeyState(VK_SHIFT)); 977 961 WORD wCtrl = HIWORD(GetKeyState(VK_CONTROL)); 978 979 if (wShift) 980 { 981 LISTVIEW_SetGroupSelection(hwnd, nItem); 982 } 983 else if (wCtrl) 984 { 985 LISTVIEW_SetItemFocus(hwnd, nItem); 986 } 987 else 988 { 989 LISTVIEW_SetSelection(hwnd, nItem); 990 991 /* if multiple selection is allowed */ 992 ListView_EnsureVisible(hwnd, nItem, FALSE); 993 } 994 } 995 996 /*** 997 * DESCRIPTION: 998 * Determines the selected item. 999 * 1000 * PARAMETER(S): 1001 * [I] HWND : window handle 1002 * [I] INT : x ccordinate 1003 * [I] INT : y coordinate 962 BOOL bResult = FALSE; 963 964 if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr))) 965 { 966 if (lStyle & LVS_SINGLESEL) 967 { 968 bResult = TRUE; 969 LISTVIEW_SetSelection(hwnd, nItem); 970 ListView_EnsureVisible(hwnd, nItem, FALSE); 971 } 972 else 973 { 974 if (wShift) 975 { 976 bResult = TRUE; 977 LISTVIEW_SetGroupSelection(hwnd, nItem); 978 } 979 else if (wCtrl) 980 { 981 bResult = LISTVIEW_SetItemFocus(hwnd, nItem); 982 } 983 else 984 { 985 bResult = TRUE; 986 LISTVIEW_SetSelection(hwnd, nItem); 987 ListView_EnsureVisible(hwnd, nItem, FALSE); 988 } 989 } 990 } 991 992 return bResult; 993 } 994 995 /*** 996 * DESCRIPTION: 997 * Selects an item based on coordinates. 998 * 999 * PARAMETER(S): 1000 * [I] HWND : window handle 1001 * [I] POINT : mouse click ccordinates 1004 1002 * 1005 1003 * RETURN: … … 1007 1005 * FAILURE : -1 1008 1006 */ 1009 static LRESULT LISTVIEW_MouseSelection(HWND hwnd, INT nPosX, INT nPosY)1007 static LRESULT LISTVIEW_MouseSelection(HWND hwnd, POINT pt) 1010 1008 { 1011 1009 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); … … 1018 1016 if (LISTVIEW_GetItemRect(hwnd, i, &rcItem) == TRUE) 1019 1017 { 1020 if ((rcItem.left <= nPosX) && (nPosX <= rcItem.right) && 1021 (rcItem.top <= nPosY) && (nPosY <= rcItem.bottom)) 1018 if (PtInRect(&rcItem, pt) != FALSE) 1022 1019 { 1023 1020 return i; … … 1118 1115 COMCTL32_Free(lpSubItem->pszText); 1119 1116 } 1120 1117 1121 1118 /* free item */ 1122 1119 COMCTL32_Free(lpSubItem); … … 1164 1161 } 1165 1162 } 1166 1163 1167 1164 if (lpLVItem->mask & LVIF_IMAGE) 1168 1165 { … … 1314 1311 * Initializes subitem attributes. 1315 1312 * 1316 * NOTE: the documentation specifies that the operation fails if the user1313 * NOTE: The documentation specifies that the operation fails if the user 1317 1314 * tries to set the indent of a subitem. 1318 1315 * … … 1543 1540 nmlv.uOldState = lpItem->state & lpLVItem->stateMask; 1544 1541 } 1545 1542 1546 1543 nmlv.uChanged = uChanged; 1547 1544 nmlv.iItem = lpLVItem->iItem; … … 1631 1628 static INT LISTVIEW_GetTopIndex(HWND hwnd) 1632 1629 { 1633 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *) GetWindowLongA(hwnd, 0);1634 1630 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 1631 UINT uView = lStyle & LVS_TYPEMASK; 1635 1632 INT nItem = 0; 1636 1637 switch (LVS_TYPEMASK & lStyle) 1638 { 1639 case LVS_LIST: 1633 SCROLLINFO scrollInfo; 1634 1635 ZeroMemory(&scrollInfo, sizeof(SCROLLINFO)); 1636 scrollInfo.cbSize = sizeof(SCROLLINFO); 1637 scrollInfo.fMask = SIF_POS; 1638 1639 if (uView == LVS_LIST) 1640 { 1640 1641 if (lStyle & WS_HSCROLL) 1641 1642 { 1642 nItem = GetScrollPos(hwnd, SB_HORZ) * infoPtr->nCountPerColumn; 1643 } 1644 break; 1645 1646 case LVS_REPORT: 1643 if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) != FALSE) 1644 { 1645 nItem = scrollInfo.nPos * LISTVIEW_GetCountPerColumn(hwnd); 1646 } 1647 } 1648 } 1649 else if (uView == LVS_REPORT) 1650 { 1647 1651 if (lStyle & WS_VSCROLL) 1648 1652 { 1649 nItem = GetScrollPos(hwnd, SB_VERT); 1650 } 1651 break; 1652 } 1653 1653 if (GetScrollInfo(hwnd, SB_VERT, &scrollInfo) != FALSE) 1654 { 1655 nItem = scrollInfo.nPos; 1656 } 1657 } 1658 } 1659 1654 1660 return nItem; 1655 }1656 1657 /***1658 * DESCRIPTION:1659 * Evaluates if scrollbars are needed & sets the scroll range/position.1660 *1661 * PARAMETER(S):1662 * [I] HWND : window handle1663 * [I] LONG : window style1664 *1665 * RETURN:1666 * None1667 */1668 static VOID LISTVIEW_SetScroll(HWND hwnd, LONG lStyle)1669 {1670 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);1671 INT nListWidth = infoPtr->rcList.right - infoPtr->rcList.left;1672 INT nListHeight = infoPtr->rcList.bottom - infoPtr->rcList.top;1673 INT nHScrollHeight = GetSystemMetrics(SM_CYHSCROLL);1674 INT nVScrollWidth = GetSystemMetrics(SM_CXVSCROLL);1675 INT nHiddenWidth;1676 INT nHiddenHeight;1677 INT nHiddenItemCount;1678 INT nScrollPos;1679 INT nMaxRange;1680 INT nCountPerPage;1681 INT nPixPerScrollPos;1682 RECT rcView;1683 1684 // TRACE(listview, "(hwnd=%x,lStyle=%lx)\n", hwnd, lStyle);1685 1686 switch (LVS_TYPEMASK & lStyle)1687 {1688 case LVS_LIST:1689 nCountPerPage = infoPtr->nCountPerRow * infoPtr->nCountPerColumn;1690 if (nCountPerPage < GETITEMCOUNT(infoPtr))1691 {1692 /* display horizontal scrollbar */1693 if ((lStyle & WS_HSCROLL) == 0)1694 {1695 ShowScrollBar(hwnd, SB_HORZ, TRUE);1696 }1697 1698 /* calculate new scrollbar range */1699 nHiddenItemCount = GETITEMCOUNT(infoPtr) - nCountPerPage;1700 if ((nHiddenItemCount % infoPtr->nCountPerColumn) == 0)1701 {1702 nMaxRange = nHiddenItemCount / infoPtr->nCountPerColumn;1703 }1704 else1705 {1706 nMaxRange = nHiddenItemCount / infoPtr->nCountPerColumn + 1;1707 }1708 1709 SetScrollRange(hwnd, SB_HORZ, 0, nMaxRange, FALSE);1710 nScrollPos = ListView_GetTopIndex(hwnd) / infoPtr->nCountPerColumn;1711 SetScrollPos(hwnd, SB_HORZ, nScrollPos, TRUE);1712 }1713 else1714 {1715 /* hide scrollbar */1716 if ((lStyle & WS_HSCROLL) != 0)1717 {1718 ShowScrollBar(hwnd, SB_HORZ, FALSE);1719 }1720 }1721 break;1722 1723 case LVS_REPORT:1724 /*1725 * This section was commented out because I experienced some problems1726 * with the scrolling of the header control. The idea was to add a1727 * horizontal scrollbar when the width of the client area was smaller1728 * than the width of the header control.1729 */1730 1731 /* if (infoPtr->nItemWidth > nListWidth) */1732 /* { */1733 /* if ((lStyle & WS_HSCROLL) == 0) */1734 /* { */1735 /* ShowScrollBar(hwnd, SB_HORZ, TRUE); */1736 /* LISTVIEW_SetSize(hwnd, lStyle, -1, -1); */1737 /* LISTVIEW_SetViewInfo(hwnd, lStyle); */1738 /* } */1739 1740 /* nListWidth = infoPtr->rcList.right - infoPtr->rcList.left; */1741 /* nHiddenWidth = infoPtr->nItemWidth - nListWidth; */1742 /* nPixPerScrollPos = max(1, nListWidth / 10); */1743 1744 /* if ((nHiddenWidth % nPixPerScrollPos) == 0) */1745 /* { */1746 /* nMaxRange = nHiddenWidth / nPixPerScrollPos; */1747 /* } */1748 /* else */1749 /* { */1750 /* nMaxRange = nHiddenWidth / nPixPerScrollPos + 1; */1751 /* } */1752 1753 /* SetScrollRange(hwnd, SB_HORZ, 0, nMaxRange, FALSE); */1754 /* SetScrollPos(hwnd, SB_HORZ, 0, TRUE); */1755 /* } */1756 /* else */1757 /* { */1758 /* if ((lStyle & WS_HSCROLL) != 0) */1759 /* { */1760 /* ShowScrollBar(hwnd, SB_HORZ, FASLE); */1761 /* LISTVIEW_SetSize(hwnd, lStyle, -1, -1); */1762 /* LISTVIEW_SetViewInfo(hwnd, lStyle); */1763 /* } */1764 /* } */1765 1766 if (infoPtr->nCountPerColumn < GETITEMCOUNT(infoPtr))1767 {1768 if ((lStyle & WS_VSCROLL) == 0)1769 {1770 if (nListWidth > nVScrollWidth)1771 {1772 ShowScrollBar(hwnd, SB_VERT, TRUE);1773 nListWidth -= nVScrollWidth;1774 }1775 }1776 1777 /* vertical range & position */1778 nMaxRange = GETITEMCOUNT(infoPtr) - infoPtr->nCountPerColumn;1779 SetScrollRange(hwnd, SB_VERT, 0, nMaxRange, FALSE);1780 SetScrollPos(hwnd, SB_VERT, ListView_GetTopIndex(hwnd), TRUE);1781 }1782 else1783 {1784 if ((lStyle & WS_VSCROLL) != 0)1785 {1786 ShowScrollBar(hwnd, SB_VERT, FALSE);1787 nListWidth += nVScrollWidth;1788 }1789 }1790 break;1791 1792 case LVS_ICON:1793 case LVS_SMALLICON:1794 if (LISTVIEW_GetViewRect(hwnd, &rcView) != FALSE)1795 {1796 if (rcView.right - rcView.left > nListWidth)1797 {1798 if ((lStyle & WS_HSCROLL) == 0)1799 {1800 if (nListHeight > nHScrollHeight)1801 {1802 ShowScrollBar(hwnd, SB_HORZ, TRUE);1803 nListHeight -= nHScrollHeight;1804 }1805 }1806 1807 /* calculate size of hidden items */1808 nHiddenWidth = rcView.right - rcView.left - nListWidth;1809 nPixPerScrollPos = max(1, nListWidth / 10);1810 1811 /* vertical range & position */1812 if ((nHiddenWidth % nPixPerScrollPos) == 0)1813 {1814 nMaxRange = nHiddenWidth / nPixPerScrollPos;1815 }1816 else1817 {1818 nMaxRange = nHiddenWidth / nPixPerScrollPos + 1;1819 }1820 1821 /* set range and position */1822 SetScrollRange(hwnd, SB_HORZ, 0, nMaxRange, FALSE);1823 SetScrollPos(hwnd, SB_HORZ, 0, TRUE);1824 }1825 else1826 {1827 if ((lStyle & WS_HSCROLL) != 0)1828 {1829 ShowScrollBar(hwnd, SB_HORZ, FALSE);1830 nListHeight += nHScrollHeight;1831 }1832 }1833 1834 if (rcView.bottom - rcView.top > nListHeight)1835 {1836 if ((lStyle & WS_VSCROLL) == 0)1837 {1838 if (nListWidth > nVScrollWidth)1839 {1840 ShowScrollBar(hwnd, SB_VERT, TRUE);1841 nListWidth -= nVScrollWidth;1842 }1843 }1844 1845 /* calculate size of hidden items */1846 nHiddenHeight = rcView.bottom - rcView.top - nListHeight;1847 nPixPerScrollPos = max(1, nListHeight / 10);1848 1849 /* set vertical range & position */1850 if ((nHiddenHeight % nPixPerScrollPos) == 0)1851 {1852 nMaxRange = nHiddenHeight / nPixPerScrollPos;1853 }1854 else1855 {1856 nMaxRange = nHiddenHeight / nPixPerScrollPos + 1;1857 }1858 1859 /* set range and position */1860 SetScrollRange(hwnd, SB_VERT, 0, nMaxRange, FALSE);1861 SetScrollPos(hwnd, SB_VERT, 0, TRUE);1862 }1863 else1864 {1865 if ((lStyle & WS_VSCROLL) != 0)1866 {1867 ShowScrollBar(hwnd, SB_VERT, FALSE);1868 nListWidth += nVScrollWidth;1869 }1870 }1871 }1872 break;1873 }1874 1661 } 1875 1662 … … 1882 1669 * [I] HDC : device context handle 1883 1670 * [I] INT : item index 1884 * [I] LPARAM : item lparam 1885 * [I] LISTVIEW_SUBITEM * : item 1886 * [I] INT : column index (header index) 1671 * [I] INT : subitem index 1887 1672 * [I] RECT * : clipping rectangle 1888 1673 * … … 1890 1675 * None 1891 1676 */ 1892 static VOID LISTVIEW_DrawSubItem(HWND hwnd, HDC hdc, INT nItem, LPARAM lParam, 1893 LISTVIEW_SUBITEM *lpSubItem, INT nColumn, 1894 RECT *lprc) 1895 { 1896 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 1677 static VOID LISTVIEW_DrawSubItem(HWND hwnd, HDC hdc, INT nItem, INT nSubItem, 1678 RECT rcItem) 1679 { 1680 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 1897 1681 CHAR szDispText[DISP_TEXT_SIZE]; 1898 LPSTR pszDispText = NULL; 1682 LVITEMA lvItem; 1683 1684 TRACE("(hwnd=%x, hdc=%x, nItem=%d, nSubItem=%d\n", hwnd, hdc, 1685 nItem, nSubItem); 1686 1687 /* get information needed for drawing the item */ 1688 ZeroMemory(&lvItem, sizeof(LVITEMA)); 1689 lvItem.mask = LVIF_TEXT; 1690 lvItem.iItem = nItem; 1691 lvItem.iSubItem = nSubItem; 1692 lvItem.cchTextMax = DISP_TEXT_SIZE; 1693 lvItem.pszText = szDispText; 1694 ListView_GetItemA(hwnd, &lvItem); 1899 1695 1900 1696 /* set item colors */ … … 1902 1698 SetTextColor(hdc, infoPtr->clrText); 1903 1699 1904 pszDispText = szDispText; 1905 LISTVIEW_GetSubItemDispInfo(hwnd, nItem, lParam, lpSubItem, nColumn, NULL, 1906 &pszDispText, DISP_TEXT_SIZE); 1907 1908 /* draw text : using arbitrary offset of 10 pixels */ 1700 ExtTextOutA(hdc, rcItem.left, rcItem.top, ETO_OPAQUE | ETO_CLIPPED, 1701 &rcItem, lvItem.pszText, lstrlenA(lvItem.pszText), NULL); 1702 } 1703 1704 1705 /*** 1706 * DESCRIPTION: 1707 * Draws an item. 1708 * 1709 * PARAMETER(S): 1710 * [I] HWND : window handle 1711 * [I] HDC : device context handle 1712 * [I] INT : item index 1713 * [I] RECT * : clipping rectangle 1714 * 1715 * RETURN: 1716 * None 1717 */ 1718 static VOID LISTVIEW_DrawItem(HWND hwnd, HDC hdc, INT nItem, RECT rcItem) 1719 { 1720 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 1721 CHAR szDispText[DISP_TEXT_SIZE]; 1722 INT nLabelWidth; 1723 LVITEMA lvItem; 1724 INT nMixMode; 1725 DWORD dwBkColor; 1726 DWORD dwTextColor; 1727 1728 TRACE("(hwnd=%x, hdc=%x, nItem=%d\n", hwnd, hdc, nItem); 1729 1730 /* get information needed for drawing the item */ 1731 ZeroMemory(&lvItem, sizeof(LVITEMA)); 1732 lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_INDENT; 1733 lvItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED | LVIS_STATEIMAGEMASK; 1734 lvItem.iItem = nItem; 1735 lvItem.iSubItem = 0; 1736 lvItem.cchTextMax = DISP_TEXT_SIZE; 1737 lvItem.pszText = szDispText; 1738 ListView_GetItemA(hwnd, &lvItem); 1739 1740 /* state icons */ 1741 if (infoPtr->himlState != NULL) 1742 { 1743 UINT uStateImage = (lvItem.state & LVIS_STATEIMAGEMASK) >> 12; 1744 if (uStateImage != 0) 1745 { 1746 ImageList_Draw(infoPtr->himlState, uStateImage - 1, hdc, rcItem.left, 1747 rcItem.top, ILD_NORMAL); 1748 } 1749 1750 rcItem.left += infoPtr->iconSize.cx; 1751 } 1909 1752 1910 ExtTextOutA(hdc, lprc->left, lprc->top, ETO_OPAQUE|ETO_CLIPPED, 1911 lprc, pszDispText, lstrlenA(pszDispText), NULL); 1912 } 1913 1914 /*** 1915 * DESCRIPTION: 1916 * Draws an item. 1753 /* small icons */ 1754 if (infoPtr->himlSmall != NULL) 1755 { 1756 if (lvItem.state & LVIS_SELECTED) 1757 { 1758 ImageList_SetBkColor(infoPtr->himlSmall, CLR_NONE); 1759 ImageList_Draw(infoPtr->himlSmall, lvItem.iImage, hdc, rcItem.left, 1760 rcItem.top, ILD_SELECTED); 1761 } 1762 else 1763 { 1764 ImageList_SetBkColor(infoPtr->himlSmall, CLR_NONE); 1765 ImageList_Draw(infoPtr->himlSmall, lvItem.iImage, hdc, rcItem.left, 1766 rcItem.top, ILD_NORMAL); 1767 } 1768 1769 rcItem.left += infoPtr->iconSize.cx; 1770 } 1771 1772 if ((lvItem.state & LVIS_SELECTED) && (infoPtr->bFocus != FALSE)) 1773 { 1774 /* set item colors */ 1775 dwBkColor = SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT)); 1776 dwTextColor = SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); 1777 /* set raster mode */ 1778 nMixMode = SetROP2(hdc, R2_XORPEN); 1779 } 1780 else if ((GetWindowLongA(hwnd, GWL_STYLE) & LVS_SHOWSELALWAYS) && 1781 (lvItem.state & LVIS_SELECTED) && (infoPtr->bFocus == FALSE)) 1782 { 1783 dwBkColor = SetBkColor(hdc, GetSysColor(COLOR_3DFACE)); 1784 dwTextColor = SetTextColor(hdc, GetSysColor(COLOR_BTNTEXT)); 1785 /* set raster mode */ 1786 nMixMode = SetROP2(hdc, R2_COPYPEN); 1787 } 1788 else 1789 { 1790 /* set item colors */ 1791 dwBkColor = SetBkColor(hdc, infoPtr->clrTextBk); 1792 dwTextColor = SetTextColor(hdc, infoPtr->clrText); 1793 /* set raster mode */ 1794 nMixMode = SetROP2(hdc, R2_COPYPEN); 1795 } 1796 1797 nLabelWidth = ListView_GetStringWidthA(hwnd, lvItem.pszText); 1798 if (rcItem.left + nLabelWidth < rcItem.right) 1799 { 1800 rcItem.right = rcItem.left + nLabelWidth; 1801 } 1802 1803 /* draw label */ 1804 ExtTextOutA(hdc, rcItem.left, rcItem.top, ETO_OPAQUE | ETO_CLIPPED, 1805 &rcItem, lvItem.pszText, lstrlenA(lvItem.pszText), NULL); 1806 1807 if ((lvItem.state & LVIS_FOCUSED) && (infoPtr->bFocus == TRUE)) 1808 { 1809 Rectangle(hdc, rcItem.left, rcItem.top, rcItem.right, rcItem.bottom); 1810 } 1811 1812 if (nMixMode != 0) 1813 { 1814 SetROP2(hdc, R2_COPYPEN); 1815 SetBkColor(hdc, infoPtr->clrTextBk); 1816 SetTextColor(hdc, infoPtr->clrText); 1817 } 1818 } 1819 1820 /*** 1821 * DESCRIPTION: 1822 * Draws an item when in large icon display mode. 1917 1823 * 1918 1824 * PARAMETER(S): … … 1926 1832 * None 1927 1833 */ 1928 static VOID LISTVIEW_DrawItem(HWND hwnd, HDC hdc, LISTVIEW_ITEM *lpItem, 1929 INT nItem, RECT rc) 1834 static VOID LISTVIEW_DrawLargeItem(HWND hwnd, HDC hdc, INT nItem, RECT rcItem) 1930 1835 { 1931 1836 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 1932 1837 CHAR szDispText[DISP_TEXT_SIZE]; 1933 LPSTR pszDispText = NULL; 1934 BOOL bSelected; 1838 INT nDrawPosX = rcItem.left; 1935 1839 INT nLabelWidth; 1936 INT nImage; 1937 UINT uState; 1938 1939 // TRACE(listview, "(hwnd=%x,hdc=%x,lpItem=%p,nItem=%d,rc.left=%d,rctop=%d,rc.right=%d,rc.bottom=%d)\n", hwnd, hdc, lpItem, nItem, rc.left, rc.top, rc.right, rc.bottom); 1940 1941 pszDispText = szDispText; 1942 LISTVIEW_GetItemDispInfo(hwnd, nItem, lpItem, &nImage, &uState, &pszDispText, 1943 DISP_TEXT_SIZE); 1944 1945 if (uState & LVIS_SELECTED) 1946 { 1947 bSelected = TRUE; 1948 1840 TEXTMETRICA tm; 1841 LVITEMA lvItem; 1842 1843 TRACE("(hwnd=%x, hdc=%x, nItem=%d, left=%d, top=%d, right=%d, \ 1844 bottom=%d)\n", hwnd, hdc, nItem, rcItem.left, rcItem.top, rcItem.right, 1845 rcItem.bottom); 1846 1847 /* get information needed for drawing the item */ 1848 ZeroMemory(&lvItem, sizeof(LVITEMA)); 1849 lvItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE; 1850 lvItem.stateMask = LVIS_SELECTED | LVIS_FOCUSED; 1851 lvItem.iItem = nItem; 1852 lvItem.iSubItem = 0; 1853 lvItem.cchTextMax = DISP_TEXT_SIZE; 1854 lvItem.pszText = szDispText; 1855 ListView_GetItemA(hwnd, &lvItem); 1856 1857 if (lvItem.state & LVIS_SELECTED) 1858 { 1949 1859 /* set item colors */ 1950 1860 SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT)); 1951 1861 SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); 1952 1953 1862 /* set raster mode */ 1954 1863 SetROP2(hdc, R2_XORPEN); … … 1956 1865 else 1957 1866 { 1958 bSelected = FALSE;1959 1960 1867 /* set item colors */ 1961 1868 SetBkColor(hdc, infoPtr->clrTextBk); 1962 1869 SetTextColor(hdc, infoPtr->clrText); 1963 1964 1870 /* set raster mode */ 1965 1871 SetROP2(hdc, R2_COPYPEN); 1966 1872 } 1967 1873 1968 /* state icons */1969 if (infoPtr->himlState != NULL)1970 {1971 /* right shift 12 bits to obtain index in image list */1972 if ( bSelected != FALSE)1973 { 1974 ImageList_Draw(infoPtr->himl State, uState >> 12, hdc, rc.left,1975 rc .top, ILD_SELECTED);1874 if (infoPtr->himlNormal != NULL) 1875 { 1876 rcItem.top += ICON_TOP_PADDING; 1877 nDrawPosX += (infoPtr->iconSpacing.cx - infoPtr->iconSize.cx) / 2; 1878 if (lvItem.state & LVIS_SELECTED) 1879 { 1880 ImageList_Draw(infoPtr->himlNormal, lvItem.iImage, hdc, nDrawPosX, 1881 rcItem.top, ILD_SELECTED); 1976 1882 } 1977 1883 else 1978 1884 { 1979 ImageList_Draw(infoPtr->himlState, uState >> 12, hdc, rc.left, 1980 rc.top, ILD_NORMAL); 1981 } 1982 1983 rc.left += infoPtr->iconSize.cx; 1984 } 1985 1986 /* small icons */ 1987 if (infoPtr->himlSmall != NULL) 1988 { 1989 if (bSelected != FALSE) 1990 { 1991 ImageList_Draw(infoPtr->himlSmall, nImage, hdc, rc.left, 1992 rc.top, ILD_SELECTED); 1993 } 1994 else 1995 { 1996 ImageList_Draw(infoPtr->himlSmall, nImage, hdc, rc.left, 1997 rc.top, ILD_NORMAL); 1998 } 1999 2000 rc.left += infoPtr->iconSize.cx; 2001 } 2002 2003 nLabelWidth = ListView_GetStringWidthA(hwnd, pszDispText); 2004 if (rc.left + nLabelWidth < rc.right) 2005 { 2006 rc.right = rc.left + nLabelWidth; 2007 } 2008 2009 /* draw label */ 2010 ExtTextOutA(hdc, rc.left, rc.top, ETO_OPAQUE|ETO_CLIPPED, 2011 &rc, pszDispText, lstrlenA(pszDispText), NULL); 2012 2013 if (lpItem->state & LVIS_FOCUSED) 2014 { 2015 Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom); 2016 } 2017 } 2018 2019 /*** 2020 * DESCRIPTION: 2021 * Draws an item when in large icon display mode. 2022 * 2023 * PARAMETER(S): 2024 * [I] HWND : window handle 2025 * [I] HDC : device context handle 2026 * [I] LISTVIEW_ITEM * : item 2027 * [I] INT : item index 2028 * [I] RECT * : clipping rectangle 2029 * 2030 * RETURN: 2031 * None 2032 */ 2033 static VOID LISTVIEW_DrawLargeItem(HWND hwnd, HDC hdc, LISTVIEW_ITEM *lpItem, 2034 INT nItem, RECT rc) 2035 { 2036 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 2037 CHAR szDispText[DISP_TEXT_SIZE]; 2038 LPSTR pszDispText = NULL; 2039 BOOL bSelected; 2040 INT nLabelWidth; 2041 INT nImage; 2042 UINT uState; 2043 INT nDrawPosX = 0; 2044 TEXTMETRICA tm; 2045 2046 // TRACE(listview, "(hwnd=%x,hdc=%x,lpItem=%p,nItem=%d,rc.left=%d,rctop=%d,rc.right=%d,rc.bottom=%d)\n", hwnd, hdc, lpItem, nItem, rc.left, rc.top, rc.right, rc.bottom); 2047 2048 pszDispText = szDispText; 2049 LISTVIEW_GetItemDispInfo(hwnd, nItem, lpItem, &nImage, &uState, &pszDispText, 2050 DISP_TEXT_SIZE); 2051 if (uState & LVIS_SELECTED) 2052 { 2053 bSelected = TRUE; 2054 2055 /* set item colors */ 2056 SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT)); 2057 SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); 2058 2059 /* set raster mode */ 2060 SetROP2(hdc, R2_XORPEN); 2061 } 2062 else 2063 { 2064 bSelected = FALSE; 2065 2066 /* set item colors */ 2067 SetBkColor(hdc, infoPtr->clrTextBk); 2068 SetTextColor(hdc, infoPtr->clrText); 2069 2070 /* set raster mode */ 2071 SetROP2(hdc, R2_COPYPEN); 2072 } 2073 2074 if (infoPtr->himlNormal != NULL) 2075 { 2076 rc.top += ICON_TOP_PADDING; 2077 nDrawPosX = rc.left + (infoPtr->iconSpacing.cx - infoPtr->iconSize.cx) / 2; 2078 if (bSelected != FALSE) 2079 { 2080 ImageList_Draw(infoPtr->himlNormal, nImage, hdc, nDrawPosX, rc.top, 2081 ILD_SELECTED); 2082 } 2083 else 2084 { 2085 ImageList_Draw(infoPtr->himlNormal, nImage, hdc, nDrawPosX, rc.top, 2086 ILD_NORMAL); 2087 } 2088 } 2089 2090 rc.top += infoPtr->iconSize.cy + ICON_BOTTOM_PADDING; 2091 nLabelWidth = ListView_GetStringWidthA(hwnd, pszDispText); 1885 ImageList_Draw(infoPtr->himlNormal, lvItem.iImage, hdc, nDrawPosX, 1886 rcItem.top, ILD_NORMAL); 1887 } 1888 } 1889 1890 rcItem.top += infoPtr->iconSize.cy + ICON_BOTTOM_PADDING; 1891 nLabelWidth = ListView_GetStringWidthA(hwnd, lvItem.pszText); 2092 1892 nDrawPosX = infoPtr->iconSpacing.cx - nLabelWidth; 2093 1893 if (nDrawPosX > 1) 2094 1894 { 2095 rc .left += nDrawPosX / 2;2096 rc .right = rc.left + nLabelWidth;1895 rcItem.left += nDrawPosX / 2; 1896 rcItem.right = rcItem.left + nLabelWidth; 2097 1897 } 2098 1898 else 2099 1899 { 2100 rc .left += 1;2101 rc .right = rc.left + infoPtr->iconSpacing.cx - 1;1900 rcItem.left += 1; 1901 rcItem.right = rcItem.left + infoPtr->iconSpacing.cx - 1; 2102 1902 } 2103 1903 2104 1904 /* draw label */ 2105 1905 GetTextMetricsA(hdc, &tm); 2106 rc .bottom = rc.top + tm.tmHeight + HEIGHT_PADDING;2107 ExtTextOutA(hdc, rc .left, rc.top, ETO_OPAQUE|ETO_CLIPPED,2108 &rc , pszDispText, lstrlenA(pszDispText), NULL);1906 rcItem.bottom = rcItem.top + tm.tmHeight + HEIGHT_PADDING; 1907 ExtTextOutA(hdc, rcItem.left, rcItem.top, ETO_OPAQUE | ETO_CLIPPED, 1908 &rcItem, lvItem.pszText, lstrlenA(lvItem.pszText), NULL); 2109 1909 2110 if (l pItem->state & LVIS_FOCUSED)2111 { 2112 Rectangle(hdc, rc .left, rc.top, rc.right, rc.bottom);1910 if (lvItem.state & LVIS_FOCUSED) 1911 { 1912 Rectangle(hdc, rcItem.left, rcItem.top, rcItem.right, rcItem.bottom); 2113 1913 } 2114 1914 } … … 2129 1929 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd,0); 2130 1930 INT nDrawPosY = infoPtr->rcList.top; 2131 LISTVIEW_ITEM *lpItem;2132 LISTVIEW_SUBITEM *lpSubItem = NULL;2133 BOOL bNeedSubItem = TRUE;2134 1931 INT nColumnCount; 2135 HDPA hdpaSubItems;2136 1932 RECT rcItem; 2137 INT j , k;1933 INT j; 2138 1934 INT nItem; 2139 1935 INT nLast; 2140 1936 2141 1937 nItem = ListView_GetTopIndex(hwnd); 2142 nLast = nItem + infoPtr->nCountPerColumn; 2143 while (nItem <= nLast) 2144 { 2145 hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, nItem); 2146 if (hdpaSubItems != NULL) 2147 { 2148 lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0); 2149 if (lpItem != NULL) 2150 { 2151 /* the width of the header items will determine the size of the 2152 listview items */ 2153 Header_GetItemRect(infoPtr->hwndHeader, 0, &rcItem); 2154 rcItem.left += REPORT_MARGINX; 2155 rcItem.right = max(rcItem.left, rcItem.right - REPORT_MARGINX); 2156 rcItem.top = nDrawPosY; 2157 rcItem.bottom = rcItem.top + infoPtr->nItemHeight; 2158 LISTVIEW_DrawItem(hwnd, hdc, lpItem, nItem, rcItem); 2159 } 2160 2161 nColumnCount = Header_GetItemCount(infoPtr->hwndHeader); 2162 for (k = 1, j = 1; j < nColumnCount; j++) 2163 { 2164 Header_GetItemRect(infoPtr->hwndHeader, j, &rcItem); 2165 rcItem.left += REPORT_MARGINX; 2166 rcItem.right = max(rcItem.left, rcItem.right - REPORT_MARGINX); 2167 rcItem.top = nDrawPosY; 2168 rcItem.bottom = rcItem.top + infoPtr->nItemHeight; 2169 2170 if (k < hdpaSubItems->nItemCount) 2171 { 2172 if (bNeedSubItem != FALSE) 1938 1939 /* add 1 for displaying a partial item at the bottom */ 1940 nLast = nItem + LISTVIEW_GetCountPerColumn(hwnd) + 1; 1941 nLast = min(nLast, GETITEMCOUNT(infoPtr)); 1942 for (; nItem < nLast; nItem++) 1943 { 1944 nColumnCount = Header_GetItemCount(infoPtr->hwndHeader); 1945 for (j = 0; j < nColumnCount; j++) 1946 { 1947 Header_GetItemRect(infoPtr->hwndHeader, j, &rcItem); 1948 rcItem.left += REPORT_MARGINX; 1949 rcItem.right = max(rcItem.left, rcItem.right - REPORT_MARGINX); 1950 rcItem.top = nDrawPosY; 1951 rcItem.bottom = rcItem.top + infoPtr->nItemHeight; 1952 if (j == 0) 1953 { 1954 LISTVIEW_DrawItem(hwnd, hdc, nItem, rcItem); 1955 } 1956 else 1957 { 1958 LISTVIEW_DrawSubItem(hwnd, hdc, nItem, j, rcItem); 1959 } 1960 } 1961 1962 nDrawPosY += infoPtr->nItemHeight; 1963 } 1964 } 1965 1966 /*** 1967 * DESCRIPTION: 1968 * Retrieves the number of items that can fit vertically in the client area. 1969 * 1970 * PARAMETER(S): 1971 * [I] HWND : window handle 1972 * 1973 * RETURN: 1974 * Number of items per row. 1975 */ 1976 static INT LISTVIEW_GetCountPerRow(HWND hwnd) 1977 { 1978 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd,0); 1979 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 1980 INT nListWidth = infoPtr->rcList.right - infoPtr->rcList.left; 1981 INT nCountPerRow = 1; 1982 1983 if (nListWidth > 0) 1984 { 1985 if (uView == LVS_REPORT) 1986 { 1987 nCountPerRow = 1; 1988 } 1989 else 1990 { 1991 nCountPerRow = nListWidth / infoPtr->nItemWidth; 1992 if (nCountPerRow == 0) 1993 { 1994 nCountPerRow = 1; 1995 } 1996 } 1997 } 1998 1999 return nCountPerRow; 2000 } 2001 2002 /*** 2003 * DESCRIPTION: 2004 * Retrieves the number of items that can fit horizontally in the client 2005 * area. 2006 * 2007 * PARAMETER(S): 2008 * [I] HWND : window handle 2009 * 2010 * RETURN: 2011 * Number of items per column. 2012 */ 2013 static INT LISTVIEW_GetCountPerColumn(HWND hwnd) 2014 { 2015 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd,0); 2016 INT nListHeight = infoPtr->rcList.bottom - infoPtr->rcList.top; 2017 INT nCountPerColumn = 1; 2018 2019 if (nListHeight > 0) 2020 { 2021 nCountPerColumn = nListHeight / infoPtr->nItemHeight; 2022 if (nCountPerColumn == 0) 2023 { 2024 nCountPerColumn = 1; 2025 } 2026 } 2027 2028 return nCountPerColumn; 2029 } 2030 2031 /*** 2032 * DESCRIPTION: 2033 * Retrieves the number of columns needed to display all the items when in 2034 * list display mode. 2035 * 2036 * PARAMETER(S): 2037 * [I] HWND : window handle 2038 * 2039 * RETURN: 2040 * Number of columns. 2041 */ 2042 static INT LISTVIEW_GetColumnCount(hwnd) 2043 { 2044 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 2045 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 2046 INT nColumnCount = 0; 2047 2048 if ((lStyle & LVS_TYPEMASK) == LVS_LIST) 2049 { 2050 if (infoPtr->rcList.right % infoPtr->nItemWidth == 0) 2051 { 2052 nColumnCount = infoPtr->rcList.right / infoPtr->nItemWidth; 2053 } 2054 else 2055 { 2056 nColumnCount = infoPtr->rcList.right / infoPtr->nItemWidth + 1; 2057 } 2058 } 2059 2060 return nColumnCount; 2061 } 2062 2063 2064 /*** 2065 * DESCRIPTION: 2066 * Draws listview items when in list display mode. 2067 * 2068 * PARAMETER(S): 2069 * [I] HWND : window handle 2070 * [I] HDC : device context handle 2071 * 2072 * RETURN: 2073 * None 2074 */ 2075 static VOID LISTVIEW_RefreshList(HWND hwnd, HDC hdc) 2076 { 2077 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 2078 RECT rcItem; 2079 INT i, j; 2080 INT nItem; 2081 INT nColumnCount; 2082 INT nCountPerColumn; 2083 2084 /* get number of fully visible columns */ 2085 nColumnCount = LISTVIEW_GetColumnCount(hwnd); 2086 nCountPerColumn = LISTVIEW_GetCountPerColumn(hwnd); 2087 nItem = ListView_GetTopIndex(hwnd); 2088 2089 for (i = 0; i < nColumnCount; i++) 2090 { 2091 for (j = 0; j < nCountPerColumn; j++, nItem++) 2092 { 2093 if (nItem >= GETITEMCOUNT(infoPtr)) 2094 return; 2095 2096 rcItem.top = j * infoPtr->nItemHeight; 2097 rcItem.left = i * infoPtr->nItemWidth; 2098 rcItem.bottom = rcItem.top + infoPtr->nItemHeight; 2099 rcItem.right = rcItem.left + infoPtr->nItemWidth; 2100 LISTVIEW_DrawItem(hwnd, hdc, nItem, rcItem); 2101 } 2102 } 2103 } 2104 2105 /*** 2106 * DESCRIPTION: 2107 * Draws listview items when in icon or small icon display mode. 2108 * 2109 * PARAMETER(S): 2110 * [I] HWND : window handle 2111 * [I] HDC : device context handle 2112 * 2113 * RETURN: 2114 * None 2115 */ 2116 static VOID LISTVIEW_RefreshIcon(HWND hwnd, HDC hdc, BOOL bSmall) 2117 { 2118 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 2119 POINT ptPosition; 2120 POINT ptOrigin; 2121 RECT rcItem; 2122 INT i; 2123 2124 LISTVIEW_GetOrigin(hwnd, &ptOrigin); 2125 for (i = 0; i < GETITEMCOUNT(infoPtr); i++) 2126 { 2127 LISTVIEW_GetItemPosition(hwnd, i, &ptPosition); 2128 ptPosition.x += ptOrigin.x; 2129 ptPosition.y += ptOrigin.y; 2130 2131 if (ptPosition.y + infoPtr->nItemHeight > infoPtr->rcList.top) 2132 { 2133 if (ptPosition.x + infoPtr->nItemWidth > infoPtr->rcList.left) 2134 { 2135 if (ptPosition.y < infoPtr->rcList.bottom) 2136 { 2137 if (ptPosition.x < infoPtr->rcList.right) 2173 2138 { 2174 lpSubItem = (LISTVIEW_SUBITEM *)DPA_GetPtr(hdpaSubItems, k); 2175 k++; 2176 } 2177 2178 if (lpSubItem != NULL) 2179 { 2180 if (lpSubItem->iSubItem == j) 2139 rcItem.top = ptPosition.y; 2140 rcItem.left = ptPosition.x; 2141 rcItem.bottom = rcItem.top + infoPtr->nItemHeight; 2142 rcItem.right = rcItem.left + infoPtr->nItemWidth; 2143 if (bSmall == FALSE) 2181 2144 { 2182 LISTVIEW_DrawSubItem(hwnd, hdc, nItem, lpItem->lParam, lpSubItem, 2183 j, &rcItem); 2184 bNeedSubItem = TRUE; 2145 LISTVIEW_DrawLargeItem(hwnd, hdc, i, rcItem); 2185 2146 } 2186 2147 else 2187 2148 { 2188 LISTVIEW_DrawSubItem(hwnd, hdc, nItem, lpItem->lParam, NULL, j, 2189 &rcItem); 2190 bNeedSubItem = FALSE; 2149 LISTVIEW_DrawItem(hwnd, hdc, i, rcItem); 2191 2150 } 2192 2151 } 2193 else 2194 { 2195 LISTVIEW_DrawSubItem(hwnd, hdc, nItem, lpItem->lParam, NULL, j, 2196 &rcItem); 2197 bNeedSubItem = TRUE; 2198 } 2199 } 2200 else 2201 { 2202 LISTVIEW_DrawSubItem(hwnd, hdc, nItem, lpItem->lParam, NULL, j, 2203 &rcItem); 2204 } 2205 } 2206 } 2207 2208 nDrawPosY += infoPtr->nItemHeight; 2209 nItem++; 2210 } 2211 } 2212 2213 /*** 2214 * DESCRIPTION: 2215 * Draws listview items when in list display mode. 2152 } 2153 } 2154 } 2155 } 2156 } 2157 2158 /*** 2159 * DESCRIPTION: 2160 * Draws listview items. 2216 2161 * 2217 2162 * PARAMETER(S): … … 2220 2165 * 2221 2166 * RETURN: 2222 * None2223 */2224 static VOID LISTVIEW_RefreshList(HWND hwnd, HDC hdc)2225 {2226 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);2227 LISTVIEW_ITEM *lpItem;2228 HDPA hdpaSubItems;2229 RECT rc;2230 INT i, j;2231 INT nColumnCount;2232 INT nItem = ListView_GetTopIndex(hwnd);2233 2234 if (infoPtr->rcList.right > 0)2235 {2236 /* get number of display columns */2237 if (infoPtr->rcList.right % infoPtr->nItemWidth == 0)2238 {2239 nColumnCount = infoPtr->rcList.right / infoPtr->nItemWidth;2240 }2241 else2242 {2243 nColumnCount = infoPtr->rcList.right / infoPtr->nItemWidth + 1;2244 }2245 2246 for (i = 0; i < nColumnCount; i++)2247 {2248 j = 0;2249 while ((nItem < GETITEMCOUNT(infoPtr)) &&2250 (j<infoPtr->nCountPerColumn))2251 {2252 hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, nItem);2253 if (hdpaSubItems != NULL)2254 {2255 lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0);2256 if (lpItem != NULL)2257 {2258 rc.top = j * infoPtr->nItemHeight;2259 rc.left = i * infoPtr->nItemWidth;2260 rc.bottom = rc.top + infoPtr->nItemHeight;2261 rc.right = rc.left + infoPtr->nItemWidth;2262 LISTVIEW_DrawItem(hwnd, hdc, lpItem, nItem, rc);2263 }2264 }2265 2266 nItem++;2267 j++;2268 }2269 }2270 }2271 }2272 2273 /***2274 * DESCRIPTION:2275 * Draws listview items when in icon or small icon display mode.2276 *2277 * PARAMETER(S):2278 * [I] HWND : window handle2279 * [I] HDC : device context handle2280 *2281 * RETURN:2282 * None2283 */2284 static VOID LISTVIEW_RefreshIcon(HWND hwnd, HDC hdc, BOOL bSmall)2285 {2286 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);2287 LISTVIEW_ITEM *lpItem;2288 HDPA hdpaSubItems;2289 POINT ptPosition;2290 POINT ptOrigin;2291 RECT rc;2292 INT i;2293 2294 LISTVIEW_GetOrigin(hwnd, &ptOrigin);2295 2296 for (i = 0; i < GETITEMCOUNT(infoPtr); i++)2297 {2298 LISTVIEW_GetItemPosition(hwnd, i, &ptPosition);2299 ptPosition.x += ptOrigin.x;2300 ptPosition.y += ptOrigin.y;2301 2302 if (ptPosition.y + infoPtr->nItemHeight > infoPtr->rcList.top)2303 {2304 if (ptPosition.x + infoPtr->nItemWidth > infoPtr->rcList.left)2305 {2306 if (ptPosition.y < infoPtr->rcList.bottom)2307 {2308 if (ptPosition.x < infoPtr->rcList.right)2309 {2310 hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, i);2311 if (hdpaSubItems != NULL)2312 {2313 lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0);2314 if (lpItem != NULL)2315 {2316 rc.top = ptPosition.y;2317 rc.left = ptPosition.x;2318 rc.bottom = rc.top + infoPtr->nItemHeight;2319 rc.right = rc.left + infoPtr->nItemWidth;2320 if (bSmall == FALSE)2321 {2322 LISTVIEW_DrawLargeItem(hwnd, hdc, lpItem, i, rc);2323 }2324 else2325 {2326 LISTVIEW_DrawItem(hwnd, hdc, lpItem, i, rc);2327 }2328 }2329 }2330 }2331 }2332 }2333 }2334 }2335 }2336 2337 /***2338 * DESCRIPTION:2339 * Draws listview items.2340 *2341 * PARAMETER(S):2342 * [I] HWND : window handle2343 * [I] HDC : device context handle2344 *2345 * RETURN:2346 2167 * NoneX 2347 2168 */ … … 2349 2170 { 2350 2171 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 2351 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);2172 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 2352 2173 HFONT hOldFont; 2353 2174 HPEN hPen, hOldPen; … … 2363 2184 SelectObject(hdc, GetStockObject(NULL_BRUSH)); 2364 2185 2365 switch (LVS_TYPEMASK & lStyle) 2366 { 2367 case LVS_LIST: 2186 if (uView == LVS_LIST) 2187 { 2368 2188 LISTVIEW_RefreshList(hwnd, hdc); 2369 break; 2370 case LVS_REPORT: 2189 } 2190 else if (uView == LVS_REPORT) 2191 { 2371 2192 LISTVIEW_RefreshReport(hwnd, hdc); 2372 break; 2373 case LVS_SMALLICON: 2193 } 2194 else if (uView == LVS_SMALLICON) 2195 { 2374 2196 LISTVIEW_RefreshIcon(hwnd, hdc, TRUE); 2375 break; 2376 case LVS_ICON: 2197 } 2198 else if (uView == LVS_ICON) 2199 { 2377 2200 LISTVIEW_RefreshIcon(hwnd, hdc, FALSE); 2378 2201 } … … 2404 2227 { 2405 2228 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 2406 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);2229 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 2407 2230 INT nItemCountPerColumn = 1; 2408 2231 INT nColumnCount = 0; … … 2410 2233 2411 2234 if (nItemCount == -1) 2235 { 2412 2236 nItemCount = GETITEMCOUNT(infoPtr); 2413 2414 if (lStyle & LVS_LIST) 2237 } 2238 2239 if (uView == LVS_LIST) 2415 2240 { 2416 2241 if (wHeight == 0xFFFF) 2417 2242 { 2418 2243 /* use current height */ 2419 wHeight = infoPtr->rcList.bottom ;2244 wHeight = infoPtr->rcList.bottom - infoPtr->rcList.top; 2420 2245 } 2421 2246 … … 2431 2256 nItemCountPerColumn = wHeight / infoPtr->nItemHeight; 2432 2257 if (nItemCountPerColumn == 0) 2258 { 2433 2259 nItemCountPerColumn = 1; 2434 2260 } 2261 2435 2262 if (nItemCount % nItemCountPerColumn != 0) 2263 { 2436 2264 nColumnCount = nItemCount / nItemCountPerColumn; 2265 } 2437 2266 else 2267 { 2438 2268 nColumnCount = nItemCount / nItemCountPerColumn + 1; 2269 } 2439 2270 } 2440 2271 } … … 2446 2277 dwViewRect = MAKELONG(wWidth, wHeight); 2447 2278 } 2448 else if ( lStyle &LVS_REPORT)2279 else if (uView == LVS_REPORT) 2449 2280 { 2450 2281 /* TO DO */ 2451 2452 else if ( lStyle &LVS_SMALLICON)2282 } 2283 else if (uView == LVS_SMALLICON) 2453 2284 { 2454 2285 /* TO DO */ 2455 2286 } 2456 else if ( lStyle &LVS_ICON)2287 else if (uView == LVS_ICON) 2457 2288 { 2458 2289 /* TO DO */ … … 2476 2307 static LRESULT LISTVIEW_Arrange(HWND hwnd, INT nAlignCode) 2477 2308 { 2478 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);2309 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 2479 2310 BOOL bResult = FALSE; 2480 2311 2481 if (((LVS_TYPEMASK & lStyle) == LVS_ICON) || 2482 ((LVS_TYPEMASK & lStyle) == LVS_SMALLICON)) 2312 if ((uView == LVS_ICON) || (uView == LVS_SMALLICON)) 2483 2313 { 2484 2314 switch (nAlignCode) … … 2520 2350 LONG lCtrlId = GetWindowLongA(hwnd, GWL_ID); 2521 2351 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 2352 UINT uView = lStyle & LVS_TYPEMASK; 2522 2353 LISTVIEW_ITEM *lpItem; 2523 2354 LISTVIEW_SUBITEM *lpSubItem; … … 2529 2360 HDPA hdpaSubItems; 2530 2361 2531 // TRACE(listview,"(hwnd=%x,)\n", hwnd);2362 TRACE("(hwnd=%x,)\n", hwnd); 2532 2363 2533 2364 if (GETITEMCOUNT(infoPtr) > 0) … … 2599 2430 2600 2431 /* align items (set position of each item) */ 2601 switch (lStyle & LVS_TYPEMASK) 2602 { 2603 case LVS_ICON: 2604 case LVS_SMALLICON: 2432 if ((uView == LVS_ICON) || (uView == LVS_SMALLICON)) 2433 { 2605 2434 if (lStyle & LVS_ALIGNLEFT) 2606 2435 { … … 2611 2440 LISTVIEW_AlignTop(hwnd); 2612 2441 } 2613 break;2614 2442 } 2615 2443 2616 LISTVIEW_ SetScroll(hwnd, lStyle);2444 LISTVIEW_UpdateScroll(hwnd); 2617 2445 2618 2446 /* invalidate client area (optimization needed) */ … … 2638 2466 { 2639 2467 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 2640 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);2468 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 2641 2469 BOOL bResult = FALSE; 2642 2470 … … 2646 2474 2647 2475 /* reset scroll parameters */ 2648 if ( (lStyle & LVS_TYPEMASK)== LVS_REPORT)2649 { 2650 LISTVIEW_SetViewInfo(hwnd, lStyle);2651 LISTVIEW_ SetScroll(hwnd, lStyle);2652 } 2653 2654 /* refresh client area */2655 InvalidateRect(hwnd, NULL, FALSE);2476 if (uView == LVS_REPORT) 2477 { 2478 /* update scrollbar(s) */ 2479 LISTVIEW_UpdateScroll(hwnd); 2480 2481 /* refresh client area */ 2482 InvalidateRect(hwnd, NULL, FALSE); 2483 } 2656 2484 } 2657 2485 … … 2675 2503 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 2676 2504 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 2505 UINT uView = lStyle & LVS_TYPEMASK; 2677 2506 LONG lCtrlId = GetWindowLongA(hwnd, GWL_ID); 2678 2507 NMLISTVIEW nmlv; … … 2683 2512 INT i; 2684 2513 2685 // TRACE(listview,"(hwnd=%x,nItem=%d)\n", hwnd, nItem);2514 TRACE("(hwnd=%x,nItem=%d)\n", hwnd, nItem); 2686 2515 2687 2516 if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr))) … … 2737 2566 2738 2567 /* align items (set position of each item) */ 2739 switch(lStyle & LVS_TYPEMASK) 2740 { 2741 case LVS_ICON: 2742 case LVS_SMALLICON: 2568 if ((uView == LVS_SMALLICON) || (uView == LVS_ICON)) 2569 { 2743 2570 if (lStyle & LVS_ALIGNLEFT) 2744 2571 { … … 2749 2576 LISTVIEW_AlignTop(hwnd); 2750 2577 } 2751 break; 2752 } 2753 2754 LISTVIEW_SetScroll(hwnd, lStyle); 2578 } 2579 2580 LISTVIEW_UpdateScroll(hwnd); 2755 2581 2756 2582 /* refresh client area */ … … 2779 2605 { 2780 2606 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 2781 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);2607 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 2782 2608 INT nListHeight = infoPtr->rcList.bottom - infoPtr->rcList.top; 2783 2609 INT nListWidth = infoPtr->rcList.right - infoPtr->rcList.left; 2784 INT nHScrollPos = 0;2785 INT nVScrollPos = 0;2786 2610 INT nScrollPosHeight = 0; 2787 2611 INT nScrollPosWidth = 0; 2612 SCROLLINFO scrollInfo; 2788 2613 RECT rcItem; 2789 BOOL bResult = FALSE; 2614 2615 ZeroMemory(&scrollInfo, sizeof(SCROLLINFO)); 2616 scrollInfo.cbSize = sizeof(SCROLLINFO); 2617 scrollInfo.fMask = SIF_POS; 2790 2618 2791 2619 /* ALWAYS bPartial == FALSE, FOR NOW! */ … … 2796 2624 if (rcItem.left < infoPtr->rcList.left) 2797 2625 { 2798 /* scroll left */ 2799 switch (LVS_TYPEMASK & lStyle) 2800 { 2801 case LVS_LIST: 2802 rcItem.left += infoPtr->rcList.left; 2803 nScrollPosWidth = infoPtr->nItemWidth; 2804 break; 2805 2806 case LVS_SMALLICON: 2807 case LVS_ICON: 2808 nScrollPosWidth = max(1, nListWidth / 10); 2809 rcItem.left += infoPtr->rcList.left; 2810 break; 2811 } 2812 2813 if (rcItem.left % nScrollPosWidth == 0) 2814 { 2815 nHScrollPos = rcItem.left / nScrollPosWidth; 2816 } 2817 else 2818 { 2819 nHScrollPos = rcItem.left / nScrollPosWidth - 1; 2626 if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) != FALSE) 2627 { 2628 /* scroll left */ 2629 if (uView == LVS_LIST) 2630 { 2631 nScrollPosWidth = infoPtr->nItemWidth; 2632 rcItem.left += infoPtr->rcList.left; 2633 } 2634 else if ((uView == LVS_SMALLICON) || (uView == LVS_ICON)) 2635 { 2636 nScrollPosWidth = max(1, nListWidth / 10); 2637 rcItem.left += infoPtr->rcList.left; 2638 } 2639 2640 if (rcItem.left % nScrollPosWidth == 0) 2641 { 2642 scrollInfo.nPos += rcItem.left / nScrollPosWidth; 2643 } 2644 else 2645 { 2646 scrollInfo.nPos += rcItem.left / nScrollPosWidth - 1; 2647 } 2648 2649 SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE); 2820 2650 } 2821 2651 } 2822 2652 else if (rcItem.right > infoPtr->rcList.right) 2823 2653 { 2824 /* scroll right */ 2825 switch (LVS_TYPEMASK & lStyle) 2826 { 2827 case LVS_LIST: 2828 rcItem.right -= infoPtr->rcList.right; 2829 nScrollPosWidth = infoPtr->nItemWidth; 2830 break; 2831 2832 case LVS_SMALLICON: 2833 case LVS_ICON: 2834 nScrollPosWidth = max(1, nListWidth / 10); 2835 rcItem.right -= infoPtr->rcList.right; 2836 break; 2837 } 2838 2839 if (rcItem.right % nScrollPosWidth == 0) 2840 { 2841 nHScrollPos = rcItem.right / nScrollPosWidth; 2842 } 2843 else 2844 { 2845 nHScrollPos = rcItem.right / nScrollPosWidth + 1; 2654 if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) != FALSE) 2655 { 2656 /* scroll right */ 2657 if (uView == LVS_LIST) 2658 { 2659 rcItem.right -= infoPtr->rcList.right; 2660 nScrollPosWidth = infoPtr->nItemWidth; 2661 } 2662 else if ((uView == LVS_SMALLICON) || (uView == LVS_ICON)) 2663 { 2664 rcItem.right -= infoPtr->rcList.right; 2665 nScrollPosWidth = max(1, nListWidth / 10); 2666 } 2667 2668 if (rcItem.right % nScrollPosWidth == 0) 2669 { 2670 scrollInfo.nPos += rcItem.right / nScrollPosWidth; 2671 } 2672 else 2673 { 2674 scrollInfo.nPos += rcItem.right / nScrollPosWidth + 1; 2675 } 2676 2677 SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE); 2846 2678 } 2847 2679 } … … 2850 2682 { 2851 2683 /* scroll up */ 2852 switch (LVS_TYPEMASK & lStyle) 2853 { 2854 case LVS_REPORT: 2855 rcItem.top -= infoPtr->rcList.top; 2856 nScrollPosHeight = infoPtr->nItemHeight; 2857 break; 2858 2859 case LVS_SMALLICON: 2860 case LVS_ICON: 2861 nScrollPosHeight = max(1, nListHeight / 10); 2862 rcItem.top += infoPtr->rcList.top; 2863 break; 2864 } 2865 2866 if (rcItem.top % nScrollPosHeight == 0) 2867 { 2868 nVScrollPos = rcItem.top / nScrollPosHeight; 2684 if (GetScrollInfo(hwnd, SB_VERT, &scrollInfo) != FALSE) 2685 { 2686 if (uView == LVS_REPORT) 2687 { 2688 rcItem.top -= infoPtr->rcList.top; 2689 nScrollPosHeight = infoPtr->nItemHeight; 2690 } 2691 else if ((uView == LVS_ICON) || (uView == LVS_SMALLICON)) 2692 { 2693 nScrollPosHeight = max(1, nListHeight / 10); 2694 rcItem.top += infoPtr->rcList.top; 2695 } 2696 2697 if (rcItem.top % nScrollPosHeight == 0) 2698 { 2699 scrollInfo.nPos += rcItem.top / nScrollPosHeight; 2700 } 2701 else 2702 { 2703 scrollInfo.nPos += rcItem.top / nScrollPosHeight - 1; 2704 } 2705 2706 SetScrollInfo(hwnd, SB_VERT, &scrollInfo, TRUE); 2707 } 2708 } 2709 else if (rcItem.bottom > infoPtr->rcList.bottom) 2710 { 2711 /* scroll down */ 2712 if (GetScrollInfo(hwnd, SB_VERT, &scrollInfo) != FALSE) 2713 { 2714 if (uView == LVS_REPORT) 2715 { 2716 rcItem.bottom -= infoPtr->rcList.bottom; 2717 nScrollPosHeight = infoPtr->nItemHeight; 2718 } 2719 else if ((uView == LVS_ICON) || (uView == LVS_SMALLICON)) 2720 { 2721 nScrollPosHeight = max(1, nListHeight / 10); 2722 rcItem.bottom -= infoPtr->rcList.bottom; 2723 } 2724 2725 if (rcItem.bottom % nScrollPosHeight == 0) 2726 { 2727 scrollInfo.nPos += rcItem.bottom / nScrollPosHeight; 2728 } 2729 else 2730 { 2731 scrollInfo.nPos += rcItem.bottom / nScrollPosHeight + 1; 2732 } 2733 2734 SetScrollInfo(hwnd, SB_VERT, &scrollInfo, TRUE); 2735 } 2736 } 2737 } 2738 2739 return TRUE; 2740 } 2741 2742 /*** 2743 * DESCRIPTION: 2744 * Retrieves the nearest item, given a position and a direction. 2745 * 2746 * PARAMETER(S): 2747 * [I] HWND : window handle 2748 * [I] POINT : start position 2749 * [I] UINT : direction 2750 * 2751 * RETURN: 2752 * Item index if successdful, -1 otherwise. 2753 */ 2754 static INT LISTVIEW_GetNearestItem(HWND hwnd, POINT pt, UINT vkDirection) 2755 { 2756 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 2757 LVHITTESTINFO lvHitTestInfo; 2758 INT nItem = -1; 2759 RECT rcView; 2760 2761 if (LISTVIEW_GetViewRect(hwnd, &rcView) != FALSE) 2762 { 2763 ZeroMemory(&lvHitTestInfo, sizeof(LVHITTESTINFO)); 2764 LISTVIEW_GetOrigin(hwnd, &lvHitTestInfo.pt); 2765 lvHitTestInfo.pt.x += pt.x; 2766 lvHitTestInfo.pt.y += pt.y; 2767 2768 do 2769 { 2770 if (vkDirection == VK_DOWN) 2771 { 2772 lvHitTestInfo.pt.y += infoPtr->nItemHeight; 2773 } 2774 else if (vkDirection == VK_UP) 2775 { 2776 lvHitTestInfo.pt.y -= infoPtr->nItemHeight; 2777 } 2778 else if (vkDirection == VK_LEFT) 2779 { 2780 lvHitTestInfo.pt.x -= infoPtr->nItemWidth; 2781 } 2782 else if (vkDirection == VK_RIGHT) 2783 { 2784 lvHitTestInfo.pt.x += infoPtr->nItemWidth; 2785 } 2786 2787 if (PtInRect(&rcView, lvHitTestInfo.pt) == FALSE) 2788 { 2789 return -1; 2869 2790 } 2870 2791 else 2871 2792 { 2872 nVScrollPos = rcItem.top / nScrollPosHeight - 1; 2873 } 2874 } 2875 else if (rcItem.bottom > infoPtr->rcList.bottom) 2876 { 2877 switch (LVS_TYPEMASK & lStyle) 2878 { 2879 case LVS_REPORT: 2880 rcItem.bottom -= infoPtr->rcList.bottom; 2881 nScrollPosHeight = infoPtr->nItemHeight; 2882 break; 2883 2884 case LVS_SMALLICON: 2885 case LVS_ICON: 2886 nScrollPosHeight = max(1, nListHeight / 10); 2887 rcItem.bottom -= infoPtr->rcList.bottom; 2888 break; 2889 } 2890 2891 if (rcItem.bottom % nScrollPosHeight == 0) 2892 { 2893 nVScrollPos = rcItem.bottom / nScrollPosHeight; 2894 } 2895 else 2896 { 2897 nVScrollPos = rcItem.bottom / nScrollPosHeight + 1; 2898 } 2899 } 2900 2901 bResult = LISTVIEW_ScrollView(hwnd, nHScrollPos, nVScrollPos); 2902 } 2903 2904 return bResult; 2905 } 2793 nItem = LISTVIEW_HitTestItem(hwnd, &lvHitTestInfo); 2794 } 2795 2796 } 2797 while (nItem == -1); 2798 } 2799 2800 return nItem; 2801 } 2906 2802 2907 2803 /*** … … 2921 2817 LPLVFINDINFO lpFindInfo) 2922 2818 { 2923 // FIXME (listview, "empty stub!\n"); 2924 2925 return -1; 2819 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 2820 POINT ptItem; 2821 CHAR szDispText[DISP_TEXT_SIZE]; 2822 LVITEMA lvItem; 2823 BOOL bWrap = FALSE; 2824 INT nItem = nStart; 2825 INT nLast = GETITEMCOUNT(infoPtr); 2826 2827 if ((nItem >= -1) && (lpFindInfo != NULL)) 2828 { 2829 ZeroMemory(&lvItem, sizeof(LVITEMA)); 2830 2831 if (lpFindInfo->flags & LVFI_PARAM) 2832 { 2833 lvItem.mask |= LVIF_PARAM; 2834 } 2835 2836 if (lpFindInfo->flags & LVFI_STRING) 2837 { 2838 lvItem.mask |= LVIF_TEXT; 2839 lvItem.pszText = szDispText; 2840 lvItem.cchTextMax = DISP_TEXT_SIZE; 2841 } 2842 2843 if (lpFindInfo->flags & LVFI_PARTIAL) 2844 { 2845 lvItem.mask |= LVIF_TEXT; 2846 lvItem.pszText = szDispText; 2847 lvItem.cchTextMax = DISP_TEXT_SIZE; 2848 } 2849 2850 if (lpFindInfo->flags & LVFI_WRAP) 2851 { 2852 bWrap = TRUE; 2853 } 2854 2855 if (lpFindInfo->flags & LVFI_NEARESTXY) 2856 { 2857 ptItem.x = lpFindInfo->pt.x; 2858 ptItem.y = lpFindInfo->pt.y; 2859 } 2860 2861 while (1) 2862 { 2863 while (nItem < nLast) 2864 { 2865 if (lpFindInfo->flags & LVFI_NEARESTXY) 2866 { 2867 nItem = LISTVIEW_GetNearestItem(hwnd, ptItem, 2868 lpFindInfo->vkDirection); 2869 if (nItem != -1) 2870 { 2871 /* get position of the new item index */ 2872 if (ListView_GetItemPosition(hwnd, nItem, &ptItem) == FALSE) 2873 return -1; 2874 } 2875 else 2876 return -1; 2877 } 2878 else 2879 { 2880 nItem++; 2881 } 2882 2883 lvItem.iItem = nItem; 2884 lvItem.iSubItem = 0; 2885 if (ListView_GetItemA(hwnd, &lvItem) != FALSE) 2886 { 2887 if (lvItem.mask & LVIF_TEXT) 2888 { 2889 if (lpFindInfo->flags & LVFI_PARTIAL) 2890 { 2891 if (strstr(lvItem.pszText, lpFindInfo->psz) == NULL) 2892 continue; 2893 } 2894 else 2895 { 2896 if (strcmp(lvItem.pszText, lpFindInfo->psz) != 0) 2897 continue; 2898 } 2899 } 2900 2901 if (lvItem.mask & LVIF_PARAM) 2902 { 2903 if (lpFindInfo->lParam != lvItem.lParam) 2904 continue; 2905 } 2906 2907 return nItem; 2908 } 2909 } 2910 2911 if (bWrap != FALSE) 2912 { 2913 nItem = -1; 2914 nLast = nStart + 1; 2915 bWrap = FALSE; 2916 } 2917 else 2918 { 2919 return -1; 2920 } 2921 } 2922 } 2923 2924 return -1; 2926 2925 } 2927 2926 … … 2991 2990 * FAILURE : FALSE 2992 2991 */ 2993 static LRESULT LISTVIEW_GetColumnA(HWND hwnd, INT nItem, 2994 LPLVCOLUMNA lpColumn) 2992 static LRESULT LISTVIEW_GetColumnA(HWND hwnd, INT nItem, LPLVCOLUMNA lpColumn) 2995 2993 { 2996 2994 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); … … 3097 3095 { 3098 3096 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 3099 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 3097 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 3098 INT nColumnWidth = 0; 3100 3099 HDITEMA hdi; 3101 INT nColumnWidth = 0; 3102 3103 switch (LVS_TYPEMASK & lStyle) 3104 { 3105 case LVS_LIST: 3100 3101 if (uView == LVS_LIST) 3102 { 3106 3103 nColumnWidth = infoPtr->nItemWidth; 3107 break;3108 3109 case LVS_REPORT:3104 } 3105 else if (uView == LVS_REPORT) 3106 { 3110 3107 /* get column width from header */ 3111 3108 ZeroMemory(&hdi, sizeof(HDITEMA)); … … 3115 3112 nColumnWidth = hdi.cxy; 3116 3113 } 3117 break;3118 3114 } 3119 3115 … … 3136 3132 { 3137 3133 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 3138 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);3134 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 3139 3135 INT nItemCount = 0; 3140 3136 3141 switch (LVS_TYPEMASK & lStyle) 3142 { 3143 case LVS_LIST: 3144 if (infoPtr->rcList.right / infoPtr->nItemWidth) 3145 { 3146 nItemCount = infoPtr->nCountPerRow * infoPtr->nCountPerColumn; 3147 } 3148 break; 3149 3150 case LVS_REPORT: 3151 nItemCount = infoPtr->nCountPerColumn; 3152 break; 3153 3154 case LVS_SMALLICON: 3155 case LVS_ICON: 3137 if (uView == LVS_LIST) 3138 { 3139 if (infoPtr->rcList.right > infoPtr->nItemWidth) 3140 { 3141 nItemCount = LISTVIEW_GetCountPerRow(hwnd) * 3142 LISTVIEW_GetCountPerColumn(hwnd); 3143 } 3144 } 3145 else if (uView == LVS_REPORT) 3146 { 3147 nItemCount = LISTVIEW_GetCountPerColumn(hwnd); 3148 } 3149 else 3150 { 3156 3151 nItemCount = GETITEMCOUNT(infoPtr); 3157 break;3158 3152 } 3159 3153 … … 3235 3229 { 3236 3230 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 3231 LONG lCtrlId = GetWindowLongA(hwnd, GWL_ID); 3232 BOOL bResult = FALSE; 3233 NMLVDISPINFOA dispInfo; 3234 LISTVIEW_SUBITEM *lpSubItem; 3237 3235 LISTVIEW_ITEM *lpItem; 3238 LISTVIEW_SUBITEM *lpSubItem;3239 3236 HDPA hdpaSubItems; 3240 BOOL bResult = FALSE; 3241 3242 // TRACE(listview, "(hwnd=%x,lpLVItem=%p)\n", hwnd, lpLVItem); 3237 3238 TRACE("(hwnd=%x, lpLVItem=%p)\n", hwnd, lpLVItem); 3243 3239 3244 3240 if (lpLVItem != NULL) … … 3246 3242 if ((lpLVItem->iItem >= 0) && (lpLVItem->iItem < GETITEMCOUNT(infoPtr))) 3247 3243 { 3244 ZeroMemory(&dispInfo, sizeof(NMLVDISPINFOA)); 3248 3245 hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, lpLVItem->iItem); 3249 3246 if (hdpaSubItems != NULL) 3250 3247 { 3251 if (lpLVItem->iSubItem == 0) 3252 { 3253 lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0); 3254 if (lpItem != NULL) 3248 lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0); 3249 if (lpItem != NULL) 3250 { 3251 bResult = TRUE; 3252 if (lpLVItem->iSubItem == 0) 3255 3253 { 3256 bResult = TRUE; 3257 3258 /* retrieve valid data */ 3259 if (lpLVItem->mask & LVIF_STATE) 3254 if ((lpItem->iImage == I_IMAGECALLBACK) && 3255 (lpLVItem->mask & LVIF_IMAGE)) 3256 { 3257 dispInfo.item.mask |= LVIF_IMAGE; 3258 } 3259 3260 if ((lpItem->pszText == LPSTR_TEXTCALLBACKA) && 3261 (lpLVItem->mask & LVIF_TEXT)) 3262 { 3263 dispInfo.item.mask |= LVIF_TEXT; 3264 ZeroMemory(lpLVItem->pszText, sizeof(CHAR)*lpLVItem->cchTextMax); 3265 dispInfo.item.pszText = lpLVItem->pszText; 3266 dispInfo.item.cchTextMax = lpLVItem->cchTextMax; 3267 } 3268 3269 if ((infoPtr->uCallbackMask != 0) && (lpLVItem->mask & LVIF_STATE)) 3270 { 3271 dispInfo.item.mask |= LVIF_STATE; 3272 dispInfo.item.stateMask = infoPtr->uCallbackMask; 3273 } 3274 3275 if (dispInfo.item.mask != 0) 3276 { 3277 dispInfo.hdr.hwndFrom = hwnd; 3278 dispInfo.hdr.idFrom = lCtrlId; 3279 dispInfo.hdr.code = LVN_GETDISPINFOA; 3280 dispInfo.item.iItem = lpLVItem->iItem; 3281 dispInfo.item.iSubItem = 0; 3282 dispInfo.item.lParam = lpItem->lParam; 3283 ListView_Notify(GetParent(hwnd), lCtrlId, &dispInfo); 3284 } 3285 3286 if (dispInfo.item.mask & LVIF_IMAGE) 3287 { 3288 lpLVItem->iImage = dispInfo.item.iImage; 3289 } 3290 else if (lpLVItem->mask & LVIF_IMAGE) 3291 { 3292 lpLVItem->iImage = lpItem->iImage; 3293 } 3294 3295 if (dispInfo.item.mask & LVIF_TEXT) 3296 { 3297 if (dispInfo.item.mask & LVIF_DI_SETITEM) 3298 { 3299 Str_SetPtrA(&lpItem->pszText, dispInfo.item.pszText); 3300 } 3301 lpLVItem->pszText = dispInfo.item.pszText; 3302 } 3303 else if (lpLVItem->mask & LVIF_TEXT) 3304 { 3305 lpLVItem->pszText = lpItem->pszText; 3306 } 3307 3308 if (dispInfo.item.mask & LVIF_STATE) 3309 { 3310 lpLVItem->state = lpItem->state; 3311 lpLVItem->state &= ~dispInfo.item.stateMask; 3312 lpLVItem->state |= (dispInfo.item.state & 3313 dispInfo.item.stateMask); 3314 } 3315 else if (lpLVItem->mask & LVIF_STATE) 3260 3316 { 3261 3317 lpLVItem->state = lpItem->state & lpLVItem->stateMask; 3262 3318 } 3263 3319 3264 if (lpLVItem->mask & LVIF_TEXT)3265 {3266 if (lpItem->pszText == LPSTR_TEXTCALLBACKA)3267 {3268 lpLVItem->pszText = LPSTR_TEXTCALLBACKA;3269 }3270 else3271 {3272 bResult = Str_GetPtrA(lpItem->pszText, lpLVItem->pszText,3273 lpLVItem->cchTextMax);3274 }3275 }3276 3277 if (lpLVItem->mask & LVIF_IMAGE)3278 {3279 lpLVItem->iImage = lpItem->iImage;3280 }3281 3282 3320 if (lpLVItem->mask & LVIF_PARAM) 3283 3321 { 3284 3322 lpLVItem->lParam = lpItem->lParam; 3285 3323 } 3286 3324 3287 3325 if (lpLVItem->mask & LVIF_INDENT) 3288 3326 { … … 3290 3328 } 3291 3329 } 3292 } 3293 else 3294 { 3295 lpSubItem = (LISTVIEW_SUBITEM *)DPA_GetPtr(hdpaSubItems, 3296 lpLVItem->iSubItem); 3297 if (lpSubItem != NULL) 3330 else 3298 3331 { 3299 bResult = TRUE;3300 3301 if (lp LVItem->mask & LVIF_TEXT)3332 lpSubItem = LISTVIEW_GetSubItemPtr(hdpaSubItems, 3333 lpLVItem->iSubItem); 3334 if (lpSubItem != NULL) 3302 3335 { 3303 if (lpSubItem->pszText == LPSTR_TEXTCALLBACKA) 3336 if ((lpSubItem->iImage == I_IMAGECALLBACK) && 3337 (lpLVItem->mask & LVIF_IMAGE)) 3304 3338 { 3305 lpLVItem->pszText = LPSTR_TEXTCALLBACKA;3339 dispInfo.item.mask |= LVIF_IMAGE; 3306 3340 } 3307 else 3341 3342 if ((lpSubItem->pszText == LPSTR_TEXTCALLBACKA) && 3343 (lpLVItem->mask & LVIF_TEXT)) 3308 3344 { 3309 bResult = Str_GetPtrA(lpSubItem->pszText, lpLVItem->pszText, 3310 lpLVItem->cchTextMax); 3345 dispInfo.item.mask |= LVIF_TEXT; 3346 ZeroMemory(lpLVItem->pszText, 3347 sizeof(CHAR)*lpLVItem->cchTextMax); 3348 dispInfo.item.pszText = lpLVItem->pszText; 3349 dispInfo.item.cchTextMax = lpLVItem->cchTextMax; 3311 3350 } 3312 3351 } 3313 3314 if (lpLVItem->mask & LVIF_IMAGE) 3352 else 3315 3353 { 3316 lpLVItem->iImage = lpSubItem->iImage; 3354 if (lpLVItem->mask & LVIF_IMAGE) 3355 { 3356 dispInfo.item.mask |= LVIF_IMAGE; 3357 } 3358 3359 if (lpLVItem->mask & LVIF_TEXT) 3360 { 3361 dispInfo.item.mask |= LVIF_TEXT; 3362 ZeroMemory(lpLVItem->pszText, 3363 sizeof(CHAR)*lpLVItem->cchTextMax); 3364 dispInfo.item.pszText = lpLVItem->pszText; 3365 dispInfo.item.cchTextMax = lpLVItem->cchTextMax; 3366 } 3367 } 3368 3369 if (dispInfo.item.mask != 0) 3370 { 3371 dispInfo.hdr.hwndFrom = hwnd; 3372 dispInfo.hdr.idFrom = lCtrlId; 3373 dispInfo.hdr.code = LVN_GETDISPINFOA; 3374 dispInfo.item.iItem = lpLVItem->iItem; 3375 dispInfo.item.iSubItem = lpLVItem->iSubItem; 3376 dispInfo.item.lParam = lpItem->lParam; 3377 ListView_Notify(GetParent(hwnd), lCtrlId, &dispInfo); 3378 } 3379 3380 if (dispInfo.item.mask & LVIF_IMAGE) 3381 { 3382 lpLVItem->iImage = dispInfo.item.iImage; 3383 } 3384 else if (lpLVItem->mask & LVIF_IMAGE) 3385 { 3386 lpLVItem->iImage = lpItem->iImage; 3387 } 3388 3389 if (dispInfo.item.mask & LVIF_TEXT) 3390 { 3391 if (dispInfo.item.mask & LVIF_DI_SETITEM) 3392 { 3393 Str_SetPtrA(&lpItem->pszText, dispInfo.item.pszText); 3394 } 3395 lpLVItem->pszText = dispInfo.item.pszText; 3396 } 3397 else if (lpLVItem->mask & LVIF_TEXT) 3398 { 3399 lpLVItem->pszText = lpItem->pszText; 3317 3400 } 3318 3401 } … … 3364 3447 { 3365 3448 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 3366 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);3449 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 3367 3450 BOOL bResult = FALSE; 3368 3451 HDPA hdpaSubItems; 3369 3452 LISTVIEW_ITEM *lpItem; 3453 INT nCountPerColumn; 3370 3454 INT nRow; 3371 3455 3372 // TRACE(listview,"(hwnd=%x,nItem=%d,lpptPosition=%p)\n", hwnd, nItem,3373 //lpptPosition);3456 TRACE("(hwnd=%x,nItem=%d,lpptPosition=%p)\n", hwnd, nItem, 3457 lpptPosition); 3374 3458 3375 3459 if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr)) && 3376 3460 (lpptPosition != NULL)) 3377 3461 { 3378 switch (LVS_TYPEMASK & lStyle) 3379 { 3380 case LVS_LIST: 3462 if (uView == LVS_LIST) 3463 { 3381 3464 bResult = TRUE; 3382 3465 nItem = nItem - ListView_GetTopIndex(hwnd); 3466 nCountPerColumn = LISTVIEW_GetCountPerColumn(hwnd); 3383 3467 if (nItem < 0) 3384 3468 { 3385 nRow = nItem % infoPtr->nCountPerColumn;3469 nRow = nItem % nCountPerColumn; 3386 3470 if (nRow == 0) 3387 3471 { 3388 lpptPosition->x = (nItem / infoPtr->nCountPerColumn * 3389 infoPtr->nItemWidth); 3472 lpptPosition->x = nItem / nCountPerColumn * infoPtr->nItemWidth; 3390 3473 lpptPosition->y = 0; 3391 3474 } 3392 3475 else 3393 3476 { 3394 lpptPosition->x = ((nItem / infoPtr->nCountPerColumn - 1) * 3395 infoPtr->nItemWidth); 3396 lpptPosition->y = ((nRow + infoPtr->nCountPerColumn) * 3397 infoPtr->nItemHeight); 3477 lpptPosition->x = (nItem / nCountPerColumn -1) * infoPtr->nItemWidth; 3478 lpptPosition->y = (nRow + nCountPerColumn) * infoPtr->nItemHeight; 3398 3479 } 3399 3480 } 3400 3481 else 3401 3482 { 3402 lpptPosition->x = (nItem / infoPtr->nCountPerColumn * 3403 infoPtr->nItemWidth); 3404 lpptPosition->y = (nItem % infoPtr->nCountPerColumn * 3405 infoPtr->nItemHeight); 3406 } 3407 break; 3408 3409 case LVS_REPORT: 3483 lpptPosition->x = nItem / nCountPerColumn * infoPtr->nItemWidth; 3484 lpptPosition->y = nItem % nCountPerColumn * infoPtr->nItemHeight; 3485 } 3486 } 3487 else if (uView == LVS_REPORT) 3488 { 3410 3489 bResult = TRUE; 3411 3490 lpptPosition->x = REPORT_MARGINX; 3412 3491 lpptPosition->y = ((nItem - ListView_GetTopIndex(hwnd)) * 3413 3492 infoPtr->nItemHeight) + infoPtr->rcList.top; 3414 break; 3415 3416 case LVS_SMALLICON: 3417 case LVS_ICON: 3493 } 3494 else 3495 { 3418 3496 hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, nItem); 3419 3497 if (hdpaSubItems != NULL) … … 3427 3505 } 3428 3506 } 3429 break;3430 3507 } 3431 3508 } … … 3450 3527 { 3451 3528 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 3452 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);3529 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 3453 3530 BOOL bResult = FALSE; 3454 3531 POINT ptOrigin; … … 3460 3537 TEXTMETRICA tm; 3461 3538 3462 // TRACE(listview, "(hwnd=%x,nItem=%d,lprc=%p)\n", hwnd, nItem, lprc);3463 3539 TRACE("(hwnd=%x, nItem=%d, lprc=%p)\n", hwnd, nItem, lprc); 3540 3464 3541 if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr)) && (lprc != NULL)) 3465 3542 { … … 3469 3546 { 3470 3547 case LVIR_ICON: 3471 switch (LVS_TYPEMASK & lStyle) 3472 { 3473 case LVS_ICON: 3548 if (uView == LVS_ICON) 3549 { 3474 3550 if (infoPtr->himlNormal != NULL) 3475 3551 { … … 3484 3560 } 3485 3561 } 3486 break;3487 3488 case LVS_SMALLICON:3562 } 3563 else if (uView == LVS_SMALLICON) 3564 { 3489 3565 if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE) 3490 3566 { … … 3495 3571 3496 3572 if (infoPtr->himlState != NULL) 3497 {3498 3573 lprc->left += infoPtr->iconSize.cx; 3499 }3500 3574 3501 3575 if (infoPtr->himlSmall != NULL) 3502 {3503 3576 lprc->right = lprc->left + infoPtr->iconSize.cx; 3504 }3505 3577 else 3506 {3507 3578 lprc->right = lprc->left; 3508 }3509 3579 } 3510 break; 3511 3512 case LVS_REPORT: 3513 case LVS_LIST: 3580 } 3581 else 3582 { 3514 3583 bResult = TRUE; 3515 3584 lprc->left = ptItem.x; … … 3530 3599 lprc->right = lprc->left; 3531 3600 } 3532 break;3533 3601 } 3534 3602 break; 3535 3603 3536 3604 case LVIR_LABEL: 3537 switch (LVS_TYPEMASK & lStyle) 3538 { 3539 case LVS_ICON: 3605 if (uView == LVS_ICON) 3606 { 3540 3607 if (infoPtr->himlNormal != NULL) 3541 3608 { … … 3566 3633 } 3567 3634 } 3568 break;3569 3570 case LVS_SMALLICON:3635 } 3636 else if (uView == LVS_SMALLICON) 3637 { 3571 3638 if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE) 3572 3639 { … … 3596 3663 } 3597 3664 } 3598 break; 3599 3600 case LVS_REPORT: 3601 case LVS_LIST: 3665 } 3666 else 3667 { 3602 3668 bResult = TRUE; 3603 3669 lprc->left = ptItem.x; … … 3616 3682 3617 3683 lprc->right = lprc->left + LISTVIEW_GetLabelWidth(hwnd, nItem); 3618 break;3619 3684 } 3620 3685 break; 3621 3686 3622 3687 case LVIR_BOUNDS: 3623 switch (LVS_TYPEMASK & lStyle) 3624 { 3625 case LVS_ICON: 3688 if (uView == LVS_ICON) 3689 { 3626 3690 if (infoPtr->himlNormal != NULL) 3627 3691 { … … 3635 3699 } 3636 3700 } 3637 break;3638 3639 case LVS_SMALLICON:3701 } 3702 else if (uView == LVS_SMALLICON) 3703 { 3640 3704 if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE) 3641 3705 { 3642 3706 bResult = TRUE; 3643 lprc->left = ptItem.x + ptOrigin.x;3707 lprc->left = ptItem.x + ptOrigin.x; 3644 3708 lprc->right = lprc->left; 3645 3709 lprc->top = ptItem.y + ptOrigin.y; 3646 3710 lprc->bottom = lprc->top + infoPtr->nItemHeight; 3647 3648 3711 if (infoPtr->himlState != NULL) 3649 {3650 3712 lprc->right += infoPtr->iconSize.cx; 3651 }3652 3653 3713 if (infoPtr->himlSmall != NULL) 3654 {3655 3714 lprc->right += infoPtr->iconSize.cx; 3656 }3657 3658 3715 lprc->right += LISTVIEW_GetLabelWidth(hwnd, nItem); 3659 3716 } 3660 break; 3661 3662 case LVS_REPORT: 3663 case LVS_LIST: 3717 } 3718 else 3719 { 3664 3720 bResult = TRUE; 3665 3721 lprc->left = ptItem.x; … … 3679 3735 3680 3736 lprc->right += LISTVIEW_GetLabelWidth(hwnd, nItem); 3681 break;3682 3737 } 3683 3738 break; 3684 3739 3685 3740 case LVIR_SELECTBOUNDS: 3686 switch (LVS_TYPEMASK & lStyle) 3687 { 3688 case LVS_ICON: 3741 if (uView == LVS_ICON) 3742 { 3689 3743 if (infoPtr->himlNormal != NULL) 3690 3744 { … … 3698 3752 } 3699 3753 } 3700 break;3701 3702 case LVS_SMALLICON:3754 } 3755 else if (uView == LVS_SMALLICON) 3756 { 3703 3757 if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE) 3704 3758 { … … 3722 3776 lprc->right += LISTVIEW_GetLabelWidth(hwnd, nItem); 3723 3777 } 3724 break; 3725 3726 case LVS_REPORT: 3727 case LVS_LIST: 3778 } 3779 else 3780 { 3728 3781 bResult = TRUE; 3729 3782 lprc->left = ptItem.x; … … 3744 3797 3745 3798 lprc->right += LISTVIEW_GetLabelWidth(hwnd, nItem); 3746 break;3747 3799 } 3748 3800 break; … … 3765 3817 * FAILURE : zero 3766 3818 */ 3767 3768 3819 static INT LISTVIEW_GetLabelWidth(HWND hwnd, INT nItem) 3769 3820 { 3770 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 3771 LISTVIEW_ITEM *lpItem; 3772 HDPA hdpaSubItems; 3821 CHAR szDispText[DISP_TEXT_SIZE]; 3773 3822 INT nLabelWidth = 0; 3774 3775 // TRACE(listview, "(hwnd=%x,nItem=%d)\n", hwnd, nItem); 3776 3777 hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, nItem); 3778 if (hdpaSubItems != NULL) 3779 { 3780 lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0); 3781 if (lpItem != NULL) 3782 { 3783 CHAR szDispText[DISP_TEXT_SIZE]; 3784 LPSTR pszDispText = NULL; 3785 pszDispText = szDispText; 3786 LISTVIEW_GetItemDispInfo(hwnd, nItem, lpItem, NULL, NULL, &pszDispText, 3787 DISP_TEXT_SIZE); 3788 nLabelWidth = ListView_GetStringWidthA(hwnd, pszDispText); 3789 } 3790 } 3791 3823 LVITEMA lvItem; 3824 3825 TRACE("(hwnd=%x, nItem=%d)\n", hwnd, nItem); 3826 3827 ZeroMemory(&lvItem, sizeof(LVITEMA)); 3828 lvItem.mask = LVIF_TEXT; 3829 lvItem.iItem = nItem; 3830 lvItem.cchTextMax = DISP_TEXT_SIZE; 3831 lvItem.pszText = szDispText; 3832 if (ListView_GetItemA(hwnd, &lvItem) != FALSE) 3833 { 3834 nLabelWidth = ListView_GetStringWidthA(hwnd, lvItem.pszText); 3835 } 3836 3792 3837 return nLabelWidth; 3793 3838 } … … 3865 3910 * 3866 3911 * RETURN: 3867 * None 3912 * SUCCESS : string length 3913 * FAILURE : 0 3868 3914 */ 3869 3915 static LRESULT LISTVIEW_GetItemTextA(HWND hwnd, INT nItem, LPLVITEMA lpLVItem) 3870 3916 { 3871 3917 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 3872 LISTVIEW_ITEM *lpItem;3873 LISTVIEW_SUBITEM *lpSubItem;3874 HDPA hdpaSubItems;3875 3918 INT nLength = 0; 3876 3919 … … 3879 3922 if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr))) 3880 3923 { 3881 hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, lpLVItem->iItem); 3882 if (hdpaSubItems != NULL) 3883 { 3884 if (lpLVItem->iSubItem == 0) 3885 { 3886 lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0); 3887 if (lpItem != NULL) 3888 { 3889 if (lpLVItem->mask & LVIF_TEXT) 3890 { 3891 if (lpItem->pszText == LPSTR_TEXTCALLBACKA) 3892 { 3893 lpLVItem->pszText = LPSTR_TEXTCALLBACKA; 3894 } 3895 else 3896 { 3897 nLength = Str_GetPtrA(lpItem->pszText, lpLVItem->pszText, 3898 lpLVItem->cchTextMax); 3899 } 3900 } 3901 } 3902 } 3903 else 3904 { 3905 lpSubItem = (LISTVIEW_SUBITEM *)DPA_GetPtr(hdpaSubItems, 3906 lpLVItem->iSubItem); 3907 if (lpSubItem != NULL) 3908 { 3909 if (lpLVItem->mask & LVIF_TEXT) 3910 { 3911 if (lpSubItem->pszText == LPSTR_TEXTCALLBACKA) 3912 { 3913 lpLVItem->pszText = LPSTR_TEXTCALLBACKA; 3914 } 3915 else 3916 { 3917 nLength = Str_GetPtrA(lpSubItem->pszText, lpLVItem->pszText, 3918 lpLVItem->cchTextMax); 3919 } 3920 } 3921 } 3922 } 3924 lpLVItem->mask = LVIF_TEXT; 3925 lpLVItem->iItem = nItem; 3926 if (ListView_GetItemA(hwnd, lpLVItem) != FALSE) 3927 { 3928 nLength = lstrlenA(lpLVItem->pszText); 3923 3929 } 3924 3930 } … … 3934 3940 * PARAMETER(S): 3935 3941 * [I] HWND : window handle 3936 * [I] INT : starting searchitem index3937 * [I] UINT : relationship flag3942 * [I] INT : item index 3943 * [I] INT : relationship flag 3938 3944 * 3939 3945 * RETURN: … … 3941 3947 * FAILURE : -1 3942 3948 */ 3943 static LRESULT LISTVIEW_GetNextItem(HWND hwnd, INT iStart, UINT uFlags) 3944 { 3945 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongA(hwnd, 0); 3946 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 3947 LISTVIEW_ITEM *lpItem; 3948 UINT style_mask = LVS_TYPEMASK & lStyle; 3949 static LRESULT LISTVIEW_GetNextItem(HWND hwnd, INT nItem, UINT uFlags) 3950 { 3951 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 3952 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 3949 3953 UINT uMask = 0; 3950 INT nItems = GETITEMCOUNT(infoPtr); 3951 INT iIndex = iStart; 3952 INT eIndex = nItems - 1; 3953 INT sIndex = 0; 3954 INT delta = 1; 3954 LVFINDINFO lvFindInfo; 3955 INT nCountPerColumn; 3956 INT i; 3955 3957 3956 INT nCountPerColumn = max((infoPtr->rcList.bottom - infoPtr->rcList.top) / 3957 infoPtr->nItemHeight, 1); 3958 INT nCountPerRow = max((infoPtr->rcList.right - infoPtr->rcList.left) / 3959 infoPtr->nItemWidth, 1); 3960 3961 if(uFlags & LVNI_ABOVE) /* moving upwards from iStart */ 3962 { 3963 if(style_mask == LVS_LIST || style_mask == LVS_REPORT) 3964 delta = -1; 3958 if ((nItem >= -1) && (nItem < GETITEMCOUNT(infoPtr))) 3959 { 3960 ZeroMemory(&lvFindInfo, sizeof(LVFINDINFO)); 3961 3962 if (uFlags & LVNI_CUT) 3963 uMask |= LVIS_CUT; 3964 3965 if (uFlags & LVNI_DROPHILITED) 3966 uMask |= LVIS_DROPHILITED; 3967 3968 if (uFlags & LVNI_FOCUSED) 3969 uMask |= LVIS_FOCUSED; 3970 3971 if (uFlags & LVNI_SELECTED) 3972 uMask |= LVIS_SELECTED; 3973 3974 if (uFlags & LVNI_ABOVE) 3975 { 3976 if ((uView == LVS_LIST) || (uView == LVS_REPORT)) 3977 { 3978 while (nItem >= 0) 3979 { 3980 nItem--; 3981 if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask) 3982 return nItem; 3983 } 3984 } 3985 else 3986 { 3987 lvFindInfo.flags = LVFI_NEARESTXY; 3988 lvFindInfo.vkDirection = VK_UP; 3989 ListView_GetItemPosition(hwnd, nItem, &lvFindInfo.pt); 3990 while ((nItem = LISTVIEW_FindItem(hwnd, nItem, &lvFindInfo)) != -1) 3991 { 3992 if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask) 3993 return nItem; 3994 } 3995 } 3996 } 3997 else if (uFlags & LVNI_BELOW) 3998 { 3999 if ((uView == LVS_LIST) || (uView == LVS_REPORT)) 4000 { 4001 while (nItem < GETITEMCOUNT(infoPtr)) 4002 { 4003 nItem++; 4004 if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask) 4005 return nItem; 4006 } 4007 } 4008 else 4009 { 4010 lvFindInfo.flags = LVFI_NEARESTXY; 4011 lvFindInfo.vkDirection = VK_DOWN; 4012 ListView_GetItemPosition(hwnd, nItem, &lvFindInfo.pt); 4013 while ((nItem = LISTVIEW_FindItem(hwnd, nItem, &lvFindInfo)) != -1) 4014 { 4015 if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask) 4016 return nItem; 4017 } 4018 } 4019 } 4020 else if (uFlags & LVNI_TOLEFT) 4021 { 4022 if (uView == LVS_LIST) 4023 { 4024 nCountPerColumn = LISTVIEW_GetCountPerColumn(hwnd); 4025 while (nItem - nCountPerColumn >= 0) 4026 { 4027 nItem -= nCountPerColumn; 4028 if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask) 4029 return nItem; 4030 } 4031 } 4032 else if ((uView == LVS_SMALLICON) || (uView == LVS_ICON)) 4033 { 4034 lvFindInfo.flags = LVFI_NEARESTXY; 4035 lvFindInfo.vkDirection = VK_LEFT; 4036 ListView_GetItemPosition(hwnd, nItem, &lvFindInfo.pt); 4037 while ((nItem = LISTVIEW_FindItem(hwnd, nItem, &lvFindInfo)) != -1) 4038 { 4039 if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask) 4040 return nItem; 4041 } 4042 } 4043 } 4044 else if (uFlags & LVNI_TORIGHT) 4045 { 4046 if (uView == LVS_LIST) 4047 { 4048 nCountPerColumn = LISTVIEW_GetCountPerColumn(hwnd); 4049 while (nItem + nCountPerColumn < GETITEMCOUNT(infoPtr)) 4050 { 4051 nItem += nCountPerColumn; 4052 if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask) 4053 return nItem; 4054 } 4055 } 4056 else if ((uView == LVS_SMALLICON) || (uView == LVS_ICON)) 4057 { 4058 lvFindInfo.flags = LVFI_NEARESTXY; 4059 lvFindInfo.vkDirection = VK_RIGHT; 4060 ListView_GetItemPosition(hwnd, nItem, &lvFindInfo.pt); 4061 while ((nItem = LISTVIEW_FindItem(hwnd, nItem, &lvFindInfo)) != -1) 4062 { 4063 if ((ListView_GetItemState(hwnd, nItem, uMask) & uMask) == uMask) 4064 return nItem; 4065 } 4066 } 4067 } 3965 4068 else 3966 4069 { 3967 if(lStyle & LVS_ALIGNLEFT) 3968 { 3969 sIndex = iStart - (iStart % nCountPerColumn); 3970 delta = -1; 3971 } 3972 else 3973 delta = -nCountPerRow; 3974 } 3975 } 3976 else if(uFlags & LVNI_BELOW) /* moving downwards from iStart */ 3977 { 3978 if(style_mask == LVS_SMALLICON || style_mask == LVS_ICON) 3979 { 3980 if (lStyle & LVS_ALIGNLEFT) 3981 eIndex = iStart + (nCountPerColumn - (iStart % nCountPerColumn) - 1); 3982 else 3983 delta = nCountPerRow; 3984 } 3985 } 3986 else if(uFlags & LVNI_TOLEFT) /* moving to the left of iStart */ 3987 { 3988 if(style_mask == LVS_LIST) 3989 delta = -infoPtr->nCountPerColumn; 3990 else if(style_mask == LVS_SMALLICON || style_mask == LVS_ICON) 3991 { 3992 if(style_mask & LVS_ALIGNLEFT) 3993 delta = -nCountPerColumn; 3994 else 3995 { 3996 sIndex = iStart - (iStart % nCountPerRow); 3997 delta = -1; 3998 } 3999 } 4000 else if(style_mask == LVS_REPORT) 4001 return -1; 4002 } 4003 else if(uFlags & LVNI_TORIGHT) /* moving to the right of iStart */ 4004 { 4005 if(style_mask == LVS_LIST) 4006 delta = infoPtr->nCountPerColumn; 4007 else if(style_mask == LVS_ICON || style_mask == LVS_SMALLICON) 4008 { 4009 if(lStyle & LVS_ALIGNLEFT) 4010 delta = nCountPerColumn; 4011 else 4012 eIndex = iStart + (nCountPerRow - (iStart % nCountPerRow) - 1); 4013 } 4014 else if(style_mask == LVS_REPORT) 4015 return -1; 4016 } 4017 4018 /* perform come bounds checking before entering the main loop */ 4019 if(sIndex < 0) sIndex = 0; 4020 if(eIndex > (nItems - 1)) eIndex = (nItems - 1); 4021 4022 /* build uMask, the mask we are searching for */ 4023 if(uFlags & LVNI_CUT) uMask|=LVIS_CUT; 4024 if(uFlags & LVNI_DROPHILITED) uMask|=LVIS_DROPHILITED; 4025 if(uFlags & LVNI_FOCUSED) uMask|=LVIS_FOCUSED; 4026 if(uFlags & LVNI_SELECTED) uMask|=LVIS_SELECTED; 4027 4028 while(TRUE) /* searching loop */ 4029 { 4030 iIndex+=delta; 4031 4032 if((iIndex < sIndex) || (iIndex > eIndex)) 4033 break; 4034 4035 /* see if flags match */ 4036 if(!uMask || (LISTVIEW_GetItemState(hwnd, iIndex, uMask) == uMask)) 4037 return iIndex; 4038 } 4070 nItem++; 4071 4072 /* search by index */ 4073 for (i = nItem; i < GETITEMCOUNT(infoPtr); i++) 4074 { 4075 if ((ListView_GetItemState(hwnd, i, uMask) & uMask) == uMask) 4076 return i; 4077 } 4078 } 4079 } 4080 4039 4081 return -1; 4040 4082 } … … 4058 4100 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 4059 4101 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 4102 UINT uView = lStyle & LVS_TYPEMASK; 4060 4103 INT nListWidth = infoPtr->rcList.right - infoPtr->rcList.left; 4061 4104 INT nListHeight = infoPtr->rcList.bottom - infoPtr->rcList.top; 4062 4105 BOOL bResult = FALSE; 4063 4064 // TRACE(listview, "(hwnd=%x,lpptOrigin=%p)\n", hwnd, lpptOrigin);4065 4066 switch (LVS_TYPEMASK & lStyle)4067 {4068 case LVS_ICON:4069 case LVS_SMALLICON:4070 if ((lStyle & WS_HSCROLL) != 0)4071 {4072 lpptOrigin->x = -GetScrollPos(hwnd, SB_HORZ) * nListWidth / 10;4073 }4074 else4075 {4076 lpptOrigin->x = 0;4077 }4078 4079 if ((lStyle & WS_VSCROLL) != 0)4080 {4081 lpptOrigin->y = -GetScrollPos(hwnd, SB_VERT) * nListHeight / 10;4082 }4083 else4084 {4085 lpptOrigin->y = 0;4086 }4087 4106 4107 TRACE("(hwnd=%x, lpptOrigin=%p)\n", hwnd, lpptOrigin); 4108 4109 if ((uView == LVS_SMALLICON) || (uView == LVS_ICON)) 4110 { 4111 SCROLLINFO scrollInfo; 4112 ZeroMemory(lpptOrigin, sizeof(POINT)); 4113 ZeroMemory(&scrollInfo, sizeof(SCROLLINFO)); 4114 scrollInfo.cbSize = sizeof(SCROLLINFO); 4115 4116 if (lStyle & WS_HSCROLL) 4117 { 4118 scrollInfo.fMask = SIF_POS; 4119 if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) != FALSE) 4120 { 4121 lpptOrigin->x = -scrollInfo.nPos * max(nListWidth / 10, 1); 4122 } 4123 } 4124 4125 if (lStyle & WS_VSCROLL) 4126 { 4127 scrollInfo.fMask = SIF_POS; 4128 if (GetScrollInfo(hwnd, SB_VERT, &scrollInfo) != FALSE) 4129 { 4130 lpptOrigin->y = -scrollInfo.nPos * max(nListHeight / 10, 1); 4131 } 4132 } 4133 4088 4134 bResult = TRUE; 4089 break; 4090 } 4091 4135 } 4136 4092 4137 return bResult; 4093 4138 } … … 4116 4161 } 4117 4162 } 4118 4163 4119 4164 return nSelectedCount; 4120 4165 } … … 4205 4250 /*** 4206 4251 * DESCRIPTION: 4207 * Set the bounding rectangle of all the items.4208 *4209 * PARAMETER(S):4210 * [I] HWND : window handle4211 * [I] LPRECT : bounding rectangle4212 *4213 * RETURN:4214 * SUCCESS : TRUE4215 * FAILURE : FALSE4216 */4217 static LRESULT LISTVIEW_SetViewRect(HWND hwnd, LPRECT lprcView)4218 {4219 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongA(hwnd, 0);4220 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);4221 BOOL bResult = FALSE;4222 4223 // TRACE(listview, "(hwnd=%x,lprcView->left=%d,lprcView->top=%d,lprcView->right=%d,lprcView->bottom=%d)\n", hwnd, lprcView->left, lprcView->top, lprcView->right, lprcView->bottom);4224 4225 if (lprcView != NULL)4226 {4227 switch (lStyle & LVS_TYPEMASK)4228 {4229 case LVS_ICON:4230 case LVS_SMALLICON:4231 bResult = TRUE;4232 infoPtr->rcView.left = lprcView->left;4233 infoPtr->rcView.top = lprcView->top;4234 infoPtr->rcView.right = lprcView->right;4235 infoPtr->rcView.bottom = lprcView->bottom;4236 break;4237 }4238 }4239 4240 return bResult;4241 }4242 4243 /***4244 * DESCRIPTION:4245 * Retrieves the bounding rectangle of all the items.4246 *4247 * PARAMETER(S):4248 * [I] HWND : window handle4249 * [O] LPRECT : bounding rectangle4250 *4251 * RETURN:4252 * SUCCESS : TRUE4253 * FAILURE : FALSE4254 */4255 static LRESULT LISTVIEW_GetViewRect(HWND hwnd, LPRECT lprcView)4256 {4257 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongA(hwnd, 0);4258 BOOL bResult = FALSE;4259 POINT ptOrigin;4260 4261 // TRACE(listview, "(hwnd=%x,lprcView=%p)\n", hwnd, lprcView);4262 4263 if (lprcView != NULL)4264 {4265 bResult = LISTVIEW_GetOrigin(hwnd, &ptOrigin);4266 if (bResult != FALSE)4267 {4268 lprcView->left = infoPtr->rcView.left + ptOrigin.x;4269 lprcView->top = infoPtr->rcView.top + ptOrigin.y;4270 lprcView->right = infoPtr->rcView.right + ptOrigin.x;4271 lprcView->bottom = infoPtr->rcView.bottom + ptOrigin.y;4272 }4273 4274 // TRACE(listview, "(lprcView->left=%d,lprcView->top=%d,lprcView->right=%d,lprcView->bottom=%d)\n", lprcView->left, lprcView->top, lprcView->right, lprcView->bottom);4275 4276 }4277 4278 return bResult;4279 }4280 4281 /***4282 * DESCRIPTION:4283 4252 * Determines which section of the item was selected (if any). 4284 4253 * … … 4296 4265 RECT rcItem; 4297 4266 INT i; 4267 4268 TRACE("(hwnd=%x, x=%ld, y=%ld)\n", hwnd, lpHitTestInfo->pt.x, 4269 lpHitTestInfo->pt.y); 4298 4270 4299 4271 for (i = 0; i < GETITEMCOUNT(infoPtr); i++) … … 4302 4274 if (LISTVIEW_GetItemRect(hwnd, i, &rcItem) != FALSE) 4303 4275 { 4304 rcItem.left = LVIR_ICON; 4305 if (LISTVIEW_GetItemRect(hwnd, i, &rcItem) != FALSE) 4306 { 4307 if ((lpHitTestInfo->pt.x >= rcItem.left) && 4308 (lpHitTestInfo->pt.x <= rcItem.right) && 4309 (lpHitTestInfo->pt.y >= rcItem.top) && 4310 (lpHitTestInfo->pt.y <= rcItem.bottom)) 4311 { 4312 lpHitTestInfo->flags = LVHT_ONITEMICON | LVHT_ONITEM; 4313 lpHitTestInfo->iItem = i; 4314 lpHitTestInfo->iSubItem = 0; 4315 return i; 4316 } 4317 } 4276 if (PtInRect(&rcItem, lpHitTestInfo->pt) != FALSE) 4277 { 4278 rcItem.left = LVIR_ICON; 4279 if (LISTVIEW_GetItemRect(hwnd, i, &rcItem) != FALSE) 4280 { 4281 if (PtInRect(&rcItem, lpHitTestInfo->pt) != FALSE) 4282 { 4283 lpHitTestInfo->flags = LVHT_ONITEMICON; 4284 lpHitTestInfo->iItem = i; 4285 lpHitTestInfo->iSubItem = 0; 4286 return i; 4287 } 4288 } 4318 4289 4319 rcItem.left = LVIR_LABEL; 4320 if (LISTVIEW_GetItemRect(hwnd, i, &rcItem) != FALSE) 4321 { 4322 if ((lpHitTestInfo->pt.x >= rcItem.left) && 4323 (lpHitTestInfo->pt.x <= rcItem.right) && 4324 (lpHitTestInfo->pt.y >= rcItem.top) && 4325 (lpHitTestInfo->pt.y <= rcItem.bottom)) 4326 { 4327 lpHitTestInfo->flags = LVHT_ONITEMLABEL | LVHT_ONITEM; 4328 lpHitTestInfo->iItem = i; 4329 lpHitTestInfo->iSubItem = 0; 4330 return i; 4331 } 4332 } 4333 4334 lpHitTestInfo->flags = LVHT_ONITEMSTATEICON | LVHT_ONITEM; 4335 lpHitTestInfo->iItem = i; 4336 lpHitTestInfo->iSubItem = 0; 4337 return i; 4290 rcItem.left = LVIR_LABEL; 4291 if (LISTVIEW_GetItemRect(hwnd, i, &rcItem) != FALSE) 4292 { 4293 if (PtInRect(&rcItem, lpHitTestInfo->pt) != FALSE) 4294 { 4295 lpHitTestInfo->flags = LVHT_ONITEMLABEL; 4296 lpHitTestInfo->iItem = i; 4297 lpHitTestInfo->iSubItem = 0; 4298 return i; 4299 } 4300 } 4301 4302 lpHitTestInfo->flags = LVHT_ONITEMSTATEICON; 4303 lpHitTestInfo->iItem = i; 4304 lpHitTestInfo->iSubItem = 0; 4305 return i; 4306 } 4338 4307 } 4339 4308 } … … 4346 4315 /*** 4347 4316 * DESCRIPTION: 4348 * Determines w ich listview item is located at the specified position.4317 * Determines which listview item is located at the specified position. 4349 4318 * 4350 4319 * PARAMETER(S): … … 4362 4331 4363 4332 lpHitTestInfo->flags = 0; 4333 4364 4334 if (infoPtr->rcList.left > lpHitTestInfo->pt.x) 4365 4335 { … … 4370 4340 lpHitTestInfo->flags = LVHT_TORIGHT; 4371 4341 } 4372 4373 4342 if (infoPtr->rcList.top > lpHitTestInfo->pt.y) 4374 4343 { 4375 4344 lpHitTestInfo->flags |= LVHT_ABOVE; 4376 } 4345 } 4377 4346 else if (infoPtr->rcList.bottom < lpHitTestInfo->pt.y) 4378 4347 { … … 4405 4374 { 4406 4375 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 4407 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);4408 4376 HDITEMA hdi; 4409 4377 INT nNewColumn = -1; 4410 4378 4411 // TRACE(listview,"(hwnd=%x,nColumn=%d,lpColumn=%p)\n",hwnd, nColumn, lpColumn); 4379 TRACE("(hwnd=%x, nColumn=%d, lpColumn=%p)\n",hwnd, nColumn, 4380 lpColumn); 4412 4381 4413 4382 if (lpColumn != NULL) … … 4490 4459 (WPARAM)nColumn, (LPARAM)&hdi); 4491 4460 4492 LISTVIEW_ SetScroll(hwnd, lStyle);4461 LISTVIEW_UpdateScroll(hwnd); 4493 4462 InvalidateRect(hwnd, NULL, FALSE); 4494 4463 } … … 4515 4484 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 4516 4485 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 4486 UINT uView = lStyle & LVS_TYPEMASK; 4517 4487 LONG lCtrlId = GetWindowLongA(hwnd, GWL_ID); 4518 4488 NMLISTVIEW nmlv; … … 4521 4491 LISTVIEW_ITEM *lpItem = NULL; 4522 4492 4523 // TRACE(listview,"(hwnd=%x,lpLVItem=%p)\n", hwnd, lpLVItem);4493 TRACE("(hwnd=%x,lpLVItem=%p)\n", hwnd, lpLVItem); 4524 4494 4525 4495 if (lpLVItem != NULL) … … 4564 4534 4565 4535 /* align items (set position of each item) */ 4566 switch (lStyle & LVS_TYPEMASK)4536 if ((uView == LVS_SMALLICON) || (uView == LVS_ICON)) 4567 4537 { 4568 case LVS_ICON:4569 case LVS_SMALLICON:4570 4538 if (lStyle & LVS_ALIGNLEFT) 4571 4539 { … … 4576 4544 LISTVIEW_AlignTop(hwnd); 4577 4545 } 4578 break;4579 4546 } 4580 4581 LISTVIEW_ SetScroll(hwnd, lStyle);4547 4548 LISTVIEW_UpdateScroll(hwnd); 4582 4549 /* refresh client area */ 4583 4550 InvalidateRect(hwnd, NULL, FALSE); … … 4803 4770 LONG lStyle; 4804 4771 4805 / * set column width only if in report mode */4772 // set column width only if in report mode 4806 4773 lStyle = GetWindowLongA(hwnd, GWL_STYLE); 4807 4774 if ((lStyle & LVS_TYPEMASK) != LVS_REPORT) 4808 4775 return (FALSE); 4809 4776 4810 / * make sure we can get the listview info */4777 // make sure we can get the listview info 4811 4778 if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0))) 4812 4779 return (FALSE); 4813 if (!infoPtr->hwndHeader) / * make sure we have a header */4780 if (!infoPtr->hwndHeader) // make sure we have a header 4814 4781 return (FALSE); 4815 4782 4816 /* 4817 * FIXME: currently ignoring LVSCW_AUTOSIZE (-1) and 4818 * LVSCV_AUTOSIZE_USEHEADER (-2) 4819 */ 4783 // FIXME: currently ignoring LVSCW_AUTOSIZE (-1) and 4784 // LVSCV_AUTOSIZE_USEHEADER (-2) 4820 4785 if (cx < 0) 4821 4786 return (FALSE); … … 4824 4789 hdi.cxy = cx; 4825 4790 4826 / * call header to update the column change */4791 // call header to update the column change 4827 4792 lret = Header_SetItemA(infoPtr->hwndHeader, (WPARAM)iCol, (LPARAM)&hdi); 4828 4793 4829 infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd , LVS_REPORT);4830 4831 InvalidateRect(hwnd, NULL, TRUE); / * force redraw of the listview */4794 infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd); 4795 4796 InvalidateRect(hwnd, NULL, TRUE); // force redraw of the listview 4832 4797 4833 4798 return lret; … … 4867 4832 himlTemp = infoPtr->himlState; 4868 4833 infoPtr->himlState = himl; 4834 ImageList_SetBkColor(infoPtr->himlState, CLR_NONE); 4869 4835 return (LRESULT)himlTemp; 4870 4836 } … … 4925 4891 static VOID LISTVIEW_SetItemCount(HWND hwnd, INT nItemCount) 4926 4892 { 4927 // FIXME (listview,"empty stub!\n");4893 FIXME("empty stub!\n"); 4928 4894 } 4929 4895 … … 4946 4912 { 4947 4913 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongA(hwnd, 0); 4948 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);4914 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 4949 4915 LISTVIEW_ITEM *lpItem; 4950 4916 HDPA hdpaSubItems; 4951 4917 BOOL bResult = FALSE; 4952 4918 4953 // TRACE(listview,"(hwnd=%x,nItem=%d,X=%d,Y=%d)\n", hwnd, nItem, nPosX, nPosY);4919 TRACE("(hwnd=%x,nItem=%d,X=%d,Y=%d)\n", hwnd, nItem, nPosX, nPosY); 4954 4920 4955 4921 if ((nItem >= 0) || (nItem < GETITEMCOUNT(infoPtr))) 4956 4922 { 4957 switch (lStyle & LVS_TYPEMASK) 4958 { 4959 case LVS_ICON: 4960 case LVS_SMALLICON: 4923 if ((uView == LVS_ICON) || (uView == LVS_SMALLICON)) 4924 { 4961 4925 hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, nItem); 4962 4926 if (hdpaSubItems != NULL) … … 4970 4934 } 4971 4935 } 4972 break;4973 4936 } 4974 4937 } … … 5003 4966 lvItem.mask = LVIF_STATE; 5004 4967 lvItem.state = lpLVItem->state; 5005 lvItem.stateMask = lpLVItem->stateMask ;4968 lvItem.stateMask = lpLVItem->stateMask ; 5006 4969 5007 4970 /* apply to all items */ … … 5104 5067 } 5105 5068 5069 5070 /*** 5071 * DESCRIPTION: 5072 * Callback internally used by LISTVIEW_SortItems() 5073 * 5074 * PARAMETER(S): 5075 * [I] LPVOID : first LISTVIEW_ITEM to compare 5076 * [I] LPVOID : second LISTVIEW_ITEM to compare 5077 * [I] LPARAM : HWND of control 5078 * 5079 * RETURN: 5080 * if first comes before second : negative 5081 * if first comes after second : positive 5082 * if first and second are equivalent : zero 5083 */ 5084 static INT WINAPI LISTVIEW_CallBackCompare( 5085 LPVOID first, 5086 LPVOID second, 5087 LPARAM lParam) 5088 { 5089 /* Forward the call to the client defined callback */ 5090 HWND hwnd = (HWND)lParam; 5091 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 5092 5093 return (infoPtr->pfnCompare)( 5094 ((LISTVIEW_ITEM *)first)->lParam, 5095 ((LISTVIEW_ITEM *)second)->lParam, 5096 infoPtr->lParamSort); 5097 } 5098 5106 5099 /*** 5107 5100 * DESCRIPTION: … … 5110 5103 * PARAMETER(S): 5111 5104 * [I] HWND : window handle 5105 * [I] WPARAM : application-defined value 5106 * [I] LPARAM : pointer to comparision callback 5112 5107 * 5113 5108 * RETURN: … … 5117 5112 static LRESULT LISTVIEW_SortItems(HWND hwnd, WPARAM wParam, LPARAM lParam) 5118 5113 { 5119 // FIXME (listview, "empty stub!\n"); 5120 5121 return TRUE; 5114 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 5115 HDPA hdpaSubItems; 5116 LISTVIEW_ITEM *lpItem; 5117 int nCount, i; 5118 HDPA sortList; 5119 5120 if (!infoPtr || !infoPtr->hdpaItems) 5121 return FALSE; 5122 5123 nCount = GETITEMCOUNT(infoPtr); 5124 // if there are 0 or 1 items, there is no need to sort 5125 if (nCount > 1) 5126 { 5127 sortList = DPA_Create(nCount); 5128 5129 infoPtr->pfnCompare = (PFNLVCOMPARE)lParam; 5130 infoPtr->lParamSort = (LPARAM)wParam; 5131 5132 // append pointers one by one to sortList 5133 for (i = 0; i < nCount; i++) 5134 { 5135 if ((hdpaSubItems = (HDPA) DPA_GetPtr(infoPtr->hdpaItems, i))) 5136 if ((lpItem = (LISTVIEW_ITEM *) DPA_GetPtr(hdpaSubItems, 0))) 5137 DPA_InsertPtr(sortList, nCount + 1, lpItem); 5138 } 5139 5140 // sort the sortList 5141 DPA_Sort(sortList, LISTVIEW_CallBackCompare, hwnd); 5142 5143 // copy the pointers back 5144 for (i = 0; i < nCount; i++) 5145 { 5146 if ((hdpaSubItems = (HDPA) DPA_GetPtr(infoPtr->hdpaItems, i)) && 5147 (lpItem = (LISTVIEW_ITEM *) DPA_GetPtr(sortList, i))) 5148 DPA_SetPtr(hdpaSubItems, 0, lpItem); 5149 } 5150 5151 DPA_Destroy(sortList); 5152 } 5153 5154 return TRUE; 5122 5155 } 5123 5156 … … 5156 5189 rc.left = LVIR_BOUNDS; 5157 5190 ListView_GetItemRect(hwnd, nItem, &rc); 5158 InvalidateRect(hwnd, &rc, FALSE);5191 InvalidateRect(hwnd, &rc, TRUE); 5159 5192 } 5160 5193 } … … 5177 5210 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 5178 5211 LPCREATESTRUCTA lpcs = (LPCREATESTRUCTA)lParam; 5212 UINT uView = lpcs->style & LVS_TYPEMASK; 5179 5213 LOGFONTA logFont; 5180 5214 … … 5187 5221 if (infoPtr->notifyFormat != NFR_ANSI) 5188 5222 { 5189 // FIXME (listview,"ANSI notify format is NOT used\n");5223 FIXME("ANSI notify format is NOT used\n"); 5190 5224 } 5191 5225 … … 5217 5251 SendMessageA(infoPtr->hwndHeader, WM_SETFONT, (WPARAM)infoPtr->hFont, 5218 5252 (LPARAM)TRUE); 5219 5220 5253 5221 switch (lpcs->style & LVS_TYPEMASK) 5222 { 5223 case LVS_ICON: 5254 if (uView == LVS_ICON) 5255 { 5224 5256 infoPtr->iconSize.cx = GetSystemMetrics(SM_CXICON); 5225 5257 infoPtr->iconSize.cy = GetSystemMetrics(SM_CYICON); 5226 break; 5227 5228 case LVS_REPORT: 5229 ShowWindow(infoPtr->hwndHeader, SW_SHOWNORMAL); 5230 case LVS_SMALLICON: 5231 case LVS_LIST: 5258 } 5259 else if (uView == LVS_REPORT) 5260 { 5261 if (!(LVS_NOCOLUMNHEADER & lpcs->style)) 5262 { 5263 ShowWindow(infoPtr->hwndHeader, SW_SHOWNORMAL); 5264 } 5265 5232 5266 infoPtr->iconSize.cx = GetSystemMetrics(SM_CXSMICON); 5233 5267 infoPtr->iconSize.cy = GetSystemMetrics(SM_CYSMICON); 5234 break; 5268 } 5269 else 5270 { 5271 infoPtr->iconSize.cx = GetSystemMetrics(SM_CXSMICON); 5272 infoPtr->iconSize.cy = GetSystemMetrics(SM_CYSMICON); 5235 5273 } 5236 5274 … … 5242 5280 5243 5281 /* initialize size of items */ 5244 infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd , lpcs->style);5245 infoPtr->nItemHeight = LISTVIEW_GetItemHeight(hwnd , lpcs->style);5282 infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd); 5283 infoPtr->nItemHeight = LISTVIEW_GetItemHeight(hwnd); 5246 5284 5247 5285 return 0; … … 5308 5346 * [I] HWND : window handle 5309 5347 * [I] INT : scroll code 5310 * [I] INT : scroll position 5348 * [I] SHORT : current scroll position if scroll code is SB_THIMBPOSITION 5349 * or SB_THUMBTRACK. 5311 5350 * [I] HWND : scrollbar control window handle 5312 5351 * … … 5314 5353 * Zero 5315 5354 */ 5316 static LRESULT LISTVIEW_VScroll(HWND hwnd, INT nScrollCode, INT nScroll,5355 static LRESULT LISTVIEW_VScroll(HWND hwnd, INT nScrollCode, SHORT nCurrentPos, 5317 5356 HWND hScrollWnd) 5318 5357 { 5319 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);5320 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);5321 INT nScrollPosInc = 0; 5322 INT nScrollPos;5323 INT nMinRange;5324 INT nMaxRange;5325 5326 GetScrollRange(hwnd, SB_VERT, &nMinRange, &nMaxRange);5327 nScrollPos = GetScrollPos(hwnd, SB_VERT);5328 5329 switch (nScrollCode)5330 {5331 case SB_LINEUP:5332 if (nScrollPos > nMinRange)5333 {5334 nScrollPosInc = -1;5335 }5358 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 5359 SCROLLINFO scrollInfo; 5360 5361 ZeroMemory(&scrollInfo, sizeof(SCROLLINFO)); 5362 scrollInfo.cbSize = sizeof(SCROLLINFO); 5363 scrollInfo.fMask = /*SIF_PAGE |*/ SIF_POS | SIF_RANGE; 5364 5365 if (GetScrollInfo(hwnd, SB_VERT, &scrollInfo) != FALSE) 5366 { 5367 INT nOldScrollPos = scrollInfo.nPos; 5368 switch (nScrollCode) 5369 { 5370 case SB_LINEUP: 5371 if (scrollInfo.nPos > scrollInfo.nMin) 5372 { 5373 scrollInfo.nPos--; 5374 } 5336 5375 break; 5337 5376 5338 case SB_LINEDOWN: 5339 if (nScrollPos < nMaxRange) 5340 { 5341 nScrollPosInc = 1; 5342 } 5343 break; 5344 5345 case SB_PAGEUP: 5346 switch (LVS_TYPEMASK & lStyle) 5347 { 5348 case LVS_REPORT: 5349 if (nScrollPos > nMinRange + infoPtr->nCountPerColumn) 5350 { 5351 nScrollPosInc = -infoPtr->nCountPerColumn; 5352 } 5353 else 5354 { 5355 nScrollPosInc = nMinRange - nScrollPos; 5356 } 5357 break; 5358 5359 case LVS_SMALLICON: 5360 case LVS_ICON: 5361 if (nScrollPos > nMinRange + 10) 5362 { 5363 nScrollPosInc = -10; 5364 } 5365 else 5366 { 5367 nScrollPosInc = nMinRange - nScrollPos; 5368 } 5369 break; 5370 } 5371 break; 5372 5373 case SB_PAGEDOWN: 5374 switch (LVS_TYPEMASK & lStyle) 5375 { 5376 case LVS_REPORT: 5377 if (nScrollPos < nMaxRange - infoPtr->nCountPerColumn) 5378 { 5379 nScrollPosInc = infoPtr->nCountPerColumn; 5380 } 5381 else 5382 { 5383 nScrollPosInc = nMaxRange - nScrollPos; 5384 } 5385 break; 5386 5387 case LVS_SMALLICON: 5388 case LVS_ICON: 5389 if (nScrollPos < nMaxRange - 10) 5390 { 5391 nScrollPosInc = 10; 5392 } 5393 else 5394 { 5395 nScrollPosInc = nMaxRange - nScrollPos; 5396 } 5397 break; 5398 } 5399 break; 5400 5401 case SB_THUMBPOSITION: 5402 nScrollPosInc = nScroll - nScrollPos; 5403 break; 5404 } 5405 5406 if (nScrollPosInc != 0) 5407 { 5408 LISTVIEW_ScrollView(hwnd, 0, nScrollPosInc); 5409 } 5410 5411 return 0; 5412 } 5413 5414 5415 /*** 5416 * DESCRIPTION: 5417 * Performs horizontal scrolling. 5418 * 5419 * PARAMETER(S): 5420 * [I] HWND : window handle 5421 * [I] INT : scroll code 5422 * [I] INT : scroll position 5423 * [I] HWND : scrollbar control window handle 5424 * 5425 * RETURN: 5426 * Zero 5427 */ 5428 static LRESULT LISTVIEW_HScroll(HWND hwnd, INT nScrollCode, 5429 INT nScroll, HWND hScrollWnd) 5430 { 5431 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 5432 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 5433 INT nScrollPosInc = 0; 5434 INT nScrollPos; 5435 INT nMinRange; 5436 INT nMaxRange; 5437 5438 GetScrollRange(hwnd, SB_HORZ, &nMinRange, &nMaxRange); 5439 nScrollPos = GetScrollPos(hwnd, SB_HORZ); 5440 5441 switch (nScrollCode) 5442 { 5443 case SB_LINELEFT: 5444 if (nScrollPos > nMinRange) 5445 { 5446 nScrollPosInc = -1; 5447 } 5448 break; 5449 5450 case SB_LINERIGHT: 5451 if (nScrollPos < nMaxRange) 5452 { 5453 nScrollPosInc = 1; 5454 } 5455 break; 5456 5457 case SB_PAGELEFT: 5458 switch (LVS_TYPEMASK & lStyle) 5459 { 5460 case LVS_LIST: 5461 if (nScrollPos > nMinRange + infoPtr->nCountPerRow) 5462 { 5463 nScrollPosInc = -infoPtr->nCountPerRow; 5464 } 5465 else 5466 { 5467 nScrollPosInc = nMinRange - nScrollPos; 5468 } 5469 break; 5470 5471 case LVS_REPORT: 5472 case LVS_SMALLICON: 5473 case LVS_ICON: 5474 if (nScrollPos > nMinRange + 10) 5475 { 5476 nScrollPosInc = -10; 5477 } 5478 else 5479 { 5480 nScrollPosInc = nMinRange - nScrollPos; 5481 } 5482 break; 5483 } 5484 break; 5485 5486 case SB_PAGERIGHT: 5487 switch (LVS_TYPEMASK & lStyle) 5488 { 5489 case LVS_LIST: 5490 if (nScrollPos < nMaxRange - infoPtr->nCountPerRow) 5491 { 5492 nScrollPosInc = infoPtr->nCountPerRow; 5493 } 5494 else 5495 { 5496 nScrollPosInc = nMaxRange - nScrollPos; 5377 case SB_LINEDOWN: 5378 if (scrollInfo.nPos < scrollInfo.nMax) 5379 { 5380 scrollInfo.nPos++; 5497 5381 } 5498 5382 break; 5499 5383 5500 case LVS_REPORT: 5501 case LVS_SMALLICON: 5502 case LVS_ICON: 5503 if (nScrollPos < nMaxRange - 10) 5504 { 5505 nScrollPosInc = 10; 5506 } 5507 else 5508 { 5509 nScrollPosInc = nMaxRange - nScrollPos; 5384 case SB_PAGEUP: 5385 if (scrollInfo.nPos > scrollInfo.nMin) 5386 { 5387 INT nPage = 0; 5388 5389 if (uView == LVS_REPORT) 5390 { 5391 nPage = LISTVIEW_GetCountPerColumn(hwnd); 5392 } 5393 else if ((uView == LVS_ICON) || (uView == LVS_SMALLICON)) 5394 { 5395 nPage = 10; 5396 } 5397 5398 if (scrollInfo.nPos >= nPage) 5399 { 5400 scrollInfo.nPos -= nPage; 5401 } 5402 else 5403 { 5404 scrollInfo.nPos = scrollInfo.nMin; 5405 } 5510 5406 } 5511 5407 break; 5512 } 5513 break; 5514 5515 case SB_THUMBPOSITION: 5516 nScrollPosInc = nScroll - nScrollPos; 5517 break; 5518 } 5519 5520 if (nScrollPosInc != 0) 5521 { 5522 LISTVIEW_ScrollView(hwnd, nScrollPosInc, 0); 5523 } 5524 5408 5409 case SB_PAGEDOWN: 5410 if (scrollInfo.nPos < scrollInfo.nMax) 5411 { 5412 INT nPage = 0; 5413 5414 if (uView == LVS_REPORT) 5415 { 5416 nPage = LISTVIEW_GetCountPerColumn(hwnd); 5417 } 5418 else if ((uView == LVS_ICON) || (uView == LVS_SMALLICON)) 5419 { 5420 nPage = 10; 5421 } 5422 5423 if (scrollInfo.nPos <= scrollInfo.nMax - nPage) 5424 { 5425 scrollInfo.nPos += nPage; 5426 } 5427 else 5428 { 5429 scrollInfo.nPos = scrollInfo.nMax; 5430 } 5431 } 5432 break; 5433 5434 case SB_THUMBPOSITION: 5435 break; 5436 } 5437 5438 if (nOldScrollPos != scrollInfo.nPos) 5439 { 5440 scrollInfo.fMask = SIF_POS; 5441 SetScrollInfo(hwnd, SB_VERT, &scrollInfo, TRUE); 5442 InvalidateRect(hwnd, NULL, TRUE); 5443 } 5444 } 5445 5446 return 0; 5447 } 5448 5449 /*** 5450 * DESCRIPTION: 5451 * Performs horizontal scrolling. 5452 * 5453 * PARAMETER(S): 5454 * [I] HWND : window handle 5455 * [I] INT : scroll code 5456 * [I] SHORT : current scroll position if scroll code is SB_THIMBPOSITION 5457 * or SB_THUMBTRACK. 5458 * [I] HWND : scrollbar control window handle 5459 * 5460 * RETURN: 5461 * Zero 5462 */ 5463 static LRESULT LISTVIEW_HScroll(HWND hwnd, INT nScrollCode, SHORT nCurrentPos, 5464 HWND hScrollWnd) 5465 { 5466 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 5467 SCROLLINFO scrollInfo; 5468 5469 ZeroMemory(&scrollInfo, sizeof(SCROLLINFO)); 5470 scrollInfo.cbSize = sizeof(SCROLLINFO); 5471 scrollInfo.fMask = /*SIF_PAGE |*/ SIF_POS | SIF_RANGE; 5472 5473 if (GetScrollInfo(hwnd, SB_HORZ, &scrollInfo) != FALSE) 5474 { 5475 INT nOldScrollPos = scrollInfo.nPos; 5476 5477 switch (nScrollCode) 5478 { 5479 case SB_LINELEFT: 5480 if (scrollInfo.nPos > scrollInfo.nMin) 5481 { 5482 scrollInfo.nPos--; 5483 } 5484 break; 5485 5486 case SB_LINERIGHT: 5487 if (scrollInfo.nPos < scrollInfo.nMax) 5488 { 5489 scrollInfo.nPos++; 5490 } 5491 break; 5492 5493 case SB_PAGELEFT: 5494 if (scrollInfo.nPos > scrollInfo.nMin) 5495 { 5496 INT nPage = 0; 5497 5498 if (uView == LVS_LIST) 5499 { 5500 nPage = LISTVIEW_GetCountPerRow(hwnd); 5501 } 5502 else if ((uView == LVS_ICON) || (uView == LVS_SMALLICON)) 5503 { 5504 nPage = 10; 5505 } 5506 5507 if (scrollInfo.nPos >= nPage) 5508 { 5509 scrollInfo.nPos -= nPage; 5510 } 5511 else 5512 { 5513 scrollInfo.nPos = scrollInfo.nMin; 5514 } 5515 } 5516 break; 5517 5518 case SB_PAGERIGHT: 5519 if (scrollInfo.nPos < scrollInfo.nMax) 5520 { 5521 INT nPage = 0; 5522 5523 if (uView == LVS_LIST) 5524 { 5525 nPage = LISTVIEW_GetCountPerRow(hwnd); 5526 } 5527 else if ((uView == LVS_ICON) || (uView == LVS_SMALLICON)) 5528 { 5529 nPage = 10; 5530 } 5531 5532 if (scrollInfo.nPos <= scrollInfo.nMax - nPage) 5533 { 5534 scrollInfo.nPos += nPage; 5535 } 5536 else 5537 { 5538 scrollInfo.nPos = scrollInfo.nMax; 5539 } 5540 } 5541 break; 5542 5543 case SB_THUMBPOSITION: 5544 break; 5545 } 5546 5547 if (nOldScrollPos != scrollInfo.nPos) 5548 { 5549 scrollInfo.fMask = SIF_POS; 5550 SetScrollInfo(hwnd, SB_HORZ, &scrollInfo, TRUE); 5551 InvalidateRect(hwnd, NULL, TRUE); 5552 } 5553 } 5554 5525 5555 return 0; 5526 5556 } … … 5541 5571 { 5542 5572 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 5543 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);5544 5573 INT nCtrlId = GetWindowLongA(hwnd, GWL_ID); 5545 INT nCountPerColumn;5546 INT nCountPerRow;5547 5574 HWND hwndParent = GetParent(hwnd); 5548 5575 NMLVKEYDOWN nmKeyDown; 5549 5576 NMHDR nmh; 5550 INT oldFocusedItem = infoPtr->nFocusedItem; 5577 INT nItem = -1; 5578 BOOL bRedraw = FALSE; 5551 5579 5552 5580 /* send LVN_KEYDOWN notification */ … … 5581 5609 if (GETITEMCOUNT(infoPtr) > 0) 5582 5610 { 5583 LISTVIEW_KeySelection(hwnd, 0);5611 nItem = 0; 5584 5612 } 5585 5613 break; … … 5588 5616 if (GETITEMCOUNT(infoPtr) > 0) 5589 5617 { 5590 LISTVIEW_KeySelection(hwnd, GETITEMCOUNT(infoPtr) - 1);5618 nItem = GETITEMCOUNT(infoPtr) - 1; 5591 5619 } 5592 5620 break; 5593 5621 5594 5622 case VK_LEFT: 5595 switch (LVS_TYPEMASK & lStyle) 5596 { 5597 case LVS_LIST: 5598 if (infoPtr->nFocusedItem >= infoPtr->nCountPerColumn) 5599 { 5600 LISTVIEW_KeySelection(hwnd, infoPtr->nFocusedItem - 5601 infoPtr->nCountPerColumn); 5602 } 5603 break; 5604 5605 case LVS_SMALLICON: 5606 case LVS_ICON: 5607 if (lStyle & LVS_ALIGNLEFT) 5608 { 5609 nCountPerColumn = max((infoPtr->rcList.bottom - infoPtr->rcList.top) / 5610 infoPtr->nItemHeight, 1); 5611 if (infoPtr->nFocusedItem >= nCountPerColumn) 5612 { 5613 LISTVIEW_KeySelection(hwnd, infoPtr->nFocusedItem - nCountPerColumn); 5614 } 5615 } 5616 else 5617 { 5618 nCountPerRow = max((infoPtr->rcList.right - infoPtr->rcList.left) / 5619 infoPtr->nItemWidth, 1); 5620 if (infoPtr->nFocusedItem % nCountPerRow != 0) 5621 { 5622 LISTVIEW_SetSelection(hwnd, infoPtr->nFocusedItem - 1); 5623 } 5624 } 5625 break; 5626 } 5623 nItem = LISTVIEW_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_TOLEFT); 5627 5624 break; 5628 5625 5629 5626 case VK_UP: 5630 switch (LVS_TYPEMASK & lStyle) 5631 { 5632 case LVS_LIST: 5633 case LVS_REPORT: 5634 if (infoPtr->nFocusedItem > 0) 5635 { 5636 LISTVIEW_KeySelection(hwnd, infoPtr->nFocusedItem - 1); 5637 } 5638 break; 5639 5640 default: 5641 if (lStyle & LVS_ALIGNLEFT) 5642 { 5643 nCountPerColumn = max((infoPtr->rcList.bottom - infoPtr->rcList.top) / 5644 infoPtr->nItemHeight, 1); 5645 if (infoPtr->nFocusedItem % nCountPerColumn != 0) 5646 { 5647 LISTVIEW_KeySelection(hwnd, infoPtr->nFocusedItem - 1); 5648 } 5649 } 5650 else 5651 { 5652 nCountPerRow = max((infoPtr->rcList.right - infoPtr->rcList.left) / 5653 infoPtr->nItemWidth, 1); 5654 if (infoPtr->nFocusedItem >= nCountPerRow) 5655 { 5656 LISTVIEW_KeySelection(hwnd, infoPtr->nFocusedItem - nCountPerRow); 5657 } 5658 } 5659 } 5627 nItem = LISTVIEW_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_ABOVE); 5660 5628 break; 5661 5629 5662 5630 case VK_RIGHT: 5663 switch (LVS_TYPEMASK & lStyle) 5664 { 5665 case LVS_LIST: 5666 if (infoPtr->nFocusedItem < GETITEMCOUNT(infoPtr) - 5667 infoPtr->nCountPerColumn) 5668 { 5669 LISTVIEW_KeySelection(hwnd, infoPtr->nFocusedItem + 5670 infoPtr->nCountPerColumn); 5671 } 5672 break; 5673 5674 case LVS_ICON: 5675 case LVS_SMALLICON: 5676 if (lStyle & LVS_ALIGNLEFT) 5677 { 5678 nCountPerColumn = max((infoPtr->rcList.bottom - infoPtr->rcList.top) / 5679 infoPtr->nItemHeight, 1); 5680 if (infoPtr->nFocusedItem < GETITEMCOUNT(infoPtr) - nCountPerColumn) 5681 { 5682 LISTVIEW_KeySelection(hwnd, infoPtr->nFocusedItem + nCountPerColumn); 5683 } 5684 } 5685 else 5686 { 5687 nCountPerRow = max((infoPtr->rcList.right - infoPtr->rcList.left) / 5688 infoPtr->nItemWidth, 1); 5689 if ((infoPtr->nFocusedItem % nCountPerRow != nCountPerRow - 1) && 5690 (infoPtr->nFocusedItem < GETITEMCOUNT(infoPtr) - 1)) 5691 { 5692 LISTVIEW_KeySelection(hwnd, infoPtr->nFocusedItem + 1); 5693 } 5694 } 5695 } 5631 nItem = LISTVIEW_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_TORIGHT); 5696 5632 break; 5697 5633 5698 5634 case VK_DOWN: 5699 switch (LVS_TYPEMASK & lStyle) 5700 { 5701 case LVS_LIST: 5702 case LVS_REPORT: 5703 if (infoPtr->nFocusedItem < GETITEMCOUNT(infoPtr) - 1) 5704 { 5705 LISTVIEW_KeySelection(hwnd, infoPtr->nFocusedItem + 1); 5706 } 5707 break; 5708 5709 case LVS_SMALLICON: 5710 case LVS_ICON: 5711 if (lStyle & LVS_ALIGNLEFT) 5712 { 5713 nCountPerColumn = max((infoPtr->rcList.bottom - infoPtr->rcList.top) / 5714 infoPtr->nItemHeight, 1); 5715 if (infoPtr->nFocusedItem % nCountPerColumn != nCountPerColumn - 1) 5716 { 5717 LISTVIEW_KeySelection(hwnd, infoPtr->nFocusedItem + 1); 5718 } 5719 } 5720 else 5721 { 5722 nCountPerRow = max((infoPtr->rcList.right - infoPtr->rcList.left) / 5723 infoPtr->nItemWidth, 1); 5724 if (infoPtr->nFocusedItem < GETITEMCOUNT(infoPtr) - nCountPerRow) 5725 { 5726 LISTVIEW_KeySelection(hwnd, infoPtr->nFocusedItem + nCountPerRow); 5727 } 5728 } 5729 } 5635 nItem = LISTVIEW_GetNextItem(hwnd, infoPtr->nFocusedItem, LVNI_BELOW); 5730 5636 break; 5731 5637 5732 5638 case VK_PRIOR: 5639 /* TO DO */ 5733 5640 break; 5734 5641 5735 5642 case VK_NEXT: 5643 /* TO DO */ 5736 5644 break; 5737 5645 } 5738 5646 5739 /* refresh client area if necessary*/ 5740 if(oldFocusedItem != infoPtr->nFocusedItem) 5741 InvalidateRect(hwnd, NULL, TRUE); 5647 if ((nItem != -1) && (nItem != infoPtr->nFocusedItem)) 5648 { 5649 bRedraw = LISTVIEW_KeySelection(hwnd, nItem); 5650 if (bRedraw != FALSE) 5651 { 5652 /* refresh client area */ 5653 InvalidateRect(hwnd, NULL, TRUE); 5654 UpdateWindow(hwnd); 5655 } 5656 } 5742 5657 5743 5658 return 0; … … 5769 5684 infoPtr->bFocus = FALSE; 5770 5685 5686 /* NEED drawing optimization ; redraw the selected items */ 5687 InvalidateRect(hwnd, NULL, FALSE); 5688 5771 5689 return 0; 5772 5690 } … … 5791 5709 NMHDR nmh; 5792 5710 5793 // TRACE(listview,"(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY);5711 TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY); 5794 5712 5795 5713 /* send NM_DBLCLK notification */ … … 5823 5741 { 5824 5742 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 5743 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 5825 5744 INT nCtrlId = GetWindowLongA(hwnd, GWL_ID); 5826 5745 static BOOL bGroupSelect = TRUE; 5746 POINT ptPosition; 5827 5747 NMHDR nmh; 5828 5748 INT nItem; 5829 5749 5830 // TRACE(listview, "(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY); 5750 TRACE("(hwnd=%x, key=%hu, X=%hu, Y=%hu)\n", hwnd, wKey, wPosX, 5751 wPosY); 5831 5752 5832 5753 /* send NM_RELEASEDCAPTURE notification */ … … 5843 5764 /* set left button down flag */ 5844 5765 infoPtr->bLButtonDown = TRUE; 5845 5846 nItem = LISTVIEW_MouseSelection(hwnd, wPosX, wPosY); 5766 5767 ptPosition.x = wPosX; 5768 ptPosition.y = wPosY; 5769 nItem = LISTVIEW_MouseSelection(hwnd, ptPosition); 5847 5770 if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr))) 5848 5771 { 5849 if ((wKey & MK_CONTROL) && (wKey & MK_SHIFT)) 5850 { 5851 if (bGroupSelect != FALSE) 5852 { 5853 LISTVIEW_AddGroupSelection(hwnd, nItem); 5772 if (lStyle & LVS_SINGLESEL) 5773 { 5774 LISTVIEW_SetSelection(hwnd, nItem); 5775 } 5776 else 5777 { 5778 if ((wKey & MK_CONTROL) && (wKey & MK_SHIFT)) 5779 { 5780 if (bGroupSelect != FALSE) 5781 { 5782 LISTVIEW_AddGroupSelection(hwnd, nItem); 5783 } 5784 else 5785 { 5786 LISTVIEW_AddSelection(hwnd, nItem); 5787 } 5788 } 5789 else if (wKey & MK_CONTROL) 5790 { 5791 bGroupSelect = LISTVIEW_ToggleSelection(hwnd, nItem); 5792 } 5793 else if (wKey & MK_SHIFT) 5794 { 5795 LISTVIEW_SetGroupSelection(hwnd, nItem); 5854 5796 } 5855 5797 else 5856 5798 { 5857 LISTVIEW_AddSelection(hwnd, nItem); 5858 } 5859 } 5860 else if (wKey & MK_CONTROL) 5861 { 5862 bGroupSelect = LISTVIEW_ToggleSelection(hwnd, nItem); 5863 } 5864 else if (wKey & MK_SHIFT) 5865 { 5866 LISTVIEW_SetGroupSelection(hwnd, nItem); 5867 } 5868 else 5869 { 5870 LISTVIEW_SetSelection(hwnd, nItem); 5799 LISTVIEW_SetSelection(hwnd, nItem); 5800 } 5871 5801 } 5872 5802 } … … 5900 5830 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 5901 5831 5902 // TRACE(listview,"(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY);5832 TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY); 5903 5833 5904 5834 if (infoPtr->bLButtonDown != FALSE) … … 5936 5866 LISTVIEW_INFO *infoPtr; 5937 5867 5938 // TRACE(listview,"(hwnd=%x,wParam=%x,lParam=%lx)\n", hwnd, wParam, lParam);5868 TRACE("(hwnd=%x,wParam=%x,lParam=%lx)\n", hwnd, wParam, lParam); 5939 5869 5940 5870 /* allocate memory for info structure */ … … 5943 5873 if (infoPtr == NULL) 5944 5874 { 5945 // ERR(listview,"could not allocate info memory!\n");5875 ERR("could not allocate info memory!\n"); 5946 5876 return 0; 5947 5877 } … … 5949 5879 if ((LISTVIEW_INFO *)GetWindowLongA(hwnd, 0) != infoPtr) 5950 5880 { 5951 // ERR(listview,"pointer assignment error!\n");5881 ERR("pointer assignment error!\n"); 5952 5882 return 0; 5953 5883 } … … 5970 5900 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 5971 5901 5972 // TRACE(listview,"(hwnd=%x)\n", hwnd);5902 TRACE("(hwnd=%x)\n", hwnd); 5973 5903 5974 5904 /* delete all items */ … … 6012 5942 if (lpnmh->code == HDN_ENDTRACKA) 6013 5943 { 6014 infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd , LVS_REPORT);5944 infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd); 6015 5945 InvalidateRect(hwnd, NULL, TRUE); 6016 5946 } … … 6043 5973 if (infoPtr->notifyFormat == NFR_UNICODE) 6044 5974 { 6045 // FIXME (listview,"NO support for unicode structures");5975 FIXME("NO support for unicode structures"); 6046 5976 } 6047 5977 } … … 6065 5995 PAINTSTRUCT ps; 6066 5996 6067 // TRACE(listview,"(hwnd=%x,hdc=%x)\n", hwnd, hdc);5997 TRACE("(hwnd=%x,hdc=%x)\n", hwnd, hdc); 6068 5998 6069 5999 if (hdc == 0) … … 6100 6030 NMHDR nmh; 6101 6031 6102 // TRACE(listview,"(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY);6032 TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY); 6103 6033 6104 6034 /* send NM_RELEASEDCAPTURE notification */ … … 6133 6063 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 6134 6064 INT nCtrlId = GetWindowLongA(hwnd, GWL_ID); 6065 POINT ptPosition; 6135 6066 NMHDR nmh; 6136 6067 INT nItem; 6137 6068 6138 // TRACE(listview,"(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY);6069 TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY); 6139 6070 6140 6071 /* send NM_RELEASEDCAPTURE notification */ … … 6154 6085 6155 6086 /* determine the index of the selected item */ 6156 nItem = LISTVIEW_MouseSelection(hwnd, wPosX, wPosY); 6087 ptPosition.x = wPosX; 6088 ptPosition.y = wPosY; 6089 nItem = LISTVIEW_MouseSelection(hwnd, ptPosition); 6157 6090 if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr))) 6158 6091 { … … 6166 6099 LISTVIEW_RemoveSelections(hwnd, 0, GETITEMCOUNT(infoPtr)); 6167 6100 } 6168 6101 6169 6102 return 0; 6170 6103 } … … 6190 6123 NMHDR nmh; 6191 6124 6192 // TRACE(listview,"(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY);6125 TRACE("(hwnd=%x,key=%hu,X=%hu,Y=%hu)\n", hwnd, wKey, wPosX, wPosY); 6193 6126 6194 6127 if (infoPtr->bRButtonDown != FALSE) … … 6252 6185 { 6253 6186 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 6254 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE);6255 6256 // TRACE(listview,"(hwnd=%x,hfont=%x,redraw=%hu)\n", hwnd, hFont, fRedraw);6187 UINT uView = GetWindowLongA(hwnd, GWL_STYLE) & LVS_TYPEMASK; 6188 6189 TRACE("(hwnd=%x,hfont=%x,redraw=%hu)\n", hwnd, hFont, fRedraw); 6257 6190 6258 6191 if (hFont == 0) … … 6265 6198 } 6266 6199 6267 if ( (LVS_TYPEMASK & lStyle )== LVS_REPORT)6200 if (uView == LVS_REPORT) 6268 6201 { 6269 6202 /* set header font */ … … 6298 6231 static LRESULT LISTVIEW_Size(HWND hwnd, int Width, int Height) 6299 6232 { 6233 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 6234 UINT uView = lStyle & LVS_TYPEMASK; 6235 6236 TRACE("(hwnd=%x, width=%d, height=%d)\n",hwnd, Width, Height); 6237 6238 LISTVIEW_UpdateSize(hwnd); 6239 6240 if ((uView == LVS_SMALLICON) || (uView == LVS_ICON)) 6241 { 6242 if (lStyle & LVS_ALIGNLEFT) 6243 { 6244 LISTVIEW_AlignLeft(hwnd); 6245 } 6246 else 6247 { 6248 LISTVIEW_AlignTop(hwnd); 6249 } 6250 } 6251 6252 LISTVIEW_UpdateScroll(hwnd); 6253 6254 /* invalidate client area + erase background */ 6255 InvalidateRect(hwnd, NULL, TRUE); 6256 6257 return 0; 6258 } 6259 6260 /*** 6261 * DESCRIPTION: 6262 * Sets the size information. 6263 * 6264 * PARAMETER(S): 6265 * [I] HWND : window handle 6266 * 6267 * RETURN: 6268 * Zero 6269 */ 6270 static VOID LISTVIEW_UpdateSize(HWND hwnd) 6271 { 6272 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 6300 6273 LONG lStyle = GetWindowLongA(hwnd, GWL_STYLE); 6301 6302 // TRACE(listview, "(hwnd=%x,width=%d,height=%d)\n",hwnd, Width, Height); 6303 6304 LISTVIEW_SetSize(hwnd, lStyle, -1, -1); 6305 switch (lStyle & LVS_TYPEMASK) 6306 { 6307 case LVS_LIST: 6308 case LVS_REPORT: 6309 LISTVIEW_SetViewInfo(hwnd, lStyle); 6310 break; 6311 6312 case LVS_ICON: 6313 case LVS_SMALLICON: 6314 if (lStyle & LVS_ALIGNLEFT) 6315 { 6316 LISTVIEW_AlignLeft(hwnd); 6317 } 6318 else 6319 { 6320 LISTVIEW_AlignTop(hwnd); 6321 } 6322 break; 6323 } 6324 6325 LISTVIEW_SetScroll(hwnd, lStyle); 6326 6327 /* invalidate + erase background */ 6328 InvalidateRect(hwnd, NULL, TRUE); 6329 6330 return 0; 6331 } 6332 6333 /*** 6334 * DESCRIPTION: 6335 * Sets the size information for a given style. 6336 * 6337 * PARAMETER(S): 6338 * [I] HWND : window handle 6339 * [I] LONG : window style 6340 * [I] WORD : new width 6341 * [I] WORD : new height 6342 * 6343 * RETURN: 6344 * Zero 6345 */ 6346 static VOID LISTVIEW_SetSize(HWND hwnd, LONG lStyle, LONG lWidth, LONG lHeight) 6347 { 6348 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 6349 HDLAYOUT hl; 6350 WINDOWPOS wp; 6274 UINT uView = lStyle & LVS_TYPEMASK; 6351 6275 RECT rcList; 6352 6276 6353 6277 GetClientRect(hwnd, &rcList); 6354 if (lWidth == -1) 6355 { 6356 infoPtr->rcList.left = max(rcList.left, 0); 6357 infoPtr->rcList.right = max(rcList.right, 0); 6358 } 6359 else 6360 { 6361 infoPtr->rcList.left = max(rcList.left, 0); 6362 infoPtr->rcList.right = infoPtr->rcList.left + max(lWidth, 0); 6363 } 6364 6365 if (lHeight == -1) 6366 { 6367 infoPtr->rcList.top = max(rcList.top, 0); 6368 infoPtr->rcList.bottom = max(rcList.bottom, 0); 6369 } 6370 else 6371 { 6372 infoPtr->rcList.top = max(rcList.top, 0); 6373 infoPtr->rcList.bottom = infoPtr->rcList.top + max(lHeight, 0); 6374 } 6375 6376 switch (lStyle & LVS_TYPEMASK) 6377 { 6378 case LVS_LIST: 6278 infoPtr->rcList.left = 0; 6279 infoPtr->rcList.right = max(rcList.right - rcList.left, 1); 6280 infoPtr->rcList.top = 0; 6281 infoPtr->rcList.bottom = max(rcList.bottom - rcList.top, 1); 6282 6283 if (uView == LVS_LIST) 6284 { 6379 6285 if ((lStyle & WS_HSCROLL) == 0) 6380 6286 { 6381 INT nHScrollHeight; 6382 nHScrollHeight = GetSystemMetrics(SM_CYHSCROLL); 6287 INT nHScrollHeight = GetSystemMetrics(SM_CYHSCROLL); 6383 6288 if (infoPtr->rcList.bottom > nHScrollHeight) 6384 6289 { … … 6386 6291 } 6387 6292 } 6388 break; 6389 6390 case LVS_REPORT: 6293 } 6294 else if (uView == LVS_REPORT) 6295 { 6296 HDLAYOUT hl; 6297 WINDOWPOS wp; 6298 6391 6299 hl.prc = &rcList; 6392 6300 hl.pwpos = ℘ 6393 6301 Header_Layout(infoPtr->hwndHeader, &hl); 6394 infoPtr->rcList.top = max(wp.cy, 0); 6395 break; 6302 if (!(LVS_NOCOLUMNHEADER & lStyle)) 6303 { 6304 infoPtr->rcList.top = max(wp.cy, 0); 6305 } 6396 6306 } 6397 6307 } … … 6413 6323 { 6414 6324 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 6325 UINT uNewView = lpss->styleNew & LVS_TYPEMASK; 6326 UINT uOldView = lpss->styleOld & LVS_TYPEMASK; 6415 6327 RECT rcList = infoPtr->rcList; 6416 HDLAYOUT hl; 6417 WINDOWPOS wp; 6418 6419 // TRACE(listview, "(hwnd=%x,styletype=%x,stylestruct=%p)\n", 6420 // hwnd, wStyleType, lpss); 6328 6329 TRACE("(hwnd=%x, styletype=%x, stylestruct=%p)\n", 6330 hwnd, wStyleType, lpss); 6421 6331 6422 6332 if (wStyleType == GWL_STYLE) 6423 6333 { 6334 if (uOldView == LVS_REPORT) 6335 { 6336 ShowWindow(infoPtr->hwndHeader, SW_HIDE); 6337 } 6338 6424 6339 if ((lpss->styleOld & WS_HSCROLL) != 0) 6425 6340 { 6426 ShowScrollBar(hwnd, SB_HORZ, FALSE);6427 } 6428 6341 ShowScrollBar(hwnd, SB_HORZ, FALSE); 6342 } 6343 6429 6344 if ((lpss->styleOld & WS_VSCROLL) != 0) 6430 6345 { 6431 ShowScrollBar(hwnd, SB_VERT, FALSE); 6432 } 6433 6434 if ((LVS_TYPEMASK & lpss->styleOld) == LVS_REPORT) 6435 { 6436 /* remove header */ 6437 ShowWindow(infoPtr->hwndHeader, SW_HIDE); 6438 } 6439 6440 switch (lpss->styleNew & LVS_TYPEMASK) 6441 { 6442 case LVS_ICON: 6346 ShowScrollBar(hwnd, SB_VERT, FALSE); 6347 } 6348 6349 if (uNewView == LVS_ICON) 6350 { 6443 6351 infoPtr->iconSize.cx = GetSystemMetrics(SM_CXICON); 6444 6352 infoPtr->iconSize.cy = GetSystemMetrics(SM_CYICON); 6445 LISTVIEW_SetSize(hwnd, lpss->styleNew, -1, -1); 6446 infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd, lpss->styleNew); 6447 infoPtr->nItemHeight = LISTVIEW_GetItemHeight(hwnd, lpss->styleNew); 6353 infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd); 6354 infoPtr->nItemHeight = LISTVIEW_GetItemHeight(hwnd); 6448 6355 if (lpss->styleNew & LVS_ALIGNLEFT) 6449 6356 { … … 6454 6361 LISTVIEW_AlignTop(hwnd); 6455 6362 } 6456 break; 6457 6458 case LVS_REPORT: 6363 } 6364 else if (uNewView == LVS_REPORT) 6365 { 6366 HDLAYOUT hl; 6367 WINDOWPOS wp; 6368 6459 6369 hl.prc = &rcList; 6460 6370 hl.pwpos = ℘ 6461 6371 Header_Layout(infoPtr->hwndHeader, &hl); 6462 SetWindowPos(infoPtr->hwndHeader, hwnd, wp.x, wp.y, wp.cx, 6463 wp.cy, wp.flags); 6464 ShowWindow(infoPtr->hwndHeader, SW_SHOWNORMAL); 6372 SetWindowPos(infoPtr->hwndHeader, hwnd, wp.x, wp.y, wp.cx, wp.cy, 6373 wp.flags); 6374 if (!(LVS_NOCOLUMNHEADER & lpss->styleNew)) 6375 { 6376 ShowWindow(infoPtr->hwndHeader, SW_SHOWNORMAL); 6377 } 6465 6378 infoPtr->iconSize.cx = GetSystemMetrics(SM_CXSMICON); 6466 6379 infoPtr->iconSize.cy = GetSystemMetrics(SM_CYSMICON); 6467 infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd, lpss->styleNew); 6468 infoPtr->nItemHeight = LISTVIEW_GetItemHeight(hwnd, lpss->styleNew); 6469 LISTVIEW_SetSize(hwnd, lpss->styleNew, -1, -1); 6470 LISTVIEW_SetViewInfo(hwnd, lpss->styleNew); 6471 break; 6472 6473 case LVS_LIST: 6380 infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd); 6381 infoPtr->nItemHeight = LISTVIEW_GetItemHeight(hwnd); 6382 } 6383 else if (uNewView == LVS_LIST) 6384 { 6474 6385 infoPtr->iconSize.cx = GetSystemMetrics(SM_CXSMICON); 6475 6386 infoPtr->iconSize.cy = GetSystemMetrics(SM_CYSMICON); 6476 infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd, lpss->styleNew); 6477 infoPtr->nItemHeight = LISTVIEW_GetItemHeight(hwnd, lpss->styleNew); 6478 LISTVIEW_SetSize(hwnd, lpss->styleNew, -1, -1); 6479 LISTVIEW_SetViewInfo(hwnd, lpss->styleNew); 6480 break; 6481 6482 case LVS_SMALLICON: 6387 infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd); 6388 infoPtr->nItemHeight = LISTVIEW_GetItemHeight(hwnd); 6389 } 6390 else 6391 { 6483 6392 infoPtr->iconSize.cx = GetSystemMetrics(SM_CXSMICON); 6484 6393 infoPtr->iconSize.cy = GetSystemMetrics(SM_CYSMICON); 6485 LISTVIEW_SetSize(hwnd, lpss->styleNew, -1, -1); 6486 infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd, lpss->styleNew); 6487 infoPtr->nItemHeight = LISTVIEW_GetItemHeight(hwnd, lpss->styleNew); 6394 infoPtr->nItemWidth = LISTVIEW_GetItemWidth(hwnd); 6395 infoPtr->nItemHeight = LISTVIEW_GetItemHeight(hwnd); 6488 6396 if (lpss->styleNew & LVS_ALIGNLEFT) 6489 6397 { … … 6494 6402 LISTVIEW_AlignTop(hwnd); 6495 6403 } 6496 break; 6497 } 6498 6499 LISTVIEW_SetScroll(hwnd, lpss->styleNew); 6404 } 6405 6406 /* update the size of the client area */ 6407 LISTVIEW_UpdateSize(hwnd); 6408 6409 /* add scrollbars if needed */ 6410 LISTVIEW_UpdateScroll(hwnd); 6500 6411 6501 /* print unsupported styles */ 6412 /* invalidate client area + erase background */ 6413 InvalidateRect(hwnd, NULL, TRUE); 6414 6415 /* print the list of unsupported window styles */ 6502 6416 LISTVIEW_UnsupportedStyles(lpss->styleNew); 6503 6504 /* invalidate client area */6505 InvalidateRect(hwnd, NULL, TRUE);6506 6417 } 6507 6418 … … 6512 6423 * DESCRIPTION: 6513 6424 * Window procedure of the listview control. 6514 * 6515 * PARAMETER(S): 6516 * [I] HWND : 6517 * [I] UINT : 6518 * [I] WPARAM : 6519 * [I] LPARAM : 6520 * 6521 * RETURN: 6522 * 6425 * 6523 6426 */ 6524 6427 LRESULT WINAPI LISTVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, … … 6830 6733 if (uMsg >= WM_USER) 6831 6734 { 6832 // ERR(listview,"unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam,6833 //lParam);6735 ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, 6736 lParam); 6834 6737 } 6835 6738 -
trunk/src/comctl32/status.c
r110 r164 1 /* $Id: status.c,v 1. 4 1999-06-16 20:25:43 cbratschiExp $ */1 /* $Id: status.c,v 1.5 1999-06-23 19:45:01 achimha Exp $ */ 2 2 /* 3 3 * Interface code to StatusWindow widget/control … … 80 80 UINT border = BDR_SUNKENOUTER; 81 81 82 if (part->style ==SBT_POPOUT)82 if (part->style & SBT_POPOUT) 83 83 border = BDR_RAISEDOUTER; 84 else if (part->style ==SBT_NOBORDERS)84 else if (part->style & SBT_NOBORDERS) 85 85 border = 0; 86 86 … … 136 136 hOldFont = SelectObject (hdc, self->hFont ? self->hFont : self->hDefaultFont); 137 137 138 if (part->style ==SBT_OWNERDRAW) {138 if (part->style & SBT_OWNERDRAW) { 139 139 DRAWITEMSTRUCT dis; 140 140 … … 192 192 else { 193 193 for (i = 0; i < infoPtr->numParts; i++) { 194 if (infoPtr->parts[i].style ==SBT_OWNERDRAW) {194 if (infoPtr->parts[i].style & SBT_OWNERDRAW) { 195 195 DRAWITEMSTRUCT dis; 196 196 … … 365 365 part = &self->parts[nPart]; 366 366 367 if (part->style ==SBT_OWNERDRAW)367 if (part->style & SBT_OWNERDRAW) 368 368 result = (LRESULT)part->text; 369 369 else { … … 391 391 part = &infoPtr->parts[nPart]; 392 392 393 if (part->style ==SBT_OWNERDRAW)393 if (part->style & SBT_OWNERDRAW) 394 394 result = (LRESULT)part->text; 395 395 else { … … 571 571 if (oldNumParts > self->numParts) { 572 572 for (i = self->numParts ; i < oldNumParts; i++) { 573 if (self->parts[i].text && (self->parts[i].style !=SBT_OWNERDRAW))573 if (self->parts[i].text && !(self->parts[i].style & SBT_OWNERDRAW)) 574 574 COMCTL32_Free (self->parts[i].text); 575 575 } … … 635 635 STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd); 636 636 STATUSWINDOWPART *part; 637 int 638 int 637 int part_num; 638 int style; 639 639 LPSTR text; 640 int 640 int len; 641 641 HDC hdc; 642 642 … … 646 646 647 647 if ((self->simple) || (self->parts==NULL) || (part_num==255)) 648 648 part = &self->part0; 649 649 else 650 650 part = &self->parts[part_num]; 651 651 if (!part) return FALSE; 652 653 if (!(part->style & SBT_OWNERDRAW) && part->text) 654 COMCTL32_Free (part->text); 655 part->text = 0; 656 657 if (style & SBT_OWNERDRAW) { 658 part->text = (LPWSTR)text; 659 } 660 else { 661 /* duplicate string */ 662 if (text && (len = lstrlenA(text))) { 663 part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR)); 664 lstrcpyAtoW (part->text, text); 665 } 666 } 652 667 part->style = style; 653 if (style == SBT_OWNERDRAW) {654 part->text = (LPWSTR)text;655 }656 else {657 /* duplicate string */658 if (part->text)659 COMCTL32_Free (part->text);660 part->text = 0;661 if (text && (len = lstrlenA(text))) {662 part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));663 lstrcpyAtoW (part->text, text);664 }665 }666 668 667 669 hdc = GetDC (hwnd); … … 687 689 688 690 if ((self->simple) || (self->parts==NULL) || (part_num==255)) 689 691 part = &self->part0; 690 692 else 691 693 part = &self->parts[part_num]; 692 694 if (!part) return FALSE; 695 696 if (!(part->style & SBT_OWNERDRAW) && part->text) 697 COMCTL32_Free (part->text); 698 part->text = 0; 699 700 if (style & SBT_OWNERDRAW) { 701 part->text = text; 702 } 703 else { 704 /* duplicate string */ 705 if (text && (len = lstrlenW(text))) { 706 part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR)); 707 lstrcpyW(part->text, text); 708 } 709 } 693 710 part->style = style; 694 if (style == SBT_OWNERDRAW) {695 part->text = text;696 }697 else {698 /* duplicate string */699 if (part->text)700 COMCTL32_Free (part->text);701 part->text = 0;702 if (text && (len = lstrlenW(text))) {703 part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));704 lstrcpyW(part->text, text);705 }706 }707 711 708 712 hdc = GetDC (hwnd); … … 892 896 { 893 897 STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd); 894 int 898 int i; 895 899 896 900 for (i = 0; i < self->numParts; i++) { 897 if (self->parts[i].text && (self->parts[i].style !=SBT_OWNERDRAW))898 899 } 900 if (self->part0.text && (self->part0.style !=SBT_OWNERDRAW))901 901 if (self->parts[i].text && !(self->parts[i].style & SBT_OWNERDRAW)) 902 COMCTL32_Free (self->parts[i].text); 903 } 904 if (self->part0.text && !(self->part0.style & SBT_OWNERDRAW)) 905 COMCTL32_Free (self->part0.text); 902 906 COMCTL32_Free (self->parts); 903 907 904 908 /* delete default font */ 905 909 if (self->hDefaultFont) 906 910 DeleteObject (self->hDefaultFont); 907 911 908 912 /* delete tool tip control */ 909 913 if (self->hwndToolTip) 910 914 DestroyWindow (self->hwndToolTip); 911 915 912 916 COMCTL32_Free (self); -
trunk/src/comctl32/tab.c
r94 r164 1 /* $Id: tab.c,v 1. 4 1999-06-10 16:22:02achimha Exp $ */1 /* $Id: tab.c,v 1.5 1999-06-23 19:45:01 achimha Exp $ */ 2 2 /* 3 3 * Tab control … … 775 775 if (isVisible) 776 776 { 777 HBRUSH hbr = CreateSolidBrush (GetSysColor(COLOR_B ACKGROUND));777 HBRUSH hbr = CreateSolidBrush (GetSysColor(COLOR_BTNFACE)); 778 778 HPEN hwPen = GetSysColorPen (COLOR_3DHILIGHT); 779 779 HPEN hbPen = GetSysColorPen (COLOR_BTNSHADOW); … … 848 848 * Background color. 849 849 */ 850 hbr = CreateSolidBrush(GetSysColor(COLOR_B ACKGROUND));850 hbr = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); 851 851 852 852 /* … … 1087 1087 RECT clientRect; 1088 1088 1089 HBRUSH brush = CreateSolidBrush(GetSysColor(COLOR_B ACKGROUND));1089 HBRUSH brush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); 1090 1090 1091 1091 hdc = givenDC ? givenDC : GetDC(hwnd); -
trunk/src/comctl32/treeview.c
r110 r164 1 /* $Id: treeview.c,v 1. 4 1999-06-16 20:25:44 cbratschiExp $ */1 /* $Id: treeview.c,v 1.5 1999-06-23 19:45:02 achimha Exp $ */ 2 2 /* Treeview control 3 3 * … … 1148 1148 } 1149 1149 1150 if (tvItem->mask & TVIF_PARAM) {1151 tvItem->lParam=wineItem->lParam;1152 }1150 // undocumented: windows ignores TVIF_PARAM and 1151 // always sets lParam 1152 tvItem->lParam=wineItem->lParam; 1153 1153 1154 1154 if (tvItem->mask & TVIF_SELECTEDIMAGE) { … … 1507 1507 infoPtr->uNumPtrsAlloced/2 * sizeof(TREEVIEW_ITEM)); 1508 1508 memcpy (&infoPtr->freeList[0], &oldfreeList[0], 1509 infoPtr->uNumPtrsAlloced>>6* sizeof(INT));1509 (infoPtr->uNumPtrsAlloced>>6) * sizeof(INT)); 1510 1510 1511 1511 COMCTL32_Free (oldItems);
Note:
See TracChangeset
for help on using the changeset viewer.