william@CS.UCLA.EDU (William Cheng) (03/11/91)
Submitted-by: william@CS.UCLA.EDU (William Cheng) Posting-number: Volume 12, Issue 22 Archive-name: tgif/part06 ---------------------------------> cut here <--------------------------------- #! /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 6 (of 23)." # Contents: grid.c group.c mainloop.c mark.c # Wrapped by william@oahu on Wed Mar 6 09:57:15 1991 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'grid.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'grid.c'\" else echo shar: Extracting \"'grid.c'\" \(17034 characters\) sed "s/^X//" >'grid.c' <<'END_OF_FILE' X/* X * Author: William Chia-Wei Cheng (william@cs.ucla.edu) X * X * Copyright (C) 1990, 1991, William Cheng. X */ X#ifndef lint Xstatic char RCSid[] = X "@(#)$Header: /tmp_mnt/n/kona/tangram/u/william/X11/TGIF2/RCS/grid.c,v 2.0 91/03/05 12:47:23 william Exp $"; X#endif X X#include <X11/Xlib.h> X#include "const.h" X#include "types.h" X X#include "choice.e" X#include "color.e" X#include "drawing.e" X#include "dup.e" X#include "msg.e" X#include "obj.e" X#include "raster.e" X#include "ruler.e" X#include "scroll.e" X#include "select.e" X#include "setup.e" X Xint gridOn = TRUE; Xint xyGrid = DEFAULT_GRID; Xint pageStyle = PORTRAIT; Xint whereToPrint = PRINTER; X Xstatic int gridShown = TRUE; X Xvoid MyHDotLine (Win, Y, XStart, XEnd, Pixel) X Window Win; X int Y, XStart, XEnd, Pixel; X{ X register int x; X X for (x = XStart; x < XEnd; x += 8) X#ifdef sun X XDrawPoint (mainDisplay, Win, defaultGC, x, Y); X#else X#ifdef ultrix X XDrawPoint (mainDisplay, Win, defaultGC, x, Y); X#else X XDrawLine (mainDisplay, Win, defaultGC, x, Y, x, Y); X#endif X#endif X} X Xvoid MyVDotLine (Win, X, YStart, YEnd, Pixel) X Window Win; X int X, YStart, YEnd, Pixel; X{ X register int y; X X for (y = YStart; y < YEnd; y += 8) X#ifdef sun X XDrawPoint (mainDisplay, Win, defaultGC, X, y); X#else X#ifdef ultrix X XDrawPoint (mainDisplay, Win, defaultGC, X, y); X#else X XDrawLine (mainDisplay, Win, defaultGC, X, y, X, y); X#endif X#endif X} X Xvoid RedrawGridLines () X{ X register int i, inc = HALF_INCH, abs_grid = HALF_INCH<<zoomScale; X int x_start, y_start, x_end, y_end, x_grid_start, y_grid_start; X int pixel = myFgPixel; X X if (!gridShown) return; X X if (drawOrigX % abs_grid == 0) X x_start = 0; X else X x_start = OFFSET_X(((int)(drawOrigX / abs_grid) + 1) * abs_grid); X if (drawOrigY % abs_grid == 0) X y_start = 0; X else X y_start = OFFSET_Y(((int)(drawOrigY / abs_grid) + 1) * abs_grid); X X x_end = min(OFFSET_X(paperWidth), OFFSET_X(drawOrigX+drawWinW)); X y_end = min(OFFSET_Y(paperHeight), OFFSET_Y(drawOrigY+drawWinH)); X X if (drawOrigX % 8 == 0) X x_grid_start = 0; X else X x_grid_start = ((int)(drawOrigX / 8) + 1) * 8 - drawOrigX; X if (drawOrigY % 8 == 0) X y_grid_start = 0; X else X y_grid_start = ((int)(drawOrigY / 8) + 1) * 8 - drawOrigY; X X for (i = x_start; i < x_end; i += inc) X MyVDotLine (drawWindow, i, y_grid_start, y_end, pixel); X for (i = y_start; i < y_end; i += inc) X MyHDotLine (drawWindow, i, x_grid_start, x_end, pixel); X} X Xvoid DrawGridLines (Win, LtX, LtY, RbX, RbY) X Window Win; X int LtX, LtY, RbX, RbY; /* absolute coordinates */ X{ X register int i, inc = HALF_INCH, abs_grid = HALF_INCH<<zoomScale; X int x_start, y_start, x_end, y_end; X int x_grid_start, y_grid_start, x_grid_end, y_grid_end; X int pixel = myFgPixel; X X if (!gridShown) return; X X if (LtX > paperWidth || LtY > paperHeight) return; X X if (LtX % abs_grid == 0) X x_start = OFFSET_X(LtX); X else X x_start = OFFSET_X(((int)(LtX / abs_grid) + 1) * abs_grid); X if (LtY % abs_grid == 0) X y_start = OFFSET_Y(LtY); X else X y_start = OFFSET_Y(((int)(LtY / abs_grid) + 1) * abs_grid); X X if (RbX % abs_grid == 0) X x_end = min(OFFSET_X(paperWidth),OFFSET_X(RbX)); X else X x_end = min(OFFSET_X(paperWidth), X OFFSET_X(((int)(RbX / abs_grid) + 1) * abs_grid)); X if (RbY % abs_grid == 0) X y_end = min(OFFSET_Y(paperHeight),OFFSET_Y(RbY)); X else X y_end = min(OFFSET_Y(paperHeight), X OFFSET_Y(((int)(RbY / abs_grid) + 1) * abs_grid)); X X if (LtX % (8<<zoomScale) == 0) X x_grid_start = OFFSET_X(LtX); X else X x_grid_start = ((int)(OFFSET_X(LtX) / 8) + 1) * 8; X if (LtY % (8<<zoomScale) == 0) X y_grid_start = OFFSET_Y(LtY); X else X y_grid_start = ((int)(OFFSET_Y(LtY) / 8) + 1) * 8; X X if (RbX % (8<<zoomScale) == 0) X x_grid_end = min(OFFSET_X(paperWidth), OFFSET_X(RbX)); X else X x_grid_end = min(OFFSET_X(paperWidth), ((int)(OFFSET_X(RbX)/8)+1)*8); X if (RbY % (8<<zoomScale) == 0) X y_grid_end = min(OFFSET_Y(paperHeight), OFFSET_Y(RbY)); X else X y_grid_end = min(OFFSET_Y(paperHeight), ((int)(OFFSET_Y(RbY)/8)+1)*8); X X for (i = x_start; i < x_end; i += inc) X MyVDotLine (Win, i, y_grid_start, y_grid_end, pixel); X for (i = y_start; i < y_end; i += inc) X MyHDotLine (Win, i, x_grid_start, x_grid_end, pixel); X} X X#define LAYOUT_INCGRID 0 X#define LAYOUT_DECGRID 1 X#define LAYOUT_GRID 2 X#define LAYOUT_SNAP 3 X#define LAYOUT_ZOOMIN 4 X#define LAYOUT_ZOOMOUT 5 X#define LAYOUT_LAND 6 X#define LAYOUT_PORT 7 X#define LAYOUT_HILAND 8 X#define LAYOUT_HIPORT 9 X#define LAYOUT_SLIDELAND 10 X#define LAYOUT_SLIDEPORT 11 X#define LAYOUT_TOGGLE_WHERE_TO_PRINT 12 X#define LAYOUT_TOGGLE_COLOR_PS 13 X X#define MAXLAYOUTMENUS 14 X Xchar * layoutMenuStr[] = X{ "+Grid #I", X "-Grid #D", X "ShowGrid #G", X "SnapOff ^#G", X "ZoomIn #Z", X "ZoomOut #O", X "Landscape", X "Portrait", X "HighLand", X "HighPort", X "SlideLand", X "SlidePort", X "Printer", X "ColorPS" X}; X#define MAX_LAYOUT_STR 14 /* longest string length in layoutMenuStr[] */ X Xstatic char showGridStr[] = "ShowGrid #G"; Xstatic char hideGridStr[] = "HideGrid #G"; X Xstatic char snapOnStr[] = "SnapOn ^#G"; Xstatic char snapOffStr[] = "SnapOff ^#G"; X Xstatic char printerStr[] = "Printer ^#X"; Xstatic char latexFigStr[] = "LaTeXFig ^#X"; Xstatic char psFileStr[] = "RawPSFile ^#X"; Xstatic char xbmStr[] = "XBitmap ^#X"; X Xstatic char bwPostScriptStr[] = "BlkWhtPS ^#K"; Xstatic char colorPostScriptStr[] = "ColorPS ^#K"; X Xvoid IncGrid () X{ X if (!gridOn) X Msg ("Snap is not on, grid size not changed."); X else if (xyGrid < HALF_INCH) X { X xyGrid *= 2; X RedrawRulers (); X } X else X Msg ("Already at maximun grid, grid size not changed."); X} X Xvoid DecGrid () X{ X if (!gridOn) X Msg ("Snap is not on, grid size not changed."); X else if (xyGrid > 4) X { X xyGrid /= 2; X RedrawRulers (); X } X else X Msg ("Already at minimum grid, grid size not changed."); X} X Xvoid ToggleGridShown () X{ X gridShown = !gridShown; X ClearAndRedrawDrawWindow (); X} X Xvoid ToggleSnapOn () X{ X gridOn = !gridOn; X if (gridOn) X Msg ("Snapping to grid point activated."); X else X Msg ("Snapping to grid point disabled."); X RedrawRulers (); X} X Xvoid ToggleColorPostScript () X{ X colorDump = !colorDump; X if (colorDump) X Msg ("PostScript file will print in color."); X else X Msg ("PostScript file will print in black-and-white."); X ShowWhereToPrint (); X} X Xvoid ToggleWhereToPrint () X{ X whereToPrint = (whereToPrint+1) % MAXWHERETOPRINT; X switch (whereToPrint) X { X case PRINTER: Msg ("Print device set to printer."); break; X case LATEX_FIG: X Msg ("Will print Encapsulated PostScript (LaTeX-Figure) file."); X break; X case PS_FILE: Msg ("Will print raw PostScript file."); break; X case XBM_FILE: X if (colorDump) X Msg ("Will print X11 Pitmap file."); X else X Msg ("Will print X11 Bitmap file."); X break; X } X ShowWhereToPrint (); X} X Xvoid ZoomIn () X{ X int zoomed_half_inch = HALF_INCH<<zoomScale; X X if (zoomScale == 0) X { X Msg ("Already at highest magnification, can no longer zoom in."); X return; X } X X TieLooseEnds (); X SetCurChoice (NOTHING); X X zoomScale--; X drawWinW >>= 1; X drawWinH >>= 1; X X if (topSel != NULL) X { X drawOrigX = min(max(0, X ((int)((paperWidth-drawWinW)/zoomed_half_inch))*zoomed_half_inch), X max(0, ((int)(selObjLtX/zoomed_half_inch))*zoomed_half_inch- X (PIX_PER_INCH<<zoomScale))); X drawOrigY = min(max(0, X ((int)((paperHeight-drawWinH)/zoomed_half_inch))*zoomed_half_inch), X max(0, ((int)(selObjLtY/zoomed_half_inch))*zoomed_half_inch- X (PIX_PER_INCH<<zoomScale))); X } X X UpdDrawWinBBox (); X AdjSplineVs (); X ClearAndRedrawDrawWindow (); X RedrawRulers (); X RedrawScrollBars (); X justDupped = FALSE; X} X Xvoid ZoomOut () X{ X int zoomed_half_inch = HALF_INCH<<zoomScale; X X if (paperWidth <= drawWinW && paperHeight <= drawWinH) X { X Msg ("Already at paper boundaries, can no longer zoom out."); X return; X } X X TieLooseEnds (); X SetCurChoice (NOTHING); X X zoomScale++; X drawWinW <<= 1; X drawWinH <<= 1; X X if (topSel != NULL) X { X drawOrigX = min(max(0, X ((int)((paperWidth-drawWinW)/zoomed_half_inch))*zoomed_half_inch), X max(0, ((int)(selObjLtX/zoomed_half_inch))*zoomed_half_inch- X (PIX_PER_INCH<<zoomScale))); X drawOrigY = min(max(0, X ((int)((paperHeight-drawWinH)/zoomed_half_inch))*zoomed_half_inch), X max(0, ((int)(selObjLtY/zoomed_half_inch))*zoomed_half_inch- X (PIX_PER_INCH<<zoomScale))); X } X else X { X if (drawOrigX + drawWinW > paperWidth) X { X if (drawWinW > paperWidth) X drawOrigX = 0; X else X drawOrigX = max(0,((int)(paperWidth-drawWinW)/zoomed_half_inch)* X zoomed_half_inch); X } X if (drawOrigY + drawWinH > paperHeight) X { X if (drawWinH > paperHeight) X drawOrigY = 0; X else X drawOrigY = max(0,((int)(paperHeight-drawWinH)/zoomed_half_inch)* X zoomed_half_inch); X } X } X X UpdDrawWinBBox (); X AdjSplineVs (); X ClearAndRedrawDrawWindow (); X RedrawRulers (); X RedrawScrollBars (); X justDupped = FALSE; X} X Xint UpdPageStyle (NewPageStyle) X int NewPageStyle; X{ X int changed = FALSE, old_w = paperWidth, old_h = paperHeight; X X switch (NewPageStyle) X { X case LANDSCAPE: X pageStyle = LANDSCAPE; X paperWidth = 10 * PIX_PER_INCH; X paperHeight = 7.5 * PIX_PER_INCH; X if (drawOrigX + drawWinW > paperWidth || drawOrigX + drawWinW > old_w) X { X if (drawOrigX + drawWinW > paperWidth) X drawOrigX = max(0,paperWidth-drawWinW); X changed = TRUE; X } X if (drawOrigY + drawWinH > paperHeight || drawOrigY + drawWinH > old_h) X { X if (drawOrigY + drawWinH > paperHeight) X drawOrigY = max(0,paperHeight-drawWinH); X changed = TRUE; X } X RedrawScrollBars (); X break; X case PORTRAIT: X pageStyle = PORTRAIT; X paperWidth = 7.5 * PIX_PER_INCH; X paperHeight = 10 * PIX_PER_INCH; X if (drawOrigX + drawWinW > paperWidth || drawOrigX + drawWinW > old_w) X { X if (drawOrigX + drawWinW > paperWidth) X drawOrigX = max(0,paperWidth-drawWinW); X changed = TRUE; X } X if (drawOrigY + drawWinH > paperHeight || drawOrigY + drawWinH > old_h) X { X if (drawOrigY + drawWinH > paperHeight) X drawOrigY = max(0,paperHeight-drawWinH); X changed = TRUE; X } X RedrawScrollBars (); X break; X case HIGHLAND: X pageStyle = HIGHLAND; X paperWidth = 21 * PIX_PER_INCH; X paperHeight = 15.5 * PIX_PER_INCH; X if (drawOrigX + drawWinW > paperWidth || drawOrigX + drawWinW > old_w) X { X if (drawOrigX + drawWinW > paperWidth) X drawOrigX = max(0,paperWidth-drawWinW); X changed = TRUE; X } X if (drawOrigY + drawWinH > paperHeight || drawOrigY + drawWinH > old_h) X { X if (drawOrigY + drawWinH > paperHeight) X drawOrigY = max(0,paperHeight-drawWinH); X changed = TRUE; X } X RedrawScrollBars (); X break; X case HIGHPORT: X pageStyle = HIGHPORT; X paperWidth = 15.5 * PIX_PER_INCH; X paperHeight = 21 * PIX_PER_INCH; X if (drawOrigX + drawWinW > paperWidth || drawOrigX + drawWinW > old_w) X { X if (drawOrigX + drawWinW > paperWidth) X drawOrigX = max(0,paperWidth-drawWinW); X changed = TRUE; X } X if (drawOrigY + drawWinH > paperHeight || drawOrigY + drawWinH > old_h) X { X if (drawOrigY + drawWinH > paperHeight) X drawOrigY = max(0,paperHeight-drawWinH); X changed = TRUE; X } X RedrawScrollBars (); X break; X case SLIDELAND: X pageStyle = SLIDELAND; X paperWidth = 5 * PIX_PER_INCH; X paperHeight = 3.75 * PIX_PER_INCH; X if (drawOrigX + drawWinW > paperWidth || drawOrigX + drawWinW > old_w) X { X if (drawOrigX + drawWinW > paperWidth) X drawOrigX = max(0,paperWidth-drawWinW); X changed = TRUE; X } X if (drawOrigY + drawWinH > paperHeight || drawOrigY + drawWinH > old_h) X { X if (drawOrigY + drawWinH > paperHeight) X drawOrigY = max(0,paperHeight-drawWinH); X changed = TRUE; X } X RedrawScrollBars (); X break; X case SLIDEPORT: X pageStyle = SLIDEPORT; X paperWidth = 3.75 * PIX_PER_INCH; X paperHeight = 5 * PIX_PER_INCH; X if (drawOrigX + drawWinW > paperWidth || drawOrigX + drawWinW > old_w) X { X if (drawOrigX + drawWinW > paperWidth) X drawOrigX = max(0,paperWidth-drawWinW); X changed = TRUE; X } X if (drawOrigY + drawWinH > paperHeight || drawOrigY + drawWinH > old_h) X { X if (drawOrigY + drawWinH > paperHeight) X drawOrigY = max(0,paperHeight-drawWinH); X changed = TRUE; X } X RedrawScrollBars (); X break; X } X return (changed); X} X Xstatic void ChangePageStyle (NewPageStyle, PageStyleStr) X int NewPageStyle; X char * PageStyleStr; X{ X char msg[MAXSTRING]; X X if (pageStyle != NewPageStyle) X { X if (UpdPageStyle (NewPageStyle)) X { X UpdDrawWinBBox (); X AdjSplineVs (); X ClearAndRedrawDrawWindow (); X } X RedrawRulers (); X SetFileModified (TRUE); X sprintf (msg, "Page style changed to %s.", PageStyleStr); X Msg (msg); X } X} X Xvoid LayoutMenu (X, Y) X int X, Y; X{ X int index, * fore_colors, * valid; X register int i; X char * menu_strings[MAXLAYOUTMENUS], * str_ptr; X X str_ptr = (char *) calloc (MAX_LAYOUT_STR*MAXLAYOUTMENUS, sizeof(char)); X for (i = 0; i < MAXLAYOUTMENUS; i++, str_ptr += MAX_LAYOUT_STR) X { X menu_strings[i] = str_ptr; X strcpy (menu_strings[i], layoutMenuStr[i]); X } X X if (gridShown) X strcpy (menu_strings[LAYOUT_GRID], hideGridStr); X else X strcpy (menu_strings[LAYOUT_GRID], showGridStr); X if (gridOn) X strcpy (menu_strings[LAYOUT_SNAP], snapOffStr); X else X strcpy (menu_strings[LAYOUT_SNAP], snapOnStr); X switch (whereToPrint) X { X case PRINTER: X strcpy (menu_strings[LAYOUT_TOGGLE_WHERE_TO_PRINT], latexFigStr); X break; X case LATEX_FIG: X strcpy (menu_strings[LAYOUT_TOGGLE_WHERE_TO_PRINT], psFileStr); X break; X case PS_FILE: X strcpy (menu_strings[LAYOUT_TOGGLE_WHERE_TO_PRINT], xbmStr); X break; X case XBM_FILE: X strcpy (menu_strings[LAYOUT_TOGGLE_WHERE_TO_PRINT], printerStr); X break; X } X if (colorDump) X strcpy (menu_strings[LAYOUT_TOGGLE_COLOR_PS], bwPostScriptStr); X else X strcpy (menu_strings[LAYOUT_TOGGLE_COLOR_PS], colorPostScriptStr); X X DefaultColorArrays (MAXLAYOUTMENUS, &fore_colors, &valid); X index = TextMenuLoop (X, Y, menu_strings, MAXLAYOUTMENUS, X fore_colors, valid, SINGLECOLOR); X X cfree (menu_strings[0]); X X switch (index) X { X case LAYOUT_INCGRID: IncGrid (); break; X case LAYOUT_DECGRID: DecGrid (); break; X case LAYOUT_GRID: ToggleGridShown (); break; X case LAYOUT_SNAP: ToggleSnapOn (); break; X case LAYOUT_ZOOMIN: ZoomIn (); break; X case LAYOUT_ZOOMOUT: ZoomOut (); break; X case LAYOUT_LAND: ChangePageStyle (LANDSCAPE, "LandScape"); break; X case LAYOUT_PORT: ChangePageStyle (PORTRAIT, "Portrait"); break; X case LAYOUT_HILAND: ChangePageStyle (HIGHLAND, "HighLand"); break; X case LAYOUT_HIPORT: ChangePageStyle (HIGHPORT, "HighPort"); break; X case LAYOUT_SLIDELAND: ChangePageStyle (SLIDELAND, "SlideLand"); break; X case LAYOUT_SLIDEPORT: ChangePageStyle (SLIDEPORT, "SlidePort"); break; X case LAYOUT_TOGGLE_WHERE_TO_PRINT: ToggleWhereToPrint (); break; X case LAYOUT_TOGGLE_COLOR_PS: ToggleColorPostScript (); break; X } X} X Xvoid GridXY (X, Y, GridX, GridY) X int X, Y, * GridX, * GridY; X{ X register int dx, dy; X X if (gridOn) X { X dx = (X+drawOrigX) % xyGrid; X if (dx < xyGrid / 2) X *GridX = X - dx; X else X *GridX = X - dx + xyGrid; X dy = (Y+drawOrigY) % xyGrid; X if (dy < xyGrid / 2) X *GridY = Y - dy; X else X *GridY = Y - dy + xyGrid; X } X else X { X *GridX = X; X *GridY = Y; X } X} X Xvoid CleanUpGrids () X{ X} END_OF_FILE if test 17034 -ne `wc -c <'grid.c'`; then echo shar: \"'grid.c'\" unpacked with wrong size! fi # end of 'grid.c' fi if test -f 'group.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'group.c'\" else echo shar: Extracting \"'group.c'\" \(6890 characters\) sed "s/^X//" >'group.c' <<'END_OF_FILE' X/* X * Author: William Chia-Wei Cheng (william@cs.ucla.edu) X * X * Copyright (C) 1990, 1991, William Cheng. X */ X#ifndef lint Xstatic char RCSid[] = X "@(#)$Header: /tmp_mnt/n/kona/tangram/u/william/X11/TGIF2/RCS/group.c,v 2.0 91/03/05 12:47:26 william Exp $"; X#endif X X#include <stdio.h> X#include <X11/Xlib.h> X#include "const.h" X#include "types.h" X X#include "attr.e" X#include "dup.e" X#include "file.e" X#include "obj.e" X#include "select.e" X#include "setup.e" X Xstatic struct SelRec * tmpTopSel, * tmpBotSel; X Xvoid CreateGroupObj (TopObjPtr, BotObjPtr) X struct ObjRec * TopObjPtr, * BotObjPtr; X{ X struct GroupRec * group_ptr; X struct ObjRec * obj_ptr; X X group_ptr = (struct GroupRec *) calloc (1, sizeof(struct GroupRec)); X group_ptr->first = TopObjPtr; X group_ptr->last = BotObjPtr; X obj_ptr = (struct ObjRec *) calloc (1, sizeof(struct ObjRec)); X obj_ptr->x = selObjLtX; /* note: selLtX, selLtY are absolute */ X obj_ptr->y = selObjLtY; X obj_ptr->type = OBJ_GROUP; X obj_ptr->bbox.ltx = selLtX; X obj_ptr->bbox.lty = selLtY; X obj_ptr->bbox.rbx = selRbX; X obj_ptr->bbox.rby = selRbY; X obj_ptr->obbox.ltx = selObjLtX; X obj_ptr->obbox.lty = selObjLtY; X obj_ptr->obbox.rbx = selObjRbX; X obj_ptr->obbox.rby = selObjRbY; X obj_ptr->detail.r = group_ptr; X obj_ptr->fattr = obj_ptr->lattr = NULL; X AddObj (NULL, topObj, obj_ptr); X} X Xvoid SaveGroupObj (FP, ObjPtr, Level) X FILE * FP; X struct ObjRec * ObjPtr; X int Level; X{ X fprintf (FP, "group([\n"); X Save (FP, ObjPtr->detail.r->last, Level+1); X fprintf (FP, "],"); X SaveAttrs (FP, ObjPtr->lattr); X fprintf (FP, ")"); X} X Xvoid SaveCompObj (FP, ObjPtr, Level) X FILE * FP; X struct ObjRec * ObjPtr; X int Level; X{ X fprintf (FP, "sym([\n"); X Save (FP, ObjPtr->detail.r->last, Level+1); X fprintf (FP, "],"); X SaveAttrs (FP, ObjPtr->lattr); X fprintf (FP, ")"); X} X Xvoid SaveIconObj (FP, ObjPtr, Level) X FILE * FP; X struct ObjRec * ObjPtr; X int Level; X{ X fprintf (FP, "icon([\n"); X Save (FP, ObjPtr->detail.r->last, Level+1); X fprintf (FP, "],\n"); X fprintf (FP, "\"%s\",%1d,", ObjPtr->detail.r->s,ObjPtr->id); X SaveAttrs (FP, ObjPtr->lattr); X fprintf (FP, ")"); X} X Xvoid ReadGroupObj (FP, ObjPtr, PRTGIF) X FILE * FP; X struct ObjRec * * ObjPtr; X int PRTGIF; X{ X struct GroupRec * group_ptr; X struct ObjRec * top_obj = NULL, * bot_obj = NULL, * obj_ptr; X int ltx, lty, rbx, rby; X int obj_ltx, obj_lty, obj_rbx, obj_rby; X X * ObjPtr = (struct ObjRec *) calloc (1, sizeof(struct ObjRec)); X X while (ReadObj (FP, &obj_ptr, PRTGIF)) X { X obj_ptr->next = top_obj; X if (top_obj == NULL) X bot_obj = obj_ptr; X else X top_obj->prev = obj_ptr; X top_obj = obj_ptr; X } X top_obj->prev = NULL; X X group_ptr = (struct GroupRec *) calloc (1, sizeof(struct GroupRec)); X group_ptr->first = top_obj; X group_ptr->last = bot_obj; X X ltx = top_obj->bbox.ltx; X lty = top_obj->bbox.lty; X rbx = top_obj->bbox.rbx; X rby = top_obj->bbox.rby; X obj_ltx = top_obj->obbox.ltx; X obj_lty = top_obj->obbox.lty; X obj_rbx = top_obj->obbox.rbx; X obj_rby = top_obj->obbox.rby; X for (obj_ptr = top_obj->next; obj_ptr != NULL; obj_ptr = obj_ptr->next) X { X if (obj_ptr->bbox.ltx < ltx) ltx = obj_ptr->bbox.ltx; X if (obj_ptr->bbox.lty < lty) lty = obj_ptr->bbox.lty; X if (obj_ptr->bbox.rbx > rbx) rbx = obj_ptr->bbox.rbx; X if (obj_ptr->bbox.rby > rby) rby = obj_ptr->bbox.rby; X if (obj_ptr->obbox.ltx < obj_ltx) obj_ltx = obj_ptr->obbox.ltx; X if (obj_ptr->obbox.lty < obj_lty) obj_lty = obj_ptr->obbox.lty; X if (obj_ptr->obbox.rbx > obj_rbx) obj_rbx = obj_ptr->obbox.rbx; X if (obj_ptr->obbox.rby > obj_rby) obj_rby = obj_ptr->obbox.rby; X } X X (*ObjPtr)->x = obj_ltx; X (*ObjPtr)->y = obj_lty; X (*ObjPtr)->type = OBJ_GROUP; X (*ObjPtr)->bbox.ltx = ltx; X (*ObjPtr)->bbox.lty = lty; X (*ObjPtr)->bbox.rbx = rbx; X (*ObjPtr)->bbox.rby = rby; X (*ObjPtr)->obbox.ltx = obj_ltx; X (*ObjPtr)->obbox.lty = obj_lty; X (*ObjPtr)->obbox.rbx = obj_rbx; X (*ObjPtr)->obbox.rby = obj_rby; X (*ObjPtr)->detail.r = group_ptr; X} X Xvoid FreeGroupObj (ObjPtr) X struct ObjRec * ObjPtr; X{ X register struct ObjRec * ptr; X X for (ptr = ObjPtr->detail.r->first; ptr != NULL; ptr = ptr->next) X FreeObj (ptr); X X cfree (ObjPtr->detail.r); X cfree (ObjPtr); X} X Xstatic Xvoid UngroupObj (ObjPtr) X struct ObjRec * ObjPtr; X /* ungroup the grouped object ObjPtr to a list of objects */ X /* when returns, a list of select pointers will be created, */ X /* tmpTopSel will point to the top of the list, and */ X /* tmpBotSel will point to the bottom of the list. */ X{ X register struct SelRec * sel_ptr; X register struct ObjRec * obj_ptr = ObjPtr->detail.r->last; X X tmpTopSel = tmpBotSel = NULL; X X for ( ; obj_ptr != NULL; obj_ptr = obj_ptr->prev) X { X sel_ptr = (struct SelRec *) calloc (1, sizeof(struct SelRec)); X sel_ptr->obj = obj_ptr; X sel_ptr->next = tmpTopSel; X if (tmpTopSel == NULL) X tmpBotSel = sel_ptr; X else X tmpTopSel->prev = sel_ptr; X tmpTopSel = sel_ptr; X } X tmpTopSel->prev = NULL; X} X Xvoid UngroupSelObj () X{ X register struct SelRec * sel_ptr; X register struct ObjRec * obj_ptr; X int sel_ltx, sel_lty, sel_rbx, sel_rby; X X if (topSel == NULL) return; X X sel_ltx = selLtX; sel_lty = selLtY; X sel_rbx = selRbX; sel_rby = selRbY; X X HighLightReverse (); X for (sel_ptr = topSel; sel_ptr != NULL; sel_ptr = sel_ptr->next) X { X obj_ptr = sel_ptr->obj; X if (obj_ptr->type == OBJ_GROUP) X { X UngroupObj (obj_ptr); X DetachGroupAttrs (obj_ptr, &tmpTopSel, &tmpBotSel); X X obj_ptr->detail.r->first->prev = obj_ptr->prev; X if (obj_ptr->prev == NULL) X topObj = obj_ptr->detail.r->first; X else X obj_ptr->prev->next = obj_ptr->detail.r->first; X obj_ptr->detail.r->last->next = obj_ptr->next; X if (obj_ptr->next == NULL) X botObj = obj_ptr->detail.r->last; X else X obj_ptr->next->prev = obj_ptr->detail.r->last; X X tmpTopSel->prev = sel_ptr->prev; X if (sel_ptr->prev == NULL) X topSel = tmpTopSel; X else X sel_ptr->prev->next = tmpTopSel; X tmpBotSel->next = sel_ptr->next; X if (sel_ptr->next == NULL) X botSel = tmpBotSel; X else X sel_ptr->next->prev = tmpBotSel; X X cfree (sel_ptr); X cfree (obj_ptr); X } X } X UpdSelBBox (); X RedrawAreas (botObj, X sel_ltx-(1<<zoomScale), sel_lty-(1<<zoomScale), X sel_rbx+(1<<zoomScale), sel_rby+(1<<zoomScale), X selLtX-(1<<zoomScale), selLtY-(1<<zoomScale), X selRbX+(1<<zoomScale), selRbY+(1<<zoomScale)); X HighLightForward (); X SetFileModified (TRUE); X justDupped = FALSE; X} END_OF_FILE if test 6890 -ne `wc -c <'group.c'`; then echo shar: \"'group.c'\" unpacked with wrong size! fi # end of 'group.c' fi if test -f 'mainloop.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'mainloop.c'\" else echo shar: Extracting \"'mainloop.c'\" \(15612 characters\) sed "s/^X//" >'mainloop.c' <<'END_OF_FILE' X/* X * Author: William Chia-Wei Cheng (william@cs.ucla.edu) X * X * Copyright (C) 1990, 1991, William Cheng. X */ X#ifndef lint Xstatic char RCSid[] = X "@(#)$Header: /tmp_mnt/n/kona/tangram/u/william/X11/TGIF2/RCS/mainloop.c,v 2.0 91/03/05 12:47:27 william Exp $"; X#endif X X#include <stdio.h> X#include <signal.h> X#include <X11/Xlib.h> X#include "const.h" X#include "types.h" X X#include "animate.e" X#include "choice.e" X#include "color.e" X#include "copypaste.e" X#include "cursor.e" X#include "dialog.e" X#include "drawing.e" X#include "file.e" X#include "font.e" X#include "grid.e" X#include "menu.e" X#include "msg.e" X#include "names.e" X#include "obj.e" X#include "raster.e" X#include "ruler.e" X#include "scroll.e" X#include "select.e" X#include "setup.e" X#include "stk.e" X#include "text.e" X#include "version.e" X#include "xbitmap.e" X Xint geometrySpecified = FALSE; Xint exitNormally = FALSE; Xchar geometrySpec[80]; Xchar initMsg1[80], initMsg2[80]; X Xstatic int quitDraw = TRUE; X Xstatic Xvoid ExecWithFile (CmdName, FileName) X char * CmdName, * FileName; X{ X int pid; X char s[255]; X X sprintf (s, "xterm -bd red -e %s %s", CmdName, FileName); X pid = fork (); X if (pid == 0) X { X system (s); X exit (0); X } X} X Xvoid DeallocStrings (FStr, Str1, Menu1, Str2, Menu2, Str3, Menu3) X char * * FStr, * * Str1, * * Menu1, * * Str2, * * Menu2, * * Str3, * * Menu3; X{ X cfree (*FStr); X cfree (*Str1); X cfree (*Menu1); X cfree (*Str2); X cfree (*Menu2); X cfree (*Str3); X cfree (*Menu3); X} X Xstatic Xvoid AllocStrings (FStr, Str1, Menu1, Str2, Menu2, Str3, Menu3) X char * * FStr, * * Str1, * * Menu1, * * Str2, * * Menu2, * * Str3, * * Menu3; X{ X char * s; X X if((s = (char *) calloc (80, sizeof(char))) == NULL) X { printf ("calloc fails!\n"); exit(-1); } X *FStr = s; X if((s = (char *) calloc (80, sizeof(char))) == NULL) X { printf ("calloc fails!\n"); exit(-1); } X *Str1 = s; X if((s = (char *) calloc (80, sizeof(char))) == NULL) X { printf ("calloc fails!\n"); exit(-1); } X *Menu1 = s; X if((s = (char *) calloc (80, sizeof(char))) == NULL) X { printf ("calloc fails!\n"); exit(-1); } X *Str2 = s; X if((s = (char *) calloc (80, sizeof(char))) == NULL) X { printf ("calloc fails!\n"); exit(-1); } X *Menu2 = s; X if((s = (char *) calloc (80, sizeof(char))) == NULL) X { printf ("calloc fails!\n"); exit(-1); } X *Str3 = s; X if((s = (char *) calloc (80, sizeof(char))) == NULL) X { printf ("calloc fails!\n"); exit(-1); } X *Menu3 = s; X} X X/* X * static X * int MyErrorHandler (display, event) X * Display * display; X * XErrorEvent * event; X * { X * if (event->type == 0) return (TRUE); X * printf ("\tError: type -- %1d\n", event->type); X * exit (-1); X * } X */ X Xvoid CleanUp () X{ X CleanUpDrawingWindow (); X CleanUpStk (); X CleanUpChoices (); X X CleanUpScrolls (); X CleanUpCursors (); X X CleanUpRuler (); X CleanUpRasters (); X CleanUpFonts (); X CleanUpMenu (); X CleanUpNames (); X CleanUpText (); X CleanUpColors (); X CleanUpFiles (); X CleanUpGrids (); X CleanUpCutBuffer (); X CleanUpXBm (); X CleanUpMsg (); X X DelAllCutSel (); X X XDestroyWindow (mainDisplay, mainWindow); X if (iconWindowCreated) X { X XDestroyWindow (mainDisplay, iconBaseWindow); X iconWindowCreated = FALSE; X } X printf ("%s terminated normally.\n", TOOL_NAME); X} X Xvoid MainLoop (Op, FileName, FuncStr, Str1, Menu1, Str2, Menu2, Str3, Menu3) X char * Op, * FileName, * * FuncStr; X char * * Str1, * * Menu1, * * Str2, * * Menu2, * * Str3, * * Menu3; X{ X XEvent input; X char * c_ptr, file_name[MAXPATHLENGTH], s[MAXPATHLENGTH]; X char full_name[MAXPATHLENGTH]; X int shorthand_rc, draw_rc, len; X struct ObjRec * obj_ptr; X FILE * fp; X X/* printf ("--> MainLoop (%s, %s, ...)\n", Op, FileName); */ X X if (strcmp (Op, "init") == 0) X { X sprintf (initMsg1, "%s Version %s", TOOL_NAME, version_string); X sprintf (initMsg2, "Copyright (C) 1990, 1991, William Chia-Wei Cheng"); X printf ("%s\n", initMsg1); X printf ("%s\n", initMsg2); X X exitNormally = FALSE; X if ((mainDisplay = XOpenDisplay (NULL)) == 0) X { X printf ("Could not open the default display! Abort!\n"); exit (-1); X } X mainScreen = DefaultScreen (mainDisplay); X mainColormap = DefaultColormap (mainDisplay, mainScreen); X mainDepth = DefaultDepth (mainDisplay, mainScreen); X mainVisual = DefaultVisual (mainDisplay, mainScreen); X rootWindow = RootWindow (mainDisplay, mainScreen); X X XSetErrorHandler (EmergencySaveForX); X XSetIOErrorHandler (EmergencySaveForX); X signal (SIGHUP, EmergencySave); X signal (SIGFPE, EmergencySave); X signal (SIGBUS, EmergencySave); X signal (SIGSEGV, EmergencySave); X X Setup (); X TwoLineMsg (initMsg1, initMsg2); X quitDraw = FALSE; X X if (FileName[0] != '\0') X { X len = strlen (FileName); X if (len >= 4 && strcmp (&FileName[len-4], ".obj") == 0) X strcpy (file_name, FileName); X else X sprintf (file_name, "%s.obj", FileName); X X if ((fp = fopen (file_name, "r")) == NULL) X { X sprintf (s, "Can not open '%s'.", file_name); X Msg (s); X } X else X { X sprintf (s, "Loading '%s' ...", file_name); X Msg (s); X X while (ReadObj (fp, &obj_ptr, FALSE)) X if (obj_ptr != NULL) X AddObj (NULL, topObj, obj_ptr); X X fclose (fp); X X if (*file_name == '/') X strcat (full_name, file_name); X else X sprintf (full_name, "%s/%s", curDir, file_name); X X SetCurDir (full_name); X *curSymDir = '\0'; X curFileDefined = TRUE; X X SetFileModified (FALSE); X sprintf (s, "Current file is '%s'.", file_name); X Msg (s); X } X } X UpdateDirInfo (); X } X SaveDrawWinInfo (); X X if (strcmp (Op, "vi") == 0) X ExecWithFile ("vi", FileName); X X if (strcmp (Op, "less") == 0) X ExecWithFile ("less", FileName); X X if (strcmp (Op, "quit") == 0) X { X CleanUp (); X quitDraw = TRUE; X XSync (mainDisplay, TRUE); X exitNormally = TRUE; X AllocStrings (FuncStr, Str1, Menu1, Str2, Menu2, Str3, Menu3); X strcpy (*FuncStr, "Quit"); X strcpy (*Str1, ""); X return; X } X X if (strcmp (Op, "msg") == 0) X { X Msg (FileName); X AllocStrings (FuncStr, Str1, Menu1, Str2, Menu2, Str3, Menu3); X strcpy (*FuncStr, ""); X return; X } X X if (strcmp (Op, "dialog") == 0) X { X Dialog (FileName, file_name); X AllocStrings (FuncStr, Str1, Menu1, Str2, Menu2, Str3, Menu3); X strcpy (*FuncStr, file_name); X strcpy (*Str1, ""); X return; X } X X if (strcmp (Op, "mainmenu") == 0 && quitDraw) X { X AllocStrings (FuncStr, Str1, Menu1, Str2, Menu2, Str3, Menu3); X strcpy (*FuncStr, "Fail"); X strcpy (*Str1, ""); X return; X } X X while (TRUE) X { X XNextEvent (mainDisplay, &input); X X if (input.type == KeyPress) X { X shorthand_rc = ShortHand (&input); X switch (shorthand_rc) X { X case BAD: /* <CONTROL> or <META> */ continue; X case INVALID: break; X default: X AllocStrings (FuncStr, Str1, Menu1, Str2, Menu2, Str3, Menu3); X strcpy (*FuncStr, fileMenuStr[shorthand_rc]); X strcpy (*Str1, curDomainName); X strcpy (*Menu1, "tmpmodel.obj"); X strcpy (*Str2, ""); X for (c_ptr = *FuncStr; *c_ptr != '\0'; c_ptr++) X if (*c_ptr == ' ') X { X *c_ptr = '\0'; X break; X } X return; X } X } X X if (input.xany.window == choiceWindow) X ChoiceEventHandler (&input); X else if (input.xany.window == drawWindow) X { X if ((draw_rc = DrawingEventHandler (&input)) != INVALID) X { X AllocStrings (FuncStr, Str1, Menu1, Str2, Menu2, Str3, Menu3); X strcpy (*FuncStr, fileMenuStr[draw_rc]); X strcpy (*Str1, curDomainName); X strcpy (*Menu1, "tmpmodel.obj"); X strcpy (*Str2, ""); X for (c_ptr = *FuncStr; *c_ptr != '\0'; c_ptr++) X if (*c_ptr == ' ') X { X *c_ptr = '\0'; X break; X } X return; X } X } X else if (input.xany.window == mainWindow) X mainWinEventHandler (&input); X else if (input.xany.window == vRuleWindow) X RedrawVRuler (&input); X else if (input.xany.window == hRuleWindow) X RedrawHRuler (&input); X else if (input.xany.window == iconWindow || X input.xany.window == iconBaseWindow) X IconEventHandler (&input); X else if (input.xany.window == titleWindow) X TitleEventHandler (&input); X else if (input.xany.window == msgWindow) X MsgEventHandler (&input); X else if (input.xany.window == vSBarWindow || X input.xany.window == hSBarWindow) X ScrollEventHandler (&input); X else if (input.xany.type == MappingNotify) X XRefreshKeyboardMapping (&(input.xmapping)); X } X} X Xstatic Xvoid HandleSimpleEvent (input) X XEvent input; X{ X if ((input.type & (PointerMotionMask | EnterWindowMask | LeaveWindowMask)) X != 0) return; X X if (input.xany.window == drawWindow) X DrawingEventHandler (&input); X else if (input.xany.window == choiceWindow) X ChoiceEventHandler (&input); X else if (input.xany.window==iconWindow || input.xany.window==iconBaseWindow) X IconEventHandler (&input); X else if (input.xany.window == titleWindow) X TitleEventHandler (&input); X else if (input.xany.window == msgWindow) X MsgEventHandler (&input); X else if (input.xany.window==vSBarWindow || input.xany.window==hSBarWindow) X ScrollEventHandler (&input); X else if (input.xany.window == hRuleWindow) X RedrawHRuler (); X else if (input.xany.window == vRuleWindow) X RedrawVRuler (); X} X Xstatic Xvoid AllocReturnStr (ReturnStr) X char * * ReturnStr; X{ X if((*ReturnStr = (char *) calloc (80, sizeof(char))) == NULL) X { printf ("calloc fails!\n"); exit(-1); } X} X Xvoid Animate (TypeStr, PolyId, SpeedStr, ColorStr, ReturnStr) X char * TypeStr, * PolyId, * SpeedStr, * ColorStr; X char * * ReturnStr; X{ X struct ObjRec * obj_ptr; X char s[80]; X int i, poly_id, speed, pixel, clicked = FALSE; X XEvent input; X XButtonEvent * button_event; X X AllocReturnStr (ReturnStr); X strcpy (*ReturnStr, ""); X X while (XPending (mainDisplay) != 0) X { X XPeekEvent (mainDisplay, &input); X if ((input.type & (PointerMotionMask | ExposureMask | EnterWindowMask | X LeaveWindowMask)) != 0) X { X XNextEvent (mainDisplay, &input); X HandleSimpleEvent (input); X } X else X { X if (input.type == ButtonPress) clicked = TRUE; X strcpy (*ReturnStr, "Interrupt"); X break; X } X } X X printf ("--> Animate (%s, %s, %s, %s)\n",TypeStr,PolyId,SpeedStr,ColorStr); X if (strcmp (TypeStr, "waitclick") == 0) X { X Msg ("Left:step. Middle:run. Right:stop."); X if (!clicked) X { X while(TRUE) X if (XPending (mainDisplay) != 0) X { X XNextEvent (mainDisplay, &input); X if (input.type == ButtonPress) X break; X } X } X else X XNextEvent (mainDisplay, &input); X X button_event = &(input.xbutton); X switch (button_event->button) X { X case Button1 : strcpy (*ReturnStr, "Left"); break; X case Button2 : strcpy (*ReturnStr, "Middle"); break; X case Button3 : strcpy (*ReturnStr, "Right"); break; X } X Msg (""); X } X else X { X poly_id = atoi (PolyId); X for (obj_ptr = topObj; obj_ptr != NULL; obj_ptr = obj_ptr->next) X if (obj_ptr->type == OBJ_POLY && obj_ptr->id == poly_id) X break; X X if (obj_ptr == NULL) X { X sprintf (s, "Can not find poly id = %1d.", poly_id); X Msg (s); X } X else if (strcmp (TypeStr, "send") == 0) X { X speed = atoi (SpeedStr); X pixel = (colorDisplay) ? xorColorPixels[obj_ptr->color] : 1; X AnimateSend (obj_ptr->detail.p, speed, pixel); X } X else if (strcmp (TypeStr, "flash") == 0) X { X if (colorDisplay) X strcpy (s, ColorStr); X else X strcpy (s, "white"); X for (i = 0; i < maxColors; i++) X if (strcmp (colorMenuItems[i], s) == 0) X { X AnimateFlashColor (obj_ptr, i); X break; X } X } X } X} X Xstatic Xvoid MyFormat (Str) X char * Str; X{ X register char * c_ptr = Str, * period_ptr = NULL; X register int i; X X for ( ; *c_ptr != '\0'; c_ptr++) X if (*c_ptr >= '0' && *c_ptr <= '9') X continue; X else if (*c_ptr == '.') X { X if (period_ptr != NULL) return; X period_ptr = c_ptr; X continue; X } X else X return; X X if (period_ptr == NULL) return; X for (c_ptr = period_ptr, i = 0; *c_ptr != '\0' && i < 7; c_ptr++, i++) ; X if (*c_ptr != '\0') *c_ptr = '\0'; X} X Xvoid UpdAttrVal (ObjId, AttrName, AttrColor, AttrVal, ReturnStr) X char * ObjId, * AttrName, * AttrColor, * AttrVal; X char * * ReturnStr; X{ X struct ObjRec * obj_ptr; X struct AttrRec * attr_ptr; X char s[80]; X int obj_id, clicked = FALSE; X XEvent input; X XButtonEvent * button_event; X X AllocReturnStr (ReturnStr); X strcpy (*ReturnStr, ""); X X while (XPending (mainDisplay) != 0) X { X XPeekEvent (mainDisplay, &input); X if ((input.type & (PointerMotionMask | ExposureMask | EnterWindowMask | X LeaveWindowMask)) != 0) X { X XNextEvent (mainDisplay, &input); X HandleSimpleEvent (input); X } X else X { X if (input.type == ButtonPress) X clicked = TRUE; X strcpy (*ReturnStr, "Interrupt"); X button_event = &(input.xbutton); X switch (button_event->button) X { X case Button1 : strcpy (*ReturnStr, "Left"); break; X case Button2 : strcpy (*ReturnStr, "Middle"); break; X case Button3 : strcpy (*ReturnStr, "Right"); break; X } X break; X } X } X X printf ("--> UpdAttrVal (%s, %s, %s, %s)\n", ObjId, AttrName, X AttrColor, AttrVal); X X obj_id = atoi (ObjId); X X for (obj_ptr = topObj; obj_ptr != NULL; obj_ptr = obj_ptr->next) X if (obj_ptr->id == obj_id) X break; X X if (obj_ptr == NULL) X { X sprintf (s, "Can not find obj id = %1d.", obj_id); X Msg (s); X } X else X { X attr_ptr = obj_ptr->fattr; X for ( ; attr_ptr != NULL; attr_ptr = attr_ptr->next) X { X if (strcmp (AttrName, attr_ptr->name) == 0 && X strcmp (AttrColor, colorMenuItems[attr_ptr->obj->color]) == 0) X break; X } X if (attr_ptr == NULL) X { X sprintf (s, "Can not find attr name '%s' and color '%s'.", X AttrName, AttrColor); X Msg (s); X } X else X { X strcpy (attr_ptr->s, AttrVal); X MyFormat(attr_ptr->s); X if (attr_ptr->nameshown) X sprintf (s, "%s%s", attr_ptr->name, attr_ptr->s); X else X strcpy (s, attr_ptr->s); X X if (attr_ptr->shown) RepaintFirstStr (attr_ptr->obj, s); X X strcpy (attr_ptr->obj->detail.t->first->s, s); X } X } X} END_OF_FILE if test 15612 -ne `wc -c <'mainloop.c'`; then echo shar: \"'mainloop.c'\" unpacked with wrong size! fi # end of 'mainloop.c' fi if test -f 'mark.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'mark.c'\" else echo shar: Extracting \"'mark.c'\" \(3162 characters\) sed "s/^X//" >'mark.c' <<'END_OF_FILE' X/* X * Author: William Chia-Wei Cheng (william@cs.ucla.edu) X * X * Copyright (C) 1990, 1991, William Cheng. X */ X#ifndef lint Xstatic char RCSid[] = X "@(#)$Header: /tmp_mnt/n/kona/tangram/u/william/X11/TGIF2/RCS/mark.c,v 2.0 91/03/05 12:47:31 william Exp $"; X#endif X X#include <stdio.h> X#include <X11/Xlib.h> X#include "const.h" X#include "types.h" X X#include "raster.e" X#include "setup.e" X#include "select.e" X X#define FORWARD 0 X#define REVERSE 1 X X#define Mark(X,Y) \ X XFillRectangle(mainDisplay,drawWindow,revDefaultGC,(X)-2,(Y)-2,5,5) X Xstatic Xvoid MarkPoly (NumPts, V) X int NumPts; X XPoint * V; X{ X register int i; X X for (i = 0; i < NumPts; i++) X Mark (OFFSET_X(V[i].x), OFFSET_Y(V[i].y)); X} X Xstatic Xvoid Mark4Corners (BBox) X struct BBRec BBox; X{ X Mark (OFFSET_X(BBox.ltx), OFFSET_Y(BBox.lty)); X Mark (OFFSET_X(BBox.ltx), OFFSET_Y(BBox.rby)); X Mark (OFFSET_X(BBox.rbx), OFFSET_Y(BBox.lty)); X Mark (OFFSET_X(BBox.rbx), OFFSET_Y(BBox.rby)); X} X Xstatic Xvoid Mark8Places (BBox) X struct BBRec BBox; X{ X register int xmid, ymid; X X if ((BBox.rbx - BBox.ltx) >> zoomScale >= 10) X { X xmid = (BBox.ltx+BBox.rbx) / 2; X Mark (OFFSET_X(xmid), OFFSET_Y(BBox.lty)); X Mark (OFFSET_X(xmid), OFFSET_Y(BBox.rby)); X } X if ((BBox.rby - BBox.lty) >> zoomScale >= 10) X { X ymid = (BBox.lty+BBox.rby) / 2; X Mark (OFFSET_X(BBox.ltx), OFFSET_Y(ymid)); X Mark (OFFSET_X(BBox.rbx), OFFSET_Y(ymid)); X } X Mark4Corners (BBox); X} X Xvoid HighLightAnObj (ObjPtr) X register struct ObjRec * ObjPtr; X{ X switch (ObjPtr->type) X { X case OBJ_POLY: X MarkPoly (ObjPtr->detail.p->n, ObjPtr->detail.p->vlist); break; X case OBJ_POLYGON: X MarkPoly (ObjPtr->detail.g->n-1, ObjPtr->detail.g->vlist); break; X X case OBJ_BOX: X case OBJ_OVAL: X case OBJ_ARC: X case OBJ_RCBOX: X case OBJ_GROUP: X case OBJ_SYM: Mark8Places (ObjPtr->obbox); break; X X case OBJ_TEXT: X case OBJ_XBM: X case OBJ_ICON: Mark4Corners (ObjPtr->obbox); break; X } X} X Xstatic Xvoid HighLight (Dir) X int Dir; X{ X register struct SelRec * sel_ptr = NULL; X register struct ObjRec * obj_ptr; X X switch (Dir) X { X case FORWARD: sel_ptr = botSel; break; X case REVERSE: sel_ptr = topSel; break; X } X while (sel_ptr != NULL) X { X obj_ptr = sel_ptr->obj; X switch (obj_ptr->type) X { X case OBJ_POLY: X MarkPoly (obj_ptr->detail.p->n, obj_ptr->detail.p->vlist); X break; X case OBJ_POLYGON: X MarkPoly (obj_ptr->detail.g->n-1, obj_ptr->detail.g->vlist); X break; X X case OBJ_BOX: X case OBJ_OVAL: X case OBJ_GROUP: X case OBJ_ARC: X case OBJ_RCBOX: X case OBJ_SYM: Mark8Places (obj_ptr->obbox); break; X X case OBJ_TEXT: X case OBJ_XBM: X case OBJ_ICON: Mark4Corners (obj_ptr->obbox); break; X } X switch (Dir) X { X case FORWARD: sel_ptr = sel_ptr->prev; break; X case REVERSE: sel_ptr = sel_ptr->next; break; X } X } X} X Xvoid HighLightForward () X{ X HighLight (FORWARD); X} X Xvoid HighLightReverse () X{ X HighLight (REVERSE); X} END_OF_FILE if test 3162 -ne `wc -c <'mark.c'`; then echo shar: \"'mark.c'\" unpacked with wrong size! fi # end of 'mark.c' fi echo shar: End of archive 6 \(of 23\). cp /dev/null ark6isdone 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 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 23 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 ---------------------------------> cut here <--------------------------------- -- Bill Cheng // UCLA Computer Science Department // (213) 206-7135 3277 Boelter Hall // Los Angeles, California 90024 // USA william@CS.UCLA.EDU ...!{uunet|ucbvax}!cs.ucla.edu!william