ReactOS 0.4.15-dev-7693-gd0e2924
colors.c File Reference
#include "console.h"
#include <debug.h>
Include dependency graph for colors.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static VOID PaintStaticControls (IN LPDRAWITEMSTRUCT drawItem, IN PCONSOLE_STATE_INFO pConInfo)
 
INT_PTR CALLBACK ColorsProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Variables

static DWORD ActiveStaticControl = 0
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file colors.c.

Function Documentation

◆ ColorsProc()

INT_PTR CALLBACK ColorsProc ( HWND  hDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 37 of file colors.c.

41{
42 DWORD colorIndex;
44
45 switch (uMsg)
46 {
47 case WM_INITDIALOG:
48 {
49 /* Set the valid range of the colour indicators */
53
54 /* Select by default the screen background option */
57
58 return TRUE;
59 }
60
61 case WM_DRAWITEM:
62 {
64
65 if (IDC_STATIC_COLOR1 <= drawItem->CtlID && drawItem->CtlID <= IDC_STATIC_COLOR16)
67 else if (drawItem->CtlID == IDC_STATIC_SCREEN_COLOR)
68 PaintText(drawItem, ConInfo, Screen);
69 else if (drawItem->CtlID == IDC_STATIC_POPUP_COLOR)
70 PaintText(drawItem, ConInfo, Popup);
71
72 return TRUE;
73 }
74
75 case WM_NOTIFY:
76 {
77 switch (((LPNMHDR)lParam)->code)
78 {
79 case PSN_APPLY:
80 {
81 ApplyConsoleInfo(hDlg);
82 return TRUE;
83 }
84
85 case UDN_DELTAPOS:
86 {
88
89 /* Get the current color */
90 colorIndex = ActiveStaticControl;
91 color = ConInfo->ColorTable[colorIndex];
92
93 if (lpnmud->hdr.idFrom == IDC_UPDOWN_COLOR_RED)
94 {
95 lpnmud->iPos = min(max(lpnmud->iPos + lpnmud->iDelta, 0), 255);
97 }
98 else if (lpnmud->hdr.idFrom == IDC_UPDOWN_COLOR_GREEN)
99 {
100 lpnmud->iPos = min(max(lpnmud->iPos + lpnmud->iDelta, 0), 255);
101 color = RGB(GetRValue(color), lpnmud->iPos, GetBValue(color));
102 }
103 else if (lpnmud->hdr.idFrom == IDC_UPDOWN_COLOR_BLUE)
104 {
105 lpnmud->iPos = min(max(lpnmud->iPos + lpnmud->iDelta, 0), 255);
106 color = RGB(GetRValue(color), GetGValue(color), lpnmud->iPos);
107 }
108 else
109 {
110 break;
111 }
112
113 ConInfo->ColorTable[colorIndex] = color;
114 InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_COLOR1 + colorIndex), NULL, TRUE);
117
118 PropSheet_Changed(GetParent(hDlg), hDlg);
119 break;
120 }
121 }
122
123 break;
124 }
125
126 case WM_COMMAND:
127 {
128 /* NOTE: both BN_CLICKED and STN_CLICKED == 0 */
129 if (HIWORD(wParam) == BN_CLICKED /* || HIWORD(wParam) == STN_CLICKED */)
130 {
131 WORD ctrlIndex = LOWORD(wParam);
132
133 if (ctrlIndex == IDC_RADIO_SCREEN_TEXT ||
134 ctrlIndex == IDC_RADIO_SCREEN_BACKGROUND ||
135 ctrlIndex == IDC_RADIO_POPUP_TEXT ||
136 ctrlIndex == IDC_RADIO_POPUP_BACKGROUND)
137 {
138 switch (ctrlIndex)
139 {
141 /* Get the colour of the screen foreground */
143 break;
144
146 /* Get the colour of the screen background */
148 break;
149
151 /* Get the colour of the popup foreground */
153 break;
154
156 /* Get the colour of the popup background */
158 break;
159 }
160
161 color = ConInfo->ColorTable[colorIndex];
162
163 /* Set the values of the colour indicators */
167
169 ActiveStaticControl = colorIndex;
171 break;
172 }
173 else
174 if (IDC_STATIC_COLOR1 <= ctrlIndex && ctrlIndex <= IDC_STATIC_COLOR16)
175 {
176 colorIndex = ctrlIndex - IDC_STATIC_COLOR1;
177
178 /* If the same static control was re-clicked, don't take it into account */
179 if (colorIndex == ActiveStaticControl)
180 break;
181
182 color = ConInfo->ColorTable[colorIndex];
183
184 /* Set the values of the colour indicators */
188
190 {
192 }
194 {
196 }
198 {
200 }
202 {
204 }
205
207 ActiveStaticControl = colorIndex;
211
212 PropSheet_Changed(GetParent(hDlg), hDlg);
213 break;
214 }
215 }
216 else if (HIWORD(wParam) == EN_KILLFOCUS)
217 {
218 WORD ctrlIndex = LOWORD(wParam);
219
220 if (ctrlIndex == IDC_EDIT_COLOR_RED ||
221 ctrlIndex == IDC_EDIT_COLOR_GREEN ||
222 ctrlIndex == IDC_EDIT_COLOR_BLUE)
223 {
224 DWORD value;
225
226 /* Get the current colour */
227 colorIndex = ActiveStaticControl;
228 color = ConInfo->ColorTable[colorIndex];
229
230 /* Modify the colour component */
231 switch (ctrlIndex)
232 {
235 value = min(max(value, 0), 255);
237 break;
238
241 value = min(max(value, 0), 255);
243 break;
244
247 value = min(max(value, 0), 255);
249 break;
250 }
251
252 ConInfo->ColorTable[colorIndex] = color;
253 InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_COLOR1 + colorIndex), NULL, TRUE);
256
257 PropSheet_Changed(GetParent(hDlg), hDlg);
258 break;
259 }
260 }
261
262 break;
263 }
264
265 default:
266 break;
267 }
268
269 return FALSE;
270}
static DWORD ActiveStaticControl
Definition: colors.c:15
static VOID PaintStaticControls(IN LPDRAWITEMSTRUCT drawItem, IN PCONSOLE_STATE_INFO pConInfo)
Definition: colors.c:18
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
PCONSOLE_STATE_INFO ConInfo
Definition: console.c:23
VOID ApplyConsoleInfo(HWND hwndDlg)
Definition: console.c:88
@ Screen
Definition: console.h:34
@ Popup
Definition: console.h:35
VOID PaintText(IN LPDRAWITEMSTRUCT drawItem, IN PCONSOLE_STATE_INFO pConInfo, IN TEXT_TYPE TextMode)
Definition: layout.c:471
#define IDC_EDIT_COLOR_GREEN
Definition: resource.h:74
#define IDC_RADIO_POPUP_BACKGROUND
Definition: resource.h:71
#define IDC_EDIT_COLOR_BLUE
Definition: resource.h:76
#define IDC_UPDOWN_COLOR_GREEN
Definition: resource.h:75
#define IDC_STATIC_SCREEN_COLOR
Definition: resource.h:78
#define IDC_STATIC_COLOR16
Definition: resource.h:96
#define IDC_UPDOWN_COLOR_BLUE
Definition: resource.h:77
#define IDC_RADIO_SCREEN_TEXT
Definition: resource.h:68
#define IDC_STATIC_COLOR1
Definition: resource.h:81
#define IDC_EDIT_COLOR_RED
Definition: resource.h:72
#define IDC_RADIO_POPUP_TEXT
Definition: resource.h:70
#define IDC_UPDOWN_COLOR_RED
Definition: resource.h:73
#define IDC_STATIC_POPUP_COLOR
Definition: resource.h:79
#define IDC_RADIO_SCREEN_BACKGROUND
Definition: resource.h:69
#define RGB(r, g, b)
Definition: precomp.h:62
#define GetBValue(quad)
Definition: precomp.h:66
#define GetGValue(quad)
Definition: precomp.h:65
#define GetRValue(quad)
Definition: precomp.h:64
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
GLuint color
Definition: glext.h:6243
#define min(a, b)
Definition: monoChain.cc:55
#define LOWORD(l)
Definition: pedump.c:82
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define PSN_APPLY
Definition: prsht.h:117
#define UDM_SETRANGE
Definition: commctrl.h:2141
struct _NM_UPDOWN * LPNMUPDOWN
#define UDN_DELTAPOS
Definition: commctrl.h:2169
#define WM_NOTIFY
Definition: richedit.h:61
COLORREF ColorTable[16]
Definition: settings.h:53
USHORT PopupAttributes
Definition: settings.h:48
USHORT ScreenAttributes
Definition: settings.h:47
int iDelta
Definition: commctrl.h:2166
NMHDR hdr
Definition: commctrl.h:2164
Definition: inflate.c:139
UINT_PTR idFrom
Definition: winuser.h:3157
#define max(a, b)
Definition: svc.c:63
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define HIWORD(l)
Definition: typedefs.h:247
Definition: pdh_main.c:94
#define TextAttribFromAttrib(Attribute)
Definition: settings.h:72
#define BkgdAttribFromAttrib(Attribute)
Definition: settings.h:73
#define MakeAttrib(TextAttrib, BkgdAttrib)
Definition: settings.h:74
LONG_PTR LPARAM
Definition: windef.h:208
DWORD COLORREF
Definition: windef.h:300
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
#define EN_KILLFOCUS
Definition: winuser.h:2024
#define WM_COMMAND
Definition: winuser.h:1739
#define WM_INITDIALOG
Definition: winuser.h:1738
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_DRAWITEM
Definition: winuser.h:1644
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
BOOL WINAPI SetDlgItemInt(_In_ HWND, _In_ int, _In_ UINT, _In_ BOOL)
HWND WINAPI GetParent(_In_ HWND)
BOOL WINAPI CheckRadioButton(_In_ HWND, _In_ int, _In_ int, _In_ int)
#define BN_CLICKED
Definition: winuser.h:1924
UINT WINAPI GetDlgItemInt(_In_ HWND, _In_ int, _Out_opt_ PBOOL, _In_ BOOL)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by InitApplet().

