W340-4 (from <Someone>)
Date: Sun, 24 Mar 2002 15:40:30 -0800 <email deleted> Subject: patch: nethack-graphical - menu window colors - W340-4 (menu checkboxes have a hard-coded white inner part) - use windowcolors settings for menu backgroud/foreground color <Someone>
This commit is contained in:
+48
-7
@@ -14,6 +14,11 @@
|
|||||||
#define NHMENU_STR_SIZE BUFSZ
|
#define NHMENU_STR_SIZE BUFSZ
|
||||||
#define MIN_TABSTOP_SIZE 8
|
#define MIN_TABSTOP_SIZE 8
|
||||||
|
|
||||||
|
#define DEFAULT_COLOR_BG_TEXT COLOR_WINDOW
|
||||||
|
#define DEFAULT_COLOR_FG_TEXT COLOR_WINDOWTEXT
|
||||||
|
#define DEFAULT_COLOR_BG_MENU COLOR_WINDOW
|
||||||
|
#define DEFAULT_COLOR_FG_MENU COLOR_WINDOWTEXT
|
||||||
|
|
||||||
typedef struct mswin_menu_item {
|
typedef struct mswin_menu_item {
|
||||||
int glyph;
|
int glyph;
|
||||||
ANY_P identifier;
|
ANY_P identifier;
|
||||||
@@ -416,6 +421,21 @@ BOOL CALLBACK MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
else
|
else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
case WM_CTLCOLORSTATIC: { /* sent by edit control before it is drawn */
|
||||||
|
HDC hdcEdit = (HDC) wParam;
|
||||||
|
HWND hwndEdit = (HWND) lParam;
|
||||||
|
if( hwndEdit == GetDlgItem(hWnd, IDC_MENU_TEXT) ) {
|
||||||
|
SetBkColor(hdcEdit,
|
||||||
|
text_bg_brush ? text_bg_color : (COLORREF)GetSysColor(DEFAULT_COLOR_BG_TEXT)
|
||||||
|
);
|
||||||
|
SetTextColor(hdcEdit,
|
||||||
|
text_fg_brush ? text_fg_color : (COLORREF)GetSysColor(DEFAULT_COLOR_FG_TEXT)
|
||||||
|
);
|
||||||
|
return (BOOL)(text_bg_brush
|
||||||
|
? text_bg_brush : SYSCLR_TO_BRUSH(DEFAULT_COLOR_BG_TEXT));
|
||||||
|
}
|
||||||
|
} return FALSE;
|
||||||
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
if( data ) {
|
if( data ) {
|
||||||
DeleteObject(data->bmpChecked);
|
DeleteObject(data->bmpChecked);
|
||||||
@@ -656,6 +676,14 @@ void SetMenuListType(HWND hWnd, int how)
|
|||||||
wndProcListViewOrig = (WNDPROC)GetWindowLong(control, GWL_WNDPROC);
|
wndProcListViewOrig = (WNDPROC)GetWindowLong(control, GWL_WNDPROC);
|
||||||
SetWindowLong(control, GWL_WNDPROC, (LONG)NHMenuListWndProc);
|
SetWindowLong(control, GWL_WNDPROC, (LONG)NHMenuListWndProc);
|
||||||
|
|
||||||
|
/* set control colors */
|
||||||
|
ListView_SetBkColor(control,
|
||||||
|
menu_bg_brush ? menu_bg_color : (COLORREF)GetSysColor(DEFAULT_COLOR_BG_MENU));
|
||||||
|
ListView_SetTextBkColor(control,
|
||||||
|
menu_bg_brush ? menu_bg_color : (COLORREF)GetSysColor(DEFAULT_COLOR_BG_MENU));
|
||||||
|
ListView_SetTextColor(control,
|
||||||
|
menu_fg_brush ? menu_fg_color : (COLORREF)GetSysColor(DEFAULT_COLOR_FG_MENU));
|
||||||
|
|
||||||
/* set control font */
|
/* set control font */
|
||||||
fnt = SendMessage(hWnd, WM_GETFONT, (WPARAM)0, (LPARAM)0);
|
fnt = SendMessage(hWnd, WM_GETFONT, (WPARAM)0, (LPARAM)0);
|
||||||
SendMessage(control, WM_SETFONT, (WPARAM)fnt, (LPARAM)0);
|
SendMessage(control, WM_SETFONT, (WPARAM)fnt, (LPARAM)0);
|
||||||
@@ -740,6 +768,7 @@ BOOL onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
TCHAR wbuf[BUFSZ];
|
TCHAR wbuf[BUFSZ];
|
||||||
RECT drawRect;
|
RECT drawRect;
|
||||||
DRAWTEXTPARAMS dtp;
|
DRAWTEXTPARAMS dtp;
|
||||||
|
COLORREF OldBg, OldFg, NewBg;
|
||||||
|
|
||||||
lpdis = (LPDRAWITEMSTRUCT) lParam;
|
lpdis = (LPDRAWITEMSTRUCT) lParam;
|
||||||
|
|
||||||
@@ -752,23 +781,33 @@ BOOL onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
tileDC = CreateCompatibleDC(lpdis->hDC);
|
tileDC = CreateCompatibleDC(lpdis->hDC);
|
||||||
saveFont = SelectObject(lpdis->hDC, mswin_get_font(NHW_MENU, item->attr, lpdis->hDC, FALSE));
|
saveFont = SelectObject(lpdis->hDC, mswin_get_font(NHW_MENU, item->attr, lpdis->hDC, FALSE));
|
||||||
|
NewBg = menu_bg_brush ? menu_bg_color : (COLORREF)GetSysColor(DEFAULT_COLOR_BG_MENU);
|
||||||
|
OldBg = SetBkColor(lpdis->hDC, NewBg);
|
||||||
|
OldFg = SetTextColor(lpdis->hDC,
|
||||||
|
menu_fg_brush ? menu_fg_color : (COLORREF)GetSysColor(DEFAULT_COLOR_FG_MENU));
|
||||||
|
|
||||||
GetTextMetrics(lpdis->hDC, &tm);
|
GetTextMetrics(lpdis->hDC, &tm);
|
||||||
|
|
||||||
x = lpdis->rcItem.left + 1;
|
x = lpdis->rcItem.left + 1;
|
||||||
|
|
||||||
/* print check mark */
|
/* print check mark */
|
||||||
if( NHMENU_IS_SELECTABLE(*item) ) {
|
if( NHMENU_IS_SELECTABLE(*item) ) {
|
||||||
HGDIOBJ saveBmp;
|
HGDIOBJ saveBrush;
|
||||||
|
HBRUSH hbrCheckMark;
|
||||||
char buf[2];
|
char buf[2];
|
||||||
|
|
||||||
switch(item->count) {
|
switch(item->count) {
|
||||||
case -1: saveBmp = SelectObject(tileDC, data->bmpChecked); break;
|
case -1: hbrCheckMark = CreatePatternBrush(data->bmpChecked); break;
|
||||||
case 0: saveBmp = SelectObject(tileDC, data->bmpNotChecked); break;
|
case 0: hbrCheckMark = CreatePatternBrush(data->bmpNotChecked); break;
|
||||||
default: saveBmp = SelectObject(tileDC, data->bmpCheckedCount); break;
|
default: hbrCheckMark = CreatePatternBrush(data->bmpCheckedCount); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
y = (lpdis->rcItem.bottom + lpdis->rcItem.top - TILE_Y) / 2;
|
y = (lpdis->rcItem.bottom + lpdis->rcItem.top - TILE_Y) / 2;
|
||||||
BitBlt(lpdis->hDC, x, y, TILE_X, TILE_Y, tileDC, 0, 0, SRCCOPY );
|
SetBrushOrgEx(lpdis->hDC, x, y, NULL);
|
||||||
|
saveBrush = SelectObject(lpdis->hDC, hbrCheckMark);
|
||||||
|
PatBlt(lpdis->hDC, x, y, TILE_X, TILE_Y, PATCOPY);
|
||||||
|
SelectObject(lpdis->hDC, saveBrush);
|
||||||
|
DeleteObject(hbrCheckMark);
|
||||||
|
|
||||||
x += TILE_X + 5;
|
x += TILE_X + 5;
|
||||||
|
|
||||||
@@ -780,7 +819,6 @@ BOOL onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
DrawText(lpdis->hDC, NH_A2W(buf, wbuf, 2), 1, &drawRect, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
|
DrawText(lpdis->hDC, NH_A2W(buf, wbuf, 2), 1, &drawRect, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX);
|
||||||
}
|
}
|
||||||
x += tm.tmAveCharWidth + tm.tmOverhang + 5;
|
x += tm.tmAveCharWidth + tm.tmOverhang + 5;
|
||||||
SelectObject(tileDC, saveBmp);
|
|
||||||
} else {
|
} else {
|
||||||
x += TILE_X + tm.tmAveCharWidth + tm.tmOverhang + 10;
|
x += TILE_X + tm.tmAveCharWidth + tm.tmOverhang + 10;
|
||||||
}
|
}
|
||||||
@@ -844,7 +882,8 @@ BOOL onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
drawRect.right = client_rt.right-1;
|
drawRect.right = client_rt.right-1;
|
||||||
drawRect.top = lpdis->rcItem.top;
|
drawRect.top = lpdis->rcItem.top;
|
||||||
drawRect.bottom = lpdis->rcItem.bottom;
|
drawRect.bottom = lpdis->rcItem.bottom;
|
||||||
FillRect(lpdis->hDC, &drawRect, (HBRUSH)GetClassLong(lpdis->hwndItem, GCL_HBRBACKGROUND) );
|
FillRect(lpdis->hDC, &drawRect,
|
||||||
|
menu_bg_brush ? menu_bg_brush : SYSCLR_TO_BRUSH(DEFAULT_COLOR_BG_MENU));
|
||||||
|
|
||||||
/* draw text */
|
/* draw text */
|
||||||
DrawText(lpdis->hDC, wbuf, _tcslen(wbuf), &drawRect,
|
DrawText(lpdis->hDC, wbuf, _tcslen(wbuf), &drawRect,
|
||||||
@@ -856,6 +895,8 @@ BOOL onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
DrawFocusRect(lpdis->hDC, &drawRect);
|
DrawFocusRect(lpdis->hDC, &drawRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetTextColor (lpdis->hDC, OldFg);
|
||||||
|
SetBkColor (lpdis->hDC, OldBg);
|
||||||
SelectObject(lpdis->hDC, saveFont);
|
SelectObject(lpdis->hDC, saveFont);
|
||||||
DeleteDC(tileDC);
|
DeleteDC(tileDC);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|||||||
+3
-6
@@ -1,9 +1,6 @@
|
|||||||
begin 600 mnsel.bmp
|
begin 600 mnsel.bmp
|
||||||
M0DWV`````````'8````H````$````!`````!``0``````(``````````````
|
M0DU^`````````#X````H````$````!`````!``$``````$````!T$@``=!(`
|
||||||
M````````````````````@```@````("``(````"``(``@(```,#`P`"`@(``
|
M`````````````````/___P```````````#_\```W_```,_P``"7\```F_```
|
||||||
M``#_``#_````__\`_P```/\`_P#__P``____````````````````````````
|
D)WP``">\```_W```/^P``#_T```__```/_P`````````````
|
||||||
M________``#_"/____\``/@`C____P``\`@(____``#P#X"/__\``/`/^`C_
|
|
||||||
M_P``\`__@(__``#XC__X"/\``/____^`CP``______@/``#_______\``/__
|
|
||||||
5_____P``````````````````````
|
|
||||||
`
|
`
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
begin 600 mnselcnt.bmp
|
begin 600 mnselcnt.bmp
|
||||||
M0DWV`````````'8````H````$````!`````!``0``````(``````````````
|
M0DU^`````````#X````H````$````!`````!``$``````$````!T$@``=!(`
|
||||||
M````````````````````@```@````("``(````"``(``@(```,#`P`"`@(``
|
M`````````````````/___P```````````#_\```__```.]P``#`,```[W```
|
||||||
M``#_``#_````__\`_P```/\`_P#__P``____````````````````````````
|
D.]P``#O<```[W```,`P``#O<```__```/_P`````````````
|
||||||
M________``#_______\``/_P__\/_P``_P````#_``#_\/__#_\``/_P__\/
|
|
||||||
M_P``__#__P__``#_\/__#_\``/\`````_P``__#__P__``#_______\``/__
|
|
||||||
5_____P``````````````````````
|
|
||||||
`
|
`
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
begin 600 mnunsel.bmp
|
begin 600 mnunsel.bmp
|
||||||
M0DWV`````````'8````H````$````!`````!``0``````(``````````````
|
M0DU^`````````#X````H````$````!`````!``$``````$````!T$@``=!(`
|
||||||
M````````````````````@```@````("``(````"``(``@(```,#`P`"`@(``
|
M`````````````````/___P```````````#_\```__```/_P``#_\```__```
|
||||||
M``#_``#_````__\`_P```/\`_P#__P``____````````````````````````
|
D/_P``#_\```__```/_P``#_\```__```/_P`````````````
|
||||||
M________``#_______\``/_______P``________``#_______\``/______
|
|
||||||
M_P``________``#_______\``/_______P``________``#_______\``/__
|
|
||||||
5_____P``````````````````````
|
|
||||||
`
|
`
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user