- Timestamp:
- Jun 16, 1999, 10:25:45 PM (26 years ago)
- Location:
- trunk/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/progress.c
r109 r110 1 /* $Id: progress.c,v 1. 4 1999-06-16 15:29:26cbratschi Exp $ */1 /* $Id: progress.c,v 1.5 1999-06-16 20:25:43 cbratschi Exp $ */ 2 2 /* 3 3 * Progress control … … 8 8 * Copyright 1999 Christoph Bratschi 9 9 * 10 * Status: complete 10 11 */ 11 12 … … 374 375 temp = infoPtr->CurVal; 375 376 if(temp != wParam){ 376 infoPtr->CurVal = (UINT16)wParam; 377 infoPtr->CurVal = (UINT16)wParam; //CB: 0..65535 allowed 377 378 PROGRESS_CoercePos(hwnd); 378 379 PROGRESS_Update (hwnd,temp); … … 398 399 UNKNOWN_PARAM(PBM_SETSTEP, wParam, lParam); 399 400 temp = infoPtr->Step; 400 infoPtr->Step = (INT)wParam; 401 infoPtr->Step = (INT)wParam; //CB: negative steps allowed 401 402 return temp; 402 403 -
trunk/src/comctl32/status.c
r94 r110 1 /* $Id: status.c,v 1. 3 1999-06-10 16:22:01 achimhaExp $ */1 /* $Id: status.c,v 1.4 1999-06-16 20:25:43 cbratschi Exp $ */ 2 2 /* 3 3 * Interface code to StatusWindow widget/control … … 6 6 * Copyright 1998, 1999 Eric Kohl 7 7 * Copyright 1999 Achim Hasenmueller 8 * Copyright 1999 Christoph Bratschi 8 9 */ 9 10 … … 56 57 SelectObject (hdc, GetSysColorPen (COLOR_3DSHADOW)); 57 58 for (i = 1; i < 11; i += 4) { 58 59 60 61 62 59 MoveToEx (hdc, pt.x - i, pt.y, NULL); 60 LineTo (hdc, pt.x, pt.y - i); 61 62 MoveToEx (hdc, pt.x - i-1, pt.y, NULL); 63 LineTo (hdc, pt.x, pt.y - i-1); 63 64 } 64 65 65 66 SelectObject (hdc, GetSysColorPen (COLOR_3DHIGHLIGHT)); 66 67 for (i = 3; i < 13; i += 4) { 67 68 68 MoveToEx (hdc, pt.x - i, pt.y, NULL); 69 LineTo (hdc, pt.x, pt.y - i); 69 70 } 70 71 … … 73 74 74 75 75 static void 76 static void 76 77 STATUSBAR_DrawPart (HDC hdc, STATUSWINDOWPART *part) 77 78 { … … 88 89 /* draw the icon */ 89 90 if (part->hIcon) { 90 91 92 93 94 91 INT cy = r.bottom - r.top; 92 93 r.left += 2; 94 DrawIconEx (hdc, r.left, r.top, part->hIcon, cy, cy, 0, 0, DI_NORMAL); 95 r.left += cy; 95 96 } 96 97 … … 101 102 UINT align = DT_LEFT; 102 103 if (*p == L'\t') { 103 104 105 106 107 108 109 104 p++; 105 align = DT_CENTER; 106 107 if (*p == L'\t') { 108 p++; 109 align = DT_RIGHT; 110 } 110 111 } 111 112 r.left += 3; 112 113 DrawTextW (hdc, p, lstrlenW (p), &r, align|DT_VCENTER|DT_SINGLELINE); 113 114 if (oldbkmode != TRANSPARENT) 114 115 SetBkMode(hdc, oldbkmode); 115 116 } 116 117 } … … 128 129 129 130 if (self->clrBk != CLR_DEFAULT) 130 131 hbrBk = CreateSolidBrush (self->clrBk); 131 132 else 132 133 hbrBk = GetSysColorBrush (COLOR_3DFACE); 133 134 FillRect(hdc, &part->bound, hbrBk); 134 135 … … 136 137 137 138 if (part->style == SBT_OWNERDRAW) { 138 139 140 141 142 143 144 145 146 147 139 DRAWITEMSTRUCT dis; 140 141 dis.CtlID = GetWindowLongA (hwnd, GWL_ID); 142 dis.itemID = -1; 143 dis.hwndItem = hwnd; 144 dis.hDC = hdc; 145 dis.rcItem = part->bound; 146 dis.itemData = (INT)part->text; 147 SendMessageA (GetParent (hwnd), WM_DRAWITEM, 148 (WPARAM)dis.CtlID, (LPARAM)&dis); 148 149 } 149 150 else 150 151 STATUSBAR_DrawPart (hdc, part); 151 152 152 153 SelectObject (hdc, hOldFont); 153 154 154 155 if (self->clrBk != CLR_DEFAULT) 155 156 DeleteObject (hbrBk); 156 157 157 158 if (GetWindowLongA (hwnd, GWL_STYLE) & SBARS_SIZEGRIP) { 158 159 160 161 159 RECT rect; 160 161 GetClientRect (hwnd, &rect); 162 STATUSBAR_DrawSizeGrip (hdc, &rect); 162 163 } 163 164 } … … 179 180 180 181 if (infoPtr->clrBk != CLR_DEFAULT) 181 182 hbrBk = CreateSolidBrush (infoPtr->clrBk); 182 183 else 183 184 hbrBk = GetSysColorBrush (COLOR_3DFACE); 184 185 FillRect(hdc, &rect, hbrBk); 185 186 … … 187 188 188 189 if (infoPtr->simple) { 189 190 STATUSBAR_DrawPart (hdc, &infoPtr->part0); 190 191 } 191 192 else { 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 193 for (i = 0; i < infoPtr->numParts; i++) { 194 if (infoPtr->parts[i].style == SBT_OWNERDRAW) { 195 DRAWITEMSTRUCT dis; 196 197 dis.CtlID = GetWindowLongA (hwnd, GWL_ID); 198 dis.itemID = -1; 199 dis.hwndItem = hwnd; 200 dis.hDC = hdc; 201 dis.rcItem = infoPtr->parts[i].bound; 202 dis.itemData = (INT)infoPtr->parts[i].text; 203 SendMessageA (GetParent (hwnd), WM_DRAWITEM, 204 (WPARAM)dis.CtlID, (LPARAM)&dis); 205 } 206 else 207 STATUSBAR_DrawPart (hdc, &infoPtr->parts[i]); 208 } 208 209 } 209 210 … … 211 212 212 213 if (infoPtr->clrBk != CLR_DEFAULT) 213 214 DeleteObject (hbrBk); 214 215 215 216 if (GetWindowLongA(hwnd, GWL_STYLE) & SBARS_SIZEGRIP) 216 217 STATUSBAR_DrawSizeGrip (hdc, &rect); 217 218 218 219 return TRUE; … … 226 227 STATUSWINDOWPART *part; 227 228 RECT rect, *r; 228 int 229 int i; 229 230 230 231 /* get our window size */ … … 238 239 /* set bounds for non-simple rectangles */ 239 240 for (i = 0; i < self->numParts; i++) { 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 241 part = &self->parts[i]; 242 r = &self->parts[i].bound; 243 r->top = rect.top; 244 r->bottom = rect.bottom; 245 if (i == 0) 246 r->left = 0; 247 else 248 r->left = self->parts[i-1].bound.right + HORZ_GAP; 249 if (part->x == -1) 250 r->right = rect.right; 251 else 252 r->right = part->x; 253 254 if (self->hwndToolTip) { 255 TTTOOLINFOA ti; 256 257 ti.cbSize = sizeof(TTTOOLINFOA); 258 ti.hwnd = hwnd; 259 ti.uId = i; 260 ti.rect = *r; 261 SendMessageA (self->hwndToolTip, TTM_NEWTOOLRECTA, 262 0, (LPARAM)&ti); 263 } 263 264 } 264 265 } … … 267 268 static VOID 268 269 STATUSBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg, 269 270 WPARAM wParam, LPARAM lParam) 270 271 { 271 272 MSG msg; … … 304 305 nPart = (INT)wParam & 0x00ff; 305 306 if ((nPart < -1) || (nPart >= self->numParts)) 306 307 return 0; 307 308 308 309 if (nPart == -1) … … 324 325 parts = (LPINT) lParam; 325 326 if (parts) { 326 327 328 329 327 return (infoPtr->numParts); 328 for (i = 0; i < num_parts; i++) { 329 parts[i] = infoPtr->parts[i].x; 330 } 330 331 } 331 332 return (infoPtr->numParts); … … 337 338 { 338 339 STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr (hwnd); 339 int 340 int part_num; 340 341 LPRECT rect; 341 342 … … 343 344 rect = (LPRECT) lParam; 344 345 if (infoPtr->simple) 345 346 *rect = infoPtr->part0.bound; 346 347 else 347 348 *rect = infoPtr->parts[part_num].bound; 348 349 return TRUE; 349 350 } … … 360 361 nPart = ((INT) wParam) & 0x00ff; 361 362 if (self->simple) 362 363 part = &self->part0; 363 364 else 364 365 part = &self->parts[nPart]; 365 366 366 367 if (part->style == SBT_OWNERDRAW) 367 368 result = (LRESULT)part->text; 368 369 else { 369 370 371 372 370 result = part->text ? lstrlenW (part->text) : 0; 371 result |= (part->style << 16); 372 if (lParam && LOWORD(result)) 373 lstrcpyWtoA((LPSTR)lParam, part->text); 373 374 } 374 375 return result; … … 386 387 nPart = ((INT)wParam) & 0x00ff; 387 388 if (infoPtr->simple) 388 389 part = &infoPtr->part0; 389 390 else 390 391 part = &infoPtr->parts[nPart]; 391 392 392 393 if (part->style == SBT_OWNERDRAW) 393 394 result = (LRESULT)part->text; 394 395 else { 395 396 397 398 396 result = part->text ? lstrlenW (part->text) : 0; 397 result |= (part->style << 16); 398 if (lParam) 399 lstrcpyW ((LPWSTR)lParam, part->text); 399 400 } 400 401 return result; … … 413 414 414 415 if (infoPtr->simple) 415 416 part = &infoPtr->part0; 416 417 else 417 418 part = &infoPtr->parts[part_num]; 418 419 419 420 if (part->text) 420 421 result = lstrlenW(part->text); 421 422 else 422 423 result = 0; 423 424 424 425 result |= (part->style << 16); … … 433 434 434 435 if (infoPtr->hwndToolTip) { 435 436 437 438 439 440 441 442 436 TTTOOLINFOA ti; 437 ti.cbSize = sizeof(TTTOOLINFOA); 438 ti.hwnd = hwnd; 439 ti.uId = LOWORD(wParam); 440 SendMessageA (infoPtr->hwndToolTip, TTM_GETTEXTA, 0, (LPARAM)&ti); 441 442 if (ti.lpszText) 443 lstrcpynA ((LPSTR)lParam, ti.lpszText, HIWORD(wParam)); 443 444 } 444 445 … … 453 454 454 455 if (infoPtr->hwndToolTip) { 455 456 457 458 459 460 461 462 456 TTTOOLINFOW ti; 457 ti.cbSize = sizeof(TTTOOLINFOW); 458 ti.hwnd = hwnd; 459 ti.uId = LOWORD(wParam); 460 SendMessageW (infoPtr->hwndToolTip, TTM_GETTEXTW, 0, (LPARAM)&ti); 461 462 if (ti.lpszText) 463 lstrcpynW ((LPWSTR)lParam, ti.lpszText, HIWORD(wParam)); 463 464 } 464 465 … … 505 506 STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd); 506 507 INT nPart = (INT)wParam & 0x00ff; 507 HDC hdc; 508 HDC hdc; 508 509 509 510 if ((nPart < -1) || (nPart >= self->numParts)) 510 511 return FALSE; 511 512 512 513 hdc = GetDC (hwnd); 513 514 if (nPart == -1) { 514 515 516 515 self->part0.hIcon = (HICON)lParam; 516 if (self->simple) 517 STATUSBAR_RefreshPart (hwnd, &self->part0, hdc); 517 518 } 518 519 else { 519 520 521 520 self->parts[nPart].hIcon = (HICON)lParam; 521 if (!(self->simple)) 522 STATUSBAR_RefreshPart (hwnd, &self->parts[nPart], hdc); 522 523 } 523 524 ReleaseDC (hwnd, hdc); … … 533 534 534 535 if (IsWindowVisible (hwnd)) { 535 536 537 538 539 540 541 542 543 544 545 546 547 536 HWND parent = GetParent (hwnd); 537 INT width, x, y; 538 RECT parent_rect; 539 540 GetClientRect (parent, &parent_rect); 541 self->height = (INT)wParam + VERT_BORDER; 542 width = parent_rect.right - parent_rect.left; 543 x = parent_rect.left; 544 y = parent_rect.bottom - self->height; 545 MoveWindow (hwnd, parent_rect.left, 546 parent_rect.bottom - self->height, 547 width, self->height, TRUE); 548 STATUSBAR_SetPartBounds (hwnd); 548 549 } 549 550 … … 557 558 STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd); 558 559 STATUSWINDOWPART *tmp; 559 HDC 560 HDC hdc; 560 561 LPINT parts; 561 int 562 int 562 int i; 563 int oldNumParts; 563 564 564 565 if (self->simple) 565 566 self->simple = FALSE; 566 567 567 568 oldNumParts = self->numParts; … … 569 570 parts = (LPINT) lParam; 570 571 if (oldNumParts > self->numParts) { 571 572 573 574 572 for (i = self->numParts ; i < oldNumParts; i++) { 573 if (self->parts[i].text && (self->parts[i].style != SBT_OWNERDRAW)) 574 COMCTL32_Free (self->parts[i].text); 575 } 575 576 } 576 577 else if (oldNumParts < self->numParts) { 577 578 579 580 581 582 583 584 } 585 578 tmp = COMCTL32_Alloc (sizeof(STATUSWINDOWPART) * self->numParts); 579 for (i = 0; i < oldNumParts; i++) { 580 tmp[i] = self->parts[i]; 581 } 582 if (self->parts) 583 COMCTL32_Free (self->parts); 584 self->parts = tmp; 585 } 586 586 587 for (i = 0; i < self->numParts; i++) { 587 588 self->parts[i].x = parts[i]; 588 589 } 589 590 590 591 if (self->hwndToolTip) { 591 592 593 594 595 596 597 598 599 600 601 602 603 // 604 605 606 607 608 609 610 611 612 613 614 615 // 616 617 618 592 INT nTipCount = 593 SendMessageA (self->hwndToolTip, TTM_GETTOOLCOUNT, 0, 0); 594 595 if (nTipCount < self->numParts) { 596 /* add tools */ 597 TTTOOLINFOA ti; 598 INT i; 599 600 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 601 ti.cbSize = sizeof(TTTOOLINFOA); 602 ti.hwnd = hwnd; 603 for (i = nTipCount; i < self->numParts; i++) { 604 // TRACE (statusbar, "add tool %d\n", i); 605 ti.uId = i; 606 SendMessageA (self->hwndToolTip, TTM_ADDTOOLA, 607 0, (LPARAM)&ti); 608 } 609 } 610 else if (nTipCount > self->numParts) { 611 /* delete tools */ 612 INT i; 613 614 for (i = nTipCount - 1; i >= self->numParts; i--) { 615 616 // FIXME (statusbar, "delete tool %d\n", i); 617 618 } 619 } 619 620 } 620 621 … … 634 635 STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd); 635 636 STATUSWINDOWPART *part; 636 int 637 int 637 int part_num; 638 int style; 638 639 LPSTR text; 639 int 640 int len; 640 641 HDC hdc; 641 642 … … 645 646 646 647 if ((self->simple) || (self->parts==NULL) || (part_num==255)) 647 648 part = &self->part0; 648 649 else 649 650 part = &self->parts[part_num]; 650 651 if (!part) return FALSE; 651 652 part->style = style; 652 653 if (style == SBT_OWNERDRAW) { 653 654 part->text = (LPWSTR)text; 654 655 } 655 656 else { 656 657 658 659 660 661 662 663 657 /* duplicate string */ 658 if (part->text) 659 COMCTL32_Free (part->text); 660 part->text = 0; 661 if (text && (len = lstrlenA(text))) { 662 part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR)); 663 lstrcpyAtoW (part->text, text); 664 } 664 665 } 665 666 … … 686 687 687 688 if ((self->simple) || (self->parts==NULL) || (part_num==255)) 688 689 part = &self->part0; 689 690 else 690 691 part = &self->parts[part_num]; 691 692 if (!part) return FALSE; 692 693 part->style = style; 693 694 if (style == SBT_OWNERDRAW) { 694 695 part->text = text; 695 696 } 696 697 else { 697 698 699 700 701 702 703 704 698 /* duplicate string */ 699 if (part->text) 700 COMCTL32_Free (part->text); 701 part->text = 0; 702 if (text && (len = lstrlenW(text))) { 703 part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR)); 704 lstrcpyW(part->text, text); 705 } 705 706 } 706 707 … … 720 721 // TRACE (statusbar, "part %d: \"%s\"\n", (INT)wParam, (LPSTR)lParam); 721 722 if (infoPtr->hwndToolTip) { 722 723 724 725 726 727 728 729 723 TTTOOLINFOA ti; 724 ti.cbSize = sizeof(TTTOOLINFOA); 725 ti.hwnd = hwnd; 726 ti.uId = (INT)wParam; 727 ti.hinst = 0; 728 ti.lpszText = (LPSTR)lParam; 729 SendMessageA (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTA, 730 0, (LPARAM)&ti); 730 731 } 731 732 … … 741 742 // TRACE (statusbar, "part %d: \"%s\"\n", (INT)wParam, (LPSTR)lParam); 742 743 if (infoPtr->hwndToolTip) { 743 744 745 746 747 748 749 750 744 TTTOOLINFOW ti; 745 ti.cbSize = sizeof(TTTOOLINFOW); 746 ti.hwnd = hwnd; 747 ti.uId = (INT)wParam; 748 ti.hinst = 0; 749 ti.lpszText = (LPWSTR)lParam; 750 SendMessageW (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTW, 751 0, (LPARAM)&ti); 751 752 } 752 753 … … 796 797 LPCREATESTRUCTA lpCreate = (LPCREATESTRUCTA)lParam; 797 798 NONCLIENTMETRICSA nclm; 798 RECT 799 int 800 HDC 799 RECT rect; 800 int width, len; 801 HDC hdc; 801 802 STATUSWINDOWINFO *self; 802 803 … … 831 832 832 833 if (IsWindowUnicode (hwnd)) { 833 834 835 836 837 834 self->bUnicode = TRUE; 835 if ((len = lstrlenW ((LPCWSTR)lpCreate->lpszName))) { 836 self->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 837 lstrcpyW (self->parts[0].text, (LPCWSTR)lpCreate->lpszName); 838 } 838 839 } 839 840 else { 840 841 842 843 841 if ((len = lstrlenA ((LPCSTR)lpCreate->lpszName))) { 842 self->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 843 lstrcpyAtoW (self->parts[0].text, (LPCSTR)lpCreate->lpszName); 844 } 844 845 } 845 846 846 847 if ((hdc = GetDC (0))) { 847 848 849 850 851 852 853 854 848 TEXTMETRICA tm; 849 HFONT hOldFont; 850 851 hOldFont = SelectObject (hdc,self->hDefaultFont); 852 GetTextMetricsA(hdc, &tm); 853 self->textHeight = tm.tmHeight; 854 SelectObject (hdc, hOldFont); 855 ReleaseDC(0, hdc); 855 856 } 856 857 857 858 if (GetWindowLongA (hwnd, GWL_STYLE) & SBT_TOOLTIPS) { 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 859 self->hwndToolTip = 860 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0, 861 CW_USEDEFAULT, CW_USEDEFAULT, 862 CW_USEDEFAULT, CW_USEDEFAULT, 863 hwnd, 0, 864 GetWindowLongA (hwnd, GWL_HINSTANCE), NULL); 865 866 if (self->hwndToolTip) { 867 NMTOOLTIPSCREATED nmttc; 868 869 nmttc.hdr.hwndFrom = hwnd; 870 nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 871 nmttc.hdr.code = NM_TOOLTIPSCREATED; 872 nmttc.hwndToolTips = self->hwndToolTip; 873 874 SendMessageA (GetParent (hwnd), WM_NOTIFY, 875 (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc); 876 } 876 877 } 877 878 … … 880 881 self->height = self->textHeight + 4 + VERT_BORDER; 881 882 MoveWindow (hwnd, lpCreate->x, lpCreate->y-1, 882 883 width, self->height, FALSE); 883 884 STATUSBAR_SetPartBounds (hwnd); 884 885 … … 891 892 { 892 893 STATUSWINDOWINFO *self = STATUSBAR_GetInfoPtr (hwnd); 893 int 894 int i; 894 895 895 896 for (i = 0; i < self->numParts; i++) { 896 897 897 if (self->parts[i].text && (self->parts[i].style != SBT_OWNERDRAW)) 898 COMCTL32_Free (self->parts[i].text); 898 899 } 899 900 if (self->part0.text && (self->part0.style != SBT_OWNERDRAW)) 900 901 COMCTL32_Free (self->part0.text); 901 902 COMCTL32_Free (self->parts); 902 903 903 904 /* delete default font */ 904 905 if (self->hDefaultFont) 905 906 DeleteObject (self->hDefaultFont); 906 907 907 908 /* delete tool tip control */ 908 909 if (self->hwndToolTip) 909 910 DestroyWindow (self->hwndToolTip); 910 911 911 912 COMCTL32_Free (self); … … 933 934 len = lstrlenW (infoPtr->parts[0].text); 934 935 if (wParam > len) { 935 936 937 938 939 936 if (infoPtr->bUnicode) 937 lstrcpyW ((LPWSTR)lParam, infoPtr->parts[0].text); 938 else 939 lstrcpyWtoA ((LPSTR)lParam, infoPtr->parts[0].text); 940 return len; 940 941 } 941 942 … … 950 951 951 952 if (infoPtr->hwndToolTip) 952 953 953 STATUSBAR_RelayEvent (infoPtr->hwndToolTip, hwnd, 954 WM_MOUSEMOVE, wParam, lParam); 954 955 return 0; 955 956 } … … 960 961 { 961 962 if (GetWindowLongA (hwnd, GWL_STYLE) & SBARS_SIZEGRIP) { 962 963 964 965 966 967 968 969 970 971 972 973 974 975 963 RECT rect; 964 POINT pt; 965 966 GetClientRect (hwnd, &rect); 967 968 pt.x = (INT)LOWORD(lParam); 969 pt.y = (INT)HIWORD(lParam); 970 ScreenToClient (hwnd, &pt); 971 972 rect.left = rect.right - 13; 973 rect.top += 2; 974 975 if (PtInRect (&rect, pt)) 976 return HTBOTTOMRIGHT; 976 977 } 977 978 … … 1005 1006 STATUSBAR_Refresh (hwnd, hdc); 1006 1007 if (!wParam) 1007 1008 EndPaint (hwnd, &ps); 1008 1009 1009 1010 return 0; … … 1018 1019 infoPtr->hFont = (HFONT)wParam; 1019 1020 if (LOWORD(lParam) == TRUE) { 1020 1021 HDC hdc = GetDC (hwnd); 1021 1022 STATUSBAR_Refresh (hwnd, hdc); 1022 1023 ReleaseDC (hwnd, hdc); … … 1036 1037 1037 1038 if (infoPtr->numParts == 0) 1038 1039 return FALSE; 1039 1040 1040 1041 part = &infoPtr->parts[0]; … … 1044 1045 part->text = 0; 1045 1046 if (infoPtr->bUnicode) { 1046 1047 1048 1049 1047 if (lParam && (len = lstrlenW((LPCWSTR)lParam))) { 1048 part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR)); 1049 lstrcpyW (part->text, (LPCWSTR)lParam); 1050 } 1050 1051 } 1051 1052 else { 1052 1053 1054 1055 1053 if (lParam && (len = lstrlenA((LPCSTR)lParam))) { 1054 part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR)); 1055 lstrcpyAtoW (part->text, (LPCSTR)lParam); 1056 } 1056 1057 } 1057 1058 … … 1080 1081 1081 1082 if (flags == SIZE_RESTORED) { 1082 1083 1084 1085 1086 1087 1088 MoveWindow (hwnd, parent_rect.left, 1089 1090 1091 1083 /* width and height don't apply */ 1084 parent = GetParent (hwnd); 1085 GetClientRect (parent, &parent_rect); 1086 width = parent_rect.right - parent_rect.left; 1087 x = parent_rect.left; 1088 y = parent_rect.bottom - infoPtr->height; 1089 MoveWindow (hwnd, parent_rect.left, 1090 parent_rect.bottom - infoPtr->height, 1091 width, infoPtr->height, TRUE); 1092 STATUSBAR_SetPartBounds (hwnd); 1092 1093 } 1093 1094 return 0; … … 1113 1114 { 1114 1115 switch (msg) { 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 case SB_SETPARTS: 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1116 case SB_GETBORDERS: 1117 return STATUSBAR_GetBorders (lParam); 1118 1119 case SB_GETICON: 1120 return STATUSBAR_GetIcon (hwnd, wParam); 1121 1122 case SB_GETPARTS: 1123 return STATUSBAR_GetParts (hwnd, wParam, lParam); 1124 1125 case SB_GETRECT: 1126 return STATUSBAR_GetRect (hwnd, wParam, lParam); 1127 1128 case SB_GETTEXTA: 1129 return STATUSBAR_GetTextA (hwnd, wParam, lParam); 1130 1131 case SB_GETTEXTW: 1132 return STATUSBAR_GetTextW (hwnd, wParam, lParam); 1133 1134 case SB_GETTEXTLENGTHA: 1135 case SB_GETTEXTLENGTHW: 1136 return STATUSBAR_GetTextLength (hwnd, wParam); 1137 1138 case SB_GETTIPTEXTA: 1139 return STATUSBAR_GetTipTextA (hwnd, wParam, lParam); 1140 1141 case SB_GETTIPTEXTW: 1142 return STATUSBAR_GetTipTextW (hwnd, wParam, lParam); 1143 1144 case SB_GETUNICODEFORMAT: 1145 return STATUSBAR_GetUnicodeFormat (hwnd); 1146 1147 case SB_ISSIMPLE: 1148 return STATUSBAR_IsSimple (hwnd); 1149 1150 case SB_SETBKCOLOR: 1151 return STATUSBAR_SetBkColor (hwnd, wParam, lParam); 1152 1153 case SB_SETICON: 1154 return STATUSBAR_SetIcon (hwnd, wParam, lParam); 1155 1156 case SB_SETMINHEIGHT: 1157 return STATUSBAR_SetMinHeight (hwnd, wParam, lParam); 1158 1159 case SB_SETPARTS: 1160 return STATUSBAR_SetParts (hwnd, wParam, lParam); 1161 1162 case SB_SETTEXTA: 1163 return STATUSBAR_SetTextA (hwnd, wParam, lParam); 1164 1165 case SB_SETTEXTW: 1166 return STATUSBAR_SetTextW (hwnd, wParam, lParam); 1167 1168 case SB_SETTIPTEXTA: 1169 return STATUSBAR_SetTipTextA (hwnd, wParam, lParam); 1170 1171 case SB_SETTIPTEXTW: 1172 return STATUSBAR_SetTipTextW (hwnd, wParam, lParam); 1173 1174 case SB_SETUNICODEFORMAT: 1175 return STATUSBAR_SetUnicodeFormat (hwnd, wParam); 1176 1177 case SB_SIMPLE: 1178 return STATUSBAR_Simple (hwnd, wParam, lParam); 1179 1180 1181 case WM_CREATE: 1182 return STATUSBAR_WMCreate (hwnd, wParam, lParam); 1183 1184 case WM_DESTROY: 1185 return STATUSBAR_WMDestroy (hwnd); 1186 1187 case WM_GETFONT: 1187 1188 return STATUSBAR_WMGetFont (hwnd); 1188 1189 1189 1190 case WM_GETTEXT: 1190 1191 return STATUSBAR_WMGetText (hwnd, wParam, lParam); 1191 1192 1192 1193 1194 1195 1193 case WM_GETTEXTLENGTH: 1194 return STATUSBAR_GetTextLength (hwnd, 0); 1195 1196 case WM_LBUTTONDBLCLK: 1196 1197 return STATUSBAR_SendNotify (hwnd, NM_DBLCLK); 1197 1198 1198 1199 1200 1201 1199 case WM_LBUTTONUP: 1200 return STATUSBAR_SendNotify (hwnd, NM_CLICK); 1201 1202 case WM_MOUSEMOVE: 1202 1203 return STATUSBAR_WMMouseMove (hwnd, wParam, lParam); 1203 1204 1204 1205 case WM_NCHITTEST: 1205 1206 return STATUSBAR_WMNCHitTest (hwnd, wParam, lParam); 1206 1207 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 // 1234 // 1235 1208 case WM_NCLBUTTONDOWN: 1209 return STATUSBAR_WMNCLButtonDown (hwnd, wParam, lParam); 1210 1211 case WM_NCLBUTTONUP: 1212 return STATUSBAR_WMNCLButtonUp (hwnd, wParam, lParam); 1213 1214 case WM_PAINT: 1215 return STATUSBAR_WMPaint (hwnd, wParam); 1216 1217 case WM_RBUTTONDBLCLK: 1218 return STATUSBAR_SendNotify (hwnd, NM_RDBLCLK); 1219 1220 case WM_RBUTTONUP: 1221 return STATUSBAR_SendNotify (hwnd, NM_RCLICK); 1222 1223 case WM_SETFONT: 1224 return STATUSBAR_WMSetFont (hwnd, wParam, lParam); 1225 1226 case WM_SETTEXT: 1227 return STATUSBAR_WMSetText (hwnd, wParam, lParam); 1228 1229 case WM_SIZE: 1230 return STATUSBAR_WMSize (hwnd, wParam, lParam); 1231 1232 default: 1233 // if (msg >= WM_USER) 1234 // ERR (statusbar, "unknown msg %04x wp=%04x lp=%08lx\n", 1235 // msg, wParam, lParam); 1236 return DefWindowProcA (hwnd, msg, wParam, lParam); 1236 1237 } 1237 1238 return 0; … … 1260 1261 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); 1261 1262 wndClass.lpszClassName = STATUSCLASSNAMEA; 1262 1263 1263 1264 RegisterClassA (&wndClass); 1264 1265 } … … 1275 1276 { 1276 1277 if (GlobalFindAtomA (STATUSCLASSNAMEA)) 1277 1278 } 1279 1278 UnregisterClassA (STATUSCLASSNAMEA, (HINSTANCE)NULL); 1279 } 1280 -
trunk/src/comctl32/toolbar.c
r94 r110 1 /* $Id: toolbar.c,v 1. 4 1999-06-10 16:22:02 achimhaExp $ */1 /* $Id: toolbar.c,v 1.5 1999-06-16 20:25:43 cbratschi Exp $ */ 2 2 /* 3 3 * Toolbar control … … 5 5 * Copyright 1998,1999 Eric Kohl 6 6 * Copyright 1999 Achim Hasenmueller 7 * Copyright 1999 Christoph Bratschi 7 8 * 8 9 * TODO: … … 65 66 static void 66 67 TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, 67 68 HDC hdc, INT nState) 68 69 { 69 70 RECT rcText = btnPtr->rect; … … 74 75 /* draw text */ 75 76 if ((btnPtr->iString > -1) && (btnPtr->iString < infoPtr->nNumStrings)) { 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 77 InflateRect (&rcText, -3, -3); 78 rcText.top += infoPtr->nBitmapHeight; 79 if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED)) 80 OffsetRect (&rcText, 1, 1); 81 82 hOldFont = SelectObject (hdc, infoPtr->hFont); 83 nOldBkMode = SetBkMode (hdc, TRANSPARENT); 84 if (!(nState & TBSTATE_ENABLED)) { 85 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT)); 86 OffsetRect (&rcText, 1, 1); 87 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1, 88 &rcText, infoPtr->dwDTFlags); 89 SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW)); 90 OffsetRect (&rcText, -1, -1); 91 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1, 92 &rcText, infoPtr->dwDTFlags); 93 } 94 else if (nState & TBSTATE_INDETERMINATE) { 95 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW)); 96 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1, 97 &rcText, infoPtr->dwDTFlags); 98 } 99 else { 100 clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT)); 101 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1, 102 &rcText, infoPtr->dwDTFlags); 103 } 104 105 SetTextColor (hdc, clrOld); 106 SelectObject (hdc, hOldFont); 107 if (nOldBkMode != TRANSPARENT) 108 SetBkMode (hdc, nOldBkMode); 108 109 } 109 110 } … … 123 124 static void 124 125 TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, 125 126 HDC hdc, INT x, INT y) 126 127 { 127 128 /* FIXME: this function is a hack since it uses image list 128 129 internals directly */ 129 130 130 131 HDC hdcImageList = CreateCompatibleDC (0); … … 142 143 SetTextColor (hdcImageList, RGB(0, 0, 0)); 143 144 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy, 144 145 hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY); 145 146 146 147 #if 0 … … 149 150 SetBkColor (hdcImageList, RGB(0, 0, 0)); 150 151 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy, 151 152 hdcImageList, himl->cx * btnPtr->iBitmap, 0, MERGEPAINT); 152 153 #endif 153 154 … … 155 156 SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT)); 156 157 BitBlt (hdc, x+1, y+1, himl->cx, himl->cy, 157 158 hdcMask, 0, 0, 0xB8074A); 158 159 159 160 SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW)); 160 161 BitBlt (hdc, x, y, himl->cx, himl->cy, 161 162 hdcMask, 0, 0, 0xB8074A); 162 163 163 164 DeleteObject (hbmMask); … … 175 176 176 177 if (btnPtr->fsState & TBSTATE_HIDDEN) 177 178 return; 178 179 179 180 rc = btnPtr->rect; 180 181 if (btnPtr->fsStyle & TBSTYLE_SEP) { 181 182 183 182 if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->idCommand == 0)) 183 TOOLBAR_DrawFlatSeparator (&btnPtr->rect, hdc); 184 return; 184 185 } 185 186 186 187 /* disabled */ 187 188 if (!(btnPtr->fsState & TBSTATE_ENABLED)) { 188 189 190 191 192 /* 193 194 195 /* 196 /* 197 198 199 200 201 202 189 DrawEdge (hdc, &rc, EDGE_RAISED, 190 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 191 192 if (dwStyle & TBSTYLE_FLAT) { 193 /* if (infoPtr->himlDis) */ 194 ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc, 195 rc.left+1, rc.top+1, ILD_NORMAL); 196 /* else */ 197 /* TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); */ 198 } 199 else 200 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); 201 202 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState); 203 return; 203 204 } 204 205 205 206 /* pressed TBSTYLE_BUTTON */ 206 207 if (btnPtr->fsState & TBSTATE_PRESSED) { 207 208 209 210 211 208 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST); 209 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc, 210 rc.left+2, rc.top+2, ILD_NORMAL); 211 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState); 212 return; 212 213 } 213 214 214 215 /* checked TBSTYLE_CHECK*/ 215 216 if ((btnPtr->fsStyle & TBSTYLE_CHECK) && 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 } 240 241 /* indeterminate */ 217 (btnPtr->fsState & TBSTATE_CHECKED)) { 218 if (dwStyle & TBSTYLE_FLAT) 219 DrawEdge (hdc, &rc, BDR_SUNKENOUTER, 220 BF_RECT | BF_MIDDLE | BF_ADJUST); 221 else 222 DrawEdge (hdc, &rc, EDGE_SUNKEN, 223 BF_RECT | BF_MIDDLE | BF_ADJUST); 224 225 TOOLBAR_DrawPattern (hdc, &rc); 226 if (dwStyle & TBSTYLE_FLAT) 227 { 228 if (infoPtr->himlDef != NULL) 229 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 230 rc.left+2, rc.top+2, ILD_NORMAL); 231 else 232 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc, 233 rc.left+2, rc.top+2, ILD_NORMAL); 234 } 235 else 236 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc, 237 rc.left+2, rc.top+2, ILD_NORMAL); 238 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState); 239 return; 240 } 241 242 /* indeterminate */ 242 243 if (btnPtr->fsState & TBSTATE_INDETERMINATE) { 243 244 245 246 247 248 249 244 DrawEdge (hdc, &rc, EDGE_RAISED, 245 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 246 247 TOOLBAR_DrawPattern (hdc, &rc); 248 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); 249 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState); 250 return; 250 251 } 251 252 252 253 if (dwStyle & TBSTYLE_FLAT) 253 254 { 254 255 256 257 258 259 260 261 262 263 255 if(btnPtr->bHot) 256 DrawEdge (hdc, &rc, BDR_RAISEDINNER, 257 BF_RECT | BF_MIDDLE | BF_SOFT); 258 259 if(infoPtr->himlDef != NULL) 260 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 261 rc.left +2, rc.top +2, ILD_NORMAL); 262 else 263 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc, 264 rc.left +2, rc.top +2, ILD_NORMAL); 264 265 } 265 266 else{ 266 267 /* normal state */ 267 268 DrawEdge (hdc, &rc, EDGE_RAISED, 268 269 270 271 269 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 270 271 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc, 272 rc.left+1, rc.top+1, ILD_NORMAL); 272 273 } 273 274 … … 286 287 btnPtr = infoPtr->buttons; 287 288 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) 288 289 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 289 290 } 290 291 … … 307 308 btnPtr = infoPtr->buttons; 308 309 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) { 309 310 311 312 313 314 315 316 317 318 310 if (!(btnPtr->fsState & TBSTATE_HIDDEN) && 311 (btnPtr->iString > -1) && 312 (btnPtr->iString < infoPtr->nNumStrings)) { 313 LPWSTR lpText = infoPtr->strings[btnPtr->iString]; 314 GetTextExtentPoint32W (hdc, lpText, lstrlenW (lpText), &sz); 315 if (sz.cx > lpSize->cx) 316 lpSize->cx = sz.cx; 317 if (sz.cy > lpSize->cy) 318 lpSize->cy = sz.cy; 319 } 319 320 } 320 321 … … 326 327 327 328 /*********************************************************************** 328 * 329 * TOOLBAR_WrapToolbar 329 330 * 330 * This function walks through the buttons and seperators in the 331 * toolbar, and sets the TBSTATE_WRAP flag only on those items where 332 * wrapping should occur based on the width of the toolbar window. 333 * It does *not* calculate button placement itself. That task 334 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage 335 * the toolbar wrapping on it's own, it can use the TBSTYLE_WRAPPABLE 331 * This function walks through the buttons and seperators in the 332 * toolbar, and sets the TBSTATE_WRAP flag only on those items where 333 * wrapping should occur based on the width of the toolbar window. 334 * It does *not* calculate button placement itself. That task 335 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage 336 * the toolbar wrapping on it's own, it can use the TBSTYLE_WRAPPABLE 336 337 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items. 337 */ 338 */ 338 339 339 340 static void … … 347 348 BOOL bWrap, bButtonWrap; 348 349 349 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */350 /* 351 /* to perform their own layout on the toolbar.*/350 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */ 351 /* no layout is necessary. Applications may use this style */ 352 /* to perform their own layout on the toolbar. */ 352 353 if( !(dwStyle & TBSTYLE_WRAPABLE) ) 353 354 return; 354 355 355 356 btnPtr = infoPtr->buttons; … … 362 363 for (i = 0; i < infoPtr->nNumButtons; i++ ) 363 364 { 364 365 366 367 368 369 370 371 372 373 374 cx = (btnPtr[i].iBitmap > 0) ? 375 376 377 378 379 /* Two or more adjacent separators form a separator group. */ 380 381 /* next row if the previous wrapping is on a button.*/382 383 (btnPtr[i].fsStyle & TBSTYLE_SEP) && 384 385 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) ) 386 387 388 389 390 391 392 393 394 395 if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2 396 > infoPtr->nWidth ) 397 398 399 400 /* If the current button is a separator and not hidden, */ 401 /*go to the next until it reaches a non separator. */402 /*Wrap the last separator if it is before a button. */403 while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) || 404 (btnPtr[i].fsState & TBSTATE_HIDDEN) ) && 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 /* If the current button is not a separator, find the last */ 423 /* separator and wrap it.*/424 425 426 427 428 429 bFound = TRUE; 430 i = j; 431 432 433 bButtonWrap = FALSE; 434 435 436 437 438 /* If no separator available for wrapping, wrap one of*/439 /* non-hidden previous button.*/440 441 442 for ( j = i - 1; 443 444 445 if (btnPtr[j].fsState & TBSTATE_HIDDEN) 446 447 448 bFound = TRUE; 449 i = j; 450 451 452 453 454 455 456 457 458 if (!bFound) 459 460 461 462 463 464 465 466 467 } 468 469 470 471 } 472 } 473 365 bWrap = FALSE; 366 btnPtr[i].fsState &= ~TBSTATE_WRAP; 367 368 if (btnPtr[i].fsState & TBSTATE_HIDDEN) 369 continue; 370 371 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */ 372 /* it is the actual width of the separator. This is used for */ 373 /* custom controls in toolbars. */ 374 if (btnPtr[i].fsStyle & TBSTYLE_SEP) 375 cx = (btnPtr[i].iBitmap > 0) ? 376 btnPtr[i].iBitmap : SEPARATOR_WIDTH; 377 else 378 cx = infoPtr->nButtonWidth; 379 380 /* Two or more adjacent separators form a separator group. */ 381 /* The first separator in a group should be wrapped to the */ 382 /* next row if the previous wrapping is on a button. */ 383 if( bButtonWrap && 384 (btnPtr[i].fsStyle & TBSTYLE_SEP) && 385 (i + 1 < infoPtr->nNumButtons ) && 386 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) ) 387 { 388 btnPtr[i].fsState |= TBSTATE_WRAP; 389 x = infoPtr->nIndent; 390 i++; 391 bButtonWrap = FALSE; 392 continue; 393 } 394 395 /* The layout makes sure the bitmap is visible, but not the button. */ 396 if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2 397 > infoPtr->nWidth ) 398 { 399 BOOL bFound = FALSE; 400 401 /* If the current button is a separator and not hidden, */ 402 /* go to the next until it reaches a non separator. */ 403 /* Wrap the last separator if it is before a button. */ 404 while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) || 405 (btnPtr[i].fsState & TBSTATE_HIDDEN) ) && 406 i < infoPtr->nNumButtons ) 407 { 408 i++; 409 bFound = TRUE; 410 } 411 412 if( bFound && i < infoPtr->nNumButtons ) 413 { 414 i--; 415 btnPtr[i].fsState |= TBSTATE_WRAP; 416 x = infoPtr->nIndent; 417 bButtonWrap = FALSE; 418 continue; 419 } 420 else if ( i >= infoPtr->nNumButtons) 421 break; 422 423 /* If the current button is not a separator, find the last */ 424 /* separator and wrap it. */ 425 for ( j = i - 1; j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--) 426 { 427 if ((btnPtr[j].fsStyle & TBSTYLE_SEP) && 428 !(btnPtr[j].fsState & TBSTATE_HIDDEN)) 429 { 430 bFound = TRUE; 431 i = j; 432 x = infoPtr->nIndent; 433 btnPtr[j].fsState |= TBSTATE_WRAP; 434 bButtonWrap = FALSE; 435 break; 436 } 437 } 438 439 /* If no separator available for wrapping, wrap one of */ 440 /* non-hidden previous button. */ 441 if (!bFound) 442 { 443 for ( j = i - 1; 444 j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--) 445 { 446 if (btnPtr[j].fsState & TBSTATE_HIDDEN) 447 continue; 448 449 bFound = TRUE; 450 i = j; 451 x = infoPtr->nIndent; 452 btnPtr[j].fsState |= TBSTATE_WRAP; 453 bButtonWrap = TRUE; 454 break; 455 } 456 } 457 458 /* If all above failed, wrap the current button. */ 459 if (!bFound) 460 { 461 btnPtr[i].fsState |= TBSTATE_WRAP; 462 bFound = TRUE; 463 x = infoPtr->nIndent; 464 if (btnPtr[i].fsState & TBSTYLE_SEP ) 465 bButtonWrap = FALSE; 466 else 467 bButtonWrap = TRUE; 468 } 469 } 470 else 471 x += cx; 472 } 473 } 474 474 475 /*********************************************************************** 475 * 476 * TOOLBAR_CalcToolbar 476 477 * 477 * This function calculates button and separator placement. It first 478 * calculates the button sizes, gets the toolbar window width and then 479 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap 478 * This function calculates button and separator placement. It first 479 * calculates the button sizes, gets the toolbar window width and then 480 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap 480 481 * on. It assigns a new location to each item and sends this location to 481 * the tooltip window if appropriate. Finally, it updates the rcBound 482 * rect and calculates the new required toolbar window height. 483 */ 482 * the tooltip window if appropriate. Finally, it updates the rcBound 483 * rect and calculates the new required toolbar window height. 484 */ 484 485 485 486 static void … … 497 498 498 499 if (sizeString.cy > 0) 499 500 infoPtr->nButtonHeight = sizeString.cy + infoPtr->nBitmapHeight + 6; 500 501 else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6) 501 502 infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6; 502 503 503 504 if (sizeString.cx > infoPtr->nBitmapWidth) 504 505 infoPtr->nButtonWidth = sizeString.cx + 6; 505 506 else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6) 506 507 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6; 507 508 508 509 TOOLBAR_WrapToolbar( hwnd ); … … 525 526 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ ) 526 527 { 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP )) 557 558 559 560 561 562 563 564 565 566 567 568 569 /* btnPtr->nRow is zero based. The space between the rows is*/570 /* also considered as a row.*/571 572 573 574 575 576 else 577 { 578 579 580 /* custom controls in toolbars.*/581 y += cy + ( (btnPtr->iBitmap > 0 ) ? 582 btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3; 583 584 /* nSepRows is used to calculate the extra height follwoing */ 585 /* the last row.*/586 587 588 589 590 591 592 528 bWrap = FALSE; 529 if (btnPtr->fsState & TBSTATE_HIDDEN) 530 { 531 SetRectEmpty (&btnPtr->rect); 532 continue; 533 } 534 535 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */ 536 /* it is the actual width of the separator. This is used for */ 537 /* custom controls in toolbars. */ 538 if (btnPtr->fsStyle & TBSTYLE_SEP) 539 cx = (btnPtr->iBitmap > 0) ? 540 btnPtr->iBitmap : SEPARATOR_WIDTH; 541 else 542 cx = infoPtr->nButtonWidth; 543 544 if (btnPtr->fsState & TBSTATE_WRAP ) 545 bWrap = TRUE; 546 547 SetRect (&btnPtr->rect, x, y, x + cx, y + cy); 548 549 if (infoPtr->rcBound.left > x) 550 infoPtr->rcBound.left = x; 551 if (infoPtr->rcBound.right < x + cx) 552 infoPtr->rcBound.right = x + cx; 553 if (infoPtr->rcBound.bottom < y + cy) 554 infoPtr->rcBound.bottom = y + cy; 555 556 /* Set the toolTip only for non-hidden, non-separator button */ 557 if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP )) 558 { 559 TTTOOLINFOA ti; 560 561 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 562 ti.cbSize = sizeof(TTTOOLINFOA); 563 ti.hwnd = hwnd; 564 ti.uId = btnPtr->idCommand; 565 ti.rect = btnPtr->rect; 566 SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA, 567 0, (LPARAM)&ti); 568 } 569 570 /* btnPtr->nRow is zero based. The space between the rows is */ 571 /* also considered as a row. */ 572 btnPtr->nRow = nRows + nSepRows; 573 if( bWrap ) 574 { 575 if ( !(btnPtr->fsStyle & TBSTYLE_SEP) ) 576 y += cy; 577 else 578 { 579 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */ 580 /* it is the actual width of the separator. This is used for */ 581 /* custom controls in toolbars. */ 582 y += cy + ( (btnPtr->iBitmap > 0 ) ? 583 btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3; 584 585 /* nSepRows is used to calculate the extra height follwoing */ 586 /* the last row. */ 587 nSepRows++; 588 } 589 x = infoPtr->nIndent; 590 nRows++; 591 } 592 else 593 x += cx; 593 594 } 594 595 … … 596 597 infoPtr->nRows = nRows + nSepRows + 1; 597 598 598 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following 599 /* the last row. 600 infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight + 601 602 nSepRows * (infoPtr->nBitmapHeight + 1) + 603 BOTTOM_BORDER; 599 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */ 600 /* the last row. */ 601 infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight + 602 nSepRows * SEPARATOR_WIDTH * 2 / 3 + 603 nSepRows * (infoPtr->nBitmapHeight + 1) + 604 BOTTOM_BORDER; 604 605 // TRACE (toolbar, "toolbar height %d\n", infoPtr->nHeight); 605 606 } … … 612 613 TBUTTON_INFO *btnPtr; 613 614 INT i; 614 615 615 616 btnPtr = infoPtr->buttons; 616 617 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) { 617 618 619 620 621 622 // 623 624 625 626 627 628 // 629 630 631 618 if (btnPtr->fsState & TBSTATE_HIDDEN) 619 continue; 620 621 if (btnPtr->fsStyle & TBSTYLE_SEP) { 622 if (PtInRect (&btnPtr->rect, *lpPt)) { 623 // TRACE (toolbar, " ON SEPARATOR %d!\n", i); 624 return -i; 625 } 626 } 627 else { 628 if (PtInRect (&btnPtr->rect, *lpPt)) { 629 // TRACE (toolbar, " ON BUTTON %d!\n", i); 630 return i; 631 } 632 } 632 633 } 633 634 … … 645 646 btnPtr = infoPtr->buttons; 646 647 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) { 647 648 // 649 650 648 if (btnPtr->idCommand == idCommand) { 649 // TRACE (toolbar, "command=%d index=%d\n", idCommand, i); 650 return i; 651 } 651 652 } 652 653 // TRACE (toolbar, "no index found for command=%d\n", idCommand); … … 662 663 663 664 if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons)) 664 665 return -1; 665 666 666 667 /* check index button */ 667 668 btnPtr = &infoPtr->buttons[nIndex]; 668 669 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) { 669 670 670 if (btnPtr->fsState & TBSTATE_CHECKED) 671 return nIndex; 671 672 } 672 673 … … 674 675 nRunIndex = nIndex - 1; 675 676 while (nRunIndex >= 0) { 676 677 678 679 680 681 682 683 677 btnPtr = &infoPtr->buttons[nRunIndex]; 678 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) { 679 if (btnPtr->fsState & TBSTATE_CHECKED) 680 return nRunIndex; 681 } 682 else 683 break; 684 nRunIndex--; 684 685 } 685 686 … … 687 688 nRunIndex = nIndex + 1; 688 689 while (nRunIndex < infoPtr->nNumButtons) { 689 btnPtr = &infoPtr->buttons[nRunIndex]; 690 691 692 693 694 695 696 690 btnPtr = &infoPtr->buttons[nRunIndex]; 691 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) { 692 if (btnPtr->fsState & TBSTATE_CHECKED) 693 return nRunIndex; 694 } 695 else 696 break; 697 nRunIndex++; 697 698 } 698 699 … … 703 704 static VOID 704 705 TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg, 705 706 WPARAM wParam, LPARAM lParam) 706 707 { 707 708 MSG msg; … … 731 732 switch (uMsg) 732 733 { 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 /* copy all buttons and append them to the right listbox */ 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 // 798 // lpdis->itemAction, lpdis->itemState);799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 734 case WM_INITDIALOG: 735 infoPtr = (TOOLBAR_INFO *)lParam; 736 SetWindowLongA (hwnd, DWL_USER, (DWORD)infoPtr); 737 738 hDsa = DSA_Create (sizeof(TBUTTON_INFO), 5); 739 740 if (infoPtr) 741 { 742 TBUTTON_INFO *btnPtr; 743 INT i; 744 745 /* insert 'virtual' separator button into 'available buttons' list */ 746 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)""); 747 748 /* copy all buttons and append them to the right listbox */ 749 btnPtr = infoPtr->buttons; 750 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) 751 { 752 DSA_InsertItem (hDsa, i, btnPtr); 753 754 if (btnPtr->fsState & TBSTATE_HIDDEN) 755 { 756 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)""); 757 } 758 else 759 { 760 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)""); 761 } 762 } 763 764 /* append 'virtual' sepatator button to the 'toolbar buttons' list */ 765 /* TODO */ 766 } 767 return TRUE; 768 769 case WM_CLOSE: 770 EndDialog(hwnd, FALSE); 771 return TRUE; 772 773 case WM_COMMAND: 774 switch (LOWORD(wParam)) 775 { 776 case IDCANCEL: 777 EndDialog(hwnd, FALSE); 778 break; 779 } 780 return TRUE; 781 782 case WM_DESTROY: 783 if (hDsa) 784 DSA_Destroy (hDsa); 785 return TRUE; 786 787 case WM_DRAWITEM: 788 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX) 789 { 790 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam; 791 RECT rcButton; 792 RECT rcText; 793 HPEN hOldPen; 794 HBRUSH hOldBrush; 795 COLORREF oldText = 0; 796 COLORREF oldBk = 0; 797 798 // FIXME(toolbar, "action: %x itemState: %x\n", 799 // lpdis->itemAction, lpdis->itemState); 800 801 if (lpdis->itemState & ODS_FOCUS) 802 { 803 oldBk = SetBkColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT)); 804 oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); 805 } 806 807 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 808 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 809 810 /* fill background rectangle */ 811 Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, 812 lpdis->rcItem.right, lpdis->rcItem.bottom); 813 814 /* calculate button and text rectangles */ 815 CopyRect (&rcButton, &lpdis->rcItem); 816 InflateRect (&rcButton, -1, -1); 817 CopyRect (&rcText, &rcButton); 818 rcButton.right = rcButton.left + infoPtr->nBitmapWidth + 6; 819 rcText.left = rcButton.right + 2; 820 821 /* draw focus rectangle */ 822 if (lpdis->itemState & ODS_FOCUS) 823 DrawFocusRect (lpdis->hDC, &lpdis->rcItem); 824 825 /* draw button */ 826 DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT); 827 828 /* draw text */ 829 if (wParam == IDC_AVAILBTN_LBOX && lpdis->itemID == 0) 830 DrawTextA (lpdis->hDC, "Separator", -1, &rcText, 831 DT_LEFT | DT_VCENTER | DT_SINGLELINE); 832 833 if (lpdis->itemState & ODS_FOCUS) 834 { 835 SetBkColor (lpdis->hDC, oldBk); 836 SetTextColor (lpdis->hDC, oldText); 837 } 838 839 SelectObject (lpdis->hDC, hOldBrush); 840 SelectObject (lpdis->hDC, hOldPen); 841 842 return TRUE; 843 } 844 return FALSE; 845 846 case WM_MEASUREITEM: 847 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX) 848 { 849 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam; 850 851 if (infoPtr) 852 lpmis->itemHeight = infoPtr->nBitmapHeight + 8; 853 else 854 lpmis->itemHeight = 16 + 8; /* default height */ 855 856 return TRUE; 857 } 858 return FALSE; 859 860 default: 861 return FALSE; 861 862 } 862 863 } … … 875 876 876 877 if ((!lpAddBmp) || ((INT)wParam <= 0)) 877 878 return -1; 878 879 879 880 // TRACE (toolbar, "adding %d bitmaps!\n", wParam); 880 881 881 882 if (!(infoPtr->himlStd)) { 882 883 884 // 885 886 887 888 889 890 891 892 if (lpAddBmp->nID & 1) 893 894 895 896 897 898 899 else 900 901 902 903 904 905 906 907 908 909 910 911 912 913 883 /* create new standard image list */ 884 885 // TRACE (toolbar, "creating standard image list!\n"); 886 887 888 /* Windows resize all the buttons to the size of a newly added STandard Image*/ 889 /* TODO: The resizing should be done each time a standard image is added*/ 890 if (lpAddBmp->hInst == HINST_COMMCTRL) 891 { 892 893 if (lpAddBmp->nID & 1) 894 { 895 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0, 896 MAKELPARAM((WORD)26, (WORD)26)); 897 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0, 898 MAKELPARAM((WORD)33, (WORD)33)); 899 } 900 else 901 { 902 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0, 903 MAKELPARAM((WORD)16, (WORD)16)); 904 905 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0, 906 MAKELPARAM((WORD)22, (WORD)22)); 907 } 908 909 TOOLBAR_CalcToolbar (hwnd); 910 } 911 912 infoPtr->himlStd = 913 ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight, 914 ILC_COLOR | ILC_MASK, (INT)wParam, 2); 914 915 } 915 916 916 917 /* Add bitmaps to the standard image list */ 917 918 if (lpAddBmp->hInst == (HINSTANCE)0) { 918 nIndex = 919 920 919 nIndex = 920 ImageList_AddMasked (infoPtr->himlStd, (HBITMAP)lpAddBmp->nID, 921 CLR_DEFAULT); 921 922 } 922 923 else if (lpAddBmp->hInst == HINST_COMMCTRL) { 923 924 925 // 926 927 928 /* Hack to "add" some reserved images within the image list 929 930 931 932 924 /* add internal bitmaps */ 925 926 // FIXME (toolbar, "internal bitmaps not supported!\n"); 927 /* TODO: Resize all the buttons when a new standard image is added */ 928 929 /* Hack to "add" some reserved images within the image list 930 to get the right image indices */ 931 nIndex = ImageList_GetImageCount (infoPtr->himlStd); 932 ImageList_SetImageCount (infoPtr->himlStd, nIndex + (INT)wParam); 933 933 934 } 934 935 else { 935 936 937 938 939 DeleteObject (hBmp); 936 HBITMAP hBmp = 937 LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID); 938 nIndex = ImageList_AddMasked (infoPtr->himlStd, hBmp, CLR_DEFAULT); 939 940 DeleteObject (hBmp); 940 941 } 941 942 … … 960 961 961 962 if (infoPtr->nNumButtons == 0) { 962 963 963 infoPtr->buttons = 964 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons); 964 965 } 965 966 else { 966 967 968 969 970 967 TBUTTON_INFO *oldButtons = infoPtr->buttons; 968 infoPtr->buttons = 969 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons); 970 memcpy (&infoPtr->buttons[0], &oldButtons[0], 971 nOldButtons * sizeof(TBUTTON_INFO)); 971 972 COMCTL32_Free (oldButtons); 972 973 } … … 976 977 /* insert new button data */ 977 978 for (nCount = 0; nCount < nAddButtons; nCount++) { 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 979 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount]; 980 btnPtr->iBitmap = lpTbb[nCount].iBitmap; 981 btnPtr->idCommand = lpTbb[nCount].idCommand; 982 btnPtr->fsState = lpTbb[nCount].fsState; 983 btnPtr->fsStyle = lpTbb[nCount].fsStyle; 984 btnPtr->dwData = lpTbb[nCount].dwData; 985 btnPtr->iString = lpTbb[nCount].iString; 986 btnPtr->bHot = FALSE; 987 988 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) { 989 TTTOOLINFOA ti; 990 991 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 992 ti.cbSize = sizeof (TTTOOLINFOA); 993 ti.hwnd = hwnd; 994 ti.uId = btnPtr->idCommand; 995 ti.hinst = 0; 996 ti.lpszText = LPSTR_TEXTCALLBACKA; 997 998 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA, 999 0, (LPARAM)&ti); 1000 } 1000 1001 } 1001 1002 … … 1018 1019 1019 1020 if ((wParam) && (HIWORD(lParam) == 0)) { 1020 1021 1022 // 1023 1024 1025 1026 1027 // 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1021 char szString[256]; 1022 INT len; 1023 // TRACE (toolbar, "adding string from resource!\n"); 1024 1025 len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam, 1026 szString, 256); 1027 1028 // TRACE (toolbar, "len=%d \"%s\"\n", len, szString); 1029 nIndex = infoPtr->nNumStrings; 1030 if (infoPtr->nNumStrings == 0) { 1031 infoPtr->strings = 1032 COMCTL32_Alloc (sizeof(LPWSTR)); 1033 } 1034 else { 1035 LPWSTR *oldStrings = infoPtr->strings; 1036 infoPtr->strings = 1037 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1)); 1038 memcpy (&infoPtr->strings[0], &oldStrings[0], 1039 sizeof(LPWSTR) * infoPtr->nNumStrings); 1040 COMCTL32_Free (oldStrings); 1041 } 1042 1043 infoPtr->strings[infoPtr->nNumStrings] = 1044 COMCTL32_Alloc (sizeof(WCHAR)*(len+1)); 1045 lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], szString); 1046 infoPtr->nNumStrings++; 1046 1047 } 1047 1048 else { 1048 1049 1050 1051 1052 1053 // 1054 1055 1056 1057 // 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1049 LPSTR p = (LPSTR)lParam; 1050 INT len; 1051 1052 if (p == NULL) 1053 return -1; 1054 // TRACE (toolbar, "adding string(s) from array!\n"); 1055 nIndex = infoPtr->nNumStrings; 1056 while (*p) { 1057 len = lstrlenA (p); 1058 // TRACE (toolbar, "len=%d \"%s\"\n", len, p); 1059 1060 if (infoPtr->nNumStrings == 0) { 1061 infoPtr->strings = 1062 COMCTL32_Alloc (sizeof(LPWSTR)); 1063 } 1064 else { 1065 LPWSTR *oldStrings = infoPtr->strings; 1066 infoPtr->strings = 1067 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1)); 1068 memcpy (&infoPtr->strings[0], &oldStrings[0], 1069 sizeof(LPWSTR) * infoPtr->nNumStrings); 1070 COMCTL32_Free (oldStrings); 1071 } 1072 1073 infoPtr->strings[infoPtr->nNumStrings] = 1074 COMCTL32_Alloc (sizeof(WCHAR)*(len+1)); 1075 lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], p); 1076 infoPtr->nNumStrings++; 1077 1078 p += (len+1); 1079 } 1079 1080 } 1080 1081 … … 1090 1091 1091 1092 if ((wParam) && (HIWORD(lParam) == 0)) { 1092 1093 1094 // 1095 1096 1097 1098 1099 // 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1093 WCHAR szString[256]; 1094 INT len; 1095 // TRACE (toolbar, "adding string from resource!\n"); 1096 1097 len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam, 1098 szString, 256); 1099 1100 // TRACE (toolbar, "len=%d \"%s\"\n", len, debugstr_w(szString)); 1101 nIndex = infoPtr->nNumStrings; 1102 if (infoPtr->nNumStrings == 0) { 1103 infoPtr->strings = 1104 COMCTL32_Alloc (sizeof(LPWSTR)); 1105 } 1106 else { 1107 LPWSTR *oldStrings = infoPtr->strings; 1108 infoPtr->strings = 1109 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1)); 1110 memcpy (&infoPtr->strings[0], &oldStrings[0], 1111 sizeof(LPWSTR) * infoPtr->nNumStrings); 1112 COMCTL32_Free (oldStrings); 1113 } 1114 1115 infoPtr->strings[infoPtr->nNumStrings] = 1116 COMCTL32_Alloc (sizeof(WCHAR)*(len+1)); 1117 lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], szString); 1118 infoPtr->nNumStrings++; 1118 1119 } 1119 1120 else { 1120 1121 1122 1123 1124 1125 // 1126 1127 1128 1129 // 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1121 LPWSTR p = (LPWSTR)lParam; 1122 INT len; 1123 1124 if (p == NULL) 1125 return -1; 1126 // TRACE (toolbar, "adding string(s) from array!\n"); 1127 nIndex = infoPtr->nNumStrings; 1128 while (*p) { 1129 len = lstrlenW (p); 1130 // TRACE (toolbar, "len=%d \"%s\"\n", len, debugstr_w(p)); 1131 1132 if (infoPtr->nNumStrings == 0) { 1133 infoPtr->strings = 1134 COMCTL32_Alloc (sizeof(LPWSTR)); 1135 } 1136 else { 1137 LPWSTR *oldStrings = infoPtr->strings; 1138 infoPtr->strings = 1139 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1)); 1140 memcpy (&infoPtr->strings[0], &oldStrings[0], 1141 sizeof(LPWSTR) * infoPtr->nNumStrings); 1142 COMCTL32_Free (oldStrings); 1143 } 1144 1145 infoPtr->strings[infoPtr->nNumStrings] = 1146 COMCTL32_Alloc (sizeof(WCHAR)*(len+1)); 1147 lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], p); 1148 infoPtr->nNumStrings++; 1149 1150 p += (len+1); 1151 } 1151 1152 } 1152 1153 … … 1172 1173 1173 1174 if (dwStyle & CCS_NORESIZE) { 1174 1175 1176 1175 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE); 1176 cx = 0; 1177 cy = 0; 1177 1178 } 1178 1179 else { 1179 1180 1181 1182 1183 1180 infoPtr->nWidth = parent_rect.right - parent_rect.left; 1181 TOOLBAR_CalcToolbar (hwnd); 1182 InvalidateRect( hwnd, NULL, TRUE ); 1183 cy = infoPtr->nHeight; 1184 cx = infoPtr->nWidth; 1184 1185 } 1185 1186 1186 1187 if (dwStyle & CCS_NOPARENTALIGN) 1187 1188 uPosFlags |= SWP_NOMOVE; 1188 1189 1189 1190 if (!(dwStyle & CCS_NODIVIDER)) 1190 1191 cy += GetSystemMetrics(SM_CYEDGE); 1191 1192 1192 1193 infoPtr->bAutoSize = TRUE; 1193 1194 SetWindowPos (hwnd, HWND_TOP, parent_rect.left, parent_rect.top, 1194 1195 cx, cy, uPosFlags); 1195 1196 1196 1197 return 0; … … 1213 1214 1214 1215 if (infoPtr == NULL) { 1215 // 1216 // 1217 1216 // ERR (toolbar, "(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam); 1217 // ERR (toolbar, "infoPtr == NULL!\n"); 1218 return 0; 1218 1219 } 1219 1220 … … 1234 1235 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1235 1236 if (nIndex == -1) 1236 1237 return FALSE; 1237 1238 1238 1239 btnPtr = &infoPtr->buttons[nIndex]; … … 1258 1259 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1259 1260 if (nIndex == -1) 1260 1261 return FALSE; 1261 1262 1262 1263 btnPtr = &infoPtr->buttons[nIndex]; 1263 1264 1264 1265 if (!(btnPtr->fsStyle & TBSTYLE_CHECK)) 1265 1266 return FALSE; 1266 1267 1267 1268 if (LOWORD(lParam) == FALSE) 1268 1269 btnPtr->fsState &= ~TBSTATE_CHECKED; 1269 1270 else { 1270 1271 nOldIndex = 1272 1273 1274 1275 1276 1277 1278 1271 if (btnPtr->fsStyle & TBSTYLE_GROUP) { 1272 nOldIndex = 1273 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex); 1274 if (nOldIndex == nIndex) 1275 return 0; 1276 if (nOldIndex != -1) 1277 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED; 1278 } 1279 btnPtr->fsState |= TBSTATE_CHECKED; 1279 1280 } 1280 1281 1281 1282 hdc = GetDC (hwnd); 1282 1283 if (nOldIndex != -1) 1283 1284 TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc); 1284 1285 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 1285 1286 ReleaseDC (hwnd, hdc); … … 1315 1316 1316 1317 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, 1317 1318 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); 1318 1319 1319 1320 if (!(hRes = FindResourceA (COMCTL32_hModule, 1320 1321 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE), 1321 1322 RT_DIALOGA))) 1322 1323 return FALSE; 1323 1324 1324 1325 if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes))) 1325 1326 return FALSE; 1326 1327 1327 1328 ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE), … … 1335 1336 1336 1337 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, 1337 1338 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); 1338 1339 1339 1340 return ret; … … 1348 1349 1349 1350 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 1350 1351 1352 if ((infoPtr->hwndToolTip) && 1353 1354 1355 1356 1357 1358 1359 1360 1361 1351 return FALSE; 1352 1353 if ((infoPtr->hwndToolTip) && 1354 !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) { 1355 TTTOOLINFOA ti; 1356 1357 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 1358 ti.cbSize = sizeof (TTTOOLINFOA); 1359 ti.hwnd = hwnd; 1360 ti.uId = infoPtr->buttons[nIndex].idCommand; 1361 1362 SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti); 1362 1363 } 1363 1364 1364 1365 if (infoPtr->nNumButtons == 1) { 1365 // 1366 1367 1368 1366 // TRACE (toolbar, " simple delete!\n"); 1367 COMCTL32_Free (infoPtr->buttons); 1368 infoPtr->buttons = NULL; 1369 infoPtr->nNumButtons = 0; 1369 1370 } 1370 1371 else { 1371 1372 TBUTTON_INFO *oldButtons = infoPtr->buttons; 1372 1373 // TRACE(toolbar, "complex delete! [nIndex=%d]\n", nIndex); 1373 1374 1374 1375 1375 infoPtr->nNumButtons--; 1376 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons); 1376 1377 if (nIndex > 0) { 1377 1378 memcpy (&infoPtr->buttons[0], &oldButtons[0], … … 1384 1385 } 1385 1386 1386 1387 COMCTL32_Free (oldButtons); 1387 1388 } 1388 1389 … … 1405 1406 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1406 1407 if (nIndex == -1) 1407 1408 return FALSE; 1408 1409 1409 1410 btnPtr = &infoPtr->buttons[nIndex]; 1410 1411 if (LOWORD(lParam) == FALSE) 1411 1412 btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED); 1412 1413 else 1413 1414 btnPtr->fsState |= TBSTATE_ENABLED; 1414 1415 1415 1416 hdc = GetDC (hwnd); … … 1432 1433 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1433 1434 if (nIndex == -1) 1434 1435 return -1; 1435 1436 1436 1437 return infoPtr->buttons[nIndex].iBitmap; … … 1454 1455 1455 1456 if (infoPtr == NULL) 1456 1457 return FALSE; 1457 1458 1458 1459 if (lpTbb == NULL) 1459 1460 return FALSE; 1460 1461 1461 1462 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 1462 1463 return FALSE; 1463 1464 1464 1465 btnPtr = &infoPtr->buttons[nIndex]; … … 1483 1484 1484 1485 if (infoPtr == NULL) 1485 1486 return -1; 1486 1487 if (lpTbInfo == NULL) 1487 1488 return -1; 1488 1489 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA)) 1489 1490 return -1; 1490 1491 1491 1492 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1492 1493 if (nIndex == -1) 1493 1494 return -1; 1494 1495 1495 1496 btnPtr = &infoPtr->buttons[nIndex]; 1496 1497 1497 1498 if (lpTbInfo->dwMask & TBIF_COMMAND) 1498 1499 lpTbInfo->idCommand = btnPtr->idCommand; 1499 1500 if (lpTbInfo->dwMask & TBIF_IMAGE) 1500 1501 lpTbInfo->iImage = btnPtr->iBitmap; 1501 1502 if (lpTbInfo->dwMask & TBIF_LPARAM) 1502 1503 lpTbInfo->lParam = btnPtr->dwData; 1503 1504 if (lpTbInfo->dwMask & TBIF_SIZE) 1504 1505 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left); 1505 1506 if (lpTbInfo->dwMask & TBIF_STATE) 1506 1507 lpTbInfo->fsState = btnPtr->fsState; 1507 1508 if (lpTbInfo->dwMask & TBIF_STYLE) 1508 1509 lpTbInfo->fsStyle = btnPtr->fsStyle; 1509 1510 if (lpTbInfo->dwMask & TBIF_TEXT) { 1510 1511 lstrcpynA (lpTbInfo->pszText, 1512 1513 1511 if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings)) 1512 lstrcpynA (lpTbInfo->pszText, 1513 (LPSTR)infoPtr->strings[btnPtr->iString], 1514 lpTbInfo->cchText); 1514 1515 } 1515 1516 … … 1527 1528 1528 1529 return MAKELONG((WORD)infoPtr->nButtonWidth, 1529 1530 (WORD)infoPtr->nButtonHeight); 1530 1531 } 1531 1532 … … 1539 1540 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1540 1541 if (nIndex == -1) 1541 1542 return -1; 1542 1543 1543 1544 nStringIndex = infoPtr->buttons[nIndex].iString; … … 1546 1547 1547 1548 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings)) 1548 1549 return -1; 1549 1550 1550 1551 if (lParam == 0) return -1; … … 1566 1567 1567 1568 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT) 1568 1569 return (LRESULT)infoPtr->himlDis; 1569 1570 else 1570 1571 return 0; 1571 1572 } 1572 1573 … … 1587 1588 1588 1589 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT) 1589 1590 return (LRESULT)infoPtr->himlHot; 1590 1591 else 1591 1592 return 0; 1592 1593 } 1593 1594 … … 1602 1603 1603 1604 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT) 1604 1605 return (LRESULT)infoPtr->himlDef; 1605 1606 else 1606 1607 return 0; 1607 1608 } 1608 1609 … … 1621 1622 1622 1623 if (infoPtr == NULL) 1623 1624 return FALSE; 1624 1625 nIndex = (INT)wParam; 1625 1626 btnPtr = &infoPtr->buttons[nIndex]; 1626 1627 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 1627 1628 return FALSE; 1628 1629 lpRect = (LPRECT)lParam; 1629 1630 if (lpRect == NULL) 1630 1631 return FALSE; 1631 1632 if (btnPtr->fsState & TBSTATE_HIDDEN) 1632 1633 1633 return FALSE; 1634 1634 1635 TOOLBAR_CalcToolbar( hwnd ); 1635 1636 1636 1637 lpRect->left = btnPtr->rect.left; 1637 1638 lpRect->right = btnPtr->rect.right; … … 1650 1651 1651 1652 if (lpSize == NULL) 1652 1653 return FALSE; 1653 1654 1654 1655 lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left; … … 1656 1657 1657 1658 // TRACE (toolbar, "maximum size %d x %d\n", 1658 // 1659 // 1659 // infoPtr->rcBound.right - infoPtr->rcBound.left, 1660 // infoPtr->rcBound.bottom - infoPtr->rcBound.top); 1660 1661 1661 1662 return TRUE; … … 1676 1677 1677 1678 if (infoPtr == NULL) 1678 1679 return FALSE; 1679 1680 nIndex = (INT)wParam; 1680 1681 btnPtr = &infoPtr->buttons[nIndex]; 1681 1682 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 1682 1683 return FALSE; 1683 1684 lpRect = (LPRECT)lParam; 1684 1685 if (lpRect == NULL) 1685 1686 1686 return FALSE; 1687 1687 1688 lpRect->left = btnPtr->rect.left; 1688 1689 lpRect->right = btnPtr->rect.right; … … 1700 1701 1701 1702 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE) 1702 1703 return infoPtr->nRows; 1703 1704 else 1704 1705 return 1; 1705 1706 } 1706 1707 … … 1714 1715 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1715 1716 if (nIndex == -1) 1716 1717 return -1; 1717 1718 1718 1719 return infoPtr->buttons[nIndex].fsState; … … 1728 1729 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1729 1730 if (nIndex == -1) 1730 1731 return -1; 1731 1732 1732 1733 return infoPtr->buttons[nIndex].fsStyle; … … 1740 1741 1741 1742 if (infoPtr == NULL) 1742 1743 return 0; 1743 1744 1744 1745 return infoPtr->nMaxTextRows; … … 1752 1753 1753 1754 if (infoPtr == NULL) 1754 1755 return 0; 1755 1756 return infoPtr->hwndToolTip; 1756 1757 } … … 1762 1763 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 1763 1764 1764 // TRACE (toolbar, "%s hwnd=0x%x stub!\n", 1765 // 1765 // TRACE (toolbar, "%s hwnd=0x%x stub!\n", 1766 // infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd); 1766 1767 1767 1768 return infoPtr->bUnicode; … … 1778 1779 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1779 1780 if (nIndex == -1) 1780 1781 return FALSE; 1781 1782 1782 1783 btnPtr = &infoPtr->buttons[nIndex]; 1783 1784 if (LOWORD(lParam) == FALSE) 1784 1785 btnPtr->fsState &= ~TBSTATE_HIDDEN; 1785 1786 else 1786 1787 btnPtr->fsState |= TBSTATE_HIDDEN; 1787 1788 1788 1789 TOOLBAR_CalcToolbar (hwnd); … … 1811 1812 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1812 1813 if (nIndex == -1) 1813 1814 return FALSE; 1814 1815 1815 1816 btnPtr = &infoPtr->buttons[nIndex]; 1816 1817 if (LOWORD(lParam) == FALSE) 1817 1818 btnPtr->fsState &= ~TBSTATE_INDETERMINATE; 1818 1819 else 1819 1820 btnPtr->fsState |= TBSTATE_INDETERMINATE; 1820 1821 1821 1822 hdc = GetDC (hwnd); … … 1836 1837 1837 1838 if (lpTbb == NULL) 1838 1839 return FALSE; 1839 1840 if (nIndex < 0) 1840 1841 return FALSE; 1841 1842 1842 1843 // TRACE (toolbar, "inserting button index=%d\n", nIndex); 1843 1844 if (nIndex > infoPtr->nNumButtons) { 1844 1845 // 1845 nIndex = infoPtr->nNumButtons; 1846 // TRACE (toolbar, "adjust index=%d\n", nIndex); 1846 1847 } 1847 1848 … … 1851 1852 /* pre insert copy */ 1852 1853 if (nIndex > 0) { 1853 1854 1854 memcpy (&infoPtr->buttons[0], &oldButtons[0], 1855 nIndex * sizeof(TBUTTON_INFO)); 1855 1856 } 1856 1857 … … 1864 1865 1865 1866 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) { 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1867 TTTOOLINFOA ti; 1868 1869 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 1870 ti.cbSize = sizeof (TTTOOLINFOA); 1871 ti.hwnd = hwnd; 1872 ti.uId = lpTbb->idCommand; 1873 ti.hinst = 0; 1874 ti.lpszText = LPSTR_TEXTCALLBACKA; 1875 1876 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA, 1877 0, (LPARAM)&ti); 1877 1878 } 1878 1879 1879 1880 /* post insert copy */ 1880 1881 if (nIndex < infoPtr->nNumButtons - 1) { 1881 1882 1882 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex], 1883 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO)); 1883 1884 } 1884 1885 … … 1905 1906 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1906 1907 if (nIndex == -1) 1907 1908 return FALSE; 1908 1909 1909 1910 return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED); … … 1919 1920 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1920 1921 if (nIndex == -1) 1921 1922 return FALSE; 1922 1923 1923 1924 return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED); … … 1933 1934 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1934 1935 if (nIndex == -1) 1935 1936 return FALSE; 1936 1937 1937 1938 return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN); … … 1947 1948 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1948 1949 if (nIndex == -1) 1949 1950 return FALSE; 1950 1951 1951 1952 return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED); … … 1961 1962 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1962 1963 if (nIndex == -1) 1963 1964 return FALSE; 1964 1965 1965 1966 return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE); … … 1975 1976 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1976 1977 if (nIndex == -1) 1977 1978 return FALSE; 1978 1979 1979 1980 return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED); … … 1997 1998 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 1998 1999 if (nIndex == -1) 1999 2000 return FALSE; 2000 2001 2001 2002 btnPtr = &infoPtr->buttons[nIndex]; 2002 2003 if (LOWORD(lParam) == FALSE) 2003 2004 btnPtr->fsState &= ~TBSTATE_PRESSED; 2004 2005 else 2005 2006 btnPtr->fsState |= TBSTATE_PRESSED; 2006 2007 2007 2008 hdc = GetDC (hwnd); … … 2026 2027 2027 2028 if ((BOOL)wParam) { 2028 2029 // 2030 // 2029 /* save toolbar information */ 2030 // FIXME (toolbar, "save to \"%s\" \"%s\"\n", 2031 // lpSave->pszSubKey, lpSave->pszValueName); 2031 2032 2032 2033 2033 2034 } 2034 2035 else { 2035 2036 2037 // 2038 // 2036 /* restore toolbar information */ 2037 2038 // FIXME (toolbar, "restore from \"%s\" \"%s\"\n", 2039 // lpSave->pszSubKey, lpSave->pszValueName); 2039 2040 2040 2041 … … 2056 2057 2057 2058 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0)) 2058 2059 return FALSE; 2059 2060 2060 2061 infoPtr->nBitmapWidth = (INT)LOWORD(lParam); … … 2074 2075 2075 2076 if (lptbbi == NULL) 2076 2077 return FALSE; 2077 2078 if (lptbbi->cbSize < sizeof(TBBUTTONINFOA)) 2078 2079 2079 return FALSE; 2080 2080 2081 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2081 2082 if (nIndex == -1) 2082 2083 return FALSE; 2083 2084 2084 2085 btnPtr = &infoPtr->buttons[nIndex]; 2085 2086 if (lptbbi->dwMask & TBIF_COMMAND) 2086 2087 btnPtr->idCommand = lptbbi->idCommand; 2087 2088 if (lptbbi->dwMask & TBIF_IMAGE) 2088 2089 btnPtr->iBitmap = lptbbi->iImage; 2089 2090 if (lptbbi->dwMask & TBIF_LPARAM) 2090 2091 btnPtr->dwData = lptbbi->lParam; 2091 2092 /* if (lptbbi->dwMask & TBIF_SIZE) */ 2092 /* 2093 /* btnPtr->cx = lptbbi->cx; */ 2093 2094 if (lptbbi->dwMask & TBIF_STATE) 2094 2095 btnPtr->fsState = lptbbi->fsState; 2095 2096 if (lptbbi->dwMask & TBIF_STYLE) 2096 2097 btnPtr->fsStyle = lptbbi->fsStyle; 2097 2098 2098 2099 if (lptbbi->dwMask & TBIF_TEXT) { 2099 if ((btnPtr->iString >= 0) || 2100 2100 if ((btnPtr->iString >= 0) || 2101 (btnPtr->iString < infoPtr->nNumStrings)) { 2101 2102 #if 0 2102 2103 2104 2103 CHAR **lpString = &infoPtr->strings[btnPtr->iString]; 2104 INT len = lstrlenA (lptbbi->pszText); 2105 *lpString = COMCTL32_ReAlloc (lpString, sizeof(char)*(len+1)); 2105 2106 #endif 2106 2107 2107 2108 /* 2109 2108 /* this is the ultimate sollution */ 2109 /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */ 2110 } 2110 2111 } 2111 2112 … … 2123 2124 2124 2125 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0)) 2125 2126 return FALSE; 2126 2127 2127 2128 infoPtr->nButtonWidth = (INT)LOWORD(lParam); … … 2138 2139 2139 2140 if (infoPtr == NULL) 2140 2141 return FALSE; 2141 2142 2142 2143 infoPtr->cxMin = (INT)LOWORD(lParam); … … 2154 2155 2155 2156 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 2156 2157 return FALSE; 2157 2158 2158 2159 infoPtr->buttons[nIndex].idCommand = (INT)lParam; … … 2160 2161 if (infoPtr->hwndToolTip) { 2161 2162 2162 // 2163 // FIXME (toolbar, "change tool tip!\n"); 2163 2164 2164 2165 } … … 2178 2179 2179 2180 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)) 2180 2181 return 0; 2181 2182 2182 2183 himlTemp = infoPtr->himlDis; … … 2185 2186 /* FIXME: redraw ? */ 2186 2187 2187 return (LRESULT)himlTemp; 2188 return (LRESULT)himlTemp; 2188 2189 } 2189 2190 … … 2197 2198 dwTemp = infoPtr->dwDTFlags; 2198 2199 infoPtr->dwDTFlags = 2199 2200 (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam; 2200 2201 2201 2202 return (LRESULT)dwTemp; … … 2212 2213 infoPtr->dwExStyle = (DWORD)lParam; 2213 2214 2214 return (LRESULT)dwTemp; 2215 return (LRESULT)dwTemp; 2215 2216 } 2216 2217 … … 2223 2224 2224 2225 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)) 2225 2226 return 0; 2226 2227 2227 2228 himlTemp = infoPtr->himlHot; … … 2230 2231 /* FIXME: redraw ? */ 2231 2232 2232 return (LRESULT)himlTemp; 2233 return (LRESULT)himlTemp; 2233 2234 } 2234 2235 … … 2244 2245 2245 2246 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)) 2246 2247 return 0; 2247 2248 2248 2249 himlTemp = infoPtr->himlDef; … … 2251 2252 /* FIXME: redraw ? */ 2252 2253 2253 return (LRESULT)himlTemp; 2254 return (LRESULT)himlTemp; 2254 2255 } 2255 2256 … … 2292 2293 2293 2294 if (infoPtr == NULL) 2294 2295 return FALSE; 2295 2296 2296 2297 infoPtr->nMaxTextRows = (INT)wParam; … … 2310 2311 2311 2312 if (infoPtr == NULL) 2312 2313 return 0; 2313 2314 hwndOldNotify = infoPtr->hwndNotify; 2314 2315 infoPtr->hwndNotify = (HWND)wParam; … … 2326 2327 if (LOWORD(wParam) > 1) { 2327 2328 2328 // 2329 // FIXME (toolbar, "multiple rows not supported!\n"); 2329 2330 2330 2331 } … … 2335 2336 /* return bounding rectangle */ 2336 2337 if (lprc) { 2337 2338 2339 2340 2338 lprc->left = infoPtr->rcBound.left; 2339 lprc->right = infoPtr->rcBound.right; 2340 lprc->top = infoPtr->rcBound.top; 2341 lprc->bottom = infoPtr->rcBound.bottom; 2341 2342 } 2342 2343 … … 2358 2359 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2359 2360 if (nIndex == -1) 2360 2361 return FALSE; 2361 2362 2362 2363 btnPtr = &infoPtr->buttons[nIndex]; … … 2381 2382 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2382 2383 if (nIndex == -1) 2383 2384 return FALSE; 2384 2385 2385 2386 btnPtr = &infoPtr->buttons[nIndex]; … … 2392 2393 if (infoPtr->hwndToolTip) { 2393 2394 2394 // 2395 // FIXME (toolbar, "change tool tip!\n"); 2395 2396 2396 2397 } … … 2406 2407 2407 2408 if (infoPtr == NULL) 2408 2409 return 0; 2409 2410 infoPtr->hwndToolTip = (HWND)wParam; 2410 2411 return 0; … … 2418 2419 BOOL bTemp; 2419 2420 2420 // TRACE (toolbar, "%s hwnd=0x%04x stub!\n", 2421 // 2421 // TRACE (toolbar, "%s hwnd=0x%04x stub!\n", 2422 // ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd); 2422 2423 2423 2424 bTemp = infoPtr->bUnicode; … … 2460 2461 2461 2462 if (dwStyle & TBSTYLE_TOOLTIPS) { 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2463 /* Create tooltip control */ 2464 infoPtr->hwndToolTip = 2465 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0, 2466 CW_USEDEFAULT, CW_USEDEFAULT, 2467 CW_USEDEFAULT, CW_USEDEFAULT, 2468 hwnd, 0, 0, 0); 2469 2470 /* Send NM_TOOLTIPSCREATED notification */ 2471 if (infoPtr->hwndToolTip) { 2472 NMTOOLTIPSCREATED nmttc; 2473 2474 nmttc.hdr.hwndFrom = hwnd; 2475 nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 2476 nmttc.hdr.code = NM_TOOLTIPSCREATED; 2477 nmttc.hwndToolTips = infoPtr->hwndToolTip; 2478 2479 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, 2480 (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc); 2481 } 2481 2482 } 2482 2483 … … 2492 2493 /* delete tooltip control */ 2493 2494 if (infoPtr->hwndToolTip) 2494 2495 DestroyWindow (infoPtr->hwndToolTip); 2495 2496 2496 2497 /* delete button data */ 2497 2498 if (infoPtr->buttons) 2498 2499 COMCTL32_Free (infoPtr->buttons); 2499 2500 2500 2501 /* delete strings */ 2501 2502 if (infoPtr->strings) { 2502 2503 2504 2505 2506 2507 2503 INT i; 2504 for (i = 0; i < infoPtr->nNumStrings; i++) 2505 if (infoPtr->strings[i]) 2506 COMCTL32_Free (infoPtr->strings[i]); 2507 2508 COMCTL32_Free (infoPtr->strings); 2508 2509 } 2509 2510 2510 2511 /* destroy default image list */ 2511 2512 if (infoPtr->himlDef) 2512 2513 ImageList_Destroy (infoPtr->himlDef); 2513 2514 2514 2515 /* destroy disabled image list */ 2515 2516 if (infoPtr->himlDis) 2516 2517 ImageList_Destroy (infoPtr->himlDis); 2517 2518 2518 2519 /* destroy hot image list */ 2519 2520 if (infoPtr->himlHot) 2520 2521 ImageList_Destroy (infoPtr->himlHot); 2521 2522 2522 2523 /* delete default font */ 2523 2524 if (infoPtr->hFont) 2524 2525 DeleteObject (infoPtr->hFont); 2525 2526 2526 2527 /* free toolbar info data */ … … 2537 2538 2538 2539 if (infoPtr->bTransparent) 2539 2540 return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam); 2540 2541 2541 2542 return DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam); … … 2557 2558 2558 2559 if (nHit >= 0) { 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2560 btnPtr = &infoPtr->buttons[nHit]; 2561 if (!(btnPtr->fsState & TBSTATE_ENABLED)) 2562 return 0; 2563 SetCapture (hwnd); 2564 infoPtr->bCaptured = TRUE; 2565 infoPtr->nButtonDown = nHit; 2566 2567 btnPtr->fsState |= TBSTATE_PRESSED; 2568 2569 hdc = GetDC (hwnd); 2570 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 2571 ReleaseDC (hwnd, hdc); 2571 2572 } 2572 2573 else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE) 2573 2574 TOOLBAR_Customize (hwnd); 2574 2575 2575 2576 return 0; … … 2587 2588 2588 2589 if (infoPtr->hwndToolTip) 2589 2590 2590 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd, 2591 WM_LBUTTONDOWN, wParam, lParam); 2591 2592 2592 2593 pt.x = (INT)LOWORD(lParam); … … 2595 2596 2596 2597 if (nHit >= 0) { 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2598 btnPtr = &infoPtr->buttons[nHit]; 2599 if (!(btnPtr->fsState & TBSTATE_ENABLED)) 2600 return 0; 2601 2602 SetCapture (hwnd); 2603 infoPtr->bCaptured = TRUE; 2604 infoPtr->nButtonDown = nHit; 2605 infoPtr->nOldHit = nHit; 2606 2607 btnPtr->fsState |= TBSTATE_PRESSED; 2608 2609 hdc = GetDC (hwnd); 2610 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 2611 ReleaseDC (hwnd, hdc); 2611 2612 } 2612 2613 … … 2627 2628 2628 2629 if (infoPtr->hwndToolTip) 2629 2630 2630 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd, 2631 WM_LBUTTONUP, wParam, lParam); 2631 2632 2632 2633 pt.x = (INT)LOWORD(lParam); … … 2635 2636 2636 2637 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) { 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 if ((nOldIndex != infoPtr->nButtonDown) && 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2638 infoPtr->bCaptured = FALSE; 2639 ReleaseCapture (); 2640 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown]; 2641 btnPtr->fsState &= ~TBSTATE_PRESSED; 2642 2643 if (nHit == infoPtr->nButtonDown) { 2644 if (btnPtr->fsStyle & TBSTYLE_CHECK) { 2645 if (btnPtr->fsStyle & TBSTYLE_GROUP) { 2646 nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, 2647 infoPtr->nButtonDown); 2648 if (nOldIndex == infoPtr->nButtonDown) 2649 bSendMessage = FALSE; 2650 if ((nOldIndex != infoPtr->nButtonDown) && 2651 (nOldIndex != -1)) 2652 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED; 2653 btnPtr->fsState |= TBSTATE_CHECKED; 2654 } 2655 else { 2656 if (btnPtr->fsState & TBSTATE_CHECKED) 2657 btnPtr->fsState &= ~TBSTATE_CHECKED; 2658 else 2659 btnPtr->fsState |= TBSTATE_CHECKED; 2660 } 2661 } 2662 } 2663 else 2664 bSendMessage = FALSE; 2665 2666 hdc = GetDC (hwnd); 2667 if (nOldIndex != -1) 2668 TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc); 2669 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 2670 ReleaseDC (hwnd, hdc); 2671 2672 if (bSendMessage) 2673 SendMessageA (infoPtr->hwndNotify, WM_COMMAND, 2674 MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd); 2675 2676 infoPtr->nButtonDown = -1; 2677 infoPtr->nOldHit = -1; 2677 2678 } 2678 2679 … … 2691 2692 2692 2693 if (infoPtr->hwndToolTip) 2693 2694 2694 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd, 2695 WM_MOUSEMOVE, wParam, lParam); 2695 2696 2696 2697 pt.x = (INT)LOWORD(lParam); … … 2702 2703 { 2703 2704 /* Remove the effect of an old hot button */ 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2705 if(infoPtr->nOldHit == infoPtr->nHotItem) 2706 { 2707 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit]; 2708 oldBtnPtr->bHot = FALSE; 2709 2710 InvalidateRect (hwnd, &oldBtnPtr->rect, TRUE); 2711 } 2712 2713 /* It's not a separator or in nowhere. It's a hot button. */ 2714 if (nHit >= 0) 2715 { 2716 btnPtr = &infoPtr->buttons[nHit]; 2717 btnPtr->bHot = TRUE; 2718 2719 hdc = GetDC (hwnd); 2720 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 2721 ReleaseDC (hwnd, hdc); 2722 2723 infoPtr->nHotItem = nHit; 2724 } 2724 2725 2725 2726 if (infoPtr->bCaptured) { 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2727 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown]; 2728 if (infoPtr->nOldHit == infoPtr->nButtonDown) { 2729 btnPtr->fsState &= ~TBSTATE_PRESSED; 2730 hdc = GetDC (hwnd); 2731 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 2732 ReleaseDC (hwnd, hdc); 2733 } 2734 else if (nHit == infoPtr->nButtonDown) { 2735 btnPtr->fsState |= TBSTATE_PRESSED; 2736 hdc = GetDC (hwnd); 2737 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 2738 ReleaseDC (hwnd, hdc); 2739 } 2740 } 2741 infoPtr->nOldHit = nHit; 2741 2742 } 2742 2743 return 0; … … 2748 2749 { 2749 2750 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */ 2750 2751 return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam); 2751 2752 /* else */ 2752 /* 2753 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */ 2753 2754 } 2754 2755 … … 2758 2759 { 2759 2760 if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER)) 2760 2761 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE); 2761 2762 2762 2763 return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam); … … 2779 2780 if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) { 2780 2781 HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE); 2781 2782 SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst); 2782 2783 } 2783 2784 … … 2794 2795 2795 2796 if (dwStyle & WS_MINIMIZE) 2796 2797 return 0; /* Nothing to do */ 2797 2798 2798 2799 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam); 2799 2800 2800 2801 if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW))) 2801 2802 return 0; 2802 2803 2803 2804 if (!(dwStyle & CCS_NODIVIDER)) 2804 2805 { 2805 2806 2807 2806 GetWindowRect (hwnd, &rcWindow); 2807 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top); 2808 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP); 2808 2809 } 2809 2810 … … 2823 2824 2824 2825 if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) { 2825 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,wParam, lParam);2826 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, wParam, lParam); 2826 2827 2827 2828 #if 0 2828 2829 2830 2831 // 2832 2833 2834 2835 2836 2837 // 2838 2839 2829 if (lpnmh->code == TTN_GETDISPINFOA) { 2830 LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam; 2831 2832 // FIXME (toolbar, "retrieving ASCII string\n"); 2833 2834 } 2835 else if (lpnmh->code == TTN_GETDISPINFOW) { 2836 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam; 2837 2838 // FIXME (toolbar, "retrieving UNICODE string\n"); 2839 2840 } 2840 2841 #endif 2841 2842 } … … 2855 2856 TOOLBAR_Refresh (hwnd, hdc); 2856 2857 if (!wParam) 2857 2858 EndPaint (hwnd, &ps); 2858 2859 return 0; 2859 2860 } … … 2874 2875 /* Resize deadlock check */ 2875 2876 if (infoPtr->bAutoSize) { 2876 2877 2877 infoPtr->bAutoSize = FALSE; 2878 return 0; 2878 2879 } 2879 2880 … … 2887 2888 2888 2889 if (flags == SIZE_RESTORED) { 2889 2890 2891 2892 2893 2894 2895 2896 2897 /* 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2890 /* width and height don't apply */ 2891 parent = GetParent (hwnd); 2892 GetClientRect(parent, &parent_rect); 2893 2894 if (dwStyle & CCS_NORESIZE) { 2895 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE); 2896 2897 /* FIXME */ 2898 /* infoPtr->nWidth = parent_rect.right - parent_rect.left; */ 2899 cy = infoPtr->nHeight; 2900 cx = infoPtr->nWidth; 2901 TOOLBAR_CalcToolbar (hwnd); 2902 infoPtr->nWidth = cx; 2903 infoPtr->nHeight = cy; 2904 } 2905 else { 2906 infoPtr->nWidth = parent_rect.right - parent_rect.left; 2907 TOOLBAR_CalcToolbar (hwnd); 2908 cy = infoPtr->nHeight; 2909 cx = infoPtr->nWidth; 2910 } 2911 2912 if (dwStyle & CCS_NOPARENTALIGN) { 2913 uPosFlags |= SWP_NOMOVE; 2914 cy = infoPtr->nHeight; 2915 cx = infoPtr->nWidth; 2916 } 2917 2918 if (!(dwStyle & CCS_NODIVIDER)) 2919 cy += GetSystemMetrics(SM_CYEDGE); 2920 2921 SetWindowPos (hwnd, 0, parent_rect.left, parent_rect.top, 2922 cx, cy, uPosFlags | SWP_NOZORDER); 2922 2923 } 2923 2924 return 0; … … 2942 2943 switch (uMsg) 2943 2944 { 2944 2945 2946 2947 2948 2949 2950 /* 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 /* case TB_GETANCHORHIGHLIGHT:*/ /* 4.71 */2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 /* case TB_GETBUTTONINFOW:*/ /* 4.71 */3000 3001 3002 3003 3004 3005 3006 3007 /* 3008 /* case TB_GETCOLORSCHEME:*/ /* 4.71 */3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 /* case TB_GETHOTITEM:*/ /* 4.71 */3020 3021 3022 3023 3024 /* case TB_GETINSERTMARK:*/ /* 4.71 */3025 /* case TB_GETINSERTMARKCOLOR:*/ /* 4.71 */3026 3027 3028 3029 3030 3031 3032 3033 /* case TB_GETOBJECT:*/ /* 4.71 */3034 /* case TB_GETPADDING:*/ /* 4.71 */3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 /* 3070 /* case TB_INSERTMARKHITTEST:*/ /* 4.71 */3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 /* case TB_LOADIMAGES:*/ /* 4.70 */3091 /* case TB_MAPACCELERATORA:*/ /* 4.71 */3092 /* case TB_MAPACCELERATORW:*/ /* 4.71 */3093 /* case TB_MARKBUTTON:*/ /* 4.71 */3094 /* case TB_MOVEBUTTON:*/ /* 4.71 */3095 3096 3097 3098 3099 /* 3100 3101 3102 3103 3104 /* 3105 /* case TB_SETANCHORHIGHLIGHT:*/ /* 4.71 */3106 3107 3108 3109 3110 3111 3112 3113 /* case TB_SETBUTTONINFOW:*/ /* 4.71 */3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 /* case TB_SETCOLORSCHEME:*/ /* 4.71 */3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 /* case TB_SETHOTITEM:*/ /* 4.71 */3139 3140 3141 3142 3143 3144 3145 3146 /* case TB_SETINSERTMARK:*/ /* 4.71 */3147 3148 3149 3150 3151 3152 3153 3154 /* case TB_SETPADDING:*/ /* 4.71 */3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 /* 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 /* 3187 /* 3188 /* 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 /* 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 /* 3229 3230 /* 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 // 3242 // 3243 2945 case TB_ADDBITMAP: 2946 return TOOLBAR_AddBitmap (hwnd, wParam, lParam); 2947 2948 case TB_ADDBUTTONSA: 2949 return TOOLBAR_AddButtonsA (hwnd, wParam, lParam); 2950 2951 /* case TB_ADDBUTTONSW: */ 2952 2953 case TB_ADDSTRINGA: 2954 return TOOLBAR_AddStringA (hwnd, wParam, lParam); 2955 2956 case TB_ADDSTRINGW: 2957 return TOOLBAR_AddStringW (hwnd, wParam, lParam); 2958 2959 case TB_AUTOSIZE: 2960 return TOOLBAR_AutoSize (hwnd, wParam, lParam); 2961 2962 case TB_BUTTONCOUNT: 2963 return TOOLBAR_ButtonCount (hwnd, wParam, lParam); 2964 2965 case TB_BUTTONSTRUCTSIZE: 2966 return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam); 2967 2968 case TB_CHANGEBITMAP: 2969 return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam); 2970 2971 case TB_CHECKBUTTON: 2972 return TOOLBAR_CheckButton (hwnd, wParam, lParam); 2973 2974 case TB_COMMANDTOINDEX: 2975 return TOOLBAR_CommandToIndex (hwnd, wParam, lParam); 2976 2977 case TB_CUSTOMIZE: 2978 return TOOLBAR_Customize (hwnd); 2979 2980 case TB_DELETEBUTTON: 2981 return TOOLBAR_DeleteButton (hwnd, wParam, lParam); 2982 2983 case TB_ENABLEBUTTON: 2984 return TOOLBAR_EnableButton (hwnd, wParam, lParam); 2985 2986 /* case TB_GETANCHORHIGHLIGHT: */ /* 4.71 */ 2987 2988 case TB_GETBITMAP: 2989 return TOOLBAR_GetBitmap (hwnd, wParam, lParam); 2990 2991 case TB_GETBITMAPFLAGS: 2992 return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam); 2993 2994 case TB_GETBUTTON: 2995 return TOOLBAR_GetButton (hwnd, wParam, lParam); 2996 2997 case TB_GETBUTTONINFOA: 2998 return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam); 2999 3000 /* case TB_GETBUTTONINFOW: */ /* 4.71 */ 3001 3002 case TB_GETBUTTONSIZE: 3003 return TOOLBAR_GetButtonSize (hwnd); 3004 3005 case TB_GETBUTTONTEXTA: 3006 return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam); 3007 3008 /* case TB_GETBUTTONTEXTW: */ 3009 /* case TB_GETCOLORSCHEME: */ /* 4.71 */ 3010 3011 case TB_GETDISABLEDIMAGELIST: 3012 return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam); 3013 3014 case TB_GETEXTENDEDSTYLE: 3015 return TOOLBAR_GetExtendedStyle (hwnd); 3016 3017 case TB_GETHOTIMAGELIST: 3018 return TOOLBAR_GetHotImageList (hwnd, wParam, lParam); 3019 3020 /* case TB_GETHOTITEM: */ /* 4.71 */ 3021 3022 case TB_GETIMAGELIST: 3023 return TOOLBAR_GetImageList (hwnd, wParam, lParam); 3024 3025 /* case TB_GETINSERTMARK: */ /* 4.71 */ 3026 /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */ 3027 3028 case TB_GETITEMRECT: 3029 return TOOLBAR_GetItemRect (hwnd, wParam, lParam); 3030 3031 case TB_GETMAXSIZE: 3032 return TOOLBAR_GetMaxSize (hwnd, wParam, lParam); 3033 3034 /* case TB_GETOBJECT: */ /* 4.71 */ 3035 /* case TB_GETPADDING: */ /* 4.71 */ 3036 3037 case TB_GETRECT: 3038 return TOOLBAR_GetRect (hwnd, wParam, lParam); 3039 3040 case TB_GETROWS: 3041 return TOOLBAR_GetRows (hwnd, wParam, lParam); 3042 3043 case TB_GETSTATE: 3044 return TOOLBAR_GetState (hwnd, wParam, lParam); 3045 3046 case TB_GETSTYLE: 3047 return TOOLBAR_GetStyle (hwnd, wParam, lParam); 3048 3049 case TB_GETTEXTROWS: 3050 return TOOLBAR_GetTextRows (hwnd, wParam, lParam); 3051 3052 case TB_GETTOOLTIPS: 3053 return TOOLBAR_GetToolTips (hwnd, wParam, lParam); 3054 3055 case TB_GETUNICODEFORMAT: 3056 return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam); 3057 3058 case TB_HIDEBUTTON: 3059 return TOOLBAR_HideButton (hwnd, wParam, lParam); 3060 3061 case TB_HITTEST: 3062 return TOOLBAR_HitTest (hwnd, wParam, lParam); 3063 3064 case TB_INDETERMINATE: 3065 return TOOLBAR_Indeterminate (hwnd, wParam, lParam); 3066 3067 case TB_INSERTBUTTONA: 3068 return TOOLBAR_InsertButtonA (hwnd, wParam, lParam); 3069 3070 /* case TB_INSERTBUTTONW: */ 3071 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */ 3072 3073 case TB_ISBUTTONCHECKED: 3074 return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam); 3075 3076 case TB_ISBUTTONENABLED: 3077 return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam); 3078 3079 case TB_ISBUTTONHIDDEN: 3080 return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam); 3081 3082 case TB_ISBUTTONHIGHLIGHTED: 3083 return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam); 3084 3085 case TB_ISBUTTONINDETERMINATE: 3086 return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam); 3087 3088 case TB_ISBUTTONPRESSED: 3089 return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam); 3090 3091 /* case TB_LOADIMAGES: */ /* 4.70 */ 3092 /* case TB_MAPACCELERATORA: */ /* 4.71 */ 3093 /* case TB_MAPACCELERATORW: */ /* 4.71 */ 3094 /* case TB_MARKBUTTON: */ /* 4.71 */ 3095 /* case TB_MOVEBUTTON: */ /* 4.71 */ 3096 3097 case TB_PRESSBUTTON: 3098 return TOOLBAR_PressButton (hwnd, wParam, lParam); 3099 3100 /* case TB_REPLACEBITMAP: */ 3101 3102 case TB_SAVERESTOREA: 3103 return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam); 3104 3105 /* case TB_SAVERESTOREW: */ 3106 /* case TB_SETANCHORHIGHLIGHT: */ /* 4.71 */ 3107 3108 case TB_SETBITMAPSIZE: 3109 return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam); 3110 3111 case TB_SETBUTTONINFOA: 3112 return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam); 3113 3114 /* case TB_SETBUTTONINFOW: */ /* 4.71 */ 3115 3116 case TB_SETBUTTONSIZE: 3117 return TOOLBAR_SetButtonSize (hwnd, wParam, lParam); 3118 3119 case TB_SETBUTTONWIDTH: 3120 return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam); 3121 3122 case TB_SETCMDID: 3123 return TOOLBAR_SetCmdId (hwnd, wParam, lParam); 3124 3125 /* case TB_SETCOLORSCHEME: */ /* 4.71 */ 3126 3127 case TB_SETDISABLEDIMAGELIST: 3128 return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam); 3129 3130 case TB_SETDRAWTEXTFLAGS: 3131 return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam); 3132 3133 case TB_SETEXTENDEDSTYLE: 3134 return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam); 3135 3136 case TB_SETHOTIMAGELIST: 3137 return TOOLBAR_SetHotImageList (hwnd, wParam, lParam); 3138 3139 /* case TB_SETHOTITEM: */ /* 4.71 */ 3140 3141 case TB_SETIMAGELIST: 3142 return TOOLBAR_SetImageList (hwnd, wParam, lParam); 3143 3144 case TB_SETINDENT: 3145 return TOOLBAR_SetIndent (hwnd, wParam, lParam); 3146 3147 /* case TB_SETINSERTMARK: */ /* 4.71 */ 3148 3149 case TB_SETINSERTMARKCOLOR: 3150 return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam); 3151 3152 case TB_SETMAXTEXTROWS: 3153 return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam); 3154 3155 /* case TB_SETPADDING: */ /* 4.71 */ 3156 3157 case TB_SETPARENT: 3158 return TOOLBAR_SetParent (hwnd, wParam, lParam); 3159 3160 case TB_SETROWS: 3161 return TOOLBAR_SetRows (hwnd, wParam, lParam); 3162 3163 case TB_SETSTATE: 3164 return TOOLBAR_SetState (hwnd, wParam, lParam); 3165 3166 case TB_SETSTYLE: 3167 return TOOLBAR_SetStyle (hwnd, wParam, lParam); 3168 3169 case TB_SETTOOLTIPS: 3170 return TOOLBAR_SetToolTips (hwnd, wParam, lParam); 3171 3172 case TB_SETUNICODEFORMAT: 3173 return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam); 3174 3175 3176 /* case WM_CHAR: */ 3177 3178 case WM_CREATE: 3179 return TOOLBAR_Create (hwnd, wParam, lParam); 3180 3181 case WM_DESTROY: 3182 return TOOLBAR_Destroy (hwnd, wParam, lParam); 3183 3184 case WM_ERASEBKGND: 3185 return TOOLBAR_EraseBackground (hwnd, wParam, lParam); 3186 3187 /* case WM_GETFONT: */ 3188 /* case WM_KEYDOWN: */ 3189 /* case WM_KILLFOCUS: */ 3190 3191 case WM_LBUTTONDBLCLK: 3192 return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam); 3193 3194 case WM_LBUTTONDOWN: 3195 return TOOLBAR_LButtonDown (hwnd, wParam, lParam); 3196 3197 case WM_LBUTTONUP: 3198 return TOOLBAR_LButtonUp (hwnd, wParam, lParam); 3199 3200 case WM_MOUSEMOVE: 3201 return TOOLBAR_MouseMove (hwnd, wParam, lParam); 3202 3203 case WM_NCACTIVATE: 3204 return TOOLBAR_NCActivate (hwnd, wParam, lParam); 3205 3206 case WM_NCCALCSIZE: 3207 return TOOLBAR_NCCalcSize (hwnd, wParam, lParam); 3208 3209 case WM_NCCREATE: 3210 return TOOLBAR_NCCreate (hwnd, wParam, lParam); 3211 3212 case WM_NCPAINT: 3213 return TOOLBAR_NCPaint (hwnd, wParam, lParam); 3214 3215 case WM_NOTIFY: 3216 return TOOLBAR_Notify (hwnd, wParam, lParam); 3217 3218 /* case WM_NOTIFYFORMAT: */ 3219 3220 case WM_PAINT: 3221 return TOOLBAR_Paint (hwnd, wParam); 3222 3223 case WM_SIZE: 3224 return TOOLBAR_Size (hwnd, wParam, lParam); 3225 3226 case WM_STYLECHANGED: 3227 return TOOLBAR_StyleChanged (hwnd, wParam, lParam); 3228 3229 /* case WM_SYSCOLORCHANGE: */ 3230 3231 /* case WM_WININICHANGE: */ 3232 3233 case WM_CHARTOITEM: 3234 case WM_COMMAND: 3235 case WM_DRAWITEM: 3236 case WM_MEASUREITEM: 3237 case WM_VKEYTOITEM: 3238 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam); 3239 3240 default: 3241 // if (uMsg >= WM_USER) 3242 // ERR (toolbar, "unknown msg %04x wp=%08x lp=%08lx\n", 3243 // uMsg, wParam, lParam); 3244 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 3244 3245 } 3245 3246 return 0; … … 3262 3263 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); 3263 3264 wndClass.lpszClassName = TOOLBARCLASSNAMEA; 3264 3265 3265 3266 RegisterClassA (&wndClass); 3266 3267 } … … 3271 3272 { 3272 3273 if (GlobalFindAtomA (TOOLBARCLASSNAMEA)) 3273 3274 } 3275 3274 UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL); 3275 } 3276 -
trunk/src/comctl32/tooltips.c
r94 r110 1 /* $Id: tooltips.c,v 1. 4 1999-06-10 16:22:02 achimhaExp $ */1 /* $Id: tooltips.c,v 1.5 1999-06-16 20:25:44 cbratschi Exp $ */ 2 2 /* 3 3 * Tool tip control … … 5 5 * Copyright 1998 Eric Kohl 6 6 * Copyright 1999 Achim Hasenmueller 7 * Copyright 1999 Christoph Bratschi 7 8 * 8 9 * TODO: … … 53 54 54 55 if (infoPtr->nMaxTipWidth > -1) 55 56 uFlags |= DT_WORDBREAK; 56 57 if (GetWindowLongA (hwnd, GWL_STYLE) & TTS_NOPREFIX) 57 58 uFlags |= DT_NOPREFIX; 58 59 GetClientRect (hwnd, &rc); 59 60 … … 76 77 SelectObject (hdc, hOldFont); 77 78 if (oldBkMode != TRANSPARENT) 78 79 SetBkMode (hdc, oldBkMode); 79 80 } 80 81 … … 86 87 87 88 if ((toolPtr->hinst) && (HIWORD((UINT)toolPtr->lpszText) == 0)) { 88 89 // 90 // 91 92 89 /* load a resource */ 90 // TRACE (tooltips, "load res string %x %x\n", 91 // toolPtr->hinst, (int)toolPtr->lpszText); 92 LoadStringW (toolPtr->hinst, (UINT)toolPtr->lpszText, 93 infoPtr->szTipText, INFOTIPSIZE); 93 94 } 94 95 else if (toolPtr->lpszText) { 95 96 97 98 99 100 101 102 103 104 105 106 107 // 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 toolPtr->lpszText =COMCTL32_Alloc ((len+1)* sizeof(WCHAR));125 126 127 128 129 130 131 132 133 134 135 136 137 toolPtr->lpszText =COMCTL32_Alloc ((len+1)*sizeof(WCHAR));138 139 140 141 142 // 143 144 145 146 147 148 // 149 150 96 if (toolPtr->lpszText == LPSTR_TEXTCALLBACKW) { 97 NMTTDISPINFOA ttnmdi; 98 99 /* fill NMHDR struct */ 100 ZeroMemory (&ttnmdi, sizeof(NMTTDISPINFOA)); 101 ttnmdi.hdr.hwndFrom = hwnd; 102 ttnmdi.hdr.idFrom = toolPtr->uId; 103 ttnmdi.hdr.code = TTN_GETDISPINFOA; 104 ttnmdi.lpszText = (LPSTR)&ttnmdi.szText; 105 ttnmdi.uFlags = toolPtr->uFlags; 106 ttnmdi.lParam = toolPtr->lParam; 107 108 // TRACE (tooltips, "hdr.idFrom = %x\n", ttnmdi.hdr.idFrom); 109 SendMessageA (toolPtr->hwnd, WM_NOTIFY, 110 (WPARAM)toolPtr->uId, (LPARAM)&ttnmdi); 111 112 if ((ttnmdi.hinst) && (HIWORD((UINT)ttnmdi.szText) == 0)) { 113 LoadStringW (ttnmdi.hinst, (UINT)ttnmdi.szText, 114 infoPtr->szTipText, INFOTIPSIZE); 115 if (ttnmdi.uFlags & TTF_DI_SETITEM) { 116 toolPtr->hinst = ttnmdi.hinst; 117 toolPtr->lpszText = (LPWSTR)ttnmdi.szText; 118 } 119 } 120 else if (ttnmdi.szText[0]) { 121 lstrcpynAtoW (infoPtr->szTipText, ttnmdi.szText, 80); 122 if (ttnmdi.uFlags & TTF_DI_SETITEM) { 123 INT len = lstrlenA (ttnmdi.szText); 124 toolPtr->hinst = 0; 125 toolPtr->lpszText = COMCTL32_Alloc ((len+1)* sizeof(WCHAR)); 126 lstrcpyAtoW (toolPtr->lpszText, ttnmdi.szText); 127 } 128 } 129 else if (ttnmdi.lpszText == 0) { 130 /* no text available */ 131 infoPtr->szTipText[0] = L'\0'; 132 } 133 else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKA) { 134 lstrcpynAtoW (infoPtr->szTipText, ttnmdi.lpszText, INFOTIPSIZE); 135 if (ttnmdi.uFlags & TTF_DI_SETITEM) { 136 INT len = lstrlenA (ttnmdi.lpszText); 137 toolPtr->hinst = 0; 138 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR)); 139 lstrcpyAtoW (toolPtr->lpszText, ttnmdi.lpszText); 140 } 141 } 142 else { 143 // ERR (tooltips, "recursive text callback!\n"); 144 infoPtr->szTipText[0] = '\0'; 145 } 146 } 147 else { 148 /* the item is a usual (unicode) text */ 149 // lstrcpynW (infoPtr->szTipText, toolPtr->lpszText, INFOTIPSIZE); 150 strncpy(infoPtr->szTipText, toolPtr->lpszText, INFOTIPSIZE); 151 } 151 152 } 152 153 else { 153 154 154 /* no text available */ 155 infoPtr->szTipText[0] = L'\0'; 155 156 } 156 157 … … 168 169 169 170 if (infoPtr->nMaxTipWidth > -1) { 170 171 171 rc.right = infoPtr->nMaxTipWidth; 172 uFlags |= DT_WORDBREAK; 172 173 } 173 174 if (GetWindowLongA (hwnd, GWL_STYLE) & TTS_NOPREFIX) 174 175 uFlags |= DT_NOPREFIX; 175 176 // TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText)); 176 177 … … 181 182 ReleaseDC (hwnd, hdc); 182 183 183 lpSize->cx = rc.right - rc.left + 4 + 184 184 lpSize->cx = rc.right - rc.left + 4 + 185 infoPtr->rcMargin.left + infoPtr->rcMargin.right; 185 186 lpSize->cy = rc.bottom - rc.top + 4 + 186 187 infoPtr->rcMargin.bottom + infoPtr->rcMargin.top; 187 188 } 188 189 … … 198 199 199 200 if (infoPtr->nTool == -1) { 200 // 201 201 // TRACE (tooltips, "invalid tool (-1)!\n"); 202 return; 202 203 } 203 204 … … 209 210 210 211 if (infoPtr->szTipText[0] == L'\0') { 211 212 212 infoPtr->nCurrentTool = -1; 213 return; 213 214 } 214 215 … … 220 221 hdr.code = TTN_SHOW; 221 222 SendMessageA (toolPtr->hwnd, WM_NOTIFY, 222 223 (WPARAM)toolPtr->uId, (LPARAM)&hdr); 223 224 224 225 // TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText)); … … 228 229 229 230 if (toolPtr->uFlags & TTF_CENTERTIP) { 230 231 232 233 234 235 236 237 238 239 231 RECT rc; 232 233 if (toolPtr->uFlags & TTF_IDISHWND) 234 GetWindowRect ((HWND)toolPtr->uId, &rc); 235 else { 236 rc = toolPtr->rect; 237 MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rc, 2); 238 } 239 rect.left = (rc.left + rc.right - size.cx) / 2; 240 rect.top = rc.bottom + 2; 240 241 } 241 242 else { 242 243 243 GetCursorPos ((LPPOINT)&rect); 244 rect.top += 20; 244 245 } 245 246 … … 252 253 253 254 AdjustWindowRectEx (&rect, GetWindowLongA (hwnd, GWL_STYLE), 254 255 FALSE, GetWindowLongA (hwnd, GWL_EXSTYLE)); 255 256 256 257 SetWindowPos (hwnd, HWND_TOP, rect.left, rect.top, 257 258 258 rect.right - rect.left, rect.bottom - rect.top, 259 SWP_SHOWWINDOW | SWP_NOACTIVATE); 259 260 260 261 /* repaint the tooltip */ … … 274 275 275 276 if (infoPtr->nCurrentTool == -1) 276 277 return; 277 278 278 279 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool]; … … 284 285 hdr.code = TTN_POP; 285 286 SendMessageA (toolPtr->hwnd, WM_NOTIFY, 286 287 (WPARAM)toolPtr->uId, (LPARAM)&hdr); 287 288 288 289 infoPtr->nCurrentTool = -1; 289 290 290 291 SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0, 291 292 SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE); 292 293 } 293 294 … … 303 304 304 305 if (infoPtr->nTrackTool == -1) { 305 // 306 306 // TRACE (tooltips, "invalid tracking tool (-1)!\n"); 307 return; 307 308 } 308 309 … … 312 313 313 314 if (infoPtr->szTipText[0] == L'\0') { 314 315 315 infoPtr->nTrackTool = -1; 316 return; 316 317 } 317 318 … … 323 324 hdr.code = TTN_SHOW; 324 325 SendMessageA (toolPtr->hwnd, WM_NOTIFY, 325 326 (WPARAM)toolPtr->uId, (LPARAM)&hdr); 326 327 327 328 // TRACE (tooltips, "\"%s\"\n", debugstr_w(infoPtr->szTipText)); … … 331 332 332 333 if (toolPtr->uFlags & TTF_ABSOLUTE) { 333 334 335 336 337 338 339 334 rect.left = infoPtr->xTrackPos; 335 rect.top = infoPtr->yTrackPos; 336 337 if (toolPtr->uFlags & TTF_CENTERTIP) { 338 rect.left -= (size.cx / 2); 339 rect.top -= (size.cy / 2); 340 } 340 341 } 341 342 else { 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 343 RECT rcTool; 344 345 if (toolPtr->uFlags & TTF_IDISHWND) 346 GetWindowRect ((HWND)toolPtr->uId, &rcTool); 347 else { 348 rcTool = toolPtr->rect; 349 MapWindowPoints (toolPtr->hwnd, (HWND)0, (LPPOINT)&rcTool, 2); 350 } 351 352 GetCursorPos ((LPPOINT)&rect); 353 rect.top += 20; 354 355 if (toolPtr->uFlags & TTF_CENTERTIP) { 356 rect.left -= (size.cx / 2); 357 rect.top -= (size.cy / 2); 358 } 359 360 /* smart placement */ 361 if ((rect.left + size.cx > rcTool.left) && (rect.left < rcTool.right) && 362 (rect.top + size.cy > rcTool.top) && (rect.top < rcTool.bottom)) 363 rect.left = rcTool.right; 363 364 } 364 365 … … 369 370 370 371 AdjustWindowRectEx (&rect, GetWindowLongA (hwnd, GWL_STYLE), 371 372 FALSE, GetWindowLongA (hwnd, GWL_EXSTYLE)); 372 373 373 374 SetWindowPos (hwnd, HWND_TOP, rect.left, rect.top, 374 375 375 rect.right - rect.left, rect.bottom - rect.top, 376 SWP_SHOWWINDOW | SWP_NOACTIVATE ); 376 377 377 378 hdc = GetDC (hwnd); … … 388 389 389 390 if (infoPtr->nTrackTool == -1) 390 391 return; 391 392 392 393 toolPtr = &infoPtr->tools[infoPtr->nTrackTool]; … … 397 398 hdr.code = TTN_POP; 398 399 SendMessageA (toolPtr->hwnd, WM_NOTIFY, 399 400 (WPARAM)toolPtr->uId, (LPARAM)&hdr); 400 401 401 402 SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0, 402 403 SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE); 403 404 } 404 405 … … 411 412 412 413 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) { 413 414 415 if (!(toolPtr->uFlags & TTF_IDISHWND) && 416 417 418 414 toolPtr = &infoPtr->tools[nTool]; 415 416 if (!(toolPtr->uFlags & TTF_IDISHWND) && 417 (lpToolInfo->hwnd == toolPtr->hwnd) && 418 (lpToolInfo->uId == toolPtr->uId)) 419 return nTool; 419 420 } 420 421 421 422 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) { 422 423 424 425 426 423 toolPtr = &infoPtr->tools[nTool]; 424 425 if ((toolPtr->uFlags & TTF_IDISHWND) && 426 (lpToolInfo->uId == toolPtr->uId)) 427 return nTool; 427 428 } 428 429 … … 438 439 439 440 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) { 440 441 442 if (!(toolPtr->uFlags & TTF_IDISHWND) && 443 444 445 441 toolPtr = &infoPtr->tools[nTool]; 442 443 if (!(toolPtr->uFlags & TTF_IDISHWND) && 444 (lpToolInfo->hwnd == toolPtr->hwnd) && 445 (lpToolInfo->uId == toolPtr->uId)) 446 return nTool; 446 447 } 447 448 448 449 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) { 449 450 451 452 453 450 toolPtr = &infoPtr->tools[nTool]; 451 452 if ((toolPtr->uFlags & TTF_IDISHWND) && 453 (lpToolInfo->uId == toolPtr->uId)) 454 return nTool; 454 455 } 455 456 … … 465 466 466 467 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) { 467 468 469 470 471 472 473 474 475 468 toolPtr = &infoPtr->tools[nTool]; 469 470 if (!(toolPtr->uFlags & TTF_IDISHWND)) { 471 if (hwnd != toolPtr->hwnd) 472 continue; 473 if (!PtInRect (&toolPtr->rect, *lpPt)) 474 continue; 475 return nTool; 476 } 476 477 } 477 478 478 479 for (nTool = 0; nTool < infoPtr->uNumTools; nTool++) { 479 480 481 482 483 484 480 toolPtr = &infoPtr->tools[nTool]; 481 482 if (toolPtr->uFlags & TTF_IDISHWND) { 483 if ((HWND)toolPtr->uId == hwnd) 484 return nTool; 485 } 485 486 } 486 487 … … 509 510 HWND hwndActive = GetActiveWindow (); 510 511 if (!hwndActive) 511 512 return FALSE; 512 513 if (hwndActive == hwnd) 513 514 return TRUE; 514 515 return IsChild (hwndActive, hwnd); 515 516 } … … 527 528 hwndTool = SendMessageA (hwnd, TTM_WINDOWFROMPOINT, 0, (LPARAM)&pt); 528 529 if (hwndTool == 0) 529 530 return -1; 530 531 531 532 ScreenToClient (hwndTool, &pt); 532 533 nTool = TOOLTIPS_GetToolFromPoint (infoPtr, hwndTool, &pt); 533 534 if (nTool == -1) 534 535 return -1; 535 536 536 537 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TTS_ALWAYSTIP) && bShowTest) { 537 538 538 if (!TOOLTIPS_IsWindowActive (GetWindow (hwnd, GW_OWNER))) 539 return -1; 539 540 } 540 541 … … 553 554 554 555 // if (infoPtr->bActive) 555 // 556 557 if (!(infoPtr->bActive) && (infoPtr->nCurrentTool != -1)) 558 556 // TRACE (tooltips, "activate!\n"); 557 558 if (!(infoPtr->bActive) && (infoPtr->nCurrentTool != -1)) 559 TOOLTIPS_Hide (hwnd, infoPtr); 559 560 560 561 return 0; … … 570 571 571 572 if (lpToolInfo == NULL) 572 573 return FALSE; 573 574 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) 574 575 return FALSE; 575 576 576 577 // TRACE (tooltips, "add tool (%x) %x %d%s!\n", 577 // 578 // 578 // hwnd, lpToolInfo->hwnd, lpToolInfo->uId, 579 // (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : ""); 579 580 580 581 if (infoPtr->uNumTools == 0) { 581 582 582 infoPtr->tools = COMCTL32_Alloc (sizeof(TTTOOL_INFO)); 583 toolPtr = infoPtr->tools; 583 584 } 584 585 else { 585 586 587 588 589 590 591 586 TTTOOL_INFO *oldTools = infoPtr->tools; 587 infoPtr->tools = 588 COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools + 1)); 589 memcpy (infoPtr->tools, oldTools, 590 infoPtr->uNumTools * sizeof(TTTOOL_INFO)); 591 COMCTL32_Free (oldTools); 592 toolPtr = &infoPtr->tools[infoPtr->uNumTools]; 592 593 } 593 594 … … 602 603 603 604 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) { 604 // 605 605 // TRACE (tooltips, "add string id %x!\n", (int)lpToolInfo->lpszText); 606 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText; 606 607 } 607 608 else if (lpToolInfo->lpszText) { 608 609 // 610 611 612 613 614 // 615 toolPtr->lpszText =COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));616 617 609 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA) { 610 // TRACE (tooltips, "add CALLBACK!\n"); 611 toolPtr->lpszText = LPSTR_TEXTCALLBACKW; 612 } 613 else { 614 INT len = lstrlenA (lpToolInfo->lpszText); 615 // TRACE (tooltips, "add text \"%s\"!\n", lpToolInfo->lpszText); 616 toolPtr->lpszText = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 617 lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText); 618 } 618 619 } 619 620 620 621 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA)) 621 622 toolPtr->lParam = lpToolInfo->lParam; 622 623 623 624 /* install subclassing hook */ 624 625 if (toolPtr->uFlags & TTF_SUBCLASS) { 625 626 627 628 629 630 631 lpttsi->wpOrigProc = 632 633 634 635 636 637 638 639 // 640 // 641 642 643 644 645 646 647 648 lpttsi->wpOrigProc = 649 650 651 652 653 654 655 656 657 658 // 626 if (toolPtr->uFlags & TTF_IDISHWND) { 627 LPTT_SUBCLASS_INFO lpttsi = 628 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 629 if (lpttsi == NULL) { 630 lpttsi = 631 (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO)); 632 lpttsi->wpOrigProc = 633 (WNDPROC)SetWindowLongA ((HWND)toolPtr->uId, 634 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc); 635 lpttsi->hwndToolTip = hwnd; 636 lpttsi->uRefCount++; 637 SetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass, 638 (HANDLE)lpttsi); 639 } 640 // else 641 // WARN (tooltips, "A window tool must only be listed once!\n"); 642 } 643 else { 644 LPTT_SUBCLASS_INFO lpttsi = 645 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass); 646 if (lpttsi == NULL) { 647 lpttsi = 648 (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO)); 649 lpttsi->wpOrigProc = 650 (WNDPROC)SetWindowLongA (toolPtr->hwnd, 651 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc); 652 lpttsi->hwndToolTip = hwnd; 653 lpttsi->uRefCount++; 654 SetPropA (toolPtr->hwnd, COMCTL32_aSubclass, (HANDLE)lpttsi); 655 } 656 else 657 lpttsi->uRefCount++; 658 } 659 // TRACE (tooltips, "subclassing installed!\n"); 659 660 } 660 661 … … 671 672 672 673 if (lpToolInfo == NULL) 673 674 return FALSE; 674 675 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW) 675 676 return FALSE; 676 677 677 678 // TRACE (tooltips, "add tool (%x) %x %d%s!\n", 678 // 679 // 679 // hwnd, lpToolInfo->hwnd, lpToolInfo->uId, 680 // (lpToolInfo->uFlags & TTF_IDISHWND) ? " TTF_IDISHWND" : ""); 680 681 681 682 if (infoPtr->uNumTools == 0) { 682 683 683 infoPtr->tools = COMCTL32_Alloc (sizeof(TTTOOL_INFO)); 684 toolPtr = infoPtr->tools; 684 685 } 685 686 else { 686 687 688 689 690 691 692 687 TTTOOL_INFO *oldTools = infoPtr->tools; 688 infoPtr->tools = 689 COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools + 1)); 690 memcpy (infoPtr->tools, oldTools, 691 infoPtr->uNumTools * sizeof(TTTOOL_INFO)); 692 COMCTL32_Free (oldTools); 693 toolPtr = &infoPtr->tools[infoPtr->uNumTools]; 693 694 } 694 695 … … 703 704 704 705 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) { 705 // 706 706 // TRACE (tooltips, "add string id %x!\n", (int)lpToolInfo->lpszText); 707 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText; 707 708 } 708 709 else if (lpToolInfo->lpszText) { 709 710 // 711 712 713 714 715 // 716 // 717 toolPtr->lpszText =COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));718 719 710 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW) { 711 // TRACE (tooltips, "add CALLBACK!\n"); 712 toolPtr->lpszText = LPSTR_TEXTCALLBACKW; 713 } 714 else { 715 INT len = lstrlenW (lpToolInfo->lpszText); 716 // TRACE (tooltips, "add text \"%s\"!\n", 717 // debugstr_w(lpToolInfo->lpszText)); 718 toolPtr->lpszText = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 719 lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText); 720 } 720 721 } 721 722 722 723 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW)) 723 724 toolPtr->lParam = lpToolInfo->lParam; 724 725 725 726 /* install subclassing hook */ 726 727 if (toolPtr->uFlags & TTF_SUBCLASS) { 727 728 729 730 731 732 733 lpttsi->wpOrigProc = 734 735 736 737 738 739 740 741 // 742 // 743 744 745 746 747 748 749 750 lpttsi->wpOrigProc = 751 752 753 754 755 756 757 758 759 760 // 728 if (toolPtr->uFlags & TTF_IDISHWND) { 729 LPTT_SUBCLASS_INFO lpttsi = 730 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 731 if (lpttsi == NULL) { 732 lpttsi = 733 (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO)); 734 lpttsi->wpOrigProc = 735 (WNDPROC)SetWindowLongA ((HWND)toolPtr->uId, 736 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc); 737 lpttsi->hwndToolTip = hwnd; 738 lpttsi->uRefCount++; 739 SetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass, 740 (HANDLE)lpttsi); 741 } 742 // else 743 // WARN (tooltips, "A window tool must only be listed once!\n"); 744 } 745 else { 746 LPTT_SUBCLASS_INFO lpttsi = 747 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass); 748 if (lpttsi == NULL) { 749 lpttsi = 750 (LPTT_SUBCLASS_INFO)COMCTL32_Alloc (sizeof(TT_SUBCLASS_INFO)); 751 lpttsi->wpOrigProc = 752 (WNDPROC)SetWindowLongA (toolPtr->hwnd, 753 GWL_WNDPROC,(LONG)TOOLTIPS_SubclassProc); 754 lpttsi->hwndToolTip = hwnd; 755 lpttsi->uRefCount++; 756 SetPropA (toolPtr->hwnd, COMCTL32_aSubclass, (HANDLE)lpttsi); 757 } 758 else 759 lpttsi->uRefCount++; 760 } 761 // TRACE (tooltips, "subclassing installed!\n"); 761 762 } 762 763 … … 774 775 775 776 if (lpToolInfo == NULL) 776 777 return 0; 777 778 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) 778 779 return 0; 779 780 if (infoPtr->uNumTools == 0) 780 781 return 0; 781 782 782 783 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo); … … 786 787 787 788 /* delete text string */ 788 toolPtr = &infoPtr->tools[nTool]; 789 toolPtr = &infoPtr->tools[nTool]; 789 790 if ((toolPtr->hinst) && (toolPtr->lpszText)) { 790 791 791 if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) 792 COMCTL32_Free (toolPtr->lpszText); 792 793 } 793 794 794 795 /* remove subclassing */ 795 796 if (toolPtr->uFlags & TTF_SUBCLASS) { 796 797 798 799 800 801 802 803 804 805 // 806 // 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 // 822 // 823 797 if (toolPtr->uFlags & TTF_IDISHWND) { 798 LPTT_SUBCLASS_INFO lpttsi = 799 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 800 if (lpttsi) { 801 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC, 802 (LONG)lpttsi->wpOrigProc); 803 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 804 COMCTL32_Free (&lpttsi); 805 } 806 // else 807 // ERR (tooltips, "Invalid data handle!\n"); 808 } 809 else { 810 LPTT_SUBCLASS_INFO lpttsi = 811 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass); 812 if (lpttsi) { 813 if (lpttsi->uRefCount == 1) { 814 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC, 815 (LONG)lpttsi->wpOrigProc); 816 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 817 COMCTL32_Free (&lpttsi); 818 } 819 else 820 lpttsi->uRefCount--; 821 } 822 // else 823 // ERR (tooltips, "Invalid data handle!\n"); 824 } 824 825 } 825 826 826 827 /* delete tool from tool list */ 827 828 if (infoPtr->uNumTools == 1) { 828 829 829 COMCTL32_Free (infoPtr->tools); 830 infoPtr->tools = NULL; 830 831 } 831 832 else { 832 833 834 835 836 837 838 839 840 841 842 843 844 833 TTTOOL_INFO *oldTools = infoPtr->tools; 834 infoPtr->tools = 835 COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools - 1)); 836 837 if (nTool > 0) 838 memcpy (&infoPtr->tools[0], &oldTools[0], 839 nTool * sizeof(TTTOOL_INFO)); 840 841 if (nTool < infoPtr->uNumTools - 1) 842 memcpy (&infoPtr->tools[nTool], &oldTools[nTool + 1], 843 (infoPtr->uNumTools - nTool - 1) * sizeof(TTTOOL_INFO)); 844 845 COMCTL32_Free (oldTools); 845 846 } 846 847 … … 860 861 861 862 if (lpToolInfo == NULL) 862 863 return 0; 863 864 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW) 864 865 return 0; 865 866 if (infoPtr->uNumTools == 0) 866 867 return 0; 867 868 868 869 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo); … … 872 873 873 874 /* delete text string */ 874 toolPtr = &infoPtr->tools[nTool]; 875 toolPtr = &infoPtr->tools[nTool]; 875 876 if ((toolPtr->hinst) && (toolPtr->lpszText)) { 876 877 877 if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) 878 COMCTL32_Free (toolPtr->lpszText); 878 879 } 879 880 880 881 /* remove subclassing */ 881 882 if (toolPtr->uFlags & TTF_SUBCLASS) { 882 883 884 885 886 887 888 889 890 891 // 892 // 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 // 908 // 909 883 if (toolPtr->uFlags & TTF_IDISHWND) { 884 LPTT_SUBCLASS_INFO lpttsi = 885 (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 886 if (lpttsi) { 887 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC, 888 (LONG)lpttsi->wpOrigProc); 889 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 890 COMCTL32_Free (&lpttsi); 891 } 892 // else 893 // ERR (tooltips, "Invalid data handle!\n"); 894 } 895 else { 896 LPTT_SUBCLASS_INFO lpttsi = 897 (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass); 898 if (lpttsi) { 899 if (lpttsi->uRefCount == 1) { 900 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC, 901 (LONG)lpttsi->wpOrigProc); 902 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 903 COMCTL32_Free (&lpttsi); 904 } 905 else 906 lpttsi->uRefCount--; 907 } 908 // else 909 // ERR (tooltips, "Invalid data handle!\n"); 910 } 910 911 } 911 912 912 913 /* delete tool from tool list */ 913 914 if (infoPtr->uNumTools == 1) { 914 915 915 COMCTL32_Free (infoPtr->tools); 916 infoPtr->tools = NULL; 916 917 } 917 918 else { 918 919 920 921 922 923 924 925 926 927 928 929 930 919 TTTOOL_INFO *oldTools = infoPtr->tools; 920 infoPtr->tools = 921 COMCTL32_Alloc (sizeof(TTTOOL_INFO) * (infoPtr->uNumTools - 1)); 922 923 if (nTool > 0) 924 memcpy (&infoPtr->tools[0], &oldTools[0], 925 nTool * sizeof(TTTOOL_INFO)); 926 927 if (nTool < infoPtr->uNumTools - 1) 928 memcpy (&infoPtr->tools[nTool], &oldTools[nTool + 1], 929 (infoPtr->uNumTools - nTool - 1) * sizeof(TTTOOL_INFO)); 930 931 COMCTL32_Free (oldTools); 931 932 } 932 933 … … 946 947 947 948 if (lpToolInfo == NULL) 948 949 return FALSE; 949 950 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) 950 951 return FALSE; 951 952 if (uIndex >= infoPtr->uNumTools) 952 953 return FALSE; 953 954 954 955 // TRACE (tooltips, "index=%u\n", uIndex); … … 966 967 967 968 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA)) 968 969 lpToolInfo->lParam = toolPtr->lParam; 969 970 970 971 return TRUE; … … 981 982 982 983 if (lpToolInfo == NULL) 983 984 return FALSE; 984 985 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW) 985 986 return FALSE; 986 987 if (uIndex >= infoPtr->uNumTools) 987 988 return FALSE; 988 989 989 990 // TRACE (tooltips, "index=%u\n", uIndex); … … 1001 1002 1002 1003 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW)) 1003 1004 lpToolInfo->lParam = toolPtr->lParam; 1004 1005 1005 1006 return TRUE; … … 1015 1016 1016 1017 if (lpToolInfo == NULL) 1017 1018 return FALSE; 1018 1019 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) 1019 1020 return FALSE; 1020 1021 1021 1022 if (lpToolInfo) { 1022 1023 1024 1025 1026 1027 1028 1029 /* 1030 1031 1032 1033 1034 1035 1036 1037 1038 1023 if (infoPtr->nCurrentTool > -1) { 1024 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool]; 1025 1026 /* copy tool data */ 1027 lpToolInfo->uFlags = toolPtr->uFlags; 1028 lpToolInfo->rect = toolPtr->rect; 1029 lpToolInfo->hinst = toolPtr->hinst; 1030 /* lpToolInfo->lpszText = toolPtr->lpszText; */ 1031 lpToolInfo->lpszText = NULL; /* FIXME */ 1032 1033 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA)) 1034 lpToolInfo->lParam = toolPtr->lParam; 1035 1036 return TRUE; 1037 } 1038 else 1039 return FALSE; 1039 1040 } 1040 1041 else 1041 1042 return (infoPtr->nCurrentTool != -1); 1042 1043 1043 1044 return FALSE; … … 1053 1054 1054 1055 if (lpToolInfo == NULL) 1055 1056 return FALSE; 1056 1057 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW) 1057 1058 return FALSE; 1058 1059 1059 1060 if (lpToolInfo) { 1060 1061 1062 1063 1064 1065 1066 1067 /* 1068 1069 1070 1071 1072 1073 1074 1075 1076 1061 if (infoPtr->nCurrentTool > -1) { 1062 toolPtr = &infoPtr->tools[infoPtr->nCurrentTool]; 1063 1064 /* copy tool data */ 1065 lpToolInfo->uFlags = toolPtr->uFlags; 1066 lpToolInfo->rect = toolPtr->rect; 1067 lpToolInfo->hinst = toolPtr->hinst; 1068 /* lpToolInfo->lpszText = toolPtr->lpszText; */ 1069 lpToolInfo->lpszText = NULL; /* FIXME */ 1070 1071 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW)) 1072 lpToolInfo->lParam = toolPtr->lParam; 1073 1074 return TRUE; 1075 } 1076 else 1077 return FALSE; 1077 1078 } 1078 1079 else 1079 1080 return (infoPtr->nCurrentTool != -1); 1080 1081 1081 1082 return FALSE; … … 1089 1090 1090 1091 switch (wParam) { 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1092 case TTDT_AUTOMATIC: 1093 return infoPtr->nAutomaticTime; 1094 1095 case TTDT_RESHOW: 1096 return infoPtr->nReshowTime; 1097 1098 case TTDT_AUTOPOP: 1099 return infoPtr->nAutoPopTime; 1100 1101 case TTDT_INITIAL: 1102 return infoPtr->nInitialTime; 1102 1103 } 1103 1104 … … 1138 1139 1139 1140 if (lpToolInfo == NULL) 1140 1141 return 0; 1141 1142 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) 1142 1143 return 0; 1143 1144 1144 1145 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo); … … 1159 1160 1160 1161 if (lpToolInfo == NULL) 1161 1162 return 0; 1162 1163 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW) 1163 1164 return 0; 1164 1165 1165 1166 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo); … … 1205 1206 1206 1207 if (lpToolInfo == NULL) 1207 1208 return FALSE; 1208 1209 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) 1209 1210 return FALSE; 1210 1211 if (infoPtr->uNumTools == 0) 1211 1212 return FALSE; 1212 1213 1213 1214 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo); 1214 1215 if (nTool == -1) 1215 1216 return FALSE; 1216 1217 1217 1218 // TRACE (tooltips, "tool %d\n", nTool); … … 1227 1228 1228 1229 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA)) 1229 1230 lpToolInfo->lParam = toolPtr->lParam; 1230 1231 1231 1232 return TRUE; … … 1242 1243 1243 1244 if (lpToolInfo == NULL) 1244 1245 return FALSE; 1245 1246 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW) 1246 1247 return FALSE; 1247 1248 if (infoPtr->uNumTools == 0) 1248 1249 return FALSE; 1249 1250 1250 1251 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo); 1251 1252 if (nTool == -1) 1252 1253 return FALSE; 1253 1254 1254 1255 // TRACE (tooltips, "tool %d\n", nTool); … … 1264 1265 1265 1266 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW)) 1266 1267 lpToolInfo->lParam = toolPtr->lParam; 1267 1268 1268 1269 return TRUE; … … 1279 1280 1280 1281 if (lptthit == 0) 1281 1282 return FALSE; 1282 1283 1283 1284 nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lptthit->hwnd, &lptthit->pt); 1284 1285 if (nTool == -1) 1285 1286 return FALSE; 1286 1287 1287 1288 // TRACE (tooltips, "tool %d!\n", nTool); … … 1289 1290 /* copy tool data */ 1290 1291 if (lptthit->ti.cbSize >= sizeof(TTTOOLINFOA)) { 1291 1292 1293 1294 1295 1296 1297 1298 /* 1299 1300 1292 toolPtr = &infoPtr->tools[nTool]; 1293 1294 lptthit->ti.uFlags = toolPtr->uFlags; 1295 lptthit->ti.hwnd = toolPtr->hwnd; 1296 lptthit->ti.uId = toolPtr->uId; 1297 lptthit->ti.rect = toolPtr->rect; 1298 lptthit->ti.hinst = toolPtr->hinst; 1299 /* lptthit->ti.lpszText = toolPtr->lpszText; */ 1300 lptthit->ti.lpszText = NULL; /* FIXME */ 1301 lptthit->ti.lParam = toolPtr->lParam; 1301 1302 } 1302 1303 … … 1314 1315 1315 1316 if (lptthit == 0) 1316 1317 return FALSE; 1317 1318 1318 1319 nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lptthit->hwnd, &lptthit->pt); 1319 1320 if (nTool == -1) 1320 1321 return FALSE; 1321 1322 1322 1323 // TRACE (tooltips, "tool %d!\n", nTool); … … 1324 1325 /* copy tool data */ 1325 1326 if (lptthit->ti.cbSize >= sizeof(TTTOOLINFOW)) { 1326 1327 1328 1329 1330 1331 1332 1333 /* 1334 1335 1327 toolPtr = &infoPtr->tools[nTool]; 1328 1329 lptthit->ti.uFlags = toolPtr->uFlags; 1330 lptthit->ti.hwnd = toolPtr->hwnd; 1331 lptthit->ti.uId = toolPtr->uId; 1332 lptthit->ti.rect = toolPtr->rect; 1333 lptthit->ti.hinst = toolPtr->hinst; 1334 /* lptthit->ti.lpszText = toolPtr->lpszText; */ 1335 lptthit->ti.lpszText = NULL; /* FIXME */ 1336 lptthit->ti.lParam = toolPtr->lParam; 1336 1337 } 1337 1338 … … 1348 1349 1349 1350 if (lpti == NULL) 1350 1351 return 0; 1351 1352 if (lpti->cbSize < TTTOOLINFO_V1_SIZEA) 1352 1353 return FALSE; 1353 1354 1354 1355 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpti); … … 1369 1370 1370 1371 if (lpti == NULL) 1371 1372 return 0; 1372 1373 if (lpti->cbSize < TTTOOLINFO_V1_SIZEW) 1373 1374 return FALSE; 1374 1375 1375 1376 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpti); … … 1401 1402 1402 1403 if (lParam == 0) { 1403 // 1404 1404 // ERR (tooltips, "lpMsg == NULL!\n"); 1405 return 0; 1405 1406 } 1406 1407 1407 1408 switch (lpMsg->message) { 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 // 1419 // 1420 1421 1422 1423 1424 1425 1426 1427 1428 // 1429 // 1430 // 1431 // 1432 1433 1434 1435 // 1436 1437 1438 1439 1440 // 1441 1442 1443 1444 1445 // 1446 1447 1409 case WM_LBUTTONDOWN: 1410 case WM_LBUTTONUP: 1411 case WM_MBUTTONDOWN: 1412 case WM_MBUTTONUP: 1413 case WM_RBUTTONDOWN: 1414 case WM_RBUTTONUP: 1415 pt = lpMsg->pt; 1416 ScreenToClient (lpMsg->hwnd, &pt); 1417 infoPtr->nOldTool = infoPtr->nTool; 1418 infoPtr->nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lpMsg->hwnd, &pt); 1419 // TRACE (tooltips, "tool (%x) %d %d\n", 1420 // hwnd, infoPtr->nOldTool, infoPtr->nTool); 1421 TOOLTIPS_Hide (hwnd, infoPtr); 1422 break; 1423 1424 case WM_MOUSEMOVE: 1425 pt = lpMsg->pt; 1426 ScreenToClient (lpMsg->hwnd, &pt); 1427 infoPtr->nOldTool = infoPtr->nTool; 1428 infoPtr->nTool = TOOLTIPS_GetToolFromPoint (infoPtr, lpMsg->hwnd, &pt); 1429 // TRACE (tooltips, "tool (%x) %d %d\n", 1430 // hwnd, infoPtr->nOldTool, infoPtr->nTool); 1431 // TRACE (tooltips, "WM_MOUSEMOVE (%04x %ld %ld)\n", 1432 // hwnd, pt.x, pt.y); 1433 if ((infoPtr->bActive) && (infoPtr->nTool != infoPtr->nOldTool)) { 1434 if (infoPtr->nOldTool == -1) { 1435 SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nInitialTime, 0); 1436 // TRACE (tooltips, "timer 1 started!\n"); 1437 } 1438 else { 1439 TOOLTIPS_Hide (hwnd, infoPtr); 1440 SetTimer (hwnd, ID_TIMERSHOW, infoPtr->nReshowTime, 0); 1441 // TRACE (tooltips, "timer 2 started!\n"); 1442 } 1443 } 1444 if (infoPtr->nCurrentTool != -1) { 1445 SetTimer (hwnd, ID_TIMERLEAVE, 100, 0); 1446 // TRACE (tooltips, "timer 3 started!\n"); 1447 } 1448 break; 1448 1449 } 1449 1450 … … 1459 1460 1460 1461 switch (wParam) { 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1462 case TTDT_AUTOMATIC: 1463 if (nTime == 0) { 1464 infoPtr->nAutomaticTime = 500; 1465 infoPtr->nReshowTime = 100; 1466 infoPtr->nAutoPopTime = 5000; 1467 infoPtr->nInitialTime = 500; 1468 } 1469 else { 1470 infoPtr->nAutomaticTime = nTime; 1471 infoPtr->nReshowTime = nTime / 5; 1472 infoPtr->nAutoPopTime = nTime * 10; 1473 infoPtr->nInitialTime = nTime; 1474 } 1475 break; 1476 1477 case TTDT_RESHOW: 1478 infoPtr->nReshowTime = nTime; 1479 break; 1480 1481 case TTDT_AUTOPOP: 1482 infoPtr->nAutoPopTime = nTime; 1483 break; 1484 1485 case TTDT_INITIAL: 1486 infoPtr->nInitialTime = nTime; 1487 break; 1487 1488 } 1488 1489 … … 1549 1550 1550 1551 if (lpToolInfo == NULL) 1551 1552 return 0; 1552 1553 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) 1553 1554 return 0; 1554 1555 1555 1556 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo); … … 1568 1569 1569 1570 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) { 1570 // 1571 1571 // TRACE (tooltips, "set string id %x!\n", (INT)lpToolInfo->lpszText); 1572 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText; 1572 1573 } 1573 1574 else if (lpToolInfo->lpszText) { 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1575 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA) 1576 toolPtr->lpszText = LPSTR_TEXTCALLBACKW; 1577 else { 1578 if (toolPtr->lpszText) { 1579 COMCTL32_Free (toolPtr->lpszText); 1580 toolPtr->lpszText = NULL; 1581 } 1582 if (lpToolInfo->lpszText) { 1583 INT len = lstrlenA (lpToolInfo->lpszText); 1584 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR)); 1585 lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText); 1586 } 1587 } 1587 1588 } 1588 1589 1589 1590 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOA)) 1590 1591 toolPtr->lParam = lpToolInfo->lParam; 1591 1592 1592 1593 return 0; … … 1603 1604 1604 1605 if (lpToolInfo == NULL) 1605 1606 return 0; 1606 1607 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW) 1607 1608 return 0; 1608 1609 1609 1610 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo); … … 1622 1623 1623 1624 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)) { 1624 // 1625 1625 // TRACE (tooltips, "set string id %x!\n", (INT)lpToolInfo->lpszText); 1626 toolPtr->lpszText = lpToolInfo->lpszText; 1626 1627 } 1627 1628 else if (lpToolInfo->lpszText) { 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1629 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW) 1630 toolPtr->lpszText = LPSTR_TEXTCALLBACKW; 1631 else { 1632 if (toolPtr->lpszText) { 1633 COMCTL32_Free (toolPtr->lpszText); 1634 toolPtr->lpszText = NULL; 1635 } 1636 if (lpToolInfo->lpszText) { 1637 INT len = lstrlenW (lpToolInfo->lpszText); 1638 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR)); 1639 lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText); 1640 } 1641 } 1641 1642 } 1642 1643 1643 1644 if (lpToolInfo->cbSize >= sizeof(TTTOOLINFOW)) 1644 1645 toolPtr->lParam = lpToolInfo->lParam; 1645 1646 1646 1647 return 0; … … 1655 1656 1656 1657 if (lpToolInfo == NULL) 1657 1658 return 0; 1658 1659 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) 1659 1660 return FALSE; 1660 1661 1661 1662 if ((BOOL)wParam) { 1662 1663 1664 1665 // 1666 1667 1668 1663 /* activate */ 1664 infoPtr->nTrackTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo); 1665 if (infoPtr->nTrackTool != -1) { 1666 // TRACE (tooltips, "activated!\n"); 1667 infoPtr->bTrackActive = TRUE; 1668 TOOLTIPS_TrackShow (hwnd, infoPtr); 1669 } 1669 1670 } 1670 1671 else { 1671 1672 1673 1674 1675 1676 1677 // 1672 /* deactivate */ 1673 TOOLTIPS_TrackHide (hwnd, infoPtr); 1674 1675 infoPtr->bTrackActive = FALSE; 1676 infoPtr->nTrackTool = -1; 1677 1678 // TRACE (tooltips, "deactivated!\n"); 1678 1679 } 1679 1680 … … 1691 1692 1692 1693 if (infoPtr->bTrackActive) { 1693 // 1694 // 1695 1696 1694 // TRACE (tooltips, "[%d %d]\n", 1695 // infoPtr->xTrackPos, infoPtr->yTrackPos); 1696 1697 TOOLTIPS_TrackShow (hwnd, infoPtr); 1697 1698 } 1698 1699 … … 1707 1708 1708 1709 if (infoPtr->nCurrentTool != -1) 1709 1710 UpdateWindow (hwnd); 1710 1711 1711 1712 return 0; … … 1722 1723 1723 1724 if (lpToolInfo == NULL) 1724 1725 return 0; 1725 1726 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEA) 1726 1727 return FALSE; 1727 1728 1728 1729 nTool = TOOLTIPS_GetToolFromInfoA (infoPtr, lpToolInfo); … … 1737 1738 1738 1739 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)){ 1739 1740 toolPtr->lpszText = (LPWSTR)lpToolInfo->lpszText; 1740 1741 } 1741 1742 else if (lpToolInfo->lpszText) { 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1743 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKA) 1744 toolPtr->lpszText = LPSTR_TEXTCALLBACKW; 1745 else { 1746 if (toolPtr->lpszText) { 1747 COMCTL32_Free (toolPtr->lpszText); 1748 toolPtr->lpszText = NULL; 1749 } 1750 if (lpToolInfo->lpszText) { 1751 INT len = lstrlenA (lpToolInfo->lpszText); 1752 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR)); 1753 lstrcpyAtoW (toolPtr->lpszText, lpToolInfo->lpszText); 1754 } 1755 } 1755 1756 } 1756 1757 1757 1758 /* force repaint */ 1758 1759 if (infoPtr->bActive) 1759 1760 TOOLTIPS_Show (hwnd, infoPtr); 1760 1761 else if (infoPtr->bTrackActive) 1761 1762 TOOLTIPS_TrackShow (hwnd, infoPtr); 1762 1763 1763 1764 return 0; … … 1774 1775 1775 1776 if (lpToolInfo == NULL) 1776 1777 return 0; 1777 1778 if (lpToolInfo->cbSize < TTTOOLINFO_V1_SIZEW) 1778 1779 return FALSE; 1779 1780 1780 1781 nTool = TOOLTIPS_GetToolFromInfoW (infoPtr, lpToolInfo); 1781 1782 if (nTool == -1) 1782 1783 return 0; 1783 1784 1784 1785 // TRACE (tooltips, "tool %d\n", nTool); … … 1790 1791 1791 1792 if ((lpToolInfo->hinst) && (HIWORD((INT)lpToolInfo->lpszText) == 0)){ 1792 1793 toolPtr->lpszText = lpToolInfo->lpszText; 1793 1794 } 1794 1795 else if (lpToolInfo->lpszText) { 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1796 if (lpToolInfo->lpszText == LPSTR_TEXTCALLBACKW) 1797 toolPtr->lpszText = LPSTR_TEXTCALLBACKW; 1798 else { 1799 if (toolPtr->lpszText) { 1800 COMCTL32_Free (toolPtr->lpszText); 1801 toolPtr->lpszText = NULL; 1802 } 1803 if (lpToolInfo->lpszText) { 1804 INT len = lstrlenW (lpToolInfo->lpszText); 1805 toolPtr->lpszText = COMCTL32_Alloc ((len+1)*sizeof(WCHAR)); 1806 lstrcpyW (toolPtr->lpszText, lpToolInfo->lpszText); 1807 } 1808 } 1808 1809 } 1809 1810 1810 1811 /* force repaint */ 1811 1812 if (infoPtr->bActive) 1812 1813 TOOLTIPS_Show (hwnd, infoPtr); 1813 1814 else if (infoPtr->bTrackActive) 1814 1815 TOOLTIPS_TrackShow (hwnd, infoPtr); 1815 1816 1816 1817 return 0; … … 1859 1860 1860 1861 nResult = (INT) SendMessageA (GetParent (hwnd), WM_NOTIFYFORMAT, 1861 1862 (WPARAM)hwnd, (LPARAM)NF_QUERY); 1862 1863 // if (nResult == NFR_ANSI) 1863 // 1864 // TRACE (tooltips, " -- WM_NOTIFYFORMAT returns: NFR_ANSI\n"); 1864 1865 // else if (nResult == NFR_UNICODE) 1865 // 1866 // FIXME (tooltips, " -- WM_NOTIFYFORMAT returns: NFR_UNICODE\n"); 1866 1867 // else 1867 // 1868 // FIXME (tooltips, " -- WM_NOTIFYFORMAT returns: error!\n"); 1868 1869 1869 1870 SetWindowPos (hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE); … … 1882 1883 /* free tools */ 1883 1884 if (infoPtr->tools) { 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1885 for (i = 0; i < infoPtr->uNumTools; i++) { 1886 toolPtr = &infoPtr->tools[i]; 1887 if ((toolPtr->hinst) && (toolPtr->lpszText)) { 1888 if (toolPtr->lpszText != LPSTR_TEXTCALLBACKW) 1889 COMCTL32_Free (toolPtr->lpszText); 1890 } 1891 1892 /* remove subclassing */ 1893 if (toolPtr->uFlags & TTF_SUBCLASS) { 1894 LPTT_SUBCLASS_INFO lpttsi; 1895 1896 if (toolPtr->uFlags & TTF_IDISHWND) 1897 lpttsi = (LPTT_SUBCLASS_INFO)GetPropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 1898 else 1899 lpttsi = (LPTT_SUBCLASS_INFO)GetPropA (toolPtr->hwnd, COMCTL32_aSubclass); 1900 1901 if (lpttsi) { 1902 SetWindowLongA ((HWND)toolPtr->uId, GWL_WNDPROC, 1903 (LONG)lpttsi->wpOrigProc); 1904 RemovePropA ((HWND)toolPtr->uId, COMCTL32_aSubclass); 1905 COMCTL32_Free (&lpttsi); 1906 } 1907 } 1908 } 1909 COMCTL32_Free (infoPtr->tools); 1909 1910 } 1910 1911 … … 1977 1978 1978 1979 if ((nTool > -1) && (nTool < infoPtr->uNumTools)) { 1979 1980 // 1981 1982 1980 if (infoPtr->tools[nTool].uFlags & TTF_TRANSPARENT) { 1981 // TRACE (tooltips, "-- in transparent mode!\n"); 1982 return HTTRANSPARENT; 1983 } 1983 1984 } 1984 1985 … … 1996 1997 TOOLTIPS_Refresh (hwnd, hdc); 1997 1998 if (!wParam) 1998 1999 EndPaint (hwnd, &ps); 1999 2000 return 0; 2000 2001 } … … 2009 2010 2010 2011 if ((LOWORD(lParam)) & (infoPtr->nCurrentTool != -1)) { 2011 // 2012 // FIXME (tooltips, "full redraw needed!\n"); 2012 2013 } 2013 2014 … … 2072 2073 switch (wParam) 2073 2074 { 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2075 case ID_TIMERSHOW: 2076 KillTimer (hwnd, ID_TIMERSHOW); 2077 if (TOOLTIPS_CheckTool (hwnd, TRUE) == infoPtr->nTool) 2078 TOOLTIPS_Show (hwnd, infoPtr); 2079 break; 2080 2081 case ID_TIMERPOP: 2082 TOOLTIPS_Hide (hwnd, infoPtr); 2083 break; 2084 2085 case ID_TIMERLEAVE: 2086 KillTimer (hwnd, ID_TIMERLEAVE); 2087 if (TOOLTIPS_CheckTool (hwnd, FALSE) == -1) { 2088 infoPtr->nTool = -1; 2089 infoPtr->nOldTool = -1; 2090 TOOLTIPS_Hide (hwnd, infoPtr); 2091 } 2092 break; 2092 2093 } 2093 2094 return 0; … … 2117 2118 { 2118 2119 LPTT_SUBCLASS_INFO lpttsi = 2119 2120 (LPTT_SUBCLASS_INFO)GetPropA (hwnd, COMCTL32_aSubclass); 2120 2121 TOOLTIPS_INFO *infoPtr; 2121 2122 UINT nTool; 2122 2123 2123 2124 switch (uMsg) { 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 // 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 // 2144 2145 2146 2147 2148 2149 2150 2151 2152 // 2153 2154 2155 2156 2157 2158 // 2159 2160 2161 2162 2163 // 2164 2165 2125 case WM_LBUTTONDOWN: 2126 case WM_LBUTTONUP: 2127 case WM_MBUTTONDOWN: 2128 case WM_MBUTTONUP: 2129 case WM_RBUTTONDOWN: 2130 case WM_RBUTTONUP: 2131 infoPtr = TOOLTIPS_GetInfoPtr(lpttsi->hwndToolTip); 2132 nTool = TOOLTIPS_GetToolFromMessage (infoPtr, hwnd); 2133 2134 // TRACE (tooltips, "subclassed mouse message %04x\n", uMsg); 2135 infoPtr->nOldTool = infoPtr->nTool; 2136 infoPtr->nTool = nTool; 2137 TOOLTIPS_Hide (lpttsi->hwndToolTip, infoPtr); 2138 break; 2139 2140 case WM_MOUSEMOVE: 2141 infoPtr = TOOLTIPS_GetInfoPtr (lpttsi->hwndToolTip); 2142 nTool = TOOLTIPS_GetToolFromMessage (infoPtr, hwnd); 2143 2144 // TRACE (tooltips, "subclassed WM_MOUSEMOVE\n"); 2145 infoPtr->nOldTool = infoPtr->nTool; 2146 infoPtr->nTool = nTool; 2147 2148 if ((infoPtr->bActive) && 2149 (infoPtr->nTool != infoPtr->nOldTool)) { 2150 if (infoPtr->nOldTool == -1) { 2151 SetTimer (hwnd, ID_TIMERSHOW, 2152 infoPtr->nInitialTime, 0); 2153 // TRACE (tooltips, "timer 1 started!\n"); 2154 } 2155 else { 2156 TOOLTIPS_Hide (lpttsi->hwndToolTip, infoPtr); 2157 SetTimer (hwnd, ID_TIMERSHOW, 2158 infoPtr->nReshowTime, 0); 2159 // TRACE (tooltips, "timer 2 started!\n"); 2160 } 2161 } 2162 if (infoPtr->nCurrentTool != -1) { 2163 SetTimer (hwnd, ID_TIMERLEAVE, 100, 0); 2164 // TRACE (tooltips, "timer 3 started!\n"); 2165 } 2166 break; 2166 2167 } 2167 2168 … … 2175 2176 switch (uMsg) 2176 2177 { 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2178 case TTM_ACTIVATE: 2179 return TOOLTIPS_Activate (hwnd, wParam, lParam); 2180 2181 case TTM_ADDTOOLA: 2182 return TOOLTIPS_AddToolA (hwnd, wParam, lParam); 2183 2184 case TTM_ADDTOOLW: 2185 return TOOLTIPS_AddToolW (hwnd, wParam, lParam); 2186 2187 case TTM_DELTOOLA: 2188 return TOOLTIPS_DelToolA (hwnd, wParam, lParam); 2189 2190 case TTM_DELTOOLW: 2191 return TOOLTIPS_DelToolW (hwnd, wParam, lParam); 2192 2193 case TTM_ENUMTOOLSA: 2194 return TOOLTIPS_EnumToolsA (hwnd, wParam, lParam); 2195 2196 case TTM_ENUMTOOLSW: 2197 return TOOLTIPS_EnumToolsW (hwnd, wParam, lParam); 2198 2199 case TTM_GETCURRENTTOOLA: 2200 return TOOLTIPS_GetCurrentToolA (hwnd, wParam, lParam); 2201 2202 case TTM_GETCURRENTTOOLW: 2203 return TOOLTIPS_GetCurrentToolW (hwnd, wParam, lParam); 2204 2205 case TTM_GETDELAYTIME: 2206 return TOOLTIPS_GetDelayTime (hwnd, wParam, lParam); 2207 2208 case TTM_GETMARGIN: 2209 return TOOLTIPS_GetMargin (hwnd, wParam, lParam); 2210 2211 case TTM_GETMAXTIPWIDTH: 2212 return TOOLTIPS_GetMaxTipWidth (hwnd, wParam, lParam); 2213 2214 case TTM_GETTEXTA: 2215 return TOOLTIPS_GetTextA (hwnd, wParam, lParam); 2216 2217 case TTM_GETTEXTW: 2218 return TOOLTIPS_GetTextW (hwnd, wParam, lParam); 2219 2220 case TTM_GETTIPBKCOLOR: 2221 return TOOLTIPS_GetTipBkColor (hwnd, wParam, lParam); 2222 2223 case TTM_GETTIPTEXTCOLOR: 2224 return TOOLTIPS_GetTipTextColor (hwnd, wParam, lParam); 2225 2226 case TTM_GETTOOLCOUNT: 2227 return TOOLTIPS_GetToolCount (hwnd, wParam, lParam); 2228 2229 case TTM_GETTOOLINFOA: 2230 return TOOLTIPS_GetToolInfoA (hwnd, wParam, lParam); 2231 2232 case TTM_GETTOOLINFOW: 2233 return TOOLTIPS_GetToolInfoW (hwnd, wParam, lParam); 2234 2235 case TTM_HITTESTA: 2236 return TOOLTIPS_HitTestA (hwnd, wParam, lParam); 2237 2238 case TTM_HITTESTW: 2239 return TOOLTIPS_HitTestW (hwnd, wParam, lParam); 2240 2241 case TTM_NEWTOOLRECTA: 2242 return TOOLTIPS_NewToolRectA (hwnd, wParam, lParam); 2243 2244 case TTM_NEWTOOLRECTW: 2245 return TOOLTIPS_NewToolRectW (hwnd, wParam, lParam); 2246 2247 case TTM_POP: 2248 return TOOLTIPS_Pop (hwnd, wParam, lParam); 2249 2250 case TTM_RELAYEVENT: 2251 return TOOLTIPS_RelayEvent (hwnd, wParam, lParam); 2252 2253 case TTM_SETDELAYTIME: 2254 return TOOLTIPS_SetDelayTime (hwnd, wParam, lParam); 2255 2256 case TTM_SETMARGIN: 2257 return TOOLTIPS_SetMargin (hwnd, wParam, lParam); 2258 2259 case TTM_SETMAXTIPWIDTH: 2260 return TOOLTIPS_SetMaxTipWidth (hwnd, wParam, lParam); 2261 2262 case TTM_SETTIPBKCOLOR: 2263 return TOOLTIPS_SetTipBkColor (hwnd, wParam, lParam); 2264 2265 case TTM_SETTIPTEXTCOLOR: 2266 return TOOLTIPS_SetTipTextColor (hwnd, wParam, lParam); 2267 2268 case TTM_SETTOOLINFOA: 2269 return TOOLTIPS_SetToolInfoA (hwnd, wParam, lParam); 2270 2271 case TTM_SETTOOLINFOW: 2272 return TOOLTIPS_SetToolInfoW (hwnd, wParam, lParam); 2273 2274 case TTM_TRACKACTIVATE: 2275 return TOOLTIPS_TrackActivate (hwnd, wParam, lParam); 2276 2277 case TTM_TRACKPOSITION: 2278 return TOOLTIPS_TrackPosition (hwnd, wParam, lParam); 2279 2280 case TTM_UPDATE: 2281 return TOOLTIPS_Update (hwnd, wParam, lParam); 2282 2283 case TTM_UPDATETIPTEXTA: 2284 return TOOLTIPS_UpdateTipTextA (hwnd, wParam, lParam); 2285 2286 case TTM_UPDATETIPTEXTW: 2287 return TOOLTIPS_UpdateTipTextW (hwnd, wParam, lParam); 2288 2289 case TTM_WINDOWFROMPOINT: 2290 return TOOLTIPS_WindowFromPoint (hwnd, wParam, lParam); 2291 2292 2293 case WM_CREATE: 2294 return TOOLTIPS_Create (hwnd, wParam, lParam); 2295 2296 case WM_DESTROY: 2297 return TOOLTIPS_Destroy (hwnd, wParam, lParam); 2298 2299 case WM_ERASEBKGND: 2300 return TOOLTIPS_EraseBackground (hwnd, wParam, lParam); 2301 2302 case WM_GETFONT: 2303 return TOOLTIPS_GetFont (hwnd, wParam, lParam); 2303 2304 2304 2305 case WM_GETTEXT: 2305 2306 return TOOLTIPS_OnWMGetText (hwnd, wParam, lParam); 2306 2307 2307 2308 case WM_GETTEXTLENGTH: 2308 2309 return TOOLTIPS_OnWMGetTextLength (hwnd, wParam, lParam); 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 /* 2327 /* 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 // 2344 // 2345 2310 2311 2312 case WM_LBUTTONDOWN: 2313 case WM_LBUTTONUP: 2314 case WM_MBUTTONDOWN: 2315 case WM_MBUTTONUP: 2316 case WM_RBUTTONDOWN: 2317 case WM_RBUTTONUP: 2318 case WM_MOUSEMOVE: 2319 return TOOLTIPS_MouseMessage (hwnd, uMsg, wParam, lParam); 2320 2321 case WM_NCCREATE: 2322 return TOOLTIPS_NCCreate (hwnd, wParam, lParam); 2323 2324 case WM_NCHITTEST: 2325 return TOOLTIPS_NCHitTest (hwnd, wParam, lParam); 2326 2327 /* case WM_NOTIFYFORMAT: */ 2328 /* return TOOLTIPS_NotifyFormat (hwnd, wParam, lParam); */ 2329 2330 case WM_PAINT: 2331 return TOOLTIPS_Paint (hwnd, wParam, lParam); 2332 2333 case WM_SETFONT: 2334 return TOOLTIPS_SetFont (hwnd, wParam, lParam); 2335 2336 case WM_TIMER: 2337 return TOOLTIPS_Timer (hwnd, wParam, lParam); 2338 2339 case WM_WININICHANGE: 2340 return TOOLTIPS_WinIniChange (hwnd, wParam, lParam); 2341 2342 default: 2343 // if (uMsg >= WM_USER) 2344 // ERR (tooltips, "unknown msg %04x wp=%08x lp=%08lx\n", 2345 // uMsg, wParam, lParam); 2346 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 2346 2347 } 2347 2348 return 0; … … 2364 2365 wndClass.hbrBackground = 0; 2365 2366 wndClass.lpszClassName = TOOLTIPS_CLASSA; 2366 2367 2367 2368 RegisterClassA (&wndClass); 2368 2369 } … … 2373 2374 { 2374 2375 if (GlobalFindAtomA (TOOLTIPS_CLASSA)) 2375 2376 } 2377 2376 UnregisterClassA (TOOLTIPS_CLASSA, (HINSTANCE)NULL); 2377 } 2378 -
trunk/src/comctl32/trackbar.c
r109 r110 1 /* $Id: trackbar.c,v 1. 4 1999-06-16 15:29:27cbratschi Exp $ */1 /* $Id: trackbar.c,v 1.5 1999-06-16 20:25:44 cbratschi Exp $ */ 2 2 /* 3 3 * Trackbar control … … 15 15 * - better tic handling. 16 16 * - more notifications. 17 * - implement TRACKBAR_Draw with inUpdate 17 18 * 18 19 */ … … 345 346 } 346 347 347 348 static VOID 349 TRACKBAR_Refresh (HWND hwnd, HDC hdc)348 //draw the trackbar 349 350 static VOID TRACKBAR_Draw(HWND hwnd,HDC hdc,INT lastPos,BOOL inUpdate) 350 351 { 351 352 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd); … … 356 357 357 358 GetClientRect (hwnd, &rcClient); 358 hBrush = CreateSolidBrush (infoPtr->clrBk); 359 FillRect (hdc, &rcClient, hBrush); 360 DeleteObject (hBrush); 359 if (!inUpdate) 360 { 361 hBrush = CreateSolidBrush (infoPtr->clrBk); 362 FillRect (hdc, &rcClient, hBrush); 363 DeleteObject (hBrush); 364 } 361 365 362 366 if (infoPtr->flags & TB_DRAGPOSVALID) { … … 478 482 } 479 483 484 //update display 485 486 static VOID TRACKBAR_Update(HWND hwnd,INT lastPos) 487 { 488 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd); 489 HDC hdc; 490 491 if (infoPtr->flags & TB_DRAGPOSVALID && lastPos == infoPtr->dragPos) return; 492 if (!infoPtr->flags & TB_DRAGPOSVALID && lastPos == infoPtr->nPos) return; 493 hdc = GetDC(hwnd); 494 TRACKBAR_Draw(hwnd,hdc,lastPos,TRUE); 495 ReleaseDC(hwnd,hdc); 496 } 497 498 //redraw everything 499 500 static VOID TRACKBAR_Refresh (HWND hwnd) 501 { 502 HDC hdc; 503 504 hdc = GetDC (hwnd); 505 TRACKBAR_Draw(hwnd,hdc,0,FALSE); 506 ReleaseDC(hwnd,hdc); 507 } 480 508 481 509 static VOID … … 541 569 infoPtr->flags |= TB_SELECTIONCHANGED; 542 570 543 if ((BOOL)wParam) 544 InvalidateRect (hwnd, NULL, FALSE); 571 if ((BOOL)wParam) TRACKBAR_Refresh(hwnd); 545 572 546 573 return 0; … … 559 586 } 560 587 561 if (wParam) 562 InvalidateRect (hwnd, NULL, FALSE); 588 if (wParam) TRACKBAR_Refresh(hwnd); 563 589 564 590 return 0; … … 811 837 TRACKBAR_INFO *infoPtr = TRACKBAR_GetInfoPtr (hwnd); 812 838 839 INT lastPos = infoPtr->nPos; 813 840 infoPtr->nPos = (INT)LOWORD(lParam); 814 841 … … 820 847 infoPtr->flags |= TB_THUMBPOSCHANGED; 821 848 822 if (wParam) 823 InvalidateRect (hwnd, NULL, FALSE); 849 if (wParam) TRACKBAR_Update(hwnd,lastPos); 824 850 825 851 return 0; … … 849 875 TRACKBAR_RecalculateTics (infoPtr); 850 876 851 if (wParam) 852 InvalidateRect (hwnd, NULL, FALSE); 877 if (wParam) TRACKBAR_Refresh(hwnd); 853 878 854 879 return 0; … … 872 897 TRACKBAR_RecalculateTics (infoPtr); 873 898 874 if (wParam) 875 InvalidateRect (hwnd, NULL, FALSE); 899 if (wParam) TRACKBAR_Refresh(hwnd); 876 900 877 901 return 0; … … 895 919 TRACKBAR_RecalculateTics (infoPtr); 896 920 897 if (wParam) 898 InvalidateRect (hwnd, NULL, FALSE); 921 if (wParam) TRACKBAR_Refresh(hwnd); 899 922 900 923 return 0; … … 912 935 TRACKBAR_RecalculateTics (infoPtr); 913 936 914 InvalidateRect (hwnd, NULL, FALSE);937 TRACKBAR_Refresh(hwnd); //CB: necessary? 915 938 916 939 return 0; … … 935 958 infoPtr->nSelMax = infoPtr->nRangeMax; 936 959 937 if (wParam) 938 InvalidateRect (hwnd, NULL, FALSE); 960 if (wParam) TRACKBAR_Refresh(hwnd); 939 961 940 962 … … 957 979 infoPtr->nSelMax = infoPtr->nRangeMax; 958 980 959 if (wParam) 960 InvalidateRect (hwnd, NULL, FALSE); 981 if (wParam) TRACKBAR_Refresh(hwnd); 961 982 962 983 return 0; … … 978 999 infoPtr->nSelMin = infoPtr->nRangeMin; 979 1000 980 if (wParam) 981 InvalidateRect (hwnd, NULL, FALSE); 1001 if (wParam) TRACKBAR_Refresh(hwnd); 982 1002 983 1003 return 0; … … 995 1015 infoPtr->flags |= TB_THUMBSIZECHANGED; 996 1016 997 InvalidateRect (hwnd, NULL, FALSE);1017 TRACKBAR_Refresh(hwnd); 998 1018 999 1019 return 0; … … 1015 1035 infoPtr->tics[infoPtr->uNumTics-1]=nPos; 1016 1036 1017 InvalidateRect (hwnd, NULL, FALSE);1037 TRACKBAR_Refresh(hwnd); 1018 1038 1019 1039 return TRUE; … … 1149 1169 infoPtr->flags &= ~TB_DRAG_MODE; 1150 1170 1151 InvalidateRect (hwnd, NULL, FALSE);1171 TRACKBAR_Refresh(hwnd); //CB: make changes here 1152 1172 1153 1173 return 0; … … 1215 1235 if (prevPos!=infoPtr->nPos) { 1216 1236 infoPtr->flags |= TB_THUMBPOSCHANGED; 1217 InvalidateRect (hwnd, NULL, FALSE);1237 TRACKBAR_Update(hwnd,prevPos); 1218 1238 } 1219 1239 … … 1247 1267 } 1248 1268 1249 InvalidateRect (hwnd, NULL, FALSE);1269 //TRACKBAR_Refresh(hwnd); //CB: nothing changed 1250 1270 1251 1271 return 0; … … 1259 1279 1260 1280 if (infoPtr->flags & TB_DRAGPOSVALID) { 1281 int lastPos = infoPtr->nPos; 1261 1282 infoPtr->nPos=infoPtr->dragPos; 1262 InvalidateRect (hwnd, NULL, FALSE);1283 TRACKBAR_Update(hwnd,lastPos); 1263 1284 } 1264 1285 … … 1277 1298 1278 1299 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam; 1279 TRACKBAR_ Refresh (hwnd, hdc);1300 TRACKBAR_Draw(hwnd,hdc,0,FALSE); 1280 1301 if(!wParam) 1281 1302 EndPaint (hwnd, &ps); … … 1292 1313 infoPtr->bFocus = TRUE; 1293 1314 1294 InvalidateRect (hwnd, NULL, FALSE);1315 TRACKBAR_Refresh(hwnd); //CB: make changes here 1295 1316 1296 1317 return 0; … … 1332 1353 DOUBLE dragPos; 1333 1354 char buf[80]; 1355 INT lastDragPos; 1334 1356 1335 1357 // TRACE (trackbar, "%x\n",wParam); … … 1344 1366 1345 1367 SetCapture (hwnd); 1368 lastDragPos = infoPtr->dragPos; 1346 1369 dragPos = TRACKBAR_ConvertPlaceToPosition (infoPtr, clickPlace, 1347 1370 dwStyle & TBS_VERT); … … 1377 1400 } 1378 1401 1379 InvalidateRect (hwnd, NULL, FALSE);1402 TRACKBAR_Update(hwnd,lastDragPos); 1380 1403 UpdateWindow (hwnd); 1381 1404 … … 1438 1461 if (pos!=infoPtr->nPos) { 1439 1462 infoPtr->flags |=TB_THUMBPOSCHANGED; 1440 InvalidateRect (hwnd, NULL, FALSE);1463 TRACKBAR_Update(hwnd,pos); 1441 1464 } 1442 1465 -
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 -
trunk/src/comctl32/updown.c
r94 r110 1 /* $Id: updown.c,v 1. 3 1999-06-10 16:22:04 achimhaExp $ */2 /* 1 /* $Id: updown.c,v 1.4 1999-06-16 20:25:45 cbratschi Exp $ */ 2 /* 3 3 * Updown control 4 4 * 5 5 * Copyright 1997 Dimitrie O. Paun 6 6 * Copyright 1999 Achim Hasenmueller 7 * Copyright 1999 Christoph Bratschi 7 8 * 8 9 * TODO: … … 67 68 //#define UNKNOWN_PARAM(msg, wParam, lParam) WARN(updown, \ 68 69 // "UpDown Ctrl: Unknown parameter(s) for message " #msg \ 69 // 70 // "(%04x): wp=%04x lp=%08lx\n", msg, wParam, lParam); 70 71 #define UNKNOWN_PARAM(msg, wParam, lParam) 71 72 … … 101 102 { 102 103 delta += (delta < 0 ? -1 : 1) * 103 104 105 104 (infoPtr->MaxVal < infoPtr->MinVal ? -1 : 1) * 105 (infoPtr->MinVal - infoPtr->MaxVal) + 106 (delta < 0 ? 1 : -1); 106 107 } 107 108 else … … 119 120 * incr - TRUE get the "increment" rect (up or right) 120 121 * FALSE get the "decrement" rect (down or left) 121 * 122 * 122 123 */ 123 124 static void UPDOWN_GetArrowRect (HWND hwnd, RECT *rect, BOOL incr) … … 130 131 len = rect->right - rect->left; /* compute the width */ 131 132 if (incr) 132 rect->left = len/2+1; 133 rect->left = len/2+1; 133 134 else 134 135 rect->right = len/2; … … 169 170 char sep[2]; 170 171 171 if(GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, 172 172 if(GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, 173 sep, sizeof(sep)) != 1) 173 174 return ','; 174 175 … … 204 205 return FALSE; 205 206 206 sep = UPDOWN_GetThousandSep(); 207 sep = UPDOWN_GetThousandSep(); 207 208 208 209 /* now get rid of the separators */ 209 210 for(src = dst = txt; *src; src++) 210 211 if(*src != sep) 211 212 *dst++ = *src; 212 213 *dst = 0; 213 214 214 215 /* try to convert the number and validate it */ 215 216 newVal = strtol(txt, &src, infoPtr->Base); 216 if(*src || !UPDOWN_InBounds (hwnd, newVal)) 217 if(*src || !UPDOWN_InBounds (hwnd, newVal)) 217 218 return FALSE; 218 219 219 // TRACE(updown, "new value(%d) read from buddy (old=%d)\n", 220 // 221 } 222 220 // TRACE(updown, "new value(%d) read from buddy (old=%d)\n", 221 // newVal, infoPtr->CurVal); 222 } 223 223 224 infoPtr->CurVal = newVal; 224 225 return TRUE; … … 239 240 int len; 240 241 241 if (!IsWindow(infoPtr->Buddy)) 242 if (!IsWindow(infoPtr->Buddy)) 242 243 return FALSE; 243 244 244 245 // TRACE(updown, "set new value(%d) to buddy.\n", 245 // 246 // infoPtr->CurVal); 246 247 247 248 /*if the buddy is a list window, we must set curr index */ … … 252 253 len = sprintf(txt1, (infoPtr->Base==16) ? "%X" : "%d", infoPtr->CurVal); 253 254 254 sep = UPDOWN_GetThousandSep(); 255 sep = UPDOWN_GetThousandSep(); 255 256 256 257 /* Do thousands seperation if necessary */ … … 258 259 char txt2[20], *src = txt1, *dst = txt2; 259 260 if(len%3 > 0){ 260 lstrcpynA (dst, src, len%3 + 1); /* need to include the null */ 261 262 261 lstrcpynA (dst, src, len%3 + 1); /* need to include the null */ 262 dst += len%3; 263 src += len%3; 263 264 } 264 265 for(len=0; *src; len++){ 265 266 267 266 if(len%3==0) 267 *dst++ = sep; 268 *dst++ = *src++; 268 269 } 269 270 *dst = 0; /* null terminate it */ … … 274 275 275 276 return TRUE; 276 } 277 } 277 278 278 279 /*********************************************************************** … … 287 288 BOOL prssed; 288 289 RECT rect; 289 290 290 291 /* Draw the incr button */ 291 292 UPDOWN_GetArrowRect (hwnd, &rect, TRUE); 292 293 prssed = (infoPtr->Flags & FLAG_INCR) && (infoPtr->Flags & FLAG_MOUSEIN); 293 DrawFrameControl(hdc, &rect, DFC_SCROLL, 294 295 296 294 DrawFrameControl(hdc, &rect, DFC_SCROLL, 295 (dwStyle & UDS_HORZ ? DFCS_SCROLLLEFT : DFCS_SCROLLUP) | 296 (prssed ? DFCS_PUSHED : 0) | 297 (dwStyle&WS_DISABLED ? DFCS_INACTIVE : 0) ); 297 298 298 299 /* Draw the space between the buttons */ 299 300 rect.top = rect.bottom; rect.bottom++; 300 301 DrawEdge(hdc, &rect, 0, BF_MIDDLE); 301 302 302 303 /* Draw the decr button */ 303 304 UPDOWN_GetArrowRect(hwnd, &rect, FALSE); 304 305 prssed = (infoPtr->Flags & FLAG_DECR) && (infoPtr->Flags & FLAG_MOUSEIN); 305 DrawFrameControl(hdc, &rect, DFC_SCROLL, 306 307 308 306 DrawFrameControl(hdc, &rect, DFC_SCROLL, 307 (dwStyle & UDS_HORZ ? DFCS_SCROLLRIGHT : DFCS_SCROLLDOWN) | 308 (prssed ? DFCS_PUSHED : 0) | 309 (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) ); 309 310 } 310 311 … … 318 319 { 319 320 HDC hdc; 320 321 321 322 hdc = GetDC (hwnd); 322 323 UPDOWN_Draw (hwnd, hdc); … … 335 336 PAINTSTRUCT ps; 336 337 HDC hdc; 337 338 338 339 hdc = BeginPaint (hwnd, &ps); 339 340 UPDOWN_Draw (hwnd, hdc); … … 345 346 * Tests if 'hwndBud' is a valid window handle. If not, returns FALSE. 346 347 * Else, sets it as a new Buddy. 347 * Then, it should subclass the buddy 348 * Then, it should subclass the buddy 348 349 * If window has the UDS_ARROWKEYS, it subcalsses the buddy window to 349 350 * process the UP/DOWN arrow keys. … … 353 354 static BOOL UPDOWN_SetBuddy (HWND hwnd, HWND hwndBud) 354 355 { 355 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd); 356 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd); 356 357 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 357 358 RECT budRect; /* new coord for the buddy */ 358 359 int x; /* new x position and width for the up-down */ 359 360 360 361 *infoPtr->szBuddyClass = '\0'; 361 362 … … 380 381 GetWindowRect(infoPtr->Buddy, &budRect); 381 382 MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->Buddy), 382 383 (POINT *)(&budRect.left), 2); 383 384 384 385 /* now do the positioning */ … … 394 395 /* first adjust the buddy to accomodate the up/down */ 395 396 SetWindowPos(infoPtr->Buddy, 0, budRect.left, budRect.top, 396 budRect.right - budRect.left, budRect.bottom - budRect.top, 397 397 budRect.right - budRect.left, budRect.bottom - budRect.top, 398 SWP_NOACTIVATE|SWP_NOZORDER); 398 399 399 400 /* now position the up/down */ … … 402 403 403 404 SetWindowPos (hwnd, 0, x, budRect.top-DEFAULT_ADDTOP,DEFAULT_WIDTH, 404 405 405 (budRect.bottom-budRect.top)+DEFAULT_ADDTOP+DEFAULT_ADDBOT, 406 SWP_NOACTIVATE|SWP_NOZORDER); 406 407 407 408 return TRUE; 408 } 409 } 409 410 410 411 /*********************************************************************** 411 412 * UPDOWN_DoAction 412 413 * 413 * This function increments/decrements the CurVal by the 414 * This function increments/decrements the CurVal by the 414 415 * 'delta' amount according to the 'incr' flag 415 416 * It notifies the parent as required. … … 419 420 static void UPDOWN_DoAction (HWND hwnd, int delta, BOOL incr) 420 421 { 421 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd); 422 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd); 422 423 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 423 424 int old_val = infoPtr->CurVal; … … 440 441 ni.hdr.hwndFrom = hwnd; 441 442 ni.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 442 ni.hdr.code = UDN_DELTAPOS; 443 ni.hdr.code = UDN_DELTAPOS; 443 444 if (SendMessageA(GetParent (hwnd), WM_NOTIFY, 444 445 (WPARAM)ni.hdr.idFrom, (LPARAM)&ni)) 445 446 return; /* we are not allowed to change */ 446 447 447 448 /* Now adjust value with (maybe new) delta */ 448 449 if (!UPDOWN_OffsetVal (hwnd, ni.iDelta)) … … 450 451 451 452 /* Now take care about our buddy */ 452 if(!IsWindow(infoPtr->Buddy)) 453 if(!IsWindow(infoPtr->Buddy)) 453 454 return; /* Nothing else to do */ 454 455 … … 461 462 we do not have the UDS_SETBUDDYINT style set? */ 462 463 463 SendMessageA (GetParent (hwnd), 464 dwStyle & UDS_HORZ ? WM_HSCROLL : WM_VSCROLL, 465 466 464 SendMessageA (GetParent (hwnd), 465 dwStyle & UDS_HORZ ? WM_HSCROLL : WM_VSCROLL, 466 MAKELONG(incr ? SB_LINEUP : SB_LINEDOWN, infoPtr->CurVal), 467 hwnd); 467 468 } 468 469 … … 487 488 * Deletes any timers, releases the mouse and does redraw if necessary. 488 489 * If the control is not in "capture" mode, it does nothing. 489 * If the control was not in cancel mode, it returns FALSE. 490 * If the control was not in cancel mode, it returns FALSE. 490 491 * If the control was in cancel mode, it returns TRUE. 491 492 */ … … 493 494 { 494 495 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd); 495 496 496 497 /* if not in 'capture' mode, do nothing */ 497 498 if(!(infoPtr->Flags & FLAG_CLICKED)) … … 500 501 KillTimer (hwnd, TIMERID1); /* kill all possible timers */ 501 502 KillTimer (hwnd, TIMERID2); 502 503 503 504 if (GetCapture() == hwnd) /* let the mouse go */ 504 ReleaseCapture(); /* if we still have it */ 505 505 ReleaseCapture(); /* if we still have it */ 506 506 507 infoPtr->Flags = 0; /* get rid of any flags */ 507 508 UPDOWN_Refresh (hwnd); /* redraw the control just in case */ 508 509 509 510 return TRUE; 510 511 } … … 515 516 * Handle a mouse event for the updown. 516 517 * 'pt' is the location of the mouse event in client or 517 * windows coordinates. 518 * windows coordinates. 518 519 */ 519 520 static void UPDOWN_HandleMouseEvent (HWND hwnd, UINT msg, POINT pt) … … 529 530 /* If we are already in the 'clicked' mode, then nothing to do */ 530 531 if(infoPtr->Flags & FLAG_CLICKED) 531 532 return; 532 533 533 534 /* If the buddy is an edit, will set focus to it */ 534 535 if (!lstrcmpA (infoPtr->szBuddyClass, "Edit")) 535 536 SetFocus(infoPtr->Buddy); 536 537 537 538 /* Now see which one is the 'active' arrow */ … … 540 541 /* Update the CurVal if necessary */ 541 542 if (dwStyle & UDS_SETBUDDYINT) 542 543 543 UPDOWN_GetBuddyInt (hwnd); 544 544 545 /* Before we proceed, see if we can spin... */ 545 546 if(!(dwStyle & UDS_WRAP)) 546 547 548 547 if(( temp && infoPtr->CurVal==infoPtr->MaxVal) || 548 (!temp && infoPtr->CurVal==infoPtr->MinVal)) 549 return; 549 550 550 551 /* Set up the correct flags */ 551 infoPtr->Flags = 0; 552 infoPtr->Flags = 0; 552 553 infoPtr->Flags |= temp ? FLAG_INCR : FLAG_DECR; 553 554 infoPtr->Flags |= FLAG_MOUSEIN; 554 555 555 556 /* repaint the control */ 556 557 UPDOWN_Refresh (hwnd); … … 563 564 564 565 /* and startup the first timer */ 565 SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 566 SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 566 567 break; 567 568 … … 569 570 /* If we are not in the 'clicked' mode, then nothing to do */ 570 571 if(!(infoPtr->Flags & FLAG_CLICKED)) 571 572 return; 572 573 573 574 /* save the flags to see if any got modified */ … … 576 577 /* Now get the 'active' arrow rectangle */ 577 578 if (infoPtr->Flags & FLAG_INCR) 578 579 UPDOWN_GetArrowRect (hwnd, &rect, TRUE); 579 580 else 580 581 UPDOWN_GetArrowRect (hwnd, &rect, FALSE); 581 582 582 583 /* Update the flags if we are in/out */ 583 584 if(PtInRect(&rect, pt)) 584 585 infoPtr->Flags |= FLAG_MOUSEIN; 585 586 else{ 586 587 588 587 infoPtr->Flags &= ~FLAG_MOUSEIN; 588 if(accelIndex != -1) /* if we have accel info */ 589 accelIndex = 0; /* reset it */ 589 590 } 590 591 /* If state changed, redraw the control */ 591 592 if(temp != infoPtr->Flags) 592 593 UPDOWN_Refresh (hwnd); 593 594 break; 594 595 595 596 default: 596 // 597 // ERR(updown, "Impossible case!\n"); 597 598 break; 598 599 } … … 604 605 */ 605 606 LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, 606 607 LPARAM lParam) 607 608 { 608 609 UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd); … … 622 623 623 624 /* initialize the info struct */ 624 infoPtr->AccelCount=0; infoPtr->AccelVect=0; 625 infoPtr->AccelCount=0; infoPtr->AccelVect=0; 625 626 infoPtr->CurVal=0; infoPtr->MinVal=0; infoPtr->MaxVal=100; /*FIXME*/ 626 627 infoPtr->Base = 10; /* Default to base 10 */ … … 630 631 /* Do we pick the buddy win ourselves? */ 631 632 if (dwStyle & UDS_AUTOBUDDY) 632 633 633 UPDOWN_SetBuddy (hwnd, GetWindow (hwnd, GW_HWNDPREV)); 634 634 635 // TRACE(updown, "UpDown Ctrl creation, hwnd=%04x\n", hwnd); 635 636 break; 636 637 637 638 case WM_DESTROY: 638 639 if(infoPtr->AccelVect) 639 640 COMCTL32_Free (infoPtr->AccelVect); 640 641 641 642 COMCTL32_Free (infoPtr); … … 643 644 // TRACE(updown, "UpDown Ctrl destruction, hwnd=%04x\n", hwnd); 644 645 break; 645 646 646 647 case WM_ENABLE: 647 648 if (dwStyle & WS_DISABLED) 648 649 UPDOWN_CancelMode (hwnd); 649 650 UPDOWN_Paint (hwnd); 650 651 break; … … 653 654 /* if initial timer, kill it and start the repeat timer */ 654 655 if(wParam == TIMERID1){ 655 656 657 658 659 660 661 662 663 664 665 656 KillTimer(hwnd, TIMERID1); 657 /* if no accel info given, used default timer */ 658 if(infoPtr->AccelCount==0 || infoPtr->AccelVect==0){ 659 accelIndex = -1; 660 temp = REPEAT_DELAY; 661 } 662 else{ 663 accelIndex = 0; /* otherwise, use it */ 664 temp = infoPtr->AccelVect[accelIndex].nSec * 1000 + 1; 665 } 666 SetTimer(hwnd, TIMERID2, temp, 0); 666 667 } 667 668 668 669 /* now, if the mouse is above us, do the thing...*/ 669 670 if(infoPtr->Flags & FLAG_MOUSEIN){ 670 671 672 673 674 675 676 677 678 SetTimer(hwnd, TIMERID2, temp, 0); 679 671 temp = accelIndex==-1 ? 1 : infoPtr->AccelVect[accelIndex].nInc; 672 UPDOWN_DoAction(hwnd, temp, infoPtr->Flags & FLAG_INCR); 673 674 if(accelIndex!=-1 && accelIndex < infoPtr->AccelCount-1){ 675 KillTimer(hwnd, TIMERID2); 676 accelIndex++; /* move to the next accel info */ 677 temp = infoPtr->AccelVect[accelIndex].nSec * 1000 + 1; 678 /* make sure we have at least 1ms intervals */ 679 SetTimer(hwnd, TIMERID2, temp, 0); 680 } 680 681 } 681 682 break; … … 687 688 case WM_LBUTTONUP: 688 689 if(!UPDOWN_CancelMode(hwnd)) 689 690 break; 690 691 /*If we released the mouse and our buddy is an edit */ 691 692 /* we must select all text in it. */ 692 693 if (!lstrcmpA (infoPtr->szBuddyClass, "Edit")) 693 694 break; 695 694 SendMessageA(infoPtr->Buddy, EM_SETSEL, 0, MAKELONG(0, -1)); 695 break; 696 696 697 case WM_LBUTTONDOWN: 697 698 case WM_MOUSEMOVE: 698 699 if(UPDOWN_IsEnabled(hwnd)){ 699 700 701 700 POINT pt; 701 CONV_POINT16TO32( (POINT16 *)&lParam, &pt ); 702 UPDOWN_HandleMouseEvent (hwnd, message, pt ); 702 703 } 703 704 break; … … 705 706 case WM_KEYDOWN: 706 707 if((dwStyle & UDS_ARROWKEYS) && UPDOWN_IsEnabled(hwnd)){ 707 708 case VK_UP: 709 710 711 712 713 714 } 715 break; 716 708 switch(wParam){ 709 case VK_UP: 710 case VK_DOWN: 711 UPDOWN_GetBuddyInt (hwnd); 712 UPDOWN_DoAction (hwnd, 1, wParam==VK_UP); 713 break; 714 } 715 } 716 break; 717 717 718 case WM_PAINT: 718 719 UPDOWN_Paint (hwnd); 719 720 break; 720 721 721 722 case UDM_GETACCEL: 722 723 if (wParam==0 && lParam==0) /*if both zero, */ 723 724 return infoPtr->AccelCount; /*just return the accel count*/ 724 725 if (wParam || lParam){ 725 726 726 UNKNOWN_PARAM(UDM_GETACCEL, wParam, lParam); 727 return 0; 727 728 } 728 729 temp = MIN(infoPtr->AccelCount, wParam); … … 733 734 // TRACE(updown, "UpDown Ctrl new accel info, hwnd=%04x\n", hwnd); 734 735 if(infoPtr->AccelVect){ 735 736 737 736 COMCTL32_Free (infoPtr->AccelVect); 737 infoPtr->AccelCount = 0; 738 infoPtr->AccelVect = 0; 738 739 } 739 740 if(wParam==0) 740 741 return TRUE; 741 742 infoPtr->AccelVect = COMCTL32_Alloc (wParam*sizeof(UDACCEL)); 742 743 if(infoPtr->AccelVect==0) 743 744 return FALSE; 744 745 memcpy(infoPtr->AccelVect, (void*)lParam, wParam*sizeof(UDACCEL)); 745 746 return TRUE; … … 747 748 case UDM_GETBASE: 748 749 if (wParam || lParam) 749 750 UNKNOWN_PARAM(UDM_GETBASE, wParam, lParam); 750 751 return infoPtr->Base; 751 752 752 753 case UDM_SETBASE: 753 // TRACE(updown, "UpDown Ctrl new base(%d), hwnd=%04x\n", 754 // 754 // TRACE(updown, "UpDown Ctrl new base(%d), hwnd=%04x\n", 755 // wParam, hwnd); 755 756 if ( !(wParam==10 || wParam==16) || lParam) 756 757 UNKNOWN_PARAM(UDM_SETBASE, wParam, lParam); 757 758 if (wParam==10 || wParam==16){ 758 759 760 759 temp = infoPtr->Base; 760 infoPtr->Base = wParam; 761 return temp; /* return the prev base */ 761 762 } 762 763 break; … … 764 765 case UDM_GETBUDDY: 765 766 if (wParam || lParam) 766 767 UNKNOWN_PARAM(UDM_GETBUDDY, wParam, lParam); 767 768 return infoPtr->Buddy; 768 769 769 770 case UDM_SETBUDDY: 770 771 if (lParam) 771 772 UNKNOWN_PARAM(UDM_SETBUDDY, wParam, lParam); 772 773 temp = infoPtr->Buddy; 773 774 infoPtr->Buddy = wParam; 774 775 UPDOWN_SetBuddy (hwnd, wParam); 775 // TRACE(updown, "UpDown Ctrl new buddy(%04x), hwnd=%04x\n", 776 // 776 // TRACE(updown, "UpDown Ctrl new buddy(%04x), hwnd=%04x\n", 777 // infoPtr->Buddy, hwnd); 777 778 return temp; 778 779 779 780 case UDM_GETPOS: 780 781 if (wParam || lParam) 781 782 UNKNOWN_PARAM(UDM_GETPOS, wParam, lParam); 782 783 temp = UPDOWN_GetBuddyInt (hwnd); 783 784 return MAKELONG(infoPtr->CurVal, temp ? 0 : 1); … … 785 786 case UDM_SETPOS: 786 787 if (wParam || HIWORD(lParam)) 787 788 UNKNOWN_PARAM(UDM_GETPOS, wParam, lParam); 788 789 temp = SLOWORD(lParam); 789 790 // TRACE(updown, "UpDown Ctrl new value(%d), hwnd=%04x\n", 790 // 791 // temp, hwnd); 791 792 if(!UPDOWN_InBounds(hwnd, temp)){ 792 if(temp < infoPtr->MinVal) 793 794 795 793 if(temp < infoPtr->MinVal) 794 temp = infoPtr->MinVal; 795 if(temp > infoPtr->MaxVal) 796 temp = infoPtr->MaxVal; 796 797 } 797 798 wParam = infoPtr->CurVal; /* save prev value */ 798 799 infoPtr->CurVal = temp; /* set the new value */ 799 800 if(dwStyle & UDS_SETBUDDYINT) 800 801 UPDOWN_SetBuddyInt (hwnd); 801 802 return wParam; /* return prev value */ 802 803 803 804 case UDM_GETRANGE: 804 805 if (wParam || lParam) 805 806 UNKNOWN_PARAM(UDM_GETRANGE, wParam, lParam); 806 807 return MAKELONG(infoPtr->MaxVal, infoPtr->MinVal); 807 808 808 809 case UDM_SETRANGE: 809 810 if (wParam) 810 811 UNKNOWN_PARAM(UDM_SETRANGE, wParam, lParam); /* we must have: */ 811 812 infoPtr->MaxVal = SLOWORD(lParam); /* UD_MINVAL <= Max <= UD_MAXVAL */ 812 813 infoPtr->MinVal = SHIWORD(lParam); /* UD_MINVAL <= Min <= UD_MAXVAL */ 813 814 /* |Max-Min| <= UD_MAXVAL */ 814 // TRACE(updown, "UpDown Ctrl new range(%d to %d), hwnd=%04x\n", 815 // 816 break; 815 // TRACE(updown, "UpDown Ctrl new range(%d to %d), hwnd=%04x\n", 816 // infoPtr->MinVal, infoPtr->MaxVal, hwnd); 817 break; 817 818 818 819 case UDM_GETRANGE32: 819 820 if (wParam) 820 821 *(LPINT)wParam = infoPtr->MinVal; 821 822 if (lParam) 822 823 *(LPINT)lParam = infoPtr->MaxVal; 823 824 break; 824 825 … … 827 828 infoPtr->MaxVal = (INT)lParam; 828 829 if (infoPtr->MaxVal <= infoPtr->MinVal) 829 830 // TRACE(updown, "UpDown Ctrl new range(%d to %d), hwnd=%04x\n", 831 // 832 break; 833 834 default: 835 if (message >= WM_USER) 836 // ERR (updown, "unknown msg %04x wp=%04x lp=%08lx\n",837 // 838 return DefWindowProcA (hwnd, message, wParam, lParam); 839 } 830 infoPtr->MaxVal = infoPtr->MinVal + 1; 831 // TRACE(updown, "UpDown Ctrl new range(%d to %d), hwnd=%04x\n", 832 // infoPtr->MinVal, infoPtr->MaxVal, hwnd); 833 break; 834 835 default: 836 // if (message >= WM_USER) 837 // ERR (updown, "unknown msg %04x wp=%04x lp=%08lx\n", 838 // message, wParam, lParam); 839 return DefWindowProcA (hwnd, message, wParam, lParam); 840 } 840 841 841 842 return 0; … … 844 845 845 846 /*********************************************************************** 846 * UPDOWN_Register[Internal]847 * UPDOWN_Register [Internal] 847 848 * 848 849 * Registers the updown window class. … … 864 865 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); 865 866 wndClass.lpszClassName = UPDOWN_CLASSA; 866 867 867 868 RegisterClassA( &wndClass ); 868 869 } … … 870 871 871 872 /*********************************************************************** 872 * UPDOWN_Unregister[Internal]873 * UPDOWN_Unregister [Internal] 873 874 * 874 875 * Unregisters the updown window class. … … 879 880 { 880 881 if (GlobalFindAtomA (UPDOWN_CLASSA)) 881 882 } 883 882 UnregisterClassA (UPDOWN_CLASSA, (HINSTANCE)NULL); 883 } 884 -
trunk/src/kernel32/winmod.cpp
r99 r110 1 /* $Id: winmod.cpp,v 1. 3 1999-06-10 19:09:05 phallerExp $ */1 /* $Id: winmod.cpp,v 1.4 1999-06-16 20:25:45 cbratschi Exp $ */ 2 2 3 3 /* … … 67 67 curnid = (NameId *)((char *)curnid + sizeof(NameId) + strlen(curnid->name)); 68 68 } 69 69 70 //try upper case search 70 71 //SvL: Copy it, since string might be located in readonly object 71 upname = (char *)malloc(strlen(lpszName)+1); 72 73 upname = (char *)malloc(strlen(lpszName)+1); //CB: Trap with MFC Toolbar/UpDown samples 72 74 strcpy(upname, lpszName); 73 75 UpCase(upname);
Note:
See TracChangeset
for help on using the changeset viewer.