wineconsole: Replace hard-coded WCUSER_ColorMap with registry color_map.

Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hugh McMaster 2016-08-08 03:08:39 +00:00 committed by Alexandre Julliard
parent 1602eff3b8
commit b1e6d4c175
2 changed files with 21 additions and 19 deletions

View File

@ -147,6 +147,14 @@ static INT_PTR WINAPI WCUSER_OptionDlgProc(HWND hDlg, UINT msg, WPARAM wParam, L
return TRUE;
}
static COLORREF get_color(struct dialog_info *di, unsigned int idc)
{
LONG_PTR index;
index = GetWindowLongPtrW(GetDlgItem(di->hDlg, idc), 0);
return di->config.color_map[index];
}
/******************************************************************
* WCUSER_FontPreviewProc
*
@ -196,10 +204,10 @@ static LRESULT WINAPI WCUSER_FontPreviewProc(HWND hWnd, UINT msg, WPARAM wParam,
int len;
hOldFont = SelectObject(ps.hdc, hFont);
bkcolor = WCUSER_ColorMap[GetWindowLongW(GetDlgItem(di->hDlg, IDC_FNT_COLOR_BK), 0)];
bkcolor = get_color(di, IDC_FNT_COLOR_BK);
FillRect(ps.hdc, &ps.rcPaint, CreateSolidBrush(bkcolor));
SetBkColor(ps.hdc, bkcolor);
SetTextColor(ps.hdc, WCUSER_ColorMap[GetWindowLongW(GetDlgItem(di->hDlg, IDC_FNT_COLOR_FG), 0)]);
SetTextColor(ps.hdc, get_color(di, IDC_FNT_COLOR_FG));
len = LoadStringW(GetModuleHandleW(NULL), IDS_FNT_PREVIEW,
buf, sizeof(buf) / sizeof(buf[0]));
if (len)
@ -228,22 +236,25 @@ static LRESULT WINAPI WCUSER_ColorPreviewProc(HWND hWnd, UINT msg, WPARAM wParam
{
case WM_PAINT:
{
PAINTSTRUCT ps;
int i, step;
RECT client, r;
HBRUSH hbr;
PAINTSTRUCT ps;
int i, step;
RECT client, r;
struct dialog_info *di;
HBRUSH hbr;
BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &client);
step = client.right / 8;
di = (struct dialog_info *)GetWindowLongPtrW(GetParent(hWnd), DWLP_USER);
for (i = 0; i < 16; i++)
{
r.top = (i / 8) * (client.bottom / 2);
r.bottom = r.top + client.bottom / 2;
r.left = (i & 7) * step;
r.right = r.left + step;
hbr = CreateSolidBrush(WCUSER_ColorMap[i]);
hbr = CreateSolidBrush(di->config.color_map[i]);
FillRect(ps.hdc, &r, hbr);
DeleteObject(hbr);
if (GetWindowLongW(hWnd, 0) == i)

View File

@ -30,15 +30,6 @@ WINE_DECLARE_DEBUG_CHANNEL(wc_font);
UINT g_uiDefaultCharset;
/* mapping console colors to RGB values */
const COLORREF WCUSER_ColorMap[16] =
{
RGB(0x00, 0x00, 0x00), RGB(0x00, 0x00, 0x80), RGB(0x00, 0x80, 0x00), RGB(0x00, 0x80, 0x80),
RGB(0x80, 0x00, 0x00), RGB(0x80, 0x00, 0x80), RGB(0x80, 0x80, 0x00), RGB(0xC0, 0xC0, 0xC0),
RGB(0x80, 0x80, 0x80), RGB(0x00, 0x00, 0xFF), RGB(0x00, 0xFF, 0x00), RGB(0x00, 0xFF, 0xFF),
RGB(0xFF, 0x00, 0x00), RGB(0xFF, 0x00, 0xFF), RGB(0xFF, 0xFF, 0x00), RGB(0xFF, 0xFF, 0xFF),
};
static BOOL WCUSER_SetFont(struct inner_data* data, const LOGFONTW* font);
/******************************************************************
@ -76,8 +67,8 @@ static void WCUSER_FillMemDC(const struct inner_data* data, int upd_tp, int upd_
for (i = 0; i < data->curcfg.sb_width; i++)
{
attr = cell[i].Attributes;
SetBkColor(PRIVATE(data)->hMemDC, WCUSER_ColorMap[(attr>>4)&0x0F]);
SetTextColor(PRIVATE(data)->hMemDC, WCUSER_ColorMap[attr&0x0F]);
SetBkColor(PRIVATE(data)->hMemDC, data->curcfg.color_map[(attr >> 4) & 0x0F]);
SetTextColor(PRIVATE(data)->hMemDC, data->curcfg.color_map[attr & 0x0F]);
for (k = i; k < data->curcfg.sb_width && cell[k].Attributes == attr; k++)
{
line[k - i] = cell[k].Char.UnicodeChar;
@ -86,7 +77,7 @@ static void WCUSER_FillMemDC(const struct inner_data* data, int upd_tp, int upd_
ExtTextOutW( PRIVATE(data)->hMemDC, i * data->curcfg.cell_width, j * data->curcfg.cell_height,
0, NULL, line, k - i, dx );
if (PRIVATE(data)->ext_leading &&
(hbr = CreateSolidBrush(WCUSER_ColorMap[(attr>>4)&0x0F])))
(hbr = CreateSolidBrush(data->curcfg.color_map[(attr >> 4) & 0x0F])))
{
r.left = i * data->curcfg.cell_width;
r.top = (j + 1) * data->curcfg.cell_height - PRIVATE(data)->ext_leading;