[comp.sources.sun] v01i023: Tooltool - a suntools user interface builder, Part 04/13

mcgrew@dartagnan.rutgers.edu (Charles Mcgrew) (06/07/89)

Submitted-by: Chuck Musciano <chuck@trantor.harris-atd.com>
Posting-number: Volume 1, Issue 23
Archive-name: tooltool2.1c/part04

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 4 (of 13)."
# Contents:  actions.c events.c misc.c tooltool.h
# Wrapped by chuck@melmac on Thu Jun  1 10:39:29 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'actions.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'actions.c'\"
else
echo shar: Extracting \"'actions.c'\" \(8513 characters\)
sed "s/^X//" >'actions.c' <<'END_OF_FILE'
X/************************************************************************/
X/*	Copyright 1988 by Chuck Musciano and Harris Corporation		*/
X/*									*/
X/*	Permission to use, copy, modify, and distribute this software	*/
X/*	and its documentation for any purpose and without fee is	*/
X/*	hereby granted, provided that the above copyright notice	*/
X/*	appear in all copies and that both that copyright notice and	*/
X/*	this permission notice appear in supporting documentation, and	*/
X/*	that the name of Chuck Musciano and Harris Corporation not be	*/
X/*	used in advertising or publicity pertaining to distribution	*/
X/*	of the software without specific, written prior permission.	*/
X/*	Chuck Musciano and Harris Corporation make no representations	*/
X/*	about the suitability of this software for any purpose.  It is	*/
X/*	provided "as is" without express or implied warranty.		*/
X/*									*/
X/*	The sale of any product based wholely or in part upon the 	*/
X/*	technology provided by tooltool is strictly forbidden without	*/
X/*	specific, prior written permission from Harris Corporation.	*/
X/*	Tooltool technology includes, but is not limited to, the source	*/
X/*	code, executable binary files, specification language, and	*/
X/*	sample specification files.					*/
X/************************************************************************/
X
X#include	<stdio.h>
X#include	<ctype.h>
X
X#include	"tooltool.h"
X
X#include	<suntool/tty.h>
X
XPUBLIC	Tty	tty;
X
X/************************************************************************/
XPRIVATE	send_text(p)
X
Xchar	*p;
X
X{	int	len, sent;
X
X	if (tty)
X	   if (p && *p)
X	      for (len = strlen(p), sent = 0; sent < len; )
X	         sent += ttysw_input(tty, p + sent, len - sent);
X}
X
X/************************************************************************/
XPRIVATE	do_open()
X
X{	d_ptr	d;
X
X	window_set(tt_base_window->frame, FRAME_CLOSED, FALSE, 0);
X	for (d = tt_base_window->next; d; d = d->next)
X	   if (d->is_open)
X	window_set(d->frame, WIN_SHOW, TRUE, 0);
X}
X
X/************************************************************************/
XPRIVATE	do_close()
X
X{	d_ptr	d;
X
X	window_set(tt_base_window->frame, FRAME_CLOSED, TRUE, 0);
X	for (d = tt_base_window->next; d; d = d->next)
X	   if (d->is_open)
X	window_set(d->frame, WIN_SHOW, FALSE, 0);
X}
X
X/************************************************************************/
XEXPORT	a_ptr	tt_make_action(op, arg1, arg2, arg3, arg4)
X
Xint	op;
Xe_ptr	arg1, arg2, arg3, arg4;
X
X{	a_ptr	a;
X
X	a = (a_ptr) safe_malloc(sizeof(a_data));
X	a->next = NULL;
X	switch (a->op = op) {
X	   case BEEP_OP     :
X	   case BREAK_OP    :
X	   case CLOSE_OP    :
X	   case CONTINUE_OP :
X	   case EXIT_OP     :
X	   		      break;
X	   case DISPLAY_OP  : 
X	   case EXPR_OP     :
X	   case POPUP_OP    :
X	   case REMOVE_OP   :
X	   case SEND_OP     : a->expr = arg1;
X	   		      break;
X	   case FOR_OP      : a->init = arg1;
X	   		      a->expr = arg2;
X	   		      a->term = arg3;
X	   		      a->body = (a_ptr) arg4;
X	   		      break;
X	   case IF_OP       : a->expr = arg1;
X	   		      a->body = (a_ptr) arg2;
X	   		      a->else_part = (a_ptr) arg3;
X	   		      break;
X	   case WHILE_OP    : a->expr = arg1;
X	   		      a->body = (a_ptr) arg2;
X	   		      break;
X	   }
X	return(a);
X}
X
X/************************************************************************/
XEXPORT	tt_do_action(a)
X
Xa_ptr	a;
X
X{	d_ptr	d;
X	static	int	in_a_popup = FALSE, exit_pending = FALSE, close_pending = FALSE, open_pending = FALSE;
X	static	int	break_pending = FALSE, continue_pending = FALSE;
X
X	tt_action_depth++;
X	for ( ; a && !break_pending && !continue_pending; a = a->next) {
X	   tt_reset_emalloc();
X	   if (tt_timer_pending) {
X	      tt_timer_pending = FALSE;
X	      tt_do_action(tt_timer_action);
X	      }
X	   switch (a->op) {
X	      case BEEP_OP    : window_bell(tt_base_window->frame);
X	   		        break;
X	      case BREAK_OP   : break_pending = TRUE;
X	   		        break;
X	      case CLOSE_OP   : if (in_a_popup)
X	      			   close_pending = TRUE;
X	      			else
X	      			   do_close();
X	   		        break;
X	      case CONTINUE_OP: continue_pending = TRUE;
X	   		        break;
X	      case DISPLAY_OP : if (a->expr->symbol->kind == SYMBOL_SYMBOL)
X	      			   abend("display: cannot display %s, which is not a dialog box or gadget", a->expr->symbol->name);
X	      			else if (a->expr->symbol->kind == SYMBOL_GADGET) {
X	      			   if (a->expr->symbol->gadget == NULL)
X	      			      abend("dialog box %s was never defined", a->expr->symbol->name);
X	      			   panel_set(a->expr->symbol->gadget->panel_item, PANEL_SHOW_ITEM, TRUE, 0);
X	      			   }
X	      			else {
X	      			   if ((d = a->expr->symbol->dialog) == NULL)
X	      			      abend("dialog box %s was never defined", a->expr->symbol->name);
X	      			   window_set(d->frame, WIN_SHOW, TRUE, 0);
X	      			   tt_do_action(d->open_action);
X	      			   d->is_open = TRUE;
X	      			   d->is_popup = FALSE;
X	      			   }
X	   		        break;
X	      case EXIT_OP    : if (in_a_popup)
X	      			   exit_pending = TRUE;
X	      			else
X	      			   exit(0);
X	   		        break;
X	      case EXPR_OP    : tt_eval(a->expr);
X	   		        break;
X	      case FOR_OP     : for (tt_eval(a->init); (int) tt_eval(a->expr)->number; tt_eval(a->term)) {
X	      			   tt_do_action(a->body);
X	      			   if (break_pending) {
X	      			      break_pending = FALSE;
X	      			      break;
X	      			      }
X	      			   if (continue_pending) {
X	      			      continue_pending = FALSE;
X	      			      continue;
X	      			      }
X	      			   }
X	   		        break;
X	      case IF_OP      : tt_do_action(((int) tt_eval(a->expr)->number)? a->body : a->else_part);
X	   		        break;
X	      case OPEN_OP    : if (in_a_popup)
X	      			   open_pending = TRUE;
X	      			else
X	      			   do_open();
X	   		        break;
X	      case POPUP_OP   : if (a->expr->symbol->kind != SYMBOL_DIALOG)
X	      			   abend("popup: %s is not a dialog box", a->expr->symbol->name);
X	      			else if ((d = a->expr->symbol->dialog) == NULL)
X	      			   abend("dialog box %s was never defined", a->expr->symbol->name);
X	      			else if (d->is_open)
X	      			   abend("popup: dialog box %s is already open", a->expr->symbol->name);
X	      			else if (in_a_popup)
X	      			   abend("nested popup windows are not allowed");
X	      			d->is_open = TRUE;
X	      			d->is_popup = TRUE;
X	      			tt_do_action(d->open_action);
X	      			in_a_popup = TRUE;
X	      			window_loop(d->frame);
X	      			in_a_popup = FALSE;
X	      			tt_do_action(d->close_action);
X	      			d->is_open = FALSE;
X	      			d->is_popup = TRUE;
X	      			if (close_pending)
X	      			   do_close();
X	      			if (open_pending)
X	      			   do_open();
X	      			if (exit_pending)
X	      			   exit(0);
X	      			close_pending = open_pending = exit_pending = FALSE;
X	   		        break;
X	      case REMOVE_OP  : if (a->expr->symbol->kind == SYMBOL_SYMBOL)
X	      			   abend("remove: cannot remove %s, which is not a dialog box or gadget", a->expr->symbol->name);
X	      			else if (a->expr->symbol->kind == SYMBOL_GADGET) {
X	      			   if (a->expr->symbol->gadget == NULL)
X	      			      abend("gadget %s was never defined", a->expr->symbol->name);
X	      			   panel_set(a->expr->symbol->gadget->panel_item, PANEL_SHOW_ITEM, FALSE, 0);
X	      			   }
X	      			else {
X	      			   if ((d = a->expr->symbol->dialog) == NULL)
X	      			      abend("dialog box %s was never defined", a->expr->symbol->name);
X	      			   if (d->is_open)
X	      			      if (d->is_popup)
X	      			         window_return(0);
X	      			      else {
X	      			         window_set(d->frame, WIN_SHOW, FALSE, 0);
X	      			         tt_do_action(d->close_action);
X	      			         d->is_open = FALSE;
X	      			         d->is_popup = FALSE;
X	      			         }
X	      			   }
X	   		        break;
X	      case SEND_OP    : send_text(tt_string_of(tt_eval(a->expr)));
X	   		        break;
X	      case WHILE_OP   : while ((int) tt_eval(a->expr)->number) {
X	      			   tt_do_action(a->body);
X	      			   if (break_pending) {
X	      			      break_pending = FALSE;
X	      			      break;
X	      			      }
X	      			   if (continue_pending) {
X	      			      continue_pending = FALSE;
X	      			      continue;
X	      			      }
X	      			   }
X	   		        break;
X	      default	      : abend("Internal error! Undefined action: %d", a->op);
X	      }
X	   }
X	if (--tt_action_depth == 0) {
X	   if (continue_pending)
X	      abend("continue action used outside of a while or for action");
X	   break_pending = FALSE;
X	   }
X}
END_OF_FILE
if test 8513 -ne `wc -c <'actions.c'`; then
    echo shar: \"'actions.c'\" unpacked with wrong size!
