1 /* $Id: colors.c 29690 2007-10-19 23:21:45Z dreimer $
3 * PROJECT: ReactOS Console Configuration DLL
4 * LICENSE: GPL - See COPYING in the top level directory
5 * FILE: dll/win32/console/colors.c
6 * PURPOSE: displays colors dialog
7 * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@student.tugraz.at)
14 PaintStaticControls(HWND hwndDlg
, PConsoleInfo pConInfo
, LPDRAWITEMSTRUCT drawItem
)
19 index
= drawItem
->CtlID
- IDC_STATIC_COLOR1
;
20 hBrush
= CreateSolidBrush(pConInfo
->Colors
[index
]);
26 FillRect(drawItem
->hDC
, &drawItem
->rcItem
, hBrush
);
27 DeleteObject((HGDIOBJ
)hBrush
);
28 if (pConInfo
->ActiveStaticControl
== index
)
30 DrawFocusRect(drawItem
->hDC
, &drawItem
->rcItem
);
44 PConsoleInfo pConInfo
;
47 LPDRAWITEMSTRUCT drawItem
;
52 pConInfo
= (PConsoleInfo
) GetWindowLongPtr(hwndDlg
, DWLP_USER
);
58 pConInfo
= (PConsoleInfo
) ((LPPROPSHEETPAGE
)lParam
)->lParam
;
59 SetWindowLongPtr(hwndDlg
, DWLP_USER
, (LONG_PTR
)pConInfo
);
60 SendMessage(GetDlgItem(hwndDlg
, IDC_RADIO_SCREEN_BACKGROUND
), BM_SETCHECK
, BST_CHECKED
, 0);
61 SendMessage(GetDlgItem(hwndDlg
, IDC_UPDOWN_COLOR_RED
), UDM_SETRANGE
, 0, (LPARAM
)MAKELONG(255, 0));
62 SendMessage(GetDlgItem(hwndDlg
, IDC_UPDOWN_COLOR_GREEN
), UDM_SETRANGE
, 0, (LPARAM
)MAKELONG(255, 0));
63 SendMessage(GetDlgItem(hwndDlg
, IDC_UPDOWN_COLOR_BLUE
), UDM_SETRANGE
, 0, (LPARAM
)MAKELONG(255, 0));
64 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_RED
, GetRValue(pConInfo
->ScreenBackground
), FALSE
);
65 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_GREEN
, GetGValue(pConInfo
->ScreenBackground
), FALSE
);
66 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_BLUE
, GetBValue(pConInfo
->ScreenBackground
), FALSE
);
67 CheckRadioButton(hwndDlg
, IDC_RADIO_SCREEN_TEXT
, IDC_RADIO_POPUP_BACKGROUND
, IDC_RADIO_SCREEN_BACKGROUND
);
72 drawItem
= (LPDRAWITEMSTRUCT
)lParam
;
73 if (drawItem
->CtlID
>= IDC_STATIC_COLOR1
&& drawItem
->CtlID
<= IDC_STATIC_COLOR16
)
75 return PaintStaticControls(hwndDlg
, pConInfo
, drawItem
);
77 else if (drawItem
->CtlID
== IDC_STATIC_SCREEN_COLOR
|| drawItem
->CtlID
== IDC_STATIC_POPUP_COLOR
)
79 PaintText(drawItem
, pConInfo
);
85 lpnmud
= (LPNMUPDOWN
) lParam
;
86 lppsn
= (LPPSHNOTIFY
) lParam
;
88 if (lppsn
->hdr
.code
== PSN_APPLY
)
90 if (!pConInfo
->AppliedConfig
)
92 ApplyConsoleInfo(hwndDlg
, pConInfo
);
96 /* options have already been applied */
97 SetWindowLong(hwndDlg
, DWL_MSGRESULT
, PSNRET_NOERROR
);
103 if (lpnmud
->hdr
.idFrom
== IDC_UPDOWN_COLOR_RED
)
107 else if (lpnmud
->hdr
.idFrom
== IDC_UPDOWN_COLOR_GREEN
)
109 green
= lpnmud
->iPos
;
111 else if (lpnmud
->hdr
.idFrom
== IDC_UPDOWN_COLOR_BLUE
)
122 red
= SendMessage(GetDlgItem(hwndDlg
, IDC_UPDOWN_COLOR_RED
), UDM_GETPOS
, 0, 0);
133 green
= SendMessage(GetDlgItem(hwndDlg
, IDC_UPDOWN_COLOR_GREEN
), UDM_GETPOS
, 0, 0);
139 green
= LOBYTE(green
);
144 blue
= SendMessage(GetDlgItem(hwndDlg
, IDC_UPDOWN_COLOR_BLUE
), UDM_GETPOS
, 0, 0);
152 pConInfo
->Colors
[pConInfo
->ActiveStaticControl
] = RGB(red
, green
, blue
);
153 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_COLOR1
+ pConInfo
->ActiveStaticControl
), NULL
, TRUE
);
154 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_SCREEN_COLOR
), NULL
, TRUE
);
155 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_POPUP_COLOR
), NULL
, TRUE
);
160 switch(LOWORD(wParam
))
162 case IDC_RADIO_SCREEN_TEXT
:
164 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_RED
, GetRValue(pConInfo
->ScreenText
), FALSE
);
165 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_GREEN
, GetGValue(pConInfo
->ScreenText
), FALSE
);
166 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_BLUE
, GetBValue(pConInfo
->ScreenText
), FALSE
);
167 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_SCREEN_COLOR
), NULL
, TRUE
);
168 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_POPUP_COLOR
), NULL
, TRUE
);
171 case IDC_RADIO_SCREEN_BACKGROUND
:
173 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_RED
, GetRValue(pConInfo
->ScreenBackground
), FALSE
);
174 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_GREEN
, GetGValue(pConInfo
->ScreenBackground
), FALSE
);
175 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_BLUE
, GetBValue(pConInfo
->ScreenBackground
), FALSE
);
176 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_SCREEN_COLOR
), NULL
, TRUE
);
177 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_POPUP_COLOR
), NULL
, TRUE
);
180 case IDC_RADIO_POPUP_TEXT
:
182 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_RED
, GetRValue(pConInfo
->PopupText
), FALSE
);
183 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_GREEN
, GetGValue(pConInfo
->PopupText
), FALSE
);
184 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_BLUE
, GetBValue(pConInfo
->PopupText
), FALSE
);
185 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_SCREEN_COLOR
), NULL
, TRUE
);
186 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_POPUP_COLOR
), NULL
, TRUE
);
189 case IDC_RADIO_POPUP_BACKGROUND
:
191 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_RED
, GetRValue(pConInfo
->PopupBackground
), FALSE
);
192 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_GREEN
, GetGValue(pConInfo
->PopupBackground
), FALSE
);
193 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_BLUE
, GetBValue(pConInfo
->PopupBackground
), FALSE
);
194 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_SCREEN_COLOR
), NULL
, TRUE
);
195 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_POPUP_COLOR
), NULL
, TRUE
);
199 if (HIWORD(wParam
) == STN_CLICKED
&& LOWORD(wParam
) >= IDC_STATIC_COLOR1
&& LOWORD(wParam
) <= IDC_STATIC_COLOR16
)
201 DWORD index
= LOWORD(wParam
) - IDC_STATIC_COLOR1
;
203 if (index
== pConInfo
->ActiveStaticControl
)
205 /* same static control was re-clicked */
209 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_RED
, GetRValue(pConInfo
->Colors
[index
]), FALSE
);
210 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_GREEN
, GetGValue(pConInfo
->Colors
[index
]), FALSE
);
211 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_BLUE
, GetBValue(pConInfo
->Colors
[index
]), FALSE
);
213 /* update global struct */
214 if (IsDlgButtonChecked(hwndDlg
, IDC_RADIO_SCREEN_TEXT
))
216 pConInfo
->ScreenText
= pConInfo
->Colors
[index
];
218 else if (IsDlgButtonChecked(hwndDlg
, IDC_RADIO_SCREEN_BACKGROUND
))
220 pConInfo
->ScreenBackground
= pConInfo
->Colors
[index
];
222 else if (IsDlgButtonChecked(hwndDlg
, IDC_RADIO_POPUP_TEXT
))
224 pConInfo
->PopupText
= pConInfo
->Colors
[index
];
226 else if (IsDlgButtonChecked(hwndDlg
, IDC_RADIO_POPUP_BACKGROUND
))
228 pConInfo
->PopupBackground
= pConInfo
->Colors
[index
];
230 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_COLOR1
+ pConInfo
->ActiveStaticControl
), NULL
, TRUE
);
231 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_COLOR1
+ index
), NULL
, TRUE
);
232 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_SCREEN_COLOR
), NULL
, TRUE
);
233 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_POPUP_COLOR
), NULL
, TRUE
);
234 pConInfo
->ActiveStaticControl
= index
;