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: Stefan Monnier
Subject: [Emacs-diffs] Changes to emacs/lwlib/xlwmenu.c
Date: Thu, 17 Mar 2005 23:19:41 -0500

Index: emacs/lwlib/xlwmenu.c
diff -c emacs/lwlib/xlwmenu.c:1.61 emacs/lwlib/xlwmenu.c:1.62
*** emacs/lwlib/xlwmenu.c:1.61  Mon Dec 27 15:22:36 2004
--- emacs/lwlib/xlwmenu.c       Fri Mar 18 04:19:41 2005
***************
*** 1,6 ****
  /* Implements a lightweight menubar widget.
     Copyright (C) 1992 Lucid, Inc.
!    Copyright (C) 2002 Free Software Foundation, Inc.
  
  This file is part of the Lucid Widget Library.
  
--- 1,6 ----
  /* Implements a lightweight menubar widget.
     Copyright (C) 1992 Lucid, Inc.
!    Copyright (C) 2002, 2005 Free Software Foundation, Inc.
  
  This file is part of the Lucid Widget Library.
  
***************
*** 135,142 ****
  static XtResource
  xlwMenuResources[] =
  {
    {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),
--- 135,147 ----
  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),
***************
*** 235,241 ****
      XtNumber(xlwMenuResources),               /* resource_count         */
      NULLQUARK,                                /* xrm_class              */
      TRUE,                             /* compress_motion        */
!     TRUE,                             /* compress_exposure      */
      TRUE,                             /* compress_enterleave    */
      FALSE,                            /* visible_interest       */
      XlwMenuDestroy,                   /* destroy                */
--- 240,246 ----
      XtNumber(xlwMenuResources),               /* resource_count         */
      NULLQUARK,                                /* xrm_class              */
      TRUE,                             /* compress_motion        */
!     XtExposeCompressMaximal,          /* compress_exposure      */
      TRUE,                             /* compress_enterleave    */
      FALSE,                            /* visible_interest       */
      XlwMenuDestroy,                   /* destroy                */
***************
*** 353,370 ****
       XlwMenuWidget mw;
       char *s;
  {
    XCharStruct xcs;
    int drop;
  
    XTextExtents (mw->menu.font, s, strlen (s), &drop, &drop, &drop, &xcs);
    return xcs.width;
  }
  
  static int
  arrow_width (mw)
       XlwMenuWidget mw;
  {
!   return (mw->menu.font->ascent * 3/4) | 1;
  }
  
  /* Return the width of toggle buttons of widget MW.  */
--- 358,391 ----
       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) (MENU_FONT_HEIGHT(mw) * 9 / 10)
+ #else
+ #define MENU_FONT_HEIGHT(mw) \
+   ((mw)->menu.font->ascent + (mw)->menu.font->descent)
+ #define MENU_FONT_ASCENT(mw) ((mw)->menu.font->ascent)
+ #endif
+ 
  static int
  arrow_width (mw)
       XlwMenuWidget mw;
  {
!   return (MENU_FONT_ASCENT (mw) * 3/4) | 1;
  }
  
  /* Return the width of toggle buttons of widget MW.  */
***************
*** 373,379 ****
  toggle_button_width (mw)
       XlwMenuWidget mw;
  {
!   return ((mw->menu.font->ascent + mw->menu.font->descent) * 2 / 3) | 1;
  }
  
  
--- 394,400 ----
  toggle_button_width (mw)
       XlwMenuWidget mw;
  {
!   return (MENU_FONT_HEIGHT (mw) * 2 / 3) | 1;
  }
  
  
***************
*** 454,462 ****
      }
    else
      {
!       *height =
!       mw->menu.font->ascent + mw->menu.font->descent
!         + 2 * mw->menu.vertical_spacing + 2 * mw->menu.shadow_thickness;
  
        *label_width =
        string_width (mw, resource_widget_value (mw, val))
--- 475,482 ----
      }
    else
      {
!       *height = MENU_FONT_HEIGHT (mw)
!       + 2 * mw->menu.vertical_spacing + 2 * mw->menu.shadow_thickness;
  
        *label_width =
        string_width (mw, resource_widget_value (mw, val))
***************
*** 571,577 ****
    double factor = 1.62;
    int thickness2 = thickness * factor;
  
!   y += (mw->menu.font->ascent + mw->menu.font->descent - height) / 2;
  
    if (down_p)
      {
--- 591,597 ----
    double factor = 1.62;
    int thickness2 = thickness * factor;
  
!   y += (MENU_FONT_HEIGHT (mw) - height) / 2;
  
    if (down_p)
      {
***************
*** 757,763 ****
    width = toggle_button_width (mw);
    height = width;
    x += mw->menu.horizontal_spacing;
!   y += (mw->menu.font->ascent - height) / 2;
    draw_shadow_rectangle (mw, window, x, y, width, height, False, selected_p);
  }
  
--- 777,783 ----
    width = toggle_button_width (mw);
    height = width;
    x += mw->menu.horizontal_spacing;
!   y += (MENU_FONT_ASCENT (mw) - height) / 2;
    draw_shadow_rectangle (mw, window, x, y, width, height, False, selected_p);
  }
  
***************
*** 777,783 ****
    width = radio_button_width (mw);
    height = width;
    x += mw->menu.horizontal_spacing;
!   y += (mw->menu.font->ascent - height) / 2;
    draw_shadow_rhombus (mw, window, x, y, width, height, False, selected_p);
  }
  