fi
# end of 'actions.c'
fi
if test -f 'events.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'events.c'\"
else
echo shar: Extracting \"'events.c'\" \(10873 characters\)
sed "s/^X//" >'events.c' <<'END_OF_FILE'
X/************************************************************************/
X/*	Copyright 1988 by Chuck Musciano and Harris Corporation		*/
X/*									*/
X/*	Permission to use, copy, modify, and distribute this software	*/
X/*	and its documentation for any purpose and without fee is	*/
X/*	hereby granted, provided that the above copyright notice	*/
X/*	appear in all copies and that both that copyright notice and	*/
X/*	this permission notice appear in supporting documentation, and	*/
X/*	that the name of Chuck Musciano and Harris Corporation not be	*/
X/*	used in advertising or publicity pertaining to distribution	*/
X/*	of the software without specific, written prior permission.	*/
X/*	Chuck Musciano and Harris Corporation make no representations	*/
X/*	about the suitability of this software for any purpose.  It is	*/
X/*	provided "as is" without express or implied warranty.		*/
X/*									*/
X/*	The sale of any product based wholely or in part upon the 	*/
X/*	technology provided by tooltool is strictly forbidden without	*/
X/*	specific, prior written permission from Harris Corporation.	*/
X/*	Tooltool technology includes, but is not limited to, the source	*/
X/*	code, executable binary files, specification language, and	*/
X/*	sample specification files.					*/
X/************************************************************************/
X
X#include	<stdio.h>
X#include	<ctype.h>
X
X#include	"tooltool.h"
X
X#include	<suntool/tty.h>
X
XPUBLIC	Tty	tty;
X
XPRIVATE	int	value_invalid = FALSE;
XPRIVATE	struct	itimerval	timer_int;
X
X/************************************************************************/
X/* These routines deal with managing tooltool events			*/
X/************************************************************************/
X
X/************************************************************************/
XPRIVATE	int	get_shifts(event)
X
XEvent	*event;
X
X{	int	shifts = 0;
X
X	if (event_shift_is_down(event))
X	   shifts += S_SHIFT;
X	if (event_ctrl_is_down(event))
X	   shifts += S_CONTROL;
X	if (event_meta_is_down(event))
X	   shifts += S_META;
X	return(shifts);
X}
X
X/************************************************************************/
XPRIVATE	int	is_a_function_key(event)
X
XEvent	*event;
X
X{
X	return(event_is_key_left(event) || event_is_key_top(event) || event_is_key_right(event));
X}
X
X/************************************************************************/
XPRIVATE	a_ptr	key_is_mapped(event)
X
XEvent	*event;
X
X{	int	set, key;
X	a_ptr	a;
X
X	if (event_is_key_left(event)) {
X	   set = LEFT_KEY_SET;
X	   key = event_id(event) - KEY_LEFT(1);
X	   }
X	else if (event_is_key_top(event)) {
X	   set = TOP_KEY_SET;
X	   key = event_id(event) - KEY_TOP(1);
X	   }
X	else if (event_is_key_right(event)) {
X	   set = RIGHT_KEY_SET;
X	   key = event_id(event) - KEY_RIGHT(1);
X	   }
X	else
X	   return(NULL);
X	return(tt_func_keys[set][key][get_shifts(event)]);
X}
X
X/************************************************************************/
XPRIVATE	timer_proc()
X
X{
X	if (tt_action_depth > 0)
X	   tt_timer_pending = TRUE;
X	else
X	   tt_do_action(tt_timer_action);
X}
X
X/************************************************************************/
XEXPORT	Panel_setting	notify_proc(item, event)
X
XPanel_item	item;
XEvent		*event;
X
X{	g_ptr	b;
X	char	*p, buf[1024];
X	int	i;
X	cv_ptr	cv;
X
X	b = (g_ptr) panel_get(item, PANEL_CLIENT_DATA);
X	if (b->kind == GADGET_BUTTON)
X	   tt_do_action(b->u.but.action[get_shifts(event)]);
X	else if (b->kind == GADGET_TEXT) {
X	   if (index(b->u.tex.completion, event_id(event))) {
X	      p = (char *) panel_get(item, PANEL_VALUE);
X	      if (p = (char *) expand_filename(p))
X	         panel_set(item, PANEL_VALUE, p, 0);
X	      else
X	         window_bell(panel_get(item, PANEL_PARENT_PANEL));
X	      }
X	   else if (index(b->u.tex.trigger, event_id(event)))
X	      tt_do_action(b->u.tex.action);
X	   else if (event_id(event) == '\t')
X	      if (event_shift_is_down(event))
X	         panel_backup_caret(panel_get(item, PANEL_PARENT_PANEL));
X	      else
X	         panel_advance_caret(panel_get(item, PANEL_PARENT_PANEL));
X	   else if (!index(b->u.tex.ignore, event_id(event)))
X	      return(PANEL_INSERT);
X	   return(PANEL_NONE);
X	   }
X	else if (b->kind == GADGET_CHOICE) {
X	   i = (int) panel_get(item, PANEL_VALUE);
X	   for (cv = b->u.cho.value; i && cv; i--, cv = cv->next)
X	      ;
X	   if (cv)
X	      tt_do_action(cv->action);
X	   }
X	else if (b->kind == GADGET_SLIDER)
X	   tt_do_action(b->u.sli.action);
X}
X
X/************************************************************************/
XEXPORT	event_proc(item, event)
X
XPanel_item	item;
XEvent		*event;
X
X{	char	c;
X	g_ptr	b;
X	a_ptr	a;
X	d_ptr	d;
X
X	d = (d_ptr) window_get(panel_get(item, PANEL_PARENT_PANEL), WIN_CLIENT_DATA);
X	b = (g_ptr) panel_get(item, PANEL_CLIENT_DATA);
X	if (event_is_ascii(event) || event_is_meta(event))
X	   if (d->text_items_exist || tt_normal_off)
X	      if (b->kind == GADGET_TEXT && event_id(event) == '\t')
X	         notify_proc(item, event);
X	      else
X	         panel_default_handle_event(item, event);
X	   else {
X	      c = event_id(event);
X	      if (tty)
X	         ttysw_input(tty, &c, 1);
X	      }
X	else if (is_a_function_key(event)) {
X	   if (a = key_is_mapped(event)) {
X	      if (event_is_down(event))
X	         tt_do_action(a);
X	      }
X	   else if (!tt_function_off)
X	      panel_default_handle_event(item, event);
X	   }
X	else { /* handle each panel item type separately */
X	   if (b->kind == GADGET_BUTTON) {
X	      if (event_is_down(event) && event_id(event) == MS_RIGHT)
X	         tt_do_action(menu_show(b->u.but.menu, d->panel, event, 0));
X	      else
X	         panel_default_handle_event(item, event);
X	      }
X	   else if (b->kind == GADGET_MENU) {
X	      if (event_is_down(event) && event_id(event) == MS_RIGHT) {
X	         a = (a_ptr) menu_show(b->u.men.menu, d->panel, event, 0);
X	         if (value_invalid)
X	            value_invalid = FALSE;
X	         else
X	            tt_do_action(a);
X	         }
X	      else
X	         panel_default_handle_event(item, event);
X	      }
X	   else
X	      panel_default_handle_event(item, event);
X	   }
X}
X
X/************************************************************************/
XEXPORT	background_proc(panel, event)
X
XPanel	panel;
XEvent	*event;
X
X{	char	c;
X	a_ptr	a;
X	d_ptr	d;
X
X	d = (d_ptr) window_get(panel, WIN_CLIENT_DATA);
X	if (event_is_ascii(event) || event_is_meta(event))
X	   if (d->text_items_exist || tt_normal_off)
X	      panel_default_handle_event(panel, event);
X	   else {
X	      c = event_id(event);
X	      if (tty)
X	         ttysw_input(tty, &c, 1);
X	      }
X	else if (is_a_function_key(event)) {
X	   if (a = key_is_mapped(event)) {
X	      if (event_is_down(event))
X	         tt_do_action(a);
X	      }
X	   else if (!tt_function_off)
X	      panel_default_handle_event(panel, event);
X	   }
X	else
X	   panel_default_handle_event(panel, event);
X}
X
X/************************************************************************/
XPRIVATE	Notify_value	handle_mouse(button, shift, tty, event, arg, type)
X
Xint			button;
Xint			shift;
XTty			tty;
XEvent			*event;
XNotify_arg		arg;
XNotify_event_type	type;
X
X{	int	x, y;
X	a_ptr	a;
X
X	if (tt_mouse_chars) {
X	   x = event_x(event) / charwidth_of(tt_a_font) + tt_mouse_base;
X	   y = event_y(event) / charheight_of(tt_a_font) + tt_mouse_base;
X	   }
X	else {
X	   x = event_x(event) + tt_mouse_base;
X	   y = event_y(event) + tt_mouse_base;
X	   }
X	if (tt_mouse[button][shift].defined == MOUSE_UNDEFINED)
X	   return(notify_next_event_func(tty, event, arg, type));
X	else if (tt_mouse[button][shift].defined == MOUSE_STRING)
X	   a = tt_mouse[button][shift].action;
X	else if (tt_mouse[button][shift].defined == MOUSE_MENU) {
X	   a = (a_ptr) menu_show(tt_mouse[button][shift].menu, tty, event, 0);
X	   if (value_invalid) {
X	      a = NULL;
X	      value_invalid = FALSE;
X	      }
X	   }
X	tt_mouse_x->value->number = x;
X	tt_mouse_y->value->number = y;
X	tt_do_action(a);
X	return(NOTIFY_DONE);
X}
X
X/************************************************************************/
XEXPORT	Menu	ttymenu_proc(m, op)
X
XMenu	m;
XMenu_generate	op;
X
X{
X	value_invalid = TRUE;
X	return(tt_ttymenu);
X}
X
X/************************************************************************/
XEXPORT	Notify_value	close_proc(win, event, arg, type)
X
XWindow	win;
XEvent	*event;
XNotify_arg	arg;
XNotify_event_type	type;
X
X{	int	init_closed, curr_closed;
X	Notify_value	value;
X	d_ptr	d;
X
X	init_closed = (int) window_get(tt_base_window->frame, FRAME_CLOSED);
X	value = notify_next_event_func(win, event, arg, type);
X	curr_closed = (int) window_get(tt_base_window->frame, FRAME_CLOSED);
X	if (init_closed != curr_closed)
X	   if (curr_closed) { /* transition from open to closed */
X	      tt_do_action(tt_base_window->close_action);
X	      for (d = tt_base_window->next; d; d = d->next)
X	         if (d->is_open)
X	            window_set(d->frame, WIN_SHOW, FALSE, 0);
X	      }
X	   else { /* transition from closed to open */
X	      tt_do_action(tt_base_window->open_action);
X	      for (d = tt_base_window->next; d; d = d->next)
X	         if (d->is_open)
X	            window_set(d->frame, WIN_SHOW, TRUE, 0);
X	      }
X	return(value);
X}
X
X/************************************************************************/
XEXPORT	Notify_value	tty_handler(tty, event, arg, type)
X
XTty			tty;
XEvent			*event;
XNotify_arg		arg;
XNotify_event_type	type;
X
X{	a_ptr	a;
X
X	if ((event_is_ascii(event) || event_is_meta(event)) && tt_normal_off)
X	   return(NOTIFY_DONE);
X	else if (is_a_function_key(event)) {
X	   if (a = key_is_mapped(event)) {
X	      if (event_is_down(event))
X	         tt_do_action(a);
X	      }
X	   else if (!tt_function_off)
X	      return(close_proc(tty, event, arg, type));
X	   return(NOTIFY_DONE);
X	   }
X	else if (event_id(event) == MS_LEFT && event_is_down(event))
X	   return(handle_mouse(MOUSE_LEFT, get_shifts(event), tty, event, arg, type));
X	else if (event_id(event) == MS_MIDDLE && event_is_down(event))
X	   return(handle_mouse(MOUSE_CENTER, get_shifts(event), tty, event, arg, type));
X	else if (event_id(event) == MS_RIGHT && event_is_down(event))
X	   return(handle_mouse(MOUSE_RIGHT, get_shifts(event), tty, event, arg, type));
X	else
X	   return(close_proc(tty, event, arg, type));
X}
X
X/************************************************************************/
XEXPORT	Notify_value	tt_dialog_done(frame)
X
XFrame	frame;
X
X{	d_ptr	d;
X
X	d = (d_ptr) window_get(frame, WIN_CLIENT_DATA);
X	d->is_open = FALSE;
X	tt_do_action(d->close_action);
X	window_set(frame, WIN_SHOW, FALSE, 0);
X	return(NOTIFY_DONE);
X}
X
X/************************************************************************/
XEXPORT	tt_set_timer(sec, usec)
X
Xint	sec;
Xint	usec;
X
X{
X	if (sec != 0 || usec != 0) {
X	   timer_int.it_value.tv_sec = timer_int.it_interval.tv_sec = sec;
X	   timer_int.it_value.tv_usec = timer_int.it_interval.tv_usec = usec;
X	   notify_set_itimer_func(tt_base_window->frame, timer_proc, ITIMER_REAL, &timer_int, NULL);
X	   }
X	else
X	   notify_set_itimer_func(tt_base_window->frame, timer_proc, ITIMER_REAL, NULL, NULL);
X}
END_OF_FILE
if test 10873 -ne `wc -c <'events.c'`; then
    echo shar: \"'events.c'\" unpacked with wrong size!
