Hugh McMaster : wineconsole: Replace hard-coded WCUSER_ColorMap with registry color_map.

Alexandre Julliard julliard at winehq.org
Tue Aug 9 11:11:03 CDT 2016


Module: wine
Branch: master
Commit: b1e6d4c1751fe0a69be87ba2cf9c167b3b1d7ac4
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b1e6d4c1751fe0a69be87ba2cf9c167b3b1d7ac4

Author: Hugh McMaster <hugh.mcmaster at outlook.com>
Date:   Mon Aug  8 03:08:39 2016 +0000

wineconsole: Replace hard-coded WCUSER_ColorMap with registry color_map.

Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/wineconsole/dialog.c | 25 ++++++++++++++++++-------
 programs/wineconsole/user.c   | 15 +++------------
 2 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/programs/wineconsole/dialog.c b/programs/wineconsole/dialog.c
index 04edfd1..9a14184 100644
--- a/programs/wineconsole/dialog.c
+++ b/programs/wineconsole/dialog.c
@@ -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)
diff --git a/programs/wineconsole/user.c b/programs/wineconsole/user.c
index 40a0757..eb68373 100644
--- a/programs/wineconsole/user.c
+++ b/programs/wineconsole/user.c
@@ -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;




More information about the wine-cvs mailing list