emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lwlib/xlwmenu.c


From: Jan Djärv
Subject: [Emacs-diffs] Changes to emacs/lwlib/xlwmenu.c
Date: Fri, 01 Apr 2005 13:42:19 -0500

Index: emacs/lwlib/xlwmenu.c
diff -c emacs/lwlib/xlwmenu.c:1.64 emacs/lwlib/xlwmenu.c:1.65
*** emacs/lwlib/xlwmenu.c:1.64  Tue Mar 22 21:41:07 2005
--- emacs/lwlib/xlwmenu.c       Fri Apr  1 18:42:19 2005
***************
*** 131,150 ****
  
  /* FIXME: F10 should enter the menu, the first one in the menu-bar.  */
  
- /* FIXME: HAVE_X_I18N does not work yet. */
- #undef HAVE_X_I18N
- 
  #define offset(field) XtOffset(XlwMenuWidget, field)
  static XtResource
  xlwMenuResources[] =
  {
  #ifdef HAVE_X_I18N
!   {XtNfont,  XtCFont, XtRFontSet, sizeof(XFontSet),
!      offset(menu.font), XtRString, "XtDefaultFontSet"},
! #else
    {XtNfont,  XtCFont, XtRFontStruct, sizeof(XFontStruct *),
       offset(menu.font), XtRString, "XtDefaultFont"},
- #endif
    {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
       offset(menu.foreground), XtRString, "XtDefaultForeground"},
    {XtNdisabledForeground, XtCDisabledForeground, XtRPixel, sizeof(Pixel),
--- 131,146 ----
  
  /* FIXME: F10 should enter the menu, the first one in the menu-bar.  */
  
  #define offset(field) XtOffset(XlwMenuWidget, field)
  static XtResource
  xlwMenuResources[] =
  {
  #ifdef HAVE_X_I18N
!   {XtNfontSet,  XtCFontSet, XtRFontSet, sizeof(XFontSet),
!      offset(menu.fontSet), XtRFontSet, NULL},
! #endif
    {XtNfont,  XtCFont, XtRFontStruct, sizeof(XFontStruct *),
       offset(menu.font), XtRString, "XtDefaultFont"},
    {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
       offset(menu.foreground), XtRString, "XtDefaultForeground"},
    {XtNdisabledForeground, XtCDisabledForeground, XtRPixel, sizeof(Pixel),
***************
*** 361,384 ****
       XlwMenuWidget mw;
       char *s;
  {
- #ifdef HAVE_X_I18N
-   XRectangle ink, logical;
-   XmbTextExtents (mw->menu.font, s, strlen (s), &ink, &logical);
-   return logical.width;
- #else
    XCharStruct xcs;
    int drop;
  
    XTextExtents (mw->menu.font, s, strlen (s), &drop, &drop, &drop, &xcs);
    return xcs.width;
! #endif
  }
  
  #ifdef HAVE_X_I18N
  #define MENU_FONT_HEIGHT(mw) \
!   ((mw)->menu.font_extents->max_logical_extent.height)
  #define MENU_FONT_ASCENT(mw) \
!   (- (mw)->menu.font_extents->max_logical_extent.y)
  #else
  #define MENU_FONT_HEIGHT(mw) \
    ((mw)->menu.font->ascent + (mw)->menu.font->descent)
--- 357,387 ----
       XlwMenuWidget mw;
       char *s;
  {
    XCharStruct xcs;
    int drop;
+ #ifdef HAVE_X_I18N
+   XRectangle ink, logical;
+   if (mw->menu.fontSet)
+     {
+       XmbTextExtents (mw->menu.fontSet, s, strlen (s), &ink, &logical);
+       return logical.width;
+     }
+ #endif
  
    XTextExtents (mw->menu.font, s, strlen (s), &drop, &drop, &drop, &xcs);
    return xcs.width;
! 
  }
  
  #ifdef HAVE_X_I18N
  #define MENU_FONT_HEIGHT(mw) \
!   ((mw)->menu.fontSet != NULL \
!    ? (mw)->menu.font_extents->max_logical_extent.height   \
!    : (mw)->menu.font->ascent + (mw)->menu.font->descent)
  #define MENU_FONT_ASCENT(mw) \
!   ((mw)->menu.fontSet != NULL \
!    ? - (mw)->menu.font_extents->max_logical_extent.y \
!    : (mw)->menu.font->ascent)
  #else
  #define MENU_FONT_HEIGHT(mw) \
    ((mw)->menu.font->ascent + (mw)->menu.font->descent)
***************
*** 1053,1062 ****
  
  
  #ifdef HAVE_X_I18N
!           XmbDrawString (XtDisplay (mw), ws->window, mw->menu.font,
! #else
!           XDrawString (XtDisplay (mw), ws->window,
  #endif
                       text_gc, x_offset,
                       y + v_spacing + shadow + font_ascent,
                       display_string, strlen (display_string));
--- 1056,1069 ----
  
  
  #ifdef HAVE_X_I18N
!           if (mw->menu.fontSet)
!             XmbDrawString (XtDisplay (mw), ws->window, mw->menu.fontSet,
!                            text_gc, x_offset,
!                            y + v_spacing + shadow + font_ascent,
!                            display_string, strlen (display_string));
!           else
  #endif
+           XDrawString (XtDisplay (mw), ws->window,
                       text_gc, x_offset,
                       y + v_spacing + shadow + font_ascent,
                       display_string, strlen (display_string));
***************
*** 1083,1092 ****
              else if (val->key)
                {
  #ifdef HAVE_X_I18N
!                 XmbDrawString (XtDisplay (mw), ws->window, mw->menu.font,
! #else
!                 XDrawString (XtDisplay (mw), ws->window,
  #endif
                               text_gc,
                               x + label_width + mw->menu.arrow_spacing,
                               y + v_spacing + shadow + font_ascent,
--- 1090,1105 ----
              else if (val->key)
                {
  #ifdef HAVE_X_I18N
!                   if (mw->menu.fontSet)
!                     XmbDrawString (XtDisplay (mw), ws->window,
!                                    mw->menu.fontSet,
!                                    text_gc,
!                                    x + label_width + mw->menu.arrow_spacing,
!                                    y + v_spacing + shadow + font_ascent,
!                                    val->key, strlen (val->key));
!                   else
  #endif
+                 XDrawString (XtDisplay (mw), ws->window,
                               text_gc,
                               x + label_width + mw->menu.arrow_spacing,
                               y + v_spacing + shadow + font_ascent,
***************
*** 1493,1526 ****
  {
    XGCValues xgcv;
    float scale;
  
! #ifndef HAVE_X_I18N
    xgcv.font = mw->menu.font->fid;
  #endif
    xgcv.foreground = mw->menu.foreground;
    xgcv.background = mw->core.background_pixel;
!   mw->menu.foreground_gc = XtGetGC ((Widget)mw,
! #ifndef HAVE_X_I18N
!                                   GCFont |
! #endif
!                                   GCForeground | GCBackground,
!                                   &xgcv);
  
- #ifndef HAVE_X_I18N
-   xgcv.font = mw->menu.font->fid;
- #endif
    xgcv.foreground = mw->menu.button_foreground;
!   xgcv.background = mw->core.background_pixel;
!   mw->menu.button_gc = XtGetGC ((Widget)mw,
! #ifndef HAVE_X_I18N
!                               GCFont |
! #endif
!                               GCForeground | GCBackground,
!                               &xgcv);
  
- #ifndef HAVE_X_I18N
-   xgcv.font = mw->menu.font->fid;
- #endif
    xgcv.background = mw->core.background_pixel;
  
  #define BRIGHTNESS(color) (((color) & 0xff) + (((color) >> 8) & 0xff) + 
(((color) >> 16) & 0xff))
--- 1506,1530 ----
  {
    XGCValues xgcv;
    float scale;
+   XtGCMask mask = GCForeground | GCBackground;
  
! #ifdef HAVE_X_I18N
!   if (!mw->menu.fontSet)
!     {
!       xgcv.font = mw->menu.font->fid;
!       mask |= GCFont;
!     }
! #else
    xgcv.font = mw->menu.font->fid;
+   mask |= GCFont;
  #endif
    xgcv.foreground = mw->menu.foreground;
    xgcv.background = mw->core.background_pixel;
!   mw->menu.foreground_gc = XtGetGC ((Widget)mw, mask, &xgcv);
  
    xgcv.foreground = mw->menu.button_foreground;
!   mw->menu.button_gc = XtGetGC ((Widget)mw, mask, &xgcv);
  
    xgcv.background = mw->core.background_pixel;
  
  #define BRIGHTNESS(color) (((color) & 0xff) + (((color) >> 8) & 0xff) + 
(((color) >> 16) & 0xff))
***************
*** 1545,1593 ****
        xgcv.foreground = mw->menu.foreground;
        xgcv.fill_style = FillStippled;
        xgcv.stipple = mw->menu.gray_pixmap;
!       mw->menu.disabled_gc = XtGetGC ((Widget)mw,
! #ifndef HAVE_X_I18N
!                                     GCFont |
! #endif
!                                     GCForeground | GCBackground
                                      | GCFillStyle | GCStipple, &xgcv);
      }
    else
      {
        /* Many colors available, use disabled pixel.  */
        xgcv.foreground = mw->menu.disabled_foreground;
!       mw->menu.disabled_gc = XtGetGC ((Widget)mw,
! #ifndef HAVE_X_I18N
!                                     GCFont |
! #endif
!                                     GCForeground | GCBackground, &xgcv);
      }
  
- #ifndef HAVE_X_I18N
-   xgcv.font = mw->menu.font->fid;
- #endif
    xgcv.foreground = mw->menu.button_foreground;
    xgcv.background = mw->core.background_pixel;
    xgcv.fill_style = FillStippled;
    xgcv.stipple = mw->menu.gray_pixmap;
!   mw->menu.inactive_button_gc = XtGetGC ((Widget)mw,
! #ifndef HAVE_X_I18N
!                                        GCFont |
! #endif
!                                        GCForeground | GCBackground
                                         | GCFillStyle | GCStipple, &xgcv);
  
- #ifndef HAVE_X_I18N
-   xgcv.font = mw->menu.font->fid;
- #endif
    xgcv.foreground = mw->core.background_pixel;
    xgcv.background = mw->menu.foreground;
!   mw->menu.background_gc = XtGetGC ((Widget)mw,
! #ifndef HAVE_X_I18N
!                                   GCFont |
! #endif
!                                   GCForeground | GCBackground,
!                                   &xgcv);
  }
  
  static void
--- 1549,1574 ----
        xgcv.foreground = mw->menu.foreground;
        xgcv.fill_style = FillStippled;
        xgcv.stipple = mw->menu.gray_pixmap;
!       mw->menu.disabled_gc = XtGetGC ((Widget)mw, mask
                                      | GCFillStyle | GCStipple, &xgcv);
      }
    else
      {
        /* Many colors available, use disabled pixel.  */
        xgcv.foreground = mw->menu.disabled_foreground;
!       mw->menu.disabled_gc = XtGetGC ((Widget)mw, mask, &xgcv);
      }
  
    xgcv.foreground = mw->menu.button_foreground;
    xgcv.background = mw->core.background_pixel;
    xgcv.fill_style = FillStippled;
    xgcv.stipple = mw->menu.gray_pixmap;
!   mw->menu.inactive_button_gc = XtGetGC ((Widget)mw, mask
                                         | GCFillStyle | GCStipple, &xgcv);
  
    xgcv.foreground = mw->core.background_pixel;
    xgcv.background = mw->menu.foreground;
!   mw->menu.background_gc = XtGetGC ((Widget)mw, mask, &xgcv);
  }
  
  static void
***************
*** 1793,1806 ****
                                   gray_bitmap_width, gray_bitmap_height,
                                   (unsigned long)1, (unsigned long)0, 1);
  
- #ifndef HAVE_X_I18N
    /* I don't understand why this ends up 0 sometimes,
       but it does.  This kludge works around it.
       Can anyone find a real fix?   -- rms.  */
    if (mw->menu.font == 0)
      mw->menu.font = xlwmenu_default_font;
! #else
!   mw->menu.font_extents = XExtentsOfFontSet (mw->menu.font);
  #endif
        
    make_drawing_gcs (mw);
--- 1774,1787 ----
                                   gray_bitmap_width, gray_bitmap_height,
                                   (unsigned long)1, (unsigned long)0, 1);
  
    /* I don't understand why this ends up 0 sometimes,
       but it does.  This kludge works around it.
       Can anyone find a real fix?   -- rms.  */
    if (mw->menu.font == 0)
      mw->menu.font = xlwmenu_default_font;
! #ifdef HAVE_X_I18N
!   if (mw->menu.fontSet)
!     mw->menu.font_extents = XExtentsOfFontSet (mw->menu.fontSet);
  #endif
        
    make_drawing_gcs (mw);
***************
*** 1969,1975 ****
  
    if (newmw->core.background_pixel != oldmw->core.background_pixel
        || newmw->menu.foreground != oldmw->menu.foreground
! #ifndef HAVE_X_I18N
        || newmw->menu.font != oldmw->menu.font
  #endif
        )
--- 1950,1959 ----
  
    if (newmw->core.background_pixel != oldmw->core.background_pixel
        || newmw->menu.foreground != oldmw->menu.foreground
! #ifdef HAVE_X_I18N
!       || newmw->menu.fontSet != oldmw->menu.fontSet
!       || (newmw->menu.fontSet == NULL && newmw->menu.font != oldmw->menu.font)
! #else
        || newmw->menu.font != oldmw->menu.font
  #endif
        )
***************
*** 1999,2008 ****
      }
  
  #ifdef HAVE_X_I18N
!   if (newmw->menu.font != oldmw->menu.font)
      {
        redisplay = True;
!       newmw->menu.font_extents = XExtentsOfFontSet (newmw->menu.font);
      }
  #endif
  
--- 1983,1992 ----
      }
  
  #ifdef HAVE_X_I18N
!   if (newmw->menu.fontSet != oldmw->menu.fontSet && newmw->menu.fontSet != 
NULL)
      {
        redisplay = True;
!       newmw->menu.font_extents = XExtentsOfFontSet (newmw->menu.fontSet);
      }
  #endif
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]