v13i066: xrainbow, Part04/05

Dave Nedde daven at maxine.WPI.EDU
Fri Jun 28 11:05:08 AEST 1991


Submitted-by: daven at maxine.WPI.EDU (Dave Nedde)
Posting-number: Volume 13, Issue 66
Archive-name: xrainbow/part04

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 4 (of 5)."
# Contents:  xrainbow/Wc1_05/Wc/WcName.c xrainbow/Wc1_05/Wc/WcReg.c
#   xrainbow/Wc1_05/Wc/WcRegXt.c xrainbow/X11/Xaw_d/DrawingA.c
#   xrainbow/X11/Xaw_d/DrawingA.doc xrainbow/include/Wc/WcCreate.h
# Wrapped by daven at ash on Mon Jun  3 12:33:24 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'xrainbow/Wc1_05/Wc/WcName.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xrainbow/Wc1_05/Wc/WcName.c'\"
else
echo shar: Extracting \"'xrainbow/Wc1_05/Wc/WcName.c'\" \(30543 characters\)
sed "s/^X//" >'xrainbow/Wc1_05/Wc/WcName.c' <<'END_OF_FILE'
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** SCCS_data: @(#)WcName.c 1.1 ( 19 Nov 90 )
X**
X** Description:	Implements several name-to-widget and widget-to-name
X**		functions which are generally useful, especially a name 
X**		to widget function which really works:
X**
X**			Widget WcFullNameToWidget(char* widget_name)
X**
X**		The widget names understood by WcFullNameToWidget() are
X**		a superset of those understood by XtNameToWidget in
X**		the X11R4 version of libXt.  XtNameToWidget only knows
X**		how to find children of a reference widget, and so the
X**		names start _below- the refernce widget.  However,
X**		WcFullNameToWidget knows how to find widgets anywhere
X**		in the widget tree: it normally starts the name search
X**		from the root of the widget tree, but it can also
X**		perform the name search relatively from the reference
X**		widget, both up and down the widget tree.
X**
X**		When name searches start at the root of the widget
X**		tree, the same syntax as that understood by Xrm is
X**		used.  Below are four examples of acceptable names:
X**
X**			*foo			*foo.XmRowColumn*glorp
X**			Mri.some*other.foo	*Form.glorp
X**
X**		Note that components may be class names, such as
X**		XmRowColumn, or may be instance names of the widgets.
X**		Ambiguous names are resolved exactly as done by 
X**		XtNameToWidget: shallowest wins, `.' binds tighter
X**		than `*', instance names bind tighter than class
X**		names.
X**
X**		In addition to resolving names from the root of the
X**		widget tree, WcFullNameToWidget also can find widget
X**		using a relative root prefix.  Three special characters
X**		are used:
X**
X**			^	means "parent"
X**			~	means the closest shell ancestor
X**			.	means start at the reference widget
X**
X**		The relative root prefix characters are exactly that:
X**		a prefix of a name which will then be passed to
X**		XtNameToWidget.  Some examples:
X**
X**			.foo	a child of the reference widget
X**			^foo	a sibling of the reference widget
X**			^^foo	a sibling of the ref' widgets's parent
X**			~foo	a child of the shell ancestor.
X**			~~*foo	some child of the shell's shell ancestor.
X**
X**		The ^ and ~ prefix characters are only valid at the 
X**		beginning.  They effectively operate on the reference
X**		widget.
X**
X**		In all cases, the characters are scanned left to right.
X**		So, the first character is acted upon, then the second,
X**		and so on.
X**		
X** Notes:	Most of the "private" part of this file goes away when 
X**		the bug in the Xt Intrinsics is fixed which causes 
X**		XtNameToWidget() to dump core whenever a Gadget exists 
X**		in the widget heirarchy...
X**
X******************************************************************************/
X
X/******************************************************************************
X* Include_files.
X******************************************************************************/
X
X#include <ctype.h>      /* isupper() and tolower macros */
X
X/*  -- X Window System includes */
X#include <X11/IntrinsicP.h>
X#include <X11/ObjectP.h>
X#include <X11/StringDefs.h>
X
X/*  -- Widget Creation Library includes */
X#include "WcCreate.h"
X#include "WcCreateP.h"
X
X/*
X*******************************************************************************
X* Private_data_definitions.
X*******************************************************************************
X*/
X
X/* shared error message and name buffers
X*******************************************************************************
X** NOTE: These are shared arrays because they are large: i.e.,
X** this is a performacne optimization intended to reduce page
X** faults which can occur while making large extensions to the
X** stack space.  Wait a minute: wouldn't this just happen
X** once, and then the stack space is alloc'd?  Yes, but a
X** huge stack space runs the risk of getting swapped, which causes
X** page faults.  This is probably a nit-picky sort of optimization.
X** Remember that D.Smyth is an old sys programmer from the stone
X** ages, and pity him instead of flaming him.
X** Be careful when filling msg not to call any funcs in here,
X** so the message does not get garbled.
X*/
X
Xstatic char     msg[MAX_ERRMSG];
Xstatic char     cleanName[MAX_PATHNAME];
X
X/* Private Data involving the root widget list
X*******************************************************************************
X*/
X
Xstatic int    numRoots = 0;
Xstatic Widget rootWidgets[MAX_ROOT_WIDGETS];
X
X/*
X*******************************************************************************
X* Private_function definitions.
X*******************************************************************************
X
X/*
X    The following implements XtNameToWidget() in a way which really works.
X
X    Note: the #if defined... assumes a FIXED version of R4.  The version
X    even as of 19 June 1990 still is not correct (dumps core on Gadgets).
X*/
X
X#if defined(XtSpecificationRelease) && XtSpecificationRelease > 4
X
XWidget WcChildNameToWidget( Widget ref, char* childName)
X{
X    return XtNameToWidget( ref, childName );
X}
X
X#else
X
X/* NOTE: The Motif 1.0 XtNameToWidget is broken: it cannot find
X** names with wild cards.  The R4 XtNameToWidget is also broken: it
X** cannot handle encounters with Gadgets.
X**
X** Below is the code extracted from the X11R4 distribution, with very
X** minor changes to make it independent from the rest of the R4 Intrinsics, 
X** and to fix the bug in encountering Gadgets.
X** 
X** Fixes: Added the two lines following this comment block.
X**	  Renamed XtNameToWidget to WcChildNameToWidget to avoid warning.
X**	  Removed "register" from arg type decls, as dbx does these
X**	  incorrectly, and a decent compiler (gcc) does this anyway.
X** -->	  Before looking for children, see if a widget is a gadget.
X**	     Gadgets can't have children, in fact those fields are
X**	     something else entirely!!!
X**
X** Here is the Copyright notice in the X11R4 files from which the
X** following section of code, through the line containing
X**		#endif from X11R4
X***********************************************************
XCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
Xand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
X
X                        All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted,
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in
Xsupporting documentation, and that the names of Digital or MIT not be
Xused in advertising or publicity pertaining to distribution of the
Xsoftware without specific, written prior permission.
X
XDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
XALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
XDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
XANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
XWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
XARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
XSOFTWARE.
X
X******************************************************************
X*/
X
X/*************** Begin source from X11R4 Xtos.h ***************/
X
X#ifndef ALLOCATE_LOCAL
X#define ALLOCATE_LOCAL(size) XtMalloc((unsigned long)(size))
X#define DEALLOCATE_LOCAL(ptr) XtFree((caddr_t)(ptr))
X#endif /* ALLOCATE_LOCAL */
X
X/*************** End source from X11R4 Xtos.h ***************/
X
X#define _XtAllocError		XtError
X
X/*************** Begin source from X11R4 lib/Xt/Intrinsics.c ***************/
X
Xstatic Widget NameListToWidget();
X
Xtypedef Widget (*NameMatchProc)();
X
Xstatic Widget MatchExactChildren(names, bindings, children, num,
X        in_depth, out_depth, found_depth)
X    XrmNameList     names;
X    XrmBindingList  bindings;
X    WidgetList children;
X    int num;
X    int in_depth, *out_depth, *found_depth;
X{
X    Cardinal   i;
X    XrmName    name = *names;
X    Widget w, result = NULL;
X    int d, min = 10000;
X
X    for (i = 0; i < num; i++) {
X        if (name == children[i]->core.xrm_name) {
X            w = NameListToWidget(children[i], &names[1], &bindings[1],
X                    in_depth+1, &d, found_depth);
X            if (w != NULL && d < min) {result = w; min = d;}
X        }
X    }
X    *out_depth = min;
X    return result;
X}
X
Xstatic Widget MatchWildChildren(names, bindings, children, num,
X        in_depth, out_depth, found_depth)
X    XrmNameList     names;
X    XrmBindingList  bindings;
X    WidgetList children;
X    int num;
X    int in_depth, *out_depth, *found_depth;
X{
X    Cardinal   i;
X    Widget w, result = NULL;
X    int d, min = 10000;
X
X    for (i = 0; i < num; i++) {
X        w = NameListToWidget(children[i], names, bindings,
X                in_depth+1, &d, found_depth);
X        if (w != NULL && d < min) {result = w; min = d;}
X    }
X    *out_depth = min;
X    return result;
X}
X
Xstatic Widget SearchChildren(root, names, bindings, matchproc,
X        in_depth, out_depth, found_depth)
X    Widget root;
X    XrmNameList     names;
X    XrmBindingList  bindings;
X    NameMatchProc matchproc;
X    int in_depth, *out_depth, *found_depth;
X{
X    Widget w1, w2;
X    int d1, d2;
X
X    if (!XtIsWidget(root)) {
X	*out_depth = 10000;	/* I don't know what this should be */
X	return (Widget)NULL;
X    }
X    if (XtIsComposite(root)) {
X        w1 = (*matchproc)(names, bindings,
X                ((CompositeWidget) root)->composite.children,
X                ((CompositeWidget) root)->composite.num_children,
X                in_depth, &d1, found_depth);
X    } else d1 = 10000;
X    w2 = (*matchproc)(names, bindings, root->core.popup_list,
X            root->core.num_popups, in_depth, &d2, found_depth);
X    *out_depth = (d1 < d2 ? d1 : d2);
X    return (d1 < d2 ? w1 : w2);
X}
X
Xstatic Widget NameListToWidget(root, names, bindings,
X        in_depth, out_depth, found_depth)
X    Widget root;
X    XrmNameList     names;
X    XrmBindingList  bindings;
X    int in_depth, *out_depth, *found_depth;
X{
X    Widget w1, w2;
X    int d1, d2;
X
X    if (in_depth >= *found_depth) {
X        *out_depth = 10000;
X        return NULL;
X    }
X
X    if (names[0] == NULLQUARK) {
X        *out_depth = *found_depth = in_depth;
X        return root;
X    }
X
X    if (*bindings == XrmBindTightly) {
X        return SearchChildren(root, names, bindings, MatchExactChildren,
X                in_depth, out_depth, found_depth);
X
X    } else {    /* XrmBindLoosely */
X        w1 = SearchChildren(root, names, bindings, MatchExactChildren,
X                in_depth, &d1, found_depth);
X        w2 = SearchChildren(root, names, bindings, MatchWildChildren,
X                in_depth, &d2, found_depth);
X        *out_depth = (d1 < d2 ? d1 : d2);
X        return (d1 < d2 ? w1 : w2);
X    }
X} /* NameListToWidget */
X
XWidget WcChildNameToWidget( ref, name )  /* was XtNameToWidget */
X    Widget ref;
X    char*  name;
X{
X    XrmName *names;
X    XrmBinding *bindings;
X    int len, depth, found = 10000;
X    Widget result;
X
X    len = strlen(name);
X    if (len == 0) return NULL;
X
X    names = (XrmName *) ALLOCATE_LOCAL((unsigned) (len+1) * sizeof(XrmName));
X    bindings = (XrmBinding *)
X        ALLOCATE_LOCAL((unsigned) (len+1) * sizeof(XrmBinding));
X    if (names == NULL || bindings == NULL) _XtAllocError("alloca");
X
X    XrmStringToBindingQuarkList(name, bindings, names);
X    if (names[0] == NULLQUARK) {
X        DEALLOCATE_LOCAL((char *) names);
X        DEALLOCATE_LOCAL((char *) bindings);
X        return NULL;
X    }
X
X    result = NameListToWidget(ref, names, bindings, 0, &depth, &found);
X
X    DEALLOCATE_LOCAL((char *) names);
X    DEALLOCATE_LOCAL((char *) bindings);
X    return result;
X} /* WcChildNameToWidget */
X
X/*************** End of source from X11R4 lib/Xt/Intrinsics.c ***************/
X#endif /* from X11R4 */
X
X/******************************************************************************
X** Public functions
X******************************************************************************/
X
X/*******************************************************************************
X** Allocate and return a lower case copy of the input string.
X** Caller must free output string!
X*******************************************************************************/
X
Xchar* WcLowerCaseCopy( in )
X    char* in;
X{
X    char* retVal = (char*)XtMalloc( 1 + strlen ( in ) );
X    char* cp = retVal;
X
X    while (*in)
X    {
X	*cp = (isupper(*in) ? tolower(*in) : *in );
X	cp++ ; in++ ;
X    }
X    *cp = NUL;
X    return retVal;
X}
X
X/******************************************************************************
X**  Return "clean" widget name, resource, or value from string
X*******************************************************************************
X    This function strips leading and trailing whitespace from the
X    passed in char*.  Note that the caller must allocate and free
X    the returned character buffer.
X******************************************************************************/
X
Xchar* WcSkipWhitespace( cp )
X    char* cp;
X{
X    while ( *cp && *cp <= ' ' )
X        cp++;
X    return cp;
X}
X
Xchar* WcSkipWhitespace_Comma( cp )
X    char* cp;
X{
X    while ( *cp && *cp <= ' ' )		/* cp = WcSkipWhitespace ( cp ); */
X        cp++;
X    if ( *cp == ',' )
X        cp++;
X    return cp;
X}
X
Xchar* WcCleanName( in, out )
X    char* in;
X    char* out;
X{
X    /* copy from in[] into out[],
X    ** ignore initial whitespace,
X    ** stop at trailing whitespace or comma.
X    ** Returns pointer to whitespace or comma following name.
X    */
X    while ( *in && *in <= ' ' )		/* in = WcSkipWhitespace( in ); */
X	in++;
X    for ( ; (*in > ' ' && *in != ',') ; in++ )
X        *out++ = *in;
X    *out = NUL;
X    return in;  /* this points at 1st whitespace or comma following "out" */
X}
X
X/* This function is necessary because XtNameToWidget cannot really
X** take a widget name which begins at the top level shell, but rather
X** only names which pretend the widget BELOW the top level shell is
X** the top level shell.  I have no idea why some thought the
X** Xt implementation is correct.  Quoting from the Xt manual:
X**
X**   XtNameToWidget returns the descendent [of root] ... according to
X**   the following rules, ... :
X**
X**   o	... qualifying the name of each object with the names of all
X**	its ancestors up to _but_not_including_ the reference widget.
X**
X** Since this is not useful for our purposes, we need to first do some 
X** screwing around to see if the user specified the widget name like one 
X** would specify any other widget name in the resource file.
X*/
X
Xchar* WcStripWhitespaceFromBothEnds( name )
X    char* name;
X{
X    char* first; 
X    char* last;
X    char* buff;
X    char* bp;
X
X    for ( first = name ; *first <= ' ' ; first ++ )
X	;
X    for ( last = first ; *last ; last++ )
X	;
X    for ( last-- ; *last <= ' ' ; last-- )
X	;
X    buff = (char*)XtMalloc( (last - first) + 2 );
X    for ( bp = buff ; first <= last ; bp++, first++ )
X	*bp = *first;
X    *bp = NUL;
X
X    return buff;
X}
X
X/*
X    -- Find the named widget
X*******************************************************************************
X
X    This function uses WcChildNameToWidget to search a widget tree for a
X    widget with the given name.  WcChildNameToWidget is basically
X    XtNameToWidget from X11R4, but hacked so it works when there are
X    Gadgets in the widget tree.
X
X    WcChildNameToWidget, like XtNameToWidget, starts searching for children
X    of a reference widget.  WcFullNameToWidget examines the first few
X    characters of the `name' argument in order to determine which widget is
X    the reference whidget where the search will begin.
X
X    The possibilities are these:  The `name' can begin with one or more of
X    the relative prefix characters: ^ or ~, which means the reference
X    widget will be some relative node in the widget tree, such as the
X    parent or the shell ancestor.  Otherwise, the  root widget will be the
X    starting point.
X*/
X
XWidget WcFullNameToWidget( w, name )
X    Widget w;
X    char*  name;
X{
X    Widget retWidget;
X    char  *widgetName;
X    char  *lowerName;
X    int    i;
X
X    widgetName = WcStripWhitespaceFromBothEnds( name );	/* must be XtFree'd */
X
X    if ( widgetName[0] == '*' )
X    {
X	retWidget = WcChildNameToWidget( WcRootWidget(w), widgetName );
X	XtFree( widgetName );
X	return retWidget;
X    }
X
X    if (widgetName[0] == '^' 
X     || widgetName[0] == '~' 
X     || widgetName[0] == '.')
X    {
X	i = 0;
X	while (widgetName[i] == '^' 	/* parent */
X	    || widgetName[i] == '~' 	/* shell ancestor */
X	    || widgetName[i] == '.')	/* eaten and ignored */
X	{
X	    if (widgetName[i] == '^')
X	    {
X		w = XtParent( w );
X	    }
X	    else if (widgetName[i] == '~')
X	    {
X		/* There is a bug in /usr/include/X11/IntrinsicP.h, in
X		** the XtIsShell() macro.  It does not parenthesize its
X		** argument when it uses it.  Therefore, the extra 
X		** parens are necessary here!
X		*/
X		while (! XtIsShell( (w = XtParent(w)) ) )
X		    ;
X	    }
X	    i++;
X	}
X	if (widgetName[i] == '\0')
X	    retWidget = w;
X	else
X	    retWidget = WcChildNameToWidget( w, &(widgetName[i]) );
X	XtFree( widgetName );
X	return retWidget;
X    }
X
X    lowerName  = WcLowerCaseCopy( widgetName );         /* must be XtFree'd */
X
X    if ( 0 == strcmp( "this", lowerName ) )
X    {
X	XtFree( widgetName );
X	XtFree( lowerName  );
X	return w;
X    }
X
X    /* Apparently, the widget name starts with a name.  We need to find
X    ** which root widget has this name.  We need to go down the list of
X    ** root widgets maintained by WcRootWidget().
X    */
X
X    {
X	Widget	root;
X	Widget  root_of_w;
X	char*	rootName;
X	char*	lowerRootName;
X	int     widgetNameLen = strlen(lowerName);
X	int	rootNameLen;
X	int	startsWithRootName;
X	char*	stripped;
X
X	/* most of the time, a widget names something else in its
X	** own widget heirarchy.  Therefore, see if the naming starts
X	** at the root widget of `w' but don't check that widget again.
X	*/
X	root_of_w = root = WcRootWidget( w ) ;
X	i = -1;
X
X	while(1)
X	{
X	    rootName = XrmQuarkToString( root->core.xrm_name );
X	    lowerRootName = WcLowerCaseCopy( rootName );       /* XtFree this */
X	    rootNameLen = strlen( lowerRootName );
X	    startsWithRootName = !strncmp(lowerName,lowerRootName,rootNameLen);
X
X	    if ( startsWithRootName && widgetName[rootNameLen] == '*' )
X	    {
X	        /* the root widget name is followed by a `*' so strip the
X		** root name, but keep the star as it implies loose binding.
X		*/
X		stripped = &widgetName[rootNameLen];
X                retWidget = WcChildNameToWidget( root, stripped );
X		XtFree( widgetName    );
X		XtFree( lowerName     );
X		XtFree( lowerRootName );
X		return retWidget;
X	    }
X
X	    else if ( startsWithRootName && widgetName[rootNameLen] == '.' )
X	    {
X		/* the root widget name is followed by a `.' so strip the
X		** root name and the period to imply tight binding.
X		*/
X		stripped = &widgetName[++rootNameLen];
X		retWidget = WcChildNameToWidget( root, stripped );
X		XtFree( widgetName    );
X		XtFree( lowerName     );
X		XtFree( lowerRootName );
X		return retWidget;
X	    }
X
X	    else if ( startsWithRootName && (widgetNameLen == rootNameLen) )
X	    {
X		/* widgetName is the root widget. */
X		XtFree( widgetName    );
X                XtFree( lowerName     );
X                XtFree( lowerRootName );
X                return root;
X	    }
X
X	    /* Did not find the root name.  Try the next, but skip the
X	    ** root_of_w which we checked first.
X	    */
X	    if (++i == numRoots)
X		break;
X	    if (root_of_w == (root = rootWidgets[i]) )
X	    {
X		if (++i == numRoots)
X		    break;
X	        root = rootWidgets[i];
X	    }
X	}
X
X	/* Completely unsucessful in parsing this name. */
X#ifdef DEBUG
X	sprintf( msg,
X	    "WcFullNameToWidget cannot convert `%s' to widget \n\
X	     Problem: Widget name must start with `*' or `.' or `~' or `^'\n\
X	              or `<aRoot>*' or `<aRoot>.' or be `this'" ,
X	     widgetName );
X	XtWarning( msg ); 
X#endif
X
X	XtFree( widgetName );
X	XtFree( lowerName );
X	XtFree( lowerRootName );
X	return NULL;
X    }
X}
X
X/*
X    -- Names to Widget List
X******************************************************************************
X    This routine converts a string of comma separated widget names
X    (or widget paths) into a list of widget id's. Blank space ignored.
X    If a NULL string is provided, NULL is put on the list.
X
X    The return value is the list of names which could NOT be
X    converted.  Note that this list is fixed size, and is re-used.
X*/
X
Xchar* WcNamesToWidgetList ( w, names, widget_list, widget_count )
X    Widget      w;                  /* reference widget */
X    char*       names;              /* string of widget names */
X    Widget      widget_list[];      /* returned widget list */
X    int	       *widget_count;       /* in widget_list[len], out widget count */
X{
X    static char ignored[MAX_XRMSTRING];
X    char*	next   = names;
X    int		max    = *widget_count;
X
X/*  -- parse the input names "widgetpath [, widgetpath] ..." */
X    ignored[0] = NUL;
X    *widget_count = 0;
X
X    do 
X    {
X	next = WcCleanName ( next, cleanName );
X
X	if ( widget_list[*widget_count] = WcFullNameToWidget ( w, cleanName ) )
X	    (*widget_count)++;
X	else
X	{
X	    if (ignored[0] == NUL)
X		strcpy(ignored, cleanName);
X	    else
X	    {
X		strcat(ignored, ", ");
X		strcat(ignored, cleanName);
X	    }
X	}
X	next = WcSkipWhitespace_Comma ( next );
X
X    } while ( *next && *widget_count < max) ;
X
X    return ignored;
X}
X
X/*
X    -- WidgetToFullName
X*******************************************************************************
X    Traverse up the widget tree, sprintf each name right up to
X    the root of the widget tree.  sprintf the names to buffer.  Use
X    recursion so order of names comes out right.  Client MUST free
X    the char string alloc's and returned by WcWidgetToFullName().
X
X    Note: If using the Motif widget set, it is likely (almost inavoidable)
X    that the "widget" may actually be a Gadget.  Well, Gadgets don't have
X    many things, particularly a core.name member.  Therefore, if using
X    Motif we must check to see if the "widget" is not actually an XmGadget.
X    If is it, then we must use XrmQuarkToString(w->core.xrm_name) rather
X    than core.name (unfortunately).  I'd rather not use the xrm name because
X    the case has been flattened: everything is lower case.  Name something
X    SomeComplexLongName and you get back somecomplexlongname.  The case
X    is always insignificant, but the mixed case name is easier to read.
X*/
X
Xstatic char* nextChar;
X
Xstatic int FullNameLen( w )
X    Widget w;
X{
X    int len;
X
X    if ( XtIsWidget(w) )
X	len = 1 + strlen ( w->core.name );
X    else
X	len = 1 + strlen ( XrmQuarkToString(w->core.xrm_name) );
X
X    if (w->core.parent)
X	len += FullNameLen(w->core.parent);
X    return len;
X}
X
Xstatic void WidgetToFullName( w )
X    Widget w;
X{
X    char* cp;
X
X    if (w->core.parent)
X    {
X        WidgetToFullName( w->core.parent );	/* nextChar AFTER parent name */
X	*nextChar++ = '.';			/* inter-name `dot' */
X    }
X
X    if ( XtIsWidget(w) )
X        cp = w->core.name;
X    else
X	cp = XrmQuarkToString(w->core.xrm_name);
X
X    while (*cp)
X	*nextChar++ = *cp++;
X}
X
Xchar* WcWidgetToFullName( w )
X    Widget w;
X{
X    char* buff = XtMalloc( FullNameLen( w ) );
X
X    nextChar = buff;
X
X    WidgetToFullName( w );
X    *nextChar = NUL;
X			
X    return buff;
X}
X
X/*
X    -- Search widget's resource list for resource_type
X*******************************************************************************
X    Gets the XtResourceList from the widget, searches the list for
X    the resource name to determine the type required, which is then
X    returned to the caller.
X*/
X
Xchar* WcGetResourceType( w, res_name )
X    Widget w;
X    char*  res_name;
X{
X    XtResource* res_list;
X    int         i, num;
X    char*	retstr;
X
X    XtGetResourceList( w->core.widget_class, &res_list, &num );
X
X    for ( i = 0 ; i < num ; i++ )
X    {
X        if (0 == strcmp( res_name, res_list[i].resource_name) 
X	 || 0 == strcmp( res_name, res_list[i].resource_class) )
X	{
X            retstr = XtNewString(res_list[i].resource_type);
X	    XtFree( res_list );
X	    return retstr;
X	}
X    }
X
X    w = XtParent( w );
X    if (XtIsConstraint( w ))
X    {
X	XtGetConstraintResourceList( w->core.widget_class, &res_list, &num );
X
X	for ( i = 0 ; i < num ; i++ )
X	{
X	    if (0 == strcmp( res_name, res_list[i].resource_name)
X	     || 0 == strcmp( res_name, res_list[i].resource_class) )
X            {
X                retstr = XtNewString(res_list[i].resource_type);
X                XtFree( res_list );
X                return retstr;
X            }
X	}
X    }
X
X    return NULL;
X}
X
X/*
X    -- Convert resource value from string to whatever the widget needs
X*******************************************************************************
X    Gets the XtResourceList from the widget, searches the list for
X    the resource name to determine the type required, then uses the
X    resource manager to convert from string to the required type.
X    Calls XtSetValue with converted type.
X
X    Note that if the widget does not have the specified resource
X    type, it is not set.  WcGetResourceType() checks for both
X    widget resources and constraint resources.
X
X    Note also that no converter-failed behavior is necessary,
X    because converters generally give their own error messages.
X*/
X
Xvoid WcSetValueFromString( w, res_name, res_val )
X    Widget w;		 /* MUST already be init'd */
X    char*  res_name;
X    char*  res_val;	/* NUL terminated, should NOT have whitespace */
X{
X    char*	res_type;	/* must be XtFree'd */
X
X    if ( res_type = WcGetResourceType( w, res_name ) )
X    {
X	/* This widget does know about this resource type */
X	WcSetValueFromStringAndType( w, res_name, res_val, res_type );
X    }
X    XtFree( res_type );
X}
X
Xvoid WcSetValueFromStringAndType( w, res_name, res_val, res_type )
X    Widget w;
X    char*  res_name;
X    char*  res_val;
X    char*  res_type;
X{
X    XrmValue    fr_val;
X    XrmValue    to_val;
X    Arg		arg[1];
X
X    fr_val.size = strlen(res_val) + 1;
X    fr_val.addr = (caddr_t)res_val;
X    to_val.size = 0;
X    to_val.addr = NULL;
X    XtConvert(
X            w,		/* the widget */
X            XtRString,	/* from type */
X            &fr_val,	/* from value */
X            res_type,	/* to type */
X            &to_val		/* the converted value */
X    );
X
X    if (to_val.addr)
X    {
X        /* Conversion worked.  */
X	if ( 0 == strcmp(res_type, "String"))
X	    XtSetArg( arg[0], res_name, to_val.addr );
X	else
X	{
X	    switch(to_val.size)
X            {
X            case sizeof(char):
X                XtSetArg( arg[0], res_name, *(char*)to_val.addr );
X                break;
X            case sizeof(short):
X                XtSetArg( arg[0], res_name, *(short*)to_val.addr );
X                break;
X            case sizeof(int):
X                XtSetArg( arg[0], res_name, *(int*)to_val.addr );
X                break;
X            default:
X	        XtSetArg( arg[0], res_name, to_val.addr );
X            }
X	}
X        XtSetValues( w, arg, 1 );
X    }
X}
X
X/*
X*******************************************************************************
X* Private Data involving the root widget list, declared at top of this file
X*	static int numRoots = 0;
X*	static Widget rootWidgets[MAX_ROOT_WIDGETS];
X*******************************************************************************
X*/
X
X
X/*
X    -- Forget about a root widget
X*******************************************************************************
X    When a root widget gets destroyed, we need to take that widget out
X    of our list of root widgets.  This is a destroy callback routine
X    which is added to a root widget's destroy callback list by WcRootWidget.
X*/
X
Xstatic void ForgetRoot ( w, client, call )
X    Widget  w;
X    caddr_t client;
X    caddr_t call;
X{
X    int i;
X    for (i = 0 ; i < numRoots ; i++ )
X    {
X        if ( w == rootWidgets[i] )
X	{
X	    /* move all following widgets up to close the gap */
X	    for ( ; i < numRoots ; i++ )
X	    {
X		rootWidgets[i] = rootWidgets[i+1];
X	    }
X	    numRoots-- ;
X	    return;
X	}
X    }
X    /* should never get here */
X}
X
X/*
X    -- Find root widget
X*******************************************************************************
X    If a widget is passed, then find the root of that widget.  See if
X    it is one of the root widgets we already know about.  Add to list
X    if not.  Return the root widget.
X
X    If no widget is passed, then return the first root widget we know
X    about.  If we know of no root widgets, then we will return a NULL
X    since the rootWidgets[] array starts out filled with nulls, and
X    gets re-filled as roots are destroyed.
X*/
X
XWidget WcRootWidget( w )
X    Widget w;
X{
X    int i;
X
X    if (w)
X    {
X	while ( XtParent(w) )
X	    w = XtParent(w);
X
X	for (i = 0 ; i < numRoots ; i++)
X	{
X	    if ( w == rootWidgets[i] )
X		return w;
X	}
X
X	rootWidgets[i] = w;
X	numRoots++;
X	XtAddCallback( w, XtNdestroyCallback, ForgetRoot, NULL );
X	return w;
X    }
X    else
X    {
X	return rootWidgets[0];
X    }
X}
X
X/*
X   -- Equivalent to ANSI C library function strstr()
X*******************************************************************************
X   This function is only necessary on systems which do not have
X   ANSI C libraries.  Soon, it looks like everybody will have
X   such libraries, what with the recent SVR4 and OSF efforts
X   to include everything for everybody.  In the meantime,
X   this will always be included in the library.  Why not put
X   #ifdef's around it?  because the problem really arises not
X   when the library is built, but when applications are built.
X   I can't very well require all application writers in the
X   world to know what this library uses...
X*/
X
Xchar* WcStrStr( s1, s2 )
X    char* s1;
X    char* s2;
X{
X    while (*s1)
X    {
X	if (*s1 == *s2)
X	{
X	    char* start = s1;
X	    char* c = s2;
X	    while (*++s1 & *++c && *s1 == *c)
X		;
X	    if (*c == '\0')
X		return start;
X	    else
X		s1 = ++start;
X	}
X	else
X	{
X	    s1++ ;
X	}
X    }
X    return (char*)0;
X}
END_OF_FILE
if test 30543 -ne `wc -c <'xrainbow/Wc1_05/Wc/WcName.c'`; then
    echo shar: \"'xrainbow/Wc1_05/Wc/WcName.c'\" unpacked with wrong size!
fi
# end of 'xrainbow/Wc1_05/Wc/WcName.c'
fi
if test -f 'xrainbow/Wc1_05/Wc/WcReg.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xrainbow/Wc1_05/Wc/WcReg.c'\"
else
echo shar: Extracting \"'xrainbow/Wc1_05/Wc/WcReg.c'\" \(18492 characters\)
sed "s/^X//" >'xrainbow/Wc1_05/Wc/WcReg.c' <<'END_OF_FILE'
X/*
X** Copyright (c) 1990 David E. Smyth
X**
X** This file was derived from work performed by Martin Brunecky at
X** Auto-trol Technology Corporation, Denver, Colorado, under the
X** following copyright:
X**
X*******************************************************************************
X* Copyright 1990 by Auto-trol Technology Corporation, Denver, Colorado.
X*
X*                        All Rights Reserved
X*
X* Permission to use, copy, modify, and distribute this software and its
X* documentation for any purpose and without fee is hereby granted, provided
X* that the above copyright notice appears on all copies and that both the
X* copyright and this permission notice appear in supporting documentation
X* and that the name of Auto-trol not be used in advertising or publicity
X* pertaining to distribution of the software without specific, prior written
X* permission.
X*
X* Auto-trol disclaims all warranties with regard to this software, including
X* all implied warranties of merchantability and fitness, in no event shall
X* Auto-trol be liable for any special, indirect or consequential damages or
X* any damages whatsoever resulting from loss of use, data or profits, whether
X* in an action of contract, negligence or other tortious action, arising out
X* of or in connection with the use or performance of this software.
X*******************************************************************************
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* SCCS_data: @(#)WcReg.c 1.1 ( 19 Nov 90 )
X*
X* Subsystem_group:
X*
X*     Widget Creation Library
X*
X* Module_description:
X*
X*     Since (for portability reasons) we can not assume runtime binding,
X*     all widget classes, creation routines (constructors), and callbacks
X*     must be "registered"  by the application BEFORE widget tree creation.
X*
X*     All four of the functions defined in this module load dynamically
X*     allocated and extended arrays of structures.  The size increment
X*     of the arrays starts at a reasonably small size (INCR_REGISTRY,
X*     initially 32), and is doubled in size everytime a given registry is
X*     filled.  This allows registries to be small, yet to not have to be
X*     realloc'd frequently when they grow large.  
X*
X*     The registries are arrays of structs.  In all four cases, the
X*     structs are very similar: they contain a name string which holds the
X*     class, constructor, or callback name as it was registered; a quark
X*     which is based on an all lower case representation of the name, and
X*     class, constructor, or callback specific information.  The name
X*     as registered should be as shown in reference documents and source
X*     code, as it is used for user error messages.
X*
X*     The registries are intended to be used by string-to-whatever converters.
X*
X*     All four registration functions currently check for duplicate
X*     entries, but do no fancy hashing scheme, nor any ties to the
X*     application context.  Assumming a relatively small number of
X*     entries in these regestries, it is assumed that a sequential
X*     search using quarks will be adequate and simple.
X
X* Module_interface_summary: 
X*
X*       WcRegisterClassPtr(
X*	    XtAppContext  app,	    - application context
X*	    String	  name,	    - class ptr name, as in ref manuals
X*	    WidgetClass   class )   - class record pointer
X*
X*       WcRegisterClassName(
X*	    XtAppContext  app,	    - application context
X*	    String	  name,	    - class name, as in ref manuals
X*	    WidgetClass   class )   - class record pointer
X*
X*       WcRegisterConstructor(
X*	    XtAppContext  app,	    - application context
X*	    String	  name,	    - constructor name, as in ref manuals
X*	    (*Widget)()   const )   - constructor function pointer
X*
X*	WcRegisterCallback(
X*	    XtAppContext  app,      - application context
X*           String        name,     - callback name, "nice" capitalization
X*	    void (*func)() )        - pointer to callback function
X*
X*	WcRegisterAction(
X*	    XtAppContext  app,      - application context
X*           String        name,     - action name
X*	    XtActionProc  proc )    - action proc
X
X*	WcAllowDuplicateRegistration   ( int allowed )
X*	WcAllowDuplicateClassPtrReg    ( int allowed )
X*	WcAllowDuplicateClassNameReg   ( int allowed )
X*	WcAllowDuplicateConstructorReg ( int allowed )
X*	WcAllowDuplicateCallbackReg    ( int allowed )
X*
X* Module_history:
X
X*   mm/dd/yy  initials  function  action
X*   --------  --------  --------  ---------------------------------------------
X*   16Jul90   D.Smyth   Added WcAllowDuplicate*()
X*   19Jun90   D.Smyth   Version 1.0 Widget Creation Library
X*   06/08/90  D.Smyth   All Added "name" member for better user msgs.
X*   02/26/90  MarBru    All       Created
X*   02/16/90  MarBru    Create..  Limited creation to composite widgets/objects
X*
X* Design_notes:
X*
X*   For VMS, we could have used LIB$FIND_IMAGE_SYMBOL and use dynamic
X*   (runtime) binding. But since most UNIX systems lack such capability,
X*   we stick to the concept of "registration" routines.
X*
X*******************************************************************************
X*/
X/*
X*******************************************************************************
X* Include_files.
X*******************************************************************************
X*/
X
X/*  -- X Window System Includes */
X#include <X11/Intrinsic.h>
X
X/*  -- Widget Creation Includes */
X#include "WcCreate.h"
X#include "WcCreateP.h"
X
X/*
X*******************************************************************************
X* Private_data_definitions.
X*******************************************************************************
X    The following cache/registry of known widget classes, contructors, 
X    and callbacks are initially empty, and are loaded by the application 
X    using "registration" routines.
X*/
X
Xstatic char     msg[MAX_ERRMSG];
X
Xstatic int allowDuplicateClassPtrReg    = FALSE;
Xstatic int allowDuplicateClassNameReg   = FALSE;
Xstatic int allowDuplicateConstructorReg = FALSE;
Xstatic int allowDuplicateCallbackReg    = FALSE;
X
X/*  -- Named class pointer cache, intially empty */
X
Xint         classes_num = 0;
Xint         classes_max = 0;
XClCacheRec *classes_ptr = NULL;
X
X/*  -- Class name cache, intially empty */
X
Xint             cl_nm_num = 0;
Xint             cl_nm_max = 0;
XClNameCacheRec* cl_nm_ptr = NULL;
X
X/*  -- Named object constructor cache, intially empty */
X
Xint          constrs_num = 0;
Xint          constrs_max = 0;
XConCacheRec *constrs_ptr = NULL;
X
X/*  -- Named callback procedures cache, intially empty */
X
Xint         callbacks_num = 0;
Xint         callbacks_max = 0;
XCBCacheRec *callbacks_ptr = NULL;
X
X/*
X*******************************************************************************
X* Private_function_declarations.
X*******************************************************************************
X*/
X
X/*
X*******************************************************************************
X* Public_function_declarations.
X*******************************************************************************
X*/
X
X/*
X    -- Allow or Disallow Duplicate Registrations
X*******************************************************************************
X    By default, the Widget Creation Library does not allow a
X    string-to-callback, string-to-class, etc bindings to be re-defined.
X    Some applications, most noticably user interface builders, need to be
X    able to change these bindings in order to provide additional
X    flexibility.  Therefore the following functions are provided.  The
X    typical user interface builder will make this single call:
X
X	WcAllowDuplicateRegistration( TRUE );
X
X    which allows class pointers, class names, constructors, and callbacks
X    to be changed during execution.
X*/
X
Xvoid WcAllowDuplicateRegistration( allowed )
X    int allowed;
X{
X    allowDuplicateClassPtrReg = allowed;
X    allowDuplicateClassNameReg = allowed;
X    allowDuplicateConstructorReg = allowed;
X    allowDuplicateCallbackReg = allowed;
X}
Xvoid WcAllowDuplicateClassPtrReg( allowed )
X    int allowed;
X{
X    allowDuplicateClassPtrReg = allowed;
X}
Xvoid WcAllowDuplicateClassNameReg( allowed )
X    int allowed;
X{
X    allowDuplicateClassNameReg = allowed;
X}
Xvoid WcAllowDuplicateConstructorReg( allowed )
X    int allowed;
X{
X    allowDuplicateConstructorReg = allowed;
X}
Xvoid WcAllowDuplicateCallbackReg( allowed )
X    int allowed;
X{
X    allowDuplicateCallbackReg = allowed;
X}
X
X/*
X    -- Register Class Pointer Name
X*******************************************************************************
X    This procedure adds class pointer name to our list of registered
X    classes. Note that the class ptr name is effectively case insensitive
X    as it is being quarkified.  However, one should register the class ptr
X    names using the "standard" capitalization (whatever is in the reference
X    manual for the widget set) as the name as registered is used for error
X    messages.
X
X   The registry is primarily used by CvtStringToClassPtr().
X*/
X
Xvoid WcRegisterClassPtr ( app, name, class )
X    XtAppContext        app;    /* not used (yet), must be present      */
X    char*               name;   /* class ptr name, case insensitive     */
X    WidgetClass         class;  /* Xt object class pointer              */
X{
X    char          *lowerCaseName;
X    XrmQuark       quark;
X    ClCacheRec    *rec;
X    int            i;
X
X    /* Might need to grow cache.  Note that growth increment is exponential:
X    ** if lots of classes, don't need to keep realloc'ing so often.
X    */
X    if (classes_num >= classes_max )
X    {
X        classes_max += (classes_max ? classes_max : INCR_REGISTRY);
X        classes_ptr  = (ClCacheRec*) XtRealloc((char*)classes_ptr,
X                             sizeof(ClCacheRec) * classes_max);
X    }
X
X    /* See if this object has been registered.  Compare quarks.
X    */
X    lowerCaseName = WcLowerCaseCopy( name );
X    quark = XrmStringToQuark ( lowerCaseName );
X    XtFree ( lowerCaseName );
X
X    for (i = 0 ; i < classes_num ; i++ )
X    {
X        if (classes_ptr[i].quark == quark)
X        {
X            /* already registered this class */
X	    if ( allowDuplicateClassPtrReg )
X	    {
X		rec = &classes_ptr[i];	/* overwrite this ClCacheRec */
X		goto found_rec;
X	    }
X            sprintf(msg,
X            "WcRegisterClassPtr (%s) - Failed \n\
X             Problem: Duplicate class registration ignored.",
X             name );
X            XtWarning( msg );
X            return;
X        }
X    }
X
X    rec = &classes_ptr[classes_num++];	/* New ClCacheRec to be filled */
X
Xfound_rec:
X    rec->quark = quark;
X    rec->class = class;
X    rec->name  = XtMalloc( strlen(name) + 1 );
X    strcpy ( rec->name, name );
X}
X
X/*
X    -- Register Class Name
X*******************************************************************************
X    This procedure adds a class name to our list of registered
X    classes. Note that the class name is effectively case insensitive
X    as it is being quarkified.  However, one should register the class
X    names using the "standard" capitalization (whatever is in the reference
X    manual for the widget set) as the name as registered is used for error
X    messages.
X
X   The registry is primarily used by CvtStringToClassName().
X*/
X
Xvoid WcRegisterClassName ( app, name, class )
X    XtAppContext	app;	/* not used (yet), must be present      */
X    char*		name;	/* class name, case insensitive   	*/
X    WidgetClass		class;	/* Xt object class pointer              */
X{
X    char           *lowerCaseName;
X    XrmQuark	    quark;
X    ClNameCacheRec *rec;
X    int		    i;
X
X    /* Might need to grow cache.  Note that growth increment is exponential:
X    ** if lots of classes, don't need to keep realloc'ing so often.
X    */
X    if (cl_nm_num >= cl_nm_max )
X    {
X	cl_nm_max += (cl_nm_max ? cl_nm_max : INCR_REGISTRY);
X	cl_nm_ptr  = (ClNameCacheRec*) XtRealloc((char*)cl_nm_ptr, 
X                             sizeof(ClNameCacheRec) * cl_nm_max);
X    }
X
X    /* See if this object has been registered.  Compare quarks.
X    */
X    lowerCaseName = WcLowerCaseCopy( name );
X    quark = XrmStringToQuark ( lowerCaseName );
X    XtFree ( lowerCaseName );
X
X    for (i = 0 ; i < cl_nm_num ; i++ )
X    {
X	if (cl_nm_ptr[i].quark == quark)
X	{
X	    /* already registered this class */
X	    if ( allowDuplicateClassNameReg )
X	    {
X		rec = &cl_nm_ptr[i];	/* overwrite this ClNameCacheRec */
X		goto found_rec;
X	    }
X	    sprintf(msg, 
X            "WcRegisterClassName (%s) - Failed \n\
X             Problem: Duplicate class registration ignored.",
X             name );
X            XtWarning( msg );
X	    return;
X	}
X    }
X
X    rec = &cl_nm_ptr[cl_nm_num++];	/* New ClNameCacheRec to be filled */
X
Xfound_rec:
X    rec->quark = quark;
X    rec->class = class;
X    rec->name  = XtMalloc( strlen(name) + 1 );
X    strcpy ( rec->name, name );
X}
X
X/*
X    -- Register constructor
X*******************************************************************************
X    This procedure adds constructor procedure/name to our list of registered
X    constructors. Note that the name is effectively case insensitive
X    as it is being quarkified.  However, one should register the 
X    names using the "standard" capitalization (whatever is in the reference
X    manual for the widget set) as the name as registered is used for error
X    messages.
X
X    Note the constructor is a "Motif Style" widget creation routine,
X    commonly called a "confusion function."  
X
X   The registry is primarily used by CvtStringToConstructor().
X*/
X
Xvoid WcRegisterConstructor ( app, name, constructor )
X    XtAppContext app;	        /* not used (yet), must be present      */
X    char*        name;	        /* constructor name, case insensitive   */
X    Widget (*constructor) ();   /* pointer to a widget creation routine */
X{
X    char          *lowerCaseName;
X    XrmQuark       quark;
X    ConCacheRec   *rec;
X    int		   i;
X
X    /* Might need to grow cache.  Note that growth increment is exponential:
X    ** if lots of constructors, don't need to keep realloc'ing so often.
X    */
X    if (constrs_num >= constrs_max )
X    {
X        constrs_max += (constrs_max ? constrs_max : INCR_REGISTRY);
X        constrs_ptr  = (ConCacheRec*) XtRealloc((char*)constrs_ptr,
X                             sizeof(ConCacheRec) * constrs_max);
X    }
X
X    /* See if this object has been registered.  Compare quarks.
X    */
X    lowerCaseName = WcLowerCaseCopy( name );
X    quark = XrmStringToQuark ( lowerCaseName );
X    XtFree ( lowerCaseName );
X
X    for (i = 0 ; i < constrs_num ; i++ )
X    {
X        if (constrs_ptr[i].quark == quark)
X        {
X            /* already registered this class */
X	    if ( allowDuplicateConstructorReg )
X	    {
X		rec = &constrs_ptr[i];	/* overwrite this ConCacheRec */
X		goto found_rec;
X	    }
X            sprintf(msg,
X            "WcRegisterConstructor (%s) - Failed \n\
X             Problem: Duplicate constructor registration ignored.",
X             name );
X            XtWarning( msg );
X            return;
X        }
X    }
X
X    rec = &constrs_ptr[constrs_num++];	/* New ClCacheRec to be filled */
X
Xfound_rec:
X    rec->quark       = quark;
X    rec->constructor = constructor;
X    rec->name        = XtMalloc( strlen(name) + 1 );
X    strcpy ( rec->name, name );
X}
X
X/*
X  -- Register Callbacks
X*******************************************************************************
X    Register callback functions which can then be bound to widget
X    callback lists by the string-to-callback converter 
X    CvtStringToCallback().
X*/
X
Xvoid WcRegisterCallback ( app, name, callback, closure )
X    XtAppContext    app;        /* not used (yet), must be present      */
X    String          name;       /* callback name, case insensitive      */
X    XtCallbackProc  callback;   /* callback function pointer            */
X    caddr_t	    closure;	/* default client data			*/
X{
X    char          *lowerCaseName;
X    XrmQuark       quark;
X    CBCacheRec    *rec;
X    int		   i;
X
X    /* Might need to grow cache.  Note that growth increment is exponential:
X    ** if lots of constructors, don't need to keep realloc'ing so often.
X    */
X    if (callbacks_num >= callbacks_max )
X    {
X        callbacks_max += (callbacks_max ? callbacks_max : INCR_REGISTRY);
X        callbacks_ptr  = (CBCacheRec*) XtRealloc((char*)callbacks_ptr,
X                             sizeof(CBCacheRec) * callbacks_max);
X    }
X
X    /* See if this callback has been registered.  Compare quarks.
X    */
X    lowerCaseName = WcLowerCaseCopy( name );
X    quark = XrmStringToQuark ( lowerCaseName );
X    XtFree ( lowerCaseName );
X
X    for (i = 0 ; i < callbacks_num ; i++ )
X    {
X        if (callbacks_ptr[i].quark == quark)
X        {
X            /* already registered this callback */
X	    if ( allowDuplicateCallbackReg )
X	    {
X		rec = &callbacks_ptr[i];	/* overwrite this CBCacheRec */
X		goto found_rec;
X	    }
X            sprintf(msg,
X            "WcRegisterCallback (%s) - Failed \n\
X             Problem: Duplicate callback registration ignored.",
X             name );
X            XtWarning( msg );
X            return;
X        }
X    }
X
X    rec = &callbacks_ptr[callbacks_num++];   /* New ClCacheRec to be filled */
X
Xfound_rec:
X    rec->quark    = quark;
X    rec->callback = callback;
X    rec->closure  = closure;
X    rec->name     = XtMalloc( strlen(name) + 1 );
X    strcpy ( rec->name, name );
X}
X
X/*
X  -- Register Actions
X*******************************************************************************
X    A simple wrapper around XtAppAddActions().
X    Register action procs which can then be bound to widget
X    actions using standard Xt mechanisms.
X*/
X
Xvoid WcRegisterAction(app, name, proc)
X    XtAppContext app;
X    String       name;
X    XtActionProc proc;
X{
X    static XtActionsRec action_rec[] = {
X        { (String)NULL, (XtActionProc)NULL }
X    };
X
X    action_rec[0].string = name;
X    action_rec[0].proc = proc;
X    XtAppAddActions(app, action_rec, 1);
X}
END_OF_FILE
if test 18492 -ne `wc -c <'xrainbow/Wc1_05/Wc/WcReg.c'`; then
    echo shar: \"'xrainbow/Wc1_05/Wc/WcReg.c'\" unpacked with wrong size!
fi
# end of 'xrainbow/Wc1_05/Wc/WcReg.c'
fi
if test -f 'xrainbow/Wc1_05/Wc/WcRegXt.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xrainbow/Wc1_05/Wc/WcRegXt.c'\"
else
echo shar: Extracting \"'xrainbow/Wc1_05/Wc/WcRegXt.c'\" \(7530 characters\)
sed "s/^X//" >'xrainbow/Wc1_05/Wc/WcRegXt.c' <<'END_OF_FILE'
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* SCCS_data: @(#)WcRegXt.c 1.1 ( 19 Nov 90 )
X*
X* Subsystem_group:
X*
X*     Widget Creation Library - Intrinsic Resource Interpreter
X*
X* Module_description:
X*
X*     This module contains registration routine for all Intrinsic
X*     widget constructors and classes.  
X*
X* Module_interface_summary: 
X*
X*     void WcRegisterIntrinsic ( XtAppContext app )
X*
X* Module_history:
X*                                                  
X*   mm/dd/yy  initials  function  action
X*   --------  --------  --------  ---------------------------------------------
X*   07/23/90  D.Smyth   cleaned up function return values.
X*   06/19/90  R.Whitby  all	  create.
X*
X* Design_notes:
X*
X*******************************************************************************
X*/
X/*
X*******************************************************************************
X* Include_files.
X*******************************************************************************
X*/
X
X#include <X11/Intrinsic.h>
X
X#include <X11/Object.h>
X#include <X11/RectObj.h>
X#include <X11/Shell.h>
X#include <X11/Vendor.h>
X
X#include "WcCreateP.h"
X
X/* -- Widget constructor routines */
X
XWidget WcCreateApplicationShell	();
XWidget WcCreateOverrideShell	();
XWidget WcCreateShell		();
XWidget WcCreateTopLevelShell	();
XWidget WcCreateTransientShell	();
XWidget WcCreateVendorShell	();
XWidget WcCreateWMShell		();
X
X
Xvoid WcRegisterIntrinsic ( app )
X    XtAppContext app;
X{
X    ONCE_PER_XtAppContext( app );
X
X#define RCN( name, class ) WcRegisterClassName ( app, name, class );
X#define RCP( name, class ) WcRegisterClassPtr  ( app, name, class );
X#define RCR( name, func )  WcRegisterConstructor(app, name, func  );
X
X    /* -- register all Intrinsic widget classes */
X
X    RCN("Object",			objectClass );
X    RCP("objectClass",			objectClass );
X    RCN("RectObj",			rectObjClass );
X    RCP("rectObjClass",			rectObjClass );
X    RCN("Core",				coreWidgetClass );
X    RCP("coreWidgetClass",		coreWidgetClass );
X    RCN("Composite",			compositeWidgetClass );
X    RCP("compositeWidgetClass",		compositeWidgetClass );
X    RCN("Constraint",			constraintWidgetClass );
X    RCP("constraintWidgetClass",	constraintWidgetClass );
X    RCN("ApplicationShell",		applicationShellWidgetClass );
X    RCP("applicationShellWidgetClass",	applicationShellWidgetClass );
X    RCN("OverrideShell",		overrideShellWidgetClass );
X    RCP("overrideShellWidgetClass",	overrideShellWidgetClass );
X    RCN("Shell",			shellWidgetClass );
X    RCP("shellWidgetClass",		shellWidgetClass );
X    RCN("TopLevelShell",		topLevelShellWidgetClass );
X    RCP("topLevelShellWidgetClass",	topLevelShellWidgetClass );
X    RCN("TransientShell",		transientShellWidgetClass );
X    RCP("transientShellWidgetClass",	transientShellWidgetClass );
X    RCN("VendorShell",			vendorShellWidgetClass );
X    RCP("vendorShellWidgetClass",	vendorShellWidgetClass );
X    RCN("WmShell",			wmShellWidgetClass );
X    RCP("wmShellWidgetClass",		wmShellWidgetClass );
X
X    /* -- register all Intrinsic constructors */
X
X    RCR("XtCreateApplicationShell",	WcCreateApplicationShell);
X    RCR("XtCreateOverrideShell",	WcCreateOverrideShell);
X    RCR("XtCreateShell",		WcCreateShell);
X    RCR("XtCreateTopLevelShell",	WcCreateTopLevelShell);
X    RCR("XtCreateTransientShell",	WcCreateTransientShell);
X    RCR("XtCreateWMShell",		WcCreateWMShell);
X    RCR("XtCreateVendorShell",		WcCreateVendorShell);
X}
X
X/*
X    -- Create Application Shell
X*******************************************************************************
X    This function creates an application shell widget.
X    
X*/
XWidget WcCreateApplicationShell ( pw, name, args, nargs )
X    Widget	pw;	/* children's parent 				*/
X    String      name;	/* widget name to create 			*/
X    Arg        *args;	/* args for widget				*/
X    Cardinal    nargs;	/* args count					*/
X{
X
X  return XtCreatePopupShell(name, applicationShellWidgetClass, pw, args, nargs);
X}
X
X/*
X    -- Create Override Shell
X*******************************************************************************
X    This function creates an override shell widget.
X    
X*/
XWidget WcCreateOverrideShell ( pw, name, args, nargs )
X    Widget	pw;	/* children's parent 				*/
X    String      name;	/* widget name to create 			*/
X    Arg        *args;	/* args for widget				*/
X    Cardinal    nargs;	/* args count					*/
X{
X  return XtCreatePopupShell(name, overrideShellWidgetClass, pw, args, nargs);
X}
X
X/*
X    -- Create Shell
X*******************************************************************************
X    This function creates a shell widget.
X    
X*/
XWidget WcCreateShell ( pw, name, args, nargs )
X    Widget	pw;	/* children's parent 				*/
X    String      name;	/* widget name to create 			*/
X    Arg        *args;	/* args for widget				*/
X    Cardinal    nargs;	/* args count					*/
X{
X  return XtCreatePopupShell(name, shellWidgetClass, pw, args, nargs);
X}
X
X/*
X    -- Create TopLevel Shell
X*******************************************************************************
X    This function creates a top level shell widget.
X    
X*/
XWidget WcCreateTopLevelShell ( pw, name, args, nargs )
X    Widget	pw;	/* children's parent 				*/
X    String      name;	/* widget name to create 			*/
X    Arg        *args;	/* args for widget				*/
X    Cardinal    nargs;	/* args count					*/
X{
X  return XtCreatePopupShell(name, topLevelShellWidgetClass, pw, args, nargs);
X}
X
X/*
X    -- Create Transient Shell
X*******************************************************************************
X    This function creates an transient shell widget.
X    
X*/
XWidget WcCreateTransientShell ( pw, name, args, nargs )
X    Widget	pw;	/* children's parent 				*/
X    String      name;	/* widget name to create 			*/
X    Arg        *args;	/* args for widget				*/
X    Cardinal    nargs;	/* args count					*/
X{
X  return XtCreatePopupShell(name, transientShellWidgetClass, pw, args, nargs);
X}
X
X/*
X    -- Create Vendor Shell
X*******************************************************************************
X    This function creates a vendor shell widget.
X    
X*/
XWidget WcCreateVendorShell ( pw, name, args, nargs )
X    Widget	pw;	/* children's parent 				*/
X    String      name;	/* widget name to create 			*/
X    Arg        *args;	/* args for widget				*/
X    Cardinal    nargs;	/* args count					*/
X{
X  return XtCreatePopupShell(name, vendorShellWidgetClass, pw, args, nargs);
X}
X
X/*
X    -- Create WM Shell
X*******************************************************************************
X    This function creates an WM shell widget.
X    
X*/
XWidget WcCreateWMShell ( pw, name, args, nargs )
X    Widget	pw;	/* children's parent 				*/
X    String      name;	/* widget name to create 			*/
X    Arg        *args;	/* args for widget				*/
X    Cardinal    nargs;	/* args count					*/
X{
X  return XtCreatePopupShell(name, wmShellWidgetClass, pw, args, nargs);
X}
END_OF_FILE
if test 7530 -ne `wc -c <'xrainbow/Wc1_05/Wc/WcRegXt.c'`; then
    echo shar: \"'xrainbow/Wc1_05/Wc/WcRegXt.c'\" unpacked with wrong size!
fi
# end of 'xrainbow/Wc1_05/Wc/WcRegXt.c'
fi
if test -f 'xrainbow/X11/Xaw_d/DrawingA.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xrainbow/X11/Xaw_d/DrawingA.c'\"
else
echo shar: Extracting \"'xrainbow/X11/Xaw_d/DrawingA.c'\" \(5171 characters\)
sed "s/^X//" >'xrainbow/X11/Xaw_d/DrawingA.c' <<'END_OF_FILE'
X/* DrawingA.c: The DrawingArea Widget Methods */
X
X/* Copyright 1990, David Nedde
X/*
X/* Permission to use, copy, modify, and distribute this
X/* software and its documentation for any purpose and without fee
X/* is granted provided that the above copyright notice appears in all copies.
X/* It is provided "as is" without express or implied warranty.
X*/
X
X#include <X11/IntrinsicP.h>
X#include <X11/StringDefs.h>
X#include <X11/CoreP.h>
X#include <X11/Xaw/SimpleP.h>
X#include <X11/Xaw_d/DrawingAP.h>
X
Xstatic void	Initialize();
Xstatic void	Destroy();
Xstatic void	Redisplay();
Xstatic void	input_draw();
Xstatic void	motion_draw();
Xstatic void	resize_draw();
X
Xstatic char defaultTranslations[] = "<BtnDown>: input() \n <BtnUp>: input() \n <KeyDown>: input() \n <KeyUp>: input() \n <Motion>: motion() \n <Configure>: resize()";
Xstatic XtActionsRec actionsList[] = {
X  { "input",  (XtActionProc)input_draw },
X  { "motion", (XtActionProc)motion_draw },
X  { "resize", (XtActionProc)resize_draw },
X};
X
X/* Default instance record values */
Xstatic XtResource resources[] = {
X  {XtNexposeCallback, XtCCallback, XtRCallback, sizeof(caddr_t),
X     XtOffset(DrawingAreaWidget, drawing_area.expose_callback), 
X     XtRCallback, NULL },
X  {XtNinputCallback, XtCCallback, XtRCallback, sizeof(caddr_t),
X     XtOffset(DrawingAreaWidget, drawing_area.input_callback), 
X     XtRCallback, NULL },
X  {XtNmotionCallback, XtCCallback, XtRCallback, sizeof(caddr_t),
X     XtOffset(DrawingAreaWidget, drawing_area.motion_callback), 
X     XtRCallback, NULL },
X  {XtNresizeCallback, XtCCallback, XtRCallback, sizeof(caddr_t),
X     XtOffset(DrawingAreaWidget, drawing_area.resize_callback), 
X     XtRCallback, NULL },
X};
X
X
XDrawingAreaClassRec drawingAreaClassRec = {
X  /* CoreClassPart */
X{
X  (WidgetClass) &simpleClassRec,	/* superclass		  */	
X    "DrawingArea",			/* class_name		  */
X    sizeof(DrawingAreaRec),		/* size			  */
X    NULL,				/* class_initialize	  */
X    NULL,				/* class_part_initialize  */
X    FALSE,				/* class_inited		  */
X    Initialize,				/* initialize		  */
X    NULL,				/* initialize_hook	  */
X    XtInheritRealize,			/* realize		  */
X    actionsList,			/* actions		  */
X    XtNumber(actionsList),		/* num_actions		  */
X    resources,				/* resources		  */
X    XtNumber(resources),		/* resource_count	  */
X    NULLQUARK,				/* xrm_class		  */
X    FALSE,				/* compress_motion	  */
X    FALSE,				/* compress_exposure	  */
X    TRUE,				/* compress_enterleave    */
X    FALSE,				/* visible_interest	  */
X    Destroy,				/* destroy		  */
X    NULL,				/* resize		  */
X    Redisplay,				/* expose		  */
X    NULL,				/* set_values		  */
X    NULL,				/* set_values_hook	  */
X    XtInheritSetValuesAlmost,		/* set_values_almost	  */
X    NULL,				/* get_values_hook	  */
X    NULL,				/* accept_focus		  */
X    XtVersion,				/* version		  */
X    NULL,				/* callback_private	  */
X    defaultTranslations,		/* tm_table		  */
X    XtInheritQueryGeometry,		/* query_geometry	  */
X    XtInheritDisplayAccelerator,	/* display_accelerator	  */
X    NULL				/* extension		  */
X  },  /* CoreClass fields initialization */
X  {
X    /* change_sensitive		*/	XtInheritChangeSensitive
X  },  /* SimpleClass fields initialization */
X  {
X    0,                                     /* field not used    */
X  },  /* DrawingAreaClass fields initialization */
X};
X
X  
XWidgetClass drawingAreaWidgetClass = (WidgetClass)&drawingAreaClassRec;
X
X
Xstatic void Initialize( request, new)
XDrawingAreaWidget request, new;
X{
X  if (request->core.width == 0)
X    new->core.width = 100;
X  if (request->core.height == 0)
X    new->core.height = 100;
X}
X
X
Xstatic void Destroy( w)
XDrawingAreaWidget w;
X{
X  XtRemoveAllCallbacks(w, XtNexposeCallback, w->drawing_area.expose_callback);
X  XtRemoveAllCallbacks(w, XtNinputCallback, w->drawing_area.input_callback);
X  XtRemoveAllCallbacks(w, XtNmotionCallback, w->drawing_area.motion_callback);
X  XtRemoveAllCallbacks(w, XtNresizeCallback, w->drawing_area.resize_callback);
X}
X
X
X/* Invoke expose callbacks */
Xstatic void Redisplay(w, event, region)
XDrawingAreaWidget w;
XXEvent		 *event;
XRegion		  region;
X{
X  XawDrawingAreaCallbackStruct cb;
X
X  cb.reason = XawCR_EXPOSE;
X  cb.event  = event;
X  cb.window = XtWindow(w);
X  XtCallCallbacks(w, XtNexposeCallback, &cb);
X}
X
X/* Invoke resize callbacks */
Xstatic void resize_draw(w, event, args, n_args)
XDrawingAreaWidget w;
XXEvent		 *event;
Xchar		 *args[];
Xint		  n_args;
X{
X  XawDrawingAreaCallbackStruct cb;
X
X  cb.reason = XawCR_RESIZE;
X  cb.event  = event;
X  cb.window = XtWindow(w);
X  XtCallCallbacks(w, XtNresizeCallback, &cb);
X}
X
X/* Invoke input callbacks */
Xstatic void input_draw(w, event, args, n_args)
XDrawingAreaWidget w;
XXEvent		 *event;
Xchar		 *args[];
Xint		  n_args;
X{
X  XawDrawingAreaCallbackStruct cb;
X
X  cb.reason = XawCR_INPUT;
X  cb.event  = event;
X  cb.window = XtWindow(w);
X  XtCallCallbacks(w, XtNinputCallback, &cb);
X}
X
X/* Invoke motion callbacks */
Xstatic void motion_draw(w, event, args, n_args)
XDrawingAreaWidget w;
XXEvent		 *event;
Xchar		 *args[];
Xint		  n_args;
X{
X  XawDrawingAreaCallbackStruct cb;
X
X  cb.reason = XawCR_MOTION;
X  cb.event  = event;
X  cb.window = XtWindow(w);
X  XtCallCallbacks(w, XtNmotionCallback, &cb);
X}
END_OF_FILE
if test 5171 -ne `wc -c <'xrainbow/X11/Xaw_d/DrawingA.c'`; then
    echo shar: \"'xrainbow/X11/Xaw_d/DrawingA.c'\" unpacked with wrong size!
fi
# end of 'xrainbow/X11/Xaw_d/DrawingA.c'
fi
if test -f 'xrainbow/X11/Xaw_d/DrawingA.doc' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xrainbow/X11/Xaw_d/DrawingA.doc'\"
else
echo shar: Extracting \"'xrainbow/X11/Xaw_d/DrawingA.doc'\" \(4291 characters\)
sed "s/^X//" >'xrainbow/X11/Xaw_d/DrawingA.doc' <<'END_OF_FILE'
XDrawingArea Widget
X
X
XSYNOPSIS
X  Application header file	<X11/Xaw_d/DrawingA.h>
X  Class header file		<X11/Xaw_d/DrawingAP.h>
X  Class				drawingAreaWidgetClass
X  Class Name			DrawingArea
X  Superclass			Simple
X
X
XOVERVIEW
X  This widget was needed to allow a drawing area in the Athena widget
X  set that doesn't require hacking up the Label widget by adding
X  complicated actions.  This widget follows Motif's DrawingArea widget
X  closely, except that it follows Athena's naming conventions and there
X  is no resize policy.  Also, Motif's Drawing area is a composite widget,
X  while this one is a simple widget.  This widget is NOT officially
X  part of the Athena widget set.
X
X
XDESCRIPTION
X  The DrawingArea widget is modeled after Motif's DrawingArea widget.
X  The DrawingArea widget is an empty widget that is easily adaptable to
X  a variety of purposes.  It does no drawing and defines no behavior
X  except for invoking callbacks.  Callbacks notify the application when
X  graphics need to be drawn (exposure events or widget resize) and when
X  the widget receives input from the keyboard or mouse.  Applications
X  are responsible for defining appearence and behavior as needed in
X  response to DrawingArea callbacks.
X
X
XClasses
X  DrawingArea inherits behavior and resources from the Core and Simple
X  classes.
X  The class pointer is DrawingAreaWidgetClass.  The class name is DrawingArea.
X
X
XNew Resources
X   Name		     	Class		RepType		Default Value
X   ----		     	-----		-------		-------------
X   exposeCallback	Callback	Pointer		NULL
X   inputCallback	Callback	Pointer		NULL
X   motionCallback	Callback	Pointer		NULL
X   resizeCallback	Callback	Pointer		NULL
X
X   XtNexposeCallback
X     Specifies list of callbacks that is called when DrawingArea recieves
X     an exposure event.  The callback reason is XawCR_EXPOSE.
X   XtNinputCallback
X     Specifies list of callbacks that is called when DrawingArea recieves
X     an keyboard or mouse event (key or button, up or down).  The callback 
X     reason is XawCR_INPUT.
X   XtNmotionCallback   
X     Specifies list of callbacks that is called when DrawingArea recieves
X     a mouse motion event.  The callback reason is XawCR_MOTION.
X   XtNresizeCallback
X     Specifies list of callbacks that is called when the DrawingArea is
X     resized.  The callback reason is XawCR_RESIZE.
X
X
XInherited Resources, Changed defaults
X   Name		     	Class		RepType		Default Value
X   ----		     	-----		-------		-------------
X   height		Height		Dimension	100
X   width		Width		Dimension	100
X
X
XCallback Information
X  A pointer to the following structure is returned with each callback.
X
X  typedef struct {
X    int	    reason;
X    XEvent *event;
X    Window  window;
X  } XawDrawingAreaCallbackStruct;
X
X  reason: Indicates why the callback was invoked
X  event:  Points to the XEvent that triggered the callback
X  window: Is set to the widget window
X
X
XBehavior
X <KeyDown>,<KeyUp>,<BtnDown>,<BtnUp>:
X   The callbacks for XtNinputCallback are called when a key or button is 
X   pressed or released.
X <Expose>:
X   The callbacks for XtNexposeCallbacks are called when the widget recieves
X   an exposure event.
X <Configure>:
X   The callbacks for XtNresizeCallbacks are called when the widget is resized.
X <Motion>:
X   The callbacks for XtNmotionCallbacks are called when the widget recieves a 
X   pointer motion event.
X
X
XDefault Translations
X  <BtnDown>:	input()
X  <BtnUp>:	input()
X  <KeyDown>:	input()
X  <KeyUp>:	input()
X  <Motion>:	motion()
X  <ResReq>:	resize()
X
X
XSEE ALSO
X  OSF/Motif Programmer's reference: XmDrawingArea
X    Open Software Foundation
X  Athena Widget Set - C Language Interface Rel 4: 3.6 Simple Widget
X    Chris D. Peterson
X  X Toolkit Intrinsics - C Language Interface
X    Joel McCormack, Paul Asenta, Ralph R. Swick
X  The X Window System, programming and Applications with Xt, OSF/Motif Edition
X    Douglas A. Young
X
X
XCOPYRIGHT
X  Copyright 1990, David Nedde
X 
X  Permission to use, copy, modify, and distribute this
X  software and its documentation for any purpose and without
X  fee is provided that the above copyright notice appears in all copies.
X  It is provided "as is" without express or implied warranty.
X
X
XAUTHOR
X  David Nedde, Computer Science Dept.		daven at maxine.wpi.edu
X  Worcester Polytechnic Institute		(508) 831-5117/5668
X  Worcester, MA 01609
END_OF_FILE
if test 4291 -ne `wc -c <'xrainbow/X11/Xaw_d/DrawingA.doc'`; then
    echo shar: \"'xrainbow/X11/Xaw_d/DrawingA.doc'\" unpacked with wrong size!
fi
# end of 'xrainbow/X11/Xaw_d/DrawingA.doc'
fi
if test -f 'xrainbow/include/Wc/WcCreate.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xrainbow/include/Wc/WcCreate.h'\"
else
echo shar: Extracting \"'xrainbow/include/Wc/WcCreate.h'\" \(7512 characters\)
sed "s/^X//" >'xrainbow/include/Wc/WcCreate.h' <<'END_OF_FILE'
X/*
X** Copyright (c) 1990 David E. Smyth
X**
X** This file was derived from work performed by Martin Brunecky at
X** Auto-trol Technology Corporation, Denver, Colorado, under the
X** following copyright:
X**
X*******************************************************************************
X* Copyright 1990 by Auto-trol Technology Corporation, Denver, Colorado.
X*
X*                        All Rights Reserved
X*
X* Permission to use, copy, modify, and distribute this software and its
X* documentation for any purpose and without fee is hereby granted, provided
X* that the above copyright notice appears on all copies and that both the
X* copyright and this permission notice appear in supporting documentation
X* and that the name of Auto-trol not be used in advertising or publicity
X* pertaining to distribution of the software without specific, prior written
X* permission.
X* 
X* Auto-trol disclaims all warranties with regard to this software, including
X* all implied warranties of merchantability and fitness, in no event shall
X* Auto-trol be liable for any special, indirect or consequential damages or
X* any damages whatsoever resulting from loss of use, data or profits, whether 
X* in an action of contract, negligence or other tortious action, arising out 
X* of or in connection with the use or performance of this software.
X*******************************************************************************
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* SCCS_data: @(#)WcCreate.h 1.1 ( 19 Nov 90 )
X*
X* Include_name:
X*
X*     WcCreate.h
X*
X* Subsystem_group:
X*
X*     Widget Creation Library
X*
X* Include_description:
X*
X*     Public defines for the Widget Creation Library supporting widget 
X*     tree creation from the Xrm database.
X*
X* Include_history:
X*
X*   mm/dd/yy  initials  action
X*   --------  --------  -------------------------------------------------------
X*   07/16/90   D.Smyth  added WcAllowDuplicate*Reg... decls
X*   06/30/90   R.Whitby added WcRegisterWcActions declaration
X*   06/19/90   D.Smyth  Widget Creation Library version 1.0 Release
X*   04/04/90   marbru   updated, added new callbacks
X*   03/27/90   marbru   updated for new names
X*   03/02/90   marbru   created
X*
X*******************************************************************************
X*/
X#ifndef _WcCreate_h
X#define _WcCreate_h
X
X/*
X#include <X11/IntrinsicP.h>
X#include <X11/CoreP.h>
X#include <X11/ObjectP.h>
X*/
X
X#ifdef FUNCTION_PROTOTYPES
X/****************************** ANSI FUNC DECLS ******************************/
X
X#define APP XtAppContext
X#define EV extern void
X#define EW extern Widget
X#define EC extern char*
X
X/* -- Widget class, constructor, and callback proc registration routines */
X
XEV WcRegisterClassPtr   (APP, char* name,   WidgetClass class);
XEV WcRegisterClassName  (APP, char* name,   WidgetClass class);
XEV WcRegisterConstructor(APP, char* name,   Widget(*constructor) () );
XEV WcRegisterCallback   (APP, char* CBname, XtCallbackProc, caddr_t defCliData);
XEV WcRegisterAction	(APP, char* name,   XtActionProc proc );
XEV WcRegisterWcCallbacks(APP );
X
X/* -- Allow duplicate registration of classes, constructors, and callbacks */
X
XEV WcAllowDuplicateRegistration   ( int allowed );
XEV WcAllowDuplicateClassPtrReg    ( int allowed );
XEV WcAllowDuplicateClassNameReg   ( int allowed );
XEV WcAllowDuplicateConstructorReg ( int allowed );
XEV WcAllowDuplicateCallbackReg    ( int allowed );
X
X/* -- Widget action registration routine */
X
XEV WcRegisterWcActions   ( APP );
X
X/* -- Widget creation routines */
X
XEV WcWidgetCreation      ( Widget root );
XEV WcCreateNamedChildren ( Widget parent, char* names );
XEV WcCreateNamedPopups   ( Widget parent, char* names );
XEW WcCreateDatabaseChild ( Widget parent, char* name, int* managed );
XEW WcCreateDatabasePopup ( Widget parent, char* name );
X
X/* -- Widget name routines 
X**	The character buffer returned by WcNamesToWidgetList contains the
X**	names which could not be converted to widgets.  This buffer is static,
X**	so its contents are changed everytime WcNamesToWidgetList is called.
X**	The character buffer returned by WcWidgetToFullName must be XtFree'd
X**	by the caller.
X*/
X
XEW WcChildNameToWidget ( Widget w, char* childName );
XEW WcFullNameToWidget  ( Widget w, char* name );
XEC WcNamesToWidgetList ( Widget, char* names, Widget widgetList[], int* count);
XEC WcWidgetToFullName  ( Widget w );
X
X/*  -- Useful for argument parsing */
X
XEC WcLowerCaseCopy        ( char* in );			/* caller frees buf */
XEC WcSkipWhitespace       ( char* cp );
XEC WcSkipWhitespace_Comma ( char* cp );
XEC WcCleanName            ( char* in, char* out );	/* out[] must exist */
XEC WcStripWhitespaceFromBothEnds (char* name );		/* caller frees buf */
X
XEC WcGetResourceType          ( Widget, char* rName );	/* caller frees buf */
XEV WcSetValueFromString       ( Widget, char* rName, char* rVal );
XEV WcSetValueFromStringAndType( Widget, char* rName, char* rVal, char* rType );
X
XEC WcStrStr( char* searchThis, char* forThisPattern );	/* like ANSI strstr */
X
X#undef APP
X#undef EV
X#undef EW
X#undef EC
X
X#else
X/**************************** NON-ANSI FUNC DECLS ****************************/
X
X/* -- Widget constructor registration routine */
X
Xextern void WcRegisterClassPtr    ();
Xextern void WcRegisterClassName   ();
Xextern void WcRegisterConstructor ();
Xextern void WcRegisterCallback    ();
Xextern void WcRegisterAction	  ();
Xextern void WcRegisterWcCallbacks ();
X
X/* -- Allow duplicate registration of classes, constructors, and callbacks */
X
Xextern void WcAllowDuplicateRegistration   ();
Xextern void WcAllowDuplicateClassPtrReg    ();
Xextern void WcAllowDuplicateClassNameReg   ();
Xextern void WcAllowDuplicateConstructorReg ();
Xextern void WcAllowDuplicateCallbackReg    ();
X
X/* -- Widget action registration routine */
X
Xextern void WcRegisterWcActions       ();
X
X/* -- Widget creation routines */
X
Xextern void   WcWidgetCreation     	();
Xextern void   WcCreateNamedChildren	();
Xextern void   WcCreateNamedPopups	();
Xextern Widget WcCreateDatabaseChild	();
Xextern Widget WcCreateDatabasePopup	();
X
X/* -- Widget name routine */
X
Xextern Widget WcChildNameToWidget	();
Xextern Widget WcFullNameToWidget	();
Xextern char*  WcNamesToWidgetList	();	/* rets: names not converted */
Xextern char*  WcWidgetToFullName	();	/* ret'd buff must be free'd */
X
Xextern char* WcLowerCaseCopy               ();	/* ret'd buff must be free'd */
Xextern char* WcSkipWhitespace              ();
Xextern char* WcSkipWhitespace_Comma        ();
Xextern char* WcCleanName                   ();
Xextern char* WcStripWhitespaceFromBothEnds ();	/* ret'd buff must be free'd */
X
Xextern char* WcGetResourceType             ();	/* ret'd buff must be free'd */
Xextern void  WcSetValueFromString          ();
Xextern void  WcSetValueFromStringAndType   ();
X
Xextern char* WcStrStr ();			/* same as ANSI strstr() */
X
X#endif /* FUNCTION_PROTOTYPES */
X
X#endif /* _WcCreate_h */
END_OF_FILE
if test 7512 -ne `wc -c <'xrainbow/include/Wc/WcCreate.h'`; then
    echo shar: \"'xrainbow/include/Wc/WcCreate.h'\" unpacked with wrong size!
fi
# end of 'xrainbow/include/Wc/WcCreate.h'
fi
echo shar: End of archive 4 \(of 5\).
cp /dev/null ark4isdone
MISSING=""
for I in 1 2 3 4 5 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 5 archives.
    echo "Please Read README"
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0

--
Dan Heller
O'Reilly && Associates       Z-Code Software    Comp-sources-x:
Senior Writer                President          comp-sources-x at uunet.uu.net
argv at ora.com                 argv at zipcode.com



More information about the Comp.sources.x mailing list