- Timestamp:
- Feb 20, 2000, 7:29:58 PM (26 years ago)
- Location:
- trunk/src/comctl32
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/tooltips.c
r2806 r2835 1 /* $Id: tooltips.c,v 1.2 1 2000-02-16 17:22:18cbratschi Exp $ */1 /* $Id: tooltips.c,v 1.22 2000-02-20 18:29:56 cbratschi Exp $ */ 2 2 /* 3 3 * Tool tip control … … 244 244 245 245 *lpRect = rc; 246 247 246 } 248 247 -
trunk/src/comctl32/trackbar.c
r2814 r2835 1 /* $Id: trackbar.c,v 1.2 5 2000-02-17 17:26:50cbratschi Exp $ */1 /* $Id: trackbar.c,v 1.26 2000-02-20 18:29:57 cbratschi Exp $ */ 2 2 /* 3 3 * Trackbar control … … 1737 1737 ti.hwnd = hwnd; 1738 1738 ti.uId = 0; 1739 ti.lpszText = ""; /* LPSTR_TEXTCALLBACK */1739 ti.lpszText = ""; 1740 1740 SetRectEmpty(&ti.rect); 1741 1741 … … 1883 1883 ti.uId = 0; 1884 1884 ti.hwnd = (UINT)hwnd; 1885 ti.hinst = 0;1885 ti.hinst = 0; 1886 1886 sprintf (buf,"%d",infoPtr->nPos); 1887 1887 ti.lpszText = (LPSTR)buf; -
trunk/src/comctl32/treeview.c
r2820 r2835 1 /* $Id: treeview.c,v 1.2 8 2000-02-18 17:13:39cbratschi Exp $ */1 /* $Id: treeview.c,v 1.29 2000-02-20 18:29:58 cbratschi Exp $ */ 2 2 /* Treeview control 3 3 * … … 6 6 * Copyright 1999 Sylvain St-Germain 7 7 * Copyright 1999 Achim Hasenmueller 8 * Copyright 1999-2000 Christoph Bratschi 8 * Copyright 1999-2000 Christoph Bratschi (cbratschi@datacomm.ch) 9 9 * 10 10 * … … 12 12 * Using DPA to store the item ptr would be good. 13 13 * -check custom draw 14 * FIXME: check fontsize. (uRealItemHeight)15 14 uHotItem 16 15 * use separate routine to get item text/image. … … 32 31 33 32 /* CB: todo 34 35 33 - bug in SetScrollInfo/ShowScrollBar: WM_SIZE and WM_NCPAINT problems (i.e. RegEdit) 34 - tooltips not finished 35 - expand not finished 36 36 - TVS_FULLROWSELECT 37 - TVS_SINGLEEXPAND38 37 - TVS_TRACKSELECT (called hottrack) 39 - TVS_INFOTIP, TVS_NOTOOLTIPS and tooltip support40 38 - WM_ENABLE: draw disabled control 41 39 */ 42 40 41 #include <stdlib.h> 43 42 #include <string.h> 43 #include <math.h> 44 44 #include "winbase.h" 45 45 #include "wingdi.h" … … 71 71 static BOOL TREEVIEW_SendCustomDrawItemNotify (HWND hwnd, HDC hdc, TREEVIEW_ITEM *tvItem, UINT uItemDrawState); 72 72 static LRESULT TREEVIEW_SelectItem (HWND hwnd, WPARAM wParam, LPARAM lParam); 73 static LRESULT TREEVIEW_DoSelectItem (HWND hwnd, INT action, HTREEITEM newSelect,INT cause);73 static LRESULT TREEVIEW_DoSelectItem(HWND hwnd,INT action,HTREEITEM newSelect,INT cause); 74 74 static void TREEVIEW_Refresh(HWND hwnd); 75 75 static void TREEVIEW_Draw(HWND hwnd,HDC hdc,RECT *updateRect); … … 409 409 infoPtr->uNumPtrsAlloced=0; 410 410 infoPtr->uMaxHandle=0; 411 infoPtr-> cx = infoPtr->cy = 0;411 infoPtr->lefttop.x = infoPtr->lefttop.y = 0; 412 412 } 413 413 } … … 456 456 INT cx,cy,prevHeight = infoPtr->uItemHeight; 457 457 458 if (wParam ==-1)458 if (wParam == -1) 459 459 { 460 460 infoPtr->uItemHeight = -1; … … 469 469 470 470 if (!(GetWindowLongA(hwnd, GWL_STYLE) & TVS_NONEVENHEIGHT)) 471 if (infoPtr->uItemHeight & 0x1) infoPtr->uItemHeight += 1;471 if (infoPtr->uItemHeight & 0x1) infoPtr->uItemHeight++; 472 472 473 473 return prevHeight; … … 645 645 item->rect.bottom-3: /* is linked to an icon */ 646 646 item->rect.bottom+1; /* is linked to a +/- box */ 647 points[1].x = points[0].x = 28+20*item->iLevel-infoPtr-> cx;647 points[1].x = points[0].x = 28+20*item->iLevel-infoPtr->lefttop.x; 648 648 points[1].y = (lastItem->rect.top+lastItem->rect.bottom)/2; /* is linked to a +/- box */ 649 649 #ifdef OS2LINEHACK … … 677 677 } 678 678 679 //CB: what does COMCTL 5.0 with CDRF_NEWFONT? recalc items? 679 //CDRF_NEWFONT: CCM_SETVERSION < 5 clips text (what we do now) 680 // > 5 ??? recalc? 680 681 681 682 /* … … 727 728 } else 728 729 { 729 points[1].x = 8+(20*item->iLevel)-infoPtr-> cx;730 points[1].x = 8+(20*item->iLevel)-infoPtr->lefttop.x; 730 731 points[1].y = points[0].y = center; 731 732 points[0].x = points[1].x + 10; … … 815 816 } 816 817 817 if (himlp )818 if (himlp && (imageIndex != I_IMAGENONE)) 818 819 { 819 820 int ovlIdx = 0; … … 1316 1317 BOOL ownDC = FALSE,changedLeftTop = FALSE; 1317 1318 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 1318 INT maxCX,maxCY; 1319 INT xDiff = 0,yDiff = 0; 1319 INT maxXScroll,maxYScroll; 1320 INT xDiff,yDiff; 1321 HFONT oldFont; 1320 1322 1321 1323 GetClientRect(hwnd,&rect); 1322 1324 infoPtr->uVisibleHeight = rect.bottom-rect.top; 1323 1325 infoPtr->uVisibleWidth = rect.right-rect.left; 1326 1327 if (infoPtr->uInternalStatus & TV_CALCALL) 1328 { 1329 itemHeight = 0; 1330 ImageList_GetIconSize (infoPtr->himlNormal, &x, &itemHeight); 1331 itemHeight = MAX(infoPtr->uItemHeight,itemHeight); 1332 1333 if (!hdc) 1334 { 1335 ownDC = TRUE; 1336 hdc = GetDC(hwnd); 1337 } 1338 1339 oldFont = SelectObject(hdc,infoPtr->hFont); 1340 GetTextMetricsA(hdc,&tm); 1341 itemHeight = MAX(tm.tmHeight+tm.tmExternalLeading,itemHeight); 1342 SelectObject(hdc,infoPtr->hBoldFont); 1343 GetTextMetricsA(hdc,&tm); 1344 itemHeight = MAX(tm.tmHeight+tm.tmExternalLeading,itemHeight); 1345 SelectObject(hdc,oldFont); 1346 if (!(dwStyle & TVS_NONEVENHEIGHT)) 1347 if (itemHeight & 0x1) itemHeight++; //important for PS_DOT pen! 1348 infoPtr->uRealItemHeight = itemHeight; 1349 infoPtr->uVScrollStep = itemHeight+ITEM_VSPACE; 1350 } else 1351 { 1352 itemHeight = infoPtr->uRealItemHeight; 1353 } 1354 infoPtr->uTotalWidth = 0; 1355 1324 1356 view = rect; 1325 OffsetRect(&view,infoPtr->cx,infoPtr->cy); 1326 1327 itemHeight = 0; 1328 ImageList_GetIconSize (infoPtr->himlNormal, &x, &itemHeight); 1329 itemHeight = MAX(infoPtr->uItemHeight,itemHeight); 1330 1331 if (!hdc) 1332 { 1333 ownDC = TRUE; 1334 hdc = GetDC(hwnd); 1335 } 1336 1337 GetTextMetricsA (hdc, &tm); 1338 itemHeight = MAX(tm.tmHeight+tm.tmExternalLeading,itemHeight); 1339 if (!(dwStyle & TVS_NONEVENHEIGHT)) 1340 if (itemHeight & 0x1) itemHeight += 1; //important for PS_DOT pen! 1341 infoPtr->uRealItemHeight = itemHeight; 1342 infoPtr->uTotalWidth = 0; 1357 OffsetRect(&view,infoPtr->lefttop.x,infoPtr->lefttop.y); 1343 1358 1344 1359 iItem = (INT)infoPtr->TopRootItem; … … 1352 1367 item->iLevel = indent; 1353 1368 1354 height = itemHeight * item->iIntegral +1;1369 height = itemHeight*item->iIntegral+ITEM_VSPACE; 1355 1370 1356 1371 //calculate size and fill rects 1357 1372 if ((infoPtr->uInternalStatus & TV_CALCALL) || !item->calculated) 1358 1373 { 1359 item->rect.top = y- infoPtr->cy;1374 item->rect.top = y-view.top; 1360 1375 item->rect.bottom = item->rect.top+height; 1361 item->rect.left = x- infoPtr->cx;1376 item->rect.left = x-view.left; 1362 1377 item->rect.right = rect.right; //dummy 1378 if (!hdc) 1379 { 1380 ownDC = TRUE; 1381 hdc = GetDC(hwnd); 1382 } 1363 1383 TREEVIEW_CalcItem(hwnd,hdc,dwStyle,infoPtr,item); 1364 1384 } else … … 1366 1386 INT xOffset,yOffset; 1367 1387 1368 xOffset = (x- infoPtr->cx)-item->rect.left;1369 yOffset = (y- infoPtr->cy)-item->rect.top;1388 xOffset = (x-view.left)-item->rect.left; 1389 yOffset = (y-view.top)-item->rect.top; 1370 1390 OffsetRect(&item->rect,xOffset,yOffset); 1371 1391 OffsetRect(&item->text,xOffset,yOffset); … … 1374 1394 OffsetRect(&item->statebitmap,xOffset,yOffset); 1375 1395 } 1376 infoPtr->uTotalWidth = MAX(infoPtr->uTotalWidth,item->rect.right+infoPtr-> cx);1377 1378 if (((y >= view.top) && (y < = view.bottom)) || ((y+height >=view.top) && (y+height <= view.bottom)))1396 infoPtr->uTotalWidth = MAX(infoPtr->uTotalWidth,item->rect.right+infoPtr->lefttop.x); 1397 1398 if (((y >= view.top) && (y < view.bottom)) || ((y+height > view.top) && (y+height <= view.bottom))) 1379 1399 { 1380 1400 item->visible = TRUE; … … 1410 1430 1411 1431 //check cx and cy 1412 maxCY = infoPtr->uTotalHeight-infoPtr->uVisibleHeight; 1413 if (maxCY < 0) maxCY = 0; 1414 if (infoPtr->cy > maxCY) 1415 { 1416 yDiff = maxCY-infoPtr->cy; 1417 infoPtr->cy = maxCY; 1418 } 1419 1420 maxCX = infoPtr->uTotalWidth-infoPtr->uVisibleWidth; 1421 if (maxCX < 0) maxCX = 0; 1422 if (infoPtr->cx > maxCX) 1423 { 1424 xDiff = maxCX-infoPtr->cx; 1425 infoPtr->cx = maxCX; 1432 yDiff = xDiff = 0; 1433 1434 maxYScroll = infoPtr->uTotalHeight-infoPtr->uVisibleHeight; 1435 if (maxYScroll < 0) maxYScroll = 0; 1436 if (infoPtr->lefttop.y > maxYScroll) 1437 { 1438 INT mod = maxYScroll % infoPtr->uVScrollStep; 1439 1440 if (mod > 0) maxYScroll += infoPtr->uVScrollStep-mod; 1441 yDiff = infoPtr->lefttop.y-maxYScroll; 1442 infoPtr->lefttop.y = maxYScroll; 1443 } 1444 1445 maxXScroll = infoPtr->uTotalWidth-infoPtr->uVisibleWidth; 1446 if (maxXScroll < 0) maxXScroll = 0; 1447 if (infoPtr->lefttop.x > maxXScroll) 1448 { 1449 xDiff = infoPtr->lefttop.x-maxXScroll; 1450 infoPtr->lefttop.x = maxXScroll; 1426 1451 } 1427 1452 … … 1432 1457 item = NULL; 1433 1458 indent = 0; 1459 infoPtr->firstVisible = 0; 1434 1460 1435 1461 while (iItem) … … 1441 1467 OffsetRect(&item->bitmap,xDiff,yDiff); 1442 1468 OffsetRect(&item->statebitmap,xDiff,yDiff); 1469 1470 y = view.top+item->rect.top; 1471 if (((y >= view.top) && (y < view.bottom)) || ((y+height > view.top) && (y+height <= view.bottom))) 1472 { 1473 item->visible = TRUE; 1474 if (!infoPtr->firstVisible) 1475 infoPtr->firstVisible = item->hItem; 1476 } else item->visible = FALSE; 1443 1477 1444 1478 if ((item->firstChild) && (item->state & TVIS_EXPANDED)) … … 1468 1502 info.nMin = 0; 1469 1503 info.nMax = infoPtr->uTotalHeight-1; 1470 info.nPos = infoPtr-> cy;1504 info.nPos = infoPtr->lefttop.y; 1471 1505 info.nPage = MAX(infoPtr->uVisibleHeight,1); 1472 1506 info.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; … … 1486 1520 info.nMin = 0; 1487 1521 info.nMax = infoPtr->uTotalWidth-1; 1488 info.nPos = infoPtr-> cx;1522 info.nPos = infoPtr->lefttop.x; 1489 1523 info.nPage = MAX(infoPtr->uVisibleWidth,1); 1490 1524 info.fMask = SIF_RANGE | SIF_POS | SIF_PAGE; … … 1678 1712 1679 1713 if (tvItem->mask & TVIF_HANDLE) 1680 tvItem->hItem =wineItem->hItem;1714 tvItem->hItem = wineItem->hItem; 1681 1715 1682 1716 if (tvItem->mask & TVIF_IMAGE) 1683 tvItem->iImage =wineItem->iImage;1717 tvItem->iImage = wineItem->iImage; 1684 1718 1685 1719 if (tvItem->mask & TVIF_INTEGRAL) 1686 tvItem->iIntegral =wineItem->iIntegral;1720 tvItem->iIntegral = wineItem->iIntegral; 1687 1721 1688 1722 // undocumented: windows ignores TVIF_PARAM and … … 1691 1725 1692 1726 if (tvItem->mask & TVIF_SELECTEDIMAGE) 1693 tvItem->iSelectedImage =wineItem->iSelectedImage;1727 tvItem->iSelectedImage = wineItem->iSelectedImage; 1694 1728 1695 1729 if (tvItem->mask & TVIF_STATE) 1696 tvItem->state =wineItem->state & tvItem->stateMask;1730 tvItem->state = wineItem->state & tvItem->stateMask; 1697 1731 1698 1732 if (tvItem->mask & TVIF_TEXT) … … 1916 1950 * Forward the DPA local callback to the treeview owner callback 1917 1951 */ 1918 static INT WINAPI TREEVIEW_CallBackCompare( 1919 LPVOID first, 1920 LPVOID second, 1921 LPARAM tvInfoPtr) 1952 static INT WINAPI TREEVIEW_CallBackCompare(LPVOID first,LPVOID second,LPARAM tvInfoPtr) 1922 1953 { 1923 1954 /* Forward the call to the client define callback */ 1924 1955 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr((HWND)tvInfoPtr); 1956 1925 1957 return (infoPtr->pCallBackSort->lpfnCompare)( 1926 1958 ((TREEVIEW_ITEM*)first)->lParam, … … 1932 1964 * Treeview native sort routine: sort on item text. 1933 1965 */ 1934 static INT WINAPI TREEVIEW_SortOnName ( 1935 LPVOID first, 1936 LPVOID second, 1937 LPARAM tvInfoPtr) 1938 { 1939 HWND hwnd=(HWND) tvInfoPtr; 1940 WCHAR *txt1, *txt2; 1966 static INT WINAPI TREEVIEW_SortOnName(LPVOID first,LPVOID second,LPARAM tvInfoPtr) 1967 { 1968 HWND hwnd = (HWND)tvInfoPtr; 1969 WCHAR *txt1,*txt2; 1941 1970 TREEVIEW_ITEM *item; 1942 1971 1943 1944 item=(TREEVIEW_ITEM *) first; 1945 if (item->pszText == LPSTR_TEXTCALLBACKW) { 1946 TREEVIEW_SendDispInfoNotify (hwnd, item, TVN_GETDISPINFO, TVIF_TEXT); 1947 } 1948 txt1=item->pszText; 1949 1950 item=(TREEVIEW_ITEM *) second; 1951 if (item->pszText == LPSTR_TEXTCALLBACKW) { 1952 TREEVIEW_SendDispInfoNotify (hwnd, item, TVN_GETDISPINFO, TVIF_TEXT); 1953 } 1954 txt2=item->pszText; 1955 1956 return -lstrcmpW(txt1,txt2); 1972 item = (TREEVIEW_ITEM *) first; 1973 if (item->pszText == LPSTR_TEXTCALLBACKW) 1974 TREEVIEW_SendDispInfoNotify (hwnd, item, TVN_GETDISPINFO, TVIF_TEXT); 1975 1976 txt1 = item->pszText; 1977 1978 item = (TREEVIEW_ITEM *) second; 1979 if (item->pszText == LPSTR_TEXTCALLBACKW) 1980 TREEVIEW_SendDispInfoNotify (hwnd, item, TVN_GETDISPINFO, TVIF_TEXT); 1981 1982 txt2 = item->pszText; 1983 1984 return lstrcmpW(txt1,txt2); 1957 1985 } 1958 1986 … … 1968 1996 */ 1969 1997 1970 static LRESULT WINAPI TREEVIEW_Sort ( 1971 HWND hwnd, 1972 BOOL fRecurse, 1973 HTREEITEM parent, 1974 LPTVSORTCB pSort 1975 ) 1998 static LRESULT WINAPI TREEVIEW_Sort(HWND hwnd,BOOL fRecurse,HTREEITEM parent,LPTVSORTCB pSort) 1976 1999 { 1977 2000 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); … … 1979 2002 INT cChildren; 1980 2003 HTREEITEM hti; 2004 BOOL root; 1981 2005 1982 2006 /* Obtain the TVSORTBC struct */ … … 1985 2009 /* undocumented feature: TVI_ROOT means `sort the whole tree' */ 1986 2010 1987 if (parent==TVI_ROOT) 1988 parent=infoPtr->TopRootItem; 2011 if ((parent == TVI_ROOT) || (parent == 0)) 2012 { 2013 root = TRUE; 2014 parent = infoPtr->TopRootItem; 2015 } 1989 2016 1990 2017 /* Check for a valid handle to the parent item */ 1991 if (!TREEVIEW_ValidItem(infoPtr, parent)) 1992 { 1993 //ERR ("invalid item hParent=%x\n", (INT)parent); 2018 sortMe = TREEVIEW_ValidItem(infoPtr,parent); 2019 if (!sortMe) 1994 2020 return FALSE; 1995 }1996 1997 /* Obtain the parent node to sort */1998 sortMe = &infoPtr->items[ (INT)parent ];1999 2021 2000 2022 cChildren = 0; 2001 for(hti = sortMe->firstChild; hti; hti = infoPtr->items[(INT)hti].sibling)2023 for(hti = root ? sortMe->hItem:sortMe->firstChild; hti; hti = infoPtr->items[(INT)hti].sibling) 2002 2024 cChildren++; 2003 2025 2004 2026 /* Make sure there is something to sort */ 2005 if ( cChildren > 1)2027 if (cChildren > 1) 2006 2028 { 2007 2029 /* pointer organization */ 2008 2030 HDPA sortList = DPA_Create(cChildren); 2009 HTREEITEM itemHandle = sortMe->firstChild;2010 TREEVIEW_ITEM *itemPtr = & infoPtr->items[ (INT)itemHandle];2031 HTREEITEM itemHandle = root ? sortMe->hItem:sortMe->firstChild; 2032 TREEVIEW_ITEM *itemPtr = &infoPtr->items[(INT)itemHandle]; 2011 2033 2012 2034 /* TREEVIEW_ITEM rechaining */ … … 2019 2041 do 2020 2042 { 2043 itemPtr = &infoPtr->items[(INT)itemHandle]; 2021 2044 DPA_InsertPtr( 2022 sortList, 2045 sortList, /* the list */ 2023 2046 cChildren+1, /* force the insertion to be an append */ 2024 itemPtr); 2047 itemPtr); /* the ptr to store */ 2025 2048 2026 2049 /* Get the next sibling */ 2027 2050 itemHandle = itemPtr->sibling; 2028 itemPtr = & infoPtr->items[ (INT)itemHandle ]; 2029 } while ( itemHandle != NULL ); 2051 } while (itemHandle != NULL); 2030 2052 2031 2053 /* let DPA perform the sort activity */ … … 2037 2059 else 2038 2060 DPA_Sort ( 2039 sortList, 2040 TREEVIEW_SortOnName,/* how */2041 hwnd); 2061 sortList, /* what */ 2062 TREEVIEW_SortOnName, /* how */ 2063 hwnd); /* owner */ 2042 2064 2043 2065 /* … … 2048 2070 /* Get the first item and get ready to start... */ 2049 2071 item = DPA_GetPtr(sortList, count++); 2050 while ( (nextItem = DPA_GetPtr(sortList, count++)) != NULL)2072 while ((nextItem = DPA_GetPtr(sortList, count++)) != NULL) 2051 2073 { 2052 2074 /* link the two current item toghether */ … … 2056 2078 if (prevItem == NULL) /* this is the first item, update the parent */ 2057 2079 { 2058 sortMe->firstChild = ((TREEVIEW_ITEM*)item)->hItem; 2080 if (root) 2081 infoPtr->TopRootItem = ((TREEVIEW_ITEM*)item)->hItem; 2082 else 2083 sortMe->firstChild = ((TREEVIEW_ITEM*)item)->hItem; 2059 2084 ((TREEVIEW_ITEM*)item)->upsibling = NULL; 2060 2085 } … … 2073 2098 2074 2099 DPA_Destroy(sortList); 2100 TREEVIEW_QueueRefresh(hwnd); 2075 2101 2076 2102 return TRUE; … … 2083 2109 * and sort the children of the TV item specified in lParam 2084 2110 */ 2085 static LRESULT WINAPI TREEVIEW_SortChildrenCB( 2086 HWND hwnd, 2087 WPARAM wParam, 2088 LPARAM lParam 2089 ) 2090 { 2091 LPTVSORTCB pSort=(LPTVSORTCB) lParam; 2111 static LRESULT WINAPI TREEVIEW_SortChildrenCB(HWND hwnd,WPARAM wParam,LPARAM lParam) 2112 { 2113 LPTVSORTCB pSort = (LPTVSORTCB) lParam; 2092 2114 2093 2115 return TREEVIEW_Sort (hwnd, wParam, pSort->hParent, pSort); … … 2098 2120 * Sort the children of the TV item specified in lParam. 2099 2121 */ 2100 static LRESULT WINAPI TREEVIEW_SortChildren ( 2101 HWND hwnd, 2102 WPARAM wParam, 2103 LPARAM lParam) 2122 static LRESULT WINAPI TREEVIEW_SortChildren(HWND hwnd,WPARAM wParam,LPARAM lParam) 2104 2123 { 2105 2124 return TREEVIEW_Sort (hwnd, (BOOL) wParam, (HTREEITEM) lParam, NULL); … … 2380 2399 } 2381 2400 2382 2383 /* Fill in info structure */ 2384 2385 wineItem->mask=tvItem->mask; 2386 wineItem->iIntegral=1; 2387 2388 if (tvItem->mask & TVIF_CHILDREN) 2389 wineItem->cChildren=tvItem->cChildren; 2390 2401 /* Fill in info structure */ 2402 2403 wineItem->mask = tvItem->mask; 2404 wineItem->iIntegral = 1; 2405 2406 if (tvItem->mask & TVIF_CHILDREN) 2407 wineItem->cChildren=tvItem->cChildren; 2391 2408 2392 2409 wineItem->expandBox.left = 0; /* Initialize the expandBox */ … … 2395 2412 wineItem->expandBox.bottom = 0; 2396 2413 2397 if (tvItem->mask & TVIF_IMAGE) 2398 wineItem->iImage=tvItem->iImage; 2399 2400 /* If the application sets TVIF_INTEGRAL without 2401 supplying a TVITEMEX structure, it's toast */ 2402 2403 if (tvItem->mask & TVIF_INTEGRAL) 2404 wineItem->iIntegral=tvItem->iIntegral; 2405 2406 if (tvItem->mask & TVIF_SELECTEDIMAGE) 2407 wineItem->iSelectedImage=tvItem->iSelectedImage; 2408 2409 if (tvItem->mask & TVIF_STATE) { 2410 wineItem->state=tvItem->state; 2411 wineItem->stateMask=tvItem->stateMask; 2412 } 2413 2414 wineItem->calculated = FALSE; 2415 TREEVIEW_QueueRefresh(hwnd); 2416 2417 return (LRESULT) iItem; 2414 if (tvItem->mask & TVIF_IMAGE) 2415 wineItem->iImage = tvItem->iImage; 2416 2417 /* If the application sets TVIF_INTEGRAL without 2418 supplying a TVITEMEX structure, it's toast */ 2419 2420 if (tvItem->mask & TVIF_INTEGRAL) 2421 wineItem->iIntegral = tvItem->iIntegral; 2422 2423 if (tvItem->mask & TVIF_SELECTEDIMAGE) 2424 wineItem->iSelectedImage = tvItem->iSelectedImage; 2425 2426 if (tvItem->mask & TVIF_STATE) 2427 { 2428 wineItem->state = tvItem->state; 2429 wineItem->stateMask = tvItem->stateMask; 2430 } 2431 2432 wineItem->calculated = FALSE; 2433 TREEVIEW_QueueRefresh(hwnd); 2434 2435 return (LRESULT) iItem; 2418 2436 } 2419 2437 … … 2634 2652 2635 2653 if (wParam == SIZE_RESTORED) 2636 {2637 2654 if (TREEVIEW_CalcItems(hwnd,0,infoPtr)) 2638 #if 1 //CB: synchron update conflicts with Odin32 implementation -> check and fix 2639 TREEVIEW_QueueRefresh(hwnd); 2640 #else 2641 TREEVIEW_Refresh(hwnd); //because size redraw isn't set 2642 #endif 2643 } 2655 TREEVIEW_Refresh(hwnd); 2644 2656 2645 2657 return TRUE; … … 2689 2701 2690 2702 /* set default settings */ 2691 infoPtr->uInternalStatus = 0;2703 infoPtr->uInternalStatus = TV_CALCALL; 2692 2704 if (IsWindowUnicode(hwnd)) infoPtr->uInternalStatus |= TV_UNICODE; 2693 2705 infoPtr->uNumItems = 0; … … 2695 2707 infoPtr->clrLine = GetSysColor (COLOR_WINDOWTEXT); 2696 2708 infoPtr->clrInsertMark = GetSysColor (COLOR_BTNTEXT); 2697 infoPtr-> cy = 0;2698 infoPtr-> cx = 0;2709 infoPtr->lefttop.y = 0; 2710 infoPtr->lefttop.x = 0; 2699 2711 infoPtr->uIndent = 15; 2700 2712 infoPtr->himlNormal = NULL; … … 2702 2714 infoPtr->uItemHeight = -1; 2703 2715 infoPtr->uRealItemHeight = 0; 2716 infoPtr->uVScrollStep = 1; 2704 2717 infoPtr->uVisibleHeight = lpcs->cy; 2705 2718 infoPtr->uTotalHeight = 0; … … 2725 2738 infoPtr->uISearchLen = 0; 2726 2739 2740 infoPtr->tipItem = 0; 2727 2741 infoPtr->hwndToolTip = 0; 2728 2742 if (!(dwStyle & TVS_NOTOOLTIPS)) … … 2752 2766 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 2753 2767 ti.cbSize = sizeof(TTTOOLINFOA); 2754 ti.uFlags = TTF_ IDISHWND | TTF_TRACK | TTF_TRANSPARENT;2768 ti.uFlags = TTF_TRACK | TTF_ABSOLUTE; 2755 2769 ti.hwnd = hwnd; 2756 2770 ti.uId = 0; 2757 ti.lpszText = " Test"; /* LPSTR_TEXTCALLBACK; */2771 ti.lpszText = ""; 2758 2772 SetRectEmpty (&ti.rect); 2759 2773 … … 2887 2901 TREEVIEW_SendTreeviewNotify (HWND hwnd, UINT code, UINT action, 2888 2902 HTREEITEM oldItem, HTREEITEM newItem) 2889 2890 2903 { 2891 2904 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); … … 2895 2908 BOOL unicode = IsWindowUnicode(parent),rc; 2896 2909 CHAR *oldText = NULL,*newText = NULL; 2897 2898 // TRACE (treeview,"code:%x action:%x olditem:%x newitem:%x\n",2899 // code,action,(INT)oldItem,(INT)newItem);2900 2910 2901 2911 ZeroMemory(&nmhdr,sizeof(NMTREEVIEWW)); … … 2979 2989 TREEVIEW_ITEM *wineItem; 2980 2990 2981 // TRACE (treeview,"code:%x dragitem:%x\n", code,(INT)dragItem);2982 2983 2991 nmhdr.hdr.hwndFrom = hwnd; 2984 2992 nmhdr.hdr.idFrom = GetWindowLongA( hwnd, GWL_ID); … … 3078 3086 LPNMCUSTOMDRAW nmcd; 3079 3087 3080 // TRACE (treeview,"drawstage:%lx hdc:%x\n", dwDrawStage, hdc);3081 3082 3088 nmcd= & nmcdhdr.nmcd; 3083 3089 nmcd->hdr.hwndFrom = hwnd; … … 3085 3091 nmcd->hdr.code = NM_CUSTOMDRAW; 3086 3092 nmcd->dwDrawStage= dwDrawStage; 3087 nmcd->hdc 3093 nmcd->hdc = hdc; 3088 3094 nmcd->rc.left = rc.left; 3089 3095 nmcd->rc.right = rc.right; … … 3219 3225 if (flag & TVE_EXPANDPARTIAL) 3220 3226 { 3221 //TRACE(treeview, " case TVE_EXPANDPARTIAL\n");3222 //FIXME (treeview, "TVE_EXPANDPARTIAL not implemented\n");3223 3227 return FALSE; //CB: to check 3224 3228 wineItem->state ^=TVIS_EXPANDED; … … 3623 3627 ht.pt.y = (INT)HIWORD(lParam); 3624 3628 3625 if (!TREEVIEW_HitTest(hwnd,&ht)) return 0;3629 TREEVIEW_HitTest(hwnd,&ht); 3626 3630 3627 3631 if (ht.hItem) 3628 3632 { 3633 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 3634 3629 3635 item = &infoPtr->items[(INT)ht.hItem]; 3636 3637 if (infoPtr->hwndToolTip && ((item->text.left < 0) || (item->text.right > infoPtr->uVisibleWidth)) && (infoPtr->tipItem != item->hItem)) 3638 { 3639 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 3640 LPWSTR text; 3641 TTTOOLINFOW ti; 3642 POINT pt; 3643 3644 if(dwStyle & TVS_INFOTIP) 3645 { 3646 NMTVGETINFOTIPW tvgit; 3647 HWND parent = GetParent(hwnd); 3648 BOOL unicode = IsWindowUnicode(parent); 3649 3650 tvgit.hdr.hwndFrom = hwnd; 3651 tvgit.hdr.idFrom = GetWindowLongA(hwnd,GWL_ID); 3652 tvgit.hdr.code = unicode ? TVN_GETINFOTIPW:TVN_GETINFOTIPA; 3653 tvgit.pszText = COMCTL32_Alloc(unicode ? INFOTIPSIZE*sizeof(WCHAR):INFOTIPSIZE*sizeof(CHAR)); 3654 tvgit.cchTextMax = INFOTIPSIZE; 3655 tvgit.hItem = item->hItem; 3656 tvgit.lParam = item->lParam; 3657 3658 if (unicode) 3659 { 3660 SendMessageW(parent,WM_NOTIFY,(WPARAM)tvgit.hdr.idFrom,(LPARAM)&tvgit); 3661 text = tvgit.pszText; 3662 } else 3663 { 3664 SendMessageA(parent,WM_NOTIFY,(WPARAM)tvgit.hdr.idFrom,(LPARAM)&tvgit); 3665 text = COMCTL32_Alloc(tvgit.cchTextMax*sizeof(WCHAR)); 3666 lstrcpyAtoW(text,(LPSTR)tvgit.pszText); 3667 } 3668 } else 3669 { 3670 if (item->pszText == LPSTR_TEXTCALLBACKW) 3671 TREEVIEW_SendDispInfoNotify(hwnd,item,TVN_GETDISPINFO,TVIF_TEXT); 3672 3673 text = item->pszText; 3674 } 3675 #if 0 //CB: not yet 3676 infoPtr->tipItem = item->hItem; 3677 ti.cbSize = sizeof(ti); 3678 ti.uId = 0; 3679 ti.hwnd = hwnd; 3680 ti.hinst = 0; 3681 ti.lpszText = text; 3682 pt.x = ti.rect.left; 3683 pt.y = ti.rect.top; 3684 ClientToScreen(hwnd,&pt); 3685 SendMessageA(infoPtr->hwndToolTip,TTM_TRACKPOSITION,0,(LPARAM)MAKELPARAM(pt.x,pt.y)); 3686 SendMessageA(infoPtr->hwndToolTip,TTM_UPDATETIPTEXTW,0,(LPARAM)&ti); 3687 SendMessageA(infoPtr->hwndToolTip,TTM_TRACKACTIVATE,(WPARAM)TRUE,(LPARAM)&ti); 3688 #endif 3689 if (text != item->pszText) COMCTL32_Free(text); 3690 } 3691 3692 if (dwStyle & TVS_TRACKSELECT) 3693 { 3694 //CB: todo: hottracking 3695 } 3630 3696 } 3631 3697 … … 3666 3732 if (ht.flags & TVHT_ONITEMBUTTON) 3667 3733 { 3668 TREEVIEW_Expand (hwnd, (WPARAM) TVE_TOGGLE, (LPARAM) ht.hItem); 3669 goto setfocus; 3670 } 3671 else if (bTrack) 3672 { 3673 if (TREEVIEW_TrackMouse(hwnd, ht.pt)) 3674 { 3675 TREEVIEW_SendTreeviewDnDNotify (hwnd, TVN_BEGINDRAG, ht.hItem, ht.pt); 3676 infoPtr->dropItem = ht.hItem; 3677 return 0; 3678 } 3734 TREEVIEW_Expand (hwnd, (WPARAM) TVE_TOGGLE, (LPARAM) ht.hItem); 3735 goto setfocus; 3736 } else if (bTrack) 3737 { 3738 if (TREEVIEW_TrackMouse(hwnd, ht.pt)) 3739 { 3740 TREEVIEW_SendTreeviewDnDNotify (hwnd, TVN_BEGINDRAG, ht.hItem, ht.pt); 3741 infoPtr->dropItem = ht.hItem; 3742 return 0; 3743 } 3679 3744 } 3680 3745 … … 3686 3751 * and the click occured on the item label... 3687 3752 */ 3688 if ( ( dwStyle & TVS_EDITLABELS ) && 3689 ( ht.flags & TVHT_ONITEMLABEL ) && 3690 ( infoPtr->selectedItem == ht.hItem ) ) 3691 { 3692 if (infoPtr->Timer & TV_EDIT_TIMER_SET) 3693 KillTimer (hwnd, TV_EDIT_TIMER); 3694 3695 infoPtr->editItem = ht.hItem; 3696 SetTimer (hwnd, TV_EDIT_TIMER, GetDoubleClickTime(), 0); 3697 infoPtr->Timer|=TV_EDIT_TIMER_SET; 3753 if ((dwStyle & TVS_EDITLABELS) && (ht.flags & TVHT_ONITEMLABEL) && (infoPtr->selectedItem == ht.hItem)) 3754 { 3755 if (infoPtr->Timer & TV_EDIT_TIMER_SET) 3756 KillTimer (hwnd, TV_EDIT_TIMER); 3757 3758 infoPtr->editItem = ht.hItem; 3759 SetTimer (hwnd, TV_EDIT_TIMER, GetDoubleClickTime(), 0); 3760 infoPtr->Timer|=TV_EDIT_TIMER_SET; 3761 } else if (ht.flags & (TVHT_ONITEMLABEL | TVHT_ONITEMICON)) 3762 { 3763 TREEVIEW_DoSelectItem(hwnd,TVGN_CARET,ht.hItem,TVC_BYMOUSE); 3764 } else if (ht.flags & TVHT_ONITEMSTATEICON) 3765 { 3766 if (dwStyle & TVS_CHECKBOXES) /* TVS_CHECKBOXES requires _us_ */ 3767 { /* to toggle the current state */ 3768 int state; 3769 TREEVIEW_ITEM *wineItem; 3770 3771 wineItem = TREEVIEW_ValidItem(infoPtr, ht.hItem); 3772 3773 state = 1-(wineItem->state>>12); 3774 wineItem->state &= ~TVIS_STATEIMAGEMASK; 3775 wineItem->state |= state<<12; 3776 if (wineItem->visible) 3777 { 3778 TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE); 3779 InvalidateRect(hwnd,&wineItem->statebitmap,TRUE); 3698 3780 } 3699 else if ( ht.flags & (TVHT_ONITEMLABEL | TVHT_ONITEMICON)) 3700 { 3701 TREEVIEW_DoSelectItem ( hwnd, TVGN_CARET, ht.hItem, TVC_BYMOUSE); 3702 } 3703 else if (ht.flags & TVHT_ONITEMSTATEICON) 3704 { 3705 if (dwStyle & TVS_CHECKBOXES) /* TVS_CHECKBOXES requires _us_ */ 3706 { /* to toggle the current state */ 3707 int state; 3708 TREEVIEW_ITEM *wineItem; 3709 3710 wineItem = TREEVIEW_ValidItem(infoPtr, ht.hItem); 3711 3712 state = 1-(wineItem->state>>12); 3713 wineItem->state &= ~TVIS_STATEIMAGEMASK; 3714 wineItem->state |= state<<12; 3715 if (wineItem->visible) 3716 { 3717 TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE); 3718 InvalidateRect(hwnd,&wineItem->statebitmap,TRUE); 3719 } 3720 } 3781 } 3721 3782 } 3722 3783 3723 3784 setfocus: 3724 3785 SetFocus (hwnd); 3786 3725 3787 return 0; 3726 3788 } … … 3799 3861 hOldFont=SelectObject (hdc, infoPtr->hFont); 3800 3862 GetTextExtentPoint32W (hdc, itemtxt, lstrlenW (itemtxt), &size); 3801 // TRACE (treeview,"%d %d %s %d\n",size.cx,size.cy,itemtxt,lstrlenA(itemtxt)); 3863 3802 3864 hbmp=CreateCompatibleBitmap (htopdc, size.cx, size.cy); 3803 3865 hOldbmp=SelectObject (hdc, hbmp); … … 3837 3899 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 3838 3900 TREEVIEW_ITEM *prevItem,*wineItem; 3901 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 3839 3902 INT prevSelect; 3840 3903 … … 3867 3930 3868 3931 if (newSelect) 3869 if (TREEVIEW_SendTreeviewNotify( 3870 hwnd, 3871 TVN_SELCHANGING, 3872 cause, 3873 (HTREEITEM)prevSelect, 3874 (HTREEITEM)newSelect)) 3932 if (TREEVIEW_SendTreeviewNotify(hwnd,TVN_SELCHANGING,cause,(HTREEITEM)prevSelect,(HTREEITEM)newSelect)) 3875 3933 return FALSE; /* FIXME: OK? */ 3876 3934 … … 3882 3940 infoPtr->selectedItem = (HTREEITEM)newSelect; 3883 3941 3942 if ((cause == TVC_BYMOUSE) && (dwStyle & TVS_SINGLEEXPAND)) 3943 { 3944 BOOL control = GetKeyState(VK_CONTROL) & 0x8000; 3945 UINT rc = TREEVIEW_SendTreeviewNotify(hwnd,TVN_SINGLEEXPAND,0,prevItem->hItem,wineItem->hItem); 3946 3947 if (!(rc & TVNRET_SKIPOLD) && !control && prevItem->state & TVIS_EXPANDED) 3948 TREEVIEW_Expand(hwnd,TVE_COLLAPSE,(LPARAM)prevItem->hItem); 3949 if (!(rc & TVNRET_SKIPNEW) && TREEVIEW_HasChildren(hwnd,wineItem)) 3950 TREEVIEW_Expand(hwnd,TVE_TOGGLE,(LPARAM)wineItem->hItem); 3951 } 3952 3884 3953 TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE); 3885 3954 TREEVIEW_RefreshItem(hwnd,prevItem,FALSE); 3886 3955 TREEVIEW_RefreshItem(hwnd,wineItem,FALSE); 3887 3956 3888 TREEVIEW_SendTreeviewNotify( 3889 hwnd, 3890 TVN_SELCHANGED, 3891 cause, 3892 (HTREEITEM)prevSelect, 3893 (HTREEITEM)newSelect); 3957 TREEVIEW_SendTreeviewNotify(hwnd,TVN_SELCHANGED,cause,(HTREEITEM)prevSelect,(HTREEITEM)newSelect); 3894 3958 3895 3959 break; … … 3914 3978 case TVGN_FIRSTVISIBLE: 3915 3979 { 3980 TREEVIEW_ITEM *firstVis; 3916 3981 INT scrollY; 3982 3983 if (!infoPtr->firstVisible) return FALSE; 3984 3985 firstVis = &infoPtr->items[(INT)infoPtr->firstVisible]; 3917 3986 3918 3987 if (wineItem->rect.top < 0) … … 3920 3989 else 3921 3990 { 3922 scrollY = MIN(wineItem->rect.top, infoPtr->uTotalHeight-infoPtr->uVisibleHeight);3923 if (scrollY < 0) scrollY = 0;3991 scrollY = MIN(wineItem->rect.top,(infoPtr->uTotalHeight-infoPtr->uVisibleHeight)-infoPtr->lefttop.y); 3992 scrollY -= scrollY % infoPtr->uVScrollStep; 3924 3993 } 3925 3994 3926 3995 if (scrollY != 0) 3927 3996 { 3928 infoPtr-> cy += scrollY;3997 infoPtr->lefttop.y += scrollY; 3929 3998 if (!TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE)) 3930 3999 TREEVIEW_CalcItems(hwnd,0,infoPtr); … … 3974 4043 infoPtr->hBoldFont = CreateFontIndirectA (&logFont); 3975 4044 3976 hdc = GetDC(hwnd); 3977 hOldFont = SelectObject (hdc, hFont); 3978 GetTextMetricsA (hdc, &tm); 3979 height= tm.tmHeight + tm.tmExternalLeading; 3980 if (height > infoPtr->uRealItemHeight) 3981 infoPtr->uRealItemHeight = height; 3982 SelectObject (hdc, hOldFont); 3983 ReleaseDC(hwnd,hdc); 4045 infoPtr->uInternalStatus |= TV_CALCALL; 4046 TREEVIEW_CalcItems(hwnd,0,infoPtr); 3984 4047 3985 4048 if (lParam) 3986 4049 { 3987 4050 TREEVIEW_UnqueueRefresh(hwnd,FALSE,FALSE); 3988 infoPtr->uInternalStatus |= TV_CALCALL;3989 TREEVIEW_CalcItems(hwnd,0,infoPtr);3990 4051 TREEVIEW_Refresh(hwnd); 3991 } else infoPtr->uInternalStatus |= TV_CALCALL;4052 } 3992 4053 3993 4054 return 0; 3994 4055 } 3995 3996 4056 3997 4057 static LRESULT … … 3999 4059 { 4000 4060 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 4001 int maxHeight;4002 int lastPos = infoPtr->cy;4061 INT scrollY; 4062 INT maxY = infoPtr->uTotalHeight-infoPtr->uVisibleHeight; 4003 4063 4004 4064 if (!(infoPtr->uInternalStatus & TV_VSCROLL)) return FALSE; … … 4007 4067 { 4008 4068 case SB_LINEUP: 4009 if (!infoPtr->cy) return FALSE; 4010 infoPtr->cy -= infoPtr->uRealItemHeight; 4011 if (infoPtr->cy < 0) infoPtr->cy = 0; 4069 scrollY = MIN(infoPtr->uVScrollStep,infoPtr->lefttop.y); 4012 4070 break; 4013 4071 4014 4072 case SB_LINEDOWN: 4015 maxHeight = infoPtr->uTotalHeight-infoPtr->uVisibleHeight; 4016 if (maxHeight <= 0) return FALSE; 4017 if (infoPtr->cy == maxHeight) return FALSE; 4018 infoPtr->cy += infoPtr->uRealItemHeight; 4019 if (infoPtr->cy > maxHeight) 4020 infoPtr->cy = maxHeight; 4073 scrollY = -infoPtr->uVScrollStep; 4074 if (infoPtr->lefttop.y-scrollY > maxY) scrollY = -(maxY-infoPtr->lefttop.y); 4021 4075 break; 4022 4076 4023 4077 case SB_PAGEUP: 4024 if (!infoPtr->cy) return FALSE; 4025 infoPtr->cy -= infoPtr->uVisibleHeight; 4026 if (infoPtr->cy < 0) infoPtr->cy = 0; 4078 scrollY = MIN(infoPtr->uVisibleHeight,infoPtr->lefttop.y); 4027 4079 break; 4028 4080 4029 4081 case SB_PAGEDOWN: 4030 maxHeight = infoPtr->uTotalHeight-infoPtr->uVisibleHeight; 4031 if (maxHeight <= 0) return FALSE; 4032 if (infoPtr->cy == maxHeight) return FALSE; 4033 infoPtr->cy += infoPtr->uVisibleHeight; 4034 if (infoPtr->cy > maxHeight) 4035 infoPtr->cy = maxHeight; 4082 scrollY = -infoPtr->uVisibleHeight; 4083 if (infoPtr->lefttop.y-scrollY > maxY) scrollY = -(maxY-infoPtr->lefttop.y); 4084 if (scrollY > 0) scrollY = 0; 4036 4085 break; 4037 4086 4038 4087 case SB_THUMBTRACK: 4039 maxHeight = infoPtr->uTotalHeight-infoPtr->uVisibleHeight; 4040 if (maxHeight <= 0) return FALSE; 4041 infoPtr->cy = HIWORD(wParam); 4042 if (infoPtr->cy < 0) infoPtr->cy = 0; 4043 if (infoPtr->cy > maxHeight) infoPtr->cy = maxHeight; 4088 scrollY = infoPtr->lefttop.y-HIWORD(wParam); 4044 4089 break; 4045 4090 … … 4048 4093 } 4049 4094 4050 if (lastPos != infoPtr->cy) 4051 { 4095 scrollY -= scrollY % infoPtr->uVScrollStep; //CB: todo 4096 4097 if (scrollY != 0) 4098 { 4099 infoPtr->lefttop.y -= scrollY; 4052 4100 if (!TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE)) 4053 4101 TREEVIEW_CalcItems(hwnd,0,infoPtr); 4054 ScrollWindowEx(hwnd,0, lastPos-infoPtr->cy,NULL,NULL,0,NULL,SW_INVALIDATE | SW_SCROLLCHILDREN | (infoPtr->uScrollTime << 16));4102 ScrollWindowEx(hwnd,0,scrollY,NULL,NULL,0,NULL,SW_INVALIDATE | SW_SCROLLCHILDREN | (infoPtr->uScrollTime << 16)); 4055 4103 4056 4104 return TRUE; … … 4065 4113 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 4066 4114 int maxWidth; 4067 int lastPos = infoPtr-> cx;4115 int lastPos = infoPtr->lefttop.x; 4068 4116 4069 4117 if (!(infoPtr->uInternalStatus & TV_HSCROLL)) return FALSE; … … 4072 4120 { 4073 4121 case SB_LINEUP: 4074 if (!infoPtr-> cx) return FALSE;4075 infoPtr-> cx -= infoPtr->uRealItemHeight;4076 if (infoPtr-> cx < 0) infoPtr->cx = 0;4122 if (!infoPtr->lefttop.x) return FALSE; 4123 infoPtr->lefttop.x -= infoPtr->uRealItemHeight; 4124 if (infoPtr->lefttop.x < 0) infoPtr->lefttop.x = 0; 4077 4125 break; 4078 4126 … … 4080 4128 maxWidth = infoPtr->uTotalWidth-infoPtr->uVisibleWidth; 4081 4129 if (maxWidth <= 0) return FALSE; 4082 if (infoPtr-> cx == maxWidth) return FALSE;4083 infoPtr-> cx += infoPtr->uRealItemHeight; /*FIXME */4084 if (infoPtr-> cx > maxWidth)4085 infoPtr-> cx = maxWidth;4130 if (infoPtr->lefttop.x == maxWidth) return FALSE; 4131 infoPtr->lefttop.x += infoPtr->uRealItemHeight; /*FIXME */ 4132 if (infoPtr->lefttop.x > maxWidth) 4133 infoPtr->lefttop.x = maxWidth; 4086 4134 break; 4087 4135 4088 4136 case SB_PAGEUP: 4089 if (!infoPtr-> cx) return FALSE;4090 infoPtr-> cx -= infoPtr->uVisibleWidth;4091 if (infoPtr-> cx < 0) infoPtr->cx = 0;4137 if (!infoPtr->lefttop.x) return FALSE; 4138 infoPtr->lefttop.x -= infoPtr->uVisibleWidth; 4139 if (infoPtr->lefttop.x < 0) infoPtr->lefttop.x = 0; 4092 4140 break; 4093 4141 … … 4095 4143 maxWidth = infoPtr->uTotalWidth-infoPtr->uVisibleWidth; 4096 4144 if (maxWidth <= 0) return FALSE; 4097 if (infoPtr-> cx == maxWidth) return FALSE;4098 infoPtr-> cx += infoPtr->uVisibleWidth;4099 if (infoPtr-> cx > maxWidth)4100 infoPtr-> cx = maxWidth;4145 if (infoPtr->lefttop.x == maxWidth) return FALSE; 4146 infoPtr->lefttop.x += infoPtr->uVisibleWidth; 4147 if (infoPtr->lefttop.x > maxWidth) 4148 infoPtr->lefttop.x = maxWidth; 4101 4149 break; 4102 4150 … … 4104 4152 maxWidth = infoPtr->uTotalWidth-infoPtr->uVisibleWidth; 4105 4153 if (maxWidth <= 0) return FALSE; 4106 infoPtr-> cx = HIWORD(wParam);4107 if (infoPtr-> cx < 0) infoPtr->cx = 0;4108 if (infoPtr-> cx > maxWidth) infoPtr->cx = maxWidth;4154 infoPtr->lefttop.x = HIWORD(wParam); 4155 if (infoPtr->lefttop.x < 0) infoPtr->lefttop.x = 0; 4156 if (infoPtr->lefttop.x > maxWidth) infoPtr->lefttop.x = maxWidth; 4109 4157 break; 4110 4158 … … 4113 4161 } 4114 4162 4115 if (lastPos != infoPtr-> cx)4163 if (lastPos != infoPtr->lefttop.x) 4116 4164 { 4117 4165 if (!TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE)) 4118 4166 TREEVIEW_CalcItems(hwnd,0,infoPtr); 4119 ScrollWindowEx(hwnd,lastPos-infoPtr-> cx,0,NULL,NULL,0,NULL,SW_INVALIDATE | SW_SCROLLCHILDREN | (infoPtr->uScrollTime << 16));4167 ScrollWindowEx(hwnd,lastPos-infoPtr->lefttop.x,0,NULL,NULL,0,NULL,SW_INVALIDATE | SW_SCROLLCHILDREN | (infoPtr->uScrollTime << 16)); 4120 4168 4121 4169 return TRUE; … … 4144 4192 { 4145 4193 int wheelDy = pulScrollLines * infoPtr->uRealItemHeight; 4146 int newDy = infoPtr-> cy + wheelDy;4147 int maxDy = infoPtr->uTotalHeight -infoPtr->uVisibleHeight;4194 int newDy = infoPtr->lefttop.y + wheelDy; 4195 int maxDy = infoPtr->uTotalHeight-infoPtr->uVisibleHeight; 4148 4196 4149 4197 if (newDy > maxDy) newDy = maxDy; 4150 4198 if (newDy < 0) newDy = 0; 4151 4199 4152 if (newDy == infoPtr-> cy) return TRUE;4200 if (newDy == infoPtr->lefttop.y) return TRUE; 4153 4201 4154 4202 TREEVIEW_VScroll(hwnd, MAKEWPARAM(SB_THUMBTRACK,newDy),0); … … 4329 4377 if (hNewSelection) 4330 4378 { 4331 if ( TREEVIEW_DoSelectItem( 4332 hwnd, 4333 TVGN_CARET, 4334 (HTREEITEM)hNewSelection, 4335 TVC_BYKEYBOARD)) 4379 if (TREEVIEW_DoSelectItem(hwnd,TVGN_CARET,(HTREEITEM)hNewSelection,TVC_BYKEYBOARD)) 4336 4380 { 4337 4381 TREEVIEW_EnsureVisible(hwnd,hNewSelection); … … 4397 4441 scrollY = item->rect.top; 4398 4442 else if (item->rect.bottom > rect.bottom) 4443 { 4444 INT mod; 4445 4399 4446 scrollY = item->rect.bottom-rect.bottom; 4400 else return FALSE; 4447 mod = scrollY % infoPtr->uVScrollStep; 4448 if (mod) scrollY += infoPtr->uVScrollStep-mod; 4449 } else return FALSE; 4401 4450 4402 4451 if (scrollY != 0) 4403 4452 { 4404 infoPtr-> cy += scrollY;4453 infoPtr->lefttop.y += scrollY; 4405 4454 TREEVIEW_CalcItems(hwnd,0,infoPtr); 4406 4455 ScrollWindowEx(hwnd,0,-scrollY,NULL,NULL,0,NULL,SW_INVALIDATE | SW_SCROLLCHILDREN | (infoPtr->uScrollTime << 16)); … … 4422 4471 } 4423 4472 4424 static TREEVIEW_ITEM* TREEVIEW_SearchChildren(HWND hwnd,TREEVIEW_INFO *infoPtr,TREEVIEW_ITEM *item,TREEVIEW_ITEM *stop,LPWSTR text,INT textlen)4425 {4426 TREEVIEW_ITEM *child,*child2;4427 4428 if (!(item->firstChild && (item->state & TVIS_EXPANDED))) return NULL;4429 4430 child = &infoPtr->items[(INT)item->firstChild];4431 while (child)4432 {4433 if (child == stop) return NULL;4434 if (TREEVIEW_Compare(hwnd,child,text,textlen)) return child;4435 child2 = TREEVIEW_SearchChildren(hwnd,infoPtr,child,stop,text,textlen);4436 if (child2) return child2;4437 if (child->sibling) child = &infoPtr->items[(INT)child->sibling];4438 else return NULL;4439 }4440 4441 return NULL;4442 }4443 4444 4473 static TREEVIEW_ITEM* TREEVIEW_Search(HWND hwnd,TREEVIEW_INFO *infoPtr,INT iItem,LPWSTR text,INT textlen) 4445 4474 { … … 4449 4478 item = start = &infoPtr->items[iItem]; 4450 4479 4451 if (TREEVIEW_Compare(hwnd,item,text,textlen)) found = TRUE; else 4452 { 4453 //search start to end 4454 while (item->sibling || item->parent) 4455 { 4456 TREEVIEW_ITEM *child = TREEVIEW_SearchChildren(hwnd,infoPtr,item,NULL,text,textlen); 4457 4458 if (child) 4459 { 4460 found = TRUE; 4461 item = child; 4462 break; 4463 } 4464 4480 //search start to end 4481 while (item) 4482 { 4483 if (TREEVIEW_Compare(hwnd,item,text,textlen)) return item; 4484 item = TREEVIEW_GetNextListItem(hwnd,infoPtr,item); 4485 } 4486 if (!found) 4487 { 4488 iItem = (INT)infoPtr->TopRootItem; 4489 item = &infoPtr->items[iItem]; 4490 4491 //search first to start 4492 while (item != start) 4493 { 4494 if (TREEVIEW_Compare(hwnd,item,text,textlen)) return item; 4465 4495 item = TREEVIEW_GetNextListItem(hwnd,infoPtr,item); 4466 if (item && TREEVIEW_Compare(hwnd,item,text,textlen))4467 {4468 found = TRUE;4469 break;4470 }4471 4496 } 4472 if (!found) 4473 { 4474 iItem = (INT)infoPtr->TopRootItem; 4475 item = &infoPtr->items[iItem]; 4476 //search first to start 4477 while (item != start) 4478 { 4479 TREEVIEW_ITEM *child; 4480 4481 if (TREEVIEW_Compare(hwnd,item,text,textlen)) 4482 { 4483 found = TRUE; 4484 break; 4485 } 4486 child = TREEVIEW_SearchChildren(hwnd,infoPtr,item,start,text,textlen); 4487 4488 if (child) 4489 { 4490 found = TRUE; 4491 item = child; 4492 break; 4493 } 4494 if (item->sibling) item = &infoPtr->items[(INT)item->sibling]; 4495 else break; 4496 } 4497 } 4498 } 4499 4500 return found ? item:NULL; 4501 } 4497 } 4498 4499 return NULL; 4500 } 4501 4502 //CB: this method is CPU intense: optimize it and use a secondary thread 4502 4503 4503 4504 static VOID TREEVIEW_ISearch(HWND hwnd,CHAR ch) … … 4534 4535 4535 4536 iItem = infoPtr->selectedItem ? (INT)infoPtr->selectedItem:(INT)infoPtr->TopRootItem; 4537 4538 if (infoPtr->selectedItem) 4539 { 4540 item = &infoPtr->items[iItem]; 4541 item = TREEVIEW_GetNextListItem(hwnd,infoPtr,item); 4542 if (!item) item = &infoPtr->items[(INT)infoPtr->TopRootItem]; 4543 iItem = (INT)item->hItem; 4544 } else iItem = (INT)infoPtr->TopRootItem; 4545 4536 4546 item = TREEVIEW_Search(hwnd,infoPtr,iItem,newString,len); 4537 if (!item && infoPtr-> pszISearch)4547 if (!item && infoPtr->selectedItem && infoPtr->pszISearch) 4538 4548 { 4539 4549 TREEVIEW_ITEM *next; 4540 //CB: todo: must press key twice to go to the next item 4550 4541 4551 item = &infoPtr->items[iItem]; 4542 next = TREEVIEW_GetNextListItem(hwnd,infoPtr,item); 4543 if (!next) next = &infoPtr->items[(INT)infoPtr->TopRootItem]; 4544 if (next && (next != item)) 4545 { 4546 next = TREEVIEW_Search(hwnd,infoPtr,(INT)next->hItem,infoPtr->pszISearch,infoPtr->uISearchLen); 4547 if (next) 4548 TREEVIEW_SelectItem(hwnd,(WPARAM)TVGN_CARET,(LPARAM)next->hItem); 4552 next = TREEVIEW_Search(hwnd,infoPtr,(INT)item->hItem,infoPtr->pszISearch,infoPtr->uISearchLen); 4553 if (next) 4554 { 4555 TREEVIEW_SelectItem(hwnd,(WPARAM)TVGN_CARET,(LPARAM)next->hItem); 4556 TREEVIEW_EnsureVisible(hwnd,next->hItem); 4549 4557 } 4550 4558 COMCTL32_Free(newString); … … 4559 4567 infoPtr->uISearchLen = len; 4560 4568 TREEVIEW_SelectItem(hwnd,(WPARAM)TVGN_CARET,(LPARAM)item->hItem); 4569 TREEVIEW_EnsureVisible(hwnd,item->hItem); 4561 4570 SetTimer(hwnd,TV_ISEARCH_TIMER,TV_ISEARCH_DELAY,0); 4562 4571 infoPtr->Timer |= TV_ISEARCH_TIMER_SET; … … 4687 4696 4688 4697 case TVM_SORTCHILDREN: 4689 //@@@PH 1999/10/25 TREEVIEW_SortChildrenCB is wrong4690 4698 return TREEVIEW_SortChildren(hwnd, wParam, lParam); 4691 4699
Note:
See TracChangeset
for help on using the changeset viewer.