[comp.sources.x] v10i041: Examples from New Xt Book, Part01/05

asente@adobe.com (11/01/90)

Submitted-by: asente@adobe.com
Posting-number: Volume 10, Issue 41
Archive-name: xt-examples/part01

[ Moderator's note --
  The following 5 shar's contain the source to the example programs used
  in Paul Asente's new book on programming Xt, the toolkit intrinsics.
  All flames for lack of Imakefile's should be directed to Paul :-)
  No, this does *not* mean that you don't have to include Imakefiles
  in your next submission!  --dan
]


#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	README
#	Makefile
#	accel.c
#	bargraph.c
#	confirm.c
#	confirm1.c
#	gadget.c
#	goodbye.c
#	justify.c
#	menu.c
#	sensitive.c
#	xbiff.c
#	xcalc.c
#	xmonitor.c
#	DemoBiff
#	DemoCalc
#	DemoMonitor
# This archive created: Wed Oct 24 14:28:46 1990
export PATH; PATH=/bin:$PATH
echo shar: extracting "'README'" '(4153 characters)'
if test -f 'README'
then
	echo shar: will not over-write existing file "'README'"
else
sed 's/^	X//' << \SHAR_EOF > 'README'
	XThis directory contains the sample widgets and applications described
	Xin "X Window System Toolkit -- Programmer's Guide and Specification" by
	XPaul Asente and Ralph Swick.  It also contains a number of simple
	Xapplications to exercise the capabilities of the widgets.
	X
	XThis directory is not set up as software to be installed.  The only changes
	Xthat might be necessary to make this build are the first three lines
	Xof the Makefile, giving the locations of the Xt library, the X11 library,
	Xand the X include files.
	X
	XThese widgets and applications require Intrinsics libraries and header
	Xfiles that are Release 4, patched through fix-11 from Project Athena.
	X
	XThe test applications are entirely self-contained and do no rely upon
	Xan application defaults file.  The sample applications xbiff, xcalc, and
	Xxmonitor do require application defaults files.  The easiest way to run them
	Xis to set the XAPPLRESDIR environment variable to : and to run the
	Xapplications in the directory containing the defaults files.
	X
	XThe contents of this directory are:
	X
	XREADME		This file
	XMakefile	The makefile for the software
	Xfragments	A directory of code fragments that are not parts of
	X		any of the other programs.
	X
	XBarDisplay.c	The implementation of the BarDisplay object
	XBarDisplay.h	The public header file for the BarDisplay object
	XBarDisplaP.h	The private header file for the BarDisplay object
	X
	XBox.c		The implementation of the Box widget
	XBox.h		The public header file for the Box widget
	XBoxP.h		The private header file for the Box widget
	X
	XConfirm.c	The implementation of the Confirm widget
	XConfirm.h       The public header file for the Confirm widget
	XConfirmP.h	The private header file for the Confirm widget
	X
	XConfirm1.c	The alternate implementation of the Confirm widget
	XConfirm1.h	The public header file for the alternate Confirm widget
	XConfirm1P.h	The private header file for the alternate Confirm widget
	X
	XGraph.c		The implementation of the Graph widget
	XGraph.h		The public header file for the Graph widget
	XGraphP.h	The private header file for the Graph widget
	X
	XGraphDispl.c	The implementation of the GraphDisplay object
	XGraphDispP.h	The private header file for the GraphDisplay object
	XGraphDispl.h	The public header file for the GraphDisplay object
	X
	XLabel.c		The implementation of the Label widget
	XLabel.h		The private header file for the Label widget
	XLabelP.h	The public header file for the Label widget
	X
	XLabelGadge.c	The implementation of the Label gadget
	XLabelGadge.h	The private header file for the Label gadget
	XLabelGadgP.h	The public header file for the Label gadget
	X
	XMenu.c		The implementation of the Menu widget
	XMenu.h		The private header file for the Menu widget
	XMenuP.h		The public header file for the Menu widget
	X
	XMenuItem.c	The implementation of the MenuItem widget
	XMenuItem.h	The private header file for the MenuItem widget
	XMenuItemP.h	The public header file for the MenuItem widget
	X
	XMinMax.c	The implementation of the MinMax widget
	XMinMax.h	The private header file for the MinMax widget
	XMinMaxP.h	The public header file for the MinMax widget
	X
	XPushbutton.c	The implementation of the Pushbutton widget
	XPushbutton.h	The private header file for the Pushbutton widget
	XPushbuttoP.h	The public header file for the Pushbutton widget
	X
	Xaccel.c		A test application to exercise accelerators
	Xbargraph.c	A test application to exercise the Graph widget
	Xconfirm.c	A test application to exercise the Confirm widget
	Xconfirm1.c	A test application to exercise the alternate Confirm widget
	Xgadget.c	A test application to exercise the Label gadget
	Xgoodbye.c	A test application to exercise the Label and Pushbutton widgets
	Xjustify.c	A test application to exercise Label widget justification
	Xmenu.c		A test application to exercise the Menu widget
	Xsensitive.c	A test application to exercise Pushbutton widget sensitivity
	X
	Xxbiff.c		The sample mail notifier application
	Xxcalc.c		The sample calculator application
	Xxmonitor.c	The sample system monitor application
	X
	XDemoBiff	The application defaults file for the mail notifier application
	XDemoCalc	The application defaults file for the calculator application
	XDemoMonitor	The application defaults file for the system monitor application
SHAR_EOF
if test 4153 -ne "`wc -c < 'README'`"
then
	echo shar: error transmitting "'README'" '(should have been 4153 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'Makefile'" '(2756 characters)'
if test -f 'Makefile'
then
	echo shar: will not over-write existing file "'Makefile'"
else
sed 's/^	X//' << \SHAR_EOF > 'Makefile'
	X#***********************************************************
	X#Copyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
	X#
	X#                        All Rights Reserved
	X#
	X#Permission to use, copy, modify, and distribute these examples for any
	X#purpose and without fee is hereby granted, provided that the above
	X#copyright notice appear in all copies and that both that copyright
	X#notice and this permission notice appear in supporting documentation,
	X#and that the name of Digital not be used in advertising or publicity
	X#pertaining to distribution of the software without specific, written
	X#prior permission.
	X#
	X#DIGITAL AND THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
	X#SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
	X#FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
	X#OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
	X#OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
	X#OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
	X#OR PERFORMANCE OF THIS SOFTWARE.
	X#
	X#******************************************************************
	X
	X# Edit the following three lines to the appropriate X11R4 libraries
	X# and include directories for your system
	X
	XXT = -lXt
	XXLIB = -lX11
	XINCLUDES = /usr/include
	X
	XWIDGETLIB = libwidgets.a
	XCC = cc -g
	XAR = ar cq 
	X
	XWIDGETS = BarDisplay.o Box.o Confirm.o Graph.o GraphDispl.o \
	X	Label.o LabelGadge.o Menu.o MenuItem.o MinMax.o Pushbutton.o
	X
	XTESTS = accel bargraph confirm confirm1 gadget goodbye justify menu sensitive
	X
	XPROGRAMS = xbiff xcalc xmonitor
	X
	X.c.o:
	X	${CC} -c -I${INCLUDES} $*.c
	X
	Xall: widgets tests programs
	X
	Xwidgets: libwidgets.a
	X
	Xtests: ${TESTS}
	X
	Xprograms: ${PROGRAMS}
	X
	Xlibwidgets.a: ${WIDGETS}
	X	rm -f $@
	X	${AR} $@ ${WIDGETS}
	X	ranlib $@
	X
	Xaccel: accel.o
	X	${CC} -o accel accel.o ${WIDGETLIB} ${XT} ${XLIB}
	X
	Xbargraph: bargraph.o 
	X	${CC} -o bargraph bargraph.o ${WIDGETLIB} ${XT} ${XLIB}
	X
	Xconfirm: confirm.o
	X	${CC} -o confirm confirm.o ${WIDGETLIB} ${XT} ${XLIB}
	X
	Xconfirm1: confirm1.o Confirm1.o
	X	${CC} -o confirm1 confirm1.o Confirm1.o ${WIDGETLIB} ${XT} ${XLIB}
	X
	Xgadget: gadget.o
	X	${CC} -o gadget gadget.o ${WIDGETLIB} ${XT} ${XLIB}
	X
	Xgoodbye: goodbye.o 
	X	${CC} -o goodbye goodbye.o ${WIDGETLIB} ${XT} ${XLIB}
	X
	Xjustify: justify.o
	X	${CC} -o justify justify.o ${WIDGETLIB} ${XT} ${XLIB}
	X
	Xmenu: menu.o
	X	${CC} -o menu menu.o ${WIDGETLIB} ${XT} ${XLIB}
	X
	Xsensitive: sensitive.o
	X	${CC} -o sensitive sensitive.o ${WIDGETLIB} ${XT} ${XLIB}
	X
	Xxbiff: xbiff.o 
	X	${CC} -o xbiff xbiff.o ${WIDGETLIB} ${XT} ${XLIB}
	X
	Xxcalc: xcalc.o
	X	${CC} -o xcalc xcalc.o ${WIDGETLIB} ${XT} ${XLIB}
	X
	Xxmonitor: xmonitor.o
	X	${CC} -o xmonitor xmonitor.o ${WIDGETLIB} ${XT} ${XLIB}
	X
	Xclean:
	X	rm -f *.o *.a *.BAK *.CKP *~ ${TESTS} ${PROGRAMS}
