diff --git a/installer/release/lang_utf8/English.lng b/installer/release/lang_utf8/English.lng index 5ae5f2103..3bfdec2d5 100644 --- a/installer/release/lang_utf8/English.lng +++ b/installer/release/lang_utf8/English.lng @@ -451,7 +451,7 @@ DLG_CODING_UNICODE_TO_DEC_PUNCTUATION=Punctuation, Block Elements, Shade DLG_CODING_UNICODE_TO_DEC_MIDDLEDOT=Middle dots (U+00B7,U+2024,U+2219) DLG_CODING_DEC_TO_UNICODE=Mapping DEC Special Graphics to Unicode -DLG_WIN_TITLE=Tera Term: Window setup +DLG_WIN_TITLE=Window DLG_WIN_TITLELABEL=&Title: DLG_WIN_CURSOR=Cursor shape DLG_WIN_BLOCK=B&lock diff --git a/installer/release/lang_utf8/French.lng b/installer/release/lang_utf8/French.lng index d7412219f..e8cb52a97 100644 --- a/installer/release/lang_utf8/French.lng +++ b/installer/release/lang_utf8/French.lng @@ -451,7 +451,7 @@ DLG_CODING_UNICODE_TO_DEC_PUNCTUATION=Punctuation, Block Elements, Shade DLG_CODING_UNICODE_TO_DEC_MIDDLEDOT=Middle dots (U+00B7,U+2024,U+2219) DLG_CODING_DEC_TO_UNICODE=Mapping DEC Special Graphics to Unicode -DLG_WIN_TITLE=Tera Term:Fenêtre de Configuration +DLG_WIN_TITLE=Fenêtre DLG_WIN_TITLELABEL=&Titre: DLG_WIN_CURSOR=Forme du curseur DLG_WIN_BLOCK=B&loc diff --git a/installer/release/lang_utf8/German.lng b/installer/release/lang_utf8/German.lng index abad834cb..869ff460c 100644 --- a/installer/release/lang_utf8/German.lng +++ b/installer/release/lang_utf8/German.lng @@ -451,7 +451,7 @@ DLG_CODING_UNICODE_TO_DEC_PUNCTUATION=Punctuation, Block Elements, Shade DLG_CODING_UNICODE_TO_DEC_MIDDLEDOT=Middle dots (U+00B7,U+2024,U+2219) DLG_CODING_DEC_TO_UNICODE=Mapping DEC Special Graphics to Unicode -DLG_WIN_TITLE=Fenster-Einstellungen +DLG_WIN_TITLE=Fenster DLG_WIN_TITLELABEL=Titel DLG_WIN_CURSOR=Cursor-Aussehen DLG_WIN_BLOCK=Block diff --git a/installer/release/lang_utf8/Japanese.lng b/installer/release/lang_utf8/Japanese.lng index 0dd3136cd..a5abcf2d2 100644 --- a/installer/release/lang_utf8/Japanese.lng +++ b/installer/release/lang_utf8/Japanese.lng @@ -451,7 +451,7 @@ DLG_CODING_UNICODE_TO_DEC_PUNCTUATION= DLG_CODING_UNICODE_TO_DEC_MIDDLEDOT=中点(U+00B7,U+2024,U+2219) DLG_CODING_DEC_TO_UNICODE=DEC Special GraphicsをUnicodeへマッピングする -DLG_WIN_TITLE=Tera Term: ウィンドウの設定 +DLG_WIN_TITLE=ウィンドウ DLG_WIN_TITLELABEL=タイトル(&T): DLG_WIN_CURSOR=カーソルの形 DLG_WIN_BLOCK=四角(&L): diff --git a/installer/release/lang_utf8/Korean.lng b/installer/release/lang_utf8/Korean.lng index 294d66e18..d7e361d53 100644 --- a/installer/release/lang_utf8/Korean.lng +++ b/installer/release/lang_utf8/Korean.lng @@ -451,7 +451,7 @@ DLG_CODING_UNICODE_TO_DEC_PUNCTUATION=Punctuation, Block Elements, Shade DLG_CODING_UNICODE_TO_DEC_MIDDLEDOT=Middle dots (U+00B7,U+2024,U+2219) DLG_CODING_DEC_TO_UNICODE=Mapping DEC Special Graphics to Unicode -DLG_WIN_TITLE=Tera Term: 창 설정 +DLG_WIN_TITLE=창 DLG_WIN_TITLELABEL=타이틀(&T): DLG_WIN_CURSOR=커서 모양 DLG_WIN_BLOCK=블럭(&L) diff --git a/installer/release/lang_utf8/Russian.lng b/installer/release/lang_utf8/Russian.lng index ce1eef632..970f67448 100644 --- a/installer/release/lang_utf8/Russian.lng +++ b/installer/release/lang_utf8/Russian.lng @@ -451,7 +451,7 @@ DLG_CODING_UNICODE_TO_DEC_PUNCTUATION=Punctuation, Block Elements, Shade DLG_CODING_UNICODE_TO_DEC_MIDDLEDOT=Middle dots (U+00B7,U+2024,U+2219) DLG_CODING_DEC_TO_UNICODE=Mapping DEC Special Graphics to Unicode -DLG_WIN_TITLE=Tera Term: Настройка окон +DLG_WIN_TITLE=окон DLG_WIN_TITLELABEL=&Название: DLG_WIN_CURSOR=Вид курсора DLG_WIN_BLOCK=&Блок diff --git a/installer/release/lang_utf8/Simplified Chinese.lng b/installer/release/lang_utf8/Simplified Chinese.lng index 2df8660f4..1fa0bdf81 100644 --- a/installer/release/lang_utf8/Simplified Chinese.lng +++ b/installer/release/lang_utf8/Simplified Chinese.lng @@ -451,7 +451,7 @@ DLG_CODING_UNICODE_TO_DEC_PUNCTUATION=Punctuation, Block Elements, Shade DLG_CODING_UNICODE_TO_DEC_MIDDLEDOT=Middle dots (U+00B7,U+2024,U+2219) DLG_CODING_DEC_TO_UNICODE=Mapping DEC Special Graphics to Unicode -DLG_WIN_TITLE=Tera Term:窗口设置 +DLG_WIN_TITLE=窗口 DLG_WIN_TITLELABEL=标题(&T): DLG_WIN_CURSOR=光标形状 DLG_WIN_BLOCK=块状(&L) diff --git a/installer/release/lang_utf8/Spanish.lng b/installer/release/lang_utf8/Spanish.lng index 0fd15880f..129558937 100644 --- a/installer/release/lang_utf8/Spanish.lng +++ b/installer/release/lang_utf8/Spanish.lng @@ -451,7 +451,7 @@ DLG_CODING_UNICODE_TO_DEC_PUNCTUATION=Punctuation, Block Elements, Shade DLG_CODING_UNICODE_TO_DEC_MIDDLEDOT=Middle dots (U+00B7,U+2024,U+2219) DLG_CODING_DEC_TO_UNICODE=Mapping DEC Special Graphics to Unicode -DLG_WIN_TITLE=Tera Term: Window setup +DLG_WIN_TITLE=Window DLG_WIN_TITLELABEL=&Title: DLG_WIN_CURSOR=Cursor shape DLG_WIN_BLOCK=B&lock diff --git a/installer/release/lang_utf8/Tamil.lng b/installer/release/lang_utf8/Tamil.lng index b1c177d34..a430ece22 100644 --- a/installer/release/lang_utf8/Tamil.lng +++ b/installer/release/lang_utf8/Tamil.lng @@ -451,7 +451,7 @@ DLG_CODING_UNICODE_TO_DEC_PUNCTUATION=நிறுத்தம், தொகு DLG_CODING_UNICODE_TO_DEC_MIDDLEDOT=மத்திய புள்ளிகள் (U+00B7,U+2024,U+2219) DLG_CODING_DEC_TO_UNICODE=பதின்மம் சிறப்பு வரைகலை ஒருங்குறிக்கு வரைபடம் -DLG_WIN_TITLE=தேரா முனை: சாளர அமைப்பு +DLG_WIN_TITLE=சாளர DLG_WIN_TITLELABEL=&தலைப்பு: DLG_WIN_CURSOR=சிமிட்டும் கோடு வடிவம் DLG_WIN_BLOCK=தடு diff --git a/installer/release/lang_utf8/Traditional Chinese.lng b/installer/release/lang_utf8/Traditional Chinese.lng index 966b20006..4e315426f 100644 --- a/installer/release/lang_utf8/Traditional Chinese.lng +++ b/installer/release/lang_utf8/Traditional Chinese.lng @@ -451,7 +451,7 @@ DLG_CODING_UNICODE_TO_DEC_PUNCTUATION=Punctuation, Block Elements, Shade DLG_CODING_UNICODE_TO_DEC_MIDDLEDOT=Middle dots (U+00B7,U+2024,U+2219) DLG_CODING_DEC_TO_UNICODE=Mapping DEC Special Graphics to Unicode -DLG_WIN_TITLE=Tera Term:視窗設定 +DLG_WIN_TITLE=視窗 DLG_WIN_TITLELABEL=標題(&T): DLG_WIN_CURSOR=游標形狀 DLG_WIN_BLOCK=塊狀(&L) diff --git a/teraterm/teraterm/CMakeLists.txt b/teraterm/teraterm/CMakeLists.txt index 16bba4918..a115f6890 100644 --- a/teraterm/teraterm/CMakeLists.txt +++ b/teraterm/teraterm/CMakeLists.txt @@ -93,6 +93,8 @@ set(SRC_DIALOG coding_pp.h coding_pp.rc coding_pp_res.h + color_sample.cpp + color_sample.h debug_pp.cpp debug_pp.h debug_pp.rc @@ -135,6 +137,8 @@ set(SRC_DIALOG themedlg.h themedlg.rc themedlg_res.h + win_pp.cpp + win_pp.h ) target_sources( diff --git a/teraterm/teraterm/addsetting.cpp b/teraterm/teraterm/addsetting.cpp index b4621cc79..36c33e6a5 100644 --- a/teraterm/teraterm/addsetting.cpp +++ b/teraterm/teraterm/addsetting.cpp @@ -60,6 +60,7 @@ #include "log_pp.h" #include "tcpip_pp.h" #include "term_pp.h" +#include "win_pp.h" #include "addsetting.h" @@ -1526,6 +1527,8 @@ CAddSettingPropSheetDlg::CAddSettingPropSheetDlg(HINSTANCE hInstance, HWND hPare AddPage(page); page = CreateTerminalPP(hInstance, hParentWnd, & ts); AddPage(page); + page = CreateWinPP(hInstance, hParentWnd, &ts); + AddPage(page); wchar_t *title = TTGetLangStrW("Tera Term", "DLG_TABSHEET_TITLE", L"Tera Term: Additional settings", ts.UILanguageFileW); SetCaption(title); @@ -1561,6 +1564,9 @@ void CAddSettingPropSheetDlg::SetStartPage(Page page) case TermPage: start_page = 12; break; + case WinPage: + start_page = 13; + break; default: start_page = 0; break; diff --git a/teraterm/teraterm/addsetting.h b/teraterm/teraterm/addsetting.h index 40dd1ba79..3fb002ae9 100644 --- a/teraterm/teraterm/addsetting.h +++ b/teraterm/teraterm/addsetting.h @@ -55,6 +55,7 @@ class CAddSettingPropSheetDlg: public TTCPropSheetDlg KeyboardPage, TcpIpPage, TermPage, + WinPage, }; void SetStartPage(Page page); @@ -71,4 +72,5 @@ typedef enum { KeyboardPage, TcpIpPage, TermPage, + WinPage, } CAddSettingPropSheetDlgPage; diff --git a/teraterm/teraterm/color_sample.cpp b/teraterm/teraterm/color_sample.cpp new file mode 100644 index 000000000..48e1f35db --- /dev/null +++ b/teraterm/teraterm/color_sample.cpp @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2024- TeraTerm Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "ttwinman.h" +#include "color_sample.h" + +typedef struct ColorSampleTag { + HWND hWnd; + WNDPROC OrigProc; + int dummy; + COLORREF fore_color; + COLORREF back_color; + HFONT SampleFont; +} ColorSampleWork; + +static LRESULT CALLBACK CSProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + ColorSampleWork *work = (ColorSampleWork *)GetWindowLongPtr(hWnd, GWLP_USERDATA); + LRESULT Result; + + switch (msg) { + case WM_PAINT: { + int i, x, y; + int DX[3]; + TEXTMETRIC Metrics; + RECT TestRect; + int FW, FH; + + PAINTSTRUCT ps; + HDC hDC; + hDC = BeginPaint(hWnd, &ps); + + SetTextColor(hDC, work->fore_color); + SetBkColor(hDC, work->back_color); + SelectObject(hDC, work->SampleFont); + GetTextMetrics(hDC, &Metrics); + FW = Metrics.tmAveCharWidth; + FH = Metrics.tmHeight; + for (i = 0; i <= 2; i++) { + DX[i] = FW; + } + GetClientRect(hWnd, &TestRect); + x = (int)((TestRect.left + TestRect.right) / 2 - FW * 1.5); + y = (TestRect.top + TestRect.bottom - FH) / 2; + ExtTextOut(hDC, x, y, ETO_CLIPPED | ETO_OPAQUE, &TestRect, "ABC", 3, &(DX[0])); + break; + } + default: + break; + } + + Result = CallWindowProcW(work->OrigProc, hWnd, msg, wParam, lParam); + + switch (msg) { + case WM_NCDESTROY: { + SetWindowLongPtr(hWnd, GWLP_USERDATA, 0); + free(work); + break; + } + default: + break; + } + + return Result; +} + +ColorSample *ColorSampleInit(HWND hWnd) +{ + ColorSampleWork *work = (ColorSampleWork *)calloc(sizeof(*work), 1); + work->hWnd = hWnd; + work->SampleFont = ts.SampleFont; + work->OrigProc = (WNDPROC)SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)CSProc); + SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)work); + InvalidateRect(hWnd, NULL, TRUE); + return work; +} + +void ColorSampleSetColor(ColorSample *work, COLORREF fore_color, COLORREF back_color) +{ + work->fore_color = fore_color; + work->back_color = back_color; + InvalidateRect(work->hWnd, NULL, TRUE); +} diff --git a/teraterm/teraterm/color_sample.h b/teraterm/teraterm/color_sample.h new file mode 100644 index 000000000..659a7d84c --- /dev/null +++ b/teraterm/teraterm/color_sample.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2024- TeraTerm Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include + +typedef struct ColorSampleTag ColorSample; + +ColorSample *ColorSampleInit(HWND hWnd); +void ColorSampleSetColor(ColorSample *work, COLORREF fore_color, COLORREF back_color); diff --git a/teraterm/teraterm/win_pp.cpp b/teraterm/teraterm/win_pp.cpp new file mode 100644 index 000000000..b90002a10 --- /dev/null +++ b/teraterm/teraterm/win_pp.cpp @@ -0,0 +1,591 @@ +/* + * Copyright (C) 2024- TeraTerm Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// WinDlg + +#include +#include +#define _CRTDBG_MAP_ALLOC +#include +#include +#include + +#include "tttypes.h" +#include "ttlib.h" +#include "dlglib.h" +#include "dlg_res.h" +#include "tipwin.h" +#include "helpid.h" +#include "asprintf.h" +#include "win32helper.h" +#include "compat_win.h" +#include "asprintf.h" +#include "ttwinman.h" +#include "color_sample.h" + +#include "win_pp.h" + +// ev[g̏s +#define REWRITE_TEMPLATE + +typedef struct { + WORD TmpColor[12][6]; + PTTSet ts; + HFONT SampleFont; + WORD VTFlag; + HWND VTWin; +} WinDlgWork; + +static ColorSample *cs; + +static void DispSample(HWND Dialog, WinDlgWork *work, int IAttr) +{ + COLORREF Text, Back; + Text = RGB(work->TmpColor[IAttr][0], + work->TmpColor[IAttr][1], + work->TmpColor[IAttr][2]); + Back = RGB(work->TmpColor[IAttr][3], + work->TmpColor[IAttr][4], + work->TmpColor[IAttr][5]); + ColorSampleSetColor(cs, Text, Back); +} + +static void ChangeColor(HWND Dialog, WinDlgWork *work, int IAttr, int IOffset) +{ + SetDlgItemInt(Dialog,IDC_WINRED,work->TmpColor[IAttr][IOffset],FALSE); + SetDlgItemInt(Dialog,IDC_WINGREEN,work->TmpColor[IAttr][IOffset+1],FALSE); + SetDlgItemInt(Dialog,IDC_WINBLUE,work->TmpColor[IAttr][IOffset+2],FALSE); + + DispSample(Dialog,work,IAttr); +} + +static void ChangeSB(HWND Dialog, WinDlgWork *work, int IAttr, int IOffset) +{ + HWND HRed, HGreen, HBlue; + + HRed = GetDlgItem(Dialog, IDC_WINREDBAR); + HGreen = GetDlgItem(Dialog, IDC_WINGREENBAR); + HBlue = GetDlgItem(Dialog, IDC_WINBLUEBAR); + + SetScrollPos(HRed,SB_CTL,work->TmpColor[IAttr][IOffset+0],TRUE); + SetScrollPos(HGreen,SB_CTL,work->TmpColor[IAttr][IOffset+1],TRUE); + SetScrollPos(HBlue,SB_CTL,work->TmpColor[IAttr][IOffset+2],TRUE); + ChangeColor(Dialog,work,IAttr,IOffset); +} + +static void RestoreVar(HWND Dialog, WinDlgWork* work, int *IAttr, int *IOffset) +{ + WORD w; + + GetRB(Dialog,&w,IDC_WINTEXT,IDC_WINBACK); + if (w==2) { + *IOffset = 3; + } + else { + *IOffset = 0; + } + if (work->VTFlag>0) { + *IAttr = GetCurSel(Dialog,IDC_WINATTR); + if (*IAttr>0) (*IAttr)--; + } + else { + *IAttr = 0; + } +} + +static INT_PTR CALLBACK WinDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam) +{ + static const DlgTextInfo TextInfos[] = { + { 0, "DLG_WIN_TITLE" }, + { IDC_WINTITLELABEL, "DLG_WIN_TITLELABEL" }, + { IDC_WINCURSOR, "DLG_WIN_CURSOR" }, + { IDC_WINBLOCK, "DLG_WIN_BLOCK" }, + { IDC_WINVERT, "DLG_WIN_VERT" }, + { IDC_WINHORZ, "DLG_WIN_HORZ" }, + { IDC_FONTBOLD, "DLG_WIN_BOLDFONT" }, + { IDC_WINHIDETITLE, "DLG_WIN_HIDETITLE" }, + { IDC_WINHIDEMENU, "DLG_WIN_HIDEMENU" }, + { IDC_WINAIXTERM16, "DLG_WIN_AIXTERM16" }, + { IDC_WINXTERM256, "DLG_WIN_XTERM256" }, + { IDC_WINSCROLL1, "DLG_WIN_SCROLL1" }, + { IDC_WINSCROLL3, "DLG_WIN_SCROLL3" }, + { IDC_WINCOLOR, "DLG_WIN_COLOR" }, + { IDC_WINTEXT, "DLG_WIN_TEXT" }, + { IDC_WINBACK, "DLG_WIN_BG" }, + { IDC_WINATTRTEXT, "DLG_WIN_ATTRIB" }, + { IDC_WINREV, "DLG_WIN_REVERSE" }, + { IDC_WINREDLABEL, "DLG_WIN_R" }, + { IDC_WINGREENLABEL, "DLG_WIN_G" }, + { IDC_WINBLUELABEL, "DLG_WIN_B" }, + { IDC_WINUSENORMALBG, "DLG_WIN_ALWAYSBG" }, + { IDOK, "BTN_OK" }, + { IDCANCEL, "BTN_CANCEL" }, + { IDC_WINHELP, "BTN_HELP" }, + }; + PTTSet ts; + HWND Wnd, HRed, HGreen, HBlue; + int IAttr, IOffset; + WORD i, pos, ScrollCode, NewPos; + WinDlgWork *work = (WinDlgWork *)GetWindowLongPtr(Dialog,DWLP_USER); + + switch (Message) { + case WM_INITDIALOG: + work = (WinDlgWork *)(((PROPSHEETPAGEW *)lParam)->lParam); + SetWindowLongPtr(Dialog, DWLP_USER, (LONG_PTR)work); + ts = work->ts; + + SetDlgTextsW(Dialog, TextInfos, _countof(TextInfos), ts->UILanguageFileW); + { + // VTWinTEKWinŃxقȂĂ + static const DlgTextInfo TextInfosVT[] = { + { IDC_WINCOLOREMU, "DLG_WIN_PCBOLD16" }, + }; + static const DlgTextInfo TextInfosTEK[] = { + { IDC_WINCOLOREMU, "DLG_WIN_COLOREMU" }, + }; + const DlgTextInfo *TextInfosVTTEK = (work->VTFlag>0) ? TextInfosVT : TextInfosTEK; + SetDlgTextsW(Dialog, TextInfosVTTEK, 1, ts->UILanguageFileW); + } + + SetDlgItemTextA(Dialog, IDC_WINTITLE, ts->Title); + SendDlgItemMessage(Dialog, IDC_WINTITLE, EM_LIMITTEXT, + sizeof(ts->Title)-1, 0); + + SetRB(Dialog,ts->HideTitle,IDC_WINHIDETITLE,IDC_WINHIDETITLE); + SetRB(Dialog,ts->EtermLookfeel.BGNoFrame,IDC_NO_FRAME,IDC_NO_FRAME); + SetRB(Dialog,ts->PopupMenu,IDC_WINHIDEMENU,IDC_WINHIDEMENU); + if ( ts->HideTitle>0 ) { + DisableDlgItem(Dialog,IDC_WINHIDEMENU,IDC_WINHIDEMENU); + } else { + DisableDlgItem(Dialog,IDC_NO_FRAME,IDC_NO_FRAME); + } + + if (work->VTFlag>0) { + SetRB(Dialog, (ts->ColorFlag&CF_PCBOLD16)!=0, IDC_WINCOLOREMU, IDC_WINCOLOREMU); + SetRB(Dialog, (ts->ColorFlag&CF_AIXTERM16)!=0, IDC_WINAIXTERM16, IDC_WINAIXTERM16); + SetRB(Dialog, (ts->ColorFlag&CF_XTERM256)!=0,IDC_WINXTERM256,IDC_WINXTERM256); + ShowDlgItem(Dialog,IDC_WINAIXTERM16,IDC_WINXTERM256); + ShowDlgItem(Dialog,IDC_WINSCROLL1,IDC_WINSCROLL3); + SetRB(Dialog,ts->EnableScrollBuff,IDC_WINSCROLL1,IDC_WINSCROLL1); + SetDlgItemInt(Dialog,IDC_WINSCROLL2,ts->ScrollBuffSize,FALSE); + + SendDlgItemMessage(Dialog, IDC_WINSCROLL2, EM_LIMITTEXT, 6, 0); + + if ( ts->EnableScrollBuff==0 ) { + DisableDlgItem(Dialog,IDC_WINSCROLL2,IDC_WINSCROLL3); + } + + for (i = 0 ; i <= 1 ; i++) { + work->TmpColor[0][i*3] = GetRValue(ts->VTColor[i]); + work->TmpColor[0][i*3+1] = GetGValue(ts->VTColor[i]); + work->TmpColor[0][i*3+2] = GetBValue(ts->VTColor[i]); + work->TmpColor[1][i*3] = GetRValue(ts->VTBoldColor[i]); + work->TmpColor[1][i*3+1] = GetGValue(ts->VTBoldColor[i]); + work->TmpColor[1][i*3+2] = GetBValue(ts->VTBoldColor[i]); + work->TmpColor[2][i*3] = GetRValue(ts->VTBlinkColor[i]); + work->TmpColor[2][i*3+1] = GetGValue(ts->VTBlinkColor[i]); + work->TmpColor[2][i*3+2] = GetBValue(ts->VTBlinkColor[i]); + work->TmpColor[3][i*3] = GetRValue(ts->VTReverseColor[i]); + work->TmpColor[3][i*3+1] = GetGValue(ts->VTReverseColor[i]); + work->TmpColor[3][i*3+2] = GetBValue(ts->VTReverseColor[i]); + work->TmpColor[4][i*3] = GetRValue(ts->URLColor[i]); + work->TmpColor[4][i*3+1] = GetGValue(ts->URLColor[i]); + work->TmpColor[4][i*3+2] = GetBValue(ts->URLColor[i]); + work->TmpColor[5][i*3] = GetRValue(ts->VTUnderlineColor[i]); + work->TmpColor[5][i*3+1] = GetGValue(ts->VTUnderlineColor[i]); + work->TmpColor[5][i*3+2] = GetBValue(ts->VTUnderlineColor[i]); + } + ShowDlgItem(Dialog,IDC_WINATTRTEXT,IDC_WINATTR); + { + static const I18nTextInfo infos[] = { + { "DLG_WIN_NORMAL", L"Normal" }, + { "DLG_WIN_BOLD", L"Bold" }, + { "DLG_WIN_BLINK", L"Blink" }, + { "DLG_WIN_REVERSEATTR", L"Reverse" }, + { NULL, L"URL" }, + { NULL, L"Underline" }, + }; + SetI18nListW("Tera Term", Dialog, IDC_WINATTR, infos, _countof(infos), ts->UILanguageFileW, 0); + } + ShowDlgItem(Dialog,IDC_WINUSENORMALBG,IDC_WINUSENORMALBG); + SetRB(Dialog,ts->UseNormalBGColor,IDC_WINUSENORMALBG,IDC_WINUSENORMALBG); + + ShowDlgItem(Dialog, IDC_FONTBOLD, IDC_FONTBOLD); + SetRB(Dialog, (ts->FontFlag & FF_BOLD) > 0, IDC_FONTBOLD,IDC_FONTBOLD); + } + else { + for (i = 0 ; i <=1 ; i++) { + work->TmpColor[0][i*3] = GetRValue(ts->TEKColor[i]); + work->TmpColor[0][i*3+1] = GetGValue(ts->TEKColor[i]); + work->TmpColor[0][i*3+2] = GetBValue(ts->TEKColor[i]); + } + SetRB(Dialog,ts->TEKColorEmu,IDC_WINCOLOREMU,IDC_WINCOLOREMU); + } + SetRB(Dialog,1,IDC_WINTEXT,IDC_WINBACK); + + SetRB(Dialog,ts->CursorShape,IDC_WINBLOCK,IDC_WINHORZ); + + cs = ColorSampleInit(GetDlgItem(Dialog, IDC_DRAW_SAMPLE_AREA)); + + IAttr = 0; + IOffset = 0; + + HRed = GetDlgItem(Dialog, IDC_WINREDBAR); + SetScrollRange(HRed,SB_CTL,0,255,TRUE); + + HGreen = GetDlgItem(Dialog, IDC_WINGREENBAR); + SetScrollRange(HGreen,SB_CTL,0,255,TRUE); + + HBlue = GetDlgItem(Dialog, IDC_WINBLUEBAR); + SetScrollRange(HBlue,SB_CTL,0,255,TRUE); + + ChangeSB(Dialog,work,IAttr,IOffset); + + //CenterWindow(Dialog, GetParent(Dialog)); + + ShowWindow(GetDlgItem(Dialog, IDOK), SW_HIDE); + ShowWindow(GetDlgItem(Dialog, IDCANCEL), SW_HIDE); + ShowWindow(GetDlgItem(Dialog, IDC_WINHELP), SW_HIDE); + + + return TRUE; + + case WM_NOTIFY: + case WM_COMMAND: + ts = work->ts; + RestoreVar(Dialog,work,&IAttr,&IOffset); + assert(IAttr < _countof(work->TmpColor)); + if (Message == WM_NOTIFY) { + NMHDR *nmhdr = (NMHDR *)lParam; + if (nmhdr->code == PSN_APPLY) { + wParam = IDOK; + } + else if (nmhdr->code == PSN_HELP) { + wParam = IDC_WINHELP; + } + else { + break; + } + } + switch (LOWORD(wParam)) { + case IDOK: { + WORD w; + //HDC DC; + GetDlgItemText(Dialog, IDC_WINTITLE, ts->Title, sizeof(ts->Title)); + GetRB(Dialog, &ts->HideTitle, IDC_WINHIDETITLE, IDC_WINHIDETITLE); + GetRB(Dialog, &w, IDC_NO_FRAME, IDC_NO_FRAME); + ts->EtermLookfeel.BGNoFrame = w; + GetRB(Dialog, &ts->PopupMenu, IDC_WINHIDEMENU, IDC_WINHIDEMENU); + // DC = GetDC(Dialog); + if (work->VTFlag > 0) { + GetRB(Dialog, &i, IDC_WINCOLOREMU, IDC_WINCOLOREMU); + if (i != 0) { + ts->ColorFlag |= CF_PCBOLD16; + } + else { + ts->ColorFlag &= ~(WORD)CF_PCBOLD16; + } + GetRB(Dialog, &i, IDC_WINAIXTERM16, IDC_WINAIXTERM16); + if (i != 0) { + ts->ColorFlag |= CF_AIXTERM16; + } + else { + ts->ColorFlag &= ~(WORD)CF_AIXTERM16; + } + GetRB(Dialog, &i, IDC_WINXTERM256, IDC_WINXTERM256); + if (i != 0) { + ts->ColorFlag |= CF_XTERM256; + } + else { + ts->ColorFlag &= ~(WORD)CF_XTERM256; + } + GetRB(Dialog, &ts->EnableScrollBuff, IDC_WINSCROLL1, IDC_WINSCROLL1); + if (ts->EnableScrollBuff > 0) { + ts->ScrollBuffSize = + GetDlgItemInt(Dialog,IDC_WINSCROLL2,NULL,FALSE); + } + for (i = 0; i <= 1; i++) { + ts->VTColor[i] = + RGB(work->TmpColor[0][i*3], + work->TmpColor[0][i*3+1], + work->TmpColor[0][i*3+2]); + ts->VTBoldColor[i] = + RGB(work->TmpColor[1][i*3], + work->TmpColor[1][i*3+1], + work->TmpColor[1][i*3+2]); + ts->VTBlinkColor[i] = + RGB(work->TmpColor[2][i*3], + work->TmpColor[2][i*3+1], + work->TmpColor[2][i*3+2]); + ts->VTReverseColor[i] = + RGB(work->TmpColor[3][i*3], + work->TmpColor[3][i*3+1], + work->TmpColor[3][i*3+2]); + ts->URLColor[i] = + RGB(work->TmpColor[4][i*3], + work->TmpColor[4][i*3+1], + work->TmpColor[4][i*3+2]); + ts->VTUnderlineColor[i] = + RGB(work->TmpColor[5][i * 3], + work->TmpColor[5][i * 3 + 1], + work->TmpColor[5][i * 3 + 2]); +#if 0 + ts->VTColor[i] = GetNearestColor(DC, ts->VTColor[i]); + ts->VTBoldColor[i] = GetNearestColor(DC, ts->VTBoldColor[i]); + ts->VTBlinkColor[i] = GetNearestColor(DC, ts->VTBlinkColor[i]); + ts->VTReverseColor[i] = GetNearestColor(DC, ts->VTReverseColor[i]); + ts->URLColor[i] = GetNearestColor(DC, ts->URLColor[i]); +#endif + } + GetRB(Dialog, &ts->UseNormalBGColor, + IDC_WINUSENORMALBG, IDC_WINUSENORMALBG); + GetRB(Dialog, &i, IDC_FONTBOLD, IDC_FONTBOLD); + if (i > 0) { + ts->FontFlag |= FF_BOLD; + } + else { + ts->FontFlag &= ~(WORD)FF_BOLD; + } + } + else { + for (i = 0; i <= 1; i++) { + ts->TEKColor[i] = + RGB(work->TmpColor[0][i*3], + work->TmpColor[0][i*3+1], + work->TmpColor[0][i*3+2]); +#if 0 + ts->TEKColor[i] = GetNearestColor(DC, ts->TEKColor[i]); +#endif + } + GetRB(Dialog, &ts->TEKColorEmu, IDC_WINCOLOREMU, IDC_WINCOLOREMU); + } + // ReleaseDC(Dialog,DC); + + GetRB(Dialog, &ts->CursorShape, IDC_WINBLOCK, IDC_WINHORZ); + //EndDialog(Dialog, 1); + return TRUE; + } + + case IDCANCEL: + //EndDialog(Dialog, 0); + return TRUE; + + case IDC_WINHIDETITLE: + GetRB(Dialog,&i,IDC_WINHIDETITLE,IDC_WINHIDETITLE); + if (i>0) { + DisableDlgItem(Dialog,IDC_WINHIDEMENU,IDC_WINHIDEMENU); + EnableDlgItem(Dialog,IDC_NO_FRAME,IDC_NO_FRAME); + } + else { + EnableDlgItem(Dialog,IDC_WINHIDEMENU,IDC_WINHIDEMENU); + DisableDlgItem(Dialog,IDC_NO_FRAME,IDC_NO_FRAME); + } + break; + + case IDC_WINSCROLL1: + GetRB(Dialog,&i,IDC_WINSCROLL1,IDC_WINSCROLL1); + if ( i>0 ) { + EnableDlgItem(Dialog,IDC_WINSCROLL2,IDC_WINSCROLL3); + } + else { + DisableDlgItem(Dialog,IDC_WINSCROLL2,IDC_WINSCROLL3); + } + break; + + case IDC_WINTEXT: + IOffset = 0; + ChangeSB(Dialog,work,IAttr,IOffset); + break; + + case IDC_WINBACK: + IOffset = 3; + ChangeSB(Dialog,work,IAttr,IOffset); + break; + + case IDC_WINREV: + i = work->TmpColor[IAttr][0]; + work->TmpColor[IAttr][0] = work->TmpColor[IAttr][3]; + work->TmpColor[IAttr][3] = i; + i = work->TmpColor[IAttr][1]; + work->TmpColor[IAttr][1] = work->TmpColor[IAttr][4]; + work->TmpColor[IAttr][4] = i; + i = work->TmpColor[IAttr][2]; + work->TmpColor[IAttr][2] = work->TmpColor[IAttr][5]; + work->TmpColor[IAttr][5] = i; + + ChangeSB(Dialog,work,IAttr,IOffset); + break; + + case IDC_WINATTR: + ChangeSB(Dialog,work,IAttr,IOffset); + break; + + case IDC_WINHELP: { + const WPARAM HelpId = work->VTFlag > 0 ? HlpSetupWindow : HlpTEKSetupWindow; + PostMessage(work->VTWin, WM_USER_DLGHELP2, HelpId, 0); + break; + } + } + break; + + case WM_HSCROLL: + ts = work->ts; + RestoreVar(Dialog,work,&IAttr,&IOffset); + HRed = GetDlgItem(Dialog, IDC_WINREDBAR); + HGreen = GetDlgItem(Dialog, IDC_WINGREENBAR); + HBlue = GetDlgItem(Dialog, IDC_WINBLUEBAR); + Wnd = (HWND)lParam; + ScrollCode = LOWORD(wParam); + NewPos = HIWORD(wParam); + if ( Wnd == HRed ) { + i = IOffset; + } + else if ( Wnd == HGreen ) { + i = IOffset + 1; + } + else if ( Wnd == HBlue ) { + i = IOffset + 2; + } + else { + return TRUE; + } + pos = work->TmpColor[IAttr][i]; + switch (ScrollCode) { + case SB_BOTTOM: + pos = 255; + break; + case SB_LINEDOWN: + if (pos<255) { + pos++; + } + break; + case SB_LINEUP: + if (pos>0) { + pos--; + } + break; + case SB_PAGEDOWN: + pos += 16; + break; + case SB_PAGEUP: + if (pos < 16) { + pos = 0; + } + else { + pos -= 16; + } + break; + case SB_THUMBPOSITION: + pos = NewPos; + break; + case SB_THUMBTRACK: + pos = NewPos; + break; + case SB_TOP: + pos = 0; + break; + default: + return TRUE; + } + if (pos > 255) { + pos = 255; + } + work->TmpColor[IAttr][i] = pos; + SetScrollPos(Wnd,SB_CTL,pos,TRUE); + ChangeColor(Dialog,work,IAttr,IOffset); + return FALSE; + } + return FALSE; +} + +static UINT CALLBACK CallBack(HWND hwnd, UINT uMsg, struct _PROPSHEETPAGEW *ppsp) +{ + (void)hwnd; + UINT ret_val = 0; + 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 CreateWinPP(HINSTANCE inst, HWND vtwin, TTTSet *pts) +{ + int id; + PROPSHEETPAGEW_V1 psp = { 0 }; + WinDlgWork *data; + wchar_t *uimsg; +// BOOL r; + + id = IDD_WINDLG; + data = (WinDlgWork *)malloc(sizeof(*data)); + data->ts = &ts; + data-> VTWin = vtwin; + + psp.dwSize = sizeof(psp); + psp.dwFlags = PSP_DEFAULT | PSP_USECALLBACK | PSP_USETITLE | PSP_HASHELP; + psp.hInstance = inst; + psp.pfnCallback = CallBack; + GetI18nStrWW("Tera Term", "DLG_WIN_TITLE", L"Tera Term: Terminal win...", pts->UILanguageFileW, &uimsg); + psp.pszTitle = uimsg; + psp.pszTemplate = MAKEINTRESOURCEW(id); +#if defined(REWRITE_TEMPLATE) + psp.dwFlags |= PSP_DLGINDIRECT; + psp.pResource = TTGetDlgTemplate(inst, MAKEINTRESOURCEA(id)); +#endif + psp.pfnDlgProc = WinDlg; + psp.lParam = (LPARAM)data; + + HPROPSHEETPAGE hpsp = CreatePropertySheetPageW((LPCPROPSHEETPAGEW)&psp); + free(uimsg); + return hpsp; +} + +#if 0 +BOOL WINAPI _SetupWin(HWND WndParent, PTTSet ts) +{ + WinDlgWork *work = (WinDlgWork *)calloc(sizeof(*work), 1); + INT_PTR r; + work->ts = ts; + work->SampleFont = ts->SampleFont; + work->VTFlag = ts->VTFlag; + work->VTWin = WndParent; + r = TTDialogBoxParam(hInst, MAKEINTRESOURCE(IDD_WINDLG), WndParent, WinDlg, (LPARAM)work); + free(work); + return (BOOL)r; +} +#endif diff --git a/teraterm/teraterm/win_pp.h b/teraterm/teraterm/win_pp.h new file mode 100644 index 000000000..808a15d78 --- /dev/null +++ b/teraterm/teraterm/win_pp.h @@ -0,0 +1,41 @@ +/* + * (C) 2024- TeraTerm Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +HPROPSHEETPAGE CreateWinPP(HINSTANCE inst, HWND vtwin, TTTSet *pts); + +#ifdef __cplusplus +} +#endif diff --git a/teraterm/ttpdlg/windlg.cpp b/teraterm/ttpdlg/windlg.cpp index 97559d2fc..5bff7ed00 100644 --- a/teraterm/ttpdlg/windlg.cpp +++ b/teraterm/ttpdlg/windlg.cpp @@ -28,513 +28,15 @@ // WinDlg -#include -#include -#define _CRTDBG_MAP_ALLOC -#include -#include -#include - -#include "tttypes.h" -#include "ttlib.h" -#include "dlglib.h" -#include "dlg_res.h" -#include "tipwin.h" -#include "helpid.h" -#include "asprintf.h" -#include "win32helper.h" -#include "compat_win.h" -#include "asprintf.h" -#include "ttwinman.h" +#include +#include "vtwin.h" #include "ttdlg.h" -typedef struct { - WORD TmpColor[12][6]; - PTTSet ts; - HFONT SampleFont; - WORD VTFlag; -} WinDlgWork; - -static void DispSample(HWND Dialog, WinDlgWork *work, int IAttr) -{ - int i,x,y; - COLORREF Text, Back; - int DX[3]; - TEXTMETRIC Metrics; - RECT TestRect; - int FW,FH; - HDC DC; - HWND HWndSample; - - HWndSample = GetDlgItem(Dialog, IDC_DRAW_SAMPLE_AREA); - DC = GetDC(HWndSample); - Text = RGB(work->TmpColor[IAttr][0], - work->TmpColor[IAttr][1], - work->TmpColor[IAttr][2]); - Text = GetNearestColor(DC, Text); - Back = RGB(work->TmpColor[IAttr][3], - work->TmpColor[IAttr][4], - work->TmpColor[IAttr][5]); - Back = GetNearestColor(DC, Back); - SetTextColor(DC, Text); - SetBkColor(DC, Back); - SelectObject(DC,work->SampleFont); - GetTextMetrics(DC, &Metrics); - FW = Metrics.tmAveCharWidth; - FH = Metrics.tmHeight; - for (i = 0 ; i <= 2 ; i++) - DX[i] = FW; - GetClientRect(HWndSample,&TestRect); - x = (int)((TestRect.left+TestRect.right) / 2 - FW * 1.5); - y = (TestRect.top+TestRect.bottom-FH) / 2; - ExtTextOut(DC, x,y, ETO_CLIPPED | ETO_OPAQUE, - &TestRect, "ABC", 3, &(DX[0])); - ReleaseDC(HWndSample,DC); -} - -static void ChangeColor(HWND Dialog, WinDlgWork *work, int IAttr, int IOffset) -{ - SetDlgItemInt(Dialog,IDC_WINRED,work->TmpColor[IAttr][IOffset],FALSE); - SetDlgItemInt(Dialog,IDC_WINGREEN,work->TmpColor[IAttr][IOffset+1],FALSE); - SetDlgItemInt(Dialog,IDC_WINBLUE,work->TmpColor[IAttr][IOffset+2],FALSE); - - DispSample(Dialog,work,IAttr); -} - -static void ChangeSB(HWND Dialog, WinDlgWork *work, int IAttr, int IOffset) -{ - HWND HRed, HGreen, HBlue; - - HRed = GetDlgItem(Dialog, IDC_WINREDBAR); - HGreen = GetDlgItem(Dialog, IDC_WINGREENBAR); - HBlue = GetDlgItem(Dialog, IDC_WINBLUEBAR); - - SetScrollPos(HRed,SB_CTL,work->TmpColor[IAttr][IOffset+0],TRUE); - SetScrollPos(HGreen,SB_CTL,work->TmpColor[IAttr][IOffset+1],TRUE); - SetScrollPos(HBlue,SB_CTL,work->TmpColor[IAttr][IOffset+2],TRUE); - ChangeColor(Dialog,work,IAttr,IOffset); -} - -static void RestoreVar(HWND Dialog, WinDlgWork* work, int *IAttr, int *IOffset) -{ - WORD w; - - GetRB(Dialog,&w,IDC_WINTEXT,IDC_WINBACK); - if (w==2) { - *IOffset = 3; - } - else { - *IOffset = 0; - } - if (work->VTFlag>0) { - *IAttr = GetCurSel(Dialog,IDC_WINATTR); - if (*IAttr>0) (*IAttr)--; - } - else { - *IAttr = 0; - } -} - -static INT_PTR CALLBACK WinDlg(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam) -{ - static const DlgTextInfo TextInfos[] = { - { 0, "DLG_WIN_TITLE" }, - { IDC_WINTITLELABEL, "DLG_WIN_TITLELABEL" }, - { IDC_WINCURSOR, "DLG_WIN_CURSOR" }, - { IDC_WINBLOCK, "DLG_WIN_BLOCK" }, - { IDC_WINVERT, "DLG_WIN_VERT" }, - { IDC_WINHORZ, "DLG_WIN_HORZ" }, - { IDC_FONTBOLD, "DLG_WIN_BOLDFONT" }, - { IDC_WINHIDETITLE, "DLG_WIN_HIDETITLE" }, - { IDC_WINHIDEMENU, "DLG_WIN_HIDEMENU" }, - { IDC_WINAIXTERM16, "DLG_WIN_AIXTERM16" }, - { IDC_WINXTERM256, "DLG_WIN_XTERM256" }, - { IDC_WINSCROLL1, "DLG_WIN_SCROLL1" }, - { IDC_WINSCROLL3, "DLG_WIN_SCROLL3" }, - { IDC_WINCOLOR, "DLG_WIN_COLOR" }, - { IDC_WINTEXT, "DLG_WIN_TEXT" }, - { IDC_WINBACK, "DLG_WIN_BG" }, - { IDC_WINATTRTEXT, "DLG_WIN_ATTRIB" }, - { IDC_WINREV, "DLG_WIN_REVERSE" }, - { IDC_WINREDLABEL, "DLG_WIN_R" }, - { IDC_WINGREENLABEL, "DLG_WIN_G" }, - { IDC_WINBLUELABEL, "DLG_WIN_B" }, - { IDC_WINUSENORMALBG, "DLG_WIN_ALWAYSBG" }, - { IDOK, "BTN_OK" }, - { IDCANCEL, "BTN_CANCEL" }, - { IDC_WINHELP, "BTN_HELP" }, - }; - PTTSet ts; - HWND Wnd, HRed, HGreen, HBlue; - int IAttr, IOffset; - WORD i, pos, ScrollCode, NewPos; - WinDlgWork *work = (WinDlgWork *)GetWindowLongPtr(Dialog,DWLP_USER); - - switch (Message) { - case WM_INITDIALOG: - work = (WinDlgWork *)lParam;; - SetWindowLongPtr(Dialog, DWLP_USER, lParam); - ts = work->ts; - - SetDlgTextsW(Dialog, TextInfos, _countof(TextInfos), ts->UILanguageFileW); - { - // VTWinTEKWinŃxقȂĂ - static const DlgTextInfo TextInfosVT[] = { - { IDC_WINCOLOREMU, "DLG_WIN_PCBOLD16" }, - }; - static const DlgTextInfo TextInfosTEK[] = { - { IDC_WINCOLOREMU, "DLG_WIN_COLOREMU" }, - }; - const DlgTextInfo *TextInfosVTTEK = (work->VTFlag>0) ? TextInfosVT : TextInfosTEK; - SetDlgTextsW(Dialog, TextInfosVTTEK, 1, ts->UILanguageFileW); - } - - SetDlgItemTextA(Dialog, IDC_WINTITLE, ts->Title); - SendDlgItemMessage(Dialog, IDC_WINTITLE, EM_LIMITTEXT, - sizeof(ts->Title)-1, 0); - - SetRB(Dialog,ts->HideTitle,IDC_WINHIDETITLE,IDC_WINHIDETITLE); - SetRB(Dialog,ts->EtermLookfeel.BGNoFrame,IDC_NO_FRAME,IDC_NO_FRAME); - SetRB(Dialog,ts->PopupMenu,IDC_WINHIDEMENU,IDC_WINHIDEMENU); - if ( ts->HideTitle>0 ) { - DisableDlgItem(Dialog,IDC_WINHIDEMENU,IDC_WINHIDEMENU); - } else { - DisableDlgItem(Dialog,IDC_NO_FRAME,IDC_NO_FRAME); - } - - if (work->VTFlag>0) { - SetRB(Dialog, (ts->ColorFlag&CF_PCBOLD16)!=0, IDC_WINCOLOREMU, IDC_WINCOLOREMU); - SetRB(Dialog, (ts->ColorFlag&CF_AIXTERM16)!=0, IDC_WINAIXTERM16, IDC_WINAIXTERM16); - SetRB(Dialog, (ts->ColorFlag&CF_XTERM256)!=0,IDC_WINXTERM256,IDC_WINXTERM256); - ShowDlgItem(Dialog,IDC_WINAIXTERM16,IDC_WINXTERM256); - ShowDlgItem(Dialog,IDC_WINSCROLL1,IDC_WINSCROLL3); - SetRB(Dialog,ts->EnableScrollBuff,IDC_WINSCROLL1,IDC_WINSCROLL1); - SetDlgItemInt(Dialog,IDC_WINSCROLL2,ts->ScrollBuffSize,FALSE); - - SendDlgItemMessage(Dialog, IDC_WINSCROLL2, EM_LIMITTEXT, 6, 0); - - if ( ts->EnableScrollBuff==0 ) { - DisableDlgItem(Dialog,IDC_WINSCROLL2,IDC_WINSCROLL3); - } - - for (i = 0 ; i <= 1 ; i++) { - work->TmpColor[0][i*3] = GetRValue(ts->VTColor[i]); - work->TmpColor[0][i*3+1] = GetGValue(ts->VTColor[i]); - work->TmpColor[0][i*3+2] = GetBValue(ts->VTColor[i]); - work->TmpColor[1][i*3] = GetRValue(ts->VTBoldColor[i]); - work->TmpColor[1][i*3+1] = GetGValue(ts->VTBoldColor[i]); - work->TmpColor[1][i*3+2] = GetBValue(ts->VTBoldColor[i]); - work->TmpColor[2][i*3] = GetRValue(ts->VTBlinkColor[i]); - work->TmpColor[2][i*3+1] = GetGValue(ts->VTBlinkColor[i]); - work->TmpColor[2][i*3+2] = GetBValue(ts->VTBlinkColor[i]); - work->TmpColor[3][i*3] = GetRValue(ts->VTReverseColor[i]); - work->TmpColor[3][i*3+1] = GetGValue(ts->VTReverseColor[i]); - work->TmpColor[3][i*3+2] = GetBValue(ts->VTReverseColor[i]); - work->TmpColor[4][i*3] = GetRValue(ts->URLColor[i]); - work->TmpColor[4][i*3+1] = GetGValue(ts->URLColor[i]); - work->TmpColor[4][i*3+2] = GetBValue(ts->URLColor[i]); - work->TmpColor[5][i*3] = GetRValue(ts->VTUnderlineColor[i]); - work->TmpColor[5][i*3+1] = GetGValue(ts->VTUnderlineColor[i]); - work->TmpColor[5][i*3+2] = GetBValue(ts->VTUnderlineColor[i]); - } - ShowDlgItem(Dialog,IDC_WINATTRTEXT,IDC_WINATTR); - { - static const I18nTextInfo infos[] = { - { "DLG_WIN_NORMAL", L"Normal" }, - { "DLG_WIN_BOLD", L"Bold" }, - { "DLG_WIN_BLINK", L"Blink" }, - { "DLG_WIN_REVERSEATTR", L"Reverse" }, - { NULL, L"URL" }, - { NULL, L"Underline" }, - }; - SetI18nListW("Tera Term", Dialog, IDC_WINATTR, infos, _countof(infos), ts->UILanguageFileW, 0); - } - ShowDlgItem(Dialog,IDC_WINUSENORMALBG,IDC_WINUSENORMALBG); - SetRB(Dialog,ts->UseNormalBGColor,IDC_WINUSENORMALBG,IDC_WINUSENORMALBG); - - ShowDlgItem(Dialog, IDC_FONTBOLD, IDC_FONTBOLD); - SetRB(Dialog, (ts->FontFlag & FF_BOLD) > 0, IDC_FONTBOLD,IDC_FONTBOLD); - } - else { - for (i = 0 ; i <=1 ; i++) { - work->TmpColor[0][i*3] = GetRValue(ts->TEKColor[i]); - work->TmpColor[0][i*3+1] = GetGValue(ts->TEKColor[i]); - work->TmpColor[0][i*3+2] = GetBValue(ts->TEKColor[i]); - } - SetRB(Dialog,ts->TEKColorEmu,IDC_WINCOLOREMU,IDC_WINCOLOREMU); - } - SetRB(Dialog,1,IDC_WINTEXT,IDC_WINBACK); - - SetRB(Dialog,ts->CursorShape,IDC_WINBLOCK,IDC_WINHORZ); - - IAttr = 0; - IOffset = 0; - - HRed = GetDlgItem(Dialog, IDC_WINREDBAR); - SetScrollRange(HRed,SB_CTL,0,255,TRUE); - - HGreen = GetDlgItem(Dialog, IDC_WINGREENBAR); - SetScrollRange(HGreen,SB_CTL,0,255,TRUE); - - HBlue = GetDlgItem(Dialog, IDC_WINBLUEBAR); - SetScrollRange(HBlue,SB_CTL,0,255,TRUE); - - ChangeSB(Dialog,work,IAttr,IOffset); - - CenterWindow(Dialog, GetParent(Dialog)); - - return TRUE; - - case WM_COMMAND: - ts = work->ts; - RestoreVar(Dialog,work,&IAttr,&IOffset); - assert(IAttr < _countof(work->TmpColor)); - switch (LOWORD(wParam)) { - case IDOK: { - WORD w; - //HDC DC; - GetDlgItemText(Dialog, IDC_WINTITLE, ts->Title, sizeof(ts->Title)); - GetRB(Dialog, &ts->HideTitle, IDC_WINHIDETITLE, IDC_WINHIDETITLE); - GetRB(Dialog, &w, IDC_NO_FRAME, IDC_NO_FRAME); - ts->EtermLookfeel.BGNoFrame = w; - GetRB(Dialog, &ts->PopupMenu, IDC_WINHIDEMENU, IDC_WINHIDEMENU); - // DC = GetDC(Dialog); - if (work->VTFlag > 0) { - GetRB(Dialog, &i, IDC_WINCOLOREMU, IDC_WINCOLOREMU); - if (i != 0) { - ts->ColorFlag |= CF_PCBOLD16; - } - else { - ts->ColorFlag &= ~(WORD)CF_PCBOLD16; - } - GetRB(Dialog, &i, IDC_WINAIXTERM16, IDC_WINAIXTERM16); - if (i != 0) { - ts->ColorFlag |= CF_AIXTERM16; - } - else { - ts->ColorFlag &= ~(WORD)CF_AIXTERM16; - } - GetRB(Dialog, &i, IDC_WINXTERM256, IDC_WINXTERM256); - if (i != 0) { - ts->ColorFlag |= CF_XTERM256; - } - else { - ts->ColorFlag &= ~(WORD)CF_XTERM256; - } - GetRB(Dialog, &ts->EnableScrollBuff, IDC_WINSCROLL1, IDC_WINSCROLL1); - if (ts->EnableScrollBuff > 0) { - ts->ScrollBuffSize = - GetDlgItemInt(Dialog,IDC_WINSCROLL2,NULL,FALSE); - } - for (i = 0; i <= 1; i++) { - ts->VTColor[i] = - RGB(work->TmpColor[0][i*3], - work->TmpColor[0][i*3+1], - work->TmpColor[0][i*3+2]); - ts->VTBoldColor[i] = - RGB(work->TmpColor[1][i*3], - work->TmpColor[1][i*3+1], - work->TmpColor[1][i*3+2]); - ts->VTBlinkColor[i] = - RGB(work->TmpColor[2][i*3], - work->TmpColor[2][i*3+1], - work->TmpColor[2][i*3+2]); - ts->VTReverseColor[i] = - RGB(work->TmpColor[3][i*3], - work->TmpColor[3][i*3+1], - work->TmpColor[3][i*3+2]); - ts->URLColor[i] = - RGB(work->TmpColor[4][i*3], - work->TmpColor[4][i*3+1], - work->TmpColor[4][i*3+2]); - ts->VTUnderlineColor[i] = - RGB(work->TmpColor[5][i * 3], - work->TmpColor[5][i * 3 + 1], - work->TmpColor[5][i * 3 + 2]); -#if 0 - ts->VTColor[i] = GetNearestColor(DC, ts->VTColor[i]); - ts->VTBoldColor[i] = GetNearestColor(DC, ts->VTBoldColor[i]); - ts->VTBlinkColor[i] = GetNearestColor(DC, ts->VTBlinkColor[i]); - ts->VTReverseColor[i] = GetNearestColor(DC, ts->VTReverseColor[i]); - ts->URLColor[i] = GetNearestColor(DC, ts->URLColor[i]); -#endif - } - GetRB(Dialog, &ts->UseNormalBGColor, - IDC_WINUSENORMALBG, IDC_WINUSENORMALBG); - GetRB(Dialog, &i, IDC_FONTBOLD, IDC_FONTBOLD); - if (i > 0) { - ts->FontFlag |= FF_BOLD; - } - else { - ts->FontFlag &= ~(WORD)FF_BOLD; - } - } - else { - for (i = 0; i <= 1; i++) { - ts->TEKColor[i] = - RGB(work->TmpColor[0][i*3], - work->TmpColor[0][i*3+1], - work->TmpColor[0][i*3+2]); -#if 0 - ts->TEKColor[i] = GetNearestColor(DC, ts->TEKColor[i]); -#endif - } - GetRB(Dialog, &ts->TEKColorEmu, IDC_WINCOLOREMU, IDC_WINCOLOREMU); - } - // ReleaseDC(Dialog,DC); - - GetRB(Dialog, &ts->CursorShape, IDC_WINBLOCK, IDC_WINHORZ); - EndDialog(Dialog, 1); - return TRUE; - } - - case IDCANCEL: - EndDialog(Dialog, 0); - return TRUE; - - case IDC_WINHIDETITLE: - GetRB(Dialog,&i,IDC_WINHIDETITLE,IDC_WINHIDETITLE); - if (i>0) { - DisableDlgItem(Dialog,IDC_WINHIDEMENU,IDC_WINHIDEMENU); - EnableDlgItem(Dialog,IDC_NO_FRAME,IDC_NO_FRAME); - } - else { - EnableDlgItem(Dialog,IDC_WINHIDEMENU,IDC_WINHIDEMENU); - DisableDlgItem(Dialog,IDC_NO_FRAME,IDC_NO_FRAME); - } - break; - - case IDC_WINSCROLL1: - GetRB(Dialog,&i,IDC_WINSCROLL1,IDC_WINSCROLL1); - if ( i>0 ) { - EnableDlgItem(Dialog,IDC_WINSCROLL2,IDC_WINSCROLL3); - } - else { - DisableDlgItem(Dialog,IDC_WINSCROLL2,IDC_WINSCROLL3); - } - break; - - case IDC_WINTEXT: - IOffset = 0; - ChangeSB(Dialog,work,IAttr,IOffset); - break; - - case IDC_WINBACK: - IOffset = 3; - ChangeSB(Dialog,work,IAttr,IOffset); - break; - - case IDC_WINREV: - i = work->TmpColor[IAttr][0]; - work->TmpColor[IAttr][0] = work->TmpColor[IAttr][3]; - work->TmpColor[IAttr][3] = i; - i = work->TmpColor[IAttr][1]; - work->TmpColor[IAttr][1] = work->TmpColor[IAttr][4]; - work->TmpColor[IAttr][4] = i; - i = work->TmpColor[IAttr][2]; - work->TmpColor[IAttr][2] = work->TmpColor[IAttr][5]; - work->TmpColor[IAttr][5] = i; - - ChangeSB(Dialog,work,IAttr,IOffset); - break; - - case IDC_WINATTR: - ChangeSB(Dialog,work,IAttr,IOffset); - break; - - case IDC_WINHELP: { - const WPARAM HelpId = work->VTFlag > 0 ? HlpSetupWindow : HlpTEKSetupWindow; - PostMessage(GetParent(Dialog),WM_USER_DLGHELP2,HelpId,0); - break; - } - } - break; - - case WM_PAINT: - ts = work->ts; - RestoreVar(Dialog,work,&IAttr,&IOffset); - DispSample(Dialog,work,IAttr); - break; - - case WM_HSCROLL: - ts = work->ts; - RestoreVar(Dialog,work,&IAttr,&IOffset); - HRed = GetDlgItem(Dialog, IDC_WINREDBAR); - HGreen = GetDlgItem(Dialog, IDC_WINGREENBAR); - HBlue = GetDlgItem(Dialog, IDC_WINBLUEBAR); - Wnd = (HWND)lParam; - ScrollCode = LOWORD(wParam); - NewPos = HIWORD(wParam); - if ( Wnd == HRed ) { - i = IOffset; - } - else if ( Wnd == HGreen ) { - i = IOffset + 1; - } - else if ( Wnd == HBlue ) { - i = IOffset + 2; - } - else { - return TRUE; - } - pos = work->TmpColor[IAttr][i]; - switch (ScrollCode) { - case SB_BOTTOM: - pos = 255; - break; - case SB_LINEDOWN: - if (pos<255) { - pos++; - } - break; - case SB_LINEUP: - if (pos>0) { - pos--; - } - break; - case SB_PAGEDOWN: - pos += 16; - break; - case SB_PAGEUP: - if (pos < 16) { - pos = 0; - } - else { - pos -= 16; - } - break; - case SB_THUMBPOSITION: - pos = NewPos; - break; - case SB_THUMBTRACK: - pos = NewPos; - break; - case SB_TOP: - pos = 0; - break; - default: - return TRUE; - } - if (pos > 255) { - pos = 255; - } - work->TmpColor[IAttr][i] = pos; - SetScrollPos(Wnd,SB_CTL,pos,TRUE); - ChangeColor(Dialog,work,IAttr,IOffset); - return FALSE; - } - return FALSE; -} - BOOL WINAPI _SetupWin(HWND WndParent, PTTSet ts) { - WinDlgWork *work = (WinDlgWork *)calloc(1, sizeof(*work)); - INT_PTR r; - work->ts = ts; - work->SampleFont = ts->SampleFont; - work->VTFlag = ts->VTFlag; - r = TTDialogBoxParam(hInst, MAKEINTRESOURCE(IDD_WINDLG), WndParent, WinDlg, (LPARAM)work); - free(work); - return (BOOL)r; + (void)WndParent; + (void)ts; + OpenExternalSetupOutside(WinPage); + return FALSE; }