Skip to content

Commit

Permalink
フォント選択ダイアログをフォント選択専用にも使えるようにした。
Browse files Browse the repository at this point in the history
  • Loading branch information
Tatsu-syo committed Jan 8, 2024
1 parent 7613ba1 commit a6963ad
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 10 deletions.
41 changes: 32 additions & 9 deletions program/FontSel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ int getFont()
/**
* コンストラクタ
*/
FontSel::FontSel(HWND parent, int resource) : BaseDialog(parent, resource)
FontSel::FontSel(HWND parent, int resource, bool fontOnly) : BaseDialog(parent, resource)
{
displayFont = NULL;
m_fontNameList = NULL;
Expand All @@ -272,6 +272,7 @@ FontSel::FontSel(HWND parent, int resource) : BaseDialog(parent, resource)
m_strike = NULL;
previousFont = NULL;
m_point = 0;
m_fontonly = fontOnly;
}

/**
Expand Down Expand Up @@ -408,12 +409,34 @@ INT_PTR FontSel::OnInitDialog()
}
}

if (m_fontonly) {
disableWithoutFontselect();
}

applyResource();
adjustPosition();

return (INT_PTR)FALSE;
}

/**
* @brief フォント選択以外を無効化する。
*
*/
void FontSel::disableWithoutFontselect(void)
{
m_fontSizeList->EnableWindow(FALSE);
m_ChersetList->EnableWindow(FALSE);
m_styleList->EnableWindow(FALSE);
m_bold->EnableWindow(FALSE);
m_italic->EnableWindow(FALSE);
m_underline->EnableWindow(FALSE);
m_strike->EnableWindow(FALSE);
setChildEnabled(IDC_STATIC_STYLE, FALSE);
setChildEnabled(IDC_STATIC_SIZE, FALSE);
setChildEnabled(IDC_STATIC_CHARSET, FALSE);
}

/**
* ウインドウ位置を親ウインドウの中央に調整する。
*/
Expand Down Expand Up @@ -492,27 +515,27 @@ void FontSel::applyResource()
// アプリタイトル
setText(langResource[27].c_str());

setChildText(IDC_STATIC_NAME, langResource[28].c_str());
setChildText(IDC_STATIC_NAME, langResource[DLG_FONT_NAME].c_str());
setChildFont(IDC_STATIC_NAME, displayFont);
setChildText(IDC_STATIC_STYLE, langResource[29].c_str());
setChildText(IDC_STATIC_STYLE, langResource[DLG_STYLE].c_str());
setChildFont(IDC_STATIC_STYLE, displayFont);
setChildText(IDC_STATIC_SIZE, langResource[30].c_str());
setChildText(IDC_STATIC_SIZE, langResource[DLG_SIZE].c_str());
setChildFont(IDC_STATIC_SIZE, displayFont);

setChildText(IDC_CHECK_BOLD, langResource[DLG_CHECK_BOLD].c_str());
setChildFont(IDC_CHECK_BOLD, displayFont);
setChildText(IDC_CHECK_ITALIC, langResource[DLG_CHECK_ITALIC].c_str());
setChildFont(IDC_CHECK_ITALIC, displayFont);
setChildText(IDC_CHECK_UNDERLINE, langResource[31].c_str());
setChildText(IDC_CHECK_UNDERLINE, langResource[DLG_UNDERLINE].c_str());
setChildFont(IDC_CHECK_UNDERLINE, displayFont);
setChildText(IDC_CHECK_STRIKE, langResource[32].c_str());
setChildText(IDC_CHECK_STRIKE, langResource[DLG_STRIKE].c_str());
setChildFont(IDC_CHECK_STRIKE, displayFont);
setChildText(IDC_STATIC_CHARSET, langResource[33].c_str());
setChildText(IDC_STATIC_CHARSET, langResource[DLG_CHARSET].c_str());
setChildFont(IDC_STATIC_CHARSET, displayFont);

setChildText(IDOK, langResource[34].c_str());
setChildText(IDOK, langResource[DLG_OK].c_str());
setChildFont(IDOK, displayFont);
setChildText(IDCANCEL, langResource[35].c_str());
setChildText(IDCANCEL, langResource[DLG_CANCEL].c_str());
setChildFont(IDCANCEL, displayFont);

setChildFont(IDC_COMBO_NAME, displayFont);
Expand Down
4 changes: 3 additions & 1 deletion program/FontSel.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,21 @@ class FontSel :
LOGFONT selectedFont;
LOGFONT *previousFont;
double m_point;
bool m_fontonly;

void adjustPosition(void);
void applyResource();
void setCharset(void);
void setStyle();
INT_PTR onOK(void);
void disableWithoutFontselect(void);

protected:
INT_PTR OnInitDialog();
INT_PTR OnCommand(WPARAM wParam);

public:
FontSel(HWND parent, int resource);
FontSel(HWND parent, int resource, bool fontOnly = false);
virtual ~FontSel(void);

LOGFONT getSelectedFont() {
Expand Down
15 changes: 15 additions & 0 deletions program/TWR/BaseDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,18 @@ void BaseDialog::setChildFont(int id, HFONT font)
target = ::GetDlgItem(hWnd, id);
SendMessage(target, WM_SETFONT, (WPARAM)font, MAKELPARAM(TRUE, 0));
}

/**
* 子項目が有効かどうか設定する
*
* @param id 子項目のID
* @param enabled TRUE:有効 FALSE:無効
*/
void BaseDialog::setChildEnabled(int id, BOOL enabled)
{
HWND target;

target = ::GetDlgItem(hWnd, id);
::EnableWindow(target, enabled);
}

1 change: 1 addition & 0 deletions program/TWR/BaseDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class BaseDialog : public TwrWnd {
HWND GetDlgItemRaw(int item);
void setChildText(int id, const TCHAR *message);
void setChildFont(int id, HFONT font);
void setChildEnabled(int id, BOOL enabled);

virtual void UpdateData(bool toObj);

Expand Down

0 comments on commit a6963ad

Please sign in to comment.