[ttssh2-commit] [10025] Theme editor を追加

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2022年 6月 26日 (日) 01:15:18 JST


Revision: 10025
          https://osdn.net/projects/ttssh2/scm/svn/commits/10025
Author:   zmatsuo
Date:     2022-06-26 01:15:18 +0900 (Sun, 26 Jun 2022)
Log Message:
-----------
Theme editor を追加

- [設定]/[その他の設定]/Theme editor
- プロパティーページの追加
- 読み込まれているテーマを修正してファイルに出力できる

Modified Paths:
--------------
    branches/theme/teraterm/common/tt_res.h
    branches/theme/teraterm/teraterm/addsetting.cpp
    branches/theme/teraterm/teraterm/ttermpro.rc
    branches/theme/teraterm/teraterm/vtdisp.c
    branches/theme/teraterm/teraterm/vtdisp.h

-------------- next part --------------
Modified: branches/theme/teraterm/common/tt_res.h
===================================================================
--- branches/theme/teraterm/common/tt_res.h	2022-06-25 16:15:08 UTC (rev 10024)
+++ branches/theme/teraterm/common/tt_res.h	2022-06-25 16:15:18 UTC (rev 10025)
@@ -127,6 +127,7 @@
 #define IDC_PROTOFNAME                  2301
 #define IDD_TABSHEET_COPYPASTE          2301
 #define IDC_PROTOPROT                   2302
+#define IDD_TABSHEET_THEME_EDITOR       2302
 #define IDC_PROTOPKTNUM                 2303
 #define IDC_PROTOBYTECOUNT              2304
 #define IDC_PROTOPERCENT                2305
@@ -147,6 +148,7 @@
 #define IDC_BGIMG_EDIT                  2510
 #define IDC_ROTATE_SIZE                 2510
 #define IDC_THEME_EDIT                  2511
+#define IDC_BGIMG_EDIT2                 2511
 #define IDC_CONFIRM_CHANGE_PASTE        2512
 #define IDC_CURSOR_CTRL_SEQ             2512
 #define IDC_LOG_ROTATE                  2512
@@ -176,6 +178,7 @@
 #define IDC_CLIPBOARD_ACCESS_LABEL      2529
 #define IDC_ROTATE_SIZE_TYPE            2529
 #define IDC_THEME_BUTTON                2529
+#define IDC_BGIMG_BUTTON2               2529
 #define IDC_CLIPBOARD_ACCESS            2530
 #define IDC_ROTATE_STEP                 2530
 #define IDC_ROTATE_STEP_TEXT            2531
@@ -192,6 +195,13 @@
 #define IDC_OPT_TIMESTAMP_TYPE          2541
 #define IDC_BGIMG_BRIGHTNESS            2551
 #define IDC_EDIT_BGIMG_BRIGHTNESS       2552
+#define IDC_BGIMG_BRIGHTNESS2           2553
+#define IDC_EDIT_BGIMG_BRIGHTNESS2      2554
+#define IDC_BGIMG_BRIGHTNESS3           2555
+#define IDC_BGIMG_BRIGHTNESS4           2556
+#define IDC_EDIT_BGIMG_BRIGHTNESS3      2557
+#define IDC_EDIT_BGIMG_BRIGHTNESS4      2558
+#define IDC_BGIMG_BRIGHTNESS5           2559
 #define IDC_TRIMNLCHAR                  2564
 #define IDC_CLIPBOARD_NOTIFY            2566
 #define IDC_LIST_HIDDEN_FONTS           2567
@@ -219,6 +229,7 @@
 #define IDC_SELECT_ON_ACTIVATE          2589
 #define IDC_MIXED_THEME_FILE            2590
 #define IDC_ACCEPT_CLEAR_SBUFF          2591
+#define IDC_MIXED_THEME_FILE2           2591
 #define IDC_DEBUG_POPUP_ENABLE          2592
 #define IDC_DEBUG_POPUP_KEY1            2593
 #define IDC_DEBUG_POPUP_KEY2            2594
