Changeset 170 for trunk/settings.cpp


Ignore:
Timestamp:
Sep 22, 2025, 10:04:44 PM (4 weeks ago)
Author:
Gregg Young
Message:

Rework Gotcha's dialogs to work better with the new font sizing in WPS. Replace some global variables with more C++ alternatives

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/settings.cpp

    r151 r170  
    279279
    280280// FIXME YUKKI! YUKKI!! YUKKI!!! But I'm too lazy to do it better now :-)
    281 HWND g_hwndSettingsDialog = NULL;
    282 HWND g_hwndPage0 = NULL;
     281//HWND g_hwndSettingsDialog = NULL;
     282//HWND g_hwndPage0 = NULL;
    283283
    284284BOOL SETTINGS :: Dialog (BOOL fOnlyLanguage)
     
    292292    hwndDlg = WinLoadDlg (HWND_DESKTOP, hwndFrame, PFNWP (DialogProcedure),
    293293                          GETMODULE, ID_DLG_SETTINGS, this);
    294     // FIXME YUKKI! YUKKI!! YUKKI!!! But I'm too lazy to do it better now :-)
    295     g_hwndSettingsDialog = hwndDlg;
    296294#ifdef _DOLOGDEBUG_
    297295    LogDebug( "Dialog: checkpoint 2" );
    298296#endif
    299 
    300     // disable this two buttons if only language select
     297#if 1
     298    // disable these two buttons if only language select
    301299    if (fAutoLanguage)
    302300    {
     
    309307    LogDebug( "Dialog: checkpoint 3" );
    310308#endif
    311 
     309   
    312310    // set notebook background color
    313311    WinSendMsg (hwndNB, BKM_SETNOTEBOOKCOLORS,
     
    349347                            MPFROM2SHORT (BKA_MAJOR | BKA_AUTOPAGESIZE,
    350348                                          BKA_LAST));
    351             //if (pset->GetLangID() == CZ || pset->GetLangID() == RU || pset->GetLangID() == PL) {
    352                 UniChar     target[300];
    353                 CHAR       ucLangStr[300];
    354                 UconvObject     uconv_object866 = NULL;
    355                 UconvObject     uconv_object852 = NULL;
    356                 UconvObject     uconv_object1207 = NULL;
    357                 UconvObject     uconv_object850 = NULL;
    358                 HAB hab;
    359                 CHAR ucFont[FACESIZE];
    360    
    361                 UniCreateUconvObject((UniChar *)L"IBM-852", &uconv_object852);
    362                 UniCreateUconvObject((UniChar *)L"IBM-850", &uconv_object850);
    363                 UniCreateUconvObject((UniChar *)L"IBM-866", &uconv_object866);
    364                 UniCreateUconvObject((UniChar *)L"IBM-1207", &uconv_object1207);
     349#ifndef _QUIET_    // Take this out and the unicode stuff in the DialogProcedure
     350            UniChar     target[300];
     351            CHAR       ucLangStr[300];
     352            UconvObject     uconv_object866 = NULL;
     353            UconvObject     uconv_object852 = NULL;
     354            UconvObject     uconv_object1207 = NULL;
     355            UconvObject     uconv_object850 = NULL;
     356            //HAB hab;
     357            CHAR ucFont[FACESIZE];
     358
     359            UniCreateUconvObject((UniChar *)L"IBM-852", &uconv_object852);
     360            UniCreateUconvObject((UniChar *)L"IBM-850", &uconv_object850);
     361            UniCreateUconvObject((UniChar *)L"IBM-866", &uconv_object866);
     362            UniCreateUconvObject((UniChar *)L"IBM-1207", &uconv_object1207);
     363           
     364            strcpy(ucLangStr, pszPageTab[i]);
     365            if (pset->GetLangID() == CZ || pset->GetLangID() == PL) {
    365366               
    366                 strcpy(ucLangStr, pszPageTab[i]);
    367                 if (pset->GetLangID() == CZ || pset->GetLangID() == PL) {
    368                    
    369                     UniStrToUcs( uconv_object852, target, ucLangStr, 299);
    370                 }
    371                 else if (pset->GetLangID() == RU)
    372                     UniStrToUcs( uconv_object866, target, ucLangStr, 299);
    373                 else {
    374                     UniStrToUcs( uconv_object850, target, ucLangStr, 299);
    375                 }
    376                 UniStrFromUcs( uconv_object1207, ucLangStr, target, 300);
    377                 WinSendMsg (hwndNB, BKM_SETTABTEXT,
    378                             MPFROMLONG (idPage[i]), MPFROMP (ucLangStr));
    379                 if (uconv_object866)
    380                     UniFreeUconvObject(uconv_object866);
    381                 if (uconv_object852)
    382                     UniFreeUconvObject(uconv_object852);
    383                 if (uconv_object850)
    384                     UniFreeUconvObject(uconv_object850);
    385                 if (uconv_object1207)
    386                     UniFreeUconvObject(uconv_object1207);
    387             //}
    388             else
    389                 WinSendMsg (hwndNB, BKM_SETTABTEXT,
    390                             MPFROMLONG (idPage[i]), MPFROMP (pszPageTab[i]));
    391         }
     367                UniStrToUcs( uconv_object852, target, ucLangStr, 299);
     368            }
     369            else if (pset->GetLangID() == RU)
     370                UniStrToUcs( uconv_object866, target, ucLangStr, 299);
     371            else {
     372                UniStrToUcs( uconv_object850, target, ucLangStr, 299);
     373            }
     374            UniStrFromUcs( uconv_object1207, ucLangStr, target, 300);
     375            WinSendMsg (hwndNB, BKM_SETTABTEXT,
     376                        MPFROMLONG (idPage[i]), MPFROMP (ucLangStr));
     377            if (uconv_object866)
     378                UniFreeUconvObject(uconv_object866);
     379            if (uconv_object852)
     380                UniFreeUconvObject(uconv_object852);
     381            if (uconv_object850)
     382                UniFreeUconvObject(uconv_object850);
     383            if (uconv_object1207)
     384                UniFreeUconvObject(uconv_object1207);
     385        }
     386#else
     387        CHAR       ucLangStr[300];
     388
     389        strcpy(ucLangStr, pszPageTab[i]);
     390        WinSendMsg (hwndNB, BKM_SETTABTEXT,
     391                    MPFROMLONG (idPage[i]), MPFROMP (ucLangStr));
     392       }
     393#endif
    392394#ifndef _QUIET_
    393395        // open and assign dialogs to pages
     
    409411        hwndPage[3] = WinLoadDlg (hwndNB, hwndNB, (PFNWP) Page4Procedure,
    410412                                  GETMODULE, ID_DLG_SETTINGSPAGE4, this);
    411         g_hwndPage0 = hwndPage[0];
     413        //g_hwndPage0 = hwndPage[0];
    412414       
    413415#endif
     
    427429    LogDebug( "Dialog: checkpoint 6" );
    428430#endif
    429     WinSendDlgItemMsg (g_hwndPage0, WID_RB_FILE, BM_CLICK,
     431    WinSendDlgItemMsg (GethwndPage0(), WID_RB_FILE, BM_CLICK,
    430432                       MPFROMSHORT (TRUE), 0);
    431433#ifdef _QUIET_
     
    434436    }
    435437#endif
    436     WinSetActiveWindow( HWND_DESKTOP, hwndDlg );
     438    SWP swp;
     439    //WinQueryWindowPos(hwndDlg, &swp);
     440    //WinSetWindowPos(hwndNB, 0, 0, 0, swp.cx - 30, swp.cy - 90, SWP_SIZE);
     441    //WinInvalidateRect(hwndNB, NULL, TRUE);
    437442#ifdef _DOLOGDEBUG_
    438443    LogDebug( "Dialog: checkpoint 7" );
     
    454459        hwndPage[i] = NULL;
    455460
    456     hwndDlg = NULLHANDLE;
     461    //hwndDlg = NULLHANDLE;
    457462#ifdef _DOLOGDEBUG_
    458463    LogDebug( "Dialog: checkpoint 9" );
     464#endif
    459465#endif
    460466    return TRUE;
     
    483489        LogDebug( "DialogProcedure: end WM_INITDLG" );
    484490#endif
     491#ifdef _QUIET_
     492        HMQ hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
     493        if (pset->GetLangID() == RU) {
     494            WinSetCp(hmq, 866);
     495        }
     496        else if (pset->GetLangID() == CZ || pset->GetLangID() == PL) {
     497            WinSetCp(hmq, 852);
     498        }
     499        else {
     500            WinSetCp(hmq, 850);
     501        }
     502
     503#else
    485504        CHAR ucFont[FACESIZE];
    486505
     
    548567           HMQ hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
    549568           WinSetCp(hmq, 1207);
    550            if (pset->GetLangID() == CZ || pset->GetLangID() == RU || pset->GetLangID() == PL) {
    551                strcpy(ucFont, "9.Times New Roman MT 30");
     569
     570           int x;
     571           ULONG ulSize;
     572
     573           PrfQueryProfileString(HINI_USERPROFILE, (PSZ) "PM_SystemFonts", (PSZ) "WindowText",
     574                                 (PSZ) "9.WarpSans", &ucFont, FACESIZE);
     575           x = atol(ucFont);
     576           if (PrfQueryProfileSize(HINI_USERPROFILE, (PSZ) "PM_Fonts", (PSZ) "WPSU.TTF", &ulSize)) {
     577               if (x < 10)
     578                   strcpy(ucFont, "9.Workplace Sans");
     579               if (x == 10)
     580                   strcpy(ucFont, "10.Workplace Sans");
     581               if (x == 11)
     582                   strcpy(ucFont, "11.Workplace Sans");
     583               if (x > 11)
     584                   strcpy(ucFont, "12.Workplace Sans");
    552585               WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
    553586           }
    554         //}
    555            else if (g_installer) {
    556                strcpy(ucFont, "9.WarpSans");
     587           else {
     588               if (x > 11)
     589                   strcpy(ucFont, "12.Times New Roman MT 30");
     590               else
     591                   strcpy(ucFont, "10.Times New Roman MT 30");
    557592               WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
    558593           }
     594#endif
    559595        return MRESULT (FALSE);
    560596        }
     
    746782            }
    747783        }
    748         HMQ hmq;
    749         BOOL bUniCodeFont = FALSE;
    750         CHAR ucFont[FACESIZE];
    751 
     784        HMQ hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
    752785        if (pset->GetLangID() == RU) {
    753             hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
    754786            WinSetCp(hmq, 866);
    755             bUniCodeFont = TRUE;
    756787        }
    757788        else if (pset->GetLangID() == CZ || pset->GetLangID() == PL) {
    758             hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
    759789            WinSetCp(hmq, 852);
    760             bUniCodeFont = TRUE;
    761790        }
    762791        else {
    763             hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
    764792            WinSetCp(hmq, 850);
    765793        }
    766 
    767         if (bUniCodeFont) {
    768             strcpy(ucFont, "9.Times New Roman MT 30");
    769             WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
    770         }
    771         else if (g_installer) {
    772             strcpy(ucFont, "9.WarpSans");
    773             WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
    774         }
    775 
    776794#ifdef _DOLOGDEBUG_
    777795        LogDebug( "Page1Procedure: end WM_INITDLG" );
     
    782800    case WM_COMMAND:
    783801        if( SHORT1FROMMP( mp1 ) == DID_CANCEL )
    784             WinPostMsg( g_hwndSettingsDialog, msg, mp1, mp2 );
     802            WinPostMsg( pset->GethwndSettingsDialog(), msg, mp1, mp2 );
    785803        return MRESULT( FALSE );
    786804
     
    952970#endif
    953971        HMQ hmq;
    954         BOOL bUniCodeFont = FALSE;
    955972        CHAR ucFont[FACESIZE];
    956        
     973
     974        hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
    957975        if (pset->GetLangID() == RU) {
    958             hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
    959976            WinSetCp(hmq, 866);
    960             bUniCodeFont = TRUE;
    961977        }
    962978        else if (pset->GetLangID() == CZ || pset->GetLangID() == PL) {
    963             hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
    964979            WinSetCp(hmq, 852);
    965             bUniCodeFont = TRUE;
    966980        }
    967981        else {
    968             hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
    969982            WinSetCp(hmq, 850);
    970         }
    971 
    972         if (bUniCodeFont) {
    973             strcpy(ucFont, "9.Times New Roman MT 30");
    974             WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
    975         }
    976         else if (g_installer) {
    977             strcpy(ucFont, "9.WarpSans");
    978             WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
    979983        }
    980984        return MRESULT (FALSE);
     
    984988        if( SHORT1FROMMP( mp1 ) == WID_PB_OK) {
    985989            saveum = TRUE;
    986             WinSendMsg ( g_hwndSettingsDialog, WM_CLOSE, 0,0);
     990            WinSendMsg ( pset->GethwndSettingsDialog(), WM_CLOSE, 0,0);
    987991        }
    988992        if( SHORT1FROMMP( mp1 ) == DID_CANCEL )
    989             WinPostMsg( g_hwndSettingsDialog, msg, mp1, mp2 );
     993            WinPostMsg( pset->GethwndSettingsDialog(), msg, mp1, mp2 );
    990994        return MRESULT( FALSE );
    991995
     
    11371141        case WID_CB_DELAYEDCAPTURE:
    11381142
    1139             WinSendDlgItemMsg (g_hwndPage0, WID_CB_DELAYEDCAPTURE, BM_SETCHECK,
     1143            WinSendDlgItemMsg (pset->GethwndPage0(), WID_CB_DELAYEDCAPTURE, BM_SETCHECK,
    11401144                               MPFROMLONG (WinQueryButtonCheckstate
    11411145                                           (hwnd,WID_CB_DELAYEDCAPTURE)),
     
    11711175#endif
    11721176        HMQ hmq;
    1173         BOOL bUniCodeFont = FALSE;
    11741177        CHAR ucFont[FACESIZE];
    1175        
     1178
     1179        hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
    11761180        if (pset->GetLangID() == RU) {
    1177             hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
    11781181            WinSetCp(hmq, 866);
    1179             bUniCodeFont = TRUE;
    11801182        }
    11811183        else if (pset->GetLangID() == CZ || pset->GetLangID() == PL) {
    1182             hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
    11831184            WinSetCp(hmq, 852);
    1184             bUniCodeFont = TRUE;
    11851185        }
    11861186        else {
    1187             hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
    11881187            WinSetCp(hmq, 850);
    1189         }
    1190 
    1191         if (bUniCodeFont) {
    1192             strcpy(ucFont, "9.Times New Roman MT 30");
    1193             WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
    11941188        }
    11951189        return MRESULT (FALSE);
     
    11981192    case WM_COMMAND:
    11991193        if( SHORT1FROMMP( mp1 ) == DID_CANCEL )
    1200             WinPostMsg( g_hwndSettingsDialog, msg, mp1, mp2 );
     1194            WinPostMsg( pset->GethwndSettingsDialog(), msg, mp1, mp2 );
    12011195        return MRESULT( FALSE );
    12021196
     
    13181312#endif
    13191313            pset = PSETTINGS (mp2);
    1320 
    1321             HMQ hmq = WinQueryWindowULong(hwnd /*WinWindowFromID(hwnd, ID_DLG_SETTINGSPAGE4)*/, QWL_HMQ);
     1314#ifdef _QUIET_
     1315            HMQ hmq;
     1316            CHAR ucFont[FACESIZE];
     1317   
     1318            hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
     1319            if (pset->GetLangID() == RU) {
     1320                WinSetCp(hmq, 866);
     1321            }
     1322            else if (pset->GetLangID() == CZ || pset->GetLangID() == PL) {
     1323                WinSetCp(hmq, 852);
     1324            }
     1325            else {
     1326                WinSetCp(hmq, 850);
     1327            }
     1328#else
     1329            HMQ hmq = WinQueryWindowULong(hwnd /*WinWindowFromID(hwnd, WID_LB_LANGUAGES)*/, QWL_HMQ);
    13221330            WinSetCp(hmq, 1207); // UPF-8 Unicode
    13231331            WinRemovePresParam(hwnd, PP_FONTNAMESIZE);
     1332#endif
    13241333#ifndef _QUIET_ //??
    13251334            pset->GetLanguages(WinWindowFromID (hwnd, WID_LB_LANGUAGES));
     
    13381347            LogDebug( "Page4Procedure: end WM_INITDLG" );
    13391348#endif
    1340 
     1349#ifdef _QUIET_
     1350            CHAR       ucLangStr[300];
     1351            int i;
     1352
     1353            for (i = 0; i < WID_ST_END - 400; i++) {
     1354                WinLoadString(hab, g_hmod, LANG_COPYRIGHT + i, sizeof(ucLangStr), ucLangStr);
     1355                WinSetDlgItemText(hwnd, WID_ST_COPYRIGHT + i, ucLangStr);
     1356            }
     1357#else
    13411358            UniChar     target[300];
    13421359            CHAR       ucLangStr[300];
     
    13491366            int i;
    13501367            HAB hab;
    1351             CHAR ucFont[FACESIZE];
     1368            CHAR ucFont[FACESIZE] = {0};
     1369            int rc;
    13521370
    13531371            UniCreateUconvObject((UniChar *)L"IBM-852", &uconv_object852);
    1354             UniCreateUconvObject((UniChar *)L"IBM-850", &uconv_object850);
     1372            rc = UniCreateUconvObject((UniChar *)L"IBM-850", &uconv_object850);
    13551373            UniCreateUconvObject((UniChar *)L"IBM-866", &uconv_object866);
    13561374           
    1357             UniCreateUconvObject((UniChar *)L"IBM-1207", &uconv_object1207);
     1375            rc = UniCreateUconvObject((UniChar *)L"IBM-1207", &uconv_object1207);
    13581376            for (i = 0; i < WID_ST_END - 400; i++) {
    1359                 WinLoadString(hab, g_hmod, LANG_COPYRIGHT + i, sizeof(ucLangStr), ucLangStr);
     1377                rc = WinLoadString(hab, g_hmod, LANG_COPYRIGHT + i, sizeof(ucLangStr), ucLangStr);
    13601378                if (pset->GetLangID() == 420 ||
    13611379                    pset->GetLangID() == PL) {
     
    13661384                    UniStrToUcs( uconv_object866, target, ucLangStr, 299);
    13671385                else {
    1368                     UniStrToUcs( uconv_object850, target, ucLangStr, 299);
     1386                    rc = UniStrToUcs( uconv_object850, target, ucLangStr, 299);
    13691387                }
    1370                 UniStrFromUcs( uconv_object1207, ucLangStr, target, 300);
    1371                 WinSetDlgItemText(hwnd, WID_ST_COPYRIGHT + i, ucLangStr);
    1372             }
    1373 
     1388                rc = UniStrFromUcs( uconv_object1207, ucLangStr, target, 300);
     1389               rc = WinSetDlgItemText(hwnd, WID_ST_COPYRIGHT + i, ucLangStr);
     1390            }
    13741391            if (uconv_object866)
    13751392                UniFreeUconvObject(uconv_object866);
     
    13801397            if (uconv_object1207)
    13811398                UniFreeUconvObject(uconv_object1207);
    1382             CHAR *env, *p;
    1383             env = getenv("OSDIR");
    1384             p = env;
    1385             p++;
    1386             if (!stricmp(p, ":\\sys") || !stricmp(p, ":\\ecs")) {
    1387                 strcpy(ucFont, "9.Workplace Sans");
     1399
     1400            int x;
     1401            ULONG ulSize;
     1402
     1403            PrfQueryProfileString(HINI_USERPROFILE, (PSZ) "PM_SystemFonts", (PSZ) "WindowText",
     1404                                  (PSZ) "9.WarpSans", &ucFont, FACESIZE);
     1405            x = atol(ucFont);
     1406            if (PrfQueryProfileSize(HINI_USERPROFILE, (PSZ) "PM_Fonts", (PSZ) "WPSUB.TTF", &ulSize)) {
     1407                if (x < 10)
     1408                    strcpy(ucFont, "9.Workplace Sans Bold");
     1409                if (x == 10)
     1410                    strcpy(ucFont, "10.Workplace Sans Bold");
     1411                if (x == 11)
     1412                    strcpy(ucFont, "11.Workplace Sans Bold");
     1413                if (x > 10)
     1414                    strcpy(ucFont, "12.Workplace Sans Bold");
     1415                rc = WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
     1416            }
     1417            else {
     1418                if (x > 11)
     1419                    strcpy(ucFont, "12.Times New Roman MT 30");
     1420                else
     1421                    strcpy(ucFont, "10.Times New Roman MT 30");
    13881422                WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
    13891423            }
    1390             else {
    1391                 strcpy(ucFont, "9.Times New Roman MT 30");
    1392                 WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
    1393             }
    1394         return MRESULT (FALSE);
     1424#endif
     1425            return MRESULT (FALSE);
    13951426        }
    13961427
    13971428    case WM_COMMAND:
    13981429        if( SHORT1FROMMP( mp1 ) == DID_CANCEL )
    1399             WinPostMsg( g_hwndSettingsDialog, msg, mp1, mp2 );
     1430            WinPostMsg( pset->GethwndSettingsDialog(), msg, mp1, mp2 );
    14001431        return MRESULT( FALSE );
    14011432#ifndef _QUIET_
     
    15631594    pszPageTab[0] = RSTR (IDS_PAGESAVE);
    15641595    pszPageTab[1] = RSTR (IDS_PAGESNAPSHOT);
    1565     pszPageTab[2] = RSTR (IDS_CAPTURE );
     1596    pszPageTab[2] = RSTR (IDS_CAPTURE);
    15661597    pszPageTab[3] = RSTR (IDS_PAGELANGUAGE);
    15671598#endif
Note: See TracChangeset for help on using the changeset viewer.