SHAR_EOF
if test 2756 -ne "`wc -c < 'Makefile'`"
then
	echo shar: error transmitting "'Makefile'" '(should have been 2756 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'accel.c'" '(3040 characters)'
if test -f 'accel.c'
then
	echo shar: will not over-write existing file "'accel.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'accel.c'
	X/***********************************************************
	XCopyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
	X
	X                        All Rights Reserved
	X
	XPermission to use, copy, modify, and distribute these examples for any
	Xpurpose and without fee is hereby granted, provided that the above
	Xcopyright notice appear in all copies and that both that copyright
	Xnotice and this permission notice appear in supporting documentation,
	Xand that the name of Digital not be used in advertising or publicity
	Xpertaining to distribution of the software without specific, written
	Xprior permission.
	X
	XDIGITAL AND THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
	XSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
	XFITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
	XOR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
	XOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
	XOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
	XOR PERFORMANCE OF THIS SOFTWARE.
	X
	X******************************************************************/
	X
	X#include <X11/Intrinsic.h>
	X#include <X11/StringDefs.h>
	X#include <X11/Shell.h>
	X
	X#include "Box.h"
	X#include "Label.h"
	X#include "Pushbutton.h"
	X
	Xvoid Goodbye(widget, clientData, callData)
	X    Widget widget;
	X    caddr_t clientData, callData;
	X{
	X    exit(0);
	X}
	X
	XWidget pushbutton, box;
	X
	Xvoid InstallAccel(widget, clientData, callData)
	X    Widget widget;
	X    caddr_t clientData, callData;
	X{
	X    XtInstallAllAccelerators(box, box);
	X}
	X
	Xint main(argc, argv)
	X    unsigned int argc;
	X    char **argv;
	X{
	X    Widget toplevel, label, accel;
	X    Arg arg[25];
	X    unsigned int n;
	X    XtAppContext app;
	X
	X    toplevel = XtAppInitialize(&app, "Accel",
	X	    (XrmOptionDescList) NULL, 0, &argc, argv,
	X	    (String *) NULL, (ArgList) NULL, 0);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNinput, TRUE);	n++;
	X    XtSetValues(toplevel, arg, n);
	X
	X    box = XtCreateManagedWidget("box", boxWidgetClass, toplevel,
	X	(Arg *) NULL, 0);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNx, 10);	n++;
	X    XtSetArg(arg[n], XtNy, 10);	n++;
	X    XtSetArg(arg[n], XtNlabel, "Goodbye, world");	n++;
	X
	X    label = XtCreateManagedWidget("label", labelWidgetClass, box,
	X	arg, n);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNx, 10); n++;
	X    XtSetArg(arg[n], XtNy, 40); n++;
	X    XtSetArg(arg[n], XtNlabel, "Install accelerators");	n++;
	X
	X    accel = XtCreateManagedWidget("accel", pushbuttonWidgetClass,
	X	box, arg, n);
	X
	X    XtAddCallback(accel, XtNcallback, InstallAccel, NULL);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNx, 10); n++;
	X    XtSetArg(arg[n], XtNy, 70); n++;
	X    XtSetArg(arg[n], XtNlabel, "Click and die");	n++;
	X    XtSetArg(arg[n], XtNaccelerators, 
	X	    XtParseAcceleratorTable(":Ctrl<Key>a: notify()"));	n++;
	X    XtSetArg(arg[n], XtNacceleratorString, " (^A)");	n++;
	X
	X    pushbutton = XtCreateManagedWidget("pushbutton", pushbuttonWidgetClass,
	X	box, arg, n);
	X
	X    XtAddCallback(pushbutton, XtNcallback, Goodbye, NULL);
	X
	X    XtRealizeWidget(toplevel);
	X    XtAppMainLoop(app);
	X}
SHAR_EOF
if test 3040 -ne "`wc -c < 'accel.c'`"
then
	echo shar: error transmitting "'accel.c'" '(should have been 3040 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bargraph.c'" '(2233 characters)'
if test -f 'bargraph.c'
then
	echo shar: will not over-write existing file "'bargraph.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'bargraph.c'
	X/***********************************************************
	XCopyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
	X
	X                        All Rights Reserved
	X
	XPermission to use, copy, modify, and distribute these examples for any
	Xpurpose and without fee is hereby granted, provided that the above
	Xcopyright notice appear in all copies and that both that copyright
	Xnotice and this permission notice appear in supporting documentation,
	Xand that the name of Digital not be used in advertising or publicity
	Xpertaining to distribution of the software without specific, written
	Xprior permission.
	X
	XDIGITAL AND THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
	XSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
	XFITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
	XOR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
	XOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
	XOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
	XOR PERFORMANCE OF THIS SOFTWARE.
	X
	X******************************************************************/
	X
	X#include <X11/Intrinsic.h>
	X#include <X11/StringDefs.h>
	X
	X#include "Graph.h"
	X#include "BarDisplay.h"
	X
	Xint main(argc, argv)
	X    unsigned int argc;
	X    char **argv;
	X{
	X    Widget toplevel, graph, display;
	X    int bars;
	X    int barvalues[25];
	X    String labels[25];
	X    char buffer[25];
	X    Arg arg[25];
	X    unsigned int n;
	X    XtAppContext app;
	X
	X    printf("How many bars? ");
	X    scanf("%d", &bars);
	X    for (n = 0; n < bars; n++) {
	X	barvalues[n] = 10*n;
	X	sprintf(buffer, "This is Label %d", n);
	X	labels[n] = XtNewString(buffer);
	X    }
	X
	X    toplevel = XtAppInitialize(&app, "BarGraph",
	X	    (XrmOptionDescList) NULL, 0, &argc, argv,
	X	    (String *) NULL, (ArgList) NULL, 0);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNnumEntries, bars); n++;
	X    XtSetArg(arg[n], XtNlabels, labels); n++;
	X    XtSetArg(arg[n], XtNvalues, barvalues); n++;
	X    XtSetArg(arg[n], XtNmaxValue, 100); n++;	
	X
	X    graph = XtCreateManagedWidget("graph", graphWidgetClass, toplevel,
	X	arg, n);
	X
	X    display = XtCreateManagedWidget("display", barDisplayObjectClass,
	X	graph, NULL, 0);
	X
	X    XtRealizeWidget(toplevel);
	X    XtAppMainLoop(app);
	X}
SHAR_EOF
if test 2233 -ne "`wc -c < 'bargraph.c'`"
then
	echo shar: error transmitting "'bargraph.c'" '(should have been 2233 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'confirm.c'" '(2736 characters)'
if test -f 'confirm.c'
then
	echo shar: will not over-write existing file "'confirm.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'confirm.c'
	X/***********************************************************
	XCopyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
	X
	X                        All Rights Reserved
	X
	XPermission to use, copy, modify, and distribute these examples for any
	Xpurpose and without fee is hereby granted, provided that the above
	Xcopyright notice appear in all copies and that both that copyright
	Xnotice and this permission notice appear in supporting documentation,
	Xand that the name of Digital not be used in advertising or publicity
	Xpertaining to distribution of the software without specific, written
	Xprior permission.
	X
	XDIGITAL AND THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
	XSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
	XFITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
	XOR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
	XOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
	XOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
	XOR PERFORMANCE OF THIS SOFTWARE.
	X
	X******************************************************************/
	X
	X#include <X11/Intrinsic.h>
	X#include <X11/StringDefs.h>
	X#include <X11/Shell.h>
	X
	X#include "Box.h"
	X#include "Label.h"
	X#include "Pushbutton.h"
	X#include "Confirm.h"
	X
	Xvoid Goodbye(widget, clientData, callData)
	X    Widget widget;
	X    caddr_t clientData, callData;
	X{
	X    exit(0);
	X}
	X
	Xint main(argc, argv)
	X    unsigned int argc;
	X    char **argv;
	X{
	X    Widget toplevel, label, pushbutton, box, confirmshell, confirm;
	X    Arg arg[25];
	X    unsigned int n;
	X    XtAppContext app;
	X
	X    toplevel = XtAppInitialize(&app, "Confirm",
	X	    (XrmOptionDescList) NULL, 0, &argc, argv,
	X	    (String *) NULL, (ArgList) NULL, 0);
	X
	X    box = XtCreateManagedWidget("box", boxWidgetClass, toplevel,
	X	(Arg *) NULL, 0);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNx, 10);	n++;
	X    XtSetArg(arg[n], XtNy, 10);	n++;
	X    XtSetArg(arg[n], XtNlabel, "Goodbye, world");	n++;
	X
	X    label = XtCreateManagedWidget("label", labelWidgetClass, box,
	X	arg, n);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNx, 10); n++;
	X    XtSetArg(arg[n], XtNy, 40); n++;
	X    XtSetArg(arg[n], XtNlabel, "Click and die");	n++;
	X
	X    pushbutton = XtCreateManagedWidget("pushbutton", pushbuttonWidgetClass,
	X	box, arg, n);
	X
	X    confirmshell = XtCreatePopupShell("confirmShell",
	X	    transientShellWidgetClass, pushbutton, NULL, 0);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNlabel, "Exiting program");	n++;
	X    
	X    confirm = XtCreateManagedWidget("confirm", confirmWidgetClass,
	X	    confirmshell, arg, n);
	X
	X    XtAddCallback(pushbutton, XtNcallback, XtCallbackNone, confirmshell);
	X    XtAddCallback(confirm, XtNcallback, Goodbye, NULL);
	X
	X    XtRealizeWidget(toplevel);
	X    XtAppMainLoop(app);
	X}
