home *** CD-ROM | disk | FTP | other *** search
- Path: uunet!cs.utexas.edu!sun-barr!newstop!sun!uunet.UU.NET
- From: balr!panasun!ken@uunet.UU.NET (Ken Marks (x2425))
- Newsgroups: comp.sources.x
- Subject: v08i083: chaos, Part07/10
- Message-ID: <140961@sun.Eng.Sun.COM>
- Date: 20 Aug 90 18:04:04 GMT
- Sender: news@sun.Eng.Sun.COM
- Lines: 2102
- Approved: argv@sun.com
-
- Submitted-by: balr!panasun!ken@uunet.UU.NET (Ken Marks (x2425))
- Posting-number: Volume 8, Issue 83
- Archive-name: chaos/part07
-
- #! /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 7 (of 10)."
- # Contents: common/colormap.c drone/mandelbrot.c master/chaos.man
- # master/fileDb.c master/settingsDb.c widgets/Push.c
- # Wrapped by ken@panasun on Mon Jul 30 14:59:50 1990
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'common/colormap.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'common/colormap.c'\"
- else
- echo shar: Extracting \"'common/colormap.c'\" \(8780 characters\)
- sed "s/^X//" >'common/colormap.c' <<'END_OF_FILE'
- X/*
- X * Copyright (c) Ken W. Marks 1989, 1990.
- X */
- X
- X#include <stdio.h>
- X#include <fcntl.h>
- X#include <math.h>
- X#include <X11/IntrinsicP.h>
- X#include <X11/StringDefs.h>
- X#include <Chaos.h>
- X#include <Colormap.h>
- X
- Xstatic unsigned char red[NUM_COLORS], green[NUM_COLORS], blue[NUM_COLORS];
- Xstatic XColor colorcell_defs[NUM_COLORS];
- Xstatic char *default_filename = "default.map";
- X
- Xvoid GetReservedColors(dpy, screen)
- XDisplay *dpy;
- XScreen *screen;
- X{
- X int ii;
- X
- X for (ii = 0; ii < NUM_RESERVED; ++ii)
- X colorcell_defs[ii].pixel = ii;
- X
- X XQueryColors(dpy, DefaultColormapOfScreen(screen), colorcell_defs,
- X NUM_RESERVED);
- X
- X for (ii = 0; ii < NUM_RESERVED; ++ii)
- X {
- X red[ii] = colorcell_defs[ii].red & 0xff;
- X green[ii] = colorcell_defs[ii].green & 0xff;
- X blue[ii] = colorcell_defs[ii].blue & 0xff;
- X }
- X}
- X
- X
- XColormap CreateColormap(dpy, screen, window)
- XDisplay *dpy;
- XScreen *screen;
- XWindow window;
- X{
- X Colormap colormap;
- X XSetWindowAttributes attributes;
- X
- X colormap = XCreateColormap(dpy, window, DefaultVisualOfScreen(screen),
- X AllocAll);
- X StoreColormap(dpy, colormap);
- X
- X attributes.colormap = colormap;
- X XChangeWindowAttributes(dpy, window, CWColormap, &attributes);
- X
- X return (colormap);
- X}
- X
- X
- Xvoid StoreColormap(dpy, colormap)
- XDisplay *dpy;
- XColormap colormap;
- X{
- X int ii;
- X
- X for (ii = 0; ii < NUM_COLORS; ii++)
- X {
- X colorcell_defs[ii].pixel = ii;
- X colorcell_defs[ii].red = red[ii] | red[ii] << 8;
- X colorcell_defs[ii].green = green[ii] | green[ii] << 8;
- X colorcell_defs[ii].blue = blue[ii] | blue[ii] << 8;
- X colorcell_defs[ii].flags = DoRed | DoGreen | DoBlue;
- X }
- X
- X XStoreColors(dpy, colormap, colorcell_defs, NUM_COLORS);
- X}
- X
- X
- Xvoid RotateColormap(dpy, colormap, rotation)
- XDisplay *dpy;
- XColormap colormap;
- XRotation rotation;
- X{
- X register int ii;
- X unsigned long temp;
- X
- X if (rotation == forward)
- X {
- X temp = colorcell_defs[NUM_RESERVED].pixel;
- X for (ii = NUM_RESERVED; ii < NUM_COLORS - 1; ii++)
- X {
- X colorcell_defs[ii].pixel = colorcell_defs[ii + 1].pixel;
- X }
- X colorcell_defs[NUM_COLORS - 1].pixel = temp;
- X }
- X else if (rotation == backward)
- X {
- X temp = colorcell_defs[NUM_COLORS - 1].pixel;
- X for (ii = NUM_COLORS - 1; ii > NUM_RESERVED; ii--)
- X {
- X colorcell_defs[ii].pixel = colorcell_defs[ii - 1].pixel;
- X }
- X colorcell_defs[NUM_RESERVED].pixel = temp;
- X }
- X else
- X {
- X eprintf("Invalid rotation specified\n");
- X abort();
- X }
- X XStoreColors(dpy, colormap, colorcell_defs, NUM_COLORS);
- X}
- X
- X
- Xint GetColormapAlignment()
- X{
- X
- X return (colorcell_defs[NUM_RESERVED].pixel);
- X}
- X
- X
- Xvoid AlignColormap(dpy, colormap, pixel)
- XDisplay *dpy;
- XColormap colormap;
- Xint pixel;
- X{
- X register int ii;
- X
- X for (ii = NUM_RESERVED; ii < NUM_COLORS; ii++, pixel++)
- X {
- X if (pixel == NUM_COLORS)
- X pixel = NUM_RESERVED;
- X colorcell_defs[ii].pixel = pixel;
- X }
- X
- X XStoreColors(dpy, colormap, colorcell_defs, NUM_COLORS);
- X}
- X
- X
- Xvoid GetColorRGB(pixel, r, g, b)
- Xint pixel;
- Xunsigned char *r;
- Xunsigned char *g;
- Xunsigned char *b;
- X{
- X *r = red[pixel];
- X *g = green[pixel];
- X *b = blue[pixel];
- X}
- X
- X
- Xvoid SetColorRGB(dpy, colormap, pixel, r, g, b)
- XDisplay *dpy;
- XColormap colormap;
- Xint pixel;
- Xunsigned char r;
- Xunsigned char g;
- Xunsigned char b;
- X{
- X red[pixel] = r;
- X green[pixel] = g;
- X blue[pixel] = b;
- X
- X colorcell_defs[pixel].pixel = pixel;
- X colorcell_defs[pixel].red = red[pixel] | red[pixel] << 8;
- X colorcell_defs[pixel].green = green[pixel] | green[pixel] << 8;
- X colorcell_defs[pixel].blue = blue[pixel] | blue[pixel] << 8;
- X
- X XStoreColors(dpy, colormap, &colorcell_defs[pixel], 1);
- X}
- X
- X
- XXColor *GetColors(num_colors)
- Xint num_colors;
- X{
- X XColor *colors =
- X (XColor *) malloc((unsigned) (sizeof(XColor) * num_colors));
- X (void) memcpy((char *) colors, (char *) colorcell_defs,
- X sizeof(XColor) * num_colors);
- X return (colors);
- X}
- X
- X
- Xvoid PutColors(colors, num_colors)
- XXColor *colors;
- Xint num_colors;
- X{
- X int ii;
- X int pixel;
- X
- X for (ii = 0; ii < num_colors; ++ii)
- X {
- X pixel = colors[ii].pixel;
- X red[pixel] = colors[ii].red & 0xff;
- X green[pixel] = colors[ii].green & 0xff;
- X blue[pixel] = colors[ii].blue & 0xff;
- X }
- X}
- X
- X
- Xvoid HSB2RGB(h, s, i, r, g, b)
- Xdouble h, s, i;
- Xdouble *r, *g, *b;
- X{
- X int j;
- X double f, p, q, t;
- X
- X if (s == 0.0)
- X *r = *g = *b = i;
- X else
- X {
- X h -= floor(h);
- X h *= 6.0;
- X j = (int) floor(h);
- X f = h - (double) j;
- X p = i * (1.0 - s);
- X q = i * (1.0 - s * f);
- X t = i * (1.0 - (s * (1.0 - f)));
- X
- X switch (j)
- X {
- X case 0:
- X *r = i;
- X *g = t;
- X *b = p;
- X break;
- X case 1:
- X *r = q;
- X *g = i;
- X *b = p;
- X break;
- X case 2:
- X *r = p;
- X *g = i;
- X *b = t;
- X break;
- X case 3:
- X *r = p;
- X *g = q;
- X *b = i;
- X break;
- X case 4:
- X *r = t;
- X *g = p;
- X *b = i;
- X break;
- X case 5:
- X *r = i;
- X *g = p;
- X *b = q;
- X break;
- X }
- X }
- X}
- X
- X
- Xvoid RGB2HSB(r, g, b, h, s, i)
- Xdouble r, g, b;
- Xdouble *h, *s, *i;
- X{
- X int j;
- X double f;
- X
- X if (r == g && g == b)
- X {
- X *i = r;
- X *s = 0.0;
- X *h = 0.0;
- X return;
- X }
- X
- X if (r < g)
- X if (r > b)
- X j = 1;
- X else if (g > b)
- X j = 2;
- X else
- X j = 3;
- X else if (r > g)
- X if (r < b)
- X j = 4;
- X else if (g < b)
- X j = 5;
- X else
- X j = 0;
- X else if (r < b)
- X j = 4;
- X else
- X j = 1;
- X
- X switch (j)
- X {
- X case 0:
- X *i = r;
- X *s = 1.0 - b / r;
- X f = (1.0 - ((1.0 - g / r) / (*s)));
- X break;
- X case 1:
- X *i = g;
- X *s = 1.0 - b / g;
- X f = (1.0 - r / g) / (*s);
- X break;
- X case 2:
- X *i = g;
- X *s = 1.0 - r / g;
- X f = (1.0 - ((1.0 - b / g) / (*s)));
- X break;
- X case 3:
- X *i = b;
- X *s = 1.0 - r / b;
- X f = (1.0 - g / b) / (*s);
- X break;
- X case 4:
- X *i = b;
- X *s = 1.0 - g / b;
- X f = (1.0 - ((1.0 - r / b) / (*s)));
- X break;
- X case 5:
- X *i = r;
- X *s = 1.0 - g / r;
- X f = (1.0 - b / r) / (*s);
- X break;
- X }
- X *h = ((double) j + f) / 6.0;
- X}
- X
- X
- Xvoid StoreHSB(reps)
- Xint reps;
- X{
- X int ii;
- X double hue, sat, bright;
- X double r, g, b;
- X
- X sat = 0.9;
- X bright = 1.0;
- X
- X for (ii = NUM_RESERVED; ii < NUM_COLORS; ii++)
- X {
- X hue = (double) ii / (double) (NUM_COLORS -
- X NUM_RESERVED) * (double) reps;
- X
- X HSB2RGB(hue, sat, bright, &r, &g, &b);
- X
- X red[ii] = (unsigned char) (r * (double) MAX_INTENSITY);
- X green[ii] = (unsigned char) (g * (double) MAX_INTENSITY);
- X blue[ii] = (unsigned char) (b * (double) MAX_INTENSITY);
- X }
- X}
- X
- X
- Xvoid StoreGray(reps)
- Xint reps;
- X{
- X int ii;
- X
- X for (ii = NUM_RESERVED; ii < NUM_COLORS; ii++)
- X red[ii] = green[ii] = blue[ii] = (ii % ((NUM_COLORS -
- X NUM_RESERVED) / reps)) * reps;
- X}
- X
- X
- Xvoid StoreRandom()
- X{
- X int ii;
- X extern int rand();
- X
- X for (ii = NUM_RESERVED; ii < NUM_COLORS; ii++)
- X {
- X red[ii] = (unsigned char) ((rand() >> 16) & MAX_INTENSITY);
- X green[ii] = (unsigned char) ((rand() >> 16) & MAX_INTENSITY);
- X blue[ii] = (unsigned char) ((rand() >> 16) & MAX_INTENSITY);
- X }
- X}
- X
- X
- Xvoid StoreTriColor()
- X{
- X int ii;
- X
- X for (ii = NUM_RESERVED; ii < NUM_COLORS; ii++)
- X {
- X switch (ii % 3)
- X {
- X case 0:
- X red[ii] = MAX_INTENSITY;
- X green[ii] = 0;
- X blue[ii] = 0;
- X break;
- X
- X case 1:
- X red[ii] = 0;
- X green[ii] = MAX_INTENSITY;
- X blue[ii] = 0;
- X break;
- X case 2:
- X red[ii] = 0;
- X green[ii] = 0;
- X blue[ii] = MAX_INTENSITY;
- X break;
- X }
- X }
- X}
- X
- X
- Xvoid StoreOctoColor()
- X{
- X int ii;
- X
- X for (ii = NUM_RESERVED; ii < NUM_COLORS; ii++)
- X {
- X red[ii] = (ii & 1) ? MAX_INTENSITY : 0;
- X green[ii] = (ii & 2) ? MAX_INTENSITY : 0;
- X blue[ii] = (ii & 4) ? MAX_INTENSITY : 0;
- X }
- X}
- X
- X
- Xvoid StoreColors(function, closure)
- Xvoid (*function) ();
- Xcaddr_t closure;
- X{
- X int ii;
- X
- X for (ii = NUM_RESERVED; ii < NUM_COLORS; ii++)
- X (*function) (ii, &red[ii], &green[ii], &blue[ii], closure);
- X}
- X
- X
- XBoolean ReadColors(dir, filename)
- Xchar *dir;
- Xchar *filename;
- X{
- X FILE *file;
- X int ii;
- X int r, g, b;
- X char path[128];
- X
- X if (filename == NULL)
- X filename = default_filename;
- X
- X (void) sprintf(path, "%s/%s", dir, filename);
- X
- X if ((file = fopen(path, "r")) == NULL)
- X {
- X#ifdef DEBUG
- X dprintf("Can't open '%s'\n", path);
- X#endif
- X return (False);
- X }
- X
- X for (ii = 0; ii < NUM_COLORS; ii++)
- X {
- X (void) fscanf(file, "%d %d %d\n", &r, &g, &b);
- X
- X /* Ignore color definitions for colors 0 to NUM_RESERVED-1 */
- X if (ii >= NUM_RESERVED)
- X {
- X red[ii] = (unsigned char) r;
- X green[ii] = (unsigned char) g;
- X blue[ii] = (unsigned char) b;
- X }
- X }
- X (void) fclose(file);
- X return (True);
- X}
- X
- X
- XBoolean WriteColors(dir, filename)
- Xchar *dir;
- Xchar *filename;
- X{
- X FILE *file;
- X int ii;
- X char path[128];
- X
- X if (filename == NULL)
- X filename = default_filename;
- X
- X (void) sprintf(path, "%s/%s", dir, filename);
- X
- X if ((file = fopen(path, "w")) == NULL)
- X {
- X#ifdef DEBUG
- X dprintf("Can't open '%s'\n", path);
- X#endif
- X return (False);
- X }
- X
- X for (ii = 0; ii < NUM_COLORS; ii++)
- X (void) fprintf(file, "%d %d %d\n", red[ii], green[ii], blue[ii]);
- X (void) fclose(file);
- X return (True);
- X}
- END_OF_FILE
- if test 8780 -ne `wc -c <'common/colormap.c'`; then
- echo shar: \"'common/colormap.c'\" unpacked with wrong size!
- fi
- # end of 'common/colormap.c'
- fi
- if test -f 'drone/mandelbrot.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'drone/mandelbrot.c'\"
- else
- echo shar: Extracting \"'drone/mandelbrot.c'\" \(3200 characters\)
- sed "s/^X//" >'drone/mandelbrot.c' <<'END_OF_FILE'
- X/*
- X * Copyright (c) Ken W. Marks 1989, 1990.
- X */
- X
- X#include <stdio.h>
- X#include <math.h>
- X#include <X11/Intrinsic.h>
- X#include <Ipc.h>
- X#include <Chaos.h>
- X#include <Colormap.h>
- X
- X#define MANDEL_INFINITY 5
- X
- X/* The Mandelbrot computation is defined here as a macro since it is
- X * used at many places below but is not a function for efficiency sake. */
- X
- X#define MANDEL_MACRO \
- X{ \
- X register double real = 0.0; \
- X register double imag = 0.0; \
- X register double real_squared = 0.0; \
- X register double imag_squared = 0.0; \
- X \
- X iter = 0; \
- X while ((real_squared + imag_squared) < MANDEL_INFINITY && iter <= limit) \
- X { \
- X imag = 2 * real * imag + q0; \
- X real = real_squared - imag_squared + p0; \
- X real_squared = real * real; \
- X imag_squared = imag * imag; \
- X ++iter; \
- X } \
- X --iter; \
- X}
- X
- X
- Xvoid ComputeMandelbrot(req, resp)
- XImageRequest *req;
- XImageResponse *resp;
- X{
- X unsigned char *dp;
- X unsigned int width;
- X unsigned int height;
- X unsigned int limit;
- X unsigned int w, h;
- X unsigned int iter;
- X unsigned int max_iter = 0;
- X double p_min;
- X double p_max;
- X double q_min;
- X double q_max;
- X double p_inc, q_inc;
- X register double p0, q0;
- X double atof();
- X
- X p_min = atof(req->p_lo);
- X p_max = atof(req->p_hi);
- X q_min = atof(req->q_lo);
- X q_max = atof(req->q_hi);
- X width = req->width;
- X height = req->height;
- X limit = req->limit;
- X
- X resp->byte_order = req->byte_order;
- X resp->serial = req->serial;
- X resp->width = req->width;
- X resp->height = req->height;
- X
- X /* dp points past the ImageResponse header */
- X dp = (unsigned char *) &resp[1];
- X
- X#ifdef DEBUG
- X (void) printf("width: %d height: %d limit: %d\n", width, height, limit);
- X (void) printf("p_min: % f\n", p_min);
- X (void) printf("p_max: % f\n", p_max);
- X (void) printf("q_min: % f\n", q_min);
- X (void) printf("q_max: % f\n", q_max);
- X#endif
- X
- X p_inc = (p_max - p_min) / (width - 1);
- X q_inc = (q_max - q_min) / (height - 1);
- X
- X w = 0;
- X p0 = p_min + w * p_inc;
- X for (h = 0; h < height; h++)
- X {
- X q0 = q_min + h * q_inc;
- X
- X MANDEL_MACRO
- X
- X if (iter != limit)
- X goto compute_all;
- X }
- X
- X w = width - 1;
- X p0 = p_min + w * p_inc;
- X for (h = 0; h < height; h++)
- X {
- X q0 = q_min + h * q_inc;
- X
- X MANDEL_MACRO
- X
- X if (iter != limit)
- X goto compute_all;
- X }
- X
- X h = 0;
- X q0 = q_min + h * q_inc;
- X for (w = 0; w < width; w++)
- X {
- X p0 = p_min + w * p_inc;
- X
- X MANDEL_MACRO
- X
- X if (iter != limit)
- X goto compute_all;
- X }
- X
- X h = height - 1;
- X q0 = q_min + h * q_inc;
- X for (w = 0; w < width; w++)
- X {
- X p0 = p_min + w * p_inc;
- X
- X MANDEL_MACRO
- X
- X if (iter != limit)
- X goto compute_all;
- X }
- X
- X (void) memset((char *) dp, BLACK, (int) (height * width *
- X sizeof(unsigned char)));
- X resp->max_iter = limit;
- X return;
- X
- Xcompute_all:
- X
- X for (h = 0; h < height; h++)
- X {
- X q0 = q_min + h * q_inc;
- X for (w = 0; w < width; w++)
- X {
- X p0 = p_min + w * p_inc;
- X
- X MANDEL_MACRO
- X
- X if (iter < limit)
- X *dp++ = (unsigned char) ((iter % (NUM_COLORS - NUM_RESERVED)) +
- X NUM_RESERVED);
- X else
- X *dp++ = (unsigned char) BLACK;
- X
- X if (iter > max_iter)
- X max_iter = iter;
- X }
- X }
- X
- X resp->max_iter = max_iter;
- X}
- END_OF_FILE
- if test 3200 -ne `wc -c <'drone/mandelbrot.c'`; then
- echo shar: \"'drone/mandelbrot.c'\" unpacked with wrong size!
- fi
- # end of 'drone/mandelbrot.c'
- fi
- if test -f 'master/chaos.man' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'master/chaos.man'\"
- else
- echo shar: Extracting \"'master/chaos.man'\" \(9683 characters\)
- sed "s/^X//" >'master/chaos.man' <<'END_OF_FILE'
- X.TH CHAOS 6 "7 June 1990" "X Version 11"
- X.SH NAME
- Xchaos \- Explore the Mandelbrot set under X11.
- X.SH SYNOPSIS
- X.B chaos
- X[ \fIoptions\fR ]
- X.SH DESCRIPTION
- X.I Chaos
- Xprovides a simple tool for exploring the Mandelbrot set. The main window
- Xis a canvas where the images are displayed. The images are computed by
- X.I drone
- Xdaemons under the direction of the
- X.I chaos
- Xprocess.
- X.PP
- XWhen
- X.I drone
- Xprocesses are started, they locate the
- X.I chaos
- Xprocess using the selection CHAOS_WINDOW. For this reason only 1
- X.I chaos
- Xprocess is allowed to run per server.
- X.PP
- XThe right mouse button will bring up a menu that will support both click
- Xand drag modes of operation. From this menu, the following commands may be
- Xaccessed:
- X.IP Draw\
- XThis will start the drawing of the current image. If the image is partially
- Xdrawn, it will continue from that point. This command is not available if
- Xthere are no
- X.I drone
- Xprocesses running.
- X.IP Redraw
- XThis will start the drawing of the current image. If the image is partially
- Xdrawn, the previous image is cleared and the image is redrawn from the start.
- XThis command is not available if there are no
- X.I drone
- Xprocesses running.
- X.IP Zoom\
- XThis will zoom into the previously specified zoom region. A zoom region is
- Xselected by dragging out a rectangle with the left mouse button. If no zoom
- Xregion is currently specified, this option is not available. If the option
- Xfor retaining aspect ratios is set, then the area that is zoomed in on is
- Xcentered at the selected zoom region but the height or width is adjusted out
- Xso that the aspect ratio remains the same. With this option reset, the
- Xspecified zoom region is zoomed to exactly - potentially changing the aspect
- Xratio. Drawing of the next level image starts automatically after a zoom
- Xcommand.
- X.IP Unzoom
- XThis will return to the next image up the zoom stack. This option remains
- Xavailable until the top level (initial) image is returned to. Since the zoom
- Xstack is linear, a new zoom command after an unzoom command will erase the
- Xportion of the stack below the current point. To continue drawing of a partial
- Ximage at this level, the draw command may be given.
- X.IP Rezoom
- XThis performs the opposite function as the unzoom command returning to the
- Xnext image down the zoom stack. This option remains available until the lowest
- Xlevel image is returned to. To continue drawing of a partial image at this
- Xlevel, the draw command may be given.
- X.IP Top\ \
- XThis pops back to the top of the zoom stack. This option remains available
- Xwhile the current level is not already the top level. To continue drawing of
- Xa partial image at this level, the draw command may be given.
- X.IP Files
- XThis will pop up the File I/O Dialogbox. This dialogbox will contain a list
- Xof any previously saved images in the image directory. Image files have the
- Xextention .cif (chaos image format) which is simply an extension of the
- X.I xwd
- Xformat. This allows these files to be loaded with
- X.I xwud
- Xor processed by any utilities that recognize standard X window dumps.
- XWhen loading or removing an image, select the image from this list and press
- Xthe appropriate button. When saving an image, type the name in the text input
- Xbox and select the Save File button. An extension of .cif will be added if
- Xnecessary.
- X.IP Drones
- XThis will pop up the Drone Control Dialogbox. This dialogbox will allow
- Xdrones to be spawned or killed on the local host and on any other hosts that
- Xare known. The toggle list contains a button for each host and another button
- Xlabeled "All Hosts". The "All Hosts" button allows all the hosts to be toggled
- Xas a group. To the left of each hostname, there is a number in parenthesis.
- XThis number indicates the number of drones running on that host. The commands
- Xfrom this dialogbox are to spawn another drone, kill 1 drone, or kill all
- Xdrones on each of the hosts selected.
- X.IP Colormap
- XThis will pop up the Colormap Control Dialogbox. This dialogbox will allow
- Xthe current colormap to be altered and colormaps to be saved and loaded.
- XColor cells are edited by selecting one from the palette and adjusting the
- XRed, Green, and Blue values with the sliders to the right. The color mixing
- Xmode may be changed to Hue, Saturation, Brightness values by pressing the
- XRGB/HSB button.
- X.IP
- XThe header file contains a define for NUM_RESERVED which specifies the number
- Xof colors to reserve at the beginning of the colormap. The minimum is 2 so
- Xthat there will always be at least black and white. The minimum number
- Xfor use with
- X.I olwm
- Xrunning in 3-D mode should be 5 (white, black, and 3 shades
- Xof gray) although reserving 6 colors leaves 250 available which, being even,
- Xallows colormaps to be defined that match up better at the ends when the
- Xcolormap is rotated.
- X.IP Settings
- XThis will pop up the Settings Dialogbox. This dialogbox will allow various
- Xsettings to be adjusted. Two sliders control the width and height of a task.
- XAs an image is being drawn, it is broken up into tasks of this size and given
- Xto the drones for computation. There are toggles to keep tasks square
- Xand to retain the aspect ratio for zooms. A text input box allows the
- Xiteration limit to be modified. Changing the task size or the iteration limit
- Xwill not change any drawing that is in progress but will take effect after a
- Xzoom or redraw command. These settings are saved and loaded with each image
- X(as is the colormap).
- X.IP Quit\
- XThis will terminate the application. This also has the effect of terminating
- Xall
- X.I drone
- Xprocesses. Typing 'q' or Ctrl-C in the main window has the same
- Xeffect.
- X.PP
- X.I Chaos
- Xwill allow drones to be started or terminated at any time (even while
- Xdrawing). Tasks unfinished by drones are picked up by other drones.
- X.PP
- XColormap rotation can be toggled by pressing the
- X.I spacebar
- Xin the main window. The direction of the rotation may be toggled by pressing
- Xthe
- X.I return
- Xkey.
- X.PP
- X.SH OPTIONS
- XIn addition to the standard X toolkit command line and resource options,
- X.I chaos
- Xunderstands the following:
- X.TP
- X.B -help
- XProvides usage statement of the chaos specific options.
- X.TP
- X.BI -map \ path
- XUse
- X.I path
- Xas the directory path to look for colormap specification files.
- X.PP
- X.TP
- X.BI -image \ path
- XUse
- X.I path
- Xas the directory path when loading or saving chaos images.
- X.TP
- X.BI -zoom \ path
- XUse
- X.I path
- Xas the directory path for the zoom stack where the chaos image at each
- Xlevel is stored and retrieved.
- X.TP
- X.BI -task_width \ w
- XUse
- X.I w
- Xas the width of the tasks given to the drone processes.
- X.TP
- X.BI -task_height \ h
- XUse
- X.I h
- Xas the height of the tasks given to the drone processes.
- X.TP
- X.B -square
- XTurn off limitation that task regions be square.
- X.TP
- X.B -aspect
- XTurn off aspect ration preservation when zooming.
- X.TP
- X.BI -limit \ n
- XUse
- X.I n
- Xas the maximum number of iterations the calculation will be performed before
- Xthe point is considered to be within the Mandelbrot set. Choosing lower values
- Xwill speed up calculations near the edge of the set but will also result in
- Xa less detailed edge.
- X.TP
- X.BI -hosts \ list
- XUse
- X.I list
- Xas a list of hosts that are available to execute drone processes. If the list
- Xcontains more than one hostname it must be enclosed in quotes.
- X.SH DIALOGBOXES
- XThe dialogboxes in
- X.I chaos
- Xare modal. While a dialogbox is displayed, both the keyboard and the pointer
- Xare grabbed. Although this is anti-social, it was the simplest method to
- Xdirect keyboard input to where it was needed regardless of the position of
- Xthe pointer and to make reasonably sure that another application's window
- Xcould not be placed on top of the dialogbox once it was displayed.
- X.PP
- XDialogboxes may be controlled with a combination of pointer and keyboard
- Xactions. Only one control at a time has keyboard focus directed to it. This
- Xcontrol is marked with a small input focus arrow. To change the currently
- Xfocused control, the
- X.I tab
- Xand
- X.I reverse-tab
- X(shifted
- X.I tab)
- Xkeys are used. When the pointer is pressed in a control, the keyboard focus
- Xjumps to that control. In addition to using the pointer, button controls
- X(push, toggle, and radio) and the listbox control may be activated using the
- X.I return
- Xkey. Some or all of the arrow keys
- X(up, down, left, and right) will work for the controls (except pushbuttons).
- XTheir actions are defined by the widget and are fairly intuitive. The text
- Xinput widget supports a minimal subset of translations from the Xaw Text
- Xwidget.
- X.SH RESOURCES
- XThe resource file
- X.I Chaos.ad
- Xis placed in the app_defaults directory during installation. The contents of
- Xthis file may be tacked on to a user's private
- X.I .Xdefaults
- Xfile to allow custom defaults.
- X.SH BUGS
- XIf
- X.I xhost
- Xis not used to allow access by other hosts, then drones spawned on these
- Xremote machines will terminate silently.
- X.PP
- XIf the window manager being used is
- X.I twm,
- Xthere is a annoying bug when popping up dialogboxes from
- X.I chaos.
- XIf the pointer is outside the top level
- X.I chaos
- Xwindow when the dialogbox is mapped, the private colormap is not installed.
- XThis is do to the partially anti-social nature of the dialogboxes which
- Xuse override-redirect shells and grab the pointer and keyboard to implement
- Xa modal interface style. This bug does not appear with
- X.I olwm
- Xbut may appear with other window managers.
- X.PP
- XThe resource
- X.I dronePath
- Xspecifies the full path of the executable that
- X.I chaos
- Xwill use to execute the drone daemons from remote shells. If the drone
- Xexecutables have not been installed in this path,
- X.I chaos
- Xwill not be able to spawn remote processes.
- X.PP
- XGiven some colormaps, the rectangle for the zoom region can be hard to see
- Xor even invisible.
- X.SH SEE ALSO
- Xdrone(6), gencmap(6)
- X.SH AUTHOR
- XKen W. Marks
- END_OF_FILE
- if test 9683 -ne `wc -c <'master/chaos.man'`; then
- echo shar: \"'master/chaos.man'\" unpacked with wrong size!
- fi
- # end of 'master/chaos.man'
- fi
- if test -f 'master/fileDb.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'master/fileDb.c'\"
- else
- echo shar: Extracting \"'master/fileDb.c'\" \(10779 characters\)
- sed "s/^X//" >'master/fileDb.c' <<'END_OF_FILE'
- X/*
- X * Copyright (c) Ken W. Marks 1989, 1990.
- X */
- X
- X#include <stdio.h>
- X#include <signal.h>
- X#include <ctype.h>
- X#include <X11/Intrinsic.h>
- X#include <X11/StringDefs.h>
- X#include <X11/Xaw/Form.h>
- X#include <Chaos.h>
- X#include <LocalDefs.h>
- X#include <Colormap.h>
- X#include <Task.h>
- X#include <Canvas.h>
- X#include <DlgShell.h>
- X#include <Menu.h>
- X#include <MenuItems.h>
- X#include <Push.h>
- X#include <Text.h>
- X#include <List.h>
- X#include <Label.h>
- X
- X#define FILE_LABEL widgets[6]
- X#define FILE_TEXT widgets[1]
- X#define FILE_LIST widgets[2]
- X
- X#define FILE_LOAD widgets[3]
- X#define FILE_SAVE widgets[4]
- X#define FILE_REMOVE widgets[5]
- X#define DISMISS widgets[0]
- X
- X#define NUM_CONTROLS (unsigned) 6
- X#define NUM_LABELS (unsigned) 1
- X
- Xstatic void FilePushActivate();
- Xstatic void FileListActivate();
- Xstatic void FileLoadFile();
- Xstatic void FileSaveFile();
- Xstatic void FileRemoveFile();
- X
- Xvoid FileUpdateFileList();
- Xvoid SaveFileProceed();
- Xvoid RemoveFileProceed();
- X
- Xextern void ConfirmSetup();
- Xextern void MessageSetup();
- X
- Xextern Widget confirm_dialogbox;
- Xextern Widget message_dialogbox;
- X
- Xstatic Widget form, widgets[NUM_CONTROLS + NUM_LABELS];
- X
- Xstatic char file_buffer[64];
- Xstatic ListItem *file_list_items;
- X
- Xstatic char *file_not_found_msg =
- X"The file '%s/%s' does not exist!\nPlease specify a valid filename.";
- X
- Xstatic char *save_file_msg =
- X"The file '%s/%s' already exists!\nDo you really wish to overwrite this image file?";
- X
- Xstatic char *save_failed_msg =
- X"Cannot write to file '%s/%s'!";
- X
- Xstatic char *load_file_msg =
- X"Cannot load file '%s/%s'!\nPlease specify a valid image filename.";
- X
- Xstatic char *remove_file_msg =
- X"The file '%s/%s' will be lost!\nDo you really wish to remove this image file?";
- X
- Xstatic char *remove_failed_msg =
- X"Cannot remove file '%s/%s'!";
- X
- Xstatic XtCallbackRec push_callbacks[] = {
- X {FilePushActivate, NULL},
- X {NULL, NULL},
- X};
- X
- Xstatic XtCallbackRec list_callbacks[] = {
- X {FileListActivate, NULL},
- X {NULL, NULL},
- X};
- X
- Xstatic Arg PopupArgs[] = {
- X {XtNborderWidth, (XtArgVal) 3},
- X};
- X
- Xstatic Arg LabelArgs[] = {
- X {XtNfromHoriz, (XtArgVal) NULL},
- X {XtNfromVert, (XtArgVal) NULL},
- X {XtNhorizDistance, (XtArgVal) 10},
- X {XtNvertDistance, (XtArgVal) 10},
- X {XtNlabel, (XtArgVal) NULL},
- X {XtNresizable, (XtArgVal) False},
- X {XtNborderWidth, (XtArgVal) 0},
- X};
- X
- Xstatic Arg PushArgs[] = {
- X {XtNfromHoriz, (XtArgVal) NULL},
- X {XtNfromVert, (XtArgVal) NULL},
- X {XtNhorizDistance, (XtArgVal) 10},
- X {XtNvertDistance, (XtArgVal) 10},
- X {XtNlabel, (XtArgVal) NULL},
- X {XtNdialogbox, (XtArgVal) NULL},
- X {XtNcallback, (XtArgVal) push_callbacks},
- X {XtNresizable, (XtArgVal) False},
- X};
- X
- Xstatic Arg ListArgs[] = {
- X {XtNfromHoriz, (XtArgVal) NULL},
- X {XtNfromVert, (XtArgVal) NULL},
- X {XtNhorizDistance, (XtArgVal) 10},
- X {XtNvertDistance, (XtArgVal) 10},
- X {XtNlistItems, (XtArgVal) NULL},
- X {XtNdialogbox, (XtArgVal) NULL},
- X {XtNresizable, (XtArgVal) False},
- X {XtNborderWidth, (XtArgVal) 1},
- X {XtNcallback, (XtArgVal) list_callbacks},
- X {XtNlistDefault, (XtArgVal) NULL},
- X {XtNcharsWide, (XtArgVal) 31},
- X {XtNnumberVisible, (XtArgVal) 8},
- X {XtNlistDefault, (XtArgVal) - 1},
- X};
- X
- Xstatic Arg TextArgs[] = {
- X {XtNfromHoriz, (XtArgVal) NULL},
- X {XtNfromVert, (XtArgVal) NULL},
- X {XtNhorizDistance, (XtArgVal) 10},
- X {XtNvertDistance, (XtArgVal) 10},
- X {XtNbuffer, (XtArgVal) NULL},
- X {XtNdialogbox, (XtArgVal) NULL},
- X {XtNresizable, (XtArgVal) False},
- X {XtNbufferLen, (XtArgVal) NULL},
- X {XtNinitialText, (XtArgVal) NULL},
- X {XtNcharsWide, (XtArgVal) NULL},
- X};
- X
- X
- X/*ARGSUSED*/
- Xstatic void FilePushActivate(widget, client_data, call_data)
- XWidget widget;
- Xcaddr_t client_data;
- Xcaddr_t call_data;
- X{
- X extern Widget file_dialogbox;
- X extern char *FileCheckFilename();
- X char *new_filename;
- X
- X if (widget == DISMISS)
- X DialogPopdown(file_dialogbox);
- X else
- X {
- X new_filename = FileCheckFilename(file_buffer, ".cif");
- X TextChangeText(FILE_TEXT, new_filename);
- X if (new_filename == NULL)
- X return;
- X
- X if (widget == FILE_LOAD)
- X FileLoadFile();
- X else if (widget == FILE_SAVE)
- X FileSaveFile();
- X else if (widget == FILE_REMOVE)
- X FileRemoveFile();
- X }
- X}
- X
- X
- X/*ARGSUSED*/
- Xstatic void FileListActivate(widget, client_data, call_data)
- XWidget widget;
- Xcaddr_t client_data;
- Xcaddr_t call_data;
- X{
- X int item = (int) call_data;
- X
- X TextChangeText(FILE_TEXT, file_list_items[item].label);
- X}
- X
- X
- Xstatic void FileLoadFile()
- X{
- X char message[256];
- X extern char *image_dir;
- X extern Boolean LoadEverything();
- X extern Boolean FileExists();
- X extern void BlatzZoomStack();
- X extern int zoom_level;
- X extern Widget menu;
- X extern Widget canvas;
- X
- X if (FileExists(image_dir, file_buffer) == False)
- X {
- X /* Popup an error message box here */
- X (void) sprintf(message, file_not_found_msg, image_dir, file_buffer);
- X MessageSetup(message, (XtCallbackProc) NULL);
- X DialogPopup(message_dialogbox);
- X return;
- X }
- X
- X /* We reset the zoom stack when a load is performed */
- X zoom_level = 0;
- X BlatzZoomStack();
- X
- X /* cannot top any more */
- X (void) MenuChangeSensitivity(menu, MENU_TOP_ITEM, False);
- X
- X /* cannot unzoom any more */
- X (void) MenuChangeSensitivity(menu, MENU_UNZOOM_ITEM, False);
- X
- X /* zoom not allowed until another region is specified */
- X (void) MenuChangeSensitivity(menu, MENU_ZOOM_ITEM, False);
- X
- X /* rezoom are not allowed */
- X (void) MenuChangeSensitivity(menu, MENU_REZOOM_ITEM, False);
- X
- X MakeTasksStale();
- X WasteTasks();
- X
- X if (LoadEverything(image_dir, file_buffer) == False)
- X {
- X /* Popup an error message box here */
- X (void) sprintf(message, load_file_msg, image_dir, file_buffer);
- X MessageSetup(message, (XtCallbackProc) NULL);
- X DialogPopup(message_dialogbox);
- X return;
- X }
- X
- X /* Because this image was loaded, we must make sure this image gets saved
- X * in case we zoom */
- X CanvasTouchCanvas(canvas);
- X}
- X
- X
- Xstatic void FileSaveFile()
- X{
- X char message[256];
- X extern char *image_dir;
- X extern Boolean FileExists();
- X extern Boolean SaveEverything();
- X
- X if (FileExists(image_dir, file_buffer))
- X {
- X /* throw a dialogbox up for confirmation first */
- X (void) sprintf(message, save_file_msg, image_dir, file_buffer);
- X ConfirmSetup(message, SaveFileProceed);
- X DialogPopup(confirm_dialogbox);
- X }
- X else
- X SaveFileProceed((Widget) NULL, (caddr_t) NULL, (caddr_t) NULL);
- X}
- X
- X
- X/*ARGSUSED*/
- Xvoid SaveFileProceed(widget, client_data, call_data)
- XWidget widget; /* unused */
- Xcaddr_t client_data; /* unused */
- Xcaddr_t call_data; /* unused */
- X{
- X char message[256];
- X
- X if (SaveEverything(image_dir, file_buffer, False) == False)
- X {
- X /* Popup an error message box here */
- X (void) sprintf(message, save_failed_msg, image_dir, file_buffer);
- X MessageSetup(message, (XtCallbackProc) NULL);
- X DialogPopup(message_dialogbox);
- X return;
- X }
- X FileUpdateFileList();
- X}
- X
- X
- Xstatic void FileRemoveFile()
- X{
- X char message[256];
- X extern Boolean FileExists();
- X
- X if (FileExists(image_dir, file_buffer) == False)
- X {
- X /* Popup an error message box here */
- X (void) sprintf(message, file_not_found_msg, image_dir, file_buffer);
- X MessageSetup(message, (XtCallbackProc) NULL);
- X DialogPopup(message_dialogbox);
- X return;
- X }
- X /* throw a dialogbox up for confirmation first */
- X (void) sprintf(message, remove_file_msg, image_dir, file_buffer);
- X ConfirmSetup(message, RemoveFileProceed);
- X DialogPopup(confirm_dialogbox);
- X}
- X
- X
- X/*ARGSUSED*/
- Xvoid RemoveFileProceed(widget, client_data, call_data)
- XWidget widget; /* unused */
- Xcaddr_t client_data; /* unused */
- Xcaddr_t call_data; /* unused */
- X{
- X char message[256];
- X extern char *image_dir;
- X extern Boolean RemoveFile();
- X
- X if (RemoveFile(image_dir, file_buffer) == False)
- X {
- X /* Popup an error message box here */
- X (void) sprintf(message, remove_failed_msg, image_dir, file_buffer);
- X MessageSetup(message, (XtCallbackProc) NULL);
- X DialogPopup(message_dialogbox);
- X return;
- X }
- X
- X TextChangeText(FILE_TEXT, (String) NULL);
- X FileUpdateFileList();
- X}
- X
- X
- Xvoid FileUpdateFileList()
- X{
- X extern char **GetFileList();
- X extern void FreeFileList();
- X extern char *image_dir;
- X
- X if (file_list_items)
- X FreeFileList((char **) file_list_items);
- X
- X file_list_items = (ListItem *) GetFileList(image_dir, "*.cif");
- X if (file_list_items != NULL)
- X (void) ListChangeItems(FILE_LIST, file_list_items);
- X}
- X
- X
- XWidget FileCreateDialogbox(parent)
- XWidget parent;
- X{
- X Widget popup;
- X
- X popup = XtCreatePopupShell("file_dialogbox_popup",
- X dialogShellWidgetClass, parent, PopupArgs, XtNumber(PopupArgs));
- X
- X form = XtCreateManagedWidget("file_dialogbox_form", formWidgetClass,
- X popup, (ArgList) NULL, (Cardinal) 0);
- X
- X LabelArgs[0].value = (XtArgVal) NULL;
- X LabelArgs[1].value = (XtArgVal) NULL;
- X LabelArgs[4].value = (XtArgVal) "File:";
- X FILE_LABEL = XtCreateManagedWidget("file_label", labelWidgetClass,
- X form, LabelArgs, XtNumber(LabelArgs));
- X
- X TextArgs[0].value = (XtArgVal) FILE_LABEL;
- X TextArgs[1].value = (XtArgVal) NULL;
- X TextArgs[4].value = (XtArgVal) file_buffer;
- X TextArgs[5].value = (XtArgVal) popup;
- X TextArgs[7].value = (XtArgVal) 64;
- X TextArgs[9].value = (XtArgVal) 16;
- X FILE_TEXT = XtCreateManagedWidget("file_text", textWidgetClass,
- X form, TextArgs, XtNumber(TextArgs));
- X
- X ListArgs[0].value = (XtArgVal) NULL;
- X ListArgs[1].value = (XtArgVal) FILE_LABEL;
- X ListArgs[5].value = (XtArgVal) popup;
- X FILE_LIST = XtCreateManagedWidget("file_list", listWidgetClass,
- X form, ListArgs, XtNumber(ListArgs));
- X
- X PushArgs[0].value = (XtArgVal) FILE_LIST;
- X PushArgs[1].value = (XtArgVal) FILE_LABEL;
- X PushArgs[4].value = (XtArgVal) "Load File";
- X PushArgs[5].value = (XtArgVal) popup;
- X FILE_LOAD = XtCreateManagedWidget("load_file_push", pushWidgetClass,
- X form, PushArgs, XtNumber(PushArgs));
- X
- X PushArgs[0].value = (XtArgVal) FILE_LIST;
- X PushArgs[1].value = (XtArgVal) FILE_LOAD;
- X PushArgs[4].value = (XtArgVal) "Save File";
- X PushArgs[5].value = (XtArgVal) popup;
- X FILE_SAVE = XtCreateManagedWidget("save_file_push", pushWidgetClass,
- X form, PushArgs, XtNumber(PushArgs));
- X
- X PushArgs[0].value = (XtArgVal) FILE_LIST;
- X PushArgs[1].value = (XtArgVal) FILE_SAVE;
- X PushArgs[4].value = (XtArgVal) "Remove File";
- X PushArgs[5].value = (XtArgVal) popup;
- X FILE_REMOVE = XtCreateManagedWidget("remove_file_push",
- X pushWidgetClass, form, PushArgs, XtNumber(PushArgs));
- X
- X PushArgs[0].value = (XtArgVal) FILE_LIST;
- X PushArgs[1].value = (XtArgVal) FILE_REMOVE;
- X PushArgs[4].value = (XtArgVal) "Dismiss";
- X PushArgs[5].value = (XtArgVal) popup;
- X DISMISS = XtCreateManagedWidget("dismiss_push", pushWidgetClass,
- X form, PushArgs, XtNumber(PushArgs));
- X
- X DialogSetFocusOrder(popup, widgets, NUM_CONTROLS);
- X return (popup);
- X}
- END_OF_FILE
- if test 10779 -ne `wc -c <'master/fileDb.c'`; then
- echo shar: \"'master/fileDb.c'\" unpacked with wrong size!
- fi
- # end of 'master/fileDb.c'
- fi
- if test -f 'master/settingsDb.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'master/settingsDb.c'\"
- else
- echo shar: Extracting \"'master/settingsDb.c'\" \(8679 characters\)
- sed "s/^X//" >'master/settingsDb.c' <<'END_OF_FILE'
- X/*
- X * Copyright (c) Ken W. Marks 1989, 1990.
- X */
- X
- X#include <stdio.h>
- X#include <signal.h>
- X#include <ctype.h>
- X#include <X11/Intrinsic.h>
- X#include <X11/StringDefs.h>
- X#include <X11/Xaw/Form.h>
- X#include <Chaos.h>
- X#include <LocalDefs.h>
- X#include <Task.h>
- X#include <Colormap.h>
- X#include <Canvas.h>
- X#include <DlgShell.h>
- X#include <Push.h>
- X#include <Compound.h>
- X#include <Text.h>
- X#include <List.h>
- X#include <Slider.h>
- X#include <Palette.h>
- X#include <Label.h>
- X
- X#define WIDTH_LABEL widgets[6]
- X#define WIDTH_SLIDER widgets[1]
- X
- X#define HEIGHT_LABEL widgets[7]
- X#define HEIGHT_SLIDER widgets[2]
- X
- X#define SQUARE_TOGGLE widgets[3]
- X#define ASPECT_TOGGLE widgets[4]
- X
- X#define LIMIT_LABEL widgets[8]
- X#define LIMIT_TEXT widgets[5]
- X
- X#define DISMISS widgets[0]
- X
- X
- X#define NUM_CONTROLS (unsigned) 6
- X#define NUM_LABELS (unsigned) 3
- X
- Xextern Boolean keep_tasks_square;
- Xextern Boolean retain_aspect_ratio;
- Xextern int task_width, task_height;
- Xextern int iteration_limit;
- X
- Xstatic void SettingsPushActivate();
- Xstatic void SettingsSliderActivate();
- Xstatic void SettingsToggleActivate();
- X
- Xstatic Widget form, widgets[NUM_CONTROLS + NUM_LABELS];
- Xstatic char initial_limit[8];
- Xstatic char limit_buffer[16];
- X
- Xstatic ToggleItem square_item[] = {
- X {"Keep tasks square", True},
- X {NULL, NULL},
- X};
- X
- Xstatic ToggleItem aspect_item[] = {
- X {"Retain aspect ration (for zooms)", True},
- X {NULL, NULL},
- X};
- X
- Xstatic XtCallbackRec push_callbacks[] = {
- X {SettingsPushActivate, NULL},
- X {NULL, NULL},
- X};
- X
- Xstatic XtCallbackRec slider_callbacks[] = {
- X {SettingsSliderActivate, NULL},
- X {NULL, NULL},
- X};
- X
- Xstatic XtCallbackRec toggle_callbacks[] = {
- X {SettingsToggleActivate, NULL},
- X {NULL, NULL},
- X};
- X
- Xstatic Arg PopupArgs[] = {
- X {XtNborderWidth, (XtArgVal) 3},
- X};
- X
- Xstatic Arg LabelArgs[] = {
- X {XtNfromHoriz, (XtArgVal) NULL},
- X {XtNfromVert, (XtArgVal) NULL},
- X {XtNhorizDistance, (XtArgVal) 10},
- X {XtNvertDistance, (XtArgVal) 10},
- X {XtNlabel, (XtArgVal) NULL},
- X {XtNresizable, (XtArgVal) False},
- X {XtNborderWidth, (XtArgVal) 0},
- X};
- X
- Xstatic Arg PushArgs[] = {
- X {XtNfromHoriz, (XtArgVal) NULL},
- X {XtNfromVert, (XtArgVal) NULL},
- X {XtNhorizDistance, (XtArgVal) 10},
- X {XtNvertDistance, (XtArgVal) 10},
- X {XtNlabel, (XtArgVal) NULL},
- X {XtNdialogbox, (XtArgVal) NULL},
- X {XtNcallback, (XtArgVal) push_callbacks},
- X {XtNresizable, (XtArgVal) False},
- X};
- X
- Xstatic Arg ToggleArgs[] = {
- X {XtNfromHoriz, (XtArgVal) NULL},
- X {XtNfromVert, (XtArgVal) NULL},
- X {XtNhorizDistance, (XtArgVal) 10},
- X {XtNvertDistance, (XtArgVal) 10},
- X {XtNtoggleItems, (XtArgVal) NULL},
- X {XtNdialogbox, (XtArgVal) NULL},
- X {XtNresizable, (XtArgVal) False},
- X {XtNborderWidth, (XtArgVal) 0},
- X {XtNcallback, (XtArgVal) toggle_callbacks},
- X {XtNbuttonType, (XtArgVal) ToggleButton},
- X};
- X
- Xstatic Arg SliderArgs[] = {
- X {XtNfromHoriz, (XtArgVal) NULL},
- X {XtNfromVert, (XtArgVal) NULL},
- X {XtNhorizDistance, (XtArgVal) 10},
- X {XtNvertDistance, (XtArgVal) 10},
- X {XtNdialogbox, (XtArgVal) NULL},
- X {XtNcallback, (XtArgVal) slider_callbacks},
- X {XtNresizable, (XtArgVal) False},
- X {XtNminValue, (XtArgVal) 16},
- X {XtNmaxValue, (XtArgVal) 128},
- X {XtNdefaultPos, (XtArgVal) NULL},
- X};
- X
- Xstatic Arg TextArgs[] = {
- X {XtNfromHoriz, (XtArgVal) NULL},
- X {XtNfromVert, (XtArgVal) NULL},
- X {XtNhorizDistance, (XtArgVal) 10},
- X {XtNvertDistance, (XtArgVal) 10},
- X {XtNbuffer, (XtArgVal) limit_buffer},
- X {XtNdialogbox, (XtArgVal) NULL},
- X {XtNresizable, (XtArgVal) False},
- X {XtNbufferLen, (XtArgVal) 16},
- X {XtNinitialText, (XtArgVal) initial_limit},
- X {XtNcharsWide, (XtArgVal) 8},
- X};
- X
- X
- Xvoid SettingsSetLimit(new_limit)
- Xint new_limit;
- X{
- X char new_limit_buffer[8];
- X
- X (void) sprintf(new_limit_buffer, "%d", new_limit);
- X TextChangeText(LIMIT_TEXT, new_limit_buffer);
- X iteration_limit = new_limit;
- X}
- X
- X
- X/*ARGSUSED*/
- Xstatic void SettingsPushActivate(widget, client_data, call_data)
- XWidget widget;
- Xcaddr_t client_data;
- Xcaddr_t call_data;
- X{
- X extern Widget settings_dialogbox;
- X int new_limit;
- X
- X DialogPopdown(settings_dialogbox);
- X new_limit = atoi(limit_buffer);
- X SettingsSetLimit(new_limit);
- X}
- X
- X
- X/*ARGSUSED*/
- Xstatic void SettingsSliderActivate(widget, client_data, call_data)
- XWidget widget;
- Xcaddr_t client_data;
- Xcaddr_t call_data;
- X{
- X extern Widget canvas;
- X
- X if (widget == WIDTH_SLIDER)
- X {
- X task_width = (unsigned int) call_data;
- X if (keep_tasks_square)
- X {
- X task_height = task_width;
- X SliderChangePosition(HEIGHT_SLIDER, (int) task_height);
- X }
- X }
- X else if (widget == HEIGHT_SLIDER)
- X {
- X task_height = (unsigned int) call_data;
- X if (keep_tasks_square)
- X {
- X task_width = task_height;
- X SliderChangePosition(WIDTH_SLIDER, (int) task_width);
- X }
- X }
- X}
- X
- X
- X/*ARGSUSED*/
- Xstatic void SettingsToggleActivate(widget, client_data, call_data)
- XWidget widget;
- Xcaddr_t client_data;
- Xcaddr_t call_data;
- X{
- X extern Widget canvas;
- X
- X if (widget == ASPECT_TOGGLE)
- X CanvasChangeRetainAspect(canvas);
- X else if (widget == SQUARE_TOGGLE)
- X {
- X keep_tasks_square = ToggleGetState(widget, (unsigned) 0);
- X if (keep_tasks_square)
- X {
- X /* we take the average of the width and height and set the new
- X * width and hight from this (to make it square) */
- X task_width = task_height = (task_width + task_height) / 2;
- X
- X SliderChangePosition(WIDTH_SLIDER, (int) task_width);
- X SliderChangePosition(HEIGHT_SLIDER, (int) task_height);
- X }
- X }
- X}
- X
- X
- XWidget SettingsCreateDialogbox(parent)
- XWidget parent;
- X{
- X Widget popup;
- X
- X popup = XtCreatePopupShell("settings_dialogbox_popup",
- X dialogShellWidgetClass, parent, PopupArgs, XtNumber(PopupArgs));
- X
- X form = XtCreateManagedWidget("settings_dialogbox_form", formWidgetClass,
- X popup, (ArgList) NULL, (Cardinal) 0);
- X
- X LabelArgs[0].value = (XtArgVal) NULL;
- X LabelArgs[1].value = (XtArgVal) NULL;
- X LabelArgs[4].value = (XtArgVal) "Task width: ";
- X WIDTH_LABEL = XtCreateManagedWidget("width_label", labelWidgetClass,
- X form, LabelArgs, XtNumber(LabelArgs));
- X
- X SliderArgs[0].value = (XtArgVal) WIDTH_LABEL;
- X SliderArgs[1].value = (XtArgVal) NULL;
- X SliderArgs[4].value = (XtArgVal) popup;
- X SliderArgs[9].value = (XtArgVal) task_width;
- X WIDTH_SLIDER = XtCreateManagedWidget("width_slider", sliderWidgetClass,
- X form, SliderArgs, XtNumber(SliderArgs));
- X
- X LabelArgs[0].value = (XtArgVal) NULL;
- X LabelArgs[1].value = (XtArgVal) WIDTH_SLIDER;
- X LabelArgs[4].value = (XtArgVal) "Task height:";
- X HEIGHT_LABEL = XtCreateManagedWidget("height_label", labelWidgetClass,
- X form, LabelArgs, XtNumber(LabelArgs));
- X
- X SliderArgs[0].value = (XtArgVal) HEIGHT_LABEL;
- X SliderArgs[1].value = (XtArgVal) WIDTH_SLIDER;
- X SliderArgs[4].value = (XtArgVal) popup;
- X SliderArgs[9].value = (XtArgVal) task_height;
- X HEIGHT_SLIDER = XtCreateManagedWidget("height_slider", sliderWidgetClass,
- X form, SliderArgs, XtNumber(SliderArgs));
- X
- X /* Pull the value from the application resource */
- X square_item[0].state = keep_tasks_square;
- X
- X ToggleArgs[0].value = (XtArgVal) NULL;
- X ToggleArgs[1].value = (XtArgVal) HEIGHT_SLIDER;
- X ToggleArgs[4].value = (XtArgVal) square_item;
- X ToggleArgs[5].value = (XtArgVal) popup;
- X SQUARE_TOGGLE = XtCreateManagedWidget("square_toggle", compoundWidgetClass,
- X form, ToggleArgs, XtNumber(ToggleArgs));
- X
- X /* Pull the value from the application resource */
- X aspect_item[0].state = retain_aspect_ratio;
- X
- X ToggleArgs[0].value = (XtArgVal) NULL;
- X ToggleArgs[1].value = (XtArgVal) SQUARE_TOGGLE;
- X ToggleArgs[4].value = (XtArgVal) aspect_item;
- X ToggleArgs[5].value = (XtArgVal) popup;
- X ASPECT_TOGGLE = XtCreateManagedWidget("aspect_toggle", compoundWidgetClass,
- X form, ToggleArgs, XtNumber(ToggleArgs));
- X
- X LabelArgs[0].value = (XtArgVal) NULL;
- X LabelArgs[1].value = (XtArgVal) ASPECT_TOGGLE;
- X LabelArgs[4].value = (XtArgVal) "Iteration Limit:";
- X LIMIT_LABEL = XtCreateManagedWidget("limit_label", labelWidgetClass,
- X form, LabelArgs, XtNumber(LabelArgs));
- X
- X (void) sprintf(initial_limit, "%d", iteration_limit);
- X
- X TextArgs[0].value = (XtArgVal) LIMIT_LABEL;
- X TextArgs[1].value = (XtArgVal) ASPECT_TOGGLE;
- X TextArgs[5].value = (XtArgVal) popup;
- X LIMIT_TEXT = XtCreateManagedWidget("limit_text", textWidgetClass,
- X form, TextArgs, XtNumber(TextArgs));
- X
- X PushArgs[0].value = (XtArgVal) NULL;
- X PushArgs[1].value = (XtArgVal) LIMIT_LABEL;
- X PushArgs[4].value = (XtArgVal) "Dismiss";
- X PushArgs[5].value = (XtArgVal) popup;
- X DISMISS = XtCreateManagedWidget("dismiss_push", pushWidgetClass,
- X form, PushArgs, XtNumber(PushArgs));
- X
- X DialogSetFocusOrder(popup, widgets, NUM_CONTROLS);
- X
- X return (popup);
- X}
- END_OF_FILE
- if test 8679 -ne `wc -c <'master/settingsDb.c'`; then
- echo shar: \"'master/settingsDb.c'\" unpacked with wrong size!
- fi
- # end of 'master/settingsDb.c'
- fi
- if test -f 'widgets/Push.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'widgets/Push.c'\"
- else
- echo shar: Extracting \"'widgets/Push.c'\" \(9363 characters\)
- sed "s/^X//" >'widgets/Push.c' <<'END_OF_FILE'
- X/*
- X * Copyright (c) Ken W. Marks 1989, 1990.
- X */
- X
- X#include <stdio.h>
- X#include <X11/Intrinsic.h>
- X#include <X11/StringDefs.h>
- X#include <Chaos.h>
- X#include <LocalDefs.h>
- X#include <PushP.h>
- X#include <DlgShell.h>
- X
- X#define LEFT_ARC '\034'
- X#define RIGHT_ARC '\035'
- X#define ARROW '\037'
- X#define BLANK '\036'
- X
- Xstatic void PushInitialize();
- Xstatic void PushResize();
- Xstatic void PushRedisplay();
- Xstatic void PushDestroy();
- Xstatic void PushSet();
- Xstatic void PushNotify();
- Xstatic void PushReset();
- Xstatic void PushMark();
- Xstatic void PushGoto();
- Xstatic void PushFocusIn();
- Xstatic void PushFocusOut();
- X
- X
- X#define offset(field) XtOffset(PushWidget, push.field)
- Xstatic XtResource push_resources[] = {
- X {XtNcallback, XtCCallback, XtRCallback, sizeof(caddr_t),
- X offset(callbacks), XtRCallback, (caddr_t) NULL},
- X {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
- X offset(foreground), XtRString, "XtDefaultForeground"},
- X {XtNfontNormal, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
- X offset(normal_font), XtRString, "push-norm"},
- X {XtNfontReverse, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
- X offset(reverse_font), XtRString, "push-rev"},
- X {XtNlabel, XtCLabel, XtRString, sizeof(String),
- X offset(label), XtRString, NULL},
- X {XtNdialogbox, XtCWidget, XtRWidget, sizeof(Widget),
- X offset(dialogbox), XtRWidget, (caddr_t) NULL},
- X};
- X
- Xstatic XtActionsRec push_actions[] =
- X{
- X {"mark", PushMark},
- X {"goto", PushGoto},
- X {"set", PushSet},
- X {"notify", PushNotify},
- X {"reset", PushReset},
- X {"focus_in", PushFocusIn},
- X {"focus_out", PushFocusOut},
- X
- X};
- X
- X#define superclass (&simpleClassRec)
- X
- Xstatic char push_translations[] =
- X"<BtnDown>: mark() set()\n\
- X <BtnUp>: notify(BUTTON) reset()\n\
- X Button1<LeaveWindow>: reset()\n\
- X Button2<LeaveWindow>: reset()\n\
- X Button3<LeaveWindow>: reset()\n\
- X Button1<EnterWindow>: set()\n\
- X Button2<EnterWindow>: set()\n\
- X Button3<EnterWindow>: set()\n\
- X <Key>Return: notify(KEY)\n\
- X Shift<Key>Tab: goto(PREV)\n\
- X <Key>Tab: goto(NEXT)\n\
- X <FocusIn>: focus_in()\n\
- X <FocusOut>: focus_out()\n\
- X";
- X
- XPushClassRec pushClassRec = {
- X {
- X /* core fields */
- X /* superclass */ (WidgetClass) superclass,
- X /* class_name */ "Push",
- X /* widget_size */ sizeof(PushRec),
- X /* class_initialize */ NULL,
- X /* class_part_initialize */ NULL,
- X /* class_inited */ FALSE,
- X /* initialize */ PushInitialize,
- X /* initialize_hook */ NULL,
- X /* realize */ XtInheritRealize,
- X /* actions */ push_actions,
- X /* num_actions */ XtNumber(push_actions),
- X /* resources */ push_resources,
- X /* resource_count */ XtNumber(push_resources),
- X /* xrm_class */ NULLQUARK,
- X /* compress_motion */ TRUE,
- X /* compress_exposure */ TRUE,
- X /* compress_enterleave */ TRUE,
- X /* visible_interest */ FALSE,
- X /* destroy */ PushDestroy,
- X /* resize */ PushResize,
- X /* expose */ PushRedisplay,
- X /* set_values */ NULL,
- X /* set_values_hook */ NULL,
- X /* set_values_almost */ XtInheritSetValuesAlmost,
- X /* get_values_hook */ NULL,
- X /* accept_focus */ NULL,
- X /* version */ XtVersion,
- X /* callback_private */ NULL,
- X /* tm_table */ push_translations,
- X /* query_geometry */ NULL,
- X /* display_accelerator */ XtInheritDisplayAccelerator,
- X /* extension */ NULL
- X },
- X {
- X /* Simple class fields initialization */
- X /* change_sensitive */ XtInheritChangeSensitive
- X }
- X};
- X
- XWidgetClass pushWidgetClass = (WidgetClass) & pushClassRec;
- X
- X
- X/************************************************************/
- X/******************** Private Procedures ********************/
- X/************************************************************/
- X
- X
- Xstatic GC PushGetGC(w, font)
- XPushWidget w;
- XFont font;
- X{
- X XGCValues values;
- X
- X values.foreground = w->push.foreground;
- X values.background = w->core.background_pixel;
- X values.font = font;
- X
- X return (XtGetGC((Widget) w,
- X (unsigned) GCForeground | GCBackground | GCFont, &values));
- X}
- X
- X
- Xstatic void PushSetSize(w)
- XPushWidget w;
- X{
- X XtWidgetGeometry my_request;
- X XFontStruct *fs = w->push.normal_font;
- X
- X w->push.baseline = fs->max_bounds.ascent;
- X
- X my_request.request_mode = CWWidth | CWHeight | CWBorderWidth;
- X my_request.width = XTextWidth(fs, w->push.label, strlen(w->push.label));
- X my_request.height = fs->max_bounds.ascent + fs->max_bounds.descent;
- X my_request.border_width = 0;
- X
- X XtMakeGeometryRequest((Widget) w, &my_request, NULL);
- X}
- X
- X
- Xstatic void PushStoreLabel(w, label)
- XPushWidget w;
- Xchar *label;
- X{
- X w->push.label_len = strlen(label) + 3;
- X w->push.label = malloc((unsigned) w->push.label_len + 1);
- X (void) strcpy(&(w->push.label[2]), label);
- X w->push.label[0] = BLANK;
- X w->push.label[1] = LEFT_ARC;
- X w->push.label[w->push.label_len - 1] = RIGHT_ARC;
- X w->push.label[w->push.label_len] = 0;
- X}
- X
- X
- X/* ARGSUSED */
- Xstatic void PushInitialize(request, new)
- XWidget request;
- XWidget new;
- X{
- X PushWidget w = (PushWidget) new;
- X
- X if (w->push.dialogbox == NULL)
- X {
- X eprintf("XtNdialogbox not set\n");
- X abort();
- X }
- X
- X if (w->push.label == NULL)
- X {
- X eprintf("XtNLabel not set\n");
- X abort();
- X }
- X
- X PushStoreLabel(w, w->push.label);
- X
- X w->push.normal_gc = PushGetGC(w, w->push.normal_font->fid);
- X w->push.reverse_gc = PushGetGC(w, w->push.reverse_font->fid);
- X
- X w->push.set = False;
- X w->push.active = False;
- X
- X PushResize((Widget) w);
- X}
- X
- X
- X/* ARGSUSED */
- Xstatic void PushRedisplay(widget, event, region)
- XWidget widget;
- XXEvent *event;
- XRegion region;
- X{
- X PushWidget w = (PushWidget) widget;
- X GC gc;
- X
- X if (XtIsRealized(widget) == False)
- X return;
- X
- X gc = w->push.set ? w->push.reverse_gc : w->push.normal_gc;
- X
- X if (w->push.active == True)
- X w->push.label[0] = ARROW;
- X else
- X w->push.label[0] = BLANK;
- X
- X XDrawImageString(XtDisplay(w), XtWindow(w), gc, 0, w->push.baseline,
- X w->push.label, w->push.label_len);
- X}
- X
- X
- Xstatic void PushResize(widget)
- XWidget widget;
- X{
- X PushSetSize((PushWidget) widget);
- X}
- X
- X
- Xstatic void PushDestroy(widget)
- XWidget widget;
- X{
- X PushWidget w = (PushWidget) widget;
- X
- X XtReleaseGC(widget, w->push.normal_gc);
- X XtReleaseGC(widget, w->push.reverse_gc);
- X}
- X
- X
- Xstatic void PushDrawArrow(widget)
- XWidget widget;
- X{
- X PushWidget w = (PushWidget) widget;
- X Display *dpy = XtDisplay(w);
- X Window window = XtWindow(w);
- X char active_string[1];
- X
- X /* must convert the arrow/blank char into string for printing */
- X active_string[0] = w->push.active ? ARROW : BLANK;
- X
- X XDrawImageString(dpy, window, w->push.normal_gc, 0,
- X w->push.baseline, active_string, 1);
- X}
- X
- X
- X/***********************************************************/
- X/******************** Action Procedures ********************/
- X/***********************************************************/
- X
- X
- X/*ARGSUSED*/
- Xstatic void PushFocusIn(widget, event, params, num_params)
- XWidget widget;
- XXEvent *event;
- XString *params;
- XCardinal *num_params; /* unused */
- X{
- X PushWidget w = (PushWidget) widget;
- X
- X if (w->push.active == False)
- X {
- X w->push.active = True;
- X PushDrawArrow(widget);
- X }
- X}
- X
- X
- X/*ARGSUSED*/
- Xstatic void PushFocusOut(widget, event, params, num_params)
- XWidget widget;
- XXEvent *event;
- XString *params;
- XCardinal *num_params; /* unused */
- X{
- X PushWidget w = (PushWidget) widget;
- X
- X if (w->push.active == True)
- X {
- X w->push.active = False;
- X PushDrawArrow(widget);
- X }
- X}
- X
- X
- X/* ARGSUSED */
- Xstatic void PushSet(widget, event, params, num_params)
- XWidget widget;
- XXEvent *event;
- XString *params; /* unused */
- XCardinal *num_params; /* unused */
- X{
- X PushWidget w = (PushWidget) widget;
- X
- X w->push.set = True;
- X PushRedisplay(widget, (XEvent *) NULL, (Region) NULL);
- X}
- X
- X
- X/* ARGSUSED */
- Xstatic void PushReset(widget, event, params, num_params)
- XWidget widget;
- XXEvent *event;
- XString *params; /* unused */
- XCardinal *num_params;
- X{
- X PushWidget w = (PushWidget) widget;
- X
- X w->push.set = False;
- X PushRedisplay(widget, (XEvent *) NULL, (Region) NULL);
- X}
- X
- X
- X/* ARGSUSED */
- Xstatic void PushNotify(widget, event, params, num_params)
- XWidget widget;
- XXEvent *event;
- XString *params;
- XCardinal *num_params; /* unused */
- X{
- X PushWidget w = (PushWidget) widget;
- X
- X if (w->push.set || params[0][0] == 'K')
- X XtCallCallbacks(widget, XtNcallback, (XtPointer) w->push.dialogbox);
- X}
- X
- X
- X/* ARGSUSED */
- Xstatic void PushMark(widget, event, params, num_params)
- XWidget widget;
- XXEvent *event; /* unused */
- XString *params; /* unused */
- XCardinal *num_params; /* unused */
- X{
- X PushWidget w = (PushWidget) widget;
- X
- X w->push.active = True;
- X
- X DialogSetNewFocus(w->push.dialogbox, widget);
- X}
- X
- X
- X/* ARGSUSED */
- Xstatic void PushGoto(widget, event, params, num_params)
- XWidget widget;
- XXEvent *event; /* unused */
- XString *params;
- XCardinal *num_params; /* unused */
- X{
- X PushWidget w = (PushWidget) widget;
- X
- X switch (params[0][0])
- X {
- X case 'P':
- X DialogSetPrevFocus(w->push.dialogbox);
- X break;
- X
- X case 'N':
- X DialogSetNextFocus(w->push.dialogbox);
- X break;
- X }
- X
- X w->push.active = False;
- X PushDrawArrow(widget);
- X}
- X
- X
- X/***********************************************************/
- X/******************** Public Procedures ********************/
- X/***********************************************************/
- X
- Xvoid PushChangeLabel(widget, label)
- XWidget widget;
- Xchar *label;
- X{
- X PushWidget w = (PushWidget) widget;
- X
- X free(w->push.label);
- X PushStoreLabel(w, label);
- X PushSetSize(w);
- X PushRedisplay(widget, (XEvent *) NULL, (Region) NULL);
- X}
- END_OF_FILE
- if test 9363 -ne `wc -c <'widgets/Push.c'`; then
- echo shar: \"'widgets/Push.c'\" unpacked with wrong size!
- fi
- # end of 'widgets/Push.c'
- fi
- echo shar: End of archive 7 \(of 10\).
- cp /dev/null ark7isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 10 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
- dan
- ----------------------------------------------------
- O'Reilly && Associates argv@sun.com / argv@ora.com
- Opinions expressed reflect those of the author only.
-