Contents in 1999-06-04-13 of release-21-2.
[chise/xemacs-chise.git.1] / lwlib / xlwmenu.c
index 87f7543..4b01283 100644 (file)
@@ -83,23 +83,23 @@ xlwMenuResources[] =
      /* We must use an iso8859-1 font here, or people without $LANG set lose.
        It's fair to assume that those who do have $LANG set also have the
        *fontList resource set, or at least know how to deal with this. */
      /* We must use an iso8859-1 font here, or people without $LANG set lose.
        It's fair to assume that those who do have $LANG set also have the
        *fontList resource set, or at least know how to deal with this. */
-     XtRString, "-*-helvetica-bold-r-*-*-*-120-*-*-*-*-iso8859-1"},
+     XtRString, (XtPointer) "-*-helvetica-bold-r-*-*-*-120-*-*-*-*-iso8859-1"},
 #else
   {XtNfont,  XtCFont, XtRFontStruct, sizeof(XFontStruct *),
 #else
   {XtNfont,  XtCFont, XtRFontStruct, sizeof(XFontStruct *),
-     offset(menu.font), XtRString, "XtDefaultFont"},
+     offset(menu.font), XtRString, (XtPointer) "XtDefaultFont"},
 # ifdef USE_XFONTSET
   {XtNfontSet,  XtCFontSet, XtRFontSet, sizeof(XFontSet),
 # ifdef USE_XFONTSET
   {XtNfontSet,  XtCFontSet, XtRFontSet, sizeof(XFontSet),
-     offset(menu.font_set), XtRString, "XtDefaultFontSet"},
+     offset(menu.font_set), XtRString, (XtPointer) "XtDefaultFontSet"},
 # endif
 #endif
   {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
 # endif
 #endif
   {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
-     offset(menu.foreground), XtRString, "XtDefaultForeground"},
+     offset(menu.foreground), XtRString, (XtPointer) "XtDefaultForeground"},
   {XtNbuttonForeground, XtCButtonForeground, XtRPixel, sizeof(Pixel),
   {XtNbuttonForeground, XtCButtonForeground, XtRPixel, sizeof(Pixel),
-     offset(menu.button_foreground), XtRString, "XtDefaultForeground"},
+     offset(menu.button_foreground), XtRString, (XtPointer) "XtDefaultForeground"},
   {XtNhighlightForeground, XtCHighlightForeground, XtRPixel, sizeof(Pixel),
   {XtNhighlightForeground, XtCHighlightForeground, XtRPixel, sizeof(Pixel),
-     offset(menu.highlight_foreground), XtRString, "XtDefaultForeground"},
+     offset(menu.highlight_foreground), XtRString, (XtPointer) "XtDefaultForeground"},
   {XtNtitleForeground, XtCTitleForeground, XtRPixel, sizeof(Pixel),
   {XtNtitleForeground, XtCTitleForeground, XtRPixel, sizeof(Pixel),
-     offset(menu.title_foreground), XtRString, "XtDefaultForeground"},
+     offset(menu.title_foreground), XtRString, (XtPointer) "XtDefaultForeground"},
   {XtNmargin, XtCMargin, XtRDimension,  sizeof(Dimension),
      offset(menu.margin), XtRImmediate, (XtPointer)2},
   {XmNmarginWidth, XmCMarginWidth, XmRHorizontalDimension, sizeof(Dimension),
   {XtNmargin, XtCMargin, XtRDimension,  sizeof(Dimension),
      offset(menu.margin), XtRImmediate, (XtPointer)2},
   {XmNmarginWidth, XmCMarginWidth, XmRHorizontalDimension, sizeof(Dimension),
@@ -423,10 +423,9 @@ string_width_u (XlwMenuWidget mw,
   int i, j;
 
 #ifdef NEED_MOTIF
   int i, j;
 
 #ifdef NEED_MOTIF
+  chars = "";
   if (!XmStringGetLtoR (string, XmFONTLIST_DEFAULT_TAG, &chars))
   if (!XmStringGetLtoR (string, XmFONTLIST_DEFAULT_TAG, &chars))
-    {
-      chars = "";
-    }
+    chars = "";
 #else
   chars = string;
 #endif
 #else
   chars = string;
 #endif
@@ -444,6 +443,7 @@ string_width_u (XlwMenuWidget mw,
   newstring = XmStringLtoRCreate (newchars, XmFONTLIST_DEFAULT_TAG);
   XmStringExtent (mw->menu.font_list, newstring, &width, &height);
   XmStringFree (newstring);
   newstring = XmStringLtoRCreate (newchars, XmFONTLIST_DEFAULT_TAG);
   XmStringExtent (mw->menu.font_list, newstring, &width, &height);
   XmStringFree (newstring);
+  XtFree (chars);
   return width;
 #else
 # ifdef USE_XFONTSET
   return width;
 #else
 # ifdef USE_XFONTSET
@@ -482,7 +482,8 @@ massage_resource_name (CONST char *in, char *out)
       char ch = massaged_resource_char[(unsigned char) *in++];
       if (ch)
        {
       char ch = massaged_resource_char[(unsigned char) *in++];
       if (ch)
        {
-         *out++ = firstp ? tolower (ch) : toupper (ch);
+         int int_ch = (int) (unsigned char) ch;
+         *out++ = firstp ? tolower (int_ch) : toupper (int_ch);
          firstp = False;
          while ((ch = massaged_resource_char[(unsigned char) *in++]) != '\0')
            *out++ = ch;
          firstp = False;
          while ((ch = massaged_resource_char[(unsigned char) *in++]) != '\0')
            *out++ = ch;
@@ -866,16 +867,18 @@ string_draw_u (XlwMenuWidget mw,
 #endif
 )
 {
 #endif
 )
 {
-int i,s=0;
-char *chars;
+  int i, s = 0;
+  char *chars;
 
 #ifdef NEED_MOTIF
 
 #ifdef NEED_MOTIF
-  XmStringGetLtoR (string, XmFONTLIST_DEFAULT_TAG, &chars);
+  chars = "";
+  if (!XmStringGetLtoR (string, XmFONTLIST_DEFAULT_TAG, &chars))
+    chars = "";
 #else
   chars = string;
 #endif
 #else
   chars = string;
 #endif
-  for (i=0;chars[i];++i) {
-      if (chars[i]=='%'&&chars[i+1]=='_') {
+  for (i=0; chars[i]; ++i) {
+      if (chars[i] == '%' && chars[i+1] == '_') {
          int w;
 
          x += string_draw_range (mw, window, x, y, gc, chars, s, i);
          int w;
 
          x += string_draw_range (mw, window, x, y, gc, chars, s, i);
@@ -891,6 +894,9 @@ char *chars;
       }
   }
   x += string_draw_range (mw, window, x, y, gc, chars, s, i);
       }
   }
   x += string_draw_range (mw, window, x, y, gc, chars, s, i);
+#ifdef NEED_MOTIF
+  XtFree (chars);
+#endif
 }
 
 static void
 }
 
 static void
@@ -1471,7 +1477,7 @@ print_widget_value (widget_value *wv, int just_one, int depth)
       print_widget_value (wv->next, 0, depth);
     }
 }
       print_widget_value (wv->next, 0, depth);
     }
 }
-#endif
+#endif /* SLOPPY_TYPES < 2 */
 
 static Boolean
 all_dashes_p (char *s)
 
 static Boolean
 all_dashes_p (char *s)
@@ -1485,30 +1491,29 @@ all_dashes_p (char *s)
     return True;
   return False;
 }
     return True;
   return False;
 }
