# HG changeset patch # User Sam Steingold # Date 970173052 0 # Node ID 833428005bf668e51da9d0ccb0665f4778a8f59d # Parent a87bf35accfc18b41cbbe46658b05c1d6f7b7987 * xlwmenu.c: Before including on SUN, define SUNOS41 to avoid redefining struct timeval and struct timezone. diff -r a87bf35accfc -r 833428005bf6 lwlib/ChangeLog --- a/lwlib/ChangeLog Thu Sep 28 20:19:44 2000 +0000 +++ b/lwlib/ChangeLog Thu Sep 28 20:30:52 2000 +0000 @@ -1,3 +1,8 @@ +2000-09-28 Sam Steingold + + * xlwmenu.c: Before including on SUN, define SUNOS41 + to avoid redefining struct timeval and struct timezone. + 2000-09-04 Miles Bader * xlwmenu.c (XlwMenuSetValues): Only frob the display if the menu @@ -160,7 +165,7 @@ * xlwmenuP.h (_XlwMenu_part): Add `highlight' callback list. 1999-10-19 Paul Eggert - + Add support for large files, plus some locale improvements. * dispatch.c, lwlib-Xaw.c, lwlib-Xlw.c, lwlib-Xm.c, lwlib.c, xlwmenu.c, @@ -169,7 +174,7 @@ * lwlib-Xm.c, lwlib.c: Do not include or , as does this. - + 1999-10-07 Gerd Moellmann * lwlib-Xm.c (make_menu_in_widget, update_one_menu_entry): Use @@ -187,7 +192,7 @@ 1999-09-10 Gerd Moellmann - * lwlib.c (lw_separator_p): Add `--:space' with the same + * lwlib.c (lw_separator_p): Add `--:space' with the same meaning as `--:noLine'. 1999-09-06 Gerd Moellmann @@ -283,7 +288,7 @@ 1999-07-12 Gerd Moellmann - * xlwmenu.c (xlwMenuResources): Change previously unused + * xlwmenu.c (xlwMenuResources): Change previously unused XtNmargin to 4. (size_menu): Take margin into account. (display_menu_item): Ditto. @@ -299,15 +304,15 @@ 2000-06-13 Gerd Moellmann * Version 20.7 released. - + 2000-02-26 Gerd Moellmann * Version 20.6 released. - + 1999-12-04 Gerd Moellmann * Version 20.5 released. - + 1999-07-12 Richard Stallman * Version 20.4 released. @@ -319,7 +324,7 @@ 1998-07-30 Paul Eggert * lwlib/Makefile.in (lwlib-utils.o, lwlib.o, lwlib-Xlw.o) - (lwlib-Xaw.o, lwlib-Xm.o, lwlib-Xol.o, lwlib-Xolmb.o): + (lwlib-Xaw.o, lwlib-Xm.o, lwlib-Xol.o, lwlib-Xolmb.o): Add dependencies to corresponding .c files. for Solaris 2.x VPATH make. 1998-04-06 Andreas Schwab @@ -370,11 +375,11 @@ * lwlib-Xm.c (update_one_menu_entry): Fix previous change: When XmIsCascadeButton, don't call XmCreateCascadeButtonGadget, just modify the existing one. - + 1996-08-09 Marcus Daniels * lwlib.c (merge_widget_value): Undo previous change. - + * lwlib-Xm.c (update_one_menu_entry): When creating a pulldown in an existing but empty menu item, in order to get a new functional pulldown, the menu item must be switched from an XmPushButtonGadget @@ -568,7 +573,7 @@ * Makefile.in (ALL_CFLAGS): Define HAVE_CONFIG_H. Add -I${srcdir}/../src. - + 1995-04-08 Paul Reilly * lwlib-Xm.c: Remove function prototypes. @@ -786,12 +791,12 @@ 1994-04-01 Frederic Pierresteguy (fp@hal.gnu.ai.mit.edu) - * lwlib-Xaw.c (make_dialog): Don't allow any geometry request from the + * lwlib-Xaw.c (make_dialog): Don't allow any geometry request from the user. 1994-03-22 Frederic Pierresteguy (fp@mole.gnu.ai.mit.edu) - * xlwmenu.c (XlwMenuResize): Don't allow the popup menu to resize + * xlwmenu.c (XlwMenuResize): Don't allow the popup menu to resize itself. Therefore reset the size to its initial value. 1994-03-19 Richard Stallman (rms@mole.gnu.ai.mit.edu) @@ -874,7 +879,7 @@ 1994-02-17 Frederic Pierresteguy (fp@mole.gnu.ai.mit.edu) - * lwlib-Xlw.c (xlw_create_popup_menu): Pass tem to + * lwlib-Xlw.c (xlw_create_popup_menu): Pass tem to XtVaCreateManagedWidget, not instance->info->val. (xlw_create_menubar): Likewise. @@ -902,7 +907,7 @@ 1994-02-04 Frederic Pierresteguy (fp@mole.gnu.ai.mit.edu) * xlwmenu.c (display_menu_item): When dealing with the menubar, - always call XDrawRectangle to clear the selection after popping down + always call XDrawRectangle to clear the selection after popping down the pulldown menu. 1994-02-01 Richard Stallman (rms@mole.gnu.ai.mit.edu) @@ -948,7 +953,7 @@ * lwlib-int.h: Renamed from lwlib-internal.h. - + ;; Local Variables: ;; coding: iso-2022-7bit-unix diff -r a87bf35accfc -r 833428005bf6 lwlib/xlwmenu.c --- a/lwlib/xlwmenu.c Thu Sep 28 20:19:44 2000 +0000 +++ b/lwlib/xlwmenu.c Thu Sep 28 20:30:52 2000 +0000 @@ -1,15 +1,15 @@ -/* Implements a lightweight menubar widget. +/* Implements a lightweight menubar widget. Copyright (C) 1992 Lucid, Inc. This file is part of the Lucid Widget Library. -The Lucid Widget Library is free software; you can redistribute it and/or +The Lucid Widget Library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. The Lucid Widget Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of +but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -27,7 +27,13 @@ #include #include +#if (defined __sun) && !(defined SUNOS41) +#define SUNOS41 #include +#undef SUNOS41 +#else +#include +#endif #include #include #include @@ -73,8 +79,8 @@ XFontStruct *xlwmenu_default_font; -static char -xlwMenuTranslations [] = +static char +xlwMenuTranslations [] = ": start()\n\ : drag()\n\ : select()\n\ @@ -111,9 +117,9 @@ "; #define offset(field) XtOffset(XlwMenuWidget, field) -static XtResource +static XtResource xlwMenuResources[] = -{ +{ {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *), offset(menu.font),XtRString, "XtDefaultFont"}, {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), @@ -141,11 +147,11 @@ {XmNbottomShadowPixmap, XmCBottomShadowPixmap, XtRPixmap, sizeof (Pixmap), offset (menu.bottom_shadow_pixmap), XtRImmediate, (XtPointer)None}, - {XtNopen, XtCCallback, XtRCallback, sizeof(XtPointer), + {XtNopen, XtCCallback, XtRCallback, sizeof(XtPointer), offset(menu.open), XtRCallback, (XtPointer)NULL}, - {XtNselect, XtCCallback, XtRCallback, sizeof(XtPointer), + {XtNselect, XtCCallback, XtRCallback, sizeof(XtPointer), offset(menu.select), XtRCallback, (XtPointer)NULL}, - {XtNhighlightCallback, XtCCallback, XtRCallback, sizeof(XtPointer), + {XtNhighlightCallback, XtCCallback, XtRCallback, sizeof(XtPointer), offset(menu.highlight), XtRCallback, (XtPointer)NULL}, {XtNmenu, XtCMenu, XtRPointer, sizeof(XtPointer), offset(menu.contents), XtRImmediate, (XtPointer)NULL}, @@ -171,7 +177,7 @@ static void Nothing(); static int separator_height (); -static XtActionsRec +static XtActionsRec xlwMenuActionsList [] = { {"start", Start}, @@ -186,7 +192,7 @@ XlwMenuClassRec xlwMenuClassRec = { { /* CoreClass fields initialization */ - (WidgetClass) SuperClass, /* superclass */ + (WidgetClass) SuperClass, /* superclass */ "XlwMenu", /* class_name */ sizeof(XlwMenuRec), /* size */ XlwMenuClassInitialize, /* class_initialize */ @@ -307,7 +313,7 @@ { XCharStruct xcs; int drop; - + XTextExtents (mw->menu.font, s, strlen (s), &drop, &drop, &drop, &xcs); return xcs.width; } @@ -341,7 +347,7 @@ static XtResource nameResource[] = -{ +{ {"labelString", "LabelString", XtRString, sizeof(String), 0, XtRImmediate, 0}, }; @@ -396,7 +402,7 @@ int* height; { enum menu_separator separator; - + if (lw_separator_p (val->name, &separator, 0)) { *height = separator_height (separator); @@ -409,11 +415,11 @@ *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)) + mw->menu.horizontal_spacing + mw->menu.shadow_thickness; - + *rest_width = mw->menu.horizontal_spacing + mw->menu.shadow_thickness; if (!horizontal_p) { @@ -453,7 +459,7 @@ if (level >= mw->menu.old_depth) abort_gracefully ((Widget) mw); - ws = &mw->menu.windows [level]; + ws = &mw->menu.windows [level]; ws->width = 0; ws->height = 0; ws->label_width = 0; @@ -480,7 +486,7 @@ ws->height += height; } } - + if (horizontal_p) ws->label_width = ws->button_width = 0; else @@ -522,9 +528,9 @@ factor = (1 + sin (alpha)) / cos (alpha) */ double factor = 1.62; int thickness2 = thickness * factor; - + y += (mw->menu.font->ascent + mw->menu.font->descent - height) / 2; - + if (down_p) { GC temp; @@ -542,7 +548,7 @@ pt[3].x = x; pt[3].y = y; XFillPolygon (dpy, window, top_gc, pt, 4, Convex, CoordModeOrigin); - + pt[0].x = x; pt[0].y = y; pt[1].x = x + thickness; @@ -552,7 +558,7 @@ pt[3].x = x + width; pt[3].y = y + height / 2; XFillPolygon (dpy, window, top_gc, pt, 4, Convex, CoordModeOrigin); - + pt[0].x = x; pt[0].y = y + height; pt[1].x = x + thickness; @@ -590,7 +596,7 @@ top_gc = bottom_gc; bottom_gc = temp; } - + points [0].x = x; points [0].y = y; points [1].x = x + width; @@ -752,17 +758,17 @@ { case SEPARATOR_NO_LINE: break; - + case SEPARATOR_SINGLE_LINE: XDrawLine (dpy, window, mw->menu.foreground_gc, x, y, x + width, y); break; - + case SEPARATOR_DOUBLE_LINE: draw_separator (mw, window, x, y, width, SEPARATOR_SINGLE_LINE); draw_separator (mw, window, x, y + 2, width, SEPARATOR_SINGLE_LINE); break; - + case SEPARATOR_SINGLE_DASHED_LINE: xgcv.line_style = LineOnOffDash; XChangeGC (dpy, mw->menu.foreground_gc, GCLineStyle, &xgcv); @@ -771,14 +777,14 @@ xgcv.line_style = LineSolid; XChangeGC (dpy, mw->menu.foreground_gc, GCLineStyle, &xgcv); break; - + case SEPARATOR_DOUBLE_DASHED_LINE: draw_separator (mw, window, x, y, width, SEPARATOR_SINGLE_DASHED_LINE); draw_separator (mw, window, x, y + 2, width, SEPARATOR_SINGLE_DASHED_LINE); break; - + case SEPARATOR_SHADOW_ETCHED_IN: XDrawLine (dpy, window, mw->menu.shadow_bottom_gc, x, y, x + width, y); @@ -792,7 +798,7 @@ XDrawLine (dpy, window, mw->menu.shadow_bottom_gc, x, y + 1, x + width, y + 1); break; - + case SEPARATOR_SHADOW_ETCHED_IN_DASH: xgcv.line_style = LineOnOffDash; XChangeGC (dpy, mw->menu.shadow_bottom_gc, GCLineStyle, &xgcv); @@ -802,7 +808,7 @@ XChangeGC (dpy, mw->menu.shadow_bottom_gc, GCLineStyle, &xgcv); XChangeGC (dpy, mw->menu.shadow_top_gc, GCLineStyle, &xgcv); break; - + case SEPARATOR_SHADOW_ETCHED_OUT_DASH: xgcv.line_style = LineOnOffDash; XChangeGC (dpy, mw->menu.shadow_bottom_gc, GCLineStyle, &xgcv); @@ -817,14 +823,14 @@ draw_separator (mw, window, x, y, width, SEPARATOR_SHADOW_ETCHED_IN); draw_separator (mw, window, x, y + 3, width, SEPARATOR_SHADOW_ETCHED_IN); break; - + case SEPARATOR_SHADOW_DOUBLE_ETCHED_OUT: draw_separator (mw, window, x, y, width, SEPARATOR_SHADOW_ETCHED_OUT); draw_separator (mw, window, x, y + 3, width, SEPARATOR_SHADOW_ETCHED_OUT); break; - + case SEPARATOR_SHADOW_DOUBLE_ETCHED_IN_DASH: xgcv.line_style = LineOnOffDash; XChangeGC (dpy, mw->menu.shadow_bottom_gc, GCLineStyle, &xgcv); @@ -863,27 +869,27 @@ { case SEPARATOR_NO_LINE: return 2; - + case SEPARATOR_SINGLE_LINE: case SEPARATOR_SINGLE_DASHED_LINE: return 1; - + case SEPARATOR_DOUBLE_LINE: case SEPARATOR_DOUBLE_DASHED_LINE: return 3; - + case SEPARATOR_SHADOW_ETCHED_IN: case SEPARATOR_SHADOW_ETCHED_OUT: case SEPARATOR_SHADOW_ETCHED_IN_DASH: case SEPARATOR_SHADOW_ETCHED_OUT_DASH: return 2; - + case SEPARATOR_SHADOW_DOUBLE_ETCHED_IN: case SEPARATOR_SHADOW_DOUBLE_ETCHED_OUT: case SEPARATOR_SHADOW_DOUBLE_ETCHED_IN_DASH: case SEPARATOR_SHADOW_DOUBLE_ETCHED_OUT_DASH: return 5; - + default: abort (); } @@ -961,7 +967,7 @@ { draw_separator (mw, ws->window, x, y, width, separator); } - else + else { int x_offset = x + h_spacing + shadow; char* display_string = resource_widget_value (mw, val); @@ -978,12 +984,12 @@ } else if (!horizontal_p && ws->button_width) 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)); - + if (!horizontal_p) { if (val->button_type == BUTTON_TYPE_TOGGLE) @@ -992,13 +998,13 @@ else if (val->button_type == BUTTON_TYPE_RADIO) draw_radio (mw, ws->window, x, y + v_spacing + shadow, val->selected); - + if (val->contents) { int a_w = arrow_width (mw); draw_arrow (mw, ws->window, deco_gc, x + width - a_w - - mw->menu.horizontal_spacing + - mw->menu.horizontal_spacing - mw->menu.shadow_thickness, y + v_spacing + shadow, a_w, highlighted_p); @@ -1013,7 +1019,7 @@ } else { - XDrawRectangle (XtDisplay (mw), ws->window, + XDrawRectangle (XtDisplay (mw), ws->window, mw->menu.background_gc, x + shadow, y + shadow, label_width + h_spacing - 1, @@ -1027,7 +1033,7 @@ False); } } - + where->x += width; where->y += height; } @@ -1061,7 +1067,7 @@ if (level < mw->menu.old_depth - 1) following_item = mw->menu.old_stack [level + 1]; - else + else following_item = NULL; if (hit) @@ -1081,7 +1087,7 @@ else highlighted_pos->y = where.y; } - + just_compute_this_one_p = just_compute_p || ((this || that) && val != this && val != that); @@ -1113,7 +1119,7 @@ else where.x = 0; } - + if (!just_compute_p) draw_shadow_rectangle (mw, ws->window, 0, 0, ws->width, ws->height, False, False); @@ -1127,7 +1133,7 @@ int level; { int i; - + mw->menu.new_depth = 0; for (i = 0; i < level; i++) push_new_stack (mw, mw->menu.old_stack [i]); @@ -1145,7 +1151,7 @@ int mask; Window root = RootWindowOfScreen (DefaultScreenOfDisplay (XtDisplay (mw))); window_state* windows; - + if (mw->menu.windows_length >= n) return; @@ -1159,7 +1165,7 @@ xswa.cursor = mw->menu.cursor_shape; mask = CWSaveUnder | CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWEventMask | CWCursor; - + if (!mw->menu.windows) { mw->menu.windows = @@ -1242,7 +1248,7 @@ ws->y = previous_ws->y - ws->height; else ws->y = screen_height - ws->height; - if (ws->y < 0) + if (ws->y < 0) ws->y = 0; } } @@ -1316,7 +1322,7 @@ if (!mw->menu.horizontal || i > 1) ws->x += mw->menu.shadow_thickness; #endif - + ws->y = (previous_ws->y + selection_position.y + mw->menu.shadow_thickness); if (mw->menu.horizontal && i == 1) @@ -1368,7 +1374,7 @@ window_state* ws; *val = NULL; - + /* Find the window */ for (i = mw->menu.old_depth - 1; i >= 0; i--) { @@ -1400,14 +1406,14 @@ 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.foreground = mw->menu.foreground; xgcv.background = mw->core.background_pixel; @@ -1416,7 +1422,7 @@ mw->menu.inactive_gc = XtGetGC ((Widget)mw, (GCFont | GCForeground | GCBackground | GCFillStyle | GCStipple), &xgcv); - + xgcv.font = mw->menu.font->fid; xgcv.foreground = mw->menu.button_foreground; xgcv.background = mw->core.background_pixel; @@ -1425,7 +1431,7 @@ 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; @@ -1473,7 +1479,7 @@ mw->menu.top_shadow_color = mw->core.background_pixel; else mw->menu.top_shadow_color = mw->menu.top_shadow_color; - + if (mw->menu.bottom_shadow_color == -1) mw->menu.bottom_shadow_color = mw->menu.foreground; else @@ -1603,7 +1609,7 @@ px[i++] = mw->menu.bottom_shadow_color; if (i > 0) x_free_dpy_colors (dpy, screen, cmap, px, i); - + XtReleaseGC ((Widget) mw, mw->menu.shadow_top_gc); XtReleaseGC ((Widget) mw, mw->menu.shadow_bottom_gc); } @@ -1618,10 +1624,10 @@ /* Get the GCs and the widget size */ XSetWindowAttributes xswa; int mask; - + Window window = RootWindowOfScreen (DefaultScreenOfDisplay (XtDisplay (mw))); Display* display = XtDisplay (mw); - + #if 0 widget_value *tem = (widget_value *) XtMalloc (sizeof (widget_value)); @@ -1633,12 +1639,12 @@ /* mw->menu.cursor = XCreateFontCursor (display, mw->menu.cursor_shape); */ mw->menu.cursor = mw->menu.cursor_shape; - + mw->menu.gray_pixmap = XCreatePixmapFromBitmapData (display, window, gray_bitmap_bits, 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. */ @@ -1647,23 +1653,23 @@ make_drawing_gcs (mw); make_shadow_gcs (mw); - + xswa.background_pixel = mw->core.background_pixel; xswa.border_pixel = mw->core.border_pixel; mask = CWBackPixel | CWBorderPixel; - + mw->menu.popped_up = False; - + mw->menu.old_depth = 1; mw->menu.old_stack = (widget_value**)XtMalloc (sizeof (widget_value*)); mw->menu.old_stack_length = 1; mw->menu.old_stack [0] = mw->menu.contents; - + mw->menu.new_depth = 0; mw->menu.new_stack = 0; mw->menu.new_stack_length = 0; push_new_stack (mw, mw->menu.contents); - + mw->menu.windows = (window_state*)XtMalloc (sizeof (window_state)); mw->menu.windows_length = 1; mw->menu.windows [0].x = 0; @@ -1671,7 +1677,7 @@ mw->menu.windows [0].width = 0; mw->menu.windows [0].height = 0; size_menu (mw, 0); - + mw->core.width = mw->menu.windows [0].width; mw->core.height = mw->menu.windows [0].height; } @@ -1709,7 +1715,7 @@ /* Only the toplevel menubar/popup is a widget so it's the only one that receives expose events through Xt. So we repaint all the other panes when receiving an Expose event. */ -static void +static void XlwMenuRedisplay (w, ev, region) Widget w; XEvent* ev; @@ -1730,7 +1736,7 @@ display_menu (mw, i, False, NULL, NULL, NULL, NULL, NULL); } -static void +static void XlwMenuDestroy (w) Widget w; { @@ -1781,7 +1787,7 @@ XtFree ((char *) mw->menu.windows); } -static Boolean +static Boolean XlwMenuSetValues (current, request, new) Widget current; Widget request; @@ -1816,7 +1822,7 @@ make_shadow_gcs (newmw); redisplay = True; - + if (XtIsRealized (current)) /* If the menu is currently displayed, change the display. */ for (i = 0; i < oldmw->menu.windows_length; i++) @@ -1833,7 +1839,7 @@ return redisplay; } -static void +static void XlwMenuResize (w) Widget w; { @@ -1868,7 +1874,7 @@ else set_new_state (mw, val, level); remap_menubar (mw); - + /* Sync with the display. Makes it feel better on X terms. */ XSync (XtDisplay (mw), False); } @@ -1896,7 +1902,7 @@ handle_single_motion_event (mw, ev); } -static void +static void Start (w, ev, params, num_params) Widget w; XEvent *ev; @@ -1925,7 +1931,7 @@ } } -static void +static void Drag (w, ev, params, num_params) Widget w; XEvent *ev; @@ -1989,7 +1995,7 @@ { XlwMenuWidget mw = (XlwMenuWidget)w; widget_value* selected_item = mw->menu.old_stack [mw->menu.old_depth - 1]; - + /* If user releases the button quickly, without selecting anything, after the initial down-click that brought the menu up, do nothing. */