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