-#endif
+#endif /* SLOPPY_TYPES */
 
 static widget_value_type
 menu_item_type (widget_value *val)
 {
   if (val->type != UNSPECIFIED_TYPE)
     return val->type;
 
 static widget_value_type
 menu_item_type (widget_value *val)
 {
   if (val->type != UNSPECIFIED_TYPE)
     return val->type;
-  else
-    {
 #if SLOPPY_TYPES
 #if SLOPPY_TYPES
-      if (all_dashes_p (val->name))
-       return SEPARATOR_TYPE;
-      else if (val->name && val->name[0] == '\0') /* push right */
-       return PUSHRIGHT_TYPE;
-      else if (val->contents) /* cascade */
-       return CASCADE_TYPE;
-      else if (val->call_data) /* push button */
-       return BUTTON_TYPE;
-      else
-       return TEXT_TYPE;
+  else if (all_dashes_p (val->name))
+    return SEPARATOR_TYPE;
+  else if (val->name && val->name[0] == '\0') /* push right */
+    return PUSHRIGHT_TYPE;
+  else if (val->contents) /* cascade */
+    return CASCADE_TYPE;
+  else if (val->call_data) /* push button */
+    return BUTTON_TYPE;
+  else
+    return TEXT_TYPE;
 #else
 #else
+  else 
     abort();
     abort();
+  return UNSPECIFIED_TYPE; /* Not reached */
 #endif
 #endif
-    }
 }
 
 static void
 }
 
 static void
