Author: janderwald Date: Sun Aug 27 13:50:29 2006 New Revision: 23737
URL: http://svn.reactos.org/svn/reactos?rev=23737&view=rev Log: * store static colors in global struct to make it thread-safe
Modified: trunk/reactos/dll/win32/console/colors.c trunk/reactos/dll/win32/console/console.c trunk/reactos/dll/win32/console/console.h
Modified: trunk/reactos/dll/win32/console/colors.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/console/colors.c?... ============================================================================== --- trunk/reactos/dll/win32/console/colors.c (original) +++ trunk/reactos/dll/win32/console/colors.c Sun Aug 27 13:50:29 2006 @@ -9,28 +9,6 @@
#include "console.h"
-static COLORREF s_Colors[] = -{ - RGB(0, 0, 0), - RGB(0, 0, 128), - RGB(0, 128, 0), - RGB(0, 128, 128), - RGB(128, 0, 0), - RGB(128, 0, 128), - RGB(128, 128, 0), - RGB(192, 192, 192), - RGB(128, 128, 128), - RGB(0, 0, 255), - RGB(0, 255, 0), - RGB(0, 255, 255), - RGB(255, 0, 0), - RGB(255, 0, 255), - RGB(255, 255, 0), - RGB(255, 255, 255) -}; - - - static BOOL PaintStaticControls(HWND hwndDlg, PConsoleInfo pConInfo, LPDRAWITEMSTRUCT drawItem) @@ -39,7 +17,7 @@ DWORD index;
index = drawItem->CtlID - IDC_STATIC_COLOR1; - hBrush = CreateSolidBrush(s_Colors[index]); + hBrush = CreateSolidBrush(pConInfo->Colors[index]); if (!hBrush) { return FALSE; @@ -171,7 +149,7 @@ } blue = LOBYTE(blue); } - s_Colors[pConInfo->ActiveStaticControl] = RGB(red, green, blue); + pConInfo->Colors[pConInfo->ActiveStaticControl] = RGB(red, green, blue); InvalidateRect(GetDlgItem(hwndDlg, IDC_STATIC_COLOR1 + pConInfo->ActiveStaticControl), NULL, TRUE); InvalidateRect(GetDlgItem(hwndDlg, IDC_STATIC_SCREEN_COLOR), NULL, TRUE); InvalidateRect(GetDlgItem(hwndDlg, IDC_STATIC_POPUP_COLOR), NULL, TRUE); @@ -228,26 +206,26 @@ break; }
- SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_RED, GetRValue(s_Colors[index]), FALSE); - SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_GREEN, GetGValue(s_Colors[index]), FALSE); - SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_BLUE, GetBValue(s_Colors[index]), FALSE); + SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_RED, GetRValue(pConInfo->Colors[index]), FALSE); + SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_GREEN, GetGValue(pConInfo->Colors[index]), FALSE); + SetDlgItemInt(hwndDlg, IDC_EDIT_COLOR_BLUE, GetBValue(pConInfo->Colors[index]), FALSE);
/* update global struct */ if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_SCREEN_TEXT)) { - pConInfo->ScreenText = s_Colors[index]; + pConInfo->ScreenText = pConInfo->Colors[index]; } else if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_SCREEN_BACKGROUND)) { - pConInfo->ScreenBackground = s_Colors[index]; + pConInfo->ScreenBackground = pConInfo->Colors[index]; } else if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_POPUP_TEXT)) { - pConInfo->PopupText = s_Colors[index]; + pConInfo->PopupText = pConInfo->Colors[index]; } else if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_POPUP_BACKGROUND)) { - pConInfo->PopupBackground = s_Colors[index]; + pConInfo->PopupBackground = pConInfo->Colors[index]; } InvalidateRect(GetDlgItem(hwndDlg, IDC_STATIC_COLOR1 + pConInfo->ActiveStaticControl), NULL, TRUE); InvalidateRect(GetDlgItem(hwndDlg, IDC_STATIC_COLOR1 + index), NULL, TRUE);
Modified: trunk/reactos/dll/win32/console/console.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/console/console.c... ============================================================================== --- trunk/reactos/dll/win32/console/console.c (original) +++ trunk/reactos/dll/win32/console/console.c Sun Aug 27 13:50:29 2006 @@ -25,6 +25,26 @@ APPLET Applets[NUM_APPLETS] = { {IDC_CPLICON, IDS_CPLNAME, IDS_CPLDESCRIPTION, InitApplet} +}; + +static COLORREF s_Colors[] = +{ + RGB(0, 0, 0), + RGB(0, 0, 128), + RGB(0, 128, 0), + RGB(0, 128, 128), + RGB(128, 0, 0), + RGB(128, 0, 128), + RGB(128, 128, 0), + RGB(192, 192, 192), + RGB(128, 128, 128), + RGB(0, 0, 255), + RGB(0, 255, 0), + RGB(0, 255, 255), + RGB(255, 0, 0), + RGB(255, 0, 255), + RGB(255, 255, 0), + RGB(255, 255, 255) };
static void @@ -67,6 +87,7 @@ pConInfo->UseRasterFonts = TRUE; pConInfo->FontSize = (DWORD)MAKELONG(8, 12); pConInfo->FontWeight = FALSE; + memcpy(pConInfo->Colors, s_Colors, sizeof(s_Colors));
GetModuleFileName(NULL, pConInfo->szProcessName, MAX_PATH); GetStartupInfo(&StartupInfo);
Modified: trunk/reactos/dll/win32/console/console.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/console/console.h... ============================================================================== --- trunk/reactos/dll/win32/console/console.h (original) +++ trunk/reactos/dll/win32/console/console.h Sun Aug 27 13:50:29 2006 @@ -41,6 +41,7 @@ COLORREF ScreenBackground; COLORREF PopupText; COLORREF PopupBackground; + COLORREF Colors[16]; } ConsoleInfo, *PConsoleInfo;
BOOL WriteConsoleOptions(PConsoleInfo pConInfo);