Index: trunk/settings.cpp
===================================================================
--- trunk/settings.cpp	(revision 151)
+++ trunk/settings.cpp	(revision 170)
@@ -279,6 +279,6 @@
 
 // FIXME YUKKI! YUKKI!! YUKKI!!! But I'm too lazy to do it better now :-)
-HWND g_hwndSettingsDialog = NULL;
-HWND g_hwndPage0 = NULL;
+//HWND g_hwndSettingsDialog = NULL;
+//HWND g_hwndPage0 = NULL;
 
 BOOL SETTINGS :: Dialog (BOOL fOnlyLanguage)
@@ -292,11 +292,9 @@
     hwndDlg = WinLoadDlg (HWND_DESKTOP, hwndFrame, PFNWP (DialogProcedure),
                           GETMODULE, ID_DLG_SETTINGS, this);
-    // FIXME YUKKI! YUKKI!! YUKKI!!! But I'm too lazy to do it better now :-)
-    g_hwndSettingsDialog = hwndDlg;
 #ifdef _DOLOGDEBUG_
     LogDebug( "Dialog: checkpoint 2" );
 #endif
-
-    // disable this two buttons if only language select
+#if 1
+    // disable these two buttons if only language select
     if (fAutoLanguage)
     {
@@ -309,5 +307,5 @@
     LogDebug( "Dialog: checkpoint 3" );
 #endif
-
+    
     // set notebook background color
     WinSendMsg (hwndNB, BKM_SETNOTEBOOKCOLORS,
@@ -349,45 +347,49 @@
                             MPFROM2SHORT (BKA_MAJOR | BKA_AUTOPAGESIZE,
                                           BKA_LAST));
-            //if (pset->GetLangID() == CZ || pset->GetLangID() == RU || pset->GetLangID() == PL) {
-                UniChar     target[300];
-                CHAR       ucLangStr[300];
-                UconvObject     uconv_object866 = NULL;
-                UconvObject     uconv_object852 = NULL;
-                UconvObject     uconv_object1207 = NULL;
-                UconvObject     uconv_object850 = NULL;
-                HAB hab;
-                CHAR ucFont[FACESIZE];
-    
-                UniCreateUconvObject((UniChar *)L"IBM-852", &uconv_object852);
-                UniCreateUconvObject((UniChar *)L"IBM-850", &uconv_object850);
-                UniCreateUconvObject((UniChar *)L"IBM-866", &uconv_object866);
-                UniCreateUconvObject((UniChar *)L"IBM-1207", &uconv_object1207);
+#ifndef _QUIET_    // Take this out and the unicode stuff in the DialogProcedure
+            UniChar     target[300];
+            CHAR       ucLangStr[300];
+            UconvObject     uconv_object866 = NULL;
+            UconvObject     uconv_object852 = NULL;
+            UconvObject     uconv_object1207 = NULL;
+            UconvObject     uconv_object850 = NULL;
+            //HAB hab;
+            CHAR ucFont[FACESIZE];
+
+            UniCreateUconvObject((UniChar *)L"IBM-852", &uconv_object852);
+            UniCreateUconvObject((UniChar *)L"IBM-850", &uconv_object850);
+            UniCreateUconvObject((UniChar *)L"IBM-866", &uconv_object866);
+            UniCreateUconvObject((UniChar *)L"IBM-1207", &uconv_object1207);
+            
+            strcpy(ucLangStr, pszPageTab[i]);
+            if (pset->GetLangID() == CZ || pset->GetLangID() == PL) {
                 
-                strcpy(ucLangStr, pszPageTab[i]);
-                if (pset->GetLangID() == CZ || pset->GetLangID() == PL) {
-                    
-                    UniStrToUcs( uconv_object852, target, ucLangStr, 299);
-                }
-                else if (pset->GetLangID() == RU)
-                    UniStrToUcs( uconv_object866, target, ucLangStr, 299);
-                else {
-                    UniStrToUcs( uconv_object850, target, ucLangStr, 299);
-                }
-                UniStrFromUcs( uconv_object1207, ucLangStr, target, 300);
-                WinSendMsg (hwndNB, BKM_SETTABTEXT,
-                            MPFROMLONG (idPage[i]), MPFROMP (ucLangStr));
-                if (uconv_object866)
-                    UniFreeUconvObject(uconv_object866);
-                if (uconv_object852)
-                    UniFreeUconvObject(uconv_object852);
-                if (uconv_object850)
-                    UniFreeUconvObject(uconv_object850);
-                if (uconv_object1207)
-                    UniFreeUconvObject(uconv_object1207);
-            //}
-            else
-                WinSendMsg (hwndNB, BKM_SETTABTEXT,
-                            MPFROMLONG (idPage[i]), MPFROMP (pszPageTab[i]));
-        }
+                UniStrToUcs( uconv_object852, target, ucLangStr, 299);
+            }
+            else if (pset->GetLangID() == RU)
+                UniStrToUcs( uconv_object866, target, ucLangStr, 299);
+            else {
+                UniStrToUcs( uconv_object850, target, ucLangStr, 299);
+            }
+            UniStrFromUcs( uconv_object1207, ucLangStr, target, 300);
+            WinSendMsg (hwndNB, BKM_SETTABTEXT,
+                        MPFROMLONG (idPage[i]), MPFROMP (ucLangStr));
+            if (uconv_object866)
+                UniFreeUconvObject(uconv_object866);
+            if (uconv_object852)
+                UniFreeUconvObject(uconv_object852);
+            if (uconv_object850)
+                UniFreeUconvObject(uconv_object850);
+            if (uconv_object1207)
+                UniFreeUconvObject(uconv_object1207);
+        }
+#else
+        CHAR       ucLangStr[300];
+
+        strcpy(ucLangStr, pszPageTab[i]);
+        WinSendMsg (hwndNB, BKM_SETTABTEXT,
+                    MPFROMLONG (idPage[i]), MPFROMP (ucLangStr));
+       }
+#endif
 #ifndef _QUIET_
         // open and assign dialogs to pages
