Skip to content

Commit

Permalink
5.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
katahiromz committed May 23, 2023
1 parent eb245d7 commit d609c26
Show file tree
Hide file tree
Showing 12 changed files with 439 additions and 282 deletions.
30 changes: 23 additions & 7 deletions GUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,7 @@ bool __fastcall XgLoadSettings(void)
xg_nRules = XG_DEFAULT_RULES;
xg_nViewMode = XG_VIEW_NORMAL;
xg_nFileType = XG_FILETYPE_XD;
xg_nLineWidthInPt = XG_LINE_WIDTH_DEFAULT;

xg_nMarkingX = xg_nMarkingY = CW_USEDEFAULT;

Expand Down Expand Up @@ -1144,6 +1145,14 @@ bool __fastcall XgLoadSettings(void)
xg_nViewMode = XG_VIEW_NORMAL;
}
}
if (!app_key.QueryDword(L"LineWidth", dwValue)) {
float value = dwValue * 0.01;
if (value < XG_MIN_LINEWIDTH)
value = XG_MIN_LINEWIDTH;
if (value > XG_MAX_LINEWIDTH)
value = XG_MAX_LINEWIDTH;
xg_nLineWidthInPt = value;
}

if (!app_key.QuerySz(L"Recent", sz, ARRAYSIZE(sz))) {
xg_dict_name = sz;
Expand Down Expand Up @@ -1256,6 +1265,7 @@ bool __fastcall XgSaveSettings(void)

app_key.SetDword(L"ShowDoubleFrameLetters", xg_bShowDoubleFrameLetters);
app_key.SetDword(L"ViewMode", xg_nViewMode);
app_key.SetDword(L"LineWidth", INT(xg_nLineWidthInPt * 100));

app_key.SetSz(L"Recent", xg_dict_name.c_str());

Expand Down Expand Up @@ -1792,16 +1802,19 @@ static void XgPrintIt(HDC hdc, PRINTDLGW* ppd, bool bPrintAnswer)
::DeleteFont(hFont);
}

// サイズを取得する。
SIZE siz;
XgGetXWordExtent(&siz);

