add_menu follow-up, part 2 of interface adjustment
Remove menu_color support from the window port side of the interface.
The window port just has to honor the color parameter that was added
to the add_menu() interface definition in June 2022 commit
2770223d10, and let the core-side of
the interface handle things.
To that end, this does the following:
Removes the #define of add_menu() from include/winprocs.h and add a
real core-side add_menu() function to windows.c which acts as a
trampoline to the window port win_add_menu() function, while providing
a single location to adjust the parameters passed to the window port
function. get_menu_coloring() is now called in there.
Moves get_menu_coloring() from options.c into windows.c and makes it
static.
Removes all the calls to get_menu_coloring() from the tty, Qt, X11,
curses, and win32 interfaces and adjusts their code to simply honor
the color parameter in add_menu, similar to what the menu_headings
change from earlier today did.
This commit is contained in:
+3
-18
@@ -991,9 +991,6 @@ onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
char *p, *p1;
|
||||
int column;
|
||||
int spacing = 0;
|
||||
|
||||
int color = NO_COLOR, attr;
|
||||
boolean menucolr = FALSE;
|
||||
double monitorScale = win10_monitor_scale(hWnd);
|
||||
int tileXScaled = (int) (TILE_X * monitorScale);
|
||||
int tileYScaled = (int) (TILE_Y * monitorScale);
|
||||
@@ -1021,6 +1018,9 @@ onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
? menu_fg_color
|
||||
: (COLORREF) GetSysColor(DEFAULT_COLOR_FG_MENU));
|
||||
|
||||
if (item->color != NO_COLOR)
|
||||
(void) SetTextColor(lpdis->hDC, nhcolor_to_RGB(item->color));
|
||||
|
||||
GetTextMetrics(lpdis->hDC, &tm);
|
||||
spacing = tm.tmAveCharWidth;
|
||||
|
||||
@@ -1058,15 +1058,6 @@ onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
if (item->accelerator != 0) {
|
||||
buf[0] = item->accelerator;
|
||||
buf[1] = '\x0';
|
||||
|
||||
if (iflags.use_menu_color
|
||||
&& (menucolr = get_menu_coloring(item->str, &color, &attr))) {
|
||||
cached_font * menu_font = mswin_get_font(NHW_MENU, attr, lpdis->hDC, FALSE);
|
||||
SelectObject(lpdis->hDC, menu_font->hFont);
|
||||
if (color != NO_COLOR)
|
||||
SetTextColor(lpdis->hDC, nhcolor_to_RGB(color));
|
||||
}
|
||||
|
||||
SetRect(&drawRect, x, lpdis->rcItem.top, lpdis->rcItem.right,
|
||||
lpdis->rcItem.bottom);
|
||||
DrawText(lpdis->hDC, NH_A2W(buf, wbuf, 2), 1, &drawRect,
|
||||
@@ -1074,12 +1065,6 @@ onDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
x += tm.tmAveCharWidth + tm.tmOverhang + spacing;
|
||||
} else {
|
||||
/* heading */
|
||||
if (iflags.use_menu_color) {
|
||||
color = item->color;
|
||||
if (color != NO_COLOR)
|
||||
(void) SetTextColor(lpdis->hDC, nhcolor_to_RGB(color));
|
||||
}
|
||||
x += tileXScaled + tm.tmAveCharWidth + tm.tmOverhang + 2 * spacing;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user