comparison lwlib/xlwmenu.c @ 371:cc15677e0335 r21-2b1

Import from CVS: tag r21-2b1
author cvs
date Mon, 13 Aug 2007 11:03:08 +0200
parents 30d2cfa1092a
children 6240c7796c7a
comparison
equal deleted inserted replaced
370:bd866891f083 371:cc15677e0335
86 XtRString, "-*-helvetica-bold-r-*-*-*-120-*-*-*-*-iso8859-1"}, 86 XtRString, "-*-helvetica-bold-r-*-*-*-120-*-*-*-*-iso8859-1"},
87 #else 87 #else
88 {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *), 88 {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
89 offset(menu.font), XtRString, "XtDefaultFont"}, 89 offset(menu.font), XtRString, "XtDefaultFont"},
90 # ifdef USE_XFONTSET 90 # ifdef USE_XFONTSET
91 /* #### Consider using the same method as for Motif; see the comment in
92 XlwMenuInitialize(). */
93 {XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet), 91 {XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet),
94 offset(menu.font_set), XtRString, "XtDefaultFontSet"}, 92 offset(menu.font_set), XtRString, "XtDefaultFontSet"},
95 # endif 93 # endif
96 #endif 94 #endif
97 {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), 95 {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
423 int charslength; 421 int charslength;
424 char *chars; 422 char *chars;
425 int i, j; 423 int i, j;
426 424
427 #ifdef NEED_MOTIF 425 #ifdef NEED_MOTIF
428 chars = "";
429 if (!XmStringGetLtoR (string, XmFONTLIST_DEFAULT_TAG, &chars)) 426 if (!XmStringGetLtoR (string, XmFONTLIST_DEFAULT_TAG, &chars))
430 chars = ""; 427 {
428 chars = "";
429 }
431 #else 430 #else
432 chars = string; 431 chars = string;
433 #endif 432 #endif
434 charslength = strlen (chars); 433 charslength = strlen (chars);
435 newchars = (char *) alloca (charslength + 1); 434 newchars = (char *) alloca (charslength + 1);
443 442
444 #ifdef NEED_MOTIF 443 #ifdef NEED_MOTIF
445 newstring = XmStringLtoRCreate (newchars, XmFONTLIST_DEFAULT_TAG); 444 newstring = XmStringLtoRCreate (newchars, XmFONTLIST_DEFAULT_TAG);
446 XmStringExtent (mw->menu.font_list, newstring, &width, &height); 445 XmStringExtent (mw->menu.font_list, newstring, &width, &height);
447 XmStringFree (newstring); 446 XmStringFree (newstring);
448 XtFree (chars);
449 return width; 447 return width;
450 #else 448 #else
451 # ifdef USE_XFONTSET 449 # ifdef USE_XFONTSET
452 XmbTextExtents (mw->menu.font_set, newchars, j, &ri, &rl); 450 XmbTextExtents (mw->menu.font_set, newchars, j, &ri, &rl);
453 return rl.width; 451 return rl.width;
482 while (*in) 480 while (*in)
483 { 481 {
484 char ch = massaged_resource_char[(unsigned char) *in++]; 482 char ch = massaged_resource_char[(unsigned char) *in++];
485 if (ch) 483 if (ch)
486 { 484 {
487 int int_ch = (int) (unsigned char) ch; 485 *out++ = firstp ? tolower (ch) : toupper (ch);
488 *out++ = firstp ? tolower (int_ch) : toupper (int_ch);
489 firstp = False; 486 firstp = False;
490 while ((ch = massaged_resource_char[(unsigned char) *in++]) != '\0') 487 while ((ch = massaged_resource_char[(unsigned char) *in++]) != '\0')
491 *out++ = ch; 488 *out++ = ch;
492 if (!*(in-1)) /* Overshot the NULL byte? */ 489 if (!*(in-1)) /* Overshot the NULL byte? */
493 break; 490 break;
871 { 868 {
872 int i,s=0; 869 int i,s=0;
873 char *chars; 870 char *chars;
874 871
875 #ifdef NEED_MOTIF 872 #ifdef NEED_MOTIF
876 chars = ""; 873 XmStringGetLtoR (string, XmFONTLIST_DEFAULT_TAG, &chars);
877 if (!XmStringGetLtoR (string, XmFONTLIST_DEFAULT_TAG, &chars))
878 chars = "";
879 #else 874 #else
880 chars = string; 875 chars = string;
881 #endif 876 #endif
882 for (i=0;chars[i];++i) { 877 for (i=0;chars[i];++i) {
883 if (chars[i]=='%'&&chars[i+1]=='_') { 878 if (chars[i]=='%'&&chars[i+1]=='_') {
894 s = i + 3; 889 s = i + 3;
895 i += 2; 890 i += 2;
896 } 891 }
897 } 892 }
898 x += string_draw_range (mw, window, x, y, gc, chars, s, i); 893 x += string_draw_range (mw, window, x, y, gc, chars, s, i);
899 #ifdef NEED_MOTIF
900 XtFree (chars);
901 #endif
902 } 894 }
903 895
904 static void 896 static void
905 binding_draw (XlwMenuWidget mw, Window w, int x, int y, GC gc, char *value) 897 binding_draw (XlwMenuWidget mw, Window w, int x, int y, GC gc, char *value)
906 { 898 {
2809 } 2801 }
2810 2802
2811 xgcv.fill_style = FillOpaqueStippled; 2803 xgcv.fill_style = FillOpaqueStippled;
2812 xgcv.foreground = mw->menu.top_shadow_color; 2804 xgcv.foreground = mw->menu.top_shadow_color;
2813 xgcv.background = mw->core.background_pixel; 2805 xgcv.background = mw->core.background_pixel;
2814 /* xgcv.stipple = mw->menu.top_shadow_pixmap; gtb */ 2806 xgcv.stipple = mw->menu.top_shadow_pixmap;
2815 if (mw->menu.top_shadow_pixmap &&
2816 mw->menu.top_shadow_pixmap != XmUNSPECIFIED_PIXMAP)
2817 xgcv.stipple = mw->menu.top_shadow_pixmap;
2818 else
2819 xgcv.stipple = 0;
2820 pm = (xgcv.stipple ? GCStipple|GCFillStyle : 0); 2807 pm = (xgcv.stipple ? GCStipple|GCFillStyle : 0);
2821 mw->menu.shadow_top_gc = 2808 mw->menu.shadow_top_gc =
2822 XtGetGC((Widget)mw, GCForeground|GCBackground|pm, &xgcv); 2809 XtGetGC((Widget)mw, GCForeground|GCBackground|pm, &xgcv);
2823 2810
2824 xgcv.foreground = mw->menu.bottom_shadow_color; 2811 xgcv.foreground = mw->menu.bottom_shadow_color;
2825 /* xgcv.stipple = mw->menu.bottom_shadow_pixmap; gtb */ 2812 xgcv.stipple = mw->menu.bottom_shadow_pixmap;
2826 if (mw->menu.bottom_shadow_pixmap &&
2827 mw->menu.bottom_shadow_pixmap != XmUNSPECIFIED_PIXMAP)
2828 xgcv.stipple = mw->menu.bottom_shadow_pixmap;
2829 else
2830 xgcv.stipple = 0;
2831 pm = (xgcv.stipple ? GCStipple|GCFillStyle : 0); 2813 pm = (xgcv.stipple ? GCStipple|GCFillStyle : 0);
2832 mw->menu.shadow_bottom_gc = 2814 mw->menu.shadow_bottom_gc =
2833 XtGetGC ((Widget)mw, GCForeground|GCBackground|pm, &xgcv); 2815 XtGetGC ((Widget)mw, GCForeground|GCBackground|pm, &xgcv);
2834 } 2816 }
2835 2817
3009 mw->menu.gray_pixmap = 2991 mw->menu.gray_pixmap =
3010 XCreatePixmapFromBitmapData (display, window, (char *) gray_bits, 2992 XCreatePixmapFromBitmapData (display, window, (char *) gray_bits,
3011 gray_width, gray_height, 1, 0, 1); 2993 gray_width, gray_height, 1, 0, 1);
3012 2994
3013 #ifdef NEED_MOTIF 2995 #ifdef NEED_MOTIF
3014 /* #### Even if it's a kludge!!!, we should consider doing the same for
3015 X Font Sets. */
3016 /* The menu.font_list slot came from the *fontList resource (Motif standard.) 2996 /* The menu.font_list slot came from the *fontList resource (Motif standard.)
3017 The menu.font_list_2 slot came from the *font resource, for backward 2997 The menu.font_list_2 slot came from the *font resource, for backward
3018 compatibility with older versions of this code, and consistency with the 2998 compatibility with older versions of this code, and consistency with the
3019 rest of emacs. If both font and fontList are specified, we use fontList. 2999 rest of emacs. If both font and fontList are specified, we use font.
3020 If only one is specified, we use that. If neither are specified, we 3000 If only one is specified, we use that. If neither are specified, we
3021 use the "fallback" value. What a kludge!!! 3001 use the "fallback" value. What a kludge!!!
3022 3002
3023 Note that this has the bug that a more general wildcard like "*fontList:" 3003 Note that this has the bug that a more general wildcard like "*fontList:"
3024 will override a more specific resource like "Emacs*menubar.font:". But 3004 will override a more specific resource like "Emacs*menubar.font:". But