home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-04-06 | 31.5 KB | 1,026 lines |
-
- #! /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 17 (of 32)."
- # Contents: starchart/starXaw.c
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'starchart/starXaw.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'starchart/starXaw.c'\"
- else
- echo shar: Extracting \"'starchart/starXaw.c'\" \(29848 characters\)
- sed "s/^X//" >'starchart/starXaw.c' <<'END_OF_FILE'
- X/*
- X * Driver creates X11 window and draws starchart information inside.
- X * Intially window size is variable, but it stays constant once it's
- X * mapped. It handles expose events, even while it's drawing.
- X * Includes glyphs for variable stars.
- X *
- X * Rewritten from scratch July 1989
- X *
- X * Copyright (c) 1990 by Craig Counterman. All rights reserved.
- X *
- X * This software may be redistributed freely, not sold.
- X * This copyright notice and disclaimer of warranty must remain
- X * unchanged.
- X *
- X * No representation is made about the suitability of this
- X * software for any purpose. It is provided "as is" without express or
- X * implied warranty, to the extent permitted by applicable law.
- X *
- X */
- X
- Xstatic char rcsid[]="$Header: starXaw.c,v 1.9 90/03/10 15:33:34 ccount Exp $";
- X
- X#include <stdio.h>
- X#include <math.h>
- X
- X#include "star3.h"
- X#include "starXaw.h"
- X
- X#ifndef SYSV
- X#include <strings.h>
- X#else
- X#include <string.h>
- X#endif
- X
- X#include <X11/cursorfont.h>
- X#include <X11/Intrinsic.h>
- X#include <X11/StringDefs.h>
- X#include <X11/Shell.h>
- X#ifdef X11R4
- X#include <X11/Xaw/Command.h>
- X#include <X11/Xaw/Form.h>
- X#include <X11/Xaw/Box.h>
- X#define ASCII_STRING
- X#define XAW_BC
- X#include <X11/Xaw/AsciiText.h>
- X#else
- X#include <X11/Command.h>
- X#include <X11/Form.h>
- X#include <X11/Box.h>
- X#include <X11/AsciiText.h>
- X#endif
- X
- Xchar *malloc();
- X
- X
- Xchar *prog="StarXaw";
- X#include "icon.h"
- X
- X
- X/* Externs */
- Xextern int g_argc;
- Xextern char **g_argv;
- X
- Xextern char *title;
- X
- Xextern int user_interact;
- X
- X
- X/* starX11 X items */
- Xextern Display *display; /* connection to display server */
- Xextern Window root, window; /* window to graphics in */
- Xextern Drawable draw_into;
- Xextern Colormap default_cmap; /* colormap */
- Xextern GC default_GC; /* graphics context */
- Xextern XFontStruct *default_font; /* default font */
- Xextern XFontStruct *greek_font; /* Greek font */
- Xextern Pixmap backup; /* backup for expose events */
- Xextern Pixel black, white, foreground, background;
- Xextern Pixel *pixels; /* color map cells */
- Xextern Pixel *star_pixels; /* color map cells for super color stars */
- Xextern int ncolors, star_colors;
- Xextern XEvent event; /* event structure */
- Xextern XGCValues values_GC; /* modify GC */
- Xextern unsigned int width, height;
- X
- Xextern Boolean reverse;
- X
- Xextern Bool use_backup;
- Xextern Bool hide_drawing;
- Xextern Bool post_preview;
- Xextern Bool post_landscape;
- Xextern Bool use_x_dashes;
- Xextern Bool is_color; /* Is it color? */
- Xextern Bool is_super_color; /* Is it many color? */
- X
- Xextern int Xargc;
- Xextern char *Xargv[];
- X
- X
- X
- Xextern mapwindow fullpage, mainmap, thumbmap;
- X
- Xextern int htick_lim, htext_lim, htext_xoff, htext_yoff;
- Xextern int vtick_lim, vtext_lim, vtext_xoff, vtext_yoff;
- X
- X/* externs for labels */
- X
- Xextern int x_nameoffset, y_nameoffset, x_lbloffset, y_lbloffset,
- X x_magoffset, y_magoffset;
- X
- X/* externs for legend: variables of positioning are here */
- Xextern int l_til;
- Xextern int l_stil;
- X
- Xextern int l_lmar1;
- Xextern int l_lmar2;
- Xextern int l_ltext;
- Xextern int l_rmar1;
- Xextern int l_rmar2;
- Xextern int l_rtext;
- X
- Xextern int l_line1;
- Xextern int l_line2;
- Xextern int l_line3;
- Xextern int l_line4;
- Xextern int l_line5;
- Xextern int l_line6;
- X
- X/* Point sizes for font calls */
- Xextern int titlesize;
- Xextern int subtlsize;
- Xextern int namesize;
- Xextern int lblsize;
- Xextern int magsize;
- X
- X/* Fonts for font calls */
- Xextern int namefnt;
- Xextern int lblfnt;
- Xextern int magfnt;
- Xextern int titlefnt;
- Xextern int subtlfnt;
- X
- X/* Scale multiplier, minimum,
- X mangitude change, maximum, for thumbnail,*/
- Xextern double th_smul;
- Xextern double th_smin;
- Xextern double th_madj;
- Xextern double th_mmax;
- X
- X#ifndef MAXPATHLEN
- X#define MAXPATHLEN 1025
- X#endif
- X#define MAX(a,b) ((a)>(b)?(a):(b))
- X#define MIN(a,b) ((a)<(b)?(a):(b))
- X
- X/* Font names */
- X#ifdef RELEASE3_FONTS
- Xstatic char *default_font_name = "*helvetica-medium-r-normal--10*";
- Xstatic char *greek_font_name = "*symbol-medium-r-normal--10*";
- Xstatic char *timesroman_font_name = "*times-medium-r-normal--";
- Xstatic char *timesbold_font_name = "*times-bold-r-normal--";
- Xstatic char *timesital_font_name = "*times-roman-i-normal--";
- Xstatic char *timesboldital_font_name = "*times-bold-i-normal--";
- Xstatic char *helv_font_name = "*helvetica-medium-r-normal--";
- Xstatic char *helvbold_font_name = "*helvetica-bold-r-normal--";
- Xstatic char *helvital_font_name = "*helvetica-medium-o-normal--";
- Xstatic char *helvboldital_font_name = "*helvetica-bold-o-normal--";
- Xstatic char *courier_font_name = "*courier-medium-r-normal--";
- Xstatic char *courital_font_name = "*courier-medium-i-normal--";
- Xstatic char *courbold_font_name = "*courier-bold-r-normal--";
- Xstatic char *couritalbold_font_name = "*courier-bold-o-normal--";
- X#else
- Xstatic char *default_font_name = "helvetica-medium10";
- Xstatic char *greek_font_name = "symbol-medium10";
- Xstatic char *timesroman_font_name = "times-roman";
- Xstatic char *timesbold_font_name = "times-bold";
- Xstatic char *timesital_font_name = "times-italic";
- Xstatic char *timesboldital_font_name = "times-bold-italic";
- Xstatic char *helv_font_name = "helvetica-medium";
- Xstatic char *helvbold_font_name = "helvetica-bold";
- Xstatic char *helvital_font_name = "helvetica-oblique";
- Xstatic char *helvboldital_font_name = "helvetica-boldoblique";
- Xstatic char *courier_font_name = "courier-medium";
- Xstatic char *courital_font_name = "courier-medium";
- Xstatic char *courbold_font_name = "courier-bold";
- Xstatic char *couritalbold_font_name = "courier-bold";
- X#endif /* RELEASE3_FONTS */
- X
- X
- X
- X
- X/* starXaw Local variables */
- XWidget interface, chart_shell, chart_widget;
- XWidget com_wid;
- XScreen *screen;
- XBool fixed_size = FALSE;
- Xint fixed_width = 500;
- Xint fixed_height = 500;
- X
- XBool fixed_win_coo = False; /* use Fixed window coordinates,
- X override X window settings in D_open*/
- X
- Xstatic int draw_chart; /* set to TRUE when D_userinput should return TRUE */
- Xstatic int quit_program; /* set to TRUE when D_userinput should return FALSE */
- Xstatic int killed_window;/* set to TRUE when the user has closed the
- X chart window during drawing */
- Xstatic int kill_the_window;/* set to TRUE if close_window should kill the
- X window immediately.
- X Otherwise lets D_break do it. */
- X
- X
- X/* main() parses the command line, and any input .starrc files
- Xcalls D_userinput() to finish setting the basic variables of the chart
- Xthen fix_mapwin, which may read a mapwin file, then D_mapwininput()
- Xto give the user final input of the detailed mapwin structure.
- XD_open then is called to begin the display.
- Xthe mapwin structure may be modified, based on the size of the window opened
- Xmain() will then write the mapwin file if so desired
- X
- XD_break is called periodically to give the user a chance to cancel input
- X
- XD_close is called at the end of plotting.
- X
- X
- XThis driver supplies:
- XD_userinput
- XD_mapwininput
- XD_open
- XD_close
- XD_break
- X
- XMuch other code is shared with starX11.c
- XD_comment is supplied to replace starX11's D_comment which writes to
- Xstandard output
- X*/
- X
- XD_open()
- X{
- X int x, y;
- X unsigned int border, depth, map_width;
- X Pixmap icon;
- X XSizeHints sizehints;
- X double legend_spacing;
- X
- X
- X Window shell_window;
- X Widget closebox;
- X
- X void expose(), close_window();
- X
- X Arg shell_args[10];
- X Arg widget_args[1];
- X Cardinal nshell_args, nwidget_args;
- X static Arg close_args[] = {
- X {XtNx, (XtArgVal) 2},
- X {XtNy, (XtArgVal) 2},
- X {XtNwidth, (XtArgVal) 10},
- X {XtNheight, (XtArgVal) 10},
- X {XtNbackground, (XtArgVal) NULL},
- X {XtNforeground, (XtArgVal) NULL},
- X };
- X
- X /* set user_interact so D_break will be called in starmain.c */
- X user_interact = TRUE;
- X
- X if (post_preview) {
- X if (post_landscape) {
- X XtSetArg(shell_args[0], XtNwidth, 768);
- X XtSetArg(shell_args[1], XtNheight, 595);
- X } else {
- X XtSetArg(shell_args[0], XtNwidth, 595);
- X XtSetArg(shell_args[1], XtNheight, 768);
- X };
- X } else {
- X XtSetArg(shell_args[0], XtNwidth, 550);
- X XtSetArg(shell_args[1], XtNheight, 550);
- X }
- X XtSetArg(shell_args[2], XtNtitle, (!title[0]) ? prog : title);
- X XtSetArg(shell_args[3], XtNiconName, (!title[0]) ? prog : title);
- X XtSetArg(shell_args[4], XtNborderColor, foreground);
- X nshell_args = 5;
- X if (fixed_size) {
- X XtSetArg(shell_args[0], XtNwidth, fixed_width);
- X XtSetArg(shell_args[1], XtNheight, fixed_height);
- X };
- X
- X XtSetArg(widget_args[0], XtNbackground, background);
- X nwidget_args = 1;
- X
- X XtSetArg(close_args[4], XtNbackground, foreground);
- X XtSetArg(close_args[5], XtNforeground, background);
- X
- X chart_shell =
- X XtCreatePopupShell(prog, topLevelShellWidgetClass, interface,
- X shell_args, nshell_args);
- X
- X killed_window = FALSE;
- X kill_the_window = FALSE;
- X
- X chart_widget = XtCreateManagedWidget(prog, compositeWidgetClass, chart_shell,
- X widget_args, nwidget_args);
- X closebox = XtCreateManagedWidget("", simpleWidgetClass,
- X chart_widget, close_args,
- X XtNumber(close_args));
- X
- X XtPopup(chart_shell, XtGrabNonexclusive);
- X window = XtWindow(chart_widget);
- X shell_window = XtWindow(chart_shell);
- X
- X if (post_preview) {
- X sizehints.flags = PSize|PMinSize|PMaxSize;
- X if (post_landscape) {
- X sizehints.width = sizehints.min_width = sizehints.max_width = 792;
- X sizehints.height = sizehints.min_height = sizehints.max_height = 576;
- X } else {
- X sizehints.width = sizehints.min_width = sizehints.max_width = 576;
- X sizehints.height = sizehints.min_height = sizehints.max_height = 792;
- X };
- X } else if (fixed_size) {
- X sizehints.flags = PSize|PMinSize|PMaxSize;
- X sizehints.width = sizehints.min_width = sizehints.max_width
- X = fixed_width;
- X sizehints.height = sizehints.min_height = sizehints.max_height
- X = fixed_height;
- X } else {
- X sizehints.flags = PMinSize;
- X sizehints.min_width = 550; sizehints.min_height = 550;
- X }
- X
- X icon = XCreateBitmapFromData(display, window, icon_bits,
- X icon_width, icon_height);
- X Xargv[0] = g_argv[0];
- X XSetStandardProperties(display, shell_window, prog, prog, icon,
- X Xargv, Xargc, &sizehints);
- X XDefineCursor(display, XtWindow(closebox),
- X XCreateFontCursor(display, XC_top_left_arrow));
- X XDefineCursor(display, window, XCreateFontCursor(display, XC_crosshair));
- X while (XtPending()) {
- X XtNextEvent(&event);
- X XtDispatchEvent(&event);
- X }
- X XSelectInput(display, window, StructureNotifyMask);
- X XMapWindow(display, window);
- X while(!XCheckTypedWindowEvent(display, shell_window, MapNotify, &event));
- X
- X XGetGeometry(display, shell_window, &root, &x, &y, &width, &height, &border,
- X &depth);
- X sizehints.width = sizehints.max_width = sizehints.min_width = width;
- X sizehints.height = sizehints.max_height = sizehints.min_height = height;
- X XtSetArg(shell_args[0], XtNwidth, width);
- X XtSetArg(shell_args[1], XtNheight, height);
- X XtSetValues(chart_shell, shell_args, nshell_args);
- X
- X map_width = width - 72;
- X
- X if (!fixed_win_coo) {
- X fullpage.width = map_width;
- X fullpage.height = height - 72;
- X fullpage.x_offset = 18;
- X fullpage.y_offset = 36;
- X
- X mainmap.width = map_width;
- X mainmap.height = ((height -72)*7)/10;
- X mainmap.x_offset = 18;
- X mainmap.y_offset = 18 + ((height - 72)*2.5)/10;
- X
- X thumbmap.width = map_width/2;
- X thumbmap.height = ((height - 72)*2)/10;
- X thumbmap.x_offset = 18 + map_width/2;
- X thumbmap.y_offset = 18;
- X };
- X
- X /* Need to adjust label here */
- X /* Want top of l_til to be at top of thumbmap */
- X l_til = thumbmap.height + thumbmap.y_offset - titlesize;
- X /* Space text in legends to fill space. Leave 10 on bottom.
- X Text totals 6*namesize+subtlsize. */
- X
- X legend_spacing = (l_til - 10 - 6*namesize - subtlsize)/7;
- X if (legend_spacing < 2) legend_spacing = 2;
- X
- X l_stil = l_til - subtlsize - legend_spacing;
- X l_line1 = l_stil - namesize - legend_spacing;
- X l_line2 = l_line1 - namesize - legend_spacing;
- X l_line3 = l_line2 - namesize - legend_spacing;
- X l_line4 = l_line3 - namesize - legend_spacing;
- X l_line5 = l_line4 - namesize - legend_spacing;
- X l_line6 = l_line5 - namesize - legend_spacing;
- X
- X
- X /* Actually, we left too much space above,
- X for proper postscript simulation.
- X We can make the maps higher */
- X if ((!post_preview) && (!fixed_size)) {
- X fullpage.height = height - fullpage.y_offset - 18;
- X mainmap.height = height - mainmap.y_offset - 18;
- X }
- X
- X sizehints.flags = PSize|PMinSize|PMaxSize;
- X XSetNormalHints(display, shell_window, &sizehints);
- X XSetNormalHints(display, window, &sizehints);
- X
- X if ((!is_color) && use_backup) {
- X backup = XCreatePixmap(display, window, width, height, depth);
- X XtAddEventHandler(chart_widget, ExposureMask, False,
- X expose,(caddr_t) backup);
- X
- X } else { /* Can't use backup pixmap on color: not enough memory */
- X use_backup = FALSE;
- X hide_drawing = FALSE;
- X }
- X draw_into = backup ? backup : window;
- X/* Should perhaps try and check for failure, and use some other
- X way of selecting use of window vs. backup */
- X
- X XtAddEventHandler(closebox, ButtonPressMask|ButtonReleaseMask,
- X False, close_window, (caddr_t) chart_widget);
- X
- X
- X values_GC.foreground = background; values_GC.background = foreground;
- X XChangeGC(display, default_GC, GCForeground|GCBackground, &values_GC);
- X XFillRectangle(display, draw_into, default_GC, 0, 0, width, height);
- X XSetForeground(display, default_GC, foreground);
- X XSetBackground(display, default_GC, background);
- X
- X return TRUE; /* open successful */
- X}
- X
- X
- Xvoid pointer_input();
- X
- XD_close()
- X{
- X if (is_killed()) {
- X XtDestroyWidget(XtParent(chart_widget));
- X if (use_backup) XFreePixmap(display, backup);
- X un_help();
- X D_comment("Closed");
- X return;
- X };
- X
- X flushlines();
- X
- X kill_the_window = TRUE;
- X
- X XtAddEventHandler(chart_widget, ButtonPressMask,False,
- X pointer_input,(caddr_t) chart_widget);
- X
- X D_comment("Waiting for close of window or mouse button 1 or 3 input");
- X
- X XtRemoveGrab(chart_shell);
- X XtAddGrab(chart_shell, True, False);
- X XtAddGrab(com_wid, False, False);
- X pointer_help();
- X}
- X
- Xvoid pointer_input(widget, closure, event)
- X Widget widget;
- X caddr_t closure; /* Widget */
- X XEvent *event;
- X{
- X int i;
- X double lat, lon, tlat, tlon;
- X char outstr[81];
- X int ra_h, ra_m, ra_s;
- X int de_d, de_m, de_s;
- X char dsign;
- X
- X
- X if ((i = invxform((int) event->xbutton.x,
- X (int) height - event->xbutton.y,
- X &lat, &lon)) >= 0) {
- X if (lon < 0.0) lon += 360.0;
- X tlon = lon / 15.0;
- X
- X ra_h = tlon;
- X ra_m = (tlon - ra_h) * 60 + (0.5 / 60);
- X ra_s = (((tlon - ra_h) * 60) - ra_m) * 60 + 0.5;
- X
- X if (ra_s >= 60) {ra_s -= 60; ra_m++;};
- X if (ra_m >= 60) {ra_m -= 60; ra_h++;};
- X
- X
- X if (lat < 0.0) {
- X tlat = -lat;
- X dsign = '-';
- X } else {
- X tlat = lat;
- X dsign = '+';
- X }
- X
- X de_d = tlat;
- X de_m = (tlat - de_d) * 60 + (0.5 / 60);
- X de_s = (((tlat - de_d) * 60) - de_m) * 60 + 0.5;
- X
- X if (de_s >= 60) {de_s -= 60; de_m++;};
- X if (de_m >= 60) {de_m -= 60; de_d++;};
- X
- X
- X sprintf(outstr, "RA: %2dh%2dm%2ds dec: %c%2dd%2dm%2ds\n",
- X ra_h, ra_m, ra_s, dsign, de_d, de_m, de_s);
- X buffer_comment(outstr, TRUE);
- X
- X if (event->xbutton.button == Button3) {
- X buffer_comment("", TRUE);
- X dblookup(i, lat, lon, 10);
- X };
- X } else {
- X /* fprintf(stderr, "Returned -1\n");*/
- X }
- X}
- X
- X
- X
- X/* Open the display connection and do much of the X initialization
- X Display text output window, and buttons for dialog boxes.
- X process dialog box input
- X draw_chart becomes true when the draw chart button gets pressed
- X*/
- XD_userinput()
- X{
- X static int initialized = FALSE;
- X
- X if (!initialized) {
- X start_X11();
- X initialized = TRUE;
- X }
- X
- X draw_chart = FALSE;
- X quit_program = FALSE;
- X while (!draw_chart) {
- X XtNextEvent(&event);
- X XtDispatchEvent(&event);
- X if (quit_program) return FALSE;
- X };
- X
- X /* User has done the input, now we are ready to begin the chart.*/
- X return TRUE;
- X}
- X
- X/*
- X D_mapwininput() is in starXawDlog.c for convenience in shared variables */
- X
- X
- X
- X
- X/* Put non-displayed comment in output. Allowed in postscript, but
- X few other drivers will be able to support this. */
- Xchar comment_buffer[MAX(MAXPATHLEN*2, 6000)];
- X/* Allow for lots of space */
- XD_comment(str)
- X char *str;
- X{
- X Arg args[3];
- X
- X strcpy(comment_buffer, str);
- X XtSetArg(args[0], XtNlabel, comment_buffer);
- X XtSetArg(args[1], XtNinsertPosition, 0);
- X XtSetValues(com_wid, args, (Cardinal)2);
- X XtTextSetLastPos(com_wid, strlen(str));
- X}
- X
- X/* D_comment with several lines of buffer */
- Xbuffer_comment(str, reset)
- X char *str;
- X int reset;
- X{
- X Arg args[2];
- X static int ncalled = 0;
- X int i,j;
- X int len, had_newline;
- X
- X if (reset) ncalled = 0;
- X if (ncalled == 0) comment_buffer[0] = '\0';
- X ncalled++;
- X
- X /* Find last character to copy */
- X len = strlen(str)-1;
- X if (str[len] == '\n') {
- X had_newline = TRUE;
- X len--; /* skip newline */
- X } else {
- X had_newline = FALSE;
- X }
- X while (str[len] == ' ') len--; /* skip spaces */
- X
- X
- X i = strlen(comment_buffer);
- X if ((i > 0) && (comment_buffer[i] != '\n')) {
- X comment_buffer[i++] = '\n';
- X comment_buffer[i] = '\0';
- X }
- X
- X /* Now i is the terminating \0 */
- X if ((i + strlen(str)) < sizeof(comment_buffer)) {
- X /* Add string to comment_buffer up to last non space before '\n' */
- X for (j = 0; j <= len; j++)
- X comment_buffer[i++] = str[j];
- X if (had_newline)
- X comment_buffer[i++] = '\n';
- X comment_buffer[i] = '\0';
- X } /* If buffer is full, ignore string */
- X
- X
- X XtSetArg(args[0], XtNlabel, comment_buffer);
- X XtSetArg(args[1], XtNinsertPosition, 0);
- X XtSetValues(com_wid, args, (Cardinal)2);
- X XtTextSetLastPos(com_wid, strlen(comment_buffer));
- X
- X XFlush(display);
- X
- X fprintf(stderr, "%s\n", str);
- X}
- X
- X
- Xint D_break()
- X{
- X if (is_killed()) {
- X XtDestroyWidget(XtParent(chart_widget));
- X if (use_backup) XFreePixmap(display, backup);
- X un_help();
- X D_comment("Closed");
- X };
- X
- X return killed_window;
- X}
- X
- X/* Widget functions */
- Xvoid Destroyed(widget, closure, callData)
- X Widget widget;
- X caddr_t closure; /* unused */
- X caddr_t callData; /* unused */
- X{
- X quit_program = TRUE;
- X}
- X
- Xvoid Quit(widget,closure,callData)
- X Widget widget;
- X caddr_t closure; /* Widget */
- X caddr_t callData;
- X{
- X XtDestroyWidget((Widget)closure);
- X}
- X
- X
- X
- X/* StarXaw X functions */
- Xextern char help_buffer[];
- Xextern Widget help_wid;
- X
- X/* Make the top level window, which contains buttons to
- X bring up the dialog boxes and do the chart */
- Xstart_X11()
- X{
- X Widget outer;
- X Arg Button_arg[10], Label_arg[10], Text_arg[10];
- X static XtCallbackRec callback[2];
- X Cardinal NButton_args, NLabel_args, nText_args;
- X
- X static Arg shell_args[2];
- X extern Button_set dlogbuttons[];
- X int i;
- X void Draw_chart(), Save_Load_file(), XHelp();
- X Widget first_button;
- X Widget new_w, old_w;
- X Pixmap icon;
- X
- X XtSetArg(Button_arg[0], XtNcallback, callback);
- X XtSetArg(Button_arg[1], XtNborderWidth, 1);
- X XtSetArg(Button_arg[2], XtNwidth, 150);
- X XtSetArg(Button_arg[3], XtNheight, 20);
- X NButton_args = 4;
- X
- X /* Label_arg[0] is the text of the label */
- X XtSetArg(Label_arg[1], XtNborderWidth, 0);
- X XtSetArg(Label_arg[2], XtNjustify, XtJustifyLeft);
- X XtSetArg(Label_arg[3], XtNheight, 20);
- X NLabel_args = 4;
- X
- X
- X Xargv[0] = g_argv[0];
- X interface = XtInitialize(prog, applicationShellWidgetClass,
- X NULL, 0, &Xargc, Xargv);
- X display = XtDisplay(interface);
- X screen = XtScreen(interface);
- X
- X X_setdisplay();
- X
- X icon = XCreateBitmapFromData(display, XtScreen(interface)->root, icon_bits,
- X icon_width, icon_height);
- X
- X XtSetArg(shell_args[0], XtNtitle, prog);
- X XtSetArg(shell_args[1], XtNiconPixmap, icon);
- X XtSetValues(interface, shell_args, (Cardinal) 2);
- X
- X
- X set_translations(); /* Set translation tables for text widgets */
- X
- X /* We have now created the interface widget, and set up the basics
- X of the display */
- X
- X /* Now we create the interface */
- X /* Currently using the "form" widget, with some labels and
- X command widgets (buttons) which will call the functions above */
- X
- X outer = XtCreateManagedWidget("form", formWidgetClass, interface,
- X NULL, (Cardinal)0);
- X XtAddCallback(outer, XtNdestroyCallback, Destroyed, NULL);
- X
- X callback[0].callback = Quit;
- X callback[0].closure = (caddr_t)interface;
- X
- X XtSetArg(Button_arg[4], XtNhorizDistance, 5);
- X XtSetArg(Button_arg[5], XtNvertDistance, 5);
- X NButton_args = 6;
- X new_w = XtCreateManagedWidget("QUIT",
- X commandWidgetClass, outer, Button_arg, NButton_args);
- X first_button = new_w;
- X old_w = new_w;
- X XtSetArg(Label_arg[0], XtNlabel, "Controls:");
- X XtSetArg(Label_arg[4], XtNfromVert, old_w);
- X NLabel_args = 5;
- X new_w = XtCreateManagedWidget("label", labelWidgetClass,
- X outer, Label_arg, NLabel_args);
- X
- X /* Button */
- X i = 0;
- X while (dlogbuttons[i].blabel[0]) {
- X old_w = new_w;
- X XtSetArg(Button_arg[4], XtNfromVert, old_w);
- X
- X callback[0].callback = *dlogbuttons[i].func;
- X new_w = XtCreateManagedWidget(dlogbuttons[i].blabel,
- X commandWidgetClass, outer, Button_arg, NButton_args);
- X i++;
- X };
- X
- X /* Button */
- X callback[0].callback = Save_Load_file;
- X old_w = new_w;
- X XtSetArg(Button_arg[4], XtNfromVert, old_w);
- X new_w = XtCreateManagedWidget("Save / Load File",
- X commandWidgetClass, outer, Button_arg, NButton_args);
- X
- X /* Label */
- X old_w = new_w;
- X XtSetArg(Label_arg[0], XtNlabel, "Actions:");
- X XtSetArg(Label_arg[4], XtNfromVert, old_w);
- X new_w = XtCreateManagedWidget("label", labelWidgetClass,
- X outer, Label_arg, NLabel_args);
- X
- X /* Button */
- X callback[0].callback = Draw_chart;
- X old_w = new_w;
- X XtSetArg(Button_arg[4], XtNfromVert, old_w);
- X new_w = XtCreateManagedWidget("Draw Chart",
- X commandWidgetClass, outer, Button_arg, NButton_args);
- X
- X
- X /* Label */
- X old_w = new_w;
- X XtSetArg(Label_arg[0], XtNlabel, "Output:");
- X XtSetArg(Label_arg[4], XtNfromVert, old_w);
- X new_w = XtCreateManagedWidget("label", labelWidgetClass, outer,
- X Label_arg, NLabel_args);
- X
- X /* Text */
- X old_w = new_w;
- X XtSetArg(Text_arg[0], XtNstring, comment_buffer);
- X XtSetArg(Text_arg[1], XtNlength, MAXPATHLEN*2);
- X XtSetArg(Text_arg[2], XtNwidth, 390);
- X XtSetArg(Text_arg[3], XtNheight, 134);
- X XtSetArg(Text_arg[4], XtNhorizDistance, 5);
- X XtSetArg(Text_arg[5], XtNfromVert, old_w);
- X XtSetArg(Text_arg[6], XtNtextOptions, wordBreak | scrollVertical);
- X nText_args = 7;
- X com_wid = XtCreateManagedWidget("",
- X asciiStringWidgetClass, outer,
- X Text_arg, nText_args);
- X
- X i = start_help();
- X XtSetArg(Text_arg[0], XtNstring, help_buffer);
- X XtSetArg(Text_arg[1], XtNlength, i);
- X XtSetArg(Text_arg[2], XtNwidth, 235);
- X XtSetArg(Text_arg[3], XtNheight, 365);
- X XtSetArg(Text_arg[4], XtNvertDistance, 5);
- X XtSetArg(Text_arg[5], XtNhorizDistance, 160);
- X nText_args = 6;
- X help_wid = XtCreateManagedWidget("",
- X asciiStringWidgetClass, outer,
- X Text_arg, nText_args);
- X
- X /* Button */
- X callback[0].callback = XHelp;
- X old_w = help_wid;
- X XtSetArg(Button_arg[2], XtNwidth, 235);
- X XtSetArg(Button_arg[4], XtNhorizDistance, 160);
- X XtSetArg(Button_arg[5], XtNvertDistance, 377);
- X new_w = XtCreateManagedWidget("Help",
- X commandWidgetClass, outer, Button_arg, NButton_args);
- X XtRealizeWidget(interface);
- X}
- X
- X
- Xvoid Draw_chart(widget,closure,callData)
- X Widget widget;
- X caddr_t closure; /* Widget */
- X caddr_t callData;
- X{
- X draw_chart = TRUE;
- X}
- X
- Xvoid expose(widget,closure,event)
- X Widget widget;
- X caddr_t closure; /* Widget */
- X XEvent *event;
- X{
- X XCopyArea(display, (Drawable) closure, XtWindow(widget), default_GC,
- X event->xexpose.x, event->xexpose.y,
- X (unsigned) event->xexpose.width, (unsigned) event->xexpose.height,
- X event->xexpose.x, event->xexpose.y);
- X}
- X
- Xvoid close_window(widget,closure,event)
- X Widget widget;
- X caddr_t closure; /* Widget */
- X XEvent *event;
- X{
- X if (XtParent((Widget) closure) == chart_shell) {
- X killed_window = TRUE;
- X killlines();
- X };
- X
- X if (kill_the_window) {
- X XtDestroyWidget(XtParent(chart_widget));
- X if (use_backup) XFreePixmap(display, backup);
- X un_help();
- X D_comment("Closed");
- X };
- X}
- X
- Xint is_killed()
- X{
- X XEvent event;
- X
- X while (XtPending()) {
- X XtNextEvent(&event);
- X XtDispatchEvent(&event);
- X }
- X return (killed_window);
- X}
- X
- X/* Setting translation tables */
- Xchar num_one_line_translations[] = "\
- X Ctrl<Key>F: forward-character() \n\
- X Ctrl<Key>B: backward-character() \n\
- X Ctrl<Key>D: delete-next-character() \n\
- X Ctrl<Key>A: beginning-of-line() \n\
- X Ctrl<Key>E: end-of-line() \n\
- X Ctrl<Key>H: delete-previous-character() \n\
- X Ctrl<Key>K: kill-to-end-of-line() \n\
- X Ctrl<Key>J: redraw-display() \n\
- X Ctrl<Key>L: redraw-display() \n\
- X Ctrl<Key>M: redraw-display() \n\
- X Ctrl<Key>N: redraw-display() \n\
- X Ctrl<Key>O: redraw-display() \n\
- X Ctrl<Key>P: redraw-display() \n\
- X Ctrl<Key>V: redraw-display() \n\
- X Ctrl<Key>W: kill-selection() \n\
- X Ctrl<Key>Y: unkill() \n\
- X Ctrl<Key>Z: redraw-display() \n\
- X Meta<Key>F: forward-word() \n\
- X Meta<Key>B: backward-word() \n\
- X Meta<Key>Y: stuff() \n\
- X Meta<Key>Z: redraw-display() \n\
- X Meta<Key>I: redraw-display() \n\
- X Meta<Key>K: redraw-display() \n\
- X Meta<Key>V: redraw-display() \n\
- X :Meta<Key>d: delete-next-word() \n\
- X :Meta<Key>D: kill-word() \n\
- X :Meta<Key>h: delete-previous-word() \n\
- X :Meta<Key>H: backward-kill-word() \n\
- X :Meta<Key>\<: redraw-display() \n\
- X :Meta<Key>\>: redraw-display() \n\
- X :Meta<Key>]: redraw-display() \n\
- X :Meta<Key>[: redraw-display() \n\
- X ~Shift Meta<Key>Delete:delete-previous-word() \n\
- X Shift Meta<Key>Delete:backward-kill-word() \n\
- X ~Shift Meta<Key>BackSpace:delete-previous-word() \n\
- X Shift Meta<Key>BackSpace:backward-kill-word() \n\
- X <Key>Right: forward-character() \n\
- X <Key>Left: backward-character() \n\
- X <Key>Delete: delete-previous-character() \n\
- X <Key>BackSpace: delete-previous-character() \n\
- X <Key>Return: redraw-display() \n\
- X <Key>Linefeed: redraw-display() \n\
- X <Key>Down: redraw-display() \n\
- X <Key>Up: redraw-display() \n\
- X <Key>0: insert-char() \n\
- X <Key>1: insert-char() \n\
- X <Key>2: insert-char() \n\
- X <Key>3: insert-char() \n\
- X <Key>4: insert-char() \n\
- X <Key>5: insert-char() \n\
- X <Key>6: insert-char() \n\
- X <Key>7: insert-char() \n\
- X <Key>8: insert-char() \n\
- X <Key>9: insert-char() \n\
- X <Key>-: insert-char() \n\
- X Shift<Key>=: insert-char() \n\
- X <Key>.: insert-char() \n\
- X <FocusIn>: focus-in() \n\
- X <FocusOut>: focus-out() \n\
- X <Btn1Down>: select-start() \n\
- X <Btn1Motion>: extend-adjust() \n\
- X <Btn1Up>: extend-end(PRIMARY, CUT_BUFFER0) \n\
- X <Btn3Down>: extend-start() \n\
- X <Btn3Motion>: extend-adjust() \n\
- X <Btn3Up>: extend-end(PRIMARY, CUT_BUFFER0)";
- X
- Xchar str_one_line_translations[] = "\
- X Ctrl<Key>F: forward-character() \n\
- X Ctrl<Key>B: backward-character() \n\
- X Ctrl<Key>D: delete-next-character() \n\
- X Ctrl<Key>A: beginning-of-line() \n\
- X Ctrl<Key>E: end-of-line() \n\
- X Ctrl<Key>H: delete-previous-character() \n\
- X Ctrl<Key>K: kill-to-end-of-line() \n\
- X Ctrl<Key>J: redraw-display() \n\
- X Ctrl<Key>L: redraw-display() \n\
- X Ctrl<Key>M: redraw-display() \n\
- X Ctrl<Key>N: redraw-display() \n\
- X Ctrl<Key>O: redraw-display() \n\
- X Ctrl<Key>P: redraw-display() \n\
- X Ctrl<Key>V: redraw-display() \n\
- X Ctrl<Key>W: kill-selection() \n\
- X Ctrl<Key>Y: unkill() \n\
- X Ctrl<Key>Z: redraw-display() \n\
- X Meta<Key>F: forward-word() \n\
- X Meta<Key>B: backward-word() \n\
- X Meta<Key>Y: stuff() \n\
- X Meta<Key>Z: redraw-display() \n\
- X Meta<Key>I: redraw-display() \n\
- X Meta<Key>K: redraw-display() \n\
- X Meta<Key>V: redraw-display() \n\
- X :Meta<Key>d: delete-next-word() \n\
- X :Meta<Key>D: kill-word() \n\
- X :Meta<Key>h: delete-previous-word() \n\
- X :Meta<Key>H: backward-kill-word() \n\
- X :Meta<Key>\<: redraw-display() \n\
- X :Meta<Key>\>: redraw-display() \n\
- X :Meta<Key>]: redraw-display() \n\
- X :Meta<Key>[: redraw-display() \n\
- X ~Shift Meta<Key>Delete:delete-previous-word() \n\
- X Shift Meta<Key>Delete:backward-kill-word() \n\
- X ~Shift Meta<Key>BackSpace:delete-previous-word() \n\
- X Shift Meta<Key>BackSpace:backward-kill-word() \n\
- X <Key>Right: forward-character() \n\
- X <Key>Left: backward-character() \n\
- X <Key>Delete: delete-previous-character() \n\
- X <Key>BackSpace: delete-previous-character() \n\
- X <Key>Return: redraw-display() \n\
- X <Key>Linefeed: redraw-display() \n\
- X <Key>Down: redraw-display() \n\
- X <Key>Up: redraw-display() \n\
- X <Key>: insert-char() \n\
- X <FocusIn>: focus-in() \n\
- X <FocusOut>: focus-out() \n\
- X <Btn1Down>: select-start() \n\
- X <Btn1Motion>: extend-adjust() \n\
- X <Btn1Up>: extend-end(PRIMARY, CUT_BUFFER0) \n\
- X <Btn3Down>: extend-start() \n\
- X <Btn3Motion>: extend-adjust() \n\
- X <Btn3Up>: extend-end(PRIMARY, CUT_BUFFER0)";
- X
- X/* <Btn2Down>: insert-selection(PRIMARY, CUT_BUFFER0) \n\*/
- X
- X
- XXtTranslations numbers_oneline, string_oneline;
- X
- Xset_translations()
- X{
- X numbers_oneline = XtParseTranslationTable(num_one_line_translations);
- X string_oneline = XtParseTranslationTable(str_one_line_translations);
- X}
- END_OF_FILE
- if test 29848 -ne `wc -c <'starchart/starXaw.c'`; then
- echo shar: \"'starchart/starXaw.c'\" unpacked with wrong size!
- fi
- # end of 'starchart/starXaw.c'
- fi
- echo shar: End of archive 17 \(of 32\).
- cp /dev/null ark17isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 32 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
-
-
-