forked from WinMerge/winmerge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAboutDlg.cpp
154 lines (134 loc) · 4.33 KB
/
AboutDlg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/////////////////////////////////////////////////////////////////////////////
// License (GPLv2+):
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
/////////////////////////////////////////////////////////////////////////////
/**
* @file AboutDlg.cpp
*
* @brief Implementation of the About-dialog.
*
*/
#include "stdafx.h"
#include "AboutDlg.h"
#include "TrDialogs.h"
#include "Picture.h"
#include "resource.h" // IDD_ABOUTBOX
/**
* @brief About-dialog class.
*
* Shows About-dialog bitmap and draws version number and other
* texts into it.
*/
class CAboutDlg::Impl : public CTrDialog
{
public:
Impl(CAboutDlg *p, CWnd* pParent = nullptr);
// Dialog Data
//{{AFX_DATA(CAboutDlg::Impl)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg::Impl)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg::Impl)
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedOpenContributors();
afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
afx_msg void OnBnClickedWWW(NMHDR *pNMHDR, LRESULT *pResult);
private:
CAboutDlg *m_p;
CPicture m_image;
CFont m_font;
};
BEGIN_MESSAGE_MAP(CAboutDlg::Impl, CTrDialog)
//{{AFX_MSG_MAP(CAboutDlg::Impl)
//}}AFX_MSG_MAP
ON_BN_CLICKED(IDC_OPEN_CONTRIBUTORS, OnBnClickedOpenContributors)
ON_WM_DRAWITEM()
ON_WM_CTLCOLOR()
ON_NOTIFY(NM_CLICK, IDC_WWW, OnBnClickedWWW)
END_MESSAGE_MAP()
CAboutDlg::Impl::Impl(CAboutDlg *p, CWnd* pParent /*= nullptr*/)
: CTrDialog(CAboutDlg::Impl::IDD)
, m_p(p)
{
}
void CAboutDlg::Impl::DoDataExchange(CDataExchange* pDX)
{
CTrDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg::Impl)
DDX_Text(pDX, IDC_COMPANY, m_p->m_info.copyright);
DDX_Text(pDX, IDC_VERSION, m_p->m_info.version);
//}}AFX_DATA_MAP
}
/**
* @brief Read version info from resource to dialog.
*/
BOOL CAboutDlg::Impl::OnInitDialog()
{
CTrDialog::OnInitDialog();
m_image.Load(IDR_SPLASH);
m_font.CreatePointFont(10 * 10, _T("Tahoma"));
SetDlgItemText(static_cast<unsigned>(IDC_STATIC), m_p->m_info.developers);
GetDlgItem(IDC_STATIC)->SetFont(&m_font);
GetDlgItem(IDC_VERSION)->SetFont(&m_font);
String link;
GetDlgItemText(IDC_WWW, link);
link = _T("<a href=\"") + m_p->m_info.website + _T("\">") + link + _T("</a>");
SetDlgItemText(IDC_WWW, link);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
HBRUSH CAboutDlg::Impl::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
if (nCtlColor == CTLCOLOR_STATIC && pWnd != GetDlgItem(IDC_WWW))
{
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)GetStockObject(NULL_BRUSH);
}
return CTrDialog::OnCtlColor(pDC, pWnd, nCtlColor);
}
void CAboutDlg::Impl::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CRect rc;
GetDlgItem(nIDCtl)->GetClientRect(&rc);
m_image.Render(CDC::FromHandle(lpDrawItemStruct->hDC), rc);
}
/**
* @brief Show contributors list.
* Opens Contributors.txt into notepad.
*/
void CAboutDlg::Impl::OnBnClickedOpenContributors()
{
int tmp = 0;
m_p->m_onclick_contributers.notify(m_p, tmp);
}
void CAboutDlg::Impl::OnBnClickedWWW(NMHDR *pNMHDR, LRESULT *pResult)
{
PNMLINK pNMLink = (PNMLINK)pNMHDR;
ShellExecute(nullptr, _T("open"), pNMLink->item.szUrl, nullptr, nullptr, SW_SHOWNORMAL);
}
CAboutDlg::CAboutDlg() : m_pimpl(new CAboutDlg::Impl(this)) {}
CAboutDlg::~CAboutDlg() {}
int CAboutDlg::DoModal() { return static_cast<int>(m_pimpl->DoModal()); }