Changeset 201 for trunk/src/helpers/dialog.c
- Timestamp:
- Aug 11, 2002, 7:07:59 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/dialog.c
r199 r201 80 80 #include "helpers\standards.h" 81 81 #include "helpers\stringh.h" 82 #include "helpers\textview.h" 82 83 #include "helpers\winh.h" 83 84 #include "helpers\xstring.h" … … 118 119 119 120 POINTL ptlTotalOfs; 121 122 LINKLIST llTempControls; // linked list of HWNDs that were 123 // created temporarily to determine 124 // control sizes for SZL_AUTOSIZE 125 // V0.9.20 (2002-08-10) [umoeller] 120 126 121 127 PLINKLIST pllControls; // linked list of HWNDs in the order … … 365 371 { 366 372 RECTL rcl = {0, 0, 0, 0}; 367 /*368 if (pControlDef->szlControlProposed.cx > 0)369 rcl.xRight = pControlDef->szlControlProposed.cx; // V0.9.12 (2001-05-31) [umoeller]370 else371 rcl.xRight = winhQueryScreenCX() * 2 / 3;372 */373 373 rcl.xRight = ulWidth; 374 374 if (pControlDef->szlDlgUnits.cy > 0) … … 488 488 489 489 default: 490 // any other control (just to be safe): 491 SetDlgFont(pControlDef, pDlgData); 492 pszlAuto->cx = 50; 493 pszlAuto->cy = pDlgData->fmLast.lMaxBaselineExt 494 + pDlgData->fmLast.lExternalLeading 495 + 7; // some space 490 if (!strcmp(pControlDef->pcszClass, WC_XTEXTVIEW)) 491 { 492 HWND hwnd = NULLHANDLE; 493 PCSZ pcszTitle; 494 495 PLISTNODE pTempNode; 496 HWND hwndFound = NULLHANDLE; 497 FOR_ALL_NODES(&pDlgData->llTempControls, pTempNode) 498 { 499 HWND hwndThis = (HWND)pTempNode->pItemData; 500 if (WinQueryWindowUShort(hwndThis, QWS_ID) == pControlDef->usID) 501 { 502 hwnd = hwndThis; 503 504 // resize it to what we really need 505 WinSetWindowPos(hwndThis, 506 HWND_BOTTOM, 507 0, 508 0, 509 ulWidth, 510 2000, 511 SWP_SIZE); 512 break; 513 } 514 } 515 516 if (!hwnd) 517 { 518 if (hwnd = WinCreateWindow(pDlgData->hwndDlg, // parent 519 (PSZ)pControlDef->pcszClass, 520 NULL, 521 pControlDef->flStyle, 522 0, 523 0, 524 ulWidth, 525 2000, // cy, for now 526 pDlgData->hwndDlg, // owner 527 HWND_BOTTOM, 528 pControlDef->usID, 529 pControlDef->pvCtlData, 530 NULL)) 531 { 532 PCSZ pcszFont = pControlDef->pcszFont; 533 // can be NULL, or CTL_COMMON_FONT 534 if (pcszFont == CTL_COMMON_FONT) 535 pcszFont = pDlgData->pcszControlsFont; 536 537 if (pcszFont) 538 winhSetWindowFont(hwnd, 539 pcszFont); 540 541 WinSetWindowText(hwnd, 542 (pcszTitle = pControlDef->pcszText) 543 ? (PSZ)pcszTitle 544 : ""); 545 546 // store the window we have created in the temp 547 // windows list so it can be reused in 548 // ColumnCreateControls 549 lstAppendItem(&pDlgData->llTempControls, 550 (PVOID)hwnd); 551 } 552 else 553 arc = DLGERR_CANNOT_CREATE_CONTROL; 554 } 555 556 if (hwnd) 557 { 558 SIZEL szlTemp; 559 WinSendMsg(hwnd, 560 TXM_QUERYTEXTEXTENT, 561 (MPARAM)&szlTemp, 562 0); 563 564 pszlAuto->cy = szlTemp.cy; 565 } 566 } 567 else 568 { 569 // any other control (just to be safe): 570 SetDlgFont(pControlDef, pDlgData); 571 pszlAuto->cx = 50; 572 pszlAuto->cy = pDlgData->fmLast.lMaxBaselineExt 573 + pDlgData->fmLast.lExternalLeading 574 + 7; // some space 575 } 496 576 } 497 577 … … 958 1038 { 959 1039 // create something: 960 PCSZ pcszFont = pControlDef->pcszFont; 961 // can be NULL, or CTL_COMMON_FONT 962 if (pcszFont == CTL_COMMON_FONT) 963 pcszFont = pDlgData->pcszControlsFont; 964 965 if (pColumnDef->hwndControl 966 = WinCreateWindow(pDlgData->hwndDlg, // parent 967 (PSZ)pcszClass, // hacked 968 (pcszTitle) // hacked 969 ? (PSZ)pcszTitle 970 : "", 971 flStyle, // hacked 972 x, 973 y, 974 cx, 975 cy, 976 pDlgData->hwndDlg, // owner 977 HWND_BOTTOM, 978 pControlDef->usID, 979 pControlDef->pvCtlData, 980 NULL)) 981 { 1040 1041 // check if we have the window on the temp list from 1042 // CalcAutoSize V0.9.20 (2002-08-10) [umoeller] 1043 PLISTNODE pTempNode; 1044 HWND hwndFound = NULLHANDLE; 1045 FOR_ALL_NODES(&pDlgData->llTempControls, pTempNode) 1046 { 1047 HWND hwndThis = (HWND)pTempNode->pItemData; 1048 if (WinQueryWindowUShort(hwndThis, QWS_ID) == pControlDef->usID) 1049 { 1050 hwndFound 1051 = pColumnDef->hwndControl 1052 = hwndThis; 1053 1054 // resize it to what we really need 1055 WinSetWindowPos(hwndThis, 1056 HWND_BOTTOM, 1057 x, 1058 y, 1059 cx, 1060 cy, 1061 SWP_SIZE | SWP_MOVE | SWP_ZORDER); 1062 1063 lstRemoveNode(&pDlgData->llTempControls, pTempNode); 1064 break; 1065 } 1066 } 1067 1068 if ( (!hwndFound) 1069 && (!(pColumnDef->hwndControl = WinCreateWindow(pDlgData->hwndDlg, // parent 1070 (PSZ)pcszClass, // hacked 1071 (pcszTitle) // hacked 1072 ? (PSZ)pcszTitle 1073 : "", 1074 flStyle, // hacked 1075 x, 1076 y, 1077 cx, 1078 cy, 1079 pDlgData->hwndDlg, // owner 1080 HWND_BOTTOM, 1081 pControlDef->usID, 1082 pControlDef->pvCtlData, 1083 NULL))) 1084 ) 1085 arc = DLGERR_CANNOT_CREATE_CONTROL; 1086 1087 if (!arc) 1088 { 1089 PCSZ pcszFont = pControlDef->pcszFont; 1090 // can be NULL, or CTL_COMMON_FONT 1091 if (pcszFont == CTL_COMMON_FONT) 1092 pcszFont = pDlgData->pcszControlsFont; 1093 1094 if (lHandleSet) 1095 { 1096 // subclass the damn static 1097 if ((flOld & 0x0F) == SS_ICON) 1098 // this was a static: 1099 ctlPrepareStaticIcon(pColumnDef->hwndControl, 1100 1); 1101 else 1102 // this was a bitmap: 1103 ctlPrepareStretchedBitmap(pColumnDef->hwndControl, 1104 TRUE); 1105 1106 WinSendMsg(pColumnDef->hwndControl, 1107 SM_SETHANDLE, 1108 (MPARAM)lHandleSet, 1109 0); 1110 } 1111 else if (pcszFont) 1112 // we must set the font explicitly here... 1113 // doesn't always work with WinCreateWindow 1114 // presparams parameter, for some reason 1115 // V0.9.12 (2001-05-31) [umoeller] 1116 winhSetWindowFont(pColumnDef->hwndControl, 1117 pcszFont); 1118 982 1119 #ifdef DEBUG_DIALOG_WINDOWS 983 1120 { … … 1020 1157 } 1021 1158 #endif 1022 1023 if (lHandleSet)1024 {1025 // subclass the damn static1026 if ((flOld & 0x0F) == SS_ICON)1027 // this was a static:1028 ctlPrepareStaticIcon(pColumnDef->hwndControl,1029 1);1030 else1031 // this was a bitmap:1032 ctlPrepareStretchedBitmap(pColumnDef->hwndControl,1033 TRUE);1034 1035 WinSendMsg(pColumnDef->hwndControl,1036 SM_SETHANDLE,1037 (MPARAM)lHandleSet,1038 0);1039 }1040 else1041 if (pcszFont)1042 // we must set the font explicitly here...1043 // doesn't always work with WinCreateWindow1044 // presparams parameter, for some reason1045 // V0.9.12 (2001-05-31) [umoeller]1046 winhSetWindowFont(pColumnDef->hwndControl,1047 pcszFont);1048 1049 1159 // append window that was created 1050 1160 // V0.9.18 (2002-03-03) [umoeller] … … 1260 1370 PROWDEF pRowThis = (PROWDEF)pRowNode->pItemData; 1261 1371 PCOLUMNDEF pCorrespondingColumn; 1262 if ( (pCorrespondingColumn = lstItemFromIndex(&pRowThis->llColumns, ulMyIndex)) 1372 if ( (pCorrespondingColumn = (PCOLUMNDEF)lstItemFromIndex(&pRowThis->llColumns, 1373 ulMyIndex)) 1263 1374 && (pCorrespondingColumn->cpColumn.cx > pColumnDef->cpColumn.cx) 1264 1375 ) … … 1357 1468 } 1358 1469 } 1470 // we should stop on errors V0.9.20 (2002-08-10) [umoeller] 1471 else 1472 break; 1359 1473 } 1360 1474 … … 1526 1640 } 1527 1641 } 1642 // we should stop on errors V0.9.20 (2002-08-10) [umoeller] 1643 else 1644 break; 1528 1645 } 1529 1646 … … 1651 1768 ZERO(pDlgData); 1652 1769 lstInit(&pDlgData->llTables, FALSE); 1770 1771 lstInit(&pDlgData->llTempControls, FALSE); // V0.9.20 (2002-08-10) [umoeller] 1653 1772 1654 1773 if (pllControls) … … 1904 2023 *@@added V0.9.15 (2001-08-26) [umoeller] 1905 2024 *@@changed V0.9.15 (2001-08-26) [umoeller]: BS_DEFAULT for other than first button was ignored, fixed 2025 *@@changed V0.9.20 (2002-08-10) [umoeller]: return code checking was missing, fixed 1906 2026 */ 1907 2027 … … 1916 2036 */ 1917 2037 1918 ProcessAll(pDlgData, 1919 PROCESS_4_CALC_POSITIONS); 1920 1921 /* 1922 * 6) create control windows, finally 1923 * 1924 */ 1925 1926 pDlgData->ptlTotalOfs.x = DLG_OUTER_SPACING_X * FACTOR_X; 1927 pDlgData->ptlTotalOfs.y = DLG_OUTER_SPACING_Y * FACTOR_Y; 1928 1929 ProcessAll(pDlgData, 1930 PROCESS_5_CREATE_CONTROLS); 1931 1932 if (pDlgData->hwndDefPushbutton) 1933 { 1934 // we had a default pushbutton: 1935 // go set it V0.9.14 (2001-08-21) [umoeller] 1936 WinSetWindowULong(pDlgData->hwndDlg, 1937 QWL_DEFBUTTON, 1938 pDlgData->hwndDefPushbutton); 1939 *phwndFocusItem = pDlgData->hwndDefPushbutton; 1940 // V0.9.15 (2001-08-26) [umoeller] 1941 } 1942 else 1943 *phwndFocusItem = (pDlgData->hwndFirstFocus) 1944 ? pDlgData->hwndFirstFocus 1945 : pDlgData->hwndDlg; 2038 // this was missing a return code, fixed V0.9.20 (2002-08-10) [umoeller] 2039 if (!(arc = ProcessAll(pDlgData, 2040 PROCESS_4_CALC_POSITIONS))) 2041 { 2042 /* 2043 * 6) create control windows, finally 2044 * 2045 */ 2046 2047 pDlgData->ptlTotalOfs.x = DLG_OUTER_SPACING_X * FACTOR_X; 2048 pDlgData->ptlTotalOfs.y = DLG_OUTER_SPACING_Y * FACTOR_Y; 2049 2050 // this was missing a return code, fixed V0.9.20 (2002-08-10) [umoeller] 2051 if (!(arc = ProcessAll(pDlgData, 2052 PROCESS_5_CREATE_CONTROLS))) 2053 { 2054 if (pDlgData->hwndDefPushbutton) 2055 { 2056 // we had a default pushbutton: 2057 // go set it V0.9.14 (2001-08-21) [umoeller] 2058 WinSetWindowULong(pDlgData->hwndDlg, 2059 QWL_DEFBUTTON, 2060 pDlgData->hwndDefPushbutton); 2061 *phwndFocusItem = pDlgData->hwndDefPushbutton; 2062 // V0.9.15 (2001-08-26) [umoeller] 2063 } 2064 else 2065 *phwndFocusItem = (pDlgData->hwndFirstFocus) 2066 ? pDlgData->hwndFirstFocus 2067 : pDlgData->hwndDlg; 2068 } 2069 } 1946 2070 1947 2071 return arc; … … 1973 2097 // this may recurse for nested tables 1974 2098 } 2099 2100 lstClear(&pDlgData->llTempControls); // V0.9.20 (2002-08-10) [umoeller] 1975 2101 1976 2102 lstClear(&pDlgData->llTables); … … 2461 2587 2462 2588 APIRET dlghFormatDlg(HWND hwndDlg, // in: dialog frame to work on 2463 PCDLGHITEM paDlgItems, 2589 PCDLGHITEM paDlgItems, // in: definition array 2464 2590 ULONG cDlgItems, // in: array item count (NOT array size) 2465 PCSZ pcszControlsFont, // in: font for ctls with CTL_COMMON_FONT2591 PCSZ pcszControlsFont, // in: font for ctls with CTL_COMMON_FONT 2466 2592 ULONG flFlags, // in: DFFL_* flags 2467 2593 PSIZEL pszlClient, // out: size of all controls (ptr can be NULL) 2468 PVOID *ppllControls) // out: new LINKLIST receiving HWNDs of created controls (ptr can be NULL)2594 PVOID *ppllControls) // out: new LINKLIST receiving HWNDs of created controls (ptr can be NULL) 2469 2595 { 2470 2596 APIRET arc = NO_ERROR;
Note:
See TracChangeset
for help on using the changeset viewer.