aboutsummaryrefslogtreecommitdiff
path: root/SetupDlg.cpp
blob: eb44ab7f11eed35f1c8fd506cc8c35f2bf995e86 (plain) (blame)
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310

#include "stdafx.h"
#include "spacemonger.h"
#include "Lang.h"
#include "SetupDlg.h"

IMPLEMENT_DYNCREATE(CSettingsDialog, CDialog)

BEGIN_MESSAGE_MAP(CSettingsDialog, CDialog)
	//{{AFX_MSG_MAP(CSettingsDialog)
	ON_BN_CLICKED(IDC_SHOW_NAME_TIPS, OnShowNameTips)
	ON_BN_CLICKED(IDC_SHOW_INFO_TIPS, OnShowInfoTips)
	ON_CBN_SELENDOK(IDC_LANG, OnLang)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

CSettingsDialog::CSettingsDialog(CWnd *parent)
	: CDialog(IDD_SETTINGS, parent)
{
}

CSettingsDialog::~CSettingsDialog()
{
}

void CSettingsDialog::OnCancel(void)
{
	theApp.m_settings.lang[0] = oldlang[0];
	theApp.m_settings.lang[1] = oldlang[1];
	theApp.m_settings.lang[2] = oldlang[2];
	theApp.m_settings.lang[3] = oldlang[3];
	CurLang = oldlangptr;

	CDialog::OnCancel();
}

void CSettingsDialog::OnOK(void)
{
	CComboBox *density = (CComboBox *)GetDlgItem(IDC_DENSITY);
	if (density != NULL)
		theApp.m_settings.density = density->GetCurSel()-3;
	CComboBox *file_color = (CComboBox *)GetDlgItem(IDC_FILE_COLOR);
	if (file_color != NULL)
		theApp.m_settings.file_color = file_color->GetCurSel();
	CComboBox *folder_color = (CComboBox *)GetDlgItem(IDC_FOLDER_COLOR);
	if (folder_color != NULL)
		theApp.m_settings.folder_color = folder_color->GetCurSel();
	CButton *auto_rescan = (CButton *)GetDlgItem(IDC_AUTO_RESCAN);
	if (auto_rescan != NULL)
		theApp.m_settings.auto_rescan = auto_rescan->GetCheck();
	CButton *animated = (CButton *)GetDlgItem(IDC_ANIMATED);
	if (animated != NULL)
		theApp.m_settings.animated_zoom = animated->GetCheck();
	CButton *disable_delete = (CButton *)GetDlgItem(IDC_DISABLE_DELETE);
	if (disable_delete != NULL)
		theApp.m_settings.disable_delete = disable_delete->GetCheck();
	CSliderCtrl *bias = (CSliderCtrl *)GetDlgItem(IDC_BIAS);
	if (bias != NULL)
		theApp.m_settings.bias = bias->GetPos()-20;
	CButton *save_pos = (CButton *)GetDlgItem(IDC_SAVE_POS);
	if (save_pos != NULL)
		theApp.m_settings.save_pos = save_pos->GetCheck();

	CButton *show_tips = (CButton *)GetDlgItem(IDC_SHOW_NAME_TIPS);
	if (show_tips != NULL)
		theApp.m_settings.show_name_tips = show_tips->GetCheck();
	show_tips = (CButton *)GetDlgItem(IDC_SHOW_ROLLOVER_BOX);
	if (show_tips != NULL)
		theApp.m_settings.rollover_box = show_tips->GetCheck();
	show_tips = (CButton *)GetDlgItem(IDC_SHOW_INFO_TIPS);
	if (show_tips != NULL)
		theApp.m_settings.show_info_tips = show_tips->GetCheck();

	CButton *tip;
	theApp.m_settings.infotip_flags = 0;
	CEdit *nametipdelay = (CEdit *)GetDlgItem(IDC_NAMETIP_DELAY);
	if (nametipdelay != NULL) {
		CString string;
		nametipdelay->GetWindowText(string);
		theApp.m_settings.nametip_delay = atoi(string);
	}

	if ((tip = (CButton *)GetDlgItem(IDC_INFOTIP_PATH)) != NULL && tip->GetCheck())
		theApp.m_settings.infotip_flags |= TIP_PATH;
	if ((tip = (CButton *)GetDlgItem(IDC_INFOTIP_NAME)) != NULL && tip->GetCheck())
		theApp.m_settings.infotip_flags |= TIP_NAME;
	if ((tip = (CButton *)GetDlgItem(IDC_INFOTIP_SIZE)) != NULL && tip->GetCheck())
		theApp.m_settings.infotip_flags |= TIP_SIZE;
	if ((tip = (CButton *)GetDlgItem(IDC_INFOTIP_DATE)) != NULL && tip->GetCheck())
		theApp.m_settings.infotip_flags |= TIP_DATE;
	if ((tip = (CButton *)GetDlgItem(IDC_INFOTIP_ATTRIB)) != NULL && tip->GetCheck())
		theApp.m_settings.infotip_flags |= TIP_ATTRIB;
	if ((tip = (CButton *)GetDlgItem(IDC_INFOTIP_ICON)) != NULL && tip->GetCheck())
		theApp.m_settings.infotip_flags |= TIP_ICON;
	CEdit *infotipdelay = (CEdit *)GetDlgItem(IDC_INFOTIP_DELAY);
	if (infotipdelay != NULL) {
		CString string;
		infotipdelay->GetWindowText(string);
		theApp.m_settings.infotip_delay = atoi(string);
	}

	CDialog::OnOK();
}

