comparison lwlib/xlwmenu.c @ 4969:cbe181529c34

Automatic merge
author Ben Wing <ben@xemacs.org>
date Wed, 03 Feb 2010 21:46:21 -0600
parents a6c778975d7d
children ade4c7e2c6cb
comparison
equal deleted inserted replaced
4968:4d35e52790f8 4969:cbe181529c34
44 #undef XmFONTLIST_DEFAULT_TAG 44 #undef XmFONTLIST_DEFAULT_TAG
45 #define XmFONTLIST_DEFAULT_TAG XmSTRING_DEFAULT_CHARSET 45 #define XmFONTLIST_DEFAULT_TAG XmSTRING_DEFAULT_CHARSET
46 #endif /* XmVersion < 1.2 */ 46 #endif /* XmVersion < 1.2 */
47 #endif 47 #endif
48 48
49 /* #### we may want to turn off USE_XFT here if !USE_XFT_MENUBARS 49 /* #### we may want to turn off HAVE_XFT here if !HAVE_XFT_MENUBARS
50 In fact, maybe that's the right interface overall? */ 50 In fact, maybe that's the right interface overall? */
51 #include "lwlib-fonts.h" 51 #include "lwlib-fonts.h"
52 #include "lwlib-colors.h" 52 #include "lwlib-colors.h"
53 #include "xlwmenuP.h" 53 #include "xlwmenuP.h"
54 54
96 #define nullpixres(name,_class,member) \ 96 #define nullpixres(name,_class,member) \
97 pixres (name, _class, member, XtRImmediate, -1) 97 pixres (name, _class, member, XtRImmediate, -1)
98 #define pmres(name,cls,member) \ 98 #define pmres(name,cls,member) \
99 Xt_RESOURCE (name, cls, XtRPixmap, Pixmap, offset(member), XtRImmediate, None) 99 Xt_RESOURCE (name, cls, XtRPixmap, Pixmap, offset(member), XtRImmediate, None)
100 100
101 #if defined(NEED_MOTIF) && !defined(USE_XFT_MENUBARS) 101 #if defined(NEED_MOTIF) && !defined(HAVE_XFT_MENUBARS)
102 /* There are three font list resources, so that we can accept either of 102 /* There are three font list resources, so that we can accept either of
103 the resources *fontList: or *font:, and so that we can tell the 103 the resources *fontList: or *font:, and so that we can tell the
104 difference between them being specified, and being defaulted to a 104 difference between them being specified, and being defaulted to a
105 font from the XtRString specified here. */ 105 font from the XtRString specified here. */
106 mflres (XmNfontList, XmCFontList, font_list, XtRImmediate, 0), 106 mflres (XmNfontList, XmCFontList, font_list, XtRImmediate, 0),
111 *fontList resource set, or at least know how to deal with this. */ 111 *fontList resource set, or at least know how to deal with this. */
112 XtRString, (XtPointer) "-*-helvetica-bold-r-*-*-*-120-*-*-*-*-iso8859-1"), 112 XtRString, (XtPointer) "-*-helvetica-bold-r-*-*-*-120-*-*-*-*-iso8859-1"),
113 #else 113 #else
114 fontres (XtNfont, XtCFont, XtRFontStruct, XFontStruct *, font, 114 fontres (XtNfont, XtCFont, XtRFontStruct, XFontStruct *, font,
115 "XtDefaultFont"), 115 "XtDefaultFont"),
116 #ifdef USE_XFT_MENUBARS 116 #ifdef HAVE_XFT_MENUBARS
117 fontres (XtNfcFontName, XtCFcFontName, XtRString, String, fcFontName, 117 fontres (XtNfcFontName, XtCFcFontName, XtRString, String, fcFontName,
118 "sans-serif-12:bold"), 118 "sans-serif-12:bold"),
119 /* #### This needs to be fixed to give a proper type and converter for 119 /* #### This needs to be fixed to give a proper type and converter for
120 XftFonts. See also xlwtabs.c. */ 120 XftFonts. See also xlwtabs.c. */
121 fontres (XtNxftFont, XtCXftFont, XtRString, XtPointer, xftFontName, 121 fontres (XtNxftFont, XtCXftFont, XtRString, XtPointer, xftFontName,
189 static void XlwMenuClassInitialize (void); 189 static void XlwMenuClassInitialize (void);
190 static void Start (Widget w, XEvent *ev, String *params, Cardinal *num_params); 190 static void Start (Widget w, XEvent *ev, String *params, Cardinal *num_params);
191 static void Drag (Widget w, XEvent *ev, String *params, Cardinal *num_params); 191 static void Drag (Widget w, XEvent *ev, String *params, Cardinal *num_params);
192 static void Select(Widget w, XEvent *ev, String *params, Cardinal *num_params); 192 static void Select(Widget w, XEvent *ev, String *params, Cardinal *num_params);
193 193
194 #if defined(NEED_MOTIF) && !defined(USE_XFT_MENUBARS) 194 #if defined(NEED_MOTIF) && !defined(HAVE_XFT_MENUBARS)
195 static XFontStruct *default_font_of_font_list (XmFontList); 195 static XFontStruct *default_font_of_font_list (XmFontList);
196 #endif 196 #endif
197 197
198 static XtActionsRec 198 static XtActionsRec
199 xlwMenuActionsList [] = 199 xlwMenuActionsList [] =
328 } 328 }
329 329
330 /* Size code */ 330 /* Size code */
331 static int 331 static int
332 string_width (XlwMenuWidget mw, 332 string_width (XlwMenuWidget mw,
333 #if defined(NEED_MOTIF) && !defined(USE_XFT_MENUBARS) 333 #if defined(NEED_MOTIF) && !defined(HAVE_XFT_MENUBARS)
334 XmString s 334 XmString s
335 #else 335 #else
336 char *s 336 char *s
337 #endif 337 #endif
338 ) 338 )
339 { 339 {
340 #if defined(NEED_MOTIF) && !defined(USE_XFT_MENUBARS) 340 #if defined(NEED_MOTIF) && !defined(HAVE_XFT_MENUBARS)
341 Dimension width, height; 341 Dimension width, height;
342 XmStringExtent (mw->menu.font_list, s, &width, &height); 342 XmStringExtent (mw->menu.font_list, s, &width, &height);
343 return width; 343 return width;
344 #else 344 #else
345 # ifdef USE_XFONTSET 345 # ifdef USE_XFONTSET
346 XRectangle ri, rl; 346 XRectangle ri, rl;
347 XmbTextExtents (mw->menu.font_set, s, strlen (s), &ri, &rl); 347 XmbTextExtents (mw->menu.font_set, s, strlen (s), &ri, &rl);
348 return rl.width; 348 return rl.width;
349 # else 349 # else
350 #ifdef USE_XFT_MENUBARS 350 #ifdef HAVE_XFT_MENUBARS
351 XGlyphInfo glyphinfo; 351 XGlyphInfo glyphinfo;
352 XftTextExtents8 (XtDisplay (mw), mw->menu.renderFont, (FcChar8 *) s, 352 XftTextExtents8 (XtDisplay (mw), mw->menu.renderFont, (FcChar8 *) s,
353 strlen (s), &glyphinfo); 353 strlen (s), &glyphinfo);
354 return glyphinfo.xOff; 354 return glyphinfo.xOff;
355 #else 355 #else
382 massaged_resource_char ['.'] = '_'; /* Convert Buffers... to buffers___ */ 382 massaged_resource_char ['.'] = '_'; /* Convert Buffers... to buffers___ */
383 } 383 }
384 384
385 static int 385 static int
386 string_width_u (XlwMenuWidget mw, 386 string_width_u (XlwMenuWidget mw,
387 #if defined(NEED_MOTIF) && !defined(USE_XFT_MENUBARS) 387 #if defined(NEED_MOTIF) && !defined(HAVE_XFT_MENUBARS)
388 XmString string 388 XmString string
389 #else 389 #else
390 char *string 390 char *string
391 #endif 391 #endif
392 ) 392 )
393 { 393 {
394 #if defined(NEED_MOTIF) && !defined(USE_XFT_MENUBARS) 394 #if defined(NEED_MOTIF) && !defined(HAVE_XFT_MENUBARS)
395 Dimension width, height; 395 Dimension width, height;
396 XmString newstring; 396 XmString newstring;
397 #else 397 #else
398 # ifdef USE_XFONTSET 398 # ifdef USE_XFONTSET
399 XRectangle ri, rl; 399 XRectangle ri, rl;
400 # else /* ! USE_XFONTSET */ 400 # else /* ! USE_XFONTSET */
401 #ifdef USE_XFT_MENUBARS 401 #ifdef HAVE_XFT_MENUBARS
402 XGlyphInfo glyphinfo; 402 XGlyphInfo glyphinfo;
403 #else 403 #else
404 XCharStruct xcs; 404 XCharStruct xcs;
405 int drop; 405 int drop;
406 #endif 406 #endif
409 char* newchars; 409 char* newchars;
410 int charslength; 410 int charslength;
411 char *chars; 411 char *chars;
412 int i, j; 412 int i, j;
413 413
414 #if defined(NEED_MOTIF) && !defined(USE_XFT_MENUBARS) 414 #if defined(NEED_MOTIF) && !defined(HAVE_XFT_MENUBARS)
415 chars = ""; 415 chars = "";
416 if (!XmStringGetLtoR (string, XmFONTLIST_DEFAULT_TAG, &chars)) 416 if (!XmStringGetLtoR (string, XmFONTLIST_DEFAULT_TAG, &chars))
417 chars = ""; 417 chars = "";
418 #else 418 #else
419 chars = string; 419 chars = string;
426 i++; 426 i++;
427 else 427 else
428 newchars[j++] = chars[i]; 428 newchars[j++] = chars[i];
429 newchars[j] = '\0'; 429 newchars[j] = '\0';
430 430
431 #if defined(NEED_MOTIF) && !defined(USE_XFT_MENUBARS) 431 #if defined(NEED_MOTIF) && !defined(HAVE_XFT_MENUBARS)
432 newstring = XmStringLtoRCreate (newchars, XmFONTLIST_DEFAULT_TAG); 432 newstring = XmStringLtoRCreate (newchars, XmFONTLIST_DEFAULT_TAG);
433 XmStringExtent (mw->menu.font_list, newstring, &width, &height); 433 XmStringExtent (mw->menu.font_list, newstring, &width, &height);
434 XmStringFree (newstring); 434 XmStringFree (newstring);
435 XtFree (chars); 435 XtFree (chars);
436 return width; 436 return width;
437 #else 437 #else
438 # ifdef USE_XFONTSET 438 # ifdef USE_XFONTSET
439 XmbTextExtents (mw->menu.font_set, newchars, j, &ri, &rl); 439 XmbTextExtents (mw->menu.font_set, newchars, j, &ri, &rl);
440 return rl.width; 440 return rl.width;
441 # else /* ! USE_XFONTSET */ 441 # else /* ! USE_XFONTSET */
442 #ifdef USE_XFT_MENUBARS 442 #ifdef HAVE_XFT_MENUBARS
443 XftTextExtents8 (XtDisplay (mw), mw->menu.renderFont, (FcChar8 *) newchars, 443 XftTextExtents8 (XtDisplay (mw), mw->menu.renderFont, (FcChar8 *) newchars,
444 j, &glyphinfo); 444 j, &glyphinfo);
445 return glyphinfo.xOff; 445 return glyphinfo.xOff;
446 #else 446 #else
447 XTextExtents (mw->menu.font, newchars, j, &drop, &drop, &drop, &xcs); 447 XTextExtents (mw->menu.font, newchars, j, &drop, &drop, &drop, &xcs);
611 } 611 }
612 612
613 return result; 613 return result;
614 } 614 }
615 615
616 #if defined(NEED_MOTIF) && !defined(USE_XFT_MENUBARS) 616 #if defined(NEED_MOTIF) && !defined(HAVE_XFT_MENUBARS)
617 617
618 static XmString 618 static XmString
619 resource_widget_value (XlwMenuWidget mw, widget_value *val) 619 resource_widget_value (XlwMenuWidget mw, widget_value *val)
620 { 620 {
621 if (!val->toolkit_data) 621 if (!val->toolkit_data)
762 #endif /* !Motif */ 762 #endif /* !Motif */
763 763
764 #define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \ 764 #define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \
765 ? ((unsigned long) (x)) : ((unsigned long) (y))) 765 ? ((unsigned long) (x)) : ((unsigned long) (y)))
766 766
767 #ifdef USE_XFT_MENUBARS 767 #ifdef HAVE_XFT_MENUBARS
768 static int 768 static int
769 x_xft_text_width (Display *dpy, XftFont *xft_font, char *run, int len) 769 x_xft_text_width (Display *dpy, XftFont *xft_font, char *run, int len)
770 { 770 {
771 static XGlyphInfo glyphinfo; 771 static XGlyphInfo glyphinfo;
772 772
780 /* Code for drawing strings. */ 780 /* Code for drawing strings. */
781 static void 781 static void
782 string_draw (XlwMenuWidget mw, 782 string_draw (XlwMenuWidget mw,
783 Window window, 783 Window window,
784 int x, int y, 784 int x, int y,
785 #ifdef USE_XFT_MENUBARS 785 #ifdef HAVE_XFT_MENUBARS
786 XftColor *color, 786 XftColor *color,
787 XftColor *colorBg, 787 XftColor *colorBg,
788 #else 788 #else
789 GC gc, 789 GC gc,
790 #endif 790 #endif
791 #if defined(NEED_MOTIF) && !defined(USE_XFT_MENUBARS) 791 #if defined(NEED_MOTIF) && !defined(HAVE_XFT_MENUBARS)
792 XmString string 792 XmString string
793 #else 793 #else
794 char *string 794 char *string
795 #endif 795 #endif
796 ) 796 )
797 { 797 {
798 #if defined(NEED_MOTIF) && !defined(USE_XFT_MENUBARS) 798 #if defined(NEED_MOTIF) && !defined(HAVE_XFT_MENUBARS)
799 XmStringDraw (XtDisplay (mw), window, 799 XmStringDraw (XtDisplay (mw), window,
800 mw->menu.font_list, 800 mw->menu.font_list,
801 string, gc, 801 string, gc,
802 x, y, 802 x, y,
803 1000, /* ???? width */ 803 1000, /* ???? width */
804 XmALIGNMENT_BEGINNING, 804 XmALIGNMENT_BEGINNING,
805 0, /* ???? layout_direction */ 805 0, /* ???? layout_direction */
806 0); 806 0);
807 #else 807 #else
808 # ifdef USE_XFT_MENUBARS 808 # ifdef HAVE_XFT_MENUBARS
809 Display *display = XtDisplay (mw); 809 Display *display = XtDisplay (mw);
810 Visual *visual = DefaultVisualOfScreen (XtScreen (mw)); 810 Visual *visual = DefaultVisualOfScreen (XtScreen (mw));
811 Colormap cmap = mw->core.colormap; 811 Colormap cmap = mw->core.colormap;
812 XftDraw *xftDraw = XftDrawCreate (display, window, visual, cmap); 812 XftDraw *xftDraw = XftDrawCreate (display, window, visual, cmap);
813 XftFont *renderFont = mw->menu.renderFont; 813 XftFont *renderFont = mw->menu.renderFont;
826 x, y + mw->menu.font_ascent, string, strlen (string)); 826 x, y + mw->menu.font_ascent, string, strlen (string));
827 # else 827 # else
828 XDrawString (XtDisplay (mw), window, gc, 828 XDrawString (XtDisplay (mw), window, gc,
829 x, y + mw->menu.font_ascent, string, strlen (string)); 829 x, y + mw->menu.font_ascent, string, strlen (string));
830 # endif /* USE_XFONTSET */ 830 # endif /* USE_XFONTSET */
831 # endif /* USE_XFT_MENUBARS */ 831 # endif /* HAVE_XFT_MENUBARS */
832 #endif /* NEED_MOTIF */ 832 #endif /* NEED_MOTIF */
833 } 833 }
834 834
835 static int 835 static int
836 string_draw_range ( 836 string_draw_range (
837 XlwMenuWidget mw, 837 XlwMenuWidget mw,
838 Window window, 838 Window window,
839 int x, int y, 839 int x, int y,
840 #ifdef USE_XFT_MENUBARS 840 #ifdef HAVE_XFT_MENUBARS
841 XftColor *color, 841 XftColor *color,
842 XftColor *colorBg, 842 XftColor *colorBg,
843 #else 843 #else
844 GC gc, 844 GC gc,
845 #endif 845 #endif
846 char *string, 846 char *string,
847 int start, 847 int start,
848 int end 848 int end
849 ) 849 )
850 { 850 {
851 #if defined(NEED_MOTIF) && !defined(USE_XFT_MENUBARS) 851 #if defined(NEED_MOTIF) && !defined(HAVE_XFT_MENUBARS)
852 Dimension width, height; 852 Dimension width, height;
853 XmString newstring; 853 XmString newstring;
854 int c; 854 int c;
855 855
856 if (end <= start) 856 if (end <= start)
883 x, y + mw->menu.font_ascent, &string[start], end - start); 883 x, y + mw->menu.font_ascent, &string[start], end - start);
884 XmbTextExtents ( 884 XmbTextExtents (
885 mw->menu.font_set, &string[start], end - start, &ri, &rl); 885 mw->menu.font_set, &string[start], end - start, &ri, &rl);
886 return rl.width; 886 return rl.width;
887 # else 887 # else
888 #ifdef USE_XFT_MENUBARS 888 #ifdef HAVE_XFT_MENUBARS
889 if (end <= start) 889 if (end <= start)
890 return 0; 890 return 0;
891 else 891 else
892 { 892 {
893 XGlyphInfo glyphinfo; 893 XGlyphInfo glyphinfo;
935 935
936 static void 936 static void
937 string_draw_u (XlwMenuWidget mw, 937 string_draw_u (XlwMenuWidget mw,
938 Window window, 938 Window window,
939 int x, int y, 939 int x, int y,
940 #ifdef USE_XFT_MENUBARS 940 #ifdef HAVE_XFT_MENUBARS
941 XftColor *color, XftColor *colorBg, GC gc, 941 XftColor *color, XftColor *colorBg, GC gc,
942 #else 942 #else
943 GC gc, 943 GC gc,
944 #endif 944 #endif
945 #if defined(NEED_MOTIF) && !defined(USE_XFT_MENUBARS) 945 #if defined(NEED_MOTIF) && !defined(HAVE_XFT_MENUBARS)
946 XmString string 946 XmString string
947 #else 947 #else
948 char *string 948 char *string
949 #endif 949 #endif
950 ) 950 )
951 { 951 {
952 int i, s = 0; 952 int i, s = 0;
953 char *chars; 953 char *chars;
954 954
955 #if defined(NEED_MOTIF) && !defined(USE_XFT_MENUBARS) 955 #if defined(NEED_MOTIF) && !defined(HAVE_XFT_MENUBARS)
956 chars = ""; 956 chars = "";
957 if (!XmStringGetLtoR (string, XmFONTLIST_DEFAULT_TAG, &chars)) 957 if (!XmStringGetLtoR (string, XmFONTLIST_DEFAULT_TAG, &chars))
958 chars = ""; 958 chars = "";
959 #else 959 #else
960 chars = string; 960 chars = string;
961 #endif 961 #endif
962 for (i=0; chars[i]; ++i) { 962 for (i=0; chars[i]; ++i) {
963 if (chars[i] == '%' && chars[i+1] == '_') { 963 if (chars[i] == '%' && chars[i+1] == '_') {
964 int w; 964 int w;
965 965
966 #ifdef USE_XFT_MENUBARS 966 #ifdef HAVE_XFT_MENUBARS
967 x += string_draw_range (mw, window, x, y, color, colorBg, chars, s, i); 967 x += string_draw_range (mw, window, x, y, color, colorBg, chars, s, i);
968 w = string_draw_range (mw, window, x, y, color, colorBg, chars, i+2, i+3); 968 w = string_draw_range (mw, window, x, y, color, colorBg, chars, i+2, i+3);
969 #else 969 #else
970 x += string_draw_range (mw, window, x, y, gc, chars, s, i); 970 x += string_draw_range (mw, window, x, y, gc, chars, s, i);
971 w = string_draw_range (mw, window, x, y, gc, chars, i+2, i+3); 971 w = string_draw_range (mw, window, x, y, gc, chars, i+2, i+3);
978 x += w; 978 x += w;
979 s = i + 3; 979 s = i + 3;
980 i += 2; 980 i += 2;
981 } 981 }
982 } 982 }
983 #ifdef USE_XFT_MENUBARS 983 #ifdef HAVE_XFT_MENUBARS
984 x += string_draw_range (mw, window, x, y, color, colorBg, chars, s, i); 984 x += string_draw_range (mw, window, x, y, color, colorBg, chars, s, i);
985 #else 985 #else
986 x += string_draw_range (mw, window, x, y, gc, chars, s, i); 986 x += string_draw_range (mw, window, x, y, gc, chars, s, i);
987 #endif 987 #endif
988 #if defined(NEED_MOTIF) && !defined(USE_XFT_MENUBARS) 988 #if defined(NEED_MOTIF) && !defined(HAVE_XFT_MENUBARS)
989 XtFree (chars); 989 XtFree (chars);
990 #endif 990 #endif
991 } 991 }
992 992
993 static void /* XXX */ 993 static void /* XXX */
994 binding_draw (XlwMenuWidget mw, Window w, int x, int y, 994 binding_draw (XlwMenuWidget mw, Window w, int x, int y,
995 #ifdef USE_XFT_MENUBARS 995 #ifdef HAVE_XFT_MENUBARS
996 XftColor *color, 996 XftColor *color,
997 XftColor *colorBg, 997 XftColor *colorBg,
998 #else 998 #else
999 GC gc, 999 GC gc,
1000 #endif 1000 #endif
1001 char *value) 1001 char *value)
1002 { 1002 {
1003 #if defined(NEED_MOTIF) && !defined(USE_XFT_MENUBARS) 1003 #if defined(NEED_MOTIF) && !defined(HAVE_XFT_MENUBARS)
1004 XmString xm_value = XmStringCreateLtoR(value, XmSTRING_DEFAULT_CHARSET); 1004 XmString xm_value = XmStringCreateLtoR(value, XmSTRING_DEFAULT_CHARSET);
1005 string_draw (mw, w, x, y, gc, xm_value); 1005 string_draw (mw, w, x, y, gc, xm_value);
1006 XmStringFree (xm_value); 1006 XmStringFree (xm_value);
1007 #else 1007 #else
1008 #ifdef USE_XFT_MENUBARS 1008 #ifdef HAVE_XFT_MENUBARS
1009 string_draw (mw, w, x, y, color, colorBg, value); 1009 string_draw (mw, w, x, y, color, colorBg, value);
1010 #else 1010 #else
1011 string_draw (mw, w, x, y, gc, value); 1011 string_draw (mw, w, x, y, gc, value);
1012 #endif 1012 #endif
1013 #endif 1013 #endif
1650 unsigned int UNUSED (binding_tab)) 1650 unsigned int UNUSED (binding_tab))
1651 { 1651 {
1652 int y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin; 1652 int y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin;
1653 GC gc; 1653 GC gc;
1654 1654
1655 #ifdef USE_XFT_MENUBARS 1655 #ifdef HAVE_XFT_MENUBARS
1656 XftColor color, colorBg; 1656 XftColor color, colorBg;
1657 Display *display = XtDisplay (mw); 1657 Display *display = XtDisplay (mw);
1658 Colormap cmap = mw->core.colormap; 1658 Colormap cmap = mw->core.colormap;
1659 Visual *visual; 1659 Visual *visual;
1660 int ignored, pixel, pixelBg; 1660 int ignored, pixel, pixelBg;
1665 if (!label_offset) 1665 if (!label_offset)
1666 label_offset = mw->menu.shadow_thickness + mw->menu.horizontal_margin; 1666 label_offset = mw->menu.shadow_thickness + mw->menu.horizontal_margin;
1667 1667
1668 if (highlighted && (in_menubar || val->contents)) 1668 if (highlighted && (in_menubar || val->contents))
1669 { 1669 {
1670 #ifdef USE_XFT_MENUBARS 1670 #ifdef HAVE_XFT_MENUBARS
1671 pixel = mw->menu.highlight_foreground; 1671 pixel = mw->menu.highlight_foreground;
1672 pixelBg = mw->core.background_pixel; 1672 pixelBg = mw->core.background_pixel;
1673 #endif 1673 #endif
1674 gc = mw->menu.highlight_gc; 1674 gc = mw->menu.highlight_gc;
1675 } 1675 }
1676 else if (in_menubar || val->contents) 1676 else if (in_menubar || val->contents)
1677 { 1677 {
1678 #ifdef USE_XFT_MENUBARS 1678 #ifdef HAVE_XFT_MENUBARS
1679 pixel = mw->menu.foreground; 1679 pixel = mw->menu.foreground;
1680 pixelBg = mw->core.background_pixel; 1680 pixelBg = mw->core.background_pixel;
1681 #endif 1681 #endif
1682 gc = mw->menu.foreground_gc; 1682 gc = mw->menu.foreground_gc;
1683 } 1683 }
1684 else 1684 else
1685 { 1685 {
1686 #ifdef USE_XFT_MENUBARS 1686 #ifdef HAVE_XFT_MENUBARS
1687 pixel = mw->menu.title_foreground; 1687 pixel = mw->menu.title_foreground;
1688 pixelBg = mw->core.background_pixel; 1688 pixelBg = mw->core.background_pixel;
1689 #endif 1689 #endif
1690 gc = mw->menu.title_gc; 1690 gc = mw->menu.title_gc;
1691 } 1691 }
1692 #ifdef USE_XFT_MENUBARS 1692 #ifdef HAVE_XFT_MENUBARS
1693 color = xft_convert_color (display, cmap, visual, pixel, 0); 1693 color = xft_convert_color (display, cmap, visual, pixel, 0);
1694 colorBg = xft_convert_color (display, cmap, visual, pixelBg, 0); 1694 colorBg = xft_convert_color (display, cmap, visual, pixelBg, 0);
1695 #endif 1695 #endif
1696 1696
1697 /* Draw the label string. */ 1697 /* Draw the label string. */
1698 string_draw_u (mw, /* XXX */ 1698 string_draw_u (mw, /* XXX */
1699 window, 1699 window,
1700 x + label_offset, y + y_offset, 1700 x + label_offset, y + y_offset,
1701 #ifdef USE_XFT_MENUBARS 1701 #ifdef HAVE_XFT_MENUBARS
1702 &color, &colorBg, gc, 1702 &color, &colorBg, gc,
1703 #else 1703 #else
1704 gc, 1704 gc,
1705 #endif 1705 #endif
1706 resource_widget_value (mw, val)); 1706 resource_widget_value (mw, val));
1722 1722
1723 /* key bindings to display? */ 1723 /* key bindings to display? */
1724 if (!in_menubar && val->key) 1724 if (!in_menubar && val->key)
1725 { 1725 {
1726 int w; 1726 int w;
1727 #if defined(NEED_MOTIF) && !defined(USE_XFT_MENUBARS) 1727 #if defined(NEED_MOTIF) && !defined(HAVE_XFT_MENUBARS)
1728 XmString key = XmStringCreateLtoR (val->key, XmSTRING_DEFAULT_CHARSET); 1728 XmString key = XmStringCreateLtoR (val->key, XmSTRING_DEFAULT_CHARSET);
1729 w = string_width (mw, key); 1729 w = string_width (mw, key);
1730 XmStringFree (key); 1730 XmStringFree (key);
1731 #else 1731 #else
1732 char *key = val->key; 1732 char *key = val->key;
1751 int y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin; 1751 int y_offset = mw->menu.shadow_thickness + mw->menu.vertical_margin;
1752 GC gc; 1752 GC gc;
1753 shadow_type type; 1753 shadow_type type;
1754 Boolean menu_pb = in_menubar && (menu_item_type (val) == BUTTON_TYPE); 1754 Boolean menu_pb = in_menubar && (menu_item_type (val) == BUTTON_TYPE);
1755 1755
1756 #ifdef USE_XFT_MENUBARS 1756 #ifdef HAVE_XFT_MENUBARS
1757 XftColor color, colorBg; 1757 XftColor color, colorBg;
1758 Display *display = XtDisplay (mw); 1758 Display *display = XtDisplay (mw);
1759 Colormap cmap = mw->core.colormap; 1759 Colormap cmap = mw->core.colormap;
1760 Visual *visual; 1760 Visual *visual;
1761 int ignored, pixel, pixelBg, dim = 0; 1761 int ignored, pixel, pixelBg, dim = 0;
1769 1769
1770 if (highlighted) 1770 if (highlighted)
1771 { 1771 {
1772 if (val->enabled) 1772 if (val->enabled)
1773 { 1773 {
1774 #ifdef USE_XFT_MENUBARS 1774 #ifdef HAVE_XFT_MENUBARS
1775 pixel = mw->menu.highlight_foreground; 1775 pixel = mw->menu.highlight_foreground;
1776 pixelBg = mw->core.background_pixel; 1776 pixelBg = mw->core.background_pixel;
1777 #endif 1777 #endif
1778 gc = mw->menu.highlight_gc; 1778 gc = mw->menu.highlight_gc;
1779 } 1779 }
1780 else 1780 else
1781 { 1781 {
1782 #ifdef USE_XFT_MENUBARS 1782 #ifdef HAVE_XFT_MENUBARS
1783 dim = 1; 1783 dim = 1;
1784 pixel = mw->menu.foreground; 1784 pixel = mw->menu.foreground;
1785 pixelBg = mw->core.background_pixel; 1785 pixelBg = mw->core.background_pixel;
1786 #endif 1786 #endif
1787 gc = mw->menu.inactive_gc; 1787 gc = mw->menu.inactive_gc;
1789 } 1789 }
1790 else if (menu_pb) 1790 else if (menu_pb)
1791 { 1791 {
1792 if (val->enabled) 1792 if (val->enabled)
1793 { 1793 {
1794 #ifdef USE_XFT_MENUBARS 1794 #ifdef HAVE_XFT_MENUBARS
1795 pixel = mw->menu.button_foreground; 1795 pixel = mw->menu.button_foreground;
1796 pixelBg = mw->core.background_pixel; 1796 pixelBg = mw->core.background_pixel;
1797 #endif 1797 #endif
1798 gc = mw->menu.button_gc; 1798 gc = mw->menu.button_gc;
1799 } 1799 }
1800 else 1800 else
1801 { 1801 {
1802 #ifdef USE_XFT_MENUBARS 1802 #ifdef HAVE_XFT_MENUBARS
1803 dim = 1; 1803 dim = 1;
1804 pixel = mw->menu.button_foreground; 1804 pixel = mw->menu.button_foreground;
1805 pixelBg = mw->core.background_pixel; 1805 pixelBg = mw->core.background_pixel;
1806 #endif 1806 #endif
1807 gc = mw->menu.inactive_button_gc; 1807 gc = mw->menu.inactive_button_gc;
1809 } 1809 }
1810 else 1810 else
1811 { 1811 {
1812 if (val->enabled) 1812 if (val->enabled)
1813 { 1813 {
1814 #ifdef USE_XFT_MENUBARS 1814 #ifdef HAVE_XFT_MENUBARS
1815 pixel = mw->menu.foreground; 1815 pixel = mw->menu.foreground;
1816 pixelBg = mw->core.background_pixel; 1816 pixelBg = mw->core.background_pixel;
1817 #endif 1817 #endif
1818 gc = mw->menu.foreground_gc; 1818 gc = mw->menu.foreground_gc;
1819 } 1819 }
1820 else 1820 else
1821 { 1821 {
1822 #ifdef USE_XFT_MENUBARS 1822 #ifdef HAVE_XFT_MENUBARS
1823 dim = 1; 1823 dim = 1;
1824 pixel = mw->menu.foreground; 1824 pixel = mw->menu.foreground;
1825 pixelBg = mw->core.background_pixel; 1825 pixelBg = mw->core.background_pixel;
1826 #endif 1826 #endif
1827 gc = mw->menu.inactive_gc; 1827 gc = mw->menu.inactive_gc;
1828 } 1828 }
1829 } 1829 }
1830 1830
1831 #ifdef USE_XFT_MENUBARS 1831 #ifdef HAVE_XFT_MENUBARS
1832 color = xft_convert_color (display, cmap, visual, pixel, dim); 1832 color = xft_convert_color (display, cmap, visual, pixel, dim);
1833 colorBg = xft_convert_color (display, cmap, visual, pixelBg, 0); 1833 colorBg = xft_convert_color (display, cmap, visual, pixelBg, 0);
1834 #endif 1834 #endif
1835 1835
1836 string_draw_u (mw, 1836 string_draw_u (mw,
1837 window, 1837 window,
1838 x + label_offset, y + y_offset, 1838 x + label_offset, y + y_offset,
1839 #ifdef USE_XFT_MENUBARS 1839 #ifdef HAVE_XFT_MENUBARS
1840 &color, &colorBg, gc, 1840 &color, &colorBg, gc,
1841 #else 1841 #else
1842 gc, 1842 gc,
1843 #endif 1843 #endif
1844 resource_widget_value (mw, val)); 1844 resource_widget_value (mw, val));
1853 binding_offset = label_offset + s_width + mw->menu.shadow_thickness; 1853 binding_offset = label_offset + s_width + mw->menu.shadow_thickness;
1854 } 1854 }
1855 binding_draw (mw, window, 1855 binding_draw (mw, window,
1856 x + binding_offset + mw->menu.column_spacing, 1856 x + binding_offset + mw->menu.column_spacing,
1857 y + y_offset, 1857 y + y_offset,
1858 #ifdef USE_XFT_MENUBARS 1858 #ifdef HAVE_XFT_MENUBARS
1859 &color, &colorBg, 1859 &color, &colorBg,
1860 #else 1860 #else
1861 gc, 1861 gc,
1862 #endif 1862 #endif
1863 val->key); 1863 val->key);
2804 /* Procedures */ 2804 /* Procedures */
2805 static void 2805 static void
2806 make_drawing_gcs (XlwMenuWidget mw) 2806 make_drawing_gcs (XlwMenuWidget mw)
2807 { 2807 {
2808 XGCValues xgcv; 2808 XGCValues xgcv;
2809 #ifdef USE_XFT_MENUBARS 2809 #ifdef HAVE_XFT_MENUBARS
2810 unsigned long flags = (GCForeground | GCBackground); 2810 unsigned long flags = (GCForeground | GCBackground);
2811 #else 2811 #else
2812 unsigned long flags = (GCFont | GCForeground | GCBackground); 2812 unsigned long flags = (GCFont | GCForeground | GCBackground);
2813 #endif 2813 #endif
2814 2814
2815 #if defined(NEED_MOTIF) && !defined(USE_XFT_MENUBARS) 2815 #if defined(NEED_MOTIF) && !defined(HAVE_XFT_MENUBARS)
2816 xgcv.font = default_font_of_font_list (mw->menu.font_list)->fid; 2816 xgcv.font = default_font_of_font_list (mw->menu.font_list)->fid;
2817 #else 2817 #else
2818 #ifndef USE_XFT_MENUBARS 2818 #ifndef HAVE_XFT_MENUBARS
2819 xgcv.font = mw->menu.font->fid; 2819 xgcv.font = mw->menu.font->fid;
2820 #endif 2820 #endif
2821 #endif 2821 #endif
2822 2822
2823 xgcv.foreground = mw->core.background_pixel; 2823 xgcv.foreground = mw->core.background_pixel;
3062 3062
3063 3063
3064 static void 3064 static void
3065 extract_font_extents (XlwMenuWidget mw) 3065 extract_font_extents (XlwMenuWidget mw)
3066 { 3066 {
3067 #if defined(NEED_MOTIF) && !defined(USE_XFT_MENUBARS) 3067 #if defined(NEED_MOTIF) && !defined(HAVE_XFT_MENUBARS)
3068 /* Find the maximal ascent/descent of the fonts in the font list 3068 /* Find the maximal ascent/descent of the fonts in the font list
3069 so that all menu items can be the same height... */ 3069 so that all menu items can be the same height... */
3070 mw->menu.font_ascent = 0; 3070 mw->menu.font_ascent = 0;
3071 mw->menu.font_descent = 0; 3071 mw->menu.font_descent = 0;
3072 3072
3147 mw->menu.font_ascent = font->ascent; 3147 mw->menu.font_ascent = font->ascent;
3148 if (font->descent > (int) mw->menu.font_descent) 3148 if (font->descent > (int) mw->menu.font_descent)
3149 mw->menu.font_descent = font->descent; 3149 mw->menu.font_descent = font->descent;
3150 } 3150 }
3151 # else /* ! USE_XFONTSET */ 3151 # else /* ! USE_XFONTSET */
3152 #ifdef USE_XFT_MENUBARS 3152 #ifdef HAVE_XFT_MENUBARS
3153 mw->menu.font_ascent = mw->menu.renderFont->ascent; 3153 mw->menu.font_ascent = mw->menu.renderFont->ascent;
3154 mw->menu.font_descent = mw->menu.renderFont->descent; 3154 mw->menu.font_descent = mw->menu.renderFont->descent;
3155 #else 3155 #else
3156 mw->menu.font_ascent = mw->menu.font->ascent; 3156 mw->menu.font_ascent = mw->menu.font->ascent;
3157 mw->menu.font_descent = mw->menu.font->descent; 3157 mw->menu.font_descent = mw->menu.font->descent;
3158 #endif 3158 #endif
3159 # endif 3159 # endif
3160 #endif /* NEED_MOTIF */ 3160 #endif /* NEED_MOTIF */
3161 } 3161 }
3162 3162
3163 #if defined(NEED_MOTIF) && !defined(USE_XFT_MENUBARS) 3163 #if defined(NEED_MOTIF) && !defined(HAVE_XFT_MENUBARS)
3164 static XFontStruct * 3164 static XFontStruct *
3165 default_font_of_font_list (XmFontList font_list) 3165 default_font_of_font_list (XmFontList font_list)
3166 { 3166 {
3167 XFontStruct *font = 0; 3167 XFontStruct *font = 0;
3168 # if 0 3168 # if 0
3228 3228
3229 mw->menu.gray_pixmap = 3229 mw->menu.gray_pixmap =
3230 XCreatePixmapFromBitmapData (display, window, (char *) gray_bits, 3230 XCreatePixmapFromBitmapData (display, window, (char *) gray_bits,
3231 gray_width, gray_height, 1, 0, 1); 3231 gray_width, gray_height, 1, 0, 1);
3232 3232
3233 #if defined(NEED_MOTIF) && !defined(USE_XFT_MENUBARS) 3233 #if defined(NEED_MOTIF) && !defined(HAVE_XFT_MENUBARS)
3234 /* #### Even if it's a kludge!!!, we should consider doing the same for 3234 /* #### Even if it's a kludge!!!, we should consider doing the same for
3235 X Font Sets. */ 3235 X Font Sets. */
3236 /* The menu.font_list slot came from the *fontList resource (Motif standard.) 3236 /* The menu.font_list slot came from the *fontList resource (Motif standard.)
3237 The menu.font_list_2 slot came from the *font resource, for backward 3237 The menu.font_list_2 slot came from the *font resource, for backward
3238 compatibility with older versions of this code, and consistency with the 3238 compatibility with older versions of this code, and consistency with the
3250 mw->menu.font_list = mw->menu.font_list_2; 3250 mw->menu.font_list = mw->menu.font_list_2;
3251 else /* otherwise use default */ 3251 else /* otherwise use default */
3252 mw->menu.font_list = mw->menu.fallback_font_list; 3252 mw->menu.font_list = mw->menu.fallback_font_list;
3253 #endif 3253 #endif
3254 3254
3255 #ifdef USE_XFT_MENUBARS 3255 #ifdef HAVE_XFT_MENUBARS
3256 /* #### kludge for name change */ 3256 /* #### kludge for name change */
3257 if (!mw->menu.fcFontName) 3257 if (!mw->menu.fcFontName)
3258 mw->menu.fcFontName = mw->menu.xftFontName; 3258 mw->menu.fcFontName = mw->menu.xftFontName;
3259 /* to do this right, we should add a new Xt Resource type + 3259 /* to do this right, we should add a new Xt Resource type +
3260 conversion function 3260 conversion function
3361 /* this doesn't come from the resource db but is created explicitly 3361 /* this doesn't come from the resource db but is created explicitly
3362 so we must free it ourselves. */ 3362 so we must free it ourselves. */
3363 XFreePixmap (XtDisplay (mw), mw->menu.gray_pixmap); 3363 XFreePixmap (XtDisplay (mw), mw->menu.gray_pixmap);
3364 mw->menu.gray_pixmap = (Pixmap) -1; 3364 mw->menu.gray_pixmap = (Pixmap) -1;
3365 3365
3366 #ifdef USE_XFT_MENUBARS 3366 #ifdef HAVE_XFT_MENUBARS
3367 XftFontClose (XtDisplay (mw), mw->menu.renderFont); 3367 XftFontClose (XtDisplay (mw), mw->menu.renderFont);
3368 #endif 3368 #endif
3369 3369
3370 /* Don't free mw->menu.contents because that comes from our creator. 3370 /* Don't free mw->menu.contents because that comes from our creator.
3371 The `*_stack' elements are just pointers into `contents' so leave 3371 The `*_stack' elements are just pointers into `contents' so leave
3407 redisplay = True; 3407 redisplay = True;
3408 3408
3409 if (newmw->core.background_pixel != oldmw->core.background_pixel 3409 if (newmw->core.background_pixel != oldmw->core.background_pixel
3410 || newmw->menu.foreground != oldmw->menu.foreground 3410 || newmw->menu.foreground != oldmw->menu.foreground
3411 /* For the XEditResource protocol, which may want to change the font. */ 3411 /* For the XEditResource protocol, which may want to change the font. */
3412 #if defined(NEED_MOTIF) && !defined(USE_XFT_MENUBARS) 3412 #if defined(NEED_MOTIF) && !defined(HAVE_XFT_MENUBARS)
3413 || newmw->menu.font_list != oldmw->menu.font_list 3413 || newmw->menu.font_list != oldmw->menu.font_list
3414 || newmw->menu.font_list_2 != oldmw->menu.font_list_2 3414 || newmw->menu.font_list_2 != oldmw->menu.font_list_2
3415 || newmw->menu.fallback_font_list != oldmw->menu.fallback_font_list 3415 || newmw->menu.fallback_font_list != oldmw->menu.fallback_font_list
3416 #else 3416 #else
3417 #ifdef USE_XFT_MENUBARS 3417 #ifdef HAVE_XFT_MENUBARS
3418 || newmw->menu.renderFont != oldmw->menu.renderFont 3418 || newmw->menu.renderFont != oldmw->menu.renderFont
3419 #else 3419 #else
3420 || newmw->menu.font != oldmw->menu.font 3420 || newmw->menu.font != oldmw->menu.font
3421 #endif 3421 #endif
3422 #endif 3422 #endif