Changeset 197
- Timestamp:
- Aug 9, 2002, 8:44:53 PM (23 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/helpers/dialog.h
r195 r197 55 55 #define DLGERR_INVALID_CONTROL_TITLE (ERROR_DLG_FIRST + 9) 56 56 #define DLGERR_INVALID_STATIC_BITMAP (ERROR_DLG_FIRST + 10) 57 58 #define ERROR_DLG_LAST (ERROR_DLG_FIRST + 10) 57 #define DLGERR_INTEGRITY_BAD_COLUMN_INDEX (ERROR_DLG_FIRST + 11) 58 59 #define ERROR_DLG_LAST (ERROR_DLG_FIRST + 11) 59 60 60 61 /* ****************************************************************** … … 67 68 68 69 #define CTL_COMMON_FONT ((PCSZ)-1) 69 70 #define ROW_VALIGN_MASK 0x000371 #define ROW_VALIGN_BOTTOM 0x000072 #define ROW_VALIGN_CENTER 0x000173 #define ROW_VALIGN_TOP 0x000274 70 75 71 /* … … 162 158 } DLGHITEMTYPE; 163 159 164 // a few handy macros for defining templates165 166 #define START_TABLE { TYPE_START_NEW_TABLE, 0 }167 168 // this macro is slightly insane, but performs type checking169 // in case the user gives a pointer which is not of CONTROLDEF170 #define START_GROUP_TABLE(pDef) { TYPE_START_NEW_TABLE, \171 ( (ULONG)(&(pDef)->pcszClass) ) }172 173 #define END_TABLE { TYPE_END_TABLE, 0 }174 175 #define START_ROW(fl) { TYPE_START_NEW_ROW, fl }176 177 #define CONTROL_DEF(pDef) { TYPE_CONTROL_DEF, \178 ( (ULONG)(&(pDef)->pcszClass) ) }179 180 160 /* 181 161 *@@ DLGHITEM: … … 197 177 // TYPE_END_TABLE // end of table 198 178 199 ULONG ulData;179 const CONTROLDEF *pCtlDef; 200 180 // -- with TYPE_START_NEW_TABLE: if NULL, this starts 201 181 // an invisible table (for formatting only). … … 205 185 // with SS_GROUPBOX to create a group around 206 186 // the table. 187 188 ULONG fl; 189 // -- with TYPE_START_NEW_TABLE. TABLE_* formatting flags. 190 #define TABLE_ALIGN_COLUMNS 0x0100 191 207 192 // -- with TYPE_START_NEW_ROW: ROW_* formatting flags. 208 // -- with TYPE_CONTROL_DEF: _CONTROLDEF pointer to a control definition 193 #define ROW_VALIGN_MASK 0x0003 194 #define ROW_VALIGN_BOTTOM 0x0000 195 #define ROW_VALIGN_CENTER 0x0001 196 #define ROW_VALIGN_TOP 0x0002 197 209 198 } DLGHITEM, *PDLGHITEM; 210 199 211 200 typedef const struct _DLGHITEM *PCDLGHITEM; 201 202 // a few handy macros for defining templates 203 204 #define START_TABLE { TYPE_START_NEW_TABLE, NULL, 0 } 205 206 #define START_TABLE_ALIGN { TYPE_START_NEW_TABLE, NULL, TABLE_ALIGN_COLUMNS } 207 // added V0.9.20 (2002-08-08) [umoeller] 208 209 #define START_GROUP_TABLE(pDef) { TYPE_START_NEW_TABLE, pDef, 0 } 210 211 #define START_GROUP_TABLE_ALIGN(pDef) { TYPE_START_NEW_TABLE, pDef, TABLE_ALIGN_COLUMNS } 212 // added V0.9.20 (2002-08-08) [umoeller] 213 214 #define END_TABLE { TYPE_END_TABLE, NULL, 0 } 215 216 #define START_ROW(fl) { TYPE_START_NEW_ROW, NULL, fl } 217 218 #define CONTROL_DEF(pDef) { TYPE_CONTROL_DEF, pDef, 0 } 212 219 213 220 /* ****************************************************************** -
trunk/src/helpers/dialog.c
r196 r197 237 237 LINKLIST llRows; // contains ROWDEF structs, no auto-free 238 238 239 PCONTROLDEF pCtlDef;// if != NULL, we create a PM control around the table239 const CONTROLDEF *pCtlDef; // if != NULL, we create a PM control around the table 240 240 241 241 CONTROLPOS cpTable; 242 243 ULONG flTable; // copied from DLGHITEM 242 244 243 245 } TABLEDEF; … … 274 276 */ 275 277 276 static VOID SetDlgFont( PCONTROLDEFpControlDef,278 static VOID SetDlgFont(const CONTROLDEF *pControlDef, 277 279 PDLGPRIVATE pDlgData) 278 280 { … … 340 342 */ 341 343 342 static APIRET CalcAutoSizeText( PCONTROLDEFpControlDef,344 static APIRET CalcAutoSizeText(const CONTROLDEF *pControlDef, 343 345 BOOL fMultiLine, // in: if TRUE, multiple lines 344 346 ULONG ulWidth, // in: proposed width of control … … 407 409 */ 408 410 409 static APIRET CalcAutoSize( PCONTROLDEFpControlDef,411 static APIRET CalcAutoSize(const CONTROLDEF *pControlDef, 410 412 ULONG ulWidth, // in: proposed width of control 411 413 PSIZEL pszlAuto, // out: computed size … … 519 521 { 520 522 APIRET arc = NO_ERROR; 521 PCONTROLDEFpControlDef = NULL;523 const CONTROLDEF *pControlDef = NULL; 522 524 ULONG xExtraColumn = 0, 523 525 yExtraColumn = 0; … … 574 576 SIZEL szlAuto; 575 577 576 pControlDef = ( PCONTROLDEF)pColumnDef->pvDefinition;578 pControlDef = (const CONTROLDEF *)pColumnDef->pvDefinition; 577 579 578 580 // do auto-size calculations only on the first loop … … 742 744 { 743 745 // no nested table, but control: 744 PCONTROLDEF pControlDef = (PCONTROLDEF)pColumnDef->pvDefinition;746 const CONTROLDEF *pControlDef = (const CONTROLDEF *)pColumnDef->pvDefinition; 745 747 xSpacingControl = pControlDef->duSpacing * FACTOR_X; 746 748 ySpacingControl = pControlDef->duSpacing * FACTOR_Y; … … 788 790 APIRET arc = NO_ERROR; 789 791 790 PCONTROLDEFpControlDef = NULL;792 const CONTROLDEF *pControlDef = NULL; 791 793 792 794 PCSZ pcszClass = NULL; … … 877 879 { 878 880 // no nested table, but control: 879 pControlDef = ( PCONTROLDEF)pColumnDef->pvDefinition;881 pControlDef = (const CONTROLDEF *)pColumnDef->pvDefinition; 880 882 // pcp = &pColumnDef->cpControl; 881 883 pcszClass = pControlDef->pcszClass; … … 1113 1115 *@@changed V0.9.12 (2001-05-31) [umoeller]: added control data 1114 1116 *@@changed V0.9.12 (2001-05-31) [umoeller]: fixed font problems 1117 *@@changed V0.9.20 (2002-08-08) [umoeller]: added support for aligning columns horizontally 1115 1118 */ 1116 1119 … … 1156 1159 { 1157 1160 // no nested table, but control: 1158 PCONTROLDEF pControlDef = (PCONTROLDEF)pColumnDef->pvDefinition;1161 const CONTROLDEF *pControlDef = (const CONTROLDEF *)pColumnDef->pvDefinition; 1159 1162 1160 1163 if ( (pControlDef->szlDlgUnits.cx < -1) … … 1225 1228 1226 1229 case PROCESS_3_CALC_FINAL_TABLE_SIZES: 1230 { 1231 PTABLEDEF pOwningTable; 1227 1232 // re-run calc sizes since we now know all 1228 1233 // the auto-size items … … 1230 1235 ProcessMode, 1231 1236 pDlgData); 1237 1238 1239 // now check if the table has TABLE_ALIGN_COLUMNS enabled 1240 // (START_TABLE_ALIGN or START_GROUP_TABLE_ALIGN macros) 1241 // and, if so, align the colums horizontally by making all 1242 // columns as wide as the widest column in the table 1243 // V0.9.20 (2002-08-08) [umoeller] 1244 if ( (pOwningRow) 1245 && (pOwningTable = pOwningRow->pOwningTable) 1246 && (pOwningTable->flTable & TABLE_ALIGN_COLUMNS) 1247 ) 1248 { 1249 // determine the index of this column in the current row 1250 ULONG ulMyIndex = lstIndexFromItem(&pOwningRow->llColumns, 1251 pColumnDef); 1252 if (ulMyIndex == -1) 1253 arc = DLGERR_INTEGRITY_BAD_COLUMN_INDEX; 1254 else 1255 { 1256 // find the widest column with this index in the table 1257 PLISTNODE pRowNode; 1258 FOR_ALL_NODES(&pOwningTable->llRows, pRowNode) 1259 { 1260 PROWDEF pRowThis = (PROWDEF)pRowNode->pItemData; 1261 PCOLUMNDEF pCorrespondingColumn; 1262 if ( (pCorrespondingColumn = lstItemFromIndex(&pRowThis->llColumns, ulMyIndex)) 1263 && (pCorrespondingColumn->cpColumn.cx > pColumnDef->cpColumn.cx) 1264 ) 1265 pColumnDef->cpColumn.cx = pCorrespondingColumn->cpColumn.cx; 1266 } 1267 } 1268 } 1269 } 1232 1270 break; 1233 1271 … … 1279 1317 pRowDef->pOwningTable = pOwningTable; 1280 1318 1281 if ( (ProcessMode == PROCESS_1_CALC_SIZES) 1282 || (ProcessMode == PROCESS_3_CALC_FINAL_TABLE_SIZES) 1283 ) 1284 { 1285 pRowDef->cpRow.cx = 0; 1286 pRowDef->cpRow.cy = 0; 1287 } 1288 else if (ProcessMode == PROCESS_4_CALC_POSITIONS) 1289 { 1290 // set up x and y so that the columns can 1291 // base on that 1292 pRowDef->cpRow.x = pOwningTable->cpTable.x; 1293 // decrease y by row height 1294 *plY -= pRowDef->cpRow.cy; 1295 // and use that for our bottom position 1296 pRowDef->cpRow.y = *plY; 1297 1298 // set lX to left of row; used by column calls below 1299 lX = pRowDef->cpRow.x; 1319 switch (ProcessMode) 1320 { 1321 case PROCESS_1_CALC_SIZES: 1322 case PROCESS_3_CALC_FINAL_TABLE_SIZES: 1323 pRowDef->cpRow.cx = 0; 1324 pRowDef->cpRow.cy = 0; 1325 break; 1326 1327 case PROCESS_4_CALC_POSITIONS: 1328 // set up x and y so that the columns can 1329 // base on that 1330 pRowDef->cpRow.x = pOwningTable->cpTable.x; 1331 // decrease y by row height 1332 *plY -= pRowDef->cpRow.cy; 1333 // and use that for our bottom position 1334 pRowDef->cpRow.y = *plY; 1335 1336 // set lX to left of row; used by column calls below 1337 lX = pRowDef->cpRow.x; 1338 break; 1300 1339 } 1301 1340 … … 1356 1395 { 1357 1396 case PROCESS_1_CALC_SIZES: 1397 pTableDef->cpTable.cx = 0; 1398 pTableDef->cpTable.cy = 0; 1399 break; 1400 1358 1401 case PROCESS_3_CALC_FINAL_TABLE_SIZES: 1359 1402 pTableDef->cpTable.cx = 0; … … 1404 1447 * 1405 1448 * The first trick to formatting is that ProcessAll will 1406 * get three times, thus going down the entire tree three1449 * get FIVE times, thus going down the entire tree FIVE 1407 1450 * times, with ProcessMode being set to one of the 1408 1451 * following for each call (in this order): … … 1510 1553 { 1511 1554 // create column and store ctl def 1512 PCOLUMNDEF pColumnDef = NEW(COLUMNDEF);1513 if (! pColumnDef)1555 PCOLUMNDEF pColumnDef; 1556 if (!(pColumnDef = NEW(COLUMNDEF))) 1514 1557 arc = ERROR_NOT_ENOUGH_MEMORY; 1515 1558 else … … 1706 1749 lstInit(&pCurrentTable->llRows, FALSE); 1707 1750 1708 if (pItemThis->ulData) 1709 // control specified: store it (this will become a PM group) 1710 pCurrentTable->pCtlDef = (PCONTROLDEF)pItemThis->ulData; 1751 // if control specified: store it (this will become a PM group) 1752 pCurrentTable->pCtlDef = pItemThis->pCtlDef; // can be NULL for plain table 1753 1754 pCurrentTable->flTable = pItemThis->fl; // V0.9.20 (2002-08-08) [umoeller] 1711 1755 1712 1756 if (fIsRoot) … … 1756 1800 lstInit(&pCurrentRow->llColumns, FALSE); 1757 1801 1758 pCurrentRow->flRowFormat = pItemThis-> ulData;1802 pCurrentRow->flRowFormat = pItemThis->fl; 1759 1803 1760 1804 lstAppendItem(&pCurrentTable->llRows, pCurrentRow); … … 1774 1818 if (!(arc = CreateColumn(pCurrentRow, 1775 1819 FALSE, // no nested table 1776 (PVOID)pItemThis-> ulData,1820 (PVOID)pItemThis->pCtlDef, 1777 1821 &pColumnDef))) 1778 1822 lstAppendItem(&pCurrentRow->llColumns, … … 1961 2005 * automatically here. Even better, for many controls, 1962 2006 * auto-sizing is supported according to the control's 1963 * text (e.g. for statics and checkboxes). In a way,1964 * this is a bitsimilar to HTML tables.2007 * text (e.g. for statics and checkboxes). This is 2008 * quite similar to HTML tables. 1965 2009 * 1966 2010 * A regular standard dialog would use something like … … 2005 2049 * -- START_TABLE starts a new table. The tables may nest, 2006 2050 * but must each be properly terminated with END_TABLE. 2051 * 2052 * Note that as opposed to HTML tables, the columns 2053 * in the rows of the table are NOT aligned under each 2054 * other. If that is what you want, use START_TABLE_ALIGN 2055 * instead. 2007 2056 * 2008 2057 * -- START_GROUP_TABLE(pDef) starts a group. This … … 2017 2066 * terminated with END_TABLE. 2018 2067 * 2068 * As with START_TABLE, columns in the rows of the table 2069 * are NOT aligned under each other. If that is what you 2070 * want, use START_GROUP_TABLE_ALIGN instead. 2071 * 2019 2072 * -- START_ROW(fl) starts a new row in a table (regular 2020 2073 * or group). This must also be the first item after … … 2044 2097 * control items will be considered to be in the same 2045 2098 * row (== positioned next to each other). 2099 * 2100 * Columns will only be aligned horizontally if the 2101 * container table was specified with START_TABLE_ALIGN 2102 * or START_GROUP_TABLE_ALIGN. 2046 2103 * 2047 2104 * There are a few rules, whose violation will produce … … 2163 2220 * specify a row first. 2164 2221 * 2165 * -- DLGERR_NULL_CTL_DEF: TYPE_END_TABLE was specified,2166 * but the CONTROLDEF ptrwas NULL.2222 * -- DLGERR_NULL_CTL_DEF: A required CONTROLDEF ptr 2223 * was NULL. 2167 2224 * 2168 2225 * -- DLGERR_CANNOT_CREATE_FRAME: unable to create the 2169 * WC_FRAME window. Maybe an invalid owner was specified. 2226 * WC_FRAME window. Typically an invalid owner was 2227 * specified. 2170 2228 * 2171 2229 * -- DLGERR_INVALID_CODE: invalid "Type" field in
Note:
See TracChangeset
for help on using the changeset viewer.