- Timestamp:
- Feb 16, 2000, 6:22:19 PM (26 years ago)
- Location:
- trunk/src/comctl32
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/progress.c
r2523 r2806 1 /* $Id: progress.c,v 1.1 2 2000-01-26 18:04:29cbratschi Exp $ */1 /* $Id: progress.c,v 1.13 2000-02-16 17:22:18 cbratschi Exp $ */ 2 2 /* 3 3 * Progress control … … 23 23 #define BORDER_WIDTH 1 24 24 25 /* Work constants */26 27 //#define UNKNOWN_PARAM(msg, wParam, lParam) WARN(progress, \28 // "Unknown parameter(s) for message " #msg \29 // "(%04x): wp=%04x lp=%08lx\n", msg, wParam, lParam);30 //#define UNKNOWN_PARAM(msg, wParam, lParam)31 32 25 #define PROGRESS_GetInfoPtr(hwnd) ((PROGRESS_INFO *)GetWindowLongA(hwnd,0)) 33 26 -
trunk/src/comctl32/tooltips.c
r2635 r2806 1 /* $Id: tooltips.c,v 1.2 0 2000-02-04 17:02:09cbratschi Exp $ */1 /* $Id: tooltips.c,v 1.21 2000-02-16 17:22:18 cbratschi Exp $ */ 2 2 /* 3 3 * Tool tip control … … 85 85 { 86 86 /* load a resource */ 87 // TRACE (tooltips,"load res string %x %x\n",toolPtr->hinst,(int)toolPtr->lpszText); 87 88 88 LoadStringW(toolPtr->hinst,(UINT)toolPtr->lpszText,infoPtr->szTipText,INFOTIPSIZE); 89 89 } else if (toolPtr->lpszText) … … 101 101 ttnmdi.uFlags = toolPtr->uFlags; 102 102 ttnmdi.lParam = toolPtr->lParam; 103 // TRACE (tooltips, "hdr.idFrom = %x\n", ttnmdi.hdr.idFrom);104 103 SendMessageA (toolPtr->hwnd,WM_NOTIFY,(WPARAM)toolPtr->uId,(LPARAM)&ttnmdi); 105 104 … … 138 137 } else 139 138 { 140 //ERR (tooltips, "recursive text callback!\n");139 //ERR (tooltips, "recursive text callback!\n"); 141 140 infoPtr->szTipText[0] = '\0'; 142 141 } -
trunk/src/comctl32/treeview.c
r2782 r2806 1 /* $Id: treeview.c,v 1.2 5 2000-02-14 17:31:40cbratschi Exp $ */1 /* $Id: treeview.c,v 1.26 2000-02-16 17:22:19 cbratschi Exp $ */ 2 2 /* Treeview control 3 3 * … … 11 11 * TODO: 12 12 * Using DPA to store the item ptr would be good. 13 * Node label edition is implemented but something appened in wine in the14 * two last weeks of march 99 that broke it.15 * refreshtreeview:16 -small array containing info about positions.17 -better implementation of RefreshItem:18 1) draw lines between parents19 2) draw items20 3) draw lines from parent<->items.21 -implement partial drawing?22 * -drag&drop: TVM_CREATEDRAGIMAGE should create drag bitmap.23 * -scrollbars: horizontal scrollbar doesn't work.24 * -Unicode messages25 13 * -check custom draw 26 * -I_CHILDRENCALLBACK27 14 * FIXME: check fontsize. (uRealItemHeight) 28 * test focusItem (redraw in different color)29 15 uHotItem 30 Edit: needs timer31 better implementation.32 * WM_HSCROLL is broken.33 16 * use separate routine to get item text/image. 34 *35 * Separate drawing/calculation.36 17 * 37 18 * FIXMEs (for personal use) … … 39 20 -DblClick: ctlmacro.exe's NM_DBLCLK seems to go wrong (returns FALSE). 40 21 -treehelper: stack corruption makes big window. 41 22 * 23 * Status: in progress 24 * Version: 5.00 42 25 */ 43 26 … … 50 33 /* CB: todo 51 34 52 - WM_LBUTTONDOWN: bug in highlight code 53 - WM_SIZE: redraw doesn't work 54 - hscroll not set 55 35 - bug in SetScrollInfo/ShowScrollBar: WM_SIZE and WM_NCPAINT problems 56 36 */ 57 37 … … 88 68 static void TREEVIEW_Refresh(HWND hwnd); 89 69 static void TREEVIEW_Draw(HWND hwnd,HDC hdc,RECT *updateRect); 90 static voidTREEVIEW_UnqueueRefresh(HWND hwnd,BOOL calc,BOOL refresh);70 static BOOL TREEVIEW_UnqueueRefresh(HWND hwnd,BOOL calc,BOOL refresh); 91 71 static void TREEVIEW_QueueRefresh(HWND hwnd); 72 static void TREEVIEW_CalcItem(HWND hwnd,HDC hdc,DWORD dwStyle,TREEVIEW_INFO *infoPtr,TREEVIEW_ITEM *item); 73 static BOOL TREEVIEW_CalcItems(HWND hwnd,HDC hdc,TREEVIEW_INFO *infoPtr); 74 static LRESULT TREEVIEW_EnsureVisible(HWND hwnd,HTREEITEM hItem); 92 75 93 76 static LRESULT CALLBACK TREEVIEW_Edit_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); … … 95 78 LRESULT WINAPI TREEVIEW_EndEditLabelNow (HWND hwnd, BOOL bCancel); 96 79 97 HWND TREEVIEW_EditLabel A(HWND hwnd, HTREEITEM hItem);80 HWND TREEVIEW_EditLabel(HWND hwnd, HTREEITEM hItem,BOOL unicode); 98 81 99 82 /* helper functions. Work with the assumption that validity of operands … … 335 318 infoPtr->uNumItems--; 336 319 killItem=& infoPtr->items[kill]; 337 if (killItem->pszText !=LPSTR_TEXTCALLBACKA)320 if (killItem->pszText != LPSTR_TEXTCALLBACKW) 338 321 COMCTL32_Free (killItem->pszText); 339 322 TREEVIEW_SendTreeviewNotify (hwnd, TVN_DELETEITEM, 0, (HTREEITEM)kill, 0); … … 355 338 INT iItem; 356 339 340 if (infoPtr->hwndEdit) SetFocus(hwnd); 341 357 342 iItem=(INT)wineItem->hItem; 358 343 tv_set_bit(iItem,infoPtr->freeList); 359 344 infoPtr->uNumItems--; 360 345 parentItem=NULL; 361 if (wineItem->pszText !=LPSTR_TEXTCALLBACKA)362 346 if (wineItem->pszText != LPSTR_TEXTCALLBACKW) 347 COMCTL32_Free (wineItem->pszText); 363 348 364 349 TREEVIEW_SendTreeviewNotify (hwnd, TVN_DELETEITEM, 0, (HTREEITEM)iItem, 0); 365 350 366 351 if (wineItem->firstChild) 367 352 TREEVIEW_RemoveAllChildren (hwnd,wineItem); 368 353 369 354 if (wineItem->parent) { … … 392 377 } 393 378 394 395 396 397 398 379 /* Note:TREEVIEW_RemoveTree doesn't remove infoPtr itself */ 399 380 400 381 static void TREEVIEW_RemoveTree (HWND hwnd) 401 402 { 403 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 404 TREEVIEW_ITEM *killItem; 405 int i; 406 407 for (i=1; i<=(INT)infoPtr->uMaxHandle; i++) 382 { 383 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 384 TREEVIEW_ITEM *killItem; 385 int i; 386 387 TREEVIEW_EndEditLabelNow(hwnd,TRUE); 388 389 for (i=1; i<=(INT)infoPtr->uMaxHandle; i++) 408 390 if (!tv_test_bit (i, infoPtr->freeList)) { 409 391 killItem=& infoPtr->items [i]; 410 if (killItem->pszText !=LPSTR_TEXTCALLBACKA)411 392 if (killItem->pszText != LPSTR_TEXTCALLBACKW) 393 COMCTL32_Free (killItem->pszText); 412 394 TREEVIEW_SendTreeviewNotify 413 395 (hwnd, TVN_DELETEITEM, 0, killItem->hItem, 0); 414 396 } 415 397 416 if (infoPtr->uNumPtrsAlloced) {398 if (infoPtr->uNumPtrsAlloced) { 417 399 COMCTL32_Free (infoPtr->items); 418 400 COMCTL32_Free (infoPtr->freeList); … … 420 402 infoPtr->uNumPtrsAlloced=0; 421 403 infoPtr->uMaxHandle=0; 404 infoPtr->cx = infoPtr->cy = 0; 422 405 } 423 406 } … … 443 426 HIMAGELIST himlTemp; 444 427 445 //TRACE (treeview,"\n");446 428 switch ((INT)wParam) { 447 429 case TVSIL_NORMAL: … … 622 604 #endif 623 605 624 // CB:pen must be selected!606 //pen must be selected! 625 607 626 608 static void TREEVIEW_DrawVLines(HDC hdc,TREEVIEW_INFO *infoPtr,TREEVIEW_ITEM *wineItem) … … 656 638 wineItem->rect.bottom-3: /* is linked to an icon */ 657 639 wineItem->rect.bottom+1; /* is linked to a +/- box */ 658 points[1].x = points[0].x = 28 + (20*wineItem->iLevel);640 points[1].x = points[0].x = 28+20*wineItem->iLevel-infoPtr->cx; 659 641 points[1].y = (lastItem->rect.top+lastItem->rect.bottom)/2; /* is linked to a +/- box */ 660 642 #ifdef OS2LINEHACK … … 667 649 668 650 static void 669 TREEVIEW_DrawItem (HWND hwnd, HDC hdc, TREEVIEW_ITEM *wineItem) 670 { 671 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 672 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 651 TREEVIEW_DrawItem(HWND hwnd,HDC hdc,TREEVIEW_ITEM *wineItem,DWORD dwStyle,TREEVIEW_INFO *infoPtr) 652 { 673 653 INT center,xpos,cx,cy, cditem; 674 654 HFONT hOldFont; 675 655 UINT uTextJustify = DT_LEFT; 676 656 RECT r; 657 658 if (!wineItem->calculated) TREEVIEW_CalcItem(hwnd,hdc,dwStyle,infoPtr,wineItem); 677 659 678 660 if (wineItem->state & TVIS_BOLD) … … 742 724 } else 743 725 { 744 points[1].x = 8 + (20*wineItem->iLevel);726 points[1].x = 8+(20*wineItem->iLevel)-infoPtr->cx; 745 727 points[1].y = points[0].y = center; 746 728 points[0].x = points[1].x + 10; … … 764 746 */ 765 747 if (wineItem->iLevel != 0)/* update position only for non root node */ 766 xpos +=(5*wineItem->iLevel);767 768 if (( dwStyle & TVS_HASBUTTONS) && (dwStyle & TVS_HASLINES))748 xpos += 5*wineItem->iLevel; 749 750 if ((dwStyle & TVS_HASBUTTONS) && (dwStyle & TVS_HASLINES)) 769 751 { 770 752 if (TREEVIEW_HasChildren(hwnd, wineItem)) 771 753 { 772 /* Setup expand box coordinate to facilitate the LMBClick handling */773 wineItem->expandBox.left = xpos-4;774 wineItem->expandBox.top = center-4;775 wineItem->expandBox.right = xpos+5;776 wineItem->expandBox.bottom = center+5;777 778 754 Rectangle(hdc,wineItem->expandBox.left,wineItem->expandBox.top,wineItem->expandBox.right,wineItem->expandBox.bottom); 779 755 … … 804 780 if (infoPtr->himlState) 805 781 himlp=&infoPtr->himlState; 806 imageIndex=wineItem->state >>12;782 imageIndex=wineItem->state >> 12; 807 783 808 784 if ((himlp) && (imageIndex)) … … 810 786 imageIndex--; /* see FIXME */ 811 787 ImageList_Draw ( *himlp, imageIndex, hdc, xpos-2, r.top+1, ILD_NORMAL); 812 ImageList_GetIconSize (*himlp, &cx, &cy); 813 wineItem->statebitmap.left=xpos-2; 814 wineItem->statebitmap.right=xpos-2+cx; 815 wineItem->statebitmap.top=r.top+1; 816 wineItem->statebitmap.bottom=r.top+1+cy; 817 xpos += cx; 788 xpos += wineItem->statebitmap.right-wineItem->statebitmap.left; 818 789 } 819 790 … … 850 821 851 822 if(wineItem->stateMask & TVIS_OVERLAYMASK) 852 ovlIdx = wineItem->state & TVIS_OVERLAYMASK;823 ovlIdx = wineItem->state & TVIS_OVERLAYMASK; 853 824 854 825 ImageList_Draw ( *himlp, imageIndex, hdc, xpos-2, r.top+1, ILD_NORMAL|ovlIdx); 855 ImageList_GetIconSize (*himlp, &cx, &cy); 856 wineItem->bitmap.left=xpos-2; 857 wineItem->bitmap.right=xpos-2+cx; 858 wineItem->bitmap.top=r.top+1; 859 wineItem->bitmap.bottom=r.top+1+cy; 860 xpos += cx; 826 xpos += wineItem->bitmap.right-wineItem->bitmap.left; 861 827 } 862 828 } … … 878 844 r.left += 3; 879 845 r.right -= 3; 880 881 wineItem->text.left = r.left;882 wineItem->text.right = r.right;883 wineItem->text.top = r.top;884 wineItem->text.bottom= r.bottom;885 886 846 oldBkMode = SetBkMode(hdc, TRANSPARENT); 887 847 … … 919 879 } 920 880 921 if (wineItem->pszText== LPSTR_TEXTCALLBACKA) { 922 //TRACE("LPSTR_TEXTCALLBACK\n"); 881 if (wineItem->pszText == LPSTR_TEXTCALLBACKW) 923 882 TREEVIEW_SendDispInfoNotify (hwnd, wineItem, TVN_GETDISPINFO, TVIF_TEXT); 924 }925 926 /* Obtain the text coordinate */927 DrawTextA (928 hdc,929 wineItem->pszText,930 lstrlenA(wineItem->pszText),931 &wineItem->text,932 uTextJustify | DT_VCENTER | DT_SINGLELINE | DT_CALCRECT | DT_NOPREFIX);933 934 /* We need to reset it to items height */935 wineItem->text.top = r.top;936 wineItem->text.bottom = r.bottom;937 wineItem->text.right += 4; /* This is extra for focus rectangle */938 883 939 884 if (hbrBk) … … 946 891 947 892 /* Draw it */ 948 DrawText A( hdc,893 DrawTextW ( hdc, 949 894 wineItem->pszText, 950 lstrlen A(wineItem->pszText),895 lstrlenW(wineItem->pszText), 951 896 &wineItem->text, 952 uTextJustify | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX | DT_END_ELLIPSIS);953 954 wineItem->text.left -= 2;897 uTextJustify | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX); 898 899 wineItem->text.left -= 2; 955 900 956 901 /* Restore the hdc state */ … … 1035 980 LPRECT lpRect = (LPRECT)lParam; 1036 981 1037 // TRACE (treeview,"\n");1038 982 /* 1039 983 * validate parameters … … 1049 993 iItem = (HTREEITEM *) lParam; 1050 994 wineItem = TREEVIEW_ValidItem (infoPtr, *iItem); 1051 if ( (!wineItem) || (!wineItem->visible))995 if (!wineItem || !wineItem->visible) 1052 996 return FALSE; 1053 997 … … 1056 1000 * the whole item size 1057 1001 */ 1058 if ((INT) wParam) { 1059 lpRect->left = wineItem->text.left; 1060 lpRect->right = wineItem->text.right; 1061 lpRect->bottom = wineItem->text.bottom; 1062 lpRect->top = wineItem->text.top; 1063 } else { 1064 lpRect->left = wineItem->rect.left; 1065 lpRect->right = wineItem->rect.right; 1066 lpRect->bottom = wineItem->rect.bottom; 1067 lpRect->top = wineItem->rect.top; 1068 } 1069 1070 // TRACE (treeview,"[L:%d R:%d T:%d B:%d]\n", 1071 // lpRect->left,lpRect->right, 1072 // lpRect->top,lpRect->bottom); 1002 if (wParam) 1003 { 1004 lpRect->left = wineItem->text.left; 1005 lpRect->right = wineItem->text.right; 1006 lpRect->bottom = wineItem->text.bottom; 1007 lpRect->top = wineItem->text.top; 1008 } else 1009 { 1010 lpRect->left = wineItem->rect.left; 1011 lpRect->right = wineItem->rect.right; 1012 lpRect->bottom = wineItem->rect.bottom; 1013 lpRect->top = wineItem->rect.top; 1014 } 1073 1015 1074 1016 return TRUE; … … 1081 1023 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 1082 1024 1083 //CB: todo: that's the number of completely visible items 1084 1085 return (LRESULT) infoPtr->uVisibleHeight / infoPtr->uRealItemHeight; 1086 } 1087 1088 1089 1090 static LRESULT 1091 TREEVIEW_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) 1025 return (LRESULT)infoPtr->uVisibleHeight/infoPtr->uRealItemHeight; 1026 } 1027 1028 static LRESULT TREEVIEW_SetItem(HWND hwnd,WPARAM wParam,LPARAM lParam,BOOL unicode) 1092 1029 { 1093 1030 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 1094 1031 TREEVIEW_ITEM *wineItem; 1095 TVITEMEX A*tvItem;1032 TVITEMEXW *tvItem; 1096 1033 INT iItem,len; 1097 1034 1098 tvItem=(LPTVITEMEXA) lParam; 1099 iItem=(INT)tvItem->hItem; 1100 // TRACE (treeview,"item %d,mask %x\n",iItem,tvItem->mask); 1035 if (infoPtr->hwndEdit) SetFocus(hwnd); 1036 1037 tvItem = (LPTVITEMEXW)lParam; 1038 iItem = (INT)tvItem->hItem; 1101 1039 1102 1040 wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)iItem); 1103 1041 if (!wineItem) return FALSE; 1104 1042 1105 if (tvItem->mask & TVIF_CHILDREN) { 1106 wineItem->cChildren=tvItem->cChildren; 1107 } 1108 1109 if (tvItem->mask & TVIF_IMAGE) { 1110 wineItem->iImage=tvItem->iImage; 1111 } 1112 1113 if (tvItem->mask & TVIF_INTEGRAL) { 1114 wineItem->iIntegral=tvItem->iIntegral; 1115 } 1116 1117 if (tvItem->mask & TVIF_PARAM) { 1118 wineItem->lParam=tvItem->lParam; 1119 } 1120 1121 if (tvItem->mask & TVIF_SELECTEDIMAGE) { 1122 wineItem->iSelectedImage=tvItem->iSelectedImage; 1123 } 1124 1125 if (tvItem->mask & TVIF_STATE) { 1126 //TRACE ("prevstate,state,mask:%x,%x,%x\n",wineItem->state,tvItem->state, 1127 //tvItem->stateMask); 1128 wineItem->state&= ~tvItem->stateMask; 1129 wineItem->state|= (tvItem->state & tvItem->stateMask); 1130 wineItem->stateMask|= tvItem->stateMask; 1131 } 1132 1133 if (tvItem->mask & TVIF_TEXT) { 1134 if (tvItem->pszText!=LPSTR_TEXTCALLBACKA) { 1135 len=lstrlenA (tvItem->pszText) + 1; 1136 if (len>wineItem->cchTextMax) { 1137 wineItem->pszText= COMCTL32_ReAlloc (wineItem->pszText, len); 1138 wineItem->cchTextMax = len; 1043 if (tvItem->mask & TVIF_CHILDREN) 1044 wineItem->cChildren = tvItem->cChildren; 1045 1046 if (tvItem->mask & TVIF_IMAGE) 1047 wineItem->iImage = tvItem->iImage; 1048 1049 if (tvItem->mask & TVIF_INTEGRAL) 1050 wineItem->iIntegral = tvItem->iIntegral; 1051 1052 if (tvItem->mask & TVIF_PARAM) 1053 wineItem->lParam = tvItem->lParam; 1054 1055 if (tvItem->mask & TVIF_SELECTEDIMAGE) 1056 wineItem->iSelectedImage = tvItem->iSelectedImage; 1057 1058 if (tvItem->mask & TVIF_STATE) 1059 { 1060 wineItem->state &= ~tvItem->stateMask; 1061 wineItem->state |= (tvItem->state & tvItem->stateMask); 1062 wineItem->stateMask |= tvItem->stateMask; 1063 } 1064 1065 if (tvItem->mask & TVIF_TEXT) 1066 { 1067 if (unicode) 1068 { 1069 if (tvItem->pszText != LPSTR_TEXTCALLBACKW) 1070 { 1071 len = lstrlenW(tvItem->pszText)+1; 1072 if (len > wineItem->cchTextMax) 1073 { 1074 wineItem->pszText= COMCTL32_ReAlloc(wineItem->pszText,len*sizeof(WCHAR)); 1075 wineItem->cchTextMax = len; 1139 1076 } 1140 lstrcpynA (wineItem->pszText, tvItem->pszText,len); 1141 } else { 1142 if (wineItem->cchTextMax) { 1143 COMCTL32_Free (wineItem->pszText); 1144 wineItem->cchTextMax=0; 1145 } 1146 wineItem->pszText=LPSTR_TEXTCALLBACKA; 1147 } 1077 lstrcpynW(wineItem->pszText,tvItem->pszText,len); 1078 } else 1079 { 1080 if (wineItem->cchTextMax) 1081 { 1082 COMCTL32_Free (wineItem->pszText); 1083 wineItem->cchTextMax = 0; 1084 } 1085 wineItem->pszText = LPSTR_TEXTCALLBACKW; 1086 } 1087 } else 1088 { 1089 LPTVITEMEXA tvItem; 1090 1091 tvItem = (LPTVITEMEXA)lParam; 1092 1093 if (tvItem->pszText != LPSTR_TEXTCALLBACKA) 1094 { 1095 len = lstrlenA (tvItem->pszText) + 1; 1096 if (len > wineItem->cchTextMax) 1097 { 1098 wineItem->pszText = COMCTL32_ReAlloc(wineItem->pszText,len*sizeof(WCHAR)); 1099 wineItem->cchTextMax = len; 1100 } 1101 lstrcpynAtoW(wineItem->pszText,tvItem->pszText,len); 1102 } else 1103 { 1104 if (wineItem->cchTextMax) 1105 { 1106 COMCTL32_Free (wineItem->pszText); 1107 wineItem->cchTextMax = 0; 1108 } 1109 wineItem->pszText = LPSTR_TEXTCALLBACKW; 1110 } 1111 } 1148 1112 } 1149 1113 1150 1114 wineItem->mask |= tvItem->mask; 1115 wineItem->calculated = FALSE; 1116 TREEVIEW_QueueRefresh(hwnd); 1151 1117 1152 1118 return TRUE; … … 1168 1134 static void TREEVIEW_Refresh(HWND hwnd) 1169 1135 { 1136 TREEVIEW_UnqueueRefresh(hwnd,TRUE,FALSE); 1137 1170 1138 InvalidateRect(hwnd,NULL,TRUE); 1171 1139 } 1172 1140 1173 static void TREEVIEW_RefreshItem(HWND hwnd,TREEVIEW_ITEM *item )1141 static void TREEVIEW_RefreshItem(HWND hwnd,TREEVIEW_ITEM *item,BOOL wholeLine) 1174 1142 { 1175 1143 if (item && item->visible) … … 1177 1145 RECT rect = item->rect; 1178 1146 1179 rect.left += TREEVIEW_LEFT_MARGIN; 1180 if (item->iLevel != 0) rect.left += (5*item->iLevel); 1181 rect.left += 15; 1147 if (wholeLine) 1148 { 1149 RECT client; 1150 1151 GetClientRect(hwnd,&client); 1152 rect.left = 0; 1153 rect.right = client.right; 1154 } else 1155 { 1156 rect.left += TREEVIEW_LEFT_MARGIN; 1157 if (item->iLevel != 0) rect.left += (5*item->iLevel); 1158 rect.left += 15; 1159 } 1160 1182 1161 InvalidateRect(hwnd,&rect,TRUE); 1183 1162 } 1184 1163 } 1185 1164 1186 //CB: HDC parameter is optional 1187 1188 static void TREEVIEW_CalcItem(HWND hwnd,HDC hdc,TREEVIEW_ITEM *item) 1189 { 1165 //HDC parameter is optional 1166 1167 static void TREEVIEW_CalcItem(HWND hwnd,HDC hdc,DWORD dwStyle,TREEVIEW_INFO *infoPtr,TREEVIEW_ITEM *item) 1168 { 1169 RECT r; 1170 INT center,xpos; 1171 BOOL ownDC = FALSE; 1172 1190 1173 item->calculated = TRUE; 1191 //CB: todo: move calc code from TREEVIEW_DrawItem 1192 } 1193 1194 //CB: HDC parameter is optional 1195 1196 static void TREEVIEW_CalcItems(HWND hwnd,HDC hdc,TREEVIEW_INFO *infoPtr) 1174 1175 r = item->rect; /* this item rectangle */ 1176 center = (r.top+r.bottom)/2; /* this item vertical center */ 1177 xpos = r.left + TREEVIEW_LEFT_MARGIN;/* horizontal starting point */ 1178 1179 if (item->iLevel != 0)/* update position only for non root node */ 1180 xpos += 5*item->iLevel; 1181 1182 if ((dwStyle & TVS_HASBUTTONS) && (dwStyle & TVS_HASLINES)) 1183 { 1184 if (TREEVIEW_HasChildren(hwnd,item)) 1185 { 1186 /* Setup expand box coordinate to facilitate the LMBClick handling */ 1187 item->expandBox.left = xpos-4; 1188 item->expandBox.top = center-4; 1189 item->expandBox.right = xpos+5; 1190 item->expandBox.bottom = center+5; 1191 } else SetRectEmpty(&item->expandBox); 1192 } else SetRectEmpty(&item->expandBox); 1193 1194 xpos += 13; /* update position */ 1195 1196 if (item->mask & (TVIF_IMAGE | TVIF_SELECTEDIMAGE)) 1197 { 1198 INT imageIndex,cx,cy; 1199 HIMAGELIST *himlp = NULL; 1200 1201 /* State images are displayed to the left of the Normal image 1202 * image number is in state; zero should be `display no image'. 1203 * FIXME: that last sentence looks like it needs some checking. 1204 */ 1205 if (infoPtr->himlState) 1206 himlp = &infoPtr->himlState; 1207 imageIndex = item->state >> 12; 1208 1209 if (himlp && imageIndex) 1210 { 1211 if (!hdc) 1212 { 1213 ownDC = TRUE; 1214 hdc = GetDC(hwnd); 1215 } 1216 1217 imageIndex--; /* see FIXME */ 1218 ImageList_GetIconSize(*himlp,&cx,&cy); 1219 item->statebitmap.left = xpos-2; 1220 item->statebitmap.right = xpos-2+cx; 1221 item->statebitmap.top = r.top+1; 1222 item->statebitmap.bottom = r.top+1+cy; 1223 xpos += cx; 1224 } else SetRectEmpty(&item->statebitmap); 1225 1226 /* Now, draw the normal image; can be either selected or 1227 * non-selected image. 1228 */ 1229 1230 himlp = NULL; 1231 if (infoPtr->himlNormal) 1232 himlp = &infoPtr->himlNormal; /* get the image list */ 1233 1234 if (himlp) 1235 { 1236 int ovlIdx = 0; 1237 1238 if(item->stateMask & TVIS_OVERLAYMASK) 1239 ovlIdx = item->state & TVIS_OVERLAYMASK; 1240 1241 if (!hdc) 1242 { 1243 ownDC = TRUE; 1244 hdc = GetDC(hwnd); 1245 } 1246 1247 ImageList_GetIconSize(*himlp,&cx,&cy); 1248 item->bitmap.left = xpos-2; 1249 item->bitmap.right = xpos-2+cx; 1250 item->bitmap.top = r.top+1; 1251 item->bitmap.bottom = r.top+1+cy; 1252 xpos += cx; 1253 } else SetRectEmpty(&item->bitmap); 1254 } else 1255 { 1256 SetRectEmpty(&item->statebitmap); 1257 SetRectEmpty(&item->bitmap); 1258 } 1259 1260 r.left = xpos; 1261 if ((item->mask & TVIF_TEXT) && (item->pszText)) 1262 { 1263 UINT uTextJustify = DT_LEFT; 1264 HFONT hOldFont; 1265 1266 r.left += 3; 1267 r.right -= 3; 1268 1269 item->text.left = r.left; 1270 item->text.right = r.right; 1271 item->text.top = r.top; 1272 item->text.bottom= r.bottom; 1273 1274 if (item->pszText== LPSTR_TEXTCALLBACKW) 1275 { 1276 //TRACE("LPSTR_TEXTCALLBACK\n"); 1277 TREEVIEW_SendDispInfoNotify (hwnd, item, TVN_GETDISPINFO, TVIF_TEXT); 1278 } 1279 1280 if (!hdc) 1281 { 1282 ownDC = TRUE; 1283 hdc = GetDC(hwnd); 1284 } 1285 1286 if (item->state & TVIS_BOLD) 1287 hOldFont = SelectObject (hdc, infoPtr->hBoldFont); 1288 else 1289 hOldFont = SelectObject (hdc, infoPtr->hFont); 1290 1291 /* Obtain the text coordinate */ 1292 DrawTextW ( 1293 hdc, 1294 item->pszText, 1295 lstrlenW(item->pszText), 1296 &item->text, 1297 uTextJustify | DT_VCENTER | DT_SINGLELINE | DT_CALCRECT | DT_NOPREFIX); 1298 1299 SelectObject(hdc,hOldFont); 1300 1301 /* We need to reset it to items height */ 1302 item->text.top = r.top; 1303 item->text.bottom = r.bottom; 1304 item->text.right += 4; /* This is extra for focus rectangle */ 1305 1306 xpos = item->text.right; 1307 } else SetRectEmpty(&item->text); 1308 1309 item->rect.right = xpos; 1310 1311 if (ownDC) ReleaseDC(hwnd,hdc); 1312 } 1313 1314 //HDC parameter is optional 1315 1316 static BOOL TREEVIEW_CalcItems(HWND hwnd,HDC hdc,TREEVIEW_INFO *infoPtr) 1197 1317 { 1198 1318 TREEVIEW_ITEM *item; 1199 INT iItem, indent,x,y,height,itemHeight ,itemWidth;1319 INT iItem, indent,x,y,height,itemHeight; 1200 1320 TEXTMETRICA tm; 1201 1321 RECT rect,view; 1202 BOOL ownDC = FALSE ;1322 BOOL ownDC = FALSE,changedLeftTop = FALSE; 1203 1323 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 1204 1324 … … 1222 1342 itemHeight = MAX(tm.tmHeight+tm.tmExternalLeading,itemHeight); 1223 1343 infoPtr->uRealItemHeight = itemHeight; 1344 infoPtr->uTotalWidth = 0; 1224 1345 1225 1346 iItem = (INT)infoPtr->TopRootItem; … … 1235 1356 height = itemHeight * item->iIntegral +1; 1236 1357 1237 item->rect.top = y-infoPtr->cy;1238 item->rect.bottom = item->rect.top+height;1239 item->rect.left = x-infoPtr->cx;1240 item->rect.right = rect.right;1241 1242 1358 //calculate size and fill rects 1243 1359 if ((infoPtr->uInternalStatus & TV_CALCALL) || !item->calculated) 1244 TREEVIEW_CalcItem(hwnd,hdc,item); 1245 1246 itemWidth = MAX(itemWidth,item->rect.right-item->rect.left); 1247 1248 if ((((y >= view.top) && (y <= view.bottom)) || ((y+height >= view.top) && (y+height <= view.bottom))) && 1249 (x >= view.left) && (x <= view.right)) 1360 { 1361 item->rect.top = y-infoPtr->cy; 1362 item->rect.bottom = item->rect.top+height; 1363 item->rect.left = x-infoPtr->cx; 1364 item->rect.right = rect.right; 1365 TREEVIEW_CalcItem(hwnd,hdc,dwStyle,infoPtr,item); 1366 } else 1367 { 1368 INT xOffset,yOffset; 1369 1370 xOffset = (x-infoPtr->cx)-item->rect.left; 1371 yOffset = (y-infoPtr->cy)-item->rect.top; 1372 OffsetRect(&item->rect,xOffset,yOffset); 1373 OffsetRect(&item->text,xOffset,yOffset); 1374 OffsetRect(&item->expandBox,xOffset,yOffset); 1375 OffsetRect(&item->bitmap,xOffset,yOffset); 1376 OffsetRect(&item->statebitmap,xOffset,yOffset); 1377 } 1378 infoPtr->uTotalWidth = MAX(infoPtr->uTotalWidth,item->rect.right+infoPtr->cx); 1379 1380 if (((y >= view.top) && (y <= view.bottom)) || ((y+height >= view.top) && (y+height <= view.bottom))) 1250 1381 { 1251 1382 item->visible = TRUE; … … 1261 1392 indent++; 1262 1393 x += infoPtr->uIndent; 1263 infoPtr->uTotalWidth = MAX(infoPtr->uTotalWidth,itemWidth+x);1264 1394 } else 1265 1395 { … … 1273 1403 } 1274 1404 } 1275 y += height;1405 y += height; 1276 1406 } /* while */ 1277 1407 … … 1279 1409 1280 1410 infoPtr->uInternalStatus &= ~TV_CALCALL; 1281 1282 1411 infoPtr->uTotalHeight = y; 1283 infoPtr->uTotalWidth = 0; //CB: not yet ready 1412 1413 if (item && item->visible) 1414 { 1415 INT xDiff = 0,yDiff = 0; 1416 1417 //check cx and cy 1418 #if 0 //CB: next step 1419 if ((infoPtr->cy > 0) && (item->rect.bottom < infoPtr->uVisibleHeight)) 1420 { 1421 INT oldCY = infoPtr->cy; 1422 1423 infoPtr->cy = infoPtr->uTotalHeight-infoPtr->uVisibleHeight; 1424 if (infoPtr->cy < 0) infoPtr->cy = 0; 1425 yDiff = infoPtr->cy-oldCY; 1426 } 1427 1428 changedLeftTop = xDiff || yDiff; 1429 if (changedLeftTop) 1430 { 1431 iItem = (INT)infoPtr->TopRootItem; 1432 item = NULL; 1433 indent = 0; 1434 MessageBeep(MB_OK); 1435 while (iItem) 1436 { 1437 item = &infoPtr->items[iItem]; 1438 OffsetRect(&item->rect,xDiff,yDiff); 1439 OffsetRect(&item->text,xDiff,yDiff); 1440 OffsetRect(&item->expandBox,xDiff,yDiff); 1441 OffsetRect(&item->bitmap,xDiff,yDiff); 1442 OffsetRect(&item->statebitmap,xDiff,yDiff); 1443 1444 1445 if ((item->firstChild) && (item->state & TVIS_EXPANDED)) 1446 { 1447 iItem = (INT)item->firstChild; 1448 indent++; 1449 } else 1450 { 1451 iItem = (INT)item->sibling; 1452 while ((!iItem) && (indent > 0)) 1453 { 1454 indent--; 1455 item = &infoPtr->items[(INT)item->parent]; 1456 iItem = (INT)item->sibling; 1457 } 1458 } 1459 } /* while */ 1460 } 1461 #endif 1462 } 1284 1463 1285 1464 if (!(dwStyle & TVS_NOSCROLL)) 1286 1465 { 1287 if (infoPtr->uTotalHeight > =infoPtr->uVisibleHeight)1466 if (infoPtr->uTotalHeight > infoPtr->uVisibleHeight) 1288 1467 { 1289 1468 SCROLLINFO info; … … 1303 1482 infoPtr->uInternalStatus &= ~TV_VSCROLL; 1304 1483 } 1305 if (!(dwStyle & TVS_NOHSCROLL) && (infoPtr->uTotalWidth > =infoPtr->uVisibleWidth))1484 if (!(dwStyle & TVS_NOHSCROLL) && (infoPtr->uTotalWidth > infoPtr->uVisibleWidth)) 1306 1485 { 1307 1486 SCROLLINFO info; … … 1327 1506 infoPtr->uInternalStatus &= ~(TV_VSCROLL | TV_HSCROLL); 1328 1507 } 1508 1509 return changedLeftTop; 1329 1510 } 1330 1511 … … 1333 1514 { 1334 1515 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 1516 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 1335 1517 HBRUSH hbrBk; 1336 1518 RECT rect; … … 1369 1551 if (updateRect && IntersectRect(NULL,&item->rect,updateRect)) 1370 1552 { 1371 TREEVIEW_DrawItem(hwnd,hdc,item );1553 TREEVIEW_DrawItem(hwnd,hdc,item,dwStyle,infoPtr); 1372 1554 visFound = TRUE; 1373 1555 } 1374 1556 } else if (visFound) break; 1375 if (!visFound )1557 if (!visFound && (dwStyle & TVS_HASLINES) && (dwStyle & TVS_LINESATROOT)) 1376 1558 { 1377 1559 //draw vertical connections … … 1380 1562 SelectObject(hdc,hOldPen); 1381 1563 } 1382 if ( (item->firstChild)&& (item->state & TVIS_EXPANDED))1564 if (item->firstChild && (item->state & TVIS_EXPANDED)) 1383 1565 { 1384 1566 iItem = (INT)item->firstChild; … … 1387 1569 { 1388 1570 iItem = (INT)item->sibling; 1389 while ( (!iItem)&& (indent > 0))1571 while (!iItem && (indent > 0)) 1390 1572 { 1391 1573 item = &infoPtr->items[(INT)item->parent]; … … 1440 1622 infoPtr->Timer &= ~TV_EDIT_TIMER_SET; 1441 1623 if (infoPtr->editItem) 1442 TREEVIEW_EditLabel A(hwnd, infoPtr->editItem);1624 TREEVIEW_EditLabel(hwnd,infoPtr->editItem,TRUE); 1443 1625 return 0; 1444 1626 default: … … 1469 1651 } 1470 1652 1471 static voidTREEVIEW_UnqueueRefresh(HWND hwnd,BOOL calc,BOOL refresh)1653 static BOOL TREEVIEW_UnqueueRefresh(HWND hwnd,BOOL calc,BOOL refresh) 1472 1654 { 1473 1655 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); … … 1479 1661 if (calc) TREEVIEW_CalcItems(hwnd,0,infoPtr); 1480 1662 if (refresh) TREEVIEW_Refresh(hwnd); 1481 } 1482 } 1483 1484 static LRESULT 1485 TREEVIEW_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) 1486 { 1487 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 1488 LPTVITEMEXA tvItem; 1663 1664 return TRUE; 1665 } 1666 1667 return FALSE; 1668 } 1669 1670 static LRESULT 1671 TREEVIEW_GetItem(HWND hwnd,WPARAM wParam,LPARAM lParam,BOOL unicode) 1672 { 1673 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 1674 LPTVITEMEXW tvItem; 1489 1675 TREEVIEW_ITEM *wineItem; 1490 1676 INT iItem; 1491 1677 1492 tvItem =(LPTVITEMEXA)lParam;1493 iItem =(INT)tvItem->hItem;1678 tvItem = (LPTVITEMEXW)lParam; 1679 iItem = (INT)tvItem->hItem; 1494 1680 1495 1681 wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)iItem); 1496 1682 if (!wineItem) return FALSE; 1497 1683 1498 if (tvItem->mask & TVIF_CHILDREN) { 1499 tvItem->cChildren = TREEVIEW_HasChildren(hwnd, wineItem); 1500 } 1501 1502 if (tvItem->mask & TVIF_HANDLE) { 1503 tvItem->hItem=wineItem->hItem; 1504 } 1505 1506 if (tvItem->mask & TVIF_IMAGE) { 1507 tvItem->iImage=wineItem->iImage; 1508 } 1509 1510 if (tvItem->mask & TVIF_INTEGRAL) { 1511 tvItem->iIntegral=wineItem->iIntegral; 1512 } 1513 1514 // undocumented: windows ignores TVIF_PARAM and 1515 // always sets lParam 1516 tvItem->lParam=wineItem->lParam; 1517 1518 if (tvItem->mask & TVIF_SELECTEDIMAGE) { 1519 tvItem->iSelectedImage=wineItem->iSelectedImage; 1520 } 1521 1522 if (tvItem->mask & TVIF_STATE) { 1523 tvItem->state=wineItem->state & tvItem->stateMask; 1524 } 1525 1526 if (tvItem->mask & TVIF_TEXT) { 1527 if (wineItem->pszText == LPSTR_TEXTCALLBACKA) { 1528 tvItem->pszText = LPSTR_TEXTCALLBACKA; /* FIXME:send notification? */ 1529 // ERR (treeview," GetItem called with LPSTR_TEXTCALLBACK\n"); 1530 } 1531 else if (wineItem->pszText) { 1532 lstrcpynA (tvItem->pszText, wineItem->pszText,tvItem->cchTextMax); 1533 } 1534 } 1535 1536 // TRACE(treeview,"item %d<%p>, txt %p, img %p, action %x\n", 1537 // iItem, 1538 // tvItem, 1539 // tvItem->pszText, 1540 // & tvItem->iImage, 1541 // tvItem->mask); 1684 if (tvItem->mask & TVIF_CHILDREN) 1685 tvItem->cChildren = TREEVIEW_HasChildren(hwnd, wineItem); 1686 1687 if (tvItem->mask & TVIF_HANDLE) 1688 tvItem->hItem=wineItem->hItem; 1689 1690 if (tvItem->mask & TVIF_IMAGE) 1691 tvItem->iImage=wineItem->iImage; 1692 1693 if (tvItem->mask & TVIF_INTEGRAL) 1694 tvItem->iIntegral=wineItem->iIntegral; 1695 1696 // undocumented: windows ignores TVIF_PARAM and 1697 // always sets lParam 1698 tvItem->lParam = wineItem->lParam; 1699 1700 if (tvItem->mask & TVIF_SELECTEDIMAGE) 1701 tvItem->iSelectedImage=wineItem->iSelectedImage; 1702 1703 if (tvItem->mask & TVIF_STATE) 1704 tvItem->state=wineItem->state & tvItem->stateMask; 1705 1706 if (tvItem->mask & TVIF_TEXT) 1707 { 1708 if (wineItem->pszText == LPSTR_TEXTCALLBACKW) 1709 TREEVIEW_SendDispInfoNotify(hwnd,wineItem,TVN_GETDISPINFO,TVIF_TEXT); 1710 if (unicode) 1711 { 1712 if (wineItem->pszText == LPSTR_TEXTCALLBACKW) 1713 tvItem->pszText = LPSTR_TEXTCALLBACKW; 1714 else if (wineItem->pszText) 1715 lstrcpynW(tvItem->pszText,wineItem->pszText,tvItem->cchTextMax); 1716 } else 1717 { 1718 LPTVITEMEXA tvItem = (LPTVITEMEXA)lParam; 1719 1720 if (wineItem->pszText == LPSTR_TEXTCALLBACKW) 1721 tvItem->pszText = LPSTR_TEXTCALLBACKA; 1722 else if (wineItem->pszText) 1723 lstrcpynWtoA(tvItem->pszText, wineItem->pszText,tvItem->cchTextMax); 1724 } 1725 } 1542 1726 1543 1727 return TRUE; … … 1558 1742 flag = (INT) wParam; 1559 1743 iItem = (INT) lParam; 1560 retval=0; 1561 switch (flag) { 1562 case TVGN_CHILD: /* Special case: child of 0 is root */ 1563 if (iItem) break; 1564 case TVGN_ROOT: retval=(INT)infoPtr->TopRootItem; 1565 break; 1566 case TVGN_CARET:retval=(INT)infoPtr->selectedItem; 1567 break; 1568 case TVGN_FIRSTVISIBLE: 1569 TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE); 1570 retval = (INT)infoPtr->firstVisible; 1571 break; 1572 case TVGN_DROPHILITE: 1573 retval=(INT)infoPtr->dropItem; 1574 break; 1575 } 1576 if (retval) { 1577 // TRACE (treeview,"flags:%x, returns %u\n", flag, retval); 1578 return retval; 1579 } 1744 retval = 0; 1745 switch (flag) 1746 { 1747 case TVGN_CHILD: /* Special case: child of 0 is root */ 1748 if (iItem) break; 1749 1750 case TVGN_ROOT: 1751 retval = (INT)infoPtr->TopRootItem; 1752 break; 1753 1754 case TVGN_CARET: 1755 retval = (INT)infoPtr->selectedItem; 1756 break; 1757 1758 case TVGN_FIRSTVISIBLE: 1759 TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE); 1760 retval = (INT)infoPtr->firstVisible; 1761 break; 1762 1763 case TVGN_DROPHILITE: 1764 retval = (INT)infoPtr->dropItem; 1765 break; 1766 } 1767 1768 if (retval) return retval; 1580 1769 1581 1770 wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)iItem); … … 1583 1772 if (!wineItem) return FALSE; 1584 1773 1585 switch (flag) { 1586 case TVGN_NEXT: retval=(INT)wineItem->sibling; 1587 break; 1588 case TVGN_PREVIOUS: 1589 retval=(INT)wineItem->upsibling; 1590 break; 1591 case TVGN_PARENT: 1592 retval=(INT)wineItem->parent; 1593 break; 1594 case TVGN_CHILD: 1595 retval=(INT)wineItem->firstChild; 1596 break; 1597 case TVGN_LASTVISIBLE: 1598 returnItem=TREEVIEW_GetLastListItem (hwnd,infoPtr,wineItem); 1599 break; 1600 case TVGN_NEXTVISIBLE: 1601 returnItem=TREEVIEW_GetNextListItem (hwnd,infoPtr,wineItem); 1602 break; 1603 case TVGN_PREVIOUSVISIBLE: 1604 returnItem=TREEVIEW_GetPrevListItem (hwnd,infoPtr, wineItem); 1605 break; 1606 default: // FIXME (treeview,"Unknown msg %x,item %x\n", flag,iItem); 1607 break; 1608 } 1609 1610 if (returnItem) { 1611 // TRACE (treeview,"flags:%x, item %d;returns %d\n", flag, iItem, 1612 // (INT)returnItem->hItem); 1613 return (INT)returnItem->hItem; 1614 } 1615 1616 // TRACE (treeview,"flags:%x, item %d;returns %d\n", flag, iItem,retval); 1774 switch (flag) 1775 { 1776 case TVGN_NEXT: 1777 retval = (INT)wineItem->sibling; 1778 break; 1779 1780 case TVGN_PREVIOUS: 1781 retval = (INT)wineItem->upsibling; 1782 break; 1783 1784 case TVGN_PARENT: 1785 retval = (INT)wineItem->parent; 1786 break; 1787 1788 case TVGN_CHILD: 1789 retval = (INT)wineItem->firstChild; 1790 break; 1791 1792 case TVGN_LASTVISIBLE: 1793 returnItem = TREEVIEW_GetLastListItem (hwnd,infoPtr,wineItem); 1794 break; 1795 1796 case TVGN_NEXTVISIBLE: 1797 returnItem = TREEVIEW_GetNextListItem (hwnd,infoPtr,wineItem); 1798 break; 1799 1800 case TVGN_PREVIOUSVISIBLE: 1801 returnItem = TREEVIEW_GetPrevListItem (hwnd,infoPtr, wineItem); 1802 break; 1803 1804 default: 1805 break; 1806 } 1807 1808 if (returnItem) return (INT)returnItem->hItem; 1809 1617 1810 return retval; 1618 1811 } … … 1622 1815 TREEVIEW_GetCount (HWND hwnd, WPARAM wParam, LPARAM lParam) 1623 1816 { 1624 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 1625 1626 // TRACE (treeview," %d\n",infoPtr->uNumItems); 1627 return (LRESULT) infoPtr->uNumItems; 1817 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 1818 1819 return (LRESULT) infoPtr->uNumItems; 1628 1820 } 1629 1821 … … 1754 1946 { 1755 1947 HWND hwnd=(HWND) tvInfoPtr; 1756 char*txt1, *txt2;1948 WCHAR *txt1, *txt2; 1757 1949 TREEVIEW_ITEM *item; 1758 1950 1759 1951 1760 1952 item=(TREEVIEW_ITEM *) first; 1761 if (item->pszText ==LPSTR_TEXTCALLBACKA) {1953 if (item->pszText == LPSTR_TEXTCALLBACKW) { 1762 1954 TREEVIEW_SendDispInfoNotify (hwnd, item, TVN_GETDISPINFO, TVIF_TEXT); 1763 1955 } … … 1765 1957 1766 1958 item=(TREEVIEW_ITEM *) second; 1767 if (item->pszText ==LPSTR_TEXTCALLBACKA) {1959 if (item->pszText == LPSTR_TEXTCALLBACKW) { 1768 1960 TREEVIEW_SendDispInfoNotify (hwnd, item, TVN_GETDISPINFO, TVIF_TEXT); 1769 1961 } 1770 1962 txt2=item->pszText; 1771 1963 1772 return - strcmp(txt1,txt2);1964 return -lstrcmpW(txt1,txt2); 1773 1965 } 1774 1966 … … 1799 1991 infoPtr->pCallBackSort = pSort; 1800 1992 1801 1993 /* undocumented feature: TVI_ROOT means `sort the whole tree' */ 1802 1994 1803 1995 if (parent==TVI_ROOT) … … 1905 2097 ) 1906 2098 { 1907 LPTVSORTCB pSort=(LPTVSORTCB) lParam;1908 1909 return TREEVIEW_Sort (hwnd, wParam, pSort->hParent, pSort);2099 LPTVSORTCB pSort=(LPTVSORTCB) lParam; 2100 2101 return TREEVIEW_Sort (hwnd, wParam, pSort->hParent, pSort); 1910 2102 } 1911 2103 … … 1919 2111 LPARAM lParam) 1920 2112 { 1921 return TREEVIEW_Sort (hwnd, (BOOL) wParam, (HTREEITEM) lParam, NULL);2113 return TREEVIEW_Sort (hwnd, (BOOL) wParam, (HTREEITEM) lParam, NULL); 1922 2114 } 1923 2115 … … 1940 2132 1941 2133 static LRESULT 1942 TREEVIEW_InsertItem A (HWND hwnd, WPARAM wParam, LPARAM lParam)1943 1944 { 1945 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 1946 TVINSERTSTRUCT A*ptdi;1947 TVITEMEX A*tvItem;2134 TREEVIEW_InsertItem(HWND hwnd,WPARAM wParam,LPARAM lParam,BOOL unicode) 2135 2136 { 2137 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 2138 TVINSERTSTRUCTW *ptdi; 2139 TVITEMEXW *tvItem; 1948 2140 TREEVIEW_ITEM *wineItem, *parentItem, *prevsib, *sibItem; 1949 2141 INT iItem,i,len; 1950 2142 2143 if (infoPtr->hwndEdit) SetFocus(hwnd); 2144 1951 2145 /* Item to insert */ 1952 ptdi = (LPTVINSERTSTRUCT A)lParam;1953 1954 2146 ptdi = (LPTVINSERTSTRUCTW)lParam; 2147 2148 /* check if memory is available */ 1955 2149 1956 2150 if (infoPtr->uNumPtrsAlloced==0) { … … 2038 2232 * when the insertion are ordered 2039 2233 */ 2040 if (tvItem->pszText!=LPSTR_TEXTCALLBACKA) 2041 { 2042 //TRACE (treeview,"(%p,%s)\n", &tvItem->pszText, tvItem->pszText); 2043 len = lstrlenA (tvItem->pszText)+1; 2044 wineItem->pszText= COMCTL32_Alloc (len); 2045 lstrcpyA (wineItem->pszText, tvItem->pszText); 2046 wineItem->cchTextMax=len; 2047 } 2048 else 2049 { 2050 //TRACE (treeview,"LPSTR_TEXTCALLBACK\n"); 2051 wineItem->pszText = LPSTR_TEXTCALLBACKA; 2052 wineItem->cchTextMax = 0; 2234 if (unicode) 2235 { 2236 if (tvItem->pszText != LPSTR_TEXTCALLBACKW) 2237 { 2238 //TRACE (treeview,"(%p,%s)\n", &tvItem->pszText, tvItem->pszText); 2239 len = lstrlenW(tvItem->pszText)+1; 2240 wineItem->pszText = COMCTL32_Alloc(len*sizeof(WCHAR)); 2241 lstrcpyW (wineItem->pszText, tvItem->pszText); 2242 wineItem->cchTextMax = len; 2243 } else 2244 { 2245 //TRACE (treeview,"LPSTR_TEXTCALLBACK\n"); 2246 wineItem->pszText = LPSTR_TEXTCALLBACKW; 2247 wineItem->cchTextMax = 0; 2248 } 2249 } else 2250 { 2251 TVITEMEXA *tvItemA = (LPTVITEMEXA)tvItem; 2252 2253 if (tvItemA->pszText != LPSTR_TEXTCALLBACKA) 2254 { 2255 //TRACE (treeview,"(%p,%s)\n", &tvItem->pszText, tvItem->pszText); 2256 len = lstrlenA(tvItemA->pszText)+1; 2257 wineItem->pszText= COMCTL32_Alloc (len*sizeof(WCHAR)); 2258 lstrcpyAtoW (wineItem->pszText, tvItemA->pszText); 2259 wineItem->cchTextMax = len; 2260 } else 2261 { 2262 //TRACE (treeview,"LPSTR_TEXTCALLBACK\n"); 2263 wineItem->pszText = LPSTR_TEXTCALLBACKW; 2264 wineItem->cchTextMax = 0; 2265 } 2053 2266 } 2054 2267 } … … 2091 2304 2092 2305 /* lookup the text if using LPSTR_TEXTCALLBACKs */ 2093 if (wineItem->pszText==LPSTR_TEXTCALLBACK A) {2306 if (wineItem->pszText==LPSTR_TEXTCALLBACKW) { 2094 2307 TREEVIEW_SendDispInfoNotify (hwnd, wineItem, TVN_GETDISPINFO, TVIF_TEXT); 2095 2308 } … … 2101 2314 2102 2315 /* lookup the text if using LPSTR_TEXTCALLBACKs */ 2103 if (aChild->pszText==LPSTR_TEXTCALLBACK A) {2316 if (aChild->pszText==LPSTR_TEXTCALLBACKW) { 2104 2317 TREEVIEW_SendDispInfoNotify (hwnd, aChild, TVN_GETDISPINFO, TVIF_TEXT); 2105 2318 } 2106 2319 2107 comp = strcmp(wineItem->pszText, aChild->pszText);2320 comp = lstrcmpW(wineItem->pszText, aChild->pszText); 2108 2321 if ( comp < 0 ) /* we are smaller than the current one */ 2109 2322 { … … 2215 2428 2216 2429 static LRESULT 2217 TREEVIEW_InsertItemW(HWND hwnd, WPARAM wParam, LPARAM lParam)2218 {2219 TVINSERTSTRUCTW *tvisW;2220 TVINSERTSTRUCTA tvisA;2221 LRESULT lRes;2222 2223 tvisW = (LPTVINSERTSTRUCTW)lParam;2224 2225 tvisA.hParent = tvisW->hParent;2226 tvisA.hInsertAfter = tvisW->hInsertAfter;2227 2228 tvisA.DUMMYUNIONNAME.item.mask = tvisW->DUMMYUNIONNAME.item.mask;2229 tvisA.DUMMYUNIONNAME.item.hItem = tvisW->DUMMYUNIONNAME.item.hItem;2230 tvisA.DUMMYUNIONNAME.item.state = tvisW->DUMMYUNIONNAME.item.state;2231 tvisA.DUMMYUNIONNAME.item.stateMask = tvisW->DUMMYUNIONNAME.item.stateMask;2232 tvisA.DUMMYUNIONNAME.item.cchTextMax = tvisW->DUMMYUNIONNAME.item.cchTextMax;2233 2234 if(tvisW->DUMMYUNIONNAME.item.pszText)2235 {2236 if (tvisW->DUMMYUNIONNAME.item.pszText!=LPSTR_TEXTCALLBACKW)2237 {2238 int len = lstrlenW (tvisW->DUMMYUNIONNAME.item.pszText)+1;2239 tvisA.DUMMYUNIONNAME.item.pszText = COMCTL32_Alloc (len);2240 lstrcpyWtoA (tvisA.DUMMYUNIONNAME.item.pszText,2241 tvisW->DUMMYUNIONNAME.item.pszText );2242 }2243 else2244 {2245 tvisA.DUMMYUNIONNAME.item.pszText = LPSTR_TEXTCALLBACKA;2246 tvisA.DUMMYUNIONNAME.item.cchTextMax = 0;2247 }2248 }2249 2250 tvisA.DUMMYUNIONNAME.item.iImage = tvisW->DUMMYUNIONNAME.item.iImage;2251 tvisA.DUMMYUNIONNAME.item.iSelectedImage = tvisW->DUMMYUNIONNAME.item.iSelectedImage;2252 tvisA.DUMMYUNIONNAME.item.cChildren = tvisW->DUMMYUNIONNAME.item.cChildren;2253 tvisA.DUMMYUNIONNAME.item.lParam = tvisW->DUMMYUNIONNAME.item.lParam;2254 2255 lRes = TREEVIEW_InsertItemA(hwnd,wParam,(LPARAM)&tvisA);2256 2257 if (tvisA.DUMMYUNIONNAME.item.pszText!=LPSTR_TEXTCALLBACKA)2258 {2259 COMCTL32_Free(tvisA.DUMMYUNIONNAME.item.pszText);2260 }2261 2262 return lRes;2263 2264 }2265 2266 2267 static LRESULT2268 2430 TREEVIEW_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam) 2269 2431 { … … 2272 2434 TREEVIEW_ITEM *wineItem; 2273 2435 2274 // TRACE (treeview,"\n"); 2275 2276 if (lParam == (INT)TVI_ROOT) {2277 TREEVIEW_RemoveTree (hwnd);2278 } else{2279 iItem= (INT)lParam;2280 2281 2282 // TRACE (treeview,"%s\n",wineItem->pszText); 2283 2436 if (lParam == (INT)TVI_ROOT) 2437 { 2438 TREEVIEW_RemoveTree (hwnd); 2439 } else 2440 { 2441 iItem = (INT)lParam; 2442 wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)iItem); 2443 if (!wineItem) return FALSE; 2444 2445 TREEVIEW_RemoveItem (hwnd, wineItem); 2284 2446 } 2285 2447 … … 2294 2456 TREEVIEW_GetIndent (HWND hwnd) 2295 2457 { 2458 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 2459 2460 return infoPtr->uIndent; 2461 } 2462 2463 static LRESULT 2464 TREEVIEW_SetIndent (HWND hwnd, WPARAM wParam) 2465 { 2466 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 2467 INT newIndent; 2468 2469 newIndent = (INT)wParam; 2470 if (newIndent < MINIMUM_INDENT) newIndent = MINIMUM_INDENT; 2471 if (newIndent != infoPtr->uIndent) 2472 { 2473 infoPtr->uIndent=newIndent; 2474 infoPtr->uInternalStatus |= TV_CALCALL; 2475 TREEVIEW_QueueRefresh(hwnd); 2476 } 2477 2478 return 0; 2479 } 2480 2481 static LRESULT 2482 TREEVIEW_GetToolTips (HWND hwnd) 2483 2484 { 2296 2485 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 2297 2486 2298 // TRACE (treeview,"\n");2299 return infoPtr->uIndent;2300 }2301 2302 static LRESULT2303 TREEVIEW_SetIndent (HWND hwnd, WPARAM wParam)2304 {2305 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);2306 INT newIndent;2307 2308 // TRACE (treeview,"\n");2309 newIndent=(INT) wParam;2310 if (newIndent < MINIMUM_INDENT) newIndent=MINIMUM_INDENT;2311 infoPtr->uIndent=newIndent;2312 2313 return 0;2314 }2315 2316 static LRESULT2317 TREEVIEW_GetToolTips (HWND hwnd)2318 2319 {2320 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);2321 2322 // TRACE (treeview,"\n");2323 2487 return infoPtr->hwndToolTip; 2324 2488 } … … 2332 2496 HWND prevToolTip; 2333 2497 2334 // TRACE (treeview,"\n");2335 2498 prevToolTip=infoPtr->hwndToolTip; 2336 2499 infoPtr->hwndToolTip= (HWND) wParam; … … 2342 2505 static LRESULT CALLBACK 2343 2506 TREEVIEW_GetEditControl (HWND hwnd) 2344 2345 { 2346 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 2347 2348 return infoPtr->hwndEdit; 2507 { 2508 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 2509 2510 return infoPtr->hwndEdit; 2349 2511 } 2350 2512 … … 2366 2528 LRESULT rc; 2367 2529 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(GetParent(hwnd)); 2368 TRACE("WM_PAINT start\n");2530 //TRACE("WM_PAINT start\n"); 2369 2531 rc = CallWindowProcA( infoPtr->wpEditOrig, hwnd, uMsg, wParam, lParam); 2370 TRACE("WM_PAINT done\n");2532 //TRACE("WM_PAINT done\n"); 2371 2533 return rc; 2372 2534 } … … 2479 2641 static LRESULT 2480 2642 TREEVIEW_Size (HWND hwnd, WPARAM wParam, LPARAM lParam) 2481 2482 { 2483 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 2484 2485 if (infoPtr->bAutoSize) 2486 { 2487 infoPtr->bAutoSize = FALSE; 2488 return 0; 2489 } 2490 infoPtr->bAutoSize = TRUE; 2643 { 2644 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 2491 2645 2492 2646 if (wParam == SIZE_RESTORED) 2493 2647 { 2494 TREEVIEW_UnqueueRefresh(hwnd,FALSE,FALSE); 2495 TREEVIEW_CalcItems(hwnd,0,infoPtr); 2496 TREEVIEW_Refresh(hwnd); 2648 if (TREEVIEW_CalcItems(hwnd,0,infoPtr)) 2649 TREEVIEW_Refresh(hwnd); 2497 2650 } 2498 2651 … … 2542 2695 2543 2696 /* set default settings */ 2544 infoPtr->uInternalStatus =0;2697 infoPtr->uInternalStatus = 0; 2545 2698 infoPtr->uNumItems=0; 2546 2699 infoPtr->clrBk = GetSysColor (COLOR_WINDOW); … … 2669 2822 { 2670 2823 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 2824 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 2671 2825 2672 2826 TREEVIEW_SendSimpleNotify (hwnd, NM_SETFOCUS); 2673 2827 2674 if (infoPtr->selectedItem) TREEVIEW_RefreshItem(hwnd,TREEVIEW_ValidItem(infoPtr,infoPtr->selectedItem)); 2828 if (!(dwStyle & TVS_SHOWSELALWAYS) && infoPtr->selectedItem) 2829 TREEVIEW_RefreshItem(hwnd,TREEVIEW_ValidItem(infoPtr,infoPtr->selectedItem),FALSE); 2675 2830 2676 2831 return 0; … … 2681 2836 { 2682 2837 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 2838 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 2683 2839 2684 2840 TREEVIEW_SendSimpleNotify (hwnd, NM_KILLFOCUS); 2685 2841 2686 if (infoPtr->selectedItem) TREEVIEW_RefreshItem(hwnd,TREEVIEW_ValidItem(infoPtr,infoPtr->selectedItem)); 2842 if (!(dwStyle & TVS_SHOWSELALWAYS) && infoPtr->selectedItem) 2843 TREEVIEW_RefreshItem(hwnd,TREEVIEW_ValidItem(infoPtr,infoPtr->selectedItem),FALSE); 2687 2844 2688 2845 return 0; … … 2710 2867 NMHDR nmhdr; 2711 2868 2712 // TRACE (treeview, "%x\n",code);2713 2869 nmhdr.hwndFrom = hwnd; 2714 2870 nmhdr.idFrom = GetWindowLongA( hwnd, GWL_ID); … … 2725 2881 { 2726 2882 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 2727 NMTREEVIEW Anmhdr;2883 NMTREEVIEWW nmhdr; 2728 2884 TREEVIEW_ITEM *wineItem; 2885 HWND parent = GetParent(hwnd); 2886 BOOL unicode = IsWindowUnicode(parent),rc; 2887 CHAR *oldText = NULL,*newText = NULL; 2729 2888 2730 2889 // TRACE (treeview,"code:%x action:%x olditem:%x newitem:%x\n", 2731 2890 // code,action,(INT)oldItem,(INT)newItem); 2732 2891 2733 ZeroMemory(&nmhdr, sizeof(NMTREEVIEWA));2892 ZeroMemory(&nmhdr,sizeof(NMTREEVIEWW)); 2734 2893 2735 2894 nmhdr.hdr.hwndFrom = hwnd; 2736 nmhdr.hdr.idFrom = GetWindowLong A( hwnd, GWL_ID);2895 nmhdr.hdr.idFrom = GetWindowLongW( hwnd, GWL_ID); 2737 2896 nmhdr.hdr.code = code; 2738 2897 nmhdr.action = action; 2739 if (oldItem) { 2740 wineItem=& infoPtr->items[(INT)oldItem]; 2741 nmhdr.itemOld.mask = wineItem->mask; 2742 nmhdr.itemOld.hItem = wineItem->hItem; 2743 nmhdr.itemOld.state = wineItem->state; 2744 nmhdr.itemOld.stateMask = wineItem->stateMask; 2745 nmhdr.itemOld.iImage = wineItem->iImage; 2746 nmhdr.itemOld.pszText = wineItem->pszText; 2747 nmhdr.itemOld.cchTextMax= wineItem->cchTextMax; 2748 nmhdr.itemOld.iImage = wineItem->iImage; 2749 nmhdr.itemOld.iSelectedImage = wineItem->iSelectedImage; 2750 nmhdr.itemOld.cChildren = wineItem->cChildren; 2751 nmhdr.itemOld.lParam = wineItem->lParam; 2752 } 2753 2754 if (newItem) { 2755 wineItem=& infoPtr->items[(INT)newItem]; 2756 nmhdr.itemNew.mask = wineItem->mask; 2757 nmhdr.itemNew.hItem = wineItem->hItem; 2758 nmhdr.itemNew.state = wineItem->state; 2759 nmhdr.itemNew.stateMask = wineItem->stateMask; 2760 nmhdr.itemNew.iImage = wineItem->iImage; 2761 nmhdr.itemNew.pszText = wineItem->pszText; 2762 nmhdr.itemNew.cchTextMax= wineItem->cchTextMax; 2763 nmhdr.itemNew.iImage = wineItem->iImage; 2764 nmhdr.itemNew.iSelectedImage = wineItem->iSelectedImage; 2765 nmhdr.itemNew.cChildren = wineItem->cChildren; 2766 nmhdr.itemNew.lParam = wineItem->lParam; 2898 if (oldItem) 2899 { 2900 wineItem=& infoPtr->items[(INT)oldItem]; 2901 nmhdr.itemOld.mask = wineItem->mask; 2902 nmhdr.itemOld.hItem = wineItem->hItem; 2903 nmhdr.itemOld.state = wineItem->state; 2904 nmhdr.itemOld.stateMask = wineItem->stateMask; 2905 nmhdr.itemOld.iImage = wineItem->iImage; 2906 if (!unicode) 2907 { 2908 if (!wineItem->pszText) nmhdr.itemOld.pszText = NULL; else 2909 { 2910 INT len = lstrlenW(wineItem->pszText)+1; 2911 2912 oldText = COMCTL32_Alloc(len); 2913 lstrcpyWtoA(oldText,wineItem->pszText); 2914 nmhdr.itemOld.pszText = (WCHAR*)oldText; 2915 } 2916 } else nmhdr.itemOld.pszText = wineItem->pszText; 2917 nmhdr.itemOld.cchTextMax= wineItem->cchTextMax; 2918 nmhdr.itemOld.iImage = wineItem->iImage; 2919 nmhdr.itemOld.iSelectedImage = wineItem->iSelectedImage; 2920 nmhdr.itemOld.cChildren = wineItem->cChildren; 2921 nmhdr.itemOld.lParam = wineItem->lParam; 2922 } 2923 2924 if (newItem) 2925 { 2926 wineItem=& infoPtr->items[(INT)newItem]; 2927 nmhdr.itemNew.mask = wineItem->mask; 2928 nmhdr.itemNew.hItem = wineItem->hItem; 2929 nmhdr.itemNew.state = wineItem->state; 2930 nmhdr.itemNew.stateMask = wineItem->stateMask; 2931 nmhdr.itemNew.iImage = wineItem->iImage; 2932 if (!unicode) 2933 { 2934 if (!wineItem->pszText) nmhdr.itemOld.pszText = NULL; else 2935 { 2936 INT len = lstrlenW(wineItem->pszText)+1; 2937 2938 newText = COMCTL32_Alloc(len); 2939 lstrcpyWtoA(newText,wineItem->pszText); 2940 nmhdr.itemOld.pszText = (WCHAR*)newText; 2941 } 2942 } else nmhdr.itemNew.pszText = wineItem->pszText; 2943 nmhdr.itemNew.cchTextMax= wineItem->cchTextMax; 2944 nmhdr.itemNew.iImage = wineItem->iImage; 2945 nmhdr.itemNew.iSelectedImage = wineItem->iSelectedImage; 2946 nmhdr.itemNew.cChildren = wineItem->cChildren; 2947 nmhdr.itemNew.lParam = wineItem->lParam; 2767 2948 } 2768 2949 … … 2770 2951 nmhdr.ptDrag.y = 0; 2771 2952 2772 return (BOOL)SendMessageA (GetParent (hwnd), WM_NOTIFY, 2773 (WPARAM) GetWindowLongA( hwnd, GWL_ID), (LPARAM)&nmhdr); 2774 2953 if (unicode) 2954 rc = (BOOL)SendMessageW(parent,WM_NOTIFY,(WPARAM)GetWindowLongW(hwnd,GWL_ID),(LPARAM)&nmhdr); 2955 else 2956 rc = (BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)GetWindowLongA(hwnd,GWL_ID),(LPARAM)&nmhdr); 2957 2958 if (oldText) COMCTL32_Free(oldText); 2959 if (newText) COMCTL32_Free(newText); 2960 2961 return rc; 2775 2962 } 2776 2963 … … 2803 2990 } 2804 2991 2805 2806 2807 2992 static BOOL 2808 2993 TREEVIEW_SendDispInfoNotify (HWND hwnd, TREEVIEW_ITEM *wineItem, UINT code, UINT what) 2809 2994 { 2810 NMTVDISPINFO Atvdi;2995 NMTVDISPINFOW tvdi; 2811 2996 BOOL retval; 2812 char *buf; 2813 2814 // TRACE (treeview,"item %d, action %x, state %d\n", 2815 // (INT)wineItem->hItem, 2816 // what, 2817 // (INT)wineItem->state); 2997 WCHAR *buf; 2998 HWND parent = GetParent(hwnd); 2999 BOOL unicode = IsWindowUnicode(parent); 2818 3000 2819 3001 tvdi.hdr.hwndFrom = hwnd; 2820 tvdi.hdr.idFrom = 3002 tvdi.hdr.idFrom = GetWindowLongA( hwnd, GWL_ID); 2821 3003 tvdi.hdr.code = code; 2822 3004 tvdi.item.mask = what; … … 2824 3006 tvdi.item.state = wineItem->state; 2825 3007 tvdi.item.lParam = wineItem->lParam; 2826 tvdi.item.pszText = COMCTL32_Alloc (128*sizeof(char));3008 tvdi.item.pszText = COMCTL32_Alloc(128*(unicode? sizeof(WCHAR):sizeof(char))); 2827 3009 tvdi.item.cchTextMax = 128; 2828 3010 buf = tvdi.item.pszText; 2829 3011 2830 retval=(BOOL)SendMessageA ( 2831 GetParent(hwnd), 2832 WM_NOTIFY, 2833 (WPARAM)tvdi.hdr.idFrom, 2834 (LPARAM)&tvdi); 3012 if (unicode) 3013 retval = (BOOL)SendMessageW(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi); 3014 else 3015 retval = (BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi); 2835 3016 2836 3017 /* Ignore posible changes */ … … 2838 3019 return retval; 2839 3020 2840 if (what & TVIF_TEXT) { 2841 wineItem->pszText = tvdi.item.pszText; 2842 if (buf==tvdi.item.pszText) { 2843 wineItem->cchTextMax = 128; 2844 } else { 2845 // TRACE (treeview,"user-supplied buffer\n"); 2846 COMCTL32_Free (buf); 2847 wineItem->cchTextMax = 0; 2848 } 2849 } 3021 if (what & TVIF_TEXT) 3022 { 3023 if (unicode) 3024 { 3025 wineItem->pszText = tvdi.item.pszText; 3026 if (buf == tvdi.item.pszText) 3027 { 3028 wineItem->cchTextMax = 128; 3029 } else 3030 { 3031 //TRACE (treeview,"user-supplied buffer\n"); 3032 COMCTL32_Free(buf); 3033 wineItem->cchTextMax = 0; 3034 } 3035 } else 3036 { 3037 if (buf == tvdi.item.pszText) 3038 { 3039 COMCTL32_Free(wineItem->pszText); 3040 wineItem->cchTextMax = 128; 3041 wineItem->pszText = COMCTL32_Alloc(128*sizeof(WCHAR)); 3042 lstrcpynAtoW(wineItem->pszText,(CHAR*)tvdi.item.pszText,wineItem->cchTextMax); 3043 COMCTL32_Free(buf); 3044 } else 3045 { 3046 //TRACE (treeview,"user-supplied buffer\n"); 3047 COMCTL32_Free(buf); 3048 wineItem->cchTextMax = 0; 3049 } 3050 } 3051 } 3052 2850 3053 if (what & TVIF_SELECTEDIMAGE) 2851 3054 wineItem->iSelectedImage = tvdi.item.iSelectedImage; … … 2857 3060 return retval; 2858 3061 } 2859 2860 2861 3062 2862 3063 static BOOL … … 2889 3090 return (BOOL)SendMessageA (GetParent (hwnd), WM_NOTIFY, 2890 3091 (WPARAM) GetWindowLongA( hwnd, GWL_ID), (LPARAM)&nmcdhdr); 2891 2892 } 2893 2894 3092 } 2895 3093 2896 3094 /* FIXME: need to find out when the flags in uItemState need to be set */ … … 2947 3145 } 2948 3146 2949 3147 static VOID TREEVIEW_SendKeyDownNotify(HWND hwnd,UINT code,WORD wVKey) 3148 { 3149 NMTVKEYDOWN nmkdhdr; 3150 3151 nmkdhdr.hdr.hwndFrom = hwnd; 3152 nmkdhdr.hdr.idFrom = GetWindowLongA( hwnd, GWL_ID); 3153 nmkdhdr.hdr.code = code; 3154 nmkdhdr.wVKey = wVKey; 3155 nmkdhdr.flags = 0; 3156 3157 SendMessageA(GetParent(hwnd),WM_NOTIFY,(WPARAM)nmkdhdr.hdr.idFrom,(LPARAM)&nmkdhdr); 3158 } 2950 3159 2951 3160 /* Note:If the specified item is the child of a collapsed parent item, … … 2963 3172 INT expand; 2964 3173 2965 flag = (UINT) 2966 expand = (INT) 3174 flag = (UINT)wParam; 3175 expand = (INT)lParam; 2967 3176 2968 3177 wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)expand); … … 2974 3183 return 0; 2975 3184 2976 // TRACE (treeview,"For (%s) flags:%x item:%d state:%d\n", 2977 // wineItem->pszText, 2978 // flag, 2979 // expand, 2980 // wineItem->state); 2981 2982 if (flag == TVE_TOGGLE) { /* FIXME: check exact behaviour here */ 2983 flag &= ~TVE_TOGGLE; /* ie: bitwise ops or 'case' ops */ 2984 if (wineItem->state & TVIS_EXPANDED) 2985 flag |= TVE_COLLAPSE; 2986 else 2987 flag |= TVE_EXPAND; 2988 } 2989 2990 switch (flag) 2991 { 2992 case TVE_COLLAPSERESET: 2993 if (!wineItem->state & TVIS_EXPANDED) 2994 return 0; 2995 2996 wineItem->state &= ~(TVIS_EXPANDEDONCE | TVIS_EXPANDED); 2997 TREEVIEW_RemoveAllChildren (hwnd, wineItem); 2998 break; 2999 3185 if ((flag & 0xF) == TVE_TOGGLE) 3186 { 3187 if (wineItem->state & TVIS_EXPANDED) 3188 flag = (flag & ~0xF)+TVE_COLLAPSE; 3189 else 3190 flag = (flag & ~0xF)+TVE_EXPAND; 3191 } 3192 3193 switch (flag & 0xF) 3194 { 3000 3195 case TVE_COLLAPSE: 3001 3196 if (!wineItem->state & TVIS_EXPANDED) 3002 3197 return 0; 3003 3198 3004 wineItem->state &= ~TVIS_EXPANDED; 3199 if (flag & TVE_COLLAPSERESET) 3200 { 3201 wineItem->state &= ~(TVIS_EXPANDEDONCE | TVIS_EXPANDED); 3202 TREEVIEW_RemoveAllChildren (hwnd, wineItem); 3203 } else wineItem->state &= ~TVIS_EXPANDED; 3005 3204 break; 3006 3205 … … 3009 3208 return 0; 3010 3209 3210 if (flag & TVE_EXPANDPARTIAL) 3211 { 3212 //TRACE(treeview, " case TVE_EXPANDPARTIAL\n"); 3213 //FIXME (treeview, "TVE_EXPANDPARTIAL not implemented\n"); 3214 return FALSE; //CB: to check 3215 wineItem->state ^=TVIS_EXPANDED; 3216 wineItem->state |=TVIS_EXPANDEDONCE; 3217 break; 3218 } 3219 3011 3220 if (!(wineItem->state & TVIS_EXPANDEDONCE)) 3012 3221 { … … 3015 3224 3016 3225 /* this item has never been expanded */ 3017 if (TREEVIEW_SendTreeviewNotify ( 3018 hwnd, 3019 TVN_ITEMEXPANDING, 3020 TVE_EXPAND, 3021 0, 3022 (HTREEITEM)expand)) 3023 { 3024 //TRACE(treeview, " TVN_ITEMEXPANDING returned TRUE, exiting...\n"); 3226 if (TREEVIEW_SendTreeviewNotify(hwnd,TVN_ITEMEXPANDING,TVE_EXPAND,0,(HTREEITEM)expand)) 3025 3227 return FALSE; 3026 } 3228 3027 3229 3028 3230 /* FIXME … … 3035 3237 */ 3036 3238 wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)expand); 3037 if (! 3239 if (!wineItem) 3038 3240 { 3039 3241 //ERR(treeview, … … 3055 3257 //TRACE(treeview, " TVN_ITEMEXPANDED sent...\n"); 3056 3258 3057 } 3058 else 3259 } else 3059 3260 { 3060 3261 /* this item has already been expanded */ … … 3062 3263 } 3063 3264 break; 3064 3065 case TVE_EXPANDPARTIAL: 3066 //TRACE(treeview, " case TVE_EXPANDPARTIAL\n"); 3067 //FIXME (treeview, "TVE_EXPANDPARTIAL not implemented\n"); 3068 wineItem->state ^=TVIS_EXPANDED; 3069 wineItem->state |=TVIS_EXPANDEDONCE; 3070 break; 3071 } 3072 3073 //TRACE(treeview, "Exiting, Item %d state is now %d...\n", 3074 // expand, 3075 // wineItem->state); 3265 default: 3266 return FALSE; 3267 } 3076 3268 3077 3269 //CB: todo: optimize! … … 3081 3273 TREEVIEW_CalcItems(hwnd,0,infoPtr); 3082 3274 TREEVIEW_Refresh(hwnd); 3275 //CB: todo: check cx and cy to fit ranges! 3083 3276 3084 3277 return TRUE; 3085 3278 } 3086 3279 3087 3088 3089 static TREEVIEW_ITEM * 3090 TREEVIEW_HitTestPoint (HWND hwnd, POINT pt) 3091 { 3092 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 3093 TREEVIEW_ITEM *wineItem; 3094 RECT rect; 3095 3096 GetClientRect (hwnd, &rect); 3097 3098 if (!infoPtr->firstVisible) return NULL; 3099 3100 wineItem=&infoPtr->items [(INT)infoPtr->firstVisible]; 3101 3102 while ((wineItem!=NULL) && (pt.y > wineItem->rect.bottom)) 3103 wineItem=TREEVIEW_GetNextListItem (hwnd,infoPtr,wineItem); 3104 3105 if (!wineItem) 3106 return NULL; 3107 3108 return wineItem; 3109 } 3110 3111 static LRESULT 3112 TREEVIEW_HitTest (HWND hwnd, LPARAM lParam) 3113 { 3114 LPTVHITTESTINFO lpht=(LPTVHITTESTINFO) lParam; 3280 static LRESULT TREEVIEW_HitTest(HWND hwnd,LPTVHITTESTINFO lpht) 3281 { 3282 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 3115 3283 TREEVIEW_ITEM *wineItem; 3116 3284 RECT rect; 3117 3285 UINT status,x,y; 3118 3286 3119 lpht->hItem =0;3287 if (!lpht) return 0; 3120 3288 GetClientRect (hwnd, &rect); 3121 status=0; 3122 x=lpht->pt.x; 3123 y=lpht->pt.y; 3124 if (x < rect.left) status|=TVHT_TOLEFT; 3125 if (x > rect.right) status|=TVHT_TORIGHT; 3126 if (y < rect.top ) status|=TVHT_ABOVE; 3127 if (y > rect.bottom) status|=TVHT_BELOW; 3128 3129 if (status) { 3130 lpht->flags=status; 3289 status = 0; 3290 x = lpht->pt.x; 3291 y = lpht->pt.y; 3292 if (x < rect.left) status |= TVHT_TOLEFT; 3293 if (x > rect.right) status |= TVHT_TORIGHT; 3294 if (y < rect.top ) status |= TVHT_ABOVE; 3295 if (y > rect.bottom) status |= TVHT_BELOW; 3296 3297 if (status) 3298 { 3299 lpht->flags = status; 3300 lpht->hItem = 0; 3301 3131 3302 return 0; 3132 3303 } 3133 3304 3134 wineItem=TREEVIEW_HitTestPoint (hwnd, lpht->pt); 3135 if (!wineItem) { 3136 lpht->flags=TVHT_NOWHERE; 3305 if (infoPtr->firstVisible) 3306 { 3307 wineItem = &infoPtr->items [(INT)infoPtr->firstVisible]; 3308 3309 while ((wineItem != NULL) && (y > wineItem->rect.bottom)) 3310 wineItem = TREEVIEW_GetNextListItem(hwnd,infoPtr,wineItem); 3311 } else wineItem = NULL; 3312 3313 if (!wineItem) 3314 { 3315 lpht->flags = TVHT_NOWHERE; 3316 lpht->hItem = 0; 3317 3137 3318 return 0; 3138 3319 } … … 3165 3346 3166 3347 done: 3167 lpht->hItem =wineItem->hItem;3348 lpht->hItem = wineItem->hItem; 3168 3349 //TRACE ("(%ld,%ld):result %x\n",lpht->pt.x,lpht->pt.y,lpht->flags); 3169 3350 … … 3171 3352 } 3172 3353 3173 HWND TREEVIEW_EditLabel A(HWND hwnd, HTREEITEM hItem)3354 HWND TREEVIEW_EditLabel(HWND hwnd,HTREEITEM hItem,BOOL unicode) 3174 3355 { 3175 3356 SIZE sz; … … 3177 3358 TREEVIEW_ITEM *editItem = TREEVIEW_ValidItem(infoPtr, (HTREEITEM)hItem); 3178 3359 HINSTANCE hinst = GetWindowLongA(hwnd, GWL_HINSTANCE); 3179 3180 3360 HDC hdc; 3181 HFONT hOldFont =0;3361 HFONT hOldFont = 0; 3182 3362 TEXTMETRICA textMetric; 3183 3363 3184 3364 //TRACE("%d %d\n",(INT)hwnd, (INT)hItem); 3185 3186 3365 if (!editItem) 3366 return FALSE; 3187 3367 3188 3368 if(infoPtr->hwndEdit) … … 3190 3370 3191 3371 /* Make shure that edit item is selected */ 3372 3192 3373 TREEVIEW_DoSelectItem ( hwnd, TVGN_CARET, hItem, TVC_UNKNOWN); 3193 //CB: todo: necessary? 3194 TREEVIEW_Refresh(hwnd); 3195 3196 if (editItem->pszText== LPSTR_TEXTCALLBACKA) 3374 3375 if (editItem->pszText == LPSTR_TEXTCALLBACKW) 3197 3376 TREEVIEW_SendDispInfoNotify (hwnd, editItem, TVN_GETDISPINFO, TVIF_TEXT); 3198 3377 … … 3205 3384 3206 3385 /*Get String Lenght in pixels */ 3207 GetTextExtentPoint32 A(hdc, editItem->pszText, strlen(editItem->pszText), &sz);3386 GetTextExtentPoint32W(hdc, editItem->pszText, lstrlenW(editItem->pszText), &sz); 3208 3387 3209 3388 /*Add Extra spacing for the next character */ … … 3239 3418 DestroyWindow(infoPtr->hwndEdit); 3240 3419 infoPtr->hwndEdit = 0; 3420 3241 3421 return (HWND)0; 3242 3422 } 3243 3423 3244 3424 infoPtr->editItem = hItem; 3245 SetWindowText A(infoPtr->hwndEdit, editItem->pszText);3425 SetWindowTextW(infoPtr->hwndEdit, editItem->pszText); 3246 3426 SetFocus(infoPtr->hwndEdit); 3247 3427 SendMessageA(infoPtr->hwndEdit, EM_SETSEL, 0, -1); … … 3257 3437 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 3258 3438 TREEVIEW_ITEM *editedItem = TREEVIEW_ValidItem (infoPtr, infoPtr->editItem); 3259 NMTVDISPINFOA tvdi; 3439 NMTVDISPINFOW tvdi; 3440 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 3441 HWND parent = GetParent(hwnd); 3442 BOOL unicode = IsWindowUnicode(parent); 3260 3443 BOOL bCommit; 3261 char tmpText[1024] = { '\0' }; 3444 WCHAR *textW = NULL; 3445 CHAR *textA = NULL; 3262 3446 int iLength = 0; 3263 3447 … … 3275 3459 if (!bCancel) 3276 3460 { 3277 iLength = GetWindowTextA(infoPtr->hwndEdit, tmpText, 1023); 3461 textW = COMCTL32_Alloc(1024*sizeof(WCHAR)); 3462 iLength = GetWindowTextW(infoPtr->hwndEdit,textW,1023); 3278 3463 3279 3464 //if (iLength >= 1023) … … 3282 3467 //} 3283 3468 3284 tvdi.item.pszText = tmpText; 3469 if (unicode) tvdi.item.pszText = textW; else 3470 { 3471 INT len = iLength+1; 3472 3473 textA = COMCTL32_Alloc(len); 3474 lstrcpynWtoA(textA,textW,len); 3475 tvdi.item.pszText = (WCHAR*)textA; 3476 } 3285 3477 tvdi.item.cchTextMax = iLength + 1; 3286 3478 } … … 3291 3483 } 3292 3484 3293 bCommit=(BOOL)SendMessageA ( 3294 GetParent(hwnd), 3295 WM_NOTIFY, 3296 (WPARAM)tvdi.hdr.idFrom, 3297 (LPARAM)&tvdi); 3485 if (unicode) 3486 bCommit=(BOOL)SendMessageW(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi); 3487 else 3488 bCommit=(BOOL)SendMessageA(parent,WM_NOTIFY,(WPARAM)tvdi.hdr.idFrom,(LPARAM)&tvdi); 3298 3489 3299 3490 if (!bCancel && bCommit) /* Apply the changes */ 3300 3491 { 3301 if (strcmp( tmpText, editedItem->pszText ) != 0) 3302 { 3303 if(NULL == COMCTL32_ReAlloc(editedItem->pszText, iLength+1 )) 3304 { 3305 //ERR("OutOfMemory, cannot allocate space for label"); 3306 DestroyWindow(infoPtr->hwndEdit); 3307 infoPtr->hwndEdit = 0; 3308 return FALSE; 3309 } 3310 else 3311 { 3312 editedItem->cchTextMax = iLength + 1; 3313 lstrcpyA( editedItem->pszText, tmpText); 3314 } 3492 if (!unicode) 3493 lstrcpynAtoW(textW,textA,iLength+1); 3494 if (lstrcmpW(textW,editedItem->pszText) != 0) 3495 { 3496 if(NULL == COMCTL32_ReAlloc(editedItem->pszText,(iLength+1)*sizeof(WCHAR))) 3497 { 3498 //ERR("OutOfMemory, cannot allocate space for label"); 3499 DestroyWindow(infoPtr->hwndEdit); 3500 infoPtr->hwndEdit = 0; 3501 if (textA) COMCTL32_Free(textA); 3502 if (textW) COMCTL32_Free(textW); 3503 3504 return FALSE; 3315 3505 } 3506 else 3507 { 3508 editedItem->cchTextMax = iLength + 1; 3509 lstrcpyW( editedItem->pszText,textW); 3510 } 3511 } 3316 3512 } 3317 3513 … … 3320 3516 infoPtr->hwndEdit = 0; 3321 3517 infoPtr->editItem = 0; 3518 if (textA) COMCTL32_Free(textA); 3519 if (textW) COMCTL32_Free(textW); 3520 3521 editedItem->calculated = FALSE; 3522 TREEVIEW_CalcItem(hwnd,0,dwStyle,infoPtr,editedItem); 3523 TREEVIEW_RefreshItem(hwnd,editedItem,TRUE); 3322 3524 3323 3525 return TRUE; … … 3381 3583 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 3382 3584 TREEVIEW_ITEM *wineItem; 3383 POINT pt;3384 3385 pt.x = (INT)LOWORD(lParam);3386 pt.y = (INT)HIWORD(lParam);3585 TV_HITTESTINFO hitinfo; 3586 3587 hitinfo.pt.x = (INT)LOWORD(lParam); 3588 hitinfo.pt.y = (INT)HIWORD(lParam); 3387 3589 SetFocus (hwnd); 3388 3590 … … 3394 3596 } 3395 3597 3396 wineItem=TREEVIEW_HitTestPoint (hwnd, pt);3397 if (!wineItem) return 0;3598 if (!TREEVIEW_HitTest(hwnd,&hitinfo) || !(hitinfo.flags & TVHT_ONITEM)) return FALSE; 3599 wineItem = &infoPtr->items [(INT)hitinfo.hItem]; 3398 3600 3399 3601 if (TREEVIEW_SendSimpleNotify (hwnd, NM_DBLCLK)!=TRUE) { /* FIXME!*/ … … 3426 3628 ht.pt.y = (INT)HIWORD(lParam); 3427 3629 3428 TREEVIEW_HitTest (hwnd, (LPARAM)&ht);3630 TREEVIEW_HitTest (hwnd,&ht); 3429 3631 //TRACE("item %d \n", (INT)ht.hItem); 3430 3632 … … 3513 3715 ht.pt.y = (INT)HIWORD(lParam); 3514 3716 3515 TREEVIEW_HitTest (hwnd, (LPARAM)&ht);3717 TREEVIEW_HitTest(hwnd,&ht); 3516 3718 3517 3719 if (TREEVIEW_TrackMouse(hwnd, ht.pt)) … … 3544 3746 RECT rc; 3545 3747 HFONT hOldFont; 3546 char*itemtxt;3748 WCHAR *itemtxt; 3547 3749 3548 3750 // TRACE (treeview,"\n"); … … 3552 3754 if (!dragItem) return 0; 3553 3755 3554 if (dragItem->pszText==LPSTR_TEXTCALLBACK A) {3756 if (dragItem->pszText==LPSTR_TEXTCALLBACKW) { 3555 3757 TREEVIEW_SendDispInfoNotify (hwnd, dragItem, TVN_GETDISPINFO, TVIF_TEXT); 3556 3758 } … … 3562 3764 3563 3765 hOldFont=SelectObject (hdc, infoPtr->hFont); 3564 GetTextExtentPoint32 A (hdc, itemtxt, lstrlenA(itemtxt), &size);3766 GetTextExtentPoint32W (hdc, itemtxt, lstrlenW (itemtxt), &size); 3565 3767 // TRACE (treeview,"%d %d %s %d\n",size.cx,size.cy,itemtxt,lstrlenA(itemtxt)); 3566 3768 hbmp=CreateCompatibleBitmap (htopdc, size.cx, size.cy); … … 3582 3784 3583 3785 SetRect (&rc, cx, 0, size.cx,size.cy); 3584 DrawText A (hdc, itemtxt, lstrlenA(itemtxt), &rc, DT_LEFT);3786 DrawTextW (hdc, itemtxt, lstrlenW (itemtxt), &rc, DT_LEFT); 3585 3787 SelectObject (hdc, hOldFont); 3586 3788 SelectObject (hdc, hOldbmp); … … 3598 3800 static LRESULT 3599 3801 TREEVIEW_DoSelectItem (HWND hwnd, INT action, HTREEITEM newSelect, INT cause) 3600 3601 3802 { 3602 3803 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); … … 3606 3807 wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)newSelect); 3607 3808 3608 // TRACE (treeview,"Entering item %d, flag %x, cause %x, state %d\n", 3609 // (INT)newSelect, 3610 // action, 3611 // cause, 3612 // wineItem->state); 3613 3614 if ( (wineItem) && (wineItem->parent)) 3615 { 3809 if (wineItem && wineItem->parent) 3810 { 3811 TREEVIEW_ITEM *parent = TREEVIEW_ValidItem(infoPtr,wineItem->parent); 3812 3616 3813 /* 3617 3814 * If the item has a collapse parent expand the parent so he 3618 3815 * can expose the item 3619 3816 */ 3620 TREEVIEW_ITEM *parentItem = TREEVIEW_ValidItem (infoPtr, wineItem->parent); 3621 3622 if (!(parentItem->state & TVIS_EXPANDED)) 3623 TREEVIEW_Expand (hwnd, TVE_EXPAND, (LPARAM) wineItem->parent); 3817 while (parent && !(parent->state & TVIS_EXPANDED)) 3818 { 3819 TREEVIEW_Expand(hwnd,TVE_EXPAND,(LPARAM)parent); 3820 parent = TREEVIEW_ValidItem(infoPtr,parent->parent); 3821 } 3624 3822 } 3625 3823 … … 3627 3825 { 3628 3826 case TVGN_CARET: 3629 prevSelect =(INT)infoPtr->selectedItem;3630 3631 if ((HTREEITEM)prevSelect ==newSelect)3827 prevSelect = (INT)infoPtr->selectedItem; 3828 3829 if ((HTREEITEM)prevSelect == newSelect) 3632 3830 return FALSE; 3633 3831 … … 3651 3849 3652 3850 TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE); 3653 TREEVIEW_RefreshItem(hwnd,prevItem );3654 TREEVIEW_RefreshItem(hwnd,wineItem );3851 TREEVIEW_RefreshItem(hwnd,prevItem,FALSE); 3852 TREEVIEW_RefreshItem(hwnd,wineItem,FALSE); 3655 3853 3656 3854 TREEVIEW_SendTreeviewNotify( … … 3669 3867 prevItem->state &= ~TVIS_DROPHILITED; 3670 3868 3671 infoPtr->dropItem =(HTREEITEM)newSelect;3869 infoPtr->dropItem = (HTREEITEM)newSelect; 3672 3870 3673 3871 if (wineItem) … … 3675 3873 3676 3874 TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE); 3677 TREEVIEW_RefreshItem(hwnd,prevItem );3678 TREEVIEW_RefreshItem(hwnd,wineItem );3875 TREEVIEW_RefreshItem(hwnd,prevItem,FALSE); 3876 TREEVIEW_RefreshItem(hwnd,wineItem,FALSE); 3679 3877 3680 3878 break; 3681 3879 3682 3880 case TVGN_FIRSTVISIBLE: 3683 // FIXME (treeview, "FIRSTVISIBLE not implemented\n"); 3881 { 3882 INT scrollY; 3883 3884 if (wineItem->rect.top < 0) 3885 scrollY = wineItem->rect.top; 3886 else 3887 { 3888 scrollY = MIN(wineItem->rect.top,infoPtr->uTotalHeight-infoPtr->uVisibleHeight); 3889 if (scrollY < 0) scrollY = 0; 3890 } 3891 3892 if (scrollY != 0) 3893 { 3894 infoPtr->cy += scrollY; 3895 if (!TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE)) 3896 TREEVIEW_CalcItems(hwnd,0,infoPtr); 3897 3898 ScrollWindowEx(hwnd,0,-scrollY,NULL,NULL,0,NULL,SW_INVALIDATE); 3899 } 3900 3684 3901 break; 3902 } 3685 3903 } 3686 3904 3687 // TRACE (treeview,"Leaving state %d\n", wineItem->state);3688 3905 return TRUE; 3689 3906 } 3690 3907 3691 /* FIXME: handle NM_KILLFocus enzo */3692 3908 static LRESULT 3693 3909 TREEVIEW_SelectItem (HWND hwnd, WPARAM wParam, LPARAM lParam) 3694 3695 3910 { 3696 3911 return TREEVIEW_DoSelectItem (hwnd, wParam, (HTREEITEM) lParam, TVC_UNKNOWN); 3697 3912 } 3698 3913 3699 3700 3701 3702 3914 static LRESULT 3703 3915 TREEVIEW_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam) 3704 3705 3916 { 3706 3917 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); … … 3712 3923 static LRESULT 3713 3924 TREEVIEW_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam) 3714 3715 3925 { 3716 3926 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); … … 3758 3968 int lastPos = infoPtr->cy; 3759 3969 3760 // TRACE (treeview,"wp %x, lp %lx\n", wParam, lParam);3761 3970 if (!infoPtr->uInternalStatus & TV_VSCROLL) return FALSE; 3762 3971 … … 3797 4006 if (lastPos != infoPtr->cy) 3798 4007 { 3799 TREEVIEW_CalcItems(hwnd,0,infoPtr); 4008 if (!TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE)) 4009 TREEVIEW_CalcItems(hwnd,0,infoPtr); 3800 4010 ScrollWindowEx(hwnd,0,lastPos-infoPtr->cy,NULL,NULL,0,NULL,SW_INVALIDATE); 3801 4011 } … … 3811 4021 int lastPos = infoPtr->cx; 3812 4022 3813 //TRACE (treeview,"wp %lx, lp %x\n", lParam, wParam);4023 //TRACE (treeview,"wp %lx, lp %x\n", lParam, wParam); 3814 4024 3815 4025 if (!infoPtr->uInternalStatus & TV_HSCROLL) return FALSE; … … 3849 4059 } 3850 4060 3851 TREEVIEW_CalcItems(hwnd,0,infoPtr); 3852 ScrollWindowEx(hwnd,lastPos-infoPtr->cx,0,NULL,NULL,0,NULL,SW_INVALIDATE); 4061 if (lastPos != infoPtr->cx) 4062 { 4063 if (!TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE)) 4064 TREEVIEW_CalcItems(hwnd,0,infoPtr); 4065 ScrollWindowEx(hwnd,lastPos-infoPtr->cx,0,NULL,NULL,0,NULL,SW_INVALIDATE); 4066 } 3853 4067 3854 4068 return TRUE; … … 3890 4104 TREEVIEW_KeyDown (HWND hwnd, WPARAM wParam, LPARAM lParam) 3891 4105 { 3892 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 3893 HTREEITEM hNewSelection = 0; 3894 INT scrollNeeds = -1; 3895 INT cyChangeNeeds = -1; 3896 INT prevSelect = (INT)infoPtr->selectedItem; 3897 3898 TREEVIEW_ITEM *prevItem = 4106 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 4107 HTREEITEM hNewSelection = 0; 4108 INT prevSelect = (INT)infoPtr->selectedItem; 4109 TREEVIEW_ITEM *prevItem = 3899 4110 (prevSelect != 0 ) ? 3900 4111 TREEVIEW_ValidItem (infoPtr, (HTREEITEM)prevSelect) : 3901 4112 NULL; 3902 3903 TREEVIEW_ITEM *newItem = NULL; 3904 3905 // TRACE (treeview,"%x %lx\n",wParam, lParam); 3906 3907 if (prevSelect == 0) 3908 return FALSE; 3909 3910 switch (wParam) { 3911 case VK_UP: 3912 newItem=TREEVIEW_GetPrevListItem (hwnd,infoPtr, prevItem); 3913 3914 if (!newItem) 3915 newItem=& infoPtr->items[(INT)infoPtr->TopRootItem]; 3916 3917 hNewSelection = newItem->hItem; 3918 3919 if (! newItem->visible) 3920 scrollNeeds = SB_LINEUP; 3921 3922 break; 3923 3924 case VK_DOWN: 3925 newItem=TREEVIEW_GetNextListItem (hwnd,infoPtr, prevItem); 3926 3927 if (!newItem) 3928 newItem=prevItem; 3929 3930 hNewSelection = newItem->hItem; 3931 3932 if (! newItem->visible) 3933 scrollNeeds = SB_LINEDOWN; 3934 3935 break; 3936 3937 case VK_HOME: 3938 newItem = &infoPtr->items[(INT)infoPtr->TopRootItem]; 3939 hNewSelection = newItem->hItem; 3940 cyChangeNeeds = 0; 3941 break; 3942 3943 case VK_END: 3944 newItem = &infoPtr->items[(INT)infoPtr->TopRootItem]; 3945 newItem = TREEVIEW_GetLastListItem (hwnd,infoPtr, newItem); 3946 hNewSelection = newItem->hItem; 3947 3948 if (! newItem->visible) 3949 cyChangeNeeds = infoPtr->uTotalHeight-infoPtr->uVisibleHeight; 3950 3951 break; 3952 3953 case VK_LEFT: 3954 if ( (prevItem->state & TVIS_EXPANDED) && 4113 TREEVIEW_ITEM *newItem = NULL; 4114 4115 TREEVIEW_SendKeyDownNotify(hwnd,TVN_KEYDOWN,wParam); 4116 4117 if (prevSelect == 0) 4118 return FALSE; 4119 4120 switch (wParam) 4121 { 4122 case VK_UP: 4123 newItem = TREEVIEW_GetPrevListItem(hwnd,infoPtr, prevItem); 4124 4125 if (!newItem) 4126 newItem = &infoPtr->items[(INT)infoPtr->TopRootItem]; 4127 4128 hNewSelection = newItem->hItem; 4129 4130 break; 4131 4132 case VK_DOWN: 4133 newItem = TREEVIEW_GetNextListItem (hwnd,infoPtr, prevItem); 4134 4135 if (!newItem) 4136 newItem = prevItem; 4137 4138 hNewSelection = newItem->hItem; 4139 4140 break; 4141 4142 case VK_HOME: 4143 newItem = &infoPtr->items[(INT)infoPtr->TopRootItem]; 4144 hNewSelection = newItem->hItem; 4145 4146 break; 4147 4148 case VK_END: 4149 newItem = &infoPtr->items[(INT)infoPtr->TopRootItem]; 4150 newItem = TREEVIEW_GetLastListItem (hwnd,infoPtr, newItem); 4151 hNewSelection = newItem->hItem; 4152 4153 break; 4154 4155 case VK_LEFT: 4156 if ( (prevItem->state & TVIS_EXPANDED) && 3955 4157 TREEVIEW_HasChildren(hwnd, prevItem)) 3956 { 3957 TREEVIEW_Expand(hwnd, TVE_COLLAPSE, prevSelect ); 3958 } 3959 else if ((INT)prevItem->parent) 3960 { 3961 newItem = (& infoPtr->items[(INT)prevItem->parent]); 3962 if (! newItem->visible) 3963 /* FIXME find a way to make this item the first visible... */ 3964 newItem = NULL; 3965 3966 hNewSelection = newItem->hItem; 3967 } 3968 3969 break; 3970 3971 case VK_RIGHT: 3972 if ( TREEVIEW_HasChildren(hwnd, prevItem) ) 3973 { 3974 if (! (prevItem->state & TVIS_EXPANDED)) 3975 TREEVIEW_Expand(hwnd, TVE_EXPAND, prevSelect ); 3976 else 3977 { 3978 newItem = (& infoPtr->items[(INT)prevItem->firstChild]); 4158 { 4159 TREEVIEW_Expand(hwnd, TVE_COLLAPSE, prevSelect ); 4160 } else if ((INT)prevItem->parent) 4161 { 4162 newItem = (& infoPtr->items[(INT)prevItem->parent]); 4163 3979 4164 hNewSelection = newItem->hItem; 3980 4165 } 3981 } 3982 3983 break; 3984 3985 case VK_ADD: 3986 if (! (prevItem->state & TVIS_EXPANDED)) 3987 TREEVIEW_Expand(hwnd, TVE_EXPAND, prevSelect ); 3988 break; 3989 3990 case VK_SUBTRACT: 3991 if (prevItem->state & TVIS_EXPANDED) 4166 4167 break; 4168 case VK_RIGHT: 4169 if (TREEVIEW_HasChildren(hwnd, prevItem)) 4170 { 4171 if (!(prevItem->state & TVIS_EXPANDED)) 4172 TREEVIEW_Expand(hwnd, TVE_EXPAND, prevSelect ); 4173 else 4174 { 4175 newItem = (& infoPtr->items[(INT)prevItem->firstChild]); 4176 hNewSelection = newItem->hItem; 4177 } 4178 } 4179 4180 break; 4181 4182 case VK_ADD: 4183 if (!(prevItem->state & TVIS_EXPANDED)) 4184 TREEVIEW_Expand(hwnd, TVE_EXPAND, prevSelect ); 4185 break; 4186 4187 case VK_SUBTRACT: 4188 if (prevItem->state & TVIS_EXPANDED) 3992 4189 TREEVIEW_Expand(hwnd, TVE_COLLAPSE, prevSelect ); 3993 4190 break; 3994 4191 3995 case VK_PRIOR: 3996 3997 newItem=TREEVIEW_GetListItem( 4192 case VK_PRIOR: 4193 newItem=TREEVIEW_GetListItem( 3998 4194 hwnd, 3999 4195 infoPtr, 4000 4196 prevItem, 4001 4197 -1*(TREEVIEW_GetVisibleCount(hwnd,0,0)-3)); 4002 if (!newItem) 4003 newItem=prevItem; 4004 4005 hNewSelection = newItem->hItem; 4006 4007 if (! newItem->visible) 4008 scrollNeeds = SB_PAGEUP; 4009 4010 break; 4011 4012 case VK_NEXT: 4013 newItem=TREEVIEW_GetListItem( 4198 if (!newItem) 4199 newItem = prevItem; 4200 4201 hNewSelection = newItem->hItem; 4202 4203 break; 4204 4205 case VK_NEXT: 4206 newItem=TREEVIEW_GetListItem( 4014 4207 hwnd, 4015 4208 infoPtr, … … 4017 4210 TREEVIEW_GetVisibleCount(hwnd,0,0)-3); 4018 4211 4019 if (!newItem) 4020 newItem=prevItem; 4021 4022 hNewSelection = newItem->hItem; 4023 4024 if (! newItem->visible) 4025 scrollNeeds = SB_PAGEDOWN; 4026 4027 break; 4028 4029 case VK_BACK: 4030 4031 case VK_RETURN: 4032 4033 default: 4034 // FIXME (treeview, "%x not implemented\n", wParam); 4035 break; 4212 if (!newItem) 4213 newItem = prevItem; 4214 4215 hNewSelection = newItem->hItem; 4216 4217 break; 4218 4219 case VK_BACK: 4220 case VK_RETURN: 4221 4222 default: 4223 break; 4036 4224 } 4037 4225 4038 4226 if (hNewSelection) 4039 4227 { 4040 /*4041 This works but does not send notification...4042 4043 prevItem->state &= ~TVIS_SELECTED;4044 newItem->state |= TVIS_SELECTED;4045 infoPtr->selectedItem = hNewSelection;4046 TREEVIEW_QueueRefresh (hwnd);4047 */4048 4049 4228 if ( TREEVIEW_DoSelectItem( 4050 4229 hwnd, … … 4053 4232 TVC_BYKEYBOARD)) 4054 4233 { 4055 /* If selection change is allowed for the new item, perform scrolling */ 4056 if (scrollNeeds != -1) 4057 TREEVIEW_VScroll(hwnd, scrollNeeds, 0); 4058 4059 if (cyChangeNeeds != -1) 4060 infoPtr->cy = cyChangeNeeds; 4061 4062 /* FIXME: Something happen in the load the in the two weeks before 4063 april 1st 1999 which makes this SetFocus mandatory otherwise, the focus 4064 is lost... However the SetFocus should not be required...*/ 4065 4066 SetFocus(hwnd); 4234 TREEVIEW_EnsureVisible(hwnd,hNewSelection); 4067 4235 } 4068 4236 } … … 4087 4255 4088 4256 return uOldScrollTime; 4257 } 4258 4259 static LRESULT TREEVIEW_EnsureVisible(HWND hwnd,HTREEITEM hItem) 4260 { 4261 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 4262 TREEVIEW_ITEM *item; 4263 RECT rect; 4264 INT scrollY; 4265 4266 item = TREEVIEW_ValidItem(infoPtr,hItem); 4267 4268 if (!item) return FALSE; 4269 4270 if (item && item->parent) 4271 { 4272 TREEVIEW_ITEM *parent = TREEVIEW_ValidItem(infoPtr,item->parent); 4273 4274 while (parent && !(parent->state & TVIS_EXPANDED)) 4275 { 4276 TREEVIEW_Expand(hwnd,TVE_EXPAND,(LPARAM)parent); 4277 parent = TREEVIEW_ValidItem(infoPtr,parent->parent); 4278 } 4279 } 4280 4281 TREEVIEW_UnqueueRefresh(hwnd,TRUE,TRUE); 4282 GetClientRect(hwnd,&rect); 4283 if (item->rect.top < 0) 4284 scrollY = item->rect.top; 4285 else if (item->rect.bottom > rect.bottom) 4286 scrollY = item->rect.bottom-rect.bottom; 4287 else return FALSE; 4288 4289 if (scrollY != 0) 4290 { 4291 infoPtr->cy += scrollY; 4292 TREEVIEW_CalcItems(hwnd,0,infoPtr); 4293 ScrollWindowEx(hwnd,0,-scrollY,NULL,NULL,0,NULL,SW_INVALIDATE); 4294 4295 return TRUE; 4296 } 4297 4298 return FALSE; 4299 } 4300 4301 static LRESULT TREEVIEW_GetISearchString(HWND hwnd,LPSTR lpsz,BOOL unicode) 4302 { 4303 //CB: todo 4304 4305 return 0; 4089 4306 } 4090 4307 … … 4100 4317 switch (uMsg) { 4101 4318 case TVM_INSERTITEMA: 4102 return TREEVIEW_InsertItem A (hwnd, wParam, lParam);4319 return TREEVIEW_InsertItem(hwnd,wParam,lParam,FALSE); 4103 4320 4104 4321 case TVM_INSERTITEMW: 4105 return TREEVIEW_InsertItem W(hwnd,wParam,lParam);4322 return TREEVIEW_InsertItem(hwnd,wParam,lParam,TRUE); 4106 4323 4107 4324 case TVM_DELETEITEM: … … 4136 4353 4137 4354 case TVM_GETITEMA: 4138 return TREEVIEW_GetItem A (hwnd, wParam, lParam);4355 return TREEVIEW_GetItem(hwnd,wParam,lParam,FALSE); 4139 4356 4140 4357 case TVM_GETITEMW: 4141 // FIXME (treeview, "Unimplemented msg TVM_GETITEMW\n"); 4142 return 0; 4358 return TREEVIEW_GetItem(hwnd,wParam,lParam,TRUE); 4143 4359 4144 4360 case TVM_SETITEMA: 4145 return TREEVIEW_SetItem A (hwnd, wParam, lParam);4361 return TREEVIEW_SetItem(hwnd,wParam,lParam,FALSE); 4146 4362 4147 4363 case TVM_SETITEMW: 4148 // FIXME (treeview, "Unimplemented msg TVM_SETITEMW\n"); 4149 return 0; 4364 return TREEVIEW_SetItem(hwnd,wParam,lParam,TRUE); 4150 4365 4151 4366 case TVM_EDITLABELA: 4152 return TREEVIEW_EditLabel A(hwnd, (HTREEITEM)lParam);4367 return TREEVIEW_EditLabel(hwnd,(HTREEITEM)lParam,FALSE); 4153 4368 4154 4369 case TVM_EDITLABELW: 4155 // FIXME (treeview, "Unimplemented msg TVM_EDITLABELW \n"); 4156 return 0; 4370 return TREEVIEW_EditLabel(hwnd,(HTREEITEM)lParam,TRUE); 4157 4371 4158 4372 case TVM_GETEDITCONTROL: … … 4163 4377 4164 4378 case TVM_HITTEST: 4165 return TREEVIEW_HitTest (hwnd,lParam);4379 return TREEVIEW_HitTest(hwnd,(LPTVHITTESTINFO)lParam); 4166 4380 4167 4381 case TVM_CREATEDRAGIMAGE: … … 4173 4387 4174 4388 case TVM_ENSUREVISIBLE: 4175 // FIXME (treeview, "Unimplemented msg TVM_ENSUREVISIBLE\n"); 4176 return 0; 4389 return TREEVIEW_EnsureVisible(hwnd,(HTREEITEM)lParam); 4177 4390 4178 4391 case TVM_SORTCHILDRENCB: … … 4183 4396 4184 4397 case TVM_GETISEARCHSTRINGA: 4185 // FIXME (treeview, "Unimplemented msg TVM_GETISEARCHSTRINGA\n"); 4186 return 0; 4398 return TREEVIEW_GetISearchString(hwnd,(LPSTR)lParam,FALSE); 4187 4399 4188 4400 case TVM_GETISEARCHSTRINGW: 4189 // FIXME (treeview, "Unimplemented msg TVM_GETISEARCHSTRINGW\n"); 4190 return 0; 4401 return TREEVIEW_GetISearchString(hwnd,(LPSTR)lParam,TRUE); 4191 4402 4192 4403 case TVM_GETTOOLTIPS:
Note:
See TracChangeset
for help on using the changeset viewer.