[alt.sources] EzMenu - Part01/01

ferguson@cs.rochester.edu (George Ferguson) (03/14/91)

You want this stuff if you took the previous xkal postings! It has changed
very slightly since xtex and my original posting of it. In particular,
whitespace is no longer considered an argument separator for arguments to
action procedures. It was too hard to escape them all otherwise.

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 1)."
# Contents:  README Imakefile Makefile ezMenu.man EzME.c EzME.h EzMEP.h
#   EzMenu.c EzMenu.h EzMenuP.h
# Wrapped by ferguson@swan.cs.rochester.edu on Wed Mar 13 13:55:30 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(2508 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X
X		README for EZMENU - Menu Widgets with Resources
X
X		 George Ferguson, ferguson@cs.rochester.edu
X
X			     12 Nov 1990
X
XDESCRIPTION:
X
X    The EzMenu package provides a resource manager interface to the Athena
X    simpleMenuWidgets. This code is lifted from the xtex distribution,
X    copyright 1989 by Dirk Grunwald. The EzMenu code is itself straight out
X    of the X distribution, hence requiring the following disclaimer, to which
X    I needn't add anything. I just wrote a short man page.
X
X    27 Feb 1991: gf: Removed use of whitespace to separate arguments in
X		     action specs, otherwise it's too hard to quote them
X		     and escape the quotes when needed. Comma is the only
X		     separator now.
X
XDISCLAIMER:
X
X * Copyright 1989 Massachusetts Institute of Technology
X *
X * Permission to use, copy, modify, distribute, and sell this software and its
X * documentation for any purpose is hereby granted without fee, provided that
X * the above copyright notice appear in all copies and that both that
X * copyright notice and this permission notice appear in supporting
X * documentation, and that the name of M.I.T. not be used in advertising or
X * publicity pertaining to distribution of the software without specific,
X * written prior permission.  M.I.T. makes no representations about the
X * suitability of this software for any purpose.  It is provided "as is"
X * without express or implied warranty.
X *
X * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
X * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
X * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
X * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
X * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X
XINSTALLATION:
X
X     1. Edit the Imakefile to reflect any changes for your site. For
X	example, by default the library created will be of the form
X
X		libezMenu-sparc.a
X
X	for example, where "-sparc" comes form the $(TARGET_MACH) variable
X	defined in Sun make. If you only use one architecture, or want
X	to make separate targets for separate architectures, just edit
X	or duplicate and edit the single target.
X
X     2. Execute
X		% xmkmf
X	to create the Makefile.
X
X     3. Execute
X		% make depend
X	to add the dependencies to the Makefile. This is optional for
X	this package unless you edit the header files.
X
X     4. Make the package using
X		% make
X
END_OF_FILE
if test 2508 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Imakefile'\"
else
echo shar: Extracting \"'Imakefile'\" \(121 characters\)
sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
X/**/#
X/**/#	Imakefile for popup library
X/**/#
X
XOBJS = EzMenu.o EzME.o
X
XNormalLibraryTarget(ezMenu$(TARGET_MACH),$(OBJS))
END_OF_FILE
if test 121 -ne `wc -c <'Imakefile'`; then
    echo shar: \"'Imakefile'\" unpacked with wrong size!