void CSettingsDialog::OnShowNameTips(void)
{
	CButton *show_tips = (CButton *)GetDlgItem(IDC_SHOW_NAME_TIPS);
	if (show_tips != NULL)
		EnableNameTipButtons(show_tips->GetCheck());
}

void CSettingsDialog::OnShowInfoTips(void)
{
	CButton *show_tips = (CButton *)GetDlgItem(IDC_SHOW_INFO_TIPS);
	if (show_tips != NULL)
		EnableInfoTipButtons(show_tips->GetCheck());
}

void CSettingsDialog::EnableNameTipButtons(BOOL bEnable)
{
	CWnd *wnd;
	if ((wnd = GetDlgItem(IDC_STATIC_NAMETIP1)) != NULL)
		wnd->EnableWindow(bEnable);
	if ((wnd = GetDlgItem(IDC_NAMETIP_DELAY)) != NULL)
		wnd->EnableWindow(bEnable);
	if ((wnd = GetDlgItem(IDC_STATIC_NAMETIP2)) != NULL)
		wnd->EnableWindow(bEnable);
}

void CSettingsDialog::EnableInfoTipButtons(BOOL bEnable)
{
	CWnd *wnd;
	if ((wnd = GetDlgItem(IDC_INFOTIP_PATH)) != NULL)
		wnd->EnableWindow(bEnable);
	if ((wnd = GetDlgItem(IDC_INFOTIP_NAME)) != NULL)
		wnd->EnableWindow(bEnable);
	if ((wnd = GetDlgItem(IDC_INFOTIP_DATE)) != NULL)
		wnd->EnableWindow(bEnable);
	if ((wnd = GetDlgItem(IDC_INFOTIP_SIZE)) != NULL)
		wnd->EnableWindow(bEnable);
	if ((wnd = GetDlgItem(IDC_INFOTIP_ATTRIB)) != NULL)
		wnd->EnableWindow(bEnable);
	if ((wnd = GetDlgItem(IDC_INFOTIP_ICON)) != NULL)
		wnd->EnableWindow(bEnable);
	if ((wnd = GetDlgItem(IDC_STATIC_INFOTIP1)) != NULL)
		wnd->EnableWindow(bEnable);
	if ((wnd = GetDlgItem(IDC_INFOTIP_DELAY)) != NULL)
		wnd->EnableWindow(bEnable);
	if ((wnd = GetDlgItem(IDC_STATIC_INFOTIP2)) != NULL)
		wnd->EnableWindow(bEnable);
}

void CSettingsDialog::OnLang(void)
{
	CComboBox *lang = (CComboBox *)GetDlgItem(IDC_LANG);
	if (lang == NULL) return;
	int index = lang->GetCurSel();
	theApp.m_settings.lang[0] = Langs[index].abbrev[0];
	theApp.m_settings.lang[1] = Langs[index].abbrev[1];
	theApp.m_settings.lang[2] = '\0';
	theApp.m_settings.lang[3] = '\0';
	CurLang = Langs[index].text;
	UpdateDialogForNewLanguage();
}