@@ -409,5 +411,5 @@
         hwndPage[3] = WinLoadDlg (hwndNB, hwndNB, (PFNWP) Page4Procedure,
                                   GETMODULE, ID_DLG_SETTINGSPAGE4, this);
-        g_hwndPage0 = hwndPage[0];
+        //g_hwndPage0 = hwndPage[0];
         
 #endif
@@ -427,5 +429,5 @@
     LogDebug( "Dialog: checkpoint 6" );
 #endif
-    WinSendDlgItemMsg (g_hwndPage0, WID_RB_FILE, BM_CLICK,
+    WinSendDlgItemMsg (GethwndPage0(), WID_RB_FILE, BM_CLICK,
                        MPFROMSHORT (TRUE), 0);
 #ifdef _QUIET_
@@ -434,5 +436,8 @@
     }
 #endif
-    WinSetActiveWindow( HWND_DESKTOP, hwndDlg );
+    SWP swp;
+    //WinQueryWindowPos(hwndDlg, &swp);
+    //WinSetWindowPos(hwndNB, 0, 0, 0, swp.cx - 30, swp.cy - 90, SWP_SIZE);
+    //WinInvalidateRect(hwndNB, NULL, TRUE);
 #ifdef _DOLOGDEBUG_
     LogDebug( "Dialog: checkpoint 7" );
@@ -454,7 +459,8 @@
         hwndPage[i] = NULL;
 
-    hwndDlg = NULLHANDLE;
+    //hwndDlg = NULLHANDLE;
 #ifdef _DOLOGDEBUG_
     LogDebug( "Dialog: checkpoint 9" );
+#endif
 #endif
     return TRUE;
@@ -483,4 +489,17 @@
         LogDebug( "DialogProcedure: end WM_INITDLG" );
 #endif
+#ifdef _QUIET_
+        HMQ hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
+        if (pset->GetLangID() == RU) {
+            WinSetCp(hmq, 866);
+        }
+        else if (pset->GetLangID() == CZ || pset->GetLangID() == PL) {
+            WinSetCp(hmq, 852);
+        }
+        else {
+            WinSetCp(hmq, 850);
+        }
+
+#else
         CHAR ucFont[FACESIZE];
 
