Changeset 94 for trunk/settings.cpp


Ignore:
Timestamp:
Jul 17, 2021, 9:24:00 PM (4 years ago)
Author:
Gregg Young
Message:

Add unicode support; Add -i switch for AOS install to GQ; Remove language selection from GQ; Remove help file lang selection from Gotcha; Clean up and rework dialogs/strings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/settings.cpp

    r92 r94  
    1818 ***/
    1919#include <direct.h>
     20#include <uconv.h>
    2021#include "settings.h"
    2122#include "ctype.h"
     
    3233USHORT ausDef[7] = { 0 };
    3334USHORT ausDefSSW[7] = { 0 };
     35BOOL  g_installer = FALSE;
    3436
    3537ImageFormatInfo Settings::ifi[BMF_INVALID] =
     
    109111        //DisplayError( "NOT Updated", "true" );
    110112    }
    111 
     113#ifdef _QUIET_
     114    HINI hini = PrfOpenProfile (hab, "gotchaq.ini");
     115#else
     116    HINI hini = PrfOpenProfile (hab, "gotcha.ini");
     117#endif
     118    BOOL fLChange = FALSE;
     119    ULONG ulDataSize;
     120    PrfQueryProfileSize(hini, "Language", "LangChangeRequested", &ulDataSize );
     121    PrfQueryProfileData(hini, "Language", "LangChangeRequested", &fLChange, &ulDataSize);
     122    if (!fLChange) {
     123    CHAR *lang = getenv("LANG");
     124#ifdef _QUIET_
     125    PSZ  psz = "goqresen";
     126#else
     127    PSZ  psz = "gotresen";
     128#endif
     129    PSZ  pszh = "gotcha_en";
     130    if (lang) {
     131        if (!strnicmp(lang, "es", 2)) {
     132            psz = "gotreses";
     133            pszh = "gotcha_es";
     134        }
     135        else if (!strnicmp(lang, "cs", 2)) {
     136            psz = "gotrescz";
     137        }
     138        else if (!strnicmp(lang, "de", 2)) {
     139            psz = "gotresde";
     140        }
     141        else if (!strnicmp(lang, "it", 2)) {
     142            psz = "gotresit";
     143            pszh = "gotcha_it";
     144        }
     145        else if (!strnicmp(lang, "br", 2)) {
     146            psz = "gotresbr";
     147            pszh = "gotcha_br";
     148        }
     149    }
     150    SetString(SEI_LANGUAGE, psz);
     151    SetString (SEI_LANGUAGEHELP, pszh);
     152    Save ();
     153    }
     154    if (hini)
     155        PrfCloseProfile (hini);
    112156    // to get the error msgs in default language
    113157    ReloadResources (QueryString(SEI_LANGUAGE));
    114 
    115     if (Error () == 1)
    116     {
    117         FileNotOpenError ();
    118         ReloadResources (QueryString(SEI_LANGUAGE));
     158#ifdef _QUIET_
     159    if (!g_installer) {
     160#endif
     161        if (Error () == 1)
     162        {
     163            FileNotOpenError ();
     164            ReloadResources (QueryString(SEI_LANGUAGE));
     165        }
     166        else if (Error () == 2)
     167        {
     168            VersionError ();
     169            ReloadResources (QueryString(SEI_LANGUAGE));
     170        }
     171#ifdef _QUIET_
    119172    }
    120     else if (Error () == 2)
    121     {
    122         VersionError ();
    123         ReloadResources (QueryString(SEI_LANGUAGE));
    124     }
     173#endif
    125174}
    126175
     
    135184}
    136185
    137 // ** FileNotOpenError **************************************************** /*fold00*/
     186// ** FileNotOpenError **************************************************** /*FOLD00*/
    138187
    139188USHORT SETTINGS :: FileNotOpenError (VOID)
     
    159208
    160209    // load the main dialog window
    161     hwndDlg = WinLoadDlg (HWND_DESKTOP, hwndFrame, PFNWP (DialogProcedure),
     210    hwndDlg = WinLoadDlg (HWND_DESKTOP, hwndFrame, (DialogProcedure),
    162211                          GETMODULE, ID_DLG_SETTINGS, this);
    163212    // FIXME YUKKI! YUKKI!! YUKKI!!! But I'm too lazy to do it better now :-)
     
    199248
    200249        idPage[0] = (ULONG)
    201             WinSendMsg (hwndNB, BKM_INSERTPAGE, 0L,
     250            WinSendMsg (hwndDlg, BKM_INSERTPAGE, 0L,
    202251                        MPFROM2SHORT (BKA_MAJOR | BKA_AUTOPAGESIZE,
    203252                                      BKA_LAST));
    204         WinSendMsg (hwndNB, BKM_SETTABTEXT, MPFROMLONG (idPage[0]),
     253        WinSendMsg (hwndDlg, BKM_SETTABTEXT, MPFROMLONG (idPage[0]),
    205254                    MPFROMP (pszPageTab[COUNT_PAGES-1]));
    206255        hwndPage[0] = WinLoadDlg (hwndNB, hwndNB, (PFNWP) Page4Procedure,
     
    214263        for (i = 0; i < cPages; i++)
    215264        {
     265            //BOOKPAGEINFO pi;
    216266            idPage[i] = (ULONG)
    217267                WinSendMsg (hwndNB, BKM_INSERTPAGE, 0L,
    218268                            MPFROM2SHORT (BKA_MAJOR | BKA_AUTOPAGESIZE,
    219269                                          BKA_LAST));
    220             WinSendMsg (hwndNB, BKM_SETTABTEXT,
    221                         MPFROMLONG (idPage[i]), MPFROMP (pszPageTab[i]));
     270#if 0
     271            pi.cb = sizeof(pi);
     272            pi.fl = BFA_PAGEFROMDLGRES | BFA_MAJORTABTEXT;
     273            pi.bLoadDlg = TRUE;
     274            pi.hmodPageDlg = g_hmod;
     275            switch (i) {
     276#ifndef  _QUIET_
     277            case 0:
     278                pi.idPageDlg = ID_DLG_SETTINGSPAGE1;
     279                pi.pfnPageDlgProc = NULL; //(PFN) Page1Procedure;
     280                break;
     281#else
     282            case 0:
     283                pi.idPageDlg = ID_DLG_SETTINGSPAGE0;
     284                pi.pfnPageDlgProc = NULL; //(PFN) WindowProcedure;
     285                break;
     286#endif
     287            case 1:
     288                pi.idPageDlg = ID_DLG_SETTINGSPAGE2;
     289                pi.pfnPageDlgProc = NULL; //(PFN) Page2Procedure;
     290                break;
     291#ifndef  _QUIET_
     292            case 2:
     293                pi.idPageDlg = ID_DLG_SETTINGSPAGE3;
     294                pi.pfnPageDlgProc = NULL; //(PFN) Page3Procedure;
     295                break;
     296#else
     297            case 2:
     298                pi.idPageDlg = ID_DLG_SETTINGSPAGE1;
     299                pi.pfnPageDlgProc = NULL; //(PFN) Page1Procedure;
     300                break;
     301#endif
     302            case 3:
     303                pi.idPageDlg = ID_DLG_SETTINGSPAGE4;
     304                pi.pfnPageDlgProc = NULL; //(PFN) Page4Procedure;
     305                break;
     306            }
     307            pi.cbMajorTab = strlen(pszPageTab[i]);
     308            pi.pszMajorTab = pszPageTab[i];
     309            pi.cbMinorTab = strlen(pszPageTab[i]);
     310            pi.pszMinorTab = pszPageTab[i];
     311            pi.cbStatusLine = 0;
     312            pi.pszStatusLine = NULL;
     313#endif
     314            if (pset->GetLangID() == CZ || pset->GetLangID() == RU || pset->GetLangID() == PL) {
     315                UniChar     target[300];
     316                CHAR       ucLangStr[300];
     317                UconvObject     uconv_object866 = NULL;
     318                UconvObject     uconv_object852 = NULL;
     319                UconvObject     uconv_object1207 = NULL;
     320                UconvObject     uconv_object850 = NULL;
     321                HAB hab;
     322                CHAR ucFont[FACESIZE];
     323   
     324                UniCreateUconvObject((UniChar *)L"IBM-852", &uconv_object852);
     325                UniCreateUconvObject((UniChar *)L"IBM-850", &uconv_object850);
     326                UniCreateUconvObject((UniChar *)L"IBM-866", &uconv_object866);
     327                UniCreateUconvObject((UniChar *)L"IBM-1207", &uconv_object1207);
     328               
     329                strcpy(ucLangStr, pszPageTab[i]);
     330                if (pset->GetLangID() == CZ || pset->GetLangID() == PL) {
     331                   
     332                    UniStrToUcs( uconv_object852, target, ucLangStr, 299);
     333                }
     334                else if (pset->GetLangID() == RU)
     335                    UniStrToUcs( uconv_object866, target, ucLangStr, 299);
     336                else {
     337                    UniStrToUcs( uconv_object850, target, ucLangStr, 299);
     338                }
     339                UniStrFromUcs( uconv_object1207, ucLangStr, target, 300);
     340                WinSendMsg (hwndNB, BKM_SETTABTEXT,
     341                            MPFROMLONG (idPage[i]), MPFROMP (ucLangStr));
     342                /*pi.cbMajorTab = strlen(ucLangStr) + 10;
     343                pi.pszMajorTab = ucLangStr;
     344                pi.cbMinorTab = 0;
     345                pi.pszMinorTab = "";*/
     346                if (uconv_object866)
     347                    UniFreeUconvObject(uconv_object866);
     348                if (uconv_object852)
     349                    UniFreeUconvObject(uconv_object852);
     350                if (uconv_object850)
     351                    UniFreeUconvObject(uconv_object850);
     352                if (uconv_object1207)
     353                    UniFreeUconvObject(uconv_object1207);
     354            }
     355            else
     356                WinSendMsg (hwndNB, BKM_SETTABTEXT,
     357                            MPFROMLONG (idPage[i]), MPFROMP (pszPageTab[i]));
     358            //WinSendMsg(hwndNB, BKM_SETPAGEINFO, MPFROMLONG(idPage[i]),
     359              //         MPFROMP(&pi));
    222360        }
    223361#ifndef _QUIET_
     
    301439}
    302440
     441ULONG winhDrawFormattedText(HPS hps, PRECTL prcl, const char *pcszText, ULONG flCmd);
     442
    303443// ** DialogProcedure ***************************************************** /*FOLD00*/
    304444
    305 MRESULT EXPENTRY
    306 SETTINGS :: DialogProcedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     445MRESULT EXPENTRY SETTINGS :: DialogProcedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    307446{
    308447    static PSETTINGS   pset = NULL;
     
    322461        LogDebug( "DialogProcedure: end WM_INITDLG" );
    323462#endif
     463        CHAR ucFont[FACESIZE];
     464        if (pset->GetLangID() == CZ || pset->GetLangID() == RU || pset->GetLangID() == PL) {
     465           HMQ hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
     466           WinSetCp(hmq, 1207);
     467           strcpy(ucFont, "8.Times New Roman MT 30");
     468           WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
     469
     470           UniChar     target[300];
     471           CHAR       ucLangStr[300];
     472           UconvObject     uconv_object866 = NULL;
     473           UconvObject     uconv_object860 = NULL;
     474           UconvObject     uconv_object852 = NULL;
     475           UconvObject     uconv_object1207 = NULL;
     476           UconvObject     uconv_object850 = NULL;
     477           HAB hab;
     478           CHAR ucFont[FACESIZE];
     479
     480           UniCreateUconvObject((UniChar *)L"IBM-852", &uconv_object852);
     481           UniCreateUconvObject((UniChar *)L"IBM-850", &uconv_object850);
     482           UniCreateUconvObject((UniChar *)L"IBM-866", &uconv_object866);
     483           UniCreateUconvObject((UniChar *)L"IBM-1207", &uconv_object1207);
     484           
     485           WinLoadString(hab, g_hmod, IDS_UNDO, sizeof(ucLangStr), ucLangStr);
     486           if (pset->GetLangID() == CZ || pset->GetLangID() == PL) {
     487               
     488               UniStrToUcs( uconv_object852, target, ucLangStr, 299);
     489           }
     490           else if (pset->GetLangID() == RU)
     491               UniStrToUcs( uconv_object866, target, ucLangStr, 299);
     492           else {
     493               UniStrToUcs( uconv_object850, target, ucLangStr, 299);
     494           }
     495           UniStrFromUcs( uconv_object1207, ucLangStr, target, 300);
     496           WinSetDlgItemText(hwnd, WID_PB_UNDO, ucLangStr);
     497           WinLoadString(hab, g_hmod, IDS_HELP, sizeof(ucLangStr), ucLangStr);
     498
     499           if (pset->GetLangID() == CZ || pset->GetLangID() == PL) {
     500               
     501               UniStrToUcs( uconv_object852, target, ucLangStr, 299);
     502           }
     503           else if (pset->GetLangID() == RU)
     504               UniStrToUcs( uconv_object866, target, ucLangStr, 299);
     505           else {
     506               UniStrToUcs( uconv_object850, target, ucLangStr, 299);
     507           }
     508           UniStrFromUcs( uconv_object1207, ucLangStr, target, 300);
     509           WinSetDlgItemText(hwnd, WID_PB_HELP, ucLangStr);
     510           if (uconv_object866)
     511               UniFreeUconvObject(uconv_object866);
     512           if (uconv_object852)
     513               UniFreeUconvObject(uconv_object852);
     514           if (uconv_object850)
     515               UniFreeUconvObject(uconv_object850);
     516           if (uconv_object1207)
     517               UniFreeUconvObject(uconv_object1207);
     518        }
     519        else {
     520        strcpy(ucFont, "10.WarpSans");
     521        WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
     522        }
     523           
    324524        return MRESULT (FALSE);
    325525
     
    437637// ** Page1Procedure ****************************************************** /*FOLD00*/
    438638
    439 MRESULT EXPENTRY
    440 SETTINGS :: Page1Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     639MRESULT EXPENTRY SETTINGS :: Page1Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    441640{
    442641    static PSETTINGS   pset = NULL;
     
    458657            }
    459658        }
     659        HMQ hmq;
     660        BOOL bUniCodeFont;
     661        CHAR ucFont[FACESIZE];
     662
     663        if (pset->GetLangID() == RU) {
     664            hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
     665            WinSetCp(hmq, 866);
     666            bUniCodeFont = TRUE;
     667        }
     668        else if (pset->GetLangID() == CZ || pset->GetLangID() == PL) {
     669            hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
     670            WinSetCp(hmq, 852);
     671            bUniCodeFont = TRUE;
     672        }
     673        else {
     674            hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
     675            WinSetCp(hmq, 850);
     676        }
     677
     678        if (bUniCodeFont) {
     679            strcpy(ucFont, "8.Times New Roman MT 30");
     680            WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
     681        }
     682        else {
     683            strcpy(ucFont, "10.WarpSans");
     684            WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
     685        }
     686
    460687#ifdef _DOLOGDEBUG_
    461688        LogDebug( "Page1Procedure: end WM_INITDLG" );
     
    463690        return MRESULT (FALSE);
    464691    }
     692
     693    case WM_DRAWITEM:
     694
     695        POWNERITEM poItem;
     696        HPS hps;
     697        RECTL       rcl,          // window area
     698                    rclClip;      // clipping region for drawn text
     699        POINTL      ptl;          // current text position
     700        FATTRS      fontAttrs;    // current font attributes
     701        FONTMETRICS fm;           // current font metr
     702
     703
     704        poItem = POWNERITEM (mp2);
     705
     706        //hps = WinBeginPaint( hwnd, NULLHANDLE, NULLHANDLE );
     707        memset( &fontAttrs, 0, sizeof(FATTRS) );
     708        PmpfF(("PageID %i", poItem->hItem));
     709        // set the font attributes and create the logical font
     710        fontAttrs.usRecordLength = sizeof(FATTRS);
     711        fontAttrs.usCodePage     = 852;
     712        fontAttrs.fsType         = FATTR_TYPE_MBCS;
     713        fontAttrs.fsFontUse      = FATTR_FONTUSE_NOMIX;
     714        strcpy( fontAttrs.szFacename, "10.WarpSans");
     715        GpiCreateLogFont( poItem->hps, NULL, 1L, &fontAttrs );
     716        GpiSetCharSet( poItem->hps, 1L );
     717        // paint the window background
     718        //WinQueryWindowRect( hwnd, &rcl ); ????
     719        WinFillRect( hps, &poItem->rclItem, SYSCLR_WINDOW );
     720        GpiQueryFontMetrics( poItem->hps, sizeof(FONTMETRICS), &fm );
     721        rclClip.xLeft   = poItem->rclItem.xLeft + fm.lAveCharWidth;
     722        rclClip.yBottom = poItem->rclItem.yBottom + fm.lXHeight;
     723        rclClip.xRight  = poItem->rclItem.xRight - fm.lAveCharWidth;
     724        rclClip.yTop    = poItem->rclItem.yTop - fm.lXHeight;
     725        ptl.x = rclClip.xLeft;
     726        ptl.y = rclClip.yTop - fm.lExternalLeading - fm.lMaxAscender;
     727        GpiCharStringPosAt( poItem->hps, &ptl, &rclClip, CHS_CLIP,
     728                           /*Strlen(pszPageTab[i])*/5, (PCH) /*pszPageTab[i]*/ "Test", NULL );
     729        WinEndPaint( hps );
     730
     731        //poItem->hwnd = hwndNB;            /*  Window handle. */
     732        //poItem->hps = hps;             /*  Presentation-space handle. */
     733        //poItem->fsState = BKS_BACKPAGESTR | BKS_MAJORTABTOP | BKS_TABBEDDIALOG;         /*  State. */
     734        //poItem->fsAttribute = BKA_MAJOR | BKA_AUTOPAGESIZE;     /*  Attribute. */
     735        //poItem->rclItem; ????        /*  Item rectangle. */
     736        //poItem->hItem = idPage[i];
     737
     738        break;
    465739
    466740    case WM_COMMAND:
     
    623897// ** Page2Procedure ****************************************************** /*FOLD00*/
    624898
    625 MRESULT EXPENTRY
    626 SETTINGS :: Page2Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     899MRESULT EXPENTRY SETTINGS :: Page2Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    627900{
    628901    static PSETTINGS   pset = NULL;
     
    638911        LogDebug( "Page1Procedure: end WM_INITDLG" );
    639912#endif
     913        HMQ hmq;
     914        BOOL bUniCodeFont;
     915        CHAR ucFont[FACESIZE];
     916       
     917        if (pset->GetLangID() == RU) {
     918            hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
     919            WinSetCp(hmq, 866);
     920            bUniCodeFont = TRUE;
     921        }
     922        else if (pset->GetLangID() == CZ || pset->GetLangID() == PL) {
     923            hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
     924            WinSetCp(hmq, 852);
     925            bUniCodeFont = TRUE;
     926        }
     927        else {
     928            hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
     929            WinSetCp(hmq, 850);
     930        }
     931
     932        if (bUniCodeFont) {
     933            strcpy(ucFont, "8.Times New Roman MT 30");
     934            WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
     935        }
     936        //else
     937           // WinRemovePresParam(hwnd, PP_FONTNAMESIZE);
    640938        return MRESULT (FALSE);
    641939
     
    8191117// ** Page3Procedure ****************************************************** /*FOLD00*/
    8201118
    821 MRESULT EXPENTRY
    822 SETTINGS :: Page3Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     1119MRESULT EXPENTRY SETTINGS :: Page3Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    8231120{
    8241121    static PSETTINGS   pset = NULL;
     
    8341131        LogDebug( "Page3Procedure: end WM_INITDLG" );
    8351132#endif
     1133        HMQ hmq;
     1134        BOOL bUniCodeFont;
     1135        CHAR ucFont[FACESIZE];
     1136       
     1137        if (pset->GetLangID() == RU) {
     1138            hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
     1139            WinSetCp(hmq, 866);
     1140            bUniCodeFont = TRUE;
     1141        }
     1142        else if (pset->GetLangID() == CZ || pset->GetLangID() == PL) {
     1143            hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
     1144            WinSetCp(hmq, 852);
     1145            bUniCodeFont = TRUE;
     1146        }
     1147        else {
     1148            hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
     1149            WinSetCp(hmq, 850);
     1150        }
     1151
     1152        if (bUniCodeFont) {
     1153            strcpy(ucFont, "8.Times New Roman MT 30");
     1154            WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
     1155        }
     1156        //else
     1157        //    WinRemovePresParam(hwnd, PP_FONTNAMESIZE);
    8361158        return MRESULT (FALSE);
    8371159
     
    9461268// ** Page4Procedure ****************************************************** /*FOLD00*/
    9471269
    948 MRESULT EXPENTRY
    949 SETTINGS :: Page4Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     1270MRESULT EXPENTRY SETTINGS :: Page4Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    9501271{
    9511272    static PSETTINGS   pset = NULL;
     
    9591280#endif
    9601281            pset = PSETTINGS (mp2);
    961 
     1282            HMQ hmq = WinQueryWindowULong(hwnd /*WinWindowFromID(hwnd, ID_DLG_SETTINGSPAGE4)*/, QWL_HMQ);
     1283            WinSetCp(hmq, 1207); // UPF-8 Unicode
     1284            WinRemovePresParam(hwnd, PP_FONTNAMESIZE);
    9621285            pset->GetLanguages(WinWindowFromID (hwnd, WID_LB_LANGUAGES));
    9631286
     
    10061329            LogDebug( "Page4Procedure: end WM_INITDLG" );
    10071330#endif
    1008         }
     1331
     1332            UniChar     target[300];
     1333            CHAR       ucLangStr[300];
     1334            UconvObject     uconv_object866 = NULL;
     1335            UconvObject     uconv_object860 = NULL;
     1336            UconvObject     uconv_object852 = NULL;
     1337            UconvObject     uconv_object1207 = NULL;
     1338            UconvObject     uconv_object850 = NULL;
     1339            int result;
     1340            int i;
     1341            HAB hab;
     1342            CHAR ucFont[FACESIZE];
     1343
     1344            UniCreateUconvObject((UniChar *)L"IBM-852", &uconv_object852);
     1345            UniCreateUconvObject((UniChar *)L"IBM-850", &uconv_object850);
     1346            UniCreateUconvObject((UniChar *)L"IBM-866", &uconv_object866);
     1347           
     1348            UniCreateUconvObject((UniChar *)L"IBM-1207", &uconv_object1207);
     1349            for (i = 0; i < WID_ST_END - 400; i++) {
     1350                WinLoadString(hab, g_hmod, LANG_COPYRIGHT + i, sizeof(ucLangStr), ucLangStr);
     1351                if (pset->GetLangID() == 420 ||
     1352                    pset->GetLangID() == PL) {
     1353                   
     1354                    UniStrToUcs( uconv_object852, target, ucLangStr, 299);
     1355                }
     1356                else if (pset->GetLangID() == RU)
     1357                    UniStrToUcs( uconv_object866, target, ucLangStr, 299);
     1358                else {
     1359                    UniStrToUcs( uconv_object850, target, ucLangStr, 299);
     1360                }
     1361                UniStrFromUcs( uconv_object1207, ucLangStr, target, 300);
     1362                WinSetDlgItemText(hwnd, WID_ST_COPYRIGHT + i, ucLangStr);
     1363            }
     1364
     1365            if (uconv_object866)
     1366                UniFreeUconvObject(uconv_object866);
     1367            if (uconv_object852)
     1368                UniFreeUconvObject(uconv_object852);
     1369            if (uconv_object850)
     1370                UniFreeUconvObject(uconv_object850);
     1371            if (uconv_object1207)
     1372                UniFreeUconvObject(uconv_object1207);
     1373           
     1374            if (pset->GetLangID() == RU || pset->GetLangID() == CZ || pset->GetLangID() == PL ||
     1375               pset->GetLangID() == IT) {
     1376                strcpy(ucFont, "8.Times New Roman MT 30");
     1377                WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
     1378            }
     1379           
     1380            //    WinRemovePresParam(hwnd, PP_FONTNAMESIZE);*/
     1381            //HMQ hmq = WinQueryWindowULong(hwnd /*WinWindowFromID(hwnd, WID_LB_LANGUAGES)*/, QWL_HMQ);
     1382            //WinSetCp(hmq, 1207); // UPF-8 Unicode
    10091383        return MRESULT (FALSE);
     1384        }
    10101385
    10111386    case WM_COMMAND:
     
    10761451
    10771452    case WM_DESTROY:
     1453#ifndef _QUIET_
    10781454        {
    10791455            CHAR   ach[_MAX_FNAME];
     1456            BOOL fChanged = TRUE;
    10801457
    10811458            ULONG ul = USHORT (WinSendDlgItemMsg (hwnd, WID_LB_LANGUAGES,
     
    10851462                                             LM_QUERYITEMHANDLE,
    10861463                                             MPFROMLONG(ul), NULL));
    1087             pset->SetString(SEI_LANGUAGE, psz);
    1088 
     1464            if (stricmp (pset->QueryString(SEI_LANGUAGE), psz) == 0)
     1465                fChanged = FALSE;
     1466            else
     1467                pset->SetString(SEI_LANGUAGE, psz);
     1468#if 0
    10891469            ul = USHORT (WinSendDlgItemMsg (hwnd, WID_LB_LANGUAGESHELP,
    10901470                                            LM_QUERYSELECTION,
     
    10921472            WinSendDlgItemMsg (hwnd, WID_LB_LANGUAGESHELP, LM_QUERYITEMTEXT,
    10931473                               MPFROM2SHORT (ul, sizeof (ach)), MPFROMP (ach));
    1094             pset->SetString (SEI_LANGUAGEHELP, ach);
    1095 
    1096             if (saveum)
     1474            if (stricmp (pset->QueryString(SEI_LANGUAGEHELP), ach) == 0 && !fChanged)
     1475                fChanged = FALSE;
     1476            else
     1477                pset->SetString (SEI_LANGUAGEHELP, ach);
     1478#endif
     1479            if (fChanged) {
     1480                if (!stricmp(psz, "gotreses") || !stricmp(psz, "goqreses"))
     1481                    strcpy(ach, "gotcha_es");
     1482                else if (!stricmp(psz, "gotresbr") || !stricmp(psz, "goqresbr"))
     1483                    strcpy(ach, "gotcha_br");
     1484                else if (!stricmp(psz, "gotresit") || !stricmp(psz, "goqresit"))
     1485                    strcpy(ach, "gotcha_it");
     1486                else
     1487                    strcpy(ach, "gotcha_en");
     1488                pset->SetString (SEI_LANGUAGEHELP, ach);
     1489            }
     1490            if (saveum && fChanged) {
    10971491                pset->Save ();
    1098         }
     1492#ifdef _QUIET_
     1493                HINI hini = PrfOpenProfile (hab, "gotchaq.ini");
     1494#else
     1495                HINI hini = PrfOpenProfile (hab, "gotcha.ini");
     1496#endif
     1497                BOOL fLChanged = TRUE;
     1498                PrfWriteProfileData(hini, "Language", "LangChangeRequested", &fLChanged, sizeof(BOOL));
     1499                if (hini)
     1500                    PrfCloseProfile (hini);
     1501            }
     1502        }
     1503#endif
    10991504        return MRESULT (FALSE);
    11001505    }
     
    11141519}
    11151520
    1116 // ** QueryWindowData ***************************************************** /*fold00*/
     1521// ** QueryWindowData ***************************************************** /*FOLD00*/
    11171522
    11181523VOID SETTINGS :: QueryWindowData (SWP *pswp, USHORT us[7], BOOL f)
     
    11581563    if ((rc = DosLoadModule(PSZ(NULL), 0, psz, &g_hmod)))
    11591564    {
    1160         DisplayError("Error",
    1161                      "Could not (re)load resource module '%s' (return code %d). "
    1162                      "Make sure the DLL is in the LIBPATH. If this is the case, "
    1163                      "try deleting GOTCHA.INI and restart. If this fails, contact "
    1164                      "the author (ygk@qwest.net).", psz, rc);
     1565        DisplayError(RSTR(IDS_HEADER_ERROR),
     1566                     RSTR(IDS_ERROR_RESOURSEMODFAILED), psz, rc);
    11651567        exit(1);
    11661568    }
    1167 
     1569    PVOID pv;
     1570    INT Lang;
     1571
     1572    DosGetResource(g_hmod, RT_RCDATA, LANG_ID, &pv);
     1573    Lang = atoi((PCHAR) pv);
     1574    SetLangID(Lang);
    11681575    ResourceString::Module(g_hmod);
    11691576#ifdef _QUIET_
     
    12361643        if ((rc = DosLoadModule(PSZ(NULL), 0, findbuf.achName, &hmod)) == NO_ERROR) {
    12371644            PVOID pv;
     1645            PVOID pl;
     1646
    12381647            if (DosGetResource(hmod, RT_RCDATA, DLL_ID, &pv) == NO_ERROR) {
    12391648#ifdef _QUIET_
     
    12421651                if (strcmp(PSZ(pv), "Gotcha!") == 0) {
    12431652#endif
    1244                     psz = PSZ(pv)+strlen(PSZ(pv))+3;
    1245                     ul = WinInsertLboxItem (hwnd, LIT_END, psz);
     1653                    psz = PSZ(pv)+strlen(PSZ(pv)) + 3;
     1654                   
     1655                    INT Lang;
     1656               
     1657                    DosGetResource(hmod, RT_RCDATA, LANG_ID, &pl);
     1658                    Lang = atoi((PCHAR) pl);
     1659#if 1
     1660                    UniChar     target[300];
     1661                    CHAR       ucLangStr[300];
     1662                    UconvObject     uconv_object866 = NULL;
     1663                    UconvObject     uconv_object852 = NULL;
     1664                    UconvObject     uconv_object1207 = NULL;
     1665                    UconvObject     uconv_object850 = NULL;
     1666                    int i;
     1667                   
     1668                    strcpy(ucLangStr, psz);
     1669                    UniCreateUconvObject((UniChar *)L"IBM-852", &uconv_object852);
     1670                    UniCreateUconvObject((UniChar *)L"IBM-850", &uconv_object850);
     1671                    UniCreateUconvObject((UniChar *)L"IBM-866", &uconv_object866);
     1672                    UniCreateUconvObject((UniChar *)L"IBM-1207", &uconv_object1207);
     1673                   
     1674                    if (Lang == CZ) {
     1675                        UniStrToUcs( uconv_object852, target, ucLangStr, 299);
     1676                        }
     1677                        else {
     1678                            UniStrToUcs( uconv_object850, target, ucLangStr, 299);
     1679                        }
     1680                        /*if (Lang == RU) {
     1681                            UniStrToUcs( uconv_object866, target, ucLangStr, 299);
     1682                        } */
     1683                        UniStrFromUcs( uconv_object1207, ucLangStr, target, 300);
     1684                    Lang = 0;
     1685                    if (uconv_object866)
     1686                        UniFreeUconvObject(uconv_object866);
     1687                    if (uconv_object852)
     1688                        UniFreeUconvObject(uconv_object852);
     1689                    if (uconv_object850)
     1690                        UniFreeUconvObject(uconv_object850);
     1691                    if (uconv_object1207)
     1692                        UniFreeUconvObject(uconv_object1207);
     1693
     1694
     1695#endif
     1696                    ul = WinInsertLboxItem (hwnd, LIT_END,/*psz*/ucLangStr);
    12461697                    WinSendMsg(hwnd, LM_SETITEMHANDLE, MPFROMLONG(ul),
    12471698                               MPFROMP (strdup(findbuf.achName)));
    12481699                }
     1700                if (pl)
     1701                    DosFreeResource(pl);
    12491702                DosFreeResource(pv);
    12501703            }
     
    13081761
    13091762// ************************************************************************
     1763
     1764ULONG winhDrawFormattedText(HPS hps,     // in: presentation space; its settings
     1765                                         // are used, but not altered
     1766                            PRECTL prcl, // in/out: rectangle to use for drawing
     1767                                         // (modified)
     1768                            const char *pcszText, // in: text to draw (zero-terminated)
     1769                            ULONG flCmd) // in: flags like in WinDrawText; I have
     1770                                         // only tested DT_TOP and DT_LEFT though.
     1771                                         // DT_WORDBREAK | DT_TEXTATTRS are always
     1772                                         // set.
     1773                                         // You can specify DT_QUERYEXTENT to only
     1774                                         // have prcl calculated without drawing.
     1775{
     1776    PSZ     p = (PSZ)pcszText;
     1777    LONG    lDrawn = 1,
     1778            lTotalDrawn = 0,
     1779            lLineCount = 0,
     1780            lOrigYTop = prcl->yTop;
     1781    ULONG   ulTextLen = strlen(pcszText),
     1782            ulCharHeight,
     1783            flCmd2,
     1784            xLeftmost = prcl->xRight,
     1785            xRightmost = prcl->xLeft;
     1786    RECTL   rcl2;
     1787
     1788    flCmd2 = flCmd | DT_WORDBREAK | DT_TEXTATTRS;
     1789
     1790    ulCharHeight = 30;//gpihQueryLineSpacing(hps);
     1791
     1792    while (    (lDrawn)
     1793            && (lTotalDrawn < ulTextLen)
     1794          )
     1795    {
     1796        memcpy(&rcl2, prcl, sizeof(rcl2));
     1797        lDrawn = WinDrawText(hps,
     1798                             ulTextLen-lTotalDrawn,
     1799                             p,
     1800                             &rcl2,
     1801                             0, 0,                       // colors
     1802                             flCmd2);
     1803
     1804        // update char counters
     1805        p += lDrawn;
     1806        lTotalDrawn += lDrawn;
     1807
     1808        // update x extents
     1809        if (rcl2.xLeft < xLeftmost)
     1810            xLeftmost = rcl2.xLeft;
     1811        if (rcl2.xRight > xRightmost)
     1812            xRightmost = rcl2.xRight;
     1813
     1814        // update y for next line
     1815        prcl->yTop -= ulCharHeight;
     1816
     1817        // increase line count
     1818        lLineCount++;
     1819    }
     1820    prcl->xLeft = xLeftmost;
     1821    prcl->xRight = xRightmost;
     1822    prcl->yBottom = prcl->yTop;
     1823    prcl->yTop = lOrigYTop;
     1824
     1825    return lLineCount;
     1826}
Note: See TracChangeset for help on using the changeset viewer.