@@ -238,6 +249,11 @@
 #define IDC_THEME_FILE                  2609
 #define IDC_TH_READ                     2610
 #define IDC_TH_WRITE                    2611
+#define IDC_BUTTON1                     2612
+#define IDC_BUTTON2                     2613
+#define IDC_BUTTON3                     2614
+#define IDC_COMBO1                      2616
+#define IDC_STATIC_HELP                 2617
 #define ID_ACC_SENDBREAK                50001
 #define ID_ACC_COPY                     50002
 #define ID_ACC_NEWCONNECTION            50003
@@ -338,7 +354,7 @@
 #define _APS_NO_MFC                     1
 #define _APS_NEXT_RESOURCE_VALUE        132
 #define _APS_NEXT_COMMAND_VALUE         52031
-#define _APS_NEXT_CONTROL_VALUE         2612
+#define _APS_NEXT_CONTROL_VALUE         2618
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif

Modified: branches/theme/teraterm/teraterm/addsetting.cpp
===================================================================
--- branches/theme/teraterm/teraterm/addsetting.cpp	2022-06-25 16:15:08 UTC (rev 10024)
+++ branches/theme/teraterm/teraterm/addsetting.cpp	2022-06-25 16:15:18 UTC (rev 10025)
@@ -55,6 +55,7 @@
 #include "font_pp.h"
 #include "asprintf.h"
 #include "win32helper.h"
