Changeset 115 for trunk/settings.cpp


Ignore:
Timestamp:
Aug 8, 2021, 6:59:05 PM (4 years ago)
Author:
Gregg Young
Message:

Changes to remove obsolete help files; select language based on system language; remove language selection from Gotcha! Quiet; Combine program and help language selection in Gotcha. Changes to get Gotcha! Quiet working in ArcaOS installer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/settings.cpp

    r99 r115  
    3333USHORT ausDef[7] = { 0 };
    3434USHORT ausDefSSW[7] = { 0 };
    35 BOOL  g_installer = FALSE;
    3635
    3736ImageFormatInfo Settings::ifi[BMF_INVALID] =
     
    9493};
    9594
     95PTHTH_SE apse2[] =
     96{
     97    new THTH_SES (SEI_SAVEFILE, "Save", "Filename", "gotcha.png"),
     98    new THTH_SES (SEI_FORCESAVEFILE, "Save", "ForceSaveFilename", "force.png"),
     99    new THTH_SEL (SEI_SAVESTYLE, "Save", "Style", SAVESTYLE_FILE),
     100    new THTH_SEL (SEI_FILEFORMAT, "Save", "FileFormat", BMF_PNG),
     101    new THTH_SEL (SEI_FILESAVESTYLE, "Save", "FileSaveStyle", FSS_NUMFILES),
     102
     103    new THTH_SES (SEI_NUMSAVEDIR, "Save", "NumSaveDir", ""),
     104    new THTH_SEF (SEI_HIDEWINDOW, "Extras", "HideWindow", TRUE),
     105    new THTH_SEF (SEI_AUTOADDEXTENSION, "Extras", "AutoaddExtension", TRUE),
     106    new THTH_SEF (SEI_CONFIRMOVERWRITE, "Extras", "ConfirmOverwrite", TRUE),
     107    new THTH_SEF (SEI_DOSOUND, "Extras", "DoSound", TRUE),
     108
     109    new THTH_SEF (SEI_DELAYEDCAPTURE, "Extras", "DelayedCapture", FALSE),
     110    new THTH_SEF (SEI_DELAYCOUNTDOWN, "Extras", "DelayCountdown", FALSE),
     111    new THTH_SEL (SEI_DELAYTIME, "Extras", "DelayTime", 5),
     112    new THTH_SEF (SEI_SERIALCAPTURE, "Extras", "SerialCapture", FALSE),
     113    new THTH_SEL (SEI_SERIALTIME, "Extras", "SerialTime", 10),
     114#ifdef _QUIET_
     115    new THTH_SEL (SEI_SSWCAPTURETYPE, "Extras", "CaptureType", CAP_SCREEN),
     116    new THTH_SEF (SEI_SNAPSHOTWINDOW, "Snapshot", NULL, NULL),
     117#else
     118    new THTH_SEF (SEI_SNAPSHOTWINDOW, "Snapshot", "Enable", FALSE),
     119    new THTH_SEL (SEI_SSWCAPTURETYPE, "Snapshot", "CaptureType", CAP_SCREEN),
     120    new THTH_SEF (SEI_SSWHIDE, "Snapshot", "Hide", TRUE),
     121    new THTH_SEF (SEI_SSWALWAYSONTOP, "Snapshot", "AlwaysOnTop", TRUE),
     122#endif
     123    new THTH_SEF (SEI_IDLEPRIORITY, "Extras", "IdlePriority", FALSE),
     124
     125    new THTH_SEB (SEI_SWP, "Window", "SWP", &swpDef, sizeof (swpDef)),
     126    new THTH_SEB (SEI_US, "Window", "US", &ausDef, sizeof (ausDef)),
     127#ifndef _QUIET_
     128    new THTH_SEB (SEI_SWPSSW, "Snapshot", "SWP", &swpDefSSW, sizeof (swpDefSSW)),
     129    new THTH_SEB (SEI_USSSW, "Snapshot", "US", &ausDefSSW, sizeof (ausDefSSW)),
     130#endif
     131    new THTH_SES (SEI_LANGUAGE,     "Language", "Program", PSZ_DEFAULTLANGUAGEMOD),
     132    new THTH_SES (SEI_LANGUAGEHELP, "Language", "Help", PSZ_DEFAULTLANGUAGEHELP),
     133
     134    new THTH_SEF (SEI_UPDATE178DONE, "Extras", "Update178Done", FALSE),
     135
     136    NULL,
     137};
     138
    96139// ** Settings ************************************************************ /*FOLD00*/
    97140
    98141Settings :: Settings (VOID) :
    99142#ifdef _QUIET_
    100     ththSettings(apse, "gotchaq.ini", L_PROFILEVERSION)
     143    ththSettings(g_installer ? apse2 : apse, g_installer ? g_installerINI : "gotchaq.ini",
     144                 L_PROFILEVERSION)
    101145#else
    102146    ththSettings(apse, "gotcha.ini", L_PROFILEVERSION)
     
    104148{
    105149    if( ! QueryFlag( SEI_UPDATE178DONE ) ) {
    106         //DisplayError( "Updated", "false" );
    107150        SetLong( SEI_SERIALTIME, QueryLong( SEI_SERIALTIME ) * 20 );
    108151        SetFlag( SEI_UPDATE178DONE );
    109     } /*else {
    110         //DisplayError( "NOT Updated", "true" );
    111         } */
    112 #ifdef _QUIET_
    113     HINI hini = PrfOpenProfile (hab, "gotchaq.ini");
     152    }
     153#ifdef _QUIET_
     154    HINI hini;
     155    if (!g_installer)
     156        hini = PrfOpenProfile (hab, "gotchaq.ini");
    114157#else
    115158    HINI hini = PrfOpenProfile (hab, "gotcha.ini");
    116159#endif
    117160    BOOL fLChange = FALSE;
    118     ULONG ulDataSize;
    119     PrfQueryProfileSize(hini, "Language", "LangChangeRequested", &ulDataSize );
    120     PrfQueryProfileData(hini, "Language", "LangChangeRequested", &fLChange, &ulDataSize);
     161    if (!g_installer) {
     162        ULONG ulDataSize;
     163        PrfQueryProfileSize(hini, "Language", "LangChangeRequested", &ulDataSize );
     164        PrfQueryProfileData(hini, "Language", "LangChangeRequested", &fLChange, &ulDataSize);
     165        }
    121166    if (!fLChange) {
    122167    CHAR *lang = getenv("LANG");
     
    129174    if (lang) {
    130175        if (!strnicmp(lang, "es", 2)) {
     176#ifdef _QUIET_
     177            psz = "goqreses";
     178#else
    131179            psz = "gotreses";
     180#endif
    132181            pszh = "gotcha_es";
    133182        }
    134183        else if (!strnicmp(lang, "cs", 2)) {
     184#ifdef _QUIET_
     185            psz = "goqrescz";
     186#else
    135187            psz = "gotrescz";
     188#endif
    136189        }
    137190        else if (!strnicmp(lang, "de", 2)) {
     191#ifdef _QUIET_
     192            psz = "goqresde";
     193#else
    138194            psz = "gotresde";
     195#endif
    139196        }
    140197        else if (!strnicmp(lang, "it", 2)) {
     198#ifdef _QUIET_
     199            psz = "goqresit";
     200#else
    141201            psz = "gotresit";
    142             pszh = "gotcha_it";
     202#endif
    143203        }
    144204        else if (!strnicmp(lang, "br", 2)) {
     205#ifdef _QUIET_
     206            psz = "goqresbr";
     207#else
    145208            psz = "gotresbr";
    146             pszh = "gotcha_br";
    147         }
    148     }
    149     SetString(SEI_LANGUAGE, psz);
    150     SetString (SEI_LANGUAGEHELP, pszh);
    151     Save ();
    152     }
    153     if (hini)
    154         PrfCloseProfile (hini);
     209#endif
     210        }
     211    }
     212        SetString(SEI_LANGUAGE, psz);
     213        SetString (SEI_LANGUAGEHELP, pszh);
     214        if (!g_installer) {
     215            Save ();
     216   
     217            if (hini)
     218                PrfCloseProfile (hini);
     219        }
     220    }
     221    //Reset Save directory for installer
     222    if (g_installer) {
     223        SetNumSaveDir (g_installerSavePath);
     224    }
    155225    // to get the error msgs in default language
    156226    ReloadResources (QueryString(SEI_LANGUAGE));
     
    179249    DisplayError (RSTR(IDS_HEADER_WARNING), RSTR(IDS_ERROR_INIFILEWRONGVERSION),
    180250                  QueryProfileName ());
     251#ifndef _QUIET_
    181252    SelectLanguage();
     253#endif
    182254    return 0;
    183255}
     
    189261    DisplayError (RSTR(IDS_HEADER_ERROR), RSTR(IDS_ERROR_INIFILENOTOPEN),
    190262                  QueryProfileName ());
     263#ifndef _QUIET_
    191264    SelectLanguage();
     265#endif
    192266    return 0;
    193267}
     
    207281
    208282    // load the main dialog window
    209     hwndDlg = WinLoadDlg (HWND_DESKTOP, hwndFrame, (DialogProcedure),
     283    hwndDlg = WinLoadDlg (HWND_DESKTOP, hwndFrame, PFNWP (DialogProcedure),
    210284                          GETMODULE, ID_DLG_SETTINGS, this);
    211285    // FIXME YUKKI! YUKKI!! YUKKI!!! But I'm too lazy to do it better now :-)
     
    262336        for (i = 0; i < cPages; i++)
    263337        {
    264             //BOOKPAGEINFO pi;
    265338            idPage[i] = (ULONG)
    266339                WinSendMsg (hwndNB, BKM_INSERTPAGE, 0L,
    267340                            MPFROM2SHORT (BKA_MAJOR | BKA_AUTOPAGESIZE,
    268341                                          BKA_LAST));
    269 #if 0
    270             pi.cb = sizeof(pi);
    271             pi.fl = BFA_PAGEFROMDLGRES | BFA_MAJORTABTEXT;
    272             pi.bLoadDlg = TRUE;
    273             pi.hmodPageDlg = g_hmod;
    274             switch (i) {
    275 #ifndef  _QUIET_
    276             case 0:
    277                 pi.idPageDlg = ID_DLG_SETTINGSPAGE1;
    278                 pi.pfnPageDlgProc = NULL; //(PFN) Page1Procedure;
    279                 break;
    280 #else
    281             case 0:
    282                 pi.idPageDlg = ID_DLG_SETTINGSPAGE0;
    283                 pi.pfnPageDlgProc = NULL; //(PFN) WindowProcedure;
    284                 break;
    285 #endif
    286             case 1:
    287                 pi.idPageDlg = ID_DLG_SETTINGSPAGE2;
    288                 pi.pfnPageDlgProc = NULL; //(PFN) Page2Procedure;
    289                 break;
    290 #ifndef  _QUIET_
    291             case 2:
    292                 pi.idPageDlg = ID_DLG_SETTINGSPAGE3;
    293                 pi.pfnPageDlgProc = NULL; //(PFN) Page3Procedure;
    294                 break;
    295 #else
    296             case 2:
    297                 pi.idPageDlg = ID_DLG_SETTINGSPAGE1;
    298                 pi.pfnPageDlgProc = NULL; //(PFN) Page1Procedure;
    299                 break;
    300 #endif
    301             case 3:
    302                 pi.idPageDlg = ID_DLG_SETTINGSPAGE4;
    303                 pi.pfnPageDlgProc = NULL; //(PFN) Page4Procedure;
    304                 break;
    305             }
    306             pi.cbMajorTab = strlen(pszPageTab[i]);
    307             pi.pszMajorTab = pszPageTab[i];
    308             pi.cbMinorTab = strlen(pszPageTab[i]);
    309             pi.pszMinorTab = pszPageTab[i];
    310             pi.cbStatusLine = 0;
    311             pi.pszStatusLine = NULL;
    312 #endif
    313342            if (pset->GetLangID() == CZ || pset->GetLangID() == RU || pset->GetLangID() == PL) {
    314343                UniChar     target[300];
     
    339368                WinSendMsg (hwndNB, BKM_SETTABTEXT,
    340369                            MPFROMLONG (idPage[i]), MPFROMP (ucLangStr));
    341                 /*pi.cbMajorTab = strlen(ucLangStr) + 10;
    342                 pi.pszMajorTab = ucLangStr;
    343                 pi.cbMinorTab = 0;
    344                 pi.pszMinorTab = "";*/
    345370                if (uconv_object866)
    346371                    UniFreeUconvObject(uconv_object866);
     
    355380                WinSendMsg (hwndNB, BKM_SETTABTEXT,
    356381                            MPFROMLONG (idPage[i]), MPFROMP (pszPageTab[i]));
    357             //WinSendMsg(hwndNB, BKM_SETPAGEINFO, MPFROMLONG(idPage[i]),
    358               //         MPFROMP(&pi));
    359382        }
    360383#ifndef _QUIET_
     
    390413                    MPFROMLONG (idPage[i]), MPFROMHWND (hwndPage[i]));
    391414
    392 /*    if (fAutoLanguage)
    393         WinSendMsg (hwndNB, BKM_TURNTOPAGE, MPFROMLONG (idPage[0]), 0L);
    394 #if (COUNT_PAGES != 4)
    395 #warning FIXME settings.cpp 264 or so ...
    396 #endif */
    397415    for (i = 0; i < cPages; i++)
    398416        WinSendMsg (hwndPage[i], UM_SETTINGS2DIALOG, 0,0);
     
    402420    WinSendDlgItemMsg (g_hwndPage0, WID_RB_FILE, BM_CLICK,
    403421                       MPFROMSHORT (TRUE), 0);
    404     //WinSendDlgItemMsg (g_hwndPage0, WID_CB_HIDEWINDOW, BM_SETCHECK,
    405     //                   MPFROMLONG (TRUE), MPFROMLONG (0));
    406     //WinSetFocus (WinWindowFromID (hwndDlg, WID_PB_OK), TRUE);
    407     //WinSetFocus( hwndPage[0], FALSE );
    408422#ifdef _QUIET_
    409423    if (HACCEL haccel = WinLoadAccelTable (hab, GETMODULE, 1)) {
     
    438452}
    439453
    440 ULONG winhDrawFormattedText(HPS hps, PRECTL prcl, const char *pcszText, ULONG flCmd);
    441454
    442455// ** DialogProcedure ***************************************************** /*FOLD00*/
     
    461474#endif
    462475        CHAR ucFont[FACESIZE];
     476
    463477        if (pset->GetLangID() == CZ || pset->GetLangID() == RU || pset->GetLangID() == PL) {
    464            HMQ hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
    465            WinSetCp(hmq, 1207);
    466            strcpy(ucFont, "9.Times New Roman MT 30");
    467            WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
    468 
    469478           UniChar     target[300];
    470479           CHAR       ucLangStr[300];
     
    515524           if (uconv_object1207)
    516525               UniFreeUconvObject(uconv_object1207);
    517         }
    518         /*else {
     526           HMQ hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
     527           WinSetCp(hmq, 1207);
     528           strcpy(ucFont, "9.Times New Roman MT 30");
     529           WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
     530        }
     531        else if (g_installer) {
    519532        strcpy(ucFont, "9.WarpSans");
    520533        WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
    521         } */
    522            
     534        }
    523535        return MRESULT (FALSE);
    524536
     
    526538        switch (SHORT1FROMMP (mp1))
    527539        {
     540#if 1
     541        case WID_PB_HELP:{
     542            HWND hwndPage;
     543            USHORT usDlgId;
     544            ULONG ulPageId =
     545                (ULONG) WinSendMsg(WinWindowFromID(hwnd, WID_NB_SETTINGS),
     546                                   BKM_QUERYPAGEID, 0, MPFROM2SHORT(BKA_TOP,
     547                                                                    0));
     548            hwndPage =
     549                LONGFROMMP(WinSendMsg
     550                           (WinWindowFromID(hwnd, WID_NB_SETTINGS),
     551                            BKM_QUERYPAGEWINDOWHWND, MPFROMLONG(ulPageId),
     552                            0));
     553            usDlgId = WinQueryWindowUShort(hwndPage, QWS_ID);
     554
     555            HMQ hmq;
     556            BOOL bUniCodeFont = FALSE;
     557            CHAR ucFont[FACESIZE];
     558           
     559            if (pset->GetLangID() == RU) {
     560                hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
     561                WinSetCp(hmq, 866);
     562                bUniCodeFont = TRUE;
     563            }
     564            else if (pset->GetLangID() == CZ || pset->GetLangID() == PL) {
     565                hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
     566                WinSetCp(hmq, 852);
     567                bUniCodeFont = TRUE;
     568            }
     569            else {
     570                hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
     571                WinSetCp(hmq, 850);
     572            }
     573            if (usDlgId == ID_DLG_SETTINGSPAGE0)
     574                g_phelp->DisplayPanel(2);
     575            else if (usDlgId == ID_DLG_SETTINGSPAGE1)
     576                g_phelp->DisplayPanel(2210);
     577#ifdef _QUIET_
     578            else if (usDlgId == ID_DLG_SETTINGSPAGE2 && (pset->GetLangID() != IT &&
     579                                                         pset->GetLangID() != BR))
     580                g_phelp->DisplayPanel(2235);
     581#else
     582            else if (usDlgId == ID_DLG_SETTINGSPAGE2)
     583                g_phelp->DisplayPanel(3);
     584#endif
     585            else if (usDlgId == ID_DLG_SETTINGSPAGE3)
     586                g_phelp->DisplayPanel(2230);
     587            else if (usDlgId == ID_DLG_SETTINGSPAGE4)
     588                g_phelp->DisplayPanel(2240);
     589            else
     590                g_phelp->DisplayPanel(4);
     591            break;
     592        }
     593#endif
    528594        case WID_PB_OK:
    529595#ifdef _DOLOGDEBUG_
     
    679745            WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
    680746        }
    681         /*else {
     747        else if (g_installer) {
    682748            strcpy(ucFont, "9.WarpSans");
    683749            WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
    684         } */
     750        }
    685751
    686752#ifdef _DOLOGDEBUG_
     
    735801                               MPFROMSHORT(0), MPFROMSHORT(TRUE) );
    736802#ifdef _QUIET_
    737 //#if 1
    738803        // set play sound button
    739804        pset->AdjustButton (hwnd, WID_CB_DOSOUND,
     
    782847                pset->SetFileSaveStyle (FSS_PROMPT);
    783848#ifdef _QUIET_
    784 //#if 1
    785849            pset->DoSound(WinQueryButtonCheckstate
    786850                          (hwnd, WID_CB_DOSOUND));
     
    886950            WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
    887951        }
    888         /*else {
     952        else if (g_installer) {
    889953            strcpy(ucFont, "9.WarpSans");
    890954            WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
    891         } */
     955        }
    892956        return MRESULT (FALSE);
    893957    }
     
    915979                            pset->SSWAlwaysOnTop ());
    916980#else
    917 //#if 1
    918981        pset->AdjustButton (hwnd, WID_CB_SERIALCAPTURE,
    919982                            pset->SerialCapture ());
     
    9721035#endif
    9731036#ifndef _QUIET_
    974 //#if 0
    9751037        // query state of checkbuttons and set flags
    9761038        pset->SSWHide(WinQueryButtonCheckstate(hwnd, WID_CB_SSWHIDE));
     
    10091071            pset->SetSSWCaptureType (CAP_SCREEN);
    10101072#ifdef _QUIET_
    1011 //#if 1
    10121073        // delay time
    10131074        ULONG   ul;
     
    11081169            WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
    11091170        }
    1110         /*else {
    1111             strcpy(ucFont, "9.WarpSans");
    1112             WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
    1113         } */
    11141171        return MRESULT (FALSE);
    11151172    }
     
    12371294#endif
    12381295            pset = PSETTINGS (mp2);
     1296
    12391297            HMQ hmq = WinQueryWindowULong(hwnd /*WinWindowFromID(hwnd, ID_DLG_SETTINGSPAGE4)*/, QWL_HMQ);
    12401298            WinSetCp(hmq, 1207); // UPF-8 Unicode
     
    13291387                UniFreeUconvObject(uconv_object1207);
    13301388           
    1331             if (pset->GetLangID() == RU || pset->GetLangID() == CZ || pset->GetLangID() == PL ||
    1332                pset->GetLangID() == IT) {
     1389            if (pset->GetLangID() == RU || pset->GetLangID() == CZ || pset->GetLangID() == PL) {
    13331390                strcpy(ucFont, "9.Times New Roman MT 30");
    13341391                WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
    13351392            }
    1336            
    1337             //    WinRemovePresParam(hwnd, PP_FONTNAMESIZE);*/
    1338             //HMQ hmq = WinQueryWindowULong(hwnd /*WinWindowFromID(hwnd, WID_LB_LANGUAGES)*/, QWL_HMQ);
    1339             //WinSetCp(hmq, 1207); // UPF-8 Unicode
     1393            else if (g_installer) {
     1394                strcpy(ucFont, "9.WarpSans");
     1395                WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
     1396            }
    13401397        return MRESULT (FALSE);
    13411398        }
     
    13671424                                                 LM_QUERYITEMHANDLE,
    13681425                                                 MPFROMLONG(i), NULL));
    1369 //                WinQueryLboxItemText (hwndLB, i, ach, sizeof (ach));
     1426
    13701427                if (stricmp (pset->QueryString(SEI_LANGUAGE), psz) == 0)
    13711428                    break;
     
    14231480            else
    14241481                pset->SetString(SEI_LANGUAGE, psz);
    1425 #if 0
    1426             ul = USHORT (WinSendDlgItemMsg (hwnd, WID_LB_LANGUAGESHELP,
    1427                                             LM_QUERYSELECTION,
    1428                                             MPFROMLONG (LIT_FIRST), 0L));
    1429             WinSendDlgItemMsg (hwnd, WID_LB_LANGUAGESHELP, LM_QUERYITEMTEXT,
    1430                                MPFROM2SHORT (ul, sizeof (ach)), MPFROMP (ach));
    1431             if (stricmp (pset->QueryString(SEI_LANGUAGEHELP), ach) == 0 && !fChanged)
    1432                 fChanged = FALSE;
    1433             else
    1434                 pset->SetString (SEI_LANGUAGEHELP, ach);
    1435 #endif
     1482
    14361483            if (fChanged) {
    14371484                if (!stricmp(psz, "gotreses") || !stricmp(psz, "goqreses"))
    14381485                    strcpy(ach, "gotcha_es");
    1439                 else if (!stricmp(psz, "gotresbr") || !stricmp(psz, "goqresbr"))
    1440                     strcpy(ach, "gotcha_br");
    1441                 else if (!stricmp(psz, "gotresit") || !stricmp(psz, "goqresit"))
    1442                     strcpy(ach, "gotcha_it");
     1486                /*else if (!stricmp(psz, "gotresit") || !stricmp(psz, "goqresit"))
     1487                    strcpy(ach, "gotcha_it");*/
    14431488                else
    14441489                    strcpy(ach, "gotcha_en");
     
    17161761    return QueryString( SEI_NUMSAVEDIR );
    17171762}
    1718 
    1719 // ************************************************************************
    1720 
    1721 ULONG winhDrawFormattedText(HPS hps,     // in: presentation space; its settings
    1722                                          // are used, but not altered
    1723                             PRECTL prcl, // in/out: rectangle to use for drawing
    1724                                          // (modified)
    1725                             const char *pcszText, // in: text to draw (zero-terminated)
    1726                             ULONG flCmd) // in: flags like in WinDrawText; I have
    1727                                          // only tested DT_TOP and DT_LEFT though.
    1728                                          // DT_WORDBREAK | DT_TEXTATTRS are always
    1729                                          // set.
    1730                                          // You can specify DT_QUERYEXTENT to only
    1731                                          // have prcl calculated without drawing.
    1732 {
    1733     PSZ     p = (PSZ)pcszText;
    1734     LONG    lDrawn = 1,
    1735             lTotalDrawn = 0,
    1736             lLineCount = 0,
    1737             lOrigYTop = prcl->yTop;
    1738     ULONG   ulTextLen = strlen(pcszText),
    1739             ulCharHeight,
    1740             flCmd2,
    1741             xLeftmost = prcl->xRight,
    1742             xRightmost = prcl->xLeft;
    1743     RECTL   rcl2;
    1744 
    1745     flCmd2 = flCmd | DT_WORDBREAK | DT_TEXTATTRS;
    1746 
    1747     ulCharHeight = 30;//gpihQueryLineSpacing(hps);
    1748 
    1749     while (    (lDrawn)
    1750             && (lTotalDrawn < ulTextLen)
    1751           )
    1752     {
    1753         memcpy(&rcl2, prcl, sizeof(rcl2));
    1754         lDrawn = WinDrawText(hps,
    1755                              ulTextLen-lTotalDrawn,
    1756                              p,
    1757                              &rcl2,
    1758                              0, 0,                       // colors
    1759                              flCmd2);
    1760 
    1761         // update char counters
    1762         p += lDrawn;
    1763         lTotalDrawn += lDrawn;
    1764 
    1765         // update x extents
    1766         if (rcl2.xLeft < xLeftmost)
    1767             xLeftmost = rcl2.xLeft;
    1768         if (rcl2.xRight > xRightmost)
    1769             xRightmost = rcl2.xRight;
    1770 
    1771         // update y for next line
    1772         prcl->yTop -= ulCharHeight;
    1773 
    1774         // increase line count
    1775         lLineCount++;
    1776     }
    1777     prcl->xLeft = xLeftmost;
    1778     prcl->xRight = xRightmost;
    1779     prcl->yBottom = prcl->yTop;
    1780     prcl->yTop = lOrigYTop;
    1781 
    1782     return lLineCount;
    1783 }
Note: See TracChangeset for help on using the changeset viewer.