fi
# end of 'Imakefile'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(8334 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X# Makefile generated by imake - do not edit!
X# $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $
X#
X# The cpp used on this machine replaces all newlines and multiple tabs and
X# spaces in a macro expansion with a single space.  Imake tries to compensate
X# for this, but is not always successful.
X#
X
X###########################################################################
X# Makefile generated from "Imake.tmpl" and <Imakefile>
X# $XConsortium: Imake.tmpl,v 1.77 89/12/18 17:01:37 jim Exp $
X#
X# Platform-specific parameters may be set in the appropriate .cf
X# configuration files.  Site-wide parameters may be set in the file
X# site.def.  Full rebuilds are recommended if any parameters are changed.
X#
X# If your C preprocessor doesn't define any unique symbols, you'll need
X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
X# "make Makefile", "make Makefiles", or "make World").
X#
X# If you absolutely can't get imake to work, you'll need to set the
X# variables at the top of each Makefile as well as the dependencies at the
X# bottom (makedepend will do this automatically).
X#
X
X###########################################################################
X# platform-specific configuration parameters - edit sun.cf to change
X
X# platform:  $XConsortium: sun.cf,v 1.38 89/12/23 16:10:10 jim Exp $
X# operating system:  SunOS 4.0.3
X
X###########################################################################
X# site-specific configuration parameters - edit site.def to change
X
X# site:  $XConsortium: site.def,v 1.21 89/12/06 11:46:50 jim Exp $
X
X            SHELL = /bin/sh
X
X              TOP = .
X      CURRENT_DIR = .
X
X               AR = ar cq
X  BOOTSTRAPCFLAGS =
X               CC = cc
X
X         COMPRESS = compress
X              CPP = /lib/cpp $(STD_CPP_DEFINES)
X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
X          INSTALL = install
X               LD = ld
X             LINT = lint
X      LINTLIBFLAG = -C
X         LINTOPTS = -axz
X               LN = ln -s
X             MAKE = make
X               MV = mv
X               CP = cp
X           RANLIB = ranlib
X  RANLIBINSTFLAGS =
X               RM = rm -f
X     STD_INCLUDES =
X  STD_CPP_DEFINES =
X      STD_DEFINES =
X EXTRA_LOAD_FLAGS =
X  EXTRA_LIBRARIES =
X             TAGS = ctags
X
X    SHAREDCODEDEF = -DSHAREDCODE
X         SHLIBDEF = -DSUNSHLIB
X
X    PROTO_DEFINES =
X
X     INSTPGMFLAGS =
X
X     INSTBINFLAGS = -m 0755
X     INSTUIDFLAGS = -m 4755
X     INSTLIBFLAGS = -m 0664
X     INSTINCFLAGS = -m 0444
X     INSTMANFLAGS = -m 0444
X     INSTDATFLAGS = -m 0444
X    INSTKMEMFLAGS = -g kmem -m 2755
X
X          DESTDIR =
X
X     TOP_INCLUDES = -I$(INCROOT)
X
X      CDEBUGFLAGS = -O
X        CCOPTIONS =
X      COMPATFLAGS =
X
X      ALLINCLUDES = $(STD_INCLUDES) $(TOP_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES)
X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(DEFINES) $(COMPATFLAGS)
X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS)
X   LDCOMBINEFLAGS = -X -r
X
X        MACROFILE = sun.cf
X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
X
X    IMAKE_DEFINES =
X
X         IRULESRC = $(CONFIGDIR)
X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
X
X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
X			$(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
X			$(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
X
X###########################################################################
X# X Window System Build Parameters
X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
X
X###########################################################################
X# X Window System make variables; this need to be coordinated with rules
X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
X
X          PATHSEP = /
X        USRLIBDIR = /usr/staff/lib
X           BINDIR = /usr/staff/bin
X          INCROOT = /usr/staff/include
X     BUILDINCROOT = $(TOP)
X      BUILDINCDIR = $(BUILDINCROOT)/X11
X      BUILDINCTOP = ..
X           INCDIR = $(INCROOT)/X11
X           ADMDIR = /tmp
X           LIBDIR = $(USRLIBDIR)/X11
X        CONFIGDIR = $(LIBDIR)/config
X       LINTLIBDIR = $(USRLIBDIR)/lint
X
X          FONTDIR = $(LIBDIR)/fonts
X         XINITDIR = $(LIBDIR)/xinit
X           XDMDIR = $(LIBDIR)/xdm
X           AWMDIR = $(LIBDIR)/awm
X           TWMDIR = $(LIBDIR)/twm
X           GWMDIR = $(LIBDIR)/gwm
X          MANPATH = $(DESTDIR)/usr/staff/man
X    MANSOURCEPATH = $(MANPATH)/man
X           MANDIR = $(MANSOURCEPATH)1
X        LIBMANDIR = $(MANSOURCEPATH)3
X      XAPPLOADDIR = $(LIBDIR)/app-defaults
XXFILESEARCHPATHDEFAULT = $(LIBDIR)/%L/%T/%N%S:$(LIBDIR)/%l/%T/%N%S:$(LIBDIR)/%T/%N%S
X	         ERRORDB = $(LIBDIR)/XtErrorDB
X
X        SOXLIBREV = 4.2
X          SOXTREV = 4.0
X         SOXAWREV = 4.0
X        SOOLDXREV = 4.0
X         SOXMUREV = 4.0
X        SOXEXTREV = 4.0
X
X       FONTCFLAGS = -t
X
X     INSTAPPFLAGS = $(INSTDATFLAGS)
X
X            IMAKE = imake
X           DEPEND = makedepend
X              RGB = rgb
X            FONTC = bdftosnf
X        MKFONTDIR = mkfontdir
X        MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier.sh
X
X        CONFIGSRC = $(TOP)/config
X        CLIENTSRC = $(TOP)/clients
X          DEMOSRC = $(TOP)/demos
X           LIBSRC = $(TOP)/lib
X          FONTSRC = $(TOP)/fonts
X       INCLUDESRC = $(TOP)/X11
X        SERVERSRC = $(TOP)/server
X          UTILSRC = $(TOP)/util
X        SCRIPTSRC = $(UTILSRC)/scripts
X       EXAMPLESRC = $(TOP)/examples
X       CONTRIBSRC = $(TOP)/../contrib
X           DOCSRC = $(TOP)/doc
X           RGBSRC = $(TOP)/rgb
X        DEPENDSRC = $(UTILSRC)/makedepend
X         IMAKESRC = $(CONFIGSRC)
X         XAUTHSRC = $(LIBSRC)/Xau
X          XLIBSRC = $(LIBSRC)/X
X           XMUSRC = $(LIBSRC)/Xmu
X       TOOLKITSRC = $(LIBSRC)/Xt
X       AWIDGETSRC = $(LIBSRC)/Xaw
X       OLDXLIBSRC = $(LIBSRC)/oldX
X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
X     MKFONTDIRSRC = $(FONTSRC)/mkfontdir
X     EXTENSIONSRC = $(TOP)/extensions
X
X  DEPEXTENSIONLIB = $(USRLIBDIR)/libXext.a
X     EXTENSIONLIB =  -lXext
X
X          DEPXLIB = $(DEPEXTENSIONLIB)
X             XLIB = $(EXTENSIONLIB) -lX11
X
X      DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
X         XAUTHLIB =  -lXau
X
X        DEPXMULIB =
X           XMULIB = -lXmu
X
X       DEPOLDXLIB =
X          OLDXLIB = -loldX
X
X      DEPXTOOLLIB =
X         XTOOLLIB = -lXt
X
X        DEPXAWLIB =
X           XAWLIB = -lXaw
X
X LINTEXTENSIONLIB = $(USRLIBDIR)/llib-lXext.ln
X         LINTXLIB = $(USRLIBDIR)/llib-lX11.ln
X          LINTXMU = $(USRLIBDIR)/llib-lXmu.ln
X        LINTXTOOL = $(USRLIBDIR)/llib-lXt.ln
X          LINTXAW = $(USRLIBDIR)/llib-lXaw.ln
X
X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
X
X         DEPLIBS1 = $(DEPLIBS)
X         DEPLIBS2 = $(DEPLIBS)
X         DEPLIBS3 = $(DEPLIBS)
X
X###########################################################################
X# Imake rules for building libraries, programs, scripts, and data files
X# rules:  $XConsortium: Imake.rules,v 1.67 89/12/18 17:14:15 jim Exp $
X
X###########################################################################
X# start of Imakefile
X
X#
X#	Imakefile for popup library
X#
X
XOBJS = EzMenu.o EzME.o
X
Xall:: libezMenu$(TARGET_MACH).a
X
XlibezMenu$(TARGET_MACH).a: $(OBJS)
X	$(RM) $@
X	$(AR) $@ $(OBJS)
X	$(RANLIB) $@
X
X###########################################################################
X# common rules for all Makefiles - do not edit
X
Xemptyrule::
X
Xclean::
X	$(RM_CMD) \#*
X
XMakefile::
X	-@if [ -f Makefile ]; then \
X	echo "	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
X	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
X	else exit 0; fi
X	$(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
X
Xtags::
X	$(TAGS) -w *.[ch]
X	$(TAGS) -xw *.[ch] > TAGS
X
Xsaber:
X	#load $(ALLDEFINES) $(SRCS)
X
Xosaber:
X	#load $(ALLDEFINES) $(OBJS)
X
X###########################################################################
X# empty rules for directories that do not have SUBDIRS - do not edit
X
Xinstall::
X	@echo "install in $(CURRENT_DIR) done"
X
Xinstall.man::
X	@echo "install.man in $(CURRENT_DIR) done"
X
XMakefiles::
X
Xincludes::
X
X###########################################################################
X# dependencies generated by makedepend
X
END_OF_FILE
if test 8334 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'ezMenu.man' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ezMenu.man'\"
else
echo shar: Extracting \"'ezMenu.man'\" \(2977 characters\)
sed "s/^X//" >'ezMenu.man' <<'END_OF_FILE'
X.\"
X.\"	ezMenu.man : Menus with a resource manager interface
X.\"
X.TH EZMENU 3 "21/9/90"
X.ds ]W U of Rochester
X.SH NAME
XezMenu - A library of menu widgets with a resource manager interface
X.SH SYNOPSIS
X.B #include "/u/ferguson/src/x/EzMenu/EzMenu.h"
X.br
X.B #include "/u/ferguson/src/x/EzMenu/EzME.h"
X.sp
X.SH DESCRIPTION
X.PP
XThis package provides a resource manager interface to the simpleMenu
Xwidgets provided in the Athena widgets. The widget class
X.B ezMenuWidgetClass
Xis defined, subclassing the simpleMenu widget.
X.sp
X.SH USAGE
X.PP
XInclude the files listed above in compilation, and link with the library
X.BR libezMenu.a .
XFor example, you might use
X
X.nf
X	% cc [files] [Xlibs] -L/u/ferguson/src/x/EzMenu -lezMenu
X.fi
X
X.sp
X.SH RESOURCE USAGE
X.PP
XAn EzMenu widget can specify it's menu using the
X.B menu
Xresource, as in
X
X.nf
X	*someMenu.menu:	...
X.fi
X
Xor using XtSetValues(3X) with resource
X.BR XtNmenu .
X.PP
XThe menu resource should be a string consisting of parenthesized entries,
Xeach of which is one of the following forms:
X.IP "\fB(item str ...)\fP"
XCreates an item with label "name". Typically an item will specify it's
Xaction after it's name, as described below.
X.IP "\fB(menu str ...)\fP"
XCreates a nested menu whose name is "str"-menu. The specification of the
Xmenu should be enclosed in parentheses.
X.IP "\fB(action str)\fP"
XThe string "str" (which should be quoted in double-quotes) will be executed as
Xif it were an action specification in a translation when the item is
Xselected. Thus it should be a whitespace-separated list of action
Xprocedures to call (with arguments) when the item is selected.
XDouble-quotes can be escaped with backslash (as can backslash itself).
X.IP \fB(line)\fP
XThis menu item will be an unselectable line (like smeLine).
X.IP \fB(blank)\fP
XThis menu item will be an unselectable blank space (like smeBSB with no
Xlabel).
X.sp
X.SH EXAMPLES
X.PP
XThe following is a simple menu specification:
X
X.nf
X	*someMenu.menu: \e
X		(item "hello" (action "do-hello()")) \e
X		(item "twice" (action "do-hello() do-hello()")) \e
X		(item "other" (action "do-other(foo) \e
X				             do-yet-another(foo,bar)")) \e
X		(line) \e
X		(item "quit"  (action "quit()")),
X.fi
X
XNote the free form use of whitespace and multiple actions.
X.sp
X.SH FILES
X.PP
X/u/ferguson/src/x/EzMenu/EzMenu.h
X.br
X/u/ferguson/src/x/EzMenu/EzME.h	
X.br
X/u/ferguson/src/x/EzMenu/libezMenu.a
X.sp
X.SH DIAGNOSTICS
X.PP
XThe package will complain of bad formats in the menu description with
Xthe cryptic string "unbalanced parens or bogus format" and an indication
Xof context. This message can also be generated if a menu item is too long
X(the current limit is 256 characters).
X.sp
X.SH SEE ALSO
X.PP
XAthena Widgets - C Language Interface
X.sp
X.SH AUTHOR
X.PP
XThe EzMenu widget routines were lifted from the program
X.BR xtex ,
Xcopyright 1989 by Dirk Grunwald. That code is lifted straight from the
XMIT distribution of the SimpleMenu widgets.
X.br
XMan page by George Ferguson (ferguson@cs.rochester.edu).
END_OF_FILE
if test 2977 -ne `wc -c <'ezMenu.man'`; then
    echo shar: \"'ezMenu.man'\" unpacked with wrong size!
fi
# end of 'ezMenu.man'
fi
if test -f 'EzME.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'EzME.c'\"
else
echo shar: Extracting \"'EzME.c'\" \(10479 characters\)
sed "s/^X//" >'EzME.c' <<'END_OF_FILE'
X#if ( !defined(lint) && !defined(SABER) )
Xstatic char Xrcsid[] = "$XConsortium: EzME.c,v 1.6 89/12/11 15:20:07 kit Exp $";
X#endif 
X
X/*
X * Copyright 1989 Massachusetts Institute of Technology
X *
X * Permission to use, copy, modify, distribute, and sell this software and its
X * documentation for any purpose is hereby granted without fee, provided that
X * the above copyright notice appear in all copies and that both that
X * copyright notice and this permission notice appear in supporting
X * documentation, and that the name of M.I.T. not be used in advertising or
X * publicity pertaining to distribution of the software without specific,
X * written prior permission.  M.I.T. makes no representations about the
X * suitability of this software for any purpose.  It is provided "as is"
X * without express or implied warranty.
X *
X * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
X * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
X * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
X * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
X * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X */
X
X/*
X * EzME.c - Source code for the generic menu entry
X *
X * Date:    September 26, 1989
X *
X * By:      Chris D. Peterson
X *          MIT X Consortium 
X *          kit@expo.lcs.mit.edu
X */
X
X#include <stdio.h>
X#include <X11/IntrinsicP.h>
X#include <X11/StringDefs.h>
X
X#include <X11/Xaw/XawInit.h>
X#include "EzMEP.h"
X#include "EzMenuP.h"
X#include <X11/Xaw/Cardinals.h>
X
X#include <ctype.h>
X
X#define offset(field) XtOffset(EzMEWidget, ezme.field)
Xstatic XtResource resources[] = {
X
X  {XtNaction, XtCAction, XtRString, sizeof(caddr_t),
X     offset(action), XtRString, (caddr_t)NULL},
X
X  {XtNmenu, XtCMenu, XtRWidget, sizeof(Widget), 
X     offset(toPopUp), XtRWidget, (caddr_t) NULL }
X};   
X#undef offset
X
Xstatic char haveSubMenuTransString[] =
X    "<EnterWindow>:     highlight()             \n\
X     <LeaveWindow>:     unhighlight() \n\
X     <BtnMotion>:       highlight()             \n\
X     <BtnUp>:           notify() unhighlight() "; 
X
Xstatic XtTranslations haveSubMenuTrans;
X
Xstatic char haveNoSubMenuTransString[] =
X    "<EnterWindow>:     highlight()             \n\
X     <LeaveWindow>:     unhighlight() MenuPopdown() \n\
X     <BtnMotion>:       highlight()             \n\
X     <BtnUp>:           notify() unhighlight()"; 
X
Xstatic XtTranslations haveNoSubMenuTrans;
X
X/*
X * Semi Public function definitions. 
X */
X
Xstatic void ClassInitialize();
Xstatic void Initialize();
Xstatic void Destroy();
Xstatic Boolean SetValues();
Xstatic void Notify();
Xstatic void Highlight();
Xstatic void UnHighlight();
X
X#define superclass (&smeBSBClassRec)
X
XEzMEClassRec ezMEClassRec = {
X  {
X    /* superclass         */    (WidgetClass) superclass,
X    /* class_name         */    "EzME",
X    /* size               */    sizeof(EzMERec),
X    /* class_initialize   */	ClassInitialize,
X    /* class_part_initialize*/	NULL,
X    /* Class init'ed      */	FALSE,
X    /* initialize         */    Initialize,
X    /* initialize_hook    */	NULL,
X    /* realize            */    NULL,
X    /* actions            */    NULL,
X    /* num_actions        */    ZERO,
X    /* resources          */    resources,
X    /* resource_count     */	XtNumber(resources),
X    /* xrm_class          */    NULLQUARK,
X    /* compress_motion    */    FALSE, 
X    /* compress_exposure  */    FALSE,
X    /* compress_enterleave*/ 	FALSE,
X    /* visible_interest   */    FALSE,
X    /* destroy            */    Destroy,
X    /* resize             */    NULL,
X    /* expose             */    XtInheritExpose,
X    /* set_values         */    SetValues,
X    /* set_values_hook    */	NULL,
X    /* set_values_almost  */	XtInheritSetValuesAlmost,  
X    /* get_values_hook    */	NULL,			
X    /* accept_focus       */    NULL,
X    /* intrinsics version */	XtVersion,
X    /* callback offsets   */    NULL,
X    /* tm_table		  */    XtInheritTranslations,
X    /* query_geometry	  */    XtInheritQueryGeometry,
X    /* display_accelerator*/    NULL,
X    /* extension	  */    NULL
X  },{
X    /* Simple Menu Entry Fields */
X      
X    /* highlight */             Highlight,
X    /* unhighlight */           UnHighlight,
X    /* notify */		Notify,		
X    /* extension */             NULL				
X  },
X  {
X    /* extension */             NULL				
X  }
X};
X
XWidgetClass ezMEObjectClass = (WidgetClass) &ezMEClassRec;
X
X/************************************************************
X *
X * Semi-Public Functions.
X *
X ************************************************************/
X
X
Xstatic void
XClassInitialize()
X{
X  haveSubMenuTrans = XtParseTranslationTable( haveSubMenuTransString );
X  haveNoSubMenuTrans = XtParseTranslationTable( haveNoSubMenuTransString );
X}
X
X/*      Function Name: Initialize
X *      Description: Initializes the simple menu widget
X *      Arguments: request - the widget requested by the argument list.
X *                 new     - the new widget with both resource and non
X *                           resource values.
X *      Returns: none.
X * 
X * MENU ENTRIES CANNOT HAVE BORDERS.
X */
X
X#ifndef XtObjectParent
X#  define XtObjectParent(x) ( x -> object.parent )
X#endif
X
X/* ARGSUSED */
Xstatic void
XInitialize(request, new)
XWidget request, new;
X{
X  EzMEWidget r = (EzMEWidget) request;
X  EzMEWidget n = (EzMEWidget) new;
X
X  n -> ezme.action = NULL;
X  if ( r -> ezme.action ) {
X    int len = strlen(r -> ezme.action);
X    n -> ezme.action = XtMalloc(len+1);
X    strcpy(n -> ezme.action, r -> ezme.action);
X  }
X
X}
X
Xstatic void
XDestroy(w)
XWidget w;
X{
X  EzMEWidget n = (EzMEWidget) w;
X
X  if ( n -> ezme.action ) {
X    XtFree( n -> ezme.action );
X  }
X}
X
Xstatic Boolean
XSetValues(current, request, new)
X     Widget current, request, new;
X{
X  EzMEWidget c = (EzMEWidget) current;
X  EzMEWidget r = (EzMEWidget) request;
X  EzMEWidget n = (EzMEWidget) new;
X
X  if (( !c -> ezme.action && r -> ezme.action)
X      ||
X      (c ->ezme.action
X       && r -> ezme.action
X       && !strcmp(c->ezme.action, r -> ezme.action)))
X      {
X	int len = strlen(r -> ezme.action);
X	XtFree(c->ezme.action);
X	n -> ezme.action = XtMalloc(len+1);
X	strcpy(n -> ezme.action, r -> ezme.action);
X      }
X}
X
X/*	Function Name: Notify
X *	Description: calls the callback proceedures for this entry.
X *	Arguments: w - the menu entry.
X *	Returns: none.
X */
X
X#define SKIPWHITE(cp) while (cp && *cp && isspace(*cp)) cp++
X
Xstatic void
XNotify(w) 
XWidget w;
X{
X  EzMEWidget widget = (EzMEWidget) w;
X  Widget parent = XtObjectParent( widget );
X  
X  XtPopdown( parent );
X
X  XtCallCallbacks(w, XtNcallback, NULL);
X  
X  if ( widget -> ezme.action ) {
X    char *action = widget -> ezme.action;
X    int actionLen = strlen( action );
X    
X    Bool doFree;
X    char stringCopy[1024];
X    char *allocatedStr;
X    char *str;
X    
X    char *actionProcName;
X    int num_params;
X    char *params[100];	/* lets hope they don't have more than that.. */
X    
X    if ( actionLen > 1023 ) {
X      allocatedStr = str = XtMalloc( actionLen + 2 );
X      doFree = True;
X    }
X    else {
X      str = stringCopy;
X      doFree = False;
X    }
X    
X    SKIPWHITE(str);
X    strcpy(str, action);
X    
X    for (;;) {
X      SKIPWHITE(str);
X      if ( str == 0 || *str == 0 ) break;
X
X      /* skip to action procedure name */
X      SKIPWHITE(str);
X      actionProcName = str;
X      
X      /* find end of action procedure name- terminate by space or paren */
X      while (*str && !( isspace(*str) || *str == '(' )) str++;
X      /* terminate action procedure name string */
X      *(str++) = 0;
X      
X      /* skip past any openning paren, e.g. in case of 'foo (bar)' */
X
X      SKIPWHITE(str);
X      if ( *str == '(') str++;
X      
X      /* now, scan to build a list of params */
X      num_params = 0;
X      while ( *str && *str != ')' && num_params < 100) {
X	SKIPWHITE(str);
X	params[num_params] = str;
X	/* gf: removed isspace(*str) from condition */
X	while (*str && !(*str == ',' || *str==')' )) {
X	  if (*str == '\\') {
X	    str++;
X	    if ( *str == 0 ) str--;
X	  }
X	  str++;
X	}
X
X	SKIPWHITE(str);
X
X	/* terminate this parameter */
X	
X	num_params++;
X	if ( *str == 0 ) {
X	  break;
X	} 
X	else if (*str == ')') {
X	  *(str++) = 0;
X	  break;
X	}
X	else {
X	  *(str++) = 0;
X	}
X	
X	SKIPWHITE(str);
X      }
X
X      SKIPWHITE(str);
X      if ( *str == ')') str++;
X      
X      XtCallActionProc(XtObjectParent(widget),
X		       actionProcName, NULL, params, num_params);
X    }
X    
X    if ( doFree ) {
X      XtFree( allocatedStr );
X    }
X  }
X}
X
Xstatic void
XHighlight(w, event, params, num_params)
XWidget w;
XXEvent * event;
XString * params;
XCardinal * num_params;
X{
X  Arg argList[20];
X  int args = 0;
X  int root_x, root_y, child_x, child_y, buttons;
X  Dimension width;
X  Dimension height;
X  
X  EzMEWidget widget = (EzMEWidget) w;
X
X  (*superclass -> sme_class.highlight) (w, event, params, num_params);
X  
X  if ( widget -> ezme.toPopUp ) {
X    Widget parent = XtObjectParent( widget );
X    Widget toPopUp = widget -> ezme.toPopUp;
X    
X    if ( toPopUp ) { 
X      
X      Window root, child;
X      Arg argList[20];
X      int args = 0;
X      int root_x, root_y, child_x, child_y, buttons;
X      Dimension width;
X      Dimension height;
X      
X      XQueryPointer(XtDisplay(parent),
X		    XtWindow(parent), &root, &child,
X		    &root_x, &root_y, &child_x, &child_y, &buttons);
X
X      root_x -= 20;
X      root_y -= 20;	/* put the mouse solidly in the window */
X
X      args = 0;
X      XtSetArg(argList[args], XtNtranslations, haveSubMenuTrans); args++;
X      XtSetValues(parent,argList,args);
X      
X      args = 0;
X      XtSetArg(argList[args], XtNx, root_x); args++;
X      XtSetArg(argList[args], XtNy, root_y); args++;
X      XtSetArg(argList[args], XtNtranslations, haveNoSubMenuTrans); args++;
X      XtSetValues(toPopUp,argList,args);
X      XtPopup(toPopUp, XtGrabExclusive);
X    }
X  }
X}
X
Xstatic void
XUnHighlight(w, event, params, num_params)
XWidget w;
XXEvent * event;
XString * params;
XCardinal * num_params;
X{
X  Arg argList[20];
X  int args = 0;
X  int root_x, root_y, child_x, child_y, buttons;
X  Dimension width;
X  Dimension height;
X  
X  EzMEWidget widget = (EzMEWidget) w;
X
X  (*superclass -> sme_class.unhighlight) (w, event, params, num_params);
X  
X  if ( widget -> ezme.toPopUp ) {
X    Widget parent = XtObjectParent( widget );
X
X    args = 0;
X    XtSetArg(argList[args], XtNtranslations, haveNoSubMenuTrans); args++;
X    XtSetValues(parent,argList,args);
X
X  }
X}
END_OF_FILE
if test 10479 -ne `wc -c <'EzME.c'`; then
    echo shar: \"'EzME.c'\" unpacked with wrong size!
fi
# end of 'EzME.c'
fi
if test -f 'EzME.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'EzME.h'\"
else
echo shar: Extracting \"'EzME.h'\" \(2058 characters\)
sed "s/^X//" >'EzME.h' <<'END_OF_FILE'
X/*
X * $XConsortium: EzME.h,v 1.4 89/12/11 15:20:09 kit Exp $
X *
X * Copyright 1989 Massachusetts Institute of Technology
X *
X * Permission to use, copy, modify, distribute, and sell this software and its
X * documentation for any purpose is hereby granted without fee, provided that
X * the above copyright notice appear in all copies and that both that
X * copyright notice and this permission notice appear in supporting
X * documentation, and that the name of M.I.T. not be used in advertising or
X * publicity pertaining to distribution of the software without specific,
X * written prior permission.  M.I.T. makes no representations about the
X * suitability of this software for any purpose.  It is provided "as is"
X * without express or implied warranty.
X *
X * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
X * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
X * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
X * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
X * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X */
X
X/*
X * EzME.h - Public Header file for EzME object.
X *
X * This is the public header file for the Athena EzME object.
X * It is intended to be used with the simple menu widget.  
X *
X * Date:    April 3, 1989
X *
X * By:      Chris D. Peterson
X *          MIT X Consortium 
X *          kit@expo.lcs.mit.edu
X */
X
X#ifndef _EzME_h
X#define _EzME_h
X
X#include <X11/RectObj.h>
X#include <X11/Xaw/Sme.h>
X
X/****************************************************************
X *
X * EzME Object
X *
X ****************************************************************/
X
Xtypedef struct _EzMEClassRec*	EzMEObjectClass;
Xtypedef struct _EzMERec*	        EzMEWidget;
X
X#define XtNaction "action"
X#define XtCAction "Action"
X
X#ifndef XtNmenuName
X#  define XtNmenuName "menuName"
X#  define XtCMenuName "MenuName"
X#endif
X
Xextern WidgetClass ezMEObjectClass;
X
X#endif /* _EzME_h */
END_OF_FILE
if test 2058 -ne `wc -c <'EzME.h'`; then
    echo shar: \"'EzME.h'\" unpacked with wrong size!
fi
# end of 'EzME.h'
fi
if test -f 'EzMEP.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'EzMEP.h'\"
else
echo shar: Extracting \"'EzMEP.h'\" \(3061 characters\)
sed "s/^X//" >'EzMEP.h' <<'END_OF_FILE'
X/*
X * $XConsortium: SmeP.h,v 1.4 89/12/11 15:20:22 kit Exp $
X *
X * Copyright 1989 Massachusetts Institute of Technology
X *
X * Permission to use, copy, modify, distribute, and sell this software and its
X * documentation for any purpose is hereby granted without fee, provided that
X * the above copyright notice appear in all copies and that both that
X * copyright notice and this permission notice appear in supporting
X * documentation, and that the name of M.I.T. not be used in advertising or
X * publicity pertaining to distribution of the software without specific,
X * written prior permission.  M.I.T. makes no representations about the
X * suitability of this software for any purpose.  It is provided "as is"
X * without express or implied warranty.
X *
X * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
X * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
X * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
X * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
X * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X */
X
X/*
X * SmeP.h - Private Header file for Sme object.
X *
X * This is the private header file for the Athena EzME object.
X * This object is intended to be used with the simple menu widget.  
X *
X * Date:    April 3, 1989
X *
X * By:      Chris D. Peterson
X *          MIT X Consortium 
X *          kit@expo.lcs.mit.edu
X */
X
X#ifndef _XawEzMEP_h
X#define _XawEzMEP_h
X
X/***********************************************************************
X *
X * EzME Widget Private Data
X *
X ***********************************************************************/
X
X#include <X11/RectObjP.h>
X#include <X11/Xaw/SmeP.h>
X#include <X11/Xaw/SmeBSBP.h>
X#include "EzME.h"
X
X/************************************************************
X *
X * New fields for the EzME widget class record.
X *
X ************************************************************/
X
Xtypedef struct _EzMEClassPart {
X  void (*highlight)();
X  void (*unhighlight)();
X  void (*notify)();	
X  XtPointer extension;
X} EzMEClassPart;
X
X/* Full class record declaration */
Xtypedef struct _EzMEClassRec {
X    RectObjClassPart    rect_class;
X    SmeClassPart	sme_class;
X    SmeBSBClassPart  sme_bsb_class;
X    EzMEClassPart	ezme_class;
X} EzMEClassRec;
X
Xextern EzMEClassRec ezmeClassRec;
X
X/* New fields for the EzME widget record */
Xtypedef struct {
X    /* resources */
X    char *action;
X    Widget toPopUp;
X} EzMEPart;
X
X/****************************************************************
X *
X * Full instance record declaration
X *
X ****************************************************************/
X
Xtypedef struct _EzMERec {
X  ObjectPart     object;
X  RectObjPart    rectangle;
X  SmePart	 sme;
X  SmeBSBPart   sme_bsb;
X  EzMEPart	 ezme;
X} EzMERec;
X
X/************************************************************
X *
X * Private declarations.
X *
X ************************************************************/
X#endif /* _XawEzMEP_h */
END_OF_FILE
if test 3061 -ne `wc -c <'EzMEP.h'`; then
    echo shar: \"'EzMEP.h'\" unpacked with wrong size!
fi
# end of 'EzMEP.h'
fi
if test -f 'EzMenu.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'EzMenu.c'\"
else
echo shar: Extracting \"'EzMenu.c'\" \(11897 characters\)
sed "s/^X//" >'EzMenu.c' <<'END_OF_FILE'
X#if ( !defined(lint) && !defined(SABER) )
Xstatic char Xrcsid[] = "$XConsortium: SimpleMenu.c,v 1.32 89/12/11 15:01:50 kit Exp $";
X#endif 
X
X/*
X * Copyright 1989 Massachusetts Institute of Technology
X *
X * Permission to use, copy, modify, distribute, and sell this software and its
X * documentation for any purpose is hereby granted without fee, provided that
X * the above copyright notice appear in all copies and that both that
X * copyright notice and this permission notice appear in supporting
X * documentation, and that the name of M.I.T. not be used in advertising or
X * publicity pertaining to distribution of the software without specific,
X * written prior permission.  M.I.T. makes no representations about the
X * suitability of this software for any purpose.  It is provided "as is"
X * without express or implied warranty.
X *
X * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
X * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
X * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
X * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
X * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X */
X
X#include <stdio.h>
X#include <X11/Xlib.h>
X#include <X11/Xos.h>  
X#include <X11/Intrinsic.h>
X#include <X11/IntrinsicP.h>
X#include <X11/StringDefs.h>
X
X#include "EzMenuP.h"
X#include <X11/Xaw/SimpleMenu.h>
X#include <X11/Xaw/Sme.h>
X#include "EzME.h"
X#include <X11/Xaw/SmeBSB.h>
X#include <X11/Xaw/SmeLine.h>
X
X#include <X11/Xaw/Cardinals.h>
X
X#include <ctype.h>
X
X#define offset(field) XtOffset(EzMenuWidget, ez_menu.field)
X
Xstatic XtResource resources[] = { 
X  {XtNmenu,  XtCMenu, XtRString, sizeof(String),
X     offset(menu), XtRString, NULL},
X};  
X#undef offset
X
X
X/*
X * Semi Public function definitions. 
X */
X
Xstatic void Initialize();
Xstatic void Destroy();
Xstatic void Realize();
Xstatic Boolean SetValues();
X
X#define superclass (&simpleMenuClassRec)
X    
XEzMenuClassRec ezMenuClassRec = {
X  {
X    /* superclass         */    (WidgetClass) superclass,
X    /* class_name         */    "EzMenu",
X    /* size               */    sizeof(EzMenuRec),
X    /* class_initialize   */	NULL,
X    /* class_part_initialize*/	NULL,
X    /* Class init'ed      */	FALSE,
X    /* initialize         */    Initialize,
X    /* initialize_hook    */	NULL,
X    /* realize            */    Realize,
X    /* actions            */    NULL,
X    /* num_actions        */    0,
X    /* resources          */    resources,
X    /* resource_count     */	XtNumber(resources),
X    /* xrm_class          */    NULLQUARK,
X    /* compress_motion    */    TRUE, 
X    /* compress_exposure  */    TRUE,
X    /* compress_enterleave*/ 	TRUE,
X    /* visible_interest   */    FALSE,
X    /* destroy            */    Destroy,
X    /* resize             */    XtInheritResize,
X    /* expose             */    XtInheritExpose,
X    /* set_values         */    SetValues,
X    /* set_values_hook    */	NULL,
X    /* set_values_almost  */	XtInheritSetValuesAlmost,  
X    /* get_values_hook    */	NULL,			
X    /* accept_focus       */    NULL,
X    /* intrinsics version */	XtVersion,
X    /* callback offsets   */    NULL,
X    /* tm_table		  */    XtInheritTranslations,
X    /* query_geometry	  */    XtInheritQueryGeometry,
X    /* display_accelerator*/    XtInheritDisplayAccelerator,
X    /* extension	  */    NULL
X  },{
X    /* geometry_manager   */    XtInheritGeometryManager,
X    /* change_managed     */    XtInheritChangeManaged,
X    /* insert_child	  */	XtInheritInsertChild,
X    /* delete_child	  */	XtInheritDeleteChild,
X    /* extension	  */    NULL
X  },{
X    /* Shell extension	  */    NULL
X  },{
X    /* Override extension */    NULL
X  },{
X    /* Simple Menu extension*/  NULL
X  },{
X    /* Ez Menu extension*/  NULL
X  }
X};
X
XWidgetClass ezMenuWidgetClass = (WidgetClass)&ezMenuClassRec;
X
X/************************************************************
X *
X * Semi-Public Functions.
X *
X ************************************************************/
X
X/*
X * routines to process menus
X */
X
X#define QUOTE '\"'
X#define BACKSLASH '\\'
X
X#define SKIPWHITE(cp) while (cp && *cp && isspace(*cp)) cp++
X#define FINDPAREN(cp) while (cp && *cp && *cp != '(') cp++
X#define FINDQUOTE(cp) while (cp && *cp && *cp != QUOTE) cp++
X#define KEY_LEN 32
X#define NAME_LEN 256
X#define LABEL_LEN 128
X
X/*
X * Parse a main level menu decl. and add all children to that parent
X */
X
Xchar *
XEzMenuParseString(from, to, maxlen)
Xchar *from;
Xchar *to;
Xint maxlen;
X{
X#ifdef OLD
X  char *oldto = to;
X  SKIPWHITE(from);
X  if ( from && *from == QUOTE ) {
X    maxlen--;
X    from++;
X    while (*from && *from != QUOTE && maxlen > 1) {
X      if ( *from == BACKSLASH) {
X	from++;
X      }
X      *to++ = *from++;
X      maxlen--;
X    }
X    if ( *from == QUOTE ) {
X      from++;
X    }
X  }
X  *to = 0;
X  return(from);
X#else /* NEW: by George Ferguson, ferguson@cs.rochester.edu, 12 Feb 1991.
X	 Allows escaped double-quotes (and backslashes) within the string
X	 being parsed, since we often need these for action specs. */
X
X  char *oldto = to;
X  int escaped = 0;
X
X  SKIPWHITE(from);
X  if (from && *from == QUOTE ) {
X    maxlen--;
X    for (from++; *from && maxlen > 1; from++) {
X      if (*from == QUOTE)
X        if (escaped) {
X          *to++ = QUOTE;
X          maxlen--;
X          escaped = 0;
X        } else
X          break;
X      else if (*from == BACKSLASH)
X        if (escaped) {
X          *to++ = BACKSLASH;
X          maxlen--;
X          escaped = 0;
X        } else
X          escaped = 1;
X      else {
X        *to++ = *from;
X        maxlen--;
X	escaped = 0;
X      }
X    }
X    if ( *from == QUOTE ) {
X      from++;
X    }
X  }
X  *to = '\0';
X  return(from);
X#endif /* OLD/NEW */
X}  
X
Xchar *
XEzMenuParseMenu(parent,menu,subMenuOk)
XWidget parent;
Xchar *menu;
XBool subMenuOk;
X{
X  char *thisWidgetName[NAME_LEN];
X  char *thisWidgetLabel[LABEL_LEN];
X
X  *thisWidgetName = 0;
X  *thisWidgetLabel = 0;
X  while(menu && *menu) {
X    SKIPWHITE(menu);
X
X    if (!menu || *menu != '(') {
X      return( menu );
X    }
X    else {
X      menu++;
X    }
X
X    SKIPWHITE(menu);
X
X    if (isalpha(*menu)) {
X      char key[KEY_LEN+1];
X      char *p = key;
X      int keylen = 0;
X
X      while(isalpha(*menu) && keylen < KEY_LEN) {
X	*p++ = *menu++;
X	keylen++;
X      }
X      *p = 0;
X
X      if (strcmp(key, "action") == 0 ) {
X	char name[NAME_LEN];
X	Arg arglist[1];
X	Cardinal num_args = 0;
X
X	menu = EzMenuParseString(menu, name, NAME_LEN);
X
X	XtSetArg(arglist[num_args], XtNaction, name); num_args++;
X	XtSetValues(parent, arglist, num_args);
X      }
X      else if (strcmp(key, "blank") == 0 ) {
X	char name[NAME_LEN];
X	Widget entry;
X
X	*name = 0;
X	menu = EzMenuParseString(menu, name, NAME_LEN);
X	if ( *name == 0 ) {
X	  static int counter = 0;
X	  sprintf(name, "blank%d", counter);
X	}
X	entry = XtCreateManagedWidget(name, smeObjectClass,
X				      parent, NULL, ZERO);
X      }
X      else if (strcmp(key, "line") == 0 ) {
X	char name[NAME_LEN];
X	Widget entry;
X
X	*name = 0;
X	menu = EzMenuParseString(menu, name, NAME_LEN);
X	if ( *name == 0 ) {
X	  static int counter = 0;
X	  sprintf(name, "line%d", counter);
X	}
X	entry = XtCreateManagedWidget(name, smeLineObjectClass, parent,
X				      NULL, ZERO);
X      }
X      else if (strcmp(key, "item") == 0 || strcmp(key, "menu") == 0 ) {
X	char name[NAME_LEN];
X	char label[LABEL_LEN];
X	Widget entry;
X	Bool isMenu;
X	extern void MenuSelect();
X	Arg arglist[10];
X	Cardinal num_args = 0;
X
X
X	isMenu = (strcmp(key, "menu") == 0);
X	*name = 0;
X
X	menu = EzMenuParseString(menu, label, LABEL_LEN);
X	menu = EzMenuParseString(menu, name, NAME_LEN);
X
X	if ( *name == 0 ) {
X	  static int counter = 0;
X	  sprintf(name, "%s%d", key, counter);
X	}
X
X	if ( *label == 0 ) {
X	  strcpy(label, name);
X	}
X
X	if ( isMenu ) {
X	  char menu_name[NAME_LEN];
X	  Widget menu_entry;
X
X	  sprintf(menu_name,"%s-menu", name);
X
X	  XtSetArg(arglist[num_args], XtNlabel, label); num_args++;
X
X	  menu_entry = XtCreatePopupShell(menu_name, ezMenuWidgetClass,
X			     parent, arglist, num_args);
X
X	  /* now, parse their menu entry. This is gross, but beats
X	   scanning ahead to find the stupid balanced parens */
X	  menu = EzMenuParseMenu(menu_entry, menu, True);
X
X	  num_args = 0;
X	  XtSetArg(arglist[num_args], XtNlabel, label); num_args++;
X	  XtSetArg(arglist[num_args], XtNmenu, menu_entry); num_args++;
X	  entry = XtCreateManagedWidget(name, ezMEObjectClass, parent, 
X					arglist, num_args);
X	}
X	else {
X	  num_args = 0;
X	  XtSetArg(arglist[num_args], XtNlabel, label); num_args++;
X	  XtSetArg(arglist[num_args], XtNmenu, 0); num_args++;
X	  entry = XtCreateManagedWidget(name, ezMEObjectClass, parent, 
X					arglist, num_args);
X	}
X
X	menu = EzMenuParseMenu(entry, menu, isMenu);
X      }
X
X      SKIPWHITE(menu);
X      if (*menu != ')') {
X	char buffer[2048];
X	XtAppContext context = 
X	  XtWidgetToApplicationContext( parent );
X
X	sprintf(buffer, "unbalanced parens or bogus format: %s\n", menu);
X
X	XtAppError(context, buffer);
X	exit(1);
X      }
X      menu++;
X    }
X  }
X  return(menu);
X}
X
X/*      Function Name: Initialize
X *      Description: Initializes the simple menu widget
X *      Arguments: request - the widget requested by the argument list.
X *                 new     - the new widget with both resource and non
X *                           resource values.
X *      Returns: none.
X */
X
X/* ARGSUSED */
Xstatic void
XInitialize(request, new)
XWidget request, new;
X{
X  EzMenuWidget newez = (EzMenuWidget) new;
X  EzMenuWidget requestez = (EzMenuWidget) request;
X
X#ifdef DEBUG
X  fprintf(stderr,"Initialize %s\n",
X	  XtWidgetName(request);
X#endif
X
X  /* just copy the string that will be used to initialize the menu */
X  
X  newez -> ez_menu.menu = 0;
X
X  if (requestez -> ez_menu.menu ) {
X    int len = strlen(requestez -> ez_menu.menu);
X    newez -> ez_menu.menu = XtMalloc( len + 1 );
X    strcpy( newez -> ez_menu.menu, requestez -> ez_menu.menu);
X  }
X
X  if ( newez -> ez_menu.menu ) {
X    EzMenuParseMenu( newez, newez -> ez_menu.menu, True );
X  }
X}
X
X/*      Function Name: Realize
X *      Description: Realizes the widget.
X *      Arguments: w - the simple menu widget.
X *                 mask - value mask for the window to create.
X *                 attrs - attributes for the window to create.
X *      Returns: none
X */
X
Xstatic void
XRealize(w, mask, attrs)
XWidget w;
XXtValueMask * mask;
XXSetWindowAttributes * attrs;
X{
X  EzMenuWidget newez = (EzMenuWidget) w;
X  (*superclass->core_class.realize) (w, mask, attrs);
X}
X
X
X/*      Function Name: SetValues
X *      Description: Relayout the menu when one of the resources is changed.
X *      Arguments: current - current state of the widget.
X *                 request - what was requested.
X *                 new - what the widget will become.
X *      Returns: none
X */
X
X/* ARGSUSED */
Xstatic Boolean
XSetValues(current, request, new)
X     Widget current, request, new;
X{
X  EzMenuWidget ez_old = (EzMenuWidget) current;
X  EzMenuWidget ez_want = (EzMenuWidget) request;
X  EzMenuWidget ez_new = (EzMenuWidget) new;
X  Boolean ret_val = FALSE;
X  if (
X
X      /* no old menu, want one now */
X
X      ( !ez_old -> ez_menu.menu && ez_want -> ez_menu.menu )
X      ||
X
X      /* old menu, new one is different */
X
X      (ez_want -> ez_menu.menu
X       && ez_old -> ez_menu.menu
X       && ( strcmp( ez_old -> ez_menu.menu,
X		   ez_want -> ez_menu.menu) != 0 ))
X      ) {
X
X    int len = strlen(ez_old -> ez_menu.menu);
X
X    ez_new -> ez_menu.menu = XtMalloc( len + 1 );
X    strcpy( ez_new -> ez_menu.menu,
X	   ez_old -> ez_menu.menu);
X    
X    if ( XtIsRealized(ez_old) ) {
X      SimpleMenuWidget smw = (SimpleMenuWidget) ez_old;
X      SmeObject *entry;
X      
X      ForAllChildren(smw, entry) {
X	XtDestroyWidget(entry);
X      }
X
X      EzMenuParseMenu(ez_new, ez_new -> ez_menu.menu, True);
X      ret_val = TRUE;
X    }
X  }
X  return(ret_val);
X}
X
Xstatic void
XDestroy(who)
XEzMenuWidget who;
X{
X  XtFree( who -> ez_menu.menu );
X}
X
END_OF_FILE
if test 11897 -ne `wc -c <'EzMenu.c'`; then
    echo shar: \"'EzMenu.c'\" unpacked with wrong size!
fi
# end of 'EzMenu.c'
fi
if test -f 'EzMenu.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'EzMenu.h'\"
else
echo shar: Extracting \"'EzMenu.h'\" \(3452 characters\)
sed "s/^X//" >'EzMenu.h' <<'END_OF_FILE'
X/*
X * $XConsortium: EzMenu.h,v 1.17 89/12/11 15:01:55 kit Exp $
X *
X * Copyright 1989 Massachusetts Institute of Technology
X *
X * Permission to use, copy, modify, distribute, and sell this software and its
X * documentation for any purpose is hereby granted without fee, provided that
X * the above copyright notice appear in all copies and that both that
X * copyright notice and this permission notice appear in supporting
X * documentation, and that the name of M.I.T. not be used in advertising or
X * publicity pertaining to distribution of the software without specific,
X * written prior permission.  M.I.T. makes no representations about the
X * suitability of this software for any purpose.  It is provided "as is"
X * without express or implied warranty.
X *
X * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
X * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
X * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
X * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
X * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X *
X * Author:  Chris D. Peterson, MIT X Consortium
X */
X
X/*
X * EzMenu.h - Public Header file for EzMenu widget.
X *
X * This is the public header file for the Athena EzMenu widget.
X * It is intended to provide one pane pulldown and popup menus within
X * the framework of the X Toolkit.  As the name implies it is a first and
X * by no means complete implementation of menu code. It does not attempt to
X * fill the needs of all applications, but does allow a resource oriented
X * interface to menus.
X *
X * Date:    April 3, 1989
X *
X * By:      Chris D. Peterson
X *          MIT X Consortium 
X *          kit@expo.lcs.mit.edu
X */
X
X#ifndef _EzMenu_h
X#define _EzMenu_h
X
X#include <X11/Shell.h>
X#include <X11/Xmu/Converters.h>
X#include <X11/Xaw/SimpleMenu.h>
X
X/****************************************************************
X *
X * EzMenu widget
X *
X ****************************************************************/
X
X/* EzMenu Resources:
X
X Name		     Class		RepType		Default Value
X ----		     -----		-------		-------------
X background	     Background		Pixel		XtDefaultBackground
X backgroundPixmap    BackgroundPixmap	Pixmap          None
X borderColor	     BorderColor	Pixel		XtDefaultForeground
X borderPixmap	     BorderPixmap	Pixmap		None
X borderWidth	     BorderWidth	Dimension	1
X bottomMargin        VerticalMargins    Dimension       VerticalSpace
X columnWidth         ColumnWidth        Dimension       Width of widest text
X cursor              Cursor             Cursor          None
X destroyCallback     Callback		Pointer		NULL
X height		     Height		Dimension	0
X label               Label              String          NULL (No label)
X labelClass          LabelClass         Pointer         smeBSBObjectClass
X mappedWhenManaged   MappedWhenManaged	Boolean		True
X rowHeight           RowHeight          Dimension       Height of Font
X sensitive	     Sensitive		Boolean		True
X topMargin           VerticalMargins    Dimension       VerticalSpace
X width		     Width		Dimension	0
X x		     Position		Position	0n
X y		     Position		Position	0
X
X*/
X
Xtypedef struct _EzMenuClassRec*	EzMenuWidgetClass;
Xtypedef struct _EzMenuRec*		EzMenuWidget;
X
X#define XtNmenu "menu"
X#define XtCMenu "Menu"
X
Xextern WidgetClass ezMenuWidgetClass;
X
X#endif /* _EzMenu_h */
END_OF_FILE
if test 3452 -ne `wc -c <'EzMenu.h'`; then
    echo shar: \"'EzMenu.h'\" unpacked with wrong size!
fi
# end of 'EzMenu.h'
fi
if test -f 'EzMenuP.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'EzMenuP.h'\"
else
echo shar: Extracting \"'EzMenuP.h'\" \(2205 characters\)
sed "s/^X//" >'EzMenuP.h' <<'END_OF_FILE'
X/*
X * $XConsortium: EzMenP.h,v 1.12 89/12/11 15:01:39 kit Exp $
X *
X * Copyright 1989 Massachusetts Institute of Technology
X *
X * Permission to use, copy, modify, distribute, and sell this software and its
X * documentation for any purpose is hereby granted without fee, provided that
X * the above copyright notice appear in all copies and that both that
X * copyright notice and this permission notice appear in supporting
X * documentation, and that the name of M.I.T. not be used in advertising or
X * publicity pertaining to distribution of the software without specific,
X * written prior permission.  M.I.T. makes no representations about the
X * suitability of this software for any purpose.  It is provided "as is"
X * without express or implied warranty.
X *
X * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
X * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
X * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
X * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
X * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X *
X */
X
X/*
X * EzMenuP.h - Private Header file for EzMenu widget.
X *
X * Date:    April 3, 1989
X *
X * By:      Chris D. Peterson
X *          MIT X Consortium
X *          kit@expo.lcs.mit.edu
X */
X
X#ifndef _EzMenuP_h
X#define _EzMenuP_h
X
X#include <X11/Xaw/SimpleMenP.h>
X#include "EzMenu.h"
X
Xtypedef struct {
X    XtPointer extension;		/* For future needs. */
X} EzMenuClassPart;
X
Xtypedef struct _EzMenuClassRec {
X  CoreClassPart	          core_class;
X  CompositeClassPart      composite_class;
X  ShellClassPart          shell_class;
X  OverrideShellClassPart  override_shell_class;
X  SimpleMenuClassPart	  simpleMenu_class;
X  EzMenuClassPart	  ezMenu_class;
X} EzMenuClassRec;
X
Xextern EzMenuClassRec ezMenuClassRec;
X
Xtypedef struct _EzMenuPart {
X    char *menu;
X} EzMenuPart;
X
Xtypedef struct _EzMenuRec {
X  CorePart		core;
X  CompositePart 	composite;
X  ShellPart 	        shell;
X  OverrideShellPart     override;
X  SimpleMenuPart	simple_menu;
X  EzMenuPart	ez_menu;
X} EzMenuRec;
X
X#endif /* _EzMenuP_h */
END_OF_FILE
if test 2205 -ne `wc -c <'EzMenuP.h'`; then
    echo shar: \"'EzMenuP.h'\" unpacked with wrong size!
fi
# end of 'EzMenuP.h'
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have the archive.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0

-- 
George Ferguson			ARPA: ferguson@cs.rochester.edu
University of Rochester		UUCP: {decvax,rutgers}!rochester!ferguson
Rochester  NY  14627-0226	VOX:  (716) 275-2527