Changeset 2635 for trunk/src/comctl32/listview.c
- Timestamp:
- Feb 4, 2000, 6:02:09 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/listview.c
r2205 r2635 1 /*$Id: listview.c,v 1.2 0 1999-12-26 17:32:12cbratschi Exp $*/1 /*$Id: listview.c,v 1.21 2000-02-04 17:02:07 cbratschi Exp $*/ 2 2 /* 3 3 * Listview control … … 45 45 */ 46 46 47 /* WINE 991212level */47 /* WINE 20000130 level */ 48 48 49 49 #include <string.h> … … 59 59 60 60 /* maximum size of a label */ 61 #define DISP_TEXT_SIZE 12861 #define DISP_TEXT_SIZE 512 62 62 63 63 /* padding for items in list and small icon display modes */ … … 105 105 * forward declarations 106 106 */ 107 static LRESULT LISTVIEW_GetItemA(HWND hwnd, LPLVITEMA lpLVItem, BOOL internal); 107 108 static INT LISTVIEW_HitTestItem(HWND, LPLVHITTESTINFO); 108 109 static INT LISTVIEW_GetCountPerRow(HWND); … … 1783 1784 lvItem.cchTextMax = DISP_TEXT_SIZE; 1784 1785 lvItem.pszText = szDispText; 1785 L istView_GetItemA(hwnd, &lvItem);1786 LISTVIEW_GetItemA(hwnd,&lvItem,TRUE); 1786 1787 1787 1788 /* set item colors */ … … 1827 1828 lvItem.cchTextMax = DISP_TEXT_SIZE; 1828 1829 lvItem.pszText = szDispText; 1829 L istView_GetItemA(hwnd, &lvItem);1830 LISTVIEW_GetItemA(hwnd,&lvItem,TRUE); 1830 1831 1831 1832 /* state icons */ … … 1948 1949 lvItem.cchTextMax = DISP_TEXT_SIZE; 1949 1950 lvItem.pszText = szDispText; 1950 L istView_GetItemA(hwnd, &lvItem);1951 LISTVIEW_GetItemA(hwnd, &lvItem,TRUE); 1951 1952 1952 1953 if (lvItem.state & LVIS_SELECTED) … … 2740 2741 * FAILURE : 0 2741 2742 */ 2742 static LRESULT LISTVIEW_GetEditControl( hwnd)2743 static LRESULT LISTVIEW_GetEditControl(HWND hwnd) 2743 2744 { 2744 2745 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); … … 3158 3159 lvItem.iItem = nItem; 3159 3160 lvItem.iSubItem = 0; 3160 if (L istView_GetItemA(hwnd, &lvItem) != FALSE)3161 if (LISTVIEW_GetItemA(hwnd, &lvItem,TRUE) != FALSE) 3161 3162 { 3162 3163 if (lvItem.mask & LVIF_TEXT) … … 3529 3530 * [I] HWND : window handle 3530 3531 * [IO] LPLVITEMA : item info 3532 * [I] internal : if true then we will use tricks that avoid copies 3533 * but are not compatible with the regular interface 3531 3534 * 3532 3535 * RETURN: … … 3534 3537 * FAILURE : FALSE 3535 3538 */ 3536 static LRESULT LISTVIEW_GetItemA(HWND hwnd, LPLVITEMA lpLVItem )3539 static LRESULT LISTVIEW_GetItemA(HWND hwnd, LPLVITEMA lpLVItem, BOOL internal) 3537 3540 { 3538 3541 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0); 3539 3542 LONG lCtrlId = GetWindowLongA(hwnd, GWL_ID); 3540 BOOL bResult = FALSE;3541 3543 NMLVDISPINFOA dispInfo; 3542 3544 LISTVIEW_SUBITEM *lpSubItem; 3543 3545 LISTVIEW_ITEM *lpItem; 3546 INT* piImage; 3547 LPSTR* ppszText; 3544 3548 HDPA hdpaSubItems; 3545 3549 3546 // TRACE("(hwnd=%x, lpLVItem=%p)\n", hwnd, lpLVItem); 3547 3548 if (lpLVItem != NULL) 3549 { 3550 if ((lpLVItem->iItem >= 0) && (lpLVItem->iItem < GETITEMCOUNT(infoPtr))) 3551 { 3552 ZeroMemory(&dispInfo, sizeof(NMLVDISPINFOA)); 3553 hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, lpLVItem->iItem); 3554 if (hdpaSubItems != NULL) 3555 { 3556 lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0); 3557 if (lpItem != NULL) 3558 { 3559 bResult = TRUE; 3560 if (lpLVItem->iSubItem == 0) 3561 { 3562 if ((lpItem->iImage == I_IMAGECALLBACK) && 3563 (lpLVItem->mask & LVIF_IMAGE)) 3564 { 3565 dispInfo.item.mask |= LVIF_IMAGE; 3566 } 3567 3568 if ((lpItem->pszText == LPSTR_TEXTCALLBACKA) && 3569 (lpLVItem->mask & LVIF_TEXT)) 3570 { 3571 dispInfo.item.mask |= LVIF_TEXT; 3572 ZeroMemory(lpLVItem->pszText, sizeof(CHAR)*lpLVItem->cchTextMax); 3573 dispInfo.item.pszText = lpLVItem->pszText; 3574 dispInfo.item.cchTextMax = lpLVItem->cchTextMax; 3575 } 3576 3577 if ((infoPtr->uCallbackMask != 0) && (lpLVItem->mask & LVIF_STATE)) 3578 { 3579 dispInfo.item.mask |= LVIF_STATE; 3580 dispInfo.item.stateMask = infoPtr->uCallbackMask; 3581 } 3582 3583 if (dispInfo.item.mask != 0) 3584 { 3585 dispInfo.hdr.hwndFrom = hwnd; 3586 dispInfo.hdr.idFrom = lCtrlId; 3587 dispInfo.hdr.code = LVN_GETDISPINFOA; 3588 dispInfo.item.iItem = lpLVItem->iItem; 3589 dispInfo.item.iSubItem = 0; 3590 dispInfo.item.lParam = lpItem->lParam; 3591 ListView_Notify(GetParent(hwnd), lCtrlId, &dispInfo); 3592 } 3593 3594 if (dispInfo.item.mask & LVIF_IMAGE) 3595 { 3596 lpLVItem->iImage = dispInfo.item.iImage; 3597 } 3598 else if (lpLVItem->mask & LVIF_IMAGE) 3599 { 3600 lpLVItem->iImage = lpItem->iImage; 3601 } 3602 3603 if (dispInfo.item.mask & LVIF_TEXT) 3604 { 3605 if (dispInfo.item.mask & LVIF_DI_SETITEM) 3606 { 3607 Str_SetPtrA(&lpItem->pszText, dispInfo.item.pszText); 3608 } 3609 strncpy(lpLVItem->pszText, dispInfo.item.pszText, lpLVItem->cchTextMax); 3610 lpLVItem->pszText[lpLVItem->cchTextMax-1]='\0'; 3611 } 3612 else if (lpLVItem->mask & LVIF_TEXT) 3613 { 3614 strncpy(lpLVItem->pszText, lpItem->pszText, lpLVItem->cchTextMax); 3615 lpLVItem->pszText[lpLVItem->cchTextMax-1]='\0'; 3616 } 3617 3618 if (dispInfo.item.mask & LVIF_STATE) 3619 { 3620 lpLVItem->state = lpItem->state; 3621 lpLVItem->state &= ~dispInfo.item.stateMask; 3622 lpLVItem->state |= (dispInfo.item.state & 3623 dispInfo.item.stateMask); 3624 } 3625 else if (lpLVItem->mask & LVIF_STATE) 3626 { 3627 lpLVItem->state = lpItem->state & lpLVItem->stateMask; 3628 } 3629 3630 if (lpLVItem->mask & LVIF_PARAM) 3631 { 3632 lpLVItem->lParam = lpItem->lParam; 3633 } 3634 3635 if (lpLVItem->mask & LVIF_INDENT) 3636 { 3637 lpLVItem->iIndent = lpItem->iIndent; 3638 } 3639 } 3640 else 3641 { 3642 lpSubItem = LISTVIEW_GetSubItemPtr(hdpaSubItems, 3643 lpLVItem->iSubItem); 3644 if (lpSubItem != NULL) 3645 { 3646 if ((lpSubItem->iImage == I_IMAGECALLBACK) && 3647 (lpLVItem->mask & LVIF_IMAGE)) 3648 { 3649 dispInfo.item.mask |= LVIF_IMAGE; 3650 } 3651 3652 if ((lpSubItem->pszText == LPSTR_TEXTCALLBACKA) && 3653 (lpLVItem->mask & LVIF_TEXT)) 3654 { 3655 dispInfo.item.mask |= LVIF_TEXT; 3656 ZeroMemory(lpLVItem->pszText, 3657 sizeof(CHAR)*lpLVItem->cchTextMax); 3658 dispInfo.item.pszText = lpLVItem->pszText; 3659 dispInfo.item.cchTextMax = lpLVItem->cchTextMax; 3660 } 3661 } 3662 else 3663 { 3664 if (lpLVItem->mask & LVIF_IMAGE) 3665 { 3666 dispInfo.item.mask |= LVIF_IMAGE; 3667 } 3668 3669 if (lpLVItem->mask & LVIF_TEXT) 3670 { 3671 dispInfo.item.mask |= LVIF_TEXT; 3672 ZeroMemory(lpLVItem->pszText, 3673 sizeof(CHAR)*lpLVItem->cchTextMax); 3674 dispInfo.item.pszText = lpLVItem->pszText; 3675 dispInfo.item.cchTextMax = lpLVItem->cchTextMax; 3676 } 3677 } 3678 3679 if (dispInfo.item.mask != 0) 3680 { 3681 dispInfo.hdr.hwndFrom = hwnd; 3682 dispInfo.hdr.idFrom = lCtrlId; 3683 dispInfo.hdr.code = LVN_GETDISPINFOA; 3684 dispInfo.item.iItem = lpLVItem->iItem; 3685 dispInfo.item.iSubItem = lpLVItem->iSubItem; 3686 dispInfo.item.lParam = lpItem->lParam; 3687 ListView_Notify(GetParent(hwnd), lCtrlId, &dispInfo); 3688 } 3689 3690 if (dispInfo.item.mask & LVIF_IMAGE) 3691 { 3692 lpLVItem->iImage = dispInfo.item.iImage; 3693 } 3694 else if (lpLVItem->mask & LVIF_IMAGE) 3695 { 3696 lpLVItem->iImage = lpItem->iImage; 3697 } 3698 3699 if (dispInfo.item.mask & LVIF_TEXT) 3700 { 3701 if (dispInfo.item.mask & LVIF_DI_SETITEM) 3702 { 3703 if (lpSubItem) 3704 Str_SetPtrA(&lpSubItem->pszText, dispInfo.item.pszText); 3705 } 3706 strncpy(lpLVItem->pszText, dispInfo.item.pszText, lpLVItem->cchTextMax); 3707 lpLVItem->pszText[lpLVItem->cchTextMax-1]='\0'; 3708 } 3709 else if (lpLVItem->mask & LVIF_TEXT) 3710 { 3711 strncpy(lpLVItem->pszText, lpSubItem->pszText, lpLVItem->cchTextMax); 3712 lpLVItem->pszText[lpLVItem->cchTextMax-1]='\0'; 3713 } 3714 } 3715 } 3716 } 3717 } 3718 } 3719 3720 return bResult; 3550 /* In the following: 3551 * lpLVItem describes the information requested by the user 3552 * lpItem/lpSubItem is what we have 3553 * dispInfo is a structure we use to request the missing 3554 * information from the application 3555 */ 3556 3557 //TRACE("(hwnd=%x, lpLVItem=%p)\n", hwnd, lpLVItem); 3558 if ((lpLVItem == NULL) || 3559 (lpLVItem->iItem < 0) || 3560 (lpLVItem->iItem >= GETITEMCOUNT(infoPtr)) 3561 ) 3562 return FALSE; 3563 hdpaSubItems = (HDPA)DPA_GetPtr(infoPtr->hdpaItems, lpLVItem->iItem); 3564 if (hdpaSubItems == NULL) 3565 return FALSE; 3566 lpItem = (LISTVIEW_ITEM *)DPA_GetPtr(hdpaSubItems, 0); 3567 if (lpItem == NULL) 3568 return FALSE; 3569 ZeroMemory(&dispInfo, sizeof(NMLVDISPINFOA)); 3570 if (lpLVItem->iSubItem == 0) 3571 { 3572 piImage=&lpItem->iImage; 3573 ppszText=&lpItem->pszText; 3574 if ((infoPtr->uCallbackMask != 0) && (lpLVItem->mask & LVIF_STATE)) 3575 { 3576 dispInfo.item.mask |= LVIF_STATE; 3577 dispInfo.item.stateMask = infoPtr->uCallbackMask; 3578 } 3579 } 3580 else 3581 { 3582 lpSubItem = LISTVIEW_GetSubItemPtr(hdpaSubItems, lpLVItem->iSubItem); 3583 if (lpSubItem != NULL) 3584 { 3585 piImage=&lpItem->iImage; 3586 ppszText=&lpItem->pszText; 3587 } 3588 else 3589 { 3590 piImage=NULL; 3591 ppszText=NULL; 3592 } 3593 } 3594 if ((lpLVItem->mask & LVIF_IMAGE) && 3595 ((piImage==NULL) || (*piImage == I_IMAGECALLBACK))) 3596 { 3597 dispInfo.item.mask |= LVIF_IMAGE; 3598 } 3599 if ((lpLVItem->mask & LVIF_TEXT) && 3600 ((ppszText==NULL) || (*ppszText == LPSTR_TEXTCALLBACKA))) 3601 { 3602 dispInfo.item.mask |= LVIF_TEXT; 3603 dispInfo.item.pszText = lpLVItem->pszText; 3604 dispInfo.item.cchTextMax = lpLVItem->cchTextMax; 3605 } 3606 if (dispInfo.item.mask != 0) 3607 { 3608 /* We don't have all the requested info, query the application */ 3609 dispInfo.hdr.hwndFrom = hwnd; 3610 dispInfo.hdr.idFrom = lCtrlId; 3611 dispInfo.hdr.code = LVN_GETDISPINFOA; 3612 dispInfo.item.iItem = lpLVItem->iItem; 3613 dispInfo.item.iSubItem = lpLVItem->iSubItem; 3614 dispInfo.item.lParam = lpItem->lParam; 3615 ListView_Notify(GetParent(hwnd), lCtrlId, &dispInfo); 3616 } 3617 if (dispInfo.item.mask & LVIF_IMAGE) 3618 { 3619 lpLVItem->iImage = dispInfo.item.iImage; 3620 } 3621 else if (lpLVItem->mask & LVIF_IMAGE) 3622 { 3623 lpLVItem->iImage = *piImage; 3624 } 3625 if (dispInfo.item.mask & LVIF_TEXT) 3626 { 3627 if ((dispInfo.item.mask & LVIF_DI_SETITEM) && (ppszText != NULL)) 3628 { 3629 Str_SetPtrA(ppszText, dispInfo.item.pszText); 3630 } 3631 /* Here lpLVItem->pszText==dispInfo.item.pszText so a copy is unnecessary */ 3632 } 3633 else if (lpLVItem->mask & LVIF_TEXT) 3634 { 3635 if (internal==TRUE) 3636 { 3637 lpLVItem->pszText=*ppszText; 3638 } else { 3639 lstrcpynA(lpLVItem->pszText, *ppszText, lpLVItem->cchTextMax); 3640 } 3641 } 3642 if (lpLVItem->iSubItem == 0) 3643 { 3644 if (dispInfo.item.mask & LVIF_STATE) 3645 { 3646 lpLVItem->state = lpItem->state; 3647 lpLVItem->state &= ~dispInfo.item.stateMask; 3648 lpLVItem->state |= (dispInfo.item.state & dispInfo.item.stateMask); 3649 } 3650 else if (lpLVItem->mask & LVIF_STATE) 3651 { 3652 lpLVItem->state = lpItem->state & lpLVItem->stateMask; 3653 } 3654 if (lpLVItem->mask & LVIF_PARAM) 3655 { 3656 lpLVItem->lParam = lpItem->lParam; 3657 } 3658 if (lpLVItem->mask & LVIF_INDENT) 3659 { 3660 lpLVItem->iIndent = lpItem->iIndent; 3661 } 3662 } 3663 return TRUE; 3721 3664 } 3722 3665 … … 4195 4138 lvItem.cchTextMax = DISP_TEXT_SIZE; 4196 4139 lvItem.pszText = szDispText; 4197 if (L istView_GetItemA(hwnd, &lvItem) != FALSE)4140 if (LISTVIEW_GetItemA(hwnd, &lvItem,TRUE) != FALSE) 4198 4141 { 4199 4142 nLabelWidth = ListView_GetStringWidthA(hwnd, lvItem.pszText); … … 4256 4199 lvItem.stateMask = uMask; 4257 4200 lvItem.mask = LVIF_STATE; 4258 if (L istView_GetItemA(hwnd, &lvItem) != FALSE)4201 if (LISTVIEW_GetItemA(hwnd, &lvItem,TRUE) != FALSE) 4259 4202 { 4260 4203 uState = lvItem.state; … … 4289 4232 lpLVItem->mask = LVIF_TEXT; 4290 4233 lpLVItem->iItem = nItem; 4291 if (L istView_GetItemA(hwnd, lpLVItem) != FALSE)4234 if (LISTVIEW_GetItemA(hwnd, lpLVItem,FALSE) != FALSE) 4292 4235 { 4293 4236 nLength = lstrlenA(lpLVItem->pszText); … … 7064 7007 7065 7008 case LVM_GETITEMA: 7066 return LISTVIEW_GetItemA(hwnd, (LPLVITEMA)lParam );7009 return LISTVIEW_GetItemA(hwnd, (LPLVITEMA)lParam,FALSE); 7067 7010 7068 7011 /* case LVM_GETITEMW: */
Note:
See TracChangeset
for help on using the changeset viewer.