Changeset 236 for trunk/src/comctl32/tab.c
- Timestamp:
- Jun 28, 1999, 5:46:28 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/tab.c
r164 r236 1 /* $Id: tab.c,v 1. 5 1999-06-23 19:45:01 achimhaExp $ */1 /* $Id: tab.c,v 1.6 1999-06-28 15:46:26 cbratschi Exp $ */ 2 2 /* 3 3 * Tab control … … 7 7 * Copyright 1999 Francis Beaudet 8 8 * Copyright 1999 Achim Hasenmueller 9 * Copyright 1999 Christoph Bratschi 9 10 * 10 11 * TODO: … … 83 84 { 84 85 TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); 85 86 86 87 return infoPtr->iSelected; 87 88 } … … 91 92 { 92 93 TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); 93 94 94 95 return infoPtr->uFocus; 95 96 } … … 111 112 INT iItem=(INT) wParam; 112 113 INT prevItem; 113 114 114 115 prevItem=-1; 115 116 if ((iItem >= 0) && (iItem < infoPtr->uNumItem)) { … … 125 126 TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); 126 127 INT iItem=(INT) wParam; 127 128 128 129 if ((iItem < 0) || (iItem > infoPtr->uNumItem)) return 0; 129 130 … … 131 132 if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BUTTONS) { 132 133 // FIXME (tab,"Should set input focus\n"); 133 } else { 134 } else { 134 135 if (infoPtr->iSelected != iItem) { 135 136 if (TAB_SendSimpleNotify(hwnd, TCN_SELCHANGING)!=TRUE) { … … 137 138 TAB_SendSimpleNotify(hwnd, TCN_SELCHANGE); 138 139 139 140 140 TAB_EnsureSelectionVisible(hwnd, infoPtr); 141 TAB_InvalidateTabArea(hwnd, infoPtr); 141 142 } 142 143 } … … 176 177 * Perform a sanity check and a trivial visibility check. 177 178 */ 178 if ( (infoPtr->uNumItem <=0) ||179 if ( (infoPtr->uNumItem == 0) || 179 180 (itemIndex >= infoPtr->uNumItem) || 180 181 (itemIndex < infoPtr->leftmostVisible) ) … … 187 188 if (itemRect==NULL) 188 189 itemRect = &tmpItemRect; 189 190 190 191 /* 191 192 * Retrieve the unmodified item rect. … … 194 195 195 196 /* 196 * "scroll" it to make sure the item at the very left of the 197 * "scroll" it to make sure the item at the very left of the 197 198 * tab control is the leftmost visible tab. 198 199 */ 199 200 OffsetRect(itemRect, 200 -infoPtr->items[infoPtr->leftmostVisible].rect.left, 201 202 203 /* 204 * Move the rectangle so the first item is slightly offset from 201 -infoPtr->items[infoPtr->leftmostVisible].rect.left, 202 0); 203 204 /* 205 * Move the rectangle so the first item is slightly offset from 205 206 * the left of the tab control. 206 207 */ 207 208 OffsetRect(itemRect, 208 209 209 SELECTED_TAB_OFFSET, 210 0); 210 211 211 212 … … 225 226 * If it also a bit higher. 226 227 */ 227 if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 228 { 228 if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 229 { 229 230 selectedRect->top -=2; /* the border is thicker on the bottom */ 230 231 selectedRect->bottom +=SELECTED_TAB_OFFSET; … … 242 243 static BOOL TAB_GetItemRect(HWND hwnd, WPARAM wParam, LPARAM lParam) 243 244 { 244 return TAB_InternalGetItemRect(hwnd, TAB_GetInfoPtr(hwnd), (INT)wParam, 245 return TAB_InternalGetItemRect(hwnd, TAB_GetInfoPtr(hwnd), (INT)wParam, 245 246 (LPRECT)lParam, (LPRECT)NULL); 246 247 } … … 252 253 */ 253 254 static LRESULT TAB_KeyUp( 254 HWND hwnd, 255 HWND hwnd, 255 256 WPARAM keyCode) 256 257 { … … 267 268 break; 268 269 } 269 270 270 271 /* 271 272 * If we changed to a valid item, change the selection … … 296 297 */ 297 298 static LRESULT TAB_FocusChanging( 298 HWND hwnd, 299 UINT uMsg, 300 WPARAM wParam, 299 HWND hwnd, 300 UINT uMsg, 301 WPARAM wParam, 301 302 LPARAM lParam) 302 303 { … … 309 310 */ 310 311 isVisible = TAB_InternalGetItemRect(hwnd, 311 312 313 314 315 312 infoPtr, 313 infoPtr->uFocus, 314 NULL, 315 &selectedRect); 316 316 317 /* 317 318 * If the rectangle is not completely invisible, invalidate that … … 331 332 static HWND TAB_InternalHitTest ( 332 333 HWND hwnd, 333 TAB_INFO* infoPtr, 334 POINT pt, 334 TAB_INFO* infoPtr, 335 POINT pt, 335 336 UINT* flags) 336 337 337 338 { 338 339 RECT rect; 339 int iCount; 340 341 for (iCount = 0; iCount < infoPtr->uNumItem; iCount++) 340 int iCount; 341 342 for (iCount = 0; iCount < infoPtr->uNumItem; iCount++) 342 343 { 343 344 TAB_InternalGetItemRect(hwnd, 344 infoPtr, 345 346 347 345 infoPtr, 346 iCount, 347 &rect, 348 NULL); 348 349 349 350 if (PtInRect (&rect, pt)) … … 363 364 TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); 364 365 LPTCHITTESTINFO lptest=(LPTCHITTESTINFO) lParam; 365 366 366 367 return TAB_InternalHitTest (hwnd, infoPtr,lptest->pt,&lptest->flags); 367 368 } … … 375 376 if (infoPtr->hwndToolTip) 376 377 TAB_RelayEvent (infoPtr->hwndToolTip, hwnd, 377 378 WM_LBUTTONDOWN, wParam, lParam); 378 379 379 380 if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_FOCUSONBUTTONDOWN ) { … … 389 390 POINT pt; 390 391 INT newItem,dummy; 391 392 392 393 if (infoPtr->hwndToolTip) 393 394 TAB_RelayEvent (infoPtr->hwndToolTip, hwnd, 394 395 395 WM_LBUTTONDOWN, wParam, lParam); 396 396 397 pt.x = (INT)LOWORD(lParam); 397 398 pt.y = (INT)HIWORD(lParam); 398 399 399 400 newItem=TAB_InternalHitTest (hwnd, infoPtr,pt,(unsigned int*)&dummy); 400 401 401 402 // TRACE(tab, "On Tab, item %d\n", newItem); 402 403 403 404 if ( (newItem!=-1) && 404 405 (infoPtr->iSelected != newItem) ) … … 434 435 if (infoPtr->hwndToolTip) 435 436 TAB_RelayEvent (infoPtr->hwndToolTip, hwnd, 436 437 WM_LBUTTONDOWN, wParam, lParam); 437 438 return 0; 438 439 } … … 445 446 */ 446 447 static LRESULT TAB_AdjustRect( 447 HWND hwnd, 448 WPARAM fLarger, 448 HWND hwnd, 449 WPARAM fLarger, 449 450 LPRECT prc) 450 451 { 451 452 TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); 452 453 453 if (fLarger) 454 if (fLarger) 454 455 { 455 456 /* … … 460 461 * Add the height of the tabs. 461 462 */ 462 if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 463 if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 463 464 prc->bottom += infoPtr->tabHeight; 464 465 else … … 475 476 InflateRect(prc, CONTROL_BORDER_SIZEX, CONTROL_BORDER_SIZEX); 476 477 } 477 else 478 else 478 479 { 479 480 /* 480 481 * Go from window rectangle. 481 482 */ 482 483 483 484 /* 484 485 * Deflate the rectangle for the border … … 494 495 * Remove the height of the tabs. 495 496 */ 496 if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 497 if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 497 498 prc->bottom -= infoPtr->tabHeight; 498 499 else … … 500 501 501 502 } 502 503 503 504 return 0; 504 505 } … … 511 512 */ 512 513 static LRESULT TAB_OnHScroll( 513 HWND hwnd, 514 HWND hwnd, 514 515 int nScrollCode, 515 516 int nPos, … … 543 544 * TAB_SetupScroling 544 545 * 545 * This method will check the current scrolling state and make sure the 546 * This method will check the current scrolling state and make sure the 546 547 * scrolling control is displayed (or not). 547 548 */ … … 561 562 controlPos.left = controlPos.right - 2*GetSystemMetrics(SM_CXHSCROLL); 562 563 563 if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 564 if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 564 565 { 565 566 controlPos.top = clientRect->bottom - infoPtr->tabHeight; … … 583 584 */ 584 585 infoPtr->hwndUpDown = CreateWindowA("ScrollBar", 585 586 587 588 589 590 591 (HMENU)NULL, 592 (HINSTANCE)NULL, 593 NULL); 586 "", 587 WS_VISIBLE | WS_CHILD | WS_OVERLAPPED | SBS_HORZ, 588 controlPos.left, controlPos.top, 589 controlPos.right - controlPos.left, 590 controlPos.bottom - controlPos.top, 591 hwnd, 592 (HMENU)NULL, 593 (HINSTANCE)NULL, 594 NULL); 594 595 } 595 596 else 596 597 { 597 SetWindowPos(infoPtr->hwndUpDown, 598 599 600 601 602 SWP_SHOWWINDOW | SWP_NOZORDER); 598 SetWindowPos(infoPtr->hwndUpDown, 599 (HWND)NULL, 600 controlPos.left, controlPos.top, 601 controlPos.right - controlPos.left, 602 controlPos.bottom - controlPos.top, 603 SWP_SHOWWINDOW | SWP_NOZORDER); 603 604 } 604 605 } … … 641 642 * a font. 642 643 */ 643 hdc = GetDC(hwnd); 644 644 hdc = GetDC(hwnd); 645 645 646 hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject (SYSTEM_FONT); 646 647 hOldFont = SelectObject (hdc, hFont); … … 651 652 */ 652 653 GetClientRect(hwnd, &clientRect); 653 654 654 655 /* 655 656 * The leftmost item will be "0" aligned … … 665 666 666 667 /* 667 * Make sure there is enough space for the letters + growing the 668 * selected item + extra space for the selected item. 669 */ 670 infoPtr->tabHeight = fontMetrics.tmHeight + 2*VERTICAL_ITEM_PADDING + 668 * Make sure there is enough space for the letters + growing the 669 * selected item + extra space for the selected item. 670 */ 671 infoPtr->tabHeight = fontMetrics.tmHeight + 2*VERTICAL_ITEM_PADDING + 671 672 SELECTED_TAB_OFFSET; 672 673 } … … 677 678 * Calculate the vertical position of the tab 678 679 */ 679 if (lStyle & TCS_BOTTOM) 680 { 681 infoPtr->items[curItem].rect.bottom = clientRect.bottom - 680 if (lStyle & TCS_BOTTOM) 681 { 682 infoPtr->items[curItem].rect.bottom = clientRect.bottom - 682 683 SELECTED_TAB_OFFSET; 683 infoPtr->items[curItem].rect.top = clientRect.bottom - 684 infoPtr->items[curItem].rect.top = clientRect.bottom - 684 685 infoPtr->tabHeight; 685 686 } 686 else 687 { 688 infoPtr->items[curItem].rect.top = clientRect.top + 687 else 688 { 689 infoPtr->items[curItem].rect.top = clientRect.top + 689 690 SELECTED_TAB_OFFSET; 690 infoPtr->items[curItem].rect.bottom = clientRect.top + 691 infoPtr->items[curItem].rect.bottom = clientRect.top + 691 692 infoPtr->tabHeight; 692 693 } … … 708 709 * Calculate how wide the tab is depending on the text it contains 709 710 */ 710 GetTextExtentPoint32A(hdc, infoPtr->items[curItem].pszText, 711 GetTextExtentPoint32A(hdc, infoPtr->items[curItem].pszText, 711 712 lstrlenA(infoPtr->items[curItem].pszText), &size); 712 713 713 714 infoPtr->items[curItem].rect.right = infoPtr->items[curItem].rect.left + 714 715 size.cx + 2*HORIZONTAL_ITEM_PADDING; … … 716 717 717 718 // TRACE(tab, "TextSize: %i\n ", size.cx); 718 // TRACE(tab, "Rect: T %i, L %i, B %i, R %i\n", 719 // 720 // 721 // 722 // infoPtr->items[curItem].rect.right);719 // TRACE(tab, "Rect: T %i, L %i, B %i, R %i\n", 720 // infoPtr->items[curItem].rect.top, 721 // infoPtr->items[curItem].rect.left, 722 // infoPtr->items[curItem].rect.bottom, 723 // infoPtr->items[curItem].rect.right); 723 724 724 725 /* … … 735 736 * Check if we need a scrolling control. 736 737 */ 737 infoPtr->needsScrolling = (curItemLeftPos + (2*SELECTED_TAB_OFFSET) > 738 infoPtr->needsScrolling = (curItemLeftPos + (2*SELECTED_TAB_OFFSET) > 738 739 clientRect.right); 739 740 740 TAB_SetupScrolling(hwnd, infoPtr, &clientRect); 741 741 TAB_SetupScrolling(hwnd, infoPtr, &clientRect); 742 742 743 /* 743 744 * Cleanup … … 751 752 * 752 753 * This method is used to draw a single tab into the tab control. 753 */ 754 */ 754 755 static void TAB_DrawItem( 755 HWND hwnd, 756 HDC hdc, 756 HWND hwnd, 757 HDC hdc, 757 758 INT iItem) 758 759 { … … 768 769 */ 769 770 isVisible = TAB_InternalGetItemRect(hwnd, 770 771 772 773 771 infoPtr, 772 iItem, 773 &itemRect, 774 &selectedRect); 774 775 775 776 if (isVisible) 776 777 { 777 HBRUSH hbr = CreateSolidBrush (GetSysColor(COLOR_BTNFACE)); 778 HBRUSH hbr = CreateSolidBrush (GetSysColor(COLOR_BTNFACE)); 778 779 HPEN hwPen = GetSysColorPen (COLOR_3DHILIGHT); 779 780 HPEN hbPen = GetSysColorPen (COLOR_BTNSHADOW); … … 782 783 HPEN holdPen; 783 784 INT oldBkMode; 784 INT cx,cy; 785 INT cx,cy; 785 786 786 787 if (lStyle & TCS_BUTTONS) 787 788 { 788 /* 789 /* 789 790 * Get item rectangle. 790 791 */ … … 795 796 if (iItem == infoPtr->iSelected) 796 797 { 797 /* 798 * Background color. 798 /* 799 * Background color. 799 800 */ 800 801 if (!(lStyle & TCS_OWNERDRAWFIXED)) 801 hbr = CreateSolidBrush(GetSysColor(COLOR_3DHILIGHT)); 802 hbr = CreateSolidBrush(GetSysColor(COLOR_3DHILIGHT)); 802 803 803 804 /* 804 805 * Erase the background. 805 */ 806 */ 806 807 FillRect(hdc, &r, hbr); 807 808 … … 819 820 LineTo (hdc, r.right, r.bottom); 820 821 LineTo (hdc, r.right, r.top); 821 822 822 823 /* shadow */ 823 824 SelectObject(hdc, hbPen); … … 829 830 /* 830 831 * Erase the background. 831 */ 832 */ 832 833 FillRect(hdc, &r, hbr); 833 834 … … 836 837 LineTo (hdc, r.left, r.top); 837 838 LineTo (hdc, r.right, r.top); 838 839 839 840 /* shadow */ 840 841 SelectObject(hdc, hbPen); … … 845 846 else 846 847 { 847 /* 848 * Background color. 848 /* 849 * Background color. 849 850 */ 850 hbr = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); 851 hbr = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); 851 852 852 853 /* … … 861 862 /* 862 863 * Erase the background. 863 * This is necessary when drawing the selected item since it is larger 864 * than the others, it might overlap with stuff already drawn by the 864 * This is necessary when drawing the selected item since it is larger 865 * than the others, it might overlap with stuff already drawn by the 865 866 * other tabs 866 */ 867 */ 867 868 FillRect(hdc, &r, hbr); 868 869 … … 875 876 r.right--; 876 877 r.bottom--; 877 878 878 879 holdPen = SelectObject (hdc, hwPen); 879 880 880 if (lStyle & TCS_BOTTOM) 881 if (lStyle & TCS_BOTTOM) 881 882 { 882 883 /* highlight */ … … 884 885 LineTo (hdc, r.left, r.bottom - ROUND_CORNER_SIZE); 885 886 LineTo (hdc, r.left + ROUND_CORNER_SIZE, r.bottom); 886 887 887 888 /* shadow */ 888 889 SelectObject(hdc, hbPen); … … 891 892 LineTo (hdc, r.right, r.top); 892 893 } 893 else 894 else 894 895 { 895 896 /* highlight */ … … 898 899 LineTo (hdc, r.left + ROUND_CORNER_SIZE, r.top); 899 900 LineTo (hdc, r.right - ROUND_CORNER_SIZE, r.top); 900 901 901 902 /* shadow */ 902 903 SelectObject(hdc, hbPen); … … 905 906 } 906 907 } 907 908 908 909 /* 909 910 * Text pen 910 911 */ 911 SelectObject(hdc, hsdPen); 912 913 oldBkMode = SetBkMode(hdc, TRANSPARENT); 912 SelectObject(hdc, hsdPen); 913 914 oldBkMode = SetBkMode(hdc, TRANSPARENT); 914 915 SetTextColor (hdc, COLOR_BTNTEXT); 915 916 … … 922 923 * Draw the icon. 923 924 */ 924 if (infoPtr->himl) 925 { 926 ImageList_Draw (infoPtr->himl, iItem, hdc, 927 925 if (infoPtr->himl) 926 { 927 ImageList_Draw (infoPtr->himl, iItem, hdc, 928 r.left, r.top+1, ILD_NORMAL); 928 929 ImageList_GetIconSize (infoPtr->himl, &cx, &cy); 929 930 r.left+=cx; … … 934 935 */ 935 936 DrawTextA(hdc, 936 infoPtr->items[iItem].pszText, 937 938 &r, 939 937 infoPtr->items[iItem].pszText, 938 lstrlenA(infoPtr->items[iItem].pszText), 939 &r, 940 DT_LEFT|DT_SINGLELINE|DT_VCENTER); 940 941 941 942 /* … … 943 944 */ 944 945 if (((lStyle & TCS_FOCUSNEVER) == 0) && 945 946 946 (GetFocus() == hwnd) && 947 (iItem == infoPtr->uFocus) ) 947 948 { 948 949 InflateRect(&r, FOCUS_RECT_HOFFSET, FOCUS_RECT_VOFFSET); … … 951 952 952 953 MoveToEx (hdc, r.left, r.top, NULL); 953 LineTo (hdc, r.right-1, r.top); 954 LineTo (hdc, r.right-1, r.top); 954 955 LineTo (hdc, r.right-1, r.bottom -1); 955 956 LineTo (hdc, r.left, r.bottom -1); … … 970 971 * This method is used to draw the raised border around the tab control 971 972 * "content" area. 972 */ 973 */ 973 974 static void TAB_DrawBorder (HWND hwnd, HDC hdc) 974 975 { … … 985 986 * Adjust for the style 986 987 */ 987 if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 988 if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 988 989 { 989 990 rect.bottom -= infoPtr->tabHeight; … … 1003 1004 /* highlight */ 1004 1005 htmPen = SelectObject (hdc, hwPen); 1005 1006 1006 1007 MoveToEx (hdc, rect.left, rect.bottom, NULL); 1007 LineTo (hdc, rect.left, rect.top); 1008 LineTo (hdc, rect.left, rect.top); 1008 1009 LineTo (hdc, rect.right, rect.top); 1009 1010 … … 1026 1027 * 1027 1028 * This method repaints the tab control.. 1028 */ 1029 */ 1029 1030 static void TAB_Refresh (HWND hwnd, HDC hdc) 1030 1031 { … … 1040 1041 if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BUTTONS) 1041 1042 { 1042 for (i = 0; i < infoPtr->uNumItem; i++) 1043 { 1044 1043 for (i = 0; i < infoPtr->uNumItem; i++) 1044 { 1045 TAB_DrawItem (hwnd, hdc, i); 1045 1046 } 1046 1047 } … … 1050 1051 * Draw all the non selected item first. 1051 1052 */ 1052 for (i = 0; i < infoPtr->uNumItem; i++) 1053 for (i = 0; i < infoPtr->uNumItem; i++) 1053 1054 { 1054 1055 if (i != infoPtr->iSelected) 1055 1056 TAB_DrawItem (hwnd, hdc, i); 1056 1057 } 1057 1058 … … 1075 1076 { 1076 1077 TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); 1077 1078 1078 1079 infoPtr->DoRedraw=(BOOL) wParam; 1079 1080 return 0; … … 1081 1082 1082 1083 static LRESULT TAB_EraseBackground( 1083 HWND hwnd, 1084 HWND hwnd, 1084 1085 HDC givenDC) 1085 1086 { … … 1135 1136 GetClientRect(infoPtr->hwndUpDown, &scrollerRect); 1136 1137 visibleRect.right -= scrollerRect.right; 1137 1138 1138 1139 /* 1139 1140 * Get the rectangle for the item 1140 1141 */ 1141 1142 isVisible = TAB_InternalGetItemRect(hwnd, 1142 1143 1144 1145 1143 infoPtr, 1144 infoPtr->iSelected, 1145 NULL, 1146 &selectedRect); 1146 1147 1147 1148 /* … … 1163 1164 1164 1165 while ( (infoPtr->leftmostVisible < infoPtr->iSelected) && 1165 1166 !isVisible) 1166 1167 { 1167 1168 infoPtr->leftmostVisible++; … … 1171 1172 */ 1172 1173 isVisible = TAB_InternalGetItemRect(hwnd, 1173 1174 1175 1176 1174 infoPtr, 1175 infoPtr->iSelected, 1176 NULL, 1177 &selectedRect); 1177 1178 1178 1179 /* … … 1189 1190 pt2.x = selectedRect.right - 1; 1190 1191 pt2.y = selectedRect.bottom - 1; 1191 1192 1192 1193 isVisible = PtInRect(&visibleRect, pt1) && PtInRect(&visibleRect, pt2); 1193 1194 } … … 1210 1211 GetClientRect(hwnd, &clientRect); 1211 1212 1212 if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 1213 if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BOTTOM) 1213 1214 { 1214 1215 clientRect.top = clientRect.bottom - (infoPtr->tabHeight + 1); … … 1227 1228 HDC hdc; 1228 1229 PAINTSTRUCT ps; 1229 1230 1230 1231 hdc = wParam== 0 ? BeginPaint (hwnd, &ps) : (HDC)wParam; 1231 1232 TAB_Refresh (hwnd, hdc); 1232 1233 1233 1234 if(!wParam) 1234 1235 EndPaint (hwnd, &ps); … … 1239 1240 static LRESULT 1240 1241 TAB_InsertItem (HWND hwnd, WPARAM wParam, LPARAM lParam) 1241 { 1242 { 1242 1243 TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); 1243 1244 TCITEMA *pti; 1244 1245 INT iItem, len; 1245 1246 RECT rect; 1246 1247 1247 1248 GetClientRect (hwnd, &rect); 1248 1249 // TRACE(tab, "Rect: %x T %i, L %i, B %i, R %i\n", hwnd, 1249 // rect.top, rect.left, rect.bottom, rect.right); 1250 1250 // rect.top, rect.left, rect.bottom, rect.right); 1251 1251 1252 pti = (TCITEMA *)lParam; 1252 1253 iItem = (INT)wParam; 1253 1254 1254 1255 if (iItem < 0) return -1; 1255 1256 if (iItem > infoPtr->uNumItem) 1256 1257 iItem = infoPtr->uNumItem; 1257 1258 1258 1259 if (infoPtr->uNumItem == 0) { 1259 1260 infoPtr->items = COMCTL32_Alloc (sizeof (TAB_ITEM)); … … 1262 1263 else { 1263 1264 TAB_ITEM *oldItems = infoPtr->items; 1264 1265 1265 1266 infoPtr->uNumItem++; 1266 1267 infoPtr->items = COMCTL32_Alloc (sizeof (TAB_ITEM) * infoPtr->uNumItem); 1267 1268 1268 1269 /* pre insert copy */ 1269 1270 if (iItem > 0) { 1270 1271 memcpy (&infoPtr->items[0], &oldItems[0], 1271 1272 } 1273 1272 iItem * sizeof(TAB_ITEM)); 1273 } 1274 1274 1275 /* post insert copy */ 1275 1276 if (iItem < infoPtr->uNumItem - 1) { 1276 1277 memcpy (&infoPtr->items[iItem+1], &oldItems[iItem], 1277 1278 1279 } 1280 1278 (infoPtr->uNumItem - iItem - 1) * sizeof(TAB_ITEM)); 1279 1280 } 1281 1281 1282 COMCTL32_Free (oldItems); 1282 1283 } 1283 1284 1284 1285 infoPtr->items[iItem].mask = pti->mask; 1285 1286 if (pti->mask & TCIF_TEXT) { … … 1289 1290 infoPtr->items[iItem].cchTextMax = pti->cchTextMax; 1290 1291 } 1291 1292 1292 1293 if (pti->mask & TCIF_IMAGE) 1293 1294 infoPtr->items[iItem].iImage = pti->iImage; 1294 1295 1295 1296 if (pti->mask & TCIF_PARAM) 1296 1297 infoPtr->items[iItem].lParam = pti->lParam; 1297 1298 1298 1299 TAB_InvalidateTabArea(hwnd, infoPtr); 1299 1300 1300 1301 // TRACE(tab, "[%04x]: added item %d '%s'\n", 1301 // 1302 // hwnd, iItem, infoPtr->items[iItem].pszText); 1302 1303 1303 1304 TAB_SetItemBounds(hwnd); … … 1305 1306 } 1306 1307 1307 static LRESULT 1308 static LRESULT 1308 1309 TAB_SetItemSize (HWND hwnd, WPARAM wParam, LPARAM lParam) 1309 1310 { … … 1322 1323 } 1323 1324 1324 static LRESULT 1325 static LRESULT 1325 1326 TAB_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) 1326 1327 { 1327 1328 TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); 1328 TCITEMA *tabItem; 1329 TAB_ITEM *wineItem; 1329 TCITEMA *tabItem; 1330 TAB_ITEM *wineItem; 1330 1331 INT iItem,len; 1331 1332 … … 1337 1338 wineItem=& infoPtr->items[iItem]; 1338 1339 1339 if (tabItem->mask & TCIF_IMAGE) 1340 if (tabItem->mask & TCIF_IMAGE) 1340 1341 wineItem->iImage=tabItem->iImage; 1341 1342 1342 if (tabItem->mask & TCIF_PARAM) 1343 if (tabItem->mask & TCIF_PARAM) 1343 1344 wineItem->lParam=tabItem->lParam; 1344 1345 1345 // if (tabItem->mask & TCIF_RTLREADING) 1346 // if (tabItem->mask & TCIF_RTLREADING) 1346 1347 // FIXME (tab,"TCIF_RTLREADING\n"); 1347 1348 1348 if (tabItem->mask & TCIF_STATE) 1349 if (tabItem->mask & TCIF_STATE) 1349 1350 wineItem->dwState=tabItem->dwState; 1350 1351 1351 1352 if (tabItem->mask & TCIF_TEXT) { 1352 len =lstrlenA (tabItem->pszText);1353 if (len>wineItem->cchTextMax) 1354 wineItem->pszText = COMCTL32_ReAlloc (wineItem->pszText, len+1);1353 len = lstrlenA (tabItem->pszText); 1354 if (len>wineItem->cchTextMax) 1355 wineItem->pszText = COMCTL32_ReAlloc (wineItem->pszText, len+1); 1355 1356 lstrcpynA (wineItem->pszText, tabItem->pszText, len); 1356 1357 } … … 1359 1360 } 1360 1361 1361 static LRESULT 1362 static LRESULT 1362 1363 TAB_GetItemCount (HWND hwnd, WPARAM wParam, LPARAM lParam) 1363 1364 { … … 1368 1369 1369 1370 1370 static LRESULT 1371 static LRESULT 1371 1372 TAB_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) 1372 1373 { … … 1383 1384 wineItem=& infoPtr->items[iItem]; 1384 1385 1385 if (tabItem->mask & TCIF_IMAGE) 1386 if (tabItem->mask & TCIF_IMAGE) 1386 1387 tabItem->iImage=wineItem->iImage; 1387 1388 1388 if (tabItem->mask & TCIF_PARAM) 1389 if (tabItem->mask & TCIF_PARAM) 1389 1390 tabItem->lParam=wineItem->lParam; 1390 1391 1391 // if (tabItem->mask & TCIF_RTLREADING) 1392 // if (tabItem->mask & TCIF_RTLREADING) 1392 1393 // FIXME (tab, "TCIF_RTLREADING\n"); 1393 1394 1394 if (tabItem->mask & TCIF_STATE) 1395 if (tabItem->mask & TCIF_STATE) 1395 1396 tabItem->dwState=wineItem->dwState; 1396 1397 1397 if (tabItem->mask & TCIF_TEXT) 1398 if (tabItem->mask & TCIF_TEXT) 1398 1399 lstrcpynA (tabItem->pszText, wineItem->pszText, tabItem->cchTextMax); 1399 1400 … … 1401 1402 } 1402 1403 1403 static LRESULT 1404 static LRESULT 1404 1405 TAB_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam) 1405 1406 { … … 1411 1412 { 1412 1413 TAB_ITEM *oldItems = infoPtr->items; 1413 1414 1414 1415 infoPtr->uNumItem--; 1415 1416 infoPtr->items = COMCTL32_Alloc(sizeof (TAB_ITEM) * infoPtr->uNumItem); 1416 1417 if (iItem > 0) 1417 1418 if (iItem > 0) 1418 1419 memcpy(&infoPtr->items[0], &oldItems[0], iItem * sizeof(TAB_ITEM)); 1419 1420 if (iItem < infoPtr->uNumItem) 1420 1421 if (iItem < infoPtr->uNumItem) 1421 1422 memcpy(&infoPtr->items[iItem], &oldItems[iItem + 1], 1422 1423 (infoPtr->uNumItem - iItem) * sizeof(TAB_ITEM)); 1423 1424 1424 1425 COMCTL32_Free (oldItems); 1425 1426 … … 1429 1430 if ((iItem == infoPtr->iSelected) && (iItem > 0)) 1430 1431 infoPtr->iSelected--; 1431 1432 1432 1433 if (iItem < infoPtr->iSelected) 1433 1434 infoPtr->iSelected--; … … 1445 1446 } 1446 1447 1447 static LRESULT 1448 static LRESULT 1448 1449 TAB_DeleteAllItems (HWND hwnd, WPARAM wParam, LPARAM lParam) 1449 1450 { … … 1452 1453 COMCTL32_Free (infoPtr->items); 1453 1454 infoPtr->uNumItem=0; 1454 1455 1455 1456 return TRUE; 1456 1457 } … … 1471 1472 { 1472 1473 TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); 1473 1474 1474 1475 // TRACE (tab,"%x %lx\n",wParam, lParam); 1475 1476 1476 1477 infoPtr->hFont = (HFONT)wParam; 1477 1478 1478 1479 TAB_SetItemBounds(hwnd); 1479 1480 … … 1525 1526 cx=LOWORD (lParam); 1526 1527 cy=HIWORD (lParam); 1527 if (GetWindowLongA(hwnd, GWL_STYLE) & CCS_NORESIZE) 1528 if (GetWindowLongA(hwnd, GWL_STYLE) & CCS_NORESIZE) 1528 1529 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE); 1529 1530 … … 1548 1549 1549 1550 1550 static LRESULT 1551 static LRESULT 1551 1552 TAB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) 1552 1553 { … … 1559 1560 1560 1561 SetWindowLongA(hwnd, 0, (DWORD)infoPtr); 1561 1562 1562 1563 infoPtr->uNumItem = 0; 1563 1564 infoPtr->hFont = 0; 1564 1565 infoPtr->items = 0; 1565 1566 infoPtr->hcurArrow = LoadCursorA (0, IDC_ARROWA); 1566 infoPtr->iSelected = 0; 1567 infoPtr->uFocus = 0; 1567 infoPtr->iSelected = 0; 1568 infoPtr->uFocus = 0; 1568 1569 infoPtr->hwndToolTip = 0; 1569 1570 infoPtr->DoRedraw = TRUE; … … 1571 1572 infoPtr->hwndUpDown = 0; 1572 1573 infoPtr->leftmostVisible = 0; 1573 1574 // TRACE(tab, "Created tab control, hwnd [%04x]\n", hwnd); 1574 1575 // TRACE(tab, "Created tab control, hwnd [%04x]\n", hwnd); 1575 1576 if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_TOOLTIPS) { 1576 1577 /* Create tooltip control */ 1577 1578 infoPtr->hwndToolTip = 1578 1579 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0, 1579 1580 1581 1582 1580 CW_USEDEFAULT, CW_USEDEFAULT, 1581 CW_USEDEFAULT, CW_USEDEFAULT, 1582 hwnd, 0, 0, 0); 1583 1583 1584 /* Send NM_TOOLTIPSCREATED notification */ 1584 1585 if (infoPtr->hwndToolTip) { 1585 1586 NMTOOLTIPSCREATED nmttc; 1586 1587 1587 1588 nmttc.hdr.hwndFrom = hwnd; 1588 1589 nmttc.hdr.idFrom = GetWindowLongA(hwnd, GWL_ID); 1589 1590 nmttc.hdr.code = NM_TOOLTIPSCREATED; 1590 1591 nmttc.hwndToolTips = infoPtr->hwndToolTip; 1591 1592 1592 1593 SendMessageA (GetParent (hwnd), WM_NOTIFY, 1593 1594 } 1595 } 1596 1594 (WPARAM)GetWindowLongA(hwnd, GWL_ID), (LPARAM)&nmttc); 1595 } 1596 } 1597 1597 1598 /* 1598 1599 * We need to get text information so we need a DC and we need to select 1599 1600 * a font. 1600 1601 */ 1601 hdc = GetDC(hwnd); 1602 hdc = GetDC(hwnd); 1602 1603 hOldFont = SelectObject (hdc, GetStockObject (SYSTEM_FONT)); 1603 1604 … … 1608 1609 1609 1610 /* 1610 * Make sure there is enough space for the letters + growing the 1611 * selected item + extra space for the selected item. 1612 */ 1613 infoPtr->tabHeight = fontMetrics.tmHeight + 2*VERTICAL_ITEM_PADDING + 1611 * Make sure there is enough space for the letters + growing the 1612 * selected item + extra space for the selected item. 1613 */ 1614 infoPtr->tabHeight = fontMetrics.tmHeight + 2*VERTICAL_ITEM_PADDING + 1614 1615 SELECTED_TAB_OFFSET; 1615 1616 … … 1634 1635 for (iItem = 0; iItem < infoPtr->uNumItem; iItem++) { 1635 1636 if (infoPtr->items[iItem].pszText) 1636 1637 COMCTL32_Free (infoPtr->items[iItem].pszText); 1637 1638 } 1638 1639 COMCTL32_Free (infoPtr->items); 1639 1640 } 1640 1641 if (infoPtr->hwndToolTip) 1641 1642 if (infoPtr->hwndToolTip) 1642 1643 DestroyWindow (infoPtr->hwndToolTip); 1643 1644 1644 1645 if (infoPtr->hwndUpDown) 1645 1646 DestroyWindow(infoPtr->hwndUpDown); … … 1656 1657 case TCM_GETIMAGELIST: 1657 1658 return TAB_GetImageList (hwnd, wParam, lParam); 1658 1659 1659 1660 case TCM_SETIMAGELIST: 1660 1661 return TAB_SetImageList (hwnd, wParam, lParam); 1661 1662 1662 1663 case TCM_GETITEMCOUNT: 1663 1664 return TAB_GetItemCount (hwnd, wParam, lParam); 1664 1665 1665 1666 case TCM_GETITEMA: 1666 1667 return TAB_GetItemA (hwnd, wParam, lParam); 1667 1668 1668 1669 case TCM_GETITEMW: 1669 1670 // FIXME (tab, "Unimplemented msg TCM_GETITEMW\n"); 1670 1671 return 0; 1671 1672 1672 1673 case TCM_SETITEMA: 1673 1674 return TAB_SetItemA (hwnd, wParam, lParam); 1674 1675 1675 1676 case TCM_SETITEMW: 1676 1677 // FIXME (tab, "Unimplemented msg TCM_SETITEMW\n"); 1677 1678 return 0; 1678 1679 1679 1680 case TCM_DELETEITEM: 1680 1681 return TAB_DeleteItem (hwnd, wParam, lParam); 1681 1682 1682 1683 case TCM_DELETEALLITEMS: 1683 1684 return TAB_DeleteAllItems (hwnd, wParam, lParam); 1684 1685 1685 1686 case TCM_GETITEMRECT: 1686 1687 return TAB_GetItemRect (hwnd, wParam, lParam); 1687 1688 1688 1689 case TCM_GETCURSEL: 1689 1690 return TAB_GetCurSel (hwnd); 1690 1691 1691 1692 case TCM_HITTEST: 1692 1693 return TAB_HitTest (hwnd, wParam, lParam); 1693 1694 1694 1695 case TCM_SETCURSEL: 1695 1696 return TAB_SetCurSel (hwnd, wParam); 1696 1697 1697 1698 case TCM_INSERTITEMA: 1698 1699 return TAB_InsertItem (hwnd, wParam, lParam); 1699 1700 1700 1701 case TCM_INSERTITEMW: 1701 1702 // FIXME (tab, "Unimplemented msg TCM_INSERTITEM32W\n"); 1702 1703 return 0; 1703 1704 1704 1705 case TCM_SETITEMEXTRA: 1705 1706 // FIXME (tab, "Unimplemented msg TCM_SETITEMEXTRA\n"); 1706 1707 return 0; 1707 1708 1708 1709 case TCM_ADJUSTRECT: 1709 1710 return TAB_AdjustRect (hwnd, (BOOL)wParam, (LPRECT)lParam); 1710 1711 1711 1712 case TCM_SETITEMSIZE: 1712 1713 return TAB_SetItemSize (hwnd, wParam, lParam); 1713 1714 1714 1715 case TCM_REMOVEIMAGE: 1715 1716 // FIXME (tab, "Unimplemented msg TCM_REMOVEIMAGE\n"); 1716 1717 return 0; 1717 1718 1718 1719 case TCM_SETPADDING: 1719 1720 // FIXME (tab, "Unimplemented msg TCM_SETPADDING\n"); 1720 1721 return 0; 1721 1722 1722 1723 case TCM_GETROWCOUNT: 1723 1724 // FIXME (tab, "Unimplemented msg TCM_GETROWCOUNT\n"); … … 1735 1736 // FIXME (tab, "Unimplemented msg TCM_HIGHLIGHTITEM\n"); 1736 1737 return 0; 1737 1738 1738 1739 case TCM_GETTOOLTIPS: 1739 1740 return TAB_GetToolTips (hwnd, wParam, lParam); 1740 1741 1741 1742 case TCM_SETTOOLTIPS: 1742 1743 return TAB_SetToolTips (hwnd, wParam, lParam); 1743 1744 1744 1745 case TCM_GETCURFOCUS: 1745 1746 return TAB_GetCurFocus (hwnd); 1746 1747 1747 1748 case TCM_SETCURFOCUS: 1748 1749 return TAB_SetCurFocus (hwnd, wParam); 1749 1750 1750 1751 case TCM_SETMINTTABWIDTH: 1751 1752 // FIXME (tab, "Unimplemented msg TCM_SETMINTTABWIDTH\n"); 1752 1753 return 0; 1753 1754 1754 1755 case TCM_DESELECTALL: 1755 1756 // FIXME (tab, "Unimplemented msg TCM_DESELECTALL\n"); 1756 1757 return 0; 1757 1758 1758 1759 case TCM_GETEXTENDEDSTYLE: 1759 1760 // FIXME (tab, "Unimplemented msg TCM_GETEXTENDEDSTYLE\n"); … … 1766 1767 case WM_GETFONT: 1767 1768 return TAB_GetFont (hwnd, wParam, lParam); 1768 1769 1769 1770 case WM_SETFONT: 1770 1771 return TAB_SetFont (hwnd, wParam, lParam); 1771 1772 1772 1773 case WM_CREATE: 1773 1774 return TAB_Create (hwnd, wParam, lParam); 1774 1775 1775 1776 case WM_NCDESTROY: 1776 1777 return TAB_Destroy (hwnd, wParam, lParam); 1777 1778 1778 1779 case WM_GETDLGCODE: 1779 1780 return DLGC_WANTARROWS | DLGC_WANTCHARS; 1780 1781 1781 1782 case WM_LBUTTONDOWN: 1782 1783 return TAB_LButtonDown (hwnd, wParam, lParam); 1783 1784 1784 1785 case WM_LBUTTONUP: 1785 1786 return TAB_LButtonUp (hwnd, wParam, lParam); 1786 1787 1787 1788 case WM_RBUTTONDOWN: 1788 1789 return TAB_RButtonDown (hwnd, wParam, lParam); 1789 1790 1790 1791 case WM_MOUSEMOVE: 1791 1792 return TAB_MouseMove (hwnd, wParam, lParam); 1792 1793 1793 1794 case WM_ERASEBKGND: 1794 1795 return TAB_EraseBackground (hwnd, (HDC)wParam); … … 1799 1800 case WM_SIZE: 1800 1801 return TAB_Size (hwnd, wParam, lParam); 1801 1802 1802 1803 case WM_SETREDRAW: 1803 1804 return TAB_SetRedraw (hwnd, wParam); … … 1805 1806 case WM_HSCROLL: 1806 1807 return TAB_OnHScroll(hwnd, (int)LOWORD(wParam), (int)HIWORD(wParam), (HWND)lParam); 1807 1808 1808 1809 case WM_KILLFOCUS: 1809 1810 case WM_SETFOCUS: … … 1815 1816 default: 1816 1817 // if (uMsg >= WM_USER) 1817 // 1818 // 1818 // ERR (tab, "unknown msg %04x wp=%08x lp=%08lx\n", 1819 // uMsg, wParam, lParam); 1819 1820 return DefWindowProcA (hwnd, uMsg, wParam, lParam); 1820 1821 } … … 1839 1840 wndClass.hbrBackground = (HBRUSH)NULL; 1840 1841 wndClass.lpszClassName = WC_TABCONTROLA; 1841 1842 1842 1843 RegisterClassA (&wndClass); 1843 1844 }
Note:
See TracChangeset
for help on using the changeset viewer.