@@ -2803,13 +2808,31 @@ make_shadow_gcs (XlwMenuWidget mw)
   xgcv.fill_style = FillOpaqueStippled;
   xgcv.foreground = mw->menu.top_shadow_color;
   xgcv.background = mw->core.background_pixel;
   xgcv.fill_style = FillOpaqueStippled;
   xgcv.foreground = mw->menu.top_shadow_color;
   xgcv.background = mw->core.background_pixel;
+/*  xgcv.stipple = mw->menu.top_shadow_pixmap; gtb */
+#ifdef NEED_MOTIF
+  if (mw->menu.top_shadow_pixmap &&
+      mw->menu.top_shadow_pixmap != XmUNSPECIFIED_PIXMAP)
+     xgcv.stipple = mw->menu.top_shadow_pixmap;
+  else
+     xgcv.stipple = 0;
+#else
   xgcv.stipple = mw->menu.top_shadow_pixmap;
   xgcv.stipple = mw->menu.top_shadow_pixmap;
+#endif /* NEED_MOTIF */
   pm = (xgcv.stipple ? GCStipple|GCFillStyle : 0);
   mw->menu.shadow_top_gc =
     XtGetGC((Widget)mw, GCForeground|GCBackground|pm, &xgcv);
 
   xgcv.foreground = mw->menu.bottom_shadow_color;
   pm = (xgcv.stipple ? GCStipple|GCFillStyle : 0);
   mw->menu.shadow_top_gc =
     XtGetGC((Widget)mw, GCForeground|GCBackground|pm, &xgcv);
 
   xgcv.foreground = mw->menu.bottom_shadow_color;
+/*  xgcv.stipple = mw->menu.bottom_shadow_pixmap; gtb */
+#ifdef NEED_MOTIF
+  if (mw->menu.bottom_shadow_pixmap &&
+      mw->menu.bottom_shadow_pixmap != XmUNSPECIFIED_PIXMAP)
+     xgcv.stipple = mw->menu.bottom_shadow_pixmap;
+  else
+     xgcv.stipple = 0;
+#else
   xgcv.stipple = mw->menu.bottom_shadow_pixmap;
   xgcv.stipple = mw->menu.bottom_shadow_pixmap;
+#endif /* NEED_MOTIF */
   pm = (xgcv.stipple ? GCStipple|GCFillStyle : 0);
   mw->menu.shadow_bottom_gc =
     XtGetGC ((Widget)mw, GCForeground|GCBackground|pm, &xgcv);
   pm = (xgcv.stipple ? GCStipple|GCFillStyle : 0);
   mw->menu.shadow_bottom_gc =
     XtGetGC ((Widget)mw, GCForeground|GCBackground|pm, &xgcv);