2 * PROJECT: ReactOS Console Configuration DLL
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/win32/console/colors.c
5 * PURPOSE: displays colors dialog
6 * PROGRAMMERS: Johannes Anderwald (johannes.anderwald@student.tugraz.at)
13 PaintStaticControls(HWND hwndDlg
, PConsoleInfo pConInfo
, LPDRAWITEMSTRUCT drawItem
)
18 index
= drawItem
->CtlID
- IDC_STATIC_COLOR1
;
19 hBrush
= CreateSolidBrush(pConInfo
->Colors
[index
]);
25 FillRect(drawItem
->hDC
, &drawItem
->rcItem
, hBrush
);
26 DeleteObject((HGDIOBJ
)hBrush
);
27 if (pConInfo
->ActiveStaticControl
== index
)
29 DrawFocusRect(drawItem
->hDC
, &drawItem
->rcItem
);
43 PConsoleInfo pConInfo
;
46 LPDRAWITEMSTRUCT drawItem
;
48 DWORD green
= MAXDWORD
;
49 DWORD blue
= MAXDWORD
;
51 pConInfo
= (PConsoleInfo
) GetWindowLongPtr(hwndDlg
, DWLP_USER
);
57 pConInfo
= (PConsoleInfo
) ((LPPROPSHEETPAGE
)lParam
)->lParam
;
58 SetWindowLongPtr(hwndDlg
, DWLP_USER
, (LONG_PTR
)pConInfo
);
59 SendMessage(GetDlgItem(hwndDlg
, IDC_RADIO_SCREEN_BACKGROUND
), BM_SETCHECK
, BST_CHECKED
, 0);
60 SendMessage(GetDlgItem(hwndDlg
, IDC_UPDOWN_COLOR_RED
), UDM_SETRANGE
, 0, (LPARAM
)MAKELONG(255, 0));
61 SendMessage(GetDlgItem(hwndDlg
, IDC_UPDOWN_COLOR_GREEN
), UDM_SETRANGE
, 0, (LPARAM
)MAKELONG(255, 0));
62 SendMessage(GetDlgItem(hwndDlg
, IDC_UPDOWN_COLOR_BLUE
), UDM_SETRANGE
, 0, (LPARAM
)MAKELONG(255, 0));
63 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_RED
, GetRValue(pConInfo
->ScreenBackground
), FALSE
);
64 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_GREEN
, GetGValue(pConInfo
->ScreenBackground
), FALSE
);
65 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_BLUE
, GetBValue(pConInfo
->ScreenBackground
), FALSE
);
66 CheckRadioButton(hwndDlg
, IDC_RADIO_SCREEN_TEXT
, IDC_RADIO_POPUP_BACKGROUND
, IDC_RADIO_SCREEN_BACKGROUND
);
71 drawItem
= (LPDRAWITEMSTRUCT
)lParam
;
72 if (drawItem
->CtlID
>= IDC_STATIC_COLOR1
&& drawItem
->CtlID
<= IDC_STATIC_COLOR16
)
74 return PaintStaticControls(hwndDlg
, pConInfo
, drawItem
);
76 else if (drawItem
->CtlID
== IDC_STATIC_SCREEN_COLOR
|| drawItem
->CtlID
== IDC_STATIC_POPUP_COLOR
)
78 PaintText(drawItem
, pConInfo
);
84 lpnmud
= (LPNMUPDOWN
) lParam
;
85 lppsn
= (LPPSHNOTIFY
) lParam
;
87 if (lppsn
->hdr
.code
== PSN_APPLY
)
89 if (!pConInfo
->AppliedConfig
)
91 ApplyConsoleInfo(hwndDlg
, pConInfo
);
95 /* options have already been applied */
96 SetWindowLongPtr(hwndDlg
, DWL_MSGRESULT
, PSNRET_NOERROR
);
102 if (lpnmud
->hdr
.idFrom
== IDC_UPDOWN_COLOR_RED
)
106 else if (lpnmud
->hdr
.idFrom
== IDC_UPDOWN_COLOR_GREEN
)
108 green
= lpnmud
->iPos
;
110 else if (lpnmud
->hdr
.idFrom
== IDC_UPDOWN_COLOR_BLUE
)
121 red
= SendMessage(GetDlgItem(hwndDlg
, IDC_UPDOWN_COLOR_RED
), UDM_GETPOS
, 0, 0);
130 if (green
== MAXDWORD
)
132 green
= SendMessage(GetDlgItem(hwndDlg
, IDC_UPDOWN_COLOR_GREEN
), UDM_GETPOS
, 0, 0);
138 green
= LOBYTE(green
);
141 if (blue
== MAXDWORD
)
143 blue
= SendMessage(GetDlgItem(hwndDlg
, IDC_UPDOWN_COLOR_BLUE
), UDM_GETPOS
, 0, 0);
151 pConInfo
->Colors
[pConInfo
->ActiveStaticControl
] = RGB(red
, green
, blue
);
152 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_COLOR1
+ pConInfo
->ActiveStaticControl
), NULL
, TRUE
);
153 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_SCREEN_COLOR
), NULL
, TRUE
);
154 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_POPUP_COLOR
), NULL
, TRUE
);
159 switch(LOWORD(wParam
))
161 case IDC_RADIO_SCREEN_TEXT
:
163 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_RED
, GetRValue(pConInfo
->ScreenText
), FALSE
);
164 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_GREEN
, GetGValue(pConInfo
->ScreenText
), FALSE
);
165 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_BLUE
, GetBValue(pConInfo
->ScreenText
), FALSE
);
166 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_SCREEN_COLOR
), NULL
, TRUE
);
167 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_POPUP_COLOR
), NULL
, TRUE
);
170 case IDC_RADIO_SCREEN_BACKGROUND
:
172 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_RED
, GetRValue(pConInfo
->ScreenBackground
), FALSE
);
173 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_GREEN
, GetGValue(pConInfo
->ScreenBackground
), FALSE
);
174 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_BLUE
, GetBValue(pConInfo
->ScreenBackground
), FALSE
);
175 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_SCREEN_COLOR
), NULL
, TRUE
);
176 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_POPUP_COLOR
), NULL
, TRUE
);
179 case IDC_RADIO_POPUP_TEXT
:
181 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_RED
, GetRValue(pConInfo
->PopupText
), FALSE
);
182 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_GREEN
, GetGValue(pConInfo
->PopupText
), FALSE
);
183 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_BLUE
, GetBValue(pConInfo
->PopupText
), FALSE
);
184 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_SCREEN_COLOR
), NULL
, TRUE
);
185 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_POPUP_COLOR
), NULL
, TRUE
);
188 case IDC_RADIO_POPUP_BACKGROUND
:
190 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_RED
, GetRValue(pConInfo
->PopupBackground
), FALSE
);
191 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_GREEN
, GetGValue(pConInfo
->PopupBackground
), FALSE
);
192 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_BLUE
, GetBValue(pConInfo
->PopupBackground
), FALSE
);
193 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_SCREEN_COLOR
), NULL
, TRUE
);
194 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_POPUP_COLOR
), NULL
, TRUE
);
198 if (HIWORD(wParam
) == STN_CLICKED
&& LOWORD(wParam
) >= IDC_STATIC_COLOR1
&& LOWORD(wParam
) <= IDC_STATIC_COLOR16
)
200 DWORD index
= LOWORD(wParam
) - IDC_STATIC_COLOR1
;
202 if (index
== pConInfo
->ActiveStaticControl
)
204 /* same static control was re-clicked */
208 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_RED
, GetRValue(pConInfo
->Colors
[index
]), FALSE
);
209 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_GREEN
, GetGValue(pConInfo
->Colors
[index
]), FALSE
);
210 SetDlgItemInt(hwndDlg
, IDC_EDIT_COLOR_BLUE
, GetBValue(pConInfo
->Colors
[index
]), FALSE
);
212 /* update global struct */
213 if (IsDlgButtonChecked(hwndDlg
, IDC_RADIO_SCREEN_TEXT
))
215 pConInfo
->ScreenText
= pConInfo
->Colors
[index
];
217 else if (IsDlgButtonChecked(hwndDlg
, IDC_RADIO_SCREEN_BACKGROUND
))
219 pConInfo
->ScreenBackground
= pConInfo
->Colors
[index
];
221 else if (IsDlgButtonChecked(hwndDlg
, IDC_RADIO_POPUP_TEXT
))
223 pConInfo
->PopupText
= pConInfo
->Colors
[index
];
225 else if (IsDlgButtonChecked(hwndDlg
, IDC_RADIO_POPUP_BACKGROUND
))
227 pConInfo
->PopupBackground
= pConInfo
->Colors
[index
];
229 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_COLOR1
+ pConInfo
->ActiveStaticControl
), NULL
, TRUE
);
230 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_COLOR1
+ index
), NULL
, TRUE
);
231 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_SCREEN_COLOR
), NULL
, TRUE
);
232 InvalidateRect(GetDlgItem(hwndDlg
, IDC_STATIC_POPUP_COLOR
), NULL
, TRUE
);
233 pConInfo
->ActiveStaticControl
= index
;