• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision7380 (tree)
Time2019-01-03 01:58:30
Authorzmatsuo

Log Message

ダイアログフォント決定方法見直し#2

Change Summary

Incremental Difference

--- branches/cmake/TTProxy/ProxyWSockHook.h (revision 7379)
+++ branches/cmake/TTProxy/ProxyWSockHook.h (revision 7380)
@@ -32,6 +32,11 @@
3232 GetI18nStrU8("TTProxy", key, buf, buf_len, def, UILanguageFile);
3333 }
3434
35+void UTIL_set_dialog_font()
36+{
37+ SetDialogFont("TTProxy", UILanguageFile);
38+}
39+
3540 #if 0
3641 int UTIL_get_lang_font(const char *key, HWND dlg, PLOGFONTA logfont, HFONT *font)
3742 {
@@ -968,6 +973,7 @@
968973 String ErrorMessage;
969974
970975 int open(HWND owner) {
976+ UTIL_set_dialog_font();
971977 return Dialog::open(instance().resource_module, IDD_OPTION_SETTING, owner);
972978 }
973979 };
@@ -1250,6 +1256,7 @@
12501256 }
12511257
12521258 int open(HWND owner) {
1259+ UTIL_set_dialog_font();
12531260 return Dialog::open(instance().resource_module, IDD_SETTING, owner);
12541261 }
12551262 };
@@ -1316,6 +1323,7 @@
13161323 }
13171324 public :
13181325 int open(HWND owner) {
1326+ UTIL_set_dialog_font();
13191327 return Dialog::open(instance().resource_module, IDD_ABOUTDIALOG, owner);
13201328 }
13211329 };
@@ -2425,7 +2433,8 @@
24252433 static bool setupDialog(HWND owner) {
24262434 SettingDialog dlg;
24272435 dlg.proxy = instance().defaultProxy;
2428- if (dlg.open(owner) == IDOK) {
2436+ UTIL_set_dialog_font();
2437+ if (dlg.open(owner) == IDOK) {
24292438 instance().defaultProxy = dlg.proxy;
24302439 return true;
24312440 }
@@ -2433,6 +2442,7 @@
24332442 }
24342443 static bool aboutDialog(HWND owner) {
24352444 AboutDialog dlg;
2445+ UTIL_set_dialog_font();
24362446 if (dlg.open(owner) == IDOK) {
24372447 return true;
24382448 }
--- branches/cmake/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.c (revision 7379)
+++ branches/cmake/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.c (revision 7380)
@@ -605,6 +605,7 @@
605605 static int PASCAL TTXProcessCommand(HWND hWin, WORD cmd) {
606606 switch (cmd) {
607607 case ID_MENU_SETUP:
608+ SetDialogFont("TTXRecurringCommand", pvar->ts->UILanguageFile);
608609 switch (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SETUP_RECURRINGCOMMAND),
609610 hWin, RecurringCommandSetting, (LPARAM)NULL)) {
610611 case IDOK:
--- branches/cmake/teraterm/common/dlglib.c (revision 7379)
+++ branches/cmake/teraterm/common/dlglib.c (revision 7380)
@@ -424,6 +424,7 @@
424424 /**
425425 * 使用するCharSetを取得する
426426 */
427+#if 0
427428 DWORD GetCharSet()
428429 {
429430 DWORD codepage;
@@ -450,10 +451,12 @@
450451
451452 return charset_info.ciCharset;
452453 }
454+#endif
453455
454456 /**
455457 * 使用するダイアログフォントの候補
456458 */
459+#if 0
457460 typedef struct {
458461 const TCHAR *face;
459462 LONG height;
@@ -508,6 +511,7 @@
508511 }
509512 }
510513 }
514+#endif
511515
512516 /**
513517 * 使用するダイアログフォントを決定する
@@ -514,8 +518,6 @@
514518 */
515519 void SetDialogFont(const char *section, const char *UILanguageFile)
516520 {
517- BYTE char_set = SYMBOL_CHARSET; // symbolを使うことはないだろう
518-
519521 // 明示的に指定されている場合はそれに従う
520522 {
521523 static const char *dlg_font_keys[] = {
@@ -528,7 +530,7 @@
528530 int i;
529531 if (section != NULL) {
530532 for (i = 0; i < _countof(dlg_font_keys); i++) {
531- result = GetI18nLogfont(section, "DLG_FONT", &logfont, 72, UILanguageFile);
533+ result = GetI18nLogfont(section, dlg_font_keys[i], &logfont, 72, UILanguageFile);
532534 if (result == TRUE) {
533535 break;
534536 }
@@ -536,7 +538,7 @@
536538 }
537539 if (result == FALSE) {
538540 for (i = 0; i < _countof(dlg_font_keys); i++) {
539- result = GetI18nLogfont("Tera Term", "DLG_FONT", &logfont, 72, UILanguageFile);
541+ result = GetI18nLogfont("Tera Term", dlg_font_keys[i], &logfont, 72, UILanguageFile);
540542 if (result == TRUE) {
541543 break;
542544 }
@@ -556,31 +558,12 @@
556558 return;
557559 }
558560 #endif
559-
560- // 使用したかったフォントのCharSetを取得
561- char_set = logfont.lfCharSet;
562- // TODO フォントが見つからなかったときの処理
563- // messagebox()出して下へ続くが妥当か?
561+ // フォントが見つからなかったとき、
562+ // 文字化けで正しく表示されない事態となる
563+ // messagebox()のフォントをとりあえず選択しておく
564564 }
565565 }
566566
567- // 実際に存在するフォントを使用する
568- {
569- if (char_set == SYMBOL_CHARSET) {
570- // 未設定の場合
571- char_set = GetCharSet();
572- }
573- const DialogFontLists *list = GetDialogFontCandidate(char_set);
574- while(list->face != NULL) {
575- if (IsExistFont(list->face, char_set, TRUE)) {
576- // 候補内に存在するフォントが存在した
577- TTSetDlgFont(list->face, list->height, char_set);
578- return;
579- }
580- list++;
581- }
582- }
583-
584567 // messageboxのフォントを選択
585568 {
586569 NONCLIENTMETRICS nci;
--- branches/cmake/teraterm/common/dlglib_tmpl.cpp (revision 7379)
+++ branches/cmake/teraterm/common/dlglib_tmpl.cpp (revision 7380)
@@ -392,7 +392,7 @@
392392 new_size = prev_size;
393393 } else {
394394 // copy with replacing font
395- size_t size_namediff =
395+ int size_namediff =
396396 wcslen(FontFaceName) - wcslen(logfont.lfFaceName);
397397 size_namediff *= sizeof(WCHAR);
398398 size_namediff += 3; // テキスト、フォント名長でalignが変化する
--- branches/cmake/teraterm/common/i18n.c (revision 7379)
+++ branches/cmake/teraterm/common/i18n.c (revision 7380)
@@ -82,12 +82,32 @@
8282 #endif
8383 }
8484
85+static void GetMessageBoxFontName(char *FontName)
86+{
87+ NONCLIENTMETRICSA nci;
88+#if(WINVER >= 0x0600)
89+ int st_size = offsetof(NONCLIENTMETRICSA, iPaddedBorderWidth);
90+#else
91+ int st_size = sizeof(NONCLIENTMETRICSA);
92+#endif
93+ BOOL r;
94+ const LOGFONTA *logfont;
8595
96+ memset(&nci, 0, sizeof(nci));
97+ nci.cbSize = st_size;
98+ r = SystemParametersInfoA(SPI_GETNONCLIENTMETRICS, st_size, &nci, 0);
99+ assert(r == TRUE);
100+ logfont = &nci.lfStatusFont;
101+
102+ strcpy(FontName, logfont->lfFaceName);
103+}
104+
86105 DllExport int GetI18nLogfont(const char *section, const char *key, PLOGFONTA logfont, int ppi, const char *iniFile)
87106 {
88107 static char tmp[MAX_UIMSG];
89108 static char font[LF_FACESIZE];
90109 int hight, charset;
110+ assert(iniFile[0] != '\0');
91111 GetPrivateProfileStringA(section, key, "", tmp, MAX_UIMSG, iniFile);
92112 if (tmp[0] == '\0') {
93113 return FALSE;
@@ -97,7 +117,12 @@
97117 GetNthNum(tmp, 2, &hight);
98118 GetNthNum(tmp, 3, &charset);
99119
100- strncpy_s(logfont->lfFaceName, sizeof(logfont->lfFaceName), font, _TRUNCATE);
120+ memset(logfont, 0, sizeof(*logfont));
121+ if (font[0] == '\0') {
122+ GetMessageBoxFontName(logfont->lfFaceName);
123+ } else {
124+ strncpy_s(logfont->lfFaceName, sizeof(logfont->lfFaceName), font, _TRUNCATE);
125+ }
101126 logfont->lfCharSet = (BYTE)charset;
102127 logfont->lfHeight = MulDiv(hight, -ppi, 72);
103128 logfont->lfWidth = 0;
--- branches/cmake/teraterm/ttpdlg/ttdlg.c (revision 7379)
+++ branches/cmake/teraterm/ttpdlg/ttdlg.c (revision 7380)
@@ -2777,6 +2777,7 @@
27772777 i = IDD_TERMDLG;
27782778 }
27792779
2780+ SetDialogFont(NULL, UILanguageFile);
27802781 return
27812782 (BOOL)DialogBoxParam(hInst,
27822783 MAKEINTRESOURCE(i),
@@ -2785,6 +2786,7 @@
27852786
27862787 DllExport BOOL WINAPI _SetupWin(HWND WndParent, PTTSet ts)
27872788 {
2789+ SetDialogFont(NULL, UILanguageFile);
27882790 return
27892791 (BOOL)DialogBoxParam(hInst,
27902792 MAKEINTRESOURCE(IDD_WINDLG),
@@ -2793,6 +2795,7 @@
27932795
27942796 DllExport BOOL WINAPI _SetupKeyboard(HWND WndParent, PTTSet ts)
27952797 {
2798+ SetDialogFont(NULL, UILanguageFile);
27962799 return
27972800 (BOOL)DialogBoxParam(hInst,
27982801 MAKEINTRESOURCE(IDD_KEYBDLG),
@@ -2801,6 +2804,7 @@
28012804
28022805 DllExport BOOL WINAPI _SetupSerialPort(HWND WndParent, PTTSet ts)
28032806 {
2807+ SetDialogFont(NULL, UILanguageFile);
28042808 return
28052809 (BOOL)DialogBoxParam(hInst,
28062810 MAKEINTRESOURCE(IDD_SERIALDLG),
@@ -2809,6 +2813,7 @@
28092813
28102814 DllExport BOOL WINAPI _SetupTCPIP(HWND WndParent, PTTSet ts)
28112815 {
2816+ SetDialogFont(NULL, UILanguageFile);
28122817 return
28132818 (BOOL)DialogBoxParam(hInst,
28142819 MAKEINTRESOURCE(IDD_TCPIPDLG),
@@ -2817,6 +2822,7 @@
28172822
28182823 DllExport BOOL WINAPI _GetHostName(HWND WndParent, PGetHNRec GetHNRec)
28192824 {
2825+ SetDialogFont(NULL, UILanguageFile);
28202826 return
28212827 (BOOL)DialogBoxParam(hInst,
28222828 MAKEINTRESOURCE(IDD_HOSTDLG),
@@ -2825,6 +2831,7 @@
28252831
28262832 DllExport BOOL WINAPI _ChangeDirectory(HWND WndParent, PCHAR CurDir)
28272833 {
2834+ SetDialogFont(NULL, UILanguageFile);
28282835 return
28292836 (BOOL)DialogBoxParam(hInst,
28302837 MAKEINTRESOURCE(IDD_DIRDLG),
@@ -2833,6 +2840,7 @@
28332840
28342841 DllExport BOOL WINAPI _AboutDialog(HWND WndParent)
28352842 {
2843+ SetDialogFont(NULL, UILanguageFile);
28362844 return
28372845 (BOOL)DialogBox(hInst,
28382846 MAKEINTRESOURCE(IDD_ABOUTDLG),
@@ -2909,6 +2917,7 @@
29092917
29102918 DllExport BOOL WINAPI _SetupGeneral(HWND WndParent, PTTSet ts)
29112919 {
2920+ SetDialogFont(NULL, UILanguageFile);
29122921 return
29132922 (BOOL)DialogBoxParam(hInst,
29142923 MAKEINTRESOURCE(IDD_GENDLG),
@@ -2917,6 +2926,7 @@
29172926
29182927 DllExport BOOL WINAPI _WindowWindow(HWND WndParent, PBOOL Close)
29192928 {
2929+ SetDialogFont(NULL, UILanguageFile);
29202930 *Close = FALSE;
29212931 return
29222932 (BOOL)DialogBoxParam(hInst,
--- branches/cmake/ttssh2/ttxssh/ttxssh.c (revision 7379)
+++ branches/cmake/ttssh2/ttxssh/ttxssh.c (revision 7380)
@@ -217,7 +217,6 @@
217217 pvar->err_msg = NULL;
218218
219219 init_TTSSH(pvar);
220- SetDialogFont("TTSSH", ts->UILanguageFile);
221220 }
222221
223222 static void normalize_generic_order(char *buf, char default_strings[], int default_strings_len)
@@ -1714,8 +1713,14 @@
17141713 return FALSE;
17151714 }
17161715
1716+static void UTIL_SetDialogFont()
1717+{
1718+ SetDialogFont("TTSSH", pvar->ts->UILanguageFile);
1719+}
1720+
17171721 static BOOL PASCAL TTXGetHostName(HWND parent, PGetHNRec rec)
17181722 {
1723+ UTIL_SetDialogFont();
17191724 return (BOOL) DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_HOSTDLG),
17201725 parent, TTXHostDlg, (LPARAM)rec);
17211726 }
@@ -5321,6 +5326,7 @@
53215326 return 0; // SSH2で処理されなかった場合は、本来の動作を行うべく、ゼロを返す。
53225327
53235328 case ID_SSHSCPMENU:
5329+ UTIL_SetDialogFont();
53245330 if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SSHSCP), hWin, TTXScpDialog,
53255331 (LPARAM) pvar) == -1) {
53265332 UTIL_get_lang_msgT("MSG_CREATEWINDOW_SCP_ERROR", uimsg1, _countof(uimsg1),
@@ -5332,6 +5338,7 @@
53325338 return 1;
53335339
53345340 case ID_SSHKEYGENMENU:
5341+ UTIL_SetDialogFont();
53355342 if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SSHKEYGEN), hWin, TTXKeyGenerator,
53365343 (LPARAM) pvar) == -1) {
53375344 UTIL_get_lang_msgT("MSG_CREATEWINDOW_KEYGEN_ERROR", uimsg1, _countof(uimsg1),
@@ -5343,6 +5350,7 @@
53435350 return 1;
53445351
53455352 case ID_ABOUTMENU:
5353+ UTIL_SetDialogFont();
53465354 if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ABOUTDIALOG),
53475355 hWin, TTXAboutDlg, (LPARAM) pvar) == -1) {
53485356 UTIL_get_lang_msgT("MSG_CREATEWINDOW_ABOUT_ERROR", uimsg1, _countof(uimsg1),
@@ -5353,9 +5361,11 @@
53535361 }
53545362 return 1;
53555363 case ID_SSHAUTH:
5364+ UTIL_SetDialogFont();
53565365 AUTH_do_cred_dialog(pvar);
53575366 return 1;
53585367 case ID_SSHSETUPMENU:
5368+ UTIL_SetDialogFont();
53595369 if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SSHSETUP),
53605370 hWin, TTXSetupDlg, (LPARAM) pvar) == -1) {
53615371 UTIL_get_lang_msgT("MSG_CREATEWINDOW_SETUP_ERROR", uimsg1, _countof(uimsg1),
@@ -5366,15 +5376,19 @@
53665376 }
53675377 return 1;
53685378 case ID_SSHAUTHSETUPMENU:
5379+ UTIL_SetDialogFont();
53695380 AUTH_do_default_cred_dialog(pvar);
53705381 return 1;
53715382 case ID_SSHFWDSETUPMENU:
5383+ UTIL_SetDialogFont();
53725384 FWDUI_do_forwarding_dialog(pvar);
53735385 return 1;
53745386 case ID_SSHUNKNOWNHOST:
5387+ UTIL_SetDialogFont();
53755388 HOSTS_do_unknown_host_dialog(hWin, pvar);
53765389 return 1;
53775390 case ID_SSHDIFFERENTKEY:
5391+ UTIL_SetDialogFont();
53785392 HOSTS_do_different_key_dialog(hWin, pvar);
53795393 return 1;
53805394 case ID_SSHASYNCMESSAGEBOX:
Show on old repository browser