--- 797,803 ----
    width = radio_button_width (mw);
    height = width;
    x += mw->menu.horizontal_spacing;
!   y += (MENU_FONT_ASCENT (mw) - height) / 2;
    draw_shadow_rhombus (mw, window, x, y, width, height, False, selected_p);
  }
  
***************
*** 954,961 ****
  {
    GC deco_gc;
    GC text_gc;
!   int font_ascent = mw->menu.font->ascent;
!   int font_descent = mw->menu.font->descent;
    int shadow = mw->menu.shadow_thickness;
    int margin = mw->menu.margin;
    int h_spacing = mw->menu.horizontal_spacing;
--- 974,981 ----
  {
    GC deco_gc;
    GC text_gc;
!   int font_height = MENU_FONT_HEIGHT (mw);
!   int font_ascent = MENU_FONT_ASCENT (mw);
    int shadow = mw->menu.shadow_thickness;
    int margin = mw->menu.margin;
    int h_spacing = mw->menu.horizontal_spacing;
***************
*** 1028,1034 ****
            x_offset += ws->button_width;
  
  
!           XDrawString (XtDisplay (mw), ws->window, text_gc, x_offset,
                       y + v_spacing + shadow + font_ascent,
                       display_string, strlen (display_string));
  
--- 1048,1059 ----
            x_offset += ws->button_width;
  
  
! #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));
  
***************
*** 1053,1059 ****
                }
              else if (val->key)
                {
!                 XDrawString (XtDisplay (mw), ws->window, text_gc,
                               x + label_width + mw->menu.arrow_spacing,
                               y + v_spacing + shadow + font_ascent,
                               val->key, strlen (val->key));
--- 1078,1089 ----
                }
              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,
                               val->key, strlen (val->key));
***************
*** 1065,1071 ****
                              mw->menu.background_gc,
                              x + shadow, y + shadow,
                              label_width + h_spacing - 1,
!                             font_ascent + font_descent + 2 * v_spacing - 1);
              draw_shadow_rectangle (mw, ws->window, x, y, width, height,
                                     True, False);
            }
--- 1095,1101 ----
                              mw->menu.background_gc,
                              x + shadow, y + shadow,
                              label_width + h_spacing - 1,
!                             font_height + 2 * v_spacing - 1);
              draw_shadow_rectangle (mw, ws->window, x, y, width, height,
                                     True, False);
            }
***************
*** 1460,1480 ****
    XGCValues xgcv;
    float scale;
  
    xgcv.font = mw->menu.font->fid;
    xgcv.foreground = mw->menu.foreground;
    xgcv.background = mw->core.background_pixel;
    mw->menu.foreground_gc = XtGetGC ((Widget)mw,
!                                   GCFont | GCForeground | GCBackground,
                                    &xgcv);
  
    xgcv.font = mw->menu.font->fid;
    xgcv.foreground = mw->menu.button_foreground;
    xgcv.background = mw->core.background_pixel;
    mw->menu.button_gc = XtGetGC ((Widget)mw,
!                               GCFont | GCForeground | GCBackground,
                                &xgcv);
  
    xgcv.font = mw->menu.font->fid;
    xgcv.background = mw->core.background_pixel;
  
  #define BRIGHTNESS(color) (((color) & 0xff) + (((color) >> 8) & 0xff) + 
(((color) >> 16) & 0xff))
--- 1490,1522 ----
    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))
***************
*** 1500,1530 ****
        xgcv.fill_style = FillStippled;
        xgcv.stipple = mw->menu.gray_pixmap;
        mw->menu.disabled_gc = XtGetGC ((Widget)mw,
!                                     (GCFont | 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,
!                                     (GCFont | GCForeground | GCBackground), 
&xgcv);
      }
  
    xgcv.font = mw->menu.font->fid;
    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,
!                                 (GCFont | GCForeground | GCBackground
!                                  | GCFillStyle | GCStipple), &xgcv);
  
    xgcv.font = mw->menu.font->fid;
    xgcv.foreground = mw->core.background_pixel;
    xgcv.background = mw->menu.foreground;
    mw->menu.background_gc = XtGetGC ((Widget)mw,
!                                   GCFont | GCForeground | GCBackground,
                                    &xgcv);
  }
  
--- 1542,1588 ----
        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);
  }
  
***************
*** 1731,1742 ****
                                   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;
! 
    make_drawing_gcs (mw);
    make_shadow_gcs (mw);
  
--- 1789,1804 ----
                                   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);
    make_shadow_gcs (mw);
  
***************
*** 1903,1909 ****
  
    if (newmw->core.background_pixel != oldmw->core.background_pixel
        || newmw->menu.foreground != oldmw->menu.foreground
!       || newmw->menu.font != oldmw->menu.font)
      {
        release_drawing_gcs (newmw);
        make_drawing_gcs (newmw);
--- 1965,1974 ----
  
    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
!       )
      {
        release_drawing_gcs (newmw);
        make_drawing_gcs (newmw);
***************
*** 1929,1934 ****
--- 1994,2007 ----
          }
      }
  
+ #ifdef HAVE_X_I18N
+   if (newmw->menu.font != oldmw->menu.font)
+     {
+       redisplay = True;
+       newmw->menu.font_extents = XExtentsOfFontSet (newmw->menu.font);
+     }
+ #endif
+ 
    return redisplay;
  }
  




reply via email to

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