3e9c23429e4c47284a8abb1e558a38797c149223
[reactos.git] / reactos / base / shell / explorer / 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 "../resource.h"
34
35 #include "../taskbar/traynotify.h"
36 #include "settings.h"
37
38
39 void ExplorerPropertySheet(HWND hparent)
40 {
41 PropertySheetDialog ps(hparent);
42
43 ps.dwFlags |= PSH_USEICONID | PSH_PROPTITLE;
44 ps.pszIcon = MAKEINTRESOURCE(IDI_REACTOS);
45 ps.pszCaption = TEXT("Explorer");
46
47 PropSheetPage psp1(IDD_DESKBAR_DESKTOP, WINDOW_CREATOR(DesktopSettingsDlg));
48 psp1.dwFlags |= PSP_USETITLE;
49 psp1.pszTitle = MAKEINTRESOURCE(IDS_DESKTOP);
50 ps.add(psp1);
51
52 PropSheetPage psp2(IDD_DESKBAR_TASKBAR, WINDOW_CREATOR(TaskbarSettingsDlg));
53 psp2.dwFlags |= PSP_USETITLE;
54 psp2.pszTitle = MAKEINTRESOURCE(IDS_TASKBAR);
55 ps.add(psp2);
56
57 PropSheetPage psp3(IDD_DESKBAR_STARTMENU, WINDOW_CREATOR(StartmenuSettingsDlg));
58 psp3.dwFlags |= PSP_USETITLE;
59 psp3.pszTitle = MAKEINTRESOURCE(IDS_STARTMENU);
60 ps.add(psp3);
61
62 ps.DoModal();
63 }
64
65
66 DesktopSettingsDlg::DesktopSettingsDlg(HWND hwnd)
67 : super(hwnd),
68 _bmp0(IDB_ICON_ALIGN_0),
69 _bmp1(IDB_ICON_ALIGN_1),
70 _bmp2(IDB_ICON_ALIGN_2),
71 _bmp3(IDB_ICON_ALIGN_3),
72 _bmp4(IDB_ICON_ALIGN_4),
73 _bmp5(IDB_ICON_ALIGN_5),
74 _bmp6(IDB_ICON_ALIGN_6),
75 _bmp7(IDB_ICON_ALIGN_7),
76 _bmp8(IDB_ICON_ALIGN_8),
77 _bmp9(IDB_ICON_ALIGN_9),
78 _bmp10(IDB_ICON_ALIGN_10)
79 {
80 new PictureButton(_hwnd, IDC_ICON_ALIGN_0, _bmp0);
81 new PictureButton(_hwnd, IDC_ICON_ALIGN_1, _bmp1);
82 new PictureButton(_hwnd, IDC_ICON_ALIGN_2, _bmp2);
83 new PictureButton(_hwnd, IDC_ICON_ALIGN_3, _bmp3);
84 new PictureButton(_hwnd, IDC_ICON_ALIGN_4, _bmp4);
85 new PictureButton(_hwnd, IDC_ICON_ALIGN_5, _bmp5);
86 new PictureButton(_hwnd, IDC_ICON_ALIGN_6, _bmp6);
87 new PictureButton(_hwnd, IDC_ICON_ALIGN_7, _bmp7);
88 new PictureButton(_hwnd, IDC_ICON_ALIGN_8, _bmp8);
89 new PictureButton(_hwnd, IDC_ICON_ALIGN_9, _bmp9);
90 new PictureButton(_hwnd, IDC_ICON_ALIGN_10, _bmp10);
91
92 _alignment_cur = SendMessage(g_Globals._hwndShellView, PM_GET_ICON_ALGORITHM, 0, 0);
93 _alignment_tmp = _alignment_cur;
94
95 _display_version_org = SendMessage(g_Globals._hwndShellView, PM_DISPLAY_VERSION, 0, MAKELONG(0,0));
96 CheckDlgButton(hwnd, ID_DESKTOP_VERSION, _display_version_org? BST_CHECKED: BST_UNCHECKED);
97 }
98
99 #ifndef PSN_QUERYINITIALFOCUS // currently (as of 18.01.2004) missing in MinGW headers
100 #define PSN_QUERYINITIALFOCUS (-213)
101 #endif
102
103 int DesktopSettingsDlg::Notify(int id, NMHDR* pnmh)
104 {
105 switch(pnmh->code) {
106 case PSN_QUERYINITIALFOCUS:
107 SetWindowLongPtr(_hwnd, DWL_MSGRESULT, (LPARAM)GetDlgItem(_hwnd, IDC_ICON_ALIGN_0+_alignment_cur));
108 break;
109
110 case PSN_APPLY:
111 _alignment_cur = _alignment_tmp;
112 _display_version_org = SendMessage(g_Globals._hwndShellView, PM_DISPLAY_VERSION, 0, MAKELONG(0,0));
113 break;
114
115 case PSN_RESET:
116 if (_alignment_tmp != _alignment_cur)
117 SendMessage(g_Globals._hwndShellView, PM_SET_ICON_ALGORITHM, _alignment_cur, 0);
118 SendMessage(g_Globals._hwndShellView, PM_DISPLAY_VERSION, _display_version_org, MAKELONG(1,0));
119 break;
120
121 default:
122 return super::Notify(id, pnmh);
123 }
124
125 return 0;
126 }
127
128 int DesktopSettingsDlg::Command(int id, int code)
129 {
130 if (id>=IDC_ICON_ALIGN_0 && id<=IDC_ICON_ALIGN_10) {
131 int alignment = id - IDC_ICON_ALIGN_0;
132
133 if (alignment != _alignment_tmp) {
134 _alignment_tmp = alignment;
135
136 PropSheet_Changed(GetParent(_hwnd), _hwnd);
137
138 SendMessage(g_Globals._hwndShellView, PM_SET_ICON_ALGORITHM, alignment, 0);
139 }
140
141 return 0;
142 }
143
144 switch(id) {
145 case ID_DESKTOP_VERSION:
146 SendMessage(g_Globals._hwndShellView, PM_DISPLAY_VERSION, 0, MAKELONG(0,1)); // toggle version display flag
147 PropSheet_Changed(GetParent(_hwnd), _hwnd);
148 break;
149
150 default:
151 return 1;
152 }
153
154 return 0;
155 }
156
157
158 TaskbarSettingsDlg::TaskbarSettingsDlg(HWND hwnd)
159 : super(hwnd),
160 _cfg_org(g_Globals._cfg)
161 {
162 XMLPos options = g_Globals.get_cfg("desktopbar/options");
163
164 CheckDlgButton(hwnd, ID_SHOW_CLOCK, XMLBool(options, "show-clock", true)? BST_CHECKED: BST_UNCHECKED);
165 CheckDlgButton(hwnd, ID_HIDE_INACTIVE_ICONS, XMLBool(options, "hide-inactive", true)? BST_CHECKED: BST_UNCHECKED);
166 }
167
168 int TaskbarSettingsDlg::Notify(int id, NMHDR* pnmh)
169 {
170 switch(pnmh->code) {
171 case PSN_APPLY:
172 _cfg_org = g_Globals._cfg;
173 break;
174
175 case PSN_RESET:
176 g_Globals._cfg = _cfg_org;
177 SendMessage(g_Globals._hwndDesktopBar, PM_REFRESH_CONFIG, 0, 0);
178 break;
179
180 default:
181 return super::Notify(id, pnmh);
182 }
183
184 return 0;
185 }
186
187 int TaskbarSettingsDlg::Command(int id, int code)
188 {
189 switch(id) {
190 case ID_CONFIG_NOTIFYAREA:
191 Dialog::DoModal(IDD_NOTIFYAREA, WINDOW_CREATOR(TrayNotifyDlg), _hwnd);
192 break;
193
194 case ID_SHOW_CLOCK: {
195 XMLBoolRef boolRef1(XMLPos(g_Globals.get_cfg("desktopbar/options")), "show-clock", true);
196 boolRef1.toggle();
197 SendMessage(g_Globals._hwndDesktopBar, PM_REFRESH_CONFIG, 0, 0);
198 PropSheet_Changed(GetParent(_hwnd), _hwnd);
199 break;}
200
201 case ID_HIDE_INACTIVE_ICONS: {
202 XMLBoolRef boolRef2(XMLPos(g_Globals.get_cfg("notify-icons/options")), "hide-inactive", true);
203 boolRef2.toggle();
204 SendMessage(g_Globals._hwndDesktopBar, PM_REFRESH_CONFIG, 0, 0);
205 PropSheet_Changed(GetParent(_hwnd), _hwnd);
206 break;}
207
208 default:
209 return 1;
210 }
211
212 return 0;
213 }
214
215
216 StartmenuSettingsDlg::StartmenuSettingsDlg(HWND hwnd)
217 : super(hwnd)
218 {
219 }
220
221 int StartmenuSettingsDlg::Command(int id, int code)
222 {
223 /*
224 switch(id) {
225 case ID_CONFIG_NOTIFYAREA:
226 Dialog::DoModal(IDD_NOTIFYAREA, WINDOW_CREATOR(TrayNotifyDlg), _hwnd);
227 return 0;
228 }
229 */
230 return 1;
231 }
232
233
234 MdiSdiDlg::MdiSdiDlg(HWND hwnd)
235 : super(hwnd)
236 {
237 CenterWindow(hwnd);
238
239 XMLPos explorer_options = g_Globals.get_cfg("general/explorer");
240 bool mdi = XMLBool(explorer_options, "mdi", true);
241 bool separateFolders = XMLBool(explorer_options, "separate-folders", true);
242
243 int id = mdi? IDC_MDI: IDC_SDI;
244 CheckDlgButton(hwnd, id, BST_CHECKED);
245 SetFocus(GetDlgItem(hwnd, id));
246
247 CheckDlgButton(hwnd, IDC_SEPARATE_SUBFOLDERS, separateFolders?BST_CHECKED:BST_UNCHECKED);
248 }
249
250 int MdiSdiDlg::Command(int id, int code)
251 {
252 if (code == BN_CLICKED) {
253 switch(id) {
254 case IDOK: {
255 bool mdi = IsDlgButtonChecked(_hwnd, IDC_MDI)==BST_CHECKED;
256 bool separateFolders = IsDlgButtonChecked(_hwnd, IDC_SEPARATE_SUBFOLDERS)==BST_CHECKED;
257
258 XMLPos explorer_options = g_Globals.get_cfg("general/explorer");
259
260 XMLBoolRef(explorer_options, "mdi") = mdi;
261 XMLBoolRef(explorer_options, "separate-folders") = separateFolders;
262 } // fall through
263
264 case IDCANCEL:
265 EndDialog(_hwnd, id);
266 break;
267 }
268
269 return 0;
270 }
271
272 return 1;
273 }