◆ PaintStaticControls()

static VOID PaintStaticControls ( IN LPDRAWITEMSTRUCT  drawItem,
IN PCONSOLE_STATE_INFO  pConInfo 
)
static

Definition at line 18 of file colors.c.

21{
22 HBRUSH hBrush;
24
25 index = min(drawItem->CtlID - IDC_STATIC_COLOR1,
26 ARRAYSIZE(pConInfo->ColorTable) - 1);
27
28 hBrush = CreateSolidBrush(pConInfo->ColorTable[index]);
29 FillRect(drawItem->hDC, &drawItem->rcItem, hBrush ? hBrush : GetStockObject(BLACK_BRUSH));
30 if (hBrush) DeleteObject(hBrush);
31
33 DrawFocusRect(drawItem->hDC, &drawItem->rcItem);
34}
#define index(s, c)
Definition: various.h:29
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
pKey DeleteObject()
GLuint index
Definition: glext.h:6031
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define BLACK_BRUSH
Definition: wingdi.h:896
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
BOOL WINAPI DrawFocusRect(_In_ HDC, _In_ LPCRECT)

Referenced by ColorsProc().

Variable Documentation

◆ ActiveStaticControl

DWORD ActiveStaticControl = 0
static

Definition at line 15 of file colors.c.

Referenced by ColorsProc(), and PaintStaticControls().