- Timestamp:
- Apr 8, 2000, 8:32:55 PM (25 years ago)
- 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:41cbratschi Exp $ */1 /* $Id: header.cpp,v 1.5 2000-04-08 18:32:53 cbratschi Exp $ */ 2 2 /* 3 3 * Header control … … 40 40 #define HEADER_GetInfoPtr(hwnd) ((HEADER_INFO*)getInfoPtr(hwnd)) 41 41 42 static VOID 43 HEADER_DrawItemImage(HWND hwnd,HDC hdc,HEADER_INFO* infoPtr,HEADER_ITEM* phdi,RECT* r,INT iItem) 42 static 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 57 static VOID HEADER_DrawItemImage(HWND hwnd,HDC hdc,HEADER_INFO* infoPtr,HEADER_ITEM* phdi,RECT* r,INT iItem) 44 58 { 45 59 if (phdi->fmt & HDF_IMAGE) … … 50 64 51 65 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; 65 71 if (!ImageList_GetImageInfo(infoPtr->himl,phdi->iImage,&info)) return; 66 72 w = info.rcImage.right-info.rcImage.left; … … 186 192 DeleteDC (hdcBitmap); 187 193 } 194 } 195 196 static 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; 188 258 } 189 259 … … 252 322 { 253 323 UINT uTextJustify; 254 WCHAR *pszText = phdi->pszText,*orgPtr; 324 WCHAR *pszText; 325 BOOL mustFree = FALSE; 255 326 256 327 if ((phdi->fmt & HDF_JUSTIFYMASK) == HDF_CENTER) … … 261 332 262 333 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; 312 337 313 338 if (!(phdi->fmt & HDF_JUSTIFYMASK) || (phdi->fmt & (HDF_LEFT | HDF_CENTER))) … … 330 355 } 331 356 } 332 if ( (phdi->pszText == LPSTR_TEXTCALLBACKW) && (pszText == orgPtr)) COMCTL32_Free(pszText);357 if (mustFree) COMCTL32_Free(pszText); 333 358 } 334 359 … … 1082 1107 1083 1108 1084 static LRESULT 1085 HEADER_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam) 1109 LRESULT HEADER_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam) 1086 1110 { 1087 1111 HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd); … … 1097 1121 1098 1122 return TRUE; 1123 } 1124 1125 //useful function for ListView control 1126 1127 DWORD 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; 1099 1203 } 1100 1204 -
trunk/src/comctl32/listview.cpp
r3285 r3351 1 /*$Id: listview.cpp,v 1.1 0 2000-03-31 14:44:20cbratschi Exp $*/1 /*$Id: listview.cpp,v 1.11 2000-04-08 18:32:54 cbratschi Exp $*/ 2 2 /* 3 3 * Listview control … … 51 51 #include "listview.h" 52 52 #include "comctl32.h" 53 #include "header.h" 53 54 #include "ctype.h" 54 55 … … 119 120 static BOOL LISTVIEW_GetItemPosition(HWND, INT, LPPOINT); 120 121 static LRESULT LISTVIEW_GetItemRect(HWND hwnd,INT nItem,LPRECT lprc,INT code); 121 static LRESULT LISTVIEW_GetItemRect(HWND, INT, LPRECT);122 122 static INT LISTVIEW_GetItemWidth(HWND); 123 123 static INT LISTVIEW_GetLabelWidth(HWND, INT); … … 180 180 } 181 181 182 static VOID LISTVIEW_RefreshItem(HWND hwnd,INT nItem )182 static VOID LISTVIEW_RefreshItem(HWND hwnd,INT nItem,BOOL wholeItem) 183 183 { 184 184 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)LISTVIEW_GetInfoPtr(hwnd); … … 186 186 187 187 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); 189 189 190 190 if ((infoPtr->uView == LVS_REPORT) && !(infoPtr->dwStyle & LVS_NOCOLUMNHEADER)) … … 192 192 RECT header; 193 193 INT headerH; 194 194 RECT rect2; 195 196 //clip header control 195 197 GetWindowRect(infoPtr->hwndHeader,&header); 196 198 headerH = rect.bottom-rect.top; 197 199 if (rect.bottom <= headerH) return; 198 200 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; 199 204 } 200 205 … … 205 210 { 206 211 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)LISTVIEW_GetInfoPtr(hwnd); 207 RECT rect, header;212 RECT rect,column; 208 213 INT xOffset = infoPtr->lefttop.x*infoPtr->scrollStep.x; 209 214 210 215 if (infoPtr->internalFlags & IF_NOREDRAW) return; 216 if (infoPtr->uView != LVS_REPORT) return; 211 217 LISTVIEW_GetItemRect(hwnd,nItem,&rect,LVIR_SELECTBOUNDS); 212 218 213 //get headerrect214 H eader_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); 217 223 218 224 if (!(infoPtr->dwStyle & LVS_NOCOLUMNHEADER)) 219 225 { 226 RECT header; 220 227 INT headerH; 221 228 229 //clip header control 222 230 GetWindowRect(infoPtr->hwndHeader,&header); 223 231 headerH = rect.bottom-rect.top; … … 1181 1189 for (i = nFirst;i < nLast;i++) 1182 1190 { 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)) 1185 1192 return i; 1186 1193 } … … 1305 1312 * 1306 1313 * RETURN: 1307 * SUCCCESS : TRUE (EQUAL) 1308 * FAILURE : FALSE (NOT EQUAL) 1314 * LVIF_* flags 1309 1315 */ 1310 1316 static UINT LISTVIEW_GetItemChanges(LISTVIEW_ITEM *lpItem,LPLVITEMW lpLVItem,BOOL unicode) … … 1412 1418 if (lpItem->pszText) 1413 1419 { 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) 1418 1421 { 1419 1422 uChanged |= LVIF_TEXT; 1420 1423 } 1421 HeapFree(GetProcessHeap(),0,textW);1422 1424 } 1423 1425 else … … 1438 1440 } 1439 1441 } 1442 1440 1443 return uChanged; 1441 1444 } … … 2831 2834 * FAILURE : FALSE 2832 2835 */ 2833 //CB: unicode parameter not used, edit doesn't use unicode chars2834 2836 static HWND LISTVIEW_EditLabel(HWND hwnd, INT nItem,BOOL unicode) 2835 2837 { … … 2893 2895 return 0; 2894 2896 2895 rect.left = LVIR_LABEL; 2896 if (!LISTVIEW_GetItemRect(hwnd, nItem, &rect)) 2897 if (!LISTVIEW_GetItemRect(hwnd, nItem, &rect,LVIR_LABEL)) 2897 2898 return 0; 2898 2899 … … 2945 2946 /* ALWAYS bPartial == FALSE, FOR NOW! */ 2946 2947 2947 rcItem.left = LVIR_BOUNDS; 2948 if (LISTVIEW_GetItemRect(hwnd, nItem, &rcItem)) 2948 if (LISTVIEW_GetItemRect(hwnd, nItem, &rcItem,LVIR_BOUNDS)) 2949 2949 { 2950 2950 if (rcItem.left < infoPtr->rcList.left) … … 3483 3483 { 3484 3484 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd); 3485 INT nColumnWidth = 0;3486 HDITEMA hdi;3487 3485 3488 3486 if (infoPtr->uView == LVS_LIST) 3489 3487 { 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 3494 3493 /* get column width from header */ 3495 3494 ZeroMemory(&hdi, sizeof(HDITEMA)); 3496 3495 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; 3504 3503 } 3505 3504 … … 4087 4086 INT nCountPerColumn; 4088 4087 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) 4092 4090 { 4093 4091 if (infoPtr->uView == LVS_LIST) … … 4142 4140 } 4143 4141 4144 //same as ListView_GetItemRect, but direct call4145 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 4151 4142 /*** 4152 4143 * DESCRIPTION: … … 4162 4153 * FAILURE : FALSE 4163 4154 */ 4164 static LRESULT LISTVIEW_GetItemRect(HWND hwnd, INT nItem, LPRECT lprc)4155 static LRESULT LISTVIEW_GetItemRect(HWND hwnd,INT nItem,LPRECT lprc,INT code) 4165 4156 { 4166 4157 LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)LISTVIEW_GetInfoPtr(hwnd); … … 4173 4164 INT nLabelWidth; 4174 4165 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) 4178 4168 { 4179 4169 if (LISTVIEW_GetItemPosition(hwnd, nItem, &ptItem) != FALSE) 4180 4170 { 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) 4187 4175 { 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)) 4189 4192 { 4190 4193 bResult = TRUE; 4191 4194 lprc->left = ptItem.x + ptOrigin.x; 4192 4195 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; 4196 4205 } 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 else4214 lprc->right = lprc->left;4215 }4216 }4217 else4218 {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;4232 4206 } 4233 4207 else 4234 4208 { 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 } 4236 4227 } 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) 4244 4232 { 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)) 4246 4265 { 4247 4266 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 4251 4281 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem); 4252 if ( infoPtr->iconSpacing.cx - nLabelWidth > 1)4282 if (lprc->left + nLabelWidth < nLeftPos + infoPtr->nItemWidth) 4253 4283 { 4254 lprc->left += (infoPtr->iconSpacing.cx - nLabelWidth) / 2;4255 4284 lprc->right = lprc->left + nLabelWidth; 4256 4285 } 4257 4286 else 4258 4287 { 4259 lprc->left += 1; 4260 lprc->right = lprc->left + infoPtr->iconSpacing.cx - 1; 4288 lprc->right = nLeftPos + infoPtr->nItemWidth; 4261 4289 } 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);4269 4290 } 4270 4291 } 4271 } 4272 else if (infoPtr->uView == LVS_SMALLICON) 4273 { 4274 if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE) 4292 else 4275 4293 { 4276 4294 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; 4279 4297 lprc->bottom = lprc->top + infoPtr->nItemHeight; 4280 4298 4281 if (infoPtr->himlState != NULL)4299 if (infoPtr->himlState) 4282 4300 { 4283 4301 lprc->left += infoPtr->iconSize.cx; 4284 4302 } 4285 4303 4286 if (infoPtr->himlSmall != NULL)4304 if (infoPtr->himlSmall) 4287 4305 { 4288 4306 lprc->left += infoPtr->iconSize.cx; … … 4299 4317 } 4300 4318 } 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) 4310 4323 { 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 } 4312 4340 } 4313 4314 if (infoPtr->himlSmall != NULL) 4341 else if (infoPtr->uView == LVS_SMALLICON) 4315 4342 { 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 } 4323 4356 } 4324 4357 else 4325 4358 { 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) 4337 4366 { 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; 4343 4368 } 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 { 4356 4372 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 } 4379 4374 4380 4375 nLabelWidth = LISTVIEW_GetLabelWidth(hwnd, nItem); … … 4387 4382 lprc->right = lprc->left + infoPtr->nItemWidth; 4388 4383 } 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) 4396 4389 { 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)) 4398 4410 { 4399 4411 bResult = TRUE; 4400 lprc->left = ptItem.x + ptOrigin.x;4412 nLeftPos= lprc->left = ptItem.x + ptOrigin.x; 4401 4413 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 } 4404 4437 } 4405 4438 } 4406 } 4407 else if (infoPtr->uView == LVS_SMALLICON) 4408 { 4409 if (LISTVIEW_GetOrigin(hwnd, &ptOrigin) != FALSE) 4439 else 4410 4440 { 4411 4441 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; 4414 4444 lprc->bottom = lprc->top + infoPtr->nItemHeight; 4415 4445 4416 if (infoPtr->himlState != NULL)4446 if (infoPtr->himlState) 4417 4447 { 4418 4448 lprc->left += infoPtr->iconSize.cx; … … 4421 4451 lprc->right = lprc->left; 4422 4452 4423 if (infoPtr->himlSmall != NULL)4453 if (infoPtr->himlSmall) 4424 4454 { 4425 4455 lprc->right += infoPtr->iconSize.cx; 4426 4456 } 4427 4457 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 } 4432 4467 } 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; 4469 4469 } 4470 4470 } … … 4589 4589 lpLVItem->mask = LVIF_TEXT; 4590 4590 lpLVItem->iItem = nItem; 4591 if (LISTVIEW_GetItem(hwnd,lpLVItem,unicode,FALSE) != FALSE) //CB: todo4591 if (LISTVIEW_GetItem(hwnd,lpLVItem,unicode,FALSE) != FALSE) 4592 4592 { 4593 4593 nLength = unicode ? lstrlenW(lpLVItem->pszText):lstrlenA((LPSTR)lpLVItem->pszText); … … 4920 4920 INT i; 4921 4921 4922 // TRACE("(hwnd=%x, x=%ld, y=%ld)\n", hwnd, lpHitTestInfo->pt.x, 4923 // lpHitTestInfo->pt.y); 4924 4922 //CB: very slow! 4925 4923 for (i = 0; i < GETITEMCOUNT(infoPtr); i++) 4926 4924 { 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)) 4934 4930 { 4935 if (PtInRect(&rcItem, lpHitTestInfo->pt) != FALSE)4931 if (PtInRect(&rcItem, lpHitTestInfo->pt)) 4936 4932 { 4937 4933 lpHitTestInfo->flags = LVHT_ONITEMICON; … … 4942 4938 } 4943 4939 4944 rcItem.left = LVIR_LABEL; 4945 if (LISTVIEW_GetItemRect(hwnd, i, &rcItem) != FALSE) 4940 if (LISTVIEW_GetItemRect(hwnd, i, &rcItem,LVIR_LABEL)) 4946 4941 { 4947 if (PtInRect(&rcItem, lpHitTestInfo->pt) != FALSE)4942 if (PtInRect(&rcItem, lpHitTestInfo->pt)) 4948 4943 { 4949 4944 lpHitTestInfo->flags = LVHT_ONITEMLABEL; … … 5100 5095 /* insert item in header control */ 5101 5096 if (unicode) 5102 nNewColumn = SendMessageA(infoPtr->hwndHeader,HDM_INSERTITEMW,(WPARAM)nColumn,(LPARAM)&hdi);5097 nNewColumn = Header_InsertItemW(infoPtr->hwndHeader,nColumn,&hdi); 5103 5098 else 5104 nNewColumn = SendMessageA(infoPtr->hwndHeader,HDM_INSERTITEMA,(WPARAM)nColumn,(LPARAM)&hdi);5099 nNewColumn = Header_InsertItemA(infoPtr->hwndHeader,nColumn,&hdi); 5105 5100 5106 5101 /* Need to reset the item width when inserting a new column */ … … 5454 5449 } 5455 5450 5456 /* LISTVIEW_SetColumnW */5457 5458 5451 /*** 5459 5452 * DESCRIPTION: … … 5511 5504 return (FALSE); 5512 5505 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 5515 5516 if (cx < 0) 5516 5517 return (FALSE); … … 5686 5687 sendNotify(hwnd,LVN_ITEMCHANGED,&nmlv.hdr); 5687 5688 5688 LISTVIEW_RefreshItem(hwnd,lpLVItem->iItem );5689 LISTVIEW_RefreshItem(hwnd,lpLVItem->iItem,TRUE); 5689 5690 } else 5690 5691 bResult = TRUE; … … 6809 6810 /* redraw the selected items */ 6810 6811 if (infoPtr->nFocusedItem != -1) 6811 LISTVIEW_RefreshItem(hwnd,infoPtr->nFocusedItem );6812 LISTVIEW_RefreshItem(hwnd,infoPtr->nFocusedItem,FALSE); 6812 6813 6813 6814 return 0; … … 6869 6870 POINT ptPosition; 6870 6871 INT nItem; 6871 //CB: selecting last items in a large list -> high cpu usage! 6872 6872 6873 /* send NM_RELEASEDCAPTURE notification */ 6873 6874 sendNotify(hwnd,NM_RELEASEDCAPTURE); … … 7246 7247 7247 7248 if (infoPtr->nFocusedItem != -1) 7248 LISTVIEW_RefreshItem(hwnd,infoPtr->nFocusedItem );7249 LISTVIEW_RefreshItem(hwnd,infoPtr->nFocusedItem,FALSE); 7249 7250 7250 7251 return 0; … … 7517 7518 7518 7519 /* invalidate client area + erase background */ 7519 LISTVIEW_Refresh(hwnd); //CB:todo7520 LISTVIEW_Refresh(hwnd); 7520 7521 7521 7522 /* print the list of unsupported window styles */ … … 7807 7808 return LISTVIEW_GetColumn(hwnd,(INT)wParam,(LPLVCOLUMNW)lParam,TRUE); 7808 7809 7809 7810 7810 case LVM_GETCOLUMNORDERARRAY: 7811 7811 return LISTVIEW_GetColumnOrderArray(hwnd, (INT)wParam, (LPINT)lParam); … … 7844 7844 return LISTVIEW_GetItem(hwnd,(LPLVITEMW)lParam,TRUE,FALSE); 7845 7845 7846 7847 7846 case LVM_GETITEMCOUNT: 7848 7847 return LISTVIEW_GetItemCount(hwnd); … … 7852 7851 7853 7852 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); 7855 7854 7856 7855 case LVM_GETITEMSPACING: … … 7867 7866 LISTVIEW_GetItemText(hwnd,(INT)wParam,(LPLVITEMW)lParam,TRUE); 7868 7867 break; 7869 7870 7868 7871 7869 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 $ */ 2 2 /* Treeview control 3 3 * … … 12 12 * Using DPA to store the item ptr would be good. 13 13 * -check custom draw 14 uHotItem15 14 * use separate routine to get item text/image. 16 15 * … … 20 19 -treehelper: stack corruption makes big window. 21 20 * 22 * Status: in progress21 * Status: complete (many things untested) 23 22 * Version: 5.80 24 23 */ … … 35 34 - VK_LEFT in WinHlp32 displays expanded icon 36 35 - expand not finished 37 - TVS_FULLROWSELECT38 - TVS_TRACKSELECT (called hottrack)39 36 - WM_ENABLE: draw disabled control 40 37 */ … … 661 658 } 662 659 660 static 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 663 679 static void 664 680 TREEVIEW_DrawItem(HWND hwnd,HDC hdc,TREEVIEW_ITEM *item,DWORD dwStyle,TREEVIEW_INFO *infoPtr) … … 935 951 /* Draw insertion mark if necessary */ 936 952 937 //if (infoPtr->insertMarkItem)938 // TRACE ("item:%d,mark:%d\n", (int)wineItem->hItem,939 // (int) infoPtr->insertMarkItem);940 953 if (item->hItem == infoPtr->insertMarkItem) 941 954 { … … 964 977 SelectObject(hdc, hOldPen); 965 978 } 979 980 //draw hot item if necessary 981 if (item->hItem == infoPtr->hotItem) 982 TREEVIEW_DrawHottrackLine(hdc,item); 966 983 967 984 if (cditem & CDRF_NOTIFYPOSTPAINT) … … 1291 1308 1292 1309 r.left = xpos; 1293 if ((item->mask & TVIF_TEXT) && (item->pszText))1310 if ((item->mask & TVIF_TEXT) && item->pszText) 1294 1311 { 1295 1312 UINT uTextJustify = DT_LEFT; … … 3285 3302 { 3286 3303 case TVE_COLLAPSE: 3304 { 3305 POINT oldLeftTop = infoPtr->lefttop; 3306 3287 3307 if (!wineItem->state & TVIS_EXPANDED) 3288 3308 return 0; … … 3293 3313 TREEVIEW_RemoveAllChildren (hwnd, wineItem); 3294 3314 } 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 3295 3343 break; 3344 } 3296 3345 3297 3346 case TVE_EXPAND: 3347 { 3348 POINT oldLeftTop = infoPtr->lefttop; 3349 3298 3350 if (wineItem->state & TVIS_EXPANDED) 3299 3351 return 0; … … 3301 3353 if (flag & TVE_EXPANDPARTIAL) 3302 3354 { 3303 return FALSE; //CB: to check3355 return FALSE; //CB: how does this work??? (only display one level? nonsense in MSDN docu) 3304 3356 wineItem->state ^=TVIS_EXPANDED; 3305 3357 wineItem->state |=TVIS_EXPANDEDONCE; … … 3335 3387 3336 3388 wineItem->state |= TVIS_EXPANDEDONCE; 3337 //TRACE(treeview, " TVN_ITEMEXPANDING sent...\n");3338 3389 3339 3390 TREEVIEW_SendTreeviewNotify (hwnd,isUnicodeNotify(&infoPtr->header) ? TVN_ITEMEXPANDEDW:TVN_ITEMEXPANDEDA,TVE_EXPAND,0,(HTREEITEM)expand); 3340 3341 //TRACE(treeview, " TVN_ITEMEXPANDED sent...\n");3342 3343 3391 } else 3344 3392 { … … 3346 3394 wineItem->state |= TVIS_EXPANDED; 3347 3395 } 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 3348 3405 break; 3406 } 3349 3407 3350 3408 default: 3351 3409 return FALSE; 3352 3410 } 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 else3362 {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 here3379 infoPtr->uInternalStatus |= TV_CALCALL;3380 TREEVIEW_CalcItems(hwnd,0,infoPtr);3381 TREEVIEW_Refresh(hwnd);3382 //CB: todo: check cx and cy to fit ranges!3383 3411 3384 3412 return TRUE; … … 3879 3907 } 3880 3908 3909 HTREEITEM 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 3881 3919 static LRESULT TREEVIEW_MouseMove(HWND hwnd,WPARAM wParam,LPARAM lParam) 3882 3920 { … … 3906 3944 if (dwStyle & TVS_TRACKSELECT) 3907 3945 { 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 } 3909 3970 } 3910 3971 … … 4131 4192 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 4132 4193 INT prevSelect; 4194 BOOL refreshPrev = FALSE,refreshNew = FALSE; 4133 4195 4134 4196 wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)newSelect); … … 4164 4226 4165 4227 if (prevItem) 4228 { 4229 refreshPrev = prevItem->state & TVIS_SELECTED; 4166 4230 prevItem->state &= ~TVIS_SELECTED; 4231 } 4167 4232 if (wineItem) 4233 { 4234 refreshNew = !(wineItem->state & TVIS_SELECTED); 4168 4235 wineItem->state |= TVIS_SELECTED; 4236 } 4169 4237 4170 4238 infoPtr->selectedItem = (HTREEITEM)newSelect; … … 4182 4250 4183 4251 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 } 4186 4324 4187 4325 TREEVIEW_SendTreeviewNotify(hwnd,isUnicodeNotify(&infoPtr->header) ? TVN_SELCHANGEDW:TVN_SELCHANGEDA,cause,(HTREEITEM)prevSelect,(HTREEITEM)newSelect); … … 4193 4331 4194 4332 if (prevItem) 4333 { 4334 refreshPrev = prevItem->state & TVIS_DROPHILITED; 4195 4335 prevItem->state &= ~TVIS_DROPHILITED; 4336 } 4196 4337 4197 4338 infoPtr->dropItem = (HTREEITEM)newSelect; 4198 4339 4199 4340 if (wineItem) 4341 { 4342 refreshNew = !(wineItem->state & TVIS_DROPHILITED); 4200 4343 wineItem->state |=TVIS_DROPHILITED; 4344 } 4201 4345 4202 4346 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); 4205 4349 4206 4350 break; … … 4242 4386 TREEVIEW_SelectItem (HWND hwnd, WPARAM wParam, LPARAM lParam) 4243 4387 { 4244 return TREEVIEW_DoSelectItem (hwnd, wParam, (HTREEITEM) lParam, TVC_UNKNOWN);4388 return TREEVIEW_DoSelectItem (hwnd, wParam, (HTREEITEM) lParam, TVC_UNKNOWN); 4245 4389 } 4246 4390 … … 4248 4392 TREEVIEW_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam) 4249 4393 { 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; 4254 4397 } 4255 4398
Note:
See TracChangeset
for help on using the changeset viewer.