Changeset 6705 for trunk/src/comctl32
- Timestamp:
- Sep 15, 2001, 11:13:31 AM (24 years ago)
- Location:
- trunk/src/comctl32
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/animate.c
r6644 r6705 1 1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */ 2 /* $Id: animate.c,v 1.14 2001-09-05 12:04:56 bird Exp $ */3 2 /* 4 3 * Animation control -
trunk/src/comctl32/comboex.c
r6644 r6705 1 /* $Id: comboex.c,v 1.12 2001-09-05 12:04:56 bird Exp $ */2 1 /* 3 2 * TODO <------------- -
trunk/src/comctl32/comctl32.c
r6644 r6705 1 /* $Id: comctl32.c,v 1.18 2001-09-05 12:04:56 bird Exp $ */2 1 /* 3 2 * Common controls functions -
trunk/src/comctl32/comctl32undoc.c
r6644 r6705 1 /* $Id: comctl32undoc.c,v 1.22 2001-09-05 12:04:57 bird Exp $ */2 1 /* 3 2 * Undocumented functions from COMCTL32.DLL -
trunk/src/comctl32/datetime.c
r6644 r6705 1 /* $Id: datetime.c,v 1.18 2001-09-05 12:04:57 bird Exp $ */2 1 /* 3 2 * Date and time picker control -
trunk/src/comctl32/flatsb.c
r6644 r6705 1 /* $Id: flatsb.c,v 1.10 2001-09-05 12:04:58 bird Exp $ */2 1 /* 3 2 * Flat Scrollbar control -
trunk/src/comctl32/imagelist.c
r6644 r6705 1 /* $Id: imagelist.c,v 1.15 2001-09-05 12:04:58 bird Exp $ */2 1 /* 3 2 * ImageList implementation -
trunk/src/comctl32/listview.c
r6644 r6705 1 /* $Id: listview.c,v 1.33 2001-09-05 12:04:59 bird Exp $ */2 1 /* 3 2 * Listview control -
trunk/src/comctl32/monthcal.c
r6644 r6705 1 /* $Id: monthcal.c,v 1.12 2001-09-05 12:05:00 bird Exp $ */2 1 /* Month calendar control 3 2 * -
trunk/src/comctl32/pager.c
r6644 r6705 1 /* $Id: pager.c,v 1.9 2001-09-05 12:05:01 bird Exp $ */2 1 /* 3 2 * Pager control … … 21 20 #include "debugtools.h" 22 21 22 DEFAULT_DEBUG_CHANNEL(pager); 23 23 24 #ifdef __WIN32OS2__ 24 25 #include "ccbase.h" 26 #undef inline 25 27 #define inline 26 28 #endif 27 28 DEFAULT_DEBUG_CHANNEL(pager);29 29 30 30 typedef struct … … 40 40 INT nPos; /* scroll position */ 41 41 INT nWidth; /* from child wnd's response to PGN_CALCSIZE */ 42 INT nHeight; /* from child wnd's response to PGN_CALCSIZE */ 42 INT nHeight; /* from child wnd's response to PGN_CALCSIZE */ 43 43 BOOL bForward; /* forward WM_MOUSEMOVE msgs to the contained wnd */ 44 44 INT TLbtnState; /* state of top or left btn */ … … 58 58 #define REPEAT_DELAY 50 59 59 60 /* the horizontal arrows are: 60 /* the horizontal arrows are: 61 61 * 62 62 * 01234 01234 … … 67 67 * 5 ** ** 68 68 * 6 * * 69 * 7 69 * 7 70 70 * 71 71 */ … … 75 75 INT x, y, w, h; 76 76 HPEN hOldPen; 77 77 78 78 w = r.right - r.left + 1; 79 79 h = r.bottom - r.top + 1; … … 108 108 } 109 109 110 /* the vertical arrows are: 110 /* the vertical arrows are: 111 111 * 112 112 * 01234567 01234567 113 * 1****** ** 113 * 1****** ** 114 114 * 2 **** **** 115 115 * 3 ** ****** … … 122 122 INT x, y, w, h; 123 123 HPEN hOldPen; 124 124 125 125 w = r.right - r.left + 1; 126 126 h = r.bottom - r.top + 1; … … 166 166 167 167 if ((rc.right - rc.left <= 0) || (rc.bottom - rc.top <= 0)) 168 return; 168 return; 169 169 170 170 hBrush = CreateSolidBrush(clrBk); … … 173 173 FillRect(hdc, &rc, hBrush); 174 174 175 if (btnState == PGF_HOT) 175 if (btnState == PGF_HOT) 176 176 { 177 177 DrawEdge( hdc, &rc, BDR_RAISEDINNER, BF_RECT); … … 181 181 PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft); 182 182 } 183 else if (btnState == PGF_NORMAL) 183 else if (btnState == PGF_NORMAL) 184 184 { 185 185 DrawEdge (hdc, &rc, BDR_OUTER, BF_FLAT); … … 189 189 PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft); 190 190 } 191 else if (btnState == PGF_DEPRESSED) 191 else if (btnState == PGF_DEPRESSED) 192 192 { 193 193 DrawEdge( hdc, &rc, BDR_SUNKENOUTER, BF_RECT); … … 197 197 PAGER_DrawVertArrow(hdc, rc, COLOR_WINDOWFRAME, topLeft); 198 198 } 199 else if (btnState == PGF_GRAYED) 199 else if (btnState == PGF_GRAYED) 200 200 { 201 201 DrawEdge (hdc, &rc, BDR_OUTER, BF_FLAT); … … 234 234 PAGER_GetButtonState (HWND hwnd, WPARAM wParam, LPARAM lParam) 235 235 { 236 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 236 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 237 237 LRESULT btnState = PGF_INVISIBLE; 238 238 INT btn = (INT)lParam; … … 251 251 PAGER_GetPos(HWND hwnd) 252 252 { 253 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 253 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 254 254 TRACE("[%04x] returns %d\n", hwnd, infoPtr->nPos); 255 255 return (LRESULT)infoPtr->nPos; … … 259 259 PAGER_GetButtonSize(HWND hwnd) 260 260 { 261 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 261 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 262 262 TRACE("[%04x] returns %d\n", hwnd, infoPtr->nButtonSize); 263 263 return (LRESULT)infoPtr->nButtonSize; … … 267 267 PAGER_GetBorder(HWND hwnd) 268 268 { 269 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 269 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 270 270 TRACE("[%04x] returns %d\n", hwnd, infoPtr->nBorder); 271 271 return (LRESULT)infoPtr->nBorder; … … 275 275 PAGER_GetBkColor(HWND hwnd) 276 276 { 277 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 277 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 278 278 TRACE("[%04x] returns %06lx\n", hwnd, infoPtr->clrBk); 279 279 return (LRESULT)infoPtr->clrBk; 280 280 } 281 281 282 static void 283 PAGER_CalcSize (HWND hwnd, INT* size, BOOL getWidth) 282 static void 283 PAGER_CalcSize (HWND hwnd, INT* size, BOOL getWidth) 284 284 { 285 285 NMPGCALCSIZE nmpgcs; … … 291 291 nmpgcs.iWidth = getWidth ? *size : 0; 292 292 nmpgcs.iHeight = getWidth ? 0 : *size; 293 SendMessageA ( hwnd, WM_NOTIFY,293 SendMessageA (GetParent (hwnd), WM_NOTIFY, 294 294 (WPARAM)nmpgcs.hdr.idFrom, (LPARAM)&nmpgcs); 295 295 … … 334 334 infoPtr->nHeight = wndSize; 335 335 336 TRACE("[%04x] SWP %dx%d at (%d,%d)\n", hwnd, 336 TRACE("[%04x] SWP %dx%d at (%d,%d)\n", hwnd, 337 337 infoPtr->nWidth, infoPtr->nHeight, 338 338 0, -nPos); … … 380 380 } 381 381 382 static void 382 static void 383 383 PAGER_GrayAndRestoreBtns(PAGER_INFO* infoPtr, INT scrollRange, 384 384 BOOL* needsResize, BOOL* needsRepaint) … … 417 417 418 418 419 static void 419 static void 420 420 PAGER_NormalizeBtns(PAGER_INFO* infoPtr, BOOL* needsRepaint) 421 421 { … … 433 433 } 434 434 435 static void 435 static void 436 436 PAGER_HideGrayBtns(PAGER_INFO* infoPtr, BOOL* needsResize) 437 437 { … … 464 464 PAGER_HideGrayBtns(infoPtr, &resizeClient); 465 465 466 if (resizeClient) /* initiate NCCalcSize to resize client wnd */ 467 SetWindowPos(hwnd, 0,0,0,0,0, 466 if (resizeClient) /* initiate NCCalcSize to resize client wnd */ { 467 SetWindowPos(hwnd, 0,0,0,0,0, 468 468 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | 469 469 SWP_NOZORDER | SWP_NOACTIVATE); 470 } 470 471 471 472 if (repaintBtns) 472 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 473 } 474 475 static LRESULT 473 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 474 } 475 476 static LRESULT 476 477 PAGER_SetPos(HWND hwnd, INT newPos, BOOL fromBtnPress) 477 478 { … … 500 501 501 502 static LRESULT 502 PAGER_HandleWindowPosChanging(HWND hwnd, W INDOWPOS *winpos)503 PAGER_HandleWindowPosChanging(HWND hwnd, WPARAM wParam, WINDOWPOS *winpos) 503 504 { 504 505 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); … … 510 511 * (i.e. height for a horizontal pager, or width for a vertical one) */ 511 512 513 /* except if the current dimension is 0 and app is setting for 514 * first time, then save amount as dimension. - GA 8/01 */ 515 512 516 if (PAGER_IsHorizontal(hwnd)) 513 winpos->cy = infoPtr->nHeight; 517 if (!infoPtr->nHeight && winpos->cy) 518 infoPtr->nHeight = winpos->cy; 519 else 520 winpos->cy = infoPtr->nHeight; 514 521 else 515 winpos->cx = infoPtr->nWidth; 516 } 517 518 return 0; 519 } 520 521 static void 522 if (!infoPtr->nWidth && winpos->cx) 523 infoPtr->nWidth = winpos->cx; 524 else 525 winpos->cx = infoPtr->nWidth; 526 return 0; 527 } 528 529 DefWindowProcA (hwnd, WM_WINDOWPOSCHANGING, wParam, (LPARAM)winpos); 530 531 return 1; 532 } 533 534 static INT 522 535 PAGER_SetFixedWidth(HWND hwnd, PAGER_INFO* infoPtr) 523 536 { … … 544 557 h = wndRect.bottom - wndRect.top + infoPtr->nButtonSize; 545 558 546 /* adjust non-scrollable dimension to fit the child */547 SetWindowPos(hwnd, 0, 0,0, infoPtr->nWidth, h,548 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER);549 550 551 559 TRACE("[%04x] infoPtr->nWidth set to %d\n", 552 hwnd, infoPtr->nWidth); 553 } 554 555 static void 560 hwnd, infoPtr->nWidth); 561 562 return h; 563 } 564 565 static INT 556 566 PAGER_SetFixedHeight(HWND hwnd, PAGER_INFO* infoPtr) 557 567 { … … 578 588 w = wndRect.right - wndRect.left + infoPtr->nButtonSize; 579 589 580 /* adjust non-scrollable dimension to fit the child */581 SetWindowPos(hwnd, 0, 0,0, w, infoPtr->nHeight,582 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER);583 584 590 TRACE("[%04x] infoPtr->nHeight set to %d\n", 585 hwnd, infoPtr->nHeight); 591 hwnd, infoPtr->nHeight); 592 593 return w; 586 594 } 587 595 … … 602 610 PAGER_SetPos(hwnd, 0, FALSE); 603 611 } 604 else 612 else 605 613 { 606 614 PAGER_UpdateBtns(hwnd, infoPtr, scrollRange, TRUE); … … 663 671 { 664 672 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 673 INT hw; 665 674 666 675 infoPtr->hwndChild = IsWindow ((HWND)lParam) ? (HWND)lParam : 0; … … 670 679 TRACE("[%04x] hwndChild=%04x\n", hwnd, infoPtr->hwndChild); 671 680 672 if (PAGER_IsHorizontal(hwnd)) 673 PAGER_SetFixedHeight(hwnd, infoPtr); 674 else 675 PAGER_SetFixedWidth(hwnd, infoPtr); 681 if (PAGER_IsHorizontal(hwnd)) { 682 hw = PAGER_SetFixedHeight(hwnd, infoPtr); 683 /* adjust non-scrollable dimension to fit the child */ 684 SetWindowPos(hwnd, 0, 0,0, hw, infoPtr->nHeight, 685 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER | 686 SWP_NOSIZE | SWP_NOACTIVATE); 687 } 688 else { 689 hw = PAGER_SetFixedWidth(hwnd, infoPtr); 690 /* adjust non-scrollable dimension to fit the child */ 691 SetWindowPos(hwnd, 0, 0,0, infoPtr->nWidth, hw, 692 SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER | 693 SWP_NOSIZE | SWP_NOACTIVATE); 694 } 676 695 677 696 /* position child within the page scroller */ 678 697 SetWindowPos(infoPtr->hwndChild, HWND_TOP, 679 698 0,0,0,0, 680 SWP_SHOWWINDOW | SWP_NOSIZE); 699 SWP_SHOWWINDOW | SWP_NOSIZE); /* native is 0 */ 681 700 682 701 infoPtr->nPos = -1; … … 701 720 nmpgScroll.hdr.code = PGN_SCROLL; 702 721 703 GetWindowRect(hwnd, &rcWnd); 704 GetClientRect(hwnd, &nmpgScroll.rcParent); 722 GetWindowRect(hwnd, &rcWnd); 723 GetClientRect(hwnd, &nmpgScroll.rcParent); 705 724 nmpgScroll.iXpos = nmpgScroll.iYpos = 0; 706 725 nmpgScroll.iDir = dir; … … 717 736 } 718 737 nmpgScroll.iScroll -= 2*infoPtr->nButtonSize; 719 738 720 739 SendMessageA (hwnd, WM_NOTIFY, 721 740 (WPARAM)nmpgScroll.hdr.idFrom, (LPARAM)&nmpgScroll); 722 741 723 742 TRACE("[%04x] PGN_SCROLL returns iScroll=%d\n", hwnd, nmpgScroll.iScroll); 724 743 … … 770 789 FIXME("[%04x] Drag and Drop style is not implemented yet.\n", hwnd); 771 790 /* 772 773 774 775 791 * If neither horizontal nor vertical style specified, default to vertical. 792 * This is probably not necessary, since the style may be set later on as 793 * the control is initialized, but just in case it isn't, set it here. 794 */ 776 795 if (!(dwStyle & PGS_HORZ) && !(dwStyle & PGS_VERT)) 777 796 { … … 799 818 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 800 819 LPRECT lpRect = (LPRECT)lParam; 820 RECT rcChildw, rcmyw, wnrc, lbrc, rbrc; 821 POINT cursor; 822 801 823 /* 802 824 * lParam points to a RECT struct. On entry, the struct 803 * contains the proposed wnd rectangle for the window. 825 * contains the proposed wnd rectangle for the window. 804 826 * On exit, the struct should contain the screen 805 827 * coordinates of the corresponding window's client area. 806 828 */ 829 830 DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam); 807 831 808 832 if (PAGER_IsHorizontal(hwnd)) 809 833 { 810 if (infoPtr->TLbtnState) /* != PGF_INVISIBLE */ 811 lpRect->left += infoPtr->nButtonSize; 812 if (infoPtr->BRbtnState) 813 lpRect->right -= infoPtr->nButtonSize; 834 infoPtr->nWidth = lpRect->right - lpRect->left; 835 PAGER_CalcSize (hwnd, &infoPtr->nWidth, TRUE); 836 GetWindowRect (infoPtr->hwndChild, &rcChildw); 837 MapWindowPoints (0, hwnd, (LPPOINT)&rcChildw, 2); 838 GetCursorPos (&cursor); 839 GetWindowRect (hwnd, &rcmyw); 840 if (PtInRect (&rcmyw, cursor)) { 841 GetWindowRect (hwnd, &wnrc); 842 lbrc = wnrc; 843 lbrc.right = lbrc.left + infoPtr->nButtonSize; 844 rbrc = wnrc; 845 rbrc.left = rbrc.right - infoPtr->nButtonSize; 846 TRACE("horz lb rect=(%d,%d)-(%d,%d), rb rect=(%d,%d)-(%d,%d)\n", 847 lbrc.left, lbrc.top, lbrc.right, lbrc.bottom, 848 rbrc.left, rbrc.top, rbrc.right, rbrc.bottom); 849 if (PtInRect (&lbrc, cursor) && infoPtr->TLbtnState) 850 RedrawWindow (hwnd, 0, 0, RDW_INVALIDATE | RDW_ERASE); 851 if (PtInRect (&rbrc, cursor) && infoPtr->BRbtnState) 852 RedrawWindow (hwnd, 0, 0, RDW_INVALIDATE | RDW_ERASE); 853 } 854 if (infoPtr->TLbtnState) /* != PGF_INVISIBLE */ 855 lpRect->left += infoPtr->nButtonSize; 856 if (infoPtr->BRbtnState) 857 lpRect->right -= infoPtr->nButtonSize; 814 858 } 815 859 else 816 860 { 817 if (infoPtr->TLbtnState) 818 lpRect->top += infoPtr->nButtonSize; 819 if (infoPtr->BRbtnState) 820 lpRect->bottom -= infoPtr->nButtonSize; 861 /* native does: (from trace of IE4 opening "Favorites" frame) 862 * DefWindowProc 863 * WM_NOITFY PGN_CALCSIZE w/ dwFlag=2 864 * GetWindowRect (child, &rc) 865 * MapWindowPoints (0, syspager, &rc, 2) 866 * GetCursorPos( &cur ) 867 * GetWindowRect (syspager, &rc2) 868 * PtInRect (&rc2, cur.x, cur.y) rtns 0 869 * returns with rect empty 870 */ 871 infoPtr->nHeight = lpRect->bottom - lpRect->top; 872 PAGER_CalcSize (hwnd, &infoPtr->nHeight, FALSE); 873 GetWindowRect (infoPtr->hwndChild, &rcChildw); 874 MapWindowPoints (0, hwnd, (LPPOINT)&rcChildw, 2); 875 GetCursorPos (&cursor); 876 GetWindowRect (hwnd, &rcmyw); 877 if (PtInRect (&rcmyw, cursor)) { 878 879 /* native does: 880 * GetWindowRect(pager, &rc) 881 * PtInRect(btn-left????, cur.x, cur.y) 882 * if true -> ??? 883 * PtInRect(btn-right????, cur.x, cur.y) 884 * if true 885 * RedrawWindow(pager, 0, 0, 5) 886 * return TRUE 887 */ 888 889 GetWindowRect (hwnd, &wnrc); 890 lbrc = wnrc; 891 lbrc.right = lbrc.left + infoPtr->nButtonSize; 892 rbrc = wnrc; 893 rbrc.left = rbrc.right - infoPtr->nButtonSize; 894 TRACE("vert lb rect=(%d,%d)-(%d,%d), rb rect=(%d,%d)-(%d,%d)\n", 895 lbrc.left, lbrc.top, lbrc.right, lbrc.bottom, 896 rbrc.left, rbrc.top, rbrc.right, rbrc.bottom); 897 if (PtInRect (&lbrc, cursor) && infoPtr->TLbtnState) 898 RedrawWindow (hwnd, 0, 0, RDW_INVALIDATE | RDW_ERASE); 899 if (PtInRect (&rbrc, cursor) && infoPtr->BRbtnState) 900 RedrawWindow (hwnd, 0, 0, RDW_INVALIDATE | RDW_ERASE); 901 } 902 if (infoPtr->TLbtnState) 903 lpRect->top += infoPtr->nButtonSize; 904 if (infoPtr->BRbtnState) 905 lpRect->bottom -= infoPtr->nButtonSize; 906 /* ???? */ 907 if ((lpRect->bottom < 0) || (lpRect->bottom > infoPtr->nHeight)) 908 lpRect->bottom = infoPtr->nHeight; 821 909 } 822 910 … … 864 952 bHorizontal, TRUE, infoPtr->TLbtnState); 865 953 PAGER_DrawButton(hdc, infoPtr->clrBk, rcBottomRight, 866 bHorizontal, FALSE, infoPtr->BRbtnState); 954 bHorizontal, FALSE, infoPtr->BRbtnState); 867 955 868 956 ReleaseDC( hwnd, hdc ); … … 870 958 } 871 959 872 static INT 960 static INT 873 961 PAGER_HitTest (HWND hwnd, LPPOINT pt) 874 962 { … … 977 1065 if(!(trackinfo.dwFlags & TME_LEAVE)) { 978 1066 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */ 979 1067 980 1068 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */ 981 1069 /* and can properly deactivate the hot button */ … … 983 1071 } 984 1072 985 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 1073 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 986 1074 } 987 1075 … … 1026 1114 1027 1115 TRACE("[%04x]\n", hwnd); 1028 1116 1029 1117 hit = PAGER_HitTest(hwnd, &pt); 1030 1118 … … 1034 1122 repaintBtns = infoPtr->TLbtnState != PGF_DEPRESSED; 1035 1123 infoPtr->TLbtnState = PGF_DEPRESSED; 1036 SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 1124 SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 1037 1125 } 1038 1126 else if (hit == HTRIGHT || hit == HTBOTTOM) … … 1040 1128 repaintBtns = infoPtr->BRbtnState != PGF_DEPRESSED; 1041 1129 infoPtr->BRbtnState = PGF_DEPRESSED; 1042 SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 1130 SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); 1043 1131 } 1044 1132 1045 1133 if (repaintBtns) 1046 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 1134 SendMessageA(hwnd, WM_NCPAINT, 0, 0); 1047 1135 1048 1136 switch(hit) … … 1089 1177 PAGER_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam) 1090 1178 { 1179 POINT pt, ptorig; 1180 HDC hdc = (HDC)wParam; 1181 HWND parent; 1182 1183 /* native does: 1184 * parent = GetParent(pager) 1185 * pt.x=0; pt.y=0; ????? 1186 * MapWindowPoints(pager, parent, &pt, 1) 1187 * OffsetWindowOrgEx(hdc, pt.x, pt.y, &ptorg) 1188 * SendMessageA(parent, WM_ERASEBKGND, hdc, 0) 1189 * SetWindowOrgEx(hdc, 0, 0, 0) 1190 */ 1191 1192 pt.x = 0; 1193 pt.y = 0; 1194 parent = GetParent(hwnd); 1195 MapWindowPoints(hwnd, parent, &pt, 1); 1196 OffsetWindowOrgEx (hdc, pt.x, pt.y, &ptorig); 1197 SendMessageA (parent, WM_ERASEBKGND, wParam, lParam); 1198 SetWindowOrgEx (hdc, ptorig.x, ptorig.y, 0); 1199 1200 1201 #if 0 1091 1202 PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); 1092 1203 HBRUSH hBrush = CreateSolidBrush(infoPtr->clrBk); … … 1104 1215 1105 1216 DeleteObject (hBrush); 1217 #endif 1218 1106 1219 return TRUE; 1107 1220 } … … 1131 1244 1132 1245 if (!infoPtr && (uMsg != WM_CREATE)) 1133 1246 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 1134 1247 1135 1248 switch (uMsg) … … 1157 1270 case PGM_RECALCSIZE: 1158 1271 return PAGER_RecalcSize(hwnd); 1159 1272 1160 1273 case PGM_SETBKCOLOR: 1161 1274 return PAGER_SetBkColor (hwnd, wParam, lParam); … … 1186 1299 1187 1300 case WM_WINDOWPOSCHANGING: 1188 return PAGER_HandleWindowPosChanging (hwnd, (WINDOWPOS*)lParam);1301 return PAGER_HandleWindowPosChanging (hwnd, wParam, (WINDOWPOS*)lParam); 1189 1302 1190 1303 case WM_NCCALCSIZE: … … 1205 1318 if (infoPtr->bForward && infoPtr->hwndChild) 1206 1319 PostMessageA(infoPtr->hwndChild, WM_MOUSEMOVE, wParam, lParam); 1207 return TRUE; 1320 return TRUE; 1208 1321 1209 1322 case WM_MOUSELEAVE: 1210 return PAGER_MouseLeave (hwnd, wParam, lParam); 1323 return PAGER_MouseLeave (hwnd, wParam, lParam); 1211 1324 1212 1325 case WM_LBUTTONDOWN: … … 1220 1333 /* 1221 1334 case WM_PAINT: 1222 return PAGER_Paint (hwnd, wParam); 1335 return PAGER_Paint (hwnd, wParam); 1223 1336 */ 1224 1337 case WM_TIMER: … … 1234 1347 { 1235 1348 PAGER_Scroll(hwnd, infoPtr->direction); 1236 SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0); 1349 SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0); 1237 1350 } 1238 1351 break; … … 1267 1380 wndClass.hbrBackground = 0; 1268 1381 wndClass.lpszClassName = WC_PAGESCROLLERA; 1269 1382 1270 1383 RegisterClassA (&wndClass); 1271 1384 } -
trunk/src/comctl32/rebar.c
r6644 r6705 1 /* $Id: rebar.c,v 1.16 2001-09-05 12:05:01 bird Exp $ */ 1 /* 2 * Testing: set to 1 to make background brush *always* green 3 */ 4 #define GLATESTING 0 5 2 6 /* 3 7 * … … 10 14 11 15 /* 12 * Rebar control rev 7f 16 * 3. REBAR_MoveChildWindows should have a loop because more than 17 * one pass is made (together with the RBN_CHILDSIZEs) is made on 18 * at least RB_INSERTBAND 19 */ 20 21 22 /* 23 * Rebar control rev 8a 13 24 * 14 25 * Copyright 1998, 1999 Eric Kohl … … 22 33 * - vertical placement 23 34 * - ComboBox and ComboBoxEx placement 24 * - center image 35 * - center image 25 36 * - Layout code. 26 37 * - Display code. … … 31 42 * rev 2,3,4 32 43 * - Implement initial version of row grouping, row separators, 33 * text and background colors. Support additional messages. 44 * text and background colors. Support additional messages. 34 45 * Support RBBS_BREAK. Implement ERASEBKGND and improve painting. 35 46 * rev 5 36 47 * - implement support for dragging Gripper left or right in a row. Supports 37 * WM_LBUTTONDOWN, WM_LBUTTONUP, and WM_MOUSEMOVE. Also support 48 * WM_LBUTTONDOWN, WM_LBUTTONUP, and WM_MOUSEMOVE. Also support 38 49 * RBS_BANDBORDERS. 39 50 * rev 6 … … 43 54 * 44 55 * rev 7 45 * 1. Redesign _Layout to better emulate native. 46 * a. Flag rebar when a band needs to be (and all bands) need to 47 * go through rest of _Layout 48 * 2. Fix RBN_ENDDRAG contents. 49 * 3. REBAR_ForceResize changed to handle shrink of client. 50 * rev 7b 51 * 4. Support RBBS_HIDDEN in _Layout (phase 2 & 3), _InternalEraseBkgnd, 52 * and _InternalHitTest 53 * 5. Support RBS_VARHEIGHT. 54 * 6. Rewrite _AdjustBands with new algorithm. 55 * rev 7c 56 * 7. Format mask and style with labels. 57 * 8. Move calls to _ForceResize and _MoveChildWindows into _Layout to 58 * centralize processing. 59 * 9. Pass "infoPtr" to all routines instead of "hwnd" to eliminate extra 60 * calls to GetWindowLongA. 61 * 10. Use _MoveChildWindows in _HandleLRDrag. 62 * 11. Another rewrite of _AdjustBands with new algorithm. 63 * 12. Correct drawing of rebar borders and handling of RBS_BORDERS. 64 * rev 7d 65 * 13. Support WM_NOTIFYFORMAT (both incoming and outgoing) and do 66 * WM_NOTIFY correctly based on results. 67 * 14. Implement WM_SETREDRAW. 68 * 15. Native WM_ERASEBKGND draws horz and vert separators between bands and 69 * rows, and fills in the background color for each band. The gripper, 70 * image, and text for each band is drawn by the WM_PAINT process. Change 71 * this code to match. 72 * rev 7e 73 * 16. RBBS_FIXEDSIZE should not affect _AdjustBands. (Found by Mike McCormack 74 * in WinZip - Thanks!) 75 * 17. Implement WM_NCCREATE to set necessary additional styles and move most 76 * of creation stuff to it like native control. 77 * 18. WM_SETFONT should redraw only if LOWORD is TRUE. 78 * 19. Implement WM_NCHITTEST to send notify to parent of NM_NCHITTEST. 79 * 20. Cleaned up dead and/or testing code. 80 * 21. Support RB_MOVEBAND. 81 * 22. Support WM_STYLECHANGED and remove all (or most) of the GetWindowLong 82 * for GWL_STYLE. 83 * 23. Support RB_MINIMIZEBAND. 84 * 24. RBBS_HIDDEN (and the CCS_VERT+RBBS_NOVERT case) should be supported 85 * by all routines now. 86 * rev 7f 87 * 25. Fix handling of text color. 88 * 26. Correct implementation of WM_SETREDRAW to be closer to native. 89 * See REBAR_SetRedraw for doc changes of actual vs. MSDN 90 * 27. Do more implementation of RBS_AUTOSIZE in the WM_SIZE processor. 91 * 28. Implement RBBS_VARIABLEHEIGHT. Used by IE4. 92 * 29. Do more testing in WM_SIZE to handle strange cases like native. 56 * - Fix algorithm for _Layout and _AdjustBand. 57 * - Fix or implement RBN_ENDDRAG, RB_MOVEBAND, WM_SETREDRAW, 58 * WM_STYLECHANGED, RB_MINIMIZEBAND, RBBS_VARIABLEHEIGHT, RBS_VARHEIGHT, 59 * RBBS_HIDDEN, WM_NOTIFYFORMAT, NM_NCHITTEST, WM_SETREDRAW, RBS_AUTOSIZE, 60 * WM_SETFONT, RBS_BORDERS 61 * - Create structures in WM_NCCREATE 62 * - Additional performance enhancements. 63 * 64 * rev 8 65 * 1. Create array of start and end band indexes by row and use. 66 * 2. Fix problem with REBAR_Layout Phase 2b to process only if only 67 * band in row. 68 * 3. Set the Caption Font (Regular) as default font for text. 69 * 4. Delete font handle on control distruction. 70 * 5. Add UpdateWindow call in _MoveChildWindows to match repainting done 71 * by native control 72 * 6. Improve some traces. 73 * 7. Invalidate window rectangles after SetBandInfo, InsertBand, ShowBand 74 * so that repainting is correct. 75 * 8. Implement RB_MAXIMIZEBAND for the "ideal=TRUE" case. 76 * 9. Implement item custom draw notifications partially. Only done for 77 * ITEMPREPAINT and ITEMPOSTPAINT. (Used by IE4 for "Favorites" frame 78 * to draw the word "Favorites"). 79 * rev 8a 80 * 10. Handle CCS_NODIVIDER and fix WS_BORDER code. 81 * 11. Fix logic error in _AdjustBands where flag was set to valid band 82 * number (0) to indicate *no* band. 83 * 12. Fix CCS_VERT errors in _ForceResize, _NCCalcSize, and _NCPaint. 84 * 13. Support some special cases of CCS_TOP (and therefore CCS_LEFT), 85 * CCS_BOTTOM (and therefore CCS_RIGHT) and CCS_NOPARENTALIGN. Not 86 * at all sure whether this is all cases. 87 * 14. Handle returned value for the RBN_CHILDSIZE notify. 88 * 15. Implement RBBS_CHILDEDGE, and set each bands "offChild" at _Layout 89 * time. 90 * 16. Fix REBARSPACE. It should depend on CCS_NODIVIDER. 93 91 * 94 92 * 95 93 * Still to do: 96 * 2. Following still not handled: RBBS_FIXEDBMP, RBBS_CHILDEDGE, 97 * RBBS_USECHEVRON 98 * 3. Following are only partially handled: 94 * 2. Following still not handled: RBBS_FIXEDBMP, 95 * RBBS_USECHEVRON, CCS_NORESIZE, 96 * CCS_NOMOVEX, CCS_NOMOVEY 97 * 3. Following are only partially handled: 99 98 * RBS_AUTOSIZE, RBBS_VARIABLEHEIGHT 100 99 * 5. Native uses (on each draw!!) SM_CYBORDER (or SM_CXBORDER for CCS_VERT) 101 * to set the size of the separator width (the value SEP_WIDTH_SIZE 100 * to set the size of the separator width (the value SEP_WIDTH_SIZE 102 101 * in here). Should be fixed!! 103 102 * 6. The following messages are not implemented: … … 117 116 #include <string.h> 118 117 119 #include "win.h"120 118 #include "winbase.h" 121 119 #include "wingdi.h" … … 134 132 typedef struct 135 133 { 136 #ifdef __WIN32OS2__137 COMCTL32_HEADER header;138 #endif139 134 UINT fStyle; 140 135 UINT fMask; … … 167 162 UINT fStatus; /* status flags, reset only by _Validate */ 168 163 UINT fDraw; /* drawing flags, reset only by _Layout */ 164 UINT uCDret; /* last return from NM_CUSTOMDRAW */ 169 165 RECT rcoldBand; /* previous calculated band rectangle */ 170 166 RECT rcBand; /* calculated band rectangle */ … … 191 187 #define NTF_INVALIDATE 0x01000000 192 188 193 194 189 typedef struct 195 190 { 191 INT istartband; /* index of first band in row */ 192 INT iendband; /* index of last band in row */ 193 } REBAR_ROW; 194 195 196 typedef struct 197 { 198 #ifdef __WIN32OS2__ 199 COMCTL32_HEADER header; 200 #endif 196 201 COLORREF clrBk; /* background color */ 197 202 COLORREF clrText; /* text color */ … … 199 204 COLORREF clrBtnFace; /* system color for BTNFACE */ 200 205 HIMAGELIST himl; /* handle to imagelist */ 201 UINT uNumBands; /* # of bands in rebar (first=0, last=uNum Rows-1 */206 UINT uNumBands; /* # of bands in rebar (first=0, last=uNumBands-1 */ 202 207 UINT uNumRows; /* # of rows of bands (first=1, last=uNumRows */ 203 208 HWND hwndSelf; /* handle of REBAR window itself */ … … 212 217 BOOL NtfUnicode; /* TRUE if parent wants notify in W format */ 213 218 BOOL DoRedraw; /* TRUE to acutally draw bands */ 214 UINT fStatus; /* Status flags (see below) */ 219 UINT fStatus; /* Status flags (see below) */ 215 220 HCURSOR hcurArrow; /* handle to the arrow cursor */ 216 221 HCURSOR hcurHorz; /* handle to the EW cursor */ … … 223 228 INT ihitoffset; /* offset of hotspot from gripper.left */ 224 229 230 REBAR_ROW *rows; /* pointer to row indexes */ 225 231 REBAR_BAND *bands; /* pointer to the array of rebar bands */ 226 232 } REBAR_INFO; … … 263 269 #define GRIPPER_WIDTH 3 264 270 265 /* This is the increment that is used over the band height */ 266 /* Determined by experiment. */ 267 #define REBARSPACE 4 271 /* Height of divider for Rebar if not disabled (CCS_NODIVIDER) */ 272 /* either top or bottom */ 273 #define REBAR_DIVIDER 2 274 275 /* This is the increment that is used over the band height */ 276 #define REBARSPACE(a) ((a->fStyle & RBBS_CHILDEDGE) ? 2*REBAR_DIVIDER : 0) 268 277 269 278 /* ---- End of REBAR layout constants. ---- */ … … 275 284 #define rcBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.bottom : b->rcBand.right) 276 285 #define rcBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.bottom - b->rcBand.top) : \ 277 286 (b->rcBand.right - b->rcBand.left)) 278 287 #define ircBlt(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.left : b->rcBand.top) 279 288 #define ircBrb(b) ((infoPtr->dwStyle & CCS_VERT) ? b->rcBand.right : b->rcBand.bottom) 280 289 #define ircBw(b) ((infoPtr->dwStyle & CCS_VERT) ? (b->rcBand.right - b->rcBand.left) : \ 281 290 (b->rcBand.bottom - b->rcBand.top)) 282 291 283 292 /* The following define determines if a given band is hidden */ … … 339 348 *line = 0; 340 349 while (band_stylename[i]) { 341 342 343 344 345 350 if (style & (1<<i)) { 351 if (*line != 0) strcat(line, " | "); 352 strcat(line, band_stylename[i]); 353 } 354 i++; 346 355 } 347 356 return line; … … 356 365 *line = 0; 357 366 while (band_maskname[i]) { 358 359 360 361 362 367 if (mask & (1<<i)) { 368 if (*line != 0) strcat(line, " | "); 369 strcat(line, band_maskname[i]); 370 } 371 i++; 363 372 } 364 373 return line; … … 371 380 if( !TRACE_ON(rebar) ) return; 372 381 TRACE("band info: ID=%u, size=%u, child=%04x, clrF=0x%06lx, clrB=0x%06lx\n", 373 pB->wID, pB->cbSize, pB->hwndChild, pB->clrFore, pB->clrBack); 382 pB->wID, pB->cbSize, pB->hwndChild, pB->clrFore, pB->clrBack); 374 383 TRACE("band info: mask=0x%08x (%s)\n", pB->fMask, REBAR_FmtMask(pB->fMask)); 375 384 if (pB->fMask & RBBIM_STYLE) 376 385 TRACE("band info: style=0x%08x (%s)\n", pB->fStyle, REBAR_FmtStyle(pB->fStyle)); 377 386 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_HEADERSIZE | RBBIM_LPARAM )) { 378 379 380 381 382 383 384 385 386 387 387 TRACE("band info:"); 388 if (pB->fMask & RBBIM_SIZE) 389 DPRINTF(" cx=%u", pB->cx); 390 if (pB->fMask & RBBIM_IDEALSIZE) 391 DPRINTF(" xIdeal=%u", pB->cxIdeal); 392 if (pB->fMask & RBBIM_HEADERSIZE) 393 DPRINTF(" xHeader=%u", pB->cxHeader); 394 if (pB->fMask & RBBIM_LPARAM) 395 DPRINTF(" lParam=0x%08lx", pB->lParam); 396 DPRINTF("\n"); 388 397 } 389 398 if (pB->fMask & RBBIM_CHILDSIZE) 390 391 pB->cxMinChild, 392 399 TRACE("band info: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n", 400 pB->cxMinChild, 401 pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral); 393 402 } 394 403 … … 401 410 if(! TRACE_ON(rebar) ) return; 402 411 403 TRACE("hwnd=%04x: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n", 404 405 412 TRACE("hwnd=%04x: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n", 413 iP->hwndSelf, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows, 414 iP->calcSize.cx, iP->calcSize.cy); 406 415 TRACE("hwnd=%04x: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, ihitBand=%d\n", 407 408 409 416 iP->hwndSelf, iP->fStatus, iP->dragStart.x, iP->dragStart.y, 417 iP->dragNow.x, iP->dragNow.y, 418 iP->ihitBand); 410 419 TRACE("hwnd=%04x: style=%08lx, I'm Unicode=%s, notify in Unicode=%s, redraw=%s\n", 411 412 420 iP->hwndSelf, iP->dwStyle, (iP->bUnicode)?"TRUE":"FALSE", 421 (iP->NtfUnicode)?"TRUE":"FALSE", (iP->DoRedraw)?"TRUE":"FALSE"); 413 422 for (i = 0; i < iP->uNumBands; i++) { 414 pB = &iP->bands[i]; 415 TRACE("band # %u: ID=%u, child=%04x, row=%u, clrF=0x%06lx, clrB=0x%06lx\n", 416 i, pB->wID, pB->hwndChild, pB->iRow, pB->clrFore, pB->clrBack); 417 TRACE("band # %u: mask=0x%08x (%s)\n", i, pB->fMask, REBAR_FmtMask(pB->fMask)); 418 if (pB->fMask & RBBIM_STYLE) 419 TRACE("band # %u: style=0x%08x (%s)\n", 420 i, pB->fStyle, REBAR_FmtStyle(pB->fStyle)); 421 TRACE("band # %u: uMinH=%u xHeader=%u", 422 i, pB->uMinHeight, pB->cxHeader); 423 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_LPARAM )) { 424 if (pB->fMask & RBBIM_SIZE) 425 DPRINTF(" cx=%u", pB->cx); 426 if (pB->fMask & RBBIM_IDEALSIZE) 427 DPRINTF(" xIdeal=%u", pB->cxIdeal); 428 if (pB->fMask & RBBIM_LPARAM) 429 DPRINTF(" lParam=0x%08lx", pB->lParam); 430 } 431 DPRINTF("\n"); 432 if (RBBIM_CHILDSIZE) 433 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n", 434 i, pB->cxMinChild, pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral); 435 TRACE("band # %u: lcx=%u, ccx=%u, hcx=%u, lcy=%u, ccy=%u, hcy=%u, offChild=%ld,%ld\n", 436 i, pB->lcx, pB->ccx, pB->hcx, pB->lcy, pB->ccy, pB->hcy, pB->offChild.cx, pB->offChild.cy); 437 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%d,%d)-(%d,%d), Grip=(%d,%d)-(%d,%d)\n", 438 i, pB->fStatus, pB->fDraw, 439 pB->rcBand.left, pB->rcBand.top, pB->rcBand.right, pB->rcBand.bottom, 440 pB->rcGripper.left, pB->rcGripper.top, pB->rcGripper.right, pB->rcGripper.bottom); 441 TRACE("band # %u: Img=(%d,%d)-(%d,%d), Txt=(%d,%d)-(%d,%d), Child=(%d,%d)-(%d,%d)\n", 442 i, 443 pB->rcCapImage.left, pB->rcCapImage.top, pB->rcCapImage.right, pB->rcCapImage.bottom, 444 pB->rcCapText.left, pB->rcCapText.top, pB->rcCapText.right, pB->rcCapText.bottom, 445 pB->rcChild.left, pB->rcChild.top, pB->rcChild.right, pB->rcChild.bottom); 423 pB = &iP->bands[i]; 424 TRACE("band # %u: ID=%u, child=%04x, row=%u, clrF=0x%06lx, clrB=0x%06lx\n", 425 i, pB->wID, pB->hwndChild, pB->iRow, pB->clrFore, pB->clrBack); 426 TRACE("band # %u: mask=0x%08x (%s)\n", i, pB->fMask, REBAR_FmtMask(pB->fMask)); 427 if (pB->fMask & RBBIM_STYLE) 428 TRACE("band # %u: style=0x%08x (%s)\n", 429 i, pB->fStyle, REBAR_FmtStyle(pB->fStyle)); 430 TRACE("band # %u: uMinH=%u xHeader=%u", 431 i, pB->uMinHeight, pB->cxHeader); 432 if (pB->fMask & (RBBIM_SIZE | RBBIM_IDEALSIZE | RBBIM_LPARAM )) { 433 if (pB->fMask & RBBIM_SIZE) 434 DPRINTF(" cx=%u", pB->cx); 435 if (pB->fMask & RBBIM_IDEALSIZE) 436 DPRINTF(" xIdeal=%u", pB->cxIdeal); 437 if (pB->fMask & RBBIM_LPARAM) 438 DPRINTF(" lParam=0x%08lx", pB->lParam); 439 } 440 DPRINTF("\n"); 441 if (RBBIM_CHILDSIZE) 442 TRACE("band # %u: xMin=%u, yMin=%u, yChild=%u, yMax=%u, yIntgl=%u\n", 443 i, pB->cxMinChild, pB->cyMinChild, pB->cyChild, pB->cyMaxChild, pB->cyIntegral); 444 if (pB->fMask & RBBIM_TEXT) 445 TRACE("band # %u: text=%s\n", 446 i, (pB->lpText) ? debugstr_w(pB->lpText) : "(null)"); 447 TRACE("band # %u: lcx=%u, ccx=%u, hcx=%u, lcy=%u, ccy=%u, hcy=%u, offChild=%ld,%ld\n", 448 i, pB->lcx, pB->ccx, pB->hcx, pB->lcy, pB->ccy, pB->hcy, pB->offChild.cx, pB->offChild.cy); 449 TRACE("band # %u: fStatus=%08x, fDraw=%08x, Band=(%d,%d)-(%d,%d), Grip=(%d,%d)-(%d,%d)\n", 450 i, pB->fStatus, pB->fDraw, 451 pB->rcBand.left, pB->rcBand.top, pB->rcBand.right, pB->rcBand.bottom, 452 pB->rcGripper.left, pB->rcGripper.top, pB->rcGripper.right, pB->rcGripper.bottom); 453 TRACE("band # %u: Img=(%d,%d)-(%d,%d), Txt=(%d,%d)-(%d,%d), Child=(%d,%d)-(%d,%d)\n", 454 i, 455 pB->rcCapImage.left, pB->rcCapImage.top, pB->rcCapImage.right, pB->rcCapImage.bottom, 456 pB->rcCapText.left, pB->rcCapText.top, pB->rcCapText.right, pB->rcCapText.bottom, 457 pB->rcChild.left, pB->rcChild.top, pB->rcChild.right, pB->rcChild.bottom); 446 458 } 447 459 … … 457 469 if (!parent) { 458 470 parent = GetParent (infoPtr->hwndSelf); 459 460 471 owner = GetWindow (infoPtr->hwndSelf, GW_OWNER); 472 if (owner) parent = owner; 461 473 } 462 474 return parent; … … 475 487 476 488 TRACE("window %04x, code=%08x, %s\n", parent, code, 477 489 (infoPtr->NtfUnicode) ? "via Unicode" : "via ANSI"); 478 490 479 491 if (infoPtr->NtfUnicode) 480 481 492 return SendMessageW (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom, 493 (LPARAM)nmhdr); 482 494 else 483 484 495 return SendMessageA (parent, WM_NOTIFY, (WPARAM) nmhdr->idFrom, 496 (LPARAM)nmhdr); 485 497 } 486 498 … … 493 505 notify_rebar.dwMask = 0; 494 506 if (uBand!=-1) { 495 496 497 498 499 500 501 502 503 504 505 506 507 507 lpBand = &infoPtr->bands[uBand]; 508 if (lpBand->fMask & RBBIM_ID) { 509 notify_rebar.dwMask |= RBNM_ID; 510 notify_rebar.wID = lpBand->wID; 511 } 512 if (lpBand->fMask & RBBIM_LPARAM) { 513 notify_rebar.dwMask |= RBNM_LPARAM; 514 notify_rebar.lParam = lpBand->lParam; 515 } 516 if (lpBand->fMask & RBBIM_STYLE) { 517 notify_rebar.dwMask |= RBNM_STYLE; 518 notify_rebar.fStyle = lpBand->fStyle; 519 } 508 520 } 509 521 notify_rebar.uBand = uBand; … … 514 526 REBAR_DrawBand (HDC hdc, REBAR_INFO *infoPtr, REBAR_BAND *lpBand) 515 527 { 516 528 HFONT hOldFont = 0; 529 INT oldBkMode = 0; 530 NMCUSTOMDRAW nmcd; 531 532 if (lpBand->fDraw & DRAW_TEXT) { 533 hOldFont = SelectObject (hdc, infoPtr->hFont); 534 oldBkMode = SetBkMode (hdc, TRANSPARENT); 535 } 536 537 /* should test for CDRF_NOTIFYITEMDRAW here */ 538 nmcd.dwDrawStage = CDDS_ITEMPREPAINT; 539 nmcd.hdc = hdc; 540 nmcd.rc = lpBand->rcBand; 541 nmcd.rc.right = lpBand->rcCapText.right; 542 nmcd.rc.bottom = lpBand->rcCapText.bottom; 543 nmcd.dwItemSpec = lpBand->wID; 544 nmcd.uItemState = 0; 545 nmcd.lItemlParam = lpBand->lParam; 546 lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW); 547 if (lpBand->uCDret == CDRF_SKIPDEFAULT) { 548 if (oldBkMode != TRANSPARENT) 549 SetBkMode (hdc, oldBkMode); 550 SelectObject (hdc, hOldFont); 551 return; 552 } 517 553 518 554 /* draw gripper */ … … 522 558 /* draw caption image */ 523 559 if (lpBand->fDraw & DRAW_IMAGE) { 524 525 526 527 528 529 530 531 532 560 POINT pt; 561 562 /* center image */ 563 pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2; 564 pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2; 565 566 ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc, 567 pt.x, pt.y, 568 ILD_TRANSPARENT); 533 569 } 534 570 535 571 /* draw caption text */ 536 572 if (lpBand->fDraw & DRAW_TEXT) { 537 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont); 538 INT oldBkMode = SetBkMode (hdc, TRANSPARENT); 539 COLORREF oldcolor = CLR_NONE; 540 oldcolor = SetTextColor (hdc, (lpBand->clrFore != CLR_NONE) ? 541 lpBand->clrFore : infoPtr->clrBtnText); 542 DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText, 543 DT_CENTER | DT_VCENTER | DT_SINGLELINE); 544 if (oldBkMode != TRANSPARENT) 545 SetBkMode (hdc, oldBkMode); 546 SetTextColor (hdc, oldcolor); 547 SelectObject (hdc, hOldFont); 573 /* need to handle CDRF_NEWFONT here */ 574 INT oldBkMode = SetBkMode (hdc, TRANSPARENT); 575 COLORREF oldcolor = CLR_NONE; 576 oldcolor = SetTextColor (hdc, (lpBand->clrFore != CLR_NONE) ? 577 lpBand->clrFore : infoPtr->clrBtnText); 578 DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText, 579 DT_CENTER | DT_VCENTER | DT_SINGLELINE); 580 if (oldBkMode != TRANSPARENT) 581 SetBkMode (hdc, oldBkMode); 582 SetTextColor (hdc, oldcolor); 583 SelectObject (hdc, hOldFont); 584 } 585 586 if (lpBand->uCDret == (CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYITEMDRAW)) { 587 nmcd.dwDrawStage = CDDS_ITEMPOSTPAINT; 588 nmcd.hdc = hdc; 589 nmcd.rc = lpBand->rcBand; 590 nmcd.rc.right = lpBand->rcCapText.right; 591 nmcd.rc.bottom = lpBand->rcCapText.bottom; 592 nmcd.dwItemSpec = lpBand->wID; 593 nmcd.uItemState = 0; 594 nmcd.lItemlParam = lpBand->lParam; 595 lpBand->uCDret = REBAR_Notify ((NMHDR *)&nmcd, infoPtr, NM_CUSTOMDRAW); 548 596 } 549 597 } … … 560 608 oldrow = infoPtr->bands[0].iRow; 561 609 for (i = 0; i < infoPtr->uNumBands; i++) { 562 lpBand = &infoPtr->bands[i]; 563 564 if (HIDDENBAND(lpBand)) continue; 565 566 /* now draw the band */ 567 REBAR_DrawBand (hdc, infoPtr, lpBand); 610 lpBand = &infoPtr->bands[i]; 611 612 if (HIDDENBAND(lpBand)) continue; 613 614 /* now draw the band */ 615 TRACE("[%04x] drawing band %i, flags=%08x\n", 616 infoPtr->hwndSelf, i, lpBand->fDraw); 617 REBAR_DrawBand (hdc, infoPtr, lpBand); 568 618 569 619 } … … 573 623 static void 574 624 REBAR_FixVert (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend, 575 576 /* Function: */ 625 INT mcy) 626 /* Function: */ 577 627 /* Cycle through bands in row and fix height of each band. */ 578 628 /* Also determine whether each band has changed. */ … … 586 636 for (i = (INT)rowstart; i<=(INT)rowend; i++) { 587 637 lpBand = &infoPtr->bands[i]; 588 589 590 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 638 if (HIDDENBAND(lpBand)) continue; 639 640 /* adjust height of bands in row to "mcy" value */ 641 if (infoPtr->dwStyle & CCS_VERT) { 642 if (lpBand->rcBand.right != lpBand->rcBand.left + mcy) 643 lpBand->rcBand.right = lpBand->rcBand.left + mcy; 644 } 645 else { 646 if (lpBand->rcBand.bottom != lpBand->rcBand.top + mcy) 647 lpBand->rcBand.bottom = lpBand->rcBand.top + mcy; 648 649 } 650 651 /* mark whether we need to invalidate this band and trace */ 652 if ((lpBand->rcoldBand.left !=lpBand->rcBand.left) || 653 (lpBand->rcoldBand.top !=lpBand->rcBand.top) || 654 (lpBand->rcoldBand.right !=lpBand->rcBand.right) || 655 (lpBand->rcoldBand.bottom !=lpBand->rcBand.bottom)) { 656 lpBand->fDraw |= NTF_INVALIDATE; 657 TRACE("band %d row=%d: changed to (%d,%d)-(%d,%d) from (%d,%d)-(%d,%d)\n", 658 i, lpBand->iRow, 659 lpBand->rcBand.left, lpBand->rcBand.top, 660 lpBand->rcBand.right, lpBand->rcBand.bottom, 661 lpBand->rcoldBand.left, lpBand->rcoldBand.top, 662 lpBand->rcoldBand.right, lpBand->rcoldBand.bottom); 663 } 664 else 665 TRACE("band %d row=%d: unchanged (%d,%d)-(%d,%d)\n", 666 i, lpBand->iRow, 667 lpBand->rcBand.left, lpBand->rcBand.top, 668 lpBand->rcBand.right, lpBand->rcBand.bottom); 619 669 } 620 670 } … … 623 673 static void 624 674 REBAR_AdjustBands (REBAR_INFO *infoPtr, UINT rowstart, UINT rowend, 625 675 INT maxx, INT mcy) 626 676 /* Function: This routine distributes the extra space in a row. */ 627 677 /* See algorithm below. */ … … 635 685 636 686 TRACE("start=%u, end=%u, max x=%d, max y=%d\n", 637 687 rowstart, rowend, maxx, mcy); 638 688 639 689 /* ******************* Phase 1 ************************ */ … … 643 693 /* or band's ->ccx reached. */ 644 694 /* If any band modified, add any space left to last band */ 645 /* adjusted. */ 695 /* adjusted. */ 646 696 /* */ 647 697 /* ****************************************************** */ … … 649 699 extra = maxx - rcBrb(lpBand); 650 700 x = 0; 651 last_adjusted = 0;701 last_adjusted = -1; 652 702 for (i=(INT)rowstart; i<=(INT)rowend; i++) { 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 } 696 if ((x >= maxx) || last_adjusted) {697 698 ERR("Phase 1 failed, x=%d, maxx=%d, start=%u, end=%u\n", 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 703 lpBand = &infoPtr->bands[i]; 704 if (HIDDENBAND(lpBand)) continue; 705 xsep = (x == 0) ? 0 : SEP_WIDTH; 706 curwidth = rcBw(lpBand); 707 708 /* set new left/top point */ 709 if (infoPtr->dwStyle & CCS_VERT) 710 lpBand->rcBand.top = x + xsep; 711 else 712 lpBand->rcBand.left = x + xsep; 713 714 /* compute new width */ 715 if (lpBand->hwndChild && extra) { 716 /* set to the "current" band size less the header */ 717 fudge = lpBand->ccx; 718 last_adjusted = i; 719 if ((lpBand->fMask & RBBIM_SIZE) && (lpBand->cx > 0) && 720 (fudge > curwidth)) { 721 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d, extra=%d\n", 722 i, fudge-curwidth, fudge, curwidth, extra); 723 if ((fudge - curwidth) > extra) 724 fudge = curwidth + extra; 725 extra -= (fudge - curwidth); 726 curwidth = fudge; 727 } 728 else { 729 TRACE("adjusting band %d by %d, fudge=%d, curwidth=%d\n", 730 i, extra, fudge, curwidth); 731 curwidth += extra; 732 extra = 0; 733 } 734 } 735 736 /* set new right/bottom point */ 737 if (infoPtr->dwStyle & CCS_VERT) 738 lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth; 739 else 740 lpBand->rcBand.right = lpBand->rcBand.left + curwidth; 741 TRACE("Phase 1 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n", 742 i, lpBand->rcBand.left, lpBand->rcBand.top, 743 lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep); 744 x = rcBrb(lpBand); 745 } 746 if ((x >= maxx) || (last_adjusted != -1)) { 747 if (x > maxx) { 748 ERR("Phase 1 failed, x=%d, maxx=%d, start=%u, end=%u\n", 749 x, maxx, rowstart, rowend); 750 } 751 /* done, so spread extra space */ 752 if (x < maxx) { 753 fudge = maxx - x; 754 TRACE("Need to spread %d on last adjusted band %d\n", 755 fudge, last_adjusted); 756 for (i=(INT)last_adjusted; i<=(INT)rowend; i++) { 757 lpBand = &infoPtr->bands[i]; 758 if (HIDDENBAND(lpBand)) continue; 759 760 /* set right/bottom point */ 761 if (i != last_adjusted) { 762 if (infoPtr->dwStyle & CCS_VERT) 763 lpBand->rcBand.top += fudge; 764 else 765 lpBand->rcBand.left += fudge; 766 } 767 768 /* set left/bottom point */ 769 if (infoPtr->dwStyle & CCS_VERT) 770 lpBand->rcBand.bottom += fudge; 771 else 772 lpBand->rcBand.right += fudge; 773 } 774 } 775 TRACE("Phase 1 succeeded, used x=%d\n", x); 776 REBAR_FixVert (infoPtr, rowstart, rowend, mcy); 777 return; 728 778 } 729 779 … … 737 787 x = 0; 738 788 for (i=(INT)rowstart; i<=(INT)rowend; i++) { 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 789 lpBand = &infoPtr->bands[i]; 790 if (HIDDENBAND(lpBand)) continue; 791 xsep = (x == 0) ? 0 : SEP_WIDTH; 792 curwidth = rcBw(lpBand); 793 794 /* set new left/top point */ 795 if (infoPtr->dwStyle & CCS_VERT) 796 lpBand->rcBand.top = x + xsep; 797 else 798 lpBand->rcBand.left = x + xsep; 799 800 /* compute new width */ 801 if (extra) { 802 curwidth += extra; 803 extra = 0; 804 } 805 806 /* set new right/bottom point */ 807 if (infoPtr->dwStyle & CCS_VERT) 808 lpBand->rcBand.bottom = lpBand->rcBand.top + curwidth; 809 else 810 lpBand->rcBand.right = lpBand->rcBand.left + curwidth; 811 TRACE("Phase 2 band %d, (%d,%d)-(%d,%d), orig x=%d, xsep=%d\n", 812 i, lpBand->rcBand.left, lpBand->rcBand.top, 813 lpBand->rcBand.right, lpBand->rcBand.bottom, x, xsep); 814 x = rcBrb(lpBand); 765 815 } 766 816 if (x >= maxx) { 767 768 ERR("Phase 2 failed, x=%d, maxx=%d, start=%u, end=%u\n", 769 770 771 772 773 774 817 if (x > maxx) { 818 ERR("Phase 2 failed, x=%d, maxx=%d, start=%u, end=%u\n", 819 x, maxx, rowstart, rowend); 820 } 821 /* done, so spread extra space */ 822 TRACE("Phase 2 succeeded, used x=%d\n", x); 823 REBAR_FixVert (infoPtr, rowstart, rowend, mcy); 824 return; 775 825 } 776 826 … … 782 832 lpBand = &infoPtr->bands[rowstart]; 783 833 ERR("Serious problem adjusting row %d, start band %d, end band %d\n", 784 834 lpBand->iRow, rowstart, rowend); 785 835 REBAR_DumpBand (infoPtr); 786 836 return; … … 806 856 if (HIDDENBAND(lpBand)) { 807 857 SetRect (&lpBand->rcChild, 808 809 810 858 lpBand->rcBand.right, lpBand->rcBand.top, 859 lpBand->rcBand.right, lpBand->rcBand.bottom); 860 continue; 811 861 } 812 862 … … 815 865 /* set initial gripper rectangle */ 816 866 SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top, 817 867 lpBand->rcBand.left, lpBand->rcBand.bottom); 818 868 819 869 /* calculate gripper rectangle */ 820 870 if ( lpBand->fStatus & HAS_GRIPPER) { 821 822 823 824 825 826 827 828 829 871 lpBand->fDraw |= DRAW_GRIPPER; 872 lpBand->rcGripper.left += REBAR_PRE_GRIPPER; 873 lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH; 874 lpBand->rcGripper.top += 2; 875 lpBand->rcGripper.bottom -= 2; 876 877 SetRect (&lpBand->rcCapImage, 878 lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.top, 879 lpBand->rcGripper.right+REBAR_ALWAYS_SPACE, lpBand->rcBand.bottom); 830 880 } 831 881 else { /* no gripper will be drawn */ 832 833 834 835 836 SetRect (&lpBand->rcCapImage, 837 838 882 xoff = 0; 883 if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT)) 884 /* if no gripper but either image or text, then leave space */ 885 xoff = REBAR_ALWAYS_SPACE; 886 SetRect (&lpBand->rcCapImage, 887 lpBand->rcBand.left+xoff, lpBand->rcBand.top, 888 lpBand->rcBand.left+xoff, lpBand->rcBand.bottom); 839 889 } 840 890 841 891 /* image is visible */ 842 892 if (lpBand->fStatus & HAS_IMAGE) { 843 844 845 846 847 848 849 850 851 /* update band height 852 853 854 855 893 lpBand->fDraw |= DRAW_IMAGE; 894 lpBand->rcCapImage.right += infoPtr->imageSize.cx; 895 lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy; 896 897 /* set initial caption text rectangle */ 898 SetRect (&lpBand->rcCapText, 899 lpBand->rcCapImage.right+REBAR_POST_IMAGE, lpBand->rcBand.top+1, 900 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1); 901 /* update band height 902 if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) { 903 lpBand->uMinHeight = infoPtr->imageSize.cy + 2; 904 lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight; 905 } */ 856 906 } 857 907 else { 858 859 860 908 /* set initial caption text rectangle */ 909 SetRect (&lpBand->rcCapText, lpBand->rcCapImage.right, lpBand->rcBand.top+1, 910 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.bottom-1); 861 911 } 862 912 863 913 /* text is visible */ 864 914 if (lpBand->fStatus & HAS_TEXT) { 865 866 lpBand->rcCapText.right = max(lpBand->rcCapText.left, 867 915 lpBand->fDraw |= DRAW_TEXT; 916 lpBand->rcCapText.right = max(lpBand->rcCapText.left, 917 lpBand->rcCapText.right-REBAR_POST_TEXT); 868 918 } 869 919 870 920 /* set initial child window rectangle if there is a child */ 871 921 if (lpBand->fMask & RBBIM_CHILD) { 872 873 874 875 876 922 xoff = lpBand->offChild.cx; 923 yoff = lpBand->offChild.cy; 924 SetRect (&lpBand->rcChild, 925 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top+yoff, 926 lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff); 877 927 } 878 928 else { 879 929 SetRect (&lpBand->rcChild, 880 881 930 lpBand->rcBand.left+lpBand->cxHeader, lpBand->rcBand.top, 931 lpBand->rcBand.right, lpBand->rcBand.bottom); 882 932 } 883 933 884 934 /* flag if notify required and invalidate rectangle */ 885 if (notify && 886 887 888 889 890 891 892 893 935 if (notify && 936 ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) || 937 (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) { 938 TRACE("Child rectangle changed for band %u\n", i); 939 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n", 940 oldChild.left, oldChild.top, 941 oldChild.right, oldChild.bottom, 942 lpBand->rcChild.left, lpBand->rcChild.top, 943 lpBand->rcChild.right, lpBand->rcChild.bottom); 894 944 } 895 945 if (lpBand->fDraw & NTF_INVALIDATE) { 896 897 lpBand->rcBand.left, 898 899 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0), 900 901 902 903 904 905 946 TRACE("invalidating (%d,%d)-(%d,%d)\n", 947 lpBand->rcBand.left, 948 lpBand->rcBand.top, 949 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0), 950 lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0)); 951 lpBand->fDraw &= ~NTF_INVALIDATE; 952 work = lpBand->rcBand; 953 if (lpBand->fDraw & DRAW_RIGHTSEP) work.right += SEP_WIDTH_SIZE; 954 if (lpBand->fDraw & DRAW_BOTTOMSEP) work.bottom += SEP_WIDTH_SIZE; 955 InvalidateRect(infoPtr->hwndSelf, &work, TRUE); 906 956 } 907 957 … … 926 976 927 977 for(i=rstart; i<rend; i++){ 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 lpBand->rcGripper.left += 3;956 lpBand->rcGripper.right -= 3;957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 SetRect (&lpBand->rcCapImage, 974 975 976 977 978 979 980 981 982 983 984 985 986 SetRect (&lpBand->rcCapText, 987 988 989 990 991 992 993 994 995 996 997 SetRect (&lpBand->rcCapText, 998 999 1000 1001 1002 1003 1004 1005 1006 lpBand->rcCapText.bottom-REBAR_POST_TEXT);1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 if (notify && 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 lpBand->rcBand.left, 1037 1038 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0), 1039 1040 1041 1042 1043 1044 1045 978 lpBand = &infoPtr->bands[i]; 979 if (HIDDENBAND(lpBand)) continue; 980 oldChild = lpBand->rcChild; 981 982 /* set initial gripper rectangle */ 983 SetRect (&lpBand->rcGripper, lpBand->rcBand.left, lpBand->rcBand.top, 984 lpBand->rcBand.right, lpBand->rcBand.top); 985 986 /* calculate gripper rectangle */ 987 if (lpBand->fStatus & HAS_GRIPPER) { 988 lpBand->fDraw |= DRAW_GRIPPER; 989 990 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER) { 991 /* vertical gripper */ 992 lpBand->rcGripper.left += 3; 993 lpBand->rcGripper.right = lpBand->rcGripper.left + GRIPPER_WIDTH; 994 lpBand->rcGripper.top += REBAR_PRE_GRIPPER; 995 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_HEIGHT; 996 997 /* initialize Caption image rectangle */ 998 SetRect (&lpBand->rcCapImage, lpBand->rcBand.left, 999 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE, 1000 lpBand->rcBand.right, 1001 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE); 1002 } 1003 else { 1004 /* horizontal gripper */ 1005 lpBand->rcGripper.left += 2; 1006 lpBand->rcGripper.right -= 2; 1007 lpBand->rcGripper.top += REBAR_PRE_GRIPPER; 1008 lpBand->rcGripper.bottom = lpBand->rcGripper.top + GRIPPER_WIDTH; 1009 1010 /* initialize Caption image rectangle */ 1011 SetRect (&lpBand->rcCapImage, lpBand->rcBand.left, 1012 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE, 1013 lpBand->rcBand.right, 1014 lpBand->rcGripper.bottom + REBAR_ALWAYS_SPACE); 1015 } 1016 } 1017 else { /* no gripper will be drawn */ 1018 xoff = 0; 1019 if (lpBand->fStatus & (HAS_IMAGE | HAS_TEXT)) 1020 /* if no gripper but either image or text, then leave space */ 1021 xoff = REBAR_ALWAYS_SPACE; 1022 /* initialize Caption image rectangle */ 1023 SetRect (&lpBand->rcCapImage, 1024 lpBand->rcBand.left, lpBand->rcBand.top+xoff, 1025 lpBand->rcBand.right, lpBand->rcBand.top+xoff); 1026 } 1027 1028 /* image is visible */ 1029 if (lpBand->fStatus & HAS_IMAGE) { 1030 lpBand->fDraw |= DRAW_IMAGE; 1031 1032 lpBand->rcCapImage.right = lpBand->rcCapImage.left + infoPtr->imageSize.cx; 1033 lpBand->rcCapImage.bottom += infoPtr->imageSize.cy; 1034 1035 /* set initial caption text rectangle */ 1036 SetRect (&lpBand->rcCapText, 1037 lpBand->rcBand.left, lpBand->rcCapImage.bottom+REBAR_POST_IMAGE, 1038 lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader); 1039 /* update band height * 1040 if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) { 1041 lpBand->uMinHeight = infoPtr->imageSize.cx + 2; 1042 lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight; 1043 } */ 1044 } 1045 else { 1046 /* set initial caption text rectangle */ 1047 SetRect (&lpBand->rcCapText, 1048 lpBand->rcBand.left, lpBand->rcCapImage.bottom, 1049 lpBand->rcBand.right, lpBand->rcBand.top+lpBand->cxHeader); 1050 } 1051 1052 /* text is visible */ 1053 if (lpBand->fStatus & HAS_TEXT) { 1054 lpBand->fDraw |= DRAW_TEXT; 1055 lpBand->rcCapText.bottom = max(lpBand->rcCapText.top, 1056 lpBand->rcCapText.bottom); 1057 } 1058 1059 /* set initial child window rectangle if there is a child */ 1060 if (lpBand->fMask & RBBIM_CHILD) { 1061 yoff = lpBand->offChild.cx; 1062 xoff = lpBand->offChild.cy; 1063 SetRect (&lpBand->rcChild, 1064 lpBand->rcBand.left+xoff, lpBand->rcBand.top+lpBand->cxHeader, 1065 lpBand->rcBand.right-xoff, lpBand->rcBand.bottom-yoff); 1066 } 1067 else { 1068 SetRect (&lpBand->rcChild, 1069 lpBand->rcBand.left, lpBand->rcBand.top+lpBand->cxHeader, 1070 lpBand->rcBand.right, lpBand->rcBand.bottom); 1071 } 1072 1073 /* flag if notify required and invalidate rectangle */ 1074 if (notify && 1075 ((oldChild.right-oldChild.left != lpBand->rcChild.right-lpBand->rcChild.left) || 1076 (oldChild.bottom-oldChild.top != lpBand->rcChild.bottom-lpBand->rcChild.top))) { 1077 TRACE("Child rectangle changed for band %u\n", i); 1078 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n", 1079 oldChild.left, oldChild.top, 1080 oldChild.right, oldChild.bottom, 1081 lpBand->rcChild.left, lpBand->rcChild.top, 1082 lpBand->rcChild.right, lpBand->rcChild.bottom); 1083 } 1084 if (lpBand->fDraw & NTF_INVALIDATE) { 1085 TRACE("invalidating (%d,%d)-(%d,%d)\n", 1086 lpBand->rcBand.left, 1087 lpBand->rcBand.top, 1088 lpBand->rcBand.right + ((lpBand->fDraw & DRAW_BOTTOMSEP) ? SEP_WIDTH_SIZE : 0), 1089 lpBand->rcBand.bottom + ((lpBand->fDraw & DRAW_RIGHTSEP) ? SEP_WIDTH_SIZE : 0)); 1090 lpBand->fDraw &= ~NTF_INVALIDATE; 1091 work = lpBand->rcBand; 1092 if (lpBand->fDraw & DRAW_RIGHTSEP) work.bottom += SEP_WIDTH_SIZE; 1093 if (lpBand->fDraw & DRAW_BOTTOMSEP) work.right += SEP_WIDTH_SIZE; 1094 InvalidateRect(infoPtr->hwndSelf, &work, TRUE); 1095 } 1046 1096 1047 1097 } … … 1055 1105 { 1056 1106 RECT rc; 1107 INT x, y, width, height; 1108 INT xedge = GetSystemMetrics(SM_CXEDGE); 1109 INT yedge = GetSystemMetrics(SM_CYEDGE); 1057 1110 1058 1111 /* TEST TEST TEST */ … … 1064 1117 1065 1118 TRACE( " old [%ld x %ld], new [%ld x %ld], client [%d x %d]\n", 1066 1067 1068 1119 infoPtr->oldSize.cx, infoPtr->oldSize.cy, 1120 infoPtr->calcSize.cx, infoPtr->calcSize.cy, 1121 rc.right, rc.bottom); 1069 1122 1070 1123 /* If we need to shrink client, then skip size test */ 1071 1124 if ((infoPtr->calcSize.cy >= rc.bottom) && 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1125 (infoPtr->calcSize.cx >= rc.right)) { 1126 1127 /* if size did not change then skip process */ 1128 if ((infoPtr->oldSize.cx == infoPtr->calcSize.cx) && 1129 (infoPtr->oldSize.cy == infoPtr->calcSize.cy) && 1130 !(infoPtr->fStatus & RESIZE_ANYHOW)) 1131 { 1132 TRACE("skipping reset\n"); 1133 return; 1134 } 1082 1135 } 1083 1136 … … 1086 1139 infoPtr->fStatus |= AUTO_RESIZE; 1087 1140 1088 rc.left = 0; 1089 rc.top = 0; 1090 rc.right = infoPtr->calcSize.cx; 1091 rc.bottom = infoPtr->calcSize.cy; 1092 1093 InflateRect (&rc, 0, GetSystemMetrics(SM_CYEDGE)); 1094 /* see comments in _NCCalcSize for reason below is not done */ 1095 #if 0 1096 if (GetWindowLongA (infoPtr->hwndSelf, GWL_STYLE) & WS_BORDER) { 1097 InflateRect (&rc, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE)); 1098 } 1099 #endif 1100 1101 TRACE("setting to (0,0)-(%d,%d)\n", 1102 rc.right - rc.left, rc.bottom - rc.top); 1103 SetWindowPos (infoPtr->hwndSelf, 0, 0, 0, 1104 rc.right - rc.left, rc.bottom - rc.top, 1105 SWP_NOMOVE | SWP_NOZORDER | SWP_SHOWWINDOW); 1141 width = 0; 1142 height = 0; 1143 x = 0; 1144 y = 0; 1145 1146 if (infoPtr->dwStyle & WS_BORDER) { 1147 width = 2 * xedge; 1148 height = 2 * yedge; 1149 } 1150 1151 if (!(infoPtr->dwStyle & CCS_NOPARENTALIGN)) { 1152 INT mode = infoPtr->dwStyle & (CCS_VERT | CCS_TOP | CCS_BOTTOM); 1153 RECT rcPcl; 1154 1155 GetClientRect(GetParent(infoPtr->hwndSelf), &rcPcl); 1156 switch (mode) { 1157 case CCS_TOP: 1158 /* _TOP sets width to parents width */ 1159 width += (rcPcl.right - rcPcl.left); 1160 height += infoPtr->calcSize.cy; 1161 x += ((infoPtr->dwStyle & WS_BORDER) ? -xedge : 0); 1162 y += ((infoPtr->dwStyle & WS_BORDER) ? -yedge : 0); 1163 y += ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER); 1164 break; 1165 case CCS_BOTTOM: 1166 /* FIXME: wrong wrong wrong */ 1167 /* _BOTTOM sets width to parents width */ 1168 width += (rcPcl.right - rcPcl.left); 1169 height += infoPtr->calcSize.cy; 1170 x += -xedge; 1171 y = rcPcl.bottom - height + 1; 1172 break; 1173 case CCS_LEFT: 1174 /* _LEFT sets height to parents height */ 1175 width += infoPtr->calcSize.cx; 1176 height += (rcPcl.bottom - rcPcl.top); 1177 x += ((infoPtr->dwStyle & WS_BORDER) ? -xedge : 0); 1178 x += ((infoPtr->dwStyle & CCS_NODIVIDER) ? 0 : REBAR_DIVIDER); 1179 y += ((infoPtr->dwStyle & WS_BORDER) ? -yedge : 0); 1180 break; 1181 case CCS_RIGHT: 1182 /* FIXME: wrong wrong wrong */ 1183 /* _RIGHT sets height to parents height */ 1184 width += infoPtr->calcSize.cx; 1185 height += (rcPcl.bottom - rcPcl.top); 1186 x = rcPcl.right - width + 1; 1187 y = -yedge; 1188 break; 1189 default: 1190 width += infoPtr->calcSize.cx; 1191 height += infoPtr->calcSize.cy; 1192 } 1193 } 1194 else { 1195 width += infoPtr->calcSize.cx; 1196 height += infoPtr->calcSize.cy; 1197 } 1198 1199 TRACE("hwnd %04x, style=%08lx, setting at (%d,%d) for (%d,%d)\n", 1200 infoPtr->hwndSelf, infoPtr->dwStyle, 1201 x, y, width, height); 1202 SetWindowPos (infoPtr->hwndSelf, 0, x, y, width, height, 1203 SWP_NOZORDER); 1106 1204 } 1107 1205 … … 1121 1219 1122 1220 for (i = start; i < endplus; i++) { 1123 lpBand = &infoPtr->bands[i]; 1124 1125 if (HIDDENBAND(lpBand)) continue; 1126 if (lpBand->hwndChild) { 1127 TRACE("hwndChild = %x\n", lpBand->hwndChild); 1128 1129 /* Always geterate the RBN_CHILDSIZE even it child 1130 did not change */ 1131 rbcz.uBand = i; 1132 rbcz.wID = lpBand->wID; 1133 rbcz.rcChild = lpBand->rcChild; 1134 rbcz.rcBand = lpBand->rcBand; 1135 rbcz.rcBand.left += lpBand->cxHeader; 1136 REBAR_Notify ((NMHDR *)&rbcz, infoPtr, RBN_CHILDSIZE); 1137 if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) { 1138 TRACE("Child rect changed by NOTIFY for band %u\n", i); 1139 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n", 1140 lpBand->rcChild.left, lpBand->rcChild.top, 1141 lpBand->rcChild.right, lpBand->rcChild.bottom, 1142 rbcz.rcChild.left, rbcz.rcChild.top, 1143 rbcz.rcChild.right, rbcz.rcChild.bottom); 1144 } 1145 1146 GetClassNameA (lpBand->hwndChild, szClassName, 40); 1147 if (!lstrcmpA (szClassName, "ComboBox") || 1148 !lstrcmpA (szClassName, WC_COMBOBOXEXA)) { 1149 INT nEditHeight, yPos; 1150 RECT rc; 1151 1152 /* special placement code for combo or comboex box */ 1153 1154 1155 /* get size of edit line */ 1156 GetWindowRect (lpBand->hwndChild, &rc); 1157 nEditHeight = rc.bottom - rc.top; 1158 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2; 1159 1160 /* center combo box inside child area */ 1161 TRACE("moving child (Combo(Ex)) %04x to (%d,%d) for (%d,%d)\n", 1162 lpBand->hwndChild, 1163 lpBand->rcChild.left, yPos, 1164 lpBand->rcChild.right - lpBand->rcChild.left, 1165 nEditHeight); 1166 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP, 1167 lpBand->rcChild.left, 1168 /*lpBand->rcChild.top*/ yPos, 1169 lpBand->rcChild.right - lpBand->rcChild.left, 1170 nEditHeight, 1171 SWP_NOZORDER); 1172 if (!deferpos) 1173 ERR("DeferWindowPos returned NULL\n"); 1174 } 1175 else { 1176 TRACE("moving child (Other) %04x to (%d,%d) for (%d,%d)\n", 1177 lpBand->hwndChild, 1178 lpBand->rcChild.left, lpBand->rcChild.top, 1179 lpBand->rcChild.right - lpBand->rcChild.left, 1180 lpBand->rcChild.bottom - lpBand->rcChild.top); 1181 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP, 1182 lpBand->rcChild.left, 1183 lpBand->rcChild.top, 1184 lpBand->rcChild.right - lpBand->rcChild.left, 1185 lpBand->rcChild.bottom - lpBand->rcChild.top, 1186 SWP_NOZORDER); 1187 if (!deferpos) 1188 ERR("DeferWindowPos returned NULL\n"); 1189 } 1190 } 1221 lpBand = &infoPtr->bands[i]; 1222 1223 if (HIDDENBAND(lpBand)) continue; 1224 if (lpBand->hwndChild) { 1225 TRACE("hwndChild = %x\n", lpBand->hwndChild); 1226 1227 /* Always geterate the RBN_CHILDSIZE even it child 1228 did not change */ 1229 rbcz.uBand = i; 1230 rbcz.wID = lpBand->wID; 1231 rbcz.rcChild = lpBand->rcChild; 1232 rbcz.rcBand = lpBand->rcBand; 1233 rbcz.rcBand.left += lpBand->cxHeader; 1234 REBAR_Notify ((NMHDR *)&rbcz, infoPtr, RBN_CHILDSIZE); 1235 if (!EqualRect (&lpBand->rcChild, &rbcz.rcChild)) { 1236 TRACE("Child rect changed by NOTIFY for band %u\n", i); 1237 TRACE(" from (%d,%d)-(%d,%d) to (%d,%d)-(%d,%d)\n", 1238 lpBand->rcChild.left, lpBand->rcChild.top, 1239 lpBand->rcChild.right, lpBand->rcChild.bottom, 1240 rbcz.rcChild.left, rbcz.rcChild.top, 1241 rbcz.rcChild.right, rbcz.rcChild.bottom); 1242 lpBand->rcChild = rbcz.rcChild; /* *** ??? */ 1243 } 1244 1245 /* native (IE4 in "Favorites" frame **1) does: 1246 * SetRect (&rc, -1, -1, -1, -1) 1247 * EqualRect (&rc,band->rc???) 1248 * if ret==0 1249 * CopyRect (band->rc????, &rc) 1250 * set flag outside of loop 1251 */ 1252 1253 GetClassNameA (lpBand->hwndChild, szClassName, 40); 1254 if (!lstrcmpA (szClassName, "ComboBox") || 1255 !lstrcmpA (szClassName, WC_COMBOBOXEXA)) { 1256 INT nEditHeight, yPos; 1257 RECT rc; 1258 1259 /* special placement code for combo or comboex box */ 1260 1261 1262 /* get size of edit line */ 1263 GetWindowRect (lpBand->hwndChild, &rc); 1264 nEditHeight = rc.bottom - rc.top; 1265 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2; 1266 1267 /* center combo box inside child area */ 1268 TRACE("moving child (Combo(Ex)) %04x to (%d,%d) for (%d,%d)\n", 1269 lpBand->hwndChild, 1270 lpBand->rcChild.left, yPos, 1271 lpBand->rcChild.right - lpBand->rcChild.left, 1272 nEditHeight); 1273 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP, 1274 lpBand->rcChild.left, 1275 /*lpBand->rcChild.top*/ yPos, 1276 lpBand->rcChild.right - lpBand->rcChild.left, 1277 nEditHeight, 1278 SWP_NOZORDER); 1279 if (!deferpos) 1280 ERR("DeferWindowPos returned NULL\n"); 1281 } 1282 else { 1283 TRACE("moving child (Other) %04x to (%d,%d) for (%d,%d)\n", 1284 lpBand->hwndChild, 1285 lpBand->rcChild.left, lpBand->rcChild.top, 1286 lpBand->rcChild.right - lpBand->rcChild.left, 1287 lpBand->rcChild.bottom - lpBand->rcChild.top); 1288 deferpos = DeferWindowPos (deferpos, lpBand->hwndChild, HWND_TOP, 1289 lpBand->rcChild.left, 1290 lpBand->rcChild.top, 1291 lpBand->rcChild.right - lpBand->rcChild.left, 1292 lpBand->rcChild.bottom - lpBand->rcChild.top, 1293 SWP_NOZORDER); 1294 if (!deferpos) 1295 ERR("DeferWindowPos returned NULL\n"); 1296 } 1297 } 1191 1298 } 1192 1299 if (!EndDeferWindowPos(deferpos)) 1193 1300 ERR("EndDeferWindowPos returned NULL\n"); 1301 1302 UpdateWindow (infoPtr->hwndSelf); 1303 1194 1304 if (infoPtr->fStatus & NTF_HGHTCHG) { 1195 1305 infoPtr->fStatus &= ~NTF_HGHTCHG; 1196 1306 REBAR_Notify (&heightchange, infoPtr, RBN_HEIGHTCHANGE); 1197 1307 } 1308 1309 /* native (from **1 above) does: 1310 * UpdateWindow(rebar) 1311 * REBAR_ForceResize 1312 * RBN_HEIGHTCHANGE if necessary 1313 * if ret from any EqualRect was 0 1314 * Goto "BeginDeferWindowPos" 1315 */ 1316 1198 1317 } 1199 1318 … … 1207 1326 REBAR_BAND *lpBand, *prevBand; 1208 1327 RECT rcClient, rcAdj; 1209 INT x, y, cx, cxsep, mmcy, mcy, clientcx, clientcy;1328 INT initx, inity, x, y, cx, cxsep, mmcy, mcy, clientcx, clientcy; 1210 1329 INT adjcx, adjcy, row, rightx, bottomy, origheight; 1211 UINT i, j, rowstart ;1330 UINT i, j, rowstart, origrows; 1212 1331 BOOL dobreak; 1213 1332 1214 1333 if (!(infoPtr->fStatus & BAND_NEEDS_LAYOUT)) { 1215 1216 1217 1334 TRACE("no layout done. No band changed.\n"); 1335 REBAR_DumpBand (infoPtr); 1336 return; 1218 1337 } 1219 1338 infoPtr->fStatus &= ~BAND_NEEDS_LAYOUT; … … 1222 1341 GetClientRect (infoPtr->hwndSelf, &rcClient); 1223 1342 TRACE("Client is (%d,%d)-(%d,%d)\n", 1224 1343 rcClient.left, rcClient.top, rcClient.right, rcClient.bottom); 1225 1344 1226 1345 if (lpRect) { 1227 1228 1229 1346 rcAdj = *lpRect; 1347 TRACE("adjustment rect is (%d,%d)-(%d,%d)\n", 1348 rcAdj.left, rcAdj.top, rcAdj.right, rcAdj.bottom); 1230 1349 } 1231 1350 else { … … 1244 1363 1245 1364 if (!infoPtr->DoRedraw && (clientcx == 0) && (clientcy == 0)) { 1246 1247 1248 1365 ERR("no redraw and client is zero, skip layout\n"); 1366 infoPtr->fStatus |= BAND_NEEDS_LAYOUT; 1367 return; 1249 1368 } 1250 1369 1251 1370 /* save height of original control */ 1252 if (infoPtr->dwStyle & CCS_VERT) 1371 if (infoPtr->dwStyle & CCS_VERT) 1253 1372 origheight = infoPtr->calcSize.cx; 1254 1373 else 1255 1374 origheight = infoPtr->calcSize.cy; 1256 1375 origrows = infoPtr->uNumRows; 1376 1377 initx = 0; 1378 inity = 0; 1257 1379 1258 1380 /* ******* Start Phase 1 - all bands on row at minimum size ******* */ 1259 1381 1260 TRACE("band loop constants, clientcx=%d, clientcy=%d \n",1261 clientcx, clientcy);1262 x = 0;1263 y = 0;1382 TRACE("band loop constants, clientcx=%d, clientcy=%d, adjcx=%d, adjcy=%d\n", 1383 clientcx, clientcy, adjcx, adjcy); 1384 x = initx; 1385 y = inity; 1264 1386 row = 1; 1265 1387 cx = 0; … … 1269 1391 1270 1392 for (i = 0; i < infoPtr->uNumBands; i++) { 1271 lpBand = &infoPtr->bands[i]; 1272 lpBand->fDraw = 0; 1273 lpBand->iRow = row; 1274 1275 if (HIDDENBAND(lpBand)) continue; 1276 1277 lpBand->rcoldBand = lpBand->rcBand; 1278 1279 /* separator from previous band */ 1280 cxsep = ( ((infoPtr->dwStyle & CCS_VERT) ? y : x)==0) ? 0 : SEP_WIDTH; 1281 1282 /* Header: includes gripper, text, image */ 1283 cx = lpBand->cxHeader; 1284 if (lpBand->fStyle & RBBS_FIXEDSIZE) cx = lpBand->lcx; 1285 1286 if (infoPtr->dwStyle & CCS_VERT) 1287 dobreak = (y + cx + cxsep > adjcy); 1393 lpBand = &infoPtr->bands[i]; 1394 lpBand->fDraw = 0; 1395 lpBand->iRow = row; 1396 1397 if (HIDDENBAND(lpBand)) continue; 1398 1399 lpBand->rcoldBand = lpBand->rcBand; 1400 1401 /* Set the offset of the child window */ 1402 if ((lpBand->fMask & RBBIM_CHILD) && 1403 !(lpBand->fStyle & RBBS_FIXEDSIZE)) { 1404 lpBand->offChild.cx = 4; /* ??? */ 1405 } 1406 lpBand->offChild.cy = ((lpBand->fStyle & RBBS_CHILDEDGE) ? 2 : 0); 1407 1408 /* separator from previous band */ 1409 cxsep = ( ((infoPtr->dwStyle & CCS_VERT) ? y==inity : x==initx)) ? 1410 0 : SEP_WIDTH; 1411 1412 /* Header: includes gripper, text, image */ 1413 cx = lpBand->cxHeader; 1414 if (lpBand->fStyle & RBBS_FIXEDSIZE) cx = lpBand->lcx; 1415 1416 if (infoPtr->dwStyle & CCS_VERT) 1417 dobreak = (y + cx + cxsep > adjcy); 1288 1418 else 1289 dobreak = (x + cx + cxsep > adjcx); 1290 1291 /* This is the check for whether we need to start a new row */ 1292 if ( ( (lpBand->fStyle & RBBS_BREAK) && (i != 0) ) || 1293 ( ((infoPtr->dwStyle & CCS_VERT) ? (y != 0) : (x != 0)) && dobreak)) { 1294 1295 for (j = rowstart; j < i; j++) { 1296 REBAR_BAND *lpB; 1297 lpB = &infoPtr->bands[j]; 1298 if (infoPtr->dwStyle & CCS_VERT) { 1299 lpB->rcBand.right = lpB->rcBand.left + mcy; 1300 } 1301 else { 1302 lpB->rcBand.bottom = lpB->rcBand.top + mcy; 1303 } 1304 } 1305 1306 TRACE("Spliting to new row %d on band %u\n", row+1, i); 1307 if (infoPtr->dwStyle & CCS_VERT) { 1308 y = 0; 1309 x += (mcy + SEP_WIDTH); 1310 } 1311 else { 1312 x = 0; 1313 y += (mcy + SEP_WIDTH); 1314 } 1315 1316 mcy = 0; 1317 cxsep = 0; 1318 row++; 1319 lpBand->iRow = row; 1320 prevBand = NULL; 1321 rowstart = i; 1322 } 1323 1324 if (mcy < lpBand->lcy + REBARSPACE) mcy = lpBand->lcy + REBARSPACE; 1325 1326 /* if boundary rect specified then limit mcy */ 1327 if (lpRect) { 1328 if (infoPtr->dwStyle & CCS_VERT) { 1329 if (x+mcy > adjcx) { 1330 mcy = adjcx - x; 1331 TRACE("row %u limiting mcy=%d, adjcx=%d, x=%d\n", 1332 i, mcy, adjcx, x); 1333 } 1334 } 1335 else { 1336 if (y+mcy > adjcy) { 1337 mcy = adjcy - y; 1338 TRACE("row %u limiting mcy=%d, adjcy=%d, y=%d\n", 1339 i, mcy, adjcy, y); 1340 } 1341 } 1342 } 1343 1344 TRACE("band %u, row %d, x=%d, y=%d, cxsep=%d, cx=%d\n", 1345 i, row, 1346 x, y, cxsep, cx); 1347 if (infoPtr->dwStyle & CCS_VERT) { 1348 /* bound the bottom side if we have a bounding rectangle */ 1349 rightx = clientcx; 1350 bottomy = (lpRect) ? min(clientcy, y+cxsep+cx) : y+cxsep+cx; 1351 lpBand->rcBand.left = x; 1352 lpBand->rcBand.right = x + min(mcy, lpBand->lcy+REBARSPACE); 1353 lpBand->rcBand.top = min(bottomy, y + cxsep); 1354 lpBand->rcBand.bottom = bottomy; 1355 lpBand->uMinHeight = lpBand->lcy; 1356 y = bottomy; 1357 } 1358 else { 1359 /* bound the right side if we have a bounding rectangle */ 1360 rightx = (lpRect) ? min(clientcx, x+cxsep+cx) : x+cxsep+cx; 1361 bottomy = clientcy; 1362 lpBand->rcBand.left = min(rightx, x + cxsep); 1363 lpBand->rcBand.right = rightx; 1364 lpBand->rcBand.top = y; 1365 lpBand->rcBand.bottom = y + min(mcy, lpBand->lcy+REBARSPACE); 1366 lpBand->uMinHeight = lpBand->lcy; 1367 x = rightx; 1368 } 1369 TRACE("band %u, row %d, (%d,%d)-(%d,%d)\n", 1370 i, row, 1371 lpBand->rcBand.left, lpBand->rcBand.top, 1372 lpBand->rcBand.right, lpBand->rcBand.bottom); 1373 prevBand = lpBand; 1419 dobreak = (x + cx + cxsep > adjcx); 1420 1421 /* This is the check for whether we need to start a new row */ 1422 if ( ( (lpBand->fStyle & RBBS_BREAK) && (i != 0) ) || 1423 ( ((infoPtr->dwStyle & CCS_VERT) ? (y != 0) : (x != 0)) && dobreak)) { 1424 1425 for (j = rowstart; j < i; j++) { 1426 REBAR_BAND *lpB; 1427 lpB = &infoPtr->bands[j]; 1428 if (infoPtr->dwStyle & CCS_VERT) { 1429 lpB->rcBand.right = lpB->rcBand.left + mcy; 1430 } 1431 else { 1432 lpB->rcBand.bottom = lpB->rcBand.top + mcy; 1433 } 1434 } 1435 1436 TRACE("P1 Spliting to new row %d on band %u\n", row+1, i); 1437 if (infoPtr->dwStyle & CCS_VERT) { 1438 y = inity; 1439 x += (mcy + SEP_WIDTH); 1440 } 1441 else { 1442 x = initx; 1443 y += (mcy + SEP_WIDTH); 1444 } 1445 1446 mcy = 0; 1447 cxsep = 0; 1448 row++; 1449 lpBand->iRow = row; 1450 prevBand = NULL; 1451 rowstart = i; 1452 } 1453 1454 if (mcy < lpBand->lcy + REBARSPACE(lpBand)) 1455 mcy = lpBand->lcy + REBARSPACE(lpBand); 1456 1457 /* if boundary rect specified then limit mcy */ 1458 if (lpRect) { 1459 if (infoPtr->dwStyle & CCS_VERT) { 1460 if (x+mcy > adjcx) { 1461 mcy = adjcx - x; 1462 TRACE("P1 row %u limiting mcy=%d, adjcx=%d, x=%d\n", 1463 i, mcy, adjcx, x); 1464 } 1465 } 1466 else { 1467 if (y+mcy > adjcy) { 1468 mcy = adjcy - y; 1469 TRACE("P1 row %u limiting mcy=%d, adjcy=%d, y=%d\n", 1470 i, mcy, adjcy, y); 1471 } 1472 } 1473 } 1474 1475 TRACE("P1 band %u, row %d, x=%d, y=%d, cxsep=%d, cx=%d\n", 1476 i, row, 1477 x, y, cxsep, cx); 1478 if (infoPtr->dwStyle & CCS_VERT) { 1479 /* bound the bottom side if we have a bounding rectangle */ 1480 rightx = clientcx; 1481 bottomy = (lpRect) ? min(clientcy, y+cxsep+cx) : y+cxsep+cx; 1482 lpBand->rcBand.left = x; 1483 lpBand->rcBand.right = x + min(mcy, 1484 lpBand->lcy+REBARSPACE(lpBand)); 1485 lpBand->rcBand.top = min(bottomy, y + cxsep); 1486 lpBand->rcBand.bottom = bottomy; 1487 lpBand->uMinHeight = lpBand->lcy; 1488 y = bottomy; 1489 } 1490 else { 1491 /* bound the right side if we have a bounding rectangle */ 1492 rightx = (lpRect) ? min(clientcx, x+cxsep+cx) : x+cxsep+cx; 1493 bottomy = clientcy; 1494 lpBand->rcBand.left = min(rightx, x + cxsep); 1495 lpBand->rcBand.right = rightx; 1496 lpBand->rcBand.top = y; 1497 lpBand->rcBand.bottom = y + min(mcy, 1498 lpBand->lcy+REBARSPACE(lpBand)); 1499 lpBand->uMinHeight = lpBand->lcy; 1500 x = rightx; 1501 } 1502 TRACE("P1 band %u, row %d, (%d,%d)-(%d,%d)\n", 1503 i, row, 1504 lpBand->rcBand.left, lpBand->rcBand.top, 1505 lpBand->rcBand.right, lpBand->rcBand.bottom); 1506 prevBand = lpBand; 1374 1507 1375 1508 } /* for (i = 0; i < infoPtr->uNumBands... */ … … 1381 1514 1382 1515 for (j = rowstart; j < infoPtr->uNumBands; j++) { 1383 1384 1385 1386 1387 1388 1389 1516 lpBand = &infoPtr->bands[j]; 1517 if (infoPtr->dwStyle & CCS_VERT) { 1518 lpBand->rcBand.right = lpBand->rcBand.left + mcy; 1519 } 1520 else { 1521 lpBand->rcBand.bottom = lpBand->rcBand.top + mcy; 1522 } 1390 1523 } 1391 1524 … … 1400 1533 mmcy = 0; 1401 1534 if (!(infoPtr->dwStyle & RBS_VARHEIGHT)) { 1402 1403 1404 1405 1406 1407 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 1535 INT xy; 1536 1537 /* get the max height of all bands */ 1538 for (i=0; i<infoPtr->uNumBands; i++) { 1539 lpBand = &infoPtr->bands[i]; 1540 if (HIDDENBAND(lpBand)) continue; 1541 if (infoPtr->dwStyle & CCS_VERT) 1542 mmcy = max(mmcy, lpBand->rcBand.right - lpBand->rcBand.left); 1543 else 1544 mmcy = max(mmcy, lpBand->rcBand.bottom - lpBand->rcBand.top); 1545 } 1546 1547 /* now adjust all rectangles by using the height found above */ 1548 xy = 0; 1549 row = 1; 1550 for (i=0; i<infoPtr->uNumBands; i++) { 1551 lpBand = &infoPtr->bands[i]; 1552 if (HIDDENBAND(lpBand)) continue; 1553 if (lpBand->iRow != row) 1554 xy += (mmcy + SEP_WIDTH); 1555 if (infoPtr->dwStyle & CCS_VERT) { 1556 lpBand->rcBand.left = xy; 1557 lpBand->rcBand.right = xy + mmcy; 1558 } 1559 else { 1560 lpBand->rcBand.top = xy; 1561 lpBand->rcBand.bottom = xy + mmcy; 1562 } 1563 } 1564 1565 /* set the x/y values to the correct maximum */ 1566 if (infoPtr->dwStyle & CCS_VERT) 1567 x = xy + mmcy; 1568 else 1569 y = xy + mmcy; 1437 1570 } 1438 1571 … … 1446 1579 if (lpRect) { 1447 1580 INT i, j, prev_rh, new_rh, adj_rh, prev_idx, current_idx; 1448 1581 REBAR_BAND *prev, *current, *walk; 1449 1582 1450 1583 /* FIXME: problem # 2 */ 1451 if (((infoPtr->dwStyle & CCS_VERT) ? 1584 if (((infoPtr->dwStyle & CCS_VERT) ? 1452 1585 #if PROBLEM2 1453 1586 (x < adjcx) : (y < adjcy) 1454 1587 #else 1455 1588 (adjcx - x > 4) : (adjcy - y > 4) 1456 1589 #endif 1457 1458 1459 1460 TRACE("adjcx=%d, adjcy=%d, x=%d, y=%d\n",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 1487 1488 current->lcy + REBARSPACE:1489 1490 1491 1492 1493 1494 1495 current->rcBand.top = 0;1496 1497 1498 1499 1500 1501 1502 current->rcBand.left = 0;1503 1504 1505 1506 1507 1508 TRACE("moving band %d to own row at (%d,%d)-(%d,%d)\n",1509 1510 1511 1512 TRACE("prev band %d at (%d,%d)-(%d,%d)\n",1513 1514 1515 1516 TRACE("values: prev_rh=%d, new_rh=%d, adj_rh=%d\n",1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 if ((infoPtr->dwStyle & CCS_VERT) ? (x >= adjcx) : (y >= adjcy)) 1534 1535 1536 1537 1590 ) && 1591 (infoPtr->uNumBands > 1)) { 1592 for (i=(INT)infoPtr->uNumBands-2; i>=0; i--) { 1593 TRACE("P2 adjcx=%d, adjcy=%d, x=%d, y=%d\n", 1594 adjcx, adjcy, x, y); 1595 1596 /* find the current band (starts at i+1) */ 1597 current = &infoPtr->bands[i+1]; 1598 current_idx = i+1; 1599 while (HIDDENBAND(current)) { 1600 i--; 1601 if (i < 0) break; /* out of bands */ 1602 current = &infoPtr->bands[i+1]; 1603 current_idx = i+1; 1604 } 1605 if (i < 0) break; /* out of bands */ 1606 1607 /* now find the prev band (starts at i) */ 1608 prev = &infoPtr->bands[i]; 1609 prev_idx = i; 1610 while (HIDDENBAND(prev)) { 1611 i--; 1612 if (i < 0) break; /* out of bands */ 1613 prev = &infoPtr->bands[i]; 1614 prev_idx = i; 1615 } 1616 if (i < 0) break; /* out of bands */ 1617 1618 prev_rh = ircBw(prev); 1619 if (prev->iRow == current->iRow) { 1620 new_rh = (infoPtr->dwStyle & RBS_VARHEIGHT) ? 1621 current->lcy + REBARSPACE(current) : 1622 mmcy; 1623 adj_rh = new_rh + SEP_WIDTH; 1624 infoPtr->uNumRows++; 1625 current->fDraw |= NTF_INVALIDATE; 1626 current->iRow++; 1627 if (infoPtr->dwStyle & CCS_VERT) { 1628 current->rcBand.top = inity; 1629 current->rcBand.bottom = clientcy; 1630 current->rcBand.left += (prev_rh + SEP_WIDTH); 1631 current->rcBand.right = current->rcBand.left + new_rh; 1632 x += adj_rh; 1633 } 1634 else { 1635 current->rcBand.left = initx; 1636 current->rcBand.right = clientcx; 1637 current->rcBand.top += (prev_rh + SEP_WIDTH); 1638 current->rcBand.bottom = current->rcBand.top + new_rh; 1639 y += adj_rh; 1640 } 1641 TRACE("P2 moving band %d to own row at (%d,%d)-(%d,%d)\n", 1642 current_idx, 1643 current->rcBand.left, current->rcBand.top, 1644 current->rcBand.right, current->rcBand.bottom); 1645 TRACE("P2 prev band %d at (%d,%d)-(%d,%d)\n", 1646 prev_idx, 1647 prev->rcBand.left, prev->rcBand.top, 1648 prev->rcBand.right, prev->rcBand.bottom); 1649 TRACE("P2 values: prev_rh=%d, new_rh=%d, adj_rh=%d\n", 1650 prev_rh, new_rh, adj_rh); 1651 /* for bands below current adjust row # and top/bottom */ 1652 for (j = current_idx+1; j<infoPtr->uNumBands; j++) { 1653 walk = &infoPtr->bands[j]; 1654 if (HIDDENBAND(walk)) continue; 1655 walk->fDraw |= NTF_INVALIDATE; 1656 walk->iRow++; 1657 if (infoPtr->dwStyle & CCS_VERT) { 1658 walk->rcBand.left += adj_rh; 1659 walk->rcBand.right += adj_rh; 1660 } 1661 else { 1662 walk->rcBand.top += adj_rh; 1663 walk->rcBand.bottom += adj_rh; 1664 } 1665 } 1666 if ((infoPtr->dwStyle & CCS_VERT) ? (x >= adjcx) : (y >= adjcy)) 1667 break; /* all done */ 1668 } 1669 } 1670 } 1538 1671 } 1539 1672 … … 1541 1674 1542 1675 1543 /* ******* Start Phase 2a - adjust all bands for height full ******* */ 1676 /* ******* Start Phase 2a - create array of start and end ******* */ 1677 /* indexes by row */ 1678 1679 if (infoPtr->uNumRows != origrows) { 1680 if (infoPtr->rows) COMCTL32_Free (infoPtr->rows); 1681 infoPtr->rows = COMCTL32_Alloc (sizeof (REBAR_ROW) * infoPtr->uNumRows); 1682 } 1683 1684 row = 0; 1685 for (i = 0; i < infoPtr->uNumBands; i++) { 1686 lpBand = &infoPtr->bands[i]; 1687 if (HIDDENBAND(lpBand)) continue; 1688 1689 if (lpBand->iRow > row) { 1690 row++; 1691 infoPtr->rows[row-1].istartband = i; 1692 } 1693 if (row == 0) { 1694 ERR("P2a bug!!!!!!\n"); 1695 } 1696 infoPtr->rows[row-1].iendband = i; 1697 } 1698 1699 for (i = 0; i < infoPtr->uNumRows; i++) { 1700 REBAR_ROW *p; 1701 1702 p = &infoPtr->rows[i]; 1703 TRACE("P2a row %d, starts %d, ends %d\n", 1704 i+1, p->istartband, p->iendband); 1705 } 1706 1707 /* ******* End Phase 2a - create array of start and end ******* */ 1708 /* indexes by row */ 1709 1710 1711 /* ******* Start Phase 2b - adjust all bands for height full ******* */ 1544 1712 /* assumes that the following variables contain: */ 1545 1713 /* y/x current height/width of all rows */ 1546 1714 /* clientcy/clientcx height/width of client area */ 1547 1715 1548 /* **** FIXME FIXME FIXME1549 * this does not take into account that more than one band1550 * is in a row!!!!!!!!!1551 */1552 1553 1716 if (((infoPtr->dwStyle & CCS_VERT) ? clientcx > x : clientcy > y) && 1554 infoPtr->uNumBands) { 1555 INT diff, i, j; 1556 1557 diff = (infoPtr->dwStyle & CCS_VERT) ? clientcx - x : clientcy - y; 1558 for (i = infoPtr->uNumBands-1; i >= 0; i--) { 1559 lpBand = &infoPtr->bands[i]; 1560 if(HIDDENBAND(lpBand)) continue; 1561 if (!lpBand->fMask & RBBS_VARIABLEHEIGHT) continue; 1562 if (((INT)lpBand->cyMaxChild < 1) || 1563 ((INT)lpBand->cyIntegral < 1)) { 1564 if (lpBand->cyMaxChild + lpBand->cyIntegral == 0) continue; 1565 ERR("band %u RBBS_VARIABLEHEIGHT set but cyMax=%d, cyInt=%d\n", 1566 i, lpBand->cyMaxChild, lpBand->cyIntegral); 1567 continue; 1568 } 1569 /* j is now the maximum height/width in the client area */ 1570 j = ((diff / lpBand->cyIntegral) * lpBand->cyIntegral) + 1571 ircBw(lpBand); 1572 if (j > lpBand->cyMaxChild + REBARSPACE) 1573 j = lpBand->cyMaxChild + REBARSPACE; 1574 diff -= (j - ircBw(lpBand)); 1575 if (infoPtr->dwStyle & CCS_VERT) 1576 lpBand->rcBand.right = lpBand->rcBand.left + j; 1577 else 1578 lpBand->rcBand.bottom = lpBand->rcBand.top + j; 1579 TRACE("P2a band %d, row %d changed to (%d,%d)-(%d,%d)\n", 1580 i, lpBand->iRow, 1581 lpBand->rcBand.left, lpBand->rcBand.top, 1582 lpBand->rcBand.right, lpBand->rcBand.bottom); 1583 if (diff <= 0) break; 1584 } 1585 if (diff < 0) { 1586 ERR("allocated more than available, diff=%d\n", diff); 1587 diff = 0; 1588 } 1589 if (infoPtr->dwStyle & CCS_VERT) 1590 x = clientcx - diff; 1591 else 1592 y = clientcy - diff; 1593 } 1594 1595 /* ******* End Phase 2a - adjust all bands for height full ******* */ 1717 infoPtr->uNumBands) { 1718 INT diff, i, iband, j; 1719 1720 diff = (infoPtr->dwStyle & CCS_VERT) ? clientcx - x : clientcy - y; 1721 for (i = infoPtr->uNumRows; i >= 1; i--) { 1722 /* if row has more than 1 band, ignore row */ 1723 if (infoPtr->rows[i-1].istartband != infoPtr->rows[i-1].iendband) 1724 continue; 1725 /* point to only band in row */ 1726 iband = infoPtr->rows[i-1].istartband; 1727 lpBand = &infoPtr->bands[iband]; 1728 if(HIDDENBAND(lpBand)) continue; 1729 if (!lpBand->fMask & RBBS_VARIABLEHEIGHT) continue; 1730 if (((INT)lpBand->cyMaxChild < 1) || 1731 ((INT)lpBand->cyIntegral < 1)) { 1732 if (lpBand->cyMaxChild + lpBand->cyIntegral == 0) continue; 1733 ERR("P2b band %u RBBS_VARIABLEHEIGHT set but cyMax=%d, cyInt=%d\n", 1734 iband, lpBand->cyMaxChild, lpBand->cyIntegral); 1735 continue; 1736 } 1737 /* j is now the maximum height/width in the client area */ 1738 j = ((diff / lpBand->cyIntegral) * lpBand->cyIntegral) + 1739 ircBw(lpBand); 1740 if (j > lpBand->cyMaxChild + REBARSPACE(lpBand)) 1741 j = lpBand->cyMaxChild + REBARSPACE(lpBand); 1742 diff -= (j - ircBw(lpBand)); 1743 if (infoPtr->dwStyle & CCS_VERT) 1744 lpBand->rcBand.right = lpBand->rcBand.left + j; 1745 else 1746 lpBand->rcBand.bottom = lpBand->rcBand.top + j; 1747 TRACE("P2b band %d, row %d changed to (%d,%d)-(%d,%d)\n", 1748 iband, lpBand->iRow, 1749 lpBand->rcBand.left, lpBand->rcBand.top, 1750 lpBand->rcBand.right, lpBand->rcBand.bottom); 1751 if (diff <= 0) break; 1752 } 1753 if (diff < 0) { 1754 ERR("P2b allocated more than available, diff=%d\n", diff); 1755 diff = 0; 1756 } 1757 if (infoPtr->dwStyle & CCS_VERT) 1758 x = clientcx - diff; 1759 else 1760 y = clientcy - diff; 1761 } 1762 1763 /* ******* End Phase 2b - adjust all bands for height full ******* */ 1596 1764 1597 1765 … … 1599 1767 1600 1768 if (infoPtr->uNumBands) { 1601 INT bandnum, bandnum_start, bandnum_end; 1602 1603 /* If RBS_BANDBORDERS set then indicate to draw bottom separator */ 1604 /* on all bands in all rows but last row. */ 1605 /* Also indicate to draw the right separator for each band in */ 1606 /* each row but the rightmost band. */ 1607 if (infoPtr->dwStyle & RBS_BANDBORDERS) { 1608 REBAR_BAND *prevband; 1609 INT currow; 1610 1611 prevband = NULL; 1612 currow = -1; 1613 for (i = 0; i < infoPtr->uNumBands; i++) { 1614 lpBand = &infoPtr->bands[i]; 1615 if (HIDDENBAND(lpBand)) continue; 1616 1617 if (lpBand->iRow < infoPtr->uNumRows) 1618 lpBand->fDraw |= DRAW_BOTTOMSEP; 1619 1620 if (lpBand->iRow != currow) prevband = NULL; 1621 currow = lpBand->iRow; 1622 if (prevband) prevband->fDraw |= DRAW_RIGHTSEP; 1623 prevband = lpBand; 1624 } 1625 } 1626 1627 /* Distribute the extra space on the horizontal and adjust */ 1628 /* all bands in row to same height. */ 1629 bandnum = 0; 1630 for (i=1; i<=infoPtr->uNumRows; i++) { 1631 bandnum_start = -1; 1632 bandnum_end = -1; 1633 mcy = 0; 1634 TRACE("processing row %d, starting band %d\n", i, bandnum); 1635 while (TRUE) { 1636 lpBand = &infoPtr->bands[bandnum]; 1637 if ((bandnum >= infoPtr->uNumBands) || 1638 ((lpBand->iRow != i) && 1639 !HIDDENBAND(lpBand))) { 1640 if ((bandnum_start == -1) || 1641 (bandnum_end == -1)) { 1642 ERR("logic error? bands=%d, rows=%d, start=%d, end=%d\n", 1643 infoPtr->uNumBands, infoPtr->uNumRows, 1644 (INT)bandnum_start, (INT)bandnum_end); 1645 ERR(" current row=%d, band=%d\n", 1646 i, bandnum); 1647 break; 1648 } 1649 REBAR_AdjustBands (infoPtr, bandnum_start, bandnum_end, 1650 (infoPtr->dwStyle & CCS_VERT) ? 1651 clientcy : clientcx, mcy); 1652 break; 1653 } 1654 if (!HIDDENBAND(lpBand)) { 1655 if (bandnum_start == -1) bandnum_start = bandnum; 1656 if (bandnum_end < bandnum) bandnum_end = bandnum; 1657 if (mcy < ircBw(lpBand)) 1658 mcy = ircBw(lpBand); 1659 } 1660 bandnum++; 1661 TRACE("point 1, bandnum=%d\n", bandnum); 1662 } 1663 TRACE("point 2, i=%d, numrows=%d, bandnum=%d\n", 1664 i, infoPtr->uNumRows, bandnum); 1665 } 1666 TRACE("point 3\n"); 1667 1668 /* Calculate the other rectangles in each band */ 1669 if (infoPtr->dwStyle & CCS_VERT) { 1670 REBAR_CalcVertBand (infoPtr, 0, infoPtr->uNumBands, 1671 notify); 1672 } 1673 else { 1674 REBAR_CalcHorzBand (infoPtr, 0, infoPtr->uNumBands, 1675 notify); 1676 } 1769 REBAR_ROW *p; 1770 1771 /* If RBS_BANDBORDERS set then indicate to draw bottom separator */ 1772 /* on all bands in all rows but last row. */ 1773 /* Also indicate to draw the right separator for each band in */ 1774 /* each row but the rightmost band. */ 1775 if (infoPtr->dwStyle & RBS_BANDBORDERS) { 1776 1777 for(i = 0; i < infoPtr->uNumRows; i++) { 1778 p = &infoPtr->rows[i]; 1779 for (j = p->istartband; j <= p->iendband; j++) { 1780 lpBand = &infoPtr->bands[j]; 1781 if (HIDDENBAND(lpBand)) continue; 1782 if (j != p->iendband) 1783 lpBand->fDraw |= DRAW_RIGHTSEP; 1784 if (i != infoPtr->uNumRows-1) 1785 lpBand->fDraw |= DRAW_BOTTOMSEP; 1786 } 1787 } 1788 } 1789 1790 /* Distribute the extra space on the horizontal and adjust */ 1791 /* all bands in row to same height. */ 1792 for (i=1; i<=infoPtr->uNumRows; i++) { 1793 p = &infoPtr->rows[i-1]; 1794 mcy = 0; 1795 1796 TRACE("P3 processing row %d, starting band %d, ending band %d\n", 1797 i, p->istartband, p->iendband); 1798 1799 /* Find the largest height of the bands in the row */ 1800 for (j = p->istartband; j <= p->iendband; j++) { 1801 lpBand = &infoPtr->bands[j]; 1802 if (HIDDENBAND(lpBand)) continue; 1803 if (mcy < ircBw(lpBand)) 1804 mcy = ircBw(lpBand); 1805 } 1806 1807 REBAR_AdjustBands (infoPtr, p->istartband, p->iendband, 1808 (infoPtr->dwStyle & CCS_VERT) ? 1809 clientcy : clientcx, mcy); 1810 } 1811 1812 /* Calculate the other rectangles in each band */ 1813 if (infoPtr->dwStyle & CCS_VERT) { 1814 REBAR_CalcVertBand (infoPtr, 0, infoPtr->uNumBands, 1815 notify); 1816 } 1817 else { 1818 REBAR_CalcHorzBand (infoPtr, 0, infoPtr->uNumBands, 1819 notify); 1820 } 1677 1821 } 1678 1822 … … 1681 1825 /* now compute size of Rebar itself */ 1682 1826 infoPtr->oldSize = infoPtr->calcSize; 1827 if (infoPtr->uNumBands == 0) { 1828 /* we have no bands, so make size the size of client */ 1829 x = clientcx; 1830 y = clientcy; 1831 } 1683 1832 if (infoPtr->dwStyle & CCS_VERT) { 1684 1685 1686 1687 1688 1833 infoPtr->calcSize.cx = x; 1834 infoPtr->calcSize.cy = clientcy; 1835 TRACE("vert, notify=%d, x=%d, origheight=%d\n", 1836 notify, x, origheight); 1837 if (notify && (x != origheight)) infoPtr->fStatus |= NTF_HGHTCHG; 1689 1838 } 1690 1839 else { 1691 1692 1693 1694 1695 if (notify && (y != origheight)) infoPtr->fStatus |= NTF_HGHTCHG; 1840 infoPtr->calcSize.cx = clientcx; 1841 infoPtr->calcSize.cy = y; 1842 TRACE("horz, notify=%d, y=%d, origheight=%d\n", 1843 notify, y, origheight); 1844 if (notify && (y != origheight)) infoPtr->fStatus |= NTF_HGHTCHG; 1696 1845 } 1697 1846 … … 1750 1899 /* calculate gripper rectangle */ 1751 1900 if ( (!(lpBand->fStyle & RBBS_NOGRIPPER)) && 1752 ( (lpBand->fStyle & RBBS_GRIPPERALWAYS) || 1753 1901 ( (lpBand->fStyle & RBBS_GRIPPERALWAYS) || 1902 ( !(lpBand->fStyle & RBBS_FIXEDSIZE) && (infoPtr->uNumBands > 1))) 1754 1903 ) { 1755 1904 lpBand->fStatus |= HAS_GRIPPER; 1756 1905 if (infoPtr->dwStyle & CCS_VERT) 1757 1906 if (infoPtr->dwStyle & RBS_VERTICALGRIPPER) 1758 1907 header += (GRIPPER_HEIGHT + REBAR_PRE_GRIPPER); 1759 1908 else 1760 1909 header += (GRIPPER_WIDTH + REBAR_PRE_GRIPPER); 1761 1910 else 1762 1911 header += (REBAR_PRE_GRIPPER + GRIPPER_WIDTH); … … 1767 1916 /* image is visible */ 1768 1917 if ((lpBand->fMask & RBBIM_IMAGE) && (infoPtr->himl)) { 1769 1918 lpBand->fStatus |= HAS_IMAGE; 1770 1919 if (infoPtr->dwStyle & CCS_VERT) { 1771 1772 1773 1774 1775 1776 1777 1920 header += (infoPtr->imageSize.cy + REBAR_POST_IMAGE); 1921 lpBand->lcy = infoPtr->imageSize.cx + 2; 1922 } 1923 else { 1924 header += (infoPtr->imageSize.cx + REBAR_POST_IMAGE); 1925 lpBand->lcy = infoPtr->imageSize.cy + 2; 1926 } 1778 1927 } 1779 1928 1780 1929 /* text is visible */ 1781 1930 if ((lpBand->fMask & RBBIM_TEXT) && (lpBand->lpText)) { 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1931 HDC hdc = GetDC (0); 1932 HFONT hOldFont = SelectObject (hdc, infoPtr->hFont); 1933 SIZE size; 1934 1935 lpBand->fStatus |= HAS_TEXT; 1936 GetTextExtentPoint32W (hdc, lpBand->lpText, 1937 lstrlenW (lpBand->lpText), &size); 1938 header += ((infoPtr->dwStyle & CCS_VERT) ? (size.cy + REBAR_POST_TEXT) : (size.cx + REBAR_POST_TEXT)); 1939 textheight = (infoPtr->dwStyle & CCS_VERT) ? 0 : size.cy; 1940 1941 SelectObject (hdc, hOldFont); 1942 ReleaseDC (0, hdc); 1794 1943 } 1795 1944 1796 1945 /* if no gripper but either image or text, then leave space */ 1797 1946 if ((lpBand->fStatus & (HAS_IMAGE | HAS_TEXT)) && 1798 1799 1947 !(lpBand->fStatus & HAS_GRIPPER)) { 1948 header += REBAR_ALWAYS_SPACE; 1800 1949 } 1801 1950 … … 1811 1960 lpBand->ccy = lpBand->lcy; 1812 1961 if (lpBand->fMask & RBBIM_CHILDSIZE) { 1813 if (!(lpBand->fStyle & RBBS_FIXEDSIZE)) {1814 lpBand->offChild.cx = 4;1815 lpBand->offChild.cy = 2;1816 }1817 1962 lpBand->lcx = lpBand->cxMinChild; 1818 1963 1819 1964 /* Set the .cy values for CHILDSIZE case */ 1820 1965 lpBand->lcy = max(lpBand->lcy, lpBand->cyMinChild); 1821 1966 lpBand->ccy = lpBand->lcy; 1822 1967 lpBand->hcy = lpBand->lcy; 1823 1968 if (lpBand->cyMaxChild != 0xffffffff) { 1824 1969 lpBand->hcy = lpBand->cyMaxChild; 1825 1970 } 1826 1827 1971 if (lpBand->cyChild != 0xffffffff) 1972 lpBand->ccy = max (lpBand->cyChild, lpBand->lcy); 1828 1973 1829 1974 TRACE("_CHILDSIZE\n"); … … 1852 1997 1853 1998 if (lprbbi->fMask & RBBIM_STYLE) 1854 1999 lpBand->fStyle = lprbbi->fStyle; 1855 2000 1856 2001 if (lprbbi->fMask & RBBIM_COLORS) { 1857 1858 2002 lpBand->clrFore = lprbbi->clrFore; 2003 lpBand->clrBack = lprbbi->clrBack; 1859 2004 } 1860 2005 1861 2006 if (lprbbi->fMask & RBBIM_IMAGE) 1862 2007 lpBand->iImage = lprbbi->iImage; 1863 2008 1864 2009 if (lprbbi->fMask & RBBIM_CHILD) { 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 2010 if (lprbbi->hwndChild) { 2011 lpBand->hwndChild = lprbbi->hwndChild; 2012 lpBand->hwndPrevParent = 2013 SetParent (lpBand->hwndChild, hwnd); 2014 /* below in trace fro WinRAR */ 2015 ShowWindow(lpBand->hwndChild, SW_SHOWNOACTIVATE | SW_SHOWNORMAL); 2016 /* above in trace fro WinRAR */ 2017 } 2018 else { 2019 TRACE("child: 0x%x prev parent: 0x%x\n", 2020 lpBand->hwndChild, lpBand->hwndPrevParent); 2021 lpBand->hwndChild = 0; 2022 lpBand->hwndPrevParent = 0; 2023 } 1879 2024 } 1880 2025 1881 2026 if (lprbbi->fMask & RBBIM_CHILDSIZE) { 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 2027 lpBand->cxMinChild = lprbbi->cxMinChild; 2028 lpBand->cyMinChild = lprbbi->cyMinChild; 2029 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) { 2030 lpBand->cyChild = lprbbi->cyChild; 2031 lpBand->cyMaxChild = lprbbi->cyMaxChild; 2032 lpBand->cyIntegral = lprbbi->cyIntegral; 2033 } 2034 else { /* special case - these should be zeroed out since */ 2035 /* RBBIM_CHILDSIZE added these in WIN32_IE >= 0x0400 */ 2036 lpBand->cyChild = 0; 2037 lpBand->cyMaxChild = 0; 2038 lpBand->cyIntegral = 0; 2039 } 1895 2040 } 1896 2041 1897 2042 if (lprbbi->fMask & RBBIM_SIZE) 1898 2043 lpBand->cx = lprbbi->cx; 1899 2044 1900 2045 if (lprbbi->fMask & RBBIM_BACKGROUND) 1901 2046 lpBand->hbmBack = lprbbi->hbmBack; 1902 2047 1903 2048 if (lprbbi->fMask & RBBIM_ID) 1904 2049 lpBand->wID = lprbbi->wID; 1905 2050 1906 2051 /* check for additional data */ 1907 2052 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) { 1908 1909 1910 1911 1912 1913 1914 1915 2053 if (lprbbi->fMask & RBBIM_IDEALSIZE) 2054 lpBand->cxIdeal = lprbbi->cxIdeal; 2055 2056 if (lprbbi->fMask & RBBIM_LPARAM) 2057 lpBand->lParam = lprbbi->lParam; 2058 2059 if (lprbbi->fMask & RBBIM_HEADERSIZE) 2060 lpBand->cxHeader = lprbbi->cxHeader; 1916 2061 } 1917 2062 } … … 1933 2078 for(i=0; i<infoPtr->uNumBands; i++) { 1934 2079 lpBand = &infoPtr->bands[i]; 1935 if (HIDDENBAND(lpBand)) continue; 1936 1937 /* draw band separator between rows */ 1938 if (lpBand->iRow != oldrow) { 1939 oldrow = lpBand->iRow; 1940 if (lpBand->fDraw & DRAW_BOTTOMSEP) { 1941 RECT rcRowSep; 1942 rcRowSep = lpBand->rcBand; 1943 if (infoPtr->dwStyle & CCS_VERT) { 1944 rcRowSep.right += SEP_WIDTH_SIZE; 1945 rcRowSep.bottom = infoPtr->calcSize.cy; 1946 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_RIGHT); 1947 } 1948 else { 1949 rcRowSep.bottom += SEP_WIDTH_SIZE; 1950 rcRowSep.right = infoPtr->calcSize.cx; 1951 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_BOTTOM); 1952 } 1953 TRACE ("drawing band separator bottom (%d,%d)-(%d,%d)\n", 1954 rcRowSep.left, rcRowSep.top, 1955 rcRowSep.right, rcRowSep.bottom); 1956 } 1957 } 1958 1959 /* draw band separator between bands in a row */ 1960 if (lpBand->fDraw & DRAW_RIGHTSEP) { 1961 RECT rcSep; 1962 rcSep = lpBand->rcBand; 1963 if (infoPtr->dwStyle & CCS_VERT) { 1964 rcSep.bottom += SEP_WIDTH_SIZE; 1965 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_BOTTOM); 1966 } 1967 else { 1968 rcSep.right += SEP_WIDTH_SIZE; 1969 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_RIGHT); 1970 } 1971 TRACE("drawing band separator right (%d,%d)-(%d,%d)\n", 1972 rcSep.left, rcSep.top, rcSep.right, rcSep.bottom); 1973 } 1974 1975 /* draw the actual background */ 1976 if (lpBand->clrBack != CLR_NONE) 1977 new = lpBand->clrBack; 1978 else 1979 new = infoPtr->clrBtnFace; 1980 rect = lpBand->rcBand; 1981 old = SetBkColor (hdc, new); 1982 TRACE("%s backround color=0x%06lx, band (%d,%d)-(%d,%d), clip (%d,%d)-(%d,%d)\n", 1983 (lpBand->clrBack == CLR_NONE) ? "std" : "", 1984 new, 1985 lpBand->rcBand.left,lpBand->rcBand.top, 1986 lpBand->rcBand.right,lpBand->rcBand.bottom, 1987 clip->left, clip->top, 1988 clip->right, clip->bottom); 1989 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, 0); 1990 SetBkColor (hdc, old); 2080 if (HIDDENBAND(lpBand)) continue; 2081 2082 /* draw band separator between rows */ 2083 if (lpBand->iRow != oldrow) { 2084 oldrow = lpBand->iRow; 2085 if (lpBand->fDraw & DRAW_BOTTOMSEP) { 2086 RECT rcRowSep; 2087 rcRowSep = lpBand->rcBand; 2088 if (infoPtr->dwStyle & CCS_VERT) { 2089 rcRowSep.right += SEP_WIDTH_SIZE; 2090 rcRowSep.bottom = infoPtr->calcSize.cy; 2091 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_RIGHT); 2092 } 2093 else { 2094 rcRowSep.bottom += SEP_WIDTH_SIZE; 2095 rcRowSep.right = infoPtr->calcSize.cx; 2096 DrawEdge (hdc, &rcRowSep, EDGE_ETCHED, BF_BOTTOM); 2097 } 2098 TRACE ("drawing band separator bottom (%d,%d)-(%d,%d)\n", 2099 rcRowSep.left, rcRowSep.top, 2100 rcRowSep.right, rcRowSep.bottom); 2101 } 2102 } 2103 2104 /* draw band separator between bands in a row */ 2105 if (lpBand->fDraw & DRAW_RIGHTSEP) { 2106 RECT rcSep; 2107 rcSep = lpBand->rcBand; 2108 if (infoPtr->dwStyle & CCS_VERT) { 2109 rcSep.bottom += SEP_WIDTH_SIZE; 2110 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_BOTTOM); 2111 } 2112 else { 2113 rcSep.right += SEP_WIDTH_SIZE; 2114 DrawEdge (hdc, &rcSep, EDGE_ETCHED, BF_RIGHT); 2115 } 2116 TRACE("drawing band separator right (%d,%d)-(%d,%d)\n", 2117 rcSep.left, rcSep.top, rcSep.right, rcSep.bottom); 2118 } 2119 2120 /* draw the actual background */ 2121 if (lpBand->clrBack != CLR_NONE) 2122 new = lpBand->clrBack; 2123 else 2124 new = infoPtr->clrBtnFace; 2125 rect = lpBand->rcBand; 2126 #if GLATESTING 2127 /* testing only - make background green to see it */ 2128 new = RGB(0,128,0); 2129 #endif 2130 old = SetBkColor (hdc, new); 2131 TRACE("%s background color=0x%06lx, band (%d,%d)-(%d,%d), clip (%d,%d)-(%d,%d)\n", 2132 (lpBand->clrBack == CLR_NONE) ? "std" : "", 2133 new, 2134 lpBand->rcBand.left,lpBand->rcBand.top, 2135 lpBand->rcBand.right,lpBand->rcBand.bottom, 2136 clip->left, clip->top, 2137 clip->right, clip->bottom); 2138 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, 0); 2139 SetBkColor (hdc, old); 1991 2140 } 1992 2141 return TRUE; … … 2005 2154 if (PtInRect (&rect, *lpPt)) 2006 2155 { 2007 if (infoPtr->uNumBands == 0) { 2008 *pFlags = RBHT_NOWHERE; 2009 if (pBand) 2010 *pBand = -1; 2011 TRACE("NOWHERE\n"); 2012 return; 2156 if (infoPtr->uNumBands == 0) { 2157 *pFlags = RBHT_NOWHERE; 2158 if (pBand) 2159 *pBand = -1; 2160 TRACE("NOWHERE\n"); 2161 return; 2162 } 2163 else { 2164 /* somewhere inside */ 2165 infoPtr->ihitBand = -1; 2166 for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) { 2167 lpBand = &infoPtr->bands[iCount]; 2168 if (HIDDENBAND(lpBand)) continue; 2169 if (PtInRect (&lpBand->rcBand, *lpPt)) { 2170 if (pBand) 2171 *pBand = iCount; 2172 if (PtInRect (&lpBand->rcGripper, *lpPt)) { 2173 *pFlags = RBHT_GRABBER; 2174 infoPtr->ihitBand = iCount; 2175 TRACE("ON GRABBER %d\n", iCount); 2176 return; 2177 } 2178 else if (PtInRect (&lpBand->rcCapImage, *lpPt)) { 2179 *pFlags = RBHT_CAPTION; 2180 TRACE("ON CAPTION %d\n", iCount); 2181 return; 2182 } 2183 else if (PtInRect (&lpBand->rcCapText, *lpPt)) { 2184 *pFlags = RBHT_CAPTION; 2185 TRACE("ON CAPTION %d\n", iCount); 2186 return; 2187 } 2188 else if (PtInRect (&lpBand->rcChild, *lpPt)) { 2189 *pFlags = RBHT_CLIENT; 2190 TRACE("ON CLIENT %d\n", iCount); 2191 return; 2192 } 2193 else { 2194 *pFlags = RBHT_NOWHERE; 2195 TRACE("NOWHERE %d\n", iCount); 2196 return; 2197 } 2198 } 2199 } 2200 2201 *pFlags = RBHT_NOWHERE; 2202 if (pBand) 2203 *pBand = -1; 2204 2205 TRACE("NOWHERE\n"); 2206 return; 2207 } 2013 2208 } 2014 2209 else { 2015 /* somewhere inside */ 2016 infoPtr->ihitBand = -1; 2017 for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) { 2018 lpBand = &infoPtr->bands[iCount]; 2019 if (HIDDENBAND(lpBand)) continue; 2020 if (PtInRect (&lpBand->rcBand, *lpPt)) { 2021 if (pBand) 2022 *pBand = iCount; 2023 if (PtInRect (&lpBand->rcGripper, *lpPt)) { 2024 *pFlags = RBHT_GRABBER; 2025 infoPtr->ihitBand = iCount; 2026 TRACE("ON GRABBER %d\n", iCount); 2027 return; 2028 } 2029 else if (PtInRect (&lpBand->rcCapImage, *lpPt)) { 2030 *pFlags = RBHT_CAPTION; 2031 TRACE("ON CAPTION %d\n", iCount); 2032 return; 2033 } 2034 else if (PtInRect (&lpBand->rcCapText, *lpPt)) { 2035 *pFlags = RBHT_CAPTION; 2036 TRACE("ON CAPTION %d\n", iCount); 2037 return; 2038 } 2039 else if (PtInRect (&lpBand->rcChild, *lpPt)) { 2040 *pFlags = RBHT_CLIENT; 2041 TRACE("ON CLIENT %d\n", iCount); 2042 return; 2043 } 2044 else { 2045 *pFlags = RBHT_NOWHERE; 2046 TRACE("NOWHERE %d\n", iCount); 2047 return; 2048 } 2049 } 2050 } 2051 2052 *pFlags = RBHT_NOWHERE; 2053 if (pBand) 2054 *pBand = -1; 2055 2056 TRACE("NOWHERE\n"); 2057 return; 2058 } 2059 } 2060 else { 2061 *pFlags = RBHT_NOWHERE; 2062 if (pBand) 2063 *pBand = -1; 2064 TRACE("NOWHERE\n"); 2065 return; 2210 *pFlags = RBHT_NOWHERE; 2211 if (pBand) 2212 *pBand = -1; 2213 TRACE("NOWHERE\n"); 2214 return; 2066 2215 } 2067 2216 … … 2092 2241 /* if this band is not shrinkable, then just move it */ 2093 2242 Leadjust = Readjust = movement; 2094 2243 ret = movement; 2095 2244 } 2096 2245 else { 2097 2246 if (movement < 0) { 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2247 /* Drag to left */ 2248 if (avail <= abs(movement)) { 2249 Readjust = movement; 2250 Leadjust = movement + avail; 2251 ret = Leadjust; 2252 } 2253 else { 2254 Readjust = movement; 2255 Leadjust = 0; 2256 ret = 0; 2257 } 2258 } 2259 else { 2260 /* Drag to right */ 2261 if (avail <= abs(movement)) { 2262 Leadjust = movement; 2263 Readjust = movement - avail; 2264 ret = Readjust; 2265 } 2266 else { 2267 Leadjust = movement; 2268 Readjust = 0; 2269 ret = 0; 2270 } 2271 } 2123 2272 } 2124 2273 … … 2126 2275 if (rcBlt(band) + Leadjust < 0) { 2127 2276 ERR("adjustment will fail, band %d: left=%d, right=%d, move=%d, rtn=%d\n", 2128 2277 i, Leadjust, Readjust, movement, ret); 2129 2278 } 2130 2279 … … 2133 2282 2134 2283 TRACE("band %d: left=%d, right=%d, move=%d, rtn=%d, rcBand=(%d,%d)-(%d,%d)\n", 2135 2136 2137 2284 i, Leadjust, Readjust, movement, ret, 2285 band->rcBand.left, band->rcBand.top, 2286 band->rcBand.right, band->rcBand.bottom); 2138 2287 return ret; 2139 2288 } … … 2158 2307 2159 2308 if (!(infoPtr->fStatus & BEGIN_DRAG_ISSUED)) { 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2309 if (REBAR_Notify_NMREBAR (infoPtr, -1, RBN_BEGINDRAG)) { 2310 /* Notify returned TRUE - abort drag */ 2311 infoPtr->dragStart.x = 0; 2312 infoPtr->dragStart.y = 0; 2313 infoPtr->dragNow = infoPtr->dragStart; 2314 infoPtr->ihitBand = -1; 2315 ReleaseCapture (); 2316 return ; 2317 } 2318 infoPtr->fStatus |= BEGIN_DRAG_ISSUED; 2170 2319 } 2171 2320 … … 2177 2326 for (i=0; i<infoPtr->uNumBands; i++) { 2178 2327 band = &infoPtr->bands[i]; 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 else 2189 2190 2191 2328 if (HIDDENBAND(band)) continue; 2329 if (band->iRow == hitBand->iRow) { 2330 imaxdBand = i; 2331 if (imindBand == -1) imindBand = i; 2332 /* minimum size of each band is size of header plus */ 2333 /* size of minimum child plus offset of child from header plus */ 2334 /* a one to separate each band. */ 2335 if (i < ihitBand) 2336 LHeaderSum += (band->lcx + SEP_WIDTH); 2337 else 2338 RHeaderSum += (band->lcx + SEP_WIDTH); 2339 2340 } 2192 2341 } 2193 2342 if (RHeaderSum) RHeaderSum -= SEP_WIDTH; /* no separator afterlast band */ … … 2201 2350 /* limit movement to inside adjustable bands - Left */ 2202 2351 if ( (ptsmove->x < mindBand->rcBand.left) || 2203 2204 2205 2352 (ptsmove->x > maxdBand->rcBand.right) || 2353 (ptsmove->y < mindBand->rcBand.top) || 2354 (ptsmove->y > maxdBand->rcBand.bottom)) 2206 2355 return; /* should swap bands */ 2207 2356 2208 2357 if (infoPtr->dwStyle & CCS_VERT) 2209 2358 movement = ptsmove->y - ((hitBand->rcBand.top+REBAR_PRE_GRIPPER) - 2210 2359 infoPtr->ihitoffset); 2211 2360 else 2212 2361 movement = ptsmove->x - ((hitBand->rcBand.left+REBAR_PRE_GRIPPER) - 2213 2362 infoPtr->ihitoffset); 2214 2363 infoPtr->dragNow = *ptsmove; 2215 2364 2216 2365 TRACE("before: movement=%d (%d,%d), imindBand=%d, ihitBand=%d, imaxdBand=%d, LSum=%d, RSum=%d\n", 2217 2218 2366 movement, ptsmove->x, ptsmove->y, imindBand, ihitBand, 2367 imaxdBand, LHeaderSum, RHeaderSum); 2219 2368 REBAR_DumpBand (infoPtr); 2220 2369 2221 if (movement < 0) { 2370 if (movement < 0) { 2222 2371 2223 2372 /* *** Drag left/up *** */ 2224 2373 compress = rcBlt(hitBand) - rcBlt(mindBand) - 2225 2226 2227 2228 2229 2230 2374 LHeaderSum; 2375 if (compress < abs(movement)) { 2376 TRACE("limiting left drag, was %d changed to %d\n", 2377 movement, -compress); 2378 movement = -compress; 2379 } 2231 2380 2232 2381 for (i=ihitBand; i>=imindBand; i--) { 2233 2234 2235 2236 2237 2238 else 2239 2240 2241 2382 band = &infoPtr->bands[i]; 2383 if (HIDDENBAND(band)) continue; 2384 if (i == ihitBand) { 2385 LEADJ(band, movement) 2386 } 2387 else 2388 movement = REBAR_Shrink (infoPtr, band, movement, i); 2389 band->ccx = rcBw(band); 2390 } 2242 2391 } 2243 2392 else { 2244 2393 BOOL first = TRUE; 2245 2394 2246 2395 /* *** Drag right/down *** */ 2247 2396 compress = rcBrb(maxdBand) - rcBlt(hitBand) - 2248 2249 2250 2251 2252 2253 2397 RHeaderSum; 2398 if (compress < abs(movement)) { 2399 TRACE("limiting right drag, was %d changed to %d\n", 2400 movement, compress); 2401 movement = compress; 2402 } 2254 2403 for (i=ihitBand-1; i<=imaxdBand; i++) { 2255 2256 2257 2258 2259 2260 2261 else 2262 2263 2264 2404 band = &infoPtr->bands[i]; 2405 if (HIDDENBAND(band)) continue; 2406 if (first) { 2407 first = FALSE; 2408 READJ(band, movement) 2409 } 2410 else 2411 movement = REBAR_Shrink (infoPtr, band, movement, i); 2412 band->ccx = rcBw(band); 2413 } 2265 2414 } 2266 2415 2267 2416 /* recompute all rectangles */ 2268 2417 if (infoPtr->dwStyle & CCS_VERT) { 2269 2270 2418 REBAR_CalcVertBand (infoPtr, imindBand, imaxdBand+1, 2419 FALSE); 2271 2420 } 2272 2421 else { 2273 REBAR_CalcHorzBand (infoPtr, imindBand, imaxdBand+1, 2274 2422 REBAR_CalcHorzBand (infoPtr, imindBand, imaxdBand+1, 2423 FALSE); 2275 2424 } 2276 2425 2277 2426 TRACE("bands after adjustment, see band # %d, %d\n", 2278 2427 imindBand, imaxdBand); 2279 2428 REBAR_DumpBand (infoPtr); 2280 2429 2281 SetRect (&newrect, 2282 2283 2284 2285 2430 SetRect (&newrect, 2431 mindBand->rcBand.left, 2432 mindBand->rcBand.top, 2433 maxdBand->rcBand.right, 2434 maxdBand->rcBand.bottom); 2286 2435 2287 2436 REBAR_MoveChildWindows (infoPtr, imindBand, imaxdBand+1); … … 2305 2454 2306 2455 if (uBand >= infoPtr->uNumBands) 2307 2456 return FALSE; 2308 2457 2309 2458 TRACE("deleting band %u!\n", uBand); … … 2312 2461 2313 2462 if (infoPtr->uNumBands == 1) { 2314 2315 2316 2317 2318 2319 2463 TRACE(" simple delete!\n"); 2464 if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild) 2465 childhwnd = lpBand->hwndChild; 2466 COMCTL32_Free (infoPtr->bands); 2467 infoPtr->bands = NULL; 2468 infoPtr->uNumBands = 0; 2320 2469 } 2321 2470 else { 2322 2471 REBAR_BAND *oldBands = infoPtr->bands; 2323 2472 TRACE("complex delete! [uBand=%u]\n", uBand); 2324 2473 2325 2326 2327 2328 2329 2474 if ((lpBand->fMask & RBBIM_CHILD) && lpBand->hwndChild) 2475 childhwnd = lpBand->hwndChild; 2476 2477 infoPtr->uNumBands--; 2478 infoPtr->bands = COMCTL32_Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands); 2330 2479 if (uBand > 0) { 2331 2480 memcpy (&infoPtr->bands[0], &oldBands[0], … … 2338 2487 } 2339 2488 2340 2489 COMCTL32_Free (oldBands); 2341 2490 } 2342 2491 … … 2370 2519 2371 2520 if (!lParam) 2372 2521 return 0; 2373 2522 if ((UINT)wParam >= infoPtr->uNumBands) 2374 2523 return 0; 2375 2524 2376 2525 lpBand = &infoPtr->bands[(UINT)wParam]; … … 2382 2531 /* style. - GA */ 2383 2532 if (infoPtr->dwStyle & RBS_BANDBORDERS) { 2384 if (infoPtr->dwStyle & CCS_VERT) { 2385 lpRect->left = 1; 2386 lpRect->top = lpBand->cxHeader + 4; 2387 lpRect->right = 1; 2388 lpRect->bottom = 0; 2533 if (infoPtr->dwStyle & CCS_VERT) { 2534 lpRect->left = 1; 2535 lpRect->top = lpBand->cxHeader + 4; 2536 lpRect->right = 1; 2537 lpRect->bottom = 0; 2538 } 2539 else { 2540 lpRect->left = lpBand->cxHeader + 4; 2541 lpRect->top = 1; 2542 lpRect->right = 0; 2543 lpRect->bottom = 1; 2544 } 2389 2545 } 2390 2546 else { 2391 lpRect->left = lpBand->cxHeader + 4; 2392 lpRect->top = 1; 2393 lpRect->right = 0; 2394 lpRect->bottom = 1; 2395 } 2396 } 2397 else { 2398 lpRect->left = lpBand->cxHeader; 2547 lpRect->left = lpBand->cxHeader; 2399 2548 } 2400 2549 return 0; … … 2418 2567 2419 2568 if (lprbbi == NULL) 2420 2569 return FALSE; 2421 2570 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA) 2422 2571 return FALSE; 2423 2572 if ((UINT)wParam >= infoPtr->uNumBands) 2424 2573 return FALSE; 2425 2574 2426 2575 TRACE("index %u\n", (UINT)wParam); … … 2430 2579 2431 2580 if (lprbbi->fMask & RBBIM_STYLE) 2432 2581 lprbbi->fStyle = lpBand->fStyle; 2433 2582 2434 2583 if (lprbbi->fMask & RBBIM_COLORS) { 2435 2436 2437 2438 2584 lprbbi->clrFore = lpBand->clrFore; 2585 lprbbi->clrBack = lpBand->clrBack; 2586 if (lprbbi->clrBack == CLR_NONE) 2587 lprbbi->clrBack = infoPtr->clrBtnFace; 2439 2588 } 2440 2589 … … 2446 2595 lprbbi->lpText[lprbbi->cch-1] = 0; 2447 2596 } 2448 else 2449 2597 else 2598 *lprbbi->lpText = 0; 2450 2599 } 2451 2600 2452 2601 if (lprbbi->fMask & RBBIM_IMAGE) { 2453 2602 if (lpBand->fMask & RBBIM_IMAGE) 2454 2603 lprbbi->iImage = lpBand->iImage; 2455 2604 else 2456 2605 lprbbi->iImage = -1; 2457 2606 } 2458 2607 2459 2608 if (lprbbi->fMask & RBBIM_CHILD) 2460 2609 lprbbi->hwndChild = lpBand->hwndChild; 2461 2610 2462 2611 if (lprbbi->fMask & RBBIM_CHILDSIZE) { 2463 2464 2465 2466 2467 2468 2469 2612 lprbbi->cxMinChild = lpBand->cxMinChild; 2613 lprbbi->cyMinChild = lpBand->cyMinChild; 2614 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) { 2615 lprbbi->cyChild = lpBand->cyChild; 2616 lprbbi->cyMaxChild = lpBand->cyMaxChild; 2617 lprbbi->cyIntegral = lpBand->cyIntegral; 2618 } 2470 2619 } 2471 2620 2472 2621 if (lprbbi->fMask & RBBIM_SIZE) 2473 2622 lprbbi->cx = lpBand->cx; 2474 2623 2475 2624 if (lprbbi->fMask & RBBIM_BACKGROUND) 2476 2625 lprbbi->hbmBack = lpBand->hbmBack; 2477 2626 2478 2627 if (lprbbi->fMask & RBBIM_ID) 2479 2628 lprbbi->wID = lpBand->wID; 2480 2629 2481 2630 /* check for additional data */ 2482 2631 if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) { 2483 2484 2485 2486 2487 2488 2489 2490 2632 if (lprbbi->fMask & RBBIM_IDEALSIZE) 2633 lprbbi->cxIdeal = lpBand->cxIdeal; 2634 2635 if (lprbbi->fMask & RBBIM_LPARAM) 2636 lprbbi->lParam = lpBand->lParam; 2637 2638 if (lprbbi->fMask & RBBIM_HEADERSIZE) 2639 lprbbi->cxHeader = lpBand->cxHeader; 2491 2640 } 2492 2641 … … 2504 2653 2505 2654 if (lprbbi == NULL) 2506 2655 return FALSE; 2507 2656 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW) 2508 2657 return FALSE; 2509 2658 if ((UINT)wParam >= infoPtr->uNumBands) 2510 2659 return FALSE; 2511 2660 2512 2661 TRACE("index %u\n", (UINT)wParam); … … 2516 2665 2517 2666 if (lprbbi->fMask & RBBIM_STYLE) 2518 2667 lprbbi->fStyle = lpBand->fStyle; 2519 2668 2520 2669 if (lprbbi->fMask & RBBIM_COLORS) { 2521 2522 2523 2524 2670 lprbbi->clrFore = lpBand->clrFore; 2671 lprbbi->clrBack = lpBand->clrBack; 2672 if (lprbbi->clrBack == CLR_NONE) 2673 lprbbi->clrBack = infoPtr->clrBtnFace; 2525 2674 } 2526 2675 2527 2676 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) { 2528 2677 if (lpBand->lpText && (lpBand->fMask & RBBIM_TEXT)) 2529 2530 else 2531 2678 lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch); 2679 else 2680 *lprbbi->lpText = 0; 2532 2681 } 2533 2682 2534 2683 if (lprbbi->fMask & RBBIM_IMAGE) { 2535 2684 if (lpBand->fMask & RBBIM_IMAGE) 2536 2685 lprbbi->iImage = lpBand->iImage; 2537 2686 else 2538 2687 lprbbi->iImage = -1; 2539 2688 } 2540 2689 2541 2690 if (lprbbi->fMask & RBBIM_CHILD) 2542 2691 lprbbi->hwndChild = lpBand->hwndChild; 2543 2692 2544 2693 if (lprbbi->fMask & RBBIM_CHILDSIZE) { 2545 2546 2547 2548 2549 2550 2551 2694 lprbbi->cxMinChild = lpBand->cxMinChild; 2695 lprbbi->cyMinChild = lpBand->cyMinChild; 2696 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) { 2697 lprbbi->cyChild = lpBand->cyChild; 2698 lprbbi->cyMaxChild = lpBand->cyMaxChild; 2699 lprbbi->cyIntegral = lpBand->cyIntegral; 2700 } 2552 2701 } 2553 2702 2554 2703 if (lprbbi->fMask & RBBIM_SIZE) 2555 2704 lprbbi->cx = lpBand->cx; 2556 2705 2557 2706 if (lprbbi->fMask & RBBIM_BACKGROUND) 2558 2707 lprbbi->hbmBack = lpBand->hbmBack; 2559 2708 2560 2709 if (lprbbi->fMask & RBBIM_ID) 2561 2710 lprbbi->wID = lpBand->wID; 2562 2711 2563 2712 /* check for additional data */ 2564 2713 if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) { 2565 2566 2567 2568 2569 2570 2571 2572 2714 if (lprbbi->fMask & RBBIM_IDEALSIZE) 2715 lprbbi->cxIdeal = lpBand->cxIdeal; 2716 2717 if (lprbbi->fMask & RBBIM_LPARAM) 2718 lprbbi->lParam = lpBand->lParam; 2719 2720 if (lprbbi->fMask & RBBIM_HEADERSIZE) 2721 lprbbi->cxHeader = lpBand->cxHeader; 2573 2722 } 2574 2723 … … 2598 2747 2599 2748 if (lpInfo == NULL) 2600 2749 return FALSE; 2601 2750 2602 2751 if (lpInfo->cbSize < sizeof (REBARINFO)) 2603 2752 return FALSE; 2604 2753 2605 2754 TRACE("getting bar info!\n"); 2606 2755 2607 2756 if (infoPtr->himl) { 2608 2609 2757 lpInfo->himl = infoPtr->himl; 2758 lpInfo->fMask |= RBIM_IMAGELIST; 2610 2759 } 2611 2760 … … 2649 2798 2650 2799 if ((iBand < 0) && ((UINT)iBand >= infoPtr->uNumBands)) 2651 2800 return FALSE; 2652 2801 if (!lprc) 2653 2802 return FALSE; 2654 2803 2655 2804 lpBand = &infoPtr->bands[iBand]; … … 2657 2806 2658 2807 TRACE("band %d, (%d,%d)-(%d,%d)\n", iBand, 2659 2808 lprc->left, lprc->top, lprc->right, lprc->bottom); 2660 2809 2661 2810 return TRUE; … … 2681 2830 2682 2831 for (i=0; i<infoPtr->uNumBands; i++) { 2683 2684 2685 2686 2687 2688 2689 2690 2832 lpBand = &infoPtr->bands[i]; 2833 if (HIDDENBAND(lpBand)) continue; 2834 if (lpBand->iRow != iRow) continue; 2835 if (infoPtr->dwStyle & CCS_VERT) 2836 j = lpBand->rcBand.right - lpBand->rcBand.left; 2837 else 2838 j = lpBand->rcBand.bottom - lpBand->rcBand.top; 2839 if (j > ret) ret = j; 2691 2840 } 2692 2841 … … 2716 2865 REBAR_GetUnicodeFormat (REBAR_INFO *infoPtr) 2717 2866 { 2718 TRACE("%s hwnd=0x%x\n", 2719 2867 TRACE("%s hwnd=0x%x\n", 2868 infoPtr->bUnicode ? "TRUE" : "FALSE", infoPtr->hwndSelf); 2720 2869 2721 2870 return infoPtr->bUnicode; … … 2734 2883 REBAR_HitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) 2735 2884 { 2736 LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam; 2885 LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam; 2737 2886 2738 2887 if (!lprbht) 2739 2888 return -1; 2740 2889 2741 2890 REBAR_InternalHitTest (infoPtr, &lprbht->pt, &lprbht->flags, &lprbht->iBand); … … 2751 2900 2752 2901 if (infoPtr == NULL) 2753 2902 return -1; 2754 2903 2755 2904 if (infoPtr->uNumBands < 1) 2756 2905 return -1; 2757 2906 2758 2907 for (i = 0; i < infoPtr->uNumBands; i++) { 2759 2760 2761 2762 2908 if (infoPtr->bands[i].wID == (UINT)wParam) { 2909 TRACE("id %u is band %u found!\n", (UINT)wParam, i); 2910 return i; 2911 } 2763 2912 } 2764 2913 … … 2776 2925 2777 2926 if (infoPtr == NULL) 2778 2927 return FALSE; 2779 2928 if (lprbbi == NULL) 2780 2929 return FALSE; 2781 2930 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA) 2782 2931 return FALSE; 2783 2932 2784 2933 /* trace the index as signed to see the -1 */ … … 2787 2936 2788 2937 if (infoPtr->uNumBands == 0) { 2789 2790 2938 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND)); 2939 uIndex = 0; 2791 2940 } 2792 2941 else { 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2942 REBAR_BAND *oldBands = infoPtr->bands; 2943 infoPtr->bands = 2944 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND)); 2945 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands)) 2946 uIndex = infoPtr->uNumBands; 2947 2948 /* pre insert copy */ 2949 if (uIndex > 0) { 2950 memcpy (&infoPtr->bands[0], &oldBands[0], 2951 uIndex * sizeof(REBAR_BAND)); 2952 } 2953 2954 /* post copy */ 2955 if (uIndex < infoPtr->uNumBands - 1) { 2956 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex], 2957 (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND)); 2958 } 2959 2960 COMCTL32_Free (oldBands); 2812 2961 } 2813 2962 … … 2832 2981 lpBand->lpText = (LPWSTR)COMCTL32_Alloc (len*sizeof(WCHAR)); 2833 2982 MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len ); 2834 2983 } 2835 2984 } 2836 2985 … … 2838 2987 /* On insert of second band, revalidate band 1 to possible add gripper */ 2839 2988 if (infoPtr->uNumBands == 2) 2840 2989 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]); 2841 2990 2842 2991 REBAR_DumpBand (infoPtr); 2843 2992 2844 2993 REBAR_Layout (infoPtr, NULL, TRUE, FALSE); 2994 InvalidateRect(infoPtr->hwndSelf, 0, 1); 2845 2995 2846 2996 return TRUE; … … 2856 3006 2857 3007 if (infoPtr == NULL) 2858 3008 return FALSE; 2859 3009 if (lprbbi == NULL) 2860 3010 return FALSE; 2861 3011 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW) 2862 3012 return FALSE; 2863 3013 2864 3014 /* trace the index as signed to see the -1 */ … … 2867 3017 2868 3018 if (infoPtr->uNumBands == 0) { 2869 2870 3019 infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND)); 3020 uIndex = 0; 2871 3021 } 2872 3022 else { 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 3023 REBAR_BAND *oldBands = infoPtr->bands; 3024 infoPtr->bands = 3025 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND)); 3026 if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands)) 3027 uIndex = infoPtr->uNumBands; 3028 3029 /* pre insert copy */ 3030 if (uIndex > 0) { 3031 memcpy (&infoPtr->bands[0], &oldBands[0], 3032 uIndex * sizeof(REBAR_BAND)); 3033 } 3034 3035 /* post copy */ 3036 if (uIndex < infoPtr->uNumBands - 1) { 3037 memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex], 3038 (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND)); 3039 } 3040 3041 COMCTL32_Free (oldBands); 2892 3042 } 2893 3043 … … 2908 3058 lpBand->lpText = NULL; 2909 3059 if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) { 2910 2911 2912 2913 2914 3060 INT len = lstrlenW (lprbbi->lpText); 3061 if (len > 0) { 3062 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 3063 strcpyW (lpBand->lpText, lprbbi->lpText); 3064 } 2915 3065 } 2916 3066 … … 2918 3068 /* On insert of second band, revalidate band 1 to possible add gripper */ 2919 3069 if (infoPtr->uNumBands == 2) 2920 3070 REBAR_ValidateBand (infoPtr, &infoPtr->bands[0]); 2921 3071 2922 3072 REBAR_DumpBand (infoPtr); 2923 3073 2924 3074 REBAR_Layout (infoPtr, NULL, TRUE, FALSE); 3075 InvalidateRect(infoPtr->hwndSelf, 0, 1); 2925 3076 2926 3077 return TRUE; … … 2931 3082 REBAR_MaximizeBand (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) 2932 3083 { 2933 FIXME("(uBand = %u fIdeal = %s) stub\n", 2934 (UINT)wParam, lParam ? "TRUE" : "FALSE"); 2935 2936 return 0; 3084 REBAR_BAND *lpBand; 3085 UINT uBand = (UINT) wParam; 3086 3087 /* Validate */ 3088 if ((infoPtr->uNumBands == 0) || 3089 ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) { 3090 /* error !!! */ 3091 ERR("Illegal MaximizeBand, requested=%d, current band count=%d\n", 3092 (INT)uBand, infoPtr->uNumBands); 3093 return FALSE; 3094 } 3095 3096 lpBand = &infoPtr->bands[uBand]; 3097 3098 if (lParam && (lpBand->fMask & RBBIM_IDEALSIZE)) { 3099 /* handle setting ideal size */ 3100 lpBand->ccx = lpBand->cxIdeal; 3101 } 3102 else { 3103 /* handle setting to max */ 3104 FIXME("(uBand = %u fIdeal = %s) case not coded\n", 3105 (UINT)wParam, lParam ? "TRUE" : "FALSE"); 3106 return FALSE; 3107 } 3108 3109 infoPtr->fStatus |= BAND_NEEDS_LAYOUT; 3110 REBAR_Layout (infoPtr, 0, TRUE, TRUE); 3111 InvalidateRect (infoPtr->hwndSelf, 0, TRUE); 3112 3113 return TRUE; 2937 3114 2938 3115 } … … 2955 3132 /* Validate */ 2956 3133 if ((infoPtr->uNumBands == 0) || 2957 2958 2959 2960 2961 3134 ((INT)uBand < 0) || (uBand >= infoPtr->uNumBands)) { 3135 /* error !!! */ 3136 ERR("Illegal MinimizeBand, requested=%d, current band count=%d\n", 3137 (INT)uBand, infoPtr->uNumBands); 3138 return FALSE; 2962 3139 } 2963 3140 … … 2966 3143 2967 3144 if (infoPtr->dwStyle & CCS_VERT) 2968 2969 3145 movement = lpBand->rcBand.bottom - lpBand->rcBand.top - 3146 lpBand->cxHeader; 2970 3147 else 2971 2972 3148 movement = lpBand->rcBand.right - lpBand->rcBand.left - 3149 lpBand->cxHeader; 2973 3150 if (movement < 0) { 2974 2975 2976 2977 2978 3151 ERR("something is wrong, band=(%d,%d)-(%d,%d), cxheader=%d\n", 3152 lpBand->rcBand.left, lpBand->rcBand.top, 3153 lpBand->rcBand.right, lpBand->rcBand.bottom, 3154 lpBand->cxHeader); 3155 return FALSE; 2979 3156 } 2980 3157 … … 2986 3163 for (i=0; i<infoPtr->uNumBands; i++) { 2987 3164 band = &infoPtr->bands[i]; 2988 2989 2990 2991 2992 3165 if (HIDDENBAND(band)) continue; 3166 if (band->iRow == lpBand->iRow) { 3167 imaxdBand = i; 3168 if (imindBand == -1) imindBand = i; 3169 } 2993 3170 } 2994 3171 … … 2996 3173 /* next visible band */ 2997 3174 if (imindBand == uBand) { 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 SetRect (&newrect, 3018 3019 3020 3021 3175 band = NULL; 3176 movement = -movement; 3177 /* find the first visible band to the right of the selected band */ 3178 for (i=uBand+1; i<=imaxdBand; i++) { 3179 band = &infoPtr->bands[i]; 3180 if (!HIDDENBAND(band)) { 3181 iprevBand = i; 3182 LEADJ(band, movement); 3183 band->ccx = rcBw(band); 3184 break; 3185 } 3186 } 3187 /* what case is this */ 3188 if (iprevBand == -1) { 3189 ERR("no previous visible band\n"); 3190 return FALSE; 3191 } 3192 startBand = uBand; 3193 endBand = iprevBand; 3194 SetRect (&newrect, 3195 lpBand->rcBand.left, 3196 lpBand->rcBand.top, 3197 band->rcBand.right, 3198 band->rcBand.bottom); 3022 3199 } 3023 3200 /* otherwise expand previous visible band */ 3024 3201 else { 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 SetRect (&newrect, 3044 3045 3046 3047 3202 band = NULL; 3203 /* find the first visible band to the left of the selected band */ 3204 for (i=uBand-1; i>=imindBand; i--) { 3205 band = &infoPtr->bands[i]; 3206 if (!HIDDENBAND(band)) { 3207 iprevBand = i; 3208 READJ(band, movement); 3209 band->ccx = rcBw(band); 3210 break; 3211 } 3212 } 3213 /* what case is this */ 3214 if (iprevBand == -1) { 3215 ERR("no previous visible band\n"); 3216 return FALSE; 3217 } 3218 startBand = iprevBand; 3219 endBand = uBand; 3220 SetRect (&newrect, 3221 band->rcBand.left, 3222 band->rcBand.top, 3223 lpBand->rcBand.right, 3224 lpBand->rcBand.bottom); 3048 3225 } 3049 3226 … … 3052 3229 /* recompute all rectangles */ 3053 3230 if (infoPtr->dwStyle & CCS_VERT) { 3054 3055 3231 REBAR_CalcVertBand (infoPtr, startBand, endBand+1, 3232 FALSE); 3056 3233 } 3057 3234 else { 3058 REBAR_CalcHorzBand (infoPtr, startBand, endBand+1, 3059 3235 REBAR_CalcHorzBand (infoPtr, startBand, endBand+1, 3236 FALSE); 3060 3237 } 3061 3238 3062 3239 TRACE("bands after minimize, see band # %d, %d\n", 3063 3240 startBand, endBand); 3064 3241 REBAR_DumpBand (infoPtr); 3065 3242 … … 3082 3259 /* Validate */ 3083 3260 if ((infoPtr->uNumBands == 0) || 3084 3085 3086 3087 3088 3089 3261 ((INT)uFrom < 0) || (uFrom >= infoPtr->uNumBands) || 3262 ((INT)uTo < 0) || (uTo >= infoPtr->uNumBands)) { 3263 /* error !!! */ 3264 ERR("Illegal MoveBand, from=%d, to=%d, current band count=%d\n", 3265 (INT)uFrom, (INT)uTo, infoPtr->uNumBands); 3266 return FALSE; 3090 3267 } 3091 3268 … … 3095 3272 /* close up rest of bands (psuedo delete) */ 3096 3273 if (uFrom < infoPtr->uNumBands - 1) { 3097 3098 3274 memcpy (&oldBands[uFrom], &oldBands[uFrom+1], 3275 (infoPtr->uNumBands - uFrom - 1) * sizeof(REBAR_BAND)); 3099 3276 } 3100 3277 3101 3278 /* allocate new space and copy rest of bands into it */ 3102 3279 infoPtr->bands = 3103 3280 (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands)*sizeof(REBAR_BAND)); 3104 3281 3105 3282 /* pre insert copy */ 3106 3283 if (uTo > 0) { 3107 3108 3284 memcpy (&infoPtr->bands[0], &oldBands[0], 3285 uTo * sizeof(REBAR_BAND)); 3109 3286 } 3110 3287 … … 3114 3291 /* post copy */ 3115 3292 if (uTo < infoPtr->uNumBands - 1) { 3116 3117 3293 memcpy (&infoPtr->bands[uTo+1], &oldBands[uTo], 3294 (infoPtr->uNumBands - uTo - 1) * sizeof(REBAR_BAND)); 3118 3295 } 3119 3296 … … 3144 3321 3145 3322 if (lprbbi == NULL) 3146 3323 return FALSE; 3147 3324 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA) 3148 3325 return FALSE; 3149 3326 if ((UINT)wParam >= infoPtr->uNumBands) 3150 3327 return FALSE; 3151 3328 3152 3329 TRACE("index %u\n", (UINT)wParam); … … 3158 3335 REBAR_CommonSetupBand (infoPtr->hwndSelf, lprbbi, lpBand); 3159 3336 if (lprbbi->fMask & RBBIM_TEXT) { 3160 3161 3162 3163 3164 3337 if (lpBand->lpText) { 3338 COMCTL32_Free (lpBand->lpText); 3339 lpBand->lpText = NULL; 3340 } 3341 if (lprbbi->lpText) { 3165 3342 INT len = MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, NULL, 0 ); 3166 3343 lpBand->lpText = (LPWSTR)COMCTL32_Alloc (len*sizeof(WCHAR)); 3167 3344 MultiByteToWideChar( CP_ACP, 0, lprbbi->lpText, -1, lpBand->lpText, len ); 3168 3345 } 3169 3346 } 3170 3347 … … 3173 3350 REBAR_DumpBand (infoPtr); 3174 3351 3175 if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) 3176 REBAR_Layout (infoPtr, NULL, TRUE, FALSE); 3352 if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) { 3353 REBAR_Layout (infoPtr, NULL, TRUE, FALSE); 3354 InvalidateRect(infoPtr->hwndSelf, 0, 1); 3355 } 3177 3356 3178 3357 return TRUE; … … 3187 3366 3188 3367 if (lprbbi == NULL) 3189 3368 return FALSE; 3190 3369 if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW) 3191 3370 return FALSE; 3192 3371 if ((UINT)wParam >= infoPtr->uNumBands) 3193 3372 return FALSE; 3194 3373 3195 3374 TRACE("index %u\n", (UINT)wParam); … … 3201 3380 REBAR_CommonSetupBand (infoPtr->hwndSelf, (LPREBARBANDINFOA)lprbbi, lpBand); 3202 3381 if (lprbbi->fMask & RBBIM_TEXT) { 3203 3204 3205 3206 3207 3208 3209 3210 3211 3382 if (lpBand->lpText) { 3383 COMCTL32_Free (lpBand->lpText); 3384 lpBand->lpText = NULL; 3385 } 3386 if (lprbbi->lpText) { 3387 INT len = lstrlenW (lprbbi->lpText); 3388 lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR)); 3389 strcpyW (lpBand->lpText, lprbbi->lpText); 3390 } 3212 3391 } 3213 3392 … … 3216 3395 REBAR_DumpBand (infoPtr); 3217 3396 3218 if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) 3397 if (lprbbi->fMask & (RBBIM_CHILDSIZE | RBBIM_SIZE)) { 3219 3398 REBAR_Layout (infoPtr, NULL, TRUE, FALSE); 3399 InvalidateRect(infoPtr->hwndSelf, 0, 1); 3400 } 3220 3401 3221 3402 return TRUE; … … 3231 3412 3232 3413 if (lpInfo == NULL) 3233 3414 return FALSE; 3234 3415 3235 3416 if (lpInfo->cbSize < sizeof (REBARINFO)) 3236 3417 return FALSE; 3237 3418 3238 3419 TRACE("setting bar info!\n"); 3239 3420 3240 3421 if (lpInfo->fMask & RBIM_IMAGELIST) { 3241 3242 3422 infoPtr->himl = lpInfo->himl; 3423 if (infoPtr->himl) { 3243 3424 INT cx, cy; 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3425 ImageList_GetIconSize (infoPtr->himl, &cx, &cy); 3426 infoPtr->imageSize.cx = cx; 3427 infoPtr->imageSize.cy = cy; 3428 } 3429 else { 3430 infoPtr->imageSize.cx = 0; 3431 infoPtr->imageSize.cy = 0; 3432 } 3433 TRACE("new image cx=%ld, cy=%ld\n", infoPtr->imageSize.cx, 3434 infoPtr->imageSize.cy); 3254 3435 } 3255 3436 … … 3257 3438 for (i=0; i<infoPtr->uNumBands; i++) { 3258 3439 lpBand = &infoPtr->bands[i]; 3259 3440 REBAR_ValidateBand (infoPtr, lpBand); 3260 3441 } 3261 3442 … … 3315 3496 BOOL bTemp = infoPtr->bUnicode; 3316 3497 3317 TRACE("to %s hwnd=0x%04x, was %s\n", 3318 3319 3498 TRACE("to %s hwnd=0x%04x, was %s\n", 3499 ((BOOL)wParam) ? "TRUE" : "FALSE", infoPtr->hwndSelf, 3500 (bTemp) ? "TRUE" : "FALSE"); 3320 3501 3321 3502 infoPtr->bUnicode = (BOOL)wParam; 3322 3503 3323 3504 return bTemp; 3324 3505 } … … 3331 3512 3332 3513 if (iVersion > COMCTL32_VERSION) 3333 3514 return -1; 3334 3515 3335 3516 infoPtr->iVersion = iVersion; … … 3347 3528 3348 3529 if (((INT)wParam < 0) || ((INT)wParam > infoPtr->uNumBands)) 3349 3530 return FALSE; 3350 3531 3351 3532 lpBand = &infoPtr->bands[(INT)wParam]; 3352 3533 3353 3534 if ((BOOL)lParam) { 3354 3355 3356 3357 3535 TRACE("show band %d\n", (INT)wParam); 3536 lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN; 3537 if (IsWindow (lpBand->hwndChild)) 3538 ShowWindow (lpBand->hwndChild, SW_SHOW); 3358 3539 } 3359 3540 else { 3360 3361 3362 3363 3541 TRACE("hide band %d\n", (INT)wParam); 3542 lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN; 3543 if (IsWindow (lpBand->hwndChild)) 3544 ShowWindow (lpBand->hwndChild, SW_HIDE); 3364 3545 } 3365 3546 3366 3547 REBAR_Layout (infoPtr, NULL, TRUE, FALSE); 3548 InvalidateRect(infoPtr->hwndSelf, 0, 1); 3367 3549 3368 3550 return TRUE; … … 3380 3562 3381 3563 TRACE("[%d %d %d %d]\n", 3382 3564 lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); 3383 3565 3384 3566 /* what is going on???? */ 3385 3567 GetWindowRect(infoPtr->hwndSelf, &t1); 3386 3568 TRACE("window rect [%d %d %d %d]\n", 3387 3569 t1.left, t1.top, t1.right, t1.bottom); 3388 3570 GetClientRect(infoPtr->hwndSelf, &t1); 3389 3571 TRACE("client rect [%d %d %d %d]\n", 3390 3572 t1.left, t1.top, t1.right, t1.bottom); 3391 3573 3392 3574 /* force full _Layout processing */ … … 3407 3589 3408 3590 if (TRACE_ON(rebar)) { 3409 3410 3411 3412 3413 3414 3591 GetWindowRect(infoPtr->hwndSelf, &wnrc1); 3592 GetClientRect(infoPtr->hwndSelf, &clrc1); 3593 TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n", 3594 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom, 3595 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom, 3596 cs->x, cs->y, cs->cx, cs->cy); 3415 3597 } 3416 3598 … … 3429 3611 /* free rebar bands */ 3430 3612 if ((infoPtr->uNumBands > 0) && infoPtr->bands) { 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3613 /* clean up each band */ 3614 for (i = 0; i < infoPtr->uNumBands; i++) { 3615 lpBand = &infoPtr->bands[i]; 3616 3617 /* delete text strings */ 3618 if (lpBand->lpText) { 3619 COMCTL32_Free (lpBand->lpText); 3620 lpBand->lpText = NULL; 3621 } 3622 /* destroy child window */ 3623 DestroyWindow (lpBand->hwndChild); 3624 } 3625 3626 /* free band array */ 3627 COMCTL32_Free (infoPtr->bands); 3628 infoPtr->bands = NULL; 3447 3629 } 3448 3630 … … 3451 3633 DeleteObject (infoPtr->hcurVert); 3452 3634 DeleteObject (infoPtr->hcurDrag); 3635 DeleteObject (infoPtr->hFont); 3453 3636 SetWindowLongA (infoPtr->hwndSelf, 0, 0); 3454 3637 … … 3523 3706 if (infoPtr->fStatus & BEGIN_DRAG_ISSUED) { 3524 3707 REBAR_Notify((NMHDR *) &layout, infoPtr, RBN_LAYOUTCHANGED); 3525 3526 3708 REBAR_Notify_NMREBAR (infoPtr, ihitBand, RBN_ENDDRAG); 3709 infoPtr->fStatus &= ~BEGIN_DRAG_ISSUED; 3527 3710 } 3528 3711 … … 3548 3731 /* if mouse did not move much, exit */ 3549 3732 if ((abs(ptsmove.x - infoPtr->dragNow.x) <= mindragx) && 3550 3733 (abs(ptsmove.y - infoPtr->dragNow.y) <= mindragy)) return 0; 3551 3734 3552 3735 band1 = &infoPtr->bands[infoPtr->ihitBand-1]; … … 3555 3738 /* Test for valid drag case - must not be first band in row */ 3556 3739 if (infoPtr->dwStyle & CCS_VERT) { 3557 if ((ptsmove.x < band2->rcBand.left) || 3558 (ptsmove.x > band2->rcBand.right) || 3559 ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) { 3560 FIXME("Cannot drag to other rows yet!!\n"); 3740 if ((ptsmove.x < band2->rcBand.left) || 3741 (ptsmove.x > band2->rcBand.right) || 3742 ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) { 3743 FIXME("Cannot drag to other rows yet!!\n"); 3744 } 3745 else { 3746 REBAR_HandleLRDrag (infoPtr, &ptsmove); 3747 } 3561 3748 } 3562 3749 else { 3563 REBAR_HandleLRDrag (infoPtr, &ptsmove); 3564 } 3565 } 3566 else { 3567 if ((ptsmove.y < band2->rcBand.top) || 3568 (ptsmove.y > band2->rcBand.bottom) || 3569 ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) { 3570 FIXME("Cannot drag to other rows yet!!\n"); 3571 } 3572 else { 3573 REBAR_HandleLRDrag (infoPtr, &ptsmove); 3574 } 3750 if ((ptsmove.y < band2->rcBand.top) || 3751 (ptsmove.y > band2->rcBand.bottom) || 3752 ((infoPtr->ihitBand > 0) && (band1->iRow != band2->iRow))) { 3753 FIXME("Cannot drag to other rows yet!!\n"); 3754 } 3755 else { 3756 REBAR_HandleLRDrag (infoPtr, &ptsmove); 3757 } 3575 3758 } 3576 3759 return 0; … … 3581 3764 REBAR_NCCalcSize (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) 3582 3765 { 3583 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE); 3584 ((LPRECT)lParam)->bottom -= GetSystemMetrics(SM_CYEDGE); 3585 3586 /* While the code below seems to be the reasonable way of */ 3587 /* handling the WS_BORDER style, the native version (as */ 3588 /* of 4.71 seems to only do the above. Go figure!! */ 3589 #if 0 3590 if (GetWindowLongA (infoPtr->hwndSelf, GWL_STYLE) & WS_BORDER) { 3591 ((LPRECT)lParam)->left += GetSystemMetrics(SM_CXEDGE); 3592 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE); 3593 ((LPRECT)lParam)->right -= GetSystemMetrics(SM_CXEDGE); 3594 ((LPRECT)lParam)->bottom -= GetSystemMetrics(SM_CYEDGE); 3595 } 3596 #endif 3597 3766 if (infoPtr->dwStyle & WS_BORDER) { 3767 InflateRect((LPRECT)lParam, -GetSystemMetrics(SM_CXEDGE), 3768 -GetSystemMetrics(SM_CYEDGE)); 3769 } 3770 TRACE("new client=(%d,%d)-(%d,%d)\n", 3771 ((LPRECT)lParam)->left, ((LPRECT)lParam)->top, 3772 ((LPRECT)lParam)->right, ((LPRECT)lParam)->bottom); 3598 3773 return 0; 3599 3774 } … … 3606 3781 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); 3607 3782 RECT wnrc1, clrc1; 3783 NONCLIENTMETRICSA ncm; 3784 HFONT tfont; 3608 3785 INT i; 3609 3786 3610 3787 if (infoPtr != NULL) { 3611 3612 3788 ERR("Strange info structure pointer *not* NULL\n"); 3789 return FALSE; 3613 3790 } 3614 3791 3615 3792 if (TRACE_ON(rebar)) { 3616 3617 3618 3619 3620 3621 3793 GetWindowRect(hwnd, &wnrc1); 3794 GetClientRect(hwnd, &clrc1); 3795 TRACE("window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d) cs=(%d,%d %dx%d)\n", 3796 wnrc1.left, wnrc1.top, wnrc1.right, wnrc1.bottom, 3797 clrc1.left, clrc1.top, clrc1.right, clrc1.bottom, 3798 cs->x, cs->y, cs->cx, cs->cy); 3622 3799 } 3623 3800 … … 3644 3821 infoPtr->bUnicode = IsWindowUnicode (hwnd); 3645 3822 infoPtr->fStatus = CREATE_RUNNING; 3823 infoPtr->hFont = GetStockObject (SYSTEM_FONT); 3646 3824 3647 3825 /* issue WM_NOTIFYFORMAT to get unicode status of parent */ 3648 3826 i = SendMessageA(REBAR_GetNotifyParent (infoPtr), 3649 3827 WM_NOTIFYFORMAT, hwnd, NF_QUERY); 3650 3828 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) { 3651 3652 3653 3829 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", 3830 i); 3831 i = NFR_ANSI; 3654 3832 } 3655 3833 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0; … … 3659 3837 SetWindowLongA (hwnd, GWL_STYLE, infoPtr->dwStyle); 3660 3838 3839 /* get font handle for Caption Font */ 3840 ncm.cbSize = sizeof(NONCLIENTMETRICSA); 3841 SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, 3842 ncm.cbSize, &ncm, 0); 3843 /* if the font is bold, set to normal */ 3844 if (ncm.lfCaptionFont.lfWeight > FW_NORMAL) { 3845 ncm.lfCaptionFont.lfWeight = FW_NORMAL; 3846 } 3847 tfont = CreateFontIndirectA (&ncm.lfCaptionFont); 3848 if (tfont) { 3849 infoPtr->hFont = tfont; 3850 } 3851 3661 3852 /* native does: 3662 3663 3664 3665 3666 3667 3853 GetSysColor (numerous); 3854 GetSysColorBrush (numerous) (see WM_SYSCOLORCHANGE); 3855 *GetStockObject (SYSTEM_FONT); 3856 *SetWindowLong (hwnd, 0, info ptr); 3857 *WM_NOTIFYFORMAT; 3858 *SetWindowLong (hwnd, GWL_STYLE, style+0x10000001); 3668 3859 WS_VISIBLE = 0x10000000; 3669 3860 CCS_TOP = 0x00000001; 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3861 *SystemParametersInfo (SPI_GETNONCLIENTMETRICS...); 3862 *CreateFontIndirect (lfCaptionFont from above); 3863 GetDC (); 3864 SelectObject (hdc, fontabove); 3865 GetTextMetrics (hdc, ); guessing is tmHeight 3866 SelectObject (hdc, oldfont); 3867 ReleaseDC (); 3868 GetWindowRect (); 3869 MapWindowPoints (0, parent, rectabove, 2); 3870 GetWindowRect (); 3871 GetClientRect (); 3872 ClientToScreen (clientrect); 3873 SetWindowPos (hwnd, 0, 0, 0, 0, 0, SWP_NOZORDER); 3683 3874 */ 3684 3875 return TRUE; … … 3708 3899 clpt = pt; 3709 3900 ScreenToClient (infoPtr->hwndSelf, &clpt); 3710 REBAR_InternalHitTest (infoPtr, &clpt, &scrap, 3711 3901 REBAR_InternalHitTest (infoPtr, &clpt, &scrap, 3902 (INT *)&nmmouse.dwItemSpec); 3712 3903 nmmouse.dwItemData = 0; 3713 3904 nmmouse.pt = clpt; 3714 3905 nmmouse.dwHitInfo = 0; 3715 3906 if ((i = REBAR_Notify((NMHDR *) &nmmouse, infoPtr, NM_NCHITTEST))) { 3716 3717 ret, i); 3718 3907 TRACE("notify changed return value from %ld to %d\n", 3908 ret, i); 3909 ret = (LRESULT) i; 3719 3910 } 3720 3911 TRACE("returning %ld, client point (%ld,%ld)\n", ret, clpt.x, clpt.y); … … 3730 3921 3731 3922 if (infoPtr->dwStyle & WS_MINIMIZE) 3732 return 0; /* Nothing to do */ 3733 3734 DefWindowProcA (infoPtr->hwndSelf, WM_NCPAINT, wParam, lParam); 3735 3736 if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW ))) 3737 return 0; 3923 return 0; /* Nothing to do */ 3738 3924 3739 3925 if (infoPtr->dwStyle & WS_BORDER) { 3740 GetWindowRect (infoPtr->hwndSelf, &rcWindow); 3741 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top); 3742 TRACE("rect (%d,%d)-(%d,%d)\n", 3743 rcWindow.left, rcWindow.top, 3744 rcWindow.right, rcWindow.bottom); 3745 /* see comments in _NCCalcSize for reason this is not done */ 3746 /* DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT); */ 3747 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP | BF_BOTTOM); 3748 } 3749 3750 ReleaseDC( infoPtr->hwndSelf, hdc ); 3926 3927 /* adjust rectangle and draw the necessary edge */ 3928 if (!(hdc = GetDCEx( infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW ))) 3929 return 0; 3930 GetWindowRect (infoPtr->hwndSelf, &rcWindow); 3931 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top); 3932 TRACE("rect (%d,%d)-(%d,%d)\n", 3933 rcWindow.left, rcWindow.top, 3934 rcWindow.right, rcWindow.bottom); 3935 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT); 3936 ReleaseDC( infoPtr->hwndSelf, hdc ); 3937 } 3751 3938 3752 3939 return 0; … … 3760 3947 3761 3948 if (lParam == NF_REQUERY) { 3762 3763 3764 3765 3766 3767 3768 3769 3770 3949 i = SendMessageA(REBAR_GetNotifyParent (infoPtr), 3950 WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY); 3951 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) { 3952 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", 3953 i); 3954 i = NFR_ANSI; 3955 } 3956 infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0; 3957 return (LRESULT)i; 3771 3958 } 3772 3959 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI); … … 3785 3972 3786 3973 TRACE("painting (%d,%d)-(%d,%d) client (%d,%d)-(%d,%d)\n", 3787 3788 3789 3974 ps.rcPaint.left, ps.rcPaint.top, 3975 ps.rcPaint.right, ps.rcPaint.bottom, 3976 rc.left, rc.top, rc.right, rc.bottom); 3790 3977 3791 3978 if (ps.fErase) { 3792 3979 /* Erase area of paint if requested */ 3793 3980 REBAR_InternalEraseBkGnd (infoPtr, wParam, lParam, &ps.rcPaint); 3794 3981 } … … 3796 3983 REBAR_Refresh (infoPtr, hdc); 3797 3984 if (!wParam) 3798 3985 EndPaint (infoPtr->hwndSelf, &ps); 3799 3986 return 0; 3800 3987 } … … 3815 4002 3816 4003 if (flags == RBHT_GRABBER) { 3817 3818 3819 3820 3821 4004 if ((infoPtr->dwStyle & CCS_VERT) && 4005 !(infoPtr->dwStyle & RBS_VERTICALGRIPPER)) 4006 SetCursor (infoPtr->hcurVert); 4007 else 4008 SetCursor (infoPtr->hcurHorz); 3822 4009 } 3823 4010 else if (flags != RBHT_CLIENT) 3824 4011 SetCursor (infoPtr->hcurArrow); 3825 4012 3826 4013 return 0; … … 3840 4027 for (i=0; i<infoPtr->uNumBands; i++) { 3841 4028 lpBand = &infoPtr->bands[i]; 3842 4029 REBAR_ValidateBand (infoPtr, lpBand); 3843 4030 } 3844 4031 … … 3861 4048 * 3862 4049 * Documentation: 3863 * According to testing V4.71 of COMCTL32 returns the 4050 * According to testing V4.71 of COMCTL32 returns the 3864 4051 * *previous* status of the redraw flag (either 0 or -1) 3865 4052 * instead of the MSDN documented value of 0 if handled … … 3869 4056 BOOL oldredraw = infoPtr->DoRedraw; 3870 4057 3871 TRACE("set to %s, fStatus=%08x\n", 3872 4058 TRACE("set to %s, fStatus=%08x\n", 4059 (wParam) ? "TRUE" : "FALSE", infoPtr->fStatus); 3873 4060 infoPtr->DoRedraw = (BOOL) wParam; 3874 4061 if (wParam) { 3875 3876 3877 3878 3879 3880 4062 if (infoPtr->fStatus & BAND_NEEDS_REDRAW) { 4063 REBAR_MoveChildWindows (infoPtr, 0, infoPtr->uNumBands); 4064 REBAR_ForceResize (infoPtr); 4065 InvalidateRect (infoPtr->hwndSelf, 0, TRUE); 4066 } 4067 infoPtr->fStatus &= ~BAND_NEEDS_REDRAW; 3881 4068 } 3882 4069 return (oldredraw) ? -1 : 0; … … 3891 4078 /* auto resize deadlock check */ 3892 4079 if (infoPtr->fStatus & AUTO_RESIZE) { 3893 3894 3895 3896 4080 infoPtr->fStatus &= ~AUTO_RESIZE; 4081 TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n", 4082 infoPtr->fStatus, lParam); 4083 return 0; 3897 4084 } 3898 4085 3899 4086 if (infoPtr->fStatus & CREATE_RUNNING) { 3900 /* still in CreateWindow */ 3901 RECT rcWin; 3902 3903 TRACE("still in CreateWindow\n"); 3904 infoPtr->fStatus &= ~CREATE_RUNNING; 3905 GetWindowRect ( infoPtr->hwndSelf, &rcWin); 3906 TRACE("win rect (%d,%d)-(%d,%d)\n", 3907 rcWin.left, rcWin.top, rcWin.right, rcWin.bottom); 3908 3909 if ((lParam == 0) && (rcWin.right-rcWin.left == 0) && 3910 (rcWin.bottom-rcWin.top == 0)) { 3911 /* native control seems to do this */ 3912 GetClientRect (GetParent(infoPtr->hwndSelf), &rcClient); 3913 TRACE("sizing rebar, message and client zero, parent client (%d,%d)\n", 3914 rcClient.right, rcClient.bottom); 4087 /* still in CreateWindow */ 4088 RECT rcWin; 4089 4090 if ((INT)wParam != SIZE_RESTORED) { 4091 ERR("WM_SIZE in create and flags=%08x, lParam=%08lx\n", 4092 wParam, lParam); 4093 } 4094 4095 TRACE("still in CreateWindow\n"); 4096 infoPtr->fStatus &= ~CREATE_RUNNING; 4097 GetWindowRect ( infoPtr->hwndSelf, &rcWin); 4098 TRACE("win rect (%d,%d)-(%d,%d)\n", 4099 rcWin.left, rcWin.top, rcWin.right, rcWin.bottom); 4100 4101 if ((lParam == 0) && (rcWin.right-rcWin.left == 0) && 4102 (rcWin.bottom-rcWin.top == 0)) { 4103 /* native control seems to do this */ 4104 GetClientRect (GetParent(infoPtr->hwndSelf), &rcClient); 4105 TRACE("sizing rebar, message and client zero, parent client (%d,%d)\n", 4106 rcClient.right, rcClient.bottom); 4107 } 4108 else { 4109 INT cx, cy; 4110 4111 cx = rcWin.right - rcWin.left; 4112 cy = rcWin.bottom - rcWin.top; 4113 if ((cx == LOWORD(lParam)) && (cy == HIWORD(lParam))) { 4114 return 0; 4115 } 4116 4117 /* do the actual WM_SIZE request */ 4118 GetClientRect (infoPtr->hwndSelf, &rcClient); 4119 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n", 4120 infoPtr->calcSize.cx, infoPtr->calcSize.cy, 4121 LOWORD(lParam), HIWORD(lParam), 4122 rcClient.right, rcClient.bottom); 4123 } 3915 4124 } 3916 4125 else { 3917 INT cx, cy; 3918 3919 cx = rcWin.right - rcWin.left; 3920 cy = rcWin.bottom - rcWin.top; 3921 if ((cx == LOWORD(lParam)) && (cy == HIWORD(lParam))) { 3922 return 0; 3923 } 3924 3925 /* do the actual WM_SIZE request */ 3926 GetClientRect (infoPtr->hwndSelf, &rcClient); 3927 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n", 3928 infoPtr->calcSize.cx, infoPtr->calcSize.cy, 3929 LOWORD(lParam), HIWORD(lParam), 3930 rcClient.right, rcClient.bottom); 3931 } 3932 } 3933 else { 3934 /* Handle cases when outside of the CreateWindow process */ 3935 3936 GetClientRect (infoPtr->hwndSelf, &rcClient); 3937 if ((lParam == 0) && (rcClient.right + rcClient.bottom != 0) && 3938 (infoPtr->dwStyle & RBS_AUTOSIZE)) { 3939 /* on a WM_SIZE to zero and current client not zero and AUTOSIZE */ 3940 /* native seems to use the current client rect for the size */ 3941 infoPtr->fStatus |= BAND_NEEDS_LAYOUT; 3942 TRACE("sizing rebar to client (%d,%d) size is zero but AUTOSIZE set\n", 3943 rcClient.right, rcClient.bottom); 3944 } 3945 else { 3946 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n", 3947 infoPtr->calcSize.cx, infoPtr->calcSize.cy, 3948 LOWORD(lParam), HIWORD(lParam), 3949 rcClient.right, rcClient.bottom); 3950 } 4126 if ((INT)wParam != SIZE_RESTORED) { 4127 ERR("WM_SIZE out of create and flags=%08x, lParam=%08lx\n", 4128 wParam, lParam); 4129 } 4130 4131 /* Handle cases when outside of the CreateWindow process */ 4132 4133 GetClientRect (infoPtr->hwndSelf, &rcClient); 4134 if ((lParam == 0) && (rcClient.right + rcClient.bottom != 0) && 4135 (infoPtr->dwStyle & RBS_AUTOSIZE)) { 4136 /* on a WM_SIZE to zero and current client not zero and AUTOSIZE */ 4137 /* native seems to use the current client rect for the size */ 4138 infoPtr->fStatus |= BAND_NEEDS_LAYOUT; 4139 TRACE("sizing rebar to client (%d,%d) size is zero but AUTOSIZE set\n", 4140 rcClient.right, rcClient.bottom); 4141 } 4142 else { 4143 TRACE("sizing rebar from (%ld,%ld) to (%d,%d), client (%d,%d)\n", 4144 infoPtr->calcSize.cx, infoPtr->calcSize.cy, 4145 LOWORD(lParam), HIWORD(lParam), 4146 rcClient.right, rcClient.bottom); 4147 } 3951 4148 } 3952 4149 3953 4150 if (infoPtr->dwStyle & RBS_AUTOSIZE) { 3954 3955 3956 3957 3958 3959 3960 TRACE("RBN_AUTOSIZE client=(%d,%d), lp=%08lx\n", 3961 4151 NMRBAUTOSIZE autosize; 4152 4153 GetClientRect(infoPtr->hwndSelf, &autosize.rcTarget); 4154 autosize.fChanged = 0; /* ??? */ 4155 autosize.rcActual = autosize.rcTarget; /* ??? */ 4156 REBAR_Notify((NMHDR *) &autosize, infoPtr, RBN_AUTOSIZE); 4157 TRACE("RBN_AUTOSIZE client=(%d,%d), lp=%08lx\n", 4158 autosize.rcTarget.right, autosize.rcTarget.bottom, lParam); 3962 4159 } 3963 4160 3964 4161 if ((infoPtr->calcSize.cx != rcClient.right) || 3965 3966 4162 (infoPtr->calcSize.cy != rcClient.bottom)) 4163 infoPtr->fStatus |= BAND_NEEDS_LAYOUT; 3967 4164 3968 4165 REBAR_Layout (infoPtr, &rcClient, TRUE, TRUE); … … 3979 4176 3980 4177 TRACE("current style=%08lx, styleOld=%08lx, style being set to=%08lx\n", 3981 4178 infoPtr->dwStyle, ss->styleOld, ss->styleNew); 3982 4179 infoPtr->dwStyle = ss->styleNew; 3983 4180 … … 3991 4188 REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); 3992 4189 3993 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", 3994 4190 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", 4191 hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam); 3995 4192 if (!infoPtr && (uMsg != WM_NCCREATE)) 3996 4193 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 3997 4194 switch (uMsg) 3998 4195 { 3999 /* 4000 4001 4002 4003 4004 /* 4005 /* 4006 4007 4008 4009 4010 4011 4012 4013 case RB_GETBANDINFO:/* obsoleted after IE3, but we have to4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 /* 4031 /* 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 /* 4091 /* 4092 /* 4093 4094 4095 4096 4097 4098 4099 4100 /* 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4196 /* case RB_BEGINDRAG: */ 4197 4198 case RB_DELETEBAND: 4199 return REBAR_DeleteBand (infoPtr, wParam, lParam); 4200 4201 /* case RB_DRAGMOVE: */ 4202 /* case RB_ENDDRAG: */ 4203 4204 case RB_GETBANDBORDERS: 4205 return REBAR_GetBandBorders (infoPtr, wParam, lParam); 4206 4207 case RB_GETBANDCOUNT: 4208 return REBAR_GetBandCount (infoPtr); 4209 4210 case RB_GETBANDINFO: /* obsoleted after IE3, but we have to 4211 support it anyway. */ 4212 case RB_GETBANDINFOA: 4213 return REBAR_GetBandInfoA (infoPtr, wParam, lParam); 4214 4215 case RB_GETBANDINFOW: 4216 return REBAR_GetBandInfoW (infoPtr, wParam, lParam); 4217 4218 case RB_GETBARHEIGHT: 4219 return REBAR_GetBarHeight (infoPtr, wParam, lParam); 4220 4221 case RB_GETBARINFO: 4222 return REBAR_GetBarInfo (infoPtr, wParam, lParam); 4223 4224 case RB_GETBKCOLOR: 4225 return REBAR_GetBkColor (infoPtr); 4226 4227 /* case RB_GETCOLORSCHEME: */ 4228 /* case RB_GETDROPTARGET: */ 4229 4230 case RB_GETPALETTE: 4231 return REBAR_GetPalette (infoPtr, wParam, lParam); 4232 4233 case RB_GETRECT: 4234 return REBAR_GetRect (infoPtr, wParam, lParam); 4235 4236 case RB_GETROWCOUNT: 4237 return REBAR_GetRowCount (infoPtr); 4238 4239 case RB_GETROWHEIGHT: 4240 return REBAR_GetRowHeight (infoPtr, wParam, lParam); 4241 4242 case RB_GETTEXTCOLOR: 4243 return REBAR_GetTextColor (infoPtr); 4244 4245 case RB_GETTOOLTIPS: 4246 return REBAR_GetToolTips (infoPtr); 4247 4248 case RB_GETUNICODEFORMAT: 4249 return REBAR_GetUnicodeFormat (infoPtr); 4250 4251 case CCM_GETVERSION: 4252 return REBAR_GetVersion (infoPtr); 4253 4254 case RB_HITTEST: 4255 return REBAR_HitTest (infoPtr, wParam, lParam); 4256 4257 case RB_IDTOINDEX: 4258 return REBAR_IdToIndex (infoPtr, wParam, lParam); 4259 4260 case RB_INSERTBANDA: 4261 return REBAR_InsertBandA (infoPtr, wParam, lParam); 4262 4263 case RB_INSERTBANDW: 4264 return REBAR_InsertBandW (infoPtr, wParam, lParam); 4265 4266 case RB_MAXIMIZEBAND: 4267 return REBAR_MaximizeBand (infoPtr, wParam, lParam); 4268 4269 case RB_MINIMIZEBAND: 4270 return REBAR_MinimizeBand (infoPtr, wParam, lParam); 4271 4272 case RB_MOVEBAND: 4273 return REBAR_MoveBand (infoPtr, wParam, lParam); 4274 4275 case RB_SETBANDINFOA: 4276 return REBAR_SetBandInfoA (infoPtr, wParam, lParam); 4277 4278 case RB_SETBANDINFOW: 4279 return REBAR_SetBandInfoW (infoPtr, wParam, lParam); 4280 4281 case RB_SETBARINFO: 4282 return REBAR_SetBarInfo (infoPtr, wParam, lParam); 4283 4284 case RB_SETBKCOLOR: 4285 return REBAR_SetBkColor (infoPtr, wParam, lParam); 4286 4287 /* case RB_SETCOLORSCHEME: */ 4288 /* case RB_SETPALETTE: */ 4289 /* return REBAR_GetPalette (infoPtr, wParam, lParam); */ 4290 4291 case RB_SETPARENT: 4292 return REBAR_SetParent (infoPtr, wParam, lParam); 4293 4294 case RB_SETTEXTCOLOR: 4295 return REBAR_SetTextColor (infoPtr, wParam, lParam); 4296 4297 /* case RB_SETTOOLTIPS: */ 4298 4299 case RB_SETUNICODEFORMAT: 4300 return REBAR_SetUnicodeFormat (infoPtr, wParam); 4301 4302 case CCM_SETVERSION: 4303 return REBAR_SetVersion (infoPtr, (INT)wParam); 4304 4305 case RB_SHOWBAND: 4306 return REBAR_ShowBand (infoPtr, wParam, lParam); 4307 4308 case RB_SIZETORECT: 4309 return REBAR_SizeToRect (infoPtr, wParam, lParam); 4113 4310 4114 4311 4115 4312 /* Messages passed to parent */ 4116 4117 4118 4119 4120 4121 4122 4123 4124 4313 case WM_COMMAND: 4314 case WM_DRAWITEM: 4315 case WM_NOTIFY: 4316 if (infoPtr->NtfUnicode) 4317 return SendMessageW (REBAR_GetNotifyParent (infoPtr), 4318 uMsg, wParam, lParam); 4319 else 4320 return SendMessageA (REBAR_GetNotifyParent (infoPtr), 4321 uMsg, wParam, lParam); 4125 4322 4126 4323 4127 4324 /* case WM_CHARTOITEM: supported according to ControlSpy */ 4128 4325 4129 4130 4131 4132 4133 4326 case WM_CREATE: 4327 return REBAR_Create (infoPtr, wParam, lParam); 4328 4329 case WM_DESTROY: 4330 return REBAR_Destroy (infoPtr, wParam, lParam); 4134 4331 4135 4332 case WM_ERASEBKGND: 4136 4137 4138 4139 4333 return REBAR_EraseBkGnd (infoPtr, wParam, lParam); 4334 4335 case WM_GETFONT: 4336 return REBAR_GetFont (infoPtr, wParam, lParam); 4140 4337 4141 4338 /* case WM_LBUTTONDBLCLK: supported according to ControlSpy */ 4142 4339 4143 4144 4145 4146 4147 4340 case WM_LBUTTONDOWN: 4341 return REBAR_LButtonDown (infoPtr, wParam, lParam); 4342 4343 case WM_LBUTTONUP: 4344 return REBAR_LButtonUp (infoPtr, wParam, lParam); 4148 4345 4149 4346 /* case WM_MEASUREITEM: supported according to ControlSpy */ 4150 4347 4151 4152 4153 4154 4155 4348 case WM_MOUSEMOVE: 4349 return REBAR_MouseMove (infoPtr, wParam, lParam); 4350 4351 case WM_NCCALCSIZE: 4352 return REBAR_NCCalcSize (infoPtr, wParam, lParam); 4156 4353 4157 4354 case WM_NCCREATE: 4158 4355 return REBAR_NCCreate (hwnd, wParam, lParam); 4159 4356 4160 4357 case WM_NCHITTEST: 4161 4162 4163 4164 4358 return REBAR_NCHitTest (infoPtr, wParam, lParam); 4359 4360 case WM_NCPAINT: 4361 return REBAR_NCPaint (infoPtr, wParam, lParam); 4165 4362 4166 4363 case WM_NOTIFYFORMAT: 4167 4168 4169 4170 4364 return REBAR_NotifyFormat (infoPtr, wParam, lParam); 4365 4366 case WM_PAINT: 4367 return REBAR_Paint (infoPtr, wParam, lParam); 4171 4368 4172 4369 /* case WM_PALETTECHANGED: supported according to ControlSpy */ … … 4176 4373 /* case WM_RBUTTONUP: supported according to ControlSpy */ 4177 4374 4178 4179 4180 4181 4182 4375 case WM_SETCURSOR: 4376 return REBAR_SetCursor (infoPtr, wParam, lParam); 4377 4378 case WM_SETFONT: 4379 return REBAR_SetFont (infoPtr, wParam, lParam); 4183 4380 4184 4381 case WM_SETREDRAW: 4185 4186 4187 4188 4382 return REBAR_SetRedraw (infoPtr, wParam, lParam); 4383 4384 case WM_SIZE: 4385 return REBAR_Size (infoPtr, wParam, lParam); 4189 4386 4190 4387 case WM_STYLECHANGED: 4191 4388 return REBAR_StyleChanged (infoPtr, wParam, lParam); 4192 4389 4193 4390 /* case WM_SYSCOLORCHANGE: supported according to ControlSpy */ 4194 4391 /* "Applications that have brushes using the existing system colors 4195 should delete those brushes and recreate them using the new 4392 should delete those brushes and recreate them using the new 4196 4393 system colors." per MSDN */ 4197 4394 4198 4395 /* case WM_VKEYTOITEM: supported according to ControlSpy */ 4199 /* 4200 4201 4202 4203 4204 4396 /* case WM_WININICHANGE: */ 4397 4398 default: 4399 if (uMsg >= WM_USER) 4400 ERR("unknown msg %04x wp=%08x lp=%08lx\n", 4401 uMsg, wParam, lParam); 4205 4402 #ifdef __WIN32OS2__ 4206 4403 return defComCtl32ProcA (hwnd, uMsg, wParam, lParam); 4207 4404 #else 4208 4405 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 4209 4406 #endif 4210 4407 } … … 4225 4422 wndClass.hCursor = 0; 4226 4423 wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); 4424 #if GLATESTING 4425 wndClass.hbrBackground = CreateSolidBrush(RGB(0,128,0)); 4426 #endif 4227 4427 wndClass.lpszClassName = REBARCLASSNAMEA; 4228 4428 4229 4429 RegisterClassA (&wndClass); 4230 4430 -
trunk/src/comctl32/status.c
r6644 r6705 1 /* $Id: status.c,v 1.23 2001-09-05 12:05:02 bird Exp $ */2 1 /* 3 2 * Interface code to StatusWindow widget/control -
trunk/src/comctl32/tab.c
r6644 r6705 1 /* $Id: tab.c,v 1.21 2001-09-05 12:05:02 bird Exp $ */2 1 /* 3 2 * Tab control -
trunk/src/comctl32/toolbar.c
r6644 r6705 1 /* $Id: toolbar.c,v 1.29 2001-09-05 12:05:03 bird Exp $ */2 1 /* 3 2 * Toolbar control … … 5 4 * Copyright 1998,1999 Eric Kohl 6 5 * Copyright 2000 Eric Kohl for CodeWeavers 6 * 7 * Differences between MSDN and actual native control operation: 8 * 1. MSDN says: "TBSTYLE_LIST: Creates a flat toolbar with button text 9 * to the right of the bitmap. Otherwise, this style is 10 * identical to TBSTYLE_FLAT." 11 * As implemented by both v4.71 and v5.80 of the native COMCTL32.DLL 12 * you can create a TBSTYLE_LIST without TBSTYLE_FLAT and the result 13 * is non-flat non-transparent buttons. Therefore TBSTYLE_LIST does 14 * *not* imply TBSTYLE_FLAT as documented. (GA 8/2001) 15 * 7 16 * 8 17 * TODO: … … 51 60 DEFAULT_DEBUG_CHANNEL(toolbar); 52 61 62 #ifdef __WIN32OS2__ 63 #undef inline 64 #define inline 65 #define COMCTL32_hPattern55AABrush GetPattern55AABrush() 66 #endif 67 53 68 typedef struct 54 69 { … … 63 78 INT nRow; 64 79 RECT rect; 65 } TBUTTON_INFO; 66 67 #ifdef __WIN32OS2__ 68 #define COMCTL32_hPattern55AABrush GetPattern55AABrush() 69 #endif 80 } TBUTTON_INFO; 70 81 71 82 typedef struct … … 98 109 HWND hwndToolTip; /* handle to tool tip control */ 99 110 HWND hwndNotify; /* handle to the window that gets notifications */ 111 HWND hwndSelf; /* my own handle */ 100 112 BOOL bTransparent; /* background transparency flag */ 113 BOOL bBtnTranspnt; /* button transparency flag */ 101 114 BOOL bAutoSize; /* auto size deadlock indicator */ 102 115 BOOL bAnchor; /* anchor highlight enabled */ 116 BOOL bNtfUnicode; /* TRUE if NOTIFYs use {W} */ 103 117 DWORD dwExStyle; /* extended toolbar style */ 104 118 DWORD dwDTFlags; /* DrawText flags */ … … 132 146 #define TOP_BORDER 2 133 147 #define BOTTOM_BORDER 2 134 #define DDARROW_WIDTH 11 148 #define DDARROW_WIDTH 11 135 149 136 150 #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0)) 137 151 #define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE) 138 152 #define TOOLBAR_HasDropDownArrows(exStyle) ((exStyle & TBSTYLE_EX_DRAWDDARROWS) ? TRUE : FALSE) 153 154 155 static void 156 TOOLBAR_DumpButton(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *bP, INT btn_num, BOOL internal) 157 { 158 if (TRACE_ON(toolbar)){ 159 TRACE("button %d id %d, bitmap=%d, state=%02x, style=%02x, data=%08lx, string=%d\n", 160 btn_num, bP->idCommand, 161 bP->iBitmap, bP->fsState, bP->fsStyle, bP->dwData, bP->iString); 162 if (internal) 163 TRACE("button %d id %d, hot=%s, row=%d, rect=(%d,%d)-(%d,%d)\n", 164 btn_num, bP->idCommand, 165 (bP->bHot) ? "TRUE":"FALSE", bP->nRow, 166 bP->rect.left, bP->rect.top, 167 bP->rect.right, bP->rect.bottom); 168 } 169 } 170 171 172 static void 173 TOOLBAR_DumpToolbar(TOOLBAR_INFO *iP, INT line) 174 { 175 if (TRACE_ON(toolbar)) { 176 INT i; 177 DWORD dwStyle; 178 179 dwStyle = GetWindowLongA (iP->hwndSelf, GWL_STYLE); 180 TRACE("toolbar %08x at line %d, exStyle=%08lx, buttons=%d, bitmaps=%d, strings=%d, style=%08lx\n", 181 iP->hwndSelf, line, 182 iP->dwExStyle, iP->nNumButtons, iP->nNumBitmaps, 183 iP->nNumStrings, dwStyle); 184 TRACE("toolbar %08x at line %d, himlInt=%p, himlDef=%p, himlHot=%p, himlDis=%p\n", 185 iP->hwndSelf, line, 186 iP->himlInt, iP->himlDef, iP->himlHot, iP->himlDis); 187 for(i=0; i<iP->nNumButtons; i++) { 188 TOOLBAR_DumpButton(iP, &iP->buttons[i], i, TRUE); 189 } 190 } 191 } 192 193 194 /*********************************************************************** 195 * TOOLBAR_CheckStyle 196 * 197 * This function validates that the styles set are implemented and 198 * issues FIXME's warning of possible problems. In a perfect world this 199 * function should be null. 200 */ 201 static void 202 TOOLBAR_CheckStyle (HWND hwnd, DWORD dwStyle) 203 { 204 if (dwStyle & TBSTYLE_ALTDRAG) 205 FIXME("[%04x] TBSTYLE_ALTDRAG not implemented\n", hwnd); 206 if (dwStyle & TBSTYLE_REGISTERDROP) 207 FIXME("[%04x] TBSTYLE_REGISTERDROP not implemented\n", hwnd); 208 } 209 210 211 static INT 212 TOOLBAR_SendNotify (NMHDR *nmhdr, TOOLBAR_INFO *infoPtr, UINT code) 213 { 214 nmhdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf); 215 nmhdr->hwndFrom = infoPtr->hwndSelf; 216 nmhdr->code = code; 217 218 TRACE("to window %04x, code=%08x, %s\n", infoPtr->hwndNotify, code, 219 (infoPtr->bNtfUnicode) ? "via Unicode" : "via ANSI"); 220 221 if (infoPtr->bNtfUnicode) 222 return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY, 223 (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr); 224 else 225 return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, 226 (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr); 227 } 139 228 140 229 static LPWSTR … … 148 237 else if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings)) 149 238 lpText = infoPtr->strings[btnPtr->iString]; 150 239 151 240 return lpText; 152 241 } 153 242 154 static BOOL 243 /*********************************************************************** 244 * TOOLBAR_GetBitmapIndex 245 * 246 * This function returns the bitmap index associated with a button. 247 * If the button specifies I_IMAGECALLBACK, then the TBN_GETDISPINFO 248 * is issued to retrieve the index. 249 */ 250 static INT 251 TOOLBAR_GetBitmapIndex(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr) 252 { 253 INT ret = btnPtr->iBitmap; 254 255 if (ret == I_IMAGECALLBACK) { 256 /* issue TBN_GETDISPINFO */ 257 NMTBDISPINFOA nmgd; 258 259 nmgd.idCommand = btnPtr->idCommand; 260 nmgd.lParam = btnPtr->dwData; 261 nmgd.dwMask = TBNF_IMAGE; 262 TOOLBAR_SendNotify ((NMHDR *) &nmgd, infoPtr, 263 (infoPtr->bNtfUnicode) ? TBN_GETDISPINFOW : 264 TBN_GETDISPINFOA); 265 if (nmgd.dwMask & TBNF_DI_SETITEM) { 266 btnPtr->iBitmap = nmgd.iImage; 267 } 268 ret = nmgd.iImage; 269 TRACE("TBN_GETDISPINFOA returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n", 270 ret, nmgd.dwMask, infoPtr->nNumBitmaps); 271 } 272 return ret; 273 } 274 275 276 static BOOL 155 277 TOOLBAR_IsValidBitmapIndex(TOOLBAR_INFO *infoPtr, INT index) 156 278 { 157 if ((index>=0) && (index < infoPtr->nNumBitmaps)) 279 if (((index>=0) && (index <= infoPtr->nNumBitmaps)) || 280 (index == I_IMAGECALLBACK)) 158 281 return TRUE; 159 282 else 160 283 return FALSE; 284 } 285 286 287 /*********************************************************************** 288 * TOOLBAR_DrawImageList 289 * 290 * This function validates the bitmap index (including I_IMAGECALLBACK 291 * functionality). It then draws the image via the ImageList_Draw 292 * function. It returns TRUE if the image was drawn, FALSE otherwise. 293 */ 294 static BOOL 295 TOOLBAR_DrawImageList (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HIMAGELIST himl, 296 HDC hdc, UINT left, UINT top, UINT draw_flags) 297 { 298 INT index; 299 300 if (!himl) return FALSE; 301 302 if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) { 303 ERR("index %d is not valid, max %d\n", 304 btnPtr->iBitmap, infoPtr->nNumBitmaps); 305 return FALSE; 306 } 307 308 if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) { 309 if (index == -1) return FALSE; 310 ERR("TBN_GETDISPINFO returned invalid index %d\n", 311 index); 312 return FALSE; 313 } 314 TRACE("drawing index=%d, himl=%p, left=%d, top=%d, flags=%08x\n", 315 index, himl, left, top, draw_flags); 316 317 ImageList_Draw (himl, index, hdc, left, top, draw_flags); 318 return TRUE; 319 } 320 321 322 /*********************************************************************** 323 * TOOLBAR_TestImageExist 324 * 325 * This function is similar to TOOLBAR_DrawImageList, except it does not 326 * draw the image. The I_IMAGECALLBACK functionality is implemented. 327 */ 328 static BOOL 329 TOOLBAR_TestImageExist (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HIMAGELIST himl) 330 { 331 INT index; 332 333 if (!himl) return FALSE; 334 335 if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) { 336 ERR("index %d is not valid, max %d\n", 337 btnPtr->iBitmap, infoPtr->nNumBitmaps); 338 return FALSE; 339 } 340 341 if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) { 342 if (index == -1) return FALSE; 343 ERR("TBN_GETDISPINFO returned invalid index %d\n", 344 index); 345 return FALSE; 346 } 347 return TRUE; 161 348 } 162 349 … … 177 364 LineTo (hdc, x, yTop); 178 365 } 366 367 368 /*********************************************************************** 369 * TOOLBAR_DrawDDFlatSeparator 370 * 371 * This function draws the separator that was flaged as TBSTYLE_DROPDOWN. 372 * In this case, the separator is a pixel high line of COLOR_BTNSHADOW, 373 * followed by a pixel high line of COLOR_BTNHIGHLIGHT. These separators 374 * are horizontal as opposed to the vertical separators for not dropdown 375 * type. 376 * 377 * FIXME: It is possible that the height of each line is really SM_CYBORDER. 378 */ 379 static void 380 TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect, HDC hdc, TBUTTON_INFO *btnPtr) 381 { 382 RECT myrect; 383 COLORREF oldcolor, newcolor; 384 385 myrect.left = lpRect->left; 386 myrect.right = lpRect->right; 387 myrect.top = lpRect->top + (lpRect->bottom - lpRect->top - 2)/2; 388 myrect.bottom = myrect.top + 1; 389 390 InflateRect (&myrect, -2, 0); 391 392 TRACE("rect=(%d,%d)-(%d,%d)\n", 393 myrect.left, myrect.top, myrect.right, myrect.bottom); 394 395 newcolor = GetSysColor (COLOR_BTNSHADOW); 396 oldcolor = SetBkColor (hdc, newcolor); 397 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0); 398 399 myrect.top = myrect.bottom; 400 myrect.bottom = myrect.top + 1; 401 402 newcolor = GetSysColor (COLOR_BTNHIGHLIGHT); 403 SetBkColor (hdc, newcolor); 404 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0); 405 406 SetBkColor (hdc, oldcolor); 407 } 408 179 409 180 410 static void … … 196 426 * Draw the text string for this button. 197 427 * note: infoPtr->himlDis *SHOULD* be non-zero when infoPtr->himlDef 198 * 428 * is non-zero, so we can simply check himlDef to see if we have 199 429 * an image list 200 430 */ 201 431 static void 202 432 TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, 203 433 HDC hdc, INT nState, DWORD dwStyle) 204 434 { 205 435 RECT rcText = btnPtr->rect; 206 436 HFONT hOldFont; 207 INT nOldBkMode;208 437 COLORREF clrOld; 209 438 LPWSTR lpText = NULL; … … 220 449 if (lpText) { 221 450 222 InflateRect (&rcText, -3, -3); 223 224 if (himl && TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) { 225 if ((dwStyle & TBSTYLE_LIST) && 226 ((btnPtr->fsStyle & TBSTYLE_AUTOSIZE) == 0) && 227 (btnPtr->iBitmap != I_IMAGENONE)) { 228 rcText.left += infoPtr->nBitmapWidth; 229 } 230 else { 231 rcText.top += infoPtr->nBitmapHeight; 232 } 233 } 234 235 if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED)) 236 OffsetRect (&rcText, 1, 1); 237 238 hOldFont = SelectObject (hdc, infoPtr->hFont); 239 nOldBkMode = SetBkMode (hdc, TRANSPARENT); 240 if (!(nState & TBSTATE_ENABLED)) { 241 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT)); 242 OffsetRect (&rcText, 1, 1); 243 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags); 244 SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW)); 245 OffsetRect (&rcText, -1, -1); 246 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags); 247 } 248 else if (nState & TBSTATE_INDETERMINATE) { 249 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW)); 250 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags); 251 } 252 else { 253 clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT)); 254 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags); 255 } 256 257 SetTextColor (hdc, clrOld); 258 SelectObject (hdc, hOldFont); 259 if (nOldBkMode != TRANSPARENT) 260 SetBkMode (hdc, nOldBkMode); 451 InflateRect (&rcText, -3, -3); 452 453 if (himl && TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) { 454 /* The following test looked like this before 455 * I changed it. IE4 "Links" toolbar would not 456 * draw correctly with the original code. - GA 8/01 457 * ((dwStyle & TBSTYLE_LIST) && 458 * ((btnPtr->fsStyle & TBSTYLE_AUTOSIZE) == 0) && 459 * (btnPtr->iBitmap != I_IMAGENONE)) 460 */ 461 if (dwStyle & TBSTYLE_LIST) { 462 /* LIST style w/ ICON offset is by matching native. */ 463 /* Matches IE4 "Links" bar. - GA 8/01 */ 464 rcText.left += (infoPtr->nBitmapWidth + 2); 465 } 466 else { 467 rcText.top += infoPtr->nBitmapHeight + 1; 468 } 469 } 470 else { 471 if (dwStyle & TBSTYLE_LIST) { 472 /* LIST style w/o ICON offset is by matching native. */ 473 /* Matches IE4 "menu" bar. - GA 8/01 */ 474 rcText.left += 4; 475 } 476 } 477 478 if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED)) 479 OffsetRect (&rcText, 1, 1); 480 481 TRACE("string rect=(%d,%d)-(%d,%d)\n", 482 rcText.left, rcText.top, rcText.right, rcText.bottom); 483 484 hOldFont = SelectObject (hdc, infoPtr->hFont); 485 if (!(nState & TBSTATE_ENABLED)) { 486 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT)); 487 OffsetRect (&rcText, 1, 1); 488 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags); 489 SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW)); 490 OffsetRect (&rcText, -1, -1); 491 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags); 492 } 493 else if (nState & TBSTATE_INDETERMINATE) { 494 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW)); 495 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags); 496 } 497 else { 498 clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT)); 499 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags); 500 } 501 502 SetTextColor (hdc, clrOld); 503 SelectObject (hdc, hOldFont); 261 504 } 262 505 } … … 276 519 static void 277 520 TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, 278 521 HDC hdc, INT x, INT y) 279 522 { 280 523 /* FIXME: this function is a hack since it uses image list 281 524 internals directly */ 282 525 283 526 HIMAGELIST himl = infoPtr->himlDef; … … 287 530 288 531 if (!himl) 289 532 return; 290 533 291 534 /* create new dc's */ … … 302 545 SetTextColor (hdcImageList, RGB(0, 0, 0)); 303 546 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy, 304 547 hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY); 305 548 306 549 /* draw the new mask */ 307 550 SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT)); 308 551 BitBlt (hdc, x+1, y+1, himl->cx, himl->cy, 309 552 hdcMask, 0, 0, 0xB8074A); 310 553 311 554 SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW)); 312 555 BitBlt (hdc, x, y, himl->cx, himl->cy, 313 556 hdcMask, 0, 0, 0xB8074A); 314 557 315 558 DeleteObject (hbmMask); … … 325 568 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 326 569 BOOL hasDropDownArrow = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && 327 570 (btnPtr->fsStyle & TBSTYLE_DROPDOWN); 328 571 RECT rc, rcArrow, rcBitmap; 329 572 330 573 if (btnPtr->fsState & TBSTATE_HIDDEN) 331 574 return; 332 575 333 576 rc = btnPtr->rect; … … 335 578 CopyRect(&rcBitmap, &rc); 336 579 337 FillRect( hdc, &rc, GetSysColorBrush(COLOR_BTNFACE)); 580 if (!infoPtr->bBtnTranspnt) 581 FillRect( hdc, &rc, GetSysColorBrush(COLOR_BTNFACE)); 338 582 339 583 if (hasDropDownArrow) 340 584 { 341 585 if (dwStyle & TBSTYLE_FLAT) 342 586 rc.right = max(rc.left, rc.right - DDARROW_WIDTH); 587 else 588 rc.right = max(rc.left, rc.right - DDARROW_WIDTH - 2); 589 rcArrow.left = rc.right; 590 } 591 592 /* Center the bitmap horizontally and vertically */ 593 if (dwStyle & TBSTYLE_LIST) 594 rcBitmap.left += 3; 343 595 else 344 rc.right = max(rc.left, rc.right - DDARROW_WIDTH - 2); 345 rcArrow.left = rc.right; 346 } 347 348 /* Center the bitmap horizontally and vertically */ 349 rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2; 596 rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2; 350 597 351 598 if(TOOLBAR_HasText(infoPtr, btnPtr)) … … 354 601 rcBitmap.top+=(infoPtr->nButtonHeight - infoPtr->nBitmapHeight) / 2; 355 602 356 TRACE("iBitmap: %d\n", btnPtr->iBitmap); 603 TRACE("iBitmap: %d, start=(%d,%d) w=%d, h=%d\n", 604 btnPtr->iBitmap, rcBitmap.left, rcBitmap.top, 605 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight); 357 606 358 607 /* separator */ … … 363 612 /* empirical tests show that iBitmap can/will be non-zero */ 364 613 /* when drawing the vertical bar... */ 365 if ((dwStyle & TBSTYLE_FLAT) /* && (btnPtr->iBitmap == 0) */) 366 TOOLBAR_DrawFlatSeparator (&rc, hdc); 367 return; 614 if ((dwStyle & TBSTYLE_FLAT) /* && (btnPtr->iBitmap == 0) */) { 615 if (btnPtr->fsStyle & TBSTYLE_DROPDOWN) 616 TOOLBAR_DrawDDFlatSeparator (&rc, hdc, btnPtr); 617 else 618 TOOLBAR_DrawFlatSeparator (&rc, hdc); 619 } 620 return; 368 621 } 369 622 370 623 /* disabled */ 371 624 if (!(btnPtr->fsState & TBSTATE_ENABLED)) { 372 373 374 375 625 if (!(dwStyle & TBSTYLE_FLAT)) 626 { 627 DrawEdge (hdc, &rc, EDGE_RAISED, 628 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 376 629 if (hasDropDownArrow) 377 630 DrawEdge (hdc, &rcArrow, EDGE_RAISED, 378 379 380 631 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 632 } 633 381 634 if (hasDropDownArrow) 382 { 383 TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top+1, COLOR_3DHIGHLIGHT); 384 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_3DSHADOW); 385 } 386 387 if (infoPtr->himlDis && 388 TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) 389 ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc, 390 rcBitmap.left, rcBitmap.top, ILD_NORMAL); 391 else 392 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top); 393 394 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); 395 return; 635 { 636 TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top+1, COLOR_3DHIGHLIGHT); 637 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_3DSHADOW); 638 } 639 640 if (!TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDis, 641 hdc, rcBitmap.left, rcBitmap.top, 642 ILD_NORMAL)) 643 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top); 644 645 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); 646 return; 396 647 } 397 648 398 649 /* pressed TBSTYLE_BUTTON */ 399 650 if (btnPtr->fsState & TBSTATE_PRESSED) { 400 401 402 DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE| BF_ADJUST);651 if (dwStyle & TBSTYLE_FLAT) 652 { 653 DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST); 403 654 if (hasDropDownArrow) 404 DrawEdge (hdc, &rcArrow, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE| BF_ADJUST);405 406 407 408 655 DrawEdge (hdc, &rcArrow, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST); 656 } 657 else 658 { 659 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST); 409 660 if (hasDropDownArrow) 410 411 661 DrawEdge (hdc, &rcArrow, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST); 662 } 412 663 413 664 if (hasDropDownArrow) 414 415 416 if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) 417 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 418 rcBitmap.left + 1, rcBitmap.top + 1,ILD_NORMAL);419 420 421 665 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME); 666 667 TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef, 668 hdc, rcBitmap.left+1, rcBitmap.top+1, 669 ILD_NORMAL); 670 671 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); 672 return; 422 673 } 423 674 424 675 /* checked TBSTYLE_CHECK */ 425 676 if ((btnPtr->fsStyle & TBSTYLE_CHECK) && 426 (btnPtr->fsState & TBSTATE_CHECKED)) { 427 if (dwStyle & TBSTYLE_FLAT) 428 DrawEdge (hdc, &rc, BDR_SUNKENOUTER, 429 BF_RECT | BF_MIDDLE | BF_ADJUST); 430 else 431 DrawEdge (hdc, &rc, EDGE_SUNKEN, 432 BF_RECT | BF_MIDDLE | BF_ADJUST); 433 434 TOOLBAR_DrawPattern (hdc, &rc); 435 436 if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) 437 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 438 rcBitmap.left + 1, rcBitmap.top + 1, ILD_NORMAL); 439 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); 440 return; 441 } 442 443 /* indeterminate */ 677 (btnPtr->fsState & TBSTATE_CHECKED)) { 678 if (dwStyle & TBSTYLE_FLAT) 679 DrawEdge (hdc, &rc, BDR_SUNKENOUTER, 680 BF_RECT | BF_ADJUST); 681 else 682 DrawEdge (hdc, &rc, EDGE_SUNKEN, 683 BF_RECT | BF_MIDDLE | BF_ADJUST); 684 685 TOOLBAR_DrawPattern (hdc, &rc); 686 687 TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef, 688 hdc, rcBitmap.left+1, rcBitmap.top+1, 689 ILD_NORMAL); 690 691 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); 692 return; 693 } 694 695 /* indeterminate */ 444 696 if (btnPtr->fsState & TBSTATE_INDETERMINATE) { 445 446 447 448 449 450 451 697 DrawEdge (hdc, &rc, EDGE_RAISED, 698 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 699 700 TOOLBAR_DrawPattern (hdc, &rc); 701 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top); 702 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); 703 return; 452 704 } 453 705 … … 455 707 if (dwStyle & TBSTYLE_FLAT) 456 708 { 457 458 459 DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);709 if (btnPtr->bHot) 710 { 711 DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT); 460 712 if (hasDropDownArrow) 461 DrawEdge (hdc, &rcArrow, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE); 462 } 463 else 464 { 713 DrawEdge (hdc, &rcArrow, BDR_RAISEDINNER, BF_RECT); 714 } 715 #if 1 716 else /* The following code needs to be removed after 717 * "hot item" support has been implemented for the 718 * case where it is being de-selected. 719 */ 720 { 465 721 FrameRect(hdc, &rc, GetSysColorBrush(COLOR_BTNFACE)); 466 722 if (hasDropDownArrow) 467 723 FrameRect(hdc, &rcArrow, GetSysColorBrush(COLOR_BTNFACE)); 468 } 724 } 725 #endif 469 726 470 727 if (hasDropDownArrow) 471 TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top, COLOR_WINDOWFRAME); 472 473 if (btnPtr->bHot && infoPtr->himlHot && 474 TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) 475 ImageList_Draw (infoPtr->himlHot, btnPtr->iBitmap, hdc, 476 rcBitmap.left, rcBitmap.top, ILD_NORMAL); 477 else if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) 478 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, 479 rcBitmap.left, rcBitmap.top, ILD_NORMAL); 728 TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top, COLOR_WINDOWFRAME); 729 730 if (btnPtr->bHot) { 731 /* if hot, attempt to draw with himlHot, if fails, use himlDef */ 732 if (!TOOLBAR_DrawImageList (infoPtr, btnPtr, 733 infoPtr->himlHot, 734 hdc, rcBitmap.left, 735 rcBitmap.top, ILD_NORMAL)) 736 TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef, 737 hdc, rcBitmap.left, rcBitmap.top, 738 ILD_NORMAL); 739 } 740 else 741 TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef, 742 hdc, rcBitmap.left, rcBitmap.top, 743 ILD_NORMAL); 480 744 } 481 745 else 482 746 { 483 484 747 DrawEdge (hdc, &rc, EDGE_RAISED, 748 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 485 749 486 750 if (hasDropDownArrow) 487 488 489 490 491 492 493 if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) 494 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,495 rcBitmap.left, rcBitmap.top,ILD_NORMAL);751 { 752 DrawEdge (hdc, &rcArrow, EDGE_RAISED, 753 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); 754 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME); 755 } 756 757 TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef, 758 hdc, rcBitmap.left, rcBitmap.top, 759 ILD_NORMAL); 496 760 } 497 761 … … 505 769 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 506 770 TBUTTON_INFO *btnPtr; 507 INT i ;771 INT i, oldBKmode = 0; 508 772 RECT rcTemp; 509 773 … … 512 776 if (infoPtr->himlDef != infoPtr->himlInt) 513 777 infoPtr->nNumBitmaps = ImageList_GetImageCount(infoPtr->himlDef); 778 779 TOOLBAR_DumpToolbar (infoPtr, __LINE__); 780 781 if (infoPtr->bBtnTranspnt) 782 oldBKmode = SetBkMode (hdc, TRANSPARENT); 783 514 784 /* redraw necessary buttons */ 515 785 btnPtr = infoPtr->buttons; … … 519 789 TOOLBAR_DrawButton (hwnd, btnPtr, hdc); 520 790 } 521 } 522 791 792 if (infoPtr->bBtnTranspnt && (oldBKmode != TRANSPARENT)) 793 SetBkMode (hdc, oldBKmode); 794 } 795 796 /*********************************************************************** 797 * TOOLBAR_MeasureString 798 * 799 * This function gets the width and height of a string in pixels. This 800 * is done first by using GetTextExtentPoint to get the basic width 801 * and height. The DrawText is called with DT_CALCRECT to get the exact 802 * width. The reason is because the text may have more than one "&" (or 803 * prefix characters as M$ likes to call them). The prefix character 804 * indicates where the underline goes, except for the string "&&" which 805 * is reduced to a single "&". GetTextExtentPoint does not process these 806 * only DrawText does. Note that the TBSTYLE_NOPREFIX is handled here. 807 */ 523 808 static void 524 TOOLBAR_MeasureString(HWND hwnd, INT index, LPSIZE lpSize) 525 { 526 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 527 TBUTTON_INFO *btnPtr; 528 HDC hdc; 529 HFONT hOldFont; 809 TOOLBAR_MeasureString(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, 810 HDC hdc, LPSIZE lpSize) 811 { 812 RECT myrect; 530 813 531 814 lpSize->cx = 0; 532 815 lpSize->cy = 0; 533 hdc = GetDC (0);534 hOldFont = SelectObject (hdc, infoPtr->hFont);535 536 btnPtr = &infoPtr->buttons[index];537 816 538 817 if (!(btnPtr->fsState & TBSTATE_HIDDEN) && 539 818 (btnPtr->iString > -1) && 540 (btnPtr->iString < infoPtr->nNumStrings)) 819 (btnPtr->iString < infoPtr->nNumStrings)) 541 820 { 542 821 LPWSTR lpText = infoPtr->strings[btnPtr->iString]; 822 823 /* first get size of all the text */ 543 824 GetTextExtentPoint32W (hdc, lpText, strlenW (lpText), lpSize); 544 } 545 546 SelectObject (hdc, hOldFont); 547 ReleaseDC (0, hdc); 825 826 /* feed above size into the rectangle for DrawText */ 827 myrect.left = myrect.top = 0; 828 myrect.right = lpSize->cx; 829 myrect.bottom = lpSize->cy; 830 831 /* Use DrawText to get true size as drawn (less pesky "&") */ 832 DrawTextW (hdc, lpText, -1, &myrect, DT_VCENTER | DT_SINGLELINE | 833 DT_CALCRECT | ((btnPtr->fsStyle & TBSTYLE_NOPREFIX) ? 834 DT_NOPREFIX : 0)); 835 836 /* feed back to caller */ 837 lpSize->cx = myrect.right; 838 lpSize->cy = myrect.bottom; 839 } 548 840 549 841 TRACE("string size %ld x %ld!\n", lpSize->cx, lpSize->cy); 550 842 } 551 843 844 /*********************************************************************** 845 * TOOLBAR_CalcStrings 846 * 847 * This function walks through each string and measures it and returns 848 * the largest height and width to caller. 849 */ 552 850 static void 553 851 TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize) … … 557 855 INT i; 558 856 SIZE sz; 559 857 HDC hdc; 858 HFONT hOldFont; 560 859 561 860 lpSize->cx = 0; 562 861 lpSize->cy = 0; 862 863 hdc = GetDC (hwnd); 864 hOldFont = SelectObject (hdc, infoPtr->hFont); 563 865 564 866 btnPtr = infoPtr->buttons; … … 566 868 if(TOOLBAR_HasText(infoPtr, btnPtr)) 567 869 { 568 TOOLBAR_MeasureString( hwnd,i,&sz);870 TOOLBAR_MeasureString(infoPtr, btnPtr, hdc, &sz); 569 871 if (sz.cx > lpSize->cx) 570 872 lpSize->cx = sz.cx; … … 574 876 } 575 877 576 TRACE("string size %ld x %ld!\n", lpSize->cx, lpSize->cy); 878 SelectObject (hdc, hOldFont); 879 ReleaseDC (hwnd, hdc); 880 881 TRACE("max string size %ld x %ld!\n", lpSize->cx, lpSize->cy); 577 882 } 578 883 579 884 /*********************************************************************** 580 * 885 * TOOLBAR_WrapToolbar 581 886 * 582 * This function walks through the buttons and seperators in the 583 * toolbar, and sets the TBSTATE_WRAP flag only on those items where 584 * wrapping should occur based on the width of the toolbar window. 585 * It does *not* calculate button placement itself. That task 586 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage 587 * the toolbar wrapping on it 's own, it can use the TBSTYLE_WRAPPABLE887 * This function walks through the buttons and seperators in the 888 * toolbar, and sets the TBSTATE_WRAP flag only on those items where 889 * wrapping should occur based on the width of the toolbar window. 890 * It does *not* calculate button placement itself. That task 891 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage 892 * the toolbar wrapping on its own, it can use the TBSTYLE_WRAPABLE 588 893 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items. 589 */ 894 */ 590 895 591 896 static void … … 598 903 BOOL bWrap, bButtonWrap; 599 904 600 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */601 /* 602 /* to perform their own layout on the toolbar.*/905 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */ 906 /* no layout is necessary. Applications may use this style */ 907 /* to perform their own layout on the toolbar. */ 603 908 if( !(dwStyle & TBSTYLE_WRAPABLE) ) 604 909 return; 605 910 606 911 btnPtr = infoPtr->buttons; … … 615 920 bButtonWrap = FALSE; 616 921 922 TRACE("start ButtonWidth=%d, BitmapWidth=%d, nWidth=%d, nIndent=%d\n", 923 infoPtr->nButtonWidth, infoPtr->nBitmapWidth, infoPtr->nWidth, 924 infoPtr->nIndent); 925 617 926 for (i = 0; i < infoPtr->nNumButtons; i++ ) 618 927 { 619 bWrap = FALSE; 620 btnPtr[i].fsState &= ~TBSTATE_WRAP; 621 622 if (btnPtr[i].fsState & TBSTATE_HIDDEN) 623 continue; 624 625 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */ 626 /* it is the actual width of the separator. This is used for */ 627 /* custom controls in toolbars. */ 628 if (btnPtr[i].fsStyle & TBSTYLE_SEP) 629 cx = (btnPtr[i].iBitmap > 0) ? 630 btnPtr[i].iBitmap : SEPARATOR_WIDTH; 631 else 632 cx = infoPtr->nButtonWidth; 633 634 /* Two or more adjacent separators form a separator group. */ 635 /* The first separator in a group should be wrapped to the */ 636 /* next row if the previous wrapping is on a button. */ 637 if( bButtonWrap && 638 (btnPtr[i].fsStyle & TBSTYLE_SEP) && 639 (i + 1 < infoPtr->nNumButtons ) && 640 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) ) 641 { 642 btnPtr[i].fsState |= TBSTATE_WRAP; 643 x = infoPtr->nIndent; 644 i++; 645 bButtonWrap = FALSE; 646 continue; 647 } 648 649 /* The layout makes sure the bitmap is visible, but not the button. */ 650 if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2 651 > infoPtr->nWidth ) 652 { 653 BOOL bFound = FALSE; 654 655 /* If the current button is a separator and not hidden, */ 656 /* go to the next until it reaches a non separator. */ 657 /* Wrap the last separator if it is before a button. */ 658 while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) || 659 (btnPtr[i].fsState & TBSTATE_HIDDEN) ) && 660 i < infoPtr->nNumButtons ) 661 { 662 i++; 663 bFound = TRUE; 664 } 665 666 if( bFound && i < infoPtr->nNumButtons ) 667 { 668 i--; 669 btnPtr[i].fsState |= TBSTATE_WRAP; 670 x = infoPtr->nIndent; 671 bButtonWrap = FALSE; 672 continue; 673 } 674 else if ( i >= infoPtr->nNumButtons) 675 break; 676 677 /* If the current button is not a separator, find the last */ 678 /* separator and wrap it. */ 679 for ( j = i - 1; j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--) 680 { 681 if ((btnPtr[j].fsStyle & TBSTYLE_SEP) && 682 !(btnPtr[j].fsState & TBSTATE_HIDDEN)) 683 { 684 bFound = TRUE; 685 i = j; 686 x = infoPtr->nIndent; 687 btnPtr[j].fsState |= TBSTATE_WRAP; 688 bButtonWrap = FALSE; 689 break; 690 } 691 } 692 693 /* If no separator available for wrapping, wrap one of */ 694 /* non-hidden previous button. */ 695 if (!bFound) 696 { 697 for ( j = i - 1; 698 j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--) 699 { 700 if (btnPtr[j].fsState & TBSTATE_HIDDEN) 701 continue; 702 703 bFound = TRUE; 704 i = j; 705 x = infoPtr->nIndent; 706 btnPtr[j].fsState |= TBSTATE_WRAP; 707 bButtonWrap = TRUE; 708 break; 709 } 710 } 711 712 /* If all above failed, wrap the current button. */ 713 if (!bFound) 714 { 715 btnPtr[i].fsState |= TBSTATE_WRAP; 716 bFound = TRUE; 717 x = infoPtr->nIndent; 718 if (btnPtr[i].fsState & TBSTYLE_SEP ) 719 bButtonWrap = FALSE; 720 else 721 bButtonWrap = TRUE; 722 } 723 } 724 else 725 x += cx; 928 bWrap = FALSE; 929 btnPtr[i].fsState &= ~TBSTATE_WRAP; 930 931 if (btnPtr[i].fsState & TBSTATE_HIDDEN) 932 continue; 933 934 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */ 935 /* it is the actual width of the separator. This is used for */ 936 /* custom controls in toolbars. */ 937 /* */ 938 /* TBSTYLE_DROPDOWN separators are treated as buttons for */ 939 /* width. - GA 8/01 */ 940 if ((btnPtr[i].fsStyle & TBSTYLE_SEP) && 941 !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN)) 942 cx = (btnPtr[i].iBitmap > 0) ? 943 btnPtr[i].iBitmap : SEPARATOR_WIDTH; 944 else 945 cx = infoPtr->nButtonWidth; 946 947 /* Two or more adjacent separators form a separator group. */ 948 /* The first separator in a group should be wrapped to the */ 949 /* next row if the previous wrapping is on a button. */ 950 if( bButtonWrap && 951 (btnPtr[i].fsStyle & TBSTYLE_SEP) && 952 (i + 1 < infoPtr->nNumButtons ) && 953 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) ) 954 { 955 TRACE("wrap point 1 btn %d style %02x\n", i, btnPtr[i].fsStyle); 956 btnPtr[i].fsState |= TBSTATE_WRAP; 957 x = infoPtr->nIndent; 958 i++; 959 bButtonWrap = FALSE; 960 continue; 961 } 962 963 /* The layout makes sure the bitmap is visible, but not the button. */ 964 /* Test added to also wrap after a button that starts a row but */ 965 /* is bigger than the area. - GA 8/01 */ 966 if (( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2 967 > infoPtr->nWidth ) || 968 ((x == infoPtr->nIndent) && (cx > infoPtr->nWidth))) 969 { 970 BOOL bFound = FALSE; 971 972 /* If the current button is a separator and not hidden, */ 973 /* go to the next until it reaches a non separator. */ 974 /* Wrap the last separator if it is before a button. */ 975 while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) || 976 (btnPtr[i].fsState & TBSTATE_HIDDEN) ) && 977 i < infoPtr->nNumButtons ) 978 { 979 i++; 980 bFound = TRUE; 981 } 982 983 if( bFound && i < infoPtr->nNumButtons ) 984 { 985 i--; 986 TRACE("wrap point 2 btn %d style %02x, x=%d, cx=%d\n", 987 i, btnPtr[i].fsStyle, x, cx); 988 btnPtr[i].fsState |= TBSTATE_WRAP; 989 x = infoPtr->nIndent; 990 bButtonWrap = FALSE; 991 continue; 992 } 993 else if ( i >= infoPtr->nNumButtons) 994 break; 995 996 /* If the current button is not a separator, find the last */ 997 /* separator and wrap it. */ 998 for ( j = i - 1; j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--) 999 { 1000 if ((btnPtr[j].fsStyle & TBSTYLE_SEP) && 1001 !(btnPtr[j].fsState & TBSTATE_HIDDEN)) 1002 { 1003 bFound = TRUE; 1004 i = j; 1005 TRACE("wrap point 3 btn %d style %02x, x=%d, cx=%d\n", 1006 i, btnPtr[i].fsStyle, x, cx); 1007 x = infoPtr->nIndent; 1008 btnPtr[j].fsState |= TBSTATE_WRAP; 1009 bButtonWrap = FALSE; 1010 break; 1011 } 1012 } 1013 1014 /* If no separator available for wrapping, wrap one of */ 1015 /* non-hidden previous button. */ 1016 if (!bFound) 1017 { 1018 for ( j = i - 1; 1019 j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--) 1020 { 1021 if (btnPtr[j].fsState & TBSTATE_HIDDEN) 1022 continue; 1023 1024 bFound = TRUE; 1025 i = j; 1026 TRACE("wrap point 4 btn %d style %02x, x=%d, cx=%d\n", 1027 i, btnPtr[i].fsStyle, x, cx); 1028 x = infoPtr->nIndent; 1029 btnPtr[j].fsState |= TBSTATE_WRAP; 1030 bButtonWrap = TRUE; 1031 break; 1032 } 1033 } 1034 1035 /* If all above failed, wrap the current button. */ 1036 if (!bFound) 1037 { 1038 TRACE("wrap point 5 btn %d style %02x, x=%d, cx=%d\n", 1039 i, btnPtr[i].fsStyle, x, cx); 1040 btnPtr[i].fsState |= TBSTATE_WRAP; 1041 bFound = TRUE; 1042 x = infoPtr->nIndent; 1043 if (btnPtr[i].fsStyle & TBSTYLE_SEP ) 1044 bButtonWrap = FALSE; 1045 else 1046 bButtonWrap = TRUE; 1047 } 1048 } 1049 else { 1050 TRACE("wrap point 6 btn %d style %02x, x=%d, cx=%d\n", 1051 i, btnPtr[i].fsStyle, x, cx); 1052 x += cx; 1053 } 726 1054 } 727 1055 } … … 729 1057 730 1058 /*********************************************************************** 731 * 1059 * TOOLBAR_CalcToolbar 732 1060 * 733 * This function calculates button and separator placement. It first 734 * calculates the button sizes, gets the toolbar window width and then 735 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap 1061 * This function calculates button and separator placement. It first 1062 * calculates the button sizes, gets the toolbar window width and then 1063 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap 736 1064 * on. It assigns a new location to each item and sends this location to 737 * the tooltip window if appropriate. Finally, it updates the rcBound 738 * rect and calculates the new required toolbar window height. 739 */ 1065 * the tooltip window if appropriate. Finally, it updates the rcBound 1066 * rect and calculates the new required toolbar window height. 1067 */ 740 1068 741 1069 static void … … 756 1084 if (dwStyle & TBSTYLE_LIST) 757 1085 { 758 infoPtr->nButtonHeight = max(infoPtr->nBitmapHeight, sizeString.cy) + 6; 759 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + sizeString.cx + 6; 1086 for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++) 1087 { 1088 if (infoPtr->buttons[i].iBitmap >= 0) 1089 usesBitmaps = TRUE; 1090 } 1091 infoPtr->nButtonHeight = max((usesBitmaps) ? infoPtr->nBitmapHeight : 1092 0, sizeString.cy) + 6; 1093 infoPtr->nButtonWidth = ((usesBitmaps) ? infoPtr->nBitmapWidth : 1094 0) + sizeString.cx + 6; 1095 TRACE("LIST style, But w=%d h=%d, useBitmaps=%d, Bit w=%d h=%d\n", 1096 infoPtr->nButtonWidth, infoPtr->nButtonHeight, usesBitmaps, 1097 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight); 1098 TOOLBAR_DumpToolbar (infoPtr, __LINE__); 760 1099 } 761 1100 else { 762 1101 for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++) 763 1102 { 764 765 1103 if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap)) 1104 usesBitmaps = TRUE; 766 1105 } 767 1106 … … 769 1108 { 770 1109 if (usesBitmaps) 771 infoPtr->nButtonHeight = sizeString.cy + 1110 infoPtr->nButtonHeight = sizeString.cy + 1111 2 + /* this is the space to separate text from bitmap */ 772 1112 infoPtr->nBitmapHeight + 6; 773 else 1113 else 774 1114 infoPtr->nButtonHeight = sizeString.cy + 6; 775 1115 } 776 1116 else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6) 777 1117 infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6; 778 1118 779 1119 if (sizeString.cx > infoPtr->nBitmapWidth) 780 1120 infoPtr->nButtonWidth = sizeString.cx + 6; 781 1121 else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6) 782 1122 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6; 783 1123 } 784 1124 785 1125 if ( infoPtr->cxMin >= 0 && infoPtr->nButtonWidth < infoPtr->cxMin ) 786 1126 infoPtr->nButtonWidth = infoPtr->cxMin; 787 if ( infoPtr->cxMax > =0 && infoPtr->nButtonWidth > infoPtr->cxMax )1127 if ( infoPtr->cxMax > 0 && infoPtr->nButtonWidth > infoPtr->cxMax ) 788 1128 infoPtr->nButtonWidth = infoPtr->cxMax; 789 1129 … … 791 1131 792 1132 x = infoPtr->nIndent; 793 y = (dwStyle & TBSTYLE_FLAT) ? 0 : TOP_BORDER;1133 y = 0; 794 1134 795 1135 /* 796 * We will set the height below, and we set the width on entry 797 * so we do not reset them here.. 1136 * We will set the height below, and we set the width on entry 1137 * so we do not reset them here.. 798 1138 */ 799 1139 #if 0 … … 828 1168 /* cy = rc.bottom - rc.top; */ 829 1169 1170 TRACE("cy=%d\n", cy); 1171 830 1172 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ ) 831 1173 { 832 bWrap = FALSE; 833 if (btnPtr->fsState & TBSTATE_HIDDEN) 834 { 835 SetRectEmpty (&btnPtr->rect); 836 continue; 837 } 838 839 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */ 840 /* it is the actual width of the separator. This is used for */ 841 /* custom controls in toolbars. */ 842 if (btnPtr->fsStyle & TBSTYLE_SEP) 843 cx = (btnPtr->iBitmap > 0) ? 844 btnPtr->iBitmap : SEPARATOR_WIDTH; 845 else 846 { 847 if (btnPtr->fsStyle & TBSTYLE_AUTOSIZE) 1174 bWrap = FALSE; 1175 if (btnPtr->fsState & TBSTATE_HIDDEN) 1176 { 1177 SetRectEmpty (&btnPtr->rect); 1178 continue; 1179 } 1180 1181 cy = infoPtr->nHeight; 1182 1183 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */ 1184 /* it is the actual width of the separator. This is used for */ 1185 /* custom controls in toolbars. */ 1186 if (btnPtr->fsStyle & TBSTYLE_SEP) { 1187 if (btnPtr->fsStyle & TBSTYLE_DROPDOWN) { 1188 cy = (btnPtr->iBitmap > 0) ? 1189 btnPtr->iBitmap : SEPARATOR_WIDTH; 1190 cx = infoPtr->nButtonWidth; 1191 } 1192 else 1193 cx = (btnPtr->iBitmap > 0) ? 1194 btnPtr->iBitmap : SEPARATOR_WIDTH; 1195 } 1196 else 1197 { 1198 if (btnPtr->fsStyle & TBSTYLE_AUTOSIZE) 848 1199 { 849 1200 SIZE sz; 850 TOOLBAR_MeasureString(hwnd,i,&sz); 851 cx = sz.cx + 6; 1201 HDC hdc; 1202 HFONT hOldFont; 1203 1204 hdc = GetDC (hwnd); 1205 hOldFont = SelectObject (hdc, infoPtr->hFont); 1206 1207 TOOLBAR_MeasureString(infoPtr, btnPtr, hdc, &sz); 1208 1209 SelectObject (hdc, hOldFont); 1210 ReleaseDC (hwnd, hdc); 1211 1212 /* Fudge amount measured against IE4 "menu" and "Links" */ 1213 /* toolbars with native control (v4.71). - GA 8/01 */ 1214 cx = sz.cx + 6 + 5 + 5; 1215 if ((dwStyle & TBSTYLE_LIST) && 1216 (TOOLBAR_TestImageExist (infoPtr, btnPtr, infoPtr->himlDef))) 1217 cx += infoPtr->nBitmapWidth; 852 1218 } 853 1219 else 854 cx = infoPtr->nButtonWidth; 855 856 if (hasDropDownArrows && (btnPtr->fsStyle & TBSTYLE_DROPDOWN)) 857 cx += DDARROW_WIDTH; 858 } 859 cy = infoPtr->nHeight; 860 861 if (btnPtr->fsState & TBSTATE_WRAP ) 862 bWrap = TRUE; 863 864 SetRect (&btnPtr->rect, x, y, x + cx, y + cy); 865 866 if (infoPtr->rcBound.left > x) 867 infoPtr->rcBound.left = x; 868 if (infoPtr->rcBound.right < x + cx) 869 infoPtr->rcBound.right = x + cx; 870 if (infoPtr->rcBound.bottom < y + cy) 871 infoPtr->rcBound.bottom = y + cy; 872 873 /* Set the toolTip only for non-hidden, non-separator button */ 874 if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP )) 875 { 876 TTTOOLINFOA ti; 877 878 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 879 ti.cbSize = sizeof(TTTOOLINFOA); 880 ti.hwnd = hwnd; 881 ti.uId = btnPtr->idCommand; 882 ti.rect = btnPtr->rect; 883 SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA, 884 0, (LPARAM)&ti); 885 } 886 887 /* btnPtr->nRow is zero based. The space between the rows is */ 888 /* also considered as a row. */ 889 btnPtr->nRow = nRows + nSepRows; 890 if( bWrap ) 891 { 892 if ( !(btnPtr->fsStyle & TBSTYLE_SEP) ) 893 y += cy; 894 else 895 { 896 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */ 897 /* it is the actual width of the separator. This is used for */ 898 /* custom controls in toolbars. */ 899 y += cy + ( (btnPtr->iBitmap > 0 ) ? 900 btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3; 901 902 /* nSepRows is used to calculate the extra height follwoing */ 903 /* the last row. */ 904 nSepRows++; 905 } 906 x = infoPtr->nIndent; 907 nRows++; 908 } 909 else 910 x += cx; 1220 cx = infoPtr->nButtonWidth; 1221 1222 if (hasDropDownArrows && (btnPtr->fsStyle & TBSTYLE_DROPDOWN)) 1223 cx += DDARROW_WIDTH; 1224 } 1225 if (btnPtr->fsState & TBSTATE_WRAP ) 1226 bWrap = TRUE; 1227 1228 SetRect (&btnPtr->rect, x, y, x + cx, y + cy); 1229 1230 if (infoPtr->rcBound.left > x) 1231 infoPtr->rcBound.left = x; 1232 if (infoPtr->rcBound.right < x + cx) 1233 infoPtr->rcBound.right = x + cx; 1234 if (infoPtr->rcBound.bottom < y + cy) 1235 infoPtr->rcBound.bottom = y + cy; 1236 1237 /* Set the toolTip only for non-hidden, non-separator button */ 1238 if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP )) 1239 { 1240 TTTOOLINFOA ti; 1241 1242 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 1243 ti.cbSize = sizeof(TTTOOLINFOA); 1244 ti.hwnd = hwnd; 1245 ti.uId = btnPtr->idCommand; 1246 ti.rect = btnPtr->rect; 1247 SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA, 1248 0, (LPARAM)&ti); 1249 } 1250 1251 /* btnPtr->nRow is zero based. The space between the rows is */ 1252 /* also considered as a row. */ 1253 btnPtr->nRow = nRows + nSepRows; 1254 1255 TRACE("button %d style=%x, bWrap=%d, nRows=%d, nSepRows=%d, btnrow=%d\n", 1256 i, btnPtr->fsStyle, bWrap, nRows, nSepRows, btnPtr->nRow); 1257 1258 if( bWrap ) 1259 { 1260 if ( !(btnPtr->fsStyle & TBSTYLE_SEP) ) 1261 y += cy; 1262 else 1263 { 1264 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */ 1265 /* it is the actual width of the separator. This is used for */ 1266 /* custom controls in toolbars. */ 1267 if ( !(btnPtr->fsStyle & TBSTYLE_DROPDOWN)) 1268 y += cy + ( (btnPtr->iBitmap > 0 ) ? 1269 btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3; 1270 else 1271 y += cy; 1272 1273 /* nSepRows is used to calculate the extra height follwoing */ 1274 /* the last row. */ 1275 nSepRows++; 1276 } 1277 x = infoPtr->nIndent; 1278 nRows++; 1279 } 1280 else 1281 x += cx; 911 1282 } 912 1283 … … 914 1285 infoPtr->nRows = nRows + nSepRows + 1; 915 1286 916 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following 917 /* the last row. 918 infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight + 919 920 nSepRows * (infoPtr->nBitmapHeight + 1) + 921 BOTTOM_BORDER; 1287 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */ 1288 /* the last row. */ 1289 infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight + 1290 nSepRows * (SEPARATOR_WIDTH * 2 / 3) + 1291 nSepRows * (infoPtr->nBitmapHeight + 1) + 1292 BOTTOM_BORDER; 922 1293 TRACE("toolbar height %d, button width %d\n", infoPtr->nHeight, infoPtr->nButtonWidth); 923 1294 } … … 930 1301 TBUTTON_INFO *btnPtr; 931 1302 INT i; 932 1303 933 1304 btnPtr = infoPtr->buttons; 934 1305 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) { 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 1306 if (btnPtr->fsState & TBSTATE_HIDDEN) 1307 continue; 1308 1309 if (btnPtr->fsStyle & TBSTYLE_SEP) { 1310 if (PtInRect (&btnPtr->rect, *lpPt)) { 1311 TRACE(" ON SEPARATOR %d!\n", i); 1312 return -i; 1313 } 1314 } 1315 else { 1316 if (PtInRect (&btnPtr->rect, *lpPt)) { 1317 TRACE(" ON BUTTON %d!\n", i); 1318 return i; 1319 } 1320 } 950 1321 } 951 1322 … … 963 1334 btnPtr = infoPtr->buttons; 964 1335 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) { 965 966 967 968 1336 if (btnPtr->idCommand == idCommand) { 1337 TRACE("command=%d index=%d\n", idCommand, i); 1338 return i; 1339 } 969 1340 } 970 1341 TRACE("no index found for command=%d\n", idCommand); … … 980 1351 981 1352 if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons)) 982 1353 return -1; 983 1354 984 1355 /* check index button */ 985 1356 btnPtr = &infoPtr->buttons[nIndex]; 986 1357 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) { 987 988 1358 if (btnPtr->fsState & TBSTATE_CHECKED) 1359 return nIndex; 989 1360 } 990 1361 … … 992 1363 nRunIndex = nIndex - 1; 993 1364 while (nRunIndex >= 0) { 994 995 996 997 998 999 1000 1001 1365 btnPtr = &infoPtr->buttons[nRunIndex]; 1366 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) { 1367 if (btnPtr->fsState & TBSTATE_CHECKED) 1368 return nRunIndex; 1369 } 1370 else 1371 break; 1372 nRunIndex--; 1002 1373 } 1003 1374 … … 1005 1376 nRunIndex = nIndex + 1; 1006 1377 while (nRunIndex < infoPtr->nNumButtons) { 1007 btnPtr = &infoPtr->buttons[nRunIndex]; 1008 1009 1010 1011 1012 1013 1014 1378 btnPtr = &infoPtr->buttons[nRunIndex]; 1379 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) { 1380 if (btnPtr->fsState & TBSTATE_CHECKED) 1381 return nRunIndex; 1382 } 1383 else 1384 break; 1385 nRunIndex++; 1015 1386 } 1016 1387 … … 1021 1392 static VOID 1022 1393 TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg, 1023 1394 WPARAM wParam, LPARAM lParam) 1024 1395 { 1025 1396 MSG msg; … … 1047 1418 PCUSTOMBUTTON btnInfo; 1048 1419 NMTOOLBARA nmtb; 1420 TOOLBAR_INFO *infoPtr = custInfo->tbInfo; 1049 1421 1050 1422 switch (uMsg) 1051 1423 { 1052 case WM_INITDIALOG: 1053 custInfo = (PCUSTDLG_INFO)lParam; 1054 SetWindowLongA (hwnd, DWL_USER, (DWORD)custInfo); 1055 1056 if (custInfo) 1057 { 1058 char Buffer[256]; 1059 int i = 0; 1060 int index; 1061 1062 /* send TBN_QUERYINSERT notification */ 1063 nmtb.hdr.hwndFrom = hwnd; 1064 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1065 nmtb.hdr.code = TBN_QUERYINSERT; 1066 nmtb.iItem = custInfo->tbInfo->nNumButtons; 1067 1068 if (!SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1069 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb)) 1070 return FALSE; 1071 1072 /* add items to 'toolbar buttons' list and check if removable */ 1073 for (i = 0; i < custInfo->tbInfo->nNumButtons; i++) 1074 { 1075 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON)); 1076 memset (&btnInfo->btn, 0, sizeof(TBBUTTON)); 1077 btnInfo->btn.fsStyle = TBSTYLE_SEP; 1078 btnInfo->bVirtual = FALSE; 1079 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64); 1080 1081 /* send TBN_QUERYDELETE notification */ 1082 nmtb.hdr.hwndFrom = hwnd; 1083 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1084 nmtb.hdr.code = TBN_QUERYDELETE; 1085 nmtb.iItem = i; 1086 1087 btnInfo->bRemovable = SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1088 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb); 1089 1090 index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, 0); 1091 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1092 } 1093 1094 /* insert separator button into 'available buttons' list */ 1095 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON)); 1096 memset (&btnInfo->btn, 0, sizeof(TBBUTTON)); 1097 btnInfo->btn.fsStyle = TBSTYLE_SEP; 1098 btnInfo->bVirtual = FALSE; 1099 btnInfo->bRemovable = TRUE; 1100 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64); 1101 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo); 1102 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1103 1104 /* insert all buttons into dsa */ 1105 for (i = 0;; i++) 1106 { 1107 /* send TBN_GETBUTTONINFO notification */ 1108 nmtb.hdr.hwndFrom = hwnd; 1109 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1110 nmtb.hdr.code = TBN_GETBUTTONINFOA; 1111 nmtb.iItem = i; 1112 nmtb.pszText = Buffer; 1113 nmtb.cchText = 256; 1114 1115 if (!SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1116 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb)) 1117 break; 1118 1119 TRACE("style: %x\n", nmtb.tbButton.fsStyle); 1120 1121 /* insert button into the apropriate list */ 1122 index = TOOLBAR_GetButtonIndex (custInfo->tbInfo, nmtb.tbButton.idCommand); 1123 if (index == -1) 1124 { 1125 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON)); 1126 memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON)); 1127 btnInfo->bVirtual = FALSE; 1128 btnInfo->bRemovable = TRUE; 1129 if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP)) 1130 strcpy (btnInfo->text, nmtb.pszText); 1131 1132 index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0); 1133 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1424 case WM_INITDIALOG: 1425 custInfo = (PCUSTDLG_INFO)lParam; 1426 SetWindowLongA (hwnd, DWL_USER, (DWORD)custInfo); 1427 1428 if (custInfo) 1429 { 1430 char Buffer[256]; 1431 int i = 0; 1432 int index; 1433 1434 /* send TBN_QUERYINSERT notification */ 1435 nmtb.iItem = custInfo->tbInfo->nNumButtons; 1436 1437 if (!TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_QUERYINSERT)) 1438 return FALSE; 1439 1440 /* add items to 'toolbar buttons' list and check if removable */ 1441 for (i = 0; i < custInfo->tbInfo->nNumButtons; i++) 1442 { 1443 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON)); 1444 memset (&btnInfo->btn, 0, sizeof(TBBUTTON)); 1445 btnInfo->btn.fsStyle = TBSTYLE_SEP; 1446 btnInfo->bVirtual = FALSE; 1447 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64); 1448 1449 /* send TBN_QUERYDELETE notification */ 1450 nmtb.iItem = i; 1451 btnInfo->bRemovable = TOOLBAR_SendNotify ((NMHDR *) &nmtb, 1452 infoPtr, 1453 TBN_QUERYDELETE); 1454 1455 index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, 0); 1456 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1457 } 1458 1459 /* insert separator button into 'available buttons' list */ 1460 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON)); 1461 memset (&btnInfo->btn, 0, sizeof(TBBUTTON)); 1462 btnInfo->btn.fsStyle = TBSTYLE_SEP; 1463 btnInfo->bVirtual = FALSE; 1464 btnInfo->bRemovable = TRUE; 1465 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64); 1466 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo); 1467 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1468 1469 /* insert all buttons into dsa */ 1470 for (i = 0;; i++) 1471 { 1472 /* send TBN_GETBUTTONINFO notification */ 1473 nmtb.iItem = i; 1474 nmtb.pszText = Buffer; 1475 nmtb.cchText = 256; 1476 1477 if (!TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_GETBUTTONINFOA)) 1478 break; 1479 1480 TRACE("style: %x\n", nmtb.tbButton.fsStyle); 1481 1482 /* insert button into the apropriate list */ 1483 index = TOOLBAR_GetButtonIndex (custInfo->tbInfo, nmtb.tbButton.idCommand); 1484 if (index == -1) 1485 { 1486 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON)); 1487 memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON)); 1488 btnInfo->bVirtual = FALSE; 1489 btnInfo->bRemovable = TRUE; 1490 if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP)) 1491 strcpy (btnInfo->text, nmtb.pszText); 1492 1493 index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0); 1494 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1495 } 1496 else 1497 { 1498 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0); 1499 memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON)); 1500 if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP)) 1501 strcpy (btnInfo->text, nmtb.pszText); 1502 1503 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1504 } 1505 } 1506 1507 /* select first item in the 'available' list */ 1508 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, 0, 0); 1509 1510 /* append 'virtual' separator button to the 'toolbar buttons' list */ 1511 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON)); 1512 memset (&btnInfo->btn, 0, sizeof(TBBUTTON)); 1513 btnInfo->btn.fsStyle = TBSTYLE_SEP; 1514 btnInfo->bVirtual = TRUE; 1515 btnInfo->bRemovable = FALSE; 1516 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64); 1517 index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo); 1518 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1519 1520 /* select last item in the 'toolbar' list */ 1521 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index, 0); 1522 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETTOPINDEX, index, 0); 1523 1524 /* set focus and disable buttons */ 1525 PostMessageA (hwnd, WM_USER, 0, 0); 1526 } 1527 return TRUE; 1528 1529 case WM_USER: 1530 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE); 1531 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE); 1532 EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), FALSE); 1533 SetFocus (GetDlgItem (hwnd, IDC_TOOLBARBTN_LBOX)); 1534 return TRUE; 1535 1536 case WM_CLOSE: 1537 EndDialog(hwnd, FALSE); 1538 return TRUE; 1539 1540 case WM_COMMAND: 1541 switch (LOWORD(wParam)) 1542 { 1543 case IDC_TOOLBARBTN_LBOX: 1544 if (HIWORD(wParam) == LBN_SELCHANGE) 1545 { 1546 PCUSTOMBUTTON btnInfo; 1547 NMTOOLBARA nmtb; 1548 int count; 1549 int index; 1550 1551 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0); 1552 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0); 1553 1554 /* send TBN_QUERYINSERT notification */ 1555 nmtb.iItem = index; 1556 TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, 1557 TBN_QUERYINSERT); 1558 1559 /* get list box item */ 1560 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0); 1561 1562 if (index == (count - 1)) 1563 { 1564 /* last item (virtual separator) */ 1565 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE); 1566 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE); 1567 } 1568 else if (index == (count - 2)) 1569 { 1570 /* second last item (last non-virtual item) */ 1571 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE); 1572 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE); 1573 } 1574 else if (index == 0) 1575 { 1576 /* first item */ 1577 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE); 1578 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE); 1579 } 1580 else 1581 { 1582 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE); 1583 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE); 1584 } 1585 1586 EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), btnInfo->bRemovable); 1587 } 1588 break; 1589 1590 case IDC_MOVEUP_BTN: 1591 { 1592 PCUSTOMBUTTON btnInfo; 1593 int index; 1594 int count; 1595 1596 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0); 1597 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0); 1598 TRACE("Move up: index %d\n", index); 1599 1600 /* send TBN_QUERYINSERT notification */ 1601 nmtb.iItem = index; 1602 1603 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, 1604 TBN_QUERYINSERT)) 1605 { 1606 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0); 1607 1608 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0); 1609 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index-1, 0); 1610 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index-1, (LPARAM)btnInfo); 1611 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index-1 , 0); 1612 1613 if (index <= 1) 1614 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE); 1615 else if (index >= (count - 3)) 1616 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE); 1617 1618 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0); 1619 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index-1, (LPARAM)&(btnInfo->btn)); 1620 } 1621 } 1622 break; 1623 1624 case IDC_MOVEDN_BTN: /* move down */ 1625 { 1626 PCUSTOMBUTTON btnInfo; 1627 int index; 1628 int count; 1629 1630 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0); 1631 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0); 1632 TRACE("Move up: index %d\n", index); 1633 1634 /* send TBN_QUERYINSERT notification */ 1635 nmtb.iItem = index; 1636 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, 1637 TBN_QUERYINSERT)) 1638 { 1639 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0); 1640 1641 /* move button down */ 1642 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0); 1643 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index+1, 0); 1644 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index+1, (LPARAM)btnInfo); 1645 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index+1 , 0); 1646 1647 if (index == 0) 1648 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE); 1649 else if (index >= (count - 3)) 1650 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE); 1651 1652 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0); 1653 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index+1, (LPARAM)&(btnInfo->btn)); 1654 } 1655 } 1656 break; 1657 1658 case IDC_REMOVE_BTN: /* remove button */ 1659 { 1660 PCUSTOMBUTTON btnInfo; 1661 int index; 1662 1663 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0); 1664 TRACE("Remove: index %d\n", index); 1665 1666 /* send TBN_QUERYDELETE notification */ 1667 nmtb.iItem = index; 1668 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, 1669 TBN_QUERYDELETE)) 1670 { 1671 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0); 1672 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0); 1673 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index , 0); 1674 1675 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0); 1676 1677 /* insert into 'available button' list */ 1678 if (!(btnInfo->btn.fsStyle & TBSTYLE_SEP)) 1679 { 1680 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0); 1681 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1682 } 1683 else 1684 COMCTL32_Free (btnInfo); 1685 } 1686 } 1687 break; 1688 1689 case IDOK: /* Add button */ 1690 { 1691 int index; 1692 int count; 1693 1694 count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0); 1695 index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCURSEL, 0, 0); 1696 TRACE("Add: index %d\n", index); 1697 1698 /* send TBN_QUERYINSERT notification */ 1699 nmtb.iItem = index; 1700 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, 1701 TBN_QUERYINSERT)) 1702 { 1703 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, index, 0); 1704 1705 if (index != 0) 1706 { 1707 /* remove from 'available buttons' list */ 1708 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_DELETESTRING, index, 0); 1709 if (index == count-1) 1710 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index-1 , 0); 1711 else 1712 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index , 0); 1713 } 1714 else 1715 { 1716 PCUSTOMBUTTON btnNew; 1717 1718 /* duplicate 'separator' button */ 1719 btnNew = (PCUSTOMBUTTON)COMCTL32_Alloc (sizeof(CUSTOMBUTTON)); 1720 memcpy (btnNew, btnInfo, sizeof(CUSTOMBUTTON)); 1721 btnInfo = btnNew; 1722 } 1723 1724 /* insert into 'toolbar button' list */ 1725 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0); 1726 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index, 0); 1727 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1728 1729 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index, (LPARAM)&(btnInfo->btn)); 1730 } 1731 } 1732 break; 1733 1734 case IDCANCEL: 1735 EndDialog(hwnd, FALSE); 1736 break; 1737 } 1738 return TRUE; 1739 1740 case WM_DESTROY: 1741 { 1742 int count; 1743 int i; 1744 1745 /* delete items from 'toolbar buttons' listbox*/ 1746 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0); 1747 for (i = 0; i < count; i++) 1748 { 1749 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, i, 0); 1750 COMCTL32_Free(btnInfo); 1751 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, 0, 0); 1752 } 1753 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_RESETCONTENT, 0, 0); 1754 1755 1756 /* delete items from 'available buttons' listbox*/ 1757 count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0); 1758 for (i = 0; i < count; i++) 1759 { 1760 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, i, 0); 1761 COMCTL32_Free(btnInfo); 1762 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, i, 0); 1763 } 1764 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_RESETCONTENT, 0, 0); 1134 1765 } 1135 else 1136 { 1137 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0); 1138 memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON)); 1139 if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP)) 1140 strcpy (btnInfo->text, nmtb.pszText); 1141 1142 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1143 } 1144 } 1145 1146 /* select first item in the 'available' list */ 1147 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, 0, 0); 1148 1149 /* append 'virtual' separator button to the 'toolbar buttons' list */ 1150 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON)); 1151 memset (&btnInfo->btn, 0, sizeof(TBBUTTON)); 1152 btnInfo->btn.fsStyle = TBSTYLE_SEP; 1153 btnInfo->bVirtual = TRUE; 1154 btnInfo->bRemovable = FALSE; 1155 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64); 1156 index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo); 1157 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1158 1159 /* select last item in the 'toolbar' list */ 1160 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index, 0); 1161 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETTOPINDEX, index, 0); 1162 1163 /* set focus and disable buttons */ 1164 PostMessageA (hwnd, WM_USER, 0, 0); 1165 } 1166 return TRUE; 1167 1168 case WM_USER: 1169 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE); 1170 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE); 1171 EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), FALSE); 1172 SetFocus (GetDlgItem (hwnd, IDC_TOOLBARBTN_LBOX)); 1173 return TRUE; 1174 1175 case WM_CLOSE: 1176 EndDialog(hwnd, FALSE); 1177 return TRUE; 1178 1179 case WM_COMMAND: 1180 switch (LOWORD(wParam)) 1181 { 1182 case IDC_TOOLBARBTN_LBOX: 1183 if (HIWORD(wParam) == LBN_SELCHANGE) 1184 { 1185 PCUSTOMBUTTON btnInfo; 1186 NMTOOLBARA nmtb; 1187 int count; 1188 int index; 1189 1190 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0); 1191 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0); 1192 1193 /* send TBN_QUERYINSERT notification */ 1194 nmtb.hdr.hwndFrom = hwnd; 1195 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1196 nmtb.hdr.code = TBN_QUERYINSERT; 1197 nmtb.iItem = index; 1198 1199 SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1200 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb); 1201 1202 /* get list box item */ 1203 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0); 1204 1205 if (index == (count - 1)) 1206 { 1207 /* last item (virtual separator) */ 1208 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE); 1209 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE); 1210 } 1211 else if (index == (count - 2)) 1212 { 1213 /* second last item (last non-virtual item) */ 1214 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE); 1215 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE); 1216 } 1217 else if (index == 0) 1218 { 1219 /* first item */ 1220 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE); 1221 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE); 1222 } 1223 else 1224 { 1225 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE); 1226 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE); 1227 } 1228 1229 EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), btnInfo->bRemovable); 1230 } 1231 break; 1232 1233 case IDC_MOVEUP_BTN: 1234 { 1235 PCUSTOMBUTTON btnInfo; 1236 int index; 1237 int count; 1238 1239 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0); 1240 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0); 1241 TRACE("Move up: index %d\n", index); 1242 1243 /* send TBN_QUERYINSERT notification */ 1244 nmtb.hdr.hwndFrom = hwnd; 1245 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1246 nmtb.hdr.code = TBN_QUERYINSERT; 1247 nmtb.iItem = index; 1248 1249 if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1250 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb)) 1251 { 1252 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0); 1253 1254 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0); 1255 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index-1, 0); 1256 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index-1, (LPARAM)btnInfo); 1257 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index-1 , 0); 1258 1259 if (index <= 1) 1260 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE); 1261 else if (index >= (count - 3)) 1262 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE); 1263 1264 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0); 1265 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index-1, (LPARAM)&(btnInfo->btn)); 1266 } 1267 } 1268 break; 1269 1270 case IDC_MOVEDN_BTN: /* move down */ 1271 { 1272 PCUSTOMBUTTON btnInfo; 1273 int index; 1274 int count; 1275 1276 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0); 1277 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0); 1278 TRACE("Move up: index %d\n", index); 1279 1280 /* send TBN_QUERYINSERT notification */ 1281 nmtb.hdr.hwndFrom = hwnd; 1282 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1283 nmtb.hdr.code = TBN_QUERYINSERT; 1284 nmtb.iItem = index; 1285 1286 if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1287 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb)) 1288 { 1289 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0); 1290 1291 /* move button down */ 1292 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0); 1293 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index+1, 0); 1294 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index+1, (LPARAM)btnInfo); 1295 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index+1 , 0); 1296 1297 if (index == 0) 1298 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE); 1299 else if (index >= (count - 3)) 1300 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE); 1301 1302 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0); 1303 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index+1, (LPARAM)&(btnInfo->btn)); 1304 } 1305 } 1306 break; 1307 1308 case IDC_REMOVE_BTN: /* remove button */ 1309 { 1310 PCUSTOMBUTTON btnInfo; 1311 int index; 1312 1313 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0); 1314 TRACE("Remove: index %d\n", index); 1315 1316 /* send TBN_QUERYDELETE notification */ 1317 nmtb.hdr.hwndFrom = hwnd; 1318 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1319 nmtb.hdr.code = TBN_QUERYDELETE; 1320 nmtb.iItem = index; 1321 1322 if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1323 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb)) 1324 { 1325 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0); 1326 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0); 1327 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index , 0); 1328 1329 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0); 1330 1331 /* insert into 'available button' list */ 1332 if (!(btnInfo->btn.fsStyle & TBSTYLE_SEP)) 1333 { 1334 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0); 1335 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1336 } 1337 else 1338 COMCTL32_Free (btnInfo); 1339 } 1340 } 1341 break; 1342 1343 case IDOK: /* Add button */ 1344 { 1345 int index; 1346 int count; 1347 1348 count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0); 1349 index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCURSEL, 0, 0); 1350 TRACE("Add: index %d\n", index); 1351 1352 /* send TBN_QUERYINSERT notification */ 1353 nmtb.hdr.hwndFrom = hwnd; 1354 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 1355 nmtb.hdr.code = TBN_QUERYINSERT; 1356 nmtb.iItem = index; 1357 1358 if (SendMessageA (custInfo->tbInfo->hwndNotify, WM_NOTIFY, 1359 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb)) 1360 { 1361 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, index, 0); 1362 1363 if (index != 0) 1364 { 1365 /* remove from 'available buttons' list */ 1366 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_DELETESTRING, index, 0); 1367 if (index == count-1) 1368 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index-1 , 0); 1369 else 1370 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index , 0); 1371 } 1372 else 1373 { 1374 PCUSTOMBUTTON btnNew; 1375 1376 /* duplicate 'separator' button */ 1377 btnNew = (PCUSTOMBUTTON)COMCTL32_Alloc (sizeof(CUSTOMBUTTON)); 1378 memcpy (btnNew, btnInfo, sizeof(CUSTOMBUTTON)); 1379 btnInfo = btnNew; 1380 } 1381 1382 /* insert into 'toolbar button' list */ 1383 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0); 1384 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index, 0); 1385 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo); 1386 1387 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index, (LPARAM)&(btnInfo->btn)); 1388 } 1389 } 1390 break; 1391 1392 case IDCANCEL: 1393 EndDialog(hwnd, FALSE); 1394 break; 1395 } 1396 return TRUE; 1397 1398 case WM_DESTROY: 1399 { 1400 int count; 1401 int i; 1402 1403 /* delete items from 'toolbar buttons' listbox*/ 1404 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0); 1405 for (i = 0; i < count; i++) 1406 { 1407 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, i, 0); 1408 COMCTL32_Free(btnInfo); 1409 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, 0, 0); 1410 } 1411 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_RESETCONTENT, 0, 0); 1412 1413 1414 /* delete items from 'available buttons' listbox*/ 1415 count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0); 1416 for (i = 0; i < count; i++) 1417 { 1418 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, i, 0); 1419 COMCTL32_Free(btnInfo); 1420 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, i, 0); 1421 } 1422 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_RESETCONTENT, 0, 0); 1423 } 1424 return TRUE; 1425 1426 case WM_DRAWITEM: 1427 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX) 1428 { 1429 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam; 1430 RECT rcButton; 1431 RECT rcText; 1432 HPEN hOldPen; 1433 HBRUSH hOldBrush; 1434 COLORREF oldText = 0; 1435 COLORREF oldBk = 0; 1436 1437 /* get item data */ 1438 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, wParam, LB_GETITEMDATA, (WPARAM)lpdis->itemID, 0); 1439 if (btnInfo == NULL) 1440 { 1441 FIXME("btnInfo invalid!\n"); 1442 return TRUE; 1443 } 1444 1445 /* set colors and select objects */ 1446 oldBk = SetBkColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 1447 if (btnInfo->bVirtual) 1448 oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_GRAYTEXT)); 1449 else 1450 oldText = SetTextColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHTTEXT:COLOR_WINDOWTEXT)); 1451 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 1452 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 1453 1454 /* fill background rectangle */ 1455 Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, 1456 lpdis->rcItem.right, lpdis->rcItem.bottom); 1457 1458 /* calculate button and text rectangles */ 1459 CopyRect (&rcButton, &lpdis->rcItem); 1460 InflateRect (&rcButton, -1, -1); 1461 CopyRect (&rcText, &rcButton); 1462 rcButton.right = rcButton.left + custInfo->tbInfo->nBitmapWidth + 6; 1463 rcText.left = rcButton.right + 2; 1464 1465 /* draw focus rectangle */ 1466 if (lpdis->itemState & ODS_FOCUS) 1467 DrawFocusRect (lpdis->hDC, &lpdis->rcItem); 1468 1469 /* draw button */ 1470 DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT); 1471 1472 /* draw image and text */ 1473 if ((btnInfo->btn.fsStyle & TBSTYLE_SEP) == 0) 1474 ImageList_Draw (custInfo->tbInfo->himlDef, btnInfo->btn.iBitmap, lpdis->hDC, 1475 rcButton.left+3, rcButton.top+3, ILD_NORMAL); 1476 DrawTextA (lpdis->hDC, btnInfo->text, -1, &rcText, 1477 DT_LEFT | DT_VCENTER | DT_SINGLELINE); 1478 1479 /* delete objects and reset colors */ 1480 SelectObject (lpdis->hDC, hOldBrush); 1481 SelectObject (lpdis->hDC, hOldPen); 1482 SetBkColor (lpdis->hDC, oldBk); 1483 SetTextColor (lpdis->hDC, oldText); 1484 1485 return TRUE; 1486 } 1487 return FALSE; 1488 1489 case WM_MEASUREITEM: 1490 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX) 1491 { 1492 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam; 1493 1494 if (custInfo && custInfo->tbInfo) 1495 lpmis->itemHeight = custInfo->tbInfo->nBitmapHeight + 8; 1496 else 1497 lpmis->itemHeight = 15 + 8; /* default height */ 1498 1499 return TRUE; 1500 } 1501 return FALSE; 1502 1503 default: 1504 return FALSE; 1766 return TRUE; 1767 1768 case WM_DRAWITEM: 1769 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX) 1770 { 1771 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam; 1772 RECT rcButton; 1773 RECT rcText; 1774 HPEN hOldPen; 1775 HBRUSH hOldBrush; 1776 COLORREF oldText = 0; 1777 COLORREF oldBk = 0; 1778 1779 /* get item data */ 1780 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, wParam, LB_GETITEMDATA, (WPARAM)lpdis->itemID, 0); 1781 if (btnInfo == NULL) 1782 { 1783 FIXME("btnInfo invalid!\n"); 1784 return TRUE; 1785 } 1786 1787 /* set colors and select objects */ 1788 oldBk = SetBkColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 1789 if (btnInfo->bVirtual) 1790 oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_GRAYTEXT)); 1791 else 1792 oldText = SetTextColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHTTEXT:COLOR_WINDOWTEXT)); 1793 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 1794 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW)); 1795 1796 /* fill background rectangle */ 1797 Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, 1798 lpdis->rcItem.right, lpdis->rcItem.bottom); 1799 1800 /* calculate button and text rectangles */ 1801 CopyRect (&rcButton, &lpdis->rcItem); 1802 InflateRect (&rcButton, -1, -1); 1803 CopyRect (&rcText, &rcButton); 1804 rcButton.right = rcButton.left + custInfo->tbInfo->nBitmapWidth + 6; 1805 rcText.left = rcButton.right + 2; 1806 1807 /* draw focus rectangle */ 1808 if (lpdis->itemState & ODS_FOCUS) 1809 DrawFocusRect (lpdis->hDC, &lpdis->rcItem); 1810 1811 /* draw button */ 1812 DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT); 1813 1814 /* draw image and text */ 1815 if ((btnInfo->btn.fsStyle & TBSTYLE_SEP) == 0) 1816 ImageList_Draw (custInfo->tbInfo->himlDef, btnInfo->btn.iBitmap, lpdis->hDC, 1817 rcButton.left+3, rcButton.top+3, ILD_NORMAL); 1818 DrawTextA (lpdis->hDC, btnInfo->text, -1, &rcText, 1819 DT_LEFT | DT_VCENTER | DT_SINGLELINE); 1820 1821 /* delete objects and reset colors */ 1822 SelectObject (lpdis->hDC, hOldBrush); 1823 SelectObject (lpdis->hDC, hOldPen); 1824 SetBkColor (lpdis->hDC, oldBk); 1825 SetTextColor (lpdis->hDC, oldText); 1826 1827 return TRUE; 1828 } 1829 return FALSE; 1830 1831 case WM_MEASUREITEM: 1832 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX) 1833 { 1834 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam; 1835 1836 if (custInfo && custInfo->tbInfo) 1837 lpmis->itemHeight = custInfo->tbInfo->nBitmapHeight + 8; 1838 else 1839 lpmis->itemHeight = 15 + 8; /* default height */ 1840 1841 return TRUE; 1842 } 1843 return FALSE; 1844 1845 default: 1846 return FALSE; 1505 1847 } 1506 1848 } … … 1521 1863 TRACE("hwnd=%x wParam=%x lParam=%lx\n", hwnd, wParam, lParam); 1522 1864 if (!lpAddBmp) 1523 1865 return -1; 1524 1866 1525 1867 if (lpAddBmp->hInst == HINST_COMMCTRL) 1526 1868 { 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 if (lpAddBmp->nID & 1) 1540 1541 1542 /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap 1543 * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this 1869 if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR) 1870 nButtons = 15; 1871 else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR) 1872 nButtons = 13; 1873 else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR) 1874 nButtons = 5; 1875 else 1876 return -1; 1877 1878 TRACE ("adding %d internal bitmaps!\n", nButtons); 1879 1880 /* Windows resize all the buttons to the size of a newly added standard image */ 1881 if (lpAddBmp->nID & 1) 1882 { 1883 /* large icons */ 1884 /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap 1885 * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this 1544 1886 */ 1545 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0, 1546 MAKELPARAM((WORD)24, (WORD)24)); 1547 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0, 1548 MAKELPARAM((WORD)31, (WORD)30)); 1887 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0, 1888 MAKELPARAM((WORD)24, (WORD)24)); 1889 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0, 1890 MAKELPARAM((WORD)31, (WORD)30)); 1891 } 1892 else 1893 { 1894 /* small icons */ 1895 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0, 1896 MAKELPARAM((WORD)16, (WORD)16)); 1897 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0, 1898 MAKELPARAM((WORD)22, (WORD)22)); 1899 } 1900 1901 TOOLBAR_CalcToolbar (hwnd); 1549 1902 } 1550 1903 else 1551 1904 { 1552 /* small icons */ 1553 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0, 1554 MAKELPARAM((WORD)16, (WORD)16)); 1555 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0, 1556 MAKELPARAM((WORD)22, (WORD)22)); 1557 } 1558 1559 TOOLBAR_CalcToolbar (hwnd); 1560 } 1561 else 1562 { 1563 nButtons = (INT)wParam; 1564 if (nButtons <= 0) 1565 return -1; 1566 1567 TRACE ("adding %d bitmaps!\n", nButtons); 1568 } 1569 1905 nButtons = (INT)wParam; 1906 if (nButtons <= 0) 1907 return -1; 1908 1909 TRACE ("adding %d bitmaps!\n", nButtons); 1910 } 1911 1570 1912 if (!(infoPtr->himlDef)) { 1571 1572 1573 1574 1575 1576 1577 1913 /* create new default image list */ 1914 TRACE ("creating default image list!\n"); 1915 1916 infoPtr->himlDef = 1917 ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight, 1918 ILC_COLOR | ILC_MASK, nButtons, 2); 1919 infoPtr->himlInt = infoPtr->himlDef; 1578 1920 } 1579 1921 … … 1583 1925 if (lpAddBmp->hInst == (HINSTANCE)0) 1584 1926 { 1585 nIndex = 1586 1587 1927 nIndex = 1928 ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID, 1929 CLR_DEFAULT); 1588 1930 } 1589 1931 else if (lpAddBmp->hInst == HINST_COMMCTRL) 1590 1932 { 1591 1592 1933 /* Add system bitmaps */ 1934 switch (lpAddBmp->nID) 1593 1935 { 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1936 case IDB_STD_SMALL_COLOR: 1937 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1938 MAKEINTRESOURCEA(IDB_STD_SMALL)); 1939 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1940 hbmLoad, CLR_DEFAULT); 1941 DeleteObject (hbmLoad); 1942 break; 1943 1944 case IDB_STD_LARGE_COLOR: 1945 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1946 MAKEINTRESOURCEA(IDB_STD_LARGE)); 1947 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1948 hbmLoad, CLR_DEFAULT); 1949 DeleteObject (hbmLoad); 1950 break; 1951 1952 case IDB_VIEW_SMALL_COLOR: 1953 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1954 MAKEINTRESOURCEA(IDB_VIEW_SMALL)); 1955 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1956 hbmLoad, CLR_DEFAULT); 1957 DeleteObject (hbmLoad); 1958 break; 1959 1960 case IDB_VIEW_LARGE_COLOR: 1961 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1962 MAKEINTRESOURCEA(IDB_VIEW_LARGE)); 1963 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1964 hbmLoad, CLR_DEFAULT); 1965 DeleteObject (hbmLoad); 1966 break; 1967 1968 case IDB_HIST_SMALL_COLOR: 1969 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1970 MAKEINTRESOURCEA(IDB_HIST_SMALL)); 1971 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1972 hbmLoad, CLR_DEFAULT); 1973 DeleteObject (hbmLoad); 1974 break; 1975 1976 case IDB_HIST_LARGE_COLOR: 1977 hbmLoad = LoadBitmapA (COMCTL32_hModule, 1978 MAKEINTRESOURCEA(IDB_HIST_LARGE)); 1979 nIndex = ImageList_AddMasked (infoPtr->himlDef, 1980 hbmLoad, CLR_DEFAULT); 1981 DeleteObject (hbmLoad); 1982 break; 1983 1984 default: 1985 nIndex = ImageList_GetImageCount (infoPtr->himlDef); 1986 ERR ("invalid imagelist!\n"); 1987 break; 1988 } 1647 1989 } 1648 1990 else 1649 1991 { 1650 1651 1652 1992 hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID); 1993 nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT); 1994 DeleteObject (hbmLoad); 1653 1995 } 1654 1996 … … 1660 2002 { 1661 2003 WARN("Desired images do not match received images : Previous image number %i Previous images in list %i added %i expecting total %i, Images in list %i\n", 1662 1663 1664 1665 2004 infoPtr->nNumBitmaps, nCount, imagecount - nCount, 2005 infoPtr->nNumBitmaps+nButtons,imagecount); 2006 2007 infoPtr->nNumBitmaps = imagecount; 1666 2008 } 1667 2009 else … … 1689 2031 1690 2032 if (infoPtr->nNumButtons == 0) { 1691 1692 2033 infoPtr->buttons = 2034 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons); 1693 2035 } 1694 2036 else { 1695 1696 1697 1698 1699 2037 TBUTTON_INFO *oldButtons = infoPtr->buttons; 2038 infoPtr->buttons = 2039 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons); 2040 memcpy (&infoPtr->buttons[0], &oldButtons[0], 2041 nOldButtons * sizeof(TBUTTON_INFO)); 1700 2042 COMCTL32_Free (oldButtons); 1701 2043 } … … 1705 2047 /* insert new button data */ 1706 2048 for (nCount = 0; nCount < nAddButtons; nCount++) { 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 2049 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount]; 2050 btnPtr->iBitmap = lpTbb[nCount].iBitmap; 2051 btnPtr->idCommand = lpTbb[nCount].idCommand; 2052 btnPtr->fsState = lpTbb[nCount].fsState; 2053 btnPtr->fsStyle = lpTbb[nCount].fsStyle; 2054 btnPtr->dwData = lpTbb[nCount].dwData; 2055 btnPtr->iString = lpTbb[nCount].iString; 2056 btnPtr->bHot = FALSE; 2057 2058 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) { 2059 TTTOOLINFOA ti; 2060 2061 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 2062 ti.cbSize = sizeof (TTTOOLINFOA); 2063 ti.hwnd = hwnd; 2064 ti.uId = btnPtr->idCommand; 2065 ti.hinst = 0; 2066 ti.lpszText = LPSTR_TEXTCALLBACKA; 2067 2068 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA, 2069 0, (LPARAM)&ti); 2070 } 1729 2071 } 1730 2072 … … 1751 2093 1752 2094 if (infoPtr->nNumButtons == 0) { 1753 1754 2095 infoPtr->buttons = 2096 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons); 1755 2097 } 1756 2098 else { 1757 1758 1759 1760 1761 2099 TBUTTON_INFO *oldButtons = infoPtr->buttons; 2100 infoPtr->buttons = 2101 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons); 2102 memcpy (&infoPtr->buttons[0], &oldButtons[0], 2103 nOldButtons * sizeof(TBUTTON_INFO)); 1762 2104 COMCTL32_Free (oldButtons); 1763 2105 } … … 1767 2109 /* insert new button data */ 1768 2110 for (nCount = 0; nCount < nAddButtons; nCount++) { 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 2111 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount]; 2112 btnPtr->iBitmap = lpTbb[nCount].iBitmap; 2113 btnPtr->idCommand = lpTbb[nCount].idCommand; 2114 btnPtr->fsState = lpTbb[nCount].fsState; 2115 btnPtr->fsStyle = lpTbb[nCount].fsStyle; 2116 btnPtr->dwData = lpTbb[nCount].dwData; 2117 btnPtr->iString = lpTbb[nCount].iString; 2118 btnPtr->bHot = FALSE; 2119 2120 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) { 2121 TTTOOLINFOW ti; 2122 2123 ZeroMemory (&ti, sizeof(TTTOOLINFOW)); 2124 ti.cbSize = sizeof (TTTOOLINFOW); 2125 ti.hwnd = hwnd; 2126 ti.uId = btnPtr->idCommand; 2127 ti.hinst = 0; 2128 ti.lpszText = LPSTR_TEXTCALLBACKW; 2129 2130 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW, 2131 0, (LPARAM)&ti); 2132 } 1791 2133 } 1792 2134 … … 1806 2148 1807 2149 if ((wParam) && (HIWORD(lParam) == 0)) { 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 2150 char szString[256]; 2151 INT len, lenW; 2152 TRACE("adding string from resource!\n"); 2153 2154 len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam, 2155 szString, 256); 2156 2157 TRACE("len=%d \"%s\"\n", len, szString); 2158 nIndex = infoPtr->nNumStrings; 2159 if (infoPtr->nNumStrings == 0) { 2160 infoPtr->strings = 2161 COMCTL32_Alloc (sizeof(LPWSTR)); 2162 } 2163 else { 2164 LPWSTR *oldStrings = infoPtr->strings; 2165 infoPtr->strings = 2166 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1)); 2167 memcpy (&infoPtr->strings[0], &oldStrings[0], 2168 sizeof(LPWSTR) * infoPtr->nNumStrings); 2169 COMCTL32_Free (oldStrings); 2170 } 1829 2171 1830 2172 lenW = MultiByteToWideChar( CP_ACP, 0, szString, -1, NULL, 0 ); … … 1832 2174 MultiByteToWideChar( CP_ACP, 0, szString, -1, 1833 2175 infoPtr->strings[infoPtr->nNumStrings], lenW ); 1834 2176 infoPtr->nNumStrings++; 1835 2177 } 1836 2178 else { 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 2179 LPSTR p = (LPSTR)lParam; 2180 INT len, lenW; 2181 2182 if (p == NULL) 2183 return -1; 2184 TRACE("adding string(s) from array!\n"); 2185 2186 nIndex = infoPtr->nNumStrings; 2187 while (*p) { 2188 len = strlen (p); 2189 TRACE("len=%d \"%s\"\n", len, p); 2190 2191 if (infoPtr->nNumStrings == 0) { 2192 infoPtr->strings = 2193 COMCTL32_Alloc (sizeof(LPWSTR)); 2194 } 2195 else { 2196 LPWSTR *oldStrings = infoPtr->strings; 2197 infoPtr->strings = 2198 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1)); 2199 memcpy (&infoPtr->strings[0], &oldStrings[0], 2200 sizeof(LPWSTR) * infoPtr->nNumStrings); 2201 COMCTL32_Free (oldStrings); 2202 } 1861 2203 1862 2204 lenW = MultiByteToWideChar( CP_ACP, 0, p, -1, NULL, 0 ); … … 1864 2206 MultiByteToWideChar( CP_ACP, 0, p, -1, 1865 2207 infoPtr->strings[infoPtr->nNumStrings], lenW ); 1866 1867 1868 1869 2208 infoPtr->nNumStrings++; 2209 2210 p += (len+1); 2211 } 1870 2212 } 1871 2213 … … 1882 2224 1883 2225 if ((wParam) && (HIWORD(lParam) == 0)) { 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 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 2226 WCHAR szString[MAX_RESOURCE_STRING_LENGTH]; 2227 INT len; 2228 TRACE("adding string from resource!\n"); 2229 2230 len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam, 2231 szString, MAX_RESOURCE_STRING_LENGTH); 2232 2233 TRACE("len=%d %s\n", len, debugstr_w(szString)); 2234 TRACE("First char: 0x%x\n", *szString); 2235 if (szString[0] == L'|') 2236 { 2237 PWSTR p = szString + 1; 2238 2239 nIndex = infoPtr->nNumStrings; 2240 while (*p != L'|') { 2241 2242 if (infoPtr->nNumStrings == 0) { 2243 infoPtr->strings = 2244 COMCTL32_Alloc (sizeof(LPWSTR)); 2245 } 2246 else { 2247 LPWSTR *oldStrings = infoPtr->strings; 2248 infoPtr->strings = 2249 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1)); 2250 memcpy (&infoPtr->strings[0], &oldStrings[0], 2251 sizeof(LPWSTR) * infoPtr->nNumStrings); 2252 COMCTL32_Free (oldStrings); 2253 } 2254 2255 len = COMCTL32_StrChrW (p, L'|') - p; 2256 TRACE("len=%d %s\n", len, debugstr_w(p)); 2257 infoPtr->strings[infoPtr->nNumStrings] = 2258 COMCTL32_Alloc (sizeof(WCHAR)*(len+1)); 2259 lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len); 2260 infoPtr->nNumStrings++; 2261 2262 p += (len+1); 2263 } 2264 } 2265 else 2266 { 1925 2267 nIndex = infoPtr->nNumStrings; 1926 2268 if (infoPtr->nNumStrings == 0) { … … 1944 2286 } 1945 2287 else { 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 2288 LPWSTR p = (LPWSTR)lParam; 2289 INT len; 2290 2291 if (p == NULL) 2292 return -1; 2293 TRACE("adding string(s) from array!\n"); 2294 nIndex = infoPtr->nNumStrings; 2295 while (*p) { 2296 len = strlenW (p); 2297 2298 TRACE("len=%d %s\n", len, debugstr_w(p)); 2299 if (infoPtr->nNumStrings == 0) { 2300 infoPtr->strings = 2301 COMCTL32_Alloc (sizeof(LPWSTR)); 2302 } 2303 else { 2304 LPWSTR *oldStrings = infoPtr->strings; 2305 infoPtr->strings = 2306 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1)); 2307 memcpy (&infoPtr->strings[0], &oldStrings[0], 2308 sizeof(LPWSTR) * infoPtr->nNumStrings); 2309 COMCTL32_Free (oldStrings); 2310 } 2311 2312 infoPtr->strings[infoPtr->nNumStrings] = 2313 COMCTL32_Alloc (sizeof(WCHAR)*(len+1)); 2314 strcpyW (infoPtr->strings[infoPtr->nNumStrings], p); 2315 infoPtr->nNumStrings++; 2316 2317 p += (len+1); 2318 } 1977 2319 } 1978 2320 … … 2005 2347 2006 2348 if (dwStyle & CCS_NORESIZE) { 2007 2008 2009 2349 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE); 2350 cx = 0; 2351 cy = 0; 2010 2352 } 2011 2353 else { 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2354 infoPtr->nWidth = parent_rect.right - parent_rect.left; 2355 TOOLBAR_CalcToolbar (hwnd); 2356 InvalidateRect( hwnd, NULL, TRUE ); 2357 cy = infoPtr->nHeight; 2358 cx = infoPtr->nWidth; 2359 2360 if (dwStyle & CCS_NOMOVEY) { 2361 GetWindowRect(hwnd, &window_rect); 2362 ScreenToClient(parent, (LPPOINT)&window_rect.left); 2363 y = window_rect.top; 2364 } 2023 2365 } 2024 2366 2025 2367 if (dwStyle & CCS_NOPARENTALIGN) 2026 2368 uPosFlags |= SWP_NOMOVE; 2027 2369 2028 2370 if (!(dwStyle & CCS_NODIVIDER)) 2029 2371 cy += GetSystemMetrics(SM_CYEDGE); 2030 2372 2031 2373 if (dwStyle & WS_BORDER) … … 2062 2404 2063 2405 if (infoPtr == NULL) { 2064 2065 2066 2406 ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam); 2407 ERR("infoPtr == NULL!\n"); 2408 return 0; 2067 2409 } 2068 2410 … … 2082 2424 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2083 2425 if (nIndex == -1) 2084 2426 return FALSE; 2085 2427 2086 2428 btnPtr = &infoPtr->buttons[nIndex]; … … 2106 2448 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2107 2449 if (nIndex == -1) 2108 2450 return FALSE; 2109 2451 2110 2452 btnPtr = &infoPtr->buttons[nIndex]; 2111 2453 2112 2454 if (!(btnPtr->fsStyle & TBSTYLE_CHECK)) 2113 2455 return FALSE; 2114 2456 2115 2457 bChecked = (btnPtr->fsState & TBSTATE_CHECKED) ? TRUE : FALSE; 2116 2458 2117 2459 if (LOWORD(lParam) == FALSE) 2118 2460 btnPtr->fsState &= ~TBSTATE_CHECKED; 2119 2461 else { 2120 2121 nOldIndex = 2122 2123 2124 2125 2126 2127 2128 2462 if (btnPtr->fsStyle & TBSTYLE_GROUP) { 2463 nOldIndex = 2464 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex); 2465 if (nOldIndex == nIndex) 2466 return 0; 2467 if (nOldIndex != -1) 2468 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED; 2469 } 2470 btnPtr->fsState |= TBSTATE_CHECKED; 2129 2471 } 2130 2472 2131 2473 if( bChecked != LOWORD(lParam) ) 2132 2474 { 2133 2475 if (nOldIndex != -1) 2134 2476 { 2135 2477 InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect, … … 2157 2499 TOOLBAR_Customize (HWND hwnd) 2158 2500 { 2501 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2159 2502 CUSTDLG_INFO custInfo; 2160 2503 LRESULT ret; … … 2163 2506 NMHDR nmhdr; 2164 2507 2165 custInfo.tbInfo = TOOLBAR_GetInfoPtr (hwnd);2508 custInfo.tbInfo = infoPtr; 2166 2509 custInfo.tbHwnd = hwnd; 2167 2510 2168 2511 /* send TBN_BEGINADJUST notification */ 2169 nmhdr.hwndFrom = hwnd; 2170 nmhdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 2171 nmhdr.code = TBN_BEGINADJUST; 2172 2173 SendMessageA (custInfo.tbInfo->hwndNotify, WM_NOTIFY, 2174 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); 2512 TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr, 2513 TBN_BEGINADJUST); 2175 2514 2176 2515 if (!(hRes = FindResourceA (COMCTL32_hModule, 2177 2516 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE), 2178 2517 RT_DIALOGA))) 2179 2518 return FALSE; 2180 2519 2181 2520 if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes))) 2182 2521 return FALSE; 2183 2522 2184 2523 ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE), … … 2189 2528 2190 2529 /* send TBN_ENDADJUST notification */ 2191 nmhdr.code = TBN_ENDADJUST; 2192 SendMessageA (custInfo.tbInfo->hwndNotify, WM_NOTIFY, 2193 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); 2530 TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr, 2531 TBN_ENDADJUST); 2194 2532 2195 2533 return ret; … … 2204 2542 2205 2543 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 2206 2207 2208 if ((infoPtr->hwndToolTip) && 2209 2210 2211 2212 2213 2214 2215 2216 2217 2544 return FALSE; 2545 2546 if ((infoPtr->hwndToolTip) && 2547 !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) { 2548 TTTOOLINFOA ti; 2549 2550 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 2551 ti.cbSize = sizeof (TTTOOLINFOA); 2552 ti.hwnd = hwnd; 2553 ti.uId = infoPtr->buttons[nIndex].idCommand; 2554 2555 SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti); 2218 2556 } 2219 2557 2220 2558 if (infoPtr->nNumButtons == 1) { 2221 2222 2223 2224 2559 TRACE(" simple delete!\n"); 2560 COMCTL32_Free (infoPtr->buttons); 2561 infoPtr->buttons = NULL; 2562 infoPtr->nNumButtons = 0; 2225 2563 } 2226 2564 else { 2227 2565 TBUTTON_INFO *oldButtons = infoPtr->buttons; 2228 2566 TRACE("complex delete! [nIndex=%d]\n", nIndex); 2229 2567 2230 2231 2568 infoPtr->nNumButtons--; 2569 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons); 2232 2570 if (nIndex > 0) { 2233 2571 memcpy (&infoPtr->buttons[0], &oldButtons[0], … … 2240 2578 } 2241 2579 2242 2580 COMCTL32_Free (oldButtons); 2243 2581 } 2244 2582 … … 2261 2599 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2262 2600 if (nIndex == -1) 2263 2601 return FALSE; 2264 2602 2265 2603 btnPtr = &infoPtr->buttons[nIndex]; … … 2269 2607 /* update the toolbar button state */ 2270 2608 if(LOWORD(lParam) == FALSE) { 2271 2609 btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED); 2272 2610 } else { 2273 2611 btnPtr->fsState |= TBSTATE_ENABLED; 2274 2612 } 2275 2613 … … 2302 2640 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2303 2641 if (nIndex == -1) 2304 2642 return -1; 2305 2643 2306 2644 return infoPtr->buttons[nIndex].iBitmap; … … 2324 2662 2325 2663 if (infoPtr == NULL) 2326 2664 return FALSE; 2327 2665 2328 2666 if (lpTbb == NULL) 2329 2667 return FALSE; 2330 2668 2331 2669 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 2332 2670 return FALSE; 2333 2671 2334 2672 btnPtr = &infoPtr->buttons[nIndex]; … … 2353 2691 2354 2692 if (infoPtr == NULL) 2355 2693 return -1; 2356 2694 if (lpTbInfo == NULL) 2357 2695 return -1; 2358 2696 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA)) 2359 2697 return -1; 2360 2698 2361 2699 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2362 2700 if (nIndex == -1) 2363 2701 return -1; 2364 2702 2365 2703 btnPtr = &infoPtr->buttons[nIndex]; 2366 2704 2367 2705 if (lpTbInfo->dwMask & TBIF_COMMAND) 2368 2706 lpTbInfo->idCommand = btnPtr->idCommand; 2369 2707 if (lpTbInfo->dwMask & TBIF_IMAGE) 2370 2708 lpTbInfo->iImage = btnPtr->iBitmap; 2371 2709 if (lpTbInfo->dwMask & TBIF_LPARAM) 2372 2710 lpTbInfo->lParam = btnPtr->dwData; 2373 2711 if (lpTbInfo->dwMask & TBIF_SIZE) 2374 2712 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left); 2375 2713 if (lpTbInfo->dwMask & TBIF_STATE) 2376 2714 lpTbInfo->fsState = btnPtr->fsState; 2377 2715 if (lpTbInfo->dwMask & TBIF_STYLE) 2378 2716 lpTbInfo->fsStyle = btnPtr->fsStyle; 2379 2717 if (lpTbInfo->dwMask & TBIF_TEXT) { 2380 2718 if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings)) 2381 { 2719 { 2382 2720 if (!WideCharToMultiByte( CP_ACP, 0, (LPWSTR)infoPtr->strings[btnPtr->iString], -1, 2383 2721 lpTbInfo->pszText, lpTbInfo->cchText, NULL, NULL )) … … 2399 2737 2400 2738 if (infoPtr == NULL) 2401 2739 return -1; 2402 2740 if (lpTbInfo == NULL) 2403 2741 return -1; 2404 2742 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW)) 2405 2743 return -1; 2406 2744 2407 2745 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2408 2746 if (nIndex == -1) 2409 2747 return -1; 2410 2748 2411 2749 btnPtr = &infoPtr->buttons[nIndex]; 2412 2750 2413 2751 if (lpTbInfo->dwMask & TBIF_COMMAND) 2414 2752 lpTbInfo->idCommand = btnPtr->idCommand; 2415 2753 if (lpTbInfo->dwMask & TBIF_IMAGE) 2416 2754 lpTbInfo->iImage = btnPtr->iBitmap; 2417 2755 if (lpTbInfo->dwMask & TBIF_LPARAM) 2418 2756 lpTbInfo->lParam = btnPtr->dwData; 2419 2757 if (lpTbInfo->dwMask & TBIF_SIZE) 2420 2758 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left); 2421 2759 if (lpTbInfo->dwMask & TBIF_STATE) 2422 2760 lpTbInfo->fsState = btnPtr->fsState; 2423 2761 if (lpTbInfo->dwMask & TBIF_STYLE) 2424 2762 lpTbInfo->fsStyle = btnPtr->fsStyle; 2425 2763 if (lpTbInfo->dwMask & TBIF_TEXT) { 2426 2427 2428 2429 2764 if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings)) 2765 lstrcpynW (lpTbInfo->pszText, 2766 (LPWSTR)infoPtr->strings[btnPtr->iString], 2767 lpTbInfo->cchText); 2430 2768 } 2431 2769 … … 2439 2777 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2440 2778 2441 return MAKELONG((WORD)infoPtr->nButtonWidth, 2442 (WORD)infoPtr->nButtonHeight); 2779 if (infoPtr->nNumButtons > 0) 2780 return MAKELONG((WORD)infoPtr->nButtonWidth, 2781 (WORD)infoPtr->nButtonHeight); 2782 else 2783 return MAKELONG(8,7); 2443 2784 } 2444 2785 … … 2452 2793 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2453 2794 if (nIndex == -1) 2454 2795 return -1; 2455 2796 2456 2797 nStringIndex = infoPtr->buttons[nIndex].iString; … … 2459 2800 2460 2801 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings)) 2461 2802 return -1; 2462 2803 2463 2804 if (lParam == 0) 2464 2805 return -1; 2465 2806 2466 2807 return WideCharToMultiByte( CP_ACP, 0, (LPWSTR)infoPtr->strings[nStringIndex], -1, … … 2477 2818 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2478 2819 if (nIndex == -1) 2479 2820 return -1; 2480 2821 2481 2822 nStringIndex = infoPtr->buttons[nIndex].iString; … … 2484 2825 2485 2826 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings)) 2486 2827 return -1; 2487 2828 2488 2829 if (lParam == 0) 2489 2830 return -1; 2490 2831 2491 2832 strcpyW ((LPWSTR)lParam, (LPWSTR)infoPtr->strings[nStringIndex]); … … 2531 2872 2532 2873 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)) 2533 2874 return -1; 2534 2875 2535 2876 if (infoPtr->nHotItem < 0) 2536 2877 return -1; 2537 2878 2538 2879 return (LRESULT)infoPtr->nHotItem; … … 2562 2903 2563 2904 if (infoPtr == NULL) 2564 2905 return FALSE; 2565 2906 nIndex = (INT)wParam; 2566 2907 btnPtr = &infoPtr->buttons[nIndex]; 2567 2908 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 2568 2909 return FALSE; 2569 2910 lpRect = (LPRECT)lParam; 2570 2911 if (lpRect == NULL) 2571 2912 return FALSE; 2572 2913 if (btnPtr->fsState & TBSTATE_HIDDEN) 2573 2574 2914 return FALSE; 2915 2575 2916 lpRect->left = btnPtr->rect.left; 2576 2917 lpRect->right = btnPtr->rect.right; … … 2589 2930 2590 2931 if (lpSize == NULL) 2591 2932 return FALSE; 2592 2933 2593 2934 lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left; … … 2595 2936 2596 2937 TRACE("maximum size %d x %d\n", 2597 2598 2938 infoPtr->rcBound.right - infoPtr->rcBound.left, 2939 infoPtr->rcBound.bottom - infoPtr->rcBound.top); 2599 2940 2600 2941 return TRUE; … … 2615 2956 2616 2957 if (infoPtr == NULL) 2617 2958 return FALSE; 2618 2959 nIndex = (INT)wParam; 2619 2960 btnPtr = &infoPtr->buttons[nIndex]; 2620 2961 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 2621 2962 return FALSE; 2622 2963 lpRect = (LPRECT)lParam; 2623 2964 if (lpRect == NULL) 2624 2625 2965 return FALSE; 2966 2626 2967 lpRect->left = btnPtr->rect.left; 2627 2968 lpRect->right = btnPtr->rect.right; … … 2639 2980 2640 2981 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE) 2641 2982 return infoPtr->nRows; 2642 2983 else 2643 2984 return 1; 2644 2985 } 2645 2986 … … 2653 2994 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2654 2995 if (nIndex == -1) 2655 2996 return -1; 2656 2997 2657 2998 return infoPtr->buttons[nIndex].fsState; … … 2667 3008 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2668 3009 if (nIndex == -1) 2669 3010 return -1; 2670 3011 2671 3012 return infoPtr->buttons[nIndex].fsStyle; … … 2679 3020 2680 3021 if (infoPtr == NULL) 2681 3022 return 0; 2682 3023 2683 3024 return infoPtr->nMaxTextRows; … … 2691 3032 2692 3033 if (infoPtr == NULL) 2693 3034 return 0; 2694 3035 return infoPtr->hwndToolTip; 2695 3036 } … … 2701 3042 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 2702 3043 2703 TRACE("%s hwnd=0x%x stub!\n", 2704 3044 TRACE("%s hwnd=0x%x stub!\n", 3045 infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd); 2705 3046 2706 3047 return infoPtr->bUnicode; … … 2727 3068 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2728 3069 if (nIndex == -1) 2729 3070 return FALSE; 2730 3071 2731 3072 btnPtr = &infoPtr->buttons[nIndex]; 2732 3073 if (LOWORD(lParam) == FALSE) 2733 3074 btnPtr->fsState &= ~TBSTATE_HIDDEN; 2734 3075 else 2735 3076 btnPtr->fsState |= TBSTATE_HIDDEN; 2736 3077 2737 3078 TOOLBAR_CalcToolbar (hwnd); … … 2759 3100 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2760 3101 if (nIndex == -1) 2761 3102 return FALSE; 2762 3103 2763 3104 btnPtr = &infoPtr->buttons[nIndex]; 2764 3105 if (LOWORD(lParam) == FALSE) 2765 3106 btnPtr->fsState &= ~TBSTATE_INDETERMINATE; 2766 3107 else 2767 3108 btnPtr->fsState |= TBSTATE_INDETERMINATE; 2768 3109 2769 3110 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr)); … … 2782 3123 2783 3124 if (lpTbb == NULL) 2784 return FALSE; 3125 return FALSE; 3126 3127 TOOLBAR_DumpButton(infoPtr, (TBUTTON_INFO *)lpTbb, nIndex, FALSE); 2785 3128 2786 3129 if (nIndex == -1) { 2787 3130 /* EPP: this seems to be an undocumented call (from my IE4) 2788 2789 2790 2791 2792 2793 2794 int 2795 LPSTR 3131 * I assume in that case that: 3132 * - lpTbb->iString is a string pointer (not a string index in strings[] table 3133 * - index of insertion is at the end of existing buttons 3134 * I only see this happen with nIndex == -1, but it could have a special 3135 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion). 3136 */ 3137 int len; 3138 LPSTR ptr; 2796 3139 2797 3140 /* FIXME: iString == -1 is undocumented */ … … 2815 3158 TRACE("inserting button index=%d\n", nIndex); 2816 3159 if (nIndex > infoPtr->nNumButtons) { 2817 2818 3160 nIndex = infoPtr->nNumButtons; 3161 TRACE("adjust index=%d\n", nIndex); 2819 3162 } 2820 3163 … … 2824 3167 /* pre insert copy */ 2825 3168 if (nIndex > 0) { 2826 2827 3169 memcpy (&infoPtr->buttons[0], &oldButtons[0], 3170 nIndex * sizeof(TBUTTON_INFO)); 2828 3171 } 2829 3172 … … 2837 3180 2838 3181 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) { 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 3182 TTTOOLINFOA ti; 3183 3184 ZeroMemory (&ti, sizeof(TTTOOLINFOA)); 3185 ti.cbSize = sizeof (TTTOOLINFOA); 3186 ti.hwnd = hwnd; 3187 ti.uId = lpTbb->idCommand; 3188 ti.hinst = 0; 3189 ti.lpszText = LPSTR_TEXTCALLBACKA; 3190 3191 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA, 3192 0, (LPARAM)&ti); 2850 3193 } 2851 3194 2852 3195 /* post insert copy */ 2853 3196 if (nIndex < infoPtr->nNumButtons - 1) { 2854 2855 3197 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex], 3198 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO)); 2856 3199 } 2857 3200 … … 2875 3218 2876 3219 if (lpTbb == NULL) 2877 3220 return FALSE; 2878 3221 if (nIndex < 0) 2879 3222 return FALSE; 2880 3223 2881 3224 TRACE("inserting button index=%d\n", nIndex); 2882 3225 if (nIndex > infoPtr->nNumButtons) { 2883 2884 3226 nIndex = infoPtr->nNumButtons; 3227 TRACE("adjust index=%d\n", nIndex); 2885 3228 } 2886 3229 … … 2890 3233 /* pre insert copy */ 2891 3234 if (nIndex > 0) { 2892 2893 3235 memcpy (&infoPtr->buttons[0], &oldButtons[0], 3236 nIndex * sizeof(TBUTTON_INFO)); 2894 3237 } 2895 3238 … … 2903 3246 2904 3247 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) { 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 3248 TTTOOLINFOW ti; 3249 3250 ZeroMemory (&ti, sizeof(TTTOOLINFOW)); 3251 ti.cbSize = sizeof (TTTOOLINFOW); 3252 ti.hwnd = hwnd; 3253 ti.uId = lpTbb->idCommand; 3254 ti.hinst = 0; 3255 ti.lpszText = LPSTR_TEXTCALLBACKW; 3256 3257 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW, 3258 0, (LPARAM)&ti); 2916 3259 } 2917 3260 2918 3261 /* post insert copy */ 2919 3262 if (nIndex < infoPtr->nNumButtons - 1) { 2920 2921 3263 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex], 3264 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO)); 2922 3265 } 2923 3266 … … 2941 3284 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2942 3285 if (nIndex == -1) 2943 3286 return FALSE; 2944 3287 2945 3288 return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED); … … 2955 3298 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2956 3299 if (nIndex == -1) 2957 3300 return FALSE; 2958 3301 2959 3302 return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED); … … 2969 3312 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2970 3313 if (nIndex == -1) 2971 3314 return TRUE; 2972 3315 2973 3316 return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN); … … 2983 3326 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2984 3327 if (nIndex == -1) 2985 3328 return FALSE; 2986 3329 2987 3330 return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED); … … 2997 3340 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 2998 3341 if (nIndex == -1) 2999 3342 return FALSE; 3000 3343 3001 3344 return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE); … … 3011 3354 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 3012 3355 if (nIndex == -1) 3013 3356 return FALSE; 3014 3357 3015 3358 return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED); … … 3032 3375 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 3033 3376 if (nIndex == -1) 3034 3377 return FALSE; 3035 3378 3036 3379 btnPtr = &infoPtr->buttons[nIndex]; 3037 3380 if (LOWORD(lParam) == FALSE) 3038 3381 btnPtr->fsState &= ~TBSTATE_PRESSED; 3039 3382 else 3040 3383 btnPtr->fsState |= TBSTATE_PRESSED; 3041 3384 3042 3385 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr)); … … 3059 3402 3060 3403 if ((BOOL)wParam) { 3061 3062 3063 3404 /* save toolbar information */ 3405 FIXME("save to \"%s\" \"%s\"\n", 3406 lpSave->pszSubKey, lpSave->pszValueName); 3064 3407 3065 3408 3066 3409 } 3067 3410 else { 3068 3069 3070 3071 3411 /* restore toolbar information */ 3412 3413 FIXME("restore from \"%s\" \"%s\"\n", 3414 lpSave->pszSubKey, lpSave->pszValueName); 3072 3415 3073 3416 … … 3087 3430 3088 3431 if (lpSave == NULL) 3432 return 0; 3433 3434 if ((BOOL)wParam) { 3435 /* save toolbar information */ 3436 FIXME("save to \"%s\" \"%s\"\n", 3437 lpSave->pszSubKey, lpSave->pszValueName); 3438 3439 3440 } 3441 else { 3442 /* restore toolbar information */ 3443 3444 FIXME("restore from \"%s\" \"%s\"\n", 3445 lpSave->pszSubKey, lpSave->pszValueName); 3446 3447 3448 } 3449 #endif 3450 3089 3451 return 0; 3090 3091 if ((BOOL)wParam) {3092 /* save toolbar information */3093 FIXME("save to \"%s\" \"%s\"\n",3094 lpSave->pszSubKey, lpSave->pszValueName);3095 3096 3097 }3098 else {3099 /* restore toolbar information */3100 3101 FIXME("restore from \"%s\" \"%s\"\n",3102 lpSave->pszSubKey, lpSave->pszValueName);3103 3104 3105 }3106 #endif3107 3108 return 0;3109 3452 } 3110 3453 … … 3128 3471 3129 3472 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0)) 3130 3473 return FALSE; 3131 3474 3132 3475 if (infoPtr->nNumButtons > 0) … … 3158 3501 3159 3502 if (lptbbi == NULL) 3160 3503 return FALSE; 3161 3504 if (lptbbi->cbSize < sizeof(TBBUTTONINFOA)) 3162 3163 3505 return FALSE; 3506 3164 3507 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 3165 3508 if (nIndex == -1) 3166 3509 return FALSE; 3167 3510 3168 3511 btnPtr = &infoPtr->buttons[nIndex]; 3169 3512 if (lptbbi->dwMask & TBIF_COMMAND) 3170 3513 btnPtr->idCommand = lptbbi->idCommand; 3171 3514 if (lptbbi->dwMask & TBIF_IMAGE) 3172 3515 btnPtr->iBitmap = lptbbi->iImage; 3173 3516 if (lptbbi->dwMask & TBIF_LPARAM) 3174 3517 btnPtr->dwData = lptbbi->lParam; 3175 3518 /* if (lptbbi->dwMask & TBIF_SIZE) */ 3176 /* 3519 /* btnPtr->cx = lptbbi->cx; */ 3177 3520 if (lptbbi->dwMask & TBIF_STATE) 3178 3521 btnPtr->fsState = lptbbi->fsState; 3179 3522 if (lptbbi->dwMask & TBIF_STYLE) 3180 3523 btnPtr->fsStyle = lptbbi->fsStyle; 3181 3524 3182 3525 if (lptbbi->dwMask & TBIF_TEXT) { 3183 if ((btnPtr->iString >= 0) || 3184 3185 3526 if ((btnPtr->iString >= 0) || 3527 (btnPtr->iString < infoPtr->nNumStrings)) { 3528 TRACE("Ooooooch\n"); 3186 3529 #if 0 3187 3188 3189 3530 WCHAR **lpString = &infoPtr->strings[btnPtr->iString]; 3531 INT len = lstrlenA (lptbbi->pszText); 3532 *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1)); 3190 3533 #endif 3191 3534 3192 3193 /* 3194 3535 /* this is the ultimate sollution */ 3536 /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */ 3537 } 3195 3538 } 3196 3539 … … 3208 3551 3209 3552 if (lptbbi == NULL) 3210 3553 return FALSE; 3211 3554 if (lptbbi->cbSize < sizeof(TBBUTTONINFOW)) 3212 3555 return FALSE; 3213 3556 3214 3557 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 3215 3558 if (nIndex == -1) 3216 3559 return FALSE; 3217 3560 3218 3561 btnPtr = &infoPtr->buttons[nIndex]; 3219 3562 if (lptbbi->dwMask & TBIF_COMMAND) 3220 3563 btnPtr->idCommand = lptbbi->idCommand; 3221 3564 if (lptbbi->dwMask & TBIF_IMAGE) 3222 3565 btnPtr->iBitmap = lptbbi->iImage; 3223 3566 if (lptbbi->dwMask & TBIF_LPARAM) 3224 3567 btnPtr->dwData = lptbbi->lParam; 3225 3568 /* if (lptbbi->dwMask & TBIF_SIZE) */ 3226 /* 3569 /* btnPtr->cx = lptbbi->cx; */ 3227 3570 if (lptbbi->dwMask & TBIF_STATE) 3228 3571 btnPtr->fsState = lptbbi->fsState; 3229 3572 if (lptbbi->dwMask & TBIF_STYLE) 3230 3573 btnPtr->fsStyle = lptbbi->fsStyle; 3231 3574 3232 3575 if (lptbbi->dwMask & TBIF_TEXT) { 3233 3234 3576 if ((btnPtr->iString >= 0) || 3577 (btnPtr->iString < infoPtr->nNumStrings)) { 3235 3578 #if 0 3236 3237 3238 3579 WCHAR **lpString = &infoPtr->strings[btnPtr->iString]; 3580 INT len = lstrlenW (lptbbi->pszText); 3581 *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1)); 3239 3582 #endif 3240 3583 3241 3242 /* 3243 3584 /* this is the ultimate solution */ 3585 /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */ 3586 } 3244 3587 } 3245 3588 … … 3256 3599 { 3257 3600 ERR("invalid parameter\n"); 3258 3601 return FALSE; 3259 3602 } 3260 3603 3261 3604 /* The documentation claims you can only change the button size before 3262 * any button has been added. But this is wrong. 3263 * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding 3605 * any button has been added. But this is wrong. 3606 * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding 3264 3607 * it to the toolbar, and it checks that the return value is nonzero - mjm 3265 3608 * Further testing shows that we must actually perform the change too. … … 3277 3620 3278 3621 if (infoPtr == NULL) { 3279 3280 3622 TRACE("Toolbar not initialized yet?????\n"); 3623 return FALSE; 3281 3624 } 3282 3625 3283 3626 /* if setting to current values, ignore */ 3284 3627 if ((infoPtr->cxMin == (INT)LOWORD(lParam)) && 3285 3286 3287 3288 return TRUE; 3628 (infoPtr->cxMax == (INT)HIWORD(lParam))) { 3629 TRACE("matches current width, min=%d, max=%d, no recalc\n", 3630 infoPtr->cxMin, infoPtr->cxMax); 3631 return TRUE; 3289 3632 } 3290 3633 … … 3295 3638 /* if both values are 0 then we are done */ 3296 3639 if (lParam == 0) { 3297 TRACE("setting both min and max to 0, norecalc\n"); 3298 3640 TRACE("setting both min and max to 0, norecalc\n"); 3641 return TRUE; 3299 3642 } 3300 3643 … … 3302 3645 recalc the bounding rectangle (does DrawText w/ DT_CALCRECT 3303 3646 which doesn't actually draw - GA). */ 3304 TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n", 3305 3647 TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n", 3648 infoPtr->nNumButtons, infoPtr->cxMin, infoPtr->cxMax); 3306 3649 3307 3650 TOOLBAR_CalcToolbar (hwnd); … … 3320 3663 3321 3664 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) 3322 3665 return FALSE; 3323 3666 3324 3667 infoPtr->buttons[nIndex].idCommand = (INT)lParam; … … 3326 3669 if (infoPtr->hwndToolTip) { 3327 3670 3328 3671 FIXME("change tool tip!\n"); 3329 3672 3330 3673 } … … 3349 3692 /* FIXME: redraw ? */ 3350 3693 3351 return (LRESULT)himlTemp; 3694 return (LRESULT)himlTemp; 3352 3695 } 3353 3696 … … 3361 3704 dwTemp = infoPtr->dwDTFlags; 3362 3705 infoPtr->dwDTFlags = 3363 3706 (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam; 3364 3707 3365 3708 return (LRESULT)dwTemp; … … 3376 3719 infoPtr->dwExStyle = (DWORD)lParam; 3377 3720 3378 return (LRESULT)dwTemp; 3721 return (LRESULT)dwTemp; 3379 3722 } 3380 3723 … … 3391 3734 /* FIXME: redraw ? */ 3392 3735 3393 return (LRESULT)himlTemp; 3736 return (LRESULT)himlTemp; 3394 3737 } 3395 3738 … … 3408 3751 { 3409 3752 3410 3753 infoPtr->nHotItem = (INT)wParam; 3411 3754 if ((INT)wParam >=0) 3412 3755 { 3413 3756 btnPtr = &infoPtr->buttons[(INT)wParam]; 3414 3757 btnPtr->bHot = TRUE; 3415 3758 InvalidateRect (hwnd, &btnPtr->rect, 3416 3759 TOOLBAR_HasText(infoPtr, btnPtr)); 3417 3760 } … … 3420 3763 btnPtr = &infoPtr->buttons[nOldHotItem]; 3421 3764 btnPtr->bHot = FALSE; 3422 3765 InvalidateRect (hwnd, &btnPtr->rect, 3423 3766 TOOLBAR_HasText(infoPtr, btnPtr)); 3424 3767 } … … 3426 3769 3427 3770 if (nOldHotItem < 0) 3428 3771 return -1; 3429 3772 3430 3773 return (LRESULT)nOldHotItem; … … 3441 3784 infoPtr->himlDef = (HIMAGELIST)lParam; 3442 3785 3443 infoPtr->nNumBitmaps = ImageList_GetImageCount(infoPtr->himlDef); 3786 infoPtr->nNumBitmaps = ImageList_GetImageCount(infoPtr->himlDef); 3787 3788 ImageList_GetIconSize(infoPtr->himlDef, &infoPtr->nBitmapWidth, 3789 &infoPtr->nBitmapHeight); 3790 TRACE("hwnd %08x, new himl=%08x, count=%d, bitmap w=%d, h=%d\n", 3791 hwnd, (INT)infoPtr->himlDef, infoPtr->nNumBitmaps, 3792 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight); 3793 3444 3794 /* FIXME: redraw ? */ 3445 3795 3446 return (LRESULT)himlTemp; 3796 return (LRESULT)himlTemp; 3447 3797 } 3448 3798 … … 3491 3841 3492 3842 if (infoPtr == NULL) 3493 3843 return FALSE; 3494 3844 3495 3845 infoPtr->nMaxTextRows = (INT)wParam; … … 3511 3861 3512 3862 if (infoPtr == NULL) 3513 3863 return 0; 3514 3864 hwndOldNotify = infoPtr->hwndNotify; 3515 3865 infoPtr->hwndNotify = (HWND)wParam; … … 3528 3878 3529 3879 if (LOWORD(wParam) > 1) { 3530 3880 FIXME("multiple rows not supported!\n"); 3531 3881 } 3532 3882 … … 3544 3894 /* return bounding rectangle */ 3545 3895 if (lprc) { 3546 3547 3548 3549 3896 lprc->left = infoPtr->rcBound.left; 3897 lprc->right = infoPtr->rcBound.right; 3898 lprc->top = infoPtr->rcBound.top; 3899 lprc->bottom = infoPtr->rcBound.bottom; 3550 3900 } 3551 3901 … … 3563 3913 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 3564 3914 if (nIndex == -1) 3565 3915 return FALSE; 3566 3916 3567 3917 btnPtr = &infoPtr->buttons[nIndex]; 3918 3919 /* if hidden state has changed the invalidate entire window and recalc */ 3920 if ((btnPtr->fsState & TBSTATE_HIDDEN) != (LOWORD(lParam) & TBSTATE_HIDDEN)) { 3921 btnPtr->fsState = LOWORD(lParam); 3922 TOOLBAR_CalcToolbar (hwnd); 3923 InvalidateRect(hwnd, 0, TOOLBAR_HasText(infoPtr, btnPtr)); 3924 return TRUE; 3925 } 3568 3926 3569 3927 /* process state changing if current state doesn't match new state */ … … 3588 3946 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); 3589 3947 if (nIndex == -1) 3590 3948 return FALSE; 3591 3949 3592 3950 btnPtr = &infoPtr->buttons[nIndex]; … … 3600 3958 3601 3959 if (infoPtr->hwndToolTip) { 3602 3960 FIXME("change tool tip!\n"); 3603 3961 } 3604 3962 } … … 3614 3972 3615 3973 if (infoPtr == NULL) 3616 3974 return 0; 3617 3975 infoPtr->hwndToolTip = (HWND)wParam; 3618 3976 return 0; … … 3626 3984 BOOL bTemp; 3627 3985 3628 TRACE("%s hwnd=0x%04x stub!\n", 3629 3986 TRACE("%s hwnd=0x%04x stub!\n", 3987 ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd); 3630 3988 3631 3989 bTemp = infoPtr->bUnicode; … … 3675 4033 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */ 3676 4034 infoPtr->hwndNotify = GetParent (hwnd); 3677 infoPtr->bTransparent = (dwStyle & TBSTYLE_FLAT); 4035 infoPtr->bTransparent = (dwStyle & TBSTYLE_TRANSPARENT); 4036 infoPtr->bBtnTranspnt = (dwStyle & (TBSTYLE_FLAT | TBSTYLE_LIST)); 3678 4037 infoPtr->dwDTFlags = (dwStyle & TBSTYLE_LIST) ? DT_LEFT | DT_VCENTER | DT_SINGLELINE : DT_CENTER; 3679 4038 infoPtr->bAnchor = FALSE; /* no anchor highlighting */ 3680 4039 infoPtr->iVersion = 0; 4040 infoPtr->bNtfUnicode = FALSE; 4041 infoPtr->hwndSelf = hwnd; 3681 4042 3682 4043 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0); … … 3684 4045 3685 4046 if (dwStyle & TBSTYLE_TOOLTIPS) { 3686 /* Create tooltip control */ 3687 infoPtr->hwndToolTip = 3688 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0, 3689 CW_USEDEFAULT, CW_USEDEFAULT, 3690 CW_USEDEFAULT, CW_USEDEFAULT, 3691 hwnd, 0, 0, 0); 3692 3693 /* Send NM_TOOLTIPSCREATED notification */ 3694 if (infoPtr->hwndToolTip) { 3695 NMTOOLTIPSCREATED nmttc; 3696 3697 nmttc.hdr.hwndFrom = hwnd; 3698 nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 3699 nmttc.hdr.code = NM_TOOLTIPSCREATED; 3700 nmttc.hwndToolTips = infoPtr->hwndToolTip; 3701 3702 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, 3703 (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc); 3704 } 3705 } 4047 /* Create tooltip control */ 4048 infoPtr->hwndToolTip = 4049 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0, 4050 CW_USEDEFAULT, CW_USEDEFAULT, 4051 CW_USEDEFAULT, CW_USEDEFAULT, 4052 hwnd, 0, 0, 0); 4053 4054 /* Send NM_TOOLTIPSCREATED notification */ 4055 if (infoPtr->hwndToolTip) { 4056 NMTOOLTIPSCREATED nmttc; 4057 4058 nmttc.hwndToolTips = infoPtr->hwndToolTip; 4059 4060 TOOLBAR_SendNotify ((NMHDR *) &nmttc, infoPtr, 4061 NM_TOOLTIPSCREATED); 4062 } 4063 } 4064 4065 TOOLBAR_CheckStyle (hwnd, dwStyle); 3706 4066 3707 4067 TOOLBAR_CalcToolbar(hwnd); … … 3718 4078 /* delete tooltip control */ 3719 4079 if (infoPtr->hwndToolTip) 3720 4080 DestroyWindow (infoPtr->hwndToolTip); 3721 4081 3722 4082 /* delete button data */ 3723 4083 if (infoPtr->buttons) 3724 4084 COMCTL32_Free (infoPtr->buttons); 3725 4085 3726 4086 /* delete strings */ 3727 4087 if (infoPtr->strings) { 3728 3729 3730 3731 3732 3733 4088 INT i; 4089 for (i = 0; i < infoPtr->nNumStrings; i++) 4090 if (infoPtr->strings[i]) 4091 COMCTL32_Free (infoPtr->strings[i]); 4092 4093 COMCTL32_Free (infoPtr->strings); 3734 4094 } 3735 4095 3736 4096 /* destroy internal image list */ 3737 4097 if (infoPtr->himlInt) 3738 4098 ImageList_Destroy (infoPtr->himlInt); 3739 4099 3740 4100 /* delete default font */ 3741 4101 if (infoPtr->hFont) 3742 4102 DeleteObject (infoPtr->hFont); 3743 4103 3744 4104 /* free toolbar info data */ … … 3754 4114 { 3755 4115 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 3756 3757 if (infoPtr->bTransparent) 3758 return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam); 3759 3760 return DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam); 4116 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); 4117 NMTBCUSTOMDRAW tbcd; 4118 INT ret, ntfret; 4119 4120 if (dwStyle & TBSTYLE_CUSTOMERASE) { 4121 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW)); 4122 tbcd.nmcd.dwDrawStage = CDDS_PREERASE; 4123 tbcd.nmcd.hdc = (HDC)wParam; 4124 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW); 4125 /* FIXME: in general the return flags *can* be or'ed together */ 4126 switch (ntfret) 4127 { 4128 case CDRF_DODEFAULT: 4129 break; 4130 case CDRF_SKIPDEFAULT: 4131 return TRUE; 4132 default: 4133 FIXME("[%04x] response %d not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n", 4134 hwnd, ntfret); 4135 } 4136 } 4137 4138 /* If the toolbar is "transparent" then pass the WM_ERASEBKGND up 4139 * to my parent for processing. 4140 */ 4141 if (infoPtr->bTransparent) { 4142 POINT pt, ptorig; 4143 HDC hdc = (HDC)wParam; 4144 HWND parent; 4145 4146 pt.x = 0; 4147 pt.y = 0; 4148 parent = GetParent(hwnd); 4149 MapWindowPoints(hwnd, parent, &pt, 1); 4150 OffsetWindowOrgEx (hdc, pt.x, pt.y, &ptorig); 4151 SendMessageA (parent, WM_ERASEBKGND, wParam, lParam); 4152 SetWindowOrgEx (hdc, ptorig.x, ptorig.y, 0); 4153 return TRUE; 4154 } 4155 ret = DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam); 4156 4157 if (dwStyle & TBSTYLE_CUSTOMERASE) { 4158 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW)); 4159 tbcd.nmcd.dwDrawStage = CDDS_POSTERASE; 4160 tbcd.nmcd.hdc = (HDC)wParam; 4161 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW); 4162 switch (ntfret) 4163 { 4164 case CDRF_DODEFAULT: 4165 break; 4166 case CDRF_SKIPDEFAULT: 4167 return TRUE; 4168 default: 4169 FIXME("[%04x] response %d not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n", 4170 hwnd, ntfret); 4171 } 4172 } 4173 return ret; 3761 4174 } 3762 4175 … … 3784 4197 3785 4198 if (nHit >= 0) { 3786 3787 3788 3789 3790 3791 3792 3793 4199 btnPtr = &infoPtr->buttons[nHit]; 4200 if (!(btnPtr->fsState & TBSTATE_ENABLED)) 4201 return 0; 4202 SetCapture (hwnd); 4203 infoPtr->bCaptured = TRUE; 4204 infoPtr->nButtonDown = nHit; 4205 4206 btnPtr->fsState |= TBSTATE_PRESSED; 3794 4207 3795 4208 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, … … 3797 4210 } 3798 4211 else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE) 3799 4212 TOOLBAR_Customize (hwnd); 3800 4213 3801 4214 return 0; … … 3810 4223 POINT pt; 3811 4224 INT nHit; 4225 NMTOOLBARA nmtb; 3812 4226 3813 4227 if (infoPtr->hwndToolTip) 3814 3815 4228 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd, 4229 WM_LBUTTONDOWN, wParam, lParam); 3816 4230 3817 4231 pt.x = (INT)LOWORD(lParam); … … 3820 4234 3821 4235 if (nHit >= 0) { 3822 RECT arrowRect; 3823 btnPtr = &infoPtr->buttons[nHit]; 3824 if (!(btnPtr->fsState & TBSTATE_ENABLED)) 3825 return 0; 3826 3827 infoPtr->nOldHit = nHit; 3828 3829 CopyRect(&arrowRect, &btnPtr->rect); 3830 arrowRect.left = max(btnPtr->rect.left, btnPtr->rect.right - DDARROW_WIDTH); 3831 3832 /* for EX_DRAWDDARROWS style, click must be in the drop-down arrow rect */ 3833 if ((btnPtr->fsStyle & TBSTYLE_DROPDOWN) && 3834 ((TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && PtInRect(&arrowRect, pt)) || 3835 (!TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle)))) 3836 { 3837 NMTOOLBARA nmtb; 3838 /* 3839 * this time we must force a Redraw, so the btn is 3840 * painted down before CaptureChanged repaints it up 3841 */ 3842 RedrawWindow(hwnd,&btnPtr->rect,0, 3843 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW); 3844 3845 nmtb.hdr.hwndFrom = hwnd; 3846 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID); 3847 nmtb.hdr.code = TBN_DROPDOWN; 3848 nmtb.iItem = btnPtr->idCommand; 3849 3850 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, 3851 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb); 3852 } 3853 else 3854 { 3855 SetCapture (hwnd); 3856 infoPtr->bCaptured = TRUE; 3857 infoPtr->nButtonDown = nHit; 3858 3859 btnPtr->fsState |= TBSTATE_PRESSED; 3860 btnPtr->bHot = FALSE; 3861 3862 InvalidateRect(hwnd, &btnPtr->rect, 3863 TOOLBAR_HasText(infoPtr, btnPtr)); 3864 } 4236 RECT arrowRect; 4237 btnPtr = &infoPtr->buttons[nHit]; 4238 if (!(btnPtr->fsState & TBSTATE_ENABLED)) 4239 return 0; 4240 4241 infoPtr->nOldHit = nHit; 4242 4243 CopyRect(&arrowRect, &btnPtr->rect); 4244 arrowRect.left = max(btnPtr->rect.left, btnPtr->rect.right - DDARROW_WIDTH); 4245 4246 /* for EX_DRAWDDARROWS style, click must be in the drop-down arrow rect */ 4247 if ((btnPtr->fsStyle & TBSTYLE_DROPDOWN) && 4248 ((TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && PtInRect(&arrowRect, pt)) || 4249 (!TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle)))) 4250 { 4251 LRESULT res; 4252 /* 4253 * this time we must force a Redraw, so the btn is 4254 * painted down before CaptureChanged repaints it up 4255 */ 4256 RedrawWindow(hwnd,&btnPtr->rect,0, 4257 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW); 4258 4259 nmtb.iItem = btnPtr->idCommand; 4260 memset(&nmtb.tbButton, 0, sizeof(TBBUTTON)); 4261 nmtb.cchText = 0; 4262 nmtb.pszText = 0; 4263 memset(&nmtb.rcButton, 0, sizeof(RECT)); 4264 res = TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, 4265 TBN_DROPDOWN); 4266 if (res != TBDDRET_TREATPRESSED) 4267 /* ??? guess (GA) */ 4268 return 0; 4269 /* otherwise drop through and process as pushed */ 4270 } 4271 /* SetCapture (hwnd); */ 4272 infoPtr->bCaptured = TRUE; 4273 infoPtr->nButtonDown = nHit; 4274 4275 btnPtr->fsState |= TBSTATE_PRESSED; 4276 btnPtr->bHot = FALSE; 4277 4278 InvalidateRect(hwnd, &btnPtr->rect, 4279 TOOLBAR_HasText(infoPtr, btnPtr)); 4280 UpdateWindow(hwnd); 4281 SetCapture (hwnd); 4282 4283 /* native issues the TBN_BEGINDRAG here */ 4284 nmtb.iItem = btnPtr->idCommand; 4285 nmtb.tbButton.iBitmap = btnPtr->iBitmap; 4286 nmtb.tbButton.idCommand = btnPtr->idCommand; 4287 nmtb.tbButton.fsState = btnPtr->fsState; 4288 nmtb.tbButton.fsStyle = btnPtr->fsStyle; 4289 nmtb.tbButton.dwData = btnPtr->dwData; 4290 nmtb.tbButton.iString = btnPtr->iString; 4291 nmtb.cchText = 0; /* !!! not correct */ 4292 nmtb.pszText = 0; /* !!! not correct */ 4293 TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, 4294 TBN_BEGINDRAG); 3865 4295 } 3866 4296 … … 3877 4307 INT nOldIndex = -1; 3878 4308 BOOL bSendMessage = TRUE; 4309 NMHDR hdr; 4310 NMMOUSE nmmouse; 4311 NMTOOLBARA nmtb; 3879 4312 3880 4313 if (infoPtr->hwndToolTip) 3881 3882 4314 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd, 4315 WM_LBUTTONUP, wParam, lParam); 3883 4316 3884 4317 pt.x = (INT)LOWORD(lParam); … … 3892 4325 3893 4326 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) { 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 if ((nOldIndex != infoPtr->nButtonDown) && 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 4327 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown]; 4328 btnPtr->fsState &= ~TBSTATE_PRESSED; 4329 4330 if (nHit == infoPtr->nButtonDown) { 4331 if (btnPtr->fsStyle & TBSTYLE_CHECK) { 4332 if (btnPtr->fsStyle & TBSTYLE_GROUP) { 4333 nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, 4334 infoPtr->nButtonDown); 4335 if (nOldIndex == infoPtr->nButtonDown) 4336 bSendMessage = FALSE; 4337 if ((nOldIndex != infoPtr->nButtonDown) && 4338 (nOldIndex != -1)) 4339 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED; 4340 btnPtr->fsState |= TBSTATE_CHECKED; 4341 } 4342 else { 4343 if (btnPtr->fsState & TBSTATE_CHECKED) 4344 btnPtr->fsState &= ~TBSTATE_CHECKED; 4345 else 4346 btnPtr->fsState |= TBSTATE_CHECKED; 4347 } 4348 } 4349 } 4350 else 4351 bSendMessage = FALSE; 4352 4353 if (nOldIndex != -1) 3921 4354 { 3922 4355 InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect, … … 3924 4357 } 3925 4358 3926 /* 3927 * now we can ReleaseCapture, which triggers CAPTURECHANGED msg, 3928 * that resets bCaptured and btn TBSTATE_PRESSED flags, 3929 * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged) 3930 */ 3931 ReleaseCapture (); 3932 3933 if (bSendMessage) 3934 SendMessageA (GetParent(hwnd), WM_COMMAND, 3935 MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd); 4359 /* 4360 * now we can ReleaseCapture, which triggers CAPTURECHANGED msg, 4361 * that resets bCaptured and btn TBSTATE_PRESSED flags, 4362 * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged) 4363 */ 4364 ReleaseCapture (); 4365 4366 /* Issue NM_RELEASEDCAPTURE to parent to let him know it is released */ 4367 TOOLBAR_SendNotify ((NMHDR *) &hdr, infoPtr, 4368 NM_RELEASEDCAPTURE); 4369 4370 /* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the 4371 * TBN_BEGINDRAG 4372 */ 4373 nmtb.iItem = btnPtr->idCommand; 4374 nmtb.tbButton.iBitmap = btnPtr->iBitmap; 4375 nmtb.tbButton.idCommand = btnPtr->idCommand; 4376 nmtb.tbButton.fsState = btnPtr->fsState; 4377 nmtb.tbButton.fsStyle = btnPtr->fsStyle; 4378 nmtb.tbButton.dwData = btnPtr->dwData; 4379 nmtb.tbButton.iString = btnPtr->iString; 4380 nmtb.cchText = 0; /* !!! not correct */ 4381 nmtb.pszText = 0; /* !!! not correct */ 4382 TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, 4383 TBN_ENDDRAG); 4384 4385 if (bSendMessage) 4386 SendMessageA (GetParent(hwnd), WM_COMMAND, 4387 MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd); 4388 4389 /* !!! Undocumented - toolbar at 4.71 level and above sends 4390 * either NMRCLICK or NM_CLICK with the NMMOUSE structure. 4391 * Only NM_RCLICK is documented. 4392 */ 4393 nmmouse.dwItemSpec = btnPtr->idCommand; 4394 nmmouse.dwItemData = btnPtr->dwData; 4395 TOOLBAR_SendNotify ((NMHDR *) &nmmouse, infoPtr, 4396 NM_CLICK); 3936 4397 } 3937 4398 … … 3950 4411 { 3951 4412 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown]; 3952 4413 btnPtr->fsState &= ~TBSTATE_PRESSED; 3953 4414 3954 4415 infoPtr->nButtonDown = -1; … … 3966 4427 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); 3967 4428 TBUTTON_INFO *hotBtnPtr, *btnPtr; 4429 RECT rc1; 3968 4430 3969 4431 if (infoPtr->nOldHit < 0) … … 3976 4438 if((infoPtr->nOldHit == infoPtr->nHotItem) && (hotBtnPtr->fsState & TBSTATE_ENABLED)) 3977 4439 { 3978 hotBtnPtr->bHot = FALSE; 3979 3980 InvalidateRect (hwnd, &hotBtnPtr->rect, TOOLBAR_HasText(infoPtr, 4440 hotBtnPtr->bHot = FALSE; 4441 rc1 = hotBtnPtr->rect; 4442 InflateRect (&rc1, 1, 1); 4443 InvalidateRect (hwnd, &rc1, TOOLBAR_HasText(infoPtr, 3981 4444 hotBtnPtr)); 3982 4445 } … … 3990 4453 btnPtr->fsState &= ~TBSTATE_PRESSED; 3991 4454 3992 InvalidateRect (hwnd, &(btnPtr->rect), TRUE); 4455 rc1 = hotBtnPtr->rect; 4456 InflateRect (&rc1, 1, 1); 4457 InvalidateRect (hwnd, &rc1, TRUE); 3993 4458 } 3994 4459 … … 4020 4485 if(!(trackinfo.dwFlags & TME_LEAVE)) { 4021 4486 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */ 4022 4487 4023 4488 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */ 4024 4489 /* and can properly deactivate the hot toolbar button */ … … 4027 4492 4028 4493 if (infoPtr->hwndToolTip) 4029 4030 4494 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd, 4495 WM_MOUSEMOVE, wParam, lParam); 4031 4496 4032 4497 pt.x = (INT)LOWORD(lParam); … … 4037 4502 if (infoPtr->nOldHit != nHit) 4038 4503 { 4039 4040 4041 if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem && 4042 4043 4044 4045 4046 4047 4504 /* Remove the effect of an old hot button if the button was enabled and was 4505 drawn with the hot button effect */ 4506 if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem && 4507 (infoPtr->buttons[infoPtr->nOldHit].fsState & TBSTATE_ENABLED)) 4508 { 4509 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit]; 4510 oldBtnPtr->bHot = FALSE; 4511 4512 InvalidateRect (hwnd, &oldBtnPtr->rect, 4048 4513 TOOLBAR_HasText(infoPtr, oldBtnPtr)); 4049 } 4050 4051 /* It's not a separator or in nowhere. It's a hot button. */ 4052 if (nHit >= 0) 4053 { 4054 btnPtr = &infoPtr->buttons[nHit]; 4055 btnPtr->bHot = TRUE; 4056 4057 infoPtr->nHotItem = nHit; 4058 4059 /* only enabled buttons show hot effect */ 4514 } 4515 4516 /* It's not a separator or in nowhere. It's a hot button. */ 4517 if (nHit >= 0) 4518 { 4519 btnPtr = &infoPtr->buttons[nHit]; 4520 4521 infoPtr->nHotItem = nHit; 4522 4523 /* only enabled buttons show hot effect */ 4060 4524 if(infoPtr->buttons[nHit].fsState & TBSTATE_ENABLED) 4061 4525 { 4526 btnPtr->bHot = TRUE; 4062 4527 InvalidateRect(hwnd, &btnPtr->rect, 4063 4528 TOOLBAR_HasText(infoPtr, btnPtr)); 4064 4529 } 4065 4530 4066 4531 } 4067 4532 4068 4533 if (infoPtr->bCaptured) { 4069 4070 4071 4534 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown]; 4535 if (infoPtr->nOldHit == infoPtr->nButtonDown) { 4536 btnPtr->fsState &= ~TBSTATE_PRESSED; 4072 4537 InvalidateRect(hwnd, &btnPtr->rect, TRUE); 4073 4074 4075 4538 } 4539 else if (nHit == infoPtr->nButtonDown) { 4540 btnPtr->fsState |= TBSTATE_PRESSED; 4076 4541 InvalidateRect(hwnd, &btnPtr->rect, TRUE); 4077 4078 4079 4542 } 4543 } 4544 infoPtr->nOldHit = nHit; 4080 4545 } 4081 4546 return 0; … … 4087 4552 { 4088 4553 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */ 4089 4554 return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam); 4090 4555 /* else */ 4091 /* 4556 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */ 4092 4557 } 4093 4558 … … 4097 4562 { 4098 4563 if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER)) 4099 4564 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE); 4100 4565 4101 4566 return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam); … … 4107 4572 { 4108 4573 TOOLBAR_INFO *infoPtr; 4574 LPCREATESTRUCTA cs = (LPCREATESTRUCTA)lParam; 4575 DWORD styleadd = 0; 4109 4576 4110 4577 /* allocate memory for info structure */ … … 4118 4585 if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) { 4119 4586 HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE); 4120 SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst); 4587 SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst); 4588 } 4589 4590 /* native control does: 4591 * Get a lot of colors and brushes 4592 * WM_NOTIFYFORMAT 4593 * SystemParametersInfoA(0x1f, 0x3c, adr1, 0) 4594 * CreateFontIndirectA(adr1) 4595 * CreateBitmap(0x27, 0x24, 1, 1, 0) 4596 * hdc = GetDC(toolbar) 4597 * GetSystemMetrics(0x48) 4598 * fnt2=CreateFontA(0xe, 0, 0, 0, 0x190, 0, 0, 0, 0, 2, 4599 * 0, 0, 0, 0, "MARLETT") 4600 * oldfnt = SelectObject(hdc, fnt2) 4601 * GetCharWidthA(hdc, 0x36, 0x36, adr2) 4602 * GetTextMetricsA(hdc, adr3) 4603 * SelectObject(hdc, oldfnt) 4604 * DeleteObject(fnt2) 4605 * ReleaseDC(hdc) 4606 * InvalidateRect(toolbar, 0, 1) 4607 * SetWindowLongA(toolbar, 0, addr) 4608 * SetWindowLongA(toolbar, -16, xxx) **sometimes** 4609 * WM_STYLECHANGING 4610 * CallWinEx old new 4611 * ie 1 0x56000a4c 0x46000a4c 0x56008a4d 4612 * ie 2 0x4600094c 0x4600094c 0x4600894d 4613 * ie 3 0x56000b4c 0x46000b4c 0x56008b4d 4614 * rebar 0x50008844 0x40008844 0x50008845 4615 * pager 0x50000844 0x40000844 0x50008845 4616 * IC35mgr 0x5400084e **nochange** 4617 * on entry to _NCCREATE 0x5400084e 4618 * rowlist 0x5400004e **nochange** 4619 * on entry to _NCCREATE 0x5400004e 4620 * 4621 */ 4622 4623 /* I think the code below is a bug, but it is the way that the native 4624 * controls seem to work. The effect is that if the user of TBSTYLE_FLAT 4625 * forgets to specify TBSTYLE_TRANSPARENT but does specify either 4626 * CCS_TOP or CCS_BOTTOM (_NOMOVEY and _TOP), then the control 4627 * does *not* set TBSTYLE_TRANSPARENT even though it should!!!! 4628 * Some how, the only cases of this seem to be MFC programs. 4629 * 4630 * Note also that the addition of _TRANSPARENT occurs *only* here. It 4631 * does not occur in the WM_STYLECHANGING routine. 4632 * (Guy Albertelli 9/2001) 4633 * 4634 */ 4635 if ((cs->style & TBSTYLE_FLAT) && !(cs->style & TBSTYLE_TRANSPARENT)) 4636 styleadd |= TBSTYLE_TRANSPARENT; 4637 if (!(cs->style & (CCS_TOP | CCS_NOMOVEY))) { 4638 styleadd |= CCS_TOP; /* default to top */ 4639 SetWindowLongA (hwnd, GWL_STYLE, cs->style | styleadd); 4121 4640 } 4122 4641 … … 4133 4652 4134 4653 if (dwStyle & WS_MINIMIZE) 4135 4654 return 0; /* Nothing to do */ 4136 4655 4137 4656 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam); 4138 4657 4139 4658 if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW))) 4140 4659 return 0; 4141 4660 4142 4661 if (!(dwStyle & CCS_NODIVIDER)) 4143 4662 { 4144 4145 4146 4147 4148 4663 GetWindowRect (hwnd, &rcWindow); 4664 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top); 4665 if( dwStyle & WS_BORDER ) 4666 OffsetRect (&rcWindow, 1, 1); 4667 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP); 4149 4668 } 4150 4669 … … 4161 4680 LPNMHDR lpnmh = (LPNMHDR)lParam; 4162 4681 4682 if (lpnmh->code == PGN_CALCSIZE) { 4683 LPNMPGCALCSIZE lppgc = (LPNMPGCALCSIZE)lParam; 4684 4685 if (lppgc->dwFlag == PGF_CALCWIDTH) { 4686 lppgc->iWidth = infoPtr->nWidth; 4687 TRACE("processed PGN_CALCSIZE, returning horz size = %d\n", 4688 infoPtr->nWidth); 4689 } 4690 else { 4691 lppgc->iHeight = infoPtr->nHeight; 4692 TRACE("processed PGN_CALCSIZE, returning vert size = %d\n", 4693 infoPtr->nHeight); 4694 } 4695 return 0; 4696 } 4697 4698 4163 4699 TRACE("passing WM_NOTIFY!\n"); 4164 4700 4165 4701 if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) { 4166 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,wParam, lParam);4702 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, wParam, lParam); 4167 4703 4168 4704 #if 0 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4705 if (lpnmh->code == TTN_GETDISPINFOA) { 4706 LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam; 4707 4708 FIXME("retrieving ASCII string\n"); 4709 4710 } 4711 else if (lpnmh->code == TTN_GETDISPINFOW) { 4712 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam; 4713 4714 FIXME("retrieving UNICODE string\n"); 4715 4716 } 4181 4717 #endif 4182 4718 } … … 4194 4730 4195 4731 /* fill ps.rcPaint with a default rect */ 4196 memcpy(&(ps.rcPaint), &(infoPtr->rcBound), sizeof(infoPtr->rcBound)); 4732 memcpy(&(ps.rcPaint), &(infoPtr->rcBound), sizeof(infoPtr->rcBound)); 4197 4733 4198 4734 hdc = wParam==0 ? BeginPaint(hwnd, &ps) : (HDC)wParam; 4199 4735 4200 4736 TRACE("psrect=(%d,%d)-(%d,%d)\n", 4201 4202 4737 ps.rcPaint.left, ps.rcPaint.top, 4738 ps.rcPaint.right, ps.rcPaint.bottom); 4203 4739 4204 4740 TOOLBAR_Refresh (hwnd, hdc, &ps); … … 4224 4760 /* Resize deadlock check */ 4225 4761 if (infoPtr->bAutoSize) { 4226 4227 4762 infoPtr->bAutoSize = FALSE; 4763 return 0; 4228 4764 } 4229 4765 … … 4240 4776 4241 4777 if (flags == SIZE_RESTORED) { 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4778 /* width and height don't apply */ 4779 parent = GetParent (hwnd); 4780 GetClientRect(parent, &parent_rect); 4781 x = parent_rect.left; 4782 y = parent_rect.top; 4783 4784 if (dwStyle & CCS_NORESIZE) { 4785 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE); 4786 4787 /* 4252 4788 * this sets the working width of the toolbar, and 4253 4789 * Calc Toolbar will not adjust it, only the height 4254 4790 */ 4255 infoPtr->nWidth = parent_rect.right - parent_rect.left; 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4791 infoPtr->nWidth = parent_rect.right - parent_rect.left; 4792 cy = infoPtr->nHeight; 4793 cx = infoPtr->nWidth; 4794 TOOLBAR_CalcToolbar (hwnd); 4795 infoPtr->nWidth = cx; 4796 infoPtr->nHeight = cy; 4797 } 4798 else { 4799 infoPtr->nWidth = parent_rect.right - parent_rect.left; 4800 TOOLBAR_CalcToolbar (hwnd); 4801 cy = infoPtr->nHeight; 4802 cx = infoPtr->nWidth; 4803 4804 if (dwStyle & CCS_NOMOVEY) { 4805 GetWindowRect(hwnd, &window_rect); 4806 ScreenToClient(parent, (LPPOINT)&window_rect.left); 4807 y = window_rect.top; 4808 } 4809 } 4810 4811 if (dwStyle & CCS_NOPARENTALIGN) { 4812 uPosFlags |= SWP_NOMOVE; 4813 cy = infoPtr->nHeight; 4814 cx = infoPtr->nWidth; 4815 } 4816 4817 if (!(dwStyle & CCS_NODIVIDER)) 4818 cy += GetSystemMetrics(SM_CYEDGE); 4819 4820 if (dwStyle & WS_BORDER) 4821 { 4822 x = y = 1; 4823 cy += GetSystemMetrics(SM_CYEDGE); 4824 cx += GetSystemMetrics(SM_CYEDGE); 4825 } 4826 4827 SetWindowPos (hwnd, 0, parent_rect.left - x, parent_rect.top - y, 4828 cx, cy, uPosFlags | SWP_NOZORDER); 4293 4829 } 4294 4830 return 0; … … 4302 4838 4303 4839 if (nType == GWL_STYLE) { 4304 if (lpStyle->styleNew & TBSTYLE_LIST) { 4305 infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE; 4306 } 4307 else { 4308 infoPtr->dwDTFlags = DT_CENTER; 4309 } 4840 if (lpStyle->styleNew & TBSTYLE_LIST) { 4841 infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE; 4842 } 4843 else { 4844 infoPtr->dwDTFlags = DT_CENTER; 4845 } 4846 infoPtr->bTransparent = (lpStyle->styleNew & TBSTYLE_TRANSPARENT); 4847 infoPtr->bBtnTranspnt = (lpStyle->styleNew & 4848 (TBSTYLE_FLAT | TBSTYLE_LIST)); 4849 TOOLBAR_CheckStyle (hwnd, lpStyle->styleNew); 4310 4850 } 4311 4851 … … 4322 4862 ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 4323 4863 { 4864 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n", 4865 hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam); 4866 4324 4867 if (!TOOLBAR_GetInfoPtr(hwnd) && (uMsg != WM_NCCREATE)) 4325 4868 return DefWindowProcA( hwnd, uMsg, wParam, lParam ); 4326 4869 4327 4870 switch (uMsg) 4328 4871 { 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 /* case TB_GETCOLORSCHEME:*/ /* 4.71 */4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 /* case TB_GETINSERTMARK:*/ /* 4.71 */4416 /* case TB_GETINSERTMARKCOLOR:*/ /* 4.71 */4417 4418 4419 4420 4421 4422 4423 4424 /* case TB_GETOBJECT:*/ /* 4.71 */4425 /* case TB_GETPADDING:*/ /* 4.71 */4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 /* case TB_INSERTMARKHITTEST:*/ /* 4.71 */4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 case TB_LOADIMAGES:/* 4.70 */4487 4488 4489 4490 /* case TB_MAPACCELERATORA:*/ /* 4.71 */4491 /* case TB_MAPACCELERATORW:*/ /* 4.71 */4492 /* case TB_MARKBUTTON:*/ /* 4.71 */4493 /* case TB_MOVEBUTTON:*/ /* 4.71 */4494 4495 4496 4497 4498 /* 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 /* case TB_SETCOLORSCHEME:*/ /* 4.71 */4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 /* case TB_SETINSERTMARK:*/ /* 4.71 */4551 4552 4553 4554 4555 4556 4557 4558 /* case TB_SETPADDING:*/ /* 4.71 */4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 /* 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 /* 4597 /* 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 return TOOLBAR_MouseLeave (hwnd, wParam, lParam); 4613 4614 4615 return TOOLBAR_CaptureChanged(hwnd); 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 /* 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 /* 4644 4645 /* 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4872 case TB_ADDBITMAP: 4873 return TOOLBAR_AddBitmap (hwnd, wParam, lParam); 4874 4875 case TB_ADDBUTTONSA: 4876 return TOOLBAR_AddButtonsA (hwnd, wParam, lParam); 4877 4878 case TB_ADDBUTTONSW: 4879 return TOOLBAR_AddButtonsW (hwnd, wParam, lParam); 4880 4881 case TB_ADDSTRINGA: 4882 return TOOLBAR_AddStringA (hwnd, wParam, lParam); 4883 4884 case TB_ADDSTRINGW: 4885 return TOOLBAR_AddStringW (hwnd, wParam, lParam); 4886 4887 case TB_AUTOSIZE: 4888 return TOOLBAR_AutoSize (hwnd); 4889 4890 case TB_BUTTONCOUNT: 4891 return TOOLBAR_ButtonCount (hwnd, wParam, lParam); 4892 4893 case TB_BUTTONSTRUCTSIZE: 4894 return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam); 4895 4896 case TB_CHANGEBITMAP: 4897 return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam); 4898 4899 case TB_CHECKBUTTON: 4900 return TOOLBAR_CheckButton (hwnd, wParam, lParam); 4901 4902 case TB_COMMANDTOINDEX: 4903 return TOOLBAR_CommandToIndex (hwnd, wParam, lParam); 4904 4905 case TB_CUSTOMIZE: 4906 return TOOLBAR_Customize (hwnd); 4907 4908 case TB_DELETEBUTTON: 4909 return TOOLBAR_DeleteButton (hwnd, wParam, lParam); 4910 4911 case TB_ENABLEBUTTON: 4912 return TOOLBAR_EnableButton (hwnd, wParam, lParam); 4913 4914 case TB_GETANCHORHIGHLIGHT: 4915 return TOOLBAR_GetAnchorHighlight (hwnd); 4916 4917 case TB_GETBITMAP: 4918 return TOOLBAR_GetBitmap (hwnd, wParam, lParam); 4919 4920 case TB_GETBITMAPFLAGS: 4921 return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam); 4922 4923 case TB_GETBUTTON: 4924 return TOOLBAR_GetButton (hwnd, wParam, lParam); 4925 4926 case TB_GETBUTTONINFOA: 4927 return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam); 4928 4929 case TB_GETBUTTONINFOW: 4930 return TOOLBAR_GetButtonInfoW (hwnd, wParam, lParam); 4931 4932 case TB_GETBUTTONSIZE: 4933 return TOOLBAR_GetButtonSize (hwnd); 4934 4935 case TB_GETBUTTONTEXTA: 4936 return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam); 4937 4938 case TB_GETBUTTONTEXTW: 4939 return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam); 4940 4941 /* case TB_GETCOLORSCHEME: */ /* 4.71 */ 4942 4943 case TB_GETDISABLEDIMAGELIST: 4944 return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam); 4945 4946 case TB_GETEXTENDEDSTYLE: 4947 return TOOLBAR_GetExtendedStyle (hwnd); 4948 4949 case TB_GETHOTIMAGELIST: 4950 return TOOLBAR_GetHotImageList (hwnd, wParam, lParam); 4951 4952 case TB_GETHOTITEM: 4953 return TOOLBAR_GetHotItem (hwnd); 4954 4955 case TB_GETIMAGELIST: 4956 return TOOLBAR_GetImageList (hwnd, wParam, lParam); 4957 4958 /* case TB_GETINSERTMARK: */ /* 4.71 */ 4959 /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */ 4960 4961 case TB_GETITEMRECT: 4962 return TOOLBAR_GetItemRect (hwnd, wParam, lParam); 4963 4964 case TB_GETMAXSIZE: 4965 return TOOLBAR_GetMaxSize (hwnd, wParam, lParam); 4966 4967 /* case TB_GETOBJECT: */ /* 4.71 */ 4968 /* case TB_GETPADDING: */ /* 4.71 */ 4969 4970 case TB_GETRECT: 4971 return TOOLBAR_GetRect (hwnd, wParam, lParam); 4972 4973 case TB_GETROWS: 4974 return TOOLBAR_GetRows (hwnd, wParam, lParam); 4975 4976 case TB_GETSTATE: 4977 return TOOLBAR_GetState (hwnd, wParam, lParam); 4978 4979 case TB_GETSTYLE: 4980 return TOOLBAR_GetStyle (hwnd, wParam, lParam); 4981 4982 case TB_GETTEXTROWS: 4983 return TOOLBAR_GetTextRows (hwnd, wParam, lParam); 4984 4985 case TB_GETTOOLTIPS: 4986 return TOOLBAR_GetToolTips (hwnd, wParam, lParam); 4987 4988 case TB_GETUNICODEFORMAT: 4989 return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam); 4990 4991 case CCM_GETVERSION: 4992 return TOOLBAR_GetVersion (hwnd); 4993 4994 case TB_HIDEBUTTON: 4995 return TOOLBAR_HideButton (hwnd, wParam, lParam); 4996 4997 case TB_HITTEST: 4998 return TOOLBAR_HitTest (hwnd, wParam, lParam); 4999 5000 case TB_INDETERMINATE: 5001 return TOOLBAR_Indeterminate (hwnd, wParam, lParam); 5002 5003 case TB_INSERTBUTTONA: 5004 return TOOLBAR_InsertButtonA (hwnd, wParam, lParam); 5005 5006 case TB_INSERTBUTTONW: 5007 return TOOLBAR_InsertButtonW (hwnd, wParam, lParam); 5008 5009 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */ 5010 5011 case TB_ISBUTTONCHECKED: 5012 return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam); 5013 5014 case TB_ISBUTTONENABLED: 5015 return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam); 5016 5017 case TB_ISBUTTONHIDDEN: 5018 return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam); 5019 5020 case TB_ISBUTTONHIGHLIGHTED: 5021 return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam); 5022 5023 case TB_ISBUTTONINDETERMINATE: 5024 return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam); 5025 5026 case TB_ISBUTTONPRESSED: 5027 return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam); 5028 5029 case TB_LOADIMAGES: /* 4.70 */ 5030 FIXME("missing standard imagelists\n"); 5031 return 0; 5032 5033 /* case TB_MAPACCELERATORA: */ /* 4.71 */ 5034 /* case TB_MAPACCELERATORW: */ /* 4.71 */ 5035 /* case TB_MARKBUTTON: */ /* 4.71 */ 5036 /* case TB_MOVEBUTTON: */ /* 4.71 */ 5037 5038 case TB_PRESSBUTTON: 5039 return TOOLBAR_PressButton (hwnd, wParam, lParam); 5040 5041 /* case TB_REPLACEBITMAP: */ 5042 5043 case TB_SAVERESTOREA: 5044 return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam); 5045 5046 case TB_SAVERESTOREW: 5047 return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam); 5048 5049 case TB_SETANCHORHIGHLIGHT: 5050 return TOOLBAR_SetAnchorHighlight (hwnd, wParam); 5051 5052 case TB_SETBITMAPSIZE: 5053 return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam); 5054 5055 case TB_SETBUTTONINFOA: 5056 return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam); 5057 5058 case TB_SETBUTTONINFOW: 5059 return TOOLBAR_SetButtonInfoW (hwnd, wParam, lParam); 5060 5061 case TB_SETBUTTONSIZE: 5062 return TOOLBAR_SetButtonSize (hwnd, wParam, lParam); 5063 5064 case TB_SETBUTTONWIDTH: 5065 return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam); 5066 5067 case TB_SETCMDID: 5068 return TOOLBAR_SetCmdId (hwnd, wParam, lParam); 5069 5070 /* case TB_SETCOLORSCHEME: */ /* 4.71 */ 5071 5072 case TB_SETDISABLEDIMAGELIST: 5073 return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam); 5074 5075 case TB_SETDRAWTEXTFLAGS: 5076 return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam); 5077 5078 case TB_SETEXTENDEDSTYLE: 5079 return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam); 5080 5081 case TB_SETHOTIMAGELIST: 5082 return TOOLBAR_SetHotImageList (hwnd, wParam, lParam); 5083 5084 case TB_SETHOTITEM: 5085 return TOOLBAR_SetHotItem (hwnd, wParam); 5086 5087 case TB_SETIMAGELIST: 5088 return TOOLBAR_SetImageList (hwnd, wParam, lParam); 5089 5090 case TB_SETINDENT: 5091 return TOOLBAR_SetIndent (hwnd, wParam, lParam); 5092 5093 /* case TB_SETINSERTMARK: */ /* 4.71 */ 5094 5095 case TB_SETINSERTMARKCOLOR: 5096 return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam); 5097 5098 case TB_SETMAXTEXTROWS: 5099 return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam); 5100 5101 /* case TB_SETPADDING: */ /* 4.71 */ 5102 5103 case TB_SETPARENT: 5104 return TOOLBAR_SetParent (hwnd, wParam, lParam); 5105 5106 case TB_SETROWS: 5107 return TOOLBAR_SetRows (hwnd, wParam, lParam); 5108 5109 case TB_SETSTATE: 5110 return TOOLBAR_SetState (hwnd, wParam, lParam); 5111 5112 case TB_SETSTYLE: 5113 return TOOLBAR_SetStyle (hwnd, wParam, lParam); 5114 5115 case TB_SETTOOLTIPS: 5116 return TOOLBAR_SetToolTips (hwnd, wParam, lParam); 5117 5118 case TB_SETUNICODEFORMAT: 5119 return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam); 5120 5121 case CCM_SETVERSION: 5122 return TOOLBAR_SetVersion (hwnd, (INT)wParam); 5123 5124 5125 /* case WM_CHAR: */ 5126 5127 case WM_CREATE: 5128 return TOOLBAR_Create (hwnd, wParam, lParam); 5129 5130 case WM_DESTROY: 5131 return TOOLBAR_Destroy (hwnd, wParam, lParam); 5132 5133 case WM_ERASEBKGND: 5134 return TOOLBAR_EraseBackground (hwnd, wParam, lParam); 5135 5136 case WM_GETFONT: 5137 return TOOLBAR_GetFont (hwnd, wParam, lParam); 5138 5139 /* case WM_KEYDOWN: */ 5140 /* case WM_KILLFOCUS: */ 5141 5142 case WM_LBUTTONDBLCLK: 5143 return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam); 5144 5145 case WM_LBUTTONDOWN: 5146 return TOOLBAR_LButtonDown (hwnd, wParam, lParam); 5147 5148 case WM_LBUTTONUP: 5149 return TOOLBAR_LButtonUp (hwnd, wParam, lParam); 5150 5151 case WM_MOUSEMOVE: 5152 return TOOLBAR_MouseMove (hwnd, wParam, lParam); 5153 5154 case WM_MOUSELEAVE: 5155 return TOOLBAR_MouseLeave (hwnd, wParam, lParam); 5156 5157 case WM_CAPTURECHANGED: 5158 return TOOLBAR_CaptureChanged(hwnd); 5159 5160 case WM_NCACTIVATE: 5161 return TOOLBAR_NCActivate (hwnd, wParam, lParam); 5162 5163 case WM_NCCALCSIZE: 5164 return TOOLBAR_NCCalcSize (hwnd, wParam, lParam); 5165 5166 case WM_NCCREATE: 5167 return TOOLBAR_NCCreate (hwnd, wParam, lParam); 5168 5169 case WM_NCPAINT: 5170 return TOOLBAR_NCPaint (hwnd, wParam, lParam); 5171 5172 case WM_NOTIFY: 5173 return TOOLBAR_Notify (hwnd, wParam, lParam); 5174 5175 /* case WM_NOTIFYFORMAT: */ 5176 5177 case WM_PAINT: 5178 return TOOLBAR_Paint (hwnd, wParam); 5179 5180 case WM_SIZE: 5181 return TOOLBAR_Size (hwnd, wParam, lParam); 5182 5183 case WM_STYLECHANGED: 5184 return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam); 5185 5186 /* case WM_SYSCOLORCHANGE: */ 5187 5188 /* case WM_WININICHANGE: */ 5189 5190 case WM_CHARTOITEM: 5191 case WM_COMMAND: 5192 case WM_DRAWITEM: 5193 case WM_MEASUREITEM: 5194 case WM_VKEYTOITEM: 5195 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam); 5196 5197 default: 5198 if (uMsg >= WM_USER) 5199 ERR("unknown msg %04x wp=%08x lp=%08lx\n", 5200 uMsg, wParam, lParam); 5201 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 4659 5202 } 4660 5203 return 0; … … 4675 5218 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); 4676 5219 wndClass.lpszClassName = TOOLBARCLASSNAMEA; 4677 5220 4678 5221 RegisterClassA (&wndClass); 4679 5222 } … … 4685 5228 UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL); 4686 5229 } 4687 -
trunk/src/comctl32/treeview.cpp
r4019 r6705 1 /* $Id: treeview.cpp,v 1.1 8 2000-08-15 17:04:39 cbratschiExp $ */1 /* $Id: treeview.cpp,v 1.19 2001-09-15 09:13:31 sandervl Exp $ */ 2 2 /* Treeview control 3 3 * … … 1335 1335 if (oldSelection == infoPtr->selectedItem) 1336 1336 { 1337 #ifdef __WIN32OS2__ 1338 //Crash in UltraEdit when opening file, because the old selected 1339 //item is already freed 1340 if (oldSelection == (TREEVIEW_ITEM *)lParam) { 1341 infoPtr->selectedItem = 0; 1342 } 1343 #endif 1337 1344 if (TREEVIEW_ValidItem(infoPtr, newSelection)) 1338 1345 TREEVIEW_DoSelectItem(infoPtr, TVGN_CARET, newSelection, TVC_UNKNOWN);
Note:
See TracChangeset
for help on using the changeset viewer.