Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenlayout.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/layout.c 00005 * PURPOSE: displays layout dialog 00006 * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@student.tugraz.at) 00007 */ 00008 00009 #include "console.h" 00010 00011 00012 void PaintConsole(LPDRAWITEMSTRUCT drawItem, PConsoleInfo pConInfo) 00013 { 00014 HBRUSH hBrush; 00015 RECT cRect, fRect; 00016 DWORD startx, starty; 00017 DWORD endx, endy; 00018 DWORD sizex, sizey; 00019 00020 FillRect(drawItem->hDC, &drawItem->rcItem, GetSysColorBrush(COLOR_BACKGROUND)); 00021 00022 sizex = drawItem->rcItem.right - drawItem->rcItem.left; 00023 sizey = drawItem->rcItem.bottom - drawItem->rcItem.top; 00024 00025 if (pConInfo->WindowPosition == UINT_MAX) 00026 { 00027 startx = sizex / 3; 00028 starty = sizey / 3; 00029 } 00030 else 00031 { 00032 // TODO: 00033 // Calculate pos correctly when console centered 00034 startx = sizex / 3; 00035 starty = sizey / 3; 00036 } 00037 00038 // TODO: 00039 // Strech console when bold fonts are selected 00040 endx = drawItem->rcItem.right - startx + 15; 00041 endy = starty + sizey / 3; 00042 00043 /* Draw console size */ 00044 SetRect(&cRect, startx, starty, endx, endy); 00045 FillRect(drawItem->hDC, &cRect, GetSysColorBrush(COLOR_WINDOWFRAME)); 00046 00047 /* Draw console border */ 00048 SetRect(&fRect, startx + 1, starty + 1, cRect.right - 1, cRect.bottom - 1); 00049 FrameRect(drawItem->hDC, &fRect, GetSysColorBrush(COLOR_ACTIVEBORDER)); 00050 00051 /* Draw left box */ 00052 SetRect(&fRect, startx + 3, starty + 3, startx + 5, starty + 5); 00053 FillRect(drawItem->hDC, &fRect, GetSysColorBrush(COLOR_ACTIVEBORDER)); 00054 00055 /* Draw window title */ 00056 SetRect(&fRect, startx + 7, starty + 3, cRect.right - 9, starty + 5); 00057 FillRect(drawItem->hDC, &fRect, GetSysColorBrush(COLOR_ACTIVECAPTION)); 00058 00059 /* Draw first right box */ 00060 SetRect(&fRect, fRect.right + 1, starty + 3, fRect.right + 3, starty + 5); 00061 FillRect(drawItem->hDC, &fRect, GetSysColorBrush(COLOR_ACTIVEBORDER)); 00062 00063 /* Draw second right box */ 00064 SetRect(&fRect, fRect.right + 1, starty + 3, fRect.right + 3, starty + 5); 00065 FillRect(drawItem->hDC, &fRect, GetSysColorBrush(COLOR_ACTIVEBORDER)); 00066 00067 /* Draw scrollbar */ 00068 SetRect(&fRect, cRect.right - 5, fRect.bottom + 1, cRect.right - 3, cRect.bottom - 3); 00069 FillRect(drawItem->hDC, &fRect, GetSysColorBrush(COLOR_SCROLLBAR)); 00070 00071 /* Draw console background */ 00072 hBrush = CreateSolidBrush(pConInfo->ScreenBackground); 00073 SetRect(&fRect, startx + 3, starty + 6, cRect.right - 6, cRect.bottom - 3); 00074 FillRect(drawItem->hDC, &fRect, hBrush); 00075 DeleteObject((HGDIOBJ)hBrush); 00076 } 00077 00078 void PaintText(LPDRAWITEMSTRUCT drawItem, PConsoleInfo pConInfo) 00079 { 00080 COLORREF pbkColor, ptColor; 00081 COLORREF nbkColor, ntColor; 00082 HBRUSH hBrush = NULL; 00083 TCHAR szText[1024]; 00084 00085 ZeroMemory(szText, sizeof(szText)); 00086 LoadString(hApplet, IDS_SCREEN_TEXT, szText, sizeof(szText) / sizeof(TCHAR)); 00087 00088 if (drawItem->CtlID == IDC_STATIC_SCREEN_COLOR) 00089 { 00090 nbkColor = pConInfo->ScreenBackground; 00091 hBrush = CreateSolidBrush(nbkColor); 00092 ntColor = pConInfo->ScreenText; 00093 } 00094 else if (drawItem->CtlID == IDC_STATIC_POPUP_COLOR) 00095 { 00096 nbkColor = pConInfo->PopupBackground; 00097 hBrush = CreateSolidBrush(nbkColor); 00098 ntColor = pConInfo->PopupText; 00099 } 00100 00101 if (!hBrush) 00102 { 00103 return; 00104 } 00105 00106 FillRect(drawItem->hDC, &drawItem->rcItem, hBrush); 00107 if (ntColor == nbkColor) 00108 { 00109 /* Text has same color -> invisible */ 00110 return; 00111 } 00112 00113 ptColor = SetTextColor(drawItem->hDC, ntColor); 00114 pbkColor = SetBkColor(drawItem->hDC, nbkColor); 00115 DrawText(drawItem->hDC, szText, _tcslen(szText), &drawItem->rcItem, 0); 00116 SetTextColor(drawItem->hDC, ptColor); 00117 SetBkColor(drawItem->hDC, pbkColor); 00118 DeleteObject((HGDIOBJ)hBrush); 00119 } 00120 00121 00122 INT_PTR 00123 CALLBACK 00124 LayoutProc( 00125 HWND hwndDlg, 00126 UINT uMsg, 00127 WPARAM wParam, 00128 LPARAM lParam 00129 ) 00130 { 00131 LPNMUPDOWN lpnmud; 00132 LPPSHNOTIFY lppsn; 00133 PConsoleInfo pConInfo = (PConsoleInfo)GetWindowLongPtr(hwndDlg, DWLP_USER); 00134 00135 UNREFERENCED_PARAMETER(hwndDlg); 00136 UNREFERENCED_PARAMETER(wParam); 00137 00138 switch(uMsg) 00139 { 00140 case WM_INITDIALOG: 00141 { 00142 DWORD xres, yres; 00143 HDC hDC; 00144 pConInfo = (PConsoleInfo) ((LPPROPSHEETPAGE)lParam)->lParam; 00145 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pConInfo); 00146 SetDlgItemInt(hwndDlg, IDC_EDIT_SCREEN_BUFFER_HEIGHT, HIWORD(pConInfo->ScreenBuffer), FALSE); 00147 SetDlgItemInt(hwndDlg, IDC_EDIT_SCREEN_BUFFER_WIDTH, LOWORD(pConInfo->ScreenBuffer), FALSE); 00148 SetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_SIZE_HEIGHT, HIWORD(pConInfo->WindowSize), FALSE); 00149 SetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_SIZE_WIDTH, LOWORD(pConInfo->WindowSize), FALSE); 00150 SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_SCREEN_BUFFER_HEIGHT), UDM_SETRANGE, 0, (LPARAM)MAKELONG(9999, 1)); 00151 SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_SCREEN_BUFFER_WIDTH), UDM_SETRANGE, 0, (LPARAM)MAKELONG(9999, 1)); 00152 SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_WINDOW_SIZE_HEIGHT), UDM_SETRANGE, 0, (LPARAM)MAKELONG(9999, 1)); 00153 SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_WINDOW_SIZE_WIDTH), UDM_SETRANGE, 0, (LPARAM)MAKELONG(9999, 1)); 00154 00155 hDC = GetDC(NULL); 00156 xres = GetDeviceCaps(hDC, HORZRES); 00157 yres = GetDeviceCaps(hDC, VERTRES); 00158 SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_WINDOW_POS_LEFT), UDM_SETRANGE, 0, (LPARAM)MAKELONG(xres, 0)); 00159 SendMessage(GetDlgItem(hwndDlg, IDC_UPDOWN_WINDOW_POS_TOP), UDM_SETRANGE, 0, (LPARAM)MAKELONG(yres, 0)); 00160 00161 if (pConInfo->WindowPosition != MAXDWORD) 00162 { 00163 SetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_POS_LEFT, LOWORD(pConInfo->WindowPosition), FALSE); 00164 SetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_POS_TOP, HIWORD(pConInfo->WindowPosition), FALSE); 00165 } 00166 else 00167 { 00168 // FIXME: Calculate window pos from xres, yres 00169 SetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_POS_LEFT, 88, FALSE); 00170 SetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_POS_TOP, 88, FALSE); 00171 EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_WINDOW_POS_LEFT), FALSE); 00172 EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_WINDOW_POS_TOP), FALSE); 00173 EnableWindow(GetDlgItem(hwndDlg, IDC_UPDOWN_WINDOW_POS_LEFT), FALSE); 00174 EnableWindow(GetDlgItem(hwndDlg, IDC_UPDOWN_WINDOW_POS_TOP), FALSE); 00175 SendMessage(GetDlgItem(hwndDlg, IDC_CHECK_SYSTEM_POS_WINDOW), BM_SETCHECK, (WPARAM)BST_CHECKED, 0); 00176 } 00177 00178 return TRUE; 00179 } 00180 case WM_DRAWITEM: 00181 { 00182 PaintConsole((LPDRAWITEMSTRUCT)lParam, pConInfo); 00183 return TRUE; 00184 } 00185 case WM_NOTIFY: 00186 { 00187 lpnmud = (LPNMUPDOWN) lParam; 00188 lppsn = (LPPSHNOTIFY) lParam; 00189 00190 if (lppsn->hdr.code == UDN_DELTAPOS) 00191 { 00192 DWORD wheight, wwidth; 00193 DWORD sheight, swidth; 00194 DWORD left, top; 00195 00196 if (lppsn->hdr.idFrom == IDC_UPDOWN_WINDOW_SIZE_WIDTH) 00197 { 00198 wwidth = lpnmud->iPos + lpnmud->iDelta; 00199 } 00200 else 00201 { 00202 wwidth = GetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_SIZE_WIDTH, NULL, FALSE); 00203 } 00204 00205 if (lppsn->hdr.idFrom == IDC_UPDOWN_WINDOW_SIZE_HEIGHT) 00206 { 00207 wheight = lpnmud->iPos + lpnmud->iDelta; 00208 } 00209 else 00210 { 00211 wheight = GetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_SIZE_HEIGHT, NULL, FALSE); 00212 } 00213 00214 if (lppsn->hdr.idFrom == IDC_UPDOWN_SCREEN_BUFFER_WIDTH) 00215 { 00216 swidth = lpnmud->iPos + lpnmud->iDelta; 00217 } 00218 else 00219 { 00220 swidth = GetDlgItemInt(hwndDlg, IDC_EDIT_SCREEN_BUFFER_WIDTH, NULL, FALSE); 00221 } 00222 00223 if (lppsn->hdr.idFrom == IDC_UPDOWN_SCREEN_BUFFER_HEIGHT) 00224 { 00225 sheight = lpnmud->iPos + lpnmud->iDelta; 00226 } 00227 else 00228 { 00229 sheight = GetDlgItemInt(hwndDlg, IDC_EDIT_SCREEN_BUFFER_HEIGHT, NULL, FALSE); 00230 } 00231 00232 if (lppsn->hdr.idFrom == IDC_UPDOWN_WINDOW_POS_LEFT) 00233 { 00234 left = lpnmud->iPos + lpnmud->iDelta; 00235 } 00236 else 00237 { 00238 left = GetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_POS_LEFT, NULL, FALSE); 00239 } 00240 00241 if (lppsn->hdr.idFrom == IDC_UPDOWN_WINDOW_POS_TOP) 00242 { 00243 top = lpnmud->iPos + lpnmud->iDelta; 00244 } 00245 else 00246 { 00247 top = GetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_POS_TOP, NULL, FALSE); 00248 } 00249 00250 if (lppsn->hdr.idFrom == IDC_UPDOWN_WINDOW_SIZE_WIDTH || lppsn->hdr.idFrom == IDC_UPDOWN_WINDOW_SIZE_HEIGHT) 00251 { 00252 /* Automatically adjust screen buffer size when window size enlarges */ 00253 if (wwidth >= swidth) 00254 { 00255 SetDlgItemInt(hwndDlg, IDC_EDIT_SCREEN_BUFFER_WIDTH, wwidth, TRUE); 00256 swidth = wwidth; 00257 } 00258 00259 if (wheight >= sheight) 00260 { 00261 SetDlgItemInt(hwndDlg, IDC_EDIT_SCREEN_BUFFER_HEIGHT, wheight, TRUE); 00262 sheight = wheight; 00263 } 00264 } 00265 swidth = max(swidth, 1); 00266 sheight = max(sheight, 1); 00267 00268 if (lppsn->hdr.idFrom == IDC_UPDOWN_SCREEN_BUFFER_WIDTH || lppsn->hdr.idFrom == IDC_UPDOWN_SCREEN_BUFFER_HEIGHT) 00269 { 00270 /* Automatically adjust window size when screen buffer decreases */ 00271 if (wwidth > swidth) 00272 { 00273 SetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_SIZE_WIDTH, swidth, TRUE); 00274 wwidth = swidth; 00275 } 00276 00277 if (wheight > sheight) 00278 { 00279 SetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_SIZE_HEIGHT, sheight, TRUE); 00280 wheight = sheight; 00281 } 00282 } 00283 00284 pConInfo->ScreenBuffer = MAKELONG(swidth, sheight); 00285 pConInfo->WindowSize = MAKELONG(wwidth, wheight); 00286 pConInfo->WindowPosition = MAKELONG(left, top); 00287 PropSheet_Changed(GetParent(hwndDlg), hwndDlg); 00288 } 00289 break; 00290 } 00291 case WM_COMMAND: 00292 { 00293 switch(LOWORD(wParam)) 00294 { 00295 case IDC_EDIT_SCREEN_BUFFER_WIDTH: 00296 case IDC_EDIT_SCREEN_BUFFER_HEIGHT: 00297 case IDC_EDIT_WINDOW_SIZE_WIDTH: 00298 case IDC_UPDOWN_WINDOW_SIZE_HEIGHT: 00299 case IDC_EDIT_WINDOW_POS_LEFT: 00300 case IDC_EDIT_WINDOW_POS_TOP: 00301 { 00302 if (HIWORD(wParam) == EN_KILLFOCUS) 00303 { 00304 DWORD wheight, wwidth; 00305 DWORD sheight, swidth; 00306 DWORD left, top; 00307 00308 wwidth = GetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_SIZE_WIDTH, NULL, FALSE); 00309 wheight = GetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_SIZE_HEIGHT, NULL, FALSE); 00310 swidth = GetDlgItemInt(hwndDlg, IDC_EDIT_SCREEN_BUFFER_WIDTH, NULL, FALSE); 00311 sheight = GetDlgItemInt(hwndDlg, IDC_EDIT_SCREEN_BUFFER_HEIGHT, NULL, FALSE); 00312 left = GetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_POS_LEFT, NULL, FALSE); 00313 top = GetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_POS_TOP, NULL, FALSE); 00314 00315 swidth = max(swidth, 1); 00316 sheight = max(sheight, 1); 00317 00318 /* Automatically adjust window size when screen buffer decreases */ 00319 if (wwidth > swidth) 00320 { 00321 SetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_SIZE_WIDTH, swidth, TRUE); 00322 wwidth = swidth; 00323 } 00324 00325 if (wheight > sheight) 00326 { 00327 SetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_SIZE_HEIGHT, sheight, TRUE); 00328 wheight = sheight; 00329 } 00330 00331 00332 pConInfo->ScreenBuffer = MAKELONG(swidth, sheight); 00333 pConInfo->WindowSize = MAKELONG(wwidth, wheight); 00334 pConInfo->WindowPosition = MAKELONG(left, top); 00335 00336 PropSheet_Changed(GetParent(hwndDlg), hwndDlg); 00337 } 00338 break; 00339 } 00340 00341 case IDC_CHECK_SYSTEM_POS_WINDOW: 00342 { 00343 LONG res = SendMessage((HWND)lParam, BM_GETCHECK, 0, 0); 00344 if (res == BST_CHECKED) 00345 { 00346 ULONG left, top; 00347 00348 left = GetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_POS_LEFT, NULL, FALSE); 00349 top = GetDlgItemInt(hwndDlg, IDC_EDIT_WINDOW_POS_TOP, NULL, FALSE); 00350 pConInfo->WindowPosition = MAKELONG(left, top); 00351 SendMessage((HWND)lParam, BM_SETCHECK, (WPARAM)BST_UNCHECKED, 0); 00352 EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_WINDOW_POS_LEFT), TRUE); 00353 EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_WINDOW_POS_TOP), TRUE); 00354 EnableWindow(GetDlgItem(hwndDlg, IDC_UPDOWN_WINDOW_POS_LEFT), TRUE); 00355 EnableWindow(GetDlgItem(hwndDlg, IDC_UPDOWN_WINDOW_POS_TOP), TRUE); 00356 } 00357 else if (res == BST_UNCHECKED) 00358 { 00359 pConInfo->WindowPosition = UINT_MAX; 00360 SendMessage((HWND)lParam, BM_SETCHECK, (WPARAM)BST_CHECKED, 0); 00361 EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_WINDOW_POS_LEFT), FALSE); 00362 EnableWindow(GetDlgItem(hwndDlg, IDC_EDIT_WINDOW_POS_TOP), FALSE); 00363 EnableWindow(GetDlgItem(hwndDlg, IDC_UPDOWN_WINDOW_POS_LEFT), FALSE); 00364 EnableWindow(GetDlgItem(hwndDlg, IDC_UPDOWN_WINDOW_POS_TOP), FALSE); 00365 } 00366 } 00367 } 00368 } 00369 default: 00370 break; 00371 } 00372 00373 return FALSE; 00374 } Generated on Sun May 27 2012 04:20:52 for ReactOS by
1.7.6.1
|