fi
# end of 'events.c'
fi
if test -f 'misc.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'misc.c'\"
else
echo shar: Extracting \"'misc.c'\" \(11000 characters\)
sed "s/^X//" >'misc.c' <<'END_OF_FILE'
X/************************************************************************/
X/*	Copyright 1988 by Chuck Musciano and Harris Corporation		*/
X/*									*/
X/*	Permission to use, copy, modify, and distribute this software	*/
X/*	and its documentation for any purpose and without fee is	*/
X/*	hereby granted, provided that the above copyright notice	*/
X/*	appear in all copies and that both that copyright notice and	*/
X/*	this permission notice appear in supporting documentation, and	*/
X/*	that the name of Chuck Musciano and Harris Corporation not be	*/
X/*	used in advertising or publicity pertaining to distribution	*/
X/*	of the software without specific, written prior permission.	*/
X/*	Chuck Musciano and Harris Corporation make no representations	*/
X/*	about the suitability of this software for any purpose.  It is	*/
X/*	provided "as is" without express or implied warranty.		*/
X/*									*/
X/*	The sale of any product based wholely or in part upon the 	*/
X/*	technology provided by tooltool is strictly forbidden without	*/
X/*	specific, prior written permission from Harris Corporation.	*/
X/*	Tooltool technology includes, but is not limited to, the source	*/
X/*	code, executable binary files, specification language, and	*/
X/*	sample specification files.					*/
X/************************************************************************/
X
X#include	<stdio.h>
X#include	<ctype.h>
X#include	<sgtty.h>
X#include	<pwd.h>
X
X#include	<sys/types.h>
X#include	<sys/stat.h>
X#include	<sys/dir.h>
X#include	<sys/file.h>
X
X#include	<suntool/sunview.h>
X#include	<suntool/icon_load.h>
X
X#include	"tooltool.h"
X
XPUBLIC	char	*index(), *rindex(), *getenv();
X
Xtypedef	struct	pc_rec	pc_data, *pc_ptr;
Xtypedef	struct	fc_rec	fc_data, *fc_ptr;
X
Xstruct	pc_rec	{char	*path;
X		 struct	pixrect	*image;
X		 pc_ptr	next;
X		};
X
Xstruct	fc_rec	{char	*path;
X		 struct	pixfont	*font;
X		 fc_ptr	next;
X		};
X
XPRIVATE	pc_ptr	pix_cache = NULL;
XPRIVATE	fc_ptr	font_cache = NULL;
X
X/************************************************************************/
XEXPORT	char	*safe_malloc(size)
X
Xint	size;
X
X{	char	*p;
X
X	if (p = (char *) malloc(size))
X	   return(p);
X	else
X	   abend("insufficient memory available");
X}
X
X/************************************************************************/
XEXPORT	safe_free(p)
X
Xchar	*p;
X
X{
X	free(p);
X}
X
X/************************************************************************/
XEXPORT	tokenize(line, argc, argv, maxv)
X
Xchar	*line;
Xint	*argc;
Xchar	*argv[];
Xint	maxv;
X
X{	char	*buf, match, *delimiters;
X
X	*argc = 0;
X	buf = (char *) tt_emalloc(strlen(line) * 2 + 1);
X	if ((delimiters = tt_string_of(tt_delimiters->value)) == NULL)
X	   delimiters = " \t\n\r\"'";
X	while (*line && (*argc < (maxv - 1))) {
X	   while (*line && index(delimiters, *line))
X	      if (*line == '"' || *line == '\'')
X	         break;
X	      else
X	         line++;
X	   if (*line == '\0')
X	      break;
X	   argv[(*argc)++] = buf;
X	   if (index(delimiters, *line)) { /* scanning a quoted string */
X	      match = *line++; /* remove the quote mark */
X	      while (*line && (*line != match))
X	         *buf++ = *line++;
X	      if (*line)
X	         line++; /* wipe out quote mark */
X	      }
X	   else {
X	      while (*line && !index(delimiters, *line))
X	         *buf++ = *line++;
X	      }
X	   *buf++ = '\0';
X	   }
X	*buf = '\0';
X	argv[*argc] = (char *) 0;
X}
X
X/************************************************************************/
XEXPORT	struct	pixrect	*tt_load_icon(path)
X
Xchar	*path;
X
X{	char	msg[IL_ERRORMSG_SIZE];
X	struct	pixrect	*p;
X	FILE	*f;
X	pc_ptr	pc;
X
X	for (pc = pix_cache; pc; pc = pc->next)
X	   if (strcmp(path, pc->path) == 0)
X	      return(pc->image);
X	if ((p = icon_load_mpr(path, msg)) == NULL) { /* not in icon format */
X	   if ((f = fopen(path, "r")) == NULL)
X	      abend("could not open %s", path);
X	   if ((p = pr_load(f, NULL)) == NULL)
X	      abend("%s must be in either icon or raster file format", path);
X	   fclose(f);
X	   }
X	pc = (pc_ptr) safe_malloc(sizeof(pc_data));
X	pc->path = strsave(path);
X	pc->image = p;
X	pc->next = pix_cache;
X	pix_cache = pc;
X	return(p);
X}
X
X/************************************************************************/
XEXPORT	struct	pixfont	*tt_open_font(path)
X
Xchar	*path;
X
X{	struct	pixfont	*p;
X	fc_ptr	pf;
X
X	for (pf = font_cache; pf; pf = pf->next)
X	   if (strcmp(path, pf->path) == 0)
X	      return(pf->font);
X	if ((p = pf_open(path)) == NULL)
X	   abend("cannot open font: %s", path);
X	pf = (fc_ptr) safe_malloc(sizeof(fc_data));
X	pf->path = strsave(path);
X	pf->font = p;
X	pf->next = font_cache;
X	font_cache = pf;
X	return(p);
X}
X
X/************************************************************************/
XEXPORT	int	text_width(text, font)
X
Xunsigned	char	*text;
Xstruct	pixfont	*font;
X
X{	int	width;
X
X	for (width = 0; *text; text++)
X	   width += font->pf_char[*text].pc_adv.x;
X	return(width);
X}
X
X/************************************************************************/
XPRIVATE	char	*root_path(path)
X
Xchar	*path;
X
X{	char	*p;
X
X	if (p = rindex(path, '/'))
X	   if (p == path)
X	      p[1] = '\0';
X	   else
X	      *p = '\0';
X	else
X	   *path = '\0';
X	return(path);
X}
X
X/************************************************************************/
XPRIVATE	char	*last_node(path)
X
Xchar	*path;
X
X{	char	*p;
X
X	return((p = rindex(path, '/'))? p + 1 : path);
X}
X
X/************************************************************************/
XEXPORT	char	*expand_filename(path)
X
Xchar	*path;
X
X{	static	char	s[1024];
X	char	pattern[1024], candidate[1024], *p,*q;
X	DIR	*dir;
X	struct	direct *dp;
X	struct	passwd	*pw;
X
X	strcpy(s, path);
X	if (*path == '~')
X	   if (path[1] == '/' || path[1] == '\0') {
X	      strcpy(s, getenv("HOME"));
X	      strcat(s, path + 1);
X	      }
X	   else {
X	      if ((p = index(path, '/')) != NULL)
X	         *p = '\0';
X	      if ((pw = getpwnam(path + 1)) != NULL) {
X	         strcpy(s, pw->pw_dir);
X	         if (p != NULL) {
X	            strcat(s, "/");
X	            strcat(s, p + 1);
X	            }
X	         }
X	      else
X	         return(NULL);
X	      }
X	strcpy(pattern, last_node(s));
X	if (*pattern == '\0')
X	   return(s);
X	root_path(s);
X	candidate[0] = '\0';
X	if (*s == '\0')
X	   strcpy(s, ".");
X	if ((dir = opendir(s)) == NULL) {
X	   strcpy(s, path);
X	   return(s);
X	   }
X	while ((dp = readdir(dir)) != NULL)
X	   if (strncmp(dp->d_name, pattern, strlen(pattern)) == 0)
X	      if (*candidate == '\0')
X	         strcpy(candidate, dp->d_name);
X	      else {
X	         for (p = candidate, q = dp->d_name; *p == *q; p++, q++)
X	            ;
X	         *p = '\0';
X	         }
X	closedir(dir);
X	if (*candidate == '\0')
X	   return(NULL);
X	else {
X	   if (strcmp(s, ".") == 0)
X	      *s = '\0';
X	   else if (s[strlen(s) - 1] != '/')
X	      strcat(s, "/");
X	   strcat(s, candidate);
X	   }
X	return(s);
X}
X
X/************************************************************************/
XEXPORT	tt_construct_label(l)
X
Xl_ptr	l;
X
X{	struct	pr_prpos	where;
X
X	if (!l->is_icon && l->image == NULL) {
X	   l->image = mem_create(text_width(l->label, l->font), l->font->pf_defaultsize.y, 1);
X	   where.pr = l->image;
X	   where.pos.x = 0;
X	   where.pos.y = baseline_of(l->font);
X	   pf_text(where, PIX_SRC, l->font, l->label);
X	   }
X}
X
X/************************************************************************/
XEXPORT	l_ptr	tt_make_label(is_icon, label, font, image)
X
Xint	is_icon;
Xchar	*label;
XPixfont	*font;
Xstruct	pixrect	*image;
X
X{	l_ptr	l;
X
X	l = (l_ptr) safe_malloc(sizeof(l_data));
X	l->is_icon = is_icon;
X	l->label = label;
X	l->font = font;
X	l->image = image;
X	return(l);
X}
X
X/************************************************************************/
XEXPORT	d_ptr	tt_make_base_window()
X
X{	d_ptr	d;
X
X	d = (d_ptr) safe_malloc(sizeof(d_data));
X	d->frame = NULL;
X	d->panel = NULL;
X	d->is_base_frame = FALSE;
X	d->is_open = TRUE;
X	d->is_popup = FALSE;
X	d->rows = 24;
X	d->columns = 80;
X	d->win_x = -1;
X	d->win_y = -1;
X	d->is_chars = TRUE;
X	d->g_align = NO_ALIGN;
X	d->proportional = FALSE;
X	d->justified = TRUE;
X	d->text_items_exist = FALSE;
X	d->gadget_pos = G_NOPOS;
X	d->gadgets = NULL;
X	d->label = NULL;
X	d->open_action = NULL;
X	d->close_action = NULL;
X	d->g_font = tt_default_font;
X	d->next = NULL;
X	return(d);
X}
X
X/************************************************************************/
XEXPORT	abend(s1, s2, s3, s4, s5, s6, s7, s8, s9)
X
Xchar	*s1, *s2, *s3, *s4, *s5, *s6, *s7, *s8, *s9;
X
X{
X	fprintf(stderr, "%s: ", tt_program);
X	fprintf(stderr, s1, s2, s3, s4, s5, s6, s7, s8, s9);
X	fprintf(stderr, "\n");
X	exit(1);
X}
X
X/************************************************************************/
XEXPORT	int	tt_is_number(s)
X
Xregister	char	*s;
X
X{	register	int	saw_digit = FALSE;
X
X	if (*s == '-' || *s == '+')
X	   s++;
X	for ( ; isdigit(*s); s++)
X	   saw_digit = TRUE;
X	if (*s == '.')
X	   for (s++; isdigit(*s); s++)
X	      saw_digit = TRUE;
X	if (*s == 'e' || *s == 'E') {
X	   if (*++s == '-' || *s == '+')
X	      s++;
X	   for ( ; isdigit(*s); s++)
X	      saw_digit = TRUE;
X	   }
X	return(saw_digit && *s == '\0');
X}
X
X/************************************************************************/
XEXPORT	int	tt_dict_compare(l, r)
X
Xchar	*l;
Xchar	*r;
X
X{	register	char	*p, *q;
X
X	for (p = l; isdigit(*p); p++)
X	   ;
X	for (q = r; isdigit(*q); q++)
X	   ;
X	if (*p || *q)
X	   return(strcmp(l, r));
X	else
X	   return(atoi(l) - atoi(r));
X}
X
X/************************************************************************/
XEXPORT	char	*tt_expand_ranges(s)
X
Xunsigned	char	*s;
X
X{	unsigned	char	*p, buf[1024];
X	int	c;
X
X	for (p = buf; *s; s) {
X	   *p++ = *s++;
X	   if (*s == '-' && *(s + 1) != '\0') {
X	      for (c = *(p - 1), s++; c <= *s; )
X	         *p++ = c++;
X	      s++;
X	      }
X	   }
X	*p = '\0';
X	return(strsave(buf));
X}
X
X/************************************************************************/
XEXPORT	wait_for_window_size(width, height, timeout)
X
Xint	width;
Xint	height;
Xint	timeout; /* in milliseconds */
X
X{	struct	winsize	win;
X
X	if (width > 0 && height > 0)
X	   do {
X	      if (ioctl(fileno(stderr), TIOCGWINSZ, &win) < 0)
X	         abend("could not obtain the window size");
X	      usleep(50000);
X	      } while ((win.ws_row != height || win.ws_col != width) && (timeout -= 50) > 0);
X}
X
X/************************************************************************/
XEXPORT	int	tt_perm_of(st)
X
Xstruct	stat	*st;
X
X{
X	if (getuid() == st->st_uid)
X	   return((st->st_mode & 0700) >> 6);
X	else if (getgid() == st->st_gid)
X	   return((st->st_mode & 070) >> 3);
X	else
X	   return((st->st_mode & 07));
X}
X
X/************************************************************************/
XEXPORT	char	*tt_full_path_of(s, mode)
X
Xchar	*s;
Xint	mode;
X
X{	char	*path, *p, *q;
X	static	char	full_path[1024];
X	struct	stat	buf;
X
X	if (*s == '/')
X	   return(s);
X	path = getenv("PATH");
X	for (p = path, q = full_path; TRUE; )
X	   if (*p == ':' || *p == '\0') {
X	      *q = '\0';
X	      strcat(full_path, "/");
X	      strcat(full_path, s);
X	      if (stat(full_path, &buf) == 0 && ((buf.st_mode & S_IFMT) == S_IFREG) && access(full_path, mode) == 0)
X	         return(full_path);
X	      q = full_path;
X	      if (*p++ == '\0')
X	         return(s);
X	      }
X	   else
X	      *q++ = *p++;
X}
END_OF_FILE
if test 11000 -ne `wc -c <'misc.c'`; then
    echo shar: \"'misc.c'\" unpacked with wrong size!
