-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettingsDlg.cpp
133 lines (100 loc) · 3.09 KB
/
SettingsDlg.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
// WinDjView
// Copyright (C) 2004-2015 Andrew Zhezherun
//
// 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.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA.
// http://www.gnu.org/copyleft/gpl.html
#include "stdafx.h"
#include "WinDjView.h"
#include "SettingsDlg.h"
#include "Drawing.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CSettingsDlg dialog
IMPLEMENT_DYNAMIC(CSettingsDlg, CPropertySheet)
CSettingsDlg::CSettingsDlg(CWnd* pParent)
: CPropertySheet(IDS_SETTINGS, pParent)
{
AddPage(&m_pageGeneral);
AddPage(&m_pageDisplay);
AddPage(&m_pageAdvanced);
if (theApp.GetDictLangsCount() > 0)
AddPage(&m_pageDict);
m_psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
}
CSettingsDlg::~CSettingsDlg()
{
}
BEGIN_MESSAGE_MAP(CSettingsDlg, CPropertySheet)
ON_WM_CTLCOLOR()
ON_WM_CREATE()
ON_MESSAGE_VOID(WM_KICKIDLE, OnKickIdle)
END_MESSAGE_MAP()
// CSettingsDlg message handlers
int CSettingsDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
EnableStackedTabs(false);
if (CPropertySheet::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
BOOL CSettingsDlg::OnInitDialog()
{
CPropertySheet::OnInitDialog();
CFont fnt;
CreateSystemDialogFont(fnt);
LOGFONT lf;
fnt.GetLogFont(&lf);
CScreenDC dcScreen;
lf.lfHeight = -MulDiv(7, dcScreen.GetDeviceCaps(LOGPIXELSY), 72);
m_font.CreateFontIndirect(&lf);
CWnd* pOK = GetDlgItem(IDOK);
CWnd* pPage = GetActivePage();
CRect rcOk, rcPage;
pOK->GetWindowRect(rcOk);
ScreenToClient(rcOk);
pPage->GetWindowRect(rcPage);
ScreenToClient(rcPage);
CRect rcClient = ::GetClientRect(this);
m_ctlAbout.Create(FormatString(IDS_VERSION_INFO, CURRENT_VERSION), WS_CHILD | WS_VISIBLE,
CRect(rcPage.left, rcOk.top, rcOk.left - 5, rcClient.bottom - 5), this, IDC_STATIC_ABOUT);
m_ctlAbout.SetFont(&m_font);
int nPage = theApp.GetAppSettings()->nActiveSettingsTab;
nPage = max(0, min(GetPageCount() - 1, nPage));
SetActivePage(nPage);
return true;
}
HBRUSH CSettingsDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH brush = CPropertySheet::OnCtlColor(pDC, pWnd, nCtlColor);
if (pWnd->GetDlgCtrlID() == IDC_STATIC_ABOUT)
{
pDC->SetTextColor(::GetSysColor(COLOR_GRAYTEXT));
}
return brush;
}
void CSettingsDlg::OnKickIdle()
{
SendMessageToDescendants(WM_KICKIDLE);
theApp.GetAppSettings()->nActiveSettingsTab = GetActiveIndex();
}
INT_PTR CSettingsDlg::DoModal()
{
set<CWnd*> disabled;
theApp.DisableTopLevelWindows(disabled);
INT_PTR nResult = CPropertySheet::DoModal();
theApp.EnableWindows(disabled);
return nResult;
}