SHAR_EOF
if test 2736 -ne "`wc -c < 'confirm.c'`"
then
	echo shar: error transmitting "'confirm.c'" '(should have been 2736 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'confirm1.c'" '(2737 characters)'
if test -f 'confirm1.c'
then
	echo shar: will not over-write existing file "'confirm1.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'confirm1.c'
	X/***********************************************************
	XCopyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
	X
	X                        All Rights Reserved
	X
	XPermission to use, copy, modify, and distribute these examples for any
	Xpurpose and without fee is hereby granted, provided that the above
	Xcopyright notice appear in all copies and that both that copyright
	Xnotice and this permission notice appear in supporting documentation,
	Xand that the name of Digital not be used in advertising or publicity
	Xpertaining to distribution of the software without specific, written
	Xprior permission.
	X
	XDIGITAL AND THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
	XSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
	XFITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
	XOR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
	XOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
	XOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
	XOR PERFORMANCE OF THIS SOFTWARE.
	X
	X******************************************************************/
	X
	X#include <X11/Intrinsic.h>
	X#include <X11/StringDefs.h>
	X#include <X11/Shell.h>
	X
	X#include "Box.h"
	X#include "Label.h"
	X#include "Pushbutton.h"
	X#include "Confirm1.h"
	X
	Xvoid Goodbye(widget, clientData, callData)
	X    Widget widget;
	X    caddr_t clientData, callData;
	X{
	X    exit(0);
	X}
	X
	Xint main(argc, argv)
	X    unsigned int argc;
	X    char **argv;
	X{
	X    Widget toplevel, label, pushbutton, box, confirmshell, confirm;
	X    Arg arg[25];
	X    unsigned int n;
	X    XtAppContext app;
	X
	X    toplevel = XtAppInitialize(&app, "Confirm",
	X	    (XrmOptionDescList) NULL, 0, &argc, argv,
	X	    (String *) NULL, (ArgList) NULL, 0);
	X
	X    box = XtCreateManagedWidget("box", boxWidgetClass, toplevel,
	X	(Arg *) NULL, 0);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNx, 10);	n++;
	X    XtSetArg(arg[n], XtNy, 10);	n++;
	X    XtSetArg(arg[n], XtNlabel, "Goodbye, world");	n++;
	X
	X    label = XtCreateManagedWidget("label", labelWidgetClass, box,
	X	arg, n);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNx, 10); n++;
	X    XtSetArg(arg[n], XtNy, 40); n++;
	X    XtSetArg(arg[n], XtNlabel, "Click and die");	n++;
	X
	X    pushbutton = XtCreateManagedWidget("pushbutton", pushbuttonWidgetClass,
	X	box, arg, n);
	X
	X    confirmshell = XtCreatePopupShell("confirmShell",
	X	    transientShellWidgetClass, pushbutton, NULL, 0);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNlabel, "Exiting program");	n++;
	X    
	X    confirm = XtCreateManagedWidget("confirm", confirmWidgetClass,
	X	    confirmshell, arg, n);
	X
	X    XtAddCallback(pushbutton, XtNcallback, XtCallbackNone, confirmshell);
	X    XtAddCallback(confirm, XtNcallback, Goodbye, NULL);
	X
	X    XtRealizeWidget(toplevel);
	X    XtAppMainLoop(app);
	X}
SHAR_EOF
if test 2737 -ne "`wc -c < 'confirm1.c'`"
then
	echo shar: error transmitting "'confirm1.c'" '(should have been 2737 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'gadget.c'" '(2498 characters)'
if test -f 'gadget.c'
then
	echo shar: will not over-write existing file "'gadget.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'gadget.c'
	X/***********************************************************
	XCopyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
	X
	X                        All Rights Reserved
	X
	XPermission to use, copy, modify, and distribute these examples for any
	Xpurpose and without fee is hereby granted, provided that the above
	Xcopyright notice appear in all copies and that both that copyright
	Xnotice and this permission notice appear in supporting documentation,
	Xand that the name of Digital not be used in advertising or publicity
	Xpertaining to distribution of the software without specific, written
	Xprior permission.
	X
	XDIGITAL AND THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
	XSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
	XFITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
	XOR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
	XOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
	XOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
	XOR PERFORMANCE OF THIS SOFTWARE.
	X
	X******************************************************************/
	X
	X#include <X11/Intrinsic.h>
	X#include <X11/StringDefs.h>
	X
	X#include "Box.h"
	X#include "LabelGadge.h"
	X#include "Pushbutton.h"
	X
	Xvoid Goodbye(widget, clientData, callData)
	X    Widget widget;
	X    caddr_t clientData, callData;
	X{
	X    exit(0);
	X}
	X
	Xint main(argc, argv)
	X    unsigned int argc;
	X    char **argv;
	X{
	X    Widget toplevel, label, pushbutton, box;
	X    Arg arg[25];
	X    unsigned int n;
	X    XtAppContext app;
	X
	X    toplevel = XtAppInitialize(&app, "Gadget",
	X	    (XrmOptionDescList) NULL, 0, &argc, argv,
	X	    (String *) NULL, (ArgList) NULL, 0);
	X
	X    box = XtCreateManagedWidget("box", boxWidgetClass, toplevel,
	X	(Arg *) NULL, 0);
	X
	X    /* Make the gadget small to make sure it's clipping to its size
	X       correctly. */
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNx, 10);	n++;
	X    XtSetArg(arg[n], XtNy, 10);	n++;
	X    XtSetArg(arg[n], XtNwidth, 70);	n++;
	X    XtSetArg(arg[n], XtNheight, 12);	n++;
	X    XtSetArg(arg[n], XtNlabel, "Goodbye, world");	n++;
	X
	X    label = XtCreateManagedWidget("label", labelGadgetClass, box,
	X	arg, n);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNx, 10); n++;
	X    XtSetArg(arg[n], XtNy, 40); n++;
	X    XtSetArg(arg[n], XtNlabel, "Click and die");	n++;
	X
	X    pushbutton = XtCreateManagedWidget("pushbutton", pushbuttonWidgetClass,
	X	box, arg, n);
	X
	X    XtAddCallback(pushbutton, XtNcallback, Goodbye, NULL);
	X
	X    XtRealizeWidget(toplevel);
	X    XtAppMainLoop(app);
	X}
SHAR_EOF
if test 2498 -ne "`wc -c < 'gadget.c'`"
then
	echo shar: error transmitting "'gadget.c'" '(should have been 2498 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'goodbye.c'" '(2390 characters)'
if test -f 'goodbye.c'
then
	echo shar: will not over-write existing file "'goodbye.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'goodbye.c'
	X/***********************************************************
	XCopyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
	X
	X                        All Rights Reserved
	X
	XPermission to use, copy, modify, and distribute these examples for any
	Xpurpose and without fee is hereby granted, provided that the above
	Xcopyright notice appear in all copies and that both that copyright
	Xnotice and this permission notice appear in supporting documentation,
	Xand that the name of Digital not be used in advertising or publicity
	Xpertaining to distribution of the software without specific, written
	Xprior permission.
	X
	XDIGITAL AND THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
	XSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
	XFITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
	XOR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
	XOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
	XOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
	XOR PERFORMANCE OF THIS SOFTWARE.
	X
	X******************************************************************/
	X
	X#include <X11/Intrinsic.h>	/* Standard include files */
	X#include <X11/StringDefs.h>
	X#include "Box.h"		/* Widget include files */
	X#include "Label.h"
	X#include "Pushbutton.h"
	X
	Xvoid Goodbye(widget, clientData, callData)   /* Callback procedure */
	X    Widget widget;
	X    XtPointer clientData, callData;
	X{
	X    exit(0);
	X}
	X
	XArg labelArgs[] = {	/* The arguments to the label widget */
	X    {XtNx,	10},
	X    {XtNy,	10},
	X    {XtNlabel,	"Goodbye, world"}};
	X
	XArg buttonArgs[] = {	/* The arguments to the button widget */
	X    {XtNx,	10},
	X    {XtNy,	40},
	X    {XtNlabel,	"Click and die"}};
	X
	Xint main(argc, argv)
	X    unsigned int argc;
	X    char **argv;
	X{
	X    Widget toplevel, label, button, box;
	X    XtAppContext app;
	X
	X    toplevel = XtAppInitialize(&app, "Goodbye",
	X	    (XrmOptionDescList) NULL, 0, &argc, argv,
	X	    (String *) NULL, (ArgList) NULL, 0);
	X
	X    box = XtCreateManagedWidget("box", boxWidgetClass,
	X	    toplevel, (Arg *) NULL, 0);
	X
	X    label = XtCreateManagedWidget("label", labelWidgetClass,
	X	    box, labelArgs, XtNumber(labelArgs));
	X
	X    button = XtCreateManagedWidget("button", pushbuttonWidgetClass,
	X	    box, buttonArgs, XtNumber(buttonArgs));
	X    XtAddCallback(button, XtNcallback, Goodbye, NULL);
	X
	X    XtRealizeWidget(toplevel);
	X    XtAppMainLoop(app);
	X}
SHAR_EOF
if test 2390 -ne "`wc -c < 'goodbye.c'`"
then
	echo shar: error transmitting "'goodbye.c'" '(should have been 2390 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'justify.c'" '(3169 characters)'
