1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * @brief Implementation of the About-dialog.
11 #include "TrDialogs.h"
13 #include "resource.h" // IDD_ABOUTBOX
15 // https://www.gnu.org/graphics/gnu-ascii.html
16 // Copyright (c) 2001 Free Software Foundation, Inc.
17 // Converted with https://tomeko.net/online_tools/cpp_text_escape.php
18 static const char gnu_ascii[] =
30 * @brief About-dialog class.
32 * Shows About-dialog bitmap and draws version number and other
35 class CAboutDlg::Impl : public CTrDialog
38 explicit Impl(CAboutDlg *p, CWnd* pParent = nullptr);
41 //{{AFX_DATA(CAboutDlg::Impl)
42 enum { IDD = IDD_ABOUTBOX };
45 // ClassWizard generated virtual function overrides
46 //{{AFX_VIRTUAL(CAboutDlg::Impl)
48 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
53 //{{AFX_MSG(CAboutDlg::Impl)
54 virtual BOOL OnInitDialog();
58 afx_msg void OnBnClickedOpenContributors();
59 afx_msg BOOL OnEraseBkgnd(CDC* pDC);
60 afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
61 afx_msg void OnBnClickedWWW(NMHDR *pNMHDR, LRESULT *pResult);
67 CFont m_font_gnu_ascii;
70 BEGIN_MESSAGE_MAP(CAboutDlg::Impl, CTrDialog)
71 //{{AFX_MSG_MAP(CAboutDlg::Impl)
73 ON_BN_CLICKED(IDC_OPEN_CONTRIBUTORS, OnBnClickedOpenContributors)
76 ON_NOTIFY(NM_CLICK, IDC_WWW, OnBnClickedWWW)
79 CAboutDlg::Impl::Impl(CAboutDlg *p, CWnd* pParent /*= nullptr*/)
80 : CTrDialog(CAboutDlg::Impl::IDD)
83 m_font.CreatePointFont(10 * 10, _T("Tahoma"));
85 lf.lfHeight = 14 * 10;
86 lf.lfWeight = FW_BOLD;
87 _tcscpy_s(lf.lfFaceName, _T("Courier New"));
88 m_font_gnu_ascii.CreatePointFontIndirect(&lf);
91 void CAboutDlg::Impl::DoDataExchange(CDataExchange* pDX)
93 CTrDialog::DoDataExchange(pDX);
94 //{{AFX_DATA_MAP(CAboutDlg::Impl)
95 DDX_Text(pDX, IDC_COMPANY, m_p->m_info.copyright);
96 DDX_Text(pDX, IDC_VERSION, m_p->m_info.version);
101 * @brief Read version info from resource to dialog.
103 BOOL CAboutDlg::Impl::OnInitDialog()
105 CTrDialog::OnInitDialog();
107 if (!LoadImageFromResource(m_image, MAKEINTRESOURCE(IDR_SPLASH), _T("IMAGE")))
109 // FIXME: LoadImageFromResource() seems to fail when running on Wine 5.0.
112 GetDlgItem(IDC_VERSION)->SetFont(&m_font);
113 GetDlgItem(IDC_GNU_ASCII)->SetFont(&m_font_gnu_ascii);
114 ::SetDlgItemTextA(m_hWnd, IDC_GNU_ASCII, gnu_ascii);
117 GetDlgItemText(IDC_WWW, link);
118 link = _T("<a href=\"") + m_p->m_info.website + _T("\">") + link + _T("</a>");
119 SetDlgItemText(IDC_WWW, link);
123 return TRUE; // return TRUE unless you set the focus to a control
124 // EXCEPTION: OCX Property Pages should return FALSE
127 HBRUSH CAboutDlg::Impl::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
129 if (nCtlColor == CTLCOLOR_STATIC)
131 if (pWnd->GetDlgCtrlID() == IDC_GNU_ASCII)
132 pDC->SetTextColor(RGB(128, 128, 128));
133 pDC->SetBkMode(TRANSPARENT);
134 return (HBRUSH)GetStockObject(NULL_BRUSH);
136 return CTrDialog::OnCtlColor(pDC, pWnd, nCtlColor);
139 BOOL CAboutDlg::Impl::OnEraseBkgnd(CDC* pDC)
145 GetDlgItem(IDC_COMPANY)->GetWindowRect(&rcCompany);
146 ScreenToClient(&rcCompany);
147 rc.top = rcCompany.bottom;
148 pDC->FillSolidRect(&rc, GetSysColor(COLOR_BTNFACE));
151 m_image.Draw(pDC->m_hDC, rc, Gdiplus::InterpolationModeBicubic);
156 * @brief Show contributors list.
157 * Opens Contributors.txt into notepad.
159 void CAboutDlg::Impl::OnBnClickedOpenContributors()
162 m_p->m_onclick_contributers.notify(m_p, tmp);
165 void CAboutDlg::Impl::OnBnClickedWWW(NMHDR *pNMHDR, LRESULT *pResult)
167 PNMLINK pNMLink = (PNMLINK)pNMHDR;
169 m_p->m_onclick_url.notify(m_p, tmp);
172 CAboutDlg::CAboutDlg() : m_pimpl(new CAboutDlg::Impl(this)) {}
173 CAboutDlg::~CAboutDlg() {}
174 int CAboutDlg::DoModal() { return static_cast<int>(m_pimpl->DoModal()); }