void CSettingsDialog::UpdateDialogForNewLanguage(void)
{
	CComboBox *lang = (CComboBox *)GetDlgItem(IDC_LANG);
	if (lang != NULL) lang->ResetContent();
	CComboBox *density = (CComboBox *)GetDlgItem(IDC_DENSITY);
	if (density != NULL) density->ResetContent();
	CComboBox *file_color = (CComboBox *)GetDlgItem(IDC_FILE_COLOR);
	if (file_color != NULL) file_color->ResetContent();
	CComboBox *folder_color = (CComboBox *)GetDlgItem(IDC_FOLDER_COLOR);
	if (folder_color != NULL) folder_color->ResetContent();

	int i;

	SetWindowText(CurLang->settings);
	SetDlgItemText(IDOK, CurLang->ok);
	SetDlgItemText(IDCANCEL, CurLang->cancel);

	SetDlgItemText(IDC_STATIC_LAYOUT, CurLang->layout);
	SetDlgItemText(IDC_STATIC_DENSITY, CurLang->density);
	SetDlgItemText(IDC_STATIC_BIAS, CurLang->bias);
	SetDlgItemText(IDC_STATIC_HORZ, CurLang->horz);
	SetDlgItemText(IDC_STATIC_EQUAL, CurLang->equal);
	SetDlgItemText(IDC_STATIC_VERT, CurLang->vert);
	SetDlgItemText(IDC_STATIC_DISPLAYCOLORS, CurLang->displaycolors);
	SetDlgItemText(IDC_STATIC_FILES, CurLang->files);
	SetDlgItemText(IDC_STATIC_FOLDERS, CurLang->folders);
	SetDlgItemText(IDC_STATIC_TOOLTIPS, CurLang->tooltips);
	SetDlgItemText(IDC_STATIC_MISCOPTIONS, CurLang->miscoptions);
	SetDlgItemText(IDC_SHOW_NAME_TIPS, CurLang->shownametips);
	SetDlgItemText(IDC_SHOW_ROLLOVER_BOX, CurLang->showrolloverbox);
	SetDlgItemText(IDC_SHOW_INFO_TIPS, CurLang->showinfotips);
	SetDlgItemText(IDC_INFOTIP_PATH, CurLang->fullpath);
	SetDlgItemText(IDC_INFOTIP_NAME, CurLang->filename);
	SetDlgItemText(IDC_INFOTIP_ICON, CurLang->icon);
	SetDlgItemText(IDC_INFOTIP_DATE, CurLang->datetime);
	SetDlgItemText(IDC_INFOTIP_SIZE, CurLang->filesize);
	SetDlgItemText(IDC_INFOTIP_ATTRIB, CurLang->attrib);
	SetDlgItemText(IDC_STATIC_NAMETIP1, CurLang->delay);
	SetDlgItemText(IDC_STATIC_NAMETIP2, CurLang->msec);
	SetDlgItemText(IDC_STATIC_INFOTIP1, CurLang->delay);
	SetDlgItemText(IDC_STATIC_INFOTIP2, CurLang->msec);
	SetDlgItemText(IDC_AUTO_RESCAN, CurLang->autorescan);
	SetDlgItemText(IDC_DISABLE_DELETE, CurLang->disabledelete);
	SetDlgItemText(IDC_ANIMATED, CurLang->animatedzoom);
	SetDlgItemText(IDC_SAVE_POS, CurLang->savepos);

	if (lang != NULL) {
		for (i = 0; Langs[i].name != NULL; i++) {
			lang->AddString(Langs[i].name);
			if (Langs[i].abbrev[0] == theApp.m_settings.lang[0]
				&& Langs[i].abbrev[1] == theApp.m_settings.lang[1])
				lang->SetCurSel(i);
		}
	}

	if (density != NULL) {
		for (i = 0; i < 6; i++)
			density->AddString(CurLang->densitynames[i]);
		density->SetCurSel(theApp.m_settings.density+3);
	}
	if (file_color != NULL) {
		for (i = 0; i < 12; i++)
			file_color->AddString(CurLang->colornames[i]);
		file_color->SetCurSel(theApp.m_settings.file_color);
	}
	if (folder_color != NULL) {
		for (i = 0; i < 12; i++)
			folder_color->AddString(CurLang->colornames[i]);
		folder_color->SetCurSel(theApp.m_settings.folder_color);
	}
	CButton *auto_rescan = (CButton *)GetDlgItem(IDC_AUTO_RESCAN);
	if (auto_rescan != NULL)
		auto_rescan->SetCheck(theApp.m_settings.auto_rescan);
	CButton *animated = (CButton *)GetDlgItem(IDC_ANIMATED);
	if (animated != NULL)
		animated->SetCheck(theApp.m_settings.animated_zoom);
	CButton *disable_delete = (CButton *)GetDlgItem(IDC_DISABLE_DELETE);
	if (disable_delete != NULL)
		disable_delete->SetCheck(theApp.m_settings.disable_delete);
	CButton *save_pos = (CButton *)GetDlgItem(IDC_SAVE_POS);
	if (save_pos != NULL)
		save_pos->SetCheck(theApp.m_settings.save_pos);

	CButton *show_name_tips = (CButton *)GetDlgItem(IDC_SHOW_NAME_TIPS);
	if (show_name_tips != NULL)
		show_name_tips->SetCheck(theApp.m_settings.show_name_tips);
	show_name_tips = (CButton *)GetDlgItem(IDC_SHOW_ROLLOVER_BOX);
	if (show_name_tips != NULL)
		show_name_tips->SetCheck(theApp.m_settings.rollover_box);

	CButton *tip;
	CButton *show_info_tips = (CButton *)GetDlgItem(IDC_SHOW_INFO_TIPS);
	if (show_info_tips != NULL)
		show_info_tips->SetCheck(theApp.m_settings.show_info_tips);
	if ((tip = (CButton *)GetDlgItem(IDC_INFOTIP_PATH)) != NULL)
		tip->SetCheck((theApp.m_settings.infotip_flags & TIP_PATH) != 0);
	if ((tip = (CButton *)GetDlgItem(IDC_INFOTIP_NAME)) != NULL)
		tip->SetCheck((theApp.m_settings.infotip_flags & TIP_NAME) != 0);
	if ((tip = (CButton *)GetDlgItem(IDC_INFOTIP_DATE)) != NULL)
		tip->SetCheck((theApp.m_settings.infotip_flags & TIP_DATE) != 0);
	if ((tip = (CButton *)GetDlgItem(IDC_INFOTIP_SIZE)) != NULL)
		tip->SetCheck((theApp.m_settings.infotip_flags & TIP_SIZE) != 0);
	if ((tip = (CButton *)GetDlgItem(IDC_INFOTIP_ATTRIB)) != NULL)
		tip->SetCheck((theApp.m_settings.infotip_flags & TIP_ATTRIB) != 0);
	if ((tip = (CButton *)GetDlgItem(IDC_INFOTIP_ICON)) != NULL)
		tip->SetCheck((theApp.m_settings.infotip_flags & TIP_ICON) != 0);

	CEdit *tipdelay = (CEdit *)GetDlgItem(IDC_NAMETIP_DELAY);
	if (tipdelay != NULL) {
		CString string;
		string.Format("%u", theApp.m_settings.nametip_delay);
		tipdelay->SetWindowText(string);
	}
	tipdelay = (CEdit *)GetDlgItem(IDC_INFOTIP_DELAY);
	if (tipdelay != NULL) {
		CString string;
		string.Format("%u", theApp.m_settings.infotip_delay);
		tipdelay->SetWindowText(string);
	}
	EnableNameTipButtons(theApp.m_settings.show_name_tips);
	EnableInfoTipButtons(theApp.m_settings.show_info_tips);

	CSliderCtrl *bias = (CSliderCtrl *)GetDlgItem(IDC_BIAS);
	if (bias != NULL) {
		bias->SetRange(0, 40, 0);
		bias->SetPos(theApp.m_settings.bias+20);
		bias->SetTicFreq(5);
	}
}

BOOL CSettingsDialog::OnInitDialog()
{
	oldlang[0] = theApp.m_settings.lang[0];
	oldlang[1] = theApp.m_settings.lang[1];
	oldlang[2] = theApp.m_settings.lang[2];
	oldlang[3] = theApp.m_settings.lang[3];
	oldlangptr = CurLang;

	UpdateDialogForNewLanguage();

	CDialog::OnInitDialog();

	return TRUE;
}