Changeset 3351 for trunk/src


Ignore:
Timestamp:
Apr 8, 2000, 8:32:55 PM (25 years ago)
Author:
cbratschi
Message:

new functionality, bug fixes

Location:
trunk/src/comctl32
Files:
3 edited

Legend:

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

    r3182 r3351  
    1 /* $Id: header.cpp,v 1.4 2000-03-21 17:30:41 cbratschi Exp $ */
     1/* $Id: header.cpp,v 1.5 2000-04-08 18:32:53 cbratschi Exp $ */
    22/*
    33 *  Header control
     
    4040#define HEADER_GetInfoPtr(hwnd) ((HEADER_INFO*)getInfoPtr(hwnd))
    4141
    42 static VOID
    43 HEADER_DrawItemImage(HWND hwnd,HDC hdc,HEADER_INFO* infoPtr,HEADER_ITEM* phdi,RECT* r,INT iItem)
     42static INT HEADER_CallbackImage(HWND hwnd,HEADER_INFO* infoPtr,HEADER_ITEM* phdi,INT iItem)
     43{
     44  NMHDDISPINFOW nmhdr;
     45
     46  nmhdr.iItem      = iItem;
     47  nmhdr.mask       = HDI_IMAGE;
     48  nmhdr.iImage     = 0;
     49  nmhdr.lParam     = phdi->lParam;
     50  sendNotify(hwnd,isUnicodeNotify(&infoPtr->header) ? HDN_GETDISPINFOW:HDN_GETDISPINFOA,&nmhdr.hdr);
     51
     52  if (nmhdr.mask & HDI_DI_SETITEM) phdi->iImage = nmhdr.iImage;
     53
     54  return nmhdr.iImage;
     55}
     56
     57static VOID HEADER_DrawItemImage(HWND hwnd,HDC hdc,HEADER_INFO* infoPtr,HEADER_ITEM* phdi,RECT* r,INT iItem)
    4458{
    4559  if (phdi->fmt & HDF_IMAGE)
     
    5064
    5165    if (phdi->iImage == I_IMAGECALLBACK)
    52     {
    53       NMHDDISPINFOW nmhdr;
    54 
    55       nmhdr.iItem      = iItem;
    56       nmhdr.mask       = HDI_IMAGE;
    57       nmhdr.iImage     = 0;
    58       nmhdr.lParam     = phdi->lParam;
    59       sendNotify(hwnd,isUnicodeNotify(&infoPtr->header) ? HDN_GETDISPINFOW:HDN_GETDISPINFOA,&nmhdr.hdr);
    60 
    61       iImage = nmhdr.iImage;
    62       if (nmhdr.mask & HDI_DI_SETITEM) phdi->iImage = iImage;
    63     } else iImage = phdi->iImage;
    64 
     66      iImage = HEADER_CallbackImage(hwnd,infoPtr,phdi,iItem);
     67    else
     68      iImage = phdi->iImage;
     69
     70    if (iImage == I_IMAGENONE) return;
    6571    if (!ImageList_GetImageInfo(infoPtr->himl,phdi->iImage,&info)) return;
    6672    w = info.rcImage.right-info.rcImage.left;
     
    186192    DeleteDC (hdcBitmap);
    187193  }
     194}
     195
     196static WCHAR* HEADER_CallbackText(HWND hwnd,HEADER_INFO* infoPtr,HEADER_ITEM* phdi,INT iItem,BOOL* mustFree)
     197{
     198  NMHDDISPINFOW nmhdr;
     199  WCHAR* orgPtr;
     200
     201  nmhdr.iItem      = iItem;
     202  nmhdr.mask       = HDI_TEXT;
     203  nmhdr.cchTextMax = phdi->cchTextMax;
     204  if (isUnicodeNotify(&infoPtr->header))
     205  {
     206    orgPtr = (WCHAR*)COMCTL32_Alloc(phdi->cchTextMax*sizeof(WCHAR));
     207    nmhdr.pszText    = orgPtr;
     208    if (nmhdr.pszText) nmhdr.pszText[0] = 0;
     209  } else
     210  {
     211    orgPtr = (WCHAR*)COMCTL32_Alloc(phdi->cchTextMax*sizeof(CHAR));
     212    nmhdr.pszText    = orgPtr;
     213    if (nmhdr.pszText) ((LPSTR)nmhdr.pszText)[0] = 0;
     214  }
     215  nmhdr.lParam     = phdi->lParam;
     216  sendNotify(hwnd,isUnicodeNotify(&infoPtr->header) ? HDN_GETDISPINFOW:HDN_GETDISPINFOA,&nmhdr.hdr);
     217
     218  if (nmhdr.pszText == LPSTR_TEXTCALLBACKW)
     219  {
     220    *mustFree = FALSE;
     221    return NULL;
     222  }
     223
     224  if (nmhdr.mask & HDI_DI_SETITEM)
     225  {
     226    if (isUnicodeNotify(&infoPtr->header))
     227    {
     228      INT len = nmhdr.pszText ? lstrlenW(nmhdr.pszText):0;
     229
     230      if (len)
     231      {
     232        phdi->pszText = (WCHAR*)COMCTL32_Alloc((len+1)*sizeof(WCHAR));
     233        lstrcpyW(phdi->pszText,nmhdr.pszText);
     234      } else phdi->pszText = NULL;
     235      if (nmhdr.pszText == orgPtr) COMCTL32_Free(nmhdr.pszText);
     236    } else
     237    {
     238      INT len = nmhdr.pszText ? lstrlenA((LPSTR)nmhdr.pszText):0;
     239
     240      if (len)
     241      {
     242        phdi->pszText = (WCHAR*)COMCTL32_Alloc((len+1)*sizeof(WCHAR));
     243        lstrcpyAtoW(phdi->pszText,(LPSTR)nmhdr.pszText);
     244      } else phdi->pszText = NULL;
     245    }
     246    COMCTL32_Free(orgPtr);
     247    *mustFree = FALSE;
     248
     249    return phdi->pszText;
     250  }
     251  if (nmhdr.pszText != orgPtr)
     252  {
     253    COMCTL32_Free(orgPtr);
     254    *mustFree = FALSE;
     255  } else *mustFree = TRUE;
     256
     257  return nmhdr.pszText;
    188258}
    189259
     
    252322    {
    253323      UINT uTextJustify;
    254       WCHAR *pszText = phdi->pszText,*orgPtr;
     324      WCHAR *pszText;
     325      BOOL mustFree = FALSE;
    255326
    256327      if ((phdi->fmt & HDF_JUSTIFYMASK) == HDF_CENTER)
     
    261332
    262333      if (phdi->pszText == LPSTR_TEXTCALLBACKW)
    263       {
    264         NMHDDISPINFOW nmhdr;
    265 
    266         nmhdr.iItem      = iItem;
    267         nmhdr.mask       = HDI_TEXT;
    268         nmhdr.cchTextMax = phdi->cchTextMax;
    269         if (isUnicodeNotify(&infoPtr->header))
    270         {
    271           orgPtr = (WCHAR*)COMCTL32_Alloc(phdi->cchTextMax*sizeof(WCHAR));
    272           nmhdr.pszText    = orgPtr;
    273           if (nmhdr.pszText) nmhdr.pszText[0] = 0;
    274         } else
    275         {
    276           orgPtr = (WCHAR*)COMCTL32_Alloc(phdi->cchTextMax*sizeof(CHAR));
    277           nmhdr.pszText    = orgPtr;
    278           if (nmhdr.pszText) ((LPSTR)nmhdr.pszText)[0] = 0;
    279         }
    280         nmhdr.lParam     = phdi->lParam;
    281         sendNotify(hwnd,isUnicodeNotify(&infoPtr->header) ? HDN_GETDISPINFOW:HDN_GETDISPINFOA,&nmhdr.hdr);
    282 
    283         pszText = nmhdr.pszText;
    284         if (nmhdr.mask & HDI_DI_SETITEM)
    285         {
    286           if (isUnicodeNotify(&infoPtr->header))
    287           {
    288             INT len = pszText ? lstrlenW(pszText):0;
    289 
    290             if (len)
    291             {
    292               phdi->pszText = (WCHAR*)COMCTL32_Alloc((len+1)*sizeof(WCHAR));
    293               lstrcpyW(phdi->pszText,pszText);
    294             } else phdi->pszText = NULL;
    295             if (pszText == orgPtr) COMCTL32_Free(pszText);
    296             pszText = phdi->pszText;
    297           } else
    298           {
    299             INT len = nmhdr.pszText ? lstrlenA((LPSTR)nmhdr.pszText):0;
    300 
    301             if (len)
    302             {
    303               pszText = (WCHAR*)COMCTL32_Alloc((len+1)*sizeof(WCHAR));
    304               lstrcpyAtoW(pszText,(LPSTR)nmhdr.pszText);
    305             } else pszText = NULL;
    306             if (nmhdr.pszText == orgPtr) COMCTL32_Free(nmhdr.pszText);
    307 
    308             phdi->pszText = pszText;
    309           }
    310         }
    311       }
     334        pszText = HEADER_CallbackText(hwnd,infoPtr,phdi,iItem,&mustFree);
     335      else
     336        pszText = phdi->pszText;
    312337
    313338      if (!(phdi->fmt & HDF_JUSTIFYMASK) || (phdi->fmt & (HDF_LEFT | HDF_CENTER)))
     
    330355        }
    331356      }
    332       if ((phdi->pszText == LPSTR_TEXTCALLBACKW) && (pszText == orgPtr)) COMCTL32_Free(pszText);
     357      if (mustFree) COMCTL32_Free(pszText);
    333358    }
    334359
     
    10821107
    10831108
    1084 static LRESULT
    1085 HEADER_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
     1109LRESULT HEADER_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
    10861110{
    10871111    HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
     
    10971121
    10981122    return TRUE;
     1123}
     1124
     1125//useful function for ListView control
     1126
     1127DWORD HEADER_GetExpandedColumnTextWidth(HWND hwnd,INT iItem)
     1128{
     1129  HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd);
     1130  INT width = 0;
     1131  HEADER_ITEM *phdi;
     1132
     1133  if ((iItem < 0) || (iItem >= (INT)infoPtr->uNumItem)) return width;
     1134
     1135  phdi = &infoPtr->items[iItem];
     1136
     1137  if (GetWindowLongA (hwnd, GWL_STYLE) & HDS_BUTTONS)
     1138    width += 4;
     1139  else
     1140    width += 2;
     1141
     1142  if (phdi->fmt & HDF_OWNERDRAW)
     1143  {
     1144    //can't calculate ownerdraw
     1145    return infoPtr->items[iItem].rect.right-infoPtr->items[iItem].rect.left;
     1146  }
     1147
     1148  if (phdi->fmt & HDF_BITMAP)
     1149  {
     1150    if (phdi->hbm)
     1151    {
     1152      BITMAP bmp;
     1153
     1154      GetObjectA (phdi->hbm,sizeof(BITMAP),(LPVOID)&bmp);
     1155
     1156      width += bmp.bmWidth+2*infoPtr->xBmpMargin;
     1157    } else width += 2*infoPtr->xBmpMargin;
     1158  }
     1159
     1160  if (phdi->fmt & HDF_IMAGE)
     1161  {
     1162    INT iImage;
     1163    IMAGEINFO info;
     1164
     1165    if (phdi->iImage == I_IMAGECALLBACK)
     1166      iImage = HEADER_CallbackImage(hwnd,infoPtr,phdi,iItem);
     1167    else
     1168      iImage = phdi->iImage;
     1169
     1170    if (iImage != I_IMAGENONE)
     1171    {
     1172      if (ImageList_GetImageInfo(infoPtr->himl,phdi->iImage,&info))
     1173      {
     1174        width += info.rcImage.right-info.rcImage.left+2*infoPtr->xBmpMargin;
     1175      }
     1176    }
     1177  }
     1178
     1179  if (phdi->fmt & HDF_STRING)
     1180  {
     1181    WCHAR* pszText;
     1182    BOOL mustFree = FALSE;
     1183    HFONT hFont,hOldFont;
     1184    SIZE size;
     1185    HDC hdc = GetDC(hwnd);
     1186
     1187    if (phdi->pszText == LPSTR_TEXTCALLBACKW)
     1188      pszText = HEADER_CallbackText(hwnd,infoPtr,phdi,iItem,&mustFree);
     1189    else
     1190      pszText = phdi->pszText;
     1191
     1192    hFont = infoPtr->hFont ? infoPtr->hFont:GetStockObject(SYSTEM_FONT);
     1193    hOldFont = SelectObject(hdc,hFont);
     1194
     1195    if (GetTextExtentPoint32W(hdc,pszText,lstrlenW(pszText),&size))
     1196      width += size.cx+2*TEXT_MARGIN;
     1197    if (mustFree) COMCTL32_Free(pszText);
     1198    SelectObject(hdc,hOldFont);
     1199    ReleaseDC(hwnd,hdc);
     1200  }
     1201
     1202  return width;
    10991203}
    11001204
  • trunk/src/comctl32/listview.cpp

    r3285 r3351  
    1 /*$Id: listview.cpp,v 1.10 2000-03-31 14:44:20 cbratschi Exp $*/
     1/*$Id: listview.cpp,v 1.11 2000-04-08 18:32:54 cbratschi Exp $*/
    22/*
    33 * Listview control
     
    5151#include "listview.h"
    5252#include "comctl32.h"
     53#include "header.h"
    5354#include "ctype.h"
    5455
     
    119120static BOOL    LISTVIEW_GetItemPosition(HWND, INT, LPPOINT);
    120121static LRESULT LISTVIEW_GetItemRect(HWND hwnd,INT nItem,LPRECT lprc,INT code);
    121 static LRESULT LISTVIEW_GetItemRect(HWND, INT, LPRECT);
    122122static INT     LISTVIEW_GetItemWidth(HWND);
    123123static INT     LISTVIEW_GetLabelWidth(HWND, INT);
     
    180180}
    181181
    182 static VOID LISTVIEW_RefreshItem(HWND hwnd,INT nItem)
     182static VOID LISTVIEW_RefreshItem(HWND hwnd,INT nItem,BOOL wholeItem)
    183183{
    184184  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)LISTVIEW_GetInfoPtr(hwnd);
     
    186186
    187187  if (infoPtr->internalFlags & IF_NOREDRAW) return;
    188   LISTVIEW_GetItemRect(hwnd,nItem,&rect,LVIR_SELECTBOUNDS);
     188  LISTVIEW_GetItemRect(hwnd,nItem,&rect,wholeItem ? LVIR_BOUNDS:LVIR_SELECTBOUNDS);
    189189
    190190  if ((infoPtr->uView == LVS_REPORT) && !(infoPtr->dwStyle & LVS_NOCOLUMNHEADER))
     
    192192    RECT header;
    193193    INT headerH;
    194 
     194    RECT rect2;
     195
     196    //clip header control
    195197    GetWindowRect(infoPtr->hwndHeader,&header);
    196198    headerH = rect.bottom-rect.top;
    197199    if (rect.bottom <= headerH) return;
    198200    if (rect.top < headerH) rect.top = headerH;
     201    //clip width
     202    HEADER_GetItemRect(infoPtr->hwndHeader,(WPARAM)0,(LPARAM)&rect2);
     203    if (rect.right > rect2.right) rect.right = rect2.right;
    199204  }
    200205
     
    205210{
    206211  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)LISTVIEW_GetInfoPtr(hwnd);
    207   RECT rect,header;
     212  RECT rect,column;
    208213  INT xOffset = infoPtr->lefttop.x*infoPtr->scrollStep.x;
    209214
    210215  if (infoPtr->internalFlags & IF_NOREDRAW) return;
     216  if (infoPtr->uView != LVS_REPORT) return;
    211217  LISTVIEW_GetItemRect(hwnd,nItem,&rect,LVIR_SELECTBOUNDS);
    212218
    213   //get header rect
    214   Header_GetItemRect(infoPtr->hwndHeader,nSubItem,&header);
    215   rect.left = header.left+REPORT_MARGINX;
    216   rect.right = max(header.left,header.right-REPORT_MARGINX);
     219  //get column rect
     220  HEADER_GetItemRect(infoPtr->hwndHeader,(WPARAM)nSubItem,(LPARAM)&column);
     221  rect.left = column.left+REPORT_MARGINX;
     222  rect.right = max(column.left,column.right-REPORT_MARGINX);
    217223
    218224  if (!(infoPtr->dwStyle & LVS_NOCOLUMNHEADER))
    219225  {
     226    RECT header;
    220227    INT headerH;
    221228
     229    //clip header control
    222230    GetWindowRect(infoPtr->hwndHeader,&header);
    223231    headerH = rect.bottom-rect.top;
     
    11811189  for (i = nFirst;i < nLast;i++)
    11821190  {
    1183     rcItem.left = LVIR_SELECTBOUNDS;
    1184     if (LISTVIEW_GetItemRect(hwnd,i,&rcItem) && PtInRect(&rcItem,pt))
     1191    if (LISTVIEW_GetItemRect(hwnd,i,&rcItem,LVIR_SELECTBOUNDS) && PtInRect(&rcItem,pt))
    11851192      return i;
    11861193  }
     
    13051312 *
    13061313 * RETURN:
    1307  *   SUCCCESS : TRUE (EQUAL)
    1308  *   FAILURE : FALSE (NOT EQUAL)
     1314 *   LVIF_* flags
    13091315 */
    13101316static UINT LISTVIEW_GetItemChanges(LISTVIEW_ITEM *lpItem,LPLVITEMW lpLVItem,BOOL unicode)
     
    14121418              if (lpItem->pszText)
    14131419              {
    1414                 LPWSTR textW = HEAP_strdupAtoW(GetProcessHeap(),0,(LPSTR)lpLVItem->pszText);
    1415 
    1416                 //CB: need a lstrcmpAtoW
    1417                 if (lstrcmpW(textW,lpItem->pszText) != 0)
     1420                if (lstrcmpAtoW((LPSTR)lpLVItem->pszText,lpItem->pszText) != 0)
    14181421                {
    14191422                  uChanged |= LVIF_TEXT;
    14201423                }
    1421                 HeapFree(GetProcessHeap(),0,textW);
    14221424              }
    14231425              else
     
    14381440    }
    14391441  }
     1442
    14401443  return uChanged;
    14411444}
     
    28312834 *   FAILURE : FALSE
    28322835 */
    2833 //CB: unicode parameter not used, edit doesn't use unicode chars
    28342836static HWND LISTVIEW_EditLabel(HWND hwnd, INT nItem,BOOL unicode)
    28352837{
     
    28932895    return 0;
    28942896
    2895   rect.left = LVIR_LABEL;
    2896   if (!LISTVIEW_GetItemRect(hwnd, nItem, &rect))
     2897  if (!LISTVIEW_GetItemRect(hwnd, nItem, &rect,LVIR_LABEL))
    28972898    return 0;
    28982899
     
    29452946  /* ALWAYS bPartial == FALSE, FOR NOW! */
    29462947
    2947   rcItem.left = LVIR_BOUNDS;
    2948   if (LISTVIEW_GetItemRect(hwnd, nItem, &rcItem))
     2948  if (LISTVIEW_GetItemRect(hwnd, nItem, &rcItem,LVIR_BOUNDS))
    29492949  {
    29502950    if (rcItem.left < infoPtr->rcList.left)
     
    34833483{
    34843484  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
    3485   INT nColumnWidth = 0;
    3486   HDITEMA hdi;
    34873485
    34883486  if (infoPtr->uView == LVS_LIST)
    34893487  {
    3490     nColumnWidth = infoPtr->nItemWidth;
    3491   }
    3492   else if (infoPtr->uView == LVS_REPORT)
    3493   {
     3488    return infoPtr->nItemWidth;
     3489  } else if (infoPtr->uView == LVS_REPORT)
     3490  {
     3491    HDITEMA hdi;
     3492
    34943493    /* get column width from header */
    34953494    ZeroMemory(&hdi, sizeof(HDITEMA));
    34963495    hdi.mask = HDI_WIDTH;
    3497     if (Header_GetItemW(infoPtr->hwndHeader, nColumn, &hdi) != FALSE)
    3498     {
    3499       nColumnWidth = hdi.cxy;
    3500     }
    3501   }
    3502 
    3503   return nColumnWidth;
     3496    if (Header_GetItemW(infoPtr->hwndHeader, nColumn, &hdi))
     3497    {
     3498      return hdi.cxy;
     3499    }
     3500  }
     3501
     3502  return 0;
    35043503}
    35053504
     
    40874086  INT nCountPerColumn;
    40884087  INT nRow;
    4089 //CB: lefttop position not used!!!
    4090   if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr)) &&
    4091       (lpptPosition != NULL))
     4088
     4089  if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr)) && lpptPosition)
    40924090  {
    40934091    if (infoPtr->uView == LVS_LIST)
     
    41424140}
    41434141
    4144 //same as ListView_GetItemRect, but direct call
    4145 static LRESULT LISTVIEW_GetItemRect(HWND hwnd,INT nItem,LPRECT lprc,INT code)
    4146 {
    4147   if (lprc) lprc->left = code;
    4148   return LISTVIEW_GetItemRect(hwnd,nItem,lprc);
    4149 }
    4150 
    41514142/***
    41524143 * DESCRIPTION:
     
    41624153 *   FAILURE : FALSE
    41634154 */
    4164 static LRESULT LISTVIEW_GetItemRect(HWND hwnd, INT nItem, LPRECT lprc)
     4155static LRESULT LISTVIEW_GetItemRect(HWND hwnd,INT nItem,LPRECT lprc,INT code)
    41654156{
    41664157  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd);
     
    41734164  INT nLabelWidth;
    41744165  TEXTMETRICA tm;
    4175 //CB: todo: LVS_REPORT view: clip text rect to header item width!
    4176 //          large icon view: text rect is wrong!
    4177   if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr)) && (lprc != NULL))
     4166
     4167  if ((nItem >= 0) && (nItem < GETITEMCOUNT(infoPtr)) && lprc)
    41784168  {
    41794169    if (LISTVIEW_GetItemPosition(hwnd, nItem, &ptItem) != FALSE)
    41804170    {
    4181       switch(lprc->left)
    4182       {
    4183       case LVIR_ICON:
    4184         if (infoPtr->uView == LVS_ICON)
    4185         {
    4186           if (infoPtr->himlNormal != NULL)
     4171      switch(code)
     4172      {
     4173        case LVIR_ICON:
     4174          if (infoPtr->uView == LVS_ICON)
    41874175          {
    4188             if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE)
     4176            if (infoPtr->himlNormal)
     4177            {
     4178              if (LISTVIEW_GetOrigin(hwnd, &ptOrigin))
     4179              {
     4180                bResult = TRUE;
     4181                lprc->left = ptItem.x + ptOrigin.x;
     4182                lprc->top = ptItem.y + ptOrigin.y;
     4183                lprc->right = lprc->left + infoPtr->iconSize.cx;
     4184                lprc->bottom = (lprc->top + infoPtr->iconSize.cy +
     4185                                ICON_BOTTOM_PADDING + ICON_TOP_PADDING);
     4186              }
     4187            }
     4188          }
     4189          else if (infoPtr->uView == LVS_SMALLICON)
     4190          {
     4191            if (LISTVIEW_GetOrigin(hwnd, &ptOrigin))
    41894192            {
    41904193              bResult = TRUE;
    41914194              lprc->left = ptItem.x + ptOrigin.x;
    41924195              lprc->top = ptItem.y + ptOrigin.y;
    4193               lprc->right = lprc->left + infoPtr->iconSize.cx;
    4194               lprc->bottom = (lprc->top + infoPtr->iconSize.cy +
    4195                               ICON_BOTTOM_PADDING + ICON_TOP_PADDING);
     4196              lprc->bottom = lprc->top + infoPtr->nItemHeight;
     4197
     4198              if (infoPtr->himlState)
     4199                lprc->left += infoPtr->iconSize.cx;
     4200
     4201              if (infoPtr->himlSmall)
     4202                lprc->right = lprc->left + infoPtr->iconSize.cx;
     4203              else
     4204                lprc->right = lprc->left;
    41964205            }
    4197           }
    4198         }
    4199         else if (infoPtr->uView == LVS_SMALLICON)
    4200         {
    4201           if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE)
    4202           {
    4203             bResult = TRUE;
    4204             lprc->left = ptItem.x + ptOrigin.x;
    4205             lprc->top = ptItem.y + ptOrigin.y;
    4206             lprc->bottom = lprc->top + infoPtr->nItemHeight;
    4207 
    4208             if (infoPtr->himlState != NULL)
    4209               lprc->left += infoPtr->iconSize.cx;
    4210 
    4211             if (infoPtr->himlSmall != NULL)
    4212               lprc->right = lprc->left + infoPtr->iconSize.cx;
    4213             else
    4214               lprc->right = lprc->left;
    4215           }
    4216         }
    4217         else
    4218         {
    4219           bResult = TRUE;
    4220           lprc->left = ptItem.x;
    4221           lprc->top = ptItem.y;
    4222           lprc->bottom = lprc->top + infoPtr->nItemHeight;
    4223 
    4224           if (infoPtr->himlState != NULL)
    4225           {
    4226             lprc->left += infoPtr->iconSize.cx;
    4227           }
    4228 
    4229           if (infoPtr->himlSmall != NULL)
    4230           {
    4231             lprc->right = lprc->left + infoPtr->iconSize.cx;
    42324206          }
    42334207          else
    42344208          {
    4235             lprc->right = lprc->left;
     4209            bResult = TRUE;
     4210            lprc->left = ptItem.x;
     4211            lprc->top = ptItem.y;
     4212            lprc->bottom = lprc->top + infoPtr->nItemHeight;
     4213
     4214            if (infoPtr->himlState)
     4215            {
     4216              lprc->left += infoPtr->iconSize.cx;
     4217            }
     4218
     4219            if (infoPtr->himlSmall != NULL)
     4220            {
     4221              lprc->right = lprc->left + infoPtr->iconSize.cx;
     4222            }
     4223            else
     4224            {
     4225              lprc->right = lprc->left;
     4226            }
    42364227          }
    4237         }
    4238         break;
    4239 
    4240       case LVIR_LABEL:
    4241         if (infoPtr->uView == LVS_ICON)
    4242         {
    4243           if (infoPtr->himlNormal != NULL)
     4228          break;
     4229
     4230        case LVIR_LABEL:
     4231          if (infoPtr->uView == LVS_ICON)
    42444232          {
    4245             if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE)
     4233            if (infoPtr->himlNormal)
     4234            {
     4235              if (LISTVIEW_GetOrigin(hwnd, &ptOrigin))
     4236              {
     4237                bResult = TRUE;
     4238                lprc->left = ptItem.x + ptOrigin.x;
     4239                lprc->top = (ptItem.y + ptOrigin.y + infoPtr->iconSize.cy +
     4240                             ICON_BOTTOM_PADDING + ICON_TOP_PADDING);
     4241                nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);
     4242                if (infoPtr->iconSpacing.cx - nLabelWidth > 1)
     4243                {
     4244                  lprc->left += (infoPtr->iconSpacing.cx - nLabelWidth) / 2;
     4245                  lprc->right = lprc->left + nLabelWidth;
     4246                }
     4247                else
     4248                {
     4249                  lprc->left += 1;
     4250                  lprc->right = lprc->left + infoPtr->iconSpacing.cx - 1;
     4251                }
     4252
     4253                hdc = GetDC(hwnd);
     4254                hOldFont = SelectObject(hdc, infoPtr->hFont);
     4255                GetTextMetricsA(hdc, &tm);
     4256                lprc->bottom = lprc->top + tm.tmHeight + HEIGHT_PADDING;
     4257                SelectObject(hdc, hOldFont);
     4258                ReleaseDC(hwnd, hdc);
     4259              }
     4260            }
     4261          }
     4262          else if (infoPtr->uView == LVS_SMALLICON)
     4263          {
     4264            if (LISTVIEW_GetOrigin(hwnd, &ptOrigin))
    42464265            {
    42474266              bResult = TRUE;
    4248               lprc->left = ptItem.x + ptOrigin.x;
    4249               lprc->top = (ptItem.y + ptOrigin.y + infoPtr->iconSize.cy +
    4250                            ICON_BOTTOM_PADDING + ICON_TOP_PADDING);
     4267              nLeftPos = lprc->left = ptItem.x + ptOrigin.x;
     4268              lprc->top = ptItem.y + ptOrigin.y;
     4269              lprc->bottom = lprc->top + infoPtr->nItemHeight;
     4270
     4271              if (infoPtr->himlState)
     4272              {
     4273                lprc->left += infoPtr->iconSize.cx;
     4274              }
     4275
     4276              if (infoPtr->himlSmall)
     4277              {
     4278                lprc->left += infoPtr->iconSize.cx;
     4279              }
     4280
    42514281              nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);
    4252               if (infoPtr->iconSpacing.cx - nLabelWidth > 1)
     4282              if (lprc->left + nLabelWidth < nLeftPos + infoPtr->nItemWidth)
    42534283              {
    4254                 lprc->left += (infoPtr->iconSpacing.cx - nLabelWidth) / 2;
    42554284                lprc->right = lprc->left + nLabelWidth;
    42564285              }
    42574286              else
    42584287              {
    4259                 lprc->left += 1;
    4260                 lprc->right = lprc->left + infoPtr->iconSpacing.cx - 1;
     4288                lprc->right = nLeftPos + infoPtr->nItemWidth;
    42614289              }
    4262 
    4263               hdc = GetDC(hwnd);
    4264               hOldFont = SelectObject(hdc, infoPtr->hFont);
    4265               GetTextMetricsA(hdc, &tm);
    4266               lprc->bottom = lprc->top + tm.tmHeight + HEIGHT_PADDING;
    4267               SelectObject(hdc, hOldFont);
    4268               ReleaseDC(hwnd, hdc);
    42694290            }
    42704291          }
    4271         }
    4272         else if (infoPtr->uView == LVS_SMALLICON)
    4273         {
    4274           if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE)
     4292          else
    42754293          {
    42764294            bResult = TRUE;
    4277             nLeftPos = lprc->left = ptItem.x + ptOrigin.x;
    4278             lprc->top = ptItem.y + ptOrigin.y;
     4295            nLeftPos = lprc->left = ptItem.x;
     4296            lprc->top = ptItem.y;
    42794297            lprc->bottom = lprc->top + infoPtr->nItemHeight;
    42804298
    4281             if (infoPtr->himlState != NULL)
     4299            if (infoPtr->himlState)
    42824300            {
    42834301              lprc->left += infoPtr->iconSize.cx;
    42844302            }
    42854303
    4286             if (infoPtr->himlSmall != NULL)
     4304            if (infoPtr->himlSmall)
    42874305            {
    42884306              lprc->left += infoPtr->iconSize.cx;
     
    42994317            }
    43004318          }
    4301         }
    4302         else
    4303         {
    4304           bResult = TRUE;
    4305           nLeftPos = lprc->left = ptItem.x;
    4306           lprc->top = ptItem.y;
    4307           lprc->bottom = lprc->top + infoPtr->nItemHeight;
    4308 
    4309           if (infoPtr->himlState != NULL)
     4319          break;
     4320
     4321        case LVIR_BOUNDS:
     4322          if (infoPtr->uView == LVS_ICON)
    43104323          {
    4311             lprc->left += infoPtr->iconSize.cx;
     4324            if (infoPtr->himlNormal)
     4325            {
     4326              if (LISTVIEW_GetOrigin(hwnd, &ptOrigin))
     4327              {
     4328                bResult = TRUE;
     4329                hdc = GetDC(hwnd);
     4330                hOldFont = SelectObject(hdc,infoPtr->hFont);
     4331                GetTextMetricsA(hdc,&tm);
     4332                SelectObject(hdc,hOldFont);
     4333                ReleaseDC(hwnd,hdc);
     4334                lprc->left = ptItem.x + ptOrigin.x;
     4335                lprc->top = ptItem.y + ptOrigin.y;
     4336                lprc->right = lprc->left + infoPtr->iconSpacing.cx;
     4337                lprc->bottom = lprc->top+infoPtr->iconSpacing.cy+ICON_BOTTOM_PADDING+tm.tmHeight+HEIGHT_PADDING;
     4338              }
     4339            }
    43124340          }
    4313 
    4314           if (infoPtr->himlSmall != NULL)
     4341          else if (infoPtr->uView == LVS_SMALLICON)
    43154342          {
    4316             lprc->left += infoPtr->iconSize.cx;
    4317           }
    4318 
    4319           nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);
    4320           if (lprc->left + nLabelWidth < nLeftPos + infoPtr->nItemWidth)
    4321           {
    4322             lprc->right = lprc->left + nLabelWidth;
     4343            if (LISTVIEW_GetOrigin(hwnd, &ptOrigin))
     4344            {
     4345              bResult = TRUE;
     4346              lprc->left = ptItem.x + ptOrigin.x;
     4347              lprc->right = lprc->left;
     4348              lprc->top = ptItem.y + ptOrigin.y;
     4349              lprc->bottom = lprc->top + infoPtr->nItemHeight;
     4350              if (infoPtr->himlState)
     4351                lprc->right += infoPtr->iconSize.cx;
     4352              if (infoPtr->himlSmall)
     4353                lprc->right += infoPtr->iconSize.cx;
     4354              lprc->right += LISTVIEW_GetLabelWidth(hwnd, nItem);
     4355            }
    43234356          }
    43244357          else
    43254358          {
    4326             lprc->right = nLeftPos + infoPtr->nItemWidth;
    4327           }
    4328         }
    4329         break;
    4330 
    4331       case LVIR_BOUNDS:
    4332         if (infoPtr->uView == LVS_ICON)
    4333         {
    4334           if (infoPtr->himlNormal != NULL)
    4335           {
    4336             if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE)
     4359            bResult = TRUE;
     4360            lprc->left = ptItem.x;
     4361            lprc->right = lprc->left;
     4362            lprc->top = ptItem.y;
     4363            lprc->bottom = lprc->top + infoPtr->nItemHeight;
     4364
     4365            if (infoPtr->himlState)
    43374366            {
    4338               bResult = TRUE;
    4339               lprc->left = ptItem.x + ptOrigin.x;
    4340               lprc->top = ptItem.y + ptOrigin.y;
    4341               lprc->right = lprc->left + infoPtr->iconSpacing.cx;
    4342               lprc->bottom = lprc->top + infoPtr->iconSpacing.cy;
     4367              lprc->right += infoPtr->iconSize.cx;
    43434368            }
    4344           }
    4345         }
    4346         else if (infoPtr->uView == LVS_SMALLICON)
    4347         {
    4348           if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE)
    4349           {
    4350             bResult = TRUE;
    4351             lprc->left = ptItem.x + ptOrigin.x;
    4352             lprc->right = lprc->left;
    4353             lprc->top = ptItem.y + ptOrigin.y;
    4354             lprc->bottom = lprc->top + infoPtr->nItemHeight;
    4355             if (infoPtr->himlState != NULL)
     4369
     4370            if (infoPtr->himlSmall)
     4371            {
    43564372              lprc->right += infoPtr->iconSize.cx;
    4357             if (infoPtr->himlSmall != NULL)
    4358               lprc->right += infoPtr->iconSize.cx;
    4359             lprc->right += LISTVIEW_GetLabelWidth(hwnd, nItem);
    4360           }
    4361         }
    4362         else
    4363         {
    4364           bResult = TRUE;
    4365           lprc->left = ptItem.x;
    4366           lprc->right = lprc->left;
    4367           lprc->top = ptItem.y;
    4368           lprc->bottom = lprc->top + infoPtr->nItemHeight;
    4369 
    4370           if (infoPtr->himlState != NULL)
    4371           {
    4372             lprc->right += infoPtr->iconSize.cx;
    4373           }
    4374 
    4375           if (infoPtr->himlSmall != NULL)
    4376           {
    4377             lprc->right += infoPtr->iconSize.cx;
    4378           }
     4373            }
    43794374
    43804375            nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);
     
    43874382              lprc->right = lprc->left + infoPtr->nItemWidth;
    43884383            }
    4389         }
    4390         break;
    4391 
    4392       case LVIR_SELECTBOUNDS:
    4393         if (infoPtr->uView == LVS_ICON)
    4394         {
    4395           if (infoPtr->himlNormal != NULL)
     4384          }
     4385          break;
     4386
     4387        case LVIR_SELECTBOUNDS:
     4388          if (infoPtr->uView == LVS_ICON)
    43964389          {
    4397             if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE)
     4390            if (infoPtr->himlNormal)
     4391            {
     4392              if (LISTVIEW_GetOrigin(hwnd, &ptOrigin))
     4393              {
     4394                bResult = TRUE;
     4395                hdc = GetDC(hwnd);
     4396                hOldFont = SelectObject(hdc,infoPtr->hFont);
     4397                GetTextMetricsA(hdc,&tm);
     4398                SelectObject(hdc,hOldFont);
     4399                ReleaseDC(hwnd,hdc);
     4400                lprc->left = ptItem.x + ptOrigin.x;
     4401                lprc->top = ptItem.y + ptOrigin.y;
     4402                lprc->right = lprc->left + infoPtr->iconSpacing.cx;
     4403                lprc->bottom = lprc->top+infoPtr->iconSpacing.cy+ICON_BOTTOM_PADDING+tm.tmHeight+HEIGHT_PADDING;
     4404              }
     4405            }
     4406          }
     4407          else if (infoPtr->uView == LVS_SMALLICON)
     4408          {
     4409            if (LISTVIEW_GetOrigin(hwnd, &ptOrigin))
    43984410            {
    43994411              bResult = TRUE;
    4400               lprc->left = ptItem.x + ptOrigin.x;
     4412              nLeftPos= lprc->left = ptItem.x + ptOrigin.x;
    44014413              lprc->top = ptItem.y + ptOrigin.y;
    4402               lprc->right = lprc->left + infoPtr->iconSpacing.cx;
    4403               lprc->bottom = lprc->top + infoPtr->iconSpacing.cy;
     4414              lprc->bottom = lprc->top + infoPtr->nItemHeight;
     4415
     4416              if (infoPtr->himlState)
     4417              {
     4418                lprc->left += infoPtr->iconSize.cx;
     4419              }
     4420
     4421              lprc->right = lprc->left;
     4422
     4423              if (infoPtr->himlSmall)
     4424              {
     4425                lprc->right += infoPtr->iconSize.cx;
     4426              }
     4427
     4428              nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);
     4429              if (lprc->right + nLabelWidth < lprc->left + infoPtr->nItemWidth)
     4430              {
     4431                lprc->right += nLabelWidth;
     4432              }
     4433              else
     4434              {
     4435                lprc->right = lprc->left + infoPtr->nItemWidth;
     4436              }
    44044437            }
    44054438          }
    4406         }
    4407         else if (infoPtr->uView == LVS_SMALLICON)
    4408         {
    4409           if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE)
     4439          else
    44104440          {
    44114441            bResult = TRUE;
    4412             nLeftPos= lprc->left = ptItem.x + ptOrigin.x;
    4413             lprc->top = ptItem.y + ptOrigin.y;
     4442            nLeftPos = lprc->left = ptItem.x;
     4443            lprc->top = ptItem.y;
    44144444            lprc->bottom = lprc->top + infoPtr->nItemHeight;
    44154445
    4416             if (infoPtr->himlState != NULL)
     4446            if (infoPtr->himlState)
    44174447            {
    44184448              lprc->left += infoPtr->iconSize.cx;
     
    44214451            lprc->right = lprc->left;
    44224452
    4423             if (infoPtr->himlSmall != NULL)
     4453            if (infoPtr->himlSmall)
    44244454            {
    44254455              lprc->right += infoPtr->iconSize.cx;
    44264456            }
    44274457
    4428           nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);
    4429           if (lprc->right + nLabelWidth < lprc->left + infoPtr->nItemWidth)
    4430           {
    4431             lprc->right += nLabelWidth;
     4458            nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);
     4459            if (lprc->right + nLabelWidth < nLeftPos + infoPtr->nItemWidth)
     4460            {
     4461              lprc->right += nLabelWidth;
     4462            }
     4463            else
     4464            {
     4465              lprc->right = nLeftPos + infoPtr->nItemWidth;
     4466            }
    44324467          }
    4433           else
    4434           {
    4435             lprc->right = lprc->left + infoPtr->nItemWidth;
    4436           }
    4437           }
    4438         }
    4439         else
    4440         {
    4441           bResult = TRUE;
    4442           nLeftPos = lprc->left = ptItem.x;
    4443           lprc->top = ptItem.y;
    4444           lprc->bottom = lprc->top + infoPtr->nItemHeight;
    4445 
    4446           if (infoPtr->himlState != NULL)
    4447           {
    4448             lprc->left += infoPtr->iconSize.cx;
    4449           }
    4450 
    4451           lprc->right = lprc->left;
    4452 
    4453           if (infoPtr->himlSmall != NULL)
    4454           {
    4455             lprc->right += infoPtr->iconSize.cx;
    4456           }
    4457 
    4458           nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem);
    4459           if (lprc->right + nLabelWidth < nLeftPos + infoPtr->nItemWidth)
    4460           {
    4461             lprc->right += nLabelWidth;
    4462           }
    4463           else
    4464           {
    4465             lprc->right = nLeftPos + infoPtr->nItemWidth;
    4466           }
    4467         }
    4468         break;
     4468          break;
    44694469      }
    44704470    }
     
    45894589      lpLVItem->mask = LVIF_TEXT;
    45904590      lpLVItem->iItem = nItem;
    4591       if (LISTVIEW_GetItem(hwnd,lpLVItem,unicode,FALSE) != FALSE) //CB: todo
     4591      if (LISTVIEW_GetItem(hwnd,lpLVItem,unicode,FALSE) != FALSE)
    45924592      {
    45934593        nLength = unicode ? lstrlenW(lpLVItem->pszText):lstrlenA((LPSTR)lpLVItem->pszText);
     
    49204920  INT i;
    49214921
    4922 //  TRACE("(hwnd=%x, x=%ld, y=%ld)\n", hwnd, lpHitTestInfo->pt.x,
    4923 //        lpHitTestInfo->pt.y);
    4924 
     4922//CB: very slow!
    49254923  for (i = 0; i < GETITEMCOUNT(infoPtr); i++)
    49264924  {
    4927     rcItem.left = LVIR_BOUNDS;
    4928     if (LISTVIEW_GetItemRect(hwnd, i, &rcItem) != FALSE)
    4929     {
    4930       if (PtInRect(&rcItem, lpHitTestInfo->pt) != FALSE)
    4931       {
    4932         rcItem.left = LVIR_ICON;
    4933         if (LISTVIEW_GetItemRect(hwnd, i, &rcItem) != FALSE)
     4925    if (LISTVIEW_GetItemRect(hwnd, i, &rcItem,LVIR_BOUNDS))
     4926    {
     4927      if (PtInRect(&rcItem, lpHitTestInfo->pt))
     4928      {
     4929        if (LISTVIEW_GetItemRect(hwnd, i, &rcItem,LVIR_ICON))
    49344930        {
    4935           if (PtInRect(&rcItem, lpHitTestInfo->pt) != FALSE)
     4931          if (PtInRect(&rcItem, lpHitTestInfo->pt))
    49364932          {
    49374933            lpHitTestInfo->flags = LVHT_ONITEMICON;
     
    49424938        }
    49434939
    4944         rcItem.left = LVIR_LABEL;
    4945         if (LISTVIEW_GetItemRect(hwnd, i, &rcItem) != FALSE)
     4940        if (LISTVIEW_GetItemRect(hwnd, i, &rcItem,LVIR_LABEL))
    49464941        {
    4947           if (PtInRect(&rcItem, lpHitTestInfo->pt) != FALSE)
     4942          if (PtInRect(&rcItem, lpHitTestInfo->pt))
    49484943          {
    49494944            lpHitTestInfo->flags = LVHT_ONITEMLABEL;
     
    51005095    /* insert item in header control */
    51015096    if (unicode)
    5102       nNewColumn = SendMessageA(infoPtr->hwndHeader,HDM_INSERTITEMW,(WPARAM)nColumn,(LPARAM)&hdi);
     5097      nNewColumn = Header_InsertItemW(infoPtr->hwndHeader,nColumn,&hdi);
    51035098    else
    5104       nNewColumn = SendMessageA(infoPtr->hwndHeader,HDM_INSERTITEMA,(WPARAM)nColumn,(LPARAM)&hdi);
     5099      nNewColumn = Header_InsertItemA(infoPtr->hwndHeader,nColumn,&hdi);
    51055100
    51065101    /* Need to reset the item width when inserting a new column */
     
    54545449}
    54555450
    5456 /* LISTVIEW_SetColumnW */
    5457 
    54585451/***
    54595452 * DESCRIPTION:
     
    55115504        return (FALSE);
    55125505
    5513     // FIXME: currently ignoring LVSCW_AUTOSIZE (-1) and
    5514     // LVSCV_AUTOSIZE_USEHEADER (-2)
     5506    if (cx == LVSCW_AUTOSIZE_USEHEADER)
     5507    {
     5508      cx = HEADER_GetExpandedColumnTextWidth(infoPtr->hwndHeader,iCol);
     5509    } else if (cx == LVSCW_AUTOSIZE)
     5510    {
     5511      cx = HEADER_GetExpandedColumnTextWidth(infoPtr->hwndHeader,iCol);
     5512
     5513      //CB: todo
     5514    }
     5515
    55155516    if (cx < 0)
    55165517        return (FALSE);
     
    56865687              sendNotify(hwnd,LVN_ITEMCHANGED,&nmlv.hdr);
    56875688
    5688               LISTVIEW_RefreshItem(hwnd,lpLVItem->iItem);
     5689              LISTVIEW_RefreshItem(hwnd,lpLVItem->iItem,TRUE);
    56895690            } else
    56905691                bResult = TRUE;
     
    68096810  /* redraw the selected items */
    68106811  if (infoPtr->nFocusedItem != -1)
    6811     LISTVIEW_RefreshItem(hwnd,infoPtr->nFocusedItem);
     6812    LISTVIEW_RefreshItem(hwnd,infoPtr->nFocusedItem,FALSE);
    68126813
    68136814  return 0;
     
    68696870  POINT ptPosition;
    68706871  INT nItem;
    6871 //CB: selecting last items in a large list -> high cpu usage!
     6872
    68726873  /* send NM_RELEASEDCAPTURE notification */
    68736874  sendNotify(hwnd,NM_RELEASEDCAPTURE);
     
    72467247
    72477248  if (infoPtr->nFocusedItem != -1)
    7248     LISTVIEW_RefreshItem(hwnd,infoPtr->nFocusedItem);
     7249    LISTVIEW_RefreshItem(hwnd,infoPtr->nFocusedItem,FALSE);
    72497250
    72507251  return 0;
     
    75177518
    75187519    /* invalidate client area + erase background */
    7519     LISTVIEW_Refresh(hwnd);//CB:todo
     7520    LISTVIEW_Refresh(hwnd);
    75207521
    75217522    /* print the list of unsupported window styles */
     
    78077808    return LISTVIEW_GetColumn(hwnd,(INT)wParam,(LPLVCOLUMNW)lParam,TRUE);
    78087809
    7809 
    78107810  case LVM_GETCOLUMNORDERARRAY:
    78117811    return LISTVIEW_GetColumnOrderArray(hwnd, (INT)wParam, (LPINT)lParam);
     
    78447844    return LISTVIEW_GetItem(hwnd,(LPLVITEMW)lParam,TRUE,FALSE);
    78457845
    7846 
    78477846  case LVM_GETITEMCOUNT:
    78487847    return LISTVIEW_GetItemCount(hwnd);
     
    78527851
    78537852  case LVM_GETITEMRECT:
    7854     return LISTVIEW_GetItemRect(hwnd, (INT)wParam, (LPRECT)lParam);
     7853    return LISTVIEW_GetItemRect(hwnd,(INT)wParam,(LPRECT)lParam,lParam ? ((LPRECT)lParam)->left:0);
    78557854
    78567855  case LVM_GETITEMSPACING:
     
    78677866    LISTVIEW_GetItemText(hwnd,(INT)wParam,(LPLVITEMW)lParam,TRUE);
    78687867    break;
    7869 
    78707868
    78717869  case LVM_GETNEXTITEM:
  • trunk/src/comctl32/treeview.cpp

    r3285 r3351  
    1 /* $Id: treeview.cpp,v 1.6 2000-03-31 14:44:25 cbratschi Exp $ */
     1/* $Id: treeview.cpp,v 1.7 2000-04-08 18:32:55 cbratschi Exp $ */
    22/* Treeview control
    33 *
     
    1212 *   Using DPA to store the item ptr would be good.
    1313 *  -check custom draw
    14                         uHotItem
    1514 *   use separate routine to get item text/image.
    1615 *
     
    2019   -treehelper: stack corruption makes big window.
    2120 *
    22  * Status: in progress
     21 * Status: complete (many things untested)
    2322 * Version: 5.80
    2423 */
     
    3534 - VK_LEFT in WinHlp32 displays expanded icon
    3635 - expand not finished
    37  - TVS_FULLROWSELECT
    38  - TVS_TRACKSELECT (called hottrack)
    3936 - WM_ENABLE: draw disabled control
    4037*/
     
    661658}
    662659
     660static VOID TREEVIEW_DrawHottrackLine(HDC hdc,TREEVIEW_ITEM *item)
     661{
     662  HPEN hPen,hOldPen;
     663  INT rop;
     664
     665  if (!item->visible) return;
     666
     667  rop = SetROP2(hdc,R2_XORPEN);
     668  hPen = CreatePen(PS_SOLID,2,RGB(0,0,0));
     669  hOldPen = SelectObject(hdc,hPen);
     670
     671  MoveToEx(hdc,item->text.left,item->text.bottom-1,NULL);
     672  LineTo(hdc,item->text.right,item->text.bottom-1);
     673
     674  DeleteObject(hPen);
     675  SelectObject(hdc,hOldPen);
     676  SetROP2(hdc,rop);
     677}
     678
    663679static void
    664680TREEVIEW_DrawItem(HWND hwnd,HDC hdc,TREEVIEW_ITEM *item,DWORD dwStyle,TREEVIEW_INFO *infoPtr)
     
    935951  /* Draw insertion mark if necessary */
    936952
    937   //if (infoPtr->insertMarkItem)
    938   //              TRACE ("item:%d,mark:%d\n", (int)wineItem->hItem,
    939   //                             (int) infoPtr->insertMarkItem);
    940953  if (item->hItem == infoPtr->insertMarkItem)
    941954  {
     
    964977    SelectObject(hdc, hOldPen);
    965978  }
     979
     980  //draw hot item if necessary
     981  if (item->hItem == infoPtr->hotItem)
     982    TREEVIEW_DrawHottrackLine(hdc,item);
    966983
    967984  if (cditem & CDRF_NOTIFYPOSTPAINT)
     
    12911308
    12921309  r.left = xpos;
    1293   if ((item->mask & TVIF_TEXT) && (item->pszText))
     1310  if ((item->mask & TVIF_TEXT) && item->pszText)
    12941311  {
    12951312    UINT  uTextJustify = DT_LEFT;
     
    32853302  {
    32863303    case TVE_COLLAPSE:
     3304    {
     3305      POINT oldLeftTop = infoPtr->lefttop;
     3306
    32873307      if (!wineItem->state & TVIS_EXPANDED)
    32883308        return 0;
     
    32933313        TREEVIEW_RemoveAllChildren (hwnd, wineItem);
    32943314      } else wineItem->state &= ~TVIS_EXPANDED;
     3315
     3316      //update window
     3317      //CB: todo: optimize!
     3318      TREEVIEW_UnqueueRefresh(hwnd,FALSE,FALSE);
     3319      //CB: todo: precalc expanded items here
     3320      TREEVIEW_CalcItems(hwnd,0,infoPtr);
     3321      TREEVIEW_Refresh(hwnd);
     3322      //CB: todo: check cx and cy to fit ranges!
     3323
     3324      //check selection
     3325      HTREEITEM hItem = infoPtr->selectedItem;
     3326
     3327      if (!TREEVIEW_ValidItem (infoPtr, hItem))
     3328        hItem = wineItem->hItem;
     3329      else
     3330      {
     3331        while (hItem)
     3332        {
     3333          hItem = infoPtr->items[(INT)hItem].parent;
     3334
     3335          if (hItem == wineItem->hItem)
     3336            break;
     3337        }
     3338      }
     3339
     3340      if (hItem)
     3341        TREEVIEW_DoSelectItem(hwnd,TVGN_CARET,hItem,TVC_UNKNOWN);
     3342
    32953343      break;
     3344    }
    32963345
    32973346    case TVE_EXPAND:
     3347    {
     3348      POINT oldLeftTop = infoPtr->lefttop;
     3349
    32983350      if (wineItem->state & TVIS_EXPANDED)
    32993351        return 0;
     
    33013353      if (flag & TVE_EXPANDPARTIAL)
    33023354      {
    3303 return FALSE; //CB: to check
     3355return FALSE; //CB: how does this work??? (only display one level? nonsense in MSDN docu)
    33043356        wineItem->state ^=TVIS_EXPANDED;
    33053357        wineItem->state |=TVIS_EXPANDEDONCE;
     
    33353387
    33363388        wineItem->state |= TVIS_EXPANDEDONCE;
    3337         //TRACE(treeview, "  TVN_ITEMEXPANDING sent...\n");
    33383389
    33393390        TREEVIEW_SendTreeviewNotify (hwnd,isUnicodeNotify(&infoPtr->header) ? TVN_ITEMEXPANDEDW:TVN_ITEMEXPANDEDA,TVE_EXPAND,0,(HTREEITEM)expand);
    3340 
    3341         //TRACE(treeview, "  TVN_ITEMEXPANDED sent...\n");
    3342 
    33433391      } else
    33443392      {
     
    33463394        wineItem->state |= TVIS_EXPANDED;
    33473395      }
     3396
     3397      //update window
     3398      //CB: todo: optimize!
     3399      TREEVIEW_UnqueueRefresh(hwnd,FALSE,FALSE);
     3400      //CB: todo: precalc expanded items here
     3401      TREEVIEW_CalcItems(hwnd,0,infoPtr);
     3402      TREEVIEW_Refresh(hwnd);
     3403      //CB: todo: check cx and cy to fit ranges!
     3404
    33483405      break;
     3406    }
    33493407
    33503408    default:
    33513409      return FALSE;
    33523410  }
    3353 
    3354   /* If item was collapsed we probably need to change selection */
    3355   if (flag & TVE_COLLAPSE)
    3356   {
    3357      HTREEITEM hItem = infoPtr->selectedItem;
    3358 
    3359      if (!TREEVIEW_ValidItem (infoPtr, hItem))
    3360         hItem = wineItem->hItem;
    3361      else
    3362      {
    3363         while ( hItem )
    3364         {
    3365            hItem = infoPtr->items[(INT)hItem].parent;
    3366 
    3367            if (hItem == wineItem->hItem)
    3368               break;
    3369         }
    3370      }
    3371 
    3372      if (hItem)
    3373         TREEVIEW_DoSelectItem(hwnd, TVGN_CARET, hItem, TVC_UNKNOWN);
    3374   }
    3375 
    3376   //CB: todo: optimize!
    3377   TREEVIEW_UnqueueRefresh(hwnd,FALSE,FALSE);
    3378   //CB: todo: precalc expanded items here
    3379   infoPtr->uInternalStatus |= TV_CALCALL;
    3380   TREEVIEW_CalcItems(hwnd,0,infoPtr);
    3381   TREEVIEW_Refresh(hwnd);
    3382   //CB: todo: check cx and cy to fit ranges!
    33833411
    33843412  return TRUE;
     
    38793907}
    38803908
     3909HTREEITEM TREEVIEW_GetHottrackItem(HWND hwnd,TREEVIEW_INFO *infoPtr,POINT pt)
     3910{
     3911  TVHITTESTINFO ht;
     3912
     3913  ht.pt = pt;
     3914  TREEVIEW_HitTest(hwnd,&ht,FALSE);
     3915
     3916  return (ht.hItem && (ht.flags & TVHT_ONITEM)) ? ht.hItem:0;
     3917}
     3918
    38813919static LRESULT TREEVIEW_MouseMove(HWND hwnd,WPARAM wParam,LPARAM lParam)
    38823920{
     
    39063944  if (dwStyle & TVS_TRACKSELECT)
    39073945  {
    3908     //CB: todo: hottracking
     3946    HTREEITEM hItem = TREEVIEW_GetHottrackItem(hwnd,infoPtr,pt);
     3947
     3948    if (infoPtr->hotItem != hItem)
     3949    {
     3950      TREEVIEW_ITEM *item;
     3951      HDC hdc = 0;
     3952
     3953      item =  TREEVIEW_ValidItem(infoPtr,infoPtr->hotItem);
     3954      if (item)
     3955      {
     3956        if (!hdc) hdc = GetDC(hwnd);
     3957        TREEVIEW_DrawHottrackLine(hdc,item);
     3958      }
     3959      if (hItem)
     3960      {
     3961        item = &infoPtr->items[(INT)hItem];
     3962        if (item)
     3963        {
     3964          if (!hdc) hdc = GetDC(hwnd);
     3965          TREEVIEW_DrawHottrackLine(hdc,item);
     3966        }
     3967      }
     3968      if (hdc) ReleaseDC(hwnd,hdc);
     3969    }
    39093970  }
    39103971
     
    41314192  DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    41324193  INT prevSelect;
     4194  BOOL refreshPrev = FALSE,refreshNew = FALSE;
    41334195
    41344196  wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)newSelect);
     
    41644226
    41654227      if (prevItem)
     4228      {
     4229        refreshPrev = prevItem->state & TVIS_SELECTED;
    41664230        prevItem->state &= ~TVIS_SELECTED;
     4231      }
    41674232      if (wineItem)
     4233      {
     4234        refreshNew = !(wineItem->state & TVIS_SELECTED);
    41684235        wineItem->state |=  TVIS_SELECTED;
     4236      }
    41694237
    41704238      infoPtr->selectedItem = (HTREEITEM)newSelect;
     
    41824250
    41834251      TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE);
    4184       TREEVIEW_RefreshItem(hwnd,prevItem,FALSE);
    4185       TREEVIEW_RefreshItem(hwnd,wineItem,FALSE);
     4252      if (dwStyle & TVS_FULLROWSELECT)
     4253      {
     4254        TREEVIEW_ITEM *item;
     4255
     4256        //deselect last selected row
     4257        if (prevItem)
     4258        {
     4259          if (refreshPrev) TREEVIEW_RefreshItem(hwnd,prevItem,FALSE);
     4260          if (prevItem->upsibling)
     4261          {
     4262            item = &infoPtr->items[(INT)prevItem->upsibling];
     4263            while (item)
     4264            {
     4265              if (item->state & TVIS_SELECTED)
     4266              {
     4267                item->state &= ~TVIS_SELECTED;
     4268                TREEVIEW_RefreshItem(hwnd,item,FALSE);
     4269              }
     4270              item = &infoPtr->items[(INT)item->upsibling];
     4271            }
     4272          }
     4273          if (prevItem->sibling)
     4274          {
     4275            item = &infoPtr->items[(INT)prevItem->sibling];
     4276            while (item)
     4277            {
     4278              if (item->state & TVIS_SELECTED)
     4279              {
     4280                item->state &= ~TVIS_SELECTED;
     4281                TREEVIEW_RefreshItem(hwnd,item,FALSE);
     4282              }
     4283              item = &infoPtr->items[(INT)item->sibling];
     4284            }
     4285          }
     4286        }
     4287
     4288        //select new row
     4289        if (wineItem)
     4290        {
     4291          if (refreshNew) TREEVIEW_RefreshItem(hwnd,wineItem,FALSE);
     4292          if (wineItem->upsibling)
     4293          {
     4294            item = &infoPtr->items[(INT)wineItem->upsibling];
     4295            while (item)
     4296            {
     4297              if (!(item->state & TVIS_SELECTED))
     4298              {
     4299                item->state |= TVIS_SELECTED;
     4300                TREEVIEW_RefreshItem(hwnd,item,FALSE);
     4301              }
     4302              item = &infoPtr->items[(INT)item->upsibling];
     4303            }
     4304          }
     4305          if (wineItem->sibling)
     4306          {
     4307            item =  &infoPtr->items[(INT)wineItem->sibling];
     4308            while (item)
     4309            {
     4310              if (!(item->state & TVIS_SELECTED))
     4311              {
     4312                item->state |= TVIS_SELECTED;
     4313                TREEVIEW_RefreshItem(hwnd,item,FALSE);
     4314              }
     4315              item = &infoPtr->items[(INT)item->sibling];
     4316            }
     4317          }
     4318        }
     4319      } else
     4320      {
     4321        if (refreshPrev) TREEVIEW_RefreshItem(hwnd,prevItem,FALSE);
     4322        if (refreshNew) TREEVIEW_RefreshItem(hwnd,wineItem,FALSE);
     4323      }
    41864324
    41874325      TREEVIEW_SendTreeviewNotify(hwnd,isUnicodeNotify(&infoPtr->header) ? TVN_SELCHANGEDW:TVN_SELCHANGEDA,cause,(HTREEITEM)prevSelect,(HTREEITEM)newSelect);
     
    41934331
    41944332      if (prevItem)
     4333      {
     4334        refreshPrev = prevItem->state & TVIS_DROPHILITED;
    41954335        prevItem->state &= ~TVIS_DROPHILITED;
     4336      }
    41964337
    41974338      infoPtr->dropItem = (HTREEITEM)newSelect;
    41984339
    41994340      if (wineItem)
     4341      {
     4342        refreshNew = !(wineItem->state & TVIS_DROPHILITED);
    42004343        wineItem->state |=TVIS_DROPHILITED;
     4344      }
    42014345
    42024346      TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE);
    4203       TREEVIEW_RefreshItem(hwnd,prevItem,FALSE);
    4204       TREEVIEW_RefreshItem(hwnd,wineItem,FALSE);
     4347      if (refreshPrev) TREEVIEW_RefreshItem(hwnd,prevItem,FALSE);
     4348      if (refreshNew) TREEVIEW_RefreshItem(hwnd,wineItem,FALSE);
    42054349
    42064350      break;
     
    42424386TREEVIEW_SelectItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
    42434387{
    4244  return TREEVIEW_DoSelectItem (hwnd, wParam, (HTREEITEM) lParam, TVC_UNKNOWN);
     4388  return TREEVIEW_DoSelectItem (hwnd, wParam, (HTREEITEM) lParam, TVC_UNKNOWN);
    42454389}
    42464390
     
    42484392TREEVIEW_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
    42494393{
    4250  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    4251 
    4252 // TRACE (treeview,"%x\n",infoPtr->hFont);
    4253  return infoPtr->hFont;
     4394  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     4395
     4396  return infoPtr->hFont;
    42544397}
    42554398
Note: See TracChangeset for help on using the changeset viewer.