Changeset 2131 for trunk/src/comctl32/treeview.c
- Timestamp:
- Dec 19, 1999, 11:32:12 AM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/treeview.c
r1793 r2131 1 /* $Id: treeview.c,v 1. 19 1999-11-21 14:00:48achimha Exp $ */1 /* $Id: treeview.c,v 1.20 1999-12-19 10:32:12 achimha Exp $ */ 2 2 /* Treeview control 3 3 * … … 42 42 */ 43 43 44 /* WINE 991 114level */44 /* WINE 991212 level */ 45 45 46 46 #include <string.h> … … 433 433 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 434 434 INT cx,cy,prevHeight=infoPtr->uItemHeight; 435 HDC hdc;436 435 437 436 // TRACE (treeview,"\n"); 438 437 if (wParam==-1) { 439 hdc=GetDC (hwnd);440 438 infoPtr->uItemHeight=-1; 441 439 return prevHeight; … … 482 480 483 481 static LRESULT 482 TREEVIEW_GetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam) 483 { 484 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 485 486 TRACE("\n"); 487 return (LRESULT) infoPtr->clrInsertMark; 488 } 489 490 static LRESULT 491 TREEVIEW_SetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam) 492 { 493 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 494 COLORREF prevColor=infoPtr->clrInsertMark; 495 496 TRACE("%d %ld\n",wParam,lParam); 497 infoPtr->clrInsertMark=(COLORREF) lParam; 498 return (LRESULT) prevColor; 499 } 500 501 static LRESULT 502 TREEVIEW_SetInsertMark (HWND hwnd, WPARAM wParam, LPARAM lParam) 503 { 504 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 505 506 FIXME("%d %ld\n",wParam,lParam); 507 if (!TREEVIEW_ValidItem (infoPtr, (HTREEITEM)lParam)) return 0; 508 FIXME("%d %ld\n",wParam,lParam); 509 510 infoPtr->insertBeforeorAfter=(BOOL) wParam; 511 infoPtr->insertMarkItem=(HTREEITEM) lParam; 512 TREEVIEW_Refresh (hwnd); 513 return 1; 514 } 515 516 static LRESULT 484 517 TREEVIEW_SetTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam) 485 518 { … … 533 566 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 534 567 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 535 INT center,xpos,cx,cy, cditem , drawmode;568 INT center,xpos,cx,cy, cditem; 536 569 HFONT hOldFont; 537 570 UINT uTextJustify = DT_LEFT; … … 547 580 //TRACE ("cdmode:%x\n",infoPtr->cdmode); 548 581 if (infoPtr->cdmode & CDRF_NOTIFYITEMDRAW) { 549 drawmode=CDDS_ITEMPREPAINT; 550 551 if (infoPtr->cdmode & CDRF_NOTIFYSUBITEMDRAW) 552 drawmode|=CDDS_SUBITEM; 553 554 cditem=TREEVIEW_SendCustomDrawItemNotify (hwnd, hdc, wineItem, drawmode); 555 556 // TRACE (treeview,"cditem:%d\n",cditem); 582 cditem = TREEVIEW_SendCustomDrawItemNotify(hwnd, hdc, 583 wineItem, CDDS_ITEMPREPAINT); 557 584 558 585 if (cditem & CDRF_SKIPDEFAULT) … … 670 697 } 671 698 672 /* 673 * Display the image ass iciated with this item699 /* 700 * Display the image associated with this item 674 701 */ 675 702 xpos += 13; /* update position */ … … 678 705 HIMAGELIST *himlp = NULL; 679 706 680 if (infoPtr->himlNormal) 707 /* State images are displayed to the left of the Normal image 708 * image number is in state; zero should be `display no image'. 709 * FIXME: that last sentence looks like it needs some checking. 710 */ 711 if (infoPtr->himlState) 712 himlp=&infoPtr->himlState; 713 imageIndex=wineItem->state>>12; 714 imageIndex++; /* yeah, right */ 715 TRACE ("imindex:%d\n",imageIndex); 716 if ((himlp) && (imageIndex)) 717 { 718 imageIndex--; /* see FIXME */ 719 ImageList_Draw ( *himlp, imageIndex, hdc, xpos-2, r.top+1, ILD_NORMAL); 720 ImageList_GetIconSize (*himlp, &cx, &cy); 721 wineItem->statebitmap.left=xpos-2; 722 wineItem->statebitmap.right=xpos-2+cx; 723 wineItem->statebitmap.top=r.top+1; 724 wineItem->statebitmap.bottom=r.top+1+cy; 725 xpos+=cx; 726 } 727 728 /* Now, draw the normal image; can be either selected or 729 * non-selected image. 730 */ 731 732 himlp=NULL; 733 if (infoPtr->himlNormal) 681 734 himlp=&infoPtr->himlNormal; /* get the image list */ 682 735 683 if ( (wineItem->state & TVIS_SELECTED) && 684 (wineItem->iSelectedImage)) { 685 686 /* State images are displayed to the left of the Normal image*/ 687 if (infoPtr->himlState) 688 himlp=&infoPtr->himlState; 689 736 imageIndex = wineItem->iImage; 737 if ( (wineItem->state & TVIS_SELECTED) && 738 (wineItem->iSelectedImage)) { 739 690 740 /* The item is curently selected */ 691 if (wineItem->iSelectedImage == I_IMAGECALLBACK) 692 TREEVIEW_SendDispInfoNotify ( 693 hwnd, 694 wineItem, 695 TVN_GETDISPINFO, 696 TVIF_SELECTEDIMAGE); 697 698 imageIndex = wineItem->iSelectedImage; 699 700 } else { 701 /* This item is not selected */ 702 if (wineItem->iImage == I_IMAGECALLBACK) 703 TREEVIEW_SendDispInfoNotify ( 704 hwnd, 705 wineItem, 706 TVN_GETDISPINFO, 707 TVIF_IMAGE); 741 if (wineItem->iSelectedImage == I_IMAGECALLBACK) 742 TREEVIEW_SendDispInfoNotify 743 (hwnd, wineItem, TVN_GETDISPINFO, TVIF_SELECTEDIMAGE); 744 745 imageIndex = wineItem->iSelectedImage; 746 } else { 747 /* The item is not selected */ 748 if (wineItem->iImage == I_IMAGECALLBACK) 749 TREEVIEW_SendDispInfoNotify 750 (hwnd, wineItem, TVN_GETDISPINFO, TVIF_IMAGE); 708 751 709 752 imageIndex = wineItem->iImage; 710 } 711 712 if (himlp) 713 { 714 /* We found an image to display? Draw it. */ 715 ImageList_Draw ( 716 *himlp, 717 wineItem->iImage, 718 hdc, 719 xpos-2, 720 r.top+1, 721 ILD_NORMAL); 722 723 ImageList_GetIconSize (*himlp, &cx, &cy); 724 xpos+=cx; 753 } 754 755 if (himlp) 756 { 757 ImageList_Draw ( *himlp, imageIndex, hdc, xpos-2, r.top+1, ILD_NORMAL); 758 ImageList_GetIconSize (*himlp, &cx, &cy); 759 wineItem->bitmap.left=xpos-2; 760 wineItem->bitmap.right=xpos-2+cx; 761 wineItem->bitmap.top=r.top+1; 762 wineItem->bitmap.bottom=r.top+1+cy; 763 xpos+=cx; 725 764 } 726 765 } 727 766 728 /* 729 * Display the text assiciated with this item 767 768 /* 769 * Display the text associated with this item 730 770 */ 731 771 r.left=xpos; 732 if ((wineItem->mask & TVIF_TEXT) && (wineItem->pszText)) 772 if ((wineItem->mask & TVIF_TEXT) && (wineItem->pszText)) 733 773 { 734 774 COLORREF oldBkColor = 0; … … 739 779 r.right -= 3; 740 780 741 wineItem->text.left = r.left; 781 wineItem->text.left = r.left; 742 782 wineItem->text.right = r.right; 743 783 wineItem->text.top = r.top; 744 784 wineItem->text.bottom= r.bottom; 745 785 746 if (wineItem->state & (TVIS_SELECTED | TVIS_DROPHILITED) ) {747 oldBkMode = SetBkMode (hdc, OPAQUE);748 oldBkColor = SetBkColor (hdc, GetSysColor( COLOR_HIGHLIGHT));749 oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_HIGHLIGHTTEXT));750 }751 else752 {753 oldBkMode = SetBkMode(hdc, TRANSPARENT);754 oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_WINDOWTEXT));755 }756 757 786 if (wineItem->pszText== LPSTR_TEXTCALLBACKA) { 758 // TRACE (treeview,"LPSTR_TEXTCALLBACK\n");787 TRACE("LPSTR_TEXTCALLBACK\n"); 759 788 TREEVIEW_SendDispInfoNotify (hwnd, wineItem, TVN_GETDISPINFO, TVIF_TEXT); 760 789 } 761 790 791 /* Yep, there are some things that need to be straightened out here. 792 Removing the comments around the setTextColor does not give the right 793 results. Dito FillRect. 794 */ 795 796 797 /* GetTextExtentPoint32A (hdc, wineItem->pszText, 798 strlen (wineItem->pszText), &size); */ 799 800 /* FillRect ( hdc, &wineItem->text, GetSysColorBrush (infoPtr->clrBk)); 801 */ 802 803 804 if (!(cditem & CDRF_NOTIFYPOSTPAINT) && 805 (wineItem->state & (TVIS_SELECTED | TVIS_DROPHILITED)) ) { 806 oldBkMode = SetBkMode (hdc, OPAQUE); 807 oldBkColor = SetBkColor (hdc, GetSysColor( COLOR_HIGHLIGHT)); 808 oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_HIGHLIGHTTEXT)); 809 } else { 810 oldBkMode = SetBkMode (hdc, TRANSPARENT); 811 oldBkColor = SetBkColor (hdc, infoPtr->clrBk); 812 /* oldTextColor = SetTextColor(hdc, infoPtr->clrText); */ 813 } 814 815 816 762 817 /* Draw it */ 763 DrawTextA ( 764 hdc, 765 wineItem->pszText, 766 lstrlenA(wineItem->pszText), 767 &wineItem->text, 768 uTextJustify | DT_VCENTER | DT_SINGLELINE ); 818 DrawTextA ( hdc, 819 wineItem->pszText, 820 lstrlenA(wineItem->pszText), 821 &wineItem->text, 822 uTextJustify | DT_VCENTER | DT_SINGLELINE ); 769 823 770 824 /* Obtain the text coordinate */ 771 825 DrawTextA ( 772 hdc, 773 wineItem->pszText, 774 lstrlenA(wineItem->pszText), 775 &wineItem->text, 776 uTextJustify | DT_VCENTER | DT_SINGLELINE | DT_CALCRECT); 826 hdc, 827 wineItem->pszText, 828 lstrlenA(wineItem->pszText), 829 &wineItem->text, 830 uTextJustify | DT_VCENTER | DT_SINGLELINE | DT_CALCRECT); 777 831 778 832 /* Restore the hdc state */ … … 785 839 786 840 /* Draw the box arround the selected item */ 787 if (wineItem->state & TVIS_SELECTED ) 841 if (wineItem->state & TVIS_SELECTED ) 788 842 { 789 HPEN h newPen = CreatePen(PS_DOT, 0, GetSysColor(COLOR_WINDOWTEXT) );790 HPEN hOldPen = SelectObject( hdc, h newPen );843 HPEN hNewPen = CreatePen(PS_DOT, 0, GetSysColor(COLOR_WINDOWTEXT) ); 844 HPEN hOldPen = SelectObject( hdc, hNewPen ); 791 845 POINT points[4]; 792 846 793 847 points[0].x = wineItem->text.left-1; 794 points[0].y = wineItem->text.top+1; 848 points[0].y = wineItem->text.top+1; 795 849 points[1].x = wineItem->text.right; 796 points[1].y = wineItem->text.top+1; 850 points[1].y = wineItem->text.top+1; 797 851 points[2].x = wineItem->text.right; 798 points[2].y = wineItem->text.bottom; 852 points[2].y = wineItem->text.bottom; 799 853 points[3].x = wineItem->text.left-1; 800 854 points[3].y = wineItem->text.bottom; 801 855 802 Polyline (hdc,points,4); 803 804 DeleteObject(h newPen);856 Polyline (hdc,points,4); 857 858 DeleteObject(hNewPen); 805 859 SelectObject(hdc, hOldPen); 806 860 } 807 861 } 808 862 809 if (cditem & CDRF_NOTIFYPOSTPAINT) 810 TREEVIEW_SendCustomDrawItemNotify (hwnd, hdc, wineItem, CDDS_ITEMPOSTPAINT); 863 /* Draw insertion mark if necessary */ 864 865 if (infoPtr->insertMarkItem) 866 TRACE ("item:%d,mark:%d\n", (int)wineItem->hItem, 867 (int) infoPtr->insertMarkItem); 868 if (wineItem->hItem==infoPtr->insertMarkItem) { 869 HPEN hNewPen, hOldPen; 870 int offset; 871 872 hNewPen = CreatePen(PS_SOLID, 2, infoPtr->clrInsertMark); 873 hOldPen = SelectObject( hdc, hNewPen ); 874 875 if (infoPtr->insertBeforeorAfter) 876 offset=wineItem->text.top+1; 877 else 878 offset=wineItem->text.bottom-1; 879 880 MoveToEx (hdc, wineItem->text.left, offset-3, NULL); 881 LineTo (hdc, wineItem->text.left, offset+3); 882 883 MoveToEx (hdc, wineItem->text.left, offset, NULL); 884 LineTo (hdc, r.right-2, offset); 885 886 MoveToEx (hdc, r.right-2, offset+3, NULL); 887 LineTo (hdc, r.right-2, offset-3); 888 889 DeleteObject(hNewPen); 890 891 SelectObject(hdc, hOldPen); 892 } 893 894 if (cditem & CDRF_NOTIFYPOSTPAINT) { 895 cditem=TREEVIEW_SendCustomDrawItemNotify 896 (hwnd, hdc, wineItem, CDDS_ITEMPOSTPAINT); 897 TRACE("postpaint:cditem-app returns 0x%x\n",cditem); 898 } 811 899 812 900 SelectObject (hdc, hOldFont); … … 832 920 833 921 /* 834 * retri ve the item ptr922 * retrieve the item ptr 835 923 */ 836 924 iItem = (HTREEITEM *) lParam; … … 909 997 910 998 if (tvItem->mask & TVIF_STATE) { 911 wineItem->state=tvItem->state & tvItem->stateMask; 999 TRACE ("prevstate,state,mask:%x,%x,%x\n",wineItem->state,tvItem->state, 1000 tvItem->stateMask); 1001 wineItem->state&= ~tvItem->stateMask; 1002 wineItem->state|= (tvItem->state & tvItem->stateMask); 1003 wineItem->stateMask|= tvItem->stateMask; 912 1004 } 913 1005 … … 1764 1856 aChild = &infoPtr->items[(INT)infoPtr->TopRootItem]; 1765 1857 1858 /* lookup the text if using LPSTR_TEXTCALLBACKs */ 1859 if (wineItem->pszText==LPSTR_TEXTCALLBACKA) { 1860 TREEVIEW_SendDispInfoNotify (hwnd, wineItem, TVN_GETDISPINFO, TVIF_TEXT); 1861 } 1862 1766 1863 /* Iterate the parent children to see where we fit in */ 1767 1864 while ( aChild != NULL ) 1768 1865 { 1769 INT comp = strcmp(wineItem->pszText, aChild->pszText); 1866 INT comp; 1867 1868 /* lookup the text if using LPSTR_TEXTCALLBACKs */ 1869 if (aChild->pszText==LPSTR_TEXTCALLBACKA) { 1870 TREEVIEW_SendDispInfoNotify (hwnd, aChild, TVN_GETDISPINFO, TVIF_TEXT); 1871 } 1872 1873 comp = strcmp(wineItem->pszText, aChild->pszText); 1770 1874 if ( comp < 0 ) /* we are smaller than the current one */ 1771 1875 { … … 2153 2257 { 2154 2258 TREEVIEW_INFO *infoPtr; 2155 LOGFONTA logFont; 2259 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 2260 LOGFONTA logFont; 2156 2261 TEXTMETRICA tm; 2157 2158 2159 // TRACE (treeview,"wnd %x\n",hwnd);2262 HDC hdc; 2263 2264 TRACE("wnd %x, style %lx\n",hwnd,dwStyle); 2160 2265 /* allocate memory for info structure */ 2161 2162 2163 2266 infoPtr = (TREEVIEW_INFO *) COMCTL32_Alloc (sizeof(TREEVIEW_INFO)); 2267 2268 SetWindowLongA( hwnd, 0, (DWORD)infoPtr); 2164 2269 2165 2270 if (infoPtr == NULL) { 2166 // ERR (treeview,"could not allocate info memory!\n");2167 2271 ERR("could not allocate info memory!\n"); 2272 return 0; 2168 2273 } 2169 2274 2170 2275 if ((TREEVIEW_INFO*) GetWindowLongA( hwnd, 0) != infoPtr) { 2171 // ERR (treeview,"pointer assignment error!\n");2172 2276 ERR("pointer assignment error!\n"); 2277 return 0; 2173 2278 } 2174 2279 2175 2280 hdc=GetDC (hwnd); 2176 2281 2177 2282 /* set default settings */ 2178 2283 infoPtr->uInternalStatus=0; 2179 2284 infoPtr->uNumItems=0; 2180 infoPtr->clrBk = GetSysColor (COLOR_WINDOW);2181 infoPtr->clrText = GetSysColor (COLOR_ BTNTEXT);2285 infoPtr->clrBk = GetSysColor (COLOR_WINDOW); 2286 infoPtr->clrText = GetSysColor (COLOR_WINDOWTEXT); 2182 2287 infoPtr->clrLine = GetSysColor (COLOR_WINDOWTEXT); 2288 infoPtr->clrInsertMark = GetSysColor (COLOR_BTNTEXT); 2183 2289 infoPtr->cy = 0; 2184 2290 infoPtr->cx = 0; … … 2186 2292 infoPtr->himlNormal = NULL; 2187 2293 infoPtr->himlState = NULL; 2188 2294 infoPtr->uItemHeight = -1; 2189 2295 GetTextMetricsA (hdc, &tm); 2190 2296 infoPtr->hFont = GetStockObject (DEFAULT_GUI_FONT); 2191 2192 2297 GetObjectA (infoPtr->hFont, sizeof (LOGFONTA), &logFont); 2298 logFont.lfWeight=FW_BOLD; 2193 2299 infoPtr->hBoldFont = CreateFontIndirectA (&logFont); 2194 2300 2195 2301 infoPtr->items = NULL; 2196 2302 infoPtr->selectedItem=0; 2197 infoPtr->clrText=-1; 2303 infoPtr->clrText=-1; /* use system color */ 2198 2304 infoPtr->dropItem=0; 2305 infoPtr->insertMarkItem=0; 2306 infoPtr->insertBeforeorAfter=0; 2199 2307 infoPtr->pCallBackSort=NULL; 2200 infoPtr->uScrollTime = 300; /* milliseconds */ 2201 2202 // @@@PH 1999/11/05 2203 infoPtr->wpEditOrig = NULL; /* no subclass */ 2204 2205 /* 2206 infoPtr->hwndNotify = GetParent32 (hwnd); 2207 infoPtr->bTransparent = ( GetWindowLongA( hwnd, GWL_STYLE) & TBSTYLE_FLAT); 2208 */ 2209 2210 infoPtr->hwndToolTip=0; 2211 if (!( GetWindowLongA( hwnd, GWL_STYLE) & TVS_NOTOOLTIPS)) { /* Create tooltip control */ 2212 TTTOOLINFOA ti; 2213 2214 infoPtr->hwndToolTip = 2215 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0, 2308 infoPtr->uScrollTime = 300; /* milliseconds */ 2309 2310 infoPtr->hwndToolTip=0; 2311 if (!(dwStyle & TVS_NOTOOLTIPS)) { /* Create tooltip control */ 2312 TTTOOLINFOA ti; 2313 2314 infoPtr->hwndToolTip = 2315 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0, 2216 2316 CW_USEDEFAULT, CW_USEDEFAULT, 2217 2317 CW_USEDEFAULT, CW_USEDEFAULT, … … 2231 2331 } 2232 2332 2233 2333 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 2234 2334 ti.cbSize = sizeof(TTTOOLINFOA); 2235 2335 ti.uFlags = TTF_IDISHWND | TTF_TRACK | TTF_TRANSPARENT ; … … 2242 2342 } 2243 2343 2244 infoPtr->hwndEdit = CreateWindowExA ( 2245 WS_EX_LEFT, 2344 // @@@PH 1999/11/05 2345 infoPtr->wpEditOrig = NULL; /* no subclass */ 2346 2347 infoPtr->hwndEdit = CreateWindowExA ( 2348 WS_EX_LEFT, 2246 2349 "EDIT", 2247 2350 0, 2248 WS_CHILD | WS_BORDER | ES_AUTOHSCROLL | 2351 WS_CHILD | WS_BORDER | ES_AUTOHSCROLL | 2249 2352 ES_WANTRETURN | ES_LEFT, 2250 2353 0, 0, 0, 0, 2251 hwnd, 2354 hwnd, 2252 2355 0,0,0); /* FIXME: (HMENU)IDTVEDIT,pcs->hInstance,0);*/ 2253 2356 2254 2357 SendMessageA ( infoPtr->hwndEdit, WM_SETFONT, infoPtr->hFont, FALSE); 2255 2358 infoPtr->wpEditOrig = (WNDPROC)SetWindowLongA ( 2256 2359 infoPtr->hwndEdit, 2257 GWL_WNDPROC, 2258 (LONG) TREEVIEW_Edit_SubclassProc); 2259 2360 GWL_WNDPROC, 2361 (LONG) TREEVIEW_Edit_SubclassProc); 2362 2363 if (dwStyle & TVS_CHECKBOXES) { 2364 HBITMAP hbmLoad; 2365 int nIndex; 2366 2367 infoPtr->himlState = 2368 ImageList_Create (16, 16,ILC_COLOR|ILC_MASK, 15, 1); 2369 2370 hbmLoad = LoadBitmapA (COMCTL32_hModule, MAKEINTRESOURCEA(IDT_CHECK)); 2371 TRACE ("%x\n",hbmLoad); 2372 nIndex = ImageList_AddMasked (infoPtr->himlState, hbmLoad, CLR_DEFAULT); 2373 TRACE ("%d\n",nIndex); 2374 DeleteObject (hbmLoad); 2375 } 2260 2376 ReleaseDC (hwnd, hdc); 2261 2377 return 0; … … 2540 2656 DWORD dwDrawStage,dwItemSpec; 2541 2657 UINT uItemState; 2658 INT retval; 2542 2659 2543 2660 dwDrawStage=CDDS_ITEM | uItemDrawState; … … 2569 2686 // dwDrawStage, hdc, dwItemSpec, uItemState); 2570 2687 2571 return (BOOL)SendMessageA (GetParent (hwnd), WM_NOTIFY, 2572 (WPARAM) GetWindowLongA( hwnd, GWL_ID), (LPARAM)&nmcdhdr); 2688 retval=SendMessageA (GetParent (hwnd), WM_NOTIFY, 2689 (WPARAM) GetWindowLongA( hwnd, GWL_ID), (LPARAM)&nmcdhdr); 2690 2691 infoPtr->clrText=nmcdhdr.clrText; 2692 infoPtr->clrBk =nmcdhdr.clrTextBk; 2693 return (BOOL) retval; 2573 2694 } 2574 2695 … … 2764 2885 2765 2886 wineItem=TREEVIEW_HitTestPoint (hwnd, lpht->pt); 2766 if (!wineItem) { 2887 if (!wineItem) { 2767 2888 lpht->flags=TVHT_NOWHERE; 2768 2889 return 0; 2769 2890 } 2770 2891 2771 /* FIXME: implement other flags2772 * Assign the appropriate flags depending on the click location2773 * Intitialize flags before to "|=" it...2774 */2775 2892 lpht->flags=0; 2776 2893 2777 if (x < wineItem->expandBox.left) 2778 { 2894 if (x < wineItem->expandBox.left) { 2779 2895 lpht->flags |= TVHT_ONITEMINDENT; 2780 } 2781 else if ( ( x >= wineItem->expandBox.left) && 2782 ( x <= wineItem->expandBox.right)) 2783 { 2896 goto done; 2897 } 2898 if ( PtInRect ( &wineItem->expandBox, lpht->pt)) { 2784 2899 lpht->flags |= TVHT_ONITEMBUTTON; 2785 } 2786 else if (x < wineItem->rect.right) 2787 { 2788 lpht->flags |= TVHT_ONITEMLABEL; 2789 } 2790 else 2791 { 2792 lpht->flags|=TVHT_ONITEMRIGHT; 2793 } 2794 2900 goto done; 2901 } 2902 if ( PtInRect ( &wineItem->bitmap, lpht->pt)) { 2903 lpht->flags |= TVHT_ONITEMICON; 2904 goto done; 2905 } 2906 if ( PtInRect ( &wineItem->statebitmap, lpht->pt)) { 2907 lpht->flags |= TVHT_ONITEMSTATEICON; 2908 goto done; 2909 } 2910 if ( PtInRect ( &wineItem->text, lpht->pt)) { 2911 lpht->flags |= TVHT_ONITEMLABEL; 2912 goto done; 2913 } 2914 2915 lpht->flags|=TVHT_ONITEMRIGHT; 2916 2917 2918 done: 2795 2919 lpht->hItem=wineItem->hItem; 2920 TRACE ("(%ld,%ld):result %x\n",lpht->pt.x,lpht->pt.y,lpht->flags); 2796 2921 2797 2922 return (LRESULT) wineItem->hItem; … … 2918 3043 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 2919 3044 INT iItem; 2920 TREEVIEW_ITEM * editItem;3045 TREEVIEW_ITEM *wineItem; 2921 3046 TVHITTESTINFO ht; 2922 3047 2923 3048 ht.pt.x = (INT)LOWORD(lParam); 2924 3049 ht.pt.y = (INT)HIWORD(lParam); 2925 2926 // TRACE (treeview,"\n");3050 3051 TRACE("\n"); 2927 3052 2928 3053 /* Return true to cancel default behaviour */ … … 2932 3057 /* Get the item */ 2933 3058 iItem = TREEVIEW_HitTest (hwnd, (LPARAM) &ht); 2934 if (!iItem) 3059 TRACE ("%d\n",iItem); 3060 if (!iItem) 2935 3061 return 0; 2936 3062 2937 editItem = TREEVIEW_ValidItem(infoPtr, (HTREEITEM)iItem);2938 3063 wineItem = TREEVIEW_ValidItem(infoPtr, (HTREEITEM)iItem); 3064 2939 3065 infoPtr->uInternalStatus &= ~(TV_LDRAG | TV_LDRAGGING); 2940 3066 2941 /* 2942 * If the style allow editing and the node is already selected 3067 /* 3068 * If the style allow editing and the node is already selected 2943 3069 * and the click occured on the item label... 2944 3070 */ 2945 if ( ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_EDITLABELS ) && 2946 ( editItem->state & TVIS_SELECTED ) &&3071 if ( ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_EDITLABELS ) && 3072 ( wineItem->state & TVIS_SELECTED ) && 2947 3073 ( ht.flags & TVHT_ONITEMLABEL )) 2948 3074 { 2949 3075 if ( infoPtr->editItem == 0 ) /* If we are not curently editing */ 2950 3076 { 2951 2952 hwnd, 2953 editItem,2954 TVN_BEGINLABELEDIT, 3077 if ( TREEVIEW_SendDispInfoNotify( /* Return true to cancel edition */ 3078 hwnd, 3079 wineItem, 3080 TVN_BEGINLABELEDIT, 2955 3081 0)) 2956 3082 { 2957 return 0; 3083 return 0; 2958 3084 } 2959 2960 // TRACE(treeview,"Edit started for %s.\n", editItem->pszText);2961 infoPtr->editItem = editItem->hItem;2962 2963 SetWindowPos (2964 infoPtr->hwndEdit, 2965 HWND_TOP, 2966 editItem->text.left - 2,2967 editItem->text.top - 1,2968 editItem->text.right - editItem->text.left + 20 ,2969 editItem->text.bottom - editItem->text.top + 3,3085 3086 TRACE("Edit started for %s.\n", wineItem->pszText); 3087 infoPtr->editItem = wineItem->hItem; 3088 3089 SetWindowPos ( 3090 infoPtr->hwndEdit, 3091 HWND_TOP, 3092 wineItem->text.left - 2, 3093 wineItem->text.top - 1, 3094 wineItem->text.right - wineItem->text.left + 20 , 3095 wineItem->text.bottom - wineItem->text.top + 3, 2970 3096 SWP_DRAWFRAME ); 2971 2972 SetWindowTextA( infoPtr->hwndEdit, editItem->pszText );3097 3098 SetWindowTextA( infoPtr->hwndEdit, wineItem->pszText ); 2973 3099 SendMessageA ( infoPtr->hwndEdit, EM_SETSEL, 0, -1 ); 2974 SetFocus ( infoPtr->hwndEdit);2975 ShowWindow ( infoPtr->hwndEdit, SW_SHOW); 3100 SetFocus ( infoPtr->hwndEdit); 3101 ShowWindow ( infoPtr->hwndEdit, SW_SHOW); 2976 3102 } 2977 3103 } … … 2982 3108 else if ( ht.flags & (TVHT_ONITEMLABEL | TVHT_ONITEMICON)) 2983 3109 { 2984 TREEVIEW_DoSelectItem ( 2985 hwnd, 2986 TVGN_CARET, 2987 (HTREEITEM)iItem, 2988 TVC_BYMOUSE); 2989 } 2990 3110 TREEVIEW_DoSelectItem ( hwnd, TVGN_CARET, (HTREEITEM)iItem, TVC_BYMOUSE); 3111 } 3112 3113 if (ht.flags & TVHT_ONITEMSTATEICON) { 3114 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 3115 3116 3117 if (dwStyle & TVS_CHECKBOXES) { /* TVS_CHECKBOXES requires _us_ */ 3118 int state; /* to toggle the current state */ 3119 state=1-(wineItem->state>>12); 3120 TRACE ("state:%x\n", state); 3121 wineItem->state&= ~TVIS_STATEIMAGEMASK; 3122 wineItem->state|=state<<12; 3123 TRACE ("state:%x\n", wineItem->state); 3124 TREEVIEW_QueueRefresh (hwnd); 3125 } 3126 } 2991 3127 return 0; 2992 3128 } … … 3069 3205 3070 3206 if (!dragItem) return 0; 3207 3208 if (dragItem->pszText==LPSTR_TEXTCALLBACKA) { 3209 TREEVIEW_SendDispInfoNotify (hwnd, dragItem, TVN_GETDISPINFO, TVIF_TEXT); 3210 } 3071 3211 itemtxt=dragItem->pszText; 3072 3212 … … 3646 3786 return TREEVIEW_SetToolTips (hwnd, wParam); 3647 3787 3648 case TVM_SETINSERTMARK: 3649 // FIXME (treeview, "Unimplemented msg TVM_SETINSERTMARK\n"); 3650 return 0; 3788 case TVM_SETINSERTMARK: 3789 return TREEVIEW_SetInsertMark (hwnd,wParam, lParam); 3651 3790 3652 3791 case TVM_SETITEMHEIGHT: … … 3683 3822 return TREEVIEW_SetLineColor (hwnd,wParam, lParam); 3684 3823 3685 case TVM_SETINSERTMARKCOLOR: 3686 // FIXME (treeview, "Unimplemented msg TVM_SETINSERTMARKCOLOR\n"); 3687 return 0; 3688 3689 case TVM_SETUNICODEFORMAT: 3690 // FIXME (treeview, "Unimplemented msg TVM_SETUNICODEFORMAT\n"); 3691 return 0; 3824 case TVM_SETINSERTMARKCOLOR: 3825 return TREEVIEW_SetInsertMarkColor (hwnd,wParam, lParam); 3826 3827 case TVM_GETINSERTMARKCOLOR: 3828 return TREEVIEW_GetInsertMarkColor (hwnd,wParam, lParam); 3692 3829 3693 3830 case TVM_GETUNICODEFORMAT:
Note:
See TracChangeset
for help on using the changeset viewer.