// EMFオブジェクトを作成する。
HDC hdcEMF = ::CreateEnhMetaFileW(hdc, nullptr, nullptr, XgLoadStringDx1(IDS_APPNAME));
if (hdcEMF != nullptr) {
// EMFオブジェクトにクロスワードを描画する。
SIZE siz;
XgGetXWordExtent(&siz);
XgSetSizeOfEMF(hdcEMF, &siz);
if (bPrintAnswer)
XgDrawXWord(xg_solution, hdcEMF, &siz, false);
XgDrawXWord(xg_solution, hdcEMF, &siz, DRAW_MODE_EMF);
else
XgDrawXWord(xg_xword, hdcEMF, &siz, false);
XgDrawXWord(xg_xword, hdcEMF, &siz, DRAW_MODE_EMF);

// EMFオブジェクトを閉じる。
HENHMETAFILE hEMF = ::CloseEnhMetaFile(hdcEMF);
Expand Down Expand Up @@ -3564,7 +3577,8 @@ void XgCopyBoard(HWND hwnd)
HDC hdc = ::CreateEnhMetaFileW(hdcRef, nullptr, nullptr, XgLoadStringDx1(IDS_APPNAME));
if (hdc) {
// EMFに描画する。
XgDrawXWord(*pxw, hdc, &siz, false);
XgSetSizeOfEMF(hdc, &siz);
XgDrawXWord(*pxw, hdc, &siz, DRAW_MODE_PRINT);

// EMFを設定。
HENHMETAFILE hEMF = ::CloseEnhMetaFile(hdc);
Expand All @@ -3578,7 +3592,7 @@ void XgCopyBoard(HWND hwnd)
RECT rc;
SetRect(&rc, 0, 0, siz.cx, siz.cy);
FillRect(hDC, &rc, GetStockBrush(WHITE_BRUSH));
XgDrawXWord(*pxw, hDC, &siz, false);
XgDrawXWord(*pxw, hDC, &siz, DRAW_MODE_PRINT);
SelectObject(hDC, hbmOld);
::DeleteDC(hDC);

Expand Down Expand Up @@ -3621,7 +3635,8 @@ void XgCopyBoardAsImage(HWND hwnd)
HDC hdc = ::CreateEnhMetaFileW(hdcRef, nullptr, nullptr, XgLoadStringDx1(IDS_APPNAME));
if (hdc) {
// EMFに描画する。
XgDrawXWord(*pxw, hdc, &siz, false);
XgSetSizeOfEMF(hdc, &siz);
XgDrawXWord(*pxw, hdc, &siz, DRAW_MODE_PRINT);
hEMF = ::CloseEnhMetaFile(hdc);
}

Expand Down Expand Up @@ -3704,6 +3719,7 @@ void __fastcall XgCopyMarkWord(HWND hwnd)
HDC hdc = ::CreateEnhMetaFileW(hdcRef, nullptr, nullptr, XgLoadStringDx1(IDS_APPNAME));
if (hdc) {
// EMFに描画する。
XgSetSizeOfEMF(hdc, &siz);
XgDrawMarkWord(hdc, &siz);
hEMF = ::CloseEnhMetaFile(hdc);
}
Expand Down
10 changes: 10 additions & 0 deletions HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@
- Improved block patterns (PAT.txt).
- Global optimization that focuses on the fact that there are fewer candidates for longer words.
- Improved block patterns dialog.
- 2023-05-23 ver.5.0.4
- Allowed line widths to be specified. Default line width to 1.0.
- Properly calculating the width of the line.
- Improved drawing of the board.
- Avoided EMF drawing defects for external softwares with incomplete EMF support.

# 開発履歴 (Japanese)

Expand Down Expand Up @@ -735,3 +740,8 @@
- 黒マスパターン(PAT.txt)を改良。
- 長い単語には候補が少ないことに着目した大局的な最適化。
- 黒マスパターンダイアログの改良。
- 2023年05月23日 ver.5.0.4
- 線の幅を指定できるようにする。線の幅のデフォルトを1.0に。
- 線の幅をちゃんと計算。
- 盤面の描画を改良。
- 不完全なEMFサポートの外部ソフトウェアに対してEMF描画の不具合を回避。
2 changes: 2 additions & 0 deletions XG_PatternDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ class XG_PatternDialog : public XG_Dialog
ShellExecuteW(hwnd, NULL, L"https://katahiromz.web.fc2.com/xword/patterns", NULL, NULL, SW_SHOWNORMAL);
}

XG_NOINLINE
INT GetType0()
{
if (IsDlgButtonChecked(m_hWnd, rad1) == BST_CHECKED)
Expand All @@ -300,6 +301,7 @@ class XG_PatternDialog : public XG_Dialog
return -1;
}

XG_NOINLINE
INT GetType1()
{
if (IsDlgButtonChecked(m_hWnd, rad4) == BST_CHECKED)
Expand Down
41 changes: 41 additions & 0 deletions XG_SettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ BOOL XG_SettingsDialog::OnInitDialog(HWND hwnd)
SendMessageW(hwnd, WM_COMMAND, IDOK, 0);
}

// 線の太さ。
WCHAR szText[MAX_PATH];
StringCchPrintfW(szText, _countof(szText), XG_LINE_WIDTH_FORMAT, xg_nLineWidthInPt);
SetDlgItemTextW(hwnd, edt6, szText);

return TRUE;
}

Expand Down Expand Up @@ -193,6 +198,17 @@ void XG_SettingsDialog::OnOK(HWND hwnd)
ComboBox_RealGetText(hCmb2, szText, _countof(szText));
xg_strDoubleFrameLetters = szText;

// 線の太さ。
GetDlgItemTextW(hwnd, edt6, szText, _countof(szText));
std::wstring str = szText;
xg_str_trim(str);
float value = wcstof(str.c_str(), NULL);
if (value > XG_MAX_LINEWIDTH)
value = XG_MAX_LINEWIDTH;
if (value < XG_MIN_LINEWIDTH)
value = XG_MIN_LINEWIDTH;
xg_nLineWidthInPt = value;

// イメージを更新する。
XgUpdateImage(xg_hMainWnd);

Expand Down Expand Up @@ -646,6 +662,31 @@ XG_SettingsDialog::DialogProcDx(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar
OnDropFiles(hwnd, (HDROP)wParam);
break;

case WM_NOTIFY:
{
NM_UPDOWN *pUpDown = (NM_UPDOWN *)lParam;
if (pUpDown->hdr.code == UDN_DELTAPOS)
{
WCHAR szText[MAX_PATH];
GetDlgItemTextW(hwnd, edt6, szText, _countof(szText));
std::wstring str = szText;
xg_str_trim(str);
float value = wcstof(str.c_str(), NULL);
if (pUpDown->iDelta < 0)
value += XG_LINE_WIDTH_DELTA;
if (pUpDown->iDelta > 0)
value -= XG_LINE_WIDTH_DELTA;
if (value > XG_MAX_LINEWIDTH)
value = XG_MAX_LINEWIDTH;
if (value < XG_MIN_LINEWIDTH)
value = XG_MIN_LINEWIDTH;
StringCchPrintfW(szText, _countof(szText), XG_LINE_WIDTH_FORMAT, value);
SetDlgItemTextW(hwnd, edt6, szText);
return TRUE;
}
}
break;

case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
Expand Down
Loading

0 comments on commit d609c26

Please sign in to comment.