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 RSET_COMBOBOX(__CONTROL_ID, __PARENT_MEMBER, __MEMBER) \ 27 do { \ 28 SendDlgItemMessageW(hwndDlg, __CONTROL_ID, CB_SETCURSEL, (WPARAM)g->SchemeAdv.Effects.__MEMBER, 0); \ 29 EnableWindow(GetDlgItem(hwndDlg, __CONTROL_ID), g->SchemeAdv.Effects.__PARENT_MEMBER); \ 30 } while(0) 31 32 /* Animated menu transitions section (checkbox + combo) */ 33 SAVE_CHECKBOX(IDC_EFFAPPEARANCE_ANIMATION, bMenuAnimation); 34 RSET_COMBOBOX(IDC_EFFAPPEARANCE_ANIMATIONTYPE, bMenuAnimation, bMenuFade); 35 36 /* Font antialiasing section (checkbox + combo) */ 37 SAVE_CHECKBOX(IDC_EFFAPPEARANCE_SMOOTHING, bFontSmoothing); 38 RSET_COMBOBOX(IDC_EFFAPPEARANCE_SMOOTHINGTYPE, bFontSmoothing, uiFontSmoothingType - 1); 39 40 /* Other checkboxes */ 41 SAVE_CHECKBOX(IDC_EFFAPPEARANCE_SETDROPSHADOW, bDropShadow); 42 SAVE_CHECKBOX(IDC_EFFAPPEARANCE_DRAGFULLWINDOWS, bDragFullWindows); 43 SAVE_CHECKBOX(IDC_EFFAPPEARANCE_KEYBOARDCUES, bKeyboardCues); 44 45 #undef SAVE_CHECKBOX 46 #undef RSET_COMBOBOX 47 48 g->bSchemeChanged = TRUE; 49 } 50 51 static VOID 52 EffAppearanceDlgSaveCurrentValues(HWND hwndDlg, GLOBALS *g) 53 { 54 /* The settings get saved at the end of ApplyScheme() in theme.c, 55 * when clicking Apply in the main dialog. */ 56 } 57 58 static VOID 59 AddToCombobox(INT Combo, HWND hwndDlg, INT From, INT To) 60 { 61 INT iElement; 62 TCHAR tstrText[80]; 63 64 for (iElement = From; iElement <= To; iElement++) 65 { 66 LoadString(hApplet, iElement, (LPTSTR)tstrText, ARRAYSIZE(tstrText)); 67 SendDlgItemMessage(hwndDlg, Combo, CB_ADDSTRING, 0, (LPARAM)tstrText); 68 } 69 } 70 71 /* Initialize the effects appearance dialog from the scheme populated in LoadCurrentScheme(), in theme.c */ 72 static VOID 73 EffAppearanceDlg_Init(HWND hwndDlg, GLOBALS *g) 74 { 75 WPARAM state; 76 77 /* Copy the current theme values */ 78 g->SchemeAdv = g->Scheme; 79 80 #define INIT_CHECKBOX(__CONTROL_ID, __MEMBER) \ 81 do { \ 82 state = /* Do a XOR of both the conditions */ \ 83 ((g->SchemeAdv.Effects.__MEMBER) != (__CONTROL_ID == IDC_EFFAPPEARANCE_KEYBOARDCUES)) \ 84 ? BST_CHECKED : BST_UNCHECKED; \ 85 SendDlgItemMessageW(hwndDlg, __CONTROL_ID, BM_SETCHECK, state, 0); \ 86 } while(0) 87 88 #define FILL_COMBOBOX(__CONTROL_ID, __FIRST_STR, __LAST_STR) \ 89 AddToCombobox(__CONTROL_ID, hwndDlg, __FIRST_STR, __LAST_STR) 90 91 /* Animated menu transitions section (checkbox + combo) */ 92 INIT_CHECKBOX(IDC_EFFAPPEARANCE_ANIMATION, bMenuAnimation); 93 FILL_COMBOBOX(IDC_EFFAPPEARANCE_ANIMATIONTYPE, IDS_SLIDEEFFECT, 94 IDS_FADEEFFECT); 95 96 /* Font antialiasing section (checkbox + combo) */ 97 INIT_CHECKBOX(IDC_EFFAPPEARANCE_SMOOTHING, bFontSmoothing); 98 FILL_COMBOBOX(IDC_EFFAPPEARANCE_SMOOTHINGTYPE, IDS_STANDARDEFFECT, 99 IDS_CLEARTYPEEFFECT); 100 101 /* Other checkboxes */ 102 INIT_CHECKBOX(IDC_EFFAPPEARANCE_SETDROPSHADOW, bDropShadow); 103 INIT_CHECKBOX(IDC_EFFAPPEARANCE_DRAGFULLWINDOWS, bDragFullWindows); 104 INIT_CHECKBOX(IDC_EFFAPPEARANCE_KEYBOARDCUES, bKeyboardCues); 105 106 #undef INIT_CHECKBOX 107 #undef FILL_COMBOBOX 108 109 /* Update the controls */ 110 EffAppearanceDlgUpdateControls(hwndDlg, g); 111 } 112 113 INT_PTR CALLBACK 114 EffAppearanceDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) 115 { 116 GLOBALS* g; 117 118 g = (GLOBALS*)GetWindowLongPtr(hwndDlg, DWLP_USER); 119 120 switch (uMsg) 121 { 122 case WM_INITDIALOG: 123 g = (GLOBALS*)lParam; 124 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)g); 125 EffAppearanceDlg_Init(hwndDlg, g); 126 break; 127 128 case WM_DESTROY: 129 break; 130 131 case WM_COMMAND: 132 switch(LOWORD(wParam)) 133 { 134 case IDOK: 135 EffAppearanceDlgSaveCurrentValues(hwndDlg, g); 136 EndDialog(hwndDlg, IDOK); 137 break; 138 139 case IDCANCEL: 140 g->SchemeAdv = g->Scheme; 141 EndDialog(hwndDlg, IDCANCEL); 142 break; 143 144 case IDC_EFFAPPEARANCE_ANIMATION: 145 case IDC_EFFAPPEARANCE_SMOOTHING: 146 case IDC_EFFAPPEARANCE_SETDROPSHADOW: 147 case IDC_EFFAPPEARANCE_DRAGFULLWINDOWS: 148 case IDC_EFFAPPEARANCE_KEYBOARDCUES: 149 if (HIWORD(wParam) == BN_CLICKED) 150 { 151 EffAppearanceDlgUpdateControls(hwndDlg, g); 152 } 153 break; 154 155 case IDC_EFFAPPEARANCE_ANIMATIONTYPE: 156 case IDC_EFFAPPEARANCE_SMOOTHINGTYPE: 157 if (HIWORD(wParam) == CBN_SELCHANGE) 158 { 159 INT Index = 160 SendDlgItemMessageW(hwndDlg, IDC_EFFAPPEARANCE_SMOOTHINGTYPE, 161 CB_GETCURSEL, 0, 0); 162 163 g->SchemeAdv.Effects.bMenuFade = 164 SendDlgItemMessageW(hwndDlg, IDC_EFFAPPEARANCE_ANIMATIONTYPE, 165 CB_GETCURSEL, 0, 0); 166 g->SchemeAdv.Effects.uiFontSmoothingType = (Index == CB_ERR) ? 0 : (Index + 1); 167 168 EffAppearanceDlgUpdateControls(hwndDlg, g); 169 } 170 break; 171 172 default: 173 return FALSE; 174 } 175 break; 176 177 default: 178 return FALSE; 179 } 180 181 return TRUE; 182 } 183