[comp.sources.x] v11i047: wcl - Widget Creation Language, Part32/35

david@devvax.Jpl.Nasa.Gov (David E. Smyth) (02/12/91)

Submitted-by: david@devvax.Jpl.Nasa.Gov (David E. Smyth)
Posting-number: Volume 11, Issue 47
Archive-name: wcl/part32

#! /bin/sh

# Make a new directory for the wc sources, cd to it, and run kits 1
# thru 35 through sh.  When all 35 kits have been run, read README.

echo "This is wc 1.05 kit 32 (of 35).  If kit 32 is complete, the line"
echo '"'"End of kit 32 (of 35)"'" will echo at the end.'
echo ""
export PATH || (echo "You didn't use sh, you clunch." ; kill $$)
mkdir DemosAthena DemosMotif Mri Xmp 2>/dev/null
echo Extracting DemosMotif/Makefile
sed >DemosMotif/Makefile <<'!STUFFY!FUNK!' -e 's/X//'
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
XSYSLIBS=-lXt -lX11
XMWM_DEFINES=-DLARGECURSORS -DSHAPE -DOPAQUE
X
X# platform:  $XConsortium: sun.cf,v 1.38 89/12/23 16:10:10 jim Exp $
X# operating system:  SunOS 4.1
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 = ./DemosMotif
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 = -m 4755
X
X          DESTDIR =
X
X     TOP_INCLUDES = -I$(INCROOT)
X
X      CDEBUGFLAGS = -O
X        CCOPTIONS = -D_NO_PROTO -DSTRINGS_ALIGNED -DNO_REGEX
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 = $(DESTDIR)/usr/lib
X           BINDIR = $(DESTDIR)/usr/bin/X11
X          INCROOT = $(DESTDIR)/usr/include
X     BUILDINCROOT = $(TOP)
X      BUILDINCDIR = $(BUILDINCROOT)/X11
X      BUILDINCTOP = ..
X           INCDIR = $(INCROOT)/X11
X           ADMDIR = $(DESTDIR)/usr/adm
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/man
X    MANSOURCEPATH = $(MANPATH)/man
X           MANDIR = $(MANSOURCEPATH)n
X        LIBMANDIR = $(MANSOURCEPATH)3
X      XAPPLOADDIR = $(LIBDIR)/app-defaults
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 = /cdb2/X11R4/mit/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# Imake rules for building and installing libraries, programs,
X# apps-defaults, and other data files.  Unlike Imake.rules, these
X# rules allow files to be installed anywhere.
X#
X# These rules *override* rules of the same name defined in Imake.rules!!
X#
X# New variables:
X#	INSTBIN		default to $BINDIR - programs installed here
X#	INSTMAN		default to $MANDIR - man pages installed here
X#	INSTAPP		default to $XAPPLOADDIR - apps-defaults files go here
X#
X# David E. Smyth: Install.rules Wed Jan  2 07:12:10 PST 1991
X
X###########################################################################
X# Makefile defines for Widget Creation Library distribution.
X# David E. Smyth: Wc.tmpl Wed Jan  2 07:44:04 PST 1991
X
X# What I use for pre-release testing
X
X      INSTLIB = /u/tds/david/tmp/lib
X      INSTLIN = /u/tds/david/tmp/lib/lint
X      INSTINC = /u/tds/david/tmp/include
X      INSTBIN = /u/tds/david/tmp/bin
X      INSTMAN = /u/tds/david/tmp/man/man1
X      INSTAPP = /u/tds/david/tmp/app-defaults
X
X      MKDIRHIER = /bin/sh /u/tds/david/bin/mkdirhier.sh
X
X   WCTOPDIR = ..
X
X      WCLIB = -L$(INSTLIB) -lWc
X      XPLIB = -L$(INSTLIB) -lXp
X     XMPLIB = -L$(INSTLIB) -lXmp
X
X    SoWcRev = 1.05
X
X       PROGRAMS = MDmotif xmailbox
X          SRCS1 = MDmotif.c
X          OBJS1 = MDmotif.o
X          SRCS2 = xmailbox.c
X          OBJS2 = xmailbox.o
XLOCAL_LIBRARIES = $(XMPLIB) -lXm $(WCLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
X
X OBJS = $(OBJS1) $(OBJS2) $(OBJS3)
X SRCS = $(SRCS1) $(SRCS2) $(SRCS3)
X
Xall:: $(PROGRAMS)
X
XMDmotif: $(OBJS1) $(DEPLIBS1)
X	$(RM) $@
X	$(CC) -o $@ $(LDOPTIONS) $(OBJS1) $(LOCAL_LIBRARIES) $(LDLIBS)  $(EXTRA_LOAD_FLAGS)
X
Xdepend::
X	$(DEPEND) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
X
Xlint:
X	$(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
Xlint1:
X	$(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
X
Xclean::
X	$(RM) $(PROGRAMS)
X
Xxmailbox: $(OBJS2) $(DEPLIBS2)
X	$(RM) $@
X	$(CC) -o $@ $(LDOPTIONS) $(OBJS2) $(LOCAL_LIBRARIES) $(LDLIBS)  $(EXTRA_LOAD_FLAGS)
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
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
!STUFFY!FUNK!
echo Extracting Xmp/Table.c:AB
sed >Xmp/Table.c:AB <<'!STUFFY!FUNK!' -e 's/X//'
X	    if (temp = FindDefLoc(tw->table.layout_db, name)) {
X		if (c_r) *c_r = temp->loc.ax;
X		if (r_r) *r_r = temp->loc.ay;
X		if (hspan_r) *hspan_r = temp->loc.h_span;
X		if (vspan_r) *vspan_r = temp->loc.v_span;
X		if (opt_r) *opt_r = temp->loc.options;
X		return True;
X	    } else {
X		return False;
X	    }
X	}
X    } else {
X	XtErrorMsg("TblFindChild", "badParent", "XtToolkitError",
X		   "Parent of widget is not a tableClassWidget",
X		   (String *) NULL, (Cardinal *) NULL);
X    }
X    /*NOTREACHED*/
X}
X
X
X
Xstatic void TblDestroy(w)
XWidget w;			/* Widget to destroy */
X/*
X * Called to free resources consumed by the widget.
X */
X{
X    TableWidget tw = (TableWidget) w;
X
X    XtFree((char *) (tw->table.init_layout));
X    XtFree((char *) (tw->table.layout_db));
X    TblFreeLocTbl(tw->table.real_layout);
X    if (tw->table.rows) XtFree((char *) (tw->table.rows));
X    if (tw->table.cols) XtFree((char *) (tw->table.cols));
X}
X
X
Xstatic Cardinal DefSpecLen(layout)
XString layout;			/* Full layout specification string */
X/*
X * Examines `layout' and determines how many statements there are.
X * Basically counts semi-colons and adds one.
X */
X{
X    extern String strchr();
X    String idx = layout;
X    Cardinal result = 0;
X
X    while (idx && *idx) {
X	idx = (char *)strchr(idx, ';');
X	if (idx) {
X	    result++;
X	    idx++;
X	}
X    }
X    return result+1;
X}
X
X#define MAX_FIELD	128
X#define NUM_FIELDS	6
X#define MAX_CHARS	255
X
Xstatic XtTblMask ParseOpts(spec)
XString spec;			/* Option letters */
X/*
X * Parses the null-terminated string of option characters in `spec'.
X * Returns a mask that is the `or' of all options selected.
X */
X{
X    static Boolean init = 0;
X    static XtTblMask all_chars[MAX_CHARS];
X    XtTblMask result = 0;
X    String idx;
X
X    if (!init) {
X	Cardinal i;
X
X	for (i = 0;  i < MAX_CHARS;  i++) all_chars[i] = 0;
X	all_chars['l'] = TBL_LEFT;
X	all_chars['r'] = TBL_RIGHT;
X	all_chars['t'] = TBL_TOP;
X	all_chars['b'] = TBL_BOTTOM;
X	all_chars['w'] = TBL_LK_WIDTH;
X	all_chars['h'] = TBL_LK_HEIGHT;
X	all_chars['W'] = TBL_SM_WIDTH;
X	all_chars['H'] = TBL_SM_HEIGHT;
X    }
X    for (idx = spec;  *idx;  idx++) {
X	result |= all_chars[*idx];
X    }
X    return result;
X}
X
Xstatic void DefParse(spec, loc_spec)
XString spec;			/* One specification statement */
XTableDefLocPtr loc_spec;	/* Result location spec        */
X/*
X * Parses a text specification statement into an internal
X * form given  by `loc_spec'.
X *
X ******************* NOTE ********************
X * Assumes only called from cvtStrToDefLoc() *
X *********************************************
X */
X{
X#ifndef MAX_TABLE_CHILD_WIDGET_NAME_LEN
X#define MAX_TABLE_CHILD_WIDGET_NAME_LEN 128
X#endif
X    static char buf[MAX_TABLE_CHILD_WIDGET_NAME_LEN];
X    int         i  = 0;
X    char*       cp = spec;
X
X    /* initial values, NOT the defaults */
X    loc_spec->loc.ax = loc_spec->loc.ay = 0;
X    loc_spec->loc.h_span = loc_spec->loc.v_span = 0;
X
X    /* Now attempt to parse the string */
X    while (*cp && *cp <= ' ') cp++;		/* eat whitespace */
X
X    while (' ' < *cp && i < MAX_TABLE_CHILD_WIDGET_NAME_LEN)
X	buf[i++] = *cp++;
X    buf[i] = '\0';
X    if ( i )
X	loc_spec->w_name = XtNewString(buf);	/* widget name */
X    else
X	loc_spec->w_name = "No Name";		/* default name */
X
X    while (*cp && *cp <= ' ') cp++;		/* eat whitespace */
X
X    while ('0' <= *cp && *cp <= '9')
X	loc_spec->loc.ax = loc_spec->loc.ax * 10 + *cp++ - '0';
X
X    while (*cp && *cp <= ' ') cp++;		/* eat whitespace */
X
X    while ('0' <= *cp && *cp <= '9')
X	loc_spec->loc.ay = loc_spec->loc.ay * 10 + *cp++ - '0';
X
X    while (*cp && *cp <= ' ') cp++;		/* eat whitespace */
X
X    while ('0' <= *cp && *cp <= '9')
X	loc_spec->loc.h_span = loc_spec->loc.h_span * 10 + *cp++ - '0';
X    if (loc_spec->loc.h_span == 0)
X	loc_spec->loc.h_span = 1;		/* default span */
X
X    while (*cp && *cp <= ' ') cp++;		/* eat whitespace */
X
X    while ('0' <= *cp && *cp <= '9')
X	loc_spec->loc.v_span = loc_spec->loc.v_span * 10 + *cp++ - '0';
X    if (loc_spec->loc.v_span == 0)
X	loc_spec->loc.v_span = 1;		/* default span */
X
X    while (*cp && *cp <= ' ') cp++;		/* eat whitespace */
X
X    i = 0;
X    while (*cp && i < MAX_TABLE_CHILD_WIDGET_NAME_LEN &&
X	*cp == 'l' || *cp == 'r' || *cp == 't' || *cp == 'b' ||
X	*cp == 'w' || *cp == 'h' || *cp == 'W' || *cp == 'H' )
X	buf[i++] = *cp++;
X    buf[i] = '\0';
X    if ( i )
X	loc_spec->loc.options = ParseOpts(buf);
X    else
X	loc_spec->loc.options = 0;		/* default */
X
X    while (*cp && *cp <= ' ') cp++;		/* eat whitespace */
X
X    if (*cp )
X	XtStringConversionWarning( spec, 
X	    "layout component: name [col] [row] [h_span] [v_span] [lrtbwhWH]");
X}
X
Xstatic String GetSpec(spec_ptr)
XString *spec_ptr;		/* Specification pointer */
X/*
X * This routine gets the next specification from the string
X * `spec_ptr' and updates the pointer appropriately.
X */
X{
X    extern String strchr();
X    String result;
X    String semi;
X
X    if (*spec_ptr && **spec_ptr) {
X	semi = (char *)strchr(*spec_ptr, ';');
X	if (semi) {
X	    *semi = '\0';
X	    result = *spec_ptr;
X	    *spec_ptr = semi+1;
X	    return result;
X	} else {
X	    result = *spec_ptr;
X	    *spec_ptr += strlen(*spec_ptr);
X	    return result;
X	}
X    } else {
X	return (String) 0;
X    }
X}
X
X
X
X/**********************************************************************
X *
X * Public routines
X *
X **********************************************************************/
X
X
X/*ARGSUSED*/
Xcaddr_t XtTblParseLayout(layout)
XString layout;			/* String layout specification */
X/*
X * Parses a string layout specification into an internal form
X * suitable for use in a call to XtSetValues().  The form is
X * a list of statements separated by semicolons.  Each statement
X * has the form:
X *   widget_name column row horizontal_span vertical_span opt_list
X * where the meaning of each field is:
X *   widget_name	Name of the widget as given to XtCreateWidget().
X *   column		Integer >= 0 descibing column in array
X *   row		Row >= 0 describing row in array
X *   horizontal_span	Integer >= 1 describing horizontal widget span
X *   vertical_span	Integer >= 1 describing vertical widget span
X *   opt_list		Series of characters each representing an option:
X *	l:  TBL_LEFT
X *	r:  TBL_RIGHT
X *      t:  TBL_TOP
X *      b:  TBL_BOTTOM
X *      w:  TBL_LK_WIDTH
X *      h:  TBL_LK_HEIGHT
X *      W:  TBL_SM_WIDTH
X *      H:  TBL_SM_HEIGHT
X * The options are as described in TblPostionChild().  The horizontal_span,
X * vertical_span, and opt_list are optional and will default to reasonable
X * values.
X */
X{
X    TableDefLocPtr result, idx;
X    Cardinal len;
X    String spec;
X    String orig;
X
X    /* Make a copy for safety */
X    if (layout && ((len = DefSpecLen(layout)) > 0)) {
X	orig = layout = XtNewString(layout);
X	result = (TableDefLocPtr) XtCalloc(len+1, sizeof(struct _TableDefLoc));
X	idx = result;
X	while (spec = GetSpec(&layout)) {
X	    DefParse(spec, idx);
X	    idx++;
X	}
X	/* null terminate */
X	idx->w_name = (String) 0;
X	XtFree(orig);
X	return (caddr_t) result;
X    } else {
X	return (caddr_t) 0;
X    }
X    /*NOTREACHED*/
X}
X
Xvoid XtTblPosition(w, col, row)
XWidget w;			/* Widget to position */
XPosition col, row;		/* Position in array  */
X/*
X * This routine positions a widget that has been created
X * under a widget of class tableWidgetClass.  The widget
X * will be placed at column `col' and row `row'.  If
X * the widget has never been placed before,  it will
X * span only one space in each direction and its
X * options will be the defaults for the table widget.
X */
X{
X    Position old_row, old_col;
X    Dimension old_hspan, old_vspan;
X    XtTblMask old_opts;
X
X    if (TblFindChild(w, &old_col, &old_row, &old_hspan, &old_vspan, &old_opts)) {
X	TblPositionChild(w, col, row, old_hspan, old_vspan, old_opts);
X    } else {
X	TblPositionChild(w, col, row, 1, 1, TBL_DEF_OPT);
X    }
X}
X
Xvoid XtTblResize(w, h_span, v_span)
XWidget w;			/* Widget to resize            */
XDimension h_span, v_span;	/* New widget span             */
X/*
X * This routine changes the span of widget `w' to (`h_span', `v_span').
X * If the widget has never been placed before,  it will be located
X * at (0,0) and its options will be the defaults for its
X * parent table widget.
X */
X{
X    Position old_row, old_col;
X    Dimension old_hspan, old_vspan;
X    XtTblMask old_opts;
X
X    if (TblFindChild(w, &old_col, &old_row, &old_hspan, &old_vspan, &old_opts)) {
X	TblPositionChild(w, old_col, old_row, h_span, v_span, old_opts);
X    } else {
X	TblPositionChild(w, 0, 0, h_span, v_span, TBL_DEF_OPT);
X    }
X}
X
Xvoid XtTblOptions(w, opt)
XWidget w;			/* Widget to change */
XXtTblMask opt;			/* New option mask  */
X/*
X * This routine changes the options of widget `w' to `opt'.  If
X * the widget has never been placed before,  it will be located
X * and (0,0) with a span of (1,1) and its options will be the
X * default options for its parent table widget.  The option
X * mask is as described for TblPositionChild.
X */
X{
X    Position old_row, old_col;
X    Dimension old_hspan, old_vspan;
X    XtTblMask old_opts;
X
X    if (TblFindChild(w, &old_col, &old_row, &old_hspan, &old_vspan, &old_opts)) {
X	TblPositionChild(w, old_col, old_row, old_hspan, old_vspan, opt);
X    } else {
X	TblPositionChild(w, 0, 0, 1, 1, opt);
X    }
X}
X
Xvoid XtTblConfig(w, col, row, h_span, v_span, opt)
XWidget w;			/* Widget to position          */
XPosition col, row;		/* Position in array           */
XDimension h_span, v_span;	/* Horizonal and vertical span */
XXtTblMask opt;			/* Widget placement options    */
X/*
X * This routine positions a widget that has been created
X * under a widget of class tableWidgetClass.  The widget
X * will be placed at column `col' and row `row'.  The
X * widget will span the distances given by `h_span' and `v_span'.
X * The options argument is as described for TblPositionChild.
X */
X{
X    TblPositionChild(w, col, row, h_span, v_span, opt);
X}
X
XWidget XtCreateTable(parent, name, arglist, argcount)
XWidget parent;
Xchar * name;
XArgList arglist;
XCardinal argcount;
X
X{
X   return(XtCreateWidget(name, tableWidgetClass, parent, arglist, argcount));
X}
X
X
!STUFFY!FUNK!
echo Extracting DemosAthena/App.c
sed >DemosAthena/App.c <<'!STUFFY!FUNK!' -e 's/X//'
X/*
X** Copyright (c) 1990 David E. Smyth
X**
X** Redistribution and use in source and binary forms are permitted
X** provided that the above copyright notice and this paragraph are
X** duplicated in all such forms and that any documentation, advertising
X** materials, and other materials related to such distribution and use
X** acknowledge that the software was developed by David E. Smyth.  The
X** name of David E. Smyth may not be used to endorse or promote products
X** derived from this software without specific prior written permission.
X** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
X** WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
X** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X**
X*/
X
X/******************************************************************************
X**
X** SCCS_data: @(#)Ari.c 1.1 ( 19 Nov 90 )
X**
X** Description:	This file contains a sample application which uses
X**		Athena widgets.  The example functionally mimics the
X**		xwidgets.c example provided in examples/Xaw on the
X**		X11R4 tape from MIT.  The Widget Creation library
X**		is used.
X**
X**              Several application specific callbacks are registered
X**		with the Wc library, and bound to the interface by
X**		specifications within the application resource file.
X**
X**		Note that this application has NO fallback resources.
X**		Since the resource file actually defines the complete
X**		widget tree, the resource file(s) MUST be found,
X**		eliminating the raison d'etre of the fallbacks.
X**
X** Notes:	This program uses the Xrm (X resource management) database
X**		for widget tree definition and management.
X**
X******************************************************************************/
X
X/******************************************************************************
X**   Include_files.
X******************************************************************************/
X
X/*  -- Minimum include files to use WidgetCreate Library */
X#include <X11/Intrinsic.h>
X#include <Wc/WcCreate.h>
X
X/*  -- application specific include files */
X#include <stdio.h>
X#include <ctype.h>
X#include <X11/Xaw/Dialog.h>
X#include <X11/StringDefs.h>
X
X/******************************************************************************
X**  Private Functions
X******************************************************************************/
X
Xextern void AriRegisterAthena ();
X
X/*
X    -- Tied to Dialog `Okay' button
X******************************************************************************
X    Adds an entry to the List widget whose name is passed as clientData.
X*/
X
Xstatic void MyOkayCB( widget, widgetName, unused )
X    Widget  widget;
X    char*   widgetName;
X    caddr_t unused;
X{
X    Widget list_widget = WcFullNameToWidget( widget, widgetName );
X    static String * list = NULL;
X    static int num_items = 0, allocated_items = 0;
X
X    if (num_items == allocated_items) {
X        allocated_items += 10;
X        list = (String *) XtRealloc(list, sizeof(String) * allocated_items);
X    }
X
X    /*
X     * The value returned by XawDialogGetValueString() does not remain good
X     * forever so we must store is somewhere.  This creates a memory leak
X     * since I don't remember these values, and free them later.  I know about
X     * it, but it doesn't seem worth fixing in this example.
X     */
X
X    list[num_items++] = XtNewString(XawDialogGetValueString(XtParent(widget)));
X    XawListChange(list_widget, list, num_items, 0, True);
X}
X
X/*
X    -- MyQuitCB
X******************************************************************************
X    This function destroys the widget tree.
X*/
X
Xstatic void MyQuitCB( widget, widgetName, ignored )
X    Widget  widget;
X    char*   widgetName;
X    caddr_t ignored;
X{
X    Widget condemmed = WcFullNameToWidget( widget, widgetName );
X    fprintf(stderr, "MyQuitCB(%s)\n", widgetName );
X    if (condemmed == NULL)
X        XtDestroyWidget( WcRootWidget( widget ) );
X    else
X	XtDestroyWidget( condemmed );
X}
X
X/*
X    -- MyTimeSinceTouchedCB  Tied to the strip chart widget.
X******************************************************************************
X    This function returns the number of 10s of seconds since the user
X    caused an event in this application.  
X    Note that the StripChart requires a return value.
X*/
X
Xstatic void MyTimeSinceTouchedCB( widget, ignored, value_ptr )
X    Widget  widget;
X    caddr_t ignored;
X    double* value_ptr;
X{
X    double *value = (double *) value_ptr;
X    static double old_value = 0.0;
X    static Time old_stamp = 1;
X    Time new_stamp;
X
X    new_stamp = XtLastTimestampProcessed( XtDisplay( widget ) );
X
X    if (old_stamp != new_stamp) 
X    {
X        old_stamp = new_stamp;
X        old_value = 0.0;
X    }
X    else 
X    {
X        Arg args[1];
X        int update;
X
X        XtSetArg(args[0], XtNupdate, &update);
X        XtGetValues(widget, args, 1);
X        old_value += (double) update / 10.0;
X    }
X
X    *value = old_value;
X}
X
X/*
X    -- MyCountCB  Tied to button, increments counter and displays.
X******************************************************************************
X   The argument is interpreted as a widget which must be a label.
X   The count, after being incremented, is displayed in this label
X   widget.  (Actually, it may be anything derived from Label).
X*/
X
Xstatic void MyCountCB( widget, widgetName, ignored )
X    Widget  widget;
X    char*   widgetName;
X    caddr_t ignored;
X{
X    Arg arg[1];
X    char text[10];
X    static int count = 0;
X
X    sprintf( text, " %d ", ++count );
X    XtSetArg( arg[0], XtNlabel, text );
X    XtSetValues( WcFullNameToWidget( widget, widgetName ), arg, 1 );
X}
X
X/*
X    -- MyThumbedCB  Tied to scrollbar's jumpProc
X******************************************************************************
X    Prints location of the thumb as a percentage of the height of the
X    scrollbar into the labe widget named by the widgetName argument.
X*/
X
Xstatic void MyThumbedCB( widget, widgetName, top_ptr )
X    Widget  widget;
X    char*   widgetName;	/* string from resource database (resource file) */
X    float*  top_ptr;	/* scrollbar callback call data:  a pointer to a float
X			** containing the location of the scrollbar's thumb.
X			*/
X{
X    Widget label = WcFullNameToWidget( widget, widgetName );
X    Arg args[1];
X    char message[BUFSIZ];
X
X    sprintf( message, " Thumbed to %d%% ", (int)((*top_ptr)*100) );
X    XtSetArg( args[0], XtNlabel, message );
X    XtSetValues( label, args, 1 );
X}
X
X/*
X    -- MyScrolledCB  Tied to scrollbar's scrollProc
X******************************************************************************
X    Prints location of the pointer into the named label widget.
X*/
X
Xstatic void MyScrolledCB( widget, widgetName, num_pixels )
X    Widget  widget;
X    char*   widgetName; /* string from resource database (resource file) */
X    int*    num_pixels;	/* scrollbar callback call data:  the number of
X			** pixels the bar has been scrolled.
X			*/
X{
X    Widget label = WcFullNameToWidget( widget, widgetName );
X    Arg args[1];
X    char message[BUFSIZ];
X
X    sprintf( message, " Scrolled at %d pixels", num_pixels);
X    XtSetArg( args[0], XtNlabel, message );
X    XtSetValues( label, args, 1 );
X}
X
X/*
X    -- MyDestroyedCB  Destroy callback of application shell
X******************************************************************************
X    This is a Destroy callback that prints the name of the destroyed widget.
X*/
X
Xstatic void MyDestroyedCB( widget, client, unused )
X    Widget widget;
X    char*  client;	/* as registered or from resource database */
X    caddr_t unused;
X{
X    fprintf( stderr, "%s : Widget %s now destroyed.\n", 
X	client, WcWidgetToFullName(widget));
X}
X
X/*
X    -- RegisterApplicationCallbacks
X******************************************************************************
X    Register all the callbacks which define the application's behaviors.
X*/
X
Xstatic void RegisterApplicationCallbacks ( app )
X    XtAppContext app;
X{
X#define RCALL(name, func, client) WcRegisterCallback(app, name, func, client)
X
X    RCALL( "MyOkayCB",			MyOkayCB,		NULL	  );
X    RCALL( "MyQuitCB",			MyQuitCB,		NULL	  );
X    RCALL( "MyTimeSinceTouchedCB",	MyTimeSinceTouchedCB,	NULL	  );
X    RCALL( "MyCountCB",			MyCountCB,		NULL	  );
X    RCALL( "MyThumbedCB",		MyThumbedCB,		NULL	  );
X    RCALL( "MyScrolledCB",		MyScrolledCB,		"Scroll"  );
X    RCALL( "MyDestroyedCB",		MyDestroyedCB,		"Destroy" );
X}
X
X/******************************************************************************
X*   MAIN function
X******************************************************************************/
X
Xmain ( argc, argv )
X    int argc;
X    char* argv[];
X{   
X    char*        appClass;
X    XtAppContext app;
X    Widget       appShell;
X
X    appClass = (char*) XtMalloc ( strlen ( argv[0] ) + 1 );
X    strcpy (appClass, argv[0]);
X    /* initialize first letter to make class, or first two if
X    ** first is already capitalized, or don't worry about it.
X    */
X    if (islower(appClass[0]))
X	appClass[0] = toupper(appClass[0]);
X    else if (islower(appClass[1]))
X        appClass[1] = toupper(appClass[1]);
X    
X    /* With the Athena widgets, we MUST register the Wc
X    ** converters first, so WcCvtStringToWidget is invoked
X    ** instead of the far less useful XmuCvtStringToWidget.
X    */
X    WcAddConverters(NULL);
X
X    /*  -- Intialize Toolkit creating the application shell */
X    appShell = XtInitialize ( 
X	argv[0], appClass,		/* app name and class */
X	NULL, 0, 			/* description of cmd line options */
X	&argc, argv 
X    );
X    app = XtWidgetToApplicationContext(appShell);
X
X    /*  -- Register all application specific callbacks and widget classes */
X    RegisterApplicationCallbacks ( app );
X
X    /*  -- Register all Athena widget classes */
X    AriRegisterAthena ( app );
X
X    /*  -- Create widget tree below toplevel shell using Xrm database */
X    WcWidgetCreation ( appShell );
X
X    /*  -- Realize the widget tree and enter the main application loop */
X    XtRealizeWidget ( appShell );
X    XtMainLoop ( );
X}
!STUFFY!FUNK!
echo Extracting Mri/M05_Dialogs
sed >Mri/M05_Dialogs <<'!STUFFY!FUNK!' -e 's/X//'
X  Dialogs
X  -------
X
X  This example allows instances of each type of Motif dialog to be
X  selected from a pulldown menu.  Both statically created and dynamically
X  created dialogs are demonstrated.
X
X  Resource Naming Considerations when using Dialog Constructors
X  -------------------------------------------------------------
X
X  Motif constructors often introduce extra widgets.  In this example, the
X  dialogs are created with XmCreate*Dialog constructors.  With Motif 1.1,
X  these constructors all instroduce dialogShells of the name 
X  <dialogName>_popup.  Therefore, when you want to specify the resources
X  of the dialog, you must remember to include the dialog shell name, or
X  use `*' as a wildcard.  
X
X  *********************************************************
X  ** NOTE!  THIS IS AN INCOMPATIBILITY WITH MOTIF 1.0 !! **
X  *********************************************************
X
X  For example:
X
X	*foo.wcChildren:		dialog
X	*foo.dialog.wcConstructor:	XmCreateQuestionDialog
X	*foo*dialog.messageString:	whatever
X
X
X  This new naming convention now allows the following to work:
X
X    *push.activateCallback:	WcManageCB( *dialog )
X
X  Under Motif 1.0, you may recall that this would have popped-up only
X  the dialog shell, which would be empty.  Its child, in this case
X  the question dialog, would still be unmanaged and so would not have
X  been visible.
X
X
X  Widgets Statically Created By XmCreate*Dialog Should Be Unmanaged
X  -----------------------------------------------------------------
X
X  Otherwise, they will appear at widget creation time in the upper
X  left location of the screen (at least when using mwm).  Probably
X  not what you had in mind.   
X
X
X  Dynamically Created Widgets
X  ---------------------------
X
X  Most of the dialogs in this example are dynamically created.  
X  When they are created, the WcCreateChildrenCB() specifies
X  the parentage of the dynamically created widget.  The dynamcially
X  created children are NOT listed in any wcChildren resource.
X
X	o	The heirarchy of statically (initially) created 
X		widgets is specified by wcChildren resources.
X
X	o	The parentage of dynamically created widgets
X		is specified by the first argument to the
X		WcCreateChildrenCB() callback function.
X
X  Multiple Identical Widgets
X  --------------------------
X
X  This example allows multiple identical copies of the dynamically
X  created dialog boxes.  The buttons on such dynamic dialos
X  invoke WcDestroyCB, which is effectively XtDestroy().
X
X  Dynamically Created Once Only
X  -----------------------------
X
X  The WorkingDialog presents an example of a common use of dynamically
X  created widgets.  The WorkingDialog is dynamically created the first
X  time it is asked for, and from then on it is simply unmanaged and
X  re-managed.  
X
X  ----------------------------------------------------------------------
X
X# The dialogs listed as children of Mri are the statically created dialogs:
X#
XMri.wcChildren:		menuBar, BulletinBoardDialog, ErrorDialog
XMri.title:		M05_Dialogs
X
X# Only the first two dialogs are statically created, with exactly
X# one instance existing throughout the life of the process.
X#
X# The button's callback unmanages the BulletinBoardDialog 
X# child of the shell.
X#
X*BulletinBoardDialog.wcConstructor:	XmCreateBulletinBoardDialog
X*BulletinBoardDialog.wcManaged:		False
X!*BulletinBoardDialog.wcTrace:		True
X*BulletinBoardDialog.wcChildren:	bbButton
X*bbButton.wcConstructor:		XmCreatePushButton
X*bbButton.labelString:			Button on a BulletinBoardDialog
X*bbButton.activateCallback:		WcUnmanageCB( ~BulletinBoardDialog )
X
X# Statically created, so buttons just unmanage:
X#
X*ErrorDialog.wcConstructor:		XmCreateErrorDialog
X!*ErrorDialog.wcTrace:			True
X*ErrorDialog.wcManaged:			False
X*ErrorDialog.messageString:		Error Dialog Message
X*ErrorDialog.cancelCallback:		WcUnmanageCB(this)
X*ErrorDialog.helpCallback:		WcUnmanageCB(this)
X*ErrorDialog.okCallback:		WcUnmanageCB(this)
X
X# All the other dialogs are dynamically created, so they start out 
X# managed, and the std buttons destroy the pop-up (parent) shell:
X
X*cancelCallback:	WcDestroyCB( ~ )
X*helpCallback:		WcDestroyCB( ~ )
X*okCallback:		WcDestroyCB( ~ )
X
X*FileSelectionDialog.wcConstructor:	XmCreateFileSelectionDialog
X!*FileSelectionDialog.wcTrace:		True
X
X#
X# The button's callback destroys the parent of the parent of the button
X# which is the dialog shell.
X#
X*FormDialog.wcConstructor:		XmCreateFormDialog
X!*FormDialog.wcTrace:			True
X*FormDialog.wcChildren:			fdButton
X*fdButton.wcConstructor:		XmCreatePushButton
X*fdButton.labelString:			Button on a FormDialog
X*fdButton.activateCallback:		WcDestroyCB( ^^ )
X
X*InformationDialog.wcConstructor:	XmCreateInformationDialog
X!*InformationDialog.wcTrace:		True
X
X*MessageDialog.wcConstructor:		XmCreateMessageDialog
X!*MessageDialog.wcTrace:			True
X
X*PromptDialog.wcConstructor:		XmCreatePromptDialog
X!*PromptDialog.wcTrace:			True
X
X*QuestionDialog.wcConstructor:		XmCreateQuestionDialog
X!*QuestionDialog.wcTrace:		True
X
X*SelectionDialog.wcConstructor:		XmCreateSelectionDialog
X!*SelectionDialog.wcTrace:		True
X
X*WarningDialog.wcConstructor:		XmCreateWarningDialog
X!*WarningDialog.wcTrace:			True
X
X!  Note: this dialog is dynamically created, and then
X!  simply unmanaged and remanaged.
X! 
X*WorkingDialog.wcConstructor:		XmCreateWorkingDialog
X!*WorkingDialog.wcTrace:			True
X*WorkingDialog.cancelCallback:		WcUnmanageCB( this )
X*WorkingDialog.helpCallback:		WcUnmanageCB( this )
X*WorkingDialog.okCallback:		WcUnmanageCB( this )
X
X  ----------------------------------------------------------------------
X
X  Below are the resources for the menuBar and all its children.
X
X  ----------------------------------------------------------------------
X
X*menuBar.wcConstructor:	XmCreateMenuBar
X*menuBar.wcChildren:	fileMenu, file, \
X			staticDialogMenu, staticDialogs, \
X			dynamicDialogMenu, dynamicDialogs
X
X! fileMenu contains only a quit button
X
X*fileMenu.wcConstructor: XmCreatePulldownMenu
X*fileMenu.wcManaged:	 False
X*fileMenu.wcChildren:    quit
X
X*quit.wcConstructor:	XmCreateCascadeButton
X*quit.labelString:	Quit
X*quit.activateCallback:	WcExitCB
X
X*file.wcConstructor:	XmCreateCascadeButton
X*file.labelString:	File
X*file.subMenuId:	*fileMenu
X
X! staticDialogMenu contains one button for each dialog
X! which is statically (initially) created.  These dialogs
X! are managed (popped-up) when the cascade button is activated.
X
X*staticDialogs.wcConstructor:	XmCreateCascadeButton
X*staticDialogs.labelString:	Manage Existing Dialogs
X*staticDialogs.subMenuId:	*staticDialogMenu
X
X*staticDialogMenu.wcConstructor:	XmCreatePulldownMenu
X*staticDialogMenu.wcManaged:		False
X*staticDialogMenu.wcChildren:		bb, ed
X
X! The BulletinBoardDialog was statically created, so we just need to
X! manage it.
X! Note unexpected wierdness of name:
X
X*bb.wcConstructor:	XmCreateCascadeButton
X*bb.labelString:	Manage BulletinBoardDialog
X*bb.activateCallback:	WcManageCB( \
X	*BulletinBoardDialog_popup.BulletinBoardDialog)
X
X! Statically created, just manage the ErrorDialog to make it pop-up.
X! Note that only one ErrorDialog widget exists, so once it is managed
X! subsequent menu button selection have no apparent effect.
X
X*ed.wcConstructor:	XmCreateCascadeButton
X*ed.labelString:	Manage ErrorDialog
X*ed.activateCallback:	WcManageCB(*ErrorDialog)
X
X! dynamicDialogMenu contains one button for each dialog
X! which can be dynamically created.  These dialogs are
X! created when the appropriate cascade button is activated.
X
X*dynamicDialogs.wcConstructor:	XmCreateCascadeButton
X*dynamicDialogs.labelString:	Create New Dialogs
X*dynamicDialogs.subMenuId:	*dynamicDialogMenu
X
X*dynamicDialogMenu.wcConstructor:	XmCreatePulldownMenu
X*dynamicDialogMenu.wcManaged:		False
X*dynamicDialogMenu.wcChildren:		fsd, fd, id, md, pd, \
X					qd, sd, warn, sep, work
X
X*sep.wcConstructor:	XmCreateSeparatorGadget
X
X! For all the rest of the dialogs, they are created, not just managed.
X!
X! This causes a new FileSelectionDialog to be created as a child of
X! the application shell.
X
X*fsd.wcConstructor:	XmCreateCascadeButton
X*fsd.labelString:	Create FileSelectionDialog
X*fsd.activateCallback:	WcCreateChildrenCB( Mri, FileSelectionDialog )
X
X! The form dialog will be the child of the parent of the menu shell
X! which is the ancestor of the `fd' cascade button.
X!
X*fd.wcConstructor:	XmCreateCascadeButton
X*fd.labelString:	Create FormDialog
X*fd.activateCallback:	WcCreateChildrenCB( ~^, FormDialog)
X
X*id.wcConstructor:	XmCreateCascadeButton
X*id.labelString:	Create InformationDialog
X*id.activateCallback:	WcCreateChildrenCB( Mri, InformationDialog)
X
X*md.wcConstructor:	XmCreateCascadeButton
X*md.labelString:	Create MessageDialog
X*md.activateCallback:	WcCreateChildrenCB( Mri, MessageDialog)
X
X*pd.wcConstructor:	XmCreateCascadeButton
X*pd.labelString:	Create PromptDialog
X*pd.activateCallback:	WcCreateChildrenCB( Mri, PromptDialog)
X
X*qd.wcConstructor:	XmCreateCascadeButton
X*qd.labelString:	Create QuestionDialog
X*qd.activateCallback:	WcCreateChildrenCB( Mri, QuestionDialog)
X
X*sd.wcConstructor:	XmCreateCascadeButton
X*sd.labelString:	Create SelectionDialog
X*sd.activateCallback:	WcCreateChildrenCB( Mri, SelectionDialog)
X
X*warn.wcConstructor:	XmCreateCascadeButton
X*warn.labelString:	Create WarningDialog
X*warn.activateCallback:	WcCreateChildrenCB( Mri, WarningDialog)
X
X! Here is something different: On the first push, the working dialog 
X! is created.  On subsequent pushes, it is just managed.
X!
X*work.wcConstructor:	XmCreateCascadeButton
X*work.labelString:	Create WorkingDialog
X*work.activateCallback:	WcCreateChildrenCB( Mri, WorkingDialog), \
X	WcSetValueCB( *work.labelString: Manage WorkingDialog),  \
X	WcSetValueCB( *work.activateCallback: \
X				WcManageCB( *WorkingDialog) )
X
X*dialogs.wcConstructor:	XmCreateCascadeButton
X*dialogs.subMenuId:	*dialogMenu
X*dialogs.labelString:	Dialogs
!STUFFY!FUNK!
echo Extracting DemosAthena/MDathena.c
sed >DemosAthena/MDathena.c <<'!STUFFY!FUNK!' -e 's/X//'
X/*
X** Copyright (c) 1990 David E. Smyth
X**
X** Redistribution and use in source and binary forms are permitted
X** provided that the above copyright notice and this paragraph are
X** duplicated in all such forms and that any documentation, advertising
X** materials, and other materials related to such distribution and use
X** acknowledge that the software was developed by David E. Smyth.  The
X** name of David E. Smyth may not be used to endorse or promote products
X** derived from this software without specific prior written permission.
X** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
X** WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
X** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X**
X*/
X
X/******************************************************************************
X**
X** SCCS_data: @(#)MDathena.c 1.1 ( 19 Nov 90 )
X**
X** Description:	This file contains main() for an example demonstrating
X**		how to support multiple displays.  This file is derived
X**		from Ari.c, and which allows prototype interfaces to be 
X**		built from resource files.  The Widget Creation library 
X**		is used.
X**
X**		Note that a real application would probably want to keep
X**		the multiple displays syncronized.  The only way to do
X**		that is to specifically cause each widget to update all
X**		the other widgets.  This takes PROGRAMMING!!!
X**
X*******************************************************************************
X**   Include_files.
X******************************************************************************/
X
X#include <X11/Intrinsic.h>
X#include <X11/Shell.h>
X#include <ctype.h>
X#include <Wc/WcCreate.h>
X#include <Wc/WcCreateP.h>	/* for callback convenience funcs	*/
X
X/******************************************************************************
X**  Global Application Data
X******************************************************************************/
X
Xint          gargc;
Xchar**       gargv;
X
Xchar*        appName;
Xchar*        appClass;
XXtAppContext app;
X
Xstatic char msg[MAX_ERRMSG];
X
X/******************************************************************************
X**  Private Functions
X******************************************************************************/
X
Xextern void XpRegisterAll ();
X
X/*
X    -- Open a new display, build another widget tree on that display.
X******************************************************************************
X*/
X
Xstatic void NewWidgetTreeOnDisplay( this, name, ignored )
X    Widget  this;
X    char*   name;	/* display name from res file */
X    caddr_t ignored;
X{
X    static char clean[128];	/* display name w/o leading & trailing junk */
X    int		i;
X    int		largc;
X    char**	largv;
X    Display*    dpy;
X    Widget      newShell;
X    Arg		args[3];
X
X    /* -- get clean display name by stripping leading & trailing whitespace */
X    (void)WcCleanName( name, clean );
X
X    /* -- make local copy of global argc and argv */
X    largc = gargc;
X    largv = (char**)XtMalloc( (gargc+1) * sizeof(char*) );
X    for (i = 0 ; i < gargc ; i++)
X	largv[i] = gargv[i];
X    largv[i] = NULL;
X
X    /* -- open display, build Xrdb, add to app context */
X    dpy = XtOpenDisplay( 
X	app, clean, appName, appClass, NULL, 0, &largc, largv );
X    if (dpy == NULL)
X    {
X	sprintf( msg, "NewWidgetTreeOnDisplay( %s ) failed:\
X		Could not open display %s", clean, clean);
X	XtWarning( msg );
X	return;
X    }
X
X    /* -- create new shell on new display */
X    /* these args are exactly what XtAppInitialize sets. */
X    i = 0;
X /* XtSetArg(args[i], XtNscreen, DefaultScreenOfDisplay(dpy));	i++; */
X    XtSetArg(args[i], XtNargc, largc);				i++;
X    XtSetArg(args[i], XtNargv, largv);				i++;
X
X    newShell = XtAppCreateShell(
X	appName, appClass,
X	applicationShellWidgetClass, 
X	dpy, 
X	args, i );
X    if (newShell == NULL)
X    {
X	sprintf( msg, "NewWidgetTreeOnDisplay( %s ) failed:\
X		Could not create new application shell.", clean);
X        XtWarning( msg );
X        return;
X    }
X
X    /* -- create widget tree under this new application shell */
X    WcWidgetCreation ( newShell );
X
X    /*  -- Realize the widget tree and return to the main application loop */
X    XtRealizeWidget ( newShell );
X    return;
X}
X
X/*
X    -- Kill a widget tree on a display, close that display.
X******************************************************************************
X*/
X
Xstatic void KillWidgetTreeOnDisplay( this, notused, ignored )
X    Widget  this;
X    caddr_t notused;
X    caddr_t ignored;
X{
X    Display* dpy = XtDisplay(this);
X    XtDestroyWidget( WcRootWidget(this) );
X    XtCloseDisplay ( dpy );
X}
X
X/*
X    -- Register application specific callbacks.
X******************************************************************************
X*/
X
Xstatic void RegisterApplication ( app )
X    XtAppContext app;
X{
X#define RCB( name, func  ) WcRegisterCallback  ( app, name, func, NULL );
X
X    /* -- register callbacks to open a new display */
X    RCB( "NewWidgetTreeOnDisplay",	NewWidgetTreeOnDisplay		);
X    RCB( "KillWidgetTreeOnDisplay",	KillWidgetTreeOnDisplay		);
X}
X
X/******************************************************************************
X*   MAIN function
X******************************************************************************/
X
Xmain ( argc, argv )
X    int argc;
X    char* argv[];
X{   
X    int		i;
X    Widget	appShell;
X
X    /* make copies of argc and argv for later use in NewWidgetTreeOnDisplay */
X    gargc = argc;
X    gargv = (char**)XtMalloc( (argc+1) * sizeof(char*) );
X    for (i = 0 ; i < argc ; i++)
X	gargv[i] = argv[i];
X    gargv[i] = NULL;
X
X    appName = argv[0];
X    appClass = (char*) XtMalloc ( strlen ( argv[0] ) + 1 );
X    strcpy (appClass, argv[0]);
X    /* initialize first letter to make class, or first two if
X    ** first is already capitalized, or don't worry about it.
X    */
X    if (islower(appClass[0]))
X	appClass[0] = toupper(appClass[0]);
X    else if (islower(appClass[1]))
X        appClass[1] = toupper(appClass[1]);
X    
X    /*  -- Intialize Toolkit creating the application shell */
X    appShell = XtInitialize ( 
X	appName, appClass,		/* app name and class */
X	NULL, 0, 			/* description of cmd line options */
X	&argc, argv 
X    );
X    app = XtWidgetToApplicationContext(appShell);
X
X    /*  -- Register all application specific callbacks and widget classes */
X    RegisterApplication ( app );
X
X    /*  -- Register all classes and constructors for desired widget set */
X    XpRegisterAll ( app );
X
X    /*  -- Create widget tree below toplevel shell using Xrm database */
X    WcWidgetCreation ( appShell );
X
X    /*  -- Realize the widget tree and enter the main application loop */
X    XtRealizeWidget ( appShell );
X    XtMainLoop ( );
X}
!STUFFY!FUNK!
echo " "
echo "End of kit 32 (of 35)"
cat /dev/null >kit32isdone
run=''
config=''
for iskit in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35; do
    if test -f kit${iskit}isdone; then
	run="$run $iskit"
    else
	todo="$todo $iskit"
    fi
done
case $todo in
    '')
	echo "You have run all your kits.  Please read README."
	for combo in `find . -name '*:AA' -print`; do
	    if test -f "$combo"; then
		realfile=`echo $combo | sed 's/:AA$//'`
		cat $realfile:[A-Z][A-Z] >$realfile
		rm -rf $realfile:[A-Z][A-Z]
	    fi
	done
	rm -rf kit*isdone
	chmod ugo+x test*
	;;
    *)  echo "You have run$run."
	echo "You still need to run$todo."
	;;
esac
: Someone might mail this, so...
exit

--
Dan Heller
------------------------------------------------
O'Reilly && Associates 		      Zyrcom Inc
Senior Writer			       President
argv@ora.com			argv@zipcode.com