From eb245d73cd8ffc3fca1c85e646e22b732e9c4561 Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Sat, 25 Mar 2023 06:52:50 +0900 Subject: [PATCH] improve patterns dialog --- GUI.hpp | 6 ++++ HISTORY.txt | 6 ++-- XG_PatternDialog.hpp | 67 +++++++++++++++++++++++++++++++------------- lang/en_US.rc | 6 ++-- lang/ja_JP.rc | 6 ++-- 5 files changed, 64 insertions(+), 27 deletions(-) diff --git a/GUI.hpp b/GUI.hpp index e729b6a..2a0f344 100644 --- a/GUI.hpp +++ b/GUI.hpp @@ -1,5 +1,11 @@ #pragma once +#ifdef _MSC_VER + #define XG_NOINLINE __declspec(noinline) +#else + #define XG_NOINLINE __attribute__((noinline)) +#endif + // ヒントウィンドウを作成する。 BOOL XgCreateHintsWnd(HWND hwnd); // ヒントウィンドウを破棄する。 diff --git a/HISTORY.txt b/HISTORY.txt index aa2906d..c0bf19a 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -205,10 +205,11 @@ - Improved "Marking" dialog. - Correctly undoing "setting a double-frame word". - Added labels to THEME.txt. -- 20XX-YY-ZZ ver.5.0.3 +- 2023-03-25 ver.5.0.3 - Made the maximum size of the block patterns 20x20. - Improved block patterns (PAT.txt). - Global optimization that focuses on the fact that there are fewer candidates for longer words. + - Improved block patterns dialog. # 開発履歴 (Japanese) @@ -729,7 +730,8 @@ - 「二重マス単語の候補と配置」ダイアログを改良。 - 二重マス単語を正しく「元に戻す」。 - THEME.txtの各項目にラベルを追加。 -- 20XX年YY月ZZ日 ver.5.0.3 +- 2023年03月25日 ver.5.0.3 - 黒マスパターンの最大サイズを20x20に。 - 黒マスパターン(PAT.txt)を改良。 - 長い単語には候補が少ないことに着目した大局的な最適化。 + - 黒マスパターンダイアログの改良。 diff --git a/XG_PatternDialog.hpp b/XG_PatternDialog.hpp index aa35d6c..94e8d9d 100644 --- a/XG_PatternDialog.hpp +++ b/XG_PatternDialog.hpp @@ -35,34 +35,32 @@ class XG_PatternDialog : public XG_Dialog } // タイプによりフィルターを行う。 - BOOL FilterPatBySize(const XG_PATDATA& pat, INT type) { + XG_NOINLINE + BOOL FilterPatBySize(const XG_PATDATA& pat, INT type0, INT type1) { if (pat.num_columns > XG_MAX_PAT_SIZE || pat.num_rows > XG_MAX_PAT_SIZE) return FALSE; - switch (type) { - case -1: - break; + switch (type0) { case rad1: - if (pat.num_columns != pat.num_rows) - return FALSE; - if (!(pat.num_columns >= 13 && pat.num_rows >= 13)) + if (!(pat.num_columns + pat.num_rows >= 28)) return FALSE; break; case rad2: - if (pat.num_columns != pat.num_rows) - return FALSE; - if (!(8 <= pat.num_columns && pat.num_columns <= 12 && - 8 <= pat.num_rows && pat.num_rows <= 12)) + if (!(pat.num_columns + pat.num_rows < 28 && + pat.num_columns + pat.num_rows > 16)) { return FALSE; } break; case rad3: - if (pat.num_columns != pat.num_rows) - return FALSE; - if (!(pat.num_columns <= 8 && pat.num_rows <= 8)) + if (!(pat.num_columns + pat.num_rows <= 16)) return FALSE; break; + default: + assert(0); + } + + switch (type1) { case rad4: if (pat.num_columns <= pat.num_rows) return FALSE; @@ -82,7 +80,8 @@ class XG_PatternDialog : public XG_Dialog return TRUE; } - BOOL RefreshContents(HWND hwnd, INT type) + XG_NOINLINE + BOOL RefreshContents(HWND hwnd, INT type0, INT type1) { // リストボックスをクリアする。 ListBox_ResetContent(GetDlgItem(hwnd, lst1)); @@ -121,7 +120,7 @@ class XG_PatternDialog : public XG_Dialog continue; } - if (FilterPatBySize(pat, type)) + if (FilterPatBySize(pat, type0, type1)) { pats.push_back(pat); } @@ -141,6 +140,7 @@ class XG_PatternDialog : public XG_Dialog } // WM_INITDIALOG + XG_NOINLINE BOOL OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) { XgCenterDialog(hwnd); @@ -156,8 +156,9 @@ class XG_PatternDialog : public XG_Dialog else CheckDlgButton(hwnd, chx1, BST_UNCHECKED); - CheckRadioButton(hwnd, rad1, rad6, rad6); - RefreshContents(hwnd, rad6); + CheckRadioButton(hwnd, rad1, rad3, rad2); + CheckRadioButton(hwnd, rad4, rad6, rad6); + RefreshContents(hwnd, rad2, rad6); static const LAYOUT_INFO layouts[] = { @@ -198,6 +199,7 @@ class XG_PatternDialog : public XG_Dialog } // 黒マスパターンのコピー。 + XG_NOINLINE void OnCopy(HWND hwnd) { HWND hLst1 = GetDlgItem(hwnd, lst1); @@ -227,6 +229,7 @@ class XG_PatternDialog : public XG_Dialog } // 黒マスパターンで「OK」ボタンを押した。 + XG_NOINLINE void OnOK(HWND hwnd) { HWND hLst1 = GetDlgItem(hwnd, lst1); @@ -286,7 +289,30 @@ class XG_PatternDialog : public XG_Dialog ShellExecuteW(hwnd, NULL, L"https://katahiromz.web.fc2.com/xword/patterns", NULL, NULL, SW_SHOWNORMAL); } + INT GetType0() + { + if (IsDlgButtonChecked(m_hWnd, rad1) == BST_CHECKED) + return rad1; + if (IsDlgButtonChecked(m_hWnd, rad2) == BST_CHECKED) + return rad2; + if (IsDlgButtonChecked(m_hWnd, rad3) == BST_CHECKED) + return rad3; + return -1; + } + + INT GetType1() + { + if (IsDlgButtonChecked(m_hWnd, rad4) == BST_CHECKED) + return rad4; + if (IsDlgButtonChecked(m_hWnd, rad5) == BST_CHECKED) + return rad5; + if (IsDlgButtonChecked(m_hWnd, rad6) == BST_CHECKED) + return rad6; + return -1; + } + // WM_COMMAND + XG_NOINLINE void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) { switch (id) @@ -315,7 +341,7 @@ class XG_PatternDialog : public XG_Dialog case rad4: case rad5: case rad6: - RefreshContents(hwnd, id); + RefreshContents(hwnd, GetType0(), GetType1()); break; } } @@ -323,6 +349,7 @@ class XG_PatternDialog : public XG_Dialog const INT cxCell = 5, cyCell = 5; // 小さなセルのサイズ。 // WM_MEASUREITEM + XG_NOINLINE void OnMeasureItem(HWND hwnd, MEASUREITEMSTRUCT * lpMeasureItem) { // リストボックスの lst1 か? @@ -339,6 +366,7 @@ class XG_PatternDialog : public XG_Dialog } // WM_DRAWITEM + XG_NOINLINE void OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT * lpDrawItem) { // リストボックスの lst1 か? @@ -492,6 +520,7 @@ class XG_PatternDialog : public XG_Dialog } // 「黒マスパターン」ダイアログプロシージャ。 + XG_NOINLINE virtual INT_PTR CALLBACK DialogProcDx(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { diff --git a/lang/en_US.rc b/lang/en_US.rc index be19fcf..0b71962 100644 --- a/lang/en_US.rc +++ b/lang/en_US.rc @@ -1306,12 +1306,12 @@ STYLE DS_CENTER | DS_MODALFRAME | WS_POPUPWINDOW | WS_CAPTION | WS_THICKFRAME | FONT 9, "Tahoma" { LTEXT "Please select a pattern from the list below.", stc1, 5, 2, 220, 12 - AUTORADIOBUTTON "&Large", rad1, 5, 15, 45, 16, WS_TABSTOP + AUTORADIOBUTTON "&Large", rad1, 5, 15, 45, 16, WS_TABSTOP | WS_GROUP AUTORADIOBUTTON "&Medium", rad2, 55, 15, 50, 16, WS_TABSTOP AUTORADIOBUTTON "&Small", rad3, 110, 15, 50, 16, WS_TABSTOP - AUTORADIOBUTTON "L&andscape", rad4, 175, 15, 48, 16, WS_TABSTOP + AUTORADIOBUTTON "L&andscape", rad4, 175, 15, 48, 16, WS_TABSTOP | WS_GROUP AUTORADIOBUTTON "&Portrait", rad5, 227, 15, 43, 16, WS_TABSTOP - AUTORADIOBUTTON "&N/A", rad6, 275, 15, 55, 16, WS_TABSTOP + AUTORADIOBUTTON "S&quare", rad6, 275, 15, 55, 16, WS_TABSTOP LTEXT "Lis&t:", stc2, 8, 37, 47, 12 LISTBOX lst1, 5, 50, 325, 190, LBS_DISABLENOSCROLL | LBS_MULTICOLUMN | LBS_NOINTEGRALHEIGHT | LBS_OWNERDRAWFIXED | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP PUSHBUTTON "&Copy", psh1, 5, 245, 60, 15 diff --git a/lang/ja_JP.rc b/lang/ja_JP.rc index 588f5ef..58d4366 100644 --- a/lang/ja_JP.rc +++ b/lang/ja_JP.rc @@ -1309,12 +1309,12 @@ STYLE DS_CENTER | DS_MODALFRAME | WS_POPUPWINDOW | WS_CAPTION | WS_THICKFRAME | FONT 9, "MS UI Gothic" { LTEXT "下のリストから黒マスパターンをお選び下さい。", stc1, 5, 2, 220, 12 - AUTORADIOBUTTON "大(&Large)", rad1, 5, 15, 45, 16, WS_TABSTOP + AUTORADIOBUTTON "大(&Large)", rad1, 5, 15, 45, 16, WS_TABSTOP | WS_GROUP AUTORADIOBUTTON "中(&Medium)", rad2, 55, 15, 50, 16, WS_TABSTOP AUTORADIOBUTTON "小(&Small)", rad3, 110, 15, 50, 16, WS_TABSTOP - AUTORADIOBUTTON "横長(&H)", rad4, 175, 15, 40, 16, WS_TABSTOP + AUTORADIOBUTTON "横長(&H)", rad4, 175, 15, 40, 16, WS_TABSTOP | WS_GROUP AUTORADIOBUTTON "縦長(&V)", rad5, 220, 15, 40, 16, WS_TABSTOP - AUTORADIOBUTTON "指定なし(&N)", rad6, 275, 15, 55, 16, WS_TABSTOP + AUTORADIOBUTTON "正方形(&Q)", rad6, 275, 15, 55, 16, WS_TABSTOP LTEXT "リスト(&T):", stc2, 8, 37, 47, 12 LISTBOX lst1, 5, 50, 325, 190, LBS_DISABLENOSCROLL | LBS_MULTICOLUMN | LBS_NOINTEGRALHEIGHT | LBS_OWNERDRAWFIXED | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP PUSHBUTTON "コピー(&C)", psh1, 5, 245, 60, 15