@@ -548,13 +567,30 @@
            HMQ hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
            WinSetCp(hmq, 1207);
-           if (pset->GetLangID() == CZ || pset->GetLangID() == RU || pset->GetLangID() == PL) {
-               strcpy(ucFont, "9.Times New Roman MT 30");
+
+           int x;
+           ULONG ulSize;
+
+           PrfQueryProfileString(HINI_USERPROFILE, (PSZ) "PM_SystemFonts", (PSZ) "WindowText",
+                                 (PSZ) "9.WarpSans", &ucFont, FACESIZE);
+           x = atol(ucFont);
+           if (PrfQueryProfileSize(HINI_USERPROFILE, (PSZ) "PM_Fonts", (PSZ) "WPSU.TTF", &ulSize)) {
+               if (x < 10)
+                   strcpy(ucFont, "9.Workplace Sans");
+               if (x == 10)
+                   strcpy(ucFont, "10.Workplace Sans");
+               if (x == 11)
+                   strcpy(ucFont, "11.Workplace Sans");
+               if (x > 11)
+                   strcpy(ucFont, "12.Workplace Sans");
                WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
            }
-        //}
-           else if (g_installer) {
-               strcpy(ucFont, "9.WarpSans");
+           else {
+               if (x > 11)
+                   strcpy(ucFont, "12.Times New Roman MT 30");
+               else
+                   strcpy(ucFont, "10.Times New Roman MT 30");
                WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
            }
+#endif
         return MRESULT (FALSE);
         }
@@ -746,32 +782,14 @@
             }
         }
-        HMQ hmq;
-        BOOL bUniCodeFont = FALSE;
-        CHAR ucFont[FACESIZE];
-
+        HMQ hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
         if (pset->GetLangID() == RU) {
-            hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
             WinSetCp(hmq, 866);
-            bUniCodeFont = TRUE;
         }
         else if (pset->GetLangID() == CZ || pset->GetLangID() == PL) {
-            hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
             WinSetCp(hmq, 852);
-            bUniCodeFont = TRUE;
         }
         else {
-            hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
             WinSetCp(hmq, 850);
         }
-
-        if (bUniCodeFont) {
-            strcpy(ucFont, "9.Times New Roman MT 30");
-            WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
-        }
-        else if (g_installer) {
-            strcpy(ucFont, "9.WarpSans");
-            WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
-        }
-
 #ifdef _DOLOGDEBUG_
         LogDebug( "Page1Procedure: end WM_INITDLG" );
@@ -782,5 +800,5 @@
     case WM_COMMAND:
         if( SHORT1FROMMP( mp1 ) == DID_CANCEL )
-            WinPostMsg( g_hwndSettingsDialog, msg, mp1, mp2 );
+            WinPostMsg( pset->GethwndSettingsDialog(), msg, mp1, mp2 );
         return MRESULT( FALSE );
 
@@ -952,29 +970,15 @@
 #endif
         HMQ hmq;
-        BOOL bUniCodeFont = FALSE;
         CHAR ucFont[FACESIZE];
-        
+
+        hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
         if (pset->GetLangID() == RU) {
-            hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
             WinSetCp(hmq, 866);
-            bUniCodeFont = TRUE;
         }
         else if (pset->GetLangID() == CZ || pset->GetLangID() == PL) {
-            hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
             WinSetCp(hmq, 852);
-            bUniCodeFont = TRUE;
         }
         else {
-            hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
             WinSetCp(hmq, 850);
-        }
-
-        if (bUniCodeFont) {
-            strcpy(ucFont, "9.Times New Roman MT 30");
-            WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
-        }
-        else if (g_installer) {
-            strcpy(ucFont, "9.WarpSans");
-            WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
         }
         return MRESULT (FALSE);
@@ -984,8 +988,8 @@
         if( SHORT1FROMMP( mp1 ) == WID_PB_OK) {
             saveum = TRUE;
-            WinSendMsg ( g_hwndSettingsDialog, WM_CLOSE, 0,0);
+            WinSendMsg ( pset->GethwndSettingsDialog(), WM_CLOSE, 0,0);
         }
         if( SHORT1FROMMP( mp1 ) == DID_CANCEL )
-            WinPostMsg( g_hwndSettingsDialog, msg, mp1, mp2 );
+            WinPostMsg( pset->GethwndSettingsDialog(), msg, mp1, mp2 );
         return MRESULT( FALSE );
 
@@ -1137,5 +1141,5 @@
         case WID_CB_DELAYEDCAPTURE:
 
-            WinSendDlgItemMsg (g_hwndPage0, WID_CB_DELAYEDCAPTURE, BM_SETCHECK,
+            WinSendDlgItemMsg (pset->GethwndPage0(), WID_CB_DELAYEDCAPTURE, BM_SETCHECK,
                                MPFROMLONG (WinQueryButtonCheckstate
                                            (hwnd,WID_CB_DELAYEDCAPTURE)),
@@ -1171,25 +1175,15 @@
 #endif
         HMQ hmq;
-        BOOL bUniCodeFont = FALSE;
         CHAR ucFont[FACESIZE];
-        
+
+        hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
         if (pset->GetLangID() == RU) {
-            hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
             WinSetCp(hmq, 866);
-            bUniCodeFont = TRUE;
         }
         else if (pset->GetLangID() == CZ || pset->GetLangID() == PL) {
-            hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
             WinSetCp(hmq, 852);
-            bUniCodeFont = TRUE;
         }
         else {
-            hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
             WinSetCp(hmq, 850);
-        }
-
-        if (bUniCodeFont) {
-            strcpy(ucFont, "9.Times New Roman MT 30");
-            WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
         }
         return MRESULT (FALSE);
@@ -1198,5 +1192,5 @@
     case WM_COMMAND:
         if( SHORT1FROMMP( mp1 ) == DID_CANCEL )
-            WinPostMsg( g_hwndSettingsDialog, msg, mp1, mp2 );
+            WinPostMsg( pset->GethwndSettingsDialog(), msg, mp1, mp2 );
         return MRESULT( FALSE );
 
@@ -1318,8 +1312,23 @@
 #endif
             pset = PSETTINGS (mp2);
-
-            HMQ hmq = WinQueryWindowULong(hwnd /*WinWindowFromID(hwnd, ID_DLG_SETTINGSPAGE4)*/, QWL_HMQ);
+#ifdef _QUIET_
+            HMQ hmq;
+            CHAR ucFont[FACESIZE];
+    
+            hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
+            if (pset->GetLangID() == RU) {
+                WinSetCp(hmq, 866);
+            }
+            else if (pset->GetLangID() == CZ || pset->GetLangID() == PL) {
+                WinSetCp(hmq, 852);
+            }
+            else {
+                WinSetCp(hmq, 850);
+            }
+#else
+            HMQ hmq = WinQueryWindowULong(hwnd /*WinWindowFromID(hwnd, WID_LB_LANGUAGES)*/, QWL_HMQ);
             WinSetCp(hmq, 1207); // UPF-8 Unicode
             WinRemovePresParam(hwnd, PP_FONTNAMESIZE);
+#endif
 #ifndef _QUIET_ //??
             pset->GetLanguages(WinWindowFromID (hwnd, WID_LB_LANGUAGES));
@@ -1338,5 +1347,13 @@
             LogDebug( "Page4Procedure: end WM_INITDLG" );
 #endif
-
+#ifdef _QUIET_
+            CHAR       ucLangStr[300];
+            int i;
+
+            for (i = 0; i < WID_ST_END - 400; i++) {
+                WinLoadString(hab, g_hmod, LANG_COPYRIGHT + i, sizeof(ucLangStr), ucLangStr);
+                WinSetDlgItemText(hwnd, WID_ST_COPYRIGHT + i, ucLangStr);
+            }
+#else
             UniChar     target[300];
             CHAR       ucLangStr[300];
@@ -1349,13 +1366,14 @@
             int i;
             HAB hab;
-            CHAR ucFont[FACESIZE];
+            CHAR ucFont[FACESIZE] = {0};
+            int rc;
 
             UniCreateUconvObject((UniChar *)L"IBM-852", &uconv_object852);
-            UniCreateUconvObject((UniChar *)L"IBM-850", &uconv_object850);
+            rc = UniCreateUconvObject((UniChar *)L"IBM-850", &uconv_object850);
             UniCreateUconvObject((UniChar *)L"IBM-866", &uconv_object866);
            
-            UniCreateUconvObject((UniChar *)L"IBM-1207", &uconv_object1207);
+            rc = UniCreateUconvObject((UniChar *)L"IBM-1207", &uconv_object1207);
             for (i = 0; i < WID_ST_END - 400; i++) {
-                WinLoadString(hab, g_hmod, LANG_COPYRIGHT + i, sizeof(ucLangStr), ucLangStr);
+                rc = WinLoadString(hab, g_hmod, LANG_COPYRIGHT + i, sizeof(ucLangStr), ucLangStr);
                 if (pset->GetLangID() == 420 ||
                     pset->GetLangID() == PL) {
@@ -1366,10 +1384,9 @@
                     UniStrToUcs( uconv_object866, target, ucLangStr, 299);
                 else {
-                    UniStrToUcs( uconv_object850, target, ucLangStr, 299);
+                    rc = UniStrToUcs( uconv_object850, target, ucLangStr, 299);
                 }
-                UniStrFromUcs( uconv_object1207, ucLangStr, target, 300);
-                WinSetDlgItemText(hwnd, WID_ST_COPYRIGHT + i, ucLangStr);
-            }
-
+                rc = UniStrFromUcs( uconv_object1207, ucLangStr, target, 300);
+               rc = WinSetDlgItemText(hwnd, WID_ST_COPYRIGHT + i, ucLangStr);
+            }
             if (uconv_object866)
                 UniFreeUconvObject(uconv_object866);
@@ -1380,22 +1397,36 @@
             if (uconv_object1207)
                 UniFreeUconvObject(uconv_object1207);
-            CHAR *env, *p;
-            env = getenv("OSDIR");
-            p = env;
-            p++;
-            if (!stricmp(p, ":\\sys") || !stricmp(p, ":\\ecs")) {
-                strcpy(ucFont, "9.Workplace Sans");
+
+            int x;
+            ULONG ulSize;
+
+            PrfQueryProfileString(HINI_USERPROFILE, (PSZ) "PM_SystemFonts", (PSZ) "WindowText",
+                                  (PSZ) "9.WarpSans", &ucFont, FACESIZE);
+            x = atol(ucFont);
+            if (PrfQueryProfileSize(HINI_USERPROFILE, (PSZ) "PM_Fonts", (PSZ) "WPSUB.TTF", &ulSize)) {
+                if (x < 10)
+                    strcpy(ucFont, "9.Workplace Sans Bold");
+                if (x == 10)
+                    strcpy(ucFont, "10.Workplace Sans Bold");
+                if (x == 11)
+                    strcpy(ucFont, "11.Workplace Sans Bold");
+                if (x > 10)
+                    strcpy(ucFont, "12.Workplace Sans Bold");
+                rc = WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
+            }
+            else {
+                if (x > 11)
+                    strcpy(ucFont, "12.Times New Roman MT 30");
+                else
+                    strcpy(ucFont, "10.Times New Roman MT 30");
                 WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
             }
-            else {
-                strcpy(ucFont, "9.Times New Roman MT 30");
-                WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
-            }
-        return MRESULT (FALSE);
+#endif
+            return MRESULT (FALSE);
         }
 
     case WM_COMMAND:
         if( SHORT1FROMMP( mp1 ) == DID_CANCEL )
-            WinPostMsg( g_hwndSettingsDialog, msg, mp1, mp2 );
+            WinPostMsg( pset->GethwndSettingsDialog(), msg, mp1, mp2 );
         return MRESULT( FALSE );
 #ifndef _QUIET_
@@ -1563,5 +1594,5 @@
     pszPageTab[0] = RSTR (IDS_PAGESAVE);
     pszPageTab[1] = RSTR (IDS_PAGESNAPSHOT);
-    pszPageTab[2] = RSTR (IDS_CAPTURE );
+    pszPageTab[2] = RSTR (IDS_CAPTURE);
     pszPageTab[3] = RSTR (IDS_PAGELANGUAGE);
 #endif
