Changeset 4006 for trunk/src/comctl32/treeview.cpp
- Timestamp:
- Aug 13, 2000, 7:12:40 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/treeview.cpp
r3970 r4006 1 /* $Id: treeview.cpp,v 1.1 6 2000-08-08 17:05:02cbratschi Exp $ */1 /* $Id: treeview.cpp,v 1.17 2000-08-13 17:12:40 cbratschi Exp $ */ 2 2 /* Treeview control 3 3 * … … 10 10 * Note that TREEVIEW_INFO * and HTREEITEM are the same thing. 11 11 * 12 * Note2: All items always! have valid (allocated) pszText field. 13 * If item's text == LPSTR_TEXTCALLBACKA/W we allocate buffer 14 * of size TEXT_CALLBACK_SIZE in DoSetItem. 15 * We use callbackMask to keep track of fields to be updated. 16 * 12 17 * 13 18 * Status: complete (many things untested) … … 17 22 /* 18 23 Most identical with: 19 - Corel 20000 212level24 - Corel 20000807 level 20 25 - (WINE 991212 level) 21 26 */ … … 71 76 #define MINIMUM_INDENT 19 72 77 73 #define IDT_CHECK 401 //CB: remove later74 75 78 #define CALLBACK_MASK_ALL (TVIF_TEXT|TVIF_CHILDREN|TVIF_IMAGE|TVIF_SELECTEDIMAGE) 76 79 77 #define STATEIMAGEINDEX(x) (((x) >> 12) & 0x0f)80 #define STATEIMAGEINDEX(x) (((x) >> 12) & 0x0f) 78 81 #define OVERLAYIMAGEINDEX(x) (((x) >> 8) & 0x0f) 82 #define ISVISIBLE(x) ((x)->displayed) 83 #define INCLIENT(x) ((x)->inclient) 79 84 80 85 typedef VOID (*TREEVIEW_ItemEnumFunc)(TREEVIEW_INFO *, TREEVIEW_ITEM *,LPVOID); … … 87 92 static VOID TREEVIEW_HideInfoTip(TREEVIEW_INFO *infoPtr); 88 93 static LRESULT TREEVIEW_DoSelectItem(TREEVIEW_INFO *, INT, HTREEITEM, INT); 89 static LRESULT TREEVIEW_EnsureVisible(TREEVIEW_INFO *, HTREEITEM);94 static LRESULT TREEVIEW_EnsureVisible(TREEVIEW_INFO *,HTREEITEM,BOOL); 90 95 static LRESULT TREEVIEW_RButtonUp(TREEVIEW_INFO *, LPPOINT); 91 96 static LRESULT TREEVIEW_EndEditLabelNow(TREEVIEW_INFO *infoPtr, BOOL bCancel); 92 static VOID TREEVIEW_UpdateScrollBars(TREEVIEW_INFO *infoPtr, BOOL);93 97 static VOID TREEVIEW_CheckInfoTip(TREEVIEW_INFO *infoPtr); 94 98 static VOID TREEVIEW_ISearch(TREEVIEW_INFO *infoPtr,CHAR ch); … … 168 172 if (item->pszText == LPSTR_TEXTCALLBACKW) return (WCHAR*)L"<callback>"; 169 173 if (item->pszText == NULL) return (WCHAR*)L"<null>"; 170 /* It would be nice to check item->callbackMask & TVIF_TEXT here, 171 * and indicate that this is a callback string, but there is nowhere 172 * to put that indication. (Or we could be clever, and put it before 173 * pszText, but that is just too hacky.) */ 174 174 175 return item->pszText; 175 176 } … … 197 198 TREEVIEW_GetLastListItem(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem) 198 199 { 199 /*200 * Get this item's last sibling201 */ 202 while (wineItem-> nextSibling)203 wineItem = wineItem->nextSibling;204 205 /*206 * If the last sibling has expanded children, restart.207 */208 if ((wineItem->state & TVIS_EXPANDED) && wineItem->firstChild != NULL)209 { 210 return TREEVIEW_GetLastListItem(infoPtr, wineItem->firstChild);211 }200 if (!wineItem) 201 return NULL; 202 203 while (wineItem->lastChild) 204 { 205 if (wineItem->state & TVIS_EXPANDED) 206 wineItem = wineItem->lastChild; 207 else 208 break; 209 } 210 211 if (wineItem == infoPtr->root) 212 return NULL; 212 213 213 214 return wineItem; … … 223 224 if (tvItem->prevSibling) 224 225 { 225 /* 226 * This item has a prevSibling, get the last item. Since 227 * GetLastListItem first looks at siblings, we must feed it with the 228 * first child. 229 */ 226 /* This item has a prevSibling, get the last item in the sibling's tree. */ 230 227 TREEVIEW_ITEM *upItem = tvItem->prevSibling; 231 228 232 if ((upItem->state & TVIS_EXPANDED) && upItem-> firstChild != NULL)233 return TREEVIEW_GetLastListItem(infoPtr, upItem-> firstChild);229 if ((upItem->state & TVIS_EXPANDED) && upItem->lastChild != NULL) 230 return TREEVIEW_GetLastListItem(infoPtr, upItem->lastChild); 234 231 else 235 232 return upItem; … … 237 234 else 238 235 { 239 /* 240 * this item does not have a prevSibling, get the parent 241 */ 236 /* this item does not have a prevSibling, get the parent */ 242 237 return (tvItem->parent != infoPtr->root) ? tvItem->parent : NULL; 243 238 } … … 252 247 TREEVIEW_GetNextListItem(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *tvItem) 253 248 { 254 assert(infoPtr != NULL);255 249 assert(tvItem != NULL); 256 250 … … 445 439 446 440 /* FIXME: need to find out when the flags in uItemState need to be set */ 441 447 442 static BOOL 448 443 TREEVIEW_SendCustomDrawItemNotify(TREEVIEW_INFO *infoPtr,HDC hdc,TREEVIEW_ITEM *wineItem,UINT uItemDrawState) … … 457 452 dwItemSpec = (DWORD)wineItem; 458 453 uItemState = 0; 459 if (wineItem == infoPtr->selectedItem)454 if (wineItem->state & TVIS_SELECTED) 460 455 { 461 456 uItemState |= CDIS_SELECTED; 462 457 if (GetFocus() == infoPtr->hwnd) uItemState |= CDIS_FOCUS; 463 458 } 464 if (wineItem == infoPtr-> focusItem)459 if (wineItem == infoPtr->selectedItem) 465 460 uItemState |= CDIS_FOCUS; 466 461 if (wineItem == infoPtr->hotItem) … … 487 482 488 483 static void 489 TREEVIEW_GetDispInfo(TREEVIEW_INFO *infoPtr,TREEVIEW_ITEM *wineItem,NMTVDISPINFOW* info,UINT mask)490 {491 info->item.mask = mask;492 info->item.hItem = wineItem;493 info->item.state = wineItem->state;494 info->item.stateMask = 0;495 info->item.lParam = wineItem->lParam;496 497 sendNotify(infoPtr->hwnd,isUnicodeNotify(&infoPtr->header) ? TVN_GETDISPINFOW:TVN_GETDISPINFOA,&info->hdr);498 }499 500 static void501 484 TREEVIEW_UpdateDispInfo(TREEVIEW_INFO *infoPtr,TREEVIEW_ITEM *wineItem,UINT mask) 502 485 { … … 507 490 if (mask == 0) return; 508 491 509 if ((mask & TVIF_TEXT) /*&& (wineItem->cchTextMax < TEXT_CALLBACK_SIZE)*/) 510 { 511 wineItem->pszText = (WCHAR*)COMCTL32_ReAlloc(wineItem->pszText,TEXT_CALLBACK_SIZE*sizeof(WCHAR)); 512 wineItem->cchTextMax = TEXT_CALLBACK_SIZE; 513 } 492 /* 'state' always contains valid value, as well as 'lParam'. 493 * All other parameters are uninitialized. 494 */ 514 495 515 496 callback.item.pszText = wineItem->pszText; 516 497 callback.item.cchTextMax = wineItem->cchTextMax; 498 callback.item.mask = mask; 499 callback.item.hItem = wineItem; 500 callback.item.state = wineItem->state; 501 callback.item.lParam = wineItem->lParam; 502 503 /* 504 callback.item.stateMask = 0; 517 505 callback.item.iImage = wineItem->iImage; 518 506 callback.item.iSelectedImage = wineItem->iSelectedImage; 519 507 callback.item.cChildren = wineItem->cChildren; 520 521 TREEVIEW_GetDispInfo(infoPtr,wineItem,&callback,mask); 508 */ 509 510 sendNotify(infoPtr->hwnd,isUnicodeNotify(&infoPtr->header) ? TVN_GETDISPINFOW:TVN_GETDISPINFOA,&callback.hdr); 522 511 523 512 /* It may have changed due to a call to SetItem. */ … … 543 532 newText = (WCHAR*)COMCTL32_Alloc(len*sizeof(WCHAR)); 544 533 lstrcpyAtoW(newText,(LPSTR)callback.item.pszText); 545 COMCTL32_Free(wineItem->pszText);534 if (wineItem->pszText) COMCTL32_Free(wineItem->pszText); 546 535 wineItem->pszText = newText; 547 536 wineItem->cchTextMax = len; … … 595 584 { 596 585 HDC hdc; 597 HFONT hOldFont ;586 HFONT hOldFont = 0; 598 587 RECT rect; 599 588 … … 869 858 newItem->prevSibling = sibling->prevSibling; 870 859 sibling->prevSibling = newItem; 871 } 860 } else newItem->prevSibling = NULL; 872 861 873 862 newItem->nextSibling = sibling; 874 863 875 864 if (parent->firstChild == sibling) 876 {877 newItem->nextSibling = parent->firstChild;878 865 parent->firstChild = newItem; 879 }880 866 881 867 if (parent->lastChild == NULL) … … 903 889 newItem->nextSibling = sibling->nextSibling; 904 890 sibling->nextSibling = newItem; 905 } 891 } else newItem->nextSibling = NULL; 906 892 907 893 newItem->prevSibling = sibling; 908 894 909 895 if (parent->lastChild == sibling) 910 {911 newItem->prevSibling = parent->lastChild;912 896 parent->lastChild = newItem; 913 }914 897 915 898 if (parent->firstChild == NULL) … … 1015 998 wineItem->iSelectedImage = tvItem->iSelectedImage; 1016 999 1017 if (wineItem->i Image == I_IMAGECALLBACK)1000 if (wineItem->iSelectedImage == I_IMAGECALLBACK) 1018 1001 callbackSet |= TVIF_SELECTEDIMAGE; 1019 1002 else … … 1059 1042 INT x; 1060 1043 TREEVIEW_ITEM *newItem, *parentItem; 1044 BOOL bTextUpdated = FALSE; 1061 1045 1062 1046 if (!ptdi) return NULL; … … 1131 1115 aChild = parentItem->firstChild; 1132 1116 1117 bTextUpdated = TRUE; 1133 1118 TREEVIEW_UpdateDispInfo(infoPtr, newItem, TVIF_TEXT); 1134 1119 … … 1150 1135 { 1151 1136 previousChild = aChild; 1152 aChild = (aChild->nextSibling == 0) /* This will help us to exit */ 1153 ? NULL /* if there is no more sibling */ 1137 1138 /* This will help us to exit if there is no more sibling */ 1139 aChild = (aChild->nextSibling == 0) 1140 ? NULL 1154 1141 : aChild->nextSibling; 1155 1142 … … 1254 1241 TREEVIEW_RemoveItem(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem) 1255 1242 { 1256 TREEVIEW_ITEM *newFirstVisible;1257 1258 1243 //TRACE("%p, (%s)\n", wineItem, TREEVIEW_ItemName(wineItem)); 1259 1244 … … 1295 1280 TREEVIEW_ITEM *oldSelection = infoPtr->selectedItem; 1296 1281 TREEVIEW_ITEM *newSelection = NULL; 1282 TREEVIEW_ITEM *newFirstVisible = NULL; 1283 TREEVIEW_ITEM *parent, *prev = NULL; 1284 BOOL visible = FALSE; 1297 1285 1298 1286 if (lParam == (LPARAM)TVI_ROOT) 1299 1287 { 1288 parent = infoPtr->root; 1300 1289 newSelection = NULL; 1290 visible = TRUE; 1301 1291 TREEVIEW_RemoveTree(infoPtr); 1302 1292 } … … 1309 1299 1310 1300 //TRACE("%p (%s)\n", wineItem, TREEVIEW_ItemName(wineItem)); 1301 parent = wineItem->parent; 1302 1303 if (ISVISIBLE(wineItem)) 1304 { 1305 prev = TREEVIEW_GetPrevListItem(infoPtr, wineItem); 1306 visible = TRUE; 1307 } 1311 1308 1312 1309 if (infoPtr->selectedItem != NULL … … 1320 1317 } 1321 1318 1319 if (infoPtr->firstVisible == wineItem) 1320 { 1321 if (wineItem->nextSibling) 1322 newFirstVisible = wineItem->nextSibling; 1323 else if (wineItem->prevSibling) 1324 newFirstVisible = wineItem->prevSibling; 1325 else if (wineItem->parent != infoPtr->root) 1326 newFirstVisible = wineItem->parent; 1327 } 1328 else 1329 newFirstVisible = infoPtr->firstVisible; 1330 1322 1331 TREEVIEW_RemoveItem(infoPtr, wineItem); 1323 1332 } 1324 1333 1325 1334 /* Don't change if somebody else already has. */ 1326 if (oldSelection == infoPtr->selectedItem 1327 && TREEVIEW_ValidItem(infoPtr, newSelection))1328 {1335 if (oldSelection == infoPtr->selectedItem) 1336 { 1337 if (TREEVIEW_ValidItem(infoPtr, newSelection)) 1329 1338 TREEVIEW_DoSelectItem(infoPtr, TVGN_CARET, newSelection, TVC_UNKNOWN); 1330 } 1339 else 1340 infoPtr->selectedItem = 0; 1341 } 1342 1343 /* Validate insertMark dropItem. 1344 * hotItem ??? - used for comparision only. 1345 */ 1346 if (!TREEVIEW_ValidItem(infoPtr, infoPtr->insertMarkItem)) 1347 infoPtr->insertMarkItem = 0; 1348 1349 if (!TREEVIEW_ValidItem(infoPtr, infoPtr->dropItem)) 1350 infoPtr->dropItem = 0; 1351 1352 if (!TREEVIEW_ValidItem(infoPtr, newFirstVisible)) 1353 newFirstVisible = infoPtr->root->firstChild; 1331 1354 1332 1355 TREEVIEW_VerifyTree(infoPtr); 1333 1356 1334 TREEVIEW_QueueRefresh(infoPtr); 1357 if (visible) 1358 TREEVIEW_QueueRefresh(infoPtr); 1359 else if (INCLIENT(parent) && !TREEVIEW_HasChildren(infoPtr,parent)) 1360 TREEVIEW_RefreshItem(infoPtr,parent,TVIF_CHILDREN); 1335 1361 1336 1362 return TRUE; … … 1420 1446 HIMAGELIST himlNew = (HIMAGELIST)lParam; 1421 1447 HIMAGELIST himlOld = 0; 1448 int oldWidth = infoPtr->normalImageWidth; 1449 int oldHeight = infoPtr->normalImageHeight; 1422 1450 1423 1451 switch (wParam) … … 1454 1482 } 1455 1483 1456 infoPtr->uInternalStatus |= TV_CALCALL; 1484 if ((oldWidth != infoPtr->normalImageWidth) || (oldHeight != infoPtr->normalImageHeight)) 1485 infoPtr->uInternalStatus |= TV_CALCALL; 1457 1486 TREEVIEW_QueueRefresh(infoPtr); 1458 1487 … … 1526 1555 TREEVIEW_SetFont(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam) 1527 1556 { 1557 UINT uHeight = infoPtr->uItemHeight; 1558 1528 1559 infoPtr->hFont = wParam ? (HFONT)wParam : GetStockObject(SYSTEM_FONT); 1529 1560 … … 1532 1563 1533 1564 if (!infoPtr->bHeightSet) 1534 1565 infoPtr->uItemHeight = TREEVIEW_NaturalHeight(infoPtr); 1535 1566 1536 1567 SendMessageA(infoPtr->hwndToolTip,WM_SETFONT,infoPtr->hFont,1); 1537 infoPtr->uInternalStatus |= TV_CALCALL; 1538 TREEVIEW_CalcItems(infoPtr); 1568 1569 if (uHeight != infoPtr->uItemHeight) 1570 { 1571 infoPtr->uInternalStatus |= TV_CALCALL; 1572 TREEVIEW_CalcItems(infoPtr); 1573 } 1539 1574 1540 1575 if (lParam) … … 1646 1681 { 1647 1682 TREEVIEW_ITEM *wineItem; 1648 const HTREEITEM *pItem = (HTREEITEM 1683 const HTREEITEM *pItem = (HTREEITEM*)lParam; 1649 1684 LPRECT lpRect = (LPRECT)lParam; 1650 1685 … … 1652 1687 * validate parameters 1653 1688 */ 1654 if ( (pItem == NULL) || (lpRect == NULL))1689 if (pItem == NULL) 1655 1690 return FALSE; 1656 1691 … … 1821 1856 retval = infoPtr->dropItem; 1822 1857 break; 1858 1859 case TVGN_LASTVISIBLE: 1860 retval = TREEVIEW_GetLastListItem(infoPtr,infoPtr->root); 1861 break; 1823 1862 } 1824 1863 … … 1848 1887 case TVGN_CHILD: 1849 1888 retval = wineItem->firstChild; 1850 break;1851 1852 case TVGN_LASTVISIBLE:1853 retval = TREEVIEW_GetLastListItem(infoPtr, wineItem);1854 1889 break; 1855 1890 … … 1981 2016 LONG plussize = (rectsize + 1) * 3 / 4; 1982 2017 1983 HPEN hNewPen = CreatePen(PS_SOLID, 0, infoPtr->clrLine); 1984 HPEN hOldPen = SelectObject(hdc, hNewPen); 2018 HPEN hNewPen = CreatePen(PS_SOLID, 0, infoPtr->clrLine); 2019 HPEN hOldPen = SelectObject(hdc, hNewPen); 2020 HBRUSH hbr = CreateSolidBrush(infoPtr->clrBk); 2021 HBRUSH hbrOld = SelectObject(hdc, hbr); 1985 2022 1986 2023 Rectangle(hdc, centerx - rectsize, centery - rectsize, 1987 2024 centerx + rectsize + 1, centery + rectsize + 1); 2025 2026 SelectObject(hdc, hbrOld); 2027 DeleteObject(hbr); 1988 2028 1989 2029 SelectObject(hdc, hOldPen); … … 2071 2111 if (infoPtr->himlState && imageIndex) 2072 2112 { 2073 ImageList_Draw(infoPtr->himlState, imageIndex - 1, hdc,2113 ImageList_Draw(infoPtr->himlState, imageIndex, hdc, 2074 2114 wineItem->stateOffset, 2075 2115 centery - infoPtr->stateImageHeight / 2, … … 2169 2209 2170 2210 /* Draw the box arround the selected item */ 2171 if ((wineItem ->state & TVIS_SELECTED) && inFocus)2211 if ((wineItem == infoPtr->selectedItem) && inFocus) 2172 2212 { 2173 2213 HPEN hNewPen = CreatePen(PS_DOT, 0, … … 2483 2523 if (pSort) 2484 2524 { 2485 pfnCompare = TREEVIEW_CallBackCompare;2525 pfnCompare = (PFNDPACOMPARE)TREEVIEW_CallBackCompare; 2486 2526 lpCompare = (LPARAM)pSort; 2487 2527 } 2488 2528 else 2489 2529 { 2490 pfnCompare = TREEVIEW_SortOnName;2530 pfnCompare = (PFNDPACOMPARE)TREEVIEW_SortOnName; 2491 2531 lpCompare = (LPARAM)infoPtr; 2492 2532 } … … 2651 2691 infoPtr->selectedItem = wineItem; 2652 2692 2653 TREEVIEW_EnsureVisible(infoPtr, wineItem);2693 TREEVIEW_EnsureVisible(infoPtr,wineItem,TRUE); 2654 2694 } 2655 2695 … … 2689 2729 } 2690 2730 2731 TREEVIEW_SendExpanded(infoPtr, wineItem, TVE_EXPAND); 2732 2691 2733 wineItem->state |= TVIS_EXPANDEDONCE; 2692 2693 TREEVIEW_SendExpanded(infoPtr, wineItem, TVE_EXPAND);2694 2695 //TRACE(" TVN_ITEMEXPANDED sent...\n");2696 2734 } 2697 2735 else … … 2813 2851 TREEVIEW_ITEM *wineItem; 2814 2852 RECT rect; 2815 UINT status, x, y; 2853 UINT status; 2854 LONG x, y; 2816 2855 2817 2856 if (!lpht) return 0; … … 3045 3084 /* Make shure that edit item is selected */ 3046 3085 3047 TREEVIEW_DoSelectItem ( infoPtr, TVGN_CARET, hItem, TVC_UNKNOWN); 3086 TREEVIEW_DoSelectItem(infoPtr,TVGN_CARET,hItem,TVC_UNKNOWN); 3087 TREEVIEW_EnsureVisible(infoPtr,hItem,TRUE); 3048 3088 3049 3089 TREEVIEW_UpdateDispInfo(infoPtr, editItem, TVIF_TEXT); … … 3279 3319 if (msg.message == WM_MOUSEMOVE) 3280 3320 { 3281 pt.x = ( INT)LOWORD(msg.lParam);3282 pt.y = ( INT)HIWORD(msg.lParam);3321 pt.x = (LONG)(INT16)LOWORD(msg.lParam); 3322 pt.y = (LONG)(INT16)HIWORD(msg.lParam); 3283 3323 if (PtInRect(&r, pt)) 3284 3324 continue; … … 3314 3354 TV_HITTESTINFO hit; 3315 3355 3316 hit.pt.x = (INT)LOWORD(lParam); 3317 hit.pt.y = (INT)HIWORD(lParam); 3356 hit.pt.x = (LONG)(INT16)LOWORD(lParam); 3357 hit.pt.y = (LONG)(INT16)HIWORD(lParam); 3358 3318 3359 SetFocus (infoPtr->hwnd); 3319 3360 … … 3357 3398 case TVHT_ONITEMLABEL: 3358 3399 case TVHT_ONITEMICON: 3359 case TVHT_ONITEMSTATEICON:3360 3400 case TVHT_ONITEMBUTTON: 3361 3401 TREEVIEW_Toggle(infoPtr, wineItem, TRUE); 3402 break; 3403 3404 case TVHT_ONITEMSTATEICON: 3405 if (infoPtr->dwStyle & TVS_CHECKBOXES) 3406 TREEVIEW_ToggleItemState(infoPtr, wineItem); 3407 else 3408 TREEVIEW_Toggle(infoPtr, wineItem, TRUE); 3362 3409 break; 3363 3410 } … … 3384 3431 } 3385 3432 3386 ht.pt.x = ( INT)LOWORD(lParam);3387 ht.pt.y = ( INT)HIWORD(lParam);3433 ht.pt.x = (LONG)(INT16)LOWORD(lParam); 3434 ht.pt.y = (LONG)(INT16)HIWORD(lParam); 3388 3435 3389 3436 TREEVIEW_HitTest(infoPtr,&ht,FALSE); … … 3454 3501 } 3455 3502 3456 ht.pt.x = ( INT)LOWORD(lParam);3457 ht.pt.y = ( INT)HIWORD(lParam);3503 ht.pt.x = (LONG)(INT16)LOWORD(lParam); 3504 ht.pt.y = (LONG)(INT16)HIWORD(lParam); 3458 3505 3459 3506 TREEVIEW_HitTest(infoPtr,&ht,FALSE); … … 3589 3636 prevSelect, 3590 3637 newSelect)) 3591 return FALSE; /* FIXME: OK? */3638 return FALSE; 3592 3639 3593 3640 if (prevSelect) … … 3617 3664 3618 3665 TREEVIEW_UnqueueRefresh(infoPtr,TRUE,TRUE); 3619 TREEVIEW_EnsureVisible(infoPtr,infoPtr->selectedItem );3666 TREEVIEW_EnsureVisible(infoPtr,infoPtr->selectedItem,FALSE); 3620 3667 if (infoPtr->dwStyle & TVS_FULLROWSELECT) 3621 3668 { … … 3775 3822 /* Scrolling ************************************************************/ 3776 3823 3777 static LRESULT TREEVIEW_EnsureVisible(TREEVIEW_INFO *infoPtr,HTREEITEM item )3824 static LRESULT TREEVIEW_EnsureVisible(TREEVIEW_INFO *infoPtr,HTREEITEM item,BOOL bHScroll) 3778 3825 { 3779 3826 RECT rect; 3780 INT scrollY ;3827 INT scrollY = 0,scrollX = 0; 3781 3828 3782 3829 if (!item) return FALSE; … … 3807 3854 mod = scrollY % infoPtr->uItemHeight; 3808 3855 if (mod) scrollY += infoPtr->uItemHeight-mod; 3809 } else return FALSE; 3810 3811 if (scrollY != 0) 3856 } 3857 3858 if (bHScroll) 3859 { 3860 if (!item->calculated) TREEVIEW_CalcItem(infoPtr,item,0); 3861 3862 if (item->textOffset < rect.left) 3863 scrollX = item->textOffset-rect.left; 3864 else if (item->textOffset+item->textWidth > rect.right) 3865 { 3866 scrollX = item->textOffset+item->textWidth-rect.right; 3867 if (scrollX > item->textOffset-rect.left) scrollX = item->textOffset-rect.left; 3868 } 3869 } 3870 3871 if ((scrollY != 0) || (scrollX != 0)) 3812 3872 { 3813 3873 infoPtr->lefttop.y += scrollY; 3874 infoPtr->lefttop.x += scrollX; 3814 3875 TREEVIEW_CalcItems(infoPtr); 3815 ScrollWindowEx(infoPtr->hwnd, 0,-scrollY,NULL,NULL,0,NULL,SW_INVALIDATE | SW_SCROLLCHILDREN | (infoPtr->uScrollTime << 16));3876 ScrollWindowEx(infoPtr->hwnd,-scrollX,-scrollY,NULL,NULL,0,NULL,SW_INVALIDATE | SW_SCROLLCHILDREN | (infoPtr->uScrollTime << 16)); 3816 3877 3817 3878 return TRUE; … … 4073 4134 if (infoPtr->dwStyle & TVS_CHECKBOXES) 4074 4135 { 4075 HBITMAP hbmLoad; 4136 RECT rc; 4137 HBITMAP hbm, hbmOld; 4138 HDC hdc; 4076 4139 int nIndex; 4077 4140 4078 infoPtr->himlState = ImageList_Create (16, 16,ILC_COLOR | ILC_MASK, 15, 1); 4079 4080 //MSDN docu says: uses DrawFrameControl but never believe what they write 4081 hbmLoad = LoadBitmapA (COMCTL32_hModule, MAKEINTRESOURCEA(IDT_CHECK)); 4082 nIndex = ImageList_AddMasked (infoPtr->himlState, hbmLoad, CLR_DEFAULT); 4083 DeleteObject (hbmLoad); 4141 infoPtr->himlState = ImageList_Create(16,16,ILC_COLOR | ILC_MASK,3,0); 4142 4143 hdc = CreateCompatibleDC(0); 4144 hbm = CreateCompatibleBitmap(hdc, 48, 16); 4145 hbmOld = SelectObject(hdc, hbm); 4146 4147 rc.left = 0; rc.top = 0; 4148 rc.right = 48; rc.bottom = 16; 4149 FillRect(hdc, &rc, (HBRUSH)(COLOR_WINDOW+1)); 4150 4151 rc.left = 18; rc.top = 2; 4152 rc.right = 30; rc.bottom = 14; 4153 DrawFrameControl(hdc, &rc, DFC_BUTTON, 4154 DFCS_BUTTONCHECK|DFCS_FLAT); 4155 4156 rc.left = 34; rc.right = 46; 4157 DrawFrameControl(hdc, &rc, DFC_BUTTON, 4158 DFCS_BUTTONCHECK|DFCS_FLAT|DFCS_CHECKED); 4159 4160 nIndex = ImageList_AddMasked(infoPtr->himlState, hbm, 4161 GetSysColor(COLOR_WINDOW)); 4162 //TRACE("chckbox index %d\n", nIndex); 4163 SelectObject(hdc, hbmOld); 4164 DeleteObject(hbm); 4165 DeleteDC(hdc); 4084 4166 4085 4167 infoPtr->stateImageWidth = 16; … … 4197 4279 4198 4280 case VK_END: 4199 newSelection = TREEVIEW_GetLastListItem(infoPtr, 4200 infoPtr->root->lastChild); 4281 newSelection = TREEVIEW_GetLastListItem(infoPtr,infoPtr->root); 4201 4282 break; 4202 4283 … … 4271 4352 if (TREEVIEW_DoSelectItem(infoPtr,TVGN_CARET,newSelection,TVC_BYKEYBOARD)) 4272 4353 { 4273 TREEVIEW_EnsureVisible(infoPtr, newSelection);4354 TREEVIEW_EnsureVisible(infoPtr,newSelection,FALSE); 4274 4355 } 4275 4356 } … … 4293 4374 4294 4375 static LRESULT 4295 TREEVIEW_StyleChanged(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam) 4296 { 4297 //TRACE("(%x %lx)\n", wParam, lParam); 4298 4376 TREEVIEW_StyleChanged(TREEVIEW_INFO *infoPtr,WPARAM wParam,LPARAM lParam) 4377 { 4299 4378 if (wParam == GWL_STYLE) 4300 infoPtr->dwStyle = ((LPSTYLESTRUCT)lParam)->styleNew; 4379 { 4380 DWORD dwNewStyle = ((LPSTYLESTRUCT)lParam)->styleNew; 4381 4382 /* we have to take special care about tooltips */ 4383 if ((infoPtr->dwStyle ^ dwNewStyle) & TVS_NOTOOLTIPS) 4384 { 4385 if (infoPtr->dwStyle & TVS_NOTOOLTIPS) 4386 { 4387 infoPtr->hwndToolTip = createToolTip(infoPtr->hwnd,TTF_TRACK | TTF_ABSOLUTE | TTF_TRANSPARENT,TRUE); 4388 SendMessageA(infoPtr->hwndToolTip,WM_SETFONT,infoPtr->hFont,0); 4389 } else 4390 { 4391 DestroyWindow(infoPtr->hwndToolTip); 4392 infoPtr->hwndToolTip = 0; 4393 } 4394 } 4395 4396 infoPtr->dwStyle = dwNewStyle; 4397 } 4301 4398 4302 4399 if (infoPtr->hwndEdit) SetFocus(infoPtr->hwnd); … … 4714 4811 { 4715 4812 TREEVIEW_SelectItem(infoPtr,(WPARAM)TVGN_CARET,(LPARAM)nearest); 4716 TREEVIEW_EnsureVisible(infoPtr,nearest );4813 TREEVIEW_EnsureVisible(infoPtr,nearest,FALSE); 4717 4814 infoPtr->dwISearchTime = GetTickCount(); 4718 4815 … … 4729 4826 infoPtr->uISearchLen = len; 4730 4827 TREEVIEW_SelectItem(infoPtr,(WPARAM)TVGN_CARET,(LPARAM)item); 4731 TREEVIEW_EnsureVisible(infoPtr,item );4828 TREEVIEW_EnsureVisible(infoPtr,item,FALSE); 4732 4829 infoPtr->dwISearchTime = GetTickCount(); 4733 4830 } else … … 4855 4952 4856 4953 case TVM_ENSUREVISIBLE: 4857 return TREEVIEW_EnsureVisible(infoPtr,(HTREEITEM)lParam );4954 return TREEVIEW_EnsureVisible(infoPtr,(HTREEITEM)lParam,TRUE); 4858 4955 4859 4956 case TVM_SORTCHILDRENCB:
Note:
See TracChangeset
for help on using the changeset viewer.