daven@maxine.WPI.EDU (Dave Nedde) (06/28/91)
Submitted-by: daven@maxine.WPI.EDU (Dave Nedde) Posting-number: Volume 13, Issue 67 Archive-name: xrainbow/part05 #! /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 5 (of 5)." # Contents: xrainbow/X11/Xaw_d/Makefile xrainbow/include/list.h # xrainbow/main/AriRegAll.c xrainbow/main/Imakefile # xrainbow/main/Makefile xrainbow/main/actions.c # xrainbow/main/callbacks.c xrainbow/main/color.c # xrainbow/main/list.c xrainbow/main/list.h xrainbow/main/misc.c # xrainbow/main/misc.h xrainbow/main/miscx.c # xrainbow/main/xrainbow.c # Wrapped by daven@ash on Mon Jun 3 12:33:25 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'xrainbow/X11/Xaw_d/Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xrainbow/X11/Xaw_d/Makefile'\" else echo shar: Extracting \"'xrainbow/X11/Xaw_d/Makefile'\" \(8387 characters\) sed "s/^X//" >'xrainbow/X11/Xaw_d/Makefile' <<'END_OF_FILE' X# Makefile generated by imake - do not edit! X# $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $ X# X# The cpp used on this machine replaces all newlines and multiple tabs and X# spaces in a macro expansion with a single space. Imake tries to compensate X# for this, but is not always successful. X# X X########################################################################### X# Makefile generated from "Imake.tmpl" and <Imakefile> X# $XConsortium: Imake.tmpl,v 1.77 89/12/18 17:01:37 jim Exp $ X# X# Platform-specific parameters may be set in the appropriate .cf X# configuration files. Site-wide parameters may be set in the file X# site.def. Full rebuilds are recommended if any parameters are changed. X# X# If your C preprocessor doesn't define any unique symbols, you'll need X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing X# "make Makefile", "make Makefiles", or "make World"). X# X# If you absolutely can't get imake to work, you'll need to set the X# variables at the top of each Makefile as well as the dependencies at the X# bottom (makedepend will do this automatically). X# X X########################################################################### X# platform-specific configuration parameters - edit sun.cf to change X X# platform: $XConsortium: sun.cf,v 1.38 89/12/23 16:10:10 jim Exp $ X# operating system: SunOS 4.1 X X########################################################################### X# site-specific configuration parameters - edit site.def to change X X# site: $XConsortium: site.def,v 1.21 89/12/06 11:46:50 jim Exp $ X X SHELL = /bin/sh X X TOP = ../../. X CURRENT_DIR = ./X11/Xaw_d X X AR = ar cq X BOOTSTRAPCFLAGS = X CC = cc X X COMPRESS = compress X CPP = /lib/cpp $(STD_CPP_DEFINES) X PREPROCESSCMD = cc -E $(STD_CPP_DEFINES) X INSTALL = install X LD = ld X LINT = lint X LINTLIBFLAG = -C X LINTOPTS = -axz X LN = ln -s X MAKE = make X MV = mv X CP = cp X RANLIB = ranlib X RANLIBINSTFLAGS = X RM = rm -f X STD_INCLUDES = X STD_CPP_DEFINES = X STD_DEFINES = X EXTRA_LOAD_FLAGS = X EXTRA_LIBRARIES = X TAGS = ctags X X SHAREDCODEDEF = -DSHAREDCODE X SHLIBDEF = -DSUNSHLIB X X PROTO_DEFINES = X X INSTPGMFLAGS = X X INSTBINFLAGS = -m 0755 X INSTUIDFLAGS = -m 4755 X INSTLIBFLAGS = -m 0664 X INSTINCFLAGS = -m 0444 X INSTMANFLAGS = -m 0444 X INSTDATFLAGS = -m 0444 X INSTKMEMFLAGS = -m 4755 X X DESTDIR = X X TOP_INCLUDES = -I$(INCROOT) X X CDEBUGFLAGS = -O X CCOPTIONS = X COMPATFLAGS = -DXAW_BC X X ALLINCLUDES = $(STD_INCLUDES) $(TOP_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES) X ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(DEFINES) $(COMPATFLAGS) X CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES) X LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES) X LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) X LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) X LDCOMBINEFLAGS = -X -r X X MACROFILE = sun.cf X RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut X X IMAKE_DEFINES = X X IRULESRC = $(CONFIGDIR) X IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES) X X ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \ X $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \ X $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES) X X########################################################################### X# X Window System Build Parameters X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $ X X########################################################################### X# X Window System make variables; this need to be coordinated with rules X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $ X X PATHSEP = / X USRLIBDIR = $(DESTDIR)/usr/lib X BINDIR = $(DESTDIR)/usr/bin/X11 X INCROOT = $(DESTDIR)/usr/include X BUILDINCROOT = $(TOP) X BUILDINCDIR = $(BUILDINCROOT)/X11 X BUILDINCTOP = .. X INCDIR = $(INCROOT)/X11 X ADMDIR = $(DESTDIR)/usr/adm X LIBDIR = $(USRLIBDIR)/X11 X CONFIGDIR = $(LIBDIR)/config X LINTLIBDIR = $(USRLIBDIR)/lint X X FONTDIR = $(LIBDIR)/fonts X XINITDIR = $(LIBDIR)/xinit X XDMDIR = $(LIBDIR)/xdm X AWMDIR = $(LIBDIR)/awm X TWMDIR = $(LIBDIR)/twm X GWMDIR = $(LIBDIR)/gwm X MANPATH = $(DESTDIR)/usr/man X MANSOURCEPATH = $(MANPATH)/man X MANDIR = $(MANSOURCEPATH)n X LIBMANDIR = $(MANSOURCEPATH)3 X XAPPLOADDIR = $(LIBDIR)/app-defaults X X SOXLIBREV = 4.2 X SOXTREV = 4.0 X SOXAWREV = 4.0 X SOOLDXREV = 4.0 X SOXMUREV = 4.0 X SOXEXTREV = 4.0 X X FONTCFLAGS = -t X X INSTAPPFLAGS = $(INSTDATFLAGS) X X IMAKE = imake X DEPEND = makedepend X RGB = rgb X FONTC = bdftosnf X MKFONTDIR = mkfontdir X MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier.sh X X CONFIGSRC = $(TOP)/config X CLIENTSRC = $(TOP)/clients X DEMOSRC = $(TOP)/demos X LIBSRC = $(TOP)/lib X FONTSRC = $(TOP)/fonts X INCLUDESRC = $(TOP)/X11 X SERVERSRC = $(TOP)/server X UTILSRC = $(TOP)/util X SCRIPTSRC = $(UTILSRC)/scripts X EXAMPLESRC = $(TOP)/examples X CONTRIBSRC = $(TOP)/../contrib X DOCSRC = $(TOP)/doc X RGBSRC = $(TOP)/rgb X DEPENDSRC = $(UTILSRC)/makedepend X IMAKESRC = $(CONFIGSRC) X XAUTHSRC = $(LIBSRC)/Xau X XLIBSRC = $(LIBSRC)/X X XMUSRC = $(LIBSRC)/Xmu X TOOLKITSRC = $(LIBSRC)/Xt X AWIDGETSRC = $(LIBSRC)/Xaw X OLDXLIBSRC = $(LIBSRC)/oldX X XDMCPLIBSRC = $(LIBSRC)/Xdmcp X BDFTOSNFSRC = $(FONTSRC)/bdftosnf X MKFONTDIRSRC = $(FONTSRC)/mkfontdir X EXTENSIONSRC = $(TOP)/extensions X X DEPEXTENSIONLIB = $(USRLIBDIR)/libXext.a X EXTENSIONLIB = -lXext X X DEPXLIB = $(DEPEXTENSIONLIB) X XLIB = $(EXTENSIONLIB) -lX11 X X DEPXAUTHLIB = $(USRLIBDIR)/libXau.a X XAUTHLIB = -lXau X X DEPXMULIB = X XMULIB = -lXmu X X DEPOLDXLIB = X OLDXLIB = -loldX X X DEPXTOOLLIB = X XTOOLLIB = -lXt X X DEPXAWLIB = X XAWLIB = -lXaw X X LINTEXTENSIONLIB = $(USRLIBDIR)/llib-lXext.ln X LINTXLIB = $(USRLIBDIR)/llib-lX11.ln X LINTXMU = $(USRLIBDIR)/llib-lXmu.ln X LINTXTOOL = $(USRLIBDIR)/llib-lXt.ln X LINTXAW = $(USRLIBDIR)/llib-lXaw.ln X X DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB) X X DEPLIBS1 = $(DEPLIBS) X DEPLIBS2 = $(DEPLIBS) X DEPLIBS3 = $(DEPLIBS) X X########################################################################### X# Imake rules for building libraries, programs, scripts, and data files X# rules: $XConsortium: Imake.rules,v 1.67 89/12/18 17:14:15 jim Exp $ X X########################################################################### X# start of Imakefile X X# X# Imakefile for Xaw_d : Dave Nedde (daven@wpi.wpi.edu) X# X X INCROOT = ../.. X SRCS = DrawingA.c X Xall:: libXaw_d.a X XlibXaw_d.a: DrawingA.o X $(RM) $@ X $(AR) $@ DrawingA.o X $(RANLIB) $@ X Xdepend:: X $(DEPEND) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS) X Xlintlib:: llib-lXaw_d.ln X Xllib-lXaw_d.ln: $(SRCS) X $(RM) $@ X $(LINT) $(LINTLIBFLAG)Xaw_d $(LINTFLAGS) $(SRCS) X X########################################################################### X# common rules for all Makefiles - do not edit X Xemptyrule:: X Xclean:: X $(RM_CMD) \#* X XMakefile:: X -@if [ -f Makefile ]; then \ X echo " $(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \ X $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \ X else exit 0; fi X $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR) X Xtags:: X $(TAGS) -w *.[ch] X $(TAGS) -xw *.[ch] > TAGS X X########################################################################### X# empty rules for directories that do not have SUBDIRS - do not edit X Xinstall:: X @echo "install in $(CURRENT_DIR) done" X Xinstall.man:: X @echo "install.man in $(CURRENT_DIR) done" X XMakefiles:: X Xincludes:: X X########################################################################### X# dependencies generated by makedepend X END_OF_FILE if test 8387 -ne `wc -c <'xrainbow/X11/Xaw_d/Makefile'`; then echo shar: \"'xrainbow/X11/Xaw_d/Makefile'\" unpacked with wrong size! fi # end of 'xrainbow/X11/Xaw_d/Makefile' fi if test -f 'xrainbow/include/list.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xrainbow/include/list.h'\" else echo shar: Extracting \"'xrainbow/include/list.h'\" \(2984 characters\) sed "s/^X//" >'xrainbow/include/list.h' <<'END_OF_FILE' X/********************************************************************** X * List.h - List data structures. X * X * David Nedde 11/21/89 X **********************************************************************/ X X#ifndef LIST_H X#define LIST_H X Xtypedef unsigned char bool; X X/* One node in the list */ Xtypedef struct list_node_struct list_node_type; Xstruct list_node_struct { X char *item_ptr; /* The data item hung off of the list */ X list_node_type *prev_node_ptr; /* Points to the prev node in the list */ X list_node_type *next_node_ptr; /* Points to the next node in the list */ X}; X X/* The list's head, tail, etc */ Xtypedef struct list_struct *list_type; Xstruct list_struct { X list_node_type *head_ptr; /* Points to the head of the list */ X list_node_type *next_ptr; /* Points to next item returned with list_next */ X list_node_type *curr_ptr; /* Points to curr item returned with list_next */ X list_node_type *tail_ptr; /* Points to the end of the list */ X}; X X#define TRUE 1 X#define FALSE 0 X X#ifndef NULL X#define NULL ((char *)0L) X#endif X X#define LIST_NULL ((list_type)NULL) X X#ifdef DEBUG X#define assert( condition, message) \ X { \ X if (!(condition)) \ X printf("List Error: File \"%s\", Line %d: %s", \ X __FILE__, __LINE__, message); \ X } X X#define LIST_TEST(list) /*list_test(list)*/ X#else X#define assert( condition, message) X#define LIST_TEST(list) X#endif X X X X#define ListMalloc(n) \ X (list_malloc(TRUE,(n)) == NULL \ X ? (char *)printf("List Error: File \"%s\", Line %d: Out of memory", \ X __FILE__,__LINE__) \ X : list_malloc(FALSE,(n))) X X X/********************************************************************** X * List of pointers handling routines X * X * List_Make - Create a list X * List_Add_End - Add to the end of the list X * List_Add_Start - Add to the start of the list X * List_Remove_Start - Remove first item from a list and return it X * List_First - Move to start of list and return first item X * List_Next - Return the next item in the list (NULL if eol) X * List_Last - Return last item in list X * List_Destroy - Deallocate the list but not the contents X * List_Deallocate - Deallocate everything in the list X * List_Dup_Node - Allocate a duplicate list node X * X * David Nedde 11/21/89 X **********************************************************************/ Xlist_type list_make(); Xchar *list_add_end(); Xchar *list_add_start(); Xchar *list_add_before_curr(); Xchar *list_add_sort(); Xchar *list_remove_start(); Xchar *list_remove_end(); Xchar *list_remove_curr(); Xchar *list_first(); Xchar *list_next(); Xchar *list_last(); Xvoid list_destroy(); Xvoid list_deallocate(); Xchar *list_dup_node(); Xchar *list_malloc(); Xint list_count(); X X#endif X END_OF_FILE if test 2984 -ne `wc -c <'xrainbow/include/list.h'`; then echo shar: \"'xrainbow/include/list.h'\" unpacked with wrong size! fi # end of 'xrainbow/include/list.h' fi if test -f 'xrainbow/main/AriRegAll.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xrainbow/main/AriRegAll.c'\" else echo shar: Extracting \"'xrainbow/main/AriRegAll.c'\" \(5207 characters\) sed "s/^X//" >'xrainbow/main/AriRegAll.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: @(#)AriRegAll.c 1.0 ( 19 June 1990 ) X* X* Subsystem_group: X* X* Widget Creation Library - Athena Resource Interpreter X* X* Module_description: X* X* This module contains registration routine for all Athena X* widget constructors and classes. X* X* Module_interface_summary: X* X* void AriRegisterAthena ( XtAppContext app ) X* X* Module_history: X* X* mm/dd/yy initials function action X* -------- -------- -------- --------------------------------------------- X* 06/19/90 D.Smyth all create. X* X* Design_notes: X* X******************************************************************************* X*/ X/* X******************************************************************************* X* Include_files. X******************************************************************************* X*/ X X#include <X11/Xatom.h> X#include <X11/Intrinsic.h> X#include <X11/StringDefs.h> X X#include <X11/Xaw/AsciiText.h> X#include <X11/Xaw/Command.h> X#include <X11/Xaw/Form.h> X#include <X11/Xaw/Label.h> X#include <X11/Xaw/List.h> X/*#include <X11/Xaw/MenuButton.h>*/ X/*#include <X11/Xaw/SimpleMenu.h>*/ X/*#include <X11/Xaw/SmeBSB.h>*/ X/*#include <X11/Xaw/Toggle.h>*/ X#include <X11/Xaw/Viewport.h> X/*#include <X11/Xaw/Scrollbar.h>*/ X/*#include <X11/Xaw/Box.h>*/ X/*#include <X11/Xaw/Clock.h>*/ X/*#include <X11/Xaw/Dialog.h>*/ X/*#include <X11/Xaw/Grip.h>*/ X/*#include <X11/Xaw/Logo.h>*/ X/*#include <X11/Xaw/SmeLine.h>*/ X/*#include <X11/Xaw/StripChart.h>*/ X#include <X11/Xaw/Paned.h> X X#include <X11/Xaw/Cardinals.h> X Xvoid AriRegisterAthena ( app ) X XtAppContext app; X{ X X#define RCN( name, class ) WcRegisterClassName ( app, name, class ); X#define RCP( name, class ) WcRegisterClassPtr ( app, name, class ); X X /* -- register all Athena widget classes */ X /* Simple Widgets (Chapt 3) */ X RCN("Command", commandWidgetClass ); X RCP("commandWidgetClass", commandWidgetClass ); X/* RCN("Grip", gripWidgetClass );*/ X/* RCP("gripWidgetClass", gripWidgetClass );*/ X RCN("Label", labelWidgetClass ); X RCP("labelWidgetClass", labelWidgetClass ); X RCN("List", listWidgetClass ); X RCP("listWidgetClass", listWidgetClass ); X/* RCN("Scrollbar", scrollbarWidgetClass );*/ X/* RCP("scrollbarWidgetClass", scrollbarWidgetClass );*/ X/* RCN("Simple", simpleWidgetClass );*/ X/* RCP("simpleWidgetClass", simpleWidgetClass );*/ X/* RCN("StripChart", stripChartWidgetClass );*/ X/* RCP("stripChartWidgetClass", stripChartWidgetClass );*/ X/* RCN("Toggle", toggleWidgetClass );*/ X/* RCP("toggleWidgetClass", toggleWidgetClass );*/ X X /* Menus (Chapt 4) */ X/* RCN("SimpleMenu", simpleMenuWidgetClass );*/ X/* RCP("simpleMenuWidgetClass", simpleMenuWidgetClass );*/ X/* RCN("SmeBSB", smeBSBObjectClass );*/ X/* RCP("smeBSBObjectClass", smeBSBObjectClass );*/ X/* RCN("SmeLine", smeLineObjectClass );*/ X/* RCP("smeLineObjectClass", smeLineObjectClass );*/ X/* RCN("Sme", smeObjectClass );*/ X/* RCP("smeObjectClass", smeObjectClass );*/ X/* RCN("MenuButton", menuButtonWidgetClass );*/ X/* RCP("menuButtonWidgetClass", menuButtonWidgetClass );*/ X X /* Text Widgets (Chapt 5) */ X RCN("AsciiText", asciiTextWidgetClass ); /* NB name */ X RCP("asciiTextWidgetClass", asciiTextWidgetClass ); X/* RCN("AsciiSrc", asciiSrcObjectClass );*/ X/* RCP("asciiSrcObjectClass", asciiSrcObjectClass );*/ X/* RCN("AsciiSink", asciiSinkObjectClass );*/ X/* RCP("asciiSinkObjectClass", asciiSinkObjectClass );*/ X/* RCN("Text", textWidgetClass );*/ X/* RCP("textWidgetClass", textWidgetClass );*/ X X /* Composite and Constraint Widgets (Chapt 6) */ X/* RCN("Box", boxWidgetClass );*/ X/* RCP("boxWidgetClass", boxWidgetClass );*/ X/* RCN("Dialog", dialogWidgetClass );*/ X/* RCP("dialogWidgetClass", dialogWidgetClass );*/ X RCN("Form", formWidgetClass ); X RCP("formWidgetClass", formWidgetClass ); X RCN("Paned", panedWidgetClass ); X RCP("panedWidgetClass", panedWidgetClass ); X RCN("Viewport", viewportWidgetClass ); X RCP("viewportWidgetClass", viewportWidgetClass ); X X /* Other Interestng Widgets (not in ref manual) */ X/* RCN("ClockWidget", clockWidgetClass );*/ X/* RCP("clockWidgetClass", clockWidgetClass );*/ X/* RCN("LogoWidget", logoWidgetClass );*/ X/* RCP("logoWidgetClass", logoWidgetClass );*/ X X#undef RCN X#undef RCP X} END_OF_FILE if test 5207 -ne `wc -c <'xrainbow/main/AriRegAll.c'`; then echo shar: \"'xrainbow/main/AriRegAll.c'\" unpacked with wrong size! fi # end of 'xrainbow/main/AriRegAll.c' fi if test -f 'xrainbow/main/Imakefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xrainbow/main/Imakefile'\" else echo shar: Extracting \"'xrainbow/main/Imakefile'\" \(1038 characters\) sed "s/^X//" >'xrainbow/main/Imakefile' <<'END_OF_FILE' X/**/# X/**/# Imakefile for XRainbow : Dave Nedde (daven@wpi.wpi.edu) X/**/# X X BASEDIR = .. X INCROOT = $(BASEDIR)/include X DEPXAW_DLIB = $(BASEDIR)/X11/Xaw_d/libXaw_d.a X DEPWCLIB = $(BASEDIR)/Wc1_05/Wc/libWc.a X XAW_DLIB = $(BASEDIR)/X11/Xaw_d/libXaw_d.a X WCLIB = $(BASEDIR)/Wc1_05/Wc/libWc.a X DEPLIBS = $(DEPXAW_DLIB) $(DEPWCLIB) \ X $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB) X LINTOPTS = -achz X DEFINES = -DRGB_TXT='"'DefaultRGBDatabase'.txt"' X X#ifdef UltrixArchitecture XLOCAL_LIBRARIES = $(DEPLIBS) X#else XLOCAL_LIBRARIES = $(WCLIB) $(XAW_DLIB) $(XAWLIB) \ X $(XMULIB) $(XTOOLLIB) $(XLIB) -L$(HOME)/lib /*-lmalloc */ X/**/#/usr/lib/debug/malloc.o X#endif X XSRCS = \ X AriRegAll.c \ X actions.c \ X callbacks.c \ X color.c \ X misc.c \ X miscx.c \ X list.c \ X xrainbow.c X XOBJS = \ X AriRegAll.o \ X actions.o \ X callbacks.o \ X color.o \ X misc.o \ X miscx.o \ X list.o \ X xrainbow.o X XComplexProgramTarget(xrainbow) X XInstallAppDefaults(xrainbow) X X Xdebug: X $(MAKE) 'CDEBUGFLAGS=-g' X END_OF_FILE if test 1038 -ne `wc -c <'xrainbow/main/Imakefile'`; then echo shar: \"'xrainbow/main/Imakefile'\" unpacked with wrong size! fi # end of 'xrainbow/main/Imakefile' fi if test -f 'xrainbow/main/Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xrainbow/main/Makefile'\" else echo shar: Extracting \"'xrainbow/main/Makefile'\" \(9477 characters\) sed "s/^X//" >'xrainbow/main/Makefile' <<'END_OF_FILE' X# Makefile generated by imake - do not edit! X# $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $ X# X# The cpp used on this machine replaces all newlines and multiple tabs and X# spaces in a macro expansion with a single space. Imake tries to compensate X# for this, but is not always successful. X# X X########################################################################### X# Makefile generated from "Imake.tmpl" and <Imakefile> X# $XConsortium: Imake.tmpl,v 1.77 89/12/18 17:01:37 jim Exp $ X# X# Platform-specific parameters may be set in the appropriate .cf X# configuration files. Site-wide parameters may be set in the file X# site.def. Full rebuilds are recommended if any parameters are changed. X# X# If your C preprocessor doesn't define any unique symbols, you'll need X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing X# "make Makefile", "make Makefiles", or "make World"). X# X# If you absolutely can't get imake to work, you'll need to set the X# variables at the top of each Makefile as well as the dependencies at the X# bottom (makedepend will do this automatically). X# X X########################################################################### X# platform-specific configuration parameters - edit sun.cf to change X X# platform: $XConsortium: sun.cf,v 1.38 89/12/23 16:10:10 jim Exp $ X# operating system: SunOS 4.1 X X########################################################################### X# site-specific configuration parameters - edit site.def to change X X# site: $XConsortium: site.def,v 1.21 89/12/06 11:46:50 jim Exp $ X X SHELL = /bin/sh X X TOP = ../. X CURRENT_DIR = ./main X X AR = ar cq X BOOTSTRAPCFLAGS = X CC = cc X X COMPRESS = compress X CPP = /lib/cpp $(STD_CPP_DEFINES) X PREPROCESSCMD = cc -E $(STD_CPP_DEFINES) X INSTALL = install X LD = ld X LINT = lint X LINTLIBFLAG = -C X LINTOPTS = -axz X LN = ln -s X MAKE = make X MV = mv X CP = cp X RANLIB = ranlib X RANLIBINSTFLAGS = X RM = rm -f X STD_INCLUDES = X STD_CPP_DEFINES = X STD_DEFINES = X EXTRA_LOAD_FLAGS = X EXTRA_LIBRARIES = X TAGS = ctags X X SHAREDCODEDEF = -DSHAREDCODE X SHLIBDEF = -DSUNSHLIB X X PROTO_DEFINES = X X INSTPGMFLAGS = X X INSTBINFLAGS = -m 0755 X INSTUIDFLAGS = -m 4755 X INSTLIBFLAGS = -m 0664 X INSTINCFLAGS = -m 0444 X INSTMANFLAGS = -m 0444 X INSTDATFLAGS = -m 0444 X INSTKMEMFLAGS = -m 4755 X X DESTDIR = X X TOP_INCLUDES = -I$(INCROOT) X X CDEBUGFLAGS = -O X CCOPTIONS = X COMPATFLAGS = -DXAW_BC X X ALLINCLUDES = $(STD_INCLUDES) $(TOP_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES) X ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(DEFINES) $(COMPATFLAGS) X CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES) X LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES) X LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) X LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) X LDCOMBINEFLAGS = -X -r X X MACROFILE = sun.cf X RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut X X IMAKE_DEFINES = X X IRULESRC = $(CONFIGDIR) X IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES) X X ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \ X $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \ X $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES) X X########################################################################### X# X Window System Build Parameters X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $ X X########################################################################### X# X Window System make variables; this need to be coordinated with rules X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $ X X PATHSEP = / X USRLIBDIR = $(DESTDIR)/usr/lib X BINDIR = $(DESTDIR)/usr/bin/X11 X INCROOT = $(DESTDIR)/usr/include X BUILDINCROOT = $(TOP) X BUILDINCDIR = $(BUILDINCROOT)/X11 X BUILDINCTOP = .. X INCDIR = $(INCROOT)/X11 X ADMDIR = $(DESTDIR)/usr/adm X LIBDIR = $(USRLIBDIR)/X11 X CONFIGDIR = $(LIBDIR)/config X LINTLIBDIR = $(USRLIBDIR)/lint X X FONTDIR = $(LIBDIR)/fonts X XINITDIR = $(LIBDIR)/xinit X XDMDIR = $(LIBDIR)/xdm X AWMDIR = $(LIBDIR)/awm X TWMDIR = $(LIBDIR)/twm X GWMDIR = $(LIBDIR)/gwm X MANPATH = $(DESTDIR)/usr/man X MANSOURCEPATH = $(MANPATH)/man X MANDIR = $(MANSOURCEPATH)n X LIBMANDIR = $(MANSOURCEPATH)3 X XAPPLOADDIR = $(LIBDIR)/app-defaults X X SOXLIBREV = 4.2 X SOXTREV = 4.0 X SOXAWREV = 4.0 X SOOLDXREV = 4.0 X SOXMUREV = 4.0 X SOXEXTREV = 4.0 X X FONTCFLAGS = -t X X INSTAPPFLAGS = $(INSTDATFLAGS) X X IMAKE = imake X DEPEND = makedepend X RGB = rgb X FONTC = bdftosnf X MKFONTDIR = mkfontdir X MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier.sh X X CONFIGSRC = $(TOP)/config X CLIENTSRC = $(TOP)/clients X DEMOSRC = $(TOP)/demos X LIBSRC = $(TOP)/lib X FONTSRC = $(TOP)/fonts X INCLUDESRC = $(TOP)/X11 X SERVERSRC = $(TOP)/server X UTILSRC = $(TOP)/util X SCRIPTSRC = $(UTILSRC)/scripts X EXAMPLESRC = $(TOP)/examples X CONTRIBSRC = $(TOP)/../contrib X DOCSRC = $(TOP)/doc X RGBSRC = $(TOP)/rgb X DEPENDSRC = $(UTILSRC)/makedepend X IMAKESRC = $(CONFIGSRC) X XAUTHSRC = $(LIBSRC)/Xau X XLIBSRC = $(LIBSRC)/X X XMUSRC = $(LIBSRC)/Xmu X TOOLKITSRC = $(LIBSRC)/Xt X AWIDGETSRC = $(LIBSRC)/Xaw X OLDXLIBSRC = $(LIBSRC)/oldX X XDMCPLIBSRC = $(LIBSRC)/Xdmcp X BDFTOSNFSRC = $(FONTSRC)/bdftosnf X MKFONTDIRSRC = $(FONTSRC)/mkfontdir X EXTENSIONSRC = $(TOP)/extensions X X DEPEXTENSIONLIB = $(USRLIBDIR)/libXext.a X EXTENSIONLIB = -lXext X X DEPXLIB = $(DEPEXTENSIONLIB) X XLIB = $(EXTENSIONLIB) -lX11 X X DEPXAUTHLIB = $(USRLIBDIR)/libXau.a X XAUTHLIB = -lXau X X DEPXMULIB = X XMULIB = -lXmu X X DEPOLDXLIB = X OLDXLIB = -loldX X X DEPXTOOLLIB = X XTOOLLIB = -lXt X X DEPXAWLIB = X XAWLIB = -lXaw X X LINTEXTENSIONLIB = $(USRLIBDIR)/llib-lXext.ln X LINTXLIB = $(USRLIBDIR)/llib-lX11.ln X LINTXMU = $(USRLIBDIR)/llib-lXmu.ln X LINTXTOOL = $(USRLIBDIR)/llib-lXt.ln X LINTXAW = $(USRLIBDIR)/llib-lXaw.ln X X DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB) X X DEPLIBS1 = $(DEPLIBS) X DEPLIBS2 = $(DEPLIBS) X DEPLIBS3 = $(DEPLIBS) X X########################################################################### X# Imake rules for building libraries, programs, scripts, and data files X# rules: $XConsortium: Imake.rules,v 1.67 89/12/18 17:14:15 jim Exp $ X X########################################################################### X# start of Imakefile X X# X# Imakefile for XRainbow : Dave Nedde (daven@wpi.wpi.edu) X# X X BASEDIR = .. X INCROOT = $(BASEDIR)/include X DEPXAW_DLIB = $(BASEDIR)/X11/Xaw_d/libXaw_d.a X DEPWCLIB = $(BASEDIR)/Wc1_05/Wc/libWc.a X XAW_DLIB = $(BASEDIR)/X11/Xaw_d/libXaw_d.a X WCLIB = $(BASEDIR)/Wc1_05/Wc/libWc.a X DEPLIBS = $(DEPXAW_DLIB) $(DEPWCLIB) \ X $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB) X LINTOPTS = -achz X DEFINES = -DRGB_TXT='"'$(LIBDIR)/rgb'.txt"' X XLOCAL_LIBRARIES = $(WCLIB) $(XAW_DLIB) $(XAWLIB) \ X $(XMULIB) $(XTOOLLIB) $(XLIB) -L$(HOME)/lib X#/usr/lib/debug/malloc.o X XSRCS = \ X AriRegAll.c \ X actions.c \ X callbacks.c \ X color.c \ X misc.c \ X miscx.c \ X list.c \ X xrainbow.c X XOBJS = \ X AriRegAll.o \ X actions.o \ X callbacks.o \ X color.o \ X misc.o \ X miscx.o \ X list.o \ X xrainbow.o X X PROGRAM = xrainbow X Xall:: xrainbow X Xxrainbow: $(OBJS) $(DEPLIBS) X $(RM) $@ X $(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS) X Xinstall:: xrainbow X $(INSTALL) -c $(INSTPGMFLAGS) xrainbow $(BINDIR) X Xinstall.man:: xrainbow.man X $(INSTALL) -c $(INSTMANFLAGS) xrainbow.man $(MANDIR)/xrainbow.n X Xdepend:: X $(DEPEND) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS) X Xlint: X $(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS) Xlint1: X $(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS) X Xclean:: X $(RM) $(PROGRAM) X Xinstall:: xrainbow.ad X $(INSTALL) -c $(INSTAPPFLAGS) xrainbow.ad $(XAPPLOADDIR)/xrainbow X Xdebug: X $(MAKE) 'CDEBUGFLAGS=-g' X X########################################################################### X# common rules for all Makefiles - do not edit X Xemptyrule:: X Xclean:: X $(RM_CMD) \#* X XMakefile:: X -@if [ -f Makefile ]; then \ X echo " $(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \ X $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \ X else exit 0; fi X $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR) X Xtags:: X $(TAGS) -w *.[ch] X $(TAGS) -xw *.[ch] > TAGS X X########################################################################### X# empty rules for directories that do not have SUBDIRS - do not edit X Xinstall:: X @echo "install in $(CURRENT_DIR) done" X Xinstall.man:: X @echo "install.man in $(CURRENT_DIR) done" X XMakefiles:: X Xincludes:: X X########################################################################### X# dependencies generated by makedepend X END_OF_FILE if test 9477 -ne `wc -c <'xrainbow/main/Makefile'`; then echo shar: \"'xrainbow/main/Makefile'\" unpacked with wrong size! fi # end of 'xrainbow/main/Makefile' fi if test -f 'xrainbow/main/actions.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xrainbow/main/actions.c'\" else echo shar: Extracting \"'xrainbow/main/actions.c'\" \(6153 characters\) sed "s/^X//" >'xrainbow/main/actions.c' <<'END_OF_FILE' X/********************************************************************** X * Actions.c - Handle widget actions X * X * EndAsciiValAction - An action that checks and sets the specified value. X * set_ascii_widget_var - Set a value in an ascii widget and associated var X * get_ascii_widget_value - Checks and sets a double value from a text widget X * set_ascii_widget_value - Sets an ascii widget's value given a double X * set_ascii_text - Set an ascii text widget to the passed string X * X * Copyright 1991, David Nedde X * X * Permission to use, copy, modify, and distribute this software X * and its documentation for any purpose and without fee is granted X * provided that the above copyright notice appears in all copies. X * It is provided "as is" without express or implied warranty. X **********************************************************************/ X#include <stdio.h> X#include <errno.h> X#include <X11/Xlib.h> X#include <X11/Intrinsic.h> X#include <X11/StringDefs.h> X#include <X11/Xutil.h> X#include <X11/Xaw/Form.h> X#include <X11/Xaw/AsciiText.h> X#include <Wc/WcCreate.h> X#include "misc.h" X X X#define NC(x,mess) \ X{ \ X if ((x) == NULL) \ X fprintf("XRainbow: System error: %s\n",mess); \ X} X X/* The intensity ratios - allocated in color.c */ Xextern double red_intensity,green_intensity,blue_intensity; X X X X/********************************************************************** X * void EndAsciiValAction(w,event,params,num_params) X * X * An action that checks and sets the specified value. X * X * Resource file syntax: X * EndAsciiValAction(ascii_widget_name) X **********************************************************************/ Xvoid EndAsciiValAction(w,event,params,num_params) XWidget w; XXEvent *event; XString *params; XCardinal *num_params; X{ X double strtod(); X X X if (*num_params != 1) X { X fprintf(stderr,"XRainbow: Resource file error: Invalid number of params passed to EndAsciiValAction\n"); X return; X } X X if (!strcmp(params[0],"red_value")) X get_ascii_widget_value(w,"red_value","Red",0,1, X &red_intensity); X else X if (!strcmp(params[0],"green_value")) X get_ascii_widget_value(w,"green_value","Green",0,1, X &green_intensity); X else X if (!strcmp(params[0],"blue_value")) X get_ascii_widget_value(w,"blue_value","Blue",0,1, X &blue_intensity); X else X fprintf(stderr,"XRainbow: Resource file error:\n\tInvalid widget name '%s' passed to EndAsciiValAction\n", X params[0]); X} X X X X/********************************************************************** X * set_ascii_widget_var X * X * Set a value in an ascii widget and it's associated variable X **********************************************************************/ Xset_ascii_widget_var(w,var_name,value) XWidget w; Xchar *var_name; Xdouble value; X{ X XEvent event; X char *params[1]; X static Cardinal num_params = 1; X X X /* Set the value in the ascii widget */ X set_ascii_widget_value(w,var_name,value); X X params[0] = var_name; X EndAsciiValAction(w,&event/*ignored*/,params,&num_params); X} X X X X/********************************************************************** X * void get_ascii_widget_value(w,event,params,num_params) X * X * Checks and sets an integer value from a text widget X * X * Resource file syntax: X * AsciiToIntAction(Ascii-widget-name,value's-name,lower-limit,upper-limit) X * X **********************************************************************/ Xget_ascii_widget_value(w,widget_name,values_name, X lower_limit,upper_limit,val_ptr) XWidget w; Xchar *widget_name; Xchar *values_name; Xint lower_limit; Xint upper_limit; Xdouble *val_ptr; X{ X Widget value_w; /* The ascii widget */ X char *answer; /* The string typed in an ascii value */ X double temp_num; /* Holds new value while validity checked */ X char *cptr; X int n; X Arg wargs[3]; X X X NC(value_w = WcFullNameToWidget(w,format_static("*%s",widget_name)), X format_static("Finding %s widget",widget_name)); X X /* Get filter string */ X n = 0; X XtSetArg(wargs[n],XtNstring,&answer); n++; X XtGetValues(value_w,wargs,n); X X /* Copy the answer since we will edit textSrc and change it's value */ X answer = XtNewString(answer); X temp_num = strtod(answer,&cptr); X X if (cptr == answer) X { X /* First character was invalid */ X printf("Bad %s number format: Enter valid number\n",values_name); X XtFree(answer); X set_ascii_widget_value(value_w,widget_name,*val_ptr); /* Reset answer */ X return; X } X X if (*cptr != '\0') X { X /* An invalid character was found */ X printf("Invalid trailing string '%s' ignored\n",cptr); X /* Set to value without trailing junk */ X set_ascii_widget_value(value_w,widget_name,temp_num); X } X X if (temp_num < lower_limit || temp_num > upper_limit) X { X printf("%s (%g) out of range (%d - %d); Enter number in range\n", X values_name,temp_num,lower_limit,upper_limit); X set_ascii_widget_value(value_w,widget_name,*val_ptr); /* Reset value */ X return; X } X *val_ptr = temp_num; /* Set requested value */ X X XtFree(answer); X} X X X X/********************************************************************** X * set_ascii_widget_value X * X * Sets an ascii widget's value to the ascii representation of the passed X * integer and puts the cursor at the end of the text X **********************************************************************/ Xset_ascii_widget_value(w,widget_name,value) XWidget w; Xchar *widget_name; Xdouble value; X{ X Widget ascii_w; X X X if ((ascii_w = WcFullNameToWidget(w,format_static("*%s",widget_name))) == NULL) X fprintf(stderr,"XSauci: Resource file error: Cannot find %s widget\n",widget_name); X X set_ascii_text(ascii_w,format_static("%g",value)); X} X X X X/********************************************************************** X * set_ascii_text X * X * Set an ascii text widget to the passed string and put the cursor at X * the end of the string. X **********************************************************************/ Xset_ascii_text(w,string) XWidget w; Xchar *string; X{ X int n; X Arg wargs[2]; X X X n = 0; X XtSetArg(wargs[n],XtNstring,string); n++; X XtSetValues(w,wargs,n); X X /* Move cursor to end of path name */ X XawTextSetInsertionPoint(w,strlen(string)); X} END_OF_FILE if test 6153 -ne `wc -c <'xrainbow/main/actions.c'`; then echo shar: \"'xrainbow/main/actions.c'\" unpacked with wrong size! fi # end of 'xrainbow/main/actions.c' fi if test -f 'xrainbow/main/callbacks.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xrainbow/main/callbacks.c'\" else echo shar: Extracting \"'xrainbow/main/callbacks.c'\" \(3336 characters\) sed "s/^X//" >'xrainbow/main/callbacks.c' <<'END_OF_FILE' X/********************************************************************** X * Callbacks.c - Handle widget callbacks X * X * setup_lists - Used to initialize the option and value lists at startup X * list_callback - Moves items between the sort options and sort values lists X * X * Copyright 1991, David Nedde X * X * Permission to use, copy, modify, and distribute this software X * and its documentation for any purpose and without fee is granted X * provided that the above copyright notice appears in all copies. X * It is provided "as is" without express or implied warranty. X **********************************************************************/ X#include <stdio.h> X#include <X11/Intrinsic.h> X#include <X11/StringDefs.h> X#include <X11/Xaw/List.h> X#include <X11/Xaw_d/DrawingA.h> X#include <Wc/WcCreate.h> X X XWidget WcFullNameToWidget(); X#define NC(x,mess) \ X{ \ X if ((x) == NULL) \ X fprintf("XRainbow: System error: %s\n",mess); \ X} X X X/* Holds sort keys available and sort keys used */ XString sort_options[7] = { "File Order", "Intensity ", "Name ", X "Red ", "Blue ", "Green ", NULL }; XString sort_values[7] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL }; X X X X/********************************************************************** X * setup_lists X * X * Used to initialize the option and value lists at runtime startup X **********************************************************************/ Xvoid setup_lists(w, side, call_data) XWidget w; Xchar *side; Xcaddr_t call_data; X{ X if (strcmp(side,"left") == 0) X XawListChange(w,sort_options,0,0,True); X else X XawListChange(w,sort_values,0,0,True); X} X X X/********************************************************************** X * list_callback X * X * Moves items between the sort options and sort values lists when they X * are selected. X **********************************************************************/ Xvoid list_callback(w, side, call_data) XWidget w; Xchar *side; XXawListReturnStruct *call_data; X{ X int x; X Widget left_w,right_w; X X X if (strcmp(side,"left") == 0) X { X /* Left widget callback */ X left_w = w; X NC(right_w = WcFullNameToWidget(w,"*right_list"), X "Cannot find right_list"); X /* Move from left to right list */ X /* Find first non-null in sort_values to put the selected string */ X for (x = 0; sort_values[x] != NULL; x++) X ; X X /* Store selected left item into right list */ X sort_values[x] = sort_options[call_data->list_index]; X /* Remove item from left list */ X for (x = call_data->list_index; sort_options[x] != NULL; x++) X sort_options[x] = sort_options[x+1]; X } X else X { X /* Right widget callback */ X right_w = w; X NC(left_w = WcFullNameToWidget(w,"*left_list"), X "Cannot find left_list"); X /* Move from right to left list */ X /* Find first non-null in sort_options to put the selected string */ X for (x = 0; sort_options[x] != NULL; x++) X ; X X /* Store selected left item into right list */ X sort_options[x] = sort_values[call_data->list_index]; X /* Remove item from left list */ X for (x = call_data->list_index; sort_values[x] != NULL; x++) X sort_values[x] = sort_values[x+1]; X } X X /* Update the lists' display, etc */ X XawListChange(left_w,sort_options,0,0,True); X XawListChange(right_w,sort_values,0,0,True); X} END_OF_FILE if test 3336 -ne `wc -c <'xrainbow/main/callbacks.c'`; then echo shar: \"'xrainbow/main/callbacks.c'\" unpacked with wrong size! fi # end of 'xrainbow/main/callbacks.c' fi if test -f 'xrainbow/main/color.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xrainbow/main/color.c'\" else echo shar: Extracting \"'xrainbow/main/color.c'\" \(13948 characters\) sed "s/^X//" >'xrainbow/main/color.c' <<'END_OF_FILE' X/********************************************************************** X * Color.c - Handle creating and displaying the colored widgets X * X * init_colors - Setup sys_colors, color_count, colormap, gc, widgets X * init_widgets - Create widgets to hold the color and color name X * color_expose - A callback for when a drawing area widget is exposed X * compare_colors - Returns an ordering between 2 colors based on sort_values X * resort_list - Sort sys_colors and redraw widgets based on new ordering. X * X * Copyright 1991, David Nedde X * X * Permission to use, copy, modify, and distribute this software X * and its documentation for any purpose and without fee is granted X * provided that the above copyright notice appears in all copies. X * It is provided "as is" without express or implied warranty. X **********************************************************************/ X#include <stdio.h> X#include <X11/Xos.h> X#include <X11/Intrinsic.h> X#include <X11/StringDefs.h> X#include <X11/Xaw_d/DrawingA.h> X#include <X11/Xaw/Label.h> X#include <X11/Xaw/Form.h> X#include <Wc/WcCreate.h> X#include <list.h> X#include "misc.h" X#include "patchlevel.h" X X X#ifndef RGB_TXT /* The file holding the rgb values */ X#define RGB_TXT "/usr/lib/X11/rgb.txt" X#endif X#define NC(x,mess) \ X{ \ X if ((x) == NULL) \ X fprintf("XRainbow: System error: %s\n",mess); \ X} X#define NUM_COLORS 50 /* Number of unique colors that can be displayed */ X#define NULL_PIXEL 300 /* Used to flag invalid pixel values */ X X/* Holds one rgb.txt color entry */ Xtypedef struct { X char colorname[50]; /* Name of the color */ X XColor color; /* r,g,b and pixel values */ X int file_seq; /* The order in rgb.txt the entry was stored */ X int seq; /* The number index the entry is */ X} sys_color_type; X Xstatic sys_color_type **sys_colors; /* Holds all rgb.txt colors */ Xstatic int color_count; /* Number of sys_colors */ Xextern String sort_values[]; /* The keys to sort on (callbacks.c) */ Xlist_type queue; /* Holds the allocated pixel values */ XGC gc; /* Global GC */ XColormap cmap; /* Global colormap */ Xint monochrome; /* True if on a mono screen */ Xdouble red_intensity; /* Color intensity ratios */ Xdouble green_intensity; Xdouble blue_intensity; X Xvoid color_expose(); /* Callback color box exposure */ XWidget WcFullNameToWidget(); Xchar *malloc(); X X X X/********************************************************************** X * init_colors X * X * Setup sys_colors, color_count, colormap, gc, widgets X **********************************************************************/ Xinit_colors(w,passed_file_name) XWidget w; Xchar *passed_file_name; X{ X Display *d = XtDisplay(w); X int x; X FILE *rgb; X int prev_r,prev_g,prev_b; /* Used to avoid dup. entries */ X int r,g,b; X char colorname[50]; X char filename[50]; X X X if (sys_colors == (sys_color_type **)0) X { X cmap = DefaultColormap(d,DefaultScreen(d)); X gc = XCreateGC(XtDisplay(w), DefaultRootWindow(XtDisplay(w)), 0, 0); X monochrome = DisplayCells(XtDisplay(w), X DefaultScreen(XtDisplay(w))) == 2; X queue = list_make(); X X /* Determine file to load */ X if (passed_file_name == (char *)0 || *passed_file_name == '\0') X strcpy(filename,RGB_TXT); X else X strcpy(filename,passed_file_name); X X X /*** Find the number of system colors */ X if (!(rgb = fopen(filename, "r"))) { X perror(filename); X exit(1); X } X color_count = 0; X prev_r = prev_g = prev_b = -1; X while (4 == fscanf(rgb, "%d %d %d %[^\n]\n", &r, &g, &b, colorname)) { X if (r != prev_r || g != prev_g || b != prev_b) { X prev_r = r; X prev_g = g; X prev_b = b; X color_count++; X } X } X X /*** We have the number of entries - allocate space and load them in */ X rewind(rgb); X X NC(sys_colors = (sys_color_type **)malloc(sizeof(sys_color_type *)* X color_count), X "Out of memory in init_colors"); X X prev_r = prev_g = prev_b = -1; X for (x = 0; x < color_count;) X { X NC(sys_colors[x] = (sys_color_type *)malloc(sizeof(sys_color_type)), X "Out of memory in init_colors"); X X fscanf(rgb, "%d %d %d %[^\n]\n", &r, &g, &b, sys_colors[x]->colorname); X if (r != prev_r || g != prev_g || b != prev_b) { X prev_r = r; X prev_g = g; X prev_b = b; X sys_colors[x]->color.red = r*(65535.0/255); /* Convert 0..255 */ X sys_colors[x]->color.green = g*(65535.0/255); /* to 0..65535 */ X sys_colors[x]->color.blue = b*(65535.0/255); X sys_colors[x]->file_seq = x; /* Location in file */ X sys_colors[x]->seq = x; /* Location in array */ X sys_colors[x]->color.pixel = NULL_PIXEL; X sys_colors[x]->color.flags = DoRed|DoGreen|DoBlue; X x++; X } X } X X init_widgets(w); /* Create all the color widgets */ X X } X} X X X X/********************************************************************** X * init_widgets X * X * Create widgets to hold the color and color name X **********************************************************************/ Xinit_widgets(w) XWidget w; X{ X Widget prev_form_w = (Widget)0; X Widget a_form_w; /* Holds all color widgets */ X Widget form_w; /* Temp for the the form widgets */ X Widget drawinga_w; /* Temp for the color drawee widgets */ X Widget label_w; /* Temp for the color name widgets */ X Dimension label_height = 1; /* Height of the label widget */ X /* Set to 1 so it is flagged and fixed */ X int x; X int n; X Arg wargs[10]; X char temp_str[50]; X X X /* Initialize the intensity ratios */ X set_ascii_widget_var(w,"red_value",.33); X set_ascii_widget_var(w,"green_value",.33); X set_ascii_widget_var(w,"blue_value",.33); X X label_w = WcFullNameToWidget(w,"*about1"); X sprintf(temp_str,"XRainbow V1.%d",PATCHLEVEL); X n = 0; X XtSetArg(wargs[n],XtNlabel,temp_str); n++; X XtSetValues(label_w,wargs,n); X X NC(a_form_w = WcFullNameToWidget(w,"*aform"),"Finding aform widget"); X X /* Create all widgets in the list */ X for (x = 0; x < color_count; x++) X { X /* Create a form widget holding a drwingArea and label widget */ X n = 0; X if (prev_form_w != (Widget)0) X XtSetArg(wargs[n],XtNfromVert,prev_form_w); n++; X form_w = XtCreateManagedWidget(format_static("form%d",x), X formWidgetClass, a_form_w, wargs, n); X prev_form_w = form_w; X X /* Create a drawingArea widget the same height as the label widget */ X n = 0; X XtSetArg(wargs[n],XtNheight,label_height); n++; X drawinga_w = XtCreateManagedWidget(format_static("drawinga%d",x), X drawingAreaWidgetClass, X form_w, wargs, n); X XtAddCallback(drawinga_w,XtNexposeCallback,color_expose, X &sys_colors[x]->seq); X X /* Create a label widget that holds the color's name */ X n = 0; X XtSetArg(wargs[n],XtNlabel,format_static("(%d,%d,%d) %s", X (int)(sys_colors[x]->color.red*(255.0/65535)), X (int)(sys_colors[x]->color.green*(255.0/65535)), X (int)(sys_colors[x]->color.blue*(255.0/65535)), X sys_colors[x]->colorname)); X n++; X XtSetArg(wargs[n],XtNfromHoriz,drawinga_w); n++; X label_w = XtCreateManagedWidget(format_static("label%d",x), X labelWidgetClass, form_w, wargs, n); X X if (label_height == 1) X { X /* Set the label_height variable to it's correct value */ X n = 0; X XtSetArg(wargs[n],XtNheight,&label_height); n++; X XtGetValues(label_w,wargs,n); X X /* Fix up the first canvas which incorrectly has height 1 */ X n = 0; X XtSetArg(wargs[n],XtNheight,label_height); n++; X XtSetValues(drawinga_w,wargs,n); X } X } X} X X X X/********************************************************************** X * color_expose X * X * A callback for when a drawing area widget is exposed X **********************************************************************/ Xvoid color_expose(w, color_index_ptr, call_data) XWidget w; Xint *color_index_ptr; XXawDrawingAreaCallbackStruct *call_data; X{ X int color_index= *color_index_ptr; /* Where in sys_colors */ X sys_color_type *unexposed_color; /* Holds color that is covered */ X XExposeEvent *xexpose; X X X if (sys_colors[color_index]->color.pixel == NULL_PIXEL) X /* The exposed drawingArea doesn't have a valid pixel -- get one */ X if (list_count(queue) >= NUM_COLORS) X { X /* Queue of pixels is full -- Use the pixel at the front of the queue X /* since it must be covered by now */ X unexposed_color = (sys_color_type *)list_remove_start(queue); X sys_colors[color_index]->color.pixel = unexposed_color->color.pixel; X unexposed_color->color.pixel = NULL_PIXEL; X list_add_end(sys_colors[color_index],queue); X } X else X { X /* Well, if queue not full, we must be just starting. */ X /* allocate the color cell ourself. */ X if (!monochrome) X { X if (!XAllocColorCells(XtDisplay(w), cmap, TRUE, NULL, 0, X &sys_colors[color_index]->color.pixel, 1)) X { X fprintf(stderr,"XRainbow: Cannot allocate color cells\n"); X exit(1); X } X } X else X { X /* Just make every color black */ X sys_colors[color_index]->color.pixel = X BlackPixel(XtDisplay(w),DefaultScreen(XtDisplay(w))); X } X /* Put ourself in the queue */ X list_add_end(sys_colors[color_index],queue); X } X X /* Now we have a good pixel value -- redraw the exposed area */ X if (!monochrome) X#if 1 X XStoreColor(XtDisplay(w),cmap,&(sys_colors[color_index]->color)); X#else X /* This won't work if the server has names than the client doesn't */ X XStoreNamedColor(XtDisplay(w),cmap,sys_colors[color_index]->colorname, X sys_colors[color_index]->color.pixel, DoRed|DoGreen|DoBlue); X#endif X XSetForeground(XtDisplay(w), gc, sys_colors[color_index]->color.pixel); X xexpose = &call_data->event->xexpose; X XFillRectangle(xexpose->display,xexpose->window,gc, X xexpose->x,xexpose->y, X xexpose->width,xexpose->height); X} X X X/********************************************************************** X * compare_colors X * X * Called by qsort X * Returns an ordering between 2 colors based on sort_values X **********************************************************************/ Xcompare_colors(a_ptr, b_ptr) Xsys_color_type **a_ptr, **b_ptr; X{ X int n; X int diff; X char *sort_str; X X X /* Keep looping, trying the next sort_values until we find a difference */ X for (n = 0, sort_str = sort_values[n]; sort_str != NULL; X n++, sort_str = sort_values[n]) X { X /* Isn't it handy that each sort_values name starts with a unique letter */ X switch (sort_str[0]) X { X case 'F': X /* File ordering -- a unique ordering */ X diff = (*a_ptr)->file_seq - (*b_ptr)->file_seq; X break; X X case 'I': X /* Intensity ordering */ X /* Could calulate intensity beforehand and store in struct for speed */ X diff = ((*a_ptr)->color.red * red_intensity + X (*a_ptr)->color.green * green_intensity + X (*a_ptr)->color.blue * blue_intensity) - X ((*b_ptr)->color.red * red_intensity + X (*b_ptr)->color.green * green_intensity + X (*b_ptr)->color.blue * blue_intensity); X break; X X case 'N': X /* Color Name ordering */ X diff = strcmp((*a_ptr)->colorname, (*b_ptr)->colorname); X break; X X case 'R': X /* Red color component ordering */ X diff = (*a_ptr)->color.red - (*b_ptr)->color.red; X break; X X case 'B': X /* Blue color component ordering */ X diff = (*a_ptr)->color.blue - (*b_ptr)->color.blue; X break; X X case 'G': X /* Green color component ordering */ X diff = (*a_ptr)->color.green - (*b_ptr)->color.green; X break; X X default: X /* What th- !? */ X fprintf(stderr,"Error: Invalid sort option name 1st char\n"); X diff = 1; X break; X } X if (diff != 0) X /* Found a difference -- get outta here */ X break; X } X return(diff); X} X X X X/********************************************************************** X * resort_list X * X * Sort sys_colors and redraw widgets based on new ordering. X * A callback from the sort_popup Apply button X **********************************************************************/ Xvoid resort_list(w, client_data, call_data) XWidget w; Xcaddr_t client_data; Xcaddr_t call_data; X{ X int x,n; X Widget a_form_w; X Widget drawinga_w; X Widget label_w; X Dimension width,height; /* DrawingAreas dimensions for XClearArea() */ X Arg warg; X Arg wargs[3]; X X X if (sort_values[0] == NULL) X /* If there are no keys to sort on, don't do anything */ X return; X X /* Sort based on the sort_values[] keys */ X qsort(sys_colors, color_count, sizeof(sys_color_type *), compare_colors); X X /* Get drawinga dimensions for later XClearArea() */ X NC(a_form_w = WcFullNameToWidget(w, "*viewport.aform"), X "Couldn't find aform widget"); X XawFormDoLayout(a_form_w,False); /* Turn off layout recomputation */ X X /* Get drawinga dimensions for later XClearArea() */ X NC(drawinga_w = WcFullNameToWidget(w, "*viewport.aform.form0.drawinga0"), X "Couldn't find drawinga widget"); X n = 0; X XtSetArg(wargs[n],XtNwidth,&width); n++; X XtSetArg(wargs[n],XtNheight,&height); n++; X XtGetValues(drawinga_w,wargs,n); X X /* Change each label and expose each drawingArea widget */ X for (x = 0; x < color_count; x++) X { X NC(label_w = WcFullNameToWidget(w, X format_static("*viewport.aform.form%d.label%d",x,x)), X "Couldn't find label widget"); X X XtSetArg(warg,XtNlabel,format_static("(%d,%d,%d) %s", X (int)(sys_colors[x]->color.red*(255.0/65535)), X (int)(sys_colors[x]->color.green*(255.0/65535)), X (int)(sys_colors[x]->color.blue*(255.0/65535)), X sys_colors[x]->colorname)); X XtSetValues(label_w,&warg,1); X X X NC(drawinga_w = WcFullNameToWidget(w, X format_static("*viewport.aform.form%d.drawinga%d",x,x)), X "Couldn't find drawinga widget"); X X /* Why do we need +1 with the width? I don;t know... */ X XClearArea(XtDisplay(drawinga_w),XtWindow(drawinga_w),0,0, X (int)width+1,(int)height,True); X } X XawFormDoLayout(a_form_w,True); /* Turn on layout recomputation */ X} END_OF_FILE if test 13948 -ne `wc -c <'xrainbow/main/color.c'`; then echo shar: \"'xrainbow/main/color.c'\" unpacked with wrong size! fi # end of 'xrainbow/main/color.c' fi if test -f 'xrainbow/main/list.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xrainbow/main/list.c'\" else echo shar: Extracting \"'xrainbow/main/list.c'\" \(6308 characters\) sed "s/^X//" >'xrainbow/main/list.c' <<'END_OF_FILE' X/********************************************************************** X * List.c - A subset of my list library, combined into one file X * X * Copyright 1991, David Nedde X * X * Permission to use, copy, modify, and distribute this software X * and its documentation for any purpose and without fee is granted X * 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 "list.h" X X/********************************************************************** X * List_Make - Create a list X * X * Usage: X * list = list_make(); X * X * list_type list <- The created list X * X * David Nedde 11/21/89 X **********************************************************************/ Xlist_type list_make() X{ X list_type list; X X X list = (list_type)ListMalloc( sizeof( struct list_struct)); X list->head_ptr = list->next_ptr = list->curr_ptr = list->tail_ptr = X (list_node_type *)NULL; X return(list); X} X X/********************************************************************** X * List_Malloc - Conditionally allocate a piece of memory. X * X * Usage: X * ptr = (ptr_type *)my_malloc(allocate, n); X * X * ptr_type *ptr <- Points to the piece of memory allocated X * bool allocate -> if TRUE, actually allocates memory X * if FALSE, returns ptr to previously allocated mem X * int n -> Number of bytes to allocate X * X * Algorithm: X * This is meant to used with the macro ListMalloc, which needs to be able X * to get the same memory pointer twice. See list.h:ListMalloc() X **********************************************************************/ Xchar *list_malloc(allocate, n) Xbool allocate; Xint n; X{ X char *malloc(); X static char *temp_ptr = NULL; X X X if (allocate) X temp_ptr = (char *)malloc((unsigned)n); X X return( temp_ptr); X} X X/********************************************************************** X * List_Count - Return the number of elements in a list X * X * Usage: X * int list_count( list); X * X * list_type list -> The list to be counted X * X * Algorithm: X * O(n) sequential counting algorithm X * X * David Nedde 5/91 X **********************************************************************/ Xint list_count( list) Xlist_type list; X{ X int count = 0; X char *item_ptr; X X assert(list != LIST_NULL,"NULL list in list_count"); X X for (item_ptr = list_first( list); X item_ptr != NULL; X item_ptr = list_next( list)) X count++; X X return(count); X} X X/********************************************************************** X * List_First - Move to start of list and return first item X * X * Usage: X * item_ptr = list_first( list); X * X * char *item_ptr <- The first item in the list X * list_type list -> The list to access X * X * David Nedde 11/21/89 X **********************************************************************/ Xchar *list_first( list) Xlist_type list; X{ X assert(list != LIST_NULL,"Getting start of a list"); X X if (list->head_ptr == (list_node_type *)NULL) X /* Empty list */ X return( NULL); X X list->next_ptr = list->head_ptr->next_node_ptr; X return( list->head_ptr->item_ptr); X} X X X/********************************************************************** X * List_Next - Return the next item in a list or NULL if end of list X * X * Usage: X * item_ptr = list_next( list); X * X * char *item_ptr <- The next item in the list X * list_type list -> The list to access X * X * David Nedde 11/21/89 X **********************************************************************/ Xchar *list_next( list) Xlist_type list; X{ X char *item_ptr; X X X assert(list != LIST_NULL,"Getting next item in list"); X X if ((list->head_ptr == (list_node_type *)NULL) || X (list->next_ptr == (list_node_type *)NULL)) X return((char *)NULL); X X item_ptr = list->next_ptr->item_ptr; X list->curr_ptr = list->next_ptr; X list->next_ptr = list->next_ptr->next_node_ptr; X return( item_ptr); X} X X/********************************************************************** X * List_Add_End - Add an item to the end of a list X * X * Usage: X * data_ptr = list_add_end( item_ptr, list); X * X * char *data_ptr <- A pointer to the data added to the list X * char *item_ptr -> A pointer to the data added to the list X * list_type list -> The list to add to X * X * David Nedde 11/21/89 X **********************************************************************/ Xchar *list_add_end( item_ptr, list) Xchar *item_ptr; Xlist_type list; X{ X list_node_type *node_ptr; X X X assert(list != LIST_NULL && item_ptr != NULL,"Adding to list's end"); X node_ptr = (list_node_type *)ListMalloc( sizeof( list_node_type)); X node_ptr->item_ptr = item_ptr; X node_ptr->next_node_ptr = (list_node_type *)NULL; X node_ptr->prev_node_ptr = list->tail_ptr; X X if (list->head_ptr == (list_node_type *)NULL) X /* Empty list */ X list->head_ptr = list->next_ptr = list->curr_ptr = list->tail_ptr = X node_ptr; X else X { X list->tail_ptr->next_node_ptr = node_ptr; X list->tail_ptr = node_ptr; X } X X return( node_ptr->item_ptr); X} X X/********************************************************************** X * List_Remove_Start - Remove an item from the beginning of a list. X * X * Usage: X * data_ptr = list_remove_start( list); X * X * char *data_ptr <- A pointer to the data removed from the list X * list_type list -> The list to remove from X * X * David Nedde 11/21/89 X **********************************************************************/ Xchar *list_remove_start( list) Xlist_type list; X{ X list_node_type *node_ptr; X char *item_ptr; X X X assert(list != LIST_NULL,"Removing from list's start"); X X if (list->head_ptr == (list_node_type *)NULL) X /* Empty list */ X return( NULL); X X node_ptr = list->head_ptr; X item_ptr = node_ptr->item_ptr; X X list->head_ptr = list->head_ptr->next_node_ptr; X X if (list->head_ptr == (list_node_type *)NULL) X /* Removing only item in list */ X list->tail_ptr = list->next_ptr = list->curr_ptr = (list_node_type *)NULL; X else X { X list->head_ptr->prev_node_ptr = (list_node_type *)NULL; X if (list->next_ptr == node_ptr) X list->next_ptr = (list_node_type *)NULL; X } X X free( (char *)node_ptr); X X return( item_ptr); X} END_OF_FILE if test 6308 -ne `wc -c <'xrainbow/main/list.c'`; then echo shar: \"'xrainbow/main/list.c'\" unpacked with wrong size! fi # end of 'xrainbow/main/list.c' fi if test -f 'xrainbow/main/list.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xrainbow/main/list.h'\" else echo shar: Extracting \"'xrainbow/main/list.h'\" \(3256 characters\) sed "s/^X//" >'xrainbow/main/list.h' <<'END_OF_FILE' X/********************************************************************** X * List.h - List data structures. X * X * Copyright 1991, David Nedde X * X * Permission to use, copy, modify, and distribute this software X * and its documentation for any purpose and without fee is granted X * provided that the above copyright notice appears in all copies. X * It is provided "as is" without express or implied warranty. X **********************************************************************/ X X#ifndef LIST_H X#define LIST_H X Xtypedef unsigned char bool; X X/* One node in the list */ Xtypedef struct list_node_struct list_node_type; Xstruct list_node_struct { X char *item_ptr; /* The data item hung off of the list */ X list_node_type *prev_node_ptr; /* Points to the prev node in the list */ X list_node_type *next_node_ptr; /* Points to the next node in the list */ X}; X X/* The list's head, tail, etc */ Xtypedef struct list_struct *list_type; Xstruct list_struct { X list_node_type *head_ptr; /* Points to the head of the list */ X list_node_type *next_ptr; /* Points to next item returned with list_next */ X list_node_type *curr_ptr; /* Points to curr item returned with list_next */ X list_node_type *tail_ptr; /* Points to the end of the list */ X}; X X#define TRUE 1 X#define FALSE 0 X X#ifndef NULL X#define NULL ((char *)0L) X#endif X X#define LIST_NULL ((list_type)NULL) X X#ifdef DEBUG X#define assert( condition, message) \ X { \ X if (!(condition)) \ X printf("List Error: File \"%s\", Line %d: %s", \ X __FILE__, __LINE__, message); \ X } X X#define LIST_TEST(list) /*list_test(list)*/ X#else X#define assert( condition, message) X#define LIST_TEST(list) X#endif X X X X#define ListMalloc(n) \ X (list_malloc(TRUE,(n)) == NULL \ X ? (char *)printf("List Error: File \"%s\", Line %d: Out of memory", \ X __FILE__,__LINE__) \ X : list_malloc(FALSE,(n))) X X X/********************************************************************** X * List of pointers handling routines X * X * List_Make - Create a list X * List_Add_End - Add to the end of the list X * List_Add_Start - Add to the start of the list X * List_Remove_Start - Remove first item from a list and return it X * List_First - Move to start of list and return first item X * List_Next - Return the next item in the list (NULL if eol) X * List_Last - Return last item in list X * List_Destroy - Deallocate the list but not the contents X * List_Deallocate - Deallocate everything in the list X * List_Dup_Node - Allocate a duplicate list node X * X * David Nedde 11/21/89 X **********************************************************************/ Xlist_type list_make(); Xchar *list_add_end(); Xchar *list_add_start(); Xchar *list_add_before_curr(); Xchar *list_add_sort(); Xchar *list_remove_start(); Xchar *list_remove_end(); Xchar *list_remove_curr(); Xchar *list_first(); Xchar *list_next(); Xchar *list_last(); Xvoid list_destroy(); Xvoid list_deallocate(); Xchar *list_dup_node(); Xchar *list_malloc(); Xint list_count(); X X#endif X END_OF_FILE if test 3256 -ne `wc -c <'xrainbow/main/list.h'`; then echo shar: \"'xrainbow/main/list.h'\" unpacked with wrong size! fi # end of 'xrainbow/main/list.h' fi if test -f 'xrainbow/main/misc.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xrainbow/main/misc.c'\" else echo shar: Extracting \"'xrainbow/main/misc.c'\" \(4065 characters\) sed "s/^X//" >'xrainbow/main/misc.c' <<'END_OF_FILE' X/********************************************************************** X * Misc.c - Support routines for XSauci X * X * format_static - Format a list of args, returning a static string. X * Make_String - Allocate a copy of the passed string X * X * Copyright 1990, David Nedde X * X * Permission to use, copy, modify, and distribute this software X * and its documentation for any purpose and without fee is granted X * 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 <stdio.h> X#include <ctype.h> X#include <varargs.h> X#include "misc.h" X X X#define NC(x,mess) \ X{ \ X if ((x) == NULL) \ X fprintf("XRainbow: System error: %s\n",mess); \ X} X Xchar *malloc(); Xchar *format_str_ap_ptr(); X Xtypedef int bool; X X#define True 1 X#define False 0 X X X/********************************************************************** X * Format_Str_Ap_Ptr - Like format_str, but gets passed an 'ap' pointer. X * Format_Static - Format a list of args, returning a static string. X * Static strings are reused after NUM_SS calls. X * X * Usage: X * str = format_static( format, arg, ...); X * X * char *str <- Points to the allocated, formatted string X * char *format -> The printf-style format to print the args with X **********************************************************************/ X#define NUM_SS 10 /* Number of static strings to use */ Xchar *format_static( format, va_alist) Xchar *format; Xva_dcl X{ X va_list ap; X int curr_str; X static int next_str = 0; X static char *static_str[NUM_SS]; X X X curr_str = next_str; X next_str = (next_str + 1) % NUM_SS; X X if (static_str[curr_str] != (char *)0) X free(static_str[curr_str]); X X va_start( ap); X static_str[curr_str] = format_str_ap_ptr( format, &ap); X va_end( ap); X X return( static_str[curr_str]); X} X Xchar *format_str_ap_ptr( format, ap_ptr) Xchar *format; Xva_list *ap_ptr; X{ X char *src_ptr; X char *dest_ptr; X char dest_str[1000]; X char *new_form_ptr; X char new_form[ 10]; X bool all_done; X X X src_ptr = format; X dest_ptr = dest_str; X while (*src_ptr != '\0') X { X while (*src_ptr != '%' && *src_ptr != '\0') X *dest_ptr++ = *src_ptr++; X X /* Now src_ptr points to a '%' or end of string */ X if (*src_ptr != '\0') X { X new_form_ptr = new_form; X *new_form_ptr++ = *src_ptr++; X all_done = False; X while (!all_done) X switch (*new_form_ptr++ = *src_ptr++) X { X case 'd': X case 'i': X case 'o': X case 'u': X case 'x': X case 'X': X *new_form_ptr = '\0'; X sprintf(dest_ptr,new_form,va_arg( *ap_ptr, int)); X all_done = True; X break; X X case 'f': X case 'e': X case 'E': X case 'g': X case 'G': X *new_form_ptr = '\0'; X sprintf(dest_ptr,new_form,va_arg( *ap_ptr, double)); X all_done = True; X break; X X case 'c': X *new_form_ptr = '\0'; X sprintf(dest_ptr,new_form,va_arg( *ap_ptr, char)); X all_done = True; X break; X X case 's': X *new_form_ptr = '\0'; X sprintf(dest_ptr,new_form,va_arg( *ap_ptr, char *)); X all_done = True; X break; X X case '%': X *new_form_ptr = '\0'; X sprintf(dest_ptr,new_form); X all_done = True; X } X X /* Move dest_ptr to the end of it's string again */ X while (*dest_ptr != '\0') X dest_ptr++; X } X } X X *dest_ptr = '\0'; /* Null terminate the string */ X X return( make_string( dest_str)); X} X X X/********************************************************************** X * Make_String - Allocate a copy of the passed string X **********************************************************************/ Xchar *make_string( str) Xchar *str; X{ X char *ret_str; X X X NC(str,"Null string passed to make_string"); X NC(ret_str = malloc((unsigned)strlen(str)+1),"Out of memory in make_string"); X (void)strcpy( ret_str, str); X X return( ret_str); X} END_OF_FILE if test 4065 -ne `wc -c <'xrainbow/main/misc.c'`; then echo shar: \"'xrainbow/main/misc.c'\" unpacked with wrong size! fi # end of 'xrainbow/main/misc.c' fi if test -f 'xrainbow/main/misc.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xrainbow/main/misc.h'\" else echo shar: Extracting \"'xrainbow/main/misc.h'\" \(534 characters\) sed "s/^X//" >'xrainbow/main/misc.h' <<'END_OF_FILE' X/********************************************************************** X * Copyright 1990, David Nedde X * X * Permission to use, copy, modify, and distribute this software X * and its documentation for any purpose and without fee is granted X * provided that the above copyright notice appears in all copies. X * It is provided "as is" without express or implied warranty. X **********************************************************************/ X Xchar *format_static(); Xchar *format_str(); Xchar *make_string(); Xchar *search_string(); END_OF_FILE if test 534 -ne `wc -c <'xrainbow/main/misc.h'`; then echo shar: \"'xrainbow/main/misc.h'\" unpacked with wrong size! fi # end of 'xrainbow/main/misc.h' fi if test -f 'xrainbow/main/miscx.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xrainbow/main/miscx.c'\" else echo shar: Extracting \"'xrainbow/main/miscx.c'\" \(3509 characters\) sed "s/^X//" >'xrainbow/main/miscx.c' <<'END_OF_FILE' X/********************************************************************** X * miscx.c - Misc X functions X * X * PlaceWindow - Moves the passed widget to a new location on the screen X * X * Copyright 1991, David Nedde X * X * Permission to use, copy, modify, and distribute this software X * and its documentation for any purpose and without fee is granted X * 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 <stdio.h> X#include <errno.h> X#include <X11/Xlib.h> X#include <X11/Xos.h> X#include <X11/Xutil.h> X#include <X11/Intrinsic.h> X#include <X11/StringDefs.h> X#include <Wc/WcCreate.h> X#include "misc.h" X X#define NC(x,mess) \ X{ \ X if ((x) == NULL) \ X fprintf("XRainbow: System error: %s\n",mess); \ X} X X X/********************************************************************** X * void PlaceWindow(w, place_type, call_data) X * X * A callback that moves the passed widget to a new location on the screen. X * X * Resource File Usage: X * PlaceWindow(pointer|widget|parent|widget_name,x_offset,y_offset) X * pointer - Place widget at pointer position X * widget - Place widget at widget location X * parent - Place widget at widget parent's location X * widget_name - Place widget at the named widget's location X * x_offset - The signed x pixel distance from specified placement point X * y_offset - The signed y pixel distance from specified placement point X **********************************************************************/ Xvoid PlaceWindow(w, place_type, call_data) XWidget w; Xchar *place_type; Xcaddr_t call_data; X{ X Widget widget; /* The widget if placing relative to one */ X Position rootx_return; /* The root x,y location to put the widget */ X Position rooty_return; X char *in_args; /* A copy of the arguments passed in */ X int x_offset; /* The offsets passed in */ X int y_offset; X char *type; /* First resource file argument */ X char *strtok(); X int n; X Arg wargs[10]; X X X /* Parse the 3 arguments into type, x/y_offset */ X in_args = XtNewString(place_type); X type = strtok(in_args,","); X x_offset = (int)atol(strtok((char *)NULL,",")); X y_offset = (int)atol(strtok((char *)NULL,",")); X X if (!strcmp(type,"pointer")) X { X /* Place widget offset from the pointer position */ X Window root_return, child_return; X unsigned int mask; X int win_x,win_y; X int root_x,root_y; X X XQueryPointer(XtDisplay(w),DefaultRootWindow(XtDisplay(w)), X &root_return,&child_return, X &root_x,&root_y,&win_x,&win_y,&mask); X rootx_return = root_x; X rooty_return = root_y; X } X else X if (!strcmp(type,"widget")) X /* Place widget at an offset from calling widget */ X XtTranslateCoords(w,(Position)0,(Position)0, X &rootx_return,&rooty_return); X else X if (!strcmp(type,"parent")) X /* Place widget at an offset from calling widget's parent */ X XtTranslateCoords(XtParent(w),(Position)0,(Position)0, X &rootx_return,&rooty_return); X else X { X /* Place widget at an offset from the specified widget */ X NC(widget = WcFullNameToWidget(w,type),"Finding widget in PlaceWindow"); X XtTranslateCoords(widget,(Position)0,(Position)0, X &rootx_return,&rooty_return); X } X X n = 0; X XtSetArg(wargs[n],XtNx,rootx_return+x_offset); n++; X XtSetArg(wargs[n],XtNy,rooty_return+y_offset); n++; X XtSetValues(w,wargs,n); X XtFree(in_args); X} END_OF_FILE if test 3509 -ne `wc -c <'xrainbow/main/miscx.c'`; then echo shar: \"'xrainbow/main/miscx.c'\" unpacked with wrong size! fi # end of 'xrainbow/main/miscx.c' fi if test -f 'xrainbow/main/xrainbow.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xrainbow/main/xrainbow.c'\" else echo shar: Extracting \"'xrainbow/main/xrainbow.c'\" \(3630 characters\) sed "s/^X//" >'xrainbow/main/xrainbow.c' <<'END_OF_FILE' X/********************************************************************** X * XRainbow.c - Main routine X * X * Copyright 1991, David Nedde X * X * Permission to use, copy, modify, and distribute this software X * and its documentation for any purpose and without fee is granted X * provided that the above copyright notice appears in all copies. X * It is provided "as is" without express or implied warranty. X **********************************************************************/ X X/* X** Copyright (c) 1990 David E. Smyth X** X** Redistribution and use in source and binary forms are permitted X** provided that the above copyright notice and this paragraph are X** duplicated in all such forms and that any documentation, advertising X** materials, and other materials related to such distribution and use X** acknowledge that the software was developed by David E. Smyth. The X** name of David E. Smyth may not be used to endorse or promote products X** derived from this software without specific prior written permission. X** THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED X** WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF X** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. X** X*/ X X/****************************************************************************** X** Include_files. X******************************************************************************/ X X#include <X11/Intrinsic.h> X#include <ctype.h> X#include <Wc/WcCreate.h> X#include <X11/Xaw_d/DrawingA.h> X Xextern void PlaceWindow (); Xextern void setup_lists (); Xextern void list_callback (); Xextern void resort_list (); Xextern void EndAsciiValAction (); X X/****************************************************************************** X* MAIN function X******************************************************************************/ X Xmain ( argc, argv ) X int argc; X char* argv[]; X{ X char* appClass; X XtAppContext app; X Widget appShell; X X appClass = (char*) XtMalloc ( strlen ( argv[0] ) + 1 ); X strcpy (appClass, argv[0]); X /* initialize first letter to make class, or first two if X ** first is already capitalized, or don't worry about it. X */ X if (islower(appClass[0])) X appClass[0] = toupper(appClass[0]); X else if (islower(appClass[1])) X appClass[1] = toupper(appClass[1]); X X /* -- Intialize Toolkit creating the application shell */ X appShell = XtInitialize ( X argv[0], appClass, /* app name and class */ X NULL, 0, /* description of cmd line options */ X &argc, argv X ); X app = XtWidgetToApplicationContext(appShell); X X /* -- Register all application specific widget classes */ X WcRegisterClassName(app, "DrawingArea", drawingAreaWidgetClass); X WcRegisterClassPtr( app, "drawingAreaWidgetClass", drawingAreaWidgetClass); X X X /* -- Register all Athena and Public widget classes */ X AriRegisterAthena(app); X X /* -- Register application specific actions */ X WcRegisterAction(app, "EndAsciiValAction", EndAsciiValAction); X X /* -- Register application specific callbacks */ X WcRegisterCallback(app, "PlaceWindow", PlaceWindow, (caddr_t)0); X WcRegisterCallback(app, "setup_lists", setup_lists, (caddr_t)0); X WcRegisterCallback(app, "list_callback", list_callback, (caddr_t)0); X WcRegisterCallback(app, "resort_list", resort_list, (caddr_t)0); X X X /* -- Create widget tree below toplevel shell using Xrm database */ X WcWidgetCreation ( appShell ); X X init_colors(appShell,argv[1]); X X /* -- Realize the widget tree and enter the main application loop */ X XtRealizeWidget ( appShell ); X XtMainLoop ( ); X} END_OF_FILE if test 3630 -ne `wc -c <'xrainbow/main/xrainbow.c'`; then echo shar: \"'xrainbow/main/xrainbow.c'\" unpacked with wrong size! fi # end of 'xrainbow/main/xrainbow.c' fi echo shar: End of archive 5 \(of 5\). cp /dev/null ark5isdone 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@uunet.uu.net argv@ora.com argv@zipcode.com