Changeset 2740 for trunk/src/comctl32/treeview.c
- Timestamp:
- Feb 10, 2000, 7:51:19 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/treeview.c
r2635 r2740 1 /* $Id: treeview.c,v 1.2 2 2000-02-04 17:02:09 cbratschi Exp $ */1 /* $Id: treeview.c,v 1.23 2000-02-10 18:51:19 cbratschi Exp $ */ 2 2 /* Treeview control 3 3 * … … 65 65 ((TREEVIEW_INFO *) GetWindowLongA( hwnd, 0)) 66 66 67 static BOOL 68 TREEVIEW_SendSimpleNotify (HWND hwnd, UINT code); 69 static BOOL 70 TREEVIEW_SendTreeviewNotify (HWND hwnd, UINT code, UINT action, 71 HTREEITEM oldItem, HTREEITEM newItem); 72 static BOOL 73 TREEVIEW_SendTreeviewDnDNotify (HWND hwnd, UINT code, HTREEITEM dragItem, 74 POINT pt); 75 static BOOL 76 TREEVIEW_SendDispInfoNotify (HWND hwnd, TREEVIEW_ITEM *wineItem, 77 UINT code, UINT what); 78 static BOOL 79 TREEVIEW_SendCustomDrawNotify (HWND hwnd, DWORD dwDrawStage, HDC hdc, 80 RECT rc); 81 static BOOL 82 TREEVIEW_SendCustomDrawItemNotify (HWND hwnd, HDC hdc, 83 TREEVIEW_ITEM *tvItem, UINT uItemDrawState); 84 static LRESULT 85 TREEVIEW_DoSelectItem (HWND hwnd, INT action, HTREEITEM newSelect, INT cause); 86 static void 87 TREEVIEW_Refresh (HWND hwnd,HDC hdc); 88 89 static LRESULT CALLBACK 90 TREEVIEW_Edit_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, 91 LPARAM lParam); 92 93 LRESULT WINAPI 94 TREEVIEW_EndEditLabelNow (HWND hwnd, WPARAM wParam, LPARAM lParam); 95 96 97 67 static BOOL TREEVIEW_SendSimpleNotify (HWND hwnd, UINT code); 68 static BOOL TREEVIEW_SendTreeviewNotify (HWND hwnd, UINT code, UINT action, HTREEITEM oldItem, HTREEITEM newItem); 69 static BOOL TREEVIEW_SendTreeviewDnDNotify (HWND hwnd, UINT code, HTREEITEM dragItem, POINT pt); 70 static BOOL TREEVIEW_SendDispInfoNotify (HWND hwnd, TREEVIEW_ITEM *wineItem, UINT code, UINT what); 71 static BOOL TREEVIEW_SendCustomDrawNotify (HWND hwnd, DWORD dwDrawStage, HDC hdc, RECT rc); 72 static BOOL TREEVIEW_SendCustomDrawItemNotify (HWND hwnd, HDC hdc, TREEVIEW_ITEM *tvItem, UINT uItemDrawState); 73 static LRESULT TREEVIEW_DoSelectItem (HWND hwnd, INT action, HTREEITEM newSelect, INT cause); 74 static void TREEVIEW_Refresh(HWND hwnd); 75 static void TREEVIEW_Draw(HWND hwnd,HDC hdc,RECT *updateRect); 76 77 static LRESULT CALLBACK TREEVIEW_Edit_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 78 79 LRESULT WINAPI TREEVIEW_EndEditLabelNow (HWND hwnd, WPARAM wParam, LPARAM lParam); 98 80 99 81 /* helper functions. Work with the assumption that validity of operands … … 383 365 384 366 385 386 387 388 389 390 367 static LRESULT 391 368 TREEVIEW_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam) … … 502 479 { 503 480 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 504 HDC hdc;505 481 506 482 //FIXME("%d %ld\n",wParam,lParam); … … 511 487 infoPtr->insertMarkItem=(HTREEITEM) lParam; 512 488 513 hdc = GetDC(hwnd); 514 TREEVIEW_Refresh(hwnd,hdc); 515 ReleaseDC(hwnd,hdc); 489 //CB: todo 490 TREEVIEW_Refresh(hwnd); 516 491 517 492 return 1; … … 912 887 HTREEITEM *iItem; 913 888 LPRECT lpRect = (LPRECT)lParam; 914 HDC hdc;915 889 916 890 // TRACE (treeview,"\n"); … … 920 894 if (lpRect == NULL) 921 895 return FALSE; 922 923 if (infoPtr->Timer & TV_REFRESH_TIMER_SET)924 {925 hdc = GetDC(hwnd);926 TREEVIEW_Refresh(hwnd,hdc); /* we want a rect for the current view */927 ReleaseDC(hwnd,hdc);928 }929 896 930 897 /* … … 965 932 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 966 933 934 //CB: todo: that's the number of completely visible items 935 967 936 return (LRESULT) infoPtr->uVisibleHeight / infoPtr->uRealItemHeight; 968 937 } … … 1046 1015 } 1047 1016 1017 static void TREEVIEW_RefreshItem(HWND hwnd,TREEVIEW_ITEM *item) 1018 { 1019 if (item && item->visible) 1020 { 1021 //CB: todo: only redraw text and icon 1022 InvalidateRect(hwnd,&item->rect,TRUE); 1023 } 1024 } 1025 1026 static void TREEVIEW_Refresh(HWND hwnd) 1027 { 1028 InvalidateRect(hwnd,NULL,TRUE); 1029 } 1030 1031 static void TREEVIEW_CalcItems(HWND hwnd) 1032 { 1033 //CB: todo: TREEVIEW_Draw should only draw, not calculate! 1034 } 1035 1036 static void TREEVIEW_SetScrollbars(HWND hwnd) 1037 { 1038 //CB: todo: dito 1039 } 1040 1041 static int TREEVIEW_GetFirstVisibleItem(HWND hwnd) 1042 { 1043 //CB: todo 1044 1045 return 0; 1046 } 1047 1048 1048 static void 1049 TREEVIEW_Refresh (HWND hwnd,HDC hdc) 1050 1049 TREEVIEW_Draw(HWND hwnd,HDC hdc,RECT *updateRect) 1051 1050 { 1052 1051 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 1053 1052 TEXTMETRICA tm; 1054 1053 HBRUSH hbrBk; 1055 RECT rect ;1054 RECT rect,view; 1056 1055 INT iItem, indent, x, y, cx, height, itemHeight; 1057 INT viewtop,viewbottom,viewleft,viewright;1058 1056 TREEVIEW_ITEM *wineItem, *prevItem; 1059 1057 1060 1058 //TRACE("\n"); 1061 1062 if (infoPtr->Timer & TV_REFRESH_TIMER_SET) {1063 KillTimer (hwnd, TV_REFRESH_TIMER);1064 infoPtr->Timer &= ~TV_REFRESH_TIMER_SET;1065 }1066 1067 1059 1068 1060 GetClientRect (hwnd, &rect); … … 1077 1069 infoPtr->uVisibleWidth= rect.right-rect.left; 1078 1070 1079 view top=infoPtr->cy;1080 view bottom=infoPtr->cy + rect.bottom-rect.top;1081 view left=infoPtr->cx;1082 viewright=infoPtr->cx + rect.right-rect.left;1071 view = updateRect ? *updateRect:rect; 1072 view.left = 0; 1073 view.right = rect.right; 1074 OffsetRect(&view,infoPtr->cx,infoPtr->cy); 1083 1075 1084 1076 /* draw background */ … … 1093 1085 indent=0; 1094 1086 x=y=0; 1095 //TRACE("[%d %d %d %d]\n",viewtop,viewbottom,viewleft,viewright);1096 1087 1097 1088 while (iItem) { … … 1110 1101 infoPtr->uRealItemHeight=itemHeight; 1111 1102 1112 1113 /* FIXME: remove this in later stage */1114 /*1115 if (wineItem->pszText!=LPSTR_TEXTCALLBACK32A)1116 TRACE (treeview, "%d %d [%d %d %d %d] (%s)\n",y,x,1117 wineItem->rect.top, wineItem->rect.bottom,1118 wineItem->rect.left, wineItem->rect.right,1119 wineItem->pszText);1120 else1121 TRACE (treeview, "%d [%d %d %d %d] (CALLBACK)\n",1122 wineItem->hItem,1123 wineItem->rect.top, wineItem->rect.bottom,1124 wineItem->rect.left, wineItem->rect.right);1125 */1126 1127 1103 height=itemHeight * wineItem->iIntegral +1; 1128 if ((y >= viewtop) && (y <= viewbottom) && 1129 (x >= viewleft ) && (x <= viewright)) { 1104 if ((((y >= view.top) && (y <= view.bottom)) || ((y+height >= view.top) && (y+height <= view.bottom))) && 1105 (x >= view.left) && (x <= view.right)) 1106 { 1130 1107 wineItem->visible = TRUE; 1131 1108 wineItem->rect.top = y - infoPtr->cy + rect.top; … … 1171 1148 1172 1149 infoPtr->uTotalHeight=y; 1173 if (y >= (view bottom-viewtop)) {1150 if (y >= (view.bottom-view.top)) { 1174 1151 if (!(infoPtr->uInternalStatus & TV_VSCROLL)) 1175 1152 ShowScrollBar (hwnd, SB_VERT, TRUE); … … 1202 1179 1203 1180 switch (wParam) { 1204 case TV_REFRESH_TIMER:1205 KillTimer (hwnd, TV_REFRESH_TIMER);1206 infoPtr->Timer &= ~TV_REFRESH_TIMER_SET;1207 InvalidateRect(hwnd, NULL, FALSE);1208 return 0;1209 1181 case TV_EDIT_TIMER: 1210 1182 KillTimer (hwnd, TV_EDIT_TIMER); … … 1218 1190 return 1; 1219 1191 } 1220 1221 1222 static void1223 TREEVIEW_QueueRefresh (HWND hwnd)1224 1225 {1226 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);1227 1228 // TRACE (treeview,"\n");1229 if (infoPtr->Timer & TV_REFRESH_TIMER_SET) {1230 KillTimer (hwnd, TV_REFRESH_TIMER);1231 }1232 1233 SetTimer (hwnd, TV_REFRESH_TIMER, TV_REFRESH_DELAY, 0);1234 infoPtr->Timer|=TV_REFRESH_TIMER_SET;1235 }1236 1237 1238 1192 1239 1193 static LRESULT … … 1312 1266 TREEVIEW_ITEM *wineItem, *returnItem; 1313 1267 INT iItem, retval, flag; 1314 HDC hdc;1315 1268 1316 1269 flag = (INT) wParam; … … 1322 1275 case TVGN_CARET:retval=(INT)infoPtr->selectedItem; 1323 1276 break; 1324 case TVGN_FIRSTVISIBLE: /* FIXME:we should only recalculate, not redraw */ 1325 hdc = GetDC (hwnd); 1326 TREEVIEW_Refresh (hwnd, hdc); 1327 ReleaseDC(hwnd,hdc); 1328 retval=(INT)infoPtr->firstVisible; 1329 break; 1277 case TVGN_FIRSTVISIBLE: /* FIXME:we should only recalculate, not redraw */ 1278 //CB: todo: remove 1279 TREEVIEW_Refresh(hwnd); 1280 retval=(INT)infoPtr->firstVisible; 1281 break; 1330 1282 case TVGN_DROPHILITE: 1331 1283 retval=(INT)infoPtr->dropItem; … … 1983 1935 } 1984 1936 1985 TREEVIEW_QueueRefresh (hwnd); 1937 //CB: todo: calc 1938 TREEVIEW_Refresh(hwnd); 1986 1939 1987 1940 return (LRESULT) iItem; … … 2059 2012 } 2060 2013 2061 TREEVIEW_QueueRefresh (hwnd); 2014 //CB: todo: calc 2015 TREEVIEW_Refresh(hwnd); 2062 2016 2063 2017 return TRUE; … … 2236 2190 } 2237 2191 2238 TREEVIEW_QueueRefresh (hwnd); 2192 //CB: todo: calc 2193 TREEVIEW_Refresh(hwnd); 2239 2194 return 0; 2240 2195 } … … 2244 2199 TREEVIEW_StyleChanged (HWND hwnd, WPARAM wParam, LPARAM lParam) 2245 2200 { 2246 HDC hdc;2247 2248 2201 //TRACE("(%x %lx)\n",wParam,lParam); 2249 hdc = GetDC (hwnd); 2250 TREEVIEW_Refresh (hwnd, hdc); 2251 ReleaseDC(hwnd,hdc); 2202 //CB: todo: calc 2203 TREEVIEW_Refresh (hwnd); 2252 2204 2253 2205 return 0; … … 2309 2261 infoPtr->pCallBackSort=NULL; 2310 2262 infoPtr->uScrollTime = 300; /* milliseconds */ 2311 2263 infoPtr->wpEditOrig = NULL; /* we haven't subclassed anything yet */ 2312 2264 infoPtr->hwndToolTip=0; 2313 2265 if (!(dwStyle & TVS_NOTOOLTIPS)) { /* Create tooltip control */ … … 2389 2341 SetWindowLongA( hwnd, 0, (DWORD)NULL); 2390 2342 2391 if (infoPtr->Timer & TV_REFRESH_TIMER_SET)2392 KillTimer (hwnd, TV_REFRESH_TIMER);2393 2343 if (infoPtr->hwndToolTip) 2394 2344 DestroyWindow (infoPtr->hwndToolTip); … … 2408 2358 // TRACE (treeview,"\n"); 2409 2359 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam; 2410 TREEVIEW_ Refresh (hwnd,hdc);2360 TREEVIEW_Draw(hwnd,hdc,&ps.rcPaint); 2411 2361 if(!wParam) 2412 2362 EndPaint (hwnd, &ps); … … 2420 2370 { 2421 2371 TREEVIEW_SendSimpleNotify (hwnd, NM_SETFOCUS); 2422 InvalidateRect(hwnd, NULL, FALSE); 2372 2373 //CB: todo: focus item 2374 2423 2375 return 0; 2424 2376 } … … 2428 2380 { 2429 2381 TREEVIEW_SendSimpleNotify (hwnd, NM_KILLFOCUS); 2430 InvalidateRect(hwnd, NULL, FALSE); 2382 2383 //CB: todo: focus item 2384 2431 2385 return 0; 2432 2386 } … … 2828 2782 // wineItem->state); 2829 2783 2830 TREEVIEW_QueueRefresh (hwnd); 2784 //CB: todo: replace 2785 TREEVIEW_Refresh(hwnd); 2831 2786 return TRUE; 2832 2787 } … … 3119 3074 wineItem->state|=state<<12; 3120 3075 //TRACE ("state:%x\n", wineItem->state); 3121 TREEVIEW_ QueueRefresh(hwnd);3076 TREEVIEW_Refresh(hwnd); 3122 3077 } 3123 3078 } … … 3300 3255 infoPtr->selectedItem=(HTREEITEM)newSelect; 3301 3256 3257 TREEVIEW_RefreshItem(hwnd,prevItem); 3258 TREEVIEW_RefreshItem(hwnd,wineItem); 3259 3302 3260 TREEVIEW_SendTreeviewNotify( 3303 3261 hwnd, … … 3320 3278 wineItem->state |=TVIS_DROPHILITED; 3321 3279 3280 TREEVIEW_RefreshItem(hwnd,prevItem); 3281 TREEVIEW_RefreshItem(hwnd,wineItem); 3282 3322 3283 break; 3323 3284 … … 3326 3287 break; 3327 3288 } 3328 3329 TREEVIEW_QueueRefresh (hwnd);3330 3289 3331 3290 // TRACE (treeview,"Leaving state %d\n", wineItem->state); … … 3384 3343 ReleaseDC (0, hdc); 3385 3344 3345 //CB: todo: calc 3386 3346 if (lParam) 3387 TREEVIEW_ QueueRefresh(hwnd);3347 TREEVIEW_Refresh(hwnd); 3388 3348 3389 3349 return 0; … … 3398 3358 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 3399 3359 int maxHeight; 3360 int lastPos = infoPtr->cy; 3400 3361 3401 3362 // TRACE (treeview,"wp %x, lp %lx\n", wParam, lParam); … … 3433 3394 } 3434 3395 3435 TREEVIEW_QueueRefresh (hwnd); 3396 ScrollWindowEx(hwnd,0,lastPos-infoPtr->cy,NULL,NULL,0,NULL,SW_INVALIDATE); 3397 3436 3398 return TRUE; 3437 3399 } … … 3478 3440 } 3479 3441 3480 TREEVIEW_QueueRefresh (hwnd); 3442 TREEVIEW_Refresh(hwnd); 3443 3444 //CB: todo: use ScrollWindowEx 3445 3481 3446 return TRUE; 3482 3447 } … … 3685 3650 { 3686 3651 if (uMsg==WM_CREATE) 3687 3652 return TREEVIEW_Create (hwnd, wParam, lParam); 3688 3653 3689 3654 if (!TREEVIEW_GetInfoPtr(hwnd)) … … 3928 3893 3929 3894 ZeroMemory (&wndClass, sizeof(WNDCLASSA)); 3930 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS ;3895 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; 3931 3896 wndClass.lpfnWndProc = (WNDPROC)TREEVIEW_WindowProc; 3932 3897 wndClass.cbClsExtra = 0;
Note:
See TracChangeset
for help on using the changeset viewer.