mirror of
https://github.com/reactos/reactos.git
synced 2025-04-20 20:36:35 +00:00
[CONSOLE.CPL]: Simplify the color selection code by factorizing common parts.
svn path=/trunk/; revision=74502
This commit is contained in:
parent
e8476bec2a
commit
c24fbddd42
1 changed files with 54 additions and 119 deletions
|
@ -132,70 +132,35 @@ ColorsProc(HWND hDlg,
|
||||||
{
|
{
|
||||||
/* NOTE: both BN_CLICKED and STN_CLICKED == 0 */
|
/* NOTE: both BN_CLICKED and STN_CLICKED == 0 */
|
||||||
if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == STN_CLICKED)
|
if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == STN_CLICKED)
|
||||||
|
{
|
||||||
|
if (LOWORD(wParam) == IDC_RADIO_SCREEN_TEXT ||
|
||||||
|
LOWORD(wParam) == IDC_RADIO_SCREEN_BACKGROUND ||
|
||||||
|
LOWORD(wParam) == IDC_RADIO_POPUP_TEXT ||
|
||||||
|
LOWORD(wParam) == IDC_RADIO_POPUP_BACKGROUND)
|
||||||
{
|
{
|
||||||
switch (LOWORD(wParam))
|
switch (LOWORD(wParam))
|
||||||
{
|
{
|
||||||
case IDC_RADIO_SCREEN_TEXT:
|
case IDC_RADIO_SCREEN_TEXT:
|
||||||
{
|
/* Get the colour of the screen foreground */
|
||||||
/* Get the color of the screen foreground */
|
|
||||||
colorIndex = TextAttribFromAttrib(ConInfo->ScreenAttributes);
|
colorIndex = TextAttribFromAttrib(ConInfo->ScreenAttributes);
|
||||||
color = ConInfo->ColorTable[colorIndex];
|
|
||||||
|
|
||||||
/* Set the values of the colour indicators */
|
|
||||||
SetDlgItemInt(hDlg, IDC_EDIT_COLOR_RED , GetRValue(color), FALSE);
|
|
||||||
SetDlgItemInt(hDlg, IDC_EDIT_COLOR_GREEN, GetGValue(color), FALSE);
|
|
||||||
SetDlgItemInt(hDlg, IDC_EDIT_COLOR_BLUE , GetBValue(color), FALSE);
|
|
||||||
|
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_COLOR1 + ActiveStaticControl), NULL, TRUE);
|
|
||||||
ActiveStaticControl = colorIndex;
|
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_COLOR1 + ActiveStaticControl), NULL, TRUE);
|
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_SCREEN_COLOR), NULL, TRUE);
|
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_POPUP_COLOR) , NULL, TRUE);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case IDC_RADIO_SCREEN_BACKGROUND:
|
case IDC_RADIO_SCREEN_BACKGROUND:
|
||||||
{
|
/* Get the colour of the screen background */
|
||||||
/* Get the color of the screen background */
|
|
||||||
colorIndex = BkgdAttribFromAttrib(ConInfo->ScreenAttributes);
|
colorIndex = BkgdAttribFromAttrib(ConInfo->ScreenAttributes);
|
||||||
color = ConInfo->ColorTable[colorIndex];
|
|
||||||
|
|
||||||
/* Set the values of the colour indicators */
|
|
||||||
SetDlgItemInt(hDlg, IDC_EDIT_COLOR_RED , GetRValue(color), FALSE);
|
|
||||||
SetDlgItemInt(hDlg, IDC_EDIT_COLOR_GREEN, GetGValue(color), FALSE);
|
|
||||||
SetDlgItemInt(hDlg, IDC_EDIT_COLOR_BLUE , GetBValue(color), FALSE);
|
|
||||||
|
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_COLOR1 + ActiveStaticControl), NULL, TRUE);
|
|
||||||
ActiveStaticControl = colorIndex;
|
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_COLOR1 + ActiveStaticControl), NULL, TRUE);
|
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_SCREEN_COLOR), NULL, TRUE);
|
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_POPUP_COLOR) , NULL, TRUE);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case IDC_RADIO_POPUP_TEXT:
|
case IDC_RADIO_POPUP_TEXT:
|
||||||
{
|
/* Get the colour of the popup foreground */
|
||||||
/* Get the color of the popup foreground */
|
|
||||||
colorIndex = TextAttribFromAttrib(ConInfo->PopupAttributes);
|
colorIndex = TextAttribFromAttrib(ConInfo->PopupAttributes);
|
||||||
color = ConInfo->ColorTable[colorIndex];
|
|
||||||
|
|
||||||
/* Set the values of the colour indicators */
|
|
||||||
SetDlgItemInt(hDlg, IDC_EDIT_COLOR_RED , GetRValue(color), FALSE);
|
|
||||||
SetDlgItemInt(hDlg, IDC_EDIT_COLOR_GREEN, GetGValue(color), FALSE);
|
|
||||||
SetDlgItemInt(hDlg, IDC_EDIT_COLOR_BLUE , GetBValue(color), FALSE);
|
|
||||||
|
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_COLOR1 + ActiveStaticControl), NULL, TRUE);
|
|
||||||
ActiveStaticControl = colorIndex;
|
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_COLOR1 + ActiveStaticControl), NULL, TRUE);
|
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_SCREEN_COLOR), NULL, TRUE);
|
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_POPUP_COLOR) , NULL, TRUE);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case IDC_RADIO_POPUP_BACKGROUND:
|
case IDC_RADIO_POPUP_BACKGROUND:
|
||||||
{
|
/* Get the colour of the popup background */
|
||||||
/* Get the color of the popup background */
|
|
||||||
colorIndex = BkgdAttribFromAttrib(ConInfo->PopupAttributes);
|
colorIndex = BkgdAttribFromAttrib(ConInfo->PopupAttributes);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
color = ConInfo->ColorTable[colorIndex];
|
color = ConInfo->ColorTable[colorIndex];
|
||||||
|
|
||||||
/* Set the values of the colour indicators */
|
/* Set the values of the colour indicators */
|
||||||
|
@ -206,12 +171,9 @@ ColorsProc(HWND hDlg,
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_COLOR1 + ActiveStaticControl), NULL, TRUE);
|
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_COLOR1 + ActiveStaticControl), NULL, TRUE);
|
||||||
ActiveStaticControl = colorIndex;
|
ActiveStaticControl = colorIndex;
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_COLOR1 + ActiveStaticControl), NULL, TRUE);
|
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_COLOR1 + ActiveStaticControl), NULL, TRUE);
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_SCREEN_COLOR), NULL, TRUE);
|
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_POPUP_COLOR) , NULL, TRUE);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
if (IDC_STATIC_COLOR1 <= LOWORD(wParam) && LOWORD(wParam) <= IDC_STATIC_COLOR16)
|
if (IDC_STATIC_COLOR1 <= LOWORD(wParam) && LOWORD(wParam) <= IDC_STATIC_COLOR16)
|
||||||
{
|
{
|
||||||
colorIndex = LOWORD(wParam) - IDC_STATIC_COLOR1;
|
colorIndex = LOWORD(wParam) - IDC_STATIC_COLOR1;
|
||||||
|
@ -222,6 +184,7 @@ ColorsProc(HWND hDlg,
|
||||||
|
|
||||||
color = ConInfo->ColorTable[colorIndex];
|
color = ConInfo->ColorTable[colorIndex];
|
||||||
|
|
||||||
|
/* Set the values of the colour indicators */
|
||||||
SetDlgItemInt(hDlg, IDC_EDIT_COLOR_RED , GetRValue(color), FALSE);
|
SetDlgItemInt(hDlg, IDC_EDIT_COLOR_RED , GetRValue(color), FALSE);
|
||||||
SetDlgItemInt(hDlg, IDC_EDIT_COLOR_GREEN, GetGValue(color), FALSE);
|
SetDlgItemInt(hDlg, IDC_EDIT_COLOR_GREEN, GetGValue(color), FALSE);
|
||||||
SetDlgItemInt(hDlg, IDC_EDIT_COLOR_BLUE , GetBValue(color), FALSE);
|
SetDlgItemInt(hDlg, IDC_EDIT_COLOR_BLUE , GetBValue(color), FALSE);
|
||||||
|
@ -255,64 +218,37 @@ ColorsProc(HWND hDlg,
|
||||||
}
|
}
|
||||||
else if (HIWORD(wParam) == EN_KILLFOCUS)
|
else if (HIWORD(wParam) == EN_KILLFOCUS)
|
||||||
{
|
{
|
||||||
|
if (LOWORD(wParam) == IDC_EDIT_COLOR_RED ||
|
||||||
|
LOWORD(wParam) == IDC_EDIT_COLOR_GREEN ||
|
||||||
|
LOWORD(wParam) == IDC_EDIT_COLOR_BLUE)
|
||||||
|
{
|
||||||
|
DWORD value;
|
||||||
|
|
||||||
|
/* Get the current colour */
|
||||||
|
colorIndex = ActiveStaticControl;
|
||||||
|
color = ConInfo->ColorTable[colorIndex];
|
||||||
|
|
||||||
|
/* Modify the colour component */
|
||||||
switch (LOWORD(wParam))
|
switch (LOWORD(wParam))
|
||||||
{
|
{
|
||||||
case IDC_EDIT_COLOR_RED:
|
case IDC_EDIT_COLOR_RED:
|
||||||
{
|
value = GetDlgItemInt(hDlg, IDC_EDIT_COLOR_RED, NULL, FALSE);
|
||||||
DWORD red;
|
value = min(max(value, 0), 255);
|
||||||
|
color = RGB(value, GetGValue(color), GetBValue(color));
|
||||||
/* Get the current color */
|
|
||||||
colorIndex = ActiveStaticControl;
|
|
||||||
color = ConInfo->ColorTable[colorIndex];
|
|
||||||
|
|
||||||
red = GetDlgItemInt(hDlg, IDC_EDIT_COLOR_RED, NULL, FALSE);
|
|
||||||
red = min(max(red, 0), 255);
|
|
||||||
|
|
||||||
color = RGB(red, GetGValue(color), GetBValue(color));
|
|
||||||
|
|
||||||
ConInfo->ColorTable[colorIndex] = color;
|
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_COLOR1 + colorIndex), NULL, TRUE);
|
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_SCREEN_COLOR), NULL, TRUE);
|
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_POPUP_COLOR) , NULL, TRUE);
|
|
||||||
|
|
||||||
PropSheet_Changed(GetParent(hDlg), hDlg);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case IDC_EDIT_COLOR_GREEN:
|
case IDC_EDIT_COLOR_GREEN:
|
||||||
{
|
value = GetDlgItemInt(hDlg, IDC_EDIT_COLOR_GREEN, NULL, FALSE);
|
||||||
DWORD green;
|
value = min(max(value, 0), 255);
|
||||||
|
color = RGB(GetRValue(color), value, GetBValue(color));
|
||||||
/* Get the current color */
|
|
||||||
colorIndex = ActiveStaticControl;
|
|
||||||
color = ConInfo->ColorTable[colorIndex];
|
|
||||||
|
|
||||||
green = GetDlgItemInt(hDlg, IDC_EDIT_COLOR_GREEN, NULL, FALSE);
|
|
||||||
green = min(max(green, 0), 255);
|
|
||||||
|
|
||||||
color = RGB(GetRValue(color), green, GetBValue(color));
|
|
||||||
|
|
||||||
ConInfo->ColorTable[colorIndex] = color;
|
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_COLOR1 + colorIndex), NULL, TRUE);
|
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_SCREEN_COLOR), NULL, TRUE);
|
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_POPUP_COLOR) , NULL, TRUE);
|
|
||||||
|
|
||||||
PropSheet_Changed(GetParent(hDlg), hDlg);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case IDC_EDIT_COLOR_BLUE:
|
case IDC_EDIT_COLOR_BLUE:
|
||||||
{
|
value = GetDlgItemInt(hDlg, IDC_EDIT_COLOR_BLUE, NULL, FALSE);
|
||||||
DWORD blue;
|
value = min(max(value, 0), 255);
|
||||||
|
color = RGB(GetRValue(color), GetGValue(color), value);
|
||||||
/* Get the current color */
|
break;
|
||||||
colorIndex = ActiveStaticControl;
|
}
|
||||||
color = ConInfo->ColorTable[colorIndex];
|
|
||||||
|
|
||||||
blue = GetDlgItemInt(hDlg, IDC_EDIT_COLOR_BLUE, NULL, FALSE);
|
|
||||||
blue = min(max(blue, 0), 255);
|
|
||||||
|
|
||||||
color = RGB(GetRValue(color), GetGValue(color), blue);
|
|
||||||
|
|
||||||
ConInfo->ColorTable[colorIndex] = color;
|
ConInfo->ColorTable[colorIndex] = color;
|
||||||
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_COLOR1 + colorIndex), NULL, TRUE);
|
InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_COLOR1 + colorIndex), NULL, TRUE);
|
||||||
|
@ -323,7 +259,6 @@ ColorsProc(HWND hDlg,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue