Changeset 202


Ignore:
Timestamp:
Aug 11, 2002, 10:23:44 PM (23 years ago)
Author:
umoeller
Message:

Sources as of V0.9.20.

Location:
trunk
Files:
2 edited

Legend:

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

    r201 r202  
    340340/*
    341341 *@@ CalcAutoSizeText:
     342 *      implementation for CalcAutoSize for static
     343 *      text, single and multi-line.
    342344 *
    343345 *@@changed V0.9.12 (2001-05-31) [umoeller]: fixed various things with statics
     
    403405
    404406/*
     407 *@@ CalcAutoSizeTextView:
     408 *      implementation for CalcAutoSize for the XTextView
     409 *      control.
     410 *
     411 *      This is slightly sick. We create the control already
     412 *      here in order to be able to have it format the text
     413 *      and then send TXM_QUERYTEXTEXTENT to it. The control
     414 *      that was created here will then be used by
     415 *      ColumnCreateControls and not be recreated, which would
     416 *      be way too expensive.
     417 *
     418 *@@added V0.9.20 (2002-08-10) [umoeller]
     419 */
     420
     421static APIRET CalcAutoSizeTextView(const CONTROLDEF *pControlDef,
     422                                   ULONG ulWidth,            // in: proposed width of control
     423                                   PSIZEL pszlAuto,          // out: computed size
     424                                   PDLGPRIVATE pDlgData)
     425{
     426    APIRET arc = NO_ERROR;
     427
     428    HWND hwnd = NULLHANDLE;
     429    PCSZ pcszTitle;
     430
     431    PLISTNODE pTempNode;
     432    HWND hwndFound = NULLHANDLE;
     433    FOR_ALL_NODES(&pDlgData->llTempControls, pTempNode)
     434    {
     435        HWND hwndThis = (HWND)pTempNode->pItemData;
     436        if (WinQueryWindowUShort(hwndThis, QWS_ID) == pControlDef->usID)
     437        {
     438            hwnd = hwndThis;
     439
     440            // resize it to what we really need
     441            WinSetWindowPos(hwndThis,
     442                            HWND_BOTTOM,
     443                            0,
     444                            0,
     445                            ulWidth,
     446                            2000,
     447                            SWP_SIZE);
     448            break;
     449        }
     450    }
     451
     452    if (!hwnd)
     453    {
     454        if (hwnd = WinCreateWindow(pDlgData->hwndDlg,   // parent
     455                                   (PSZ)pControlDef->pcszClass,
     456                                   NULL,
     457                                   pControlDef->flStyle,
     458                                   0,
     459                                   0,
     460                                   ulWidth,
     461                                   2000,         // cy, for now
     462                                   pDlgData->hwndDlg,   // owner
     463                                   HWND_BOTTOM,
     464                                   pControlDef->usID,
     465                                   pControlDef->pvCtlData,
     466                                   NULL))
     467        {
     468            PCSZ pcszFont = pControlDef->pcszFont;
     469                            // can be NULL, or CTL_COMMON_FONT
     470            if (pcszFont == CTL_COMMON_FONT)
     471                pcszFont = pDlgData->pcszControlsFont;
     472
     473            if (pcszFont)
     474                winhSetWindowFont(hwnd,
     475                                  pcszFont);
     476
     477            WinSetWindowText(hwnd,
     478                             (pcszTitle = pControlDef->pcszText)
     479                                 ? (PSZ)pcszTitle
     480                                 : "");
     481
     482            // store the window we have created in the temp
     483            // windows list so it can be reused in
     484            // ColumnCreateControls
     485            lstAppendItem(&pDlgData->llTempControls,
     486                          (PVOID)hwnd);
     487        }
     488        else
     489            arc = DLGERR_CANNOT_CREATE_CONTROL;
     490    }
     491
     492    if (hwnd)
     493    {
     494        SIZEL szlTemp;
     495        WinSendMsg(hwnd,
     496                   TXM_QUERYTEXTEXTENT,
     497                   (MPARAM)&szlTemp,
     498                   0);
     499
     500        pszlAuto->cy = szlTemp.cy;
     501    }
     502
     503    return arc;
     504}
     505
     506/*
    405507 *@@ CalcAutoSize:
     508 *      helper func that gets called from ColumnCalcSizes for
     509 *      every control that has set SZL_AUTOSIZE for its size.
     510 *
     511 *      We try to be smart and set a correct size for the
     512 *      control, depending on its class and data.
     513 *
     514 *      Presently this works for
     515 *
     516 *      --  static text, single and multiline
     517 *
     518 *      --  static icons and bitmaps
     519 *
     520 *      --  pushbuttons, radio buttons, and checkboxes
     521 *
     522 *      --  the XTextView control (yes! V0.9.20).
    406523 *
    407524 *@@changed V0.9.12 (2001-05-31) [umoeller]: fixed various things with statics
    408525 *@@changed V0.9.16 (2001-10-15) [umoeller]: added APIRET
     526 *@@changed V0.9.20 (2002-08-10) [umoeller]: added support for textview
    409527 */
    410528
     
    488606
    489607        default:
    490             if (!strcmp(pControlDef->pcszClass, WC_XTEXTVIEW))
     608            // added support for textview V0.9.20 (2002-08-10) [umoeller]
     609            if (    (((ULONG)pControlDef->pcszClass & 0xFFFF0000) != 0xFFFF0000)
     610                 && (!strcmp(pControlDef->pcszClass, WC_XTEXTVIEW))
     611               )
    491612            {
    492                 HWND hwnd = NULLHANDLE;
    493                 PCSZ pcszTitle;
    494 
    495                 PLISTNODE pTempNode;
    496                 HWND hwndFound = NULLHANDLE;
    497                 FOR_ALL_NODES(&pDlgData->llTempControls, pTempNode)
    498                 {
    499                     HWND hwndThis = (HWND)pTempNode->pItemData;
    500                     if (WinQueryWindowUShort(hwndThis, QWS_ID) == pControlDef->usID)
    501                     {
    502                         hwnd = hwndThis;
    503 
    504                         // resize it to what we really need
    505                         WinSetWindowPos(hwndThis,
    506                                         HWND_BOTTOM,
    507                                         0,
    508                                         0,
    509                                         ulWidth,
    510                                         2000,
    511                                         SWP_SIZE);
    512                         break;
    513                     }
    514                 }
    515 
    516                 if (!hwnd)
    517                 {
    518                     if (hwnd = WinCreateWindow(pDlgData->hwndDlg,   // parent
    519                                                (PSZ)pControlDef->pcszClass,
    520                                                NULL,
    521                                                pControlDef->flStyle,
    522                                                0,
    523                                                0,
    524                                                ulWidth,
    525                                                2000,         // cy, for now
    526                                                pDlgData->hwndDlg,   // owner
    527                                                HWND_BOTTOM,
    528                                                pControlDef->usID,
    529                                                pControlDef->pvCtlData,
    530                                                NULL))
    531                     {
    532                         PCSZ pcszFont = pControlDef->pcszFont;
    533                                         // can be NULL, or CTL_COMMON_FONT
    534                         if (pcszFont == CTL_COMMON_FONT)
    535                             pcszFont = pDlgData->pcszControlsFont;
    536 
    537                         if (pcszFont)
    538                             winhSetWindowFont(hwnd,
    539                                               pcszFont);
    540 
    541                         WinSetWindowText(hwnd,
    542                                          (pcszTitle = pControlDef->pcszText)
    543                                              ? (PSZ)pcszTitle
    544                                              : "");
    545 
    546                         // store the window we have created in the temp
    547                         // windows list so it can be reused in
    548                         // ColumnCreateControls
    549                         lstAppendItem(&pDlgData->llTempControls,
    550                                       (PVOID)hwnd);
    551                     }
    552                     else
    553                         arc = DLGERR_CANNOT_CREATE_CONTROL;
    554                 }
    555 
    556                 if (hwnd)
    557                 {
    558                     SIZEL szlTemp;
    559                     WinSendMsg(hwnd,
    560                                TXM_QUERYTEXTEXTENT,
    561                                (MPARAM)&szlTemp,
    562                                0);
    563 
    564                     pszlAuto->cy = szlTemp.cy;
    565                 }
     613                arc = CalcAutoSizeTextView(pControlDef,
     614                                           ulWidth,
     615                                           pszlAuto,
     616                                           pDlgData);
    566617            }
    567618            else
Note: See TracChangeset for help on using the changeset viewer.