ReactOS  0.4.13-dev-687-g023794c
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 39 of file colors.c.

43 {
44  DWORD colorIndex;
46 
47  switch (uMsg)
48  {
49  case WM_INITDIALOG:
50  {
51  /* Set the valid range of the colour indicators */
55 
56  /* Select by default the screen background option */
59 
60  return TRUE;
61  }
62 
63  case WM_DRAWITEM:
64  {
66 
67  if (IDC_STATIC_COLOR1 <= drawItem->CtlID && drawItem->CtlID <= IDC_STATIC_COLOR16)
68  PaintStaticControls(drawItem, ConInfo);
69  else if (drawItem->CtlID == IDC_STATIC_SCREEN_COLOR)
70  PaintText(drawItem, ConInfo, Screen);
71  else if (drawItem->CtlID == IDC_STATIC_POPUP_COLOR)
72  PaintText(drawItem, ConInfo, Popup);
73 
74  return TRUE;
75  }
76 
77  case WM_NOTIFY:
78  {
79  switch (((LPNMHDR)lParam)->code)
80  {
81  case PSN_APPLY:
82  {
83  ApplyConsoleInfo(hDlg);
84  return TRUE;
85  }
86 
87  case UDN_DELTAPOS:
88  {
89  LPNMUPDOWN lpnmud = (LPNMUPDOWN)lParam;
90 
91  /* Get the current color */
92  colorIndex = ActiveStaticControl;
93  color = ConInfo->ColorTable[colorIndex];
94 
95  if (lpnmud->hdr.idFrom == IDC_UPDOWN_COLOR_RED)
96  {
97  lpnmud->iPos = min(max(lpnmud->iPos + lpnmud->iDelta, 0), 255);
98  color = RGB(lpnmud->iPos, GetGValue(color), GetBValue(color));
99  }
100  else if (lpnmud->hdr.idFrom == IDC_UPDOWN_COLOR_GREEN)
101  {
102  lpnmud->iPos = min(max(lpnmud->iPos + lpnmud->iDelta, 0), 255);
103  color = RGB(GetRValue(color), lpnmud->iPos, GetBValue(color));
104  }
105  else if (lpnmud->hdr.idFrom == IDC_UPDOWN_COLOR_BLUE)
106  {
107  lpnmud->iPos = min(max(lpnmud->iPos + lpnmud->iDelta, 0), 255);
108  color = RGB(GetRValue(color), GetGValue(color), lpnmud->iPos);
109  }
110  else
111  {
112  break;
113  }
114 
115  ConInfo->ColorTable[colorIndex] = color;
116  InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_COLOR1 + colorIndex), NULL, TRUE);
119 
120  PropSheet_Changed(GetParent(hDlg), hDlg);
121  break;
122  }
123  }
124 
125  break;
126  }
127 
128  case WM_COMMAND:
129  {
130  /* NOTE: both BN_CLICKED and STN_CLICKED == 0 */
132  {
137  {
138  switch (LOWORD(wParam))
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
175  {
176  colorIndex = LOWORD(wParam) - 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  if (LOWORD(wParam) == IDC_EDIT_COLOR_RED ||
221  {
222  DWORD value;
223 
224  /* Get the current colour */
225  colorIndex = ActiveStaticControl;
226  color = ConInfo->ColorTable[colorIndex];
227 
228  /* Modify the colour component */
229  switch (LOWORD(wParam))
230  {
231  case IDC_EDIT_COLOR_RED:
233  value = min(max(value, 0), 255);
235  break;
236 
239  value = min(max(value, 0), 255);
241  break;
242 
243  case IDC_EDIT_COLOR_BLUE:
245  value = min(max(value, 0), 255);
247  break;
248  }
249 
250  ConInfo->ColorTable[colorIndex] = color;
251  InvalidateRect(GetDlgItem(hDlg, IDC_STATIC_COLOR1 + colorIndex), NULL, TRUE);
254 
255  PropSheet_Changed(GetParent(hDlg), hDlg);
256  break;
257  }
258  }
259 
260  break;
261  }
262 
263  default:
264  break;
265  }
266 
267  return FALSE;
268 }
#define IDC_RADIO_POPUP_BACKGROUND
Definition: resource.h:71
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
USHORT ScreenAttributes
Definition: settings.h:47
NMHDR hdr
Definition: commctrl.h:2136
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
#define IDC_UPDOWN_COLOR_RED
Definition: resource.h:73
struct _NM_UPDOWN * LPNMUPDOWN
#define GetRValue(rgb)
Definition: wingdi.h:2913
#define PSN_APPLY
Definition: prsht.h:117
WPARAM wParam
Definition: combotst.c:138
#define IDC_STATIC_POPUP_COLOR
Definition: resource.h:79
#define GetGValue(rgb)
Definition: wingdi.h:2914
#define EN_KILLFOCUS
Definition: winuser.h:2007
static VOID PaintStaticControls(IN LPDRAWITEMSTRUCT drawItem, IN PCONSOLE_STATE_INFO pConInfo)
Definition: colors.c:18
GLuint color
Definition: glext.h:6243
#define IDC_STATIC_SCREEN_COLOR
Definition: resource.h:78
#define MakeAttrib(TextAttrib, BkgdAttrib)
Definition: settings.h:74
UINT_PTR idFrom
Definition: winuser.h:3132
COLORREF ColorTable[16]
Definition: settings.h:53
#define MAKELONG(a, b)
Definition: typedefs.h:248
#define IDC_EDIT_COLOR_RED
Definition: resource.h:72
smooth NULL
Definition: ftsmooth.c:416
UINT WINAPI GetDlgItemInt(_In_ HWND, _In_ int, _Out_opt_ PBOOL, _In_ BOOL)
#define IDC_EDIT_COLOR_BLUE
Definition: resource.h:76
VOID ApplyConsoleInfo(HWND hwndDlg)
Definition: console.c:88
LONG_PTR LPARAM
Definition: windef.h:208
#define IDC_EDIT_COLOR_GREEN
Definition: resource.h:74
#define IDC_RADIO_SCREEN_TEXT
Definition: resource.h:68
#define UDM_SETRANGE
Definition: commctrl.h:2113
#define IDC_UPDOWN_COLOR_BLUE
Definition: resource.h:77
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
#define BkgdAttribFromAttrib(Attribute)
Definition: settings.h:73
#define STN_CLICKED
Definition: winuser.h:2076
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define PropSheet_Changed(d, w)
Definition: prsht.h:326
DWORD COLORREF
Definition: windef.h:285
#define RGB(r, g, b)
Definition: wingdi.h:2918
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define BN_CLICKED
Definition: winuser.h:1907
unsigned long DWORD
Definition: ntddk_ex.h:95
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI SetDlgItemInt(_In_ HWND, _In_ int, _In_ UINT, _In_ BOOL)
#define UDN_DELTAPOS
Definition: commctrl.h:2141
#define WM_COMMAND
Definition: winuser.h:1722
#define TextAttribFromAttrib(Attribute)
Definition: settings.h:72
GLsizei const GLfloat * value
Definition: glext.h:6069
Definition: console.h:35
static DWORD ActiveStaticControl
Definition: colors.c:15
#define IDC_RADIO_SCREEN_BACKGROUND
Definition: resource.h:69
int iDelta
Definition: commctrl.h:2138
HWND WINAPI GetParent(_In_ HWND)
#define IDC_STATIC_COLOR1
Definition: resource.h:81
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define IDC_RADIO_POPUP_TEXT
Definition: resource.h:70
PCONSOLE_STATE_INFO ConInfo
Definition: console.c:23
#define min(a, b)
Definition: monoChain.cc:55
#define WM_DRAWITEM
Definition: winuser.h:1627
#define HIWORD(l)
Definition: typedefs.h:246
#define GetBValue(rgb)
Definition: wingdi.h:2915
Definition: console.h:34
BOOL WINAPI CheckRadioButton(_In_ HWND, _In_ int, _In_ int, _In_ int)
USHORT PopupAttributes
Definition: settings.h:48
VOID PaintText(IN LPDRAWITEMSTRUCT drawItem, IN PCONSOLE_STATE_INFO pConInfo, IN TEXT_TYPE TextMode)
Definition: layout.c:471
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define WM_NOTIFY
Definition: richedit.h:61
#define IDC_STATIC_COLOR16
Definition: resource.h:96
#define IDC_UPDOWN_COLOR_GREEN
Definition: resource.h:75

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;
23  DWORD index;
24 
25  index = min(drawItem->CtlID - IDC_STATIC_COLOR1,
26  ARRAYSIZE(pConInfo->ColorTable) - 1);
27 
28  hBrush = CreateSolidBrush(pConInfo->ColorTable[index]);
29  if (!hBrush) return;
30 
31  FillRect(drawItem->hDC, &drawItem->rcItem, hBrush);
32  DeleteObject(hBrush);
33 
35  DrawFocusRect(drawItem->hDC, &drawItem->rcItem);
36 }
BOOL WINAPI DrawFocusRect(_In_ HDC, _In_ LPCRECT)
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLuint index
Definition: glext.h:6031
unsigned long DWORD
Definition: ntddk_ex.h:95
#define index(s, c)
Definition: various.h:29
static DWORD ActiveStaticControl
Definition: colors.c:15
#define IDC_STATIC_COLOR1
Definition: resource.h:81
#define min(a, b)
Definition: monoChain.cc:55
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)

Referenced by ColorsProc().

Variable Documentation

◆ ActiveStaticControl

DWORD ActiveStaticControl = 0
static

Definition at line 15 of file colors.c.

Referenced by ColorsProc(), and PaintStaticControls().