Ignore:
Timestamp:
May 31, 2001, 9:13:25 PM (24 years ago)
Author:
umoeller
Message:

Fixes to dialogs and other stuff.

File:
1 edited

Legend:

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

    r74 r79  
    103103
    104104    HPS         hps;
    105     const char  *pcszFontLast;
    106     LONG        lcidLast;
     105    /* const char  *pcszFontLast;
     106    LONG        lcidLast; */
    107107} DLGPRIVATE, *PDLGPRIVATE;
    108108
     
    215215 *@@ CalcAutoSizeText:
    216216 *
     217 *@@changed V0.9.12 (2001-05-31) [umoeller]: fixed various things with statics
     218 *@@changed V0.9.12 (2001-05-31) [umoeller]: fixed broken fonts
    217219 */
    218220
     
    222224                      PDLGPRIVATE pDlgData)
    223225{
    224     BOOL        fFind = TRUE;
     226    BOOL        fFind = FALSE;
    225227    RECTL       rclText;
     228    LONG        lcid = 0;
    226229
    227230    const char *pcszFontThis = pControlDef->pcszFont;
     
    233236
    234237    if (!pDlgData->hps)
    235     {
    236         // first call: get a PS
    237238        pDlgData->hps = WinGetPS(pDlgData->hwndDlg);
    238         fFind = TRUE;
    239     }
    240     else
    241         if (strhcmp(pcszFontThis, pDlgData->pcszFontLast))
    242             fFind = TRUE;
    243 
    244     if (fFind)
     239
     240    if (pcszFontThis)
    245241    {
    246242        FONTMETRICS fm;
    247         LONG lcid;
    248243        LONG lPointSize = 0;
    249         if (pDlgData->lcidLast)
    250         {
    251             // delete old font
    252             GpiSetCharSet(pDlgData->hps, LCID_DEFAULT);
    253             GpiDeleteSetId(pDlgData->hps, pDlgData->lcidLast);
    254         }
    255244
    256245        // create new font
    257         pDlgData->lcidLast = gpihFindPresFont(NULLHANDLE,        // no window yet
    258                                               FALSE,
    259                                               pDlgData->hps,
    260                                               pcszFontThis,
    261                                               &fm,
    262                                               &lPointSize);
    263         GpiSetCharSet(pDlgData->hps, pDlgData->lcidLast);
     246        lcid = gpihFindPresFont(NULLHANDLE,        // no window yet
     247                                FALSE,
     248                                pDlgData->hps,
     249                                pcszFontThis,
     250                                &fm,
     251                                &lPointSize);
     252        GpiSetCharSet(pDlgData->hps, lcid);
    264253        if (fm.fsDefn & FM_DEFN_OUTLINE)
    265254            gpihSetPointSize(pDlgData->hps, lPointSize);
     
    275264        if (fMultiLine)
    276265        {
    277             RECTL rcl = {0, 0, 1000, 1000};
     266            RECTL rcl = {0, 0, 0, 0};
     267            if (pControlDef->szlControlProposed.cx != -1)
     268                rcl.xRight = pControlDef->szlControlProposed.cx;   // V0.9.12 (2001-05-31) [umoeller]
     269            else
     270                rcl.xRight = winhQueryScreenCX() * 2 / 3;
     271            if (pControlDef->szlControlProposed.cy != -1)
     272                rcl.yTop = pControlDef->szlControlProposed.cy;   // V0.9.12 (2001-05-31) [umoeller]
     273            else
     274                rcl.yTop = winhQueryScreenCY() * 2 / 3;
     275
    278276            winhDrawFormattedText(pDlgData->hps,
    279277                                  &rcl,
     
    294292        }
    295293    }
     294
     295    /* if (lcid)
     296    {
     297        GpiSetCharSet(pDlgData->hps, LCID_DEFAULT);
     298        GpiDeleteSetId(pDlgData->hps, lcid);
     299    } */
     300
    296301}
    297302
     
    299304 *@@ CalcAutoSize:
    300305 *
     306 *@@changed V0.9.12 (2001-05-31) [umoeller]: fixed various things with statics
    301307 */
    302308
     
    336342
    337343        case 0xffff0005L: // WC_STATIC:
    338             if (pControlDef->flStyle & SS_TEXT)
     344            if ((pControlDef->flStyle & 0x0F) == SS_TEXT)
    339345                CalcAutoSizeText(pControlDef,
    340346                                 ((pControlDef->flStyle & DT_WORDBREAK) != 0),
    341347                                 pszlAuto,
    342348                                 pDlgData);
    343             else if (pControlDef->flStyle & SS_BITMAP)
     349            else if ((pControlDef->flStyle & 0x0F) == SS_BITMAP)
    344350            {
    345351                HBITMAP hbm = (HBITMAP)pControlDef->pcszText;
     
    357363                }
    358364            }
     365            else if ((pControlDef->flStyle & 0x0F) == SS_ICON)
     366            {
     367                pszlAuto->cx = WinQuerySysValue(HWND_DESKTOP, SV_CXICON);
     368                pszlAuto->cy = WinQuerySysValue(HWND_DESKTOP, SV_CYICON);
     369            }
    359370        break;
    360371    }
     
    397408 *         after the recursion.
    398409 *
     410 *@@changed V0.9.12 (2001-05-31) [umoeller]: added control data
     411 *@@changed V0.9.12 (2001-05-31) [umoeller]: fixed font problems
    399412 */
    400413
     
    559572            ULONG       flStyle = 0;
    560573            LHANDLE     lHandleSet = NULLHANDLE;
     574            ULONG       flOld = 0;
    561575
    562576            if (pColumnDef->fIsNestedTable)
     
    594608                // we have used a HBITMAP in there!
    595609                if (    ((ULONG)pControlDef->pcszClass == 0xffff0005L) // WC_STATIC:
    596                      && (flStyle & SS_BITMAP)
     610                     && (    ((flStyle & 0x0F) == SS_BITMAP)
     611                          || ((flStyle & 0x0F) == SS_ICON)
     612                        )
    597613                   )
    598614                {
    599                     // change style flag to not use SS_BITMAP;
     615                    // change style flag to not use SS_BITMAP nor SS_ICON;
    600616                    // control creation fails otherwise (stupid, stupid PM)
    601                     flStyle = ((flStyle & ~SS_BITMAP) | SS_FGNDFRAME);
     617                    flOld = flStyle;
     618                    flStyle = ((flStyle & ~0x0F) | SS_FGNDFRAME);
    602619                    pcszTitle = "";
    603620                    lHandleSet = (LHANDLE)pControlDef->pcszText;
     
    608625            {
    609626                // create something:
    610                 PPRESPARAMS ppp = NULL;
     627                // PPRESPARAMS ppp = NULL;
    611628
    612629                const char  *pcszFont = pControlDef->pcszFont;
     
    615632                    pcszFont = pDlgData->pcszControlsFont;
    616633
    617                 if (pcszFont)
     634                /* if (pcszFont)
    618635                    winhStorePresParam(&ppp,
    619636                                       PP_FONTNAMESIZE,
    620637                                       strlen(pcszFont),
    621                                        (PVOID)pcszFont);
     638                                       (PVOID)pcszFont); */
    622639
    623640                pColumnDef->hwndControl
     
    635652                                      HWND_BOTTOM,
    636653                                      pControlDef->usID,
    637                                       NULL,             // @@todo control data
    638                                       ppp);
    639 
    640                 if (pColumnDef->hwndControl && lHandleSet)
     654                                      pControlDef->pvCtlData,
     655                                      NULL); // ppp);
     656
     657                if ((pColumnDef->hwndControl) && (lHandleSet))
    641658                {
    642659                    // subclass the damn static
    643                     ctlPrepareStretchedBitmap(pColumnDef->hwndControl,
    644                                               TRUE);
     660                    if ((flOld & 0x0F) == SS_ICON)
     661                        // this was a static:
     662                        ctlPrepareStaticIcon(pColumnDef->hwndControl,
     663                                             1);
     664                    else
     665                        // this was a bitmap:
     666                        ctlPrepareStretchedBitmap(pColumnDef->hwndControl,
     667                                                  TRUE);
    645668
    646669                    WinSendMsg(pColumnDef->hwndControl,
     
    649672                               0);
    650673                }
    651 
    652                 if (ppp)
    653                     free(ppp);
     674                else
     675                    if (pcszFont)
     676                        // we must set the font explicitly here...
     677                        // doesn't always work with WinCreateWindow
     678                        // presparams parameter, for some reason
     679                        // V0.9.12 (2001-05-31) [umoeller]
     680                        winhSetWindowFont(pColumnDef->hwndControl,
     681                                          pcszFont);
    654682
    655683                if (pColumnDef->hwndControl)
     
    13231351
    13241352        FRAMECDATA      fcData = {0};
     1353        ULONG           flStyle = 0;
    13251354
    13261355        #define FCF_DIALOGBOX   0x40000000L
     
    13281357        fcData.cb = sizeof(FRAMECDATA);
    13291358        fcData.flCreateFlags = flCreateFlags | FCF_DIALOGBOX;
     1359
     1360        if (flCreateFlags & FCF_SIZEBORDER)
     1361            // dialog has size border:
     1362            // add "clip siblings" style
     1363            flStyle |= WS_CLIPSIBLINGS;
    13301364
    13311365        pDlgData->hwndDlg = WinCreateWindow(HWND_DESKTOP,
    13321366                                            WC_FRAME,
    13331367                                            (PSZ)pcszDlgTitle,
    1334                                             0,               // style; invisible for now
     1368                                            flStyle,        // style; invisible for now
    13351369                                            0, 0, 0, 0,
    13361370                                            hwndOwner,
    13371371                                            HWND_TOP,
    1338                                             0,               // ID
     1372                                            0,              // ID
    13391373                                            &fcData,
    1340                                             NULL);           // presparams
     1374                                            NULL);          // presparams
    13411375
    13421376        if (!pDlgData->hwndDlg)
     
    13571391                       PROCESS_CALC_SIZES);
    13581392
    1359             // this might have created a HPS and a font in dlgdata
    1360             // for auto-sizing controls
    13611393            if (pDlgData->hps)
    1362             {
    1363                 if (pDlgData->lcidLast)
    1364                 {
    1365                     // delete old font
    1366                     GpiSetCharSet(pDlgData->hps, LCID_DEFAULT);
    1367                     GpiDeleteSetId(pDlgData->hps, pDlgData->lcidLast);
    1368                     pDlgData->lcidLast = 0;
    1369                 }
    1370 
    13711394                WinReleasePS(pDlgData->hps);
    1372                 pDlgData->hps = NULLHANDLE;
    1373             }
    13741395
    13751396            WinSubclassWindow(pDlgData->hwndDlg, pfnwpDialogProc);
     
    16491670            // control
    16501671
    1651             _Pmpf((__FUNCTION__ ": hwnd 0x%lX", hwnd));
     1672            // _Pmpf((__FUNCTION__ ": hwnd 0x%lX", hwnd));
    16521673
    16531674            // check if this is a focusable control
     
    17021723            if (!strcmp(szClass, "#3"))    // button
    17031724            {
    1704                 _Pmpf((__FUNCTION__ ": found button"));
     1725                // _Pmpf((__FUNCTION__ ": found button"));
    17051726                if (    (WinQueryWindowULong(hwnd, QWL_STYLE) & (BS_PUSHBUTTON | BS_DEFAULT))
    17061727                     == (BS_PUSHBUTTON | BS_DEFAULT)
    17071728                   )
    17081729                {
    1709                     _Pmpf(("   is default!"));
     1730                    // _Pmpf(("   is default!"));
    17101731                    WinPostMsg(hwnd,
    17111732                               BM_CLICK,
Note: See TracChangeset for help on using the changeset viewer.