+#include "vtdisp.h"	// for ThemeEditorCreate()
 
 const mouse_cursor_t MouseCursor[] = {
 	{"ARROW", IDC_ARROW},
@@ -1692,6 +1693,8 @@
 	AddPage(page);
 	page = FontPageCreate(hInstance, &ts);
 	AddPage(page);
+	page = ThemeEditorCreate(hInstance, &ts);
+	AddPage(page);
 
 	wchar_t *title = TTGetLangStrW("Tera Term", "DLG_TABSHEET_TITLE", L"Tera Term: Additional settings", ts.UILanguageFile);
 	SetCaption(title);

Modified: branches/theme/teraterm/teraterm/ttermpro.rc
===================================================================
--- branches/theme/teraterm/teraterm/ttermpro.rc	2022-06-25 16:15:08 UTC (rev 10024)
+++ branches/theme/teraterm/teraterm/ttermpro.rc	2022-06-25 16:15:18 UTC (rev 10025)
@@ -351,7 +351,35 @@
     PUSHBUTTON      "Cancel",IDCANCEL,215,166,50,14
 END
 
+IDD_TABSHEET_THEME_EDITOR DIALOGEX 0, 0, 326, 309
+STYLE DS_SETFONT | DS_CONTROL | WS_CHILD | WS_SYSMENU
+FONT 8, "Tahoma", 0, 0, 0x0
+BEGIN
+    CONTROL         "&Eterm lookfeel(*)",IDC_ETERM_LOOKFEEL,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,228,270,74,12
+    CONTROL         "Mixed &ThemeFile to Background (alpha blend desktop wallpaper image)",IDC_MIXED_THEME_FILE,
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,167,269,10
+    LTEXT           "Image Brightness (Alpha) 0...255",IDC_BGIMG_BRIGHTNESS,37,182,143,8
+    EDITTEXT        IDC_EDIT_BGIMG_BRIGHTNESS,37,247,34,14,ES_AUTOHSCROLL | ES_NUMBER
+    CONTROL         "Background &Image",IDC_BGIMG_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,107,73,10
+    EDITTEXT        IDC_BGIMG_EDIT,37,123,255,14,ES_AUTOHSCROLL
+    PUSHBUTTON      "...",IDC_BGIMG_BUTTON,302,123,14,14
+    LTEXT           "targte file",IDC_BGIMG_BRIGHTNESS2,5,5,126,8
+    CONTROL         "Mixed simple color plane",IDC_MIXED_THEME_FILE2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,22,217,221,10
+    EDITTEXT        IDC_EDIT_BGIMG_BRIGHTNESS2,37,277,22,14,ES_AUTOHSCROLL | ES_NUMBER
+    EDITTEXT        IDC_BGIMG_EDIT2,22,17,270,14,ES_AUTOHSCROLL | ES_READONLY
+    PUSHBUTTON      "Read",IDC_BUTTON1,22,35,50,14
+    PUSHBUTTON      "Write",IDC_BUTTON3,77,35,50,14
+    LTEXT           "Alpha 0...255",IDC_BGIMG_BRIGHTNESS3,37,265,143,8
+    LTEXT           "Color (RRGGBB)",IDC_BGIMG_BRIGHTNESS4,37,232,143,8
+    EDITTEXT        IDC_EDIT_BGIMG_BRIGHTNESS3,37,195,22,14,ES_AUTOHSCROLL | ES_NUMBER
+    EDITTEXT        IDC_EDIT_BGIMG_BRIGHTNESS4,37,87,34,14,ES_AUTOHSCROLL | ES_NUMBER
+    LTEXT           "Color (RRGGBB)",IDC_BGIMG_BRIGHTNESS5,37,73,143,8
+    LTEXT           "base",IDC_STATIC,22,58,16,8
+    COMBOBOX        IDC_COMBO1,37,146,107,45,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+    LTEXT           "static text",IDC_STATIC_HELP,135,34,176,82
+END
 
+
 /////////////////////////////////////////////////////////////////////////////
 //
 // DESIGNINFO
@@ -455,6 +483,21 @@
         VERTGUIDE, 18
         BOTTOMMARGIN, 180
     END
+
+    IDD_TABSHEET_THEME_EDITOR, DIALOG
+    BEGIN
+        LEFTMARGIN, 5
+        RIGHTMARGIN, 320
+        VERTGUIDE, 22
+        VERTGUIDE, 37
+        VERTGUIDE, 292
+        VERTGUIDE, 302
+        TOPMARGIN, 5
+        BOTTOMMARGIN, 305
+        HORZGUIDE, 24
+        HORZGUIDE, 42
+        HORZGUIDE, 130
+    END
 END
 #endif    // APSTUDIO_INVOKED
 

Modified: branches/theme/teraterm/teraterm/vtdisp.c
===================================================================
--- branches/theme/teraterm/teraterm/vtdisp.c	2022-06-25 16:15:08 UTC (rev 10024)
+++ branches/theme/teraterm/teraterm/vtdisp.c	2022-06-25 16:15:18 UTC (rev 10025)
@@ -205,8 +205,63 @@
 static HBITMAP GetBitmapHandle(const char *File);
 
 
-//\x95֗\x98\x8A֐\x94\x81\x99
+typedef struct {
+	BG_PATTERN id;
+	const char *str;
+} BG_PATTERN_ST;
 
+static const BG_PATTERN_ST *GetBGPatternList(int index)
+{
+	static const BG_PATTERN_ST bg_pattern_list[] = {
+		{ BG_STRETCH, "stretch" },
+		{ BG_TILE, "tile" },
+		{ BG_CENTER, "center" },
+		{ BG_FIT_WIDTH, "fit_width" },
+		{ BG_FIT_HEIGHT, "fit_height" },
+		{ BG_AUTOFIT, "autofit" },
+		{ BG_AUTOFILL, "autofill" },
+	};
+
+	if (index >= _countof(bg_pattern_list)) {
+		return NULL;
+	}
+	return &bg_pattern_list[index];
+}
+
+static const char *GetBGPatternStr(BG_PATTERN id)
+{
+	int index;
+	for (index = 0;; index++) {
+		const BG_PATTERN_ST *st = GetBGPatternList(index);
+		if (st == NULL) {
+			// \x8C\xA9\x82‚\xA9\x82\xE7\x82Ȃ\xA2
+			st = GetBGPatternList(0);
+			return st->str;
+		}
+		if (st->id == id) {
+			return st->str;
+		}
+	}
+}
+
+static BOOL GetBGPatternID(const char *str, BG_PATTERN *pattern)
+{
+	int index;
+	for (index = 0;; index++) {
+		const BG_PATTERN_ST *st = GetBGPatternList(index);
+		if (st == NULL) {
+			// \x8C\xA9\x82‚\xA9\x82\xE7\x82Ȃ\xA2
+			st = GetBGPatternList(0);
+			*pattern = st->id;
+			return FALSE;
+		}
+		if (_stricmp(st->str, str) == 0) {
+			*pattern = st->id;
+			return TRUE;
+		}
+	}
+}
+
 // LoadImage() \x82\xB5\x82\xA9\x8Eg\x82\xA6\x82Ȃ\xA2\x8A‹\xAB\x82\xA9\x82ǂ\xA4\x82\xA9\x82𔻕ʂ\xB7\x82\xE9\x81B
 // LoadImage()\x82ł\xCD .bmp \x88ȊO\x82̉摜\x83t\x83@\x83C\x83\x8B\x82\xAA\x88\xB5\x82\xA6\x82Ȃ\xA2\x82̂ŗv\x92\x8D\x88ӁB
 // (2014.4.20 yutaka)
@@ -1285,9 +1340,21 @@
 
 static BG_PATTERN BGGetPattern(const char *name, BG_PATTERN def, const wchar_t *file)
 {
+#if 0
 	static const char *strList[6] = {"stretch", "tile", "center", "fitwidth", "fitheight", "autofit"};
 
 	return BGGetStrIndex(name, def, file, strList, 6);
+#endif
+	BG_PATTERN retval;
+	char str[64];
+	GetPrivateProfileStringAFileW(BG_SECTION, name, "", str, _countof(str), file);
+	if (str[0] == 0) {
+		return def;
+	}
+	if (GetBGPatternID(str, &retval) == FALSE) {
+		retval = def;
+	}
+	return retval;
 }
 
 static BG_TYPE BGGetType(const char *name, BG_TYPE def, const wchar_t *file)
@@ -1436,6 +1503,41 @@
 	free(prevDir);
 }
 
