[alt.sources] EzMenu - Menu widgets with a resource manager interface, Part01/02

ferguson@cs.rochester.edu (George Ferguson) (11/15/90)

#! /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 2)."
# Contents:  README Imakefile Makefile ezMenu.man EzME.c EzME.h
#   EzMenuP.h
# Wrapped by ferguson@swan.cs.rochester.edu on Mon Nov 12 14:07:37 1990
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'\" \(2294 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
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 2294 -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'\" \(8306 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.a
X
XlibezMenu.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 8306 -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'\" \(2903 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"-name. The specification of the
Xmenu should be enclosed in parentheses.
X.IP "\fB(action str)\fP"
XThe string "str" (which can 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.
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 2903 -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'\" \(10449 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	while (*str && !( isspace(*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 10449 -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 '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 2\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked both archives.
    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		VOX:  (716) 275-2527