Ignore:
Timestamp:
Oct 13, 2001, 7:57:58 PM (24 years ago)
Author:
umoeller
Message:

Lots of updates from the last week for conditional compiles and other stuff.

File:
1 edited

Legend:

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

    r106 r108  
    227227
    228228/*
    229  *@@ CalcAutoSizeText:
    230  *
    231  *@@changed V0.9.12 (2001-05-31) [umoeller]: fixed various things with statics
    232  *@@changed V0.9.12 (2001-05-31) [umoeller]: fixed broken fonts
    233  *@@changed V0.9.14 (2001-08-01) [umoeller]: now caching fonts, which is significantly faster
    234  */
    235 
    236 VOID CalcAutoSizeText(PCONTROLDEF pControlDef,
    237                       BOOL fMultiLine,          // in: if TRUE, multiple lines
    238                       PSIZEL pszlAuto,          // out: computed size
    239                       PDLGPRIVATE pDlgData)
    240 {
     229 *@@ SetDlgFont:
     230 *
     231 *@@added V0.9.16 (2001-10-11) [umoeller]
     232 */
     233
     234VOID SetDlgFont(PCONTROLDEF pControlDef,
     235                PDLGPRIVATE pDlgData)
     236{
     237    LONG lPointSize = 0;
    241238    const char *pcszFontThis = pControlDef->pcszFont;
    242239                    // can be NULL,
     
    249246        pDlgData->hps = WinGetPS(pDlgData->hwndDlg);
    250247
    251     if (pcszFontThis)
    252     {
    253         LONG lPointSize = 0;
    254 
    255         // check if we can reuse font data from last time
    256         // V0.9.14 (2001-08-01) [umoeller]
    257         if (strhcmp(pcszFontThis,
    258                     pDlgData->pcszFontLast))
    259         {
    260             // different font than last time:
    261 
    262             // delete old font?
    263             if (pDlgData->lcidLast)
    264             {
    265                 GpiSetCharSet(pDlgData->hps, LCID_DEFAULT);
    266                 GpiDeleteSetId(pDlgData->hps, pDlgData->lcidLast);
    267             }
    268 
     248    // check if we can reuse font data from last time
     249    // V0.9.14 (2001-08-01) [umoeller]
     250    if (strhcmp(pcszFontThis,               // can be NULL!
     251                pDlgData->pcszFontLast))
     252    {
     253        // different font than last time:
     254
     255        // delete old font?
     256        if (pDlgData->lcidLast)
     257        {
     258            GpiSetCharSet(pDlgData->hps, LCID_DEFAULT);     // LCID_DEFAULT == 0
     259            GpiDeleteSetId(pDlgData->hps, pDlgData->lcidLast);
     260        }
     261
     262        if (pcszFontThis)
     263        {
    269264            // create new font
    270265            pDlgData->lcidLast = gpihFindPresFont(NULLHANDLE,        // no window yet
     
    278273            if (pDlgData->fmLast.fsDefn & FM_DEFN_OUTLINE)
    279274                gpihSetPointSize(pDlgData->hps, lPointSize);
    280 
    281             pDlgData->pcszFontLast = pcszFontThis;
    282         }
    283 
    284         pszlAuto->cy =   pDlgData->fmLast.lMaxBaselineExt
    285                        + pDlgData->fmLast.lExternalLeading;
    286     }
     275        }
     276        else
     277        {
     278            // use default font:
     279            // @@todo handle presparams, maybe inherited?
     280            GpiSetCharSet(pDlgData->hps, LCID_DEFAULT);
     281            GpiQueryFontMetrics(pDlgData->hps,
     282                                sizeof(pDlgData->fmLast),
     283                                &pDlgData->fmLast);
     284        }
     285
     286        pDlgData->pcszFontLast = pcszFontThis;      // can be NULL
     287    }
     288}
     289
     290/*
     291 *@@ CalcAutoSizeText:
     292 *
     293 *@@changed V0.9.12 (2001-05-31) [umoeller]: fixed various things with statics
     294 *@@changed V0.9.12 (2001-05-31) [umoeller]: fixed broken fonts
     295 *@@changed V0.9.14 (2001-08-01) [umoeller]: now caching fonts, which is significantly faster
     296 */
     297
     298VOID CalcAutoSizeText(PCONTROLDEF pControlDef,
     299                      BOOL fMultiLine,          // in: if TRUE, multiple lines
     300                      PSIZEL pszlAuto,          // out: computed size
     301                      PDLGPRIVATE pDlgData)
     302{
     303    SetDlgFont(pControlDef, pDlgData);
     304
     305    pszlAuto->cy =   pDlgData->fmLast.lMaxBaselineExt
     306                   + pDlgData->fmLast.lExternalLeading;
    287307
    288308    // ok, we FINALLY have a font now...
     
    396416            }
    397417        break;
     418
     419        default:
     420            // any other control (just to be safe):
     421            SetDlgFont(pControlDef, pDlgData);
     422            pszlAuto->cx = 50;
     423            pszlAuto->cy =   pDlgData->fmLast.lMaxBaselineExt
     424                           + pDlgData->fmLast.lExternalLeading
     425                           + 5;         // some space
    398426    }
    399427}
     
    566594    LHANDLE     lHandleSet = NULLHANDLE;
    567595    ULONG       flOld = 0;
     596
     597    LONG        y, cy;              // for combo box hacks
    568598
    569599    if (pColumnDef->fIsNestedTable)
     
    588618                pcszTitle = pControlDef->pcszText;
    589619                flStyle = pControlDef->flStyle;
     620
     621                y = pcp->y + pDlgData->ptlTotalOfs.y;
     622                cy = pcp->cy;
    590623            }
    591624        }
     
    598631        pcszTitle = pControlDef->pcszText;
    599632        flStyle = pControlDef->flStyle;
     633
     634        y = pcp->y + pDlgData->ptlTotalOfs.y;
     635        cy = pcp->cy;
    600636
    601637        // change the title if this is a static with SS_BITMAP;
     
    613649            pcszTitle = "";
    614650            lHandleSet = (LHANDLE)pControlDef->pcszText;
     651        }
     652        // hack the stupid drop-down combobox which doesn't
     653        // expand otherwise (the size of the drop-down is
     654        // the full size of the control... duh)
     655        else if (    ((ULONG)pControlDef->pcszClass == 0xffff0002L)
     656                  && (flStyle & (CBS_DROPDOWN | CBS_DROPDOWNLIST))
     657                )
     658        {
     659            y -= 100;
     660            cy += 100;
    615661        }
    616662    }
     
    640686                              flStyle,      // hacked
    641687                              pcp->x + pDlgData->ptlTotalOfs.x,
    642                               pcp->y + pDlgData->ptlTotalOfs.y,
     688                              y,
    643689                              pcp->cx,
    644                               pcp->cy,
     690                              cy,
    645691                              pDlgData->hwndDlg,   // owner
    646692                              HWND_BOTTOM,
Note: See TracChangeset for help on using the changeset viewer.