+void WriteInt3(const char *Sect, const char *Key, const wchar_t *FName,
+			   int i1, int i2, int i3)
+{
+	char Temp[96];
+	_snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d,%d",
+	            i1, i2,i3);
+	WritePrivateProfileStringAFileW(Sect, Key, Temp, FName);
+}
+
+void WriteCOLORREF(const char *Sect, const char *Key, const wchar_t *FName, COLORREF color)
+{
+	int red = color & 0xff;
+	int green = (color >> 8) & 0xff;
+	int blue = (color >> 16) & 0xff;
+
+	WriteInt3(Sect, Key, FName, red, green, blue);
+}
+
+/**
+ *	\x83e\x81[\x83}\x83t\x83@\x83C\x83\x8B\x82̏\x91\x82\xAB\x8D\x9E\x82\xDD
+ */
+static void BGWriteIniFile(const wchar_t *file)
+{
+	WritePrivateProfileStringAFileW(BG_SECTION, BG_DESTFILE, BGDest.file, file);
+	WritePrivateProfileStringAFileW(BG_SECTION, "BGDestType",
+									BGDest.type == BG_PICTURE ? "picture" : "color", file);
+	WriteCOLORREF(BG_SECTION, "BGDestColor", file, BGDest.color);
+	WritePrivateProfileStringAFileW(BG_SECTION, "BGDestPattern", GetBGPatternStr(BGDest.pattern), file);
+
+	WritePrivateProfileIntAFileW(BG_SECTION, "BGSrc1Alpha", BGSrc1.alpha, file);
+
+	WritePrivateProfileIntAFileW(BG_SECTION, "BGSrc2Alpha", BGSrc2.alpha, file);
+	WriteCOLORREF(BG_SECTION, "BGSrc2Color", file, BGSrc2.color);
+}
+
 static void BGDestruct(void)
 {
   if(!BGEnable)
@@ -3899,3 +4001,307 @@
 	}
 	return color;
 }
