Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygencolors.c
Go to the documentation of this file.
00001 /* 00002 * PROJECT: ReactOS Console Configuration DLL 00003 * LICENSE: GPL - See COPYING in the top level directory 00004 * FILE: dll/win32/console/colors.c 00005 * PURPOSE: displays colors dialog 00006 * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@student.tugraz.at) 00007 */ 00008 00009 #include "console.h" 00010 00011 static 00012 BOOL 00013 PaintStaticControls(HWND hwndDlg, PConsoleInfo pConInfo, LPDRAWITEMSTRUCT drawItem) 00014 { 00015 HBRUSH hBrush; 00016 DWORD index; 00017 00018 index = drawItem->CtlID - IDC_STATIC_COLOR1; 00019 hBrush = CreateSolidBrush(pConInfo->Colors[index]); 00020 if (!hBrush) 00021 { 00022 return FALSE; 00023 } 00024 00025 FillRect(drawItem->hDC, &drawItem->rcItem, hBrush); 00026 DeleteObject((HGDIOBJ)hBrush); 00027 if (pConInfo->ActiveStaticControl == index) 00028 { 00029 DrawFocusRect(drawItem->hDC, &drawItem->rcItem); 00030 } 00031 return TRUE; 00032 } 00033 00034 INT_PTR 00035 CALLBACK 00036 ColorsProc( 00037 HWND hwndDlg, 00038 UINT uMsg, 00039 WPARAM wParam, 00040 LPARAM lParam 00041 ) 00042 { 00043 PConsoleInfo pConInfo; 00044 LPNMUPDOWN lpnmud; 00045 LPPSHNOTIFY lppsn; 00046 LPDRAWITEMSTRUCT drawItem; 00047 DWORD red = MAXDWORD; 00048 DWORD green = MAXDWORD; 00049 DWORD blue = MAXDWORD; 00050 00051 pConInfo = (PConsoleInfo) GetWindowLongPtr(hwndDlg, DWLP_USER); 00052 00053 switch(uMsg) 00054 { 00055 case WM_INITDIALOG: 00056 { 00057 pConInfo = (PConsoleInfo) ((LPPROPSHEETPAGE)lParam)->lParam; 00058 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pConInfo); 00059 SendMessage(GetDlgItem(hwndDlg, IDC_RADIO_SCREEN_BACKGROUND), BM_SETCHECK, BST_CHECKED, 0); 00060 SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_COLOR_RED), UDM_SETRANGE, 0, (LPARAM)MAKELONG(255, 0)); 00061 SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_COLOR_GREEN), UDM_SETRANGE, 0, (LPARAM)MAKELONG(255, 0)); 00062 SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_COLOR_BLUE), UDM_SETRANGE, 0, (LPARAM)MAKELONG(255, 0)); 00063 SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_RED, GetRValue(pConInfo->ScreenBackground), FALSE); 00064 SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_GREEN, GetGValue(pConInfo->ScreenBackground), FALSE); 00065 SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_BLUE, GetBValue(pConInfo->ScreenBackground), FALSE); 00066 CheckRadioButton(hwndDlg, IDC_RADIO_SCREEN_TEXT, IDC_RADIO_POPUP_BACKGROUND, IDC_RADIO_SCREEN_BACKGROUND); 00067 return TRUE; 00068 } 00069 case WM_DRAWITEM: 00070 { 00071 drawItem = (LPDRAWITEMSTRUCT)lParam; 00072 if (drawItem->CtlID >= IDC_STATIC_COLOR1 && drawItem->CtlID <= IDC_STATIC_COLOR16) 00073 { 00074 return PaintStaticControls(hwndDlg, pConInfo, drawItem); 00075 } 00076 else if (drawItem->CtlID == IDC_STATIC_SCREEN_COLOR || drawItem->CtlID == IDC_STATIC_POPUP_COLOR) 00077 { 00078 PaintText(drawItem, pConInfo); 00079 return TRUE; 00080 } 00081 } 00082 case WM_NOTIFY: 00083 { 00084 lpnmud = (LPNMUPDOWN) lParam; 00085 lppsn = (LPPSHNOTIFY) lParam; 00086 00087 if (lppsn->hdr.code == PSN_APPLY) 00088 { 00089 if (!pConInfo->AppliedConfig) 00090 { 00091 ApplyConsoleInfo(hwndDlg, pConInfo); 00092 } 00093 else 00094 { 00095 /* Options have already been applied */ 00096 SetWindowLongPtr(hwndDlg, DWL_MSGRESULT, PSNRET_NOERROR); 00097 return TRUE; 00098 } 00099 return TRUE; 00100 } 00101 00102 if (lpnmud->hdr.idFrom == IDC_UPDOWN_COLOR_RED) 00103 { 00104 red = lpnmud->iPos; 00105 } 00106 else if (lpnmud->hdr.idFrom == IDC_UPDOWN_COLOR_GREEN) 00107 { 00108 green = lpnmud->iPos; 00109 } 00110 else if (lpnmud->hdr.idFrom == IDC_UPDOWN_COLOR_BLUE) 00111 { 00112 blue = lpnmud->iPos; 00113 } 00114 else 00115 { 00116 break; 00117 } 00118 00119 if (red == MAXDWORD) 00120 { 00121 red = SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_COLOR_RED), UDM_GETPOS, 0, 0); 00122 if (HIWORD(red)) 00123 { 00124 // TODO: Handle error 00125 break; 00126 } 00127 red = LOBYTE(red); 00128 } 00129 00130 if (green == MAXDWORD) 00131 { 00132 green = SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_COLOR_GREEN), UDM_GETPOS, 0, 0); 00133 if (HIWORD(green)) 00134 { 00135 // TODO: Handle error 00136 break; 00137 } 00138 green = LOBYTE(green); 00139 } 00140 00141 if (blue == MAXDWORD) 00142 { 00143 blue = SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_COLOR_BLUE), UDM_GETPOS, 0, 0); 00144 if (HIWORD(blue)) 00145 { 00146 // TODO: Handle error 00147 break; 00148 } 00149 blue = LOBYTE(blue); 00150 } 00151 pConInfo->Colors[pConInfo->ActiveStaticControl] = RGB(red, green, blue); 00152 InvalidateRect(GetDlgItem(hwndDlg, IDC_STATIC_COLOR1 + pConInfo->ActiveStaticControl), NULL, TRUE); 00153 InvalidateRect(GetDlgItem(hwndDlg, IDC_STATIC_SCREEN_COLOR), NULL, TRUE); 00154 InvalidateRect(GetDlgItem(hwndDlg, IDC_STATIC_POPUP_COLOR), NULL, TRUE); 00155 break; 00156 } 00157 case WM_COMMAND: 00158 { 00159 switch(LOWORD(wParam)) 00160 { 00161 case IDC_RADIO_SCREEN_TEXT: 00162 { 00163 SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_RED, GetRValue(pConInfo->ScreenText), FALSE); 00164 SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_GREEN, GetGValue(pConInfo->ScreenText), FALSE); 00165 SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_BLUE, GetBValue(pConInfo->ScreenText), FALSE); 00166 InvalidateRect(GetDlgItem(hwndDlg, IDC_STATIC_SCREEN_COLOR), NULL, TRUE); 00167 InvalidateRect(GetDlgItem(hwndDlg, IDC_STATIC_POPUP_COLOR), NULL, TRUE); 00168 break; 00169 } 00170 case IDC_RADIO_SCREEN_BACKGROUND: 00171 { 00172 SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_RED, GetRValue(pConInfo->ScreenBackground), FALSE); 00173 SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_GREEN, GetGValue(pConInfo->ScreenBackground), FALSE); 00174 SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_BLUE, GetBValue(pConInfo->ScreenBackground), FALSE); 00175 InvalidateRect(GetDlgItem(hwndDlg, IDC_STATIC_SCREEN_COLOR), NULL, TRUE); 00176 InvalidateRect(GetDlgItem(hwndDlg, IDC_STATIC_POPUP_COLOR), NULL, TRUE); 00177 break; 00178 } 00179 case IDC_RADIO_POPUP_TEXT: 00180 { 00181 SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_RED, GetRValue(pConInfo->PopupText), FALSE); 00182 SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_GREEN, GetGValue(pConInfo->PopupText), FALSE); 00183 SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_BLUE, GetBValue(pConInfo->PopupText), FALSE); 00184 InvalidateRect(GetDlgItem(hwndDlg, IDC_STATIC_SCREEN_COLOR), NULL, TRUE); 00185 InvalidateRect(GetDlgItem(hwndDlg, IDC_STATIC_POPUP_COLOR), NULL, TRUE); 00186 break; 00187 } 00188 case IDC_RADIO_POPUP_BACKGROUND: 00189 { 00190 SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_RED, GetRValue(pConInfo->PopupBackground), FALSE); 00191 SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_GREEN, GetGValue(pConInfo->PopupBackground), FALSE); 00192 SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_BLUE, GetBValue(pConInfo->PopupBackground), FALSE); 00193 InvalidateRect(GetDlgItem(hwndDlg, IDC_STATIC_SCREEN_COLOR), NULL, TRUE); 00194 InvalidateRect(GetDlgItem(hwndDlg, IDC_STATIC_POPUP_COLOR), NULL, TRUE); 00195 break; 00196 } 00197 } 00198 if (HIWORD(wParam) == STN_CLICKED && LOWORD(wParam) >= IDC_STATIC_COLOR1 && LOWORD(wParam) <= IDC_STATIC_COLOR16) 00199 { 00200 DWORD index = LOWORD(wParam) - IDC_STATIC_COLOR1; 00201 00202 if (index == pConInfo->ActiveStaticControl) 00203 { 00204 /* Same static control was re-clicked */ 00205 break; 00206 } 00207 00208 SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_RED, GetRValue(pConInfo->Colors[index]), FALSE); 00209 SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_GREEN, GetGValue(pConInfo->Colors[index]), FALSE); 00210 SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_BLUE, GetBValue(pConInfo->Colors[index]), FALSE); 00211 00212 /* Update global struct */ 00213 if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_SCREEN_TEXT)) 00214 { 00215 pConInfo->ScreenText = pConInfo->Colors[index]; 00216 } 00217 else if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_SCREEN_BACKGROUND)) 00218 { 00219 pConInfo->ScreenBackground = pConInfo->Colors[index]; 00220 } 00221 else if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_POPUP_TEXT)) 00222 { 00223 pConInfo->PopupText = pConInfo->Colors[index]; 00224 } 00225 else if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_POPUP_BACKGROUND)) 00226 { 00227 pConInfo->PopupBackground = pConInfo->Colors[index]; 00228 } 00229 InvalidateRect(GetDlgItem(hwndDlg, IDC_STATIC_COLOR1 + pConInfo->ActiveStaticControl), NULL, TRUE); 00230 InvalidateRect(GetDlgItem(hwndDlg, IDC_STATIC_COLOR1 + index), NULL, TRUE); 00231 InvalidateRect(GetDlgItem(hwndDlg, IDC_STATIC_SCREEN_COLOR), NULL, TRUE); 00232 InvalidateRect(GetDlgItem(hwndDlg, IDC_STATIC_POPUP_COLOR), NULL, TRUE); 00233 pConInfo->ActiveStaticControl = index; 00234 PropSheet_Changed(GetParent(hwndDlg), hwndDlg); 00235 break; 00236 } 00237 } 00238 00239 default: 00240 break; 00241 } 00242 00243 return FALSE; 00244 } Generated on Fri May 25 2012 04:18:59 for ReactOS by
1.7.6.1
|