Changeset 91 for trunk/src/helpers/dialog.c
- Timestamp:
- Aug 2, 2001, 10:36:35 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/dialog.c
r89 r91 110 110 const char *pcszControlsFont; // from dlghCreateDlg 111 111 112 // V0.9.14 (2001-08-01) [umoeller] 112 113 HPS hps; 113 /* const char *pcszFontLast; 114 LONG lcidLast; */ 114 const char *pcszFontLast; 115 LONG lcidLast; 116 FONTMETRICS fmLast; 117 115 118 } DLGPRIVATE, *PDLGPRIVATE; 116 119 … … 148 151 BOOL fIsNestedTable; // if TRUE, pvDefinition points to a nested TABLEDEF; 149 152 // if FALSE, pvDefinition points to a CONTROLDEF as 150 // specified by the user153 // specified by the caller 151 154 152 155 PVOID pvDefinition; // either a PTABLEDEF or a PCONTROLDEF … … 225 228 *@@changed V0.9.12 (2001-05-31) [umoeller]: fixed various things with statics 226 229 *@@changed V0.9.12 (2001-05-31) [umoeller]: fixed broken fonts 230 *@@changed V0.9.14 (2001-08-01) [umoeller]: now caching fonts, which is significantly faster 227 231 */ 228 232 … … 232 236 PDLGPRIVATE pDlgData) 233 237 { 234 BOOL fFind = FALSE;235 RECTL rclText;236 LONG lcid = 0;237 238 238 const char *pcszFontThis = pControlDef->pcszFont; 239 239 // can be NULL, … … 248 248 if (pcszFontThis) 249 249 { 250 FONTMETRICS fm;251 250 LONG lPointSize = 0; 252 251 253 // create new font 254 lcid = gpihFindPresFont(NULLHANDLE, // no window yet 255 FALSE, 256 pDlgData->hps, 257 pcszFontThis, 258 &fm, 259 &lPointSize); 260 GpiSetCharSet(pDlgData->hps, lcid); 261 if (fm.fsDefn & FM_DEFN_OUTLINE) 262 gpihSetPointSize(pDlgData->hps, lPointSize); 263 264 pszlAuto->cy = fm.lMaxBaselineExt + fm.lExternalLeading; 252 // check if we can reuse font data from last time 253 // V0.9.14 (2001-08-01) [umoeller] 254 if (strhcmp(pcszFontThis, 255 pDlgData->pcszFontLast)) 256 { 257 // different font than last time: 258 259 // delete old font? 260 if (pDlgData->lcidLast) 261 { 262 GpiSetCharSet(pDlgData->hps, LCID_DEFAULT); 263 GpiDeleteSetId(pDlgData->hps, pDlgData->lcidLast); 264 } 265 266 // create new font 267 pDlgData->lcidLast = gpihFindPresFont(NULLHANDLE, // no window yet 268 FALSE, 269 pDlgData->hps, 270 pcszFontThis, 271 &pDlgData->fmLast, 272 &lPointSize); 273 274 GpiSetCharSet(pDlgData->hps, pDlgData->lcidLast); 275 if (pDlgData->fmLast.fsDefn & FM_DEFN_OUTLINE) 276 gpihSetPointSize(pDlgData->hps, lPointSize); 277 278 pDlgData->pcszFontLast = pcszFontThis; 279 } 280 281 pszlAuto->cy = pDlgData->fmLast.lMaxBaselineExt 282 + pDlgData->fmLast.lExternalLeading; 265 283 } 266 284 … … 300 318 } 301 319 } 302 303 /* if (lcid)304 {305 GpiSetCharSet(pDlgData->hps, LCID_DEFAULT);306 GpiDeleteSetId(pDlgData->hps, lcid);307 } */308 309 320 } 310 321 … … 336 347 | BS_CHECKBOX 337 348 | BS_RADIOBUTTON)) 349 { 350 // give a little extra width for the box bitmap 338 351 pszlAuto->cx += 20; // @@todo 352 // and height 353 pszlAuto->cy += 2; 354 } 339 355 else if (pControlDef->flStyle & BS_BITMAP) 340 356 ; … … 722 738 PDLGPRIVATE pDlgData) 723 739 { 724 ULONG ul;740 // ULONG ul; 725 741 LONG lX; 726 742 PLISTNODE pNode; … … 791 807 PDLGPRIVATE pDlgData) 792 808 { 793 ULONG ul;809 // ULONG ul; 794 810 LONG lY; 795 811 PLISTNODE pNode; … … 864 880 PROCESSMODE ProcessMode) 865 881 { 866 ULONG ul;882 // ULONG ul; 867 883 PLISTNODE pNode; 868 884 CONTROLPOS cpTable; … … 943 959 944 960 return (arc); 961 } 962 963 /* 964 *@@ FreeTable: 965 * frees the specified table and recurses 966 * into nested tables, if necessary. 967 * 968 * This was added with V0.9.14 to fix the 969 * bad memory leaks with nested tables. 970 * 971 *@@added V0.9.14 (2001-08-01) [umoeller] 972 */ 973 974 VOID FreeTable(PTABLEDEF pTable) 975 { 976 // for each table, clean up the rows 977 PLISTNODE pRowNode; 978 FOR_ALL_NODES(&pTable->llRows, pRowNode) 979 { 980 PROWDEF pRow = (PROWDEF)pRowNode->pItemData; 981 982 // for each row, clean up the columns 983 PLISTNODE pColumnNode; 984 FOR_ALL_NODES(&pRow->llColumns, pColumnNode) 985 { 986 PCOLUMNDEF pColumn = (PCOLUMNDEF)pColumnNode->pItemData; 987 988 if (pColumn->fIsNestedTable) 989 { 990 // nested table: recurse! 991 PTABLEDEF pNestedTable = (PTABLEDEF)pColumn->pvDefinition; 992 FreeTable(pNestedTable); 993 } 994 995 free(pColumn); 996 } 997 lstClear(&pRow->llColumns); 998 999 free(pRow); 1000 } 1001 lstClear(&pTable->llRows); 1002 1003 free(pTable); 945 1004 } 946 1005 … … 1181 1240 * 1182 1241 *@@changed V0.9.14 (2001-07-07) [umoeller]: fixed disabled mouse with hwndOwner == HWND_DESKTOP 1242 *@@changed V0.9.14 (2001-08-01) [umoeller]: fixed major memory leaks with nested tables 1183 1243 */ 1184 1244 … … 1270 1330 // create "table" column for this 1271 1331 PCOLUMNDEF pColumnDef; 1272 arc = CreateColumn(pCurrentRow,1273 TRUE, // nested table1274 pCurrentTable,1275 &pColumnDef);1276 if (!arc)1277 lstAppendItem(&pCurrentRow->llColumns,pColumnDef);1332 if (!(arc = CreateColumn(pCurrentRow, 1333 TRUE, // nested table 1334 pCurrentTable, 1335 &pColumnDef))) 1336 lstAppendItem(&pCurrentRow->llColumns, 1337 pColumnDef); 1278 1338 } 1279 1339 } … … 1319 1379 { 1320 1380 PCOLUMNDEF pColumnDef; 1321 arc = CreateColumn(pCurrentRow,1322 FALSE, // no nested table1323 (PVOID)pItemThis->ulData,1324 &pColumnDef);1325 if (!arc)1326 lstAppendItem(&pCurrentRow->llColumns,pColumnDef);1381 if (!(arc = CreateColumn(pCurrentRow, 1382 FALSE, // no nested table 1383 (PVOID)pItemThis->ulData, 1384 &pColumnDef))) 1385 lstAppendItem(&pCurrentRow->llColumns, 1386 pColumnDef); 1327 1387 break; } 1328 1388 … … 1416 1476 PROCESS_CALC_SIZES); 1417 1477 1478 if (pDlgData->lcidLast) 1479 { 1480 GpiSetCharSet(pDlgData->hps, LCID_DEFAULT); 1481 GpiDeleteSetId(pDlgData->hps, pDlgData->lcidLast); 1482 } 1418 1483 if (pDlgData->hps) 1419 1484 WinReleasePS(pDlgData->hps); … … 1506 1571 PTABLEDEF pTable = (PTABLEDEF)pTableNode->pItemData; 1507 1572 1508 // for each table, clean up the rows 1509 PLISTNODE pRowNode; 1510 FOR_ALL_NODES(&pTable->llRows, pRowNode) 1511 { 1512 PROWDEF pRow = (PROWDEF)pRowNode->pItemData; 1513 1514 // for each row, clean up the columns 1515 PLISTNODE pColumnNode; 1516 FOR_ALL_NODES(&pRow->llColumns, pColumnNode) 1517 { 1518 PCOLUMNDEF pColumn = (PCOLUMNDEF)pColumnNode->pItemData; 1519 free(pColumn); 1520 } 1521 lstClear(&pRow->llColumns); 1522 1523 free(pRow); 1524 } 1525 lstClear(&pTable->llRows); 1526 1527 free(pTable); 1573 FreeTable(pTable); 1574 // this may recurse for nested tables 1528 1575 } 1529 1576 … … 1532 1579 1533 1580 free(pDlgData); 1581 } 1582 1583 if (arc) 1584 { 1585 CHAR szErr[300]; 1586 sprintf(szErr, "Error %d occured in dlghCreateDlg.", arc); 1587 winhDebugBox(hwndOwner, 1588 "Error in Dialog Manager", 1589 szErr); 1534 1590 } 1535 1591
Note:
See TracChangeset
for help on using the changeset viewer.