+
+//////////////////////////////////////////////////////////////////////////////
+
+#include "tt_res.h"
+#include "dlglib.h"
+#include "tipwin2.h"
+#include "helpid.h"
+
+typedef struct _FontPPData {
+	HINSTANCE hInst;
+	TTTSet *pts;
+	DLGTEMPLATE *dlg_templ;
+	wchar_t *target_file;
+	TipWin2 *tipwin;
+} ThemeEditorData;
+
+static void SetWindowTextColor(HWND hWnd, COLORREF color)
+{
+	char str[32];
+	sprintf(str, "%02x%02x%02x", GetRValue(color), GetGValue(color), GetBValue(color));
+	SetWindowTextA(hWnd, str);
+}
+
+static void SetDlgItemTextColor(HWND hDlg, int ID, COLORREF color)
+{
+	SetWindowTextColor(GetDlgItem(hDlg, ID), color);
+}
+
+static COLORREF GetWindowTextColor(HWND hWnd)
+{
+	char str[32];
+	unsigned int r, g, b;
+	char elem[3];
+
+	GetWindowTextA(hWnd, str, _countof(str));
+
+	memcpy(elem, &str[0], 2);
+	elem[2] = 0;
+	r = 0;
+	sscanf(elem, "%x", &r);
+
+	memcpy(elem, &str[2], 2);
+	elem[2] = 0;
+	g = 0;
+	sscanf(elem, "%x", &g);
+
+	memcpy(elem, &str[4], 2);
+	elem[2] = 0;
+	b = 0;
+	sscanf(elem, "%x", &b);
+
+	return RGB(r, g, b);
+}
+
+static COLORREF GetDlgItemTextColor(HWND hDlg, int ID)
+{
+	return GetWindowTextColor(GetDlgItem(hDlg, ID));
+}
+
+static void ResetControls(HWND hWnd, ThemeEditorData *dlg_data)
+{
+	SendDlgItemMessage(hWnd, IDC_BGIMG_CHECK, BM_SETCHECK, (BGDest.type == BG_PICTURE) ? TRUE : FALSE, 0);
+	SetDlgItemTextA(hWnd, IDC_BGIMG_EDIT, BGDest.file);
+	SetDlgItemTextColor(hWnd, IDC_EDIT_BGIMG_BRIGHTNESS4, BGDest.color);
+	{
+		int count = SendDlgItemMessageA(hWnd, IDC_COMBO1, CB_GETCOUNT, 0, 0);
+		int sel = 0;
+		int i;
+		for (i = 0; i < count; i++) {
+			BG_PATTERN pattern = (BG_PATTERN)SendDlgItemMessageW(hWnd, IDC_COMBO1, CB_GETITEMDATA, i, 0);
+			if (pattern == BGDest.pattern) {
+				sel = i;
+				break;
+			}
+		}
+		SendDlgItemMessage(hWnd, IDC_COMBO1, CB_SETCURSEL, sel, 0);
+	}
+
+
+	SendDlgItemMessage(hWnd, IDC_MIXED_THEME_FILE, BM_SETCHECK, BGSrc1.alpha != 0, 0);
+	SetDlgItemInt(hWnd, IDC_EDIT_BGIMG_BRIGHTNESS3, BGSrc1.alpha, FALSE);
+
+	SendDlgItemMessage(hWnd, IDC_MIXED_THEME_FILE2, BM_SETCHECK, BGSrc2.alpha != 0, 0);
+	SetDlgItemInt(hWnd, IDC_EDIT_BGIMG_BRIGHTNESS2, BGSrc2.alpha, FALSE);
+	SetDlgItemTextColor(hWnd, IDC_EDIT_BGIMG_BRIGHTNESS, BGSrc2.color);
+}
+
+static INT_PTR CALLBACK Proc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
+{
+	static const DlgTextInfo TextInfos[] = {
+		{0, "DLG_GEN_TITLE"},
+	};
+	ThemeEditorData *dlg_data = (ThemeEditorData *)GetWindowLongPtr(hWnd, DWLP_USER);
+	TTTSet *ts = dlg_data == NULL ? NULL : dlg_data->pts;
+
+	switch (msg) {
+		case WM_INITDIALOG: {
+			int i;
+			dlg_data = (ThemeEditorData *)(((PROPSHEETPAGEW_V1 *)lp)->lParam);
+			ts = dlg_data->pts;
+			SetWindowLongPtr(hWnd, DWLP_USER, (LONG_PTR)dlg_data);
+
+			dlg_data->tipwin = TipWin2Create(NULL, hWnd);
+			TipWin2SetTextW(dlg_data->tipwin, IDC_BGIMG_EDIT2,
+							L"\x82\xA2\x82ܕ\\x8E\xA6\x82\xB3\x82\xEA\x82Ă\xA2\x82\xE9\x83e\x81[\x83}\x83t\x83@\x83C\x83\x8B\x96\xBC"
+				);
+			TipWin2SetTextW(dlg_data->tipwin, IDC_BUTTON1,
+							L"target file \x82\xF0\x8Dēǂݍ\x9E\x82݂\xB7\x82\xE9\n"
+							L"\x8F\xAB\x97\x88\x82́A\x94C\x88ӂ̃e\x81[\x83}\x83t\x83@\x83C\x83\x8B\x82\xF0\x93ǂݍ\x9E\x82߂\xE9\x82悤\x82ɂ\xB7\x82\xE9"
+				);
+			TipWin2SetTextW(dlg_data->tipwin, IDC_BUTTON3,
+							L"\x8C\xBB\x8D݂̃_\x83C\x83A\x83\x8D\x83O\x82̏\xF3\x91Ԃ\xF0\x83e\x81[\x83}\x83t\x83@\x83C\x83\x8B\x82ɏ\x91\x82\xAB\x8D\x9E\x82\xDE\n"
+							L"\x8F\x91\x82\xAB\x8D\x9E\x82񂾃C\x83t\x83@\x83C\x83\x8B(\x83e\x81[\x83}\x83t\x83@\x83C\x83\x8B)\x82\xF0\n"
+							L"\x81u\x95\\x8E\xA6\x83^\x83u\x81v\x82œǂݍ\x9E\x82ݎw\x92肵\x82āA\x81uok\x81v\x89\x9F\x82\xB7\x82Ɣ\xBD\x89f\x82\xB3\x82\xEA\x82\xE9\n"
+							L"\x82\xB1\x82̃y\x81[\x83W\x82̐ݒ\xE8\x82͂\xB1\x82\xEA\x82ŏ\x91\x82\xAB\x8Fo\x82\xB3\x82Ȃ\xA2\x82Ǝ\xB8\x82\xED\x82\xEA\x82\xE9\n"
+				);
+			SetDlgItemTextW(hWnd, IDC_STATIC_HELP,
+							L"\x8E\x9F\x82̏\x87\x82ō\x87\x90\xAC\x82\xB3\x82\xEA\x82āA\x94w\x8Ci\x82ɕ\\x8E\xA6\x82\xB3\x82\xEA\x82\xE9\n"
+							L"base\n"
+							L"\x81\xAB\n"
+							L"Background Image\n"
+							L"\x81\xAB\n"
+							L"wallpaper\n"
+							L"\x81\xAB\n"
+							L"simple color plane"
+				);
+
+			for (i = 0;; i++) {
+				int index;
+				const BG_PATTERN_ST *st = GetBGPatternList(i);
+				if (st == NULL) {
+					break;
+				}
+				index = SendDlgItemMessageA(hWnd, IDC_COMBO1, CB_ADDSTRING, 0, (LPARAM)st->str);
+				SendDlgItemMessageW(hWnd, IDC_COMBO1, CB_SETITEMDATA, index, st->id);
+			}
+			SetDlgItemTextW(hWnd, IDC_BGIMG_EDIT2, dlg_data->target_file);
+			ResetControls(hWnd, dlg_data);
+
+			break;
+		}
+		case WM_NOTIFY: {
+			NMHDR *nmhdr = (NMHDR *)lp;
+			switch (nmhdr->code) {
+				case PSN_APPLY: {
+					TipWin2Destroy(dlg_data->tipwin);
+					dlg_data->tipwin = NULL;
+					break;
+				}
+				case PSN_HELP:
+					MessageBox(hWnd, "Tera Term", "not implimented",
+							   MB_OK | MB_ICONEXCLAMATION);
+					break;
+				default:
+					break;
+			}
+			break;
+		}
+		case WM_COMMAND: {
+			switch (wp) {
+			case IDC_BUTTON1 | (BN_CLICKED << 16): {
+				// \x8Dēǂݍ\x9E\x82\xDD
+				wchar_t *theme_file;
+				hGetDlgItemTextW(hWnd, IDC_BGIMG_EDIT2, &theme_file);
+				free(ts->EtermLookfeel.BGThemeFileW);
+				ts->EtermLookfeel.BGThemeFileW = theme_file;
+
+				BGReadIniFile(ts->EtermLookfeel.BGThemeFileW);
+				ResetControls(hWnd, dlg_data);
+				BGSetupPrimary(TRUE);
+				break;
+			}
+			case IDC_BGIMG_BUTTON | (BN_CLICKED << 16): {
+				// \x89摜\x83t\x83@\x83C\x83\x8B\x91I\x91\xF0
+				OPENFILENAMEW ofn = {0};
+				wchar_t bg_file[MAX_PATH];
+				wchar_t *bg_file_in;
+
+				hGetDlgItemTextW(hWnd, IDC_BGIMG_EDIT, &bg_file_in);
+				wcscpy_s(bg_file, _countof(bg_file), bg_file_in);
+				free(bg_file_in);
+
+				ofn.lStructSize = get_OPENFILENAME_SIZEW();
+				ofn.hwndOwner   = hWnd;
+				ofn.lpstrFile   = bg_file;
+				ofn.nMaxFile    = _countof(bg_file);
+				//ofn.lpstrFilter = "";
+				ofn.nFilterIndex = 1;
+				ofn.hInstance = hInst;
+				ofn.lpstrDefExt = L"jpg";
+				ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
+				ofn.lpstrTitle = L"select bg image file";
+
+				if (GetOpenFileNameW(&ofn)) {
+					SetDlgItemTextW(hWnd, IDC_BGIMG_EDIT, bg_file);
+				}
+				break;
+			}
+			case IDC_BUTTON3 | (BN_CLICKED << 16): {
+				// \x83R\x83\x93\x83g\x83\x8D\x81[\x83\x8B\x82\xA9\x82\xE7\x93ǂݏo\x82\xB5
+				wchar_t *theme_file_in;
+				wchar_t theme_file[MAX_PATH];
+				OPENFILENAMEW ofn = {0};
+				{
+					LRESULT checked;
+					int index;
+					checked = SendDlgItemMessageA(hWnd, IDC_BGIMG_CHECK, BM_GETCHECK, 0, 0);
+					BGDest.type = checked & BST_CHECKED ? BG_PICTURE : BG_COLOR;
+					GetDlgItemTextA(hWnd, IDC_BGIMG_EDIT, BGDest.file, sizeof(BGDest.file));
+					BGDest.color = GetDlgItemTextColor(hWnd, IDC_EDIT_BGIMG_BRIGHTNESS4);
+					index = SendDlgItemMessage(hWnd, IDC_COMBO1, CB_GETCURSEL, 0, 0);
+					BGDest.pattern = (BG_PATTERN)SendDlgItemMessage(hWnd, IDC_COMBO1, CB_GETITEMDATA, index, 0);
+
+					checked = SendDlgItemMessageA(hWnd, IDC_MIXED_THEME_FILE, BM_GETCHECK, 0, 0);
+					if (checked & BST_CHECKED) {
+						BGSrc1.alpha = GetDlgItemInt(hWnd, IDC_EDIT_BGIMG_BRIGHTNESS3, NULL, FALSE);
+					} else {
+						BGSrc1.alpha = 0;
+					}
+
+					checked = SendDlgItemMessageA(hWnd, IDC_MIXED_THEME_FILE2, BM_GETCHECK, 0, 0);
+					if (checked & BST_CHECKED) {
+						BGSrc2.alpha = GetDlgItemInt(hWnd, IDC_EDIT_BGIMG_BRIGHTNESS, NULL, FALSE);
+					} else {
+						BGSrc2.alpha = 0;
+					}
+					BGSrc2.color = GetDlgItemTextColor(hWnd, IDC_EDIT_BGIMG_BRIGHTNESS);
+				}
+
+				hGetDlgItemTextW(hWnd, IDC_BGIMG_EDIT2, &theme_file_in);
+				wcscpy_s(theme_file, _countof(theme_file), theme_file_in);
+				free(theme_file_in);
+
+				ofn.lStructSize = get_OPENFILENAME_SIZEW();
+				ofn.hwndOwner   = hWnd;
+				ofn.lpstrFile   = theme_file;
+				ofn.nMaxFile    = _countof(theme_file);
+				//ofn.lpstrFilter = "";
+				ofn.nFilterIndex = 1;
+				ofn.hInstance = hInst;
+				ofn.lpstrDefExt = L"ini";
+				ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
+				ofn.lpstrTitle = L"save theme file";
+
+				if (GetSaveFileNameW(&ofn)) {
+					BGWriteIniFile(theme_file);
+				}
+				break;
+			}
+			default:
+				break;
+			}
+			break;
+		}
+		default:
+			return FALSE;
+	}
+	return FALSE;
+}
+
+static UINT CALLBACK CallBack(HWND hwnd, UINT uMsg, struct _PROPSHEETPAGEW *ppsp)
+{
+	UINT ret_val = 0;
+	(void)hwnd;
+	switch (uMsg) {
+	case PSPCB_CREATE:
+		ret_val = 1;
+		break;
+	case PSPCB_RELEASE:
+		free((void *)ppsp->pResource);
+		ppsp->pResource = NULL;
+		free((void *)ppsp->lParam);
+		ppsp->lParam = 0;
+		break;
+	default:
+		break;
+	}
+	return ret_val;
+}
+
+HPROPSHEETPAGE ThemeEditorCreate(HINSTANCE inst, TTTSet *pts)
+{
+	const int id = IDD_TABSHEET_THEME_EDITOR;
+	PROPSHEETPAGEW_V1 psp = {0};
+
+	ThemeEditorData *Param = (ThemeEditorData *)calloc(sizeof(ThemeEditorData), 1);
+	Param->target_file = _wcsdup(pts->EtermLookfeel.BGThemeFileW);
+	Param->pts = &ts;
+
+	psp.dwSize = sizeof(psp);
+	psp.dwFlags = PSP_DEFAULT | PSP_USECALLBACK | PSP_USETITLE /*| PSP_HASHELP */;
+	psp.hInstance = inst;
+	psp.pfnCallback = CallBack;
+	psp.pszTitle = L"Theme Editor";		// TODO lng \x83t\x83@\x83C\x83\x8B\x82ɓ\xFC\x82\xEA\x82\xE9
+	psp.pszTemplate = MAKEINTRESOURCEW(id);
+	psp.dwFlags |= PSP_DLGINDIRECT;
+	Param->dlg_templ = TTGetDlgTemplate(inst, MAKEINTRESOURCEA(id));
+	psp.pResource = Param->dlg_templ;
+
+	psp.pfnDlgProc = Proc;
+	psp.lParam = (LPARAM)Param;
+
+	return CreatePropertySheetPageW((LPPROPSHEETPAGEW)&psp);
+}

Modified: branches/theme/teraterm/teraterm/vtdisp.h
===================================================================
--- branches/theme/teraterm/teraterm/vtdisp.h	2022-06-25 16:15:08 UTC (rev 10024)
+++ branches/theme/teraterm/teraterm/vtdisp.h	2022-06-25 16:15:18 UTC (rev 10025)
@@ -153,6 +153,8 @@
 #define WINDOW_REFRESH  6
 #define WINDOW_TOGGLE_MAXIMIZE 7
 
+HPROPSHEETPAGE ThemeEditorCreate(HINSTANCE inst, TTTSet *pts);
+
 #ifdef __cplusplus
 }
 #endif


ttssh2-commit メーリングリストの案内
Back to archive index