Ignore:
Timestamp:
Apr 6, 2001, 7:12:11 PM (24 years ago)
Author:
umoeller
Message:

misc changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/dialog.c

    r54 r55  
    157157typedef struct _ROWDEF
    158158{
    159     PTABLEDEF   pOwningTable;   // table whose linked list this row belongs to
    160 
    161     LINKLIST    llColumns;      // contains COLUMNDEF structs, no auto-free
     159    PTABLEDEF   pOwningTable;       // table whose linked list this row belongs to
     160
     161    LINKLIST    llColumns;          // contains COLUMNDEF structs, no auto-free
     162
     163    ULONG       flRowFormat;        // one of:
     164                                    // -- ROW_VALIGN_BOTTOM           0x0000
     165                                    // -- ROW_VALIGN_CENTER           0x0001
     166                                    // -- ROW_VALIGN_TOP              0x0002
    162167
    163168    CONTROLPOS  cpRow;
     
    188193{
    189194    PROCESS_CALC_SIZES,             // step 1
    190     PROCESS_CALC_POSITIONS,         // step 2
    191     PROCESS_CREATE_CONTROLS         // step 3
     195    PROCESS_CALC_POSITIONS,         // step 3
     196    PROCESS_CREATE_CONTROLS         // step 4
    192197} PROCESSMODE;
    193198
     
    212217
    213218VOID CalcAutoSizeText(PCONTROLDEF pControlDef,
     219                      BOOL fMultiLine,          // in: if TRUE, multiple lines
    214220                      PSIZEL pszlAuto,          // out: computed size
    215221                      PDLGPRIVATE pDlgData)
     
    265271    if (pControlDef->pcszText)
    266272    {
    267         POINTL aptl[TXTBOX_COUNT];
    268         GpiQueryTextBox(pDlgData->hps,
    269                         strlen(pControlDef->pcszText),
    270                         (PCH)pControlDef->pcszText,
    271                         TXTBOX_COUNT,
    272                         aptl);
    273         pszlAuto->cx = aptl[TXTBOX_TOPRIGHT].x - aptl[TXTBOX_BOTTOMLEFT].x;
     273        // do we have multiple lines?
     274        if (fMultiLine)
     275        {
     276            RECTL rcl = {0, 0, 1000, 1000};
     277            winhDrawFormattedText(pDlgData->hps,
     278                                  &rcl,
     279                                  pControlDef->pcszText,
     280                                  DT_LEFT | DT_TOP | DT_WORDBREAK | DT_QUERYEXTENT);
     281            pszlAuto->cx = rcl.xRight - rcl.xLeft;
     282            pszlAuto->cy = rcl.yTop - rcl.yBottom;
     283        }
     284        else
     285        {
     286            POINTL aptl[TXTBOX_COUNT];
     287            GpiQueryTextBox(pDlgData->hps,
     288                            strlen(pControlDef->pcszText),
     289                            (PCH)pControlDef->pcszText,
     290                            TXTBOX_COUNT,
     291                            aptl);
     292            pszlAuto->cx = aptl[TXTBOX_TOPRIGHT].x - aptl[TXTBOX_BOTTOMLEFT].x;
     293        }
    274294    }
    275295}
     
    292312        case 0xffff0003L: // WC_BUTTON:
    293313            CalcAutoSizeText(pControlDef,
     314                             FALSE,         // no multiline
    294315                             pszlAuto,
    295316                             pDlgData);
     
    316337            if (pControlDef->flStyle & SS_TEXT)
    317338                CalcAutoSizeText(pControlDef,
     339                                 ((pControlDef->flStyle & DT_WORDBREAK) != 0),
    318340                                 pszlAuto,
    319341                                 pDlgData);
     
    384406    pColumnDef->pOwningRow = pOwningRow;
    385407
    386     // for PROCESS_CALC_SIZES: have control return its size
    387     //      plus spacings into szlControl
    388     // for PROCESS_CALC_POSITIONS: have control compute its
    389     //      position from the column position (there may be
    390     //      spacings)
    391     // for PROCESS_CREATE_CONTROLS: well, create the control
    392408    switch (ProcessMode)
    393409    {
     410        /*
     411         * PROCESS_CALC_SIZES:
     412         *      step 1.
     413         */
     414
    394415        case PROCESS_CALC_SIZES:
    395416        {
     
    454475        break; }
    455476
     477        /*
     478         * PROCESS_CALC_POSITIONS:
     479         *      step 2.
     480         */
     481
    456482        case PROCESS_CALC_POSITIONS:
    457483        {
     
    459485            ULONG ulSpacing = 0;
    460486
    461             // column position = *plX
     487            // column position = *plX on ProcessRow stack
    462488            pColumnDef->cpColumn.x = *plX;
    463489            pColumnDef->cpColumn.y = pOwningRow->cpRow.y;
     490
     491            // check vertical alignment of row;
     492            // we might need to increase column y
     493            switch (pOwningRow->flRowFormat & ROW_VALIGN_MASK)
     494            {
     495                // case ROW_VALIGN_BOTTOM:      // do nothing
     496
     497                case ROW_VALIGN_CENTER:
     498                    if (pColumnDef->cpColumn.cy < pOwningRow->cpRow.cy)
     499                        pColumnDef->cpColumn.y
     500                            += (   (pOwningRow->cpRow.cy - pColumnDef->cpColumn.cy)
     501                                 / 2);
     502                break;
     503
     504                case ROW_VALIGN_TOP:
     505                    if (pColumnDef->cpColumn.cy < pOwningRow->cpRow.cy)
     506                        pColumnDef->cpColumn.y
     507                            += (pOwningRow->cpRow.cy - pColumnDef->cpColumn.cy);
     508                break;
     509            }
    464510
    465511            if (pColumnDef->fIsNestedTable)
     
    481527            *plX += pColumnDef->cpColumn.cx;
    482528
    483             // calculate control pos by applying spacing
     529            // calculate CONTROL pos from COLUMN pos by applying spacing
    484530            pColumnDef->cpControl.x =   pColumnDef->cpColumn.x
    485531                                      + ulSpacing;
     
    499545            }
    500546        break; }
     547
     548        /*
     549         * PROCESS_CREATE_CONTROLS:
     550         *      step 3.
     551         */
    501552
    502553        case PROCESS_CREATE_CONTROLS:
     
    11761227                        lstInit(&pCurrentRow->llColumns, FALSE);
    11771228
     1229                        pCurrentRow->flRowFormat = pItemThis->ulData;
     1230
    11781231                        lstAppendItem(&pCurrentTable->llRows, pCurrentRow);
    11791232                    }
Note: See TracChangeset for help on using the changeset viewer.