diff --git a/doc/fixes36.2 b/doc/fixes36.2 index d470094ba..127f7ee1b 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -220,7 +220,7 @@ Qt: add Qt5 specific hints file for linux and Mac OS X (Ray Chason) Qt: enable compiling Qt5 on Windows (Ray Chason) Qt: entering extended commands, hide non-matching ones Qt: remember tile and font size -X11: implement menucolors and allow menus to obey inverse attribute +X11: implement menucolors and allow menus to obey some attributes X11: make key translations work with menus on Linux X11: allow mouse wheel scrolling to work in menus by default X11: handle paged menu control keys diff --git a/include/winX.h b/include/winX.h index 6939353c9..6bb771a9b 100644 --- a/include/winX.h +++ b/include/winX.h @@ -157,6 +157,8 @@ struct menu_info_t { XColor nh_colors[CLR_MAX]; XFontStruct *fs; /* Font for the window. */ + XFontStruct *boldfs; /* Bold font */ + Display *boldfs_dpy; long menu_count; /* number entered by user */ Dimension line_height; /* Total height of a line of text. */ Dimension internal_height; /* Internal height between widget & border */ @@ -297,6 +299,7 @@ E void FDECL(positionpopup, (Widget, BOOLEAN_P)); E struct xwindow *FDECL(find_widget, (Widget)); E Boolean FDECL(nhApproxColor, (Screen *, Colormap, char *, XColor *)); E void FDECL(get_widget_window_geometry, (Widget, int *, int *, int *, int *)); +E char *FDECL(fontname_boldify, (const char *)); E Dimension FDECL(nhFontHeight, (Widget)); E char FDECL(key_event_to_char, (XKeyEvent *)); E void FDECL(msgkey, (Widget, XtPointer, XEvent *)); diff --git a/sys/winnt/Makefile.gcc b/sys/winnt/Makefile.gcc index d46b94299..849724e55 100644 --- a/sys/winnt/Makefile.gcc +++ b/sys/winnt/Makefile.gcc @@ -966,7 +966,7 @@ $(DAT)/porthelp: $(MSWSYS)/porthelp $(subst /,\,@copy $(MSWSYS)/porthelp $@ >nul) nhdat: $(U)dlb_main.exe $(DAT)/data $(DAT)/oracles $(OPTIONS_FILE) \ - $(DAT)/quest.dat $(DAT)/rumors $(DAT)/help $(DAT)/hh $(DAT)/cmdhelp \ + $(DAT)/quest.dat $(DAT)/rumors $(DAT)/help $(DAT)/hh $(DAT)/cmdhelp $(DAT)/keyhelp \ $(DAT)/history $(DAT)/opthelp $(DAT)/wizhelp $(DAT)/dungeon \ $(DAT)/porthelp $(DAT)/license $(DAT)/engrave $(DAT)/epitaph $(DAT)/bogusmon $(DAT)/tribute $(O)sp_lev.tag $(subst /,\,echo data >$(DAT)/dlb.lst) @@ -980,6 +980,7 @@ nhdat: $(U)dlb_main.exe $(DAT)/data $(DAT)/oracles $(OPTIONS_FILE) \ $(subst /,\,echo help >>$(DAT)/dlb.lst) $(subst /,\,echo hh >>$(DAT)/dlb.lst) $(subst /,\,echo cmdhelp >>$(DAT)/dlb.lst) + $(subst /,\,echo keyhelp >>$(DAT)/dlb.lst) $(subst /,\,echo history >>$(DAT)/dlb.lst) $(subst /,\,echo opthelp >>$(DAT)/dlb.lst) $(subst /,\,echo wizhelp >>$(DAT)/dlb.lst) diff --git a/sys/winnt/Makefile.msc b/sys/winnt/Makefile.msc index 08acb206d..01c6dabaa 100644 --- a/sys/winnt/Makefile.msc +++ b/sys/winnt/Makefile.msc @@ -1033,7 +1033,7 @@ $(DAT)\porthelp: $(MSWSYS)\porthelp @copy $(MSWSYS)\porthelp $@ >nul nhdat: $(U)dlb_main.exe $(DAT)\data $(DAT)\oracles $(OPTIONS_FILE) \ - $(DAT)\quest.dat $(DAT)\rumors $(DAT)\help $(DAT)\hh $(DAT)\cmdhelp \ + $(DAT)\quest.dat $(DAT)\rumors $(DAT)\help $(DAT)\hh $(DAT)\cmdhelp $(DAT)\keyhelp \ $(DAT)\history $(DAT)\opthelp $(DAT)\wizhelp $(DAT)\dungeon $(DAT)\porthelp \ $(DAT)\license $(DAT)\engrave $(DAT)\epitaph $(DAT)\bogusmon $(DAT)\tribute $(O)sp_lev.tag cd $(DAT) @@ -1052,6 +1052,7 @@ nhdat: $(U)dlb_main.exe $(DAT)\data $(DAT)\oracles $(OPTIONS_FILE) \ echo help >>dlb.lst echo hh >>dlb.lst echo cmdhelp >>dlb.lst + echo keyhelp >>dlb.lst echo history >>dlb.lst echo opthelp >>dlb.lst echo wizhelp >>dlb.lst diff --git a/win/X11/winX.c b/win/X11/winX.c index fa94043cd..39c650973 100644 --- a/win/X11/winX.c +++ b/win/X11/winX.c @@ -484,6 +484,34 @@ int *x, *y, *width, *height; *y -= top; } +/* Change the full font name string so the weight is "bold" */ +char * +fontname_boldify(fontname) +const char *fontname; +{ + static char buf[BUFSZ]; + char *bufp = buf; + int idx = 0; + + while (*fontname) { + if (*fontname == '-') + idx++; + *bufp = *fontname; + if (idx == 3) { + strcat(buf, "bold"); + bufp += 5; + do { + fontname++; + } while (*fontname && *fontname != '-'); + } else { + bufp++; + fontname++; + } + } + *bufp = '\0'; + return buf; +} + #ifdef TEXTCOLOR /* ARGSUSED */ static void diff --git a/win/X11/winmenu.c b/win/X11/winmenu.c index 77009b8d7..9e0acff50 100644 --- a/win/X11/winmenu.c +++ b/win/X11/winmenu.c @@ -778,6 +778,31 @@ Widget form,under; return all; } +void +load_boldfont(wp, w) +struct xwindow *wp; +Widget w; +{ + Arg args[1]; + XFontStruct *fs; + unsigned long ret; + char *fontname; + Display *dpy; + + if (wp->menu_information->boldfs) + return; + + XtSetArg(args[0], nhStr(XtNfont), &fs); + XtGetValues(w, args, 1); + + if (!XGetFontProperty(fs, XA_FONT, &ret)) + return; + + wp->menu_information->boldfs_dpy = dpy = XtDisplay(w); + fontname = fontname_boldify(XGetAtomName(dpy, (Atom)ret)); + wp->menu_information->boldfs = XLoadQueryFont(dpy, fontname); +} + void menu_create_entries(wp, curr_menu) struct xwindow *wp; @@ -843,6 +868,13 @@ struct menu *curr_menu; : labelWidgetClass, wp->w, args, num_args); + if (attr == ATR_BOLD) { + load_boldfont(wp, curr->w); + num_args = 0; + XtSetArg(args[num_args], nhStr(XtNfont), wp->menu_information->boldfs); num_args++; + XtSetValues(curr->w, args, num_args); + } + if (canpick) XtAddCallback(linewidget, XtNcallback, menu_select, (XtPointer) curr); @@ -1001,6 +1033,13 @@ menu_item **menu_list; if (menu_info->is_up && permi && menu_info->curr_menu.base) { /* perm_invent window - explicitly destroy old menu entry widgets, without recreating whole window */ + WidgetList wlist; + Cardinal numchild; + num_args = 0; + XtSetArg(args[num_args], XtNchildren, &wlist); num_args++; + XtSetArg(args[num_args], XtNnumChildren, &numchild); num_args++; + XtGetValues(wp->w, args, num_args); + XtUnmanageChildren(wlist, numchild); for (curr = menu_info->curr_menu.base; curr; curr = curr->next) if (curr->w) XtDestroyWidget(curr->w); @@ -1285,6 +1324,8 @@ destroy_menu_window(wp) struct xwindow *wp; { clear_old_menu(wp); /* this will also destroy the widgets */ + if (wp->menu_information->boldfs) + XFreeFont(wp->menu_information->boldfs_dpy, wp->menu_information->boldfs); free((genericptr_t) wp->menu_information); wp->menu_information = (struct menu_info_t *) 0; wp->type = NHW_NONE; /* allow re-use */ diff --git a/win/win32/vs2015/files.props b/win/win32/vs2015/files.props index d905edbdd..e40a34cb9 100644 --- a/win/win32/vs2015/files.props +++ b/win/win32/vs2015/files.props @@ -218,6 +218,7 @@ + @@ -225,4 +226,4 @@ - \ No newline at end of file + diff --git a/win/win32/vs2017/files.props b/win/win32/vs2017/files.props index 7a93b0d68..e40a34cb9 100644 --- a/win/win32/vs2017/files.props +++ b/win/win32/vs2017/files.props @@ -218,6 +218,7 @@ +