Changeset 110 for trunk/src/comctl32/treeview.c
- Timestamp:
- Jun 16, 1999, 10:25:45 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/treeview.c
r94 r110 1 /* $Id: treeview.c,v 1. 3 1999-06-10 16:22:03 achimhaExp $ */1 /* $Id: treeview.c,v 1.4 1999-06-16 20:25:44 cbratschi Exp $ */ 2 2 /* Treeview control 3 3 * … … 6 6 * Copyright 1999 Sylvain St-Germain 7 7 * Copyright 1999 Achim Hasenmueller 8 * Copyright 1999 Christoph Bratschi 8 9 * 9 10 * 10 11 * TODO: 11 12 * Using DPA to store the item ptr would be good. 12 * Node label edition is implemented but something appened in wine in the 13 * Node label edition is implemented but something appened in wine in the 13 14 * two last weeks of march 99 that broke it. 14 * refreshtreeview: 15 16 15 * refreshtreeview: 16 -small array containing info about positions. 17 -better implementation of RefreshItem: 17 18 1) draw lines between parents 18 19 2) draw items 19 20 20 3) draw lines from parent<->items. 21 -implement partial drawing? 21 22 * -drag&drop: TVM_CREATEDRAGIMAGE should create drag bitmap. 22 23 * -scrollbars: horizontal scrollbar doesn't work. … … 26 27 * FIXME: check fontsize. (uRealItemHeight) 27 28 * test focusItem (redraw in different color) 28 29 30 29 uHotItem 30 Edit: needs timer 31 better implementation. 31 32 * WM_HSCROLL is broken. 32 33 * use separate routine to get item text/image. 33 * 34 * 34 35 * Separate drawing/calculation. 35 36 * 36 37 * FIXMEs (for personal use) 37 Expand: 38 -DblClick: 39 -treehelper: stack corruption makes big window. 40 38 Expand: -ctlmacro expands twice ->toggle. 39 -DblClick: ctlmacro.exe's NM_DBLCLK seems to go wrong (returns FALSE). 40 -treehelper: stack corruption makes big window. 41 41 42 */ 42 43 … … 54 55 * has no side effects in this file. 55 56 */ 56 #define tv_test_bit(nr,bf) 57 #define tv_set_bit(nr,bf) 58 #define tv_clear_bit(nr,bf) 57 #define tv_test_bit(nr,bf) (((LPBYTE)bf)[nr>>3]&(1<<(nr&7))) 58 #define tv_set_bit(nr,bf) ((LPBYTE)bf)[nr>>3]|=(1<<(nr&7)) 59 #define tv_clear_bit(nr,bf) ((LPBYTE)bf)[nr>>3]&=~(1<<(nr&7)) 59 60 60 61 … … 65 66 TREEVIEW_SendSimpleNotify (HWND hwnd, UINT code); 66 67 static BOOL 67 TREEVIEW_SendTreeviewNotify (HWND hwnd, UINT code, UINT action, 68 68 TREEVIEW_SendTreeviewNotify (HWND hwnd, UINT code, UINT action, 69 HTREEITEM oldItem, HTREEITEM newItem); 69 70 static BOOL 70 TREEVIEW_SendTreeviewDnDNotify (HWND hwnd, UINT code, HTREEITEM dragItem, 71 71 TREEVIEW_SendTreeviewDnDNotify (HWND hwnd, UINT code, HTREEITEM dragItem, 72 POINT pt); 72 73 static BOOL 73 TREEVIEW_SendDispInfoNotify (HWND hwnd, TREEVIEW_ITEM *wineItem, 74 74 TREEVIEW_SendDispInfoNotify (HWND hwnd, TREEVIEW_ITEM *wineItem, 75 UINT code, UINT what); 75 76 static BOOL 76 77 TREEVIEW_SendCustomDrawNotify (HWND hwnd, DWORD dwDrawStage, HDC hdc, 77 78 RECT rc); 78 79 static BOOL 79 80 TREEVIEW_SendCustomDrawItemNotify (HWND hwnd, HDC hdc, … … 85 86 86 87 static LRESULT CALLBACK 87 TREEVIEW_Edit_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, 88 88 TREEVIEW_Edit_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, 89 LPARAM lParam); 89 90 90 91 LRESULT WINAPI … … 94 95 95 96 96 /* helper functions. Work with the assumption that validity of operands 97 /* helper functions. Work with the assumption that validity of operands 97 98 is checked beforehand, and that tree state is valid. */ 98 99 99 /* FIXME: MS documentation says `GetNextVisibleItem' returns NULL 100 /* FIXME: MS documentation says `GetNextVisibleItem' returns NULL 100 101 if not succesfull'. Probably only applies to derefencing infoPtr 101 102 (ie we are offered a valid treeview structure) 102 and not whether there is a next `visible' child. 103 and not whether there is a next `visible' child. 103 104 FIXME: check other failures. 104 105 */ … … 111 112 HTREEITEM handle) 112 113 { 113 if ((!handle) || (handle>infoPtr->uMaxHandle)) 114 if ((!handle) || (handle>infoPtr->uMaxHandle)) 114 115 return NULL; 115 116 116 if (tv_test_bit ((INT)handle, infoPtr->freeList)) 117 if (tv_test_bit ((INT)handle, infoPtr->freeList)) 117 118 return NULL; 118 119 … … 130 131 TREEVIEW_ITEM *wineItem = tvItem; 131 132 132 /* 133 * Get this item last sibling 133 /* 134 * Get this item last sibling 134 135 */ 135 while (wineItem->sibling) 136 137 138 /* 136 while (wineItem->sibling) 137 wineItem=& infoPtr->items [(INT)wineItem->sibling]; 138 139 /* 139 140 * If the last sibling has expanded children, restart. 140 141 */ 141 142 if ( ( wineItem->cChildren > 0 ) && ( wineItem->state & TVIS_EXPANDED) ) 142 143 return TREEVIEW_GetLastListItem( 143 infoPtr, 144 infoPtr, 144 145 &(infoPtr->items[(INT)wineItem->firstChild])); 145 146 … … 148 149 149 150 /*************************************************************************** 150 * This method returns the previous physical item in the list not 151 * This method returns the previous physical item in the list not 151 152 * considering the tree hierarchy. 152 153 */ 153 154 static TREEVIEW_ITEM *TREEVIEW_GetPrevListItem( 154 TREEVIEW_INFO *infoPtr, 155 TREEVIEW_INFO *infoPtr, 155 156 TREEVIEW_ITEM *tvItem) 156 157 { 157 if (tvItem->upsibling) 158 if (tvItem->upsibling) 158 159 { 159 /* 160 /* 160 161 * This item has a upsibling, get the last item. Since, GetLastListItem 161 162 * first looks at siblings, we must feed it with the first child. 162 163 */ 163 164 TREEVIEW_ITEM *upItem = &infoPtr->items[(INT)tvItem->upsibling]; 164 165 165 166 if ( ( upItem->cChildren > 0 ) && ( upItem->state & TVIS_EXPANDED) ) 166 return TREEVIEW_GetLastListItem( 167 infoPtr, 167 return TREEVIEW_GetLastListItem( 168 infoPtr, 168 169 &infoPtr->items[(INT)upItem->firstChild]); 169 170 else … … 175 176 * this item does not have a upsibling, get the parent 176 177 */ 177 if (tvItem->parent) 178 if (tvItem->parent) 178 179 return &infoPtr->items[(INT)tvItem->parent]; 179 180 } … … 184 185 185 186 /*************************************************************************** 186 * This method returns the next physical item in the treeview not 187 * This method returns the next physical item in the treeview not 187 188 * considering the tree hierarchy. 188 189 */ 189 190 static TREEVIEW_ITEM *TREEVIEW_GetNextListItem( 190 TREEVIEW_INFO *infoPtr, 191 TREEVIEW_INFO *infoPtr, 191 192 TREEVIEW_ITEM *tvItem) 192 193 { 193 194 TREEVIEW_ITEM *wineItem = NULL; 194 195 195 /* 196 /* 196 197 * If this item has children and is expanded, return the first child 197 198 */ 198 if ((tvItem->firstChild) && (tvItem->state & TVIS_EXPANDED)) 199 199 if ((tvItem->firstChild) && (tvItem->state & TVIS_EXPANDED)) 200 return (& infoPtr->items[(INT)tvItem->firstChild]); 200 201 201 202 … … 203 204 * try to get the sibling 204 205 */ 205 if (tvItem->sibling) 206 206 if (tvItem->sibling) 207 return (& infoPtr->items[(INT)tvItem->sibling]); 207 208 208 209 /* … … 212 213 while (wineItem->parent) { 213 214 wineItem=& infoPtr->items [(INT)wineItem->parent]; 214 if (wineItem->sibling)215 if (wineItem->sibling) 215 216 return (& infoPtr->items [(INT)wineItem->sibling]); 216 } 217 218 return NULL; 217 } 218 219 return NULL; 219 220 } 220 221 221 222 /*************************************************************************** 222 * This method returns the nth item starting at the given item. It returns 223 * This method returns the nth item starting at the given item. It returns 223 224 * the last item (or first) we we run out of items. 224 225 * … … 227 228 */ 228 229 static TREEVIEW_ITEM *TREEVIEW_GetListItem( 229 TREEVIEW_INFO *infoPtr, 230 TREEVIEW_INFO *infoPtr, 230 231 TREEVIEW_ITEM *tvItem, 231 232 LONG count) … … 241 242 { 242 243 /* Keep a pointer to the previous in case we ask for more than we got */ 243 previousItem = wineItem; 244 previousItem = wineItem; 244 245 wineItem = TREEVIEW_GetNextListItem(infoPtr, wineItem); 245 } 246 } 246 247 247 248 if (wineItem == NULL) … … 254 255 { 255 256 /* Keep a pointer to the previous in case we ask for more than we got */ 256 previousItem = wineItem; 257 previousItem = wineItem; 257 258 wineItem = TREEVIEW_GetPrevListItem(infoPtr, wineItem); 258 259 } … … 267 268 } 268 269 269 270 270 271 /*************************************************************************** 271 * This method 272 * This method 272 273 */ 273 274 static void TREEVIEW_RemoveAllChildren( … … 277 278 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 278 279 TREEVIEW_ITEM *killItem; 279 INT 280 280 INT kill; 281 281 282 kill=(INT)parentItem->firstChild; 282 283 while (kill) { 283 284 285 if (killItem->pszText!=LPSTR_TEXTCALLBACKA) 286 287 288 if (killItem->firstChild) 289 290 284 tv_set_bit ( kill, infoPtr->freeList); 285 killItem=& infoPtr->items[kill]; 286 if (killItem->pszText!=LPSTR_TEXTCALLBACKA) 287 COMCTL32_Free (killItem->pszText); 288 TREEVIEW_SendTreeviewNotify (hwnd, TVN_DELETEITEM, 0, (HTREEITEM)kill, 0); 289 if (killItem->firstChild) 290 TREEVIEW_RemoveAllChildren (hwnd, killItem); 291 kill=(INT)killItem->sibling; 291 292 } 292 293 293 294 if (parentItem->cChildren>0) { 294 295 296 295 infoPtr->uNumItems -= parentItem->cChildren; 296 parentItem->firstChild = 0; 297 parentItem->cChildren = 0; 297 298 } 298 299 … … 312 313 infoPtr->uNumItems--; 313 314 parentItem=NULL; 314 if (wineItem->pszText!=LPSTR_TEXTCALLBACKA) 315 315 if (wineItem->pszText!=LPSTR_TEXTCALLBACKA) 316 COMCTL32_Free (wineItem->pszText); 316 317 317 318 TREEVIEW_SendTreeviewNotify (hwnd, TVN_DELETEITEM, 0, (HTREEITEM)iItem, 0); 318 319 319 if (wineItem->firstChild) 320 320 if (wineItem->firstChild) 321 TREEVIEW_RemoveAllChildren (hwnd,wineItem); 321 322 322 323 if (wineItem->parent) { 323 324 325 case I_CHILDRENCALLBACK: 326 // 327 328 329 330 parentItem->firstChild=0; 331 332 333 334 if ((INT)parentItem->firstChild==iItem) 335 336 324 parentItem=& infoPtr->items [(INT)wineItem->parent]; 325 switch (parentItem->cChildren) { 326 case I_CHILDRENCALLBACK: 327 // FIXME (treeview,"we don't handle I_CHILDRENCALLBACK yet\n"); 328 break; 329 case 1: 330 parentItem->cChildren=0; 331 parentItem->firstChild=0; 332 return; 333 default: 334 parentItem->cChildren--; 335 if ((INT)parentItem->firstChild==iItem) 336 parentItem->firstChild=wineItem->sibling; 337 } 337 338 } 338 339 339 if (iItem==(INT)infoPtr->TopRootItem) 340 340 if (iItem==(INT)infoPtr->TopRootItem) 341 infoPtr->TopRootItem=(HTREEITEM)wineItem->sibling; 341 342 if (wineItem->upsibling) { 342 343 343 upsiblingItem=& infoPtr->items [(INT)wineItem->upsibling]; 344 upsiblingItem->sibling=wineItem->sibling; 344 345 } 345 346 if (wineItem->sibling) { 346 347 347 siblingItem=& infoPtr->items [(INT)wineItem->sibling]; 348 siblingItem->upsibling=wineItem->upsibling; 348 349 } 349 350 } … … 356 357 357 358 static void TREEVIEW_RemoveTree (HWND hwnd) 358 359 359 360 { 360 361 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); … … 362 363 int i; 363 364 364 for (i=1; i<=(INT)infoPtr->uMaxHandle; i++) 365 366 killItem=& infoPtr->items [i]; 367 368 369 TREEVIEW_SendTreeviewNotify 370 371 } 365 for (i=1; i<=(INT)infoPtr->uMaxHandle; i++) 366 if (!tv_test_bit (i, infoPtr->freeList)) { 367 killItem=& infoPtr->items [i]; 368 if (killItem->pszText!=LPSTR_TEXTCALLBACKA) 369 COMCTL32_Free (killItem->pszText); 370 TREEVIEW_SendTreeviewNotify 371 (hwnd, TVN_DELETEITEM, 0, killItem->hItem, 0); 372 } 372 373 373 374 if (infoPtr->uNumPtrsAlloced) { … … 377 378 infoPtr->uNumPtrsAlloced=0; 378 379 infoPtr->uMaxHandle=0; 379 } 380 } 380 381 } 381 382 … … 394 395 if (infoPtr==NULL) return 0; 395 396 396 if ((INT)wParam == TVSIL_NORMAL) 397 398 if ((INT)wParam == TVSIL_STATE) 399 397 if ((INT)wParam == TVSIL_NORMAL) 398 return (LRESULT) infoPtr->himlNormal; 399 if ((INT)wParam == TVSIL_STATE) 400 return (LRESULT) infoPtr->himlState; 400 401 401 402 return 0; … … 410 411 // TRACE (treeview,"\n"); 411 412 switch ((INT)wParam) { 412 413 414 415 416 417 418 419 420 413 case TVSIL_NORMAL: 414 himlTemp = infoPtr->himlNormal; 415 infoPtr->himlNormal = (HIMAGELIST)lParam; 416 return (LRESULT)himlTemp; 417 418 case TVSIL_STATE: 419 himlTemp = infoPtr->himlState; 420 infoPtr->himlState = (HIMAGELIST)lParam; 421 return (LRESULT)himlTemp; 421 422 } 422 423 … … 435 436 // TRACE (treeview,"\n"); 436 437 if (wParam==-1) { 437 438 439 438 hdc=GetDC (hwnd); 439 infoPtr->uItemHeight=-1; 440 return prevHeight; 440 441 } 441 442 … … 446 447 447 448 if (!( GetWindowLongA( hwnd, GWL_STYLE) & TVS_NONEVENHEIGHT)) 448 449 infoPtr->uItemHeight = (INT) wParam & 0xfffffffe; 449 450 return prevHeight; 450 451 } … … 454 455 { 455 456 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 456 457 457 458 // TRACE (treeview,"\n"); 458 459 return infoPtr->uItemHeight; 459 460 } 460 461 461 462 static LRESULT 462 463 TREEVIEW_SetTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam) … … 474 475 { 475 476 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 476 477 477 478 // TRACE (treeview,"\n"); 478 479 return (LRESULT) infoPtr->clrText; … … 494 495 { 495 496 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 496 497 497 498 // TRACE (treeview,"\n"); 498 499 return (LRESULT) infoPtr->clrBk; … … 500 501 501 502 502 /* cdmode: custom draw mode as received from app. in first NMCUSTOMDRAW 503 /* cdmode: custom draw mode as received from app. in first NMCUSTOMDRAW 503 504 notification */ 504 505 … … 516 517 RECT r; 517 518 518 519 if (wineItem->state & TVIS_BOLD) 520 521 else 522 519 520 if (wineItem->state & TVIS_BOLD) 521 hOldFont = SelectObject (hdc, infoPtr->hBoldFont); 522 else 523 hOldFont = SelectObject (hdc, infoPtr->hFont); 523 524 524 525 cditem=0; 525 526 if (infoPtr->cdmode & CDRF_NOTIFYITEMDRAW) { 526 527 528 if (infoPtr->cdmode & CDRF_NOTIFYSUBITEMDRAW) 527 drawmode=CDDS_ITEMPREPAINT; 528 529 if (infoPtr->cdmode & CDRF_NOTIFYSUBITEMDRAW) 529 530 drawmode|=CDDS_SUBITEM; 530 531 531 532 533 // 534 535 if (cditem & CDRF_SKIPDEFAULT) 536 537 538 539 /* 540 * Set drawing starting points 532 cditem=TREEVIEW_SendCustomDrawItemNotify (hwnd, hdc, wineItem, drawmode); 533 534 // TRACE (treeview,"cditem:%d\n",cditem); 535 536 if (cditem & CDRF_SKIPDEFAULT) 537 return; 538 } 539 540 /* 541 * Set drawing starting points 541 542 */ 542 543 r = wineItem->rect; /* this item rectangle */ … … 544 545 xpos = r.left + TREEVIEW_LEFT_MARGIN;/* horizontal starting point */ 545 546 546 /* 547 * Display the tree hierarchy 547 /* 548 * Display the tree hierarchy 548 549 */ 549 if ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_HASLINES) 550 if ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_HASLINES) 550 551 { 551 /* 552 * Write links to parent node 552 /* 553 * Write links to parent node 553 554 * we draw the L starting from the child to the parent 554 555 * … … 557 558 * points[2] is attached to the parent or the up sibling 558 559 */ 559 if ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_LINESATROOT) 560 if ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_LINESATROOT) 560 561 { 561 562 TREEVIEW_ITEM *upNode = NULL; 562 563 BOOL hasParentOrSibling = TRUE; 563 564 RECT upRect = {0,0,0,0}; 564 565 HPEN hOldPen, hnewPen; 565 566 /* 566 POINT points[3]; 567 /* 567 568 * determine the target location of the line at root, either be linked 568 569 * to the up sibling or to the parent node. 569 570 */ 570 571 if (wineItem->upsibling) 571 572 upNode = TREEVIEW_ValidItem (infoPtr, wineItem->upsibling); 572 573 else if (wineItem->parent) 573 574 upNode = TREEVIEW_ValidItem (infoPtr, wineItem->parent); 574 575 else 575 576 hasParentOrSibling = FALSE; … … 582 583 points[2].x = points[1].x = upRect.left+8; 583 584 points[0].x = points[2].x + 10; 584 points[2].y = upRect.bottom-3; 585 points[2].y = upRect.bottom-3; 585 586 points[1].y = points[0].y = center; 586 587 } 587 588 else 588 589 { 589 points[2].x = points[1].x = 8 + (20*wineItem->iLevel); 590 points[2].y = ( upNode->cChildren == 0) ? 590 points[2].x = points[1].x = 8 + (20*wineItem->iLevel); 591 points[2].y = ( upNode->cChildren == 0) ? 591 592 upRect.top : /* is linked to the "L" above */ 592 ( wineItem->upsibling != NULL) ? 593 ( wineItem->upsibling != NULL) ? 593 594 upRect.bottom-3: /* is linked to an icon */ 594 595 upRect.bottom+1; /* is linked to a +/- box */ 595 596 points[1].y = points[0].y = center; 596 points[0].x = points[1].x + 10; 597 points[0].x = points[1].x + 10; 597 598 } 598 599 /* 599 600 /* 600 601 * Get a doted pen 601 */ 602 */ 602 603 hnewPen = CreatePen(PS_DOT, 0, GetSysColor(COLOR_WINDOWTEXT) ); 603 604 hOldPen = SelectObject( hdc, hnewPen ); 604 605 605 606 if (hasParentOrSibling) 606 Polyline (hdc,points,3); 607 Polyline (hdc,points,3); 607 608 else 608 Polyline (hdc,points,2); 609 609 Polyline (hdc,points,2); 610 610 611 DeleteObject(hnewPen); 611 612 SelectObject(hdc, hOldPen); … … 613 614 } 614 615 615 /* 616 /* 616 617 * Display the (+/-) signs 617 618 */ … … 619 620 xpos+=(5*wineItem->iLevel); 620 621 621 if (( GetWindowLongA( hwnd, GWL_STYLE) & TVS_HASBUTTONS) && 622 if (( GetWindowLongA( hwnd, GWL_STYLE) & TVS_HASBUTTONS) && 622 623 ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_HASLINES)) 623 624 { 624 625 625 if ( (wineItem->cChildren) || 626 (wineItem->cChildren == I_CHILDRENCALLBACK)) 626 627 { 627 628 /* Setup expand box coordinate to facilitate the LMBClick handling */ … … 631 632 wineItem->expandBox.bottom = center+5; 632 633 633 634 hdc, 635 wineItem->expandBox.left, 636 wineItem->expandBox.top , 637 wineItem->expandBox.right, 634 Rectangle ( 635 hdc, 636 wineItem->expandBox.left, 637 wineItem->expandBox.top , 638 wineItem->expandBox.right, 638 639 wineItem->expandBox.bottom); 639 640 640 641 642 643 644 645 646 641 MoveToEx (hdc, xpos-2, center, NULL); 642 LineTo (hdc, xpos+3, center); 643 644 if (!(wineItem->state & TVIS_EXPANDED)) { 645 MoveToEx (hdc, xpos, center-2, NULL); 646 LineTo (hdc, xpos, center+3); 647 } 647 648 } 648 649 } 649 650 650 /* 651 /* 651 652 * Display the image assiciated with this item 652 653 */ … … 656 657 HIMAGELIST *himlp = NULL; 657 658 658 if (infoPtr->himlNormal) 659 if (infoPtr->himlNormal) 659 660 himlp=&infoPtr->himlNormal; /* get the image list */ 660 661 661 if ( (wineItem->state & TVIS_SELECTED) &&662 (wineItem->iSelectedImage)) { 663 662 if ( (wineItem->state & TVIS_SELECTED) && 663 (wineItem->iSelectedImage)) { 664 664 665 /* State images are displayed to the left of the Normal image*/ 665 if (infoPtr->himlState) 666 if (infoPtr->himlState) 666 667 himlp=&infoPtr->himlState; 667 668 668 669 /* The item is curently selected */ 669 if (wineItem->iSelectedImage == I_IMAGECALLBACK) 670 671 hwnd, 672 wineItem, 673 TVN_GETDISPINFO, 670 if (wineItem->iSelectedImage == I_IMAGECALLBACK) 671 TREEVIEW_SendDispInfoNotify ( 672 hwnd, 673 wineItem, 674 TVN_GETDISPINFO, 674 675 TVIF_SELECTEDIMAGE); 675 676 676 677 imageIndex = wineItem->iSelectedImage; 677 678 678 } else { 679 } else { 679 680 /* This item is not selected */ 680 if (wineItem->iImage == I_IMAGECALLBACK) 681 TREEVIEW_SendDispInfoNotify ( 682 hwnd, 683 wineItem, 684 TVN_GETDISPINFO, 681 if (wineItem->iImage == I_IMAGECALLBACK) 682 TREEVIEW_SendDispInfoNotify ( 683 hwnd, 684 wineItem, 685 TVN_GETDISPINFO, 685 686 TVIF_IMAGE); 686 687 687 688 imageIndex = wineItem->iImage; 688 689 689 } 690 690 691 if (himlp) 691 { 692 { 692 693 /* We found an image to display? Draw it. */ 693 694 *himlp, 694 ImageList_Draw ( 695 *himlp, 695 696 wineItem->iImage, 696 hdc, 697 xpos-2, 698 r.top+1, 697 hdc, 698 xpos-2, 699 r.top+1, 699 700 ILD_NORMAL); 700 701 701 702 702 ImageList_GetIconSize (*himlp, &cx, &cy); 703 xpos+=cx; 703 704 } 704 705 } 705 706 706 /* 707 /* 707 708 * Display the text assiciated with this item 708 709 */ 709 710 r.left=xpos; 710 if ((wineItem->mask & TVIF_TEXT) && (wineItem->pszText)) 711 if ((wineItem->mask & TVIF_TEXT) && (wineItem->pszText)) 711 712 { 712 713 COLORREF oldBkColor = 0; … … 717 718 r.right -= 3; 718 719 719 wineItem->text.left = r.left; 720 wineItem->text.left = r.left; 720 721 wineItem->text.right = r.right; 721 722 wineItem->text.top = r.top; … … 726 727 oldBkColor = SetBkColor (hdc, GetSysColor( COLOR_HIGHLIGHT)); 727 728 oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_HIGHLIGHTTEXT)); 728 } 729 else 729 } 730 else 730 731 { 731 732 oldBkMode = SetBkMode(hdc, TRANSPARENT); … … 740 741 /* Draw it */ 741 742 DrawTextA ( 742 hdc, 743 wineItem->pszText, 744 lstrlenA(wineItem->pszText), 745 &wineItem->text, 746 uTextJustify | DT_VCENTER | DT_SINGLELINE ); 743 hdc, 744 wineItem->pszText, 745 lstrlenA(wineItem->pszText), 746 &wineItem->text, 747 uTextJustify | DT_VCENTER | DT_SINGLELINE ); 747 748 748 749 /* Obtain the text coordinate */ 749 750 DrawTextA ( 750 hdc, 751 wineItem->pszText, 752 lstrlenA(wineItem->pszText), 753 &wineItem->text, 754 uTextJustify | DT_VCENTER | DT_SINGLELINE | DT_CALCRECT); 751 hdc, 752 wineItem->pszText, 753 lstrlenA(wineItem->pszText), 754 &wineItem->text, 755 uTextJustify | DT_VCENTER | DT_SINGLELINE | DT_CALCRECT); 755 756 756 757 /* Restore the hdc state */ … … 763 764 764 765 /* Draw the box arround the selected item */ 765 if (wineItem->state & TVIS_SELECTED ) 766 if (wineItem->state & TVIS_SELECTED ) 766 767 { 767 768 HPEN hnewPen = CreatePen(PS_DOT, 0, GetSysColor(COLOR_WINDOWTEXT) ); 768 769 HPEN hOldPen = SelectObject( hdc, hnewPen ); 769 770 POINT points[4]; 770 771 771 772 points[0].x = wineItem->text.left-1; 772 points[0].y = wineItem->text.top+1; 773 points[0].y = wineItem->text.top+1; 773 774 points[1].x = wineItem->text.right; 774 points[1].y = wineItem->text.top+1; 775 points[1].y = wineItem->text.top+1; 775 776 points[2].x = wineItem->text.right; 776 points[2].y = wineItem->text.bottom; 777 points[2].y = wineItem->text.bottom; 777 778 points[3].x = wineItem->text.left-1; 778 779 points[3].y = wineItem->text.bottom; 779 780 780 Polyline (hdc,points,4); 781 Polyline (hdc,points,4); 781 782 782 783 DeleteObject(hnewPen); … … 786 787 787 788 if (cditem & CDRF_NOTIFYPOSTPAINT) 788 789 TREEVIEW_SendCustomDrawItemNotify (hwnd, hdc, wineItem, CDDS_ITEMPOSTPAINT); 789 790 790 791 SelectObject (hdc, hOldFont); … … 800 801 801 802 // TRACE (treeview,"\n"); 802 /* 803 /* 803 804 * validate parameters 804 805 */ 805 if ( (infoPtr==NULL) || (lpRect == NULL) ) 806 if ( (infoPtr==NULL) || (lpRect == NULL) ) 806 807 return FALSE; 807 808 808 if (infoPtr->Timer & TV_REFRESH_TIMER_SET) 809 TREEVIEW_Refresh (hwnd);/* we want a rect for the current view */810 811 /* 809 if (infoPtr->Timer & TV_REFRESH_TIMER_SET) 810 TREEVIEW_Refresh (hwnd); /* we want a rect for the current view */ 811 812 /* 812 813 * retrive the item ptr 813 */ 814 */ 814 815 iItem = (HTREEITEM *) lParam; 815 816 wineItem = TREEVIEW_ValidItem (infoPtr, *iItem); 816 if ((!wineItem) || (!wineItem->visible)) 817 if ((!wineItem) || (!wineItem->visible)) 817 818 return FALSE; 818 819 819 /* 820 * If wParam is TRUE return the text size otherwise return 821 * the whole item size 820 /* 821 * If wParam is TRUE return the text size otherwise return 822 * the whole item size 822 823 */ 823 824 if ((INT) wParam) { 824 lpRect->left= wineItem->text.left;825 lpRect->right 826 lpRect->bottom 827 lpRect->top 825 lpRect->left = wineItem->text.left; 826 lpRect->right = wineItem->text.right; 827 lpRect->bottom = wineItem->text.bottom; 828 lpRect->top = wineItem->text.top; 828 829 } else { 829 lpRect->left 830 lpRect->right 830 lpRect->left = wineItem->rect.left; 831 lpRect->right = wineItem->rect.right; 831 832 lpRect->bottom = wineItem->rect.bottom; 832 lpRect->top 833 } 834 835 // TRACE (treeview,"[L:%d R:%d T:%d B:%d]\n", 833 lpRect->top = wineItem->rect.top; 834 } 835 836 // TRACE (treeview,"[L:%d R:%d T:%d B:%d]\n", 836 837 // lpRect->left,lpRect->right, 837 // 838 // lpRect->top,lpRect->bottom); 838 839 839 840 return TRUE; … … 875 876 876 877 if (tvItem->mask & TVIF_INTEGRAL) { 877 wineItem->iIntegral=tvItem->iIntegral; 878 wineItem->iIntegral=tvItem->iIntegral; 878 879 // FIXME (treeview," TVIF_INTEGRAL not supported yet\n"); 879 880 } … … 892 893 893 894 if (tvItem->mask & TVIF_TEXT) { 894 895 if (tvItem->pszText!=LPSTR_TEXTCALLBACKA) { 895 896 len=lstrlenA (tvItem->pszText); 896 if (len>wineItem->cchTextMax) 897 897 if (len>wineItem->cchTextMax) 898 wineItem->pszText= COMCTL32_ReAlloc (wineItem->pszText, len+1); 898 899 lstrcpynA (wineItem->pszText, tvItem->pszText,len); 899 900 901 902 903 904 905 900 } else { 901 if (wineItem->cchTextMax) { 902 COMCTL32_Free (wineItem->pszText); 903 wineItem->cchTextMax=0; 904 } 905 wineItem->pszText=LPSTR_TEXTCALLBACKA; 906 } 906 907 } 907 908 … … 918 919 { 919 920 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 920 921 921 TEXTMETRICA tm; 922 HBRUSH hbrBk; 922 923 RECT rect; 923 924 HDC hdc; 924 925 INT iItem, indent, x, y, cx, height, itemHeight; 925 926 INT viewtop,viewbottom,viewleft,viewright; … … 928 929 // TRACE (treeview,"\n"); 929 930 930 931 hdc=GetDC (hwnd); 931 932 932 933 if (infoPtr->Timer & TV_REFRESH_TIMER_SET) { 933 934 934 KillTimer (hwnd, TV_REFRESH_TIMER); 935 infoPtr->Timer &= ~TV_REFRESH_TIMER_SET; 935 936 } 936 937 937 938 938 939 GetClientRect (hwnd, &rect); 939 940 if ((rect.left-rect.right ==0) || (rect.top-rect.bottom==0)) return; 940 941 941 infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify 942 943 944 945 946 947 948 949 950 942 infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify 943 (hwnd, CDDS_PREPAINT, hdc, rect); 944 945 if (infoPtr->cdmode==CDRF_SKIPDEFAULT) { 946 ReleaseDC (hwnd, hdc); 947 return; 948 } 949 950 infoPtr->uVisibleHeight= rect.bottom-rect.top; 951 infoPtr->uVisibleWidth= rect.right-rect.left; 951 952 952 953 viewtop=infoPtr->cy; … … 958 959 959 960 /* draw background */ 960 961 961 962 hbrBk = GetSysColorBrush (COLOR_WINDOW); 962 963 FillRect(hdc, &rect, hbrBk); … … 971 972 972 973 while (iItem) { 973 974 prevItem=wineItem; 974 975 wineItem= & infoPtr->items[iItem]; 975 976 wineItem->iLevel=indent; 976 977 977 978 ImageList_GetIconSize (infoPtr->himlNormal, &cx, &itemHeight); 978 979 if (infoPtr->uItemHeight>itemHeight) 979 980 981 982 983 984 985 infoPtr->uRealItemHeight=itemHeight; 980 itemHeight=infoPtr->uItemHeight; 981 982 GetTextMetricsA (hdc, &tm); 983 if ((tm.tmHeight + tm.tmExternalLeading) > itemHeight) 984 itemHeight=tm.tmHeight + tm.tmExternalLeading; 985 986 infoPtr->uRealItemHeight=itemHeight; 986 987 987 988 988 989 /* FIXME: remove this in later stage */ 989 990 /* 990 // if (wineItem->pszText!=LPSTR_TEXTCALLBACK32A)991 // 992 // 993 // 994 // 995 // else996 // 997 // 998 // 999 // 991 // if (wineItem->pszText!=LPSTR_TEXTCALLBACK32A) 992 // TRACE (treeview, "%d %d [%d %d %d %d] (%s)\n",y,x, 993 // wineItem->rect.top, wineItem->rect.bottom, 994 // wineItem->rect.left, wineItem->rect.right, 995 // wineItem->pszText); 996 // else 997 // TRACE (treeview, "%d [%d %d %d %d] (CALLBACK)\n", 998 // wineItem->hItem, 999 // wineItem->rect.top, wineItem->rect.bottom, 1000 // wineItem->rect.left, wineItem->rect.right); 1000 1001 */ 1001 1002 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 if (x>infoPtr->uTotalWidth) 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1003 height=itemHeight * wineItem->iIntegral +1; 1004 if ((y >= viewtop) && (y <= viewbottom) && 1005 (x >= viewleft ) && (x <= viewright)) { 1006 wineItem->visible = TRUE; 1007 wineItem->rect.top = y - infoPtr->cy + rect.top; 1008 wineItem->rect.bottom = wineItem->rect.top + height ; 1009 wineItem->rect.left = x - infoPtr->cx + rect.left; 1010 wineItem->rect.right = rect.right; 1011 if (!infoPtr->firstVisible) 1012 infoPtr->firstVisible=wineItem->hItem; 1013 TREEVIEW_DrawItem (hwnd, hdc, wineItem); 1014 } 1015 else { 1016 wineItem->visible = FALSE; 1017 wineItem->rect.left = wineItem->rect.top = 0; 1018 wineItem->rect.right= wineItem->rect.bottom = 0; 1019 wineItem->text.left = wineItem->text.top = 0; 1020 wineItem->text.right= wineItem->text.bottom = 0; 1021 } 1022 1023 /* look up next item */ 1024 1025 if ((wineItem->firstChild) && (wineItem->state & TVIS_EXPANDED)) { 1026 iItem=(INT)wineItem->firstChild; 1027 indent++; 1028 x+=infoPtr->uIndent; 1029 if (x>infoPtr->uTotalWidth) 1030 infoPtr->uTotalWidth=x; 1031 } 1032 else { 1033 iItem=(INT)wineItem->sibling; 1034 while ((!iItem) && (indent>0)) { 1035 indent--; 1036 x-=infoPtr->uIndent; 1037 prevItem=wineItem; 1038 wineItem=&infoPtr->items[(INT)wineItem->parent]; 1039 iItem=(INT)wineItem->sibling; 1040 } 1041 } 1041 1042 y +=height; 1042 } 1043 } /* while */ 1043 1044 1044 1045 /* FIXME: infoPtr->uTotalWidth should also take item label into account */ … … 1047 1048 infoPtr->uTotalHeight=y; 1048 1049 if (y >= (viewbottom-viewtop)) { 1049 1050 1051 1052 SetScrollRange (hwnd, SB_VERT, 0,1053 1054 1055 1050 if (!(infoPtr->uInternalStatus & TV_VSCROLL)) 1051 ShowScrollBar (hwnd, SB_VERT, TRUE); 1052 infoPtr->uInternalStatus |=TV_VSCROLL; 1053 SetScrollRange (hwnd, SB_VERT, 0, 1054 y - infoPtr->uVisibleHeight, FALSE); 1055 SetScrollPos (hwnd, SB_VERT, infoPtr->cy, TRUE); 1056 } 1056 1057 else { 1057 if (infoPtr->uInternalStatus & TV_VSCROLL) 1058 1059 1060 1061 1062 1063 if (infoPtr->cdmode & CDRF_NOTIFYPOSTPAINT) 1064 infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify1065 1058 if (infoPtr->uInternalStatus & TV_VSCROLL) 1059 ShowScrollBar (hwnd, SB_VERT, FALSE); 1060 infoPtr->uInternalStatus &= ~TV_VSCROLL; 1061 } 1062 1063 1064 if (infoPtr->cdmode & CDRF_NOTIFYPOSTPAINT) 1065 infoPtr->cdmode=TREEVIEW_SendCustomDrawNotify 1066 (hwnd, CDDS_POSTPAINT, hdc, rect); 1066 1067 1067 1068 ReleaseDC (hwnd, hdc); … … 1070 1071 1071 1072 1072 static LRESULT 1073 static LRESULT 1073 1074 TREEVIEW_HandleTimer (HWND hwnd, WPARAM wParam, LPARAM lParam) 1074 1075 { … … 1079 1080 1080 1081 switch (wParam) { 1081 1082 1083 1082 case TV_REFRESH_TIMER: 1083 KillTimer (hwnd, TV_REFRESH_TIMER); 1084 infoPtr->Timer &= ~TV_REFRESH_TIMER_SET; 1084 1085 InvalidateRect(hwnd, NULL, FALSE); 1085 1086 1087 1088 1089 1090 1091 // 1092 1086 return 0; 1087 case TV_EDIT_TIMER: 1088 KillTimer (hwnd, TV_EDIT_TIMER); 1089 infoPtr->Timer &= ~TV_EDIT_TIMER_SET; 1090 return 0; 1091 default: 1092 // ERR (treeview,"got unknown timer\n"); 1093 break; 1093 1094 } 1094 1095 1095 1096 return 1; 1096 1097 } … … 1105 1106 // TRACE (treeview,"\n"); 1106 1107 if (infoPtr->Timer & TV_REFRESH_TIMER_SET) { 1107 1108 KillTimer (hwnd, TV_REFRESH_TIMER); 1108 1109 } 1109 1110 … … 1129 1130 1130 1131 if (tvItem->mask & TVIF_CHILDREN) { 1131 // if (TVIF_CHILDREN==I_CHILDRENCALLBACK)1132 // 1132 // if (TVIF_CHILDREN==I_CHILDRENCALLBACK) 1133 // FIXME (treeview,"I_CHILDRENCALLBACK not supported\n"); 1133 1134 tvItem->cChildren=wineItem->cChildren; 1134 1135 } … … 1143 1144 1144 1145 if (tvItem->mask & TVIF_INTEGRAL) { 1145 tvItem->iIntegral=wineItem->iIntegral; 1146 // 1146 tvItem->iIntegral=wineItem->iIntegral; 1147 // FIXME (treeview," TVIF_INTEGRAL not supported yet\n"); 1147 1148 } 1148 1149 … … 1160 1161 1161 1162 if (tvItem->mask & TVIF_TEXT) { 1162 1163 1164 // 1165 1166 1167 1168 1163 if (wineItem->pszText == LPSTR_TEXTCALLBACKA) { 1164 tvItem->pszText = LPSTR_TEXTCALLBACKA; /* FIXME:send notification? */ 1165 // ERR (treeview," GetItem called with LPSTR_TEXTCALLBACK\n"); 1166 } 1167 else if (wineItem->pszText) { 1168 lstrcpynA (tvItem->pszText, wineItem->pszText, tvItem->cchTextMax); 1169 } 1169 1170 } 1170 1171 1171 // TRACE(treeview,"item %d<%p>, txt %p, img %p, action %x\n", 1172 // TRACE(treeview,"item %d<%p>, txt %p, img %p, action %x\n", 1172 1173 // iItem, 1173 // tvItem, 1174 // tvItem->pszText, 1175 // & tvItem->iImage, 1174 // tvItem, 1175 // tvItem->pszText, 1176 // & tvItem->iImage, 1176 1177 // tvItem->mask); 1177 1178 … … 1197 1198 retval=0; 1198 1199 switch (flag) { 1199 1200 1201 1202 1203 case TVGN_FIRSTVISIBLE: 1204 TREEVIEW_Refresh (hwnd);1200 case TVGN_ROOT: retval=(INT)infoPtr->TopRootItem; 1201 break; 1202 case TVGN_CARET:retval=(INT)infoPtr->selectedItem; 1203 break; 1204 case TVGN_FIRSTVISIBLE: 1205 TREEVIEW_Refresh (hwnd); 1205 1206 /* FIXME:we should only recalculate, not redraw */ 1206 1207 1208 1209 1210 1211 1207 retval=(INT)infoPtr->firstVisible; 1208 break; 1209 case TVGN_DROPHILITE: 1210 retval=(INT)infoPtr->dropItem; 1211 break; 1212 } 1212 1213 if (retval) { 1213 // 1214 1215 } 1216 1214 // TRACE (treeview,"flags:%x, returns %u\n", flag, retval); 1215 return retval; 1216 } 1217 1217 1218 wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)iItem); 1218 1219 returnItem = NULL; 1219 1220 if (!wineItem) return FALSE; 1220 1221 1221 switch (flag) 1222 1223 1224 case TVGN_PREVIOUS: 1225 1226 1227 1228 1229 1230 1231 1232 1233 case TVGN_LASTVISIBLE: 1234 1235 1236 case TVGN_NEXTVISIBLE: 1237 1238 1239 case TVGN_PREVIOUSVISIBLE: 1240 1241 1242 default: //FIXME (treeview,"Unknown msg %x,item %x\n", flag,iItem);1243 1244 1222 switch (flag) { 1223 case TVGN_NEXT: retval=(INT)wineItem->sibling; 1224 break; 1225 case TVGN_PREVIOUS: 1226 retval=(INT)wineItem->upsibling; 1227 break; 1228 case TVGN_PARENT: 1229 retval=(INT)wineItem->parent; 1230 break; 1231 case TVGN_CHILD: 1232 retval=(INT)wineItem->firstChild; 1233 break; 1234 case TVGN_LASTVISIBLE: 1235 returnItem=TREEVIEW_GetLastListItem (infoPtr,wineItem); 1236 break; 1237 case TVGN_NEXTVISIBLE: 1238 returnItem=TREEVIEW_GetNextListItem (infoPtr,wineItem); 1239 break; 1240 case TVGN_PREVIOUSVISIBLE: 1241 returnItem=TREEVIEW_GetPrevListItem (infoPtr, wineItem); 1242 break; 1243 default: // FIXME (treeview,"Unknown msg %x,item %x\n", flag,iItem); 1244 break; 1245 } 1245 1246 1246 1247 if (returnItem) { 1247 // 1248 // 1249 1248 // TRACE (treeview,"flags:%x, item %d;returns %d\n", flag, iItem, 1249 // (INT)returnItem->hItem); 1250 return (INT)returnItem->hItem; 1250 1251 } 1251 1252 … … 1265 1266 1266 1267 /*************************************************************************** 1267 * This method does the chaining of the insertion of a treeview item 1268 * This method does the chaining of the insertion of a treeview item 1268 1269 * before an item. 1269 1270 */ 1270 1271 static void TREEVIEW_InsertBefore( 1271 1272 TREEVIEW_INFO *infoPtr, 1272 TREEVIEW_ITEM *newItem, 1273 TREEVIEW_ITEM *newItem, 1273 1274 TREEVIEW_ITEM *sibling, 1274 1275 TREEVIEW_ITEM *parent) … … 1285 1286 1286 1287 if (sibling != NULL) /* Insert before this sibling for this parent */ 1287 { 1288 { 1288 1289 /* Store the new item sibling up sibling and sibling tem handle */ 1289 1290 siblingHandle = sibling->hItem; … … 1292 1293 if ( (INT)sibling->upsibling != 0 ) 1293 1294 upSibling = &infoPtr->items[(INT)sibling->upsibling]; 1294 1295 1295 1296 /* Adjust the sibling pointer */ 1296 1297 sibling->upsibling = newItem->hItem; 1297 1298 1298 1299 /* Adjust the new item pointers */ 1299 1300 newItem->upsibling = upSiblingHandle; 1300 1301 newItem->sibling = siblingHandle; 1301 1302 1302 1303 /* Adjust the up sibling pointer */ 1303 if ( upSibling != NULL ) 1304 if ( upSibling != NULL ) 1304 1305 upSibling->sibling = newItem->hItem; 1305 1306 else … … 1312 1313 1313 1314 /*************************************************************************** 1314 * This method does the chaining of the insertion of a treeview item 1315 * This method does the chaining of the insertion of a treeview item 1315 1316 * after an item. 1316 1317 */ 1317 1318 static void TREEVIEW_InsertAfter( 1318 1319 TREEVIEW_INFO *infoPtr, 1319 TREEVIEW_ITEM *newItem, 1320 TREEVIEW_ITEM *newItem, 1320 1321 TREEVIEW_ITEM *upSibling, 1321 1322 TREEVIEW_ITEM *parent) … … 1332 1333 1333 1334 if (upSibling != NULL) /* Insert after this upsibling for this parent */ 1334 { 1335 { 1335 1336 /* Store the new item up sibling and sibling item handle */ 1336 1337 upSiblingHandle = upSibling->hItem; … … 1339 1340 if ( (INT)upSibling->sibling != 0 ) 1340 1341 sibling = &infoPtr->items[(INT)upSibling->sibling]; 1341 1342 1342 1343 /* Adjust the up sibling pointer */ 1343 1344 upSibling->sibling = newItem->hItem; 1344 1345 1345 1346 /* Adjust the new item pointers */ 1346 1347 newItem->upsibling = upSiblingHandle; 1347 1348 newItem->sibling = siblingHandle; 1348 1349 1349 1350 /* Adjust the sibling pointer */ 1350 if ( sibling != NULL ) 1351 sibling->upsibling = newItem->hItem; 1351 if ( sibling != NULL ) 1352 sibling->upsibling = newItem->hItem; 1352 1353 /* 1353 else 1354 newItem is the last of the level, nothing else to do 1354 else 1355 newItem is the last of the level, nothing else to do 1355 1356 */ 1356 1357 } … … 1362 1363 * Forward the DPA local callback to the treeview owner callback 1363 1364 */ 1364 static INT WINAPI TREEVIEW_CallBackCompare( 1365 LPVOID first, 1366 LPVOID second, 1365 static INT WINAPI TREEVIEW_CallBackCompare( 1366 LPVOID first, 1367 LPVOID second, 1367 1368 LPARAM tvInfoPtr) 1368 1369 { … … 1380 1381 */ 1381 1382 LRESULT WINAPI TREEVIEW_SortChildrenCB( 1382 HWND hwnd, 1383 WPARAM wParam, 1383 HWND hwnd, 1384 WPARAM wParam, 1384 1385 LPARAM lParam) 1385 1386 { … … 1390 1391 infoPtr->pCallBackSort = (LPTVSORTCB)lParam; 1391 1392 1392 /* Obtain the parent node to sort */ 1393 /* Obtain the parent node to sort */ 1393 1394 sortMe = &infoPtr->items[ (INT)infoPtr->pCallBackSort->hParent ]; 1394 1395 1395 1396 /* Make sure there is something to sort */ 1396 if ( sortMe->cChildren > 1 ) 1397 if ( sortMe->cChildren > 1 ) 1397 1398 { 1398 1399 /* pointer organization */ … … 1408 1409 1409 1410 /* Build the list of item to sort */ 1410 do 1411 do 1411 1412 { 1412 1413 DPA_InsertPtr( 1413 1414 sortList, /* the list */ 1414 1415 sortMe->cChildren+1, /* force the insertion to be an append */ 1415 itemPtr); /* the ptr to store */ 1416 itemPtr); /* the ptr to store */ 1416 1417 1417 1418 /* Get the next sibling */ … … 1422 1423 /* let DPA perform the sort activity */ 1423 1424 DPA_Sort( 1424 sortList, /* what */ 1425 sortList, /* what */ 1425 1426 TREEVIEW_CallBackCompare, /* how */ 1426 1427 hwnd); /* owner */ 1427 1428 1428 /* 1429 * Reorganized TREEVIEW_ITEM structures. 1429 /* 1430 * Reorganized TREEVIEW_ITEM structures. 1430 1431 * Note that we know we have at least two elements. 1431 1432 */ 1432 1433 1433 1434 /* Get the first item and get ready to start... */ 1434 item = DPA_GetPtr(sortList, count++); 1435 item = DPA_GetPtr(sortList, count++); 1435 1436 while ( (nextItem = DPA_GetPtr(sortList, count++)) != NULL ) 1436 1437 { … … 1450 1451 1451 1452 /* get ready for the next one */ 1452 prevItem = item; 1453 prevItem = item; 1453 1454 item = nextItem; 1454 1455 } 1455 1456 1456 1457 /* the last item is pointed to by item and never has a sibling */ 1457 ((TREEVIEW_ITEM*)item)->sibling = NULL; 1458 ((TREEVIEW_ITEM*)item)->sibling = NULL; 1458 1459 1459 1460 DPA_Destroy(sortList); … … 1465 1466 1466 1467 1467 /* the method used below isn't the most memory-friendly, but it avoids 1468 a lot of memory reallocations */ 1468 /* the method used below isn't the most memory-friendly, but it avoids 1469 a lot of memory reallocations */ 1469 1470 1470 1471 /* BTW: we waste handle 0; 0 is not an allowed handle. */ … … 1476 1477 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 1477 1478 TVINSERTSTRUCTA *ptdi; 1478 TVITEMEXA 1479 TVITEMEXA *tvItem; 1479 1480 TREEVIEW_ITEM *wineItem, *parentItem, *prevsib, *sibItem; 1480 INT 1481 1481 INT iItem,listItems,i,len; 1482 1482 1483 /* Item to insert */ 1483 1484 ptdi = (LPTVINSERTSTRUCTA) lParam; 1484 1485 1485 1486 /* check if memory is available */ 1486 1487 1487 1488 if (infoPtr->uNumPtrsAlloced==0) { … … 1489 1490 infoPtr->freeList= COMCTL32_Alloc ((1+(TVITEM_ALLOC>>5)) * sizeof (INT)); 1490 1491 infoPtr->uNumPtrsAlloced=TVITEM_ALLOC; 1491 1492 infoPtr->TopRootItem=(HTREEITEM)1; 1492 1493 } 1493 1494 1494 /* 1495 * Reallocate contiguous space for items 1495 /* 1496 * Reallocate contiguous space for items 1496 1497 */ 1497 1498 if (infoPtr->uNumItems == (infoPtr->uNumPtrsAlloced-1) ) { 1498 1499 1500 1501 1499 TREEVIEW_ITEM *oldItems = infoPtr->items; 1500 INT *oldfreeList = infoPtr->freeList; 1501 1502 infoPtr->uNumPtrsAlloced*=2; 1502 1503 infoPtr->items = COMCTL32_Alloc (infoPtr->uNumPtrsAlloced*sizeof (TREEVIEW_ITEM)); 1503 1504 infoPtr->freeList= COMCTL32_Alloc ((1+(infoPtr->uNumPtrsAlloced>>5))*sizeof (INT)); … … 1508 1509 infoPtr->uNumPtrsAlloced>>6 * sizeof(INT)); 1509 1510 1510 COMCTL32_Free (oldItems); 1511 COMCTL32_Free (oldfreeList); 1511 COMCTL32_Free (oldItems); 1512 COMCTL32_Free (oldfreeList); 1512 1513 } 1513 1514 1514 /* 1515 /* 1515 1516 * Reset infoPtr structure with new stat according to current TV picture 1516 1517 */ 1517 1518 iItem=0; 1518 1519 infoPtr->uNumItems++; 1519 if ((INT)infoPtr->uMaxHandle==(infoPtr->uNumItems-1)) { 1520 1521 1522 } else { 1523 1524 1520 if ((INT)infoPtr->uMaxHandle==(infoPtr->uNumItems-1)) { 1521 iItem=infoPtr->uNumItems; 1522 infoPtr->uMaxHandle = (HTREEITEM)((INT)infoPtr->uMaxHandle + 1); 1523 } else { /* check freelist */ 1524 for (i=0; i<infoPtr->uNumPtrsAlloced>>5; i++) { 1525 if (infoPtr->freeList[i]) { 1525 1526 // WHAT IS FFS? NOT IN VAC++ C LIBRARY!!! 1526 // 1527 // iItem=ffs (infoPtr->freeList[i])-1; 1527 1528 // 1528 1529 1530 1531 1532 } 1533 } 1534 1535 // if (TRACE_ON(treeview)) { 1536 // for (i=0; i<infoPtr->uNumPtrsAlloced>>5; i++) 1537 // 1529 tv_clear_bit(iItem,&infoPtr->freeList[i]); 1530 iItem+=i<<5; 1531 break; 1532 } 1533 } 1534 } 1535 1536 // if (TRACE_ON(treeview)) { 1537 // for (i=0; i<infoPtr->uNumPtrsAlloced>>5; i++) 1538 // TRACE (treeview,"%8x\n",infoPtr->freeList[i]); 1538 1539 // } 1539 1540 1540 1541 // if (!iItem) ERR (treeview, "Argh -- can't find free item.\n"); 1541 1542 1542 /* 1543 * Find the parent item of the new item 1544 */ 1543 /* 1544 * Find the parent item of the new item 1545 */ 1545 1546 tvItem= & ptdi->DUMMYUNIONNAME.itemex; 1546 1547 wineItem=& infoPtr->items[iItem]; … … 1548 1549 if ((ptdi->hParent==TVI_ROOT) || (ptdi->hParent==0)) { 1549 1550 parentItem = NULL; 1550 wineItem->parent = 0; 1551 wineItem->parent = 0; 1551 1552 sibItem = &infoPtr->items [(INT)infoPtr->TopRootItem]; 1552 1553 listItems = infoPtr->uNumItems; 1553 1554 } 1554 1555 else { 1555 1556 1556 parentItem = &infoPtr->items[(INT)ptdi->hParent]; 1557 1557 1558 /* Do the insertion here it if it's the only item of this parent */ 1558 if (!parentItem->firstChild)1559 1560 1561 1562 1563 1564 1565 } 1566 1567 1568 /* NOTE: I am moving some setup of the wineItem object that was initialy 1569 * done at the end of the function since some of the values are 1570 * required by the Callback sorting 1559 if (!parentItem->firstChild) 1560 parentItem->firstChild=(HTREEITEM)iItem; 1561 1562 wineItem->parent = ptdi->hParent; 1563 sibItem = &infoPtr->items [(INT)parentItem->firstChild]; 1564 parentItem->cChildren++; 1565 listItems = parentItem->cChildren; 1566 } 1567 1568 1569 /* NOTE: I am moving some setup of the wineItem object that was initialy 1570 * done at the end of the function since some of the values are 1571 * required by the Callback sorting 1571 1572 */ 1572 1573 1573 if (tvItem->mask & TVIF_TEXT) 1574 if (tvItem->mask & TVIF_TEXT) 1574 1575 { 1575 1576 /* … … 1577 1578 * when the insertion are ordered 1578 1579 */ 1579 if (tvItem->pszText!=LPSTR_TEXTCALLBACKA) 1580 if (tvItem->pszText!=LPSTR_TEXTCALLBACKA) 1580 1581 { 1581 // TRACE (treeview,"(%p,%s)\n", &tvItem->pszText, tvItem->pszText); 1582 // TRACE (treeview,"(%p,%s)\n", &tvItem->pszText, tvItem->pszText); 1582 1583 len = lstrlenA (tvItem->pszText)+1; 1583 1584 wineItem->pszText= COMCTL32_Alloc (len+1); … … 1585 1586 wineItem->cchTextMax=len; 1586 1587 } 1587 else 1588 else 1588 1589 { 1589 1590 // TRACE (treeview,"LPSTR_TEXTCALLBACK\n"); … … 1593 1594 } 1594 1595 1595 if (tvItem->mask & TVIF_PARAM) 1596 if (tvItem->mask & TVIF_PARAM) 1596 1597 wineItem->lParam=tvItem->lParam; 1597 1598 1598 1599 1599 wineItem->upsibling=0; /* needed in case we're the first item in a list */ 1600 wineItem->sibling=0; 1600 wineItem->upsibling=0; /* needed in case we're the first item in a list */ 1601 wineItem->sibling=0; 1601 1602 wineItem->firstChild=0; 1602 1603 wineItem->hItem=(HTREEITEM)iItem; … … 1606 1607 1607 1608 switch ((DWORD) ptdi->hInsertAfter) { 1608 case (DWORD) TVI_FIRST: 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 case (DWORD) TVI_SORT: 1620 if (sibItem==wineItem)1621 /* 1622 * This item is the first child of the level and it 1623 * has already been inserted 1624 */ 1625 break; 1609 case (DWORD) TVI_FIRST: 1610 if (wineItem->parent) { 1611 wineItem->sibling=parentItem->firstChild; 1612 parentItem->firstChild=(HTREEITEM)iItem; 1613 } else { 1614 wineItem->sibling=infoPtr->TopRootItem; 1615 infoPtr->TopRootItem=(HTREEITEM)iItem; 1616 } 1617 sibItem->upsibling=(HTREEITEM)iItem; 1618 break; 1619 1620 case (DWORD) TVI_SORT: 1621 if (sibItem==wineItem) 1622 /* 1623 * This item is the first child of the level and it 1624 * has already been inserted 1625 */ 1626 break; 1626 1627 else 1627 1628 { 1628 TREEVIEW_ITEM *aChild = 1629 TREEVIEW_ITEM *aChild = 1629 1630 &infoPtr->items[(INT)parentItem->firstChild]; 1630 1631 1631 1632 TREEVIEW_ITEM *previousChild = NULL; 1632 1633 BOOL bItemInserted = FALSE; 1633 1634 1634 1635 /* Iterate the parent children to see where we fit in */ 1635 1636 while ( aChild != NULL ) … … 1648 1649 ? NULL /* if there is no more sibling */ 1649 1650 : &infoPtr->items[(INT)aChild->sibling]; 1650 1651 1651 1652 /* Look at the next item */ 1652 1653 continue; … … 1654 1655 else if ( comp == 0 ) 1655 1656 { 1656 /* 1657 * An item with this name is already existing, therefore, 1658 * we add after the one we found 1657 /* 1658 * An item with this name is already existing, therefore, 1659 * we add after the one we found 1659 1660 */ 1660 1661 TREEVIEW_InsertAfter(infoPtr, wineItem, aChild, parentItem); … … 1663 1664 } 1664 1665 } 1665 1666 /* 1666 1667 /* 1667 1668 * we reach the end of the child list and the item as not 1668 1669 * yet been inserted, therefore, insert it after the last child. … … 1670 1671 if ( (! bItemInserted ) && (aChild == NULL) ) 1671 1672 TREEVIEW_InsertAfter(infoPtr, wineItem, previousChild, parentItem); 1672 1673 1673 1674 break; 1674 1675 } 1675 1676 1676 1677 1677 case (DWORD) TVI_LAST: 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1678 case (DWORD) TVI_LAST: 1679 if (sibItem==wineItem) break; 1680 while (sibItem->sibling) { 1681 prevsib=sibItem; 1682 sibItem=&infoPtr->items [(INT)sibItem->sibling]; 1683 } 1684 sibItem->sibling=(HTREEITEM)iItem; 1685 wineItem->upsibling=sibItem->hItem; 1686 break; 1687 default: 1688 while ((sibItem->sibling) && (sibItem->hItem!=ptdi->hInsertAfter)) 1689 { 1690 prevsib=sibItem; 1690 1691 sibItem=&infoPtr->items [(INT)sibItem->sibling]; 1691 1692 } 1692 1693 // 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 } 1693 if (sibItem->hItem!=ptdi->hInsertAfter) { 1694 // ERR (treeview, "tried to insert item after nonexisting handle.\n"); 1695 break; 1696 } 1697 prevsib=sibItem; 1698 if (sibItem->sibling) { 1699 sibItem=&infoPtr->items [(INT)sibItem->sibling]; 1700 sibItem->upsibling=(HTREEITEM)iItem; 1701 wineItem->sibling=sibItem->hItem; 1702 } 1703 prevsib->sibling=(HTREEITEM)iItem; 1704 wineItem->upsibling=prevsib->hItem; 1705 break; 1706 } 1707 } 1707 1708 1708 1709 1709 1710 /* Fill in info structure */ 1710 1711 1711 // TRACE (treeview,"new item %d; parent %d, mask %x\n", iItem, 1712 // 1712 // TRACE (treeview,"new item %d; parent %d, mask %x\n", iItem, 1713 // (INT)wineItem->parent,tvItem->mask); 1713 1714 1714 1715 wineItem->mask=tvItem->mask; 1715 wineItem->iIntegral=1; 1716 wineItem->iIntegral=1; 1716 1717 1717 1718 if (tvItem->mask & TVIF_CHILDREN) { 1718 1719 // if (tvItem->cChildren==I_CHILDRENCALLBACK)1720 // 1721 1719 wineItem->cChildren=tvItem->cChildren; 1720 // if (tvItem->cChildren==I_CHILDRENCALLBACK) 1721 // FIXME (treeview," I_CHILDRENCALLBACK not supported\n"); 1722 } 1722 1723 1723 1724 wineItem->expandBox.left = 0; /* Initialize the expandBox */ … … 1726 1727 wineItem->expandBox.bottom = 0; 1727 1728 1728 if (tvItem->mask & TVIF_IMAGE) 1729 1730 1731 1732 1733 1734 if (tvItem->mask & TVIF_INTEGRAL) 1735 wineItem->iIntegral=tvItem->iIntegral;1736 1737 if (tvItem->mask & TVIF_SELECTEDIMAGE) 1738 1729 if (tvItem->mask & TVIF_IMAGE) 1730 wineItem->iImage=tvItem->iImage; 1731 1732 /* If the application sets TVIF_INTEGRAL without 1733 supplying a TVITEMEX structure, it's toast */ 1734 1735 if (tvItem->mask & TVIF_INTEGRAL) 1736 wineItem->iIntegral=tvItem->iIntegral; 1737 1738 if (tvItem->mask & TVIF_SELECTEDIMAGE) 1739 wineItem->iSelectedImage=tvItem->iSelectedImage; 1739 1740 1740 1741 if (tvItem->mask & TVIF_STATE) { 1741 // TRACE(treeview, "Changing item state from %d to %d\n", 1742 // wineItem->state, 1742 // TRACE(treeview, "Changing item state from %d to %d\n", 1743 // wineItem->state, 1743 1744 // tvItem->state); 1744 1745 1745 wineItem->state=tvItem->state; 1746 wineItem->stateMask=tvItem->stateMask; 1746 1747 } 1747 1748 … … 1767 1768 1768 1769 if (lParam == (INT)TVI_ROOT) { 1769 1770 TREEVIEW_RemoveTree (hwnd); 1770 1771 } else { 1771 1772 1773 1772 iItem= (INT) lParam; 1773 wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)iItem); 1774 if (!wineItem) return FALSE; 1774 1775 // TRACE (treeview,"%s\n",wineItem->pszText); 1775 1776 TREEVIEW_RemoveItem (hwnd, wineItem); 1776 1777 } 1777 1778 … … 1797 1798 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 1798 1799 INT newIndent; 1799 1800 1800 1801 // TRACE (treeview,"\n"); 1801 1802 newIndent=(INT) wParam; 1802 1803 if (newIndent < MINIMUM_INDENT) newIndent=MINIMUM_INDENT; 1803 1804 infoPtr->uIndent=newIndent; 1804 1805 1805 1806 return 0; 1806 1807 } … … 1842 1843 1843 1844 LRESULT CALLBACK 1844 TREEVIEW_Edit_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, 1845 1846 { 1847 switch (uMsg) 1845 TREEVIEW_Edit_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, 1846 LPARAM lParam) 1847 { 1848 switch (uMsg) 1848 1849 { 1849 case WM_ERASEBKGND: 1850 case WM_ERASEBKGND: 1850 1851 { 1851 1852 RECT rc; … … 1879 1880 { 1880 1881 // TRACE (treeview, "%x %ld\n",wParam, lParam); 1881 1882 switch (HIWORD(wParam)) 1882 1883 switch (HIWORD(wParam)) 1883 1884 { 1884 1885 case EN_UPDATE: 1885 1886 { 1886 /* 1887 * Adjust the edit window size 1887 /* 1888 * Adjust the edit window size 1888 1889 */ 1889 1890 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); … … 1896 1897 { 1897 1898 LONG newWidth = (iLength * tm.tmAveCharWidth) + 15; 1898 1899 SetWindowPos (1899 1900 SetWindowPos ( 1900 1901 infoPtr->hwndEdit, 1901 HWND_TOP, 1902 editItem->text.left - 2, 1902 HWND_TOP, 1903 editItem->text.left - 2, 1903 1904 editItem->text.top - 1, 1904 1905 newWidth, … … 1912 1913 1913 1914 case EN_KILLFOCUS: 1914 /* TREEVIEW_EndEditLabelNow(hwnd, (WPARAM)FALSE, 0); 1915 /* TREEVIEW_EndEditLabelNow(hwnd, (WPARAM)FALSE, 0); 1915 1916 */ 1916 1917 break; … … 1929 1930 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 1930 1931 1931 if (infoPtr->bAutoSize) 1932 if (infoPtr->bAutoSize) 1932 1933 { 1933 1934 infoPtr->bAutoSize = FALSE; … … 1936 1937 infoPtr->bAutoSize = TRUE; 1937 1938 1938 if (wParam == SIZE_RESTORED) 1939 if (wParam == SIZE_RESTORED) 1939 1940 { 1940 1941 infoPtr->uTotalWidth = LOWORD (lParam); 1941 1942 infoPtr->uTotalHeight = HIWORD (lParam); 1942 1943 } else { 1943 // 1944 // FIXME (treeview,"WM_SIZE flag %x %lx not handled\n", wParam, lParam); 1944 1945 } 1945 1946 … … 1956 1957 1957 1958 // TRACE (treeview,"(%x %lx)\n",wParam,lParam); 1958 1959 if (wParam & (GWL_STYLE)) 1960 1961 if (wParam & (GWL_EXSTYLE)) 1962 1959 1960 if (wParam & (GWL_STYLE)) 1961 SetWindowLongA( hwnd, GWL_STYLE, lpss->styleNew); 1962 if (wParam & (GWL_EXSTYLE)) 1963 SetWindowLongA( hwnd, GWL_STYLE, lpss->styleNew); 1963 1964 1964 1965 return 0; … … 1969 1970 { 1970 1971 TREEVIEW_INFO *infoPtr; 1971 1972 LOGFONTA logFont; 1972 1973 TEXTMETRICA tm; 1973 1974 1974 HDC hdc; 1975 1975 1976 // TRACE (treeview,"wnd %x\n",hwnd); 1976 1977 /* allocate memory for info structure */ … … 1980 1981 1981 1982 if (infoPtr == NULL) { 1982 // 1983 1983 // ERR (treeview, "could not allocate info memory!\n"); 1984 return 0; 1984 1985 } 1985 1986 1986 1987 if ((TREEVIEW_INFO*) GetWindowLongA( hwnd, 0) != infoPtr) { 1987 // 1988 1988 // ERR (treeview, "pointer assignment error!\n"); 1989 return 0; 1989 1990 } 1990 1991 1991 1992 hdc=GetDC (hwnd); 1992 1993 1993 1994 /* set default settings */ … … 2001 2002 infoPtr->himlNormal = NULL; 2002 2003 infoPtr->himlState = NULL; 2003 2004 infoPtr->uItemHeight = -1; 2004 2005 GetTextMetricsA (hdc, &tm); 2005 2006 infoPtr->hFont = GetStockObject (DEFAULT_GUI_FONT); 2006 2007 2007 GetObjectA (infoPtr->hFont, sizeof (LOGFONTA), &logFont); 2008 logFont.lfWeight=FW_BOLD; 2008 2009 infoPtr->hBoldFont = CreateFontIndirectA (&logFont); 2009 2010 2010 2011 infoPtr->items = NULL; 2011 2012 infoPtr->selectedItem=0; 2012 infoPtr->clrText=-1; 2013 infoPtr->clrText=-1; /* use system color */ 2013 2014 infoPtr->dropItem=0; 2014 2015 infoPtr->pCallBackSort=NULL; … … 2019 2020 */ 2020 2021 2021 2022 infoPtr->hwndToolTip=0; 2022 2023 if (!( GetWindowLongA( hwnd, GWL_STYLE) & TVS_NOTOOLTIPS)) { /* Create tooltip control */ 2023 2024 2025 infoPtr->hwndToolTip = 2026 2024 TTTOOLINFOA ti; 2025 2026 infoPtr->hwndToolTip = 2027 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0, 2027 2028 CW_USEDEFAULT, CW_USEDEFAULT, 2028 2029 CW_USEDEFAULT, CW_USEDEFAULT, … … 2042 2043 } 2043 2044 2044 2045 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 2045 2046 ti.cbSize = sizeof(TTTOOLINFOA); 2046 2047 ti.uFlags = TTF_IDISHWND | TTF_TRACK | TTF_TRANSPARENT ; … … 2053 2054 } 2054 2055 2055 infoPtr->hwndEdit = CreateWindowExA (2056 WS_EX_LEFT, 2056 infoPtr->hwndEdit = CreateWindowExA ( 2057 WS_EX_LEFT, 2057 2058 "EDIT", 2058 2059 0, 2059 WS_CHILD | WS_BORDER | ES_AUTOHSCROLL | 2060 WS_CHILD | WS_BORDER | ES_AUTOHSCROLL | 2060 2061 ES_WANTRETURN | ES_LEFT, 2061 2062 0, 0, 0, 0, 2062 hwnd, 2063 hwnd, 2063 2064 0,0,0); /* FIXME: (HMENU)IDTVEDIT,pcs->hInstance,0);*/ 2064 2065 2065 2066 SendMessageA ( infoPtr->hwndEdit, WM_SETFONT, infoPtr->hFont, FALSE); 2066 2067 infoPtr->wpEditOrig = (WNDPROC)SetWindowLongA ( 2067 2068 infoPtr->hwndEdit, 2068 GWL_WNDPROC, 2069 2069 GWL_WNDPROC, 2070 (LONG) TREEVIEW_Edit_SubclassProc); 2070 2071 2071 2072 ReleaseDC (hwnd, hdc); … … 2075 2076 2076 2077 2077 static LRESULT 2078 TREEVIEW_Destroy (HWND hwnd) 2078 static LRESULT 2079 TREEVIEW_Destroy (HWND hwnd) 2079 2080 { 2080 2081 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); 2081 2082 2082 2083 // TRACE (treeview,"\n"); 2083 2084 TREEVIEW_RemoveTree (hwnd); 2084 if (infoPtr->Timer & TV_REFRESH_TIMER_SET) 2085 if (infoPtr->Timer & TV_REFRESH_TIMER_SET) 2085 2086 KillTimer (hwnd, TV_REFRESH_TIMER); 2086 if (infoPtr->hwndToolTip) 2087 2087 if (infoPtr->hwndToolTip) 2088 DestroyWindow (infoPtr->hwndToolTip); 2088 2089 2089 2090 COMCTL32_Free (infoPtr); … … 2104 2105 EndPaint (hwnd, &ps); 2105 2106 // TRACE (treeview,"done\n"); 2106 2107 2107 2108 return DefWindowProcA (hwnd, WM_PAINT, wParam, lParam); 2108 2109 } … … 2142 2143 2143 2144 2144 2145 2145 2146 /* Notifications */ 2146 2147 2147 2148 2148 2149 2149 2150 … … 2166 2167 2167 2168 static BOOL 2168 TREEVIEW_SendTreeviewNotify (HWND hwnd, UINT code, UINT action, 2169 2169 TREEVIEW_SendTreeviewNotify (HWND hwnd, UINT code, UINT action, 2170 HTREEITEM oldItem, HTREEITEM newItem) 2170 2171 2171 2172 { … … 2175 2176 2176 2177 // TRACE (treeview,"code:%x action:%x olditem:%x newitem:%x\n", 2177 // 2178 // code,action,(INT)oldItem,(INT)newItem); 2178 2179 nmhdr.hdr.hwndFrom = hwnd; 2179 2180 nmhdr.hdr.idFrom = GetWindowLongA( hwnd, GWL_ID); … … 2181 2182 nmhdr.action = action; 2182 2183 if (oldItem) { 2183 2184 nmhdr.itemOld.mask= wineItem->mask;2185 nmhdr.itemOld.hItem= wineItem->hItem;2186 nmhdr.itemOld.state= wineItem->state;2187 nmhdr.itemOld.stateMask= wineItem->stateMask;2188 nmhdr.itemOld.iImage= wineItem->iImage;2189 nmhdr.itemOld.pszText= wineItem->pszText;2190 2191 nmhdr.itemOld.iImage= wineItem->iImage;2192 nmhdr.itemOld.iSelectedImage= wineItem->iSelectedImage;2193 2194 nmhdr.itemOld.lParam= wineItem->lParam;2184 wineItem=& infoPtr->items[(INT)oldItem]; 2185 nmhdr.itemOld.mask = wineItem->mask; 2186 nmhdr.itemOld.hItem = wineItem->hItem; 2187 nmhdr.itemOld.state = wineItem->state; 2188 nmhdr.itemOld.stateMask = wineItem->stateMask; 2189 nmhdr.itemOld.iImage = wineItem->iImage; 2190 nmhdr.itemOld.pszText = wineItem->pszText; 2191 nmhdr.itemOld.cchTextMax= wineItem->cchTextMax; 2192 nmhdr.itemOld.iImage = wineItem->iImage; 2193 nmhdr.itemOld.iSelectedImage = wineItem->iSelectedImage; 2194 nmhdr.itemOld.cChildren = wineItem->cChildren; 2195 nmhdr.itemOld.lParam = wineItem->lParam; 2195 2196 } 2196 2197 2197 2198 if (newItem) { 2198 2199 nmhdr.itemNew.mask= wineItem->mask;2200 nmhdr.itemNew.hItem= wineItem->hItem;2201 nmhdr.itemNew.state= wineItem->state;2202 nmhdr.itemNew.stateMask= wineItem->stateMask;2203 nmhdr.itemNew.iImage= wineItem->iImage;2204 nmhdr.itemNew.pszText= wineItem->pszText;2205 2206 nmhdr.itemNew.iImage= wineItem->iImage;2207 nmhdr.itemNew.iSelectedImage= wineItem->iSelectedImage;2208 2209 nmhdr.itemNew.lParam= wineItem->lParam;2199 wineItem=& infoPtr->items[(INT)newItem]; 2200 nmhdr.itemNew.mask = wineItem->mask; 2201 nmhdr.itemNew.hItem = wineItem->hItem; 2202 nmhdr.itemNew.state = wineItem->state; 2203 nmhdr.itemNew.stateMask = wineItem->stateMask; 2204 nmhdr.itemNew.iImage = wineItem->iImage; 2205 nmhdr.itemNew.pszText = wineItem->pszText; 2206 nmhdr.itemNew.cchTextMax= wineItem->cchTextMax; 2207 nmhdr.itemNew.iImage = wineItem->iImage; 2208 nmhdr.itemNew.iSelectedImage = wineItem->iSelectedImage; 2209 nmhdr.itemNew.cChildren = wineItem->cChildren; 2210 nmhdr.itemNew.lParam = wineItem->lParam; 2210 2211 } 2211 2212 … … 2219 2220 2220 2221 static BOOL 2221 TREEVIEW_SendTreeviewDnDNotify (HWND hwnd, UINT code, HTREEITEM dragItem, 2222 2222 TREEVIEW_SendTreeviewDnDNotify (HWND hwnd, UINT code, HTREEITEM dragItem, 2223 POINT pt) 2223 2224 { 2224 2225 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); … … 2233 2234 nmhdr.action = 0; 2234 2235 wineItem=& infoPtr->items[(INT)dragItem]; 2235 nmhdr.itemNew.mask 2236 nmhdr.itemNew.hItem 2237 nmhdr.itemNew.state 2238 nmhdr.itemNew.lParam 2236 nmhdr.itemNew.mask = wineItem->mask; 2237 nmhdr.itemNew.hItem = wineItem->hItem; 2238 nmhdr.itemNew.state = wineItem->state; 2239 nmhdr.itemNew.lParam = wineItem->lParam; 2239 2240 2240 2241 nmhdr.ptDrag.x = pt.x; … … 2249 2250 2250 2251 static BOOL 2251 TREEVIEW_SendDispInfoNotify (HWND hwnd, TREEVIEW_ITEM *wineItem, 2252 2252 TREEVIEW_SendDispInfoNotify (HWND hwnd, TREEVIEW_ITEM *wineItem, 2253 UINT code, UINT what) 2253 2254 { 2254 2255 NMTVDISPINFOA tvdi; … … 2261 2262 // (INT)wineItem->state); 2262 2263 2263 tvdi.hdr.hwndFrom 2264 tvdi.hdr.idFrom 2265 tvdi.hdr.code 2266 tvdi.item.mask 2267 tvdi.item.hItem 2268 tvdi.item.state 2269 tvdi.item.lParam 2264 tvdi.hdr.hwndFrom = hwnd; 2265 tvdi.hdr.idFrom = GetWindowLongA( hwnd, GWL_ID); 2266 tvdi.hdr.code = code; 2267 tvdi.item.mask = what; 2268 tvdi.item.hItem = wineItem->hItem; 2269 tvdi.item.state = wineItem->state; 2270 tvdi.item.lParam = wineItem->lParam; 2270 2271 tvdi.item.pszText = COMCTL32_Alloc (128*sizeof(char)); 2271 2272 buf = tvdi.item.pszText; 2272 2273 2273 2274 retval=(BOOL)SendMessageA ( 2274 GetParent(hwnd), 2275 GetParent(hwnd), 2275 2276 WM_NOTIFY, 2276 (WPARAM)tvdi.hdr.idFrom, 2277 (WPARAM)tvdi.hdr.idFrom, 2277 2278 (LPARAM)&tvdi); 2278 2279 2279 2280 if (what & TVIF_TEXT) { 2280 2281 2282 2283 } else { 2284 // 2285 2286 2287 2288 2289 if (what & TVIF_SELECTEDIMAGE) 2290 2291 if (what & TVIF_IMAGE) 2292 2293 if (what & TVIF_CHILDREN) 2294 2281 wineItem->pszText = tvdi.item.pszText; 2282 if (buf==tvdi.item.pszText) { 2283 wineItem->cchTextMax = 128; 2284 } else { 2285 // TRACE (treeview,"user-supplied buffer\n"); 2286 COMCTL32_Free (buf); 2287 wineItem->cchTextMax = 0; 2288 } 2289 } 2290 if (what & TVIF_SELECTEDIMAGE) 2291 wineItem->iSelectedImage = tvdi.item.iSelectedImage; 2292 if (what & TVIF_IMAGE) 2293 wineItem->iImage = tvdi.item.iImage; 2294 if (what & TVIF_CHILDREN) 2295 wineItem->cChildren = tvdi.item.cChildren; 2295 2296 2296 2297 return retval; … … 2301 2302 static BOOL 2302 2303 TREEVIEW_SendCustomDrawNotify (HWND hwnd, DWORD dwDrawStage, HDC hdc, 2303 2304 RECT rc) 2304 2305 { 2305 2306 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); … … 2314 2315 nmcd->hdr.code = NM_CUSTOMDRAW; 2315 2316 nmcd->dwDrawStage= dwDrawStage; 2316 nmcd->hdc 2317 nmcd->hdc = hdc; 2317 2318 nmcd->rc.left = rc.left; 2318 2319 nmcd->rc.right = rc.right; … … 2337 2338 static BOOL 2338 2339 TREEVIEW_SendCustomDrawItemNotify (HWND hwnd, HDC hdc, 2339 2340 TREEVIEW_ITEM *wineItem, UINT uItemDrawState) 2340 2341 { 2341 2342 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); … … 2344 2345 DWORD dwDrawStage,dwItemSpec; 2345 2346 UINT uItemState; 2346 2347 2347 2348 dwDrawStage=CDDS_ITEM | uItemDrawState; 2348 2349 dwItemSpec=(DWORD)wineItem->hItem; 2349 2350 uItemState=0; 2350 2351 if (wineItem->hItem==infoPtr->selectedItem) uItemState|=CDIS_SELECTED; 2351 if (wineItem->hItem==infoPtr->focusItem) 2352 if (wineItem->hItem==infoPtr->focusItem) uItemState|=CDIS_FOCUS; 2352 2353 if (wineItem->hItem==infoPtr->hotItem) uItemState|=CDIS_HOT; 2353 2354 … … 2357 2358 nmcd->hdr.code = NM_CUSTOMDRAW; 2358 2359 nmcd->dwDrawStage= dwDrawStage; 2359 nmcd->hdc 2360 nmcd->hdc = hdc; 2360 2361 nmcd->rc.left = wineItem->rect.left; 2361 2362 nmcd->rc.right = wineItem->rect.right; … … 2371 2372 2372 2373 // TRACE (treeview,"drawstage:%lx hdc:%x item:%lx, itemstate:%x\n", 2373 // 2374 // dwDrawStage, hdc, dwItemSpec, uItemState); 2374 2375 2375 2376 return (BOOL)SendMessageA (GetParent (hwnd), WM_NOTIFY, … … 2380 2381 2381 2382 /* Note:If the specified item is the child of a collapsed parent item, 2382 the parent's list of child items is (recursively) expanded to reveal the 2383 specified item. This is mentioned for TREEVIEW_SelectItem; don't 2383 the parent's list of child items is (recursively) expanded to reveal the 2384 specified item. This is mentioned for TREEVIEW_SelectItem; don't 2384 2385 know if it also applies here. 2385 2386 */ … … 2392 2393 UINT flag; 2393 2394 INT expand; 2394 2395 2395 2396 flag = (UINT) wParam; 2396 2397 expand = (INT) lParam; … … 2398 2399 wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)expand); 2399 2400 2400 if (!wineItem) 2401 if (!wineItem) 2401 2402 return 0; 2402 if (!wineItem->cChildren) 2403 if (!wineItem->cChildren) 2403 2404 return 0; 2404 2405 2405 // TRACE (treeview,"For (%s) flags:%x item:%d state:%d\n", 2406 // TRACE (treeview,"For (%s) flags:%x item:%d state:%d\n", 2406 2407 // wineItem->pszText, 2407 // flag, 2408 // flag, 2408 2409 // expand, 2409 2410 // wineItem->state); … … 2416 2417 if (flag == TVE_TOGGLE) { /* FIXME: check exact behaviour here */ 2417 2418 flag &= ~TVE_TOGGLE; /* ie: bitwise ops or 'case' ops */ 2418 if (wineItem->state & TVIS_EXPANDED) 2419 if (wineItem->state & TVIS_EXPANDED) 2419 2420 flag |= TVE_COLLAPSE; 2420 2421 else … … 2422 2423 } 2423 2424 2424 switch (flag) 2425 switch (flag) 2425 2426 { 2426 case TVE_COLLAPSERESET: 2427 case TVE_COLLAPSERESET: 2427 2428 // TRACE(treeview, " case TVE_COLLAPSERESET\n"); 2428 if (!wineItem->state & TVIS_EXPANDED) 2429 if (!wineItem->state & TVIS_EXPANDED) 2429 2430 return 0; 2430 2431 … … 2433 2434 break; 2434 2435 2435 case TVE_COLLAPSE: 2436 case TVE_COLLAPSE: 2436 2437 // TRACE(treeview, " case TVE_COLLAPSE\n"); 2437 if (!wineItem->state & TVIS_EXPANDED) 2438 if (!wineItem->state & TVIS_EXPANDED) 2438 2439 return 0; 2439 2440 … … 2441 2442 break; 2442 2443 2443 case TVE_EXPAND: 2444 case TVE_EXPAND: 2444 2445 // TRACE(treeview, " case TVE_EXPAND\n"); 2445 if (wineItem->state & TVIS_EXPANDED) 2446 if (wineItem->state & TVIS_EXPANDED) 2446 2447 return 0; 2447 2448 2448 2449 // TRACE(treeview, " is not expanded...\n"); 2449 2450 if (!(wineItem->state & TVIS_EXPANDEDONCE)) 2451 { 2450 2451 if (!(wineItem->state & TVIS_EXPANDEDONCE)) 2452 { 2452 2453 // TRACE(treeview, " and has never been expanded...\n"); 2453 2454 wineItem->state |= TVIS_EXPANDED; … … 2455 2456 /* this item has never been expanded */ 2456 2457 if (TREEVIEW_SendTreeviewNotify ( 2457 hwnd, 2458 TVN_ITEMEXPANDING, 2459 TVE_EXPAND, 2460 0, 2458 hwnd, 2459 TVN_ITEMEXPANDING, 2460 TVE_EXPAND, 2461 0, 2461 2462 (HTREEITEM)expand)) 2462 2463 { 2463 2464 // TRACE(treeview, " TVN_ITEMEXPANDING returned TRUE, exiting...\n"); 2464 return FALSE; 2465 return FALSE; 2465 2466 } 2466 2467 2467 2468 /* FIXME 2468 2469 * Since the TVN_ITEMEXPANDING message may has caused the parent to 2469 * insert new items which in turn may have cause items placeholder 2470 * reallocation, I reassign the current item pointer so we have 2471 * something valid to work with... 2472 * However, this should not be necessary, 2470 * insert new items which in turn may have cause items placeholder 2471 * reallocation, I reassign the current item pointer so we have 2472 * something valid to work with... 2473 * However, this should not be necessary, 2473 2474 * investigation required in TREEVIEW_InsertItemA 2474 2475 */ 2475 2476 wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)expand); 2476 if (! wineItem) 2477 { 2478 // ERR(treeview, 2477 if (! wineItem) 2478 { 2479 // ERR(treeview, 2479 2480 // "Catastropic situation, cannot retreive item #%d\n", 2480 2481 // expand); … … 2486 2487 2487 2488 TREEVIEW_SendTreeviewNotify ( 2488 hwnd, 2489 TVN_ITEMEXPANDED, 2490 TVE_EXPAND, 2491 0, 2489 hwnd, 2490 TVN_ITEMEXPANDED, 2491 TVE_EXPAND, 2492 0, 2492 2493 (HTREEITEM)expand); 2493 2494 … … 2510 2511 } 2511 2512 2512 // TRACE(treeview, "Exiting, Item %d state is now %d...\n", 2513 // expand, 2513 // TRACE(treeview, "Exiting, Item %d state is now %d...\n", 2514 // expand, 2514 2515 // wineItem->state); 2515 2516 2516 2517 TREEVIEW_QueueRefresh (hwnd); 2517 2518 return TRUE; … … 2535 2536 while ((wineItem!=NULL) && (pt.y > wineItem->rect.bottom)) 2536 2537 wineItem=TREEVIEW_GetNextListItem (infoPtr,wineItem); 2537 2538 if (!wineItem) 2539 2538 2539 if (!wineItem) 2540 return NULL; 2540 2541 2541 2542 return wineItem; … … 2568 2569 2569 2570 wineItem=TREEVIEW_HitTestPoint (hwnd, lpht->pt); 2570 if (!wineItem) { 2571 if (!wineItem) { 2571 2572 lpht->flags=TVHT_NOWHERE; 2572 2573 return 0; … … 2574 2575 2575 2576 /* FIXME: implement other flags 2576 * Assign the appropriate flags depending on the click location 2577 * Intitialize flags before to "|=" it... 2577 * Assign the appropriate flags depending on the click location 2578 * Intitialize flags before to "|=" it... 2578 2579 */ 2579 2580 lpht->flags=0; 2580 2581 2581 if (x < wineItem->expandBox.left) 2582 if (x < wineItem->expandBox.left) 2582 2583 { 2583 2584 lpht->flags |= TVHT_ONITEMINDENT; 2584 } 2585 else if ( ( x >= wineItem->expandBox.left) && 2585 } 2586 else if ( ( x >= wineItem->expandBox.left) && 2586 2587 ( x <= wineItem->expandBox.right)) 2587 2588 { 2588 2589 lpht->flags |= TVHT_ONITEMBUTTON; 2589 2590 } 2590 else if (x < wineItem->rect.right) 2591 else if (x < wineItem->rect.right) 2591 2592 { 2592 lpht->flags |= TVHT_ONITEMLABEL; 2593 } 2593 lpht->flags |= TVHT_ONITEMLABEL; 2594 } 2594 2595 else 2595 2596 { 2596 2597 lpht->flags|=TVHT_ONITEMRIGHT; 2597 2598 } 2598 2599 2599 2600 lpht->hItem=wineItem->hItem; 2600 2601 … … 2612 2613 if ( ! (BOOL)wParam ) /* wParam is set to true to cancel the edition */ 2613 2614 { 2614 2615 hwnd, 2615 if ( TREEVIEW_SendDispInfoNotify( /* return true to cancel edition */ 2616 hwnd, 2616 2617 editedItem, 2617 TVN_ENDLABELEDIT, 2618 TVN_ENDLABELEDIT, 2618 2619 0)) 2619 2620 { 2620 2621 bRevert = TRUE; 2621 bReturn = FALSE; 2622 bReturn = FALSE; 2622 2623 } 2623 2624 } … … 2629 2630 bReturn = FALSE; 2630 2631 2631 if (iLength == 0) 2632 if (iLength == 0) 2632 2633 { 2633 2634 // ERR( treeview, "Problem retreiving new item label."); … … 2635 2636 else if (iLength >= 1023) 2636 2637 { 2637 // ERR( treeview, 2638 // ERR( treeview, 2638 2639 // "Insuficient space to retrieve new item label, new label ignored."); 2639 2640 } … … 2646 2647 { 2647 2648 LPSTR tmpLabel = COMCTL32_Alloc( iLength+1 ); 2648 2649 2649 2650 // if ( tmpLabel == NULL ) 2650 // ERR( treeview, 2651 // ERR( treeview, 2651 2652 // "OutOfMemory, cannot allocate space for label"); 2652 2653 // else … … 2660 2661 } 2661 2662 2662 2663 2663 ShowWindow(infoPtr->hwndEdit, SW_HIDE); 2664 EnableWindow(infoPtr->hwndEdit, FALSE); 2664 2665 infoPtr->editItem = 0; 2665 2666 } … … 2684 2685 if (!wineItem) return 0; 2685 2686 // TRACE (treeview,"item %d \n",(INT)wineItem->hItem); 2686 2687 2687 2688 if (TREEVIEW_SendSimpleNotify (hwnd, NM_DBLCLK)!=TRUE) { /* FIXME!*/ 2688 2689 TREEVIEW_Expand (hwnd, (WPARAM) TVE_TOGGLE, (LPARAM) wineItem->hItem); 2689 2690 } 2690 2691 return TRUE; … … 2713 2714 infoPtr->uInternalStatus|=TV_LDRAG; 2714 2715 } 2715 2716 2716 2717 return 0; 2717 2718 } … … 2724 2725 TREEVIEW_ITEM *editItem; 2725 2726 TVHITTESTINFO ht; 2726 2727 2727 2728 ht.pt.x = (INT)LOWORD(lParam); 2728 2729 ht.pt.y = (INT)HIWORD(lParam); 2729 2730 2730 2731 // TRACE (treeview,"\n"); 2731 2732 … … 2736 2737 /* Get the item */ 2737 2738 iItem = TREEVIEW_HitTest (hwnd, (LPARAM) &ht); 2738 if (!iItem) 2739 if (!iItem) 2739 2740 return 0; 2740 2741 2741 2742 editItem = TREEVIEW_ValidItem(infoPtr, (HTREEITEM)iItem); 2742 2743 2743 2744 infoPtr->uInternalStatus &= ~(TV_LDRAG | TV_LDRAGGING); 2744 2745 2745 /* 2746 * If the style allow editing and the node is already selected 2746 /* 2747 * If the style allow editing and the node is already selected 2747 2748 * and the click occured on the item label... 2748 2749 */ 2749 if ( ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_EDITLABELS ) && 2750 if ( ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_EDITLABELS ) && 2750 2751 ( editItem->state & TVIS_SELECTED ) && 2751 2752 ( ht.flags & TVHT_ONITEMLABEL )) … … 2753 2754 if ( infoPtr->editItem == 0 ) /* If we are not curently editing */ 2754 2755 { 2755 2756 hwnd, 2757 editItem, 2758 TVN_BEGINLABELEDIT, 2756 if ( TREEVIEW_SendDispInfoNotify( /* Return true to cancel edition */ 2757 hwnd, 2758 editItem, 2759 TVN_BEGINLABELEDIT, 2759 2760 0)) 2760 2761 { 2761 return 0; 2762 return 0; 2762 2763 } 2763 2764 // 2765 2766 2767 SetWindowPos (2768 infoPtr->hwndEdit, 2769 HWND_TOP, 2770 editItem->text.left - 2, 2764 2765 // TRACE(treeview,"Edit started for %s.\n", editItem->pszText); 2766 infoPtr->editItem = editItem->hItem; 2767 2768 SetWindowPos ( 2769 infoPtr->hwndEdit, 2770 HWND_TOP, 2771 editItem->text.left - 2, 2771 2772 editItem->text.top - 1, 2772 2773 editItem->text.right - editItem->text.left + 20 , 2773 2774 editItem->text.bottom - editItem->text.top + 3, 2774 2775 SWP_DRAWFRAME ); 2775 2776 2776 2777 SetWindowTextA( infoPtr->hwndEdit, editItem->pszText ); 2777 2778 SendMessageA ( infoPtr->hwndEdit, EM_SETSEL, 0, -1 ); 2778 SetFocus ( infoPtr->hwndEdit);2779 ShowWindow ( infoPtr->hwndEdit, SW_SHOW); 2779 SetFocus ( infoPtr->hwndEdit); 2780 ShowWindow ( infoPtr->hwndEdit, SW_SHOW); 2780 2781 } 2781 2782 } … … 2787 2788 { 2788 2789 TREEVIEW_DoSelectItem ( 2789 hwnd, 2790 TVGN_CARET, 2791 (HTREEITEM)iItem, 2790 hwnd, 2791 TVGN_CARET, 2792 (HTREEITEM)iItem, 2792 2793 TVC_BYMOUSE); 2793 2794 } … … 2835 2836 2836 2837 if (infoPtr->uInternalStatus & TV_LDRAG) { 2837 2838 2839 2840 2841 2838 TREEVIEW_SendTreeviewDnDNotify (hwnd, TVN_BEGINDRAG, hotItem->hItem, pt); 2839 infoPtr->uInternalStatus &= ~TV_LDRAG; 2840 infoPtr->uInternalStatus |= TV_LDRAGGING; 2841 infoPtr->dropItem=hotItem->hItem; 2842 return 0; 2842 2843 } 2843 2844 2844 2845 if (infoPtr->uInternalStatus & TV_RDRAG) { 2845 2846 2847 2848 2849 2846 TREEVIEW_SendTreeviewDnDNotify (hwnd, TVN_BEGINRDRAG, hotItem->hItem, pt); 2847 infoPtr->uInternalStatus &= ~TV_RDRAG; 2848 infoPtr->uInternalStatus |= TV_RDRAGGING; 2849 infoPtr->dropItem=hotItem->hItem; 2850 return 0; 2850 2851 } 2851 2852 2852 2853 return 0; 2853 2854 } … … 2867 2868 HFONT hOldFont; 2868 2869 char *itemtxt; 2869 2870 2870 2871 // TRACE (treeview,"\n"); 2871 2872 if (!(infoPtr->himlNormal)) return 0; 2872 2873 dragItem=TREEVIEW_ValidItem (infoPtr, (HTREEITEM) lParam); 2873 2874 2874 2875 if (!dragItem) return 0; 2875 2876 itemtxt=dragItem->pszText; … … 2877 2878 hwtop=GetDesktopWindow (); 2878 2879 htopdc= GetDC (hwtop); 2879 hdc=CreateCompatibleDC (htopdc); 2880 2880 hdc=CreateCompatibleDC (htopdc); 2881 2881 2882 hOldFont=SelectObject (hdc, infoPtr->hFont); 2882 2883 GetTextExtentPoint32A (hdc, itemtxt, lstrlenA (itemtxt), &size); … … 2924 2925 wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)newSelect); 2925 2926 2926 // TRACE (treeview,"Entering item %d, flag %x, cause %x, state %d\n", 2927 // (INT)newSelect, 2928 // action, 2927 // TRACE (treeview,"Entering item %d, flag %x, cause %x, state %d\n", 2928 // (INT)newSelect, 2929 // action, 2929 2930 // cause, 2930 2931 // wineItem->state); … … 2932 2933 if ( (wineItem) && (wineItem->parent)) 2933 2934 { 2934 /* 2935 * If the item has a collapse parent expand the parent so he 2936 * can expose the item 2935 /* 2936 * If the item has a collapse parent expand the parent so he 2937 * can expose the item 2937 2938 */ 2938 2939 TREEVIEW_ITEM *parentItem = TREEVIEW_ValidItem (infoPtr, wineItem->parent); 2939 if ( !(parentItem->state & TVIS_EXPANDED)) 2940 if ( !(parentItem->state & TVIS_EXPANDED)) 2940 2941 TREEVIEW_Expand (hwnd, TVE_EXPAND, (LPARAM) wineItem->parent); 2941 2942 } 2942 2943 2943 switch (action) 2944 switch (action) 2944 2945 { 2945 case TVGN_CARET: 2946 case TVGN_CARET: 2946 2947 prevSelect=(INT)infoPtr->selectedItem; 2947 2948 2948 if ((HTREEITEM)prevSelect==newSelect) 2949 if ((HTREEITEM)prevSelect==newSelect) 2949 2950 return FALSE; 2950 2951 2951 2952 prevItem= TREEVIEW_ValidItem (infoPtr, (HTREEITEM)prevSelect); 2952 2953 2953 if (newSelect) 2954 if (newSelect) 2954 2955 if (TREEVIEW_SendTreeviewNotify( 2955 hwnd, 2956 TVN_SELCHANGING, 2957 cause, 2958 (HTREEITEM)prevSelect, 2959 (HTREEITEM)newSelect)) 2956 hwnd, 2957 TVN_SELCHANGING, 2958 cause, 2959 (HTREEITEM)prevSelect, 2960 (HTREEITEM)newSelect)) 2960 2961 return FALSE; /* FIXME: OK? */ 2961 2962 if (prevItem) 2962 2963 if (prevItem) 2963 2964 prevItem->state &= ~TVIS_SELECTED; 2964 if (wineItem) 2965 if (wineItem) 2965 2966 wineItem->state |= TVIS_SELECTED; 2966 2967 … … 2968 2969 2969 2970 TREEVIEW_SendTreeviewNotify( 2970 hwnd, 2971 TVN_SELCHANGED, 2971 hwnd, 2972 TVN_SELCHANGED, 2972 2973 cause, 2973 2974 (HTREEITEM)prevSelect, … … 2976 2977 break; 2977 2978 2978 case TVGN_DROPHILITE: 2979 case TVGN_DROPHILITE: 2979 2980 prevItem= TREEVIEW_ValidItem (infoPtr, infoPtr->dropItem); 2980 2981 2981 if (prevItem) 2982 if (prevItem) 2982 2983 prevItem->state &= ~TVIS_DROPHILITED; 2983 2984 2984 2985 infoPtr->dropItem=(HTREEITEM)newSelect; 2985 2986 2986 if (wineItem) 2987 if (wineItem) 2987 2988 wineItem->state |=TVIS_DROPHILITED; 2988 2989 … … 2993 2994 break; 2994 2995 } 2995 2996 2996 2997 TREEVIEW_QueueRefresh (hwnd); 2997 2998 … … 3010 3011 3011 3012 3012 3013 3013 3014 static LRESULT 3014 3015 TREEVIEW_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam) … … 3033 3034 3034 3035 // TRACE (treeview,"%x %lx\n",wParam, lParam); 3035 3036 3036 3037 infoPtr->hFont = (HFONT)wParam; 3037 3038 … … 3046 3047 GetTextMetricsA (hdc, &tm); 3047 3048 height= tm.tmHeight + tm.tmExternalLeading; 3048 if (height>infoPtr->uRealItemHeight) 3049 3049 if (height>infoPtr->uRealItemHeight) 3050 infoPtr->uRealItemHeight=height; 3050 3051 SelectObject (hdc, hOldFont); 3051 3052 ReleaseDC (0, hdc); 3052 3053 3053 if (lParam) 3054 3055 3054 if (lParam) 3055 TREEVIEW_QueueRefresh (hwnd); 3056 3056 3057 return 0; 3057 3058 } … … 3070 3071 3071 3072 switch (LOWORD (wParam)) { 3072 case SB_LINEUP: 3073 3074 3075 3076 3077 case SB_LINEDOWN: 3078 3079 3080 3081 if (infoPtr->cy > maxHeight) 3082 3083 3084 case SB_PAGEUP: 3085 3086 3087 3088 3089 3090 3091 3092 3073 case SB_LINEUP: 3074 if (!infoPtr->cy) return FALSE; 3075 infoPtr->cy -= infoPtr->uRealItemHeight; 3076 if (infoPtr->cy < 0) infoPtr->cy=0; 3077 break; 3078 case SB_LINEDOWN: 3079 maxHeight=infoPtr->uTotalHeight-infoPtr->uVisibleHeight; 3080 if (infoPtr->cy == maxHeight) return FALSE; 3081 infoPtr->cy += infoPtr->uRealItemHeight; 3082 if (infoPtr->cy > maxHeight) 3083 infoPtr->cy = maxHeight; 3084 break; 3085 case SB_PAGEUP: 3086 if (!infoPtr->cy) return FALSE; 3087 infoPtr->cy -= infoPtr->uVisibleHeight; 3088 if (infoPtr->cy < 0) infoPtr->cy=0; 3089 break; 3090 case SB_PAGEDOWN: 3091 maxHeight=infoPtr->uTotalHeight-infoPtr->uVisibleHeight; 3092 if (infoPtr->cy == maxHeight) return FALSE; 3093 infoPtr->cy += infoPtr->uVisibleHeight; 3093 3094 if (infoPtr->cy > maxHeight) 3094 3095 infoPtr->cy = maxHeight; 3095 3096 case SB_THUMBTRACK: 3097 3098 3099 3100 } 3101 3096 break; 3097 case SB_THUMBTRACK: 3098 infoPtr->cy = HIWORD (wParam); 3099 break; 3100 3101 } 3102 3102 3103 TREEVIEW_QueueRefresh (hwnd); 3103 3104 return TRUE; … … 3105 3106 3106 3107 static LRESULT 3107 TREEVIEW_HScroll (HWND hwnd, WPARAM wParam, LPARAM lParam) 3108 TREEVIEW_HScroll (HWND hwnd, WPARAM wParam, LPARAM lParam) 3108 3109 { 3109 3110 TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd); … … 3111 3112 3112 3113 // TRACE (treeview,"wp %lx, lp %x\n", lParam, wParam); 3113 3114 3114 3115 if (!infoPtr->uInternalStatus & TV_HSCROLL) return FALSE; 3115 3116 3116 3117 switch (LOWORD (wParam)) { 3117 case SB_LINEUP: 3118 3119 3120 3121 3122 case SB_LINEDOWN: 3123 3124 3125 3126 if (infoPtr->cx > maxWidth) 3127 3128 3129 case SB_PAGEUP: 3130 3131 3132 3133 3134 3135 3136 3137 3118 case SB_LINEUP: 3119 if (!infoPtr->cx) return FALSE; 3120 infoPtr->cx -= infoPtr->uRealItemHeight; 3121 if (infoPtr->cx < 0) infoPtr->cx=0; 3122 break; 3123 case SB_LINEDOWN: 3124 maxWidth=infoPtr->uTotalWidth-infoPtr->uVisibleWidth; 3125 if (infoPtr->cx == maxWidth) return FALSE; 3126 infoPtr->cx += infoPtr->uRealItemHeight; /*FIXME */ 3127 if (infoPtr->cx > maxWidth) 3128 infoPtr->cx = maxWidth; 3129 break; 3130 case SB_PAGEUP: 3131 if (!infoPtr->cx) return FALSE; 3132 infoPtr->cx -= infoPtr->uVisibleWidth; 3133 if (infoPtr->cx < 0) infoPtr->cx=0; 3134 break; 3135 case SB_PAGEDOWN: 3136 maxWidth=infoPtr->uTotalWidth-infoPtr->uVisibleWidth; 3137 if (infoPtr->cx == maxWidth) return FALSE; 3138 infoPtr->cx += infoPtr->uVisibleWidth; 3138 3139 if (infoPtr->cx > maxWidth) 3139 3140 infoPtr->cx = maxWidth; 3140 3141 case SB_THUMBTRACK: 3142 3143 3144 3145 } 3146 3141 break; 3142 case SB_THUMBTRACK: 3143 infoPtr->cx = HIWORD (wParam); 3144 break; 3145 3146 } 3147 3147 3148 TREEVIEW_QueueRefresh (hwnd); 3148 3149 return TRUE; … … 3159 3160 INT prevSelect = (INT)infoPtr->selectedItem; 3160 3161 3161 TREEVIEW_ITEM *prevItem = 3162 (prevSelect != 0 ) ? 3162 TREEVIEW_ITEM *prevItem = 3163 (prevSelect != 0 ) ? 3163 3164 TREEVIEW_ValidItem (infoPtr, (HTREEITEM)prevSelect) : 3164 3165 NULL; … … 3168 3169 // TRACE (treeview,"%x %lx\n",wParam, lParam); 3169 3170 3170 if (prevSelect == 0) 3171 if (prevSelect == 0) 3171 3172 return FALSE; 3172 3173 3173 3174 switch (wParam) { 3174 case VK_UP: 3175 3176 3177 if (!newItem) 3178 3175 case VK_UP: 3176 newItem=TREEVIEW_GetPrevListItem (infoPtr, prevItem); 3177 3178 if (!newItem) 3179 newItem=& infoPtr->items[(INT)infoPtr->TopRootItem]; 3179 3180 3180 3181 hNewSelection = newItem->hItem; … … 3183 3184 scrollNeeds = SB_LINEUP; 3184 3185 3185 3186 3187 case VK_DOWN: 3188 3189 3190 if (!newItem) 3186 break; 3187 3188 case VK_DOWN: 3189 newItem=TREEVIEW_GetNextListItem (infoPtr, prevItem); 3190 3191 if (!newItem) 3191 3192 newItem=prevItem; 3192 3193 … … 3196 3197 scrollNeeds = SB_LINEDOWN; 3197 3198 3198 3199 3200 3201 3199 break; 3200 3201 case VK_HOME: 3202 newItem = &infoPtr->items[(INT)infoPtr->TopRootItem]; 3202 3203 hNewSelection = newItem->hItem; 3203 3204 cyChangeNeeds = 0; 3204 3205 3206 3207 3208 3205 break; 3206 3207 case VK_END: 3208 newItem = &infoPtr->items[(INT)infoPtr->TopRootItem]; 3209 newItem = TREEVIEW_GetLastListItem (infoPtr, newItem); 3209 3210 hNewSelection = newItem->hItem; 3210 3211 … … 3212 3213 cyChangeNeeds = infoPtr->uTotalHeight-infoPtr->uVisibleHeight; 3213 3214 3214 3215 3216 3215 break; 3216 3217 case VK_LEFT: 3217 3218 if ( (prevItem->cChildren > 0) && (prevItem->state & TVIS_EXPANDED) ) 3218 3219 { 3219 3220 TREEVIEW_Expand(hwnd, TVE_COLLAPSE, prevSelect ); 3220 3221 } 3221 else if ((INT)prevItem->parent) 3222 else if ((INT)prevItem->parent) 3222 3223 { 3223 3224 newItem = (& infoPtr->items[(INT)prevItem->parent]); 3224 if (! newItem->visible) 3225 if (! newItem->visible) 3225 3226 /* FIXME find a way to make this item the first visible... */ 3226 newItem = NULL; 3227 newItem = NULL; 3227 3228 3228 3229 hNewSelection = newItem->hItem; … … 3231 3232 break; 3232 3233 3233 3234 if ( ( prevItem->cChildren > 0) || 3234 case VK_RIGHT: 3235 if ( ( prevItem->cChildren > 0) || 3235 3236 ( prevItem->cChildren == I_CHILDRENCALLBACK)) 3236 3237 { … … 3257 3258 3258 3259 case VK_PRIOR: 3259 3260 3261 infoPtr, 3260 3261 newItem=TREEVIEW_GetListItem( 3262 infoPtr, 3262 3263 prevItem, 3263 3264 -1*(TREEVIEW_GetVisibleCount(hwnd,0,0)-3)); 3264 if (!newItem) 3265 if (!newItem) 3265 3266 newItem=prevItem; 3266 3267 3267 3268 hNewSelection = newItem->hItem; 3268 3269 … … 3270 3271 scrollNeeds = SB_PAGEUP; 3271 3272 3272 3273 break; 3273 3274 3274 3275 case VK_NEXT: 3275 3276 infoPtr, 3276 newItem=TREEVIEW_GetListItem( 3277 infoPtr, 3277 3278 prevItem, 3278 3279 TREEVIEW_GetVisibleCount(hwnd,0,0)-3); 3279 3280 3280 if (!newItem) 3281 if (!newItem) 3281 3282 newItem=prevItem; 3282 3283 … … 3286 3287 scrollNeeds = SB_PAGEDOWN; 3287 3288 3288 3289 3290 3291 3292 3289 break; 3290 3291 case VK_BACK: 3292 3293 case VK_RETURN: 3293 3294 3294 3295 default: 3295 // 3296 3296 // FIXME (treeview, "%x not implemented\n", wParam); 3297 break; 3297 3298 } 3298 3299 3299 if (hNewSelection) 3300 if (hNewSelection) 3300 3301 { 3301 /* 3302 /* 3302 3303 This works but does not send notification... 3303 3304 … … 3308 3309 */ 3309 3310 3310 if ( TREEVIEW_DoSelectItem( 3311 hwnd, 3312 TVGN_CARET, 3313 (HTREEITEM)hNewSelection, 3311 if ( TREEVIEW_DoSelectItem( 3312 hwnd, 3313 TVGN_CARET, 3314 (HTREEITEM)hNewSelection, 3314 3315 TVC_BYKEYBOARD)) 3315 3316 { … … 3317 3318 if (scrollNeeds != -1) 3318 3319 TREEVIEW_VScroll(hwnd, scrollNeeds, 0); 3319 3320 3320 3321 if (cyChangeNeeds != -1) 3321 3322 infoPtr->cy = cyChangeNeeds; 3322 3323 3323 /* FIXME: Something happen in the load the in the two weeks before 3324 april 1st 1999 which makes this SetFocus mandatory otherwise, the focus 3324 /* FIXME: Something happen in the load the in the two weeks before 3325 april 1st 1999 which makes this SetFocus mandatory otherwise, the focus 3325 3326 is lost... However the SetFocus should not be required...*/ 3326 3327 3327 3328 SetFocus(hwnd); 3328 3329 } … … 3337 3338 { 3338 3339 switch (uMsg) { 3339 3340 case TVM_INSERTITEMA: 3340 3341 return TREEVIEW_InsertItemA (hwnd, wParam, lParam); 3341 3342 3342 3343 // 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 // 3381 3382 3383 3384 3385 3386 3387 // 3388 3389 3390 3391 // 3392 3393 3394 3395 // 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 // 3412 3413 3414 3415 // 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 // 3426 3427 3428 3429 // 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 // 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 // 3462 3463 3464 3465 // 3466 3467 3468 3469 // 3470 3471 3472 3473 // 3474 3475 3476 3477 // 3478 3479 3480 case WM_COMMAND: 3481 3482 3483 3484 3485 3486 3487 3488 3489 /* 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 case WM_SETFOCUS: 3511 3512 3513 case WM_KILLFOCUS: 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 /* 3537 case WM_STYLECHANGED: 3538 3539 3540 /* 3541 3542 3543 3544 3545 case WM_SIZE: 3546 3547 3548 case WM_HSCROLL: 3549 3550 case WM_VSCROLL: 3551 3552 3553 3554 // 3555 3556 3557 3558 3559 // 3560 // 3561 3343 case TVM_INSERTITEMW: 3344 // FIXME (treeview, "Unimplemented msg TVM_INSERTITEM32W\n"); 3345 return 0; 3346 3347 case TVM_DELETEITEM: 3348 return TREEVIEW_DeleteItem (hwnd, wParam, lParam); 3349 3350 case TVM_EXPAND: 3351 return TREEVIEW_Expand (hwnd, wParam, lParam); 3352 3353 case TVM_GETITEMRECT: 3354 return TREEVIEW_GetItemRect (hwnd, wParam, lParam); 3355 3356 case TVM_GETCOUNT: 3357 return TREEVIEW_GetCount (hwnd, wParam, lParam); 3358 3359 case TVM_GETINDENT: 3360 return TREEVIEW_GetIndent (hwnd); 3361 3362 case TVM_SETINDENT: 3363 return TREEVIEW_SetIndent (hwnd, wParam); 3364 3365 case TVM_GETIMAGELIST: 3366 return TREEVIEW_GetImageList (hwnd, wParam, lParam); 3367 3368 case TVM_SETIMAGELIST: 3369 return TREEVIEW_SetImageList (hwnd, wParam, lParam); 3370 3371 case TVM_GETNEXTITEM: 3372 return TREEVIEW_GetNextItem (hwnd, wParam, lParam); 3373 3374 case TVM_SELECTITEM: 3375 return TREEVIEW_SelectItem (hwnd, wParam, lParam); 3376 3377 case TVM_GETITEMA: 3378 return TREEVIEW_GetItemA (hwnd, wParam, lParam); 3379 3380 case TVM_GETITEMW: 3381 // FIXME (treeview, "Unimplemented msg TVM_GETITEM32W\n"); 3382 return 0; 3383 3384 case TVM_SETITEMA: 3385 return TREEVIEW_SetItemA (hwnd, wParam, lParam); 3386 3387 case TVM_SETITEMW: 3388 // FIXME (treeview, "Unimplemented msg TVM_SETITEMW\n"); 3389 return 0; 3390 3391 case TVM_EDITLABELA: 3392 // FIXME (treeview, "Unimplemented msg TVM_EDITLABEL32A \n"); 3393 return 0; 3394 3395 case TVM_EDITLABELW: 3396 // FIXME (treeview, "Unimplemented msg TVM_EDITLABEL32W \n"); 3397 return 0; 3398 3399 case TVM_GETEDITCONTROL: 3400 return TREEVIEW_GetEditControl (hwnd); 3401 3402 case TVM_GETVISIBLECOUNT: 3403 return TREEVIEW_GetVisibleCount (hwnd, wParam, lParam); 3404 3405 case TVM_HITTEST: 3406 return TREEVIEW_HitTest (hwnd, lParam); 3407 3408 case TVM_CREATEDRAGIMAGE: 3409 return TREEVIEW_CreateDragImage (hwnd, wParam, lParam); 3410 3411 case TVM_SORTCHILDREN: 3412 // FIXME (treeview, "Unimplemented msg TVM_SORTCHILDREN\n"); 3413 return 0; 3414 3415 case TVM_ENSUREVISIBLE: 3416 // FIXME (treeview, "Unimplemented msg TVM_ENSUREVISIBLE\n"); 3417 return 0; 3418 3419 case TVM_SORTCHILDRENCB: 3420 return TREEVIEW_SortChildrenCB(hwnd, wParam, lParam); 3421 3422 case TVM_ENDEDITLABELNOW: 3423 return TREEVIEW_EndEditLabelNow (hwnd, wParam, lParam); 3424 3425 case TVM_GETISEARCHSTRINGA: 3426 // FIXME (treeview, "Unimplemented msg TVM_GETISEARCHSTRING32A\n"); 3427 return 0; 3428 3429 case TVM_GETISEARCHSTRINGW: 3430 // FIXME (treeview, "Unimplemented msg TVM_GETISEARCHSTRING32W\n"); 3431 return 0; 3432 3433 case TVM_GETTOOLTIPS: 3434 return TREEVIEW_GetToolTips (hwnd); 3435 3436 case TVM_SETTOOLTIPS: 3437 return TREEVIEW_SetToolTips (hwnd, wParam); 3438 3439 case TVM_SETINSERTMARK: 3440 // FIXME (treeview, "Unimplemented msg TVM_SETINSERTMARK\n"); 3441 return 0; 3442 3443 case TVM_SETITEMHEIGHT: 3444 return TREEVIEW_SetItemHeight (hwnd, wParam); 3445 3446 case TVM_GETITEMHEIGHT: 3447 return TREEVIEW_GetItemHeight (hwnd); 3448 3449 case TVM_SETBKCOLOR: 3450 return TREEVIEW_SetBkColor (hwnd, wParam, lParam); 3451 3452 case TVM_SETTEXTCOLOR: 3453 return TREEVIEW_SetTextColor (hwnd, wParam, lParam); 3454 3455 case TVM_GETBKCOLOR: 3456 return TREEVIEW_GetBkColor (hwnd); 3457 3458 case TVM_GETTEXTCOLOR: 3459 return TREEVIEW_GetTextColor (hwnd); 3460 3461 case TVM_SETSCROLLTIME: 3462 // FIXME (treeview, "Unimplemented msg TVM_SETSCROLLTIME\n"); 3463 return 0; 3464 3465 case TVM_GETSCROLLTIME: 3466 // FIXME (treeview, "Unimplemented msg TVM_GETSCROLLTIME\n"); 3467 return 0; 3468 3469 case TVM_SETINSERTMARKCOLOR: 3470 // FIXME (treeview, "Unimplemented msg TVM_SETINSERTMARKCOLOR\n"); 3471 return 0; 3472 3473 case TVM_SETUNICODEFORMAT: 3474 // FIXME (treeview, "Unimplemented msg TVM_SETUNICODEFORMAT\n"); 3475 return 0; 3476 3477 case TVM_GETUNICODEFORMAT: 3478 // FIXME (treeview, "Unimplemented msg TVM_GETUNICODEFORMAT\n"); 3479 return 0; 3480 3481 case WM_COMMAND: 3482 return TREEVIEW_Command (hwnd, wParam, lParam); 3483 3484 case WM_CREATE: 3485 return TREEVIEW_Create (hwnd, wParam, lParam); 3486 3487 case WM_DESTROY: 3488 return TREEVIEW_Destroy (hwnd); 3489 3490 /* case WM_ENABLE: */ 3491 3492 case WM_ERASEBKGND: 3493 return TREEVIEW_EraseBackground (hwnd, wParam, lParam); 3494 3495 case WM_GETDLGCODE: 3496 return DLGC_WANTARROWS | DLGC_WANTCHARS; 3497 3498 case WM_PAINT: 3499 return TREEVIEW_Paint (hwnd, wParam, lParam); 3500 3501 case WM_GETFONT: 3502 return TREEVIEW_GetFont (hwnd, wParam, lParam); 3503 3504 case WM_SETFONT: 3505 return TREEVIEW_SetFont (hwnd, wParam, lParam); 3506 3507 case WM_KEYDOWN: 3508 return TREEVIEW_KeyDown (hwnd, wParam, lParam); 3509 3510 3511 case WM_SETFOCUS: 3512 return TREEVIEW_SetFocus (hwnd, wParam, lParam); 3513 3514 case WM_KILLFOCUS: 3515 return TREEVIEW_KillFocus (hwnd, wParam, lParam); 3516 3517 3518 case WM_LBUTTONDOWN: 3519 return TREEVIEW_LButtonDown (hwnd, wParam, lParam); 3520 3521 case WM_LBUTTONUP: 3522 return TREEVIEW_LButtonUp (hwnd, wParam, lParam); 3523 3524 case WM_LBUTTONDBLCLK: 3525 return TREEVIEW_LButtonDoubleClick (hwnd, wParam, lParam); 3526 3527 case WM_RBUTTONDOWN: 3528 return TREEVIEW_RButtonDown (hwnd, wParam, lParam); 3529 3530 case WM_RBUTTONUP: 3531 return TREEVIEW_RButtonUp (hwnd, wParam, lParam); 3532 3533 case WM_MOUSEMOVE: 3534 return TREEVIEW_MouseMove (hwnd, wParam, lParam); 3535 3536 3537 /* case WM_SYSCOLORCHANGE: */ 3538 case WM_STYLECHANGED: 3539 return TREEVIEW_StyleChanged (hwnd, wParam, lParam); 3540 3541 /* case WM_SETREDRAW: */ 3542 3543 case WM_TIMER: 3544 return TREEVIEW_HandleTimer (hwnd, wParam, lParam); 3545 3546 case WM_SIZE: 3547 return TREEVIEW_Size (hwnd, wParam,lParam); 3548 3549 case WM_HSCROLL: 3550 return TREEVIEW_HScroll (hwnd, wParam, lParam); 3551 case WM_VSCROLL: 3552 return TREEVIEW_VScroll (hwnd, wParam, lParam); 3553 3554 case WM_DRAWITEM: 3555 // printf ("drawItem\n"); 3556 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 3557 3558 default: 3559 // if (uMsg >= WM_USER) 3560 // FIXME (treeview, "Unknown msg %04x wp=%08x lp=%08lx\n", 3561 // uMsg, wParam, lParam); 3562 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 3562 3563 } 3563 3564 return 0; … … 3582 3583 wndClass.hbrBackground = 0; 3583 3584 wndClass.lpszClassName = WC_TREEVIEWA; 3584 3585 3585 3586 RegisterClassA (&wndClass); 3586 3587 } … … 3591 3592 { 3592 3593 if (GlobalFindAtomA (WC_TREEVIEWA)) 3593 3594 } 3595 3594 UnregisterClassA (WC_TREEVIEWA, (HINSTANCE)NULL); 3595 } 3596
Note:
See TracChangeset
for help on using the changeset viewer.