3e449b822845f268c23d170fec9db02b46894554
[reactos.git] / modules / rosapps / applications / explorer-old / dialogs / settings.cpp
1 /*
2 * Copyright 2004 Martin Fuchs
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19
20 //
21 // Explorer clone
22 //
23 // dialogs/settings.cpp
24 //
25 // Explorer dialogs
26 //
27 // Martin Fuchs, 18.01.2004
28 //
29
30
31 #include <precomp.h>
32
33 #include "../taskbar/traynotify.h"
34 #include "settings.h"
35
36
37 void ExplorerPropertySheet(HWND hparent)
38 {
39 PropertySheetDialog ps(hparent);
40
41 ps.dwFlags |= PSH_USEICONID | PSH_PROPTITLE;
42 ps.pszIcon = MAKEINTRESOURCE(IDI_REACTOS);
43 ps.pszCaption = TEXT("Explorer");
44
45 PropSheetPage psp1(IDD_DESKBAR_DESKTOP, WINDOW_CREATOR(DesktopSettingsDlg));
46 psp1.dwFlags |= PSP_USETITLE;
47 psp1.pszTitle = MAKEINTRESOURCE(IDS_DESKTOP);
48 ps.add(psp1);
49
50 PropSheetPage psp2(IDD_DESKBAR_TASKBAR, WINDOW_CREATOR(TaskbarSettingsDlg));
51 psp2.dwFlags |= PSP_USETITLE;
52 psp2.pszTitle = MAKEINTRESOURCE(IDS_TASKBAR);
53 ps.add(psp2);
54
55 PropSheetPage psp3(IDD_DESKBAR_STARTMENU, WINDOW_CREATOR(StartmenuSettingsDlg));
56 psp3.dwFlags |= PSP_USETITLE;
57 psp3.pszTitle = MAKEINTRESOURCE(IDS_STARTMENU);
58 ps.add(psp3);
59
60 ps.DoModal();
61 }
62
63
64 DesktopSettingsDlg::DesktopSettingsDlg(HWND hwnd)
65 : super(hwnd),
66 _bmp0(IDB_ICON_ALIGN_0),
67 _bmp1(IDB_ICON_ALIGN_1),
68 _bmp2(IDB_ICON_ALIGN_2),
69 _bmp3(IDB_ICON_ALIGN_3),
70 _bmp4(IDB_ICON_ALIGN_4),
71 _bmp5(IDB_ICON_ALIGN_5),
72 _bmp6(IDB_ICON_ALIGN_6),
73 _bmp7(IDB_ICON_ALIGN_7),
74 _bmp8(IDB_ICON_ALIGN_8),
75 _bmp9(IDB_ICON_ALIGN_9),
76 _bmp10(IDB_ICON_ALIGN_10)
77 {
78 new PictureButton(_hwnd, IDC_ICON_ALIGN_0, _bmp0);
79 new PictureButton(_hwnd, IDC_ICON_ALIGN_1, _bmp1);
80 new PictureButton(_hwnd, IDC_ICON_ALIGN_2, _bmp2);
81 new PictureButton(_hwnd, IDC_ICON_ALIGN_3, _bmp3);
82 new PictureButton(_hwnd, IDC_ICON_ALIGN_4, _bmp4);
83 new PictureButton(_hwnd, IDC_ICON_ALIGN_5, _bmp5);
84 new PictureButton(_hwnd, IDC_ICON_ALIGN_6, _bmp6);
85 new PictureButton(_hwnd, IDC_ICON_ALIGN_7, _bmp7);
86 new PictureButton(_hwnd, IDC_ICON_ALIGN_8, _bmp8);
87 new PictureButton(_hwnd, IDC_ICON_ALIGN_9, _bmp9);
88 new PictureButton(_hwnd, IDC_ICON_ALIGN_10, _bmp10);
89
90 _alignment_cur = SendMessage(g_Globals._hwndShellView, PM_GET_ICON_ALGORITHM, 0, 0);
91 _alignment_tmp = _alignment_cur;
92
93 _display_version_org = SendMessage(g_Globals._hwndShellView, PM_DISPLAY_VERSION, 0, MAKELONG(0,0));
94 CheckDlgButton(hwnd, ID_DESKTOP_VERSION, _display_version_org? BST_CHECKED: BST_UNCHECKED);
95 }
96
97 #ifndef PSN_QUERYINITIALFOCUS // currently (as of 18.01.2004) missing in MinGW headers
98 #define PSN_QUERYINITIALFOCUS (-213)
99 #endif
100
101 int DesktopSettingsDlg::Notify(int id, NMHDR* pnmh)
102 {
103 switch(pnmh->code) {
104 case PSN_QUERYINITIALFOCUS:
105 SetWindowLongPtr(_hwnd, DWL_MSGRESULT, (LPARAM)GetDlgItem(_hwnd, IDC_ICON_ALIGN_0+_alignment_cur));
106 break;
107
108 case PSN_APPLY:
109 _alignment_cur = _alignment_tmp;
110 _display_version_org = SendMessage(g_Globals._hwndShellView, PM_DISPLAY_VERSION, 0, MAKELONG(0,0));
111 break;
112
113 case PSN_RESET:
114 if (_alignment_tmp != _alignment_cur)
115 SendMessage(g_Globals._hwndShellView, PM_SET_ICON_ALGORITHM, _alignment_cur, 0);
116 SendMessage(g_Globals._hwndShellView, PM_DISPLAY_VERSION, _display_version_org, MAKELONG(1,0));
117 break;
118
119 default:
120 return super::Notify(id, pnmh);
121 }
122
123 return 0;
124 }
125
126 int DesktopSettingsDlg::Command(int id, int code)
127 {
128 if (id>=IDC_ICON_ALIGN_0 && id<=IDC_ICON_ALIGN_10) {
129 int alignment = id - IDC_ICON_ALIGN_0;
130
131 if (alignment != _alignment_tmp) {
132 _alignment_tmp = alignment;
133
134 PropSheet_Changed(GetParent(_hwnd), _hwnd);
135
136 SendMessage(g_Globals._hwndShellView, PM_SET_ICON_ALGORITHM, alignment, 0);
137 }
138
139 return 0;
140 }
141
142 switch(id) {
143 case ID_DESKTOP_VERSION:
144 SendMessage(g_Globals._hwndShellView, PM_DISPLAY_VERSION, 0, MAKELONG(0,1)); // toggle version display flag
145 PropSheet_Changed(GetParent(_hwnd), _hwnd);
146 break;
147
148 default:
149 return 1;
150 }
151
152 return 0;
153 }
154
155
156 TaskbarSettingsDlg::TaskbarSettingsDlg(HWND hwnd)
157 : super(hwnd),
158 _cfg_org(g_Globals._cfg)
159 {
160 XMLPos options = g_Globals.get_cfg("desktopbar/options");
161
162 CheckDlgButton(hwnd, ID_SHOW_CLOCK, XMLBool(options, "show-clock", true)? BST_CHECKED: BST_UNCHECKED);
163 CheckDlgButton(hwnd, ID_HIDE_INACTIVE_ICONS, XMLBool(options, "hide-inactive", true)? BST_CHECKED: BST_UNCHECKED);
164 }
165
166 int TaskbarSettingsDlg::Notify(int id, NMHDR* pnmh)
167 {
168 switch(pnmh->code) {
169 case PSN_APPLY:
170 _cfg_org = g_Globals._cfg;
171 break;
172
173 case PSN_RESET:
174 g_Globals._cfg = _cfg_org;
175 SendMessage(g_Globals._hwndDesktopBar, PM_REFRESH_CONFIG, 0, 0);
176 break;
177
178 default:
179 return super::Notify(id, pnmh);
180 }
181
182 return 0;
183 }
184
185 int TaskbarSettingsDlg::Command(int id, int code)
186 {
187 switch(id) {
188 case ID_CONFIG_NOTIFYAREA:
189 Dialog::DoModal(IDD_NOTIFYAREA, WINDOW_CREATOR(TrayNotifyDlg), _hwnd);
190 break;
191
192 case ID_SHOW_CLOCK: {
193 XMLBoolRef boolRef1(XMLPos(g_Globals.get_cfg("desktopbar/options")), "show-clock", true);
194 boolRef1.toggle();
195 SendMessage(g_Globals._hwndDesktopBar, PM_REFRESH_CONFIG, 0, 0);
196 PropSheet_Changed(GetParent(_hwnd), _hwnd);
197 break;}
198
199 case ID_HIDE_INACTIVE_ICONS: {
200 XMLBoolRef boolRef2(XMLPos(g_Globals.get_cfg("notify-icons/options")), "hide-inactive", true);
201 boolRef2.toggle();
202 SendMessage(g_Globals._hwndDesktopBar, PM_REFRESH_CONFIG, 0, 0);
203 PropSheet_Changed(GetParent(_hwnd), _hwnd);
204 break;}
205
206 default:
207 return 1;
208 }
209
210 return 0;
211 }
212
213
214 StartmenuSettingsDlg::StartmenuSettingsDlg(HWND hwnd)
215 : super(hwnd)
216 {
217 }
218
219 int StartmenuSettingsDlg::Command(int id, int code)
220 {
221 /*
222 switch(id) {
223 case ID_CONFIG_NOTIFYAREA:
224 Dialog::DoModal(IDD_NOTIFYAREA, WINDOW_CREATOR(TrayNotifyDlg), _hwnd);
225 return 0;
226 }
227 */
228 return 1;
229 }
230
231
232 MdiSdiDlg::MdiSdiDlg(HWND hwnd)
233 : super(hwnd)
234 {
235 CenterWindow(hwnd);
236
237 XMLPos explorer_options = g_Globals.get_cfg("general/explorer");
238 bool mdi = XMLBool(explorer_options, "mdi", true);
239 bool separateFolders = XMLBool(explorer_options, "separate-folders", true);
240
241 int id = mdi? IDC_MDI: IDC_SDI;
242 CheckDlgButton(hwnd, id, BST_CHECKED);
243 SetFocus(GetDlgItem(hwnd, id));
244
245 CheckDlgButton(hwnd, IDC_SEPARATE_SUBFOLDERS, separateFolders?BST_CHECKED:BST_UNCHECKED);
246 }
247
248 int MdiSdiDlg::Command(int id, int code)
249 {
250 if (code == BN_CLICKED) {
251 switch(id) {
252 case IDOK: {
253 bool mdi = IsDlgButtonChecked(_hwnd, IDC_MDI)==BST_CHECKED;
254 bool separateFolders = IsDlgButtonChecked(_hwnd, IDC_SEPARATE_SUBFOLDERS)==BST_CHECKED;
255
256 XMLPos explorer_options = g_Globals.get_cfg("general/explorer");
257
258 XMLBoolRef(explorer_options, "mdi") = mdi;
259 XMLBoolRef(explorer_options, "separate-folders") = separateFolders;
260 } // fall through
261
262 case IDCANCEL:
263 EndDialog(_hwnd, id);
264 break;
265 }
266
267 return 0;
268 }
269
270 return 1;
271 }