if test -f 'justify.c'
then
	echo shar: will not over-write existing file "'justify.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'justify.c'
	X/***********************************************************
	XCopyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
	X
	X                        All Rights Reserved
	X
	XPermission to use, copy, modify, and distribute these examples for any
	Xpurpose and without fee is hereby granted, provided that the above
	Xcopyright notice appear in all copies and that both that copyright
	Xnotice and this permission notice appear in supporting documentation,
	Xand that the name of Digital not be used in advertising or publicity
	Xpertaining to distribution of the software without specific, written
	Xprior permission.
	X
	XDIGITAL AND THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
	XSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
	XFITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
	XOR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
	XOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
	XOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
	XOR PERFORMANCE OF THIS SOFTWARE.
	X
	X******************************************************************/
	X
	X#include <X11/Intrinsic.h>
	X#include <X11/StringDefs.h>
	X
	X#include "MinMax.h"
	X#include "Label.h"
	X#include "Pushbutton.h"
	X
	Xvoid Goodbye(widget, clientData, callData)
	X    Widget widget;
	X    caddr_t clientData, callData;
	X{
	X    exit(0);
	X}
	X
	XWidget pushbutton;
	X
	Xvoid Rejustify(widget, clientData, callData)
	X    Widget widget;
	X    caddr_t clientData, callData;
	X{
	X    static Justify justify = Left;
	X    Arg arg[1];
	X
	X    if (justify == Left) justify = Center;
	X    else if (justify == Center) justify = Right;
	X    else justify = Left;
	X
	X    XtSetArg(arg[0], XtNjustify, justify);
	X    XtSetValues(pushbutton, arg, 1);
	X}
	X
	Xint main(argc, argv)
	X    unsigned int argc;
	X    char **argv;
	X{
	X    Widget toplevel, label, justify, box;
	X    Arg arg[25];
	X    unsigned int n;
	X    XtAppContext app;
	X
	X    toplevel = XtAppInitialize(&app, "Justify",
	X	    (XrmOptionDescList) NULL, 0, &argc, argv,
	X	    (String *) NULL, (ArgList) NULL, 0);
	X
	X    box = XtCreateManagedWidget("box", minMaxWidgetClass, toplevel,
	X	(Arg *) NULL, 0);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNx, 10);	n++;
	X    XtSetArg(arg[n], XtNy, 10);	n++;
	X    XtSetArg(arg[n], XtNlabel, "Goodbye, world");	n++;
	X
	X    label = XtCreateManagedWidget("label", labelWidgetClass, box,
	X	arg, n);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNx, 10); n++;
	X    XtSetArg(arg[n], XtNy, 40); n++;
	X    XtSetArg(arg[n], XtNlabel, "Change justification");	n++;
	X
	X    justify = XtCreateManagedWidget("justify", pushbuttonWidgetClass,
	X	box, arg, n);
	X
	X    XtAddCallback(justify, XtNcallback, Rejustify, NULL);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNx, 10); n++;
	X    XtSetArg(arg[n], XtNy, 70); n++;
	X    XtSetArg(arg[n], XtNlabel, "Click and die");	n++;
	X    XtSetArg(arg[n], XtNminWidth, 50);	n++;
	X    XtSetArg(arg[n], XtNmaxWidth, 200);	n++;
	X    XtSetArg(arg[n], XtNminHeight, 15);	n++;
	X    XtSetArg(arg[n], XtNmaxHeight, 100);	n++;
	X
	X    pushbutton = XtCreateManagedWidget("pushbutton", pushbuttonWidgetClass,
	X	box, arg, n);
	X
	X    XtAddCallback(pushbutton, XtNcallback, Goodbye, NULL);
	X
	X    XtRealizeWidget(toplevel);
	X    XtAppMainLoop(app);
	X}
SHAR_EOF
if test 3169 -ne "`wc -c < 'justify.c'`"
then
	echo shar: error transmitting "'justify.c'" '(should have been 3169 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'menu.c'" '(5539 characters)'
if test -f 'menu.c'
then
	echo shar: will not over-write existing file "'menu.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'menu.c'
	X/***********************************************************
	XCopyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
	X
	X                        All Rights Reserved
	X
	XPermission to use, copy, modify, and distribute these examples for any
	Xpurpose and without fee is hereby granted, provided that the above
	Xcopyright notice appear in all copies and that both that copyright
	Xnotice and this permission notice appear in supporting documentation,
	Xand that the name of Digital not be used in advertising or publicity
	Xpertaining to distribution of the software without specific, written
	Xprior permission.
	X
	XDIGITAL AND THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
	XSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
	XFITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
	XOR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
	XOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
	XOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
	XOR PERFORMANCE OF THIS SOFTWARE.
	X
	X******************************************************************/
	X
	X#include <X11/Intrinsic.h>
	X#include <X11/StringDefs.h>
	X#include <X11/Shell.h>
	X
	X#include "Box.h"
	X#include "Label.h"
	X#include "Pushbutton.h"
	X#include "Menu.h"
	X#include "MenuItem.h"
	X
	Xvoid Goodbye(widget, clientData, callData)
	X    Widget widget;
	X    caddr_t clientData, callData;
	X{
	X    exit(0);
	X}
	X
	Xvoid Widen(widget, clientData, callData)
	X    Widget widget;
	X    caddr_t clientData, callData;
	X{
	X    Widget w = (Widget) clientData;
	X    Arg arg[25];
	X    int n;
	X    String label;
	X    char buffer[100];
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNlabel, &label);	n++;
	X
	X    XtGetValues(w, arg, n);
	X    strcpy(&buffer[1], label);
	X    buffer[0] = buffer[1];
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNlabel, buffer);	n++;
	X    XtSetArg(arg[n], XtNwidth, 0);	n++;
	X    XtSetArg(arg[n], XtNheight, 0);	n++;
	X
	X    XtSetValues(w, arg, n);
	X}
	X
	Xvoid Narrow(widget, clientData, callData)
	X    Widget widget;
	X    caddr_t clientData, callData;
	X{
	X    Widget w = (Widget) clientData;
	X    Arg arg[25];
	X    int n;
	X    String label;
	X    char buffer[100];
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNlabel, &label);	n++;
	X
	X    XtGetValues(w, arg, n);
	X    strcpy(buffer, &label[1]);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNlabel, buffer);	n++;
	X    XtSetArg(arg[n], XtNwidth, 0);	n++;
	X    XtSetArg(arg[n], XtNheight, 0);	n++;
	X
	X    XtSetValues(w, arg, n);
	X}
	X
	Xvoid Shuffle(widget, clientData, callData)
	X    Widget widget;
	X    caddr_t clientData, callData;
	X{
	X    Widget w = (Widget) clientData;
	X    Arg arg[25];
	X    int n;
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNinsertBefore, 1);	n++;
	X    XtSetValues(w, arg, n);
	X}
	X
	XWidget menushell;
	X
	Xstatic void RepositionMenu(w, event, params, num_params)
	X    Widget w;
	X    XEvent *event;
	X    String *params;
	X    Cardinal *num_params;
	X{
	X    XButtonEvent *b = &event->xbutton;
	X    Dimension width, height, border;
	X    Arg arg[25];
	X    int n;
	X
	X    if (event->xany.type != ButtonPress) return;
	X
	X    XtRealizeWidget(menushell);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNwidth, &width);		n++;
	X    XtSetArg(arg[n], XtNheight, &height);	n++;
	X    XtSetArg(arg[n], XtNborderWidth, &border);	n++;
	X    XtGetValues(menushell, arg, n);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNx, b->x_root - width/2 - border);	n++;
	X    XtSetArg(arg[n], XtNy, b->y_root - height/2 - border);	n++;
	X    XtSetValues(menushell, arg, n);
	X}
	X
	XXtActionsRec actions[] = {
	X    {"RepositionMenu", RepositionMenu}
	X};
	X
	Xstatic char *menuTranslations = 
	X    "<Btn1Down>		: RepositionMenu() MenuPopup(menuShell) unhighlight()";
	X
	X
	Xint main(argc, argv)
	X    unsigned int argc;
	X    char **argv;
	X{
	X    Widget toplevel, label, pushbutton, box, menu, exititem, first, widen, narrow, shuffle;
	X    Arg arg[25];
	X    unsigned int n;
	X    XtAppContext app;
	X
	X    toplevel = XtAppInitialize(&app, "Menu",
	X	    (XrmOptionDescList) NULL, 0, &argc, argv,
	X	    (String *) NULL, (ArgList) NULL, 0);
	X
	X    XtAppAddActions(app, actions, XtNumber(actions));
	X
	X    box = XtCreateManagedWidget("box", boxWidgetClass, toplevel,
	X	(Arg *) NULL, 0);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNx, 10);	n++;
	X    XtSetArg(arg[n], XtNy, 10);	n++;
	X    XtSetArg(arg[n], XtNlabel, "Goodbye, world");	n++;
	X
	X    label = XtCreateManagedWidget("label", labelWidgetClass, box,
	X	arg, n);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNx, 10); n++;
	X    XtSetArg(arg[n], XtNy, 40); n++;
	X    XtSetArg(arg[n], XtNlabel, "Exit menu");	n++;
	X
	X    pushbutton = XtCreateManagedWidget("pushbutton", pushbuttonWidgetClass,
	X	box, arg, n);
	X
	X    XtOverrideTranslations(pushbutton,
	X	    XtParseTranslationTable(menuTranslations));
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNallowShellResize, TRUE);	n++;
	X
	X    menushell = XtCreatePopupShell("menuShell",
	X	    overrideShellWidgetClass, pushbutton, arg, n);
	X
	X    menu = XtCreateManagedWidget("menu", menuWidgetClass,
	X	    menushell, NULL, 0);
	X
	X    first = XtCreateManagedWidget("aaaaa", menuItemWidgetClass, menu, NULL, 0);
	X    widen = XtCreateManagedWidget("widen", menuItemWidgetClass, menu, NULL, 0);
	X    narrow = XtCreateManagedWidget("narrow", menuItemWidgetClass, menu, NULL, 0);
	X    shuffle = XtCreateManagedWidget("shuffle", menuItemWidgetClass, menu, NULL, 0);
	X    exititem = XtCreateManagedWidget("exit", menuItemWidgetClass, menu, NULL, 0);
	X
	X    XtAddCallback(widen, XtNcallback, Widen, first);
	X    XtAddCallback(narrow, XtNcallback, Narrow, first);
	X    XtAddCallback(shuffle, XtNcallback, Shuffle, first);
	X    XtAddCallback(exititem, XtNcallback, Goodbye, NULL);
	X
	X    XtRealizeWidget(toplevel);
	X    XtAppMainLoop(app);
	X}
