Ignore:
Timestamp:
May 22, 2000, 7:25:13 PM (25 years ago)
Author:
cbratschi
Message:

merged with Corel WINE 20000513, added new DPA_* functions

File:
1 edited

Legend:

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

    r3520 r3585  
    1 /*$Id: listview.cpp,v 1.18 2000-05-10 19:50:32 cbratschi Exp $*/
     1/*$Id: listview.cpp,v 1.19 2000-05-22 17:25:08 cbratschi Exp $*/
    22/*
    33 * Listview control
     
    5050/*
    5151 Most identical with:
    52  - Corel 20000317 level
     52 - Corel 20000513 level
    5353 - (WINE 20000130 level)
    5454*/
     
    831831}
    832832
     833static BOOL LISTVIEW_IsItemSelected(LISTVIEW_INFO *infoPtr,INT nItem)
     834{
     835  LISTVIEW_ITEM *lpItem;
     836  INT pos = 0;
     837
     838  while ((lpItem = (LISTVIEW_ITEM*)DPA_GetPtr(infoPtr->hdpaSelItems,pos)) != NULL)
     839  {
     840    if (DPA_GetPtrIndex(infoPtr->hdpaItems,lpItem) == nItem) return TRUE;
     841    pos++;
     842  }
     843
     844  return FALSE;
     845}
     846
    833847/***
    834848 * DESCRIPTION:
     
    851865  for (i = nFirst; i <= nLast; i++)
    852866  {
    853     LISTVIEW_SetItemState(hwnd,i,LVIS_SELECTED,LVIS_SELECTED);
     867    if (!LISTVIEW_IsItemSelected(infoPtr,nItem))
     868    {
     869      LISTVIEW_SetItemState(hwnd,i,LVIS_SELECTED,LVIS_SELECTED);
     870    }
    854871  }
    855872
    856873  LISTVIEW_SetItemFocus(hwnd, nItem);
    857   infoPtr->nSelectionMark = nItem;
    858874}
    859875
     
    873889  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
    874890
    875   LISTVIEW_SetItemState(hwnd,nItem,LVIS_SELECTED,LVIS_SELECTED);
     891  if (!LISTVIEW_IsItemSelected(infoPtr,nItem))
     892  {
     893    LISTVIEW_SetItemState(hwnd,nItem,LVIS_SELECTED,LVIS_SELECTED);
     894  }
    876895
    877896  LISTVIEW_SetItemFocus(hwnd, nItem);
    878   infoPtr->nSelectionMark = nItem;
    879897}
    880898
     
    894912{
    895913  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
    896   BOOL bResult;
    897 
    898   if (LISTVIEW_GetItemState(hwnd, nItem, LVIS_SELECTED) & LVIS_SELECTED)
    899   {
    900     LISTVIEW_SetItemState(hwnd,nItem,0,LVIS_SELECTED);
    901     bResult = FALSE;
    902   }
    903   else
    904   {
    905     LISTVIEW_SetItemState(hwnd,nItem,LVIS_SELECTED,LVIS_SELECTED);
     914  BOOL bResult = FALSE;
     915  DWORD state = 0,stateMask = 0;
     916
     917  if (nItem != infoPtr->nFocusedItem)
     918  {
     919    stateMask = LVIS_FOCUSED;
     920    LISTVIEW_SetItemState(hwnd,infoPtr->nFocusedItem,state,stateMask);
     921  }
     922
     923  stateMask = LVIS_SELECTED;
     924  if (!LISTVIEW_IsItemSelected(infoPtr,nItem))
     925  {
    906926    bResult = TRUE;
    907   }
    908 
    909   LISTVIEW_SetItemFocus(hwnd, nItem);
     927    state = LVIS_SELECTED;
     928  }
    910929  infoPtr->nSelectionMark = nItem;
     930  LISTVIEW_SetItemState(hwnd,nItem,state,stateMask);
     931
     932  if (nItem != infoPtr->nFocusedItem)
     933  {
     934    state =  LVIS_FOCUSED;
     935    stateMask = LVIS_FOCUSED;
     936    infoPtr->nFocusedItem = nItem;
     937    LISTVIEW_SetItemState(hwnd,nItem,state,stateMask);
     938  }
    911939
    912940  return bResult;
     
    970998      if ((i < nFirst) || (i > nLast))
    971999      {
    972         LISTVIEW_SetItemState(hwnd,i,0,LVIS_SELECTED);
     1000        if (LISTVIEW_IsItemSelected(infoPtr,i))
     1001        {
     1002          LISTVIEW_SetItemState(hwnd,i,0,LVIS_SELECTED);
     1003        }
    9731004      }
    9741005      else
    9751006      {
    976         LISTVIEW_SetItemState(hwnd,i,LVIS_SELECTED,LVIS_SELECTED);
    977       }
    978     }
     1007        if (!LISTVIEW_IsItemSelected(infoPtr,i))
     1008        {
     1009          LISTVIEW_SetItemState(hwnd,i,LVIS_SELECTED,LVIS_SELECTED);
     1010        }
     1011      }
     1012    }
     1013    LISTVIEW_SetItemState(hwnd,infoPtr->nFocusedItem,0,LVIS_FOCUSED);
     1014
     1015    infoPtr->nFocusedItem = nItem;
     1016    LISTVIEW_SetItemState(hwnd,nItem,LVIS_SELECTED | LVIS_FOCUSED,LVIS_SELECTED | LVIS_FOCUSED);
     1017
    9791018  }
    9801019  else
     
    9911030    rcSel.bottom = max(ptSelMark.y, ptItem.y) + infoPtr->nItemHeight;
    9921031    LISTVIEW_SetSelectionRect(hwnd, rcSel);
    993   }
    994 
    995   LISTVIEW_SetItemFocus(hwnd, nItem);
     1032    LISTVIEW_SetItemFocus(hwnd, nItem);
     1033  }
    9961034}
    9971035
     
    36393677              if (isUnicodeNotify(&infoPtr->header))
    36403678              {
    3641                 Str_SetPtrW(&lpItemData->pszText,dispInfo.item.pszText);
     3679                Str_SetPtrW(&lpItemData->pszText,(dispInfo.item.pszText == LPSTR_TEXTCALLBACKW) ? NULL:dispInfo.item.pszText);
    36423680              } else
    36433681              {
    3644                 INT len = dispInfo.item.pszText ? lstrlenA((LPSTR)dispInfo.item.pszText):0;
     3682                INT len = (dispInfo.item.pszText && (dispInfo.item.pszText != LPSTR_TEXTCALLBACKW)) ? lstrlenA((LPSTR)dispInfo.item.pszText):0;
    36453683
    36463684                if (lpItemData->pszText != LPSTR_TEXTCALLBACKW) COMCTL32_Free(lpItemData->pszText);
     
    36543692            }
    36553693            /* Make sure the source string is valid */
    3656             if (!dispInfo.item.pszText)
     3694            if (!dispInfo.item.pszText || (dispInfo.item.pszText == LPSTR_TEXTCALLBACKW))
    36573695            {
    36583696              if (!internal)
     
    64866524  INT maxY = infoPtr->maxScroll.y-infoPtr->scrollPage.y,oldY = infoPtr->lefttop.y;
    64876525
     6526  if (infoPtr->hwndEdit)
     6527  {
     6528    SendMessageA(infoPtr->hwndEdit, WM_KILLFOCUS, 0, 0);
     6529  }
     6530
    64886531  switch (nScrollCode)
    64896532  {
     
    65676610  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)LISTVIEW_GetInfoPtr(hwnd);
    65686611  INT maxX = infoPtr->maxScroll.x-infoPtr->scrollPage.x,oldX = infoPtr->lefttop.x;
     6612
     6613  if (infoPtr->hwndEdit)
     6614  {
     6615    SendMessageA(infoPtr->hwndEdit, WM_KILLFOCUS, 0, 0);
     6616  }
    65696617
    65706618  switch (nScrollCode)
     
    67436791    break;
    67446792
     6793  case VK_NEXT:
     6794    if (infoPtr->uView == LVS_REPORT)
     6795    {
     6796      nItem = infoPtr->nFocusedItem + LISTVIEW_GetCountPerColumn(hwnd);
     6797    }
     6798    else
     6799    {
     6800      nItem = infoPtr->nFocusedItem + LISTVIEW_GetCountPerColumn(hwnd) * LISTVIEW_GetCountPerRow(hwnd);
     6801    }
     6802    if(nItem >= GETITEMCOUNT(infoPtr)) nItem = GETITEMCOUNT(infoPtr) - 1;
     6803    break;
     6804
    67456805  case VK_PRIOR:
    6746     /* TO DO */
    6747     break;
    6748 
    6749   case VK_NEXT:
    6750     /* TO DO */
     6806    if (infoPtr->uView == LVS_REPORT)
     6807    {
     6808      nItem = infoPtr->nFocusedItem - LISTVIEW_GetCountPerColumn(hwnd);
     6809    }
     6810    else
     6811    {
     6812      nItem = infoPtr->nFocusedItem - LISTVIEW_GetCountPerColumn(hwnd) * LISTVIEW_GetCountPerRow(hwnd);
     6813    }
     6814    if(nItem < 0) nItem = 0;
    67516815    break;
    67526816  }
     
    70117075  sendNotify(hwnd,NM_RELEASEDCAPTURE);
    70127076
    7013   if (infoPtr->bFocus == FALSE)
     7077  if (!infoPtr->bFocus)
    70147078    SetFocus(hwnd);
    70157079
     
    70247088    if (infoPtr->dwStyle & LVS_SINGLESEL)
    70257089    {
    7026       if ((LISTVIEW_GetItemState(hwnd, nItem, LVIS_SELECTED) & LVIS_SELECTED) && infoPtr->bDoEditLabel != TRUE)
     7090      if (LISTVIEW_IsItemSelected(infoPtr,nItem) && !infoPtr->bDoEditLabel)
    70277091        infoPtr->bDoEditLabel = TRUE;
    70287092      else
     
    70337097      if ((wKey & MK_CONTROL) && (wKey & MK_SHIFT))
    70347098      {
    7035         if (bGroupSelect != FALSE)
     7099        if (bGroupSelect)
    70367100        {
    70377101          LISTVIEW_AddGroupSelection(hwnd, nItem);
     
    70527116      else
    70537117      {
    7054         if ((LISTVIEW_GetItemState(hwnd, nItem, LVIS_SELECTED) & LVIS_SELECTED) && (infoPtr->bDoEditLabel != TRUE))
     7118        if (LISTVIEW_IsItemSelected(infoPtr,nItem) && !infoPtr->bDoEditLabel)
    70557119          infoPtr->bDoEditLabel = TRUE;
    70567120        else
Note: See TracChangeset for help on using the changeset viewer.