fi
# end of 'misc.c'
fi
if test -f 'tooltool.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tooltool.h'\"
else
echo shar: Extracting \"'tooltool.h'\" \(10629 characters\)
sed "s/^X//" >'tooltool.h' <<'END_OF_FILE'
X/************************************************************************/
X/*	Copyright 1988 by Chuck Musciano and Harris Corporation		*/
X/*									*/
X/*	Permission to use, copy, modify, and distribute this software	*/
X/*	and its documentation for any purpose and without fee is	*/
X/*	hereby granted, provided that the above copyright notice	*/
X/*	appear in all copies and that both that copyright notice and	*/
X/*	this permission notice appear in supporting documentation, and	*/
X/*	that the name of Chuck Musciano and Harris Corporation not be	*/
X/*	used in advertising or publicity pertaining to distribution	*/
X/*	of the software without specific, written prior permission.	*/
X/*	Chuck Musciano and Harris Corporation make no representations	*/
X/*	about the suitability of this software for any purpose.  It is	*/
X/*	provided "as is" without express or implied warranty.		*/
X/*									*/
X/*	The sale of any product based wholely or in part upon the 	*/
X/*	technology provided by tooltool is strictly forbidden without	*/
X/*	specific, prior written permission from Harris Corporation.	*/
X/*	Tooltool technology includes, but is not limited to, the source	*/
X/*	code, executable binary files, specification language, and	*/
X/*	sample specification files.					*/
X/************************************************************************/
X
X
X#include	<suntool/sunview.h>
X#include	<suntool/panel.h>
X
X/* Help delineate where routines are used and defined
X */
X#define		PUBLIC			extern
X#define		PRIVATE			static
X#define		EXPORT
X
X#define		strsave(s)		((char *) strcpy((char *) safe_malloc(strlen(s) + 1), s))
X#define		estrsave(s)		((char *) strcpy((char *) tt_emalloc(strlen(s) + 1), s))
X#define		baseline_of(f)		(-((f)->pf_char['0'].pc_home.y))
X#define		charwidth_of(f)		((f)->pf_char['0'].pc_adv.x)
X#define		charheight_of(f)	((f)->pf_defaultsize.y)
X#define		value_of(v)		((v)->is_number? (v)->number : 0.0)
X
X/* The gadget position possibilities
X */
X#define		G_NOPOS			-1
X#define		G_TOP			0
X#define		G_BOTTOM		1
X#define		G_LEFT			2
X#define		G_RIGHT			3
X
X/* The shift states available for various function keys
X */
X#define		S_NORMAL		0
X#define		S_SHIFT			1
X#define		S_CONTROL		2
X#define		S_META			4
X#define		MAX_SHIFT_SETS		8
X
X/* The kind of gadgets we can create
X */
X#define		GADGET_BUTTON		0
X#define		GADGET_CHOICE		1
X#define		GADGET_LABEL		2
X#define		GADGET_MENU		3
X#define		GADGET_SLIDER		4
X#define		GADGET_TEXT		5
X
X/* Special functions that gadgets can perform
X */
X#define		BEEP_OP			0
X#define		BREAK_OP		1
X#define		CLOSE_OP		2
X#define		CONTINUE_OP		3
X#define		DISPLAY_OP		4
X#define		EXIT_OP			5
X#define		EXPR_OP			6
X#define		FOR_OP			7
X#define		IF_OP			8
X#define		OPEN_OP			9
X#define		POPUP_OP		10
X#define		REMOVE_OP		11
X#define		SEND_OP			12
X#define		WHILE_OP		13
X
X/* How labels are aligned with respect to each other
X */
X#define		NO_ALIGN		0
X#define		ALIGN_TOP		1
X#define		ALIGN_MIDDLE		2
X#define		ALIGN_BOTTOM		3
X
X/* The different function key sets on a Sun-3 keyboard
X */
X#define		LEFT_KEY_SET		0
X#define		TOP_KEY_SET		1
X#define		RIGHT_KEY_SET		2
X#define		MAX_KEY_SETS		3
X
X#define		MAX_FUNC_KEYS		15
X
X/* Mouse buttons
X */
X#define		MOUSE_LEFT		0
X#define		MOUSE_CENTER		1
X#define		MOUSE_RIGHT		2
X
X#define		MAX_MOUSE_BUTTONS	3
X
X/* The functions a mouse key can perform
X */
X#define		MOUSE_UNDEFINED		0
X#define		MOUSE_STRING		1
X#define		MOUSE_MENU		2
X
X/* The ways a choice gadget can be laid out
X */
X#define		CHOICE_CURRENT		0
X#define		CHOICE_CYCLE		1
X#define		CHOICE_HORIZONTAL	2
X#define		CHOICE_VERTICAL		3
X
X/* The kinds of symbols a user can define
X */
X#define		SYMBOL_SYMBOL		0
X#define		SYMBOL_GADGET		1
X#define		SYMBOL_DIALOG		2
X
X/* Various expression operators
X */
X#define		E_AND			0
X#define		E_ARRAY_REF		1
X#define		E_ASSIGN_AND		2
X#define		E_ASSIGN_DIVIDE		3
X#define		E_ASSIGN_MINUS		4
X#define		E_ASSIGN_MODULO		5
X#define		E_ASSIGN_OR		6
X#define		E_ASSIGN_PLUS		7
X#define		E_ASSIGN_TIMES		8
X#define		E_ASSIGN_XOR		9
X#define		E_ASSIGNMENT		10
X#define		E_COMMA			11
X#define		E_COMPLEMENT		12
X#define		E_DIVIDE		13
X#define		E_EQUAL			14
X#define		E_FUNC_ID		15
X#define		E_GREATER		16
X#define		E_GREATER_EQUAL		17
X#define		E_LEFT_SHIFT		18
X#define		E_LESS			19
X#define		E_LESS_EQUAL		20
X#define		E_LOGICAL_AND		21
X#define		E_LOGICAL_NOT		22
X#define		E_LOGICAL_OR		23
X#define		E_MINUS			24
X#define		E_MODULO		25
X#define		E_NOT_EQUAL		26
X#define		E_NUMBER		27
X#define		E_OR			28
X#define		E_PAREN			29
X#define		E_PLUS			30
X#define		E_POSTDECREMENT		31
X#define		E_POSTINCREMENT		32
X#define		E_PREDECREMENT		33
X#define		E_PREINCREMENT		34
X#define		E_QUESTION		35
X#define		E_RIGHT_SHIFT		36
X#define		E_STRING		37
X#define		E_SYMBOL		38
X#define		E_TIMES			39
X#define		E_UMINUS		40
X#define		E_XOR			41
X
X/* The kinds of values we can express.
X */
X#define		V_NOTHING		0
X#define		V_ARRAY			1
X#define		V_GADGET		2
X#define		V_NUMBER		4
X#define		V_INTERVAL		8
X
X#define		V_TYPES			(V_ARRAY | V_NUMBER)
X#define		V_SPECIAL		(V_GADGET | V_INTERVAL)
X
X#define		is_array(v)		((v)->kind & V_ARRAY)
X#define		is_gadget(v)		((v)->kind & V_GADGET)
X#define		is_number(v)		((v)->kind & V_NUMBER)
X#define		is_interval(v)		((v)->kind & V_INTERVAL)
X
X/* Special things used to beat a Suntools window size bug
X */
X#define		POLLING_MAGIC_NUMBER	"\001\002\003\004"
X#define		POLLING_TIME_OUT	20000 /* milliseconds */
X
X/* The data necessary to describe a label.  If "is_icon" is FALSE,
X * "label" holds the label text, and "font" holds the label font.
X * If TRUE, "image" holds the bitmap of the icon for the label.
X */
Xtypedef	struct	l_rec	l_data, *l_ptr;
X
Xstruct	l_rec	{int	is_icon;
X		 char	*label;
X		 struct	pixfont	*font;
X		 struct	pixrect	*image;
X		};
X
X/* The data needed to describe a gadget.  "Kind" is one of 
X * GADGET_*, above, and indicates which portion of the union
X * is valid for this gadget.  "Image" contains the image bitmap
X * for buttons and menus, and labels if they are icons.  Sliders
X * and choices have their own, SunView-created, images.  For all
X * gadgets, "width" and "height" are set to reflect the image
X * bounding box, for gadget layout purposes.  The gadgets are 
X * linked together via "next".
X */
X
Xtypedef	struct	a_rec	a_data, *a_ptr;
Xtypedef	struct	cv_rec	cv_data, *cv_ptr;
Xtypedef struct	d_rec	d_data, *d_ptr;
Xtypedef	struct	e_rec	e_data, *e_ptr;
Xtypedef	struct	g_rec	g_data, *g_ptr;
Xtypedef	struct	s_rec	s_data, *s_ptr;
Xtypedef	struct	v_rec	v_data, *v_ptr;
X
Xtypedef	v_ptr	(*f_ptr)();
X
Xstruct	but_rec	{l_ptr	label[MAX_SHIFT_SETS];
X		 a_ptr	action[MAX_SHIFT_SETS];
X		 Menu	menu;
X		};
X
Xstruct	cv_rec	{l_ptr	label;
X		 a_ptr	action;
X		 cv_ptr	next;
X		};
X
Xstruct	cho_rec	{l_ptr	label;
X		 int	mode;
X		 int	ch_width;
X		 int	ch_height;
X		 l_ptr	mark;
X		 l_ptr	nomark;
X		 cv_ptr	value;
X		};
X
Xstruct	lab_rec	{l_ptr	label;
X		};
X
Xstruct	men_rec	{l_ptr	label;
X		 Menu	menu;
X		};
X
Xstruct	sli_rec	{l_ptr	label;
X		 int	minimum;
X		 int	maximum;
X		 int	initial;
X		 int	value;
X		 int	range;
X		 int	width;
X		 a_ptr	action;
X		 struct	pixfont	*font;
X		};
X
Xstruct	tex_rec	{l_ptr	label;
X		 char	*trigger;
X		 char	*completion;
X		 char	*ignore;
X		 int	display_len;
X		 int	retain_len;
X		 a_ptr	action; 
X		 struct	pixfont	*font;
X		};
X
Xstruct	g_rec	{int	kind;
X		 char	*name;
X		 Panel_item	panel_item;
X		 struct	pixrect	*image;
X		 int	width;
X		 int	height;
X		 int	x;
X		 int	y;
X		 g_ptr	next;
X		 union	{struct	but_rec	but;
X		 	 struct	cho_rec	cho;
X		 	 struct	lab_rec	lab;
X		 	 struct	men_rec	men;
X		 	 struct	sli_rec	sli;
X		 	 struct	tex_rec	tex;
X		 	} u;
X		};
X
X/* The data necessary to describe an action.
X */
Xstruct	a_rec	{int	op;
X		 e_ptr	init;
X		 e_ptr	expr;
X		 e_ptr	term;
X		 a_ptr	body;
X		 a_ptr	else_part;
X		 a_ptr	next;
X		};
X
X/* The data necessary to describe an expression
X */
Xstruct	e_rec	{int	op;
X		 e_ptr	left;
X		 e_ptr	right;
X		 e_ptr	extra;
X		 s_ptr	symbol;
X		 char	*string;
X		 double	value;
X		 f_ptr	func;
X		};
X
X/* The data necessary to describe a value
X */
Xstruct	v_rec	{int	kind;
X		 char	*str;	/* except when an array */
X		 double	number;	/* if a number */
X		 g_ptr	gadget;	/* if a gadget */
X		 char	*index; /* array element index string */
X		 v_ptr	value;	/* if an array */
X		 v_ptr	left;	/* links for array element tree */
X		 v_ptr	right;
X		};
X
X/* The data necessary to describe a symbol.
X */
Xstruct	s_rec	{int	kind;
X		 char	*name;
X		 g_ptr	gadget;		/* if a gadget */
X		 d_ptr	dialog;		/* if a dialog */
X		 v_ptr	value;		/* if a symbol */
X		 s_ptr	left;
X		 s_ptr	right;
X		};
X
X/* The data necessary to describe a panel
X */
Xstruct	d_rec	{Frame	frame;
X		 Panel	panel;
X		 int	is_base_frame;
X		 int	is_open;
X		 int	is_popup;
X		 int	rows;
X		 int	columns;
X		 int	win_x;
X		 int	win_y;
X		 int	is_chars;
X		 int	g_align;
X		 int	proportional;
X		 int	justified;
X		 int	text_items_exist;
X		 int	gadget_pos;
X		 g_ptr	gadgets;
X		 char	*label;
X		 a_ptr	open_action;
X		 a_ptr	close_action;
X		 struct	pixfont	*g_font;
X		 d_ptr	next;
X		};
X
X/* A mouse record holds operation to be performed by one mouse
X * button/shift-state combination.  "Defined" is one of 
X * MOUSE_{UNDEFINED,STRING,MENU}.  If MOUSE_STRING, "value" holds
X * the text to be transmitted.  If MOUSE_MENU, "menu" holds
X * the menu to be displayed.
X */
Xtypedef	struct	m_rec	m_data;
X
Xstruct	m_rec	{int	defined;
X		 a_ptr	action;
X		 Menu	menu;
X		};
X
X/* A variety of public data.  All globals begin with "tt_".
X */
XPUBLIC	a_ptr	tt_initial_action,
X		tt_timer_action,
X		tt_func_keys[MAX_KEY_SETS][MAX_FUNC_KEYS][MAX_SHIFT_SETS];
X
XPUBLIC	char	*tt_application,
X		*tt_curr_file,
X		*tt_icon,
X		*tt_program;
X
XPUBLIC	d_ptr	tt_base_window;
X
XPUBLIC	int	tt_mouse_base,
X		tt_mouse_chars,
X		tt_errors_occured,
X		tt_normal_off,
X		tt_function_off,
X		tt_action_depth,
X		tt_timer_pending;
X
XPUBLIC	l_ptr	tt_default_mark,
X		tt_default_nomark,
X		tt_default_cycle;
X
XPUBLIC	m_data	tt_mouse[MAX_MOUSE_BUTTONS][MAX_SHIFT_SETS];
X
XPUBLIC	Menu	tt_ttymenu;
X
XPUBLIC	struct	pixfont	*tt_default_font,
X			*tt_a_font;
X
XPUBLIC	struct	pixrect	tt_mark_image,
X			tt_nomark_image,
X			tt_cycle_image;
X
XPUBLIC	s_ptr	tt_mouse_x, tt_mouse_y, tt_delimiters;
X
X/* Public routines which do not return void.
X */
XPUBLIC	char	*safe_malloc();
XPUBLIC	struct	pixrect	*tt_load_icon();
XPUBLIC	struct	pixfont	*tt_open_font();
XPUBLIC	l_ptr	tt_make_label();
XPUBLIC	a_ptr	tt_make_action();
XPUBLIC	s_ptr	tt_find_symbol();
XPUBLIC	v_ptr	tt_get_value();
XPUBLIC	d_ptr	tt_make_base_window();
XPUBLIC	e_ptr	tt_make_expr();
XPUBLIC	v_ptr	tt_eval();
XPUBLIC	char	*tt_string_of();
XPUBLIC	f_ptr	tt_is_function();
XPUBLIC	char	*tt_emalloc();
XPUBLIC	v_ptr	tt_int_result();
XPUBLIC	v_ptr	tt_double_result();
XPUBLIC	v_ptr	tt_string_result();
XPUBLIC	v_ptr	tt_insert_array();
XPUBLIC	char	*tt_get_selection();
XPUBLIC	char	*tt_expand_ranges();
XPUBLIC	char	*tt_full_path_of();
END_OF_FILE
if test 10629 -ne `wc -c <'tooltool.h'`; then
    echo shar: \"'tooltool.h'\" unpacked with wrong size!
fi
# end of 'tooltool.h'
fi
echo shar: End of archive 4 \(of 13\).
cp /dev/null ark4isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 13 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


Chuck Musciano			ARPA  : chuck@trantor.harris-atd.com
Harris Corporation 		Usenet: ...!uunet!x102a!trantor!chuck
PO Box 37, MS 3A/1912		AT&T  : (407) 727-6131
Melbourne, FL 32902		FAX   : (407) 727-{5118,5227,4004}