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

new functionality, bug fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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:
Note: See TracChangeset for help on using the changeset viewer.