SHAR_EOF
if test 5539 -ne "`wc -c < 'menu.c'`"
then
	echo shar: error transmitting "'menu.c'" '(should have been 5539 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'sensitive.c'" '(2850 characters)'
if test -f 'sensitive.c'
then
	echo shar: will not over-write existing file "'sensitive.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'sensitive.c'
	X/***********************************************************
	XCopyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
	X
	X                        All Rights Reserved
	X
	XPermission to use, copy, modify, and distribute these examples for any
	Xpurpose and without fee is hereby granted, provided that the above
	Xcopyright notice appear in all copies and that both that copyright
	Xnotice and this permission notice appear in supporting documentation,
	Xand that the name of Digital not be used in advertising or publicity
	Xpertaining to distribution of the software without specific, written
	Xprior permission.
	X
	XDIGITAL AND THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
	XSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
	XFITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
	XOR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
	XOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
	XOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
	XOR PERFORMANCE OF THIS SOFTWARE.
	X
	X******************************************************************/
	X
	X#include <X11/Intrinsic.h>
	X#include <X11/StringDefs.h>
	X
	X#include "Box.h"
	X#include "Label.h"
	X#include "Pushbutton.h"
	X
	Xvoid Goodbye(widget, clientData, callData)
	X    Widget widget;
	X    caddr_t clientData, callData;
	X{
	X    exit(0);
	X}
	X
	XWidget pushbutton;
	X
	Xvoid Sensitize(widget, clientData, callData)
	X    Widget widget;
	X    caddr_t clientData, callData;
	X{
	X    static Boolean sensitive = TRUE;
	X
	X    sensitive = !sensitive;
	X    XtSetSensitive(pushbutton, sensitive);
	X}
	X
	Xint main(argc, argv)
	X    unsigned int argc;
	X    char **argv;
	X{
	X    Widget toplevel, label, sensitize, box;
	X    Arg arg[25];
	X    unsigned int n;
	X    XtAppContext app;
	X
	X    toplevel = XtAppInitialize(&app, "Sensitive",
	X	    (XrmOptionDescList) NULL, 0, &argc, argv,
	X	    (String *) NULL, (ArgList) NULL, 0);
	X
	X    box = XtCreateManagedWidget("box", boxWidgetClass, toplevel,
	X	(Arg *) NULL, 0);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNx, 10);	n++;
	X    XtSetArg(arg[n], XtNy, 10);	n++;
	X    XtSetArg(arg[n], XtNlabel, "Goodbye, world");	n++;
	X
	X    label = XtCreateManagedWidget("label", labelWidgetClass, box,
	X	arg, n);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNx, 10); n++;
	X    XtSetArg(arg[n], XtNy, 40); n++;
	X    XtSetArg(arg[n], XtNlabel, "Toggle sensitivity");	n++;
	X
	X    sensitize = XtCreateManagedWidget("sensitize", pushbuttonWidgetClass,
	X	box, arg, n);
	X
	X    XtAddCallback(sensitize, XtNcallback, Sensitize, NULL);
	X
	X    n = 0;
	X    XtSetArg(arg[n], XtNx, 10); n++;
	X    XtSetArg(arg[n], XtNy, 70); n++;
	X    XtSetArg(arg[n], XtNlabel, "Click and die");	n++;
	X
	X    pushbutton = XtCreateManagedWidget("pushbutton", pushbuttonWidgetClass,
	X	box, arg, n);
	X
	X    XtAddCallback(pushbutton, XtNcallback, Goodbye, NULL);
	X
	X    XtRealizeWidget(toplevel);
	X    XtAppMainLoop(app);
	X}
SHAR_EOF
if test 2850 -ne "`wc -c < 'sensitive.c'`"
then
	echo shar: error transmitting "'sensitive.c'" '(should have been 2850 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'xbiff.c'" '(5813 characters)'
if test -f 'xbiff.c'
then
	echo shar: will not over-write existing file "'xbiff.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'xbiff.c'
	X/***********************************************************
	XCopyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
	X
	X                        All Rights Reserved
	X
	XPermission to use, copy, modify, and distribute these examples for any
	Xpurpose and without fee is hereby granted, provided that the above
	Xcopyright notice appear in all copies and that both that copyright
	Xnotice and this permission notice appear in supporting documentation,
	Xand that the name of Digital not be used in advertising or publicity
	Xpertaining to distribution of the software without specific, written
	Xprior permission.
	X
	XDIGITAL AND THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
	XSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
	XFITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
	XOR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
	XOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
	XOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
	XOR PERFORMANCE OF THIS SOFTWARE.
	X
	X******************************************************************/
	X
	X#include <X11/Intrinsic.h>
	X#include <X11/StringDefs.h>
	X#include <X11/Shell.h>
	X#include "Confirm.h"
	X
	X#include <stdio.h>
	X#include <strings.h>
	X#include <unistd.h>
	X#include <pwd.h>
	X#include <sys/stat.h>
	X
	XXtAppContext app;
	XWidget toplevel, confirm = NULL;
	Xunsigned long fileSize;
	X
	Xvoid GetMailFile(), Timer(), Popup(), CreatePopup(), Callback();
	XBoolean CheckNewMail();
	XString FindWhoFrom();
	X
	Xtypedef struct {
	X    Boolean quiet;
	X    String mail_file;
	X    int timeout;
	X    String default_message;
	X    String from_message;
	X} OptionsRec;
	X
	XOptionsRec options;
	X
	X#define BUFSIZE 1000
	X
	X#define Offset(field) XtOffsetOf(OptionsRec, field)
	X
	XXtResource resources[] = {
	X    {"quiet", "Quiet", XtRBoolean, sizeof(Boolean),
	X	Offset(quiet), XtRImmediate, (XtPointer) FALSE},
	X    {"mailFile", "MailFile", XtRString, sizeof(String),
	X	Offset(mail_file), XtRString, (XtPointer) NULL},
	X    {"interval", "Interval", XtRInt, sizeof(int),
	X	Offset(timeout), XtRImmediate, (XtPointer) 60},
	X    {"defaultMessage", "DefaultMessage", XtRString, sizeof(String),
	X	Offset(default_message), XtRString, "New mail from someone"},
	X    {"fromMessage", "FromMessage", XtRString, sizeof(String),
	X	Offset(from_message), XtRString, "New mail from %s"}
	X};
	X
	X#undef Offset
	X
	XXrmOptionDescRec optionDesc[] = {
	X    {"-quiet", "*quiet", XrmoptionNoArg, (XtPointer) "on"},
	X    {"-file", "*mailFile", XrmoptionSepArg, (XtPointer) NULL},
	X    {"-interval", "*interval", XrmoptionSepArg, (XtPointer) NULL}
	X};
	X
	Xmain(argc, argv)
	X    int argc;
	X    char *argv[];
	X{
	X    toplevel = XtAppInitialize(&app, "DemoBiff",
	X	    optionDesc, XtNumber(optionDesc), &argc, argv,
	X            (String *) NULL, (ArgList) NULL, 0);
	X
	X    XtGetApplicationResources(toplevel, (XtPointer) &options,
	X	    resources, XtNumber(resources), (Arg *) NULL, 0);
	X
	X    GetMailFile();
	X    (void) XtAppAddTimeOut(app, options.timeout * 1000,
	X	    Timer, (XtPointer) NULL);
	X    XtAppMainLoop(app);
	X}
	X
	Xvoid GetMailFile()
	X{
	X    extern int getuid();
	X    struct passwd *pw;
	X    extern struct passwd *getpwuid();
	X    struct stat status;
	X    char buffer[BUFSIZE];
	X
	X    if (options.mail_file == NULL) {
	X	pw = getpwuid(getuid());
	X	if (pw == NULL) {
	X	    XtAppErrorMsg(app, "noUser", "getMailFile",
	X		    "DemoBiffError", "Could not get user name",
	X		    (String *) NULL, (Cardinal *) NULL);
	X	}
	X    
	X	(void) sprintf(buffer, "/usr/spool/mail/%s", pw->pw_name);
	X	options.mail_file = XtNewString(buffer);
	X    }
	X
	X    if (access(options.mail_file, R_OK) != 0 ||
	X	    stat(options.mail_file, &status) != 0) {
	X	XtAppErrorMsg(app, "noAccess", "getMailFile", "DemoBiffError",
	X		"Could not read mail spool file",
	X		(String *) NULL, (Cardinal *) NULL);
	X    }
	X
	X    fileSize = status.st_size;
	X}
	X
	Xvoid Timer(client_data, id)
	X    XtPointer client_data;
	X    XtIntervalId *id;
	X{
	X    if (!CheckNewMail()) {
	X	(void) XtAppAddTimeOut(app, options.timeout * 1000,
	X		Timer, (XtPointer) NULL);
	X    }
	X}
	X
	XBoolean CheckNewMail()
	X{
	X    struct stat status;
	X
	X    if (access(options.mail_file, R_OK) != 0 ||
	X	    stat(options.mail_file, &status) != 0) {
	X	XtAppErrorMsg(app, "noAccess", "checkNewMail", "DemoBiffError",
	X		"Could not read mail spool file",
	X		(String *) NULL, (Cardinal *) NULL);
	X    }
	X
	X    if (status.st_size <= fileSize) {
	X	fileSize = status.st_size;
	X	return FALSE;
	X    }
	X
	X    Popup(FindWhoFrom());
	X    if (!options.quiet) XBell(XtDisplay(toplevel), 100);
	X    fileSize = status.st_size;
	X    return TRUE;
	X}
	X
	XString FindWhoFrom()
	X{
	X    char buffer[BUFSIZE];
	X    static char message[BUFSIZE];
	X    FILE *mail = fopen(options.mail_file, "r");
	X    int fromLen = strlen("From: ");
	X
	X    if (mail == NULL) {
	X	return options.default_message;
	X    }
	X
	X    if (fseek(mail, fileSize, 0) == -1) {
	X	fclose(mail);
	X	return options.default_message;
	X    }
	X
	X    while (1) {
	X	if (fgets(buffer, BUFSIZE, mail) == NULL ||
	X		buffer[0] == '\n') {
	X	    fclose(mail);
	X	    return options.default_message;
	X	}
	X	if (strncmp(buffer, "From: ", fromLen) == 0) {
	X	    buffer[strlen(buffer)-1] = '\0';	/* Replace \n */
	X	    (void) sprintf(message, options.from_message,
	X		    &buffer[fromLen]);
	X	    fclose(mail);
	X	    return message;
	X	}
	X    }
	X}    
	X
	Xvoid Popup(string)
	X    String string;
	X{
	X    Arg args[10];
	X    int i = 0;
	X
	X    if (confirm == NULL) CreatePopup();
	X
	X    XtSetArg(args[i], XtNlabel, string);	i++;
	X    XtSetValues(confirm, args, i);
	X    XtPopup(toplevel, XtGrabNone);
	X}
	X
	Xvoid CreatePopup()
	X{
	X    confirm = XtCreateManagedWidget("confirm", confirmWidgetClass,
	X	    toplevel, (Arg *) NULL, 0);
	X    XtAddCallback(confirm, XtNcallback, Callback, (XtPointer) NULL);
	X}
	X
	Xvoid Callback(w, client_data, call_data)
	X    Widget w;
	X    XtPointer client_data, call_data;
	X{
	X    (void) XtAppAddTimeOut(app, 0, Timer, (XtPointer) NULL);
	X}
SHAR_EOF
if test 5813 -ne "`wc -c < 'xbiff.c'`"
then
	echo shar: error transmitting "'xbiff.c'" '(should have been 5813 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'xcalc.c'" '(9434 characters)'
if test -f 'xcalc.c'
then
	echo shar: will not over-write existing file "'xcalc.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'xcalc.c'
	X/***********************************************************
	XCopyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
	X
	X                        All Rights Reserved
	X
	XPermission to use, copy, modify, and distribute these examples for any
	Xpurpose and without fee is hereby granted, provided that the above
	Xcopyright notice appear in all copies and that both that copyright
	Xnotice and this permission notice appear in supporting documentation,
	Xand that the name of Digital not be used in advertising or publicity
	Xpertaining to distribution of the software without specific, written
	Xprior permission.
	X
	XDIGITAL AND THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
	XSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
	XFITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
	XOR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
	XOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
	XOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
	XOR PERFORMANCE OF THIS SOFTWARE.
	X
	X******************************************************************/
	X
	X#include <X11/Intrinsic.h>
	X#include <X11/StringDefs.h>
	X#include <X11/Shell.h>
	X#include <X11/Xatom.h>
	X
	X#include "Box.h"
	X#include "Pushbutton.h"
	X#include "MenuItem.h"
	X#include "Menu.h"
	X
	X/* Calculator variables */
	Xdouble currentInput = 0, total = 0;
	XBoolean inputDecimal = FALSE, inputNumber = FALSE;
	Xdouble scale;
	Xdouble *numberToDisplay = &total;
	X
	X/* Pending operation */
	Xtypedef enum {Start, Equal, Add, Sub, Mul, Div} operation;
	Xoperation lastOp = Start;
	X
	X/* Interface variables */
	XXtAppContext app;
	XWidget display;		/* Calculator's display */
	XWidget menuShell;
	XBoolean hasSelection = FALSE;
	X
	Xvoid CreateInterface(), InputDigit(), InputDecimal(), Function(),
	X	Clear(), RefreshDisplay(), RepositionMenu(), Quit(), Select(),
	X	Paste(), PasteData(), LoseSelection();
	X
	XXtActionsRec actions[] = {
	X    {"RepositionMenu", RepositionMenu}
	X};
	X
	Xint main(argc, argv)
	X    int argc;
	X    char *argv[];
	X{
	X    Widget toplevel;
	X
	X    toplevel = XtAppInitialize(&app, "DemoCalc",
	X	    (XrmOptionDescList) NULL, 0, &argc, argv,
	X            (String *) NULL, (ArgList) NULL, 0);
	X
	X    XtAppAddActions(app, actions, XtNumber(actions));
	X
	X    /* Make XtMenuPopup synchronous */
	X    XtRegisterGrabAction(XtMenuPopupAction, FALSE,
	X	    ButtonPressMask | ButtonReleaseMask, GrabModeSync,
	X	    GrabModeAsync);
	X
	X    CreateInterface(toplevel);
	X    RefreshDisplay();
	X    XtRealizeWidget(toplevel);
	X    XtAppMainLoop(app);
	X}
	X
	Xvoid CreateInterface(toplevel)
	X    Widget toplevel;
	X{
	X    Widget main, widget, menu;
	X
	X    main = XtCreateManagedWidget("main", boxWidgetClass,
	X	    toplevel, (Arg *) NULL, 0);
	X    display = XtCreateManagedWidget("display", pushbuttonWidgetClass, 
	X	    main, (Arg *) NULL, 0);
	X    XtAddCallback(display, XtNloseSelection,
	X	    LoseSelection, (XtPointer) NULL);
	X
	X#define CreatePushbutton(name, callback, data) \
	X	widget = XtCreateManagedWidget(name, pushbuttonWidgetClass, \
	X		main, (Arg *) NULL, 0); \
	X	XtAddCallback(widget, XtNcallback, callback, (XtPointer) data);
	X
	X    CreatePushbutton("button0", InputDigit, 0);
	X    CreatePushbutton("button1", InputDigit, 1);
	X    CreatePushbutton("button2", InputDigit, 2);
	X    CreatePushbutton("button3", InputDigit, 3);
	X    CreatePushbutton("button4", InputDigit, 4);
	X    CreatePushbutton("button5", InputDigit, 5);
	X    CreatePushbutton("button6", InputDigit, 6);
	X    CreatePushbutton("button7", InputDigit, 7);
	X    CreatePushbutton("button8", InputDigit, 8);
	X    CreatePushbutton("button9", InputDigit, 9);
	X
	X    CreatePushbutton("decimal", InputDecimal, NULL);
	X
	X    CreatePushbutton("plus", Function, Add);
	X    CreatePushbutton("minus", Function, Sub);
	X    CreatePushbutton("times", Function, Mul);
	X    CreatePushbutton("divide", Function, Div);
	X    CreatePushbutton("equals", Function, Equal);
	X
	X    CreatePushbutton("clearEntry", Clear, FALSE);
	X    CreatePushbutton("clear", Clear, TRUE);
	X#undef CreatePushbutton
	X
	X    menuShell = XtCreatePopupShell("menuShell",
	X	    overrideShellWidgetClass, main, (Arg *) NULL, 0);
	X    menu = XtCreateManagedWidget("menu", menuWidgetClass, menuShell,
	X	    (Arg *) NULL, 0);
	X
	X#define CreateMenuItem(name, callback) \
	X	widget = XtCreateManagedWidget(name, menuItemWidgetClass, \
	X		menu, (Arg *) NULL, 0); \
	X	XtAddCallback(widget, XtNcallback, callback, (XtPointer) NULL);
	X
	X    CreateMenuItem("select", Select);
	X    CreateMenuItem("paste", Paste);
	X    CreateMenuItem("quit", Quit);
	X#undef CreateMenuItem
	X    XtInstallAllAccelerators(main, main);
	X}
	X
	Xvoid InputDigit(w, client_data, call_data)
	X    Widget w;
	X    XtPointer client_data;	/* Digit to input */
	X    XtPointer call_data;
	X{
	X    int num = (int) client_data;
	X
	X    if (inputDecimal) {
	X	currentInput += num * scale;
	X	scale /= 10;
	X    } else currentInput = currentInput * 10 + num;
	X
	X    numberToDisplay = &currentInput;
	X    RefreshDisplay();
	X    inputNumber = TRUE;
	X}
	X
	Xvoid InputDecimal(w, client_data, call_data)
	X    Widget w;
	X    XtPointer client_data, call_data;
	X{
	X    inputDecimal = inputNumber = TRUE;
	X    scale = 0.1;
	X    numberToDisplay = &currentInput;
	X    RefreshDisplay();
	X}
	X
	Xvoid Function(w, client_data, call_data)
	X    Widget w;
	X    XtPointer client_data;	/* Operation code */
	X    XtPointer call_data;
	X{
	X    switch (lastOp) {
	X	case Add:
	X	    total += currentInput;
	X	    break;
	X	case Sub:
	X	    total -= currentInput;
	X	    break;
	X	case Mul:
	X	    total *= currentInput;
	X	    break;
	X	case Div:
	X	    if (currentInput == 0.0) XBell(XtDisplay(display), 100);
	X	    else total /= currentInput;
	X	    break;
	X	case Equal:
	X	    if (inputNumber) total = currentInput;
	X	    break;
	X	case Start:
	X	    total = currentInput;
	X	    break;
	X    }
	X    lastOp = (operation) client_data;
	X    currentInput = 0;
	X    inputDecimal = inputNumber = FALSE;
	X
	X    numberToDisplay = &total;
	X    RefreshDisplay();
	X}
	X
	Xvoid Clear(w, client_data, call_data)
	X    Widget w;
	X    XtPointer client_data;	/* FALSE for Clear Entry */
	X    XtPointer call_data;
	X{
	X    currentInput = 0;
	X    if ((Boolean) client_data) {
	X	total = 0;
	X	lastOp = Start;
	X    }
	X    inputDecimal = inputNumber = FALSE;
	X
	X    numberToDisplay = &currentInput;
	X    RefreshDisplay();
	X}
	X
	Xvoid RefreshDisplay()
	X{
	X    char buffer[100];
	X    Arg args[10];
	X    int i = 0;
	X
	X    if (hasSelection) {		/* Get rid of it */
	X	LabelSelectText(display, XA_PRIMARY, FALSE);
	X	/* LoseSelection resets hasSelection and uninverts display */
	X    }
	X
	X    sprintf(buffer, "%g", *numberToDisplay);
	X    XtSetArg(args[i], XtNlabel, buffer);	i++;
	X    XtSetValues(display, args, i);
	X}
	X
	Xvoid RepositionMenu(w, event, params, num_params)
	X    Widget w;
	X    XEvent *event;
	X    String *params;
	X    Cardinal *num_params;
	X{
	X    XButtonEvent *b = &event->xbutton;
	X    Dimension width, height, border;
	X    Arg arg[25];
	X    int n;
	X
	X    if (event->type != ButtonPress) return;
	X
	X    /* Size isn't valid before realizing */
	X    XtRealizeWidget(menuShell);
	X
	X    /* Fetch size */
	X    n = 0;
	X    XtSetArg(arg[n], XtNwidth, &width);		n++;
	X    XtSetArg(arg[n], XtNheight, &height);	n++;
	X    XtSetArg(arg[n], XtNborderWidth, &border);	n++;
	X    XtGetValues(menuShell, arg, n);
	X
	X    /* Reposition menu */
	X    n = 0;
	X    XtSetArg(arg[n], XtNx, b->x_root - width/2 - border);	n++;
	X    XtSetArg(arg[n], XtNy, b->y_root - height/2 - border);	n++;
	X    XtSetValues(menuShell, arg, n);
	X}
	X
	Xvoid Quit(w, client_data, call_data)
	X    Widget w;
	X    XtPointer client_data, call_data;
	X{
	X    exit(0);
	X}
	X
	Xvoid Select(w, client_data, call_data)
	X    Widget w;
	X    XtPointer client_data, call_data;
	X{
	X    if (hasSelection) return;
	X
	X    /* Ask for selection */
	X    if (LabelSelectText(display, XA_PRIMARY, TRUE)) {
	X	hasSelection = TRUE;
	X
	X	/* Invert display widget */
	X	XtCallActionProc(display, "invert", (XEvent *) NULL,
	X		(String *) NULL, 0);
	X    }
	X}
	X
	Xvoid LoseSelection(w, client_data, call_data)
	X    Widget w;
	X    XtPointer client_data, call_data;
	X{
	X    hasSelection = FALSE;
	X
	X    /* Uninvert the display */
	X    XtCallActionProc(display, "uninvert", (XEvent *) NULL,
	X	    (String *) NULL, 0);
	X}
	X
	Xvoid Paste(w, client_data, call_data)
	X    Widget w;
	X    XtPointer client_data, call_data;
	X{
	X    XtGetSelectionValue(display, XA_PRIMARY, XA_STRING, PasteData,
	X	    (XtPointer) NULL, XtLastTimestampProcessed(XtDisplay(w)));
	X}
	X
	Xvoid PasteData(w, client_data, selection, type, value, length, format)
	X    Widget w;
	X    XtPointer client_data;
	X    Atom *selection, *type;
	X    XtPointer value;
	X    unsigned long *length;
	X    int *format;
	X{
	X    register int i;
	X    char *ch = (char *) value;
	X
	X    /* Make sure we got what we expected */
	X    if (*selection != XA_PRIMARY || *type != XA_STRING ||
	X	    *format != 8 || value == NULL) return;
	X
	X    for (i = 0; i < *length; i++) {
	X	if (ch[i] >= '0' && ch[i] <= '9') {
	X	    InputDigit(display, (XtPointer) (ch[i] - '0'),
	X		    (XtPointer) NULL);
	X	} else switch (ch[i]) {
	X	    case '+':
	X		Function(display, (XtPointer) Add, (XtPointer) NULL);
	X		break;
	X	    case '-':
	X		Function(display, (XtPointer) Sub, (XtPointer) NULL);
	X		break;
	X	    case '*':
	X		Function(display, (XtPointer) Mul, (XtPointer) NULL);
	X		break;
	X	    case '/':
	X		Function(display, (XtPointer) Div, (XtPointer) NULL);
	X		break;
	X	    case '=':
	X		Function(display, (XtPointer) Equal, (XtPointer) NULL);
	X		break;
	X	    case '.':
	X		InputDecimal(display, (XtPointer) NULL,
	X			(XtPointer) NULL);
	X		break;
	X	    default:
	X		return;
	X	}
	X    }
	X    Function(display, (XtPointer) Equal, (XtPointer) NULL);
	X
	X    XtFree((XtPointer) value);
	X}
SHAR_EOF
if test 9434 -ne "`wc -c < 'xcalc.c'`"
then
	echo shar: error transmitting "'xcalc.c'" '(should have been 9434 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'xmonitor.c'" '(3792 characters)'
if test -f 'xmonitor.c'
then
	echo shar: will not over-write existing file "'xmonitor.c'"
else
sed 's/^	X//' << \SHAR_EOF > 'xmonitor.c'
	X/***********************************************************
	XCopyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
	X
	X                        All Rights Reserved
	X
	XPermission to use, copy, modify, and distribute these examples for any
	Xpurpose and without fee is hereby granted, provided that the above
	Xcopyright notice appear in all copies and that both that copyright
	Xnotice and this permission notice appear in supporting documentation,
	Xand that the name of Digital not be used in advertising or publicity
	Xpertaining to distribution of the software without specific, written
	Xprior permission.
	X
	XDIGITAL AND THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
	XSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
	XFITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
	XOR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
	XOF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
	XOR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
	XOR PERFORMANCE OF THIS SOFTWARE.
	X
	X******************************************************************/
	X
	X#include <stdio.h>
	X#include <X11/Intrinsic.h>
	X#include <X11/StringDefs.h>
	X#include "Graph.h"
	X#include "BarDisplay.h"
	X
	XXtAppContext app;
	XWidget graph;
	Xint *fields;
	X
	Xvoid Timer(), CreateGraphWidget(), GetGraphData();
	Xtypedef struct {
	X    int timeout;
	X    int num_fields;
	X    String command;
	X} OptionsRec;
	X
	XOptionsRec options;
	X
	X#define Offset(field) XtOffsetOf(OptionsRec, field)
	X
	XXtResource resources[] = {
	X    {"interval", "Interval", XtRInt, sizeof(int),
	X	Offset(timeout), XtRImmediate, (XtPointer) 5},
	X    {"numFields", "NumFields", XtRInt, sizeof(int),
	X	Offset(num_fields), XtRImmediate, (XtPointer) 3},
	X    {"command", "Command", XtRString, sizeof(String),
	X	Offset(command), XtRString,
	X    "vmstat 1 2 | awk '{if (NR == 4) print $(NF-2), $(NF-1), $(NF)}'"}
	X};
	X
	X#undef Offset
	X
	XXrmOptionDescRec optionDesc[] = {
	X    {"-interval", "*interval", XrmoptionSepArg, (XtPointer) NULL}
	X};
	X
	Xmain(argc, argv)
	X    int argc;
	X    char *argv[];
	X{
	X    Widget toplevel;
	X
	X    toplevel = XtAppInitialize(&app, "DemoMonitor",
	X	    optionDesc, XtNumber(optionDesc), &argc, argv,
	X            (String *) NULL, (ArgList) NULL, 0);
	X
	X    XtGetApplicationResources(toplevel, (XtPointer) &options,
	X	    resources, XtNumber(resources), (Arg *) NULL, 0);
	X
	X    fields = (int *) XtCalloc(options.num_fields, sizeof(int));
	X
	X    CreateGraphWidget(toplevel);
	X    XtRealizeWidget(toplevel);
	X
	X    (void) XtAppAddTimeOut(app, options.timeout * 1000,
	X	    Timer, (XtPointer) NULL);
	X
	X    XtAppMainLoop(app);
	X}
	X
	Xvoid CreateGraphWidget(parent)
	X    Widget parent;
	X{
	X    Arg args[10];
	X    int n;
	X
	X    GetGraphData();
	X
	X    n = 0;
	X    XtSetArg(args[n], XtNnumEntries, options.num_fields);   n++;
	X    XtSetArg(args[n], XtNvalues, fields);		    n++;
	X    graph = XtCreateManagedWidget("graph", graphWidgetClass, parent,
	X	    args, n);
	X
	X    (void) XtCreateWidget("bar", barDisplayObjectClass, graph,
	X	    (Arg *) NULL, 0);
	X}
	X
	Xvoid Timer(client_data, id)
	X    XtPointer client_data;
	X    XtIntervalId *id;
	X{
	X    Arg args[10];
	X    int n;
	X
	X    GetGraphData();
	X
	X    n = 0;
	X    XtSetArg(args[n], XtNvalues, fields);    n++;
	X    XtSetValues(graph, args, n);
	X
	X    (void) XtAppAddTimeOut(app, options.timeout * 1000,
	X	    Timer, (XtPointer) NULL);
	X}
	X
	Xvoid GetGraphData()
	X{
	X    int status;
	X    FILE *f;
	X    int i;
	X
	X    f = popen(options.command, "r");
	X
	X    for (i = 0; i < options.num_fields; i++) {
	X	status = fscanf(f, "%d", &fields[i]);
	X	if (status != 1) {
	X            XtAppWarningMsg(app, "noData", "getGraphData",
	X            	    "DemoLoadError", "Not enough fields in data",
	X		    (String *) NULL, (Cardinal *) NULL);
	X	    for (; i < options.num_fields; i++) fields[i] = 0;
	X	    break;
	X	}
	X    }
	X
	X    pclose(f);
	X}
SHAR_EOF
if test 3792 -ne "`wc -c < 'xmonitor.c'`"
then
	echo shar: error transmitting "'xmonitor.c'" '(should have been 3792 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'DemoBiff'" '(1200 characters)'
if test -f 'DemoBiff'
then
	echo shar: will not over-write existing file "'DemoBiff'"
else
sed 's/^	X//' << \SHAR_EOF > 'DemoBiff'
	X!***********************************************************
	X!Copyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
	X!
	X!                        All Rights Reserved
	X!
	X!Permission to use, copy, modify, and distribute these examples for any
	X!purpose and without fee is hereby granted, provided that the above
	X!copyright notice appear in all copies and that both that copyright
	X!notice and this permission notice appear in supporting documentation,
	X!and that the name of Digital not be used in advertising or publicity
	X!pertaining to distribution of the software without specific, written
	X!prior permission.
	X!
	X!DIGITAL AND THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
	X!SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
	X!FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
	X!OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
	X!OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
	X!OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
	X!OR PERFORMANCE OF THIS SOFTWARE.
	X!
	X!******************************************************************
	X
	X*AllowShellResize : TRUE
	X*Title : Mail notifier
SHAR_EOF
if test 1200 -ne "`wc -c < 'DemoBiff'`"
then
	echo shar: error transmitting "'DemoBiff'" '(should have been 1200 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'DemoCalc'" '(3262 characters)'
if test -f 'DemoCalc'
then
	echo shar: will not over-write existing file "'DemoCalc'"
else
sed 's/^	X//' << \SHAR_EOF > 'DemoCalc'
	X!***********************************************************
	X!Copyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
	X!
	X!                        All Rights Reserved
	X!
	X!Permission to use, copy, modify, and distribute these examples for any
	X!purpose and without fee is hereby granted, provided that the above
	X!copyright notice appear in all copies and that both that copyright
	X!notice and this permission notice appear in supporting documentation,
	X!and that the name of Digital not be used in advertising or publicity
	X!pertaining to distribution of the software without specific, written
	X!prior permission.
	X!
	X!DIGITAL AND THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
	X!SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
	X!FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
	X!OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
	X!OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
	X!OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
	X!OR PERFORMANCE OF THIS SOFTWARE.
	X!
	X!******************************************************************
	X
	X*input : TRUE
	X*main.translations : <Btn2Down> : RepositionMenu() MenuPopup(menuShell)
	X
	X*display.x : 10
	X*display.y : 10
	X*display.width : 130
	X*display.justify : Right
	X*display.translations : #replace
	X
	X*Pushbutton.width : 25
	X*Pushbutton.justify : Center
	X
	X*button0.x : 45
	X*button0.y : 150
	X*button0.label :0
	X*button0.accelerators : :<Key>0 : notify()
	X
	X*button1.x : 10
	X*button1.y : 115
	X*button1.label :1
	X*button1.accelerators : :<Key>1 : notify()
	X
	X*button2.x : 45
	X*button2.y : 115
	X*button2.label :2
	X*button2.accelerators : :<Key>2 : notify()
	X
	X*button3.x : 80
	X*button3.y : 115
	X*button3.label :3
	X*button3.accelerators : :<Key>3 : notify()
	X
	X*button4.x : 10
	X*button4.y : 80
	X*button4.label :4
	X*button4.accelerators : :<Key>4 : notify()
	X
	X*button5.x : 45
	X*button5.y : 80
	X*button5.label :5
	X*button5.accelerators : :<Key>5 : notify()
	X
	X*button6.x : 80
	X*button6.y : 80
	X*button6.label :6
	X*button6.accelerators : :<Key>6 : notify()
	X
	X*button7.x : 10
	X*button7.y : 45
	X*button7.label :7
	X*button7.accelerators : :<Key>7 : notify()
	X
	X*button8.x : 45
	X*button8.y : 45
	X*button8.label :8
	X*button8.accelerators : :<Key>8 : notify()
	X
	X*button9.x : 80
	X*button9.y : 45
	X*button9.label :9
	X*button9.accelerators : :<Key>9 : notify()
	X
	X*decimal.x : 80
	X*decimal.y : 150
	X*decimal.label :.
	X*decimal.accelerators : :<Key>. : notify()
	X
	X*plus.x : 115
	X*plus.y : 45
	X*plus.label :+
	X*plus.accelerators : :<Key>+ : notify()
	X
	X*minus.x : 115
	X*minus.y : 80
	X*minus.label :-
	X*minus.accelerators : :<Key>- : notify()
	X
	X*times.x : 115
	X*times.y : 115
	X*times.label :*
	X*times.accelerators : :<Key>* : notify()
	X
	X*divide.x : 115
	X*divide.y : 150
	X*divide.label :/
	X*divide.accelerators : :<Key>/ : notify()
	X
	X*equals.x : 115
	X*equals.y : 185
	X*equals.label :=
	X*equals.accelerators : :<Key>= : notify()
	X
	X*clearEntry.x : 10
	X*clearEntry.y : 150
	X*clearEntry.label :CE
	X*clearEntry.accelerators : :<Key>c : notify()
	X
	X*clear.x : 10
	X*clear.y : 185
	X*clear.label :C
	X*clear.accelerators : :<Key>C : notify()
	X
	X*select.label :Select
	X*select.accelerators : <Key>S : notify()
	X
	X*paste.label :Paste
	X*paste.accelerators : <Key>P : notify()
	X
	X*quit.label :Quit
	X*quit.accelerators : <Key>Q : notify()
SHAR_EOF
if test 3262 -ne "`wc -c < 'DemoCalc'`"
then
	echo shar: error transmitting "'DemoCalc'" '(should have been 3262 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'DemoMonitor'" '(1208 characters)'
if test -f 'DemoMonitor'
then
	echo shar: will not over-write existing file "'DemoMonitor'"
else
sed 's/^	X//' << \SHAR_EOF > 'DemoMonitor'
	X!***********************************************************
	X!Copyright 1990 by Digital Equipment Corporation, Maynard, Massachusetts.
	X!
	X!                        All Rights Reserved
	X!
	X!Permission to use, copy, modify, and distribute these examples for any
	X!purpose and without fee is hereby granted, provided that the above
	X!copyright notice appear in all copies and that both that copyright
	X!notice and this permission notice appear in supporting documentation,
	X!and that the name of Digital not be used in advertising or publicity
	X!pertaining to distribution of the software without specific, written
	X!prior permission.
	X!
	X!DIGITAL AND THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
	X!SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
	X!FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
	X!OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
	X!OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
	X!OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
	X!OR PERFORMANCE OF THIS SOFTWARE.
	X!
	X!******************************************************************
	X
	X*graph.labels: User\nSystem\nIdle
	X*graph.maxValue : 100
SHAR_EOF
if test 1208 -ne "`wc -c < 'DemoMonitor'`"
then
	echo shar: error transmitting "'DemoMonitor'" '(should have been 1208 characters)'
fi
fi # end of overwriting check
#	End of shell archive
exit 0

dan
----------------------------------------------------
O'Reilly && Associates   argv@sun.com / argv@ora.com
Opinions expressed reflect those of the author only.