Changeset 2814 for trunk/src/comctl32/treeview.c
- Timestamp:
- Feb 17, 2000, 6:26:51 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/treeview.c
r2806 r2814 1 /* $Id: treeview.c,v 1.2 6 2000-02-16 17:22:19cbratschi Exp $ */1 /* $Id: treeview.c,v 1.27 2000-02-17 17:26:51 cbratschi Exp $ */ 2 2 /* Treeview control 3 3 * … … 22 22 * 23 23 * Status: in progress 24 * Version: 5. 0024 * Version: 5.80 25 25 */ 26 26 … … 33 33 /* CB: todo 34 34 35 - bug in SetScrollInfo/ShowScrollBar: WM_SIZE and WM_NCPAINT problems 35 - bug in SetScrollInfo/ShowScrollBar: WM_SIZE and WM_NCPAINT problems (i.e. RegEdit) 36 - WM_HSCROLL: some rects are wrong 37 - TVS_FULLROWSELECT 38 - TVS_SINGLEEXPAND 39 - TVS_TRACKSELECT (called hottrack) 40 - TVS_INFOTIP, TVS_NOTOOLTIPS and tooltip support 41 - WM_ENABLE: draw disabled control 36 42 */ 37 43 … … 447 453 { 448 454 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 449 INT cx,cy,prevHeight=infoPtr->uItemHeight; 450 451 // TRACE (treeview,"\n"); 452 if (wParam==-1) { 453 infoPtr->uItemHeight=-1; 454 return prevHeight; 455 INT cx,cy,prevHeight = infoPtr->uItemHeight; 456 457 if (wParam==-1) 458 { 459 infoPtr->uItemHeight = -1; 460 461 return prevHeight; 455 462 } 456 463 457 464 ImageList_GetIconSize (infoPtr->himlNormal, &cx, &cy); 458 465 459 if (wParam>cy) cy=wParam; 460 infoPtr->uItemHeight=cy; 461 462 if (!( GetWindowLongA( hwnd, GWL_STYLE) & TVS_NONEVENHEIGHT)) 463 infoPtr->uItemHeight = (INT) wParam & 0xfffffffe; 466 if (wParam > cy) cy = wParam; 467 infoPtr->uItemHeight = cy; 468 469 if (!(GetWindowLongA(hwnd, GWL_STYLE) & TVS_NONEVENHEIGHT)) 470 if (infoPtr->uItemHeight & 0x1) infoPtr->uItemHeight += 1; 471 464 472 return prevHeight; 465 473 } … … 470 478 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 471 479 472 // TRACE (treeview,"\n");473 480 return infoPtr->uItemHeight; 474 481 } … … 606 613 //pen must be selected! 607 614 608 static void TREEVIEW_DrawVLines(HDC hdc,TREEVIEW_INFO *infoPtr,TREEVIEW_ITEM * wineItem)615 static void TREEVIEW_DrawVLines(HDC hdc,TREEVIEW_INFO *infoPtr,TREEVIEW_ITEM *item) 609 616 { 610 617 POINT points[2]; 611 618 INT center; 612 619 613 center = ( wineItem->rect.top+wineItem->rect.bottom)/2;620 center = (item->rect.top+item->rect.bottom)/2; 614 621 //INT cChildren = TREEVIEW_HasChildren(hwnd,wineItem); 615 if (( wineItem->iLevel == 0) && !wineItem->upsibling && wineItem->sibling)616 { 617 TREEVIEW_ITEM *lastItem = &infoPtr->items[(INT) wineItem->sibling];622 if ((item->iLevel == 0) && !item->upsibling && item->sibling) 623 { 624 TREEVIEW_ITEM *lastItem = &infoPtr->items[(INT)item->sibling]; 618 625 619 626 while (lastItem->sibling) lastItem = &infoPtr->items[(INT)lastItem->sibling]; … … 629 636 } 630 637 631 if ( wineItem->firstChild && (wineItem->state & TVIS_EXPANDED))632 { 633 TREEVIEW_ITEM *lastItem = &infoPtr->items[(INT) wineItem->firstChild];638 if (item->firstChild && (item->state & TVIS_EXPANDED)) 639 { 640 TREEVIEW_ITEM *lastItem = &infoPtr->items[(INT)item->firstChild]; 634 641 635 642 while (lastItem->sibling) lastItem = &infoPtr->items[(INT)lastItem->sibling]; 636 643 637 644 points[0].y = (lastItem->upsibling != NULL) ? 638 wineItem->rect.bottom-3: /* is linked to an icon */639 wineItem->rect.bottom+1; /* is linked to a +/- box */640 points[1].x = points[0].x = 28+20* wineItem->iLevel-infoPtr->cx;645 item->rect.bottom-3: /* is linked to an icon */ 646 item->rect.bottom+1; /* is linked to a +/- box */ 647 points[1].x = points[0].x = 28+20*item->iLevel-infoPtr->cx; 641 648 points[1].y = (lastItem->rect.top+lastItem->rect.bottom)/2; /* is linked to a +/- box */ 642 649 #ifdef OS2LINEHACK … … 649 656 650 657 static void 651 TREEVIEW_DrawItem(HWND hwnd,HDC hdc,TREEVIEW_ITEM * wineItem,DWORD dwStyle,TREEVIEW_INFO *infoPtr)652 { 653 INT center, xpos,cx,cy,cditem;658 TREEVIEW_DrawItem(HWND hwnd,HDC hdc,TREEVIEW_ITEM *item,DWORD dwStyle,TREEVIEW_INFO *infoPtr) 659 { 660 INT center,cditem; 654 661 HFONT hOldFont; 655 UINT uTextJustify = DT_LEFT; 656 RECT r; 657 658 if (!wineItem->calculated) TREEVIEW_CalcItem(hwnd,hdc,dwStyle,infoPtr,wineItem); 659 660 if (wineItem->state & TVIS_BOLD) 661 hOldFont = SelectObject (hdc, infoPtr->hBoldFont); 662 663 if (!item->calculated) TREEVIEW_CalcItem(hwnd,hdc,dwStyle,infoPtr,item); 664 665 if (item->state & TVIS_BOLD) 666 hOldFont = SelectObject(hdc,infoPtr->hBoldFont); 662 667 else 663 hOldFont = SelectObject (hdc,infoPtr->hFont);668 hOldFont = SelectObject(hdc,infoPtr->hFont); 664 669 665 670 cditem = 0; … … 667 672 if (infoPtr->cdmode & CDRF_NOTIFYITEMDRAW) 668 673 { 669 cditem = TREEVIEW_SendCustomDrawItemNotify(hwnd, hdc, wineItem, CDDS_ITEMPREPAINT);674 cditem = TREEVIEW_SendCustomDrawItemNotify(hwnd, hdc, item, CDDS_ITEMPREPAINT); 670 675 671 676 if (cditem & CDRF_SKIPDEFAULT) return; … … 677 682 * Set drawing starting points 678 683 */ 679 r = wineItem->rect; /* this item rectangle */ 680 center = (r.top+r.bottom)/2; /* this item vertical center */ 681 xpos = r.left + TREEVIEW_LEFT_MARGIN;/* horizontal starting point */ 684 center = (item->rect.top+item->rect.bottom)/2; /* this item vertical center */ 682 685 683 686 /* … … 704 707 hOldPen = SelectObject(hdc,hnewPen); 705 708 706 TREEVIEW_DrawVLines(hdc,infoPtr, wineItem);709 TREEVIEW_DrawVLines(hdc,infoPtr,item); 707 710 708 711 /* … … 710 713 * to the up sibling or to the parent node. 711 714 */ 712 if ( wineItem->upsibling)713 upNode = TREEVIEW_ValidItem (infoPtr, wineItem->upsibling);714 else if ( wineItem->parent)715 upNode = TREEVIEW_ValidItem (infoPtr, wineItem->parent);715 if (item->upsibling) 716 upNode = TREEVIEW_ValidItem (infoPtr, item->upsibling); 717 else if (item->parent) 718 upNode = TREEVIEW_ValidItem (infoPtr, item->parent); 716 719 717 720 if (upNode) upRect = upNode->rect; 718 721 719 if ( wineItem->iLevel == 0)722 if (item->iLevel == 0) 720 723 { 721 724 points[1].x = upRect.left+8; … … 724 727 } else 725 728 { 726 points[1].x = 8+(20* wineItem->iLevel)-infoPtr->cx;729 points[1].x = 8+(20*item->iLevel)-infoPtr->cx; 727 730 points[1].y = points[0].y = center; 728 731 points[0].x = points[1].x + 10; … … 745 748 * Display the (+/-) signs 746 749 */ 747 if (wineItem->iLevel != 0)/* update position only for non root node */748 xpos += 5*wineItem->iLevel;749 750 750 if ((dwStyle & TVS_HASBUTTONS) && (dwStyle & TVS_HASLINES)) 751 751 { 752 if (TREEVIEW_HasChildren(hwnd, wineItem)) 753 { 754 Rectangle(hdc,wineItem->expandBox.left,wineItem->expandBox.top,wineItem->expandBox.right,wineItem->expandBox.bottom); 755 756 MoveToEx (hdc, xpos-2, center, NULL); 757 LineTo (hdc, xpos+3, center); 758 759 if (!(wineItem->state & TVIS_EXPANDED)) 760 { 761 MoveToEx (hdc, xpos, center-2, NULL); 762 LineTo (hdc, xpos, center+3); 752 if (TREEVIEW_HasChildren(hwnd,item)) 753 { 754 INT vCenter = (item->expandBox.top+item->expandBox.bottom)/2; 755 INT hCenter = (item->expandBox.right+item->expandBox.left)/2; 756 757 Rectangle(hdc,item->expandBox.left,item->expandBox.top,item->expandBox.right,item->expandBox.bottom); 758 759 MoveToEx(hdc,item->expandBox.left+2,vCenter,NULL); 760 LineTo(hdc,item->expandBox.right-2,vCenter); 761 762 if (!(item->state & TVIS_EXPANDED)) 763 { 764 MoveToEx(hdc,hCenter,item->expandBox.top+2,NULL); 765 LineTo(hdc,hCenter,item->expandBox.bottom-2); 763 766 } 764 767 } … … 768 771 * Display the image associated with this item 769 772 */ 770 xpos += 13; /* update position */ 771 if (wineItem->mask & (TVIF_IMAGE|TVIF_SELECTEDIMAGE)) 773 if ((item->mask & (TVIF_IMAGE | TVIF_SELECTEDIMAGE)) || (dwStyle & TVS_CHECKBOXES)) 772 774 { 773 775 INT imageIndex; … … 779 781 */ 780 782 if (infoPtr->himlState) 781 himlp =&infoPtr->himlState;782 imageIndex =wineItem->state >> 12;783 784 if ( (himlp) && (imageIndex))783 himlp =& infoPtr->himlState; 784 imageIndex = item->state >> 12; 785 786 if (himlp && imageIndex) 785 787 { 786 788 imageIndex--; /* see FIXME */ 787 ImageList_Draw ( *himlp, imageIndex, hdc, xpos-2, r.top+1, ILD_NORMAL); 788 xpos += wineItem->statebitmap.right-wineItem->statebitmap.left; 789 ImageList_Draw(*himlp,imageIndex,hdc,item->statebitmap.left,item->statebitmap.top,ILD_NORMAL); 789 790 } 790 791 … … 793 794 */ 794 795 795 himlp =NULL;796 himlp = NULL; 796 797 if (infoPtr->himlNormal) 797 himlp=&infoPtr->himlNormal; /* get the image list */ 798 799 imageIndex = wineItem->iImage; 800 if ( (wineItem->state & TVIS_SELECTED) && 801 (wineItem->iSelectedImage)) 802 { 803 798 himlp = &infoPtr->himlNormal; /* get the image list */ 799 800 imageIndex = item->iImage; 801 if ((item->state & TVIS_SELECTED) && item->iSelectedImage) 802 { 804 803 /* The item is curently selected */ 805 if ( wineItem->iSelectedImage == I_IMAGECALLBACK)806 TREEVIEW_SendDispInfoNotify(hwnd, wineItem, TVN_GETDISPINFO, TVIF_SELECTEDIMAGE);807 808 imageIndex = wineItem->iSelectedImage;804 if (item->iSelectedImage == I_IMAGECALLBACK) 805 TREEVIEW_SendDispInfoNotify(hwnd, item, TVN_GETDISPINFO, TVIF_SELECTEDIMAGE); 806 807 imageIndex = item->iSelectedImage; 809 808 } else 810 809 { 811 810 /* The item is not selected */ 812 if ( wineItem->iImage == I_IMAGECALLBACK)813 TREEVIEW_SendDispInfoNotify(hwnd, wineItem, TVN_GETDISPINFO, TVIF_IMAGE);814 815 imageIndex = wineItem->iImage;811 if (item->iImage == I_IMAGECALLBACK) 812 TREEVIEW_SendDispInfoNotify(hwnd, item, TVN_GETDISPINFO, TVIF_IMAGE); 813 814 imageIndex = item->iImage; 816 815 } 817 816 … … 820 819 int ovlIdx = 0; 821 820 822 if(wineItem->stateMask & TVIS_OVERLAYMASK) 823 ovlIdx = wineItem->state & TVIS_OVERLAYMASK; 824 825 ImageList_Draw ( *himlp, imageIndex, hdc, xpos-2, r.top+1, ILD_NORMAL|ovlIdx); 826 xpos += wineItem->bitmap.right-wineItem->bitmap.left; 821 if(item->stateMask & TVIS_OVERLAYMASK) 822 ovlIdx = item->state & TVIS_OVERLAYMASK; 823 824 ImageList_Draw(*himlp,imageIndex,hdc,item->bitmap.left,item->bitmap.top,ILD_NORMAL | ovlIdx); 827 825 } 828 826 } … … 832 830 */ 833 831 /* Don't paint item's text if it's being edited */ 834 if (!infoPtr->hwndEdit || (infoPtr->editItem != wineItem->hItem))835 { 836 r.left=xpos;837 if ((wineItem->mask & TVIF_TEXT) && (wineItem->pszText))838 {832 if (!infoPtr->hwndEdit || (infoPtr->editItem != item->hItem)) 833 { 834 if ((item->mask & TVIF_TEXT) && (item->pszText)) 835 { 836 UINT uTextJustify = DT_LEFT; 839 837 COLORREF oldTextColor = 0; 840 838 INT oldBkMode; … … 842 840 BOOL inFocus = GetFocus() == hwnd; 843 841 844 r.left += 3;845 r.right -= 3;846 842 oldBkMode = SetBkMode(hdc, TRANSPARENT); 847 843 … … 852 848 * - Otherwise - don't fill background 853 849 */ 854 if ((wineItem->state & TVIS_DROPHILITED) || 855 ((wineItem->state & TVIS_SELECTED) && 856 (inFocus || (GetWindowLongA( hwnd, GWL_STYLE) & TVS_SHOWSELALWAYS)))) 857 { 858 if ((wineItem->state & TVIS_DROPHILITED) || inFocus) 859 { 860 hbrBk = CreateSolidBrush(GetSysColor( COLOR_HIGHLIGHT)); 861 oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_HIGHLIGHTTEXT)); 862 } 863 else 864 { 865 hbrBk = CreateSolidBrush(GetSysColor( COLOR_BTNFACE)); 866 867 if (infoPtr->clrText == -1) 868 oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_WINDOWTEXT)); 869 else 870 oldTextColor = SetTextColor(hdc, infoPtr->clrText); 871 } 850 if ((item->state & TVIS_DROPHILITED) || 851 ((item->state & TVIS_SELECTED) && 852 (inFocus || (GetWindowLongA( hwnd, GWL_STYLE) & TVS_SHOWSELALWAYS)))) 853 { 854 if ((item->state & TVIS_DROPHILITED) || inFocus) 855 { 856 hbrBk = CreateSolidBrush(GetSysColor( COLOR_HIGHLIGHT)); 857 oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_HIGHLIGHTTEXT)); 858 } else 859 { 860 hbrBk = CreateSolidBrush(GetSysColor( COLOR_BTNFACE)); 861 862 if (infoPtr->clrText == -1) 863 oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_WINDOWTEXT)); 864 else 865 oldTextColor = SetTextColor(hdc, infoPtr->clrText); 866 } 867 } else 868 { 869 if (infoPtr->clrText == -1) 870 oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_WINDOWTEXT)); 871 else 872 oldTextColor = SetTextColor(hdc, infoPtr->clrText); 872 873 } 873 else 874 { 875 if (infoPtr->clrText == -1) 876 oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_WINDOWTEXT)); 877 else 878 oldTextColor = SetTextColor(hdc, infoPtr->clrText); 874 875 if (item->pszText == LPSTR_TEXTCALLBACKW) 876 TREEVIEW_SendDispInfoNotify (hwnd, item, TVN_GETDISPINFO, TVIF_TEXT); 877 878 if (hbrBk) 879 { 880 FillRect(hdc, &item->text, hbrBk); 881 DeleteObject(hbrBk); 879 882 } 880 883 881 if (wineItem->pszText == LPSTR_TEXTCALLBACKW) 882 TREEVIEW_SendDispInfoNotify (hwnd, wineItem, TVN_GETDISPINFO, TVIF_TEXT); 883 884 if (hbrBk) 885 { 886 FillRect(hdc, &wineItem->text, hbrBk); 887 DeleteObject(hbrBk); 888 } 889 890 wineItem->text.left += 2; 884 item->text.left += 2; 891 885 892 886 /* Draw it */ 893 887 DrawTextW ( hdc, 894 wineItem->pszText,895 lstrlenW( wineItem->pszText),896 & wineItem->text,888 item->pszText, 889 lstrlenW(item->pszText), 890 &item->text, 897 891 uTextJustify | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX); 898 892 899 wineItem->text.left -= 2;893 item->text.left -= 2; 900 894 901 895 /* Restore the hdc state */ … … 903 897 904 898 /* Draw the box arround the selected item */ 905 if ( wineItem->state & TVIS_SELECTED)899 if (item->state & TVIS_SELECTED) 906 900 { 907 901 HPEN hNewPen = CreatePen(PS_DOT, 0, GetSysColor(COLOR_WINDOWTEXT) ); … … 910 904 POINT points[5]; 911 905 912 points[4].x = points[0].x = wineItem->text.left;913 points[4].y = points[0].y = wineItem->text.top;914 points[1].x = wineItem->text.right-1 ;915 points[1].y = wineItem->text.top;916 points[2].x = wineItem->text.right-1;917 points[2].y = wineItem->text.bottom-1;918 points[3].x = wineItem->text.left;919 points[3].y = wineItem->text.bottom-1;906 points[4].x = points[0].x = item->text.left; 907 points[4].y = points[0].y = item->text.top; 908 points[1].x = item->text.right-1 ; 909 points[1].y = item->text.top; 910 points[2].x = item->text.right-1; 911 points[2].y = item->text.bottom-1; 912 points[3].x = item->text.left; 913 points[3].y = item->text.bottom-1; 920 914 921 915 Polyline (hdc,points,5); … … 927 921 928 922 if (oldBkMode != TRANSPARENT) 929 923 SetBkMode(hdc, oldBkMode); 930 924 } 931 925 } … … 936 930 // TRACE ("item:%d,mark:%d\n", (int)wineItem->hItem, 937 931 // (int) infoPtr->insertMarkItem); 938 if ( wineItem->hItem==infoPtr->insertMarkItem)932 if (item->hItem == infoPtr->insertMarkItem) 939 933 { 940 934 HPEN hNewPen, hOldPen; … … 945 939 946 940 if (infoPtr->insertBeforeorAfter) 947 offset =wineItem->text.top+1;941 offset = item->text.top+1; 948 942 else 949 offset =wineItem->text.bottom-1;950 951 MoveToEx (hdc, wineItem->text.left, offset-3, NULL);952 LineTo (hdc, wineItem->text.left, offset+3);953 954 MoveToEx (hdc, wineItem->text.left, offset,NULL);955 LineTo (hdc, r.right-2,offset);956 957 MoveToEx (hdc, r.right-2, offset+3, NULL);958 LineTo (hdc, r.right-2, offset-3);943 offset = item->text.bottom-1; 944 945 MoveToEx(hdc,item->text.left, offset-3, NULL); 946 LineTo(hdc,item->text.left, offset+3); 947 948 MoveToEx(hdc,item->text.left,offset,NULL); 949 LineTo(hdc,item->text.right-2,offset); 950 951 MoveToEx(hdc,item->text.right-2, offset+3, NULL); 952 LineTo(hdc,item->text.right-2, offset-3); 959 953 960 954 DeleteObject(hNewPen); … … 964 958 965 959 if (cditem & CDRF_NOTIFYPOSTPAINT) 966 { 967 cditem = TREEVIEW_SendCustomDrawItemNotify(hwnd, hdc, wineItem, CDDS_ITEMPOSTPAINT); 968 //TRACE("postpaint:cditem-app returns 0x%x\n",cditem); 969 } 960 cditem = TREEVIEW_SendCustomDrawItemNotify(hwnd, hdc, item, CDDS_ITEMPOSTPAINT); 970 961 971 962 SelectObject (hdc, hOldFont); … … 1154 1145 } else 1155 1146 { 1156 rect.left += TREEVIEW_LEFT_MARGIN; 1157 if (item->iLevel != 0) rect.left += (5*item->iLevel); 1158 rect.left += 15; 1147 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 1148 1149 //redraw text and image 1150 if (((item->mask & (TVIF_IMAGE | TVIF_SELECTEDIMAGE)) || (dwStyle & TVS_CHECKBOXES)) && (item->iSelectedImage != item->iImage)) 1151 { 1152 rect.left += TREEVIEW_LEFT_MARGIN; 1153 if (item->iLevel != 0) rect.left += (5*item->iLevel); 1154 rect.left += 15; 1155 } else rect = item->text; 1159 1156 } 1160 1157 … … 1194 1191 xpos += 13; /* update position */ 1195 1192 1196 if ( item->mask & (TVIF_IMAGE | TVIF_SELECTEDIMAGE))1193 if ((item->mask & (TVIF_IMAGE | TVIF_SELECTEDIMAGE)) || (dwStyle & TVS_CHECKBOXES)) 1197 1194 { 1198 1195 INT imageIndex,cx,cy; … … 1272 1269 item->text.bottom= r.bottom; 1273 1270 1274 if (item->pszText== LPSTR_TEXTCALLBACKW) 1275 { 1276 //TRACE("LPSTR_TEXTCALLBACK\n"); 1271 if (item->pszText == LPSTR_TEXTCALLBACKW) 1277 1272 TREEVIEW_SendDispInfoNotify (hwnd, item, TVN_GETDISPINFO, TVIF_TEXT); 1278 }1279 1273 1280 1274 if (!hdc) … … 1341 1335 GetTextMetricsA (hdc, &tm); 1342 1336 itemHeight = MAX(tm.tmHeight+tm.tmExternalLeading,itemHeight); 1337 if (!(dwStyle & TVS_NONEVENHEIGHT)) 1338 if (itemHeight & 0x1) itemHeight += 1; //important for PS_DOT pen! 1343 1339 infoPtr->uRealItemHeight = itemHeight; 1344 1340 infoPtr->uTotalWidth = 0; … … 1362 1358 item->rect.bottom = item->rect.top+height; 1363 1359 item->rect.left = x-infoPtr->cx; 1364 item->rect.right = rect.right; 1360 item->rect.right = rect.right; //dummy 1365 1361 TREEVIEW_CalcItem(hwnd,hdc,dwStyle,infoPtr,item); 1366 1362 } else … … 1530 1526 1531 1527 if (infoPtr->cdmode == CDRF_SKIPDEFAULT) return; 1532 1533 /* draw background */1534 1535 hbrBk = CreateSolidBrush (infoPtr->clrBk);1536 FillRect(hdc, &rect, hbrBk);1537 DeleteObject(hbrBk);1538 1528 1539 1529 //draw items … … 2481 2471 static LRESULT 2482 2472 TREEVIEW_GetToolTips (HWND hwnd) 2483 2484 { 2485 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 2486 2487 return infoPtr->hwndToolTip; 2473 { 2474 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 2475 2476 return infoPtr->hwndToolTip; 2488 2477 } 2489 2478 … … 2491 2480 static LRESULT 2492 2481 TREEVIEW_SetToolTips (HWND hwnd, WPARAM wParam) 2493 2494 { 2495 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 2496 HWND prevToolTip; 2497 2498 prevToolTip=infoPtr->hwndToolTip; 2499 infoPtr->hwndToolTip= (HWND) wParam; 2500 2501 return prevToolTip; 2482 { 2483 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 2484 HWND prevToolTip; 2485 2486 prevToolTip = infoPtr->hwndToolTip; 2487 infoPtr->hwndToolTip = (HWND)wParam; 2488 2489 return prevToolTip; 2502 2490 } 2503 2491 … … 2647 2635 { 2648 2636 if (TREEVIEW_CalcItems(hwnd,0,infoPtr)) 2649 TREEVIEW_Refresh(hwnd); 2650 } 2651 2652 return 0; 2653 } 2654 2637 TREEVIEW_Refresh(hwnd); //because size redraw isn't set 2638 } 2639 2640 return TRUE; 2641 } 2655 2642 2656 2643 static LRESULT … … 2658 2645 { 2659 2646 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 2647 2648 if (infoPtr->hwndEdit) SetFocus(hwnd); 2660 2649 2661 2650 //CB: todo: check styles … … 2666 2655 } 2667 2656 2657 static LRESULT 2658 TREEVIEW_SysColorChange(HWND hwnd,WPARAM wParam,LPARAM lParam) 2659 { 2660 TREEVIEW_Refresh(hwnd); 2661 2662 return DefWindowProcA(hwnd,WM_SYSCOLORCHANGE,wParam,lParam); 2663 } 2668 2664 2669 2665 static LRESULT 2670 2666 TREEVIEW_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) 2671 2667 { 2672 TREEVIEW_INFO *infoPtr; 2673 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 2674 LOGFONTA logFont; 2675 TEXTMETRICA tm; 2676 HDC hdc; 2677 2678 //TRACE("wnd %x, style %lx\n",hwnd,dwStyle); 2679 /* allocate memory for info structure */ 2680 infoPtr = (TREEVIEW_INFO *) COMCTL32_Alloc (sizeof(TREEVIEW_INFO)); 2681 2682 SetWindowLongA( hwnd, 0, (DWORD)infoPtr); 2683 2684 if (infoPtr == NULL) { 2685 //ERR("could not allocate info memory!\n"); 2686 return 0; 2668 TREEVIEW_INFO *infoPtr; 2669 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 2670 LOGFONTA logFont; 2671 TEXTMETRICA tm; 2672 HDC hdc; 2673 2674 /* allocate memory for info structure */ 2675 infoPtr = (TREEVIEW_INFO *) COMCTL32_Alloc (sizeof(TREEVIEW_INFO)); 2676 2677 SetWindowLongA( hwnd, 0, (DWORD)infoPtr); 2678 2679 if (infoPtr == NULL) return 0; 2680 2681 if ((TREEVIEW_INFO*)GetWindowLongA(hwnd,0) != infoPtr) return 0; 2682 2683 hdc = GetDC(hwnd); 2684 2685 /* set default settings */ 2686 infoPtr->uInternalStatus = 0; 2687 if (IsWindowUnicode(hwnd)) infoPtr->uInternalStatus |= TV_UNICODE; 2688 infoPtr->uNumItems=0; 2689 infoPtr->clrBk = GetSysColor (COLOR_WINDOW); 2690 infoPtr->clrLine = GetSysColor (COLOR_WINDOWTEXT); 2691 infoPtr->clrInsertMark = GetSysColor (COLOR_BTNTEXT); 2692 infoPtr->cy = 0; 2693 infoPtr->cx = 0; 2694 infoPtr->uIndent = 15; 2695 infoPtr->himlNormal = NULL; 2696 infoPtr->himlState = NULL; 2697 infoPtr->uItemHeight = -1; 2698 GetTextMetricsA (hdc, &tm); 2699 infoPtr->hFont = GetStockObject (DEFAULT_GUI_FONT); 2700 GetObjectA (infoPtr->hFont, sizeof (LOGFONTA), &logFont); 2701 logFont.lfWeight=FW_BOLD; 2702 infoPtr->hBoldFont = CreateFontIndirectA (&logFont); 2703 2704 infoPtr->items = NULL; 2705 infoPtr->selectedItem = 0; 2706 infoPtr->clrText=-1; /* use system color */ 2707 infoPtr->dropItem=0; 2708 infoPtr->insertMarkItem=0; 2709 infoPtr->insertBeforeorAfter=0; 2710 infoPtr->pCallBackSort=NULL; 2711 infoPtr->uScrollTime = 300; /* milliseconds */ 2712 infoPtr->hwndEdit = 0; 2713 2714 infoPtr->hwndToolTip=0; 2715 if (!(dwStyle & TVS_NOTOOLTIPS)) 2716 { 2717 /* Create tooltip control */ 2718 TTTOOLINFOA ti; 2719 2720 infoPtr->hwndToolTip = 2721 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0, 2722 CW_USEDEFAULT, CW_USEDEFAULT, 2723 CW_USEDEFAULT, CW_USEDEFAULT, 2724 hwnd, 0, 0, 0); 2725 2726 /* Send NM_TOOLTIPSCREATED notification */ 2727 if (infoPtr->hwndToolTip) 2728 { 2729 NMTOOLTIPSCREATED nmttc; 2730 2731 nmttc.hdr.hwndFrom = hwnd; 2732 nmttc.hdr.idFrom = GetWindowLongA( hwnd, GWL_ID); 2733 nmttc.hdr.code = NM_TOOLTIPSCREATED; 2734 nmttc.hwndToolTips = infoPtr->hwndToolTip; 2735 2736 SendMessageA (GetParent(hwnd),WM_NOTIFY,(WPARAM)GetWindowLongA(hwnd,GWL_ID),(LPARAM)&nmttc); 2687 2737 } 2688 2738 2689 if ((TREEVIEW_INFO*) GetWindowLongA( hwnd, 0) != infoPtr) { 2690 //ERR("pointer assignment error!\n"); 2691 return 0; 2692 } 2693 2694 hdc=GetDC (hwnd); 2695 2696 /* set default settings */ 2697 infoPtr->uInternalStatus = 0; 2698 infoPtr->uNumItems=0; 2699 infoPtr->clrBk = GetSysColor (COLOR_WINDOW); 2700 infoPtr->clrLine = GetSysColor (COLOR_WINDOWTEXT); 2701 infoPtr->clrInsertMark = GetSysColor (COLOR_BTNTEXT); 2702 infoPtr->cy = 0; 2703 infoPtr->cx = 0; 2704 infoPtr->uIndent = 15; 2705 infoPtr->himlNormal = NULL; 2706 infoPtr->himlState = NULL; 2707 infoPtr->uItemHeight = -1; 2708 GetTextMetricsA (hdc, &tm); 2709 infoPtr->hFont = GetStockObject (DEFAULT_GUI_FONT); 2710 GetObjectA (infoPtr->hFont, sizeof (LOGFONTA), &logFont); 2711 logFont.lfWeight=FW_BOLD; 2712 infoPtr->hBoldFont = CreateFontIndirectA (&logFont); 2713 2714 infoPtr->items = NULL; 2715 infoPtr->selectedItem = 0; 2716 infoPtr->clrText=-1; /* use system color */ 2717 infoPtr->dropItem=0; 2718 infoPtr->insertMarkItem=0; 2719 infoPtr->insertBeforeorAfter=0; 2720 infoPtr->pCallBackSort=NULL; 2721 infoPtr->uScrollTime = 300; /* milliseconds */ 2722 infoPtr->hwndEdit = 0; 2723 2724 /* 2725 infoPtr->hwndNotify = GetParent32 (hwnd); 2726 infoPtr->bTransparent = ( GetWindowLongA( hwnd, GWL_STYLE) & TBSTYLE_FLAT); 2727 */ 2728 2729 infoPtr->hwndToolTip=0; 2730 if (!(dwStyle & TVS_NOTOOLTIPS)) { /* Create tooltip control */ 2731 TTTOOLINFOA ti; 2732 2733 infoPtr->hwndToolTip = 2734 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0, 2735 CW_USEDEFAULT, CW_USEDEFAULT, 2736 CW_USEDEFAULT, CW_USEDEFAULT, 2737 hwnd, 0, 0, 0); 2738 2739 /* Send NM_TOOLTIPSCREATED notification */ 2740 if (infoPtr->hwndToolTip) { 2741 NMTOOLTIPSCREATED nmttc; 2742 2743 nmttc.hdr.hwndFrom = hwnd; 2744 nmttc.hdr.idFrom = GetWindowLongA( hwnd, GWL_ID); 2745 nmttc.hdr.code = NM_TOOLTIPSCREATED; 2746 nmttc.hwndToolTips = infoPtr->hwndToolTip; 2747 2748 SendMessageA (GetParent (hwnd), WM_NOTIFY, 2749 (WPARAM) GetWindowLongA( hwnd, GWL_ID), (LPARAM)&nmttc); 2750 } 2751 2752 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 2753 ti.cbSize = sizeof(TTTOOLINFOA); 2754 ti.uFlags = TTF_IDISHWND | TTF_TRACK | TTF_TRANSPARENT ; 2755 ti.hwnd = hwnd; 2756 ti.uId = 0; 2757 ti.lpszText = "Test"; /* LPSTR_TEXTCALLBACK; */ 2758 SetRectEmpty (&ti.rect); 2759 2760 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA, 0, (LPARAM)&ti); 2761 } 2762 2763 if (dwStyle & TVS_CHECKBOXES) { 2764 HBITMAP hbmLoad; 2765 int nIndex; 2766 2767 infoPtr->himlState = 2768 ImageList_Create (16, 16,ILC_COLOR|ILC_MASK, 15, 1); 2769 2770 hbmLoad = LoadBitmapA (COMCTL32_hModule, MAKEINTRESOURCEA(IDT_CHECK)); 2771 //TRACE ("%x\n",hbmLoad); 2772 nIndex = ImageList_AddMasked (infoPtr->himlState, hbmLoad, CLR_DEFAULT); 2773 //TRACE ("%d\n",nIndex); 2774 DeleteObject (hbmLoad); 2775 } 2739 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 2740 ti.cbSize = sizeof(TTTOOLINFOA); 2741 ti.uFlags = TTF_IDISHWND | TTF_TRACK | TTF_TRANSPARENT; 2742 ti.hwnd = hwnd; 2743 ti.uId = 0; 2744 ti.lpszText = "Test"; /* LPSTR_TEXTCALLBACK; */ 2745 SetRectEmpty (&ti.rect); 2746 2747 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA, 0, (LPARAM)&ti); 2748 } 2749 2750 if (dwStyle & TVS_CHECKBOXES) 2751 { 2752 HBITMAP hbmLoad; 2753 int nIndex; 2754 2755 infoPtr->himlState = ImageList_Create (16, 16,ILC_COLOR | ILC_MASK, 15, 1); 2756 2757 //CB: MSDN docu says: uses DrawFrameControl 2758 hbmLoad = LoadBitmapA (COMCTL32_hModule, MAKEINTRESOURCEA(IDT_CHECK)); 2759 nIndex = ImageList_AddMasked (infoPtr->himlState, hbmLoad, CLR_DEFAULT); 2760 DeleteObject (hbmLoad); 2761 } 2776 2762 ReleaseDC (hwnd, hdc); 2763 2777 2764 return 0; 2778 2765 } 2779 2780 2781 2766 2782 2767 static LRESULT … … 2846 2831 } 2847 2832 2833 static LRESULT TREEVIEW_Enable(HWND hwnd,WPARAM wParam,LPARAM lParam) 2834 { 2835 TREEVIEW_Refresh(hwnd); 2836 2837 return DefWindowProcA(hwnd,WM_ENABLE,wParam,lParam); 2838 } 2839 2848 2840 static LRESULT 2849 2841 TREEVIEW_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam) … … 2853 2845 RECT rect; 2854 2846 2855 // TRACE (treeview,"\n");2856 2847 GetClientRect (hwnd, &rect); 2857 2848 FillRect ((HDC)wParam, &rect, hBrush); 2858 2849 DeleteObject (hBrush); 2850 2859 2851 return TRUE; 2852 } 2853 2854 static LRESULT TREEVIEW_GetDlgCode(HWND hwnd,WPARAM wParam,LPARAM lParam) 2855 { 2856 return DLGC_WANTARROWS | DLGC_WANTCHARS; 2860 2857 } 2861 2858 … … 3175 3172 expand = (INT)lParam; 3176 3173 3177 wineItem = TREEVIEW_ValidItem (infoPtr, 3174 wineItem = TREEVIEW_ValidItem (infoPtr,(HTREEITEM)expand); 3178 3175 3179 3176 if (!wineItem) … … 3263 3260 } 3264 3261 break; 3262 3265 3263 default: 3266 3264 return FALSE; … … 3319 3317 } 3320 3318 3321 lpht->flags =0;3319 lpht->flags = 0; 3322 3320 3323 3321 if (x < wineItem->expandBox.left) { … … 3342 3340 } 3343 3341 3344 lpht->flags|=TVHT_ONITEMRIGHT; 3345 3342 lpht->flags |= TVHT_ONITEMRIGHT; 3346 3343 3347 3344 done: 3348 3345 lpht->hItem = wineItem->hItem; 3349 //TRACE ("(%ld,%ld):result %x\n",lpht->pt.x,lpht->pt.y,lpht->flags);3350 3346 3351 3347 return (LRESULT) wineItem->hItem; … … 3362 3358 TEXTMETRICA textMetric; 3363 3359 3364 //TRACE("%d %d\n",(INT)hwnd, (INT)hItem);3365 3360 if (!editItem) 3366 3361 return FALSE; … … 3369 3364 return infoPtr->hwndEdit; 3370 3365 3371 3366 /* Make shure that edit item is selected */ 3372 3367 3373 3368 TREEVIEW_DoSelectItem ( hwnd, TVGN_CARET, hItem, TVC_UNKNOWN); 3374 3369 3375 3370 if (editItem->pszText == LPSTR_TEXTCALLBACKW) 3376 3371 TREEVIEW_SendDispInfoNotify (hwnd, editItem, TVN_GETDISPINFO, TVIF_TEXT); 3377 3372 3378 3373 hdc = GetDC(hwnd); 3379 3374 /* Select the font to get appropriate metric dimensions */ 3380 3375 if(infoPtr->hFont != 0) 3381 3376 { … … 3599 3594 wineItem = &infoPtr->items [(INT)hitinfo.hItem]; 3600 3595 3601 if (TREEVIEW_SendSimpleNotify (hwnd, NM_DBLCLK)!=TRUE) { /* FIXME!*/ 3602 TREEVIEW_Expand (hwnd, (WPARAM) TVE_TOGGLE, (LPARAM) wineItem->hItem); 3603 } 3596 //MSDN documentation says: stop on non zero. but this isn't true in this case 3597 if (!TREEVIEW_SendSimpleNotify (hwnd, NM_DBLCLK)) 3598 TREEVIEW_Expand (hwnd, (WPARAM) TVE_TOGGLE, (LPARAM) wineItem->hItem); 3599 3604 3600 return TRUE; 3601 } 3602 3603 static LRESULT TREEVIEW_MouseMove(HWND hwnd,WPARAM wParam,LPARAM lParam) 3604 { 3605 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 3606 TVHITTESTINFO ht; 3607 TREEVIEW_ITEM *item; 3608 3609 ht.pt.x = (INT)LOWORD(lParam); 3610 ht.pt.y = (INT)HIWORD(lParam); 3611 3612 if (!TREEVIEW_HitTest(hwnd,&ht)) return 0; 3613 3614 if (ht.hItem) 3615 { 3616 item = &infoPtr->items[(INT)ht.hItem]; 3617 } 3618 3619 return 0; 3605 3620 } 3606 3621 … … 3612 3627 BOOL bTrack; 3613 3628 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 3614 3615 3629 3616 3630 /* If Edit control is active - kill it and return. … … 3629 3643 3630 3644 TREEVIEW_HitTest (hwnd,&ht); 3631 //TRACE("item %d \n", (INT)ht.hItem);3632 3645 3633 3646 bTrack = (ht.flags & TVHT_ONITEM) && !(dwStyle & TVS_DISABLEDRAGDROP); … … 3655 3668 if(TREEVIEW_SendSimpleNotify (hwnd, NM_CLICK)) 3656 3669 goto setfocus; 3670 3671 //CB: todo: check ht.flags for WM_HSCROLL! 3657 3672 3658 3673 /* … … 3679 3694 if (dwStyle & TVS_CHECKBOXES) /* TVS_CHECKBOXES requires _us_ */ 3680 3695 { /* to toggle the current state */ 3681 int state; 3682 TREEVIEW_ITEM *wineItem; 3683 3684 wineItem = TREEVIEW_ValidItem(infoPtr, ht.hItem); 3685 3686 state=1-(wineItem->state>>12); 3687 //TRACE ("state:%x\n", state); 3688 wineItem->state&= ~TVIS_STATEIMAGEMASK; 3689 wineItem->state|=state<<12; 3690 //TRACE ("state:%x\n", wineItem->state); 3691 //CB: todo: optimize 3692 TREEVIEW_QueueRefresh (hwnd); 3693 } 3696 int state; 3697 TREEVIEW_ITEM *wineItem; 3698 3699 wineItem = TREEVIEW_ValidItem(infoPtr, ht.hItem); 3700 3701 state = 1-(wineItem->state>>12); 3702 wineItem->state &= ~TVIS_STATEIMAGEMASK; 3703 wineItem->state |= state<<12; 3704 if (wineItem->visible) 3705 { 3706 TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE); 3707 InvalidateRect(hwnd,&wineItem->statebitmap,TRUE); 3708 } 3709 } 3694 3710 } 3695 3711 … … 3732 3748 3733 3749 return 0; 3750 } 3751 3752 static LRESULT TREEVIEW_RButtonDoubleClick(HWND hwnd,WPARAM wParam,LPARAM lParam) 3753 { 3754 TREEVIEW_SendSimpleNotify(hwnd,NM_RDBLCLK); 3755 3756 return DefWindowProcA(hwnd,WM_RBUTTONDBLCLK,wParam,lParam); 3734 3757 } 3735 3758 … … 3817 3840 while (parent && !(parent->state & TVIS_EXPANDED)) 3818 3841 { 3819 TREEVIEW_Expand(hwnd,TVE_EXPAND,(LPARAM)parent );3842 TREEVIEW_Expand(hwnd,TVE_EXPAND,(LPARAM)parent->hItem); 3820 3843 parent = TREEVIEW_ValidItem(infoPtr,parent->parent); 3821 3844 } … … 3896 3919 TREEVIEW_CalcItems(hwnd,0,infoPtr); 3897 3920 3898 ScrollWindowEx(hwnd,0,-scrollY,NULL,NULL,0,NULL,SW_INVALIDATE );3921 ScrollWindowEx(hwnd,0,-scrollY,NULL,NULL,0,NULL,SW_INVALIDATE | SW_SCROLLCHILDREN | (infoPtr->uScrollTime << 16)); 3899 3922 } 3900 3923 … … 3968 3991 int lastPos = infoPtr->cy; 3969 3992 3970 if (!infoPtr->uInternalStatus & TV_VSCROLL) return FALSE; 3971 3972 if(infoPtr->hwndEdit) 3973 SetFocus(hwnd); 3974 3975 switch (LOWORD (wParam)) { 3976 case SB_LINEUP: 3977 if (!infoPtr->cy) return FALSE; 3978 infoPtr->cy -= infoPtr->uRealItemHeight; 3979 if (infoPtr->cy < 0) infoPtr->cy=0; 3980 break; 3981 case SB_LINEDOWN: 3982 maxHeight=infoPtr->uTotalHeight-infoPtr->uVisibleHeight; 3983 if (infoPtr->cy == maxHeight) return FALSE; 3984 infoPtr->cy += infoPtr->uRealItemHeight; 3985 if (infoPtr->cy > maxHeight) 3986 infoPtr->cy = maxHeight; 3987 break; 3988 case SB_PAGEUP: 3989 if (!infoPtr->cy) return FALSE; 3990 infoPtr->cy -= infoPtr->uVisibleHeight; 3991 if (infoPtr->cy < 0) infoPtr->cy=0; 3992 break; 3993 case SB_PAGEDOWN: 3994 maxHeight=infoPtr->uTotalHeight-infoPtr->uVisibleHeight; 3995 if (infoPtr->cy == maxHeight) return FALSE; 3996 infoPtr->cy += infoPtr->uVisibleHeight; 3997 if (infoPtr->cy > maxHeight) 3998 infoPtr->cy = maxHeight; 3999 break; 4000 case SB_THUMBTRACK: 4001 infoPtr->cy = HIWORD (wParam); 4002 break; 4003 3993 if (!(infoPtr->uInternalStatus & TV_VSCROLL)) return FALSE; 3994 3995 switch (LOWORD (wParam)) 3996 { 3997 case SB_LINEUP: 3998 if (!infoPtr->cy) return FALSE; 3999 infoPtr->cy -= infoPtr->uRealItemHeight; 4000 if (infoPtr->cy < 0) infoPtr->cy = 0; 4001 break; 4002 4003 case SB_LINEDOWN: 4004 maxHeight = infoPtr->uTotalHeight-infoPtr->uVisibleHeight; 4005 if (maxHeight <= 0) return FALSE; 4006 if (infoPtr->cy == maxHeight) return FALSE; 4007 infoPtr->cy += infoPtr->uRealItemHeight; 4008 if (infoPtr->cy > maxHeight) 4009 infoPtr->cy = maxHeight; 4010 break; 4011 4012 case SB_PAGEUP: 4013 if (!infoPtr->cy) return FALSE; 4014 infoPtr->cy -= infoPtr->uVisibleHeight; 4015 if (infoPtr->cy < 0) infoPtr->cy = 0; 4016 break; 4017 4018 case SB_PAGEDOWN: 4019 maxHeight = infoPtr->uTotalHeight-infoPtr->uVisibleHeight; 4020 if (maxHeight <= 0) return FALSE; 4021 if (infoPtr->cy == maxHeight) return FALSE; 4022 infoPtr->cy += infoPtr->uVisibleHeight; 4023 if (infoPtr->cy > maxHeight) 4024 infoPtr->cy = maxHeight; 4025 break; 4026 4027 case SB_THUMBTRACK: 4028 maxHeight = infoPtr->uTotalHeight-infoPtr->uVisibleHeight; 4029 if (maxHeight <= 0) return FALSE; 4030 infoPtr->cy = HIWORD(wParam); 4031 if (infoPtr->cy < 0) infoPtr->cy = 0; 4032 if (infoPtr->cy > maxHeight) infoPtr->cy = maxHeight; 4033 break; 4034 4035 default: 4036 return FALSE; 4004 4037 } 4005 4038 … … 4008 4041 if (!TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE)) 4009 4042 TREEVIEW_CalcItems(hwnd,0,infoPtr); 4010 ScrollWindowEx(hwnd,0,lastPos-infoPtr->cy,NULL,NULL,0,NULL,SW_INVALIDATE); 4011 } 4012 4013 return TRUE; 4043 ScrollWindowEx(hwnd,0,lastPos-infoPtr->cy,NULL,NULL,0,NULL,SW_INVALIDATE | SW_SCROLLCHILDREN | (infoPtr->uScrollTime << 16)); 4044 4045 return TRUE; 4046 } 4047 4048 return FALSE; 4014 4049 } 4015 4050 … … 4021 4056 int lastPos = infoPtr->cx; 4022 4057 4023 //TRACE (treeview,"wp %lx, lp %x\n", lParam, wParam); 4024 4025 if (!infoPtr->uInternalStatus & TV_HSCROLL) return FALSE; 4026 4027 if(infoPtr->hwndEdit) 4028 SetFocus(hwnd); 4029 4030 switch (LOWORD (wParam)) { 4031 case SB_LINEUP: 4032 if (!infoPtr->cx) return FALSE; 4033 infoPtr->cx -= infoPtr->uRealItemHeight; 4034 if (infoPtr->cx < 0) infoPtr->cx=0; 4035 break; 4036 case SB_LINEDOWN: 4037 maxWidth=infoPtr->uTotalWidth-infoPtr->uVisibleWidth; 4038 if (infoPtr->cx == maxWidth) return FALSE; 4039 infoPtr->cx += infoPtr->uRealItemHeight; /*FIXME */ 4040 if (infoPtr->cx > maxWidth) 4041 infoPtr->cx = maxWidth; 4042 break; 4043 case SB_PAGEUP: 4044 if (!infoPtr->cx) return FALSE; 4045 infoPtr->cx -= infoPtr->uVisibleWidth; 4046 if (infoPtr->cx < 0) infoPtr->cx=0; 4047 break; 4048 case SB_PAGEDOWN: 4049 maxWidth=infoPtr->uTotalWidth-infoPtr->uVisibleWidth; 4050 if (infoPtr->cx == maxWidth) return FALSE; 4051 infoPtr->cx += infoPtr->uVisibleWidth; 4052 if (infoPtr->cx > maxWidth) 4053 infoPtr->cx = maxWidth; 4054 break; 4055 case SB_THUMBTRACK: 4056 infoPtr->cx = HIWORD (wParam); 4057 break; 4058 4058 if (!(infoPtr->uInternalStatus & TV_HSCROLL)) return FALSE; 4059 4060 switch (LOWORD (wParam)) 4061 { 4062 case SB_LINEUP: 4063 if (!infoPtr->cx) return FALSE; 4064 infoPtr->cx -= infoPtr->uRealItemHeight; 4065 if (infoPtr->cx < 0) infoPtr->cx = 0; 4066 break; 4067 4068 case SB_LINEDOWN: 4069 maxWidth = infoPtr->uTotalWidth-infoPtr->uVisibleWidth; 4070 if (maxWidth <= 0) return FALSE; 4071 if (infoPtr->cx == maxWidth) return FALSE; 4072 infoPtr->cx += infoPtr->uRealItemHeight; /*FIXME */ 4073 if (infoPtr->cx > maxWidth) 4074 infoPtr->cx = maxWidth; 4075 break; 4076 4077 case SB_PAGEUP: 4078 if (!infoPtr->cx) return FALSE; 4079 infoPtr->cx -= infoPtr->uVisibleWidth; 4080 if (infoPtr->cx < 0) infoPtr->cx = 0; 4081 break; 4082 4083 case SB_PAGEDOWN: 4084 maxWidth = infoPtr->uTotalWidth-infoPtr->uVisibleWidth; 4085 if (maxWidth <= 0) return FALSE; 4086 if (infoPtr->cx == maxWidth) return FALSE; 4087 infoPtr->cx += infoPtr->uVisibleWidth; 4088 if (infoPtr->cx > maxWidth) 4089 infoPtr->cx = maxWidth; 4090 break; 4091 4092 case SB_THUMBTRACK: 4093 maxWidth = infoPtr->uTotalWidth-infoPtr->uVisibleWidth; 4094 if (maxWidth <= 0) return FALSE; 4095 infoPtr->cx = HIWORD(wParam); 4096 if (infoPtr->cx < 0) infoPtr->cx = 0; 4097 if (infoPtr->cx > maxWidth) infoPtr->cx = maxWidth; 4098 break; 4099 4100 default: 4101 return FALSE; 4059 4102 } 4060 4103 … … 4063 4106 if (!TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE)) 4064 4107 TREEVIEW_CalcItems(hwnd,0,infoPtr); 4065 ScrollWindowEx(hwnd,lastPos-infoPtr->cx,0,NULL,NULL,0,NULL,SW_INVALIDATE); 4066 } 4067 4068 return TRUE; 4108 ScrollWindowEx(hwnd,lastPos-infoPtr->cx,0,NULL,NULL,0,NULL,SW_INVALIDATE | SW_SCROLLCHILDREN | (infoPtr->uScrollTime << 16)); 4109 4110 return TRUE; 4111 } 4112 4113 return FALSE; 4069 4114 } 4070 4115 … … 4112 4157 NULL; 4113 4158 TREEVIEW_ITEM *newItem = NULL; 4159 BOOL control; 4114 4160 4115 4161 TREEVIEW_SendKeyDownNotify(hwnd,TVN_KEYDOWN,wParam); 4162 4163 control = GetKeyState(VK_CONTROL) & 0x8000; 4164 4165 if (control) 4166 { 4167 DWORD scrollMsg = 0; 4168 BOOL horz = FALSE; 4169 4170 switch (wParam) 4171 { 4172 case VK_UP: 4173 //CB: todo: VK_UP doesn't work 4174 scrollMsg = SB_LINELEFT; 4175 break; 4176 4177 case VK_DOWN: 4178 scrollMsg = SB_LINERIGHT; 4179 break; 4180 4181 case VK_LEFT: 4182 scrollMsg = SB_LINELEFT; 4183 horz = TRUE; 4184 break; 4185 4186 case VK_RIGHT: 4187 scrollMsg = SB_LINERIGHT; 4188 horz = TRUE; 4189 break; 4190 4191 case VK_PRIOR: 4192 scrollMsg = SB_PAGELEFT; 4193 break; 4194 4195 case VK_NEXT: 4196 scrollMsg = SB_PAGERIGHT; 4197 break; 4198 } 4199 if (scrollMsg) 4200 { 4201 SendMessageA(hwnd,horz ? WM_HSCROLL:WM_VSCROLL,MAKELONG(scrollMsg,0),0); 4202 return TRUE; 4203 } 4204 } 4116 4205 4117 4206 if (prevSelect == 0) … … 4166 4255 4167 4256 break; 4257 4168 4258 case VK_RIGHT: 4169 4259 if (TREEVIEW_HasChildren(hwnd, prevItem)) … … 4217 4307 break; 4218 4308 4309 case VK_RETURN: 4310 TREEVIEW_SendSimpleNotify(hwnd,NM_RETURN); 4311 break; 4312 4219 4313 case VK_BACK: 4220 case VK_RETURN:4221 4314 4222 4315 default: … … 4243 4336 { 4244 4337 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 4338 4245 4339 return infoPtr->uScrollTime; 4246 4340 } … … 4274 4368 while (parent && !(parent->state & TVIS_EXPANDED)) 4275 4369 { 4276 TREEVIEW_Expand(hwnd,TVE_EXPAND,(LPARAM)parent );4370 TREEVIEW_Expand(hwnd,TVE_EXPAND,(LPARAM)parent->hItem); 4277 4371 parent = TREEVIEW_ValidItem(infoPtr,parent->parent); 4278 4372 } … … 4291 4385 infoPtr->cy += scrollY; 4292 4386 TREEVIEW_CalcItems(hwnd,0,infoPtr); 4293 ScrollWindowEx(hwnd,0,-scrollY,NULL,NULL,0,NULL,SW_INVALIDATE );4387 ScrollWindowEx(hwnd,0,-scrollY,NULL,NULL,0,NULL,SW_INVALIDATE | SW_SCROLLCHILDREN | (infoPtr->uScrollTime << 16)); 4294 4388 4295 4389 return TRUE; … … 4301 4395 static LRESULT TREEVIEW_GetISearchString(HWND hwnd,LPSTR lpsz,BOOL unicode) 4302 4396 { 4303 //CB: todo 4397 //CB: todo: MSDN documentation is useless 4304 4398 4305 4399 return 0; 4400 } 4401 4402 static LRESULT TREEVIEW_SetCursor(HWND hwnd,WPARAM wParam,LPARAM lParam) 4403 { 4404 TREEVIEW_SendSimpleNotify(hwnd,NM_SETCURSOR); //CB: todo: result 4405 4406 return DefWindowProcA(hwnd,WM_SETCURSOR,wParam,lParam); 4407 } 4408 4409 static LRESULT TREEVIEW_GetUnicodeFormat(HWND hwnd,WPARAM wParam,LPARAM lParam) 4410 { 4411 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 4412 4413 return infoPtr->uInternalStatus & TV_UNICODE; 4414 } 4415 4416 static LRESULT TREEVIEW_SetUnicodeFormat(HWND hwnd,WPARAM wParam,LPARAM lParam) 4417 { 4418 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 4419 BOOL oldFormat = infoPtr->uInternalStatus & TV_UNICODE; 4420 4421 if (wParam) 4422 infoPtr->uInternalStatus |= TV_UNICODE; 4423 else 4424 infoPtr->uInternalStatus &= ~TV_UNICODE; 4425 4426 return oldFormat; 4306 4427 } 4307 4428 … … 4450 4571 4451 4572 case TVM_GETUNICODEFORMAT: 4452 // FIXME (treeview, "Unimplemented msg TVM_GETUNICODEFORMAT\n"); 4453 return 0; 4573 return TREEVIEW_GetUnicodeFormat(hwnd,wParam,lParam); 4574 4575 case TVM_SETUNICODEFORMAT: 4576 return TREEVIEW_SetUnicodeFormat(hwnd,wParam,lParam); 4454 4577 4455 4578 case WM_COMMAND: … … 4459 4582 return TREEVIEW_Destroy (hwnd); 4460 4583 4461 /* case WM_ENABLE: */ 4584 case WM_ENABLE: 4585 return TREEVIEW_Enable(hwnd,wParam,lParam); 4462 4586 4463 4587 case WM_ERASEBKGND: … … 4465 4589 4466 4590 case WM_GETDLGCODE: 4467 return DLGC_WANTARROWS | DLGC_WANTCHARS;4591 return TREEVIEW_GetDlgCode(hwnd,wParam,lParam); 4468 4592 4469 4593 case WM_PAINT: … … 4485 4609 return TREEVIEW_KillFocus (hwnd, wParam, lParam); 4486 4610 4611 case WM_MOUSEMOVE: 4612 return TREEVIEW_MouseMove(hwnd,wParam,lParam); 4613 4487 4614 case WM_LBUTTONDOWN: 4488 4615 return TREEVIEW_LButtonDown (hwnd, wParam, lParam); … … 4494 4621 return TREEVIEW_RButtonDown (hwnd, wParam, lParam); 4495 4622 4623 case WM_RBUTTONDBLCLK: 4624 return TREEVIEW_RButtonDoubleClick(hwnd,wParam,lParam); 4625 4496 4626 case WM_STYLECHANGED: 4497 4627 return TREEVIEW_StyleChanged (hwnd, wParam, lParam); 4498 4628 4499 /* case WM_SYSCOLORCHANGE: */ 4629 case WM_SYSCOLORCHANGE: 4630 return TREEVIEW_SysColorChange(hwnd,wParam,lParam); 4631 4632 case WM_SETCURSOR: 4633 return TREEVIEW_SetCursor(hwnd,wParam,lParam); 4500 4634 4501 4635 case WM_SETREDRAW:
Note:
See TracChangeset
for help on using the changeset viewer.