1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Display Control Panel
4 * PURPOSE: Effects appearance dialog
5 * PROGRAMMERS: Jan Roeloffzen <jroeloffzen@hotmail.com>
6 * Ismael Ferreras Morezuelas <swyterzone+reactos@gmail.com>
7 */
8
9 #include "desk.h"
10
11 /* Update all the controls with the current values for the selected screen element */
12 static VOID
EffAppearanceDlgUpdateControls(HWND hwndDlg,GLOBALS * g)13 EffAppearanceDlgUpdateControls(HWND hwndDlg, GLOBALS *g)
14 {
15 WPARAM state;
16
17 #define SAVE_CHECKBOX(__CONTROL_ID, __MEMBER) \
18 do { \
19 state = SendDlgItemMessageW(hwndDlg, __CONTROL_ID, BM_GETCHECK, 0, 0); \
20 g->SchemeAdv.Effects.__MEMBER = /* Do a XOR of both the conditions */ \
21 ((state == BST_CHECKED) != (__CONTROL_ID == IDC_EFFAPPEARANCE_KEYBOARDCUES)); \
22 } while(0)
23
24 #define SAVE_CHECKBOX_SCH(__CONTROL_ID, __MEMBER) \
25 do { \
26 state = SendDlgItemMessageW(hwndDlg, __CONTROL_ID, BM_GETCHECK, 0, 0); \
27 g->SchemeAdv.__MEMBER = (state == BST_CHECKED); \
28 } while(0)
29
30 #define RSET_COMBOBOX(__CONTROL_ID, __PARENT_MEMBER, __MEMBER) \
31 do { \
32 SendDlgItemMessageW(hwndDlg, __CONTROL_ID, CB_SETCURSEL, (WPARAM)g->SchemeAdv.Effects.__MEMBER, 0); \
33 EnableWindow(GetDlgItem(hwndDlg, __CONTROL_ID), g->SchemeAdv.Effects.__PARENT_MEMBER); \
34 } while(0)
35
36 /* Animated menu transitions section (checkbox + combo) */
37 SAVE_CHECKBOX(IDC_EFFAPPEARANCE_ANIMATION, bMenuAnimation);
38 RSET_COMBOBOX(IDC_EFFAPPEARANCE_ANIMATIONTYPE, bMenuAnimation, bMenuFade);
39
40 /* Font antialiasing section (checkbox + combo) */
41 SAVE_CHECKBOX(IDC_EFFAPPEARANCE_SMOOTHING, bFontSmoothing);
42 RSET_COMBOBOX(IDC_EFFAPPEARANCE_SMOOTHINGTYPE, bFontSmoothing, uiFontSmoothingType - 1);
43
44 /* Other checkboxes */
45 SAVE_CHECKBOX(IDC_EFFAPPEARANCE_SETDROPSHADOW, bDropShadow);
46 SAVE_CHECKBOX(IDC_EFFAPPEARANCE_DRAGFULLWINDOWS, bDragFullWindows);
47 SAVE_CHECKBOX(IDC_EFFAPPEARANCE_KEYBOARDCUES, bKeyboardCues);
48 SAVE_CHECKBOX_SCH(IDC_EFFAPPEARANCE_FLATMENUS, bFlatMenus);
49
50 #undef SAVE_CHECKBOX
51 #undef RSET_COMBOBOX
52
53 g->bSchemeChanged = TRUE;
54 }
55
56 static VOID
EffAppearanceDlgSaveCurrentValues(HWND hwndDlg,GLOBALS * g)57 EffAppearanceDlgSaveCurrentValues(HWND hwndDlg, GLOBALS *g)
58 {
59 /* The settings get saved at the end of ApplyScheme() in theme.c,
60 * when clicking Apply in the main dialog. */
61 }
62
63 static VOID
AddToCombobox(INT Combo,HWND hwndDlg,INT From,INT To)64 AddToCombobox(INT Combo, HWND hwndDlg, INT From, INT To)
65 {
66 INT iElement;
67 TCHAR tstrText[80];
68
69 for (iElement = From; iElement <= To; iElement++)
70 {
71 LoadString(hApplet, iElement, (LPTSTR)tstrText, _countof(tstrText));
72 SendDlgItemMessage(hwndDlg, Combo, CB_ADDSTRING, 0, (LPARAM)tstrText);
73 }
74 }
75
76 /* Initialize the effects appearance dialog from the scheme populated in LoadCurrentScheme(), in theme.c */
77 static VOID
EffAppearanceDlg_Init(HWND hwndDlg,GLOBALS * g)78 EffAppearanceDlg_Init(HWND hwndDlg, GLOBALS *g)
79 {
80 WPARAM state;
81
82 /* Copy the current theme values */
83 g->SchemeAdv = g->Scheme;
84
85 #define INIT_CHECKBOX(__CONTROL_ID, __MEMBER) \
86 do { \
87 state = /* Do a XOR of both the conditions */ \
88 ((g->SchemeAdv.Effects.__MEMBER) != (__CONTROL_ID == IDC_EFFAPPEARANCE_KEYBOARDCUES)) \
89 ? BST_CHECKED : BST_UNCHECKED; \
90 SendDlgItemMessageW(hwndDlg, __CONTROL_ID, BM_SETCHECK, state, 0); \
91 } while(0)
92
93 #define INIT_CHECKBOX_SCH(__CONTROL_ID, __MEMBER) \
94 do { \
95 state = /* Do a XOR of both the conditions */ \
96 ((g->SchemeAdv.__MEMBER) == TRUE) \
97 ? BST_CHECKED : BST_UNCHECKED; \
98 SendDlgItemMessageW(hwndDlg, __CONTROL_ID, BM_SETCHECK, state, 0); \
99 } while(0)
100
101 #define FILL_COMBOBOX(__CONTROL_ID, __FIRST_STR, __LAST_STR) \
102 AddToCombobox(__CONTROL_ID, hwndDlg, __FIRST_STR, __LAST_STR)
103
104 /* Animated menu transitions section (checkbox + combo) */
105 INIT_CHECKBOX(IDC_EFFAPPEARANCE_ANIMATION, bMenuAnimation);
106 FILL_COMBOBOX(IDC_EFFAPPEARANCE_ANIMATIONTYPE, IDS_SLIDEEFFECT,
107 IDS_FADEEFFECT);
108
109 /* Font antialiasing section (checkbox + combo) */
110 INIT_CHECKBOX(IDC_EFFAPPEARANCE_SMOOTHING, bFontSmoothing);
111 FILL_COMBOBOX(IDC_EFFAPPEARANCE_SMOOTHINGTYPE, IDS_STANDARDEFFECT,
112 IDS_CLEARTYPEEFFECT);
113
114 /* Other checkboxes */
115 INIT_CHECKBOX(IDC_EFFAPPEARANCE_SETDROPSHADOW, bDropShadow);
116 INIT_CHECKBOX(IDC_EFFAPPEARANCE_DRAGFULLWINDOWS, bDragFullWindows);
117 INIT_CHECKBOX(IDC_EFFAPPEARANCE_KEYBOARDCUES, bKeyboardCues);
118 INIT_CHECKBOX_SCH(IDC_EFFAPPEARANCE_FLATMENUS, bFlatMenus);
119
120 #undef INIT_CHECKBOX
121 #undef FILL_COMBOBOX
122
123 /* Update the controls */
124 EffAppearanceDlgUpdateControls(hwndDlg, g);
125 }
126
127 INT_PTR CALLBACK
EffAppearanceDlgProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)128 EffAppearanceDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
129 {
130 GLOBALS* g;
131
132 g = (GLOBALS*)GetWindowLongPtr(hwndDlg, DWLP_USER);
133
134 switch (uMsg)
135 {
136 case WM_INITDIALOG:
137 g = (GLOBALS*)lParam;
138 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)g);
139 EffAppearanceDlg_Init(hwndDlg, g);
140 break;
141
142 case WM_DESTROY:
143 break;
144
145 case WM_COMMAND:
146 switch(LOWORD(wParam))
147 {
148 case IDOK:
149 EffAppearanceDlgSaveCurrentValues(hwndDlg, g);
150 EndDialog(hwndDlg, IDOK);
151 break;
152
153 case IDCANCEL:
154 g->SchemeAdv = g->Scheme;
155 EndDialog(hwndDlg, IDCANCEL);
156 break;
157
158 case IDC_EFFAPPEARANCE_ANIMATION:
159 case IDC_EFFAPPEARANCE_SMOOTHING:
160 case IDC_EFFAPPEARANCE_SETDROPSHADOW:
161 case IDC_EFFAPPEARANCE_DRAGFULLWINDOWS:
162 case IDC_EFFAPPEARANCE_KEYBOARDCUES:
163 case IDC_EFFAPPEARANCE_FLATMENUS:
164 if (HIWORD(wParam) == BN_CLICKED)
165 EffAppearanceDlgUpdateControls(hwndDlg, g);
166 break;
167
168 case IDC_EFFAPPEARANCE_ANIMATIONTYPE:
169 case IDC_EFFAPPEARANCE_SMOOTHINGTYPE:
170 if (HIWORD(wParam) == CBN_SELCHANGE)
171 {
172 INT Index =
173 SendDlgItemMessageW(hwndDlg, IDC_EFFAPPEARANCE_SMOOTHINGTYPE,
174 CB_GETCURSEL, 0, 0);
175
176 g->SchemeAdv.Effects.bMenuFade =
177 SendDlgItemMessageW(hwndDlg, IDC_EFFAPPEARANCE_ANIMATIONTYPE,
178 CB_GETCURSEL, 0, 0);
179 g->SchemeAdv.Effects.uiFontSmoothingType = (Index == CB_ERR) ? 0 : (Index + 1);
180
181 EffAppearanceDlgUpdateControls(hwndDlg, g);
182 }
183 break;
184
185 default:
186 return FALSE;
187 }
188 break;
189
190 default:
191 return FALSE;
192 }
193
194 return TRUE;
195 }
196