Changeset 10535 for trunk/src/comctl32/status.c
- Timestamp:
- Mar 17, 2004, 5:38:52 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/status.c
r8526 r10535 20 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 21 * 22 * FIXME: 23 * 1) Implement all CCS_* styles. 24 * 2) Should we hide grip if the parent window is maximized? 22 * NOTE 23 * 24 * This code was audited for completeness against the documented features 25 * of Comctl32.dll version 6.0 on Sep. 24, 2002, by Dimitrie O. Paun. 26 * 27 * Unless otherwise noted, we believe this code to be complete, as per 28 * the specification mentioned above. 29 * If you discover missing features, or bugs, please note them below. 30 * 31 * TODO: 32 * -- CCS_BOTTOM (default) 33 * -- CCS_LEFT 34 * -- CCS_NODEVIDER 35 * -- CCS_NOMOVEX 36 * -- CCS_NOMOVEY 37 * -- CCS_NOPARENTALIGN 38 * -- CCS_RIGHT 39 * -- CCS_TOP 40 * -- CCS_VERT (defaults to RIGHT) 25 41 */ 26 42 43 #include <stdarg.h> 27 44 #include <string.h> 28 45 46 #include "windef.h" 29 47 #include "winbase.h" 30 48 #include "wine/unicode.h" 49 #include "wingdi.h" 50 #include "winuser.h" 51 #include "winnls.h" 31 52 #include "commctrl.h" 53 #include "comctl32.h" 32 54 #include "wine/debug.h" 33 55 … … 46 68 { 47 69 HWND Self; 70 HWND Notify; 48 71 WORD numParts; 49 72 UINT height; … … 87 110 INT i; 88 111 89 TRACE("draw size grip % d,%d - %d,%d\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);112 TRACE("draw size grip %ld,%ld - %ld,%ld\n", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); 90 113 91 114 pt.x = lpRect->right - 1; … … 125 148 126 149 127 static void 150 static void 128 151 STATUSBAR_DrawPart (HDC hdc, const STATUSWINDOWPART *part, const STATUSWINDOWINFO *infoPtr, int itemID) 129 152 { … … 131 154 UINT border = BDR_SUNKENOUTER; 132 155 133 TRACE("part bound % d,%d - %d,%d\n", r.left, r.top, r.right, r.bottom);156 TRACE("part bound %ld,%ld - %ld,%ld\n", r.left, r.top, r.right, r.bottom); 134 157 if (part->style & SBT_POPOUT) 135 158 border = BDR_RAISEDOUTER; … … 138 161 139 162 DrawEdge(hdc, &r, border, BF_RECT|BF_ADJUST); 140 163 141 164 if (part->style & SBT_OWNERDRAW) 142 165 { … … 149 172 dis.rcItem = r; 150 173 dis.itemData = (INT)part->text; 151 SendMessageW (GetParent (infoPtr->Self), WM_DRAWITEM, 152 (WPARAM)dis.CtlID, (LPARAM)&dis); 153 } 174 SendMessageW (infoPtr->Notify, WM_DRAWITEM, (WPARAM)dis.CtlID, (LPARAM)&dis); 175 } 154 176 else 155 177 { … … 158 180 INT cy = r.bottom - r.top; 159 181 160 r.left += 2; 182 r.left += 2; 161 183 DrawIconEx (hdc, r.left, r.top, part->hIcon, cy, cy, 0, 0, DI_NORMAL); 162 184 r.left += cy; … … 257 279 /* get our window size */ 258 280 GetClientRect (infoPtr->Self, &rect); 259 TRACE("client wnd size is % d,%d - %d,%d\n", rect.left, rect.top, rect.right, rect.bottom);281 TRACE("client wnd size is %ld,%ld - %ld,%ld\n", rect.left, rect.top, rect.right, rect.bottom); 260 282 261 283 rect.top += VERT_BORDER; … … 540 562 RECT parent_rect; 541 563 542 GetClientRect ( GetParent (infoPtr->Self), &parent_rect);564 GetClientRect (infoPtr->Notify, &parent_rect); 543 565 infoPtr->height = height + VERT_BORDER; 544 566 width = parent_rect.right - parent_rect.left; … … 568 590 for (i = infoPtr->numParts ; i < oldNumParts; i++) { 569 591 if (infoPtr->parts[i].text && !(infoPtr->parts[i].style & SBT_OWNERDRAW)) 570 COMCTL32_Free (infoPtr->parts[i].text);592 Free (infoPtr->parts[i].text); 571 593 } 572 594 } else if (oldNumParts < infoPtr->numParts) { 573 tmp = COMCTL32_Alloc (sizeof(STATUSWINDOWPART) * infoPtr->numParts);595 tmp = Alloc (sizeof(STATUSWINDOWPART) * infoPtr->numParts); 574 596 if (!tmp) return FALSE; 575 597 for (i = 0; i < oldNumParts; i++) { … … 577 599 } 578 600 if (infoPtr->parts) 579 COMCTL32_Free (infoPtr->parts);601 Free (infoPtr->parts); 580 602 infoPtr->parts = tmp; 581 603 } … … 587 609 return TRUE; 588 610 } 589 611 590 612 for (i = 0; i < infoPtr->numParts; i++) 591 613 infoPtr->parts[i].x = parts[i]; … … 626 648 627 649 static BOOL 628 STATUSBAR_SetTextT (STATUSWINDOWINFO *infoPtr, INT nPart, WORD style, 650 STATUSBAR_SetTextT (STATUSWINDOWINFO *infoPtr, INT nPart, WORD style, 629 651 LPCWSTR text, BOOL isW) 630 652 { … … 632 654 BOOL changed = FALSE; 633 655 634 if (style & SBT_OWNERDRAW) { 635 TRACE("part %d, text % x\n",nPart,text);656 if (style & SBT_OWNERDRAW) { 657 TRACE("part %d, text %p\n",nPart,text); 636 658 } 637 659 else TRACE("part %d, text %s\n", nPart, debugstr_t(text, isW)); … … 663 685 LPCSTR atxt = (LPCSTR)text; 664 686 DWORD len = MultiByteToWideChar( CP_ACP, 0, atxt, -1, NULL, 0 ); 665 ntext = COMCTL32_Alloc( (len + 1)*sizeof(WCHAR) );687 ntext = Alloc( (len + 1)*sizeof(WCHAR) ); 666 688 if (!ntext) return FALSE; 667 689 MultiByteToWideChar( CP_ACP, 0, atxt, -1, ntext, len ); 668 690 } else if (text) { 669 ntext = COMCTL32_Alloc( (strlenW(text) + 1)*sizeof(WCHAR) );691 ntext = Alloc( (strlenW(text) + 1)*sizeof(WCHAR) ); 670 692 if (!ntext) return FALSE; 671 693 strcpyW (ntext, text); … … 675 697 if (text) { 676 698 if (!changed && part->text && !lstrcmpW(ntext, part->text)) { 677 if (!isW) COMCTL32_Free(ntext);699 if (!isW) Free(ntext); 678 700 return TRUE; 679 701 } 680 702 } else { 681 if (!changed && !part->text) 703 if (!changed && !part->text) 682 704 return TRUE; 683 705 } 684 706 685 707 if (part->text) 686 COMCTL32_Free (part->text);708 Free (part->text); 687 709 part->text = ntext; 688 710 } … … 758 780 nmhdr.idFrom = GetWindowLongW (infoPtr->Self, GWL_ID); 759 781 nmhdr.code = SBN_SIMPLEMODECHANGE; 760 SendMessageW ( GetParent (infoPtr->Self), WM_NOTIFY, 0, (LPARAM)&nmhdr);782 SendMessageW (infoPtr->Notify, WM_NOTIFY, 0, (LPARAM)&nmhdr); 761 783 InvalidateRect(infoPtr->Self, NULL, FALSE); 762 784 return TRUE; … … 772 794 for (i = 0; i < infoPtr->numParts; i++) { 773 795 if (infoPtr->parts[i].text && !(infoPtr->parts[i].style & SBT_OWNERDRAW)) 774 COMCTL32_Free (infoPtr->parts[i].text);796 Free (infoPtr->parts[i].text); 775 797 } 776 798 if (infoPtr->part0.text && !(infoPtr->part0.style & SBT_OWNERDRAW)) 777 COMCTL32_Free (infoPtr->part0.text);778 COMCTL32_Free (infoPtr->parts);799 Free (infoPtr->part0.text); 800 Free (infoPtr->parts); 779 801 780 802 /* delete default font */ … … 786 808 DestroyWindow (infoPtr->hwndToolTip); 787 809 788 COMCTL32_Free (infoPtr);789 810 SetWindowLongW(infoPtr->Self, 0, 0); 811 Free (infoPtr); 790 812 return 0; 791 813 } … … 803 825 804 826 TRACE("\n"); 805 infoPtr = (STATUSWINDOWINFO*) COMCTL32_Alloc (sizeof(STATUSWINDOWINFO));827 infoPtr = (STATUSWINDOWINFO*)Alloc (sizeof(STATUSWINDOWINFO)); 806 828 if (!infoPtr) goto create_fail; 807 829 SetWindowLongW (hwnd, 0, (DWORD)infoPtr); 808 830 809 831 infoPtr->Self = hwnd; 832 infoPtr->Notify = lpCreate->hwndParent; 810 833 infoPtr->numParts = 1; 811 834 infoPtr->parts = 0; … … 814 837 infoPtr->hFont = 0; 815 838 816 i = SendMessageW( GetParent (hwnd), WM_NOTIFYFORMAT,hwnd, NF_QUERY);839 i = SendMessageW(infoPtr->Notify, WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY); 817 840 infoPtr->NtfUnicode = (i == NFR_UNICODE); 818 841 … … 834 857 835 858 /* initialize first part */ 836 infoPtr->parts = COMCTL32_Alloc (sizeof(STATUSWINDOWPART));859 infoPtr->parts = Alloc (sizeof(STATUSWINDOWPART)); 837 860 if (!infoPtr->parts) goto create_fail; 838 861 infoPtr->parts[0].bound = rect; … … 846 869 if (lpCreate->lpszName && 847 870 (len = strlenW ((LPCWSTR)lpCreate->lpszName))) { 848 infoPtr->parts[0].text = COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));871 infoPtr->parts[0].text = Alloc ((len + 1)*sizeof(WCHAR)); 849 872 if (!infoPtr->parts[0].text) goto create_fail; 850 873 strcpyW (infoPtr->parts[0].text, (LPCWSTR)lpCreate->lpszName); … … 855 878 (len = strlen((LPCSTR)lpCreate->lpszName))) { 856 879 DWORD lenW = MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lpCreate->lpszName, -1, NULL, 0 ); 857 infoPtr->parts[0].text = COMCTL32_Alloc (lenW*sizeof(WCHAR));880 infoPtr->parts[0].text = Alloc (lenW*sizeof(WCHAR)); 858 881 if (!infoPtr->parts[0].text) goto create_fail; 859 882 MultiByteToWideChar( CP_ACP, 0, (LPCSTR)lpCreate->lpszName, -1, … … 871 894 #endif 872 895 873 if ((hdc = GetDC ( 0))) {896 if ((hdc = GetDC (hwnd))) { 874 897 TEXTMETRICW tm; 875 898 HFONT hOldFont; … … 879 902 textHeight = tm.tmHeight; 880 903 SelectObject (hdc, hOldFont); 881 ReleaseDC ( 0, hdc);904 ReleaseDC (hwnd, hdc); 882 905 } 883 906 TRACE(" textHeight=%d\n", textHeight); … … 886 909 infoPtr->hwndToolTip = 887 910 CreateWindowExW (0, TOOLTIPS_CLASSW, NULL, 0, 888 CW_USEDEFAULT, CW_USEDEFAULT, 889 CW_USEDEFAULT, CW_USEDEFAULT, 890 hwnd, 0, 891 GetWindowLongW (hwnd, GWL_HINSTANCE), NULL); 911 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 912 CW_USEDEFAULT, hwnd, 0, 913 (HINSTANCE)GetWindowLongW(hwnd, GWL_HINSTANCE), NULL); 892 914 893 915 if (infoPtr->hwndToolTip) { … … 901 923 SendMessageW (lpCreate->hwndParent, WM_NOTIFY, 902 924 (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc); 903 } 925 } 904 926 } 905 927 906 928 if (!(dwStyle & CCS_NORESIZE)) { /* don't resize wnd if it doesn't want it ! */ 907 GetClientRect ( GetParent (hwnd), &rect);929 GetClientRect (infoPtr->Notify, &rect); 908 930 width = rect.right - rect.left; 909 931 infoPtr->height = textHeight + 4 + VERT_BORDER; … … 914 936 915 937 return 0; 916 938 917 939 create_fail: 918 940 TRACE(" failed!\n"); … … 993 1015 { 994 1016 infoPtr->hFont = font; 995 TRACE("% 04x\n", infoPtr->hFont);1017 TRACE("%p\n", infoPtr->hFont); 996 1018 if (redraw) 997 1019 InvalidateRect(infoPtr->Self, NULL, FALSE); … … 1014 1036 /* duplicate string */ 1015 1037 if (part->text) 1016 COMCTL32_Free (part->text);1038 Free (part->text); 1017 1039 part->text = 0; 1018 1040 if (infoPtr->bUnicode) { 1019 1041 if (text && (len = strlenW((LPCWSTR)text))) { 1020 part->text = COMCTL32_Alloc ((len+1)*sizeof(WCHAR));1042 part->text = Alloc ((len+1)*sizeof(WCHAR)); 1021 1043 if (!part->text) return FALSE; 1022 1044 strcpyW (part->text, (LPCWSTR)text); … … 1026 1048 if (text && (len = lstrlenA(text))) { 1027 1049 DWORD lenW = MultiByteToWideChar( CP_ACP, 0, text, -1, NULL, 0 ); 1028 part->text = COMCTL32_Alloc (lenW*sizeof(WCHAR));1050 part->text = Alloc (lenW*sizeof(WCHAR)); 1029 1051 if (!part->text) return FALSE; 1030 1052 MultiByteToWideChar( CP_ACP, 0, text, -1, part->text, lenW ); … … 1039 1061 1040 1062 static BOOL 1063 #ifdef __WIN32OS2__ 1064 STATUSBAR_WMSize (STATUSWINDOWINFO *infoPtr, WORD flags, LPARAM lParam) 1065 #else 1041 1066 STATUSBAR_WMSize (STATUSWINDOWINFO *infoPtr, WORD flags) 1067 #endif 1042 1068 { 1043 1069 INT width, x, y; … … 1047 1073 TRACE("flags %04x\n", flags); 1048 1074 1049 if (flags != SIZE_RESTORED) { 1050 WARN("flags MUST be SIZE_RESTORED\n"); 1075 if (flags != SIZE_RESTORED && flags != SIZE_MAXIMIZED) 1076 { 1077 WARN("flags MUST be SIZE_RESTORED or SIZE_MAXIMIZED\n"); 1051 1078 return FALSE; 1052 1079 } 1080 1053 1081 #ifdef __WIN32OS2__ 1054 1082 if (GetWindowLongW(infoPtr->Self, GWL_STYLE) & CCS_NORESIZE) { … … 1057 1085 return FALSE; 1058 1086 } 1087 1088 /* Invalidate the window if we need to draw a size grip */ 1089 /* TODO: The size grip area would be sufficient though */ 1090 if (GetWindowLongW (infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP) 1091 { 1092 RECT rcWin; 1093 1094 GetClientRect(infoPtr->Self, &rcWin); 1095 if(HIWORD(lParam) != (rcWin.bottom - rcWin.top) || 1096 LOWORD(lParam) != (rcWin.right - rcWin.left)) 1097 { 1098 TRACE("SBARS_SIZEGRIP && height/width changed -> invalidate window"); 1099 InvalidateRect(infoPtr->Self,NULL,TRUE); 1100 } 1101 } 1059 1102 #else 1060 1103 if (GetWindowLongW(infoPtr->Self, GWL_STYLE) & CCS_NORESIZE) return FALSE; … … 1062 1105 1063 1106 /* width and height don't apply */ 1064 GetClientRect ( GetParent(infoPtr->Self), &parent_rect);1107 GetClientRect (infoPtr->Notify, &parent_rect); 1065 1108 width = parent_rect.right - parent_rect.left; 1066 1109 x = parent_rect.left; 1067 1110 y = parent_rect.bottom - infoPtr->height; 1068 MoveWindow (infoPtr->Self, parent_rect.left, 1111 MoveWindow (infoPtr->Self, parent_rect.left, 1069 1112 parent_rect.bottom - infoPtr->height, 1070 1113 width, infoPtr->height, TRUE); … … 1074 1117 1075 1118 1076 static LRESULT 1119 static LRESULT 1077 1120 STATUSBAR_NotifyFormat (STATUSWINDOWINFO *infoPtr, HWND from, INT cmd) 1078 1121 { 1079 1122 if (cmd == NF_REQUERY) { 1080 INT i = SendMessageW(from, WM_NOTIFYFORMAT, infoPtr->Self, NF_QUERY);1123 INT i = SendMessageW(from, WM_NOTIFYFORMAT, (WPARAM)infoPtr->Self, NF_QUERY); 1081 1124 infoPtr->NtfUnicode = (i == NFR_UNICODE); 1082 1125 } … … 1088 1131 STATUSBAR_SendNotify (HWND hwnd, UINT code) 1089 1132 { 1133 STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr(hwnd); 1090 1134 NMHDR nmhdr; 1091 1135 … … 1094 1138 nmhdr.idFrom = GetWindowLongW (hwnd, GWL_ID); 1095 1139 nmhdr.code = code; 1096 SendMessageW ( GetParent (hwnd), WM_NOTIFY, 0, (LPARAM)&nmhdr);1140 SendMessageW (infoPtr->Notify, WM_NOTIFY, 0, (LPARAM)&nmhdr); 1097 1141 return 0; 1098 1142 } … … 1107 1151 LRESULT res; 1108 1152 1109 TRACE("hwnd=% xmsg=%x wparam=%x lparam=%lx\n", hwnd, msg, wParam, lParam);1153 TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n", hwnd, msg, wParam, lParam); 1110 1154 if (!infoPtr && msg != WM_CREATE) 1111 1155 return DefWindowProcW (hwnd, msg, wParam, lParam); … … 1116 1160 1117 1161 case SB_GETICON: 1118 return STATUSBAR_GetIcon (infoPtr, nPart);1162 return (LRESULT)STATUSBAR_GetIcon (infoPtr, nPart); 1119 1163 1120 1164 case SB_GETPARTS: … … 1155 1199 return STATUSBAR_SetMinHeight (infoPtr, (INT)wParam); 1156 1200 1157 case SB_SETPARTS: 1201 case SB_SETPARTS: 1158 1202 return STATUSBAR_SetParts (infoPtr, (INT)wParam, (LPINT)lParam); 1159 1203 … … 1183 1227 1184 1228 case WM_GETFONT: 1185 return infoPtr->hFont? infoPtr->hFont : infoPtr->hDefaultFont;1229 return (LRESULT)(infoPtr->hFont? infoPtr->hFont : infoPtr->hDefaultFont); 1186 1230 1187 1231 case WM_GETTEXT: … … 1208 1252 case WM_NCLBUTTONUP: 1209 1253 case WM_NCLBUTTONDOWN: 1210 PostMessageW ( GetParent (hwnd), msg, wParam, lParam);1254 PostMessageW (infoPtr->Notify, msg, wParam, lParam); 1211 1255 return 0; 1212 1256 1213 1257 case WM_NOTIFYFORMAT: 1214 1258 return STATUSBAR_NotifyFormat(infoPtr, (HWND)wParam, (INT)lParam); 1215 1259 1216 1260 case WM_PAINT: 1217 1261 return STATUSBAR_WMPaint (infoPtr, (HDC)wParam); … … 1230 1274 1231 1275 case WM_SIZE: 1276 #ifdef __WIN32OS2__ 1277 if (STATUSBAR_WMSize (infoPtr, (WORD)wParam, lParam)) return 0; 1278 #else 1232 1279 if (STATUSBAR_WMSize (infoPtr, (WORD)wParam)) return 0; 1280 #endif 1233 1281 return DefWindowProcW (hwnd, msg, wParam, lParam); 1234 1282 1235 1283 default: 1236 if ( msg >= WM_USER)1284 if ((msg >= WM_USER) && (msg < WM_APP)) 1237 1285 ERR("unknown msg %04x wp=%04x lp=%08lx\n", 1238 1286 msg, wParam, lParam); … … 1259 1307 wndClass.cbClsExtra = 0; 1260 1308 wndClass.cbWndExtra = sizeof(STATUSWINDOWINFO *); 1261 wndClass.hCursor = LoadCursorW (0, IDC_ARROWW);1309 wndClass.hCursor = LoadCursorW (0, (LPWSTR)IDC_ARROWW); 1262 1310 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); 1263 1311 wndClass.lpszClassName = STATUSCLASSNAMEW; 1264 1312 1265 1313 RegisterClassW (&wndClass); 1266 1314 } … … 1276 1324 STATUS_Unregister (void) 1277 1325 { 1278 UnregisterClassW (STATUSCLASSNAMEW, (HINSTANCE)NULL); 1279 } 1280 1326 UnregisterClassW (STATUSCLASSNAMEW, NULL); 1327 }
Note:
See TracChangeset
for help on using the changeset viewer.