Changeset 94 for trunk/settings.cpp
- Timestamp:
- Jul 17, 2021, 9:24:00 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/settings.cpp
r92 r94 18 18 ***/ 19 19 #include <direct.h> 20 #include <uconv.h> 20 21 #include "settings.h" 21 22 #include "ctype.h" … … 32 33 USHORT ausDef[7] = { 0 }; 33 34 USHORT ausDefSSW[7] = { 0 }; 35 BOOL g_installer = FALSE; 34 36 35 37 ImageFormatInfo Settings::ifi[BMF_INVALID] = … … 109 111 //DisplayError( "NOT Updated", "true" ); 110 112 } 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); 112 156 // to get the error msgs in default language 113 157 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_ 119 172 } 120 else if (Error () == 2) 121 { 122 VersionError (); 123 ReloadResources (QueryString(SEI_LANGUAGE)); 124 } 173 #endif 125 174 } 126 175 … … 135 184 } 136 185 137 // ** FileNotOpenError **************************************************** /* fold00*/186 // ** FileNotOpenError **************************************************** /*FOLD00*/ 138 187 139 188 USHORT SETTINGS :: FileNotOpenError (VOID) … … 159 208 160 209 // load the main dialog window 161 hwndDlg = WinLoadDlg (HWND_DESKTOP, hwndFrame, PFNWP(DialogProcedure),210 hwndDlg = WinLoadDlg (HWND_DESKTOP, hwndFrame, (DialogProcedure), 162 211 GETMODULE, ID_DLG_SETTINGS, this); 163 212 // FIXME YUKKI! YUKKI!! YUKKI!!! But I'm too lazy to do it better now :-) … … 199 248 200 249 idPage[0] = (ULONG) 201 WinSendMsg (hwnd NB, BKM_INSERTPAGE, 0L,250 WinSendMsg (hwndDlg, BKM_INSERTPAGE, 0L, 202 251 MPFROM2SHORT (BKA_MAJOR | BKA_AUTOPAGESIZE, 203 252 BKA_LAST)); 204 WinSendMsg (hwnd NB, BKM_SETTABTEXT, MPFROMLONG (idPage[0]),253 WinSendMsg (hwndDlg, BKM_SETTABTEXT, MPFROMLONG (idPage[0]), 205 254 MPFROMP (pszPageTab[COUNT_PAGES-1])); 206 255 hwndPage[0] = WinLoadDlg (hwndNB, hwndNB, (PFNWP) Page4Procedure, … … 214 263 for (i = 0; i < cPages; i++) 215 264 { 265 //BOOKPAGEINFO pi; 216 266 idPage[i] = (ULONG) 217 267 WinSendMsg (hwndNB, BKM_INSERTPAGE, 0L, 218 268 MPFROM2SHORT (BKA_MAJOR | BKA_AUTOPAGESIZE, 219 269 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)); 222 360 } 223 361 #ifndef _QUIET_ … … 301 439 } 302 440 441 ULONG winhDrawFormattedText(HPS hps, PRECTL prcl, const char *pcszText, ULONG flCmd); 442 303 443 // ** DialogProcedure ***************************************************** /*FOLD00*/ 304 444 305 MRESULT EXPENTRY 306 SETTINGS :: DialogProcedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 445 MRESULT EXPENTRY SETTINGS :: DialogProcedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 307 446 { 308 447 static PSETTINGS pset = NULL; … … 322 461 LogDebug( "DialogProcedure: end WM_INITDLG" ); 323 462 #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 324 524 return MRESULT (FALSE); 325 525 … … 437 637 // ** Page1Procedure ****************************************************** /*FOLD00*/ 438 638 439 MRESULT EXPENTRY 440 SETTINGS :: Page1Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 639 MRESULT EXPENTRY SETTINGS :: Page1Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 441 640 { 442 641 static PSETTINGS pset = NULL; … … 458 657 } 459 658 } 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 460 687 #ifdef _DOLOGDEBUG_ 461 688 LogDebug( "Page1Procedure: end WM_INITDLG" ); … … 463 690 return MRESULT (FALSE); 464 691 } 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; 465 739 466 740 case WM_COMMAND: … … 623 897 // ** Page2Procedure ****************************************************** /*FOLD00*/ 624 898 625 MRESULT EXPENTRY 626 SETTINGS :: Page2Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 899 MRESULT EXPENTRY SETTINGS :: Page2Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 627 900 { 628 901 static PSETTINGS pset = NULL; … … 638 911 LogDebug( "Page1Procedure: end WM_INITDLG" ); 639 912 #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); 640 938 return MRESULT (FALSE); 641 939 … … 819 1117 // ** Page3Procedure ****************************************************** /*FOLD00*/ 820 1118 821 MRESULT EXPENTRY 822 SETTINGS :: Page3Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 1119 MRESULT EXPENTRY SETTINGS :: Page3Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 823 1120 { 824 1121 static PSETTINGS pset = NULL; … … 834 1131 LogDebug( "Page3Procedure: end WM_INITDLG" ); 835 1132 #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); 836 1158 return MRESULT (FALSE); 837 1159 … … 946 1268 // ** Page4Procedure ****************************************************** /*FOLD00*/ 947 1269 948 MRESULT EXPENTRY 949 SETTINGS :: Page4Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 1270 MRESULT EXPENTRY SETTINGS :: Page4Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) 950 1271 { 951 1272 static PSETTINGS pset = NULL; … … 959 1280 #endif 960 1281 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); 962 1285 pset->GetLanguages(WinWindowFromID (hwnd, WID_LB_LANGUAGES)); 963 1286 … … 1006 1329 LogDebug( "Page4Procedure: end WM_INITDLG" ); 1007 1330 #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 1009 1383 return MRESULT (FALSE); 1384 } 1010 1385 1011 1386 case WM_COMMAND: … … 1076 1451 1077 1452 case WM_DESTROY: 1453 #ifndef _QUIET_ 1078 1454 { 1079 1455 CHAR ach[_MAX_FNAME]; 1456 BOOL fChanged = TRUE; 1080 1457 1081 1458 ULONG ul = USHORT (WinSendDlgItemMsg (hwnd, WID_LB_LANGUAGES, … … 1085 1462 LM_QUERYITEMHANDLE, 1086 1463 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 1089 1469 ul = USHORT (WinSendDlgItemMsg (hwnd, WID_LB_LANGUAGESHELP, 1090 1470 LM_QUERYSELECTION, … … 1092 1472 WinSendDlgItemMsg (hwnd, WID_LB_LANGUAGESHELP, LM_QUERYITEMTEXT, 1093 1473 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) { 1097 1491 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 1099 1504 return MRESULT (FALSE); 1100 1505 } … … 1114 1519 } 1115 1520 1116 // ** QueryWindowData ***************************************************** /* fold00*/1521 // ** QueryWindowData ***************************************************** /*FOLD00*/ 1117 1522 1118 1523 VOID SETTINGS :: QueryWindowData (SWP *pswp, USHORT us[7], BOOL f) … … 1158 1563 if ((rc = DosLoadModule(PSZ(NULL), 0, psz, &g_hmod))) 1159 1564 { 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); 1165 1567 exit(1); 1166 1568 } 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); 1168 1575 ResourceString::Module(g_hmod); 1169 1576 #ifdef _QUIET_ … … 1236 1643 if ((rc = DosLoadModule(PSZ(NULL), 0, findbuf.achName, &hmod)) == NO_ERROR) { 1237 1644 PVOID pv; 1645 PVOID pl; 1646 1238 1647 if (DosGetResource(hmod, RT_RCDATA, DLL_ID, &pv) == NO_ERROR) { 1239 1648 #ifdef _QUIET_ … … 1242 1651 if (strcmp(PSZ(pv), "Gotcha!") == 0) { 1243 1652 #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); 1246 1697 WinSendMsg(hwnd, LM_SETITEMHANDLE, MPFROMLONG(ul), 1247 1698 MPFROMP (strdup(findbuf.achName))); 1248 1699 } 1700 if (pl) 1701 DosFreeResource(pl); 1249 1702 DosFreeResource(pv); 1250 1703 } … … 1308 1761 1309 1762 // ************************************************************************ 1763 1764 ULONG 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.