/************************************************* * C source code for xmesc, xmlev and xm4dg. * Compiled with commands like: * $cc -c -o xmescc.o -DXM2D xm234.c * $cc -c -o xmlevc.o -DXM3D xm234.c * $cc -c -o xm4dgc.o -DXM4D xm234.c * to generate the different object codes for different programs. * Author D.C. Radford * Last revised August 1999 **************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "util.h" #include "minig.h" #ifdef XM2D #include "escl8r.h" #else #include "levit8r.h" #endif /* external variables defined in miniga.c */ extern Display *disp_id; extern Screen *screen_id; extern Window win_id; extern GC gc_id, gc_comp_id; extern int win_width, win_height, menu_mode; /* from xmminig2 */ extern int select_gw(int); extern int set_size(int winpix, int width, int height); #define MAX_MENU 12 #define MAX_OPT 15 XtAppContext app_context; Widget toplevel, menubar, mainWindow1, mainWindow2; Widget drawingArea1, drawingArea2, command, posText; Widget menubarBtn[MAX_MENU], pulldowns[MAX_MENU]; Widget pdmenuBtn[MAX_MENU][MAX_OPT]; Pixmap pixmap; Window window1, window2, root_id; Display *disp_id; GC xmgc; Cursor watchCursor; Arg args [10]; Position xorig, yorig; Dimension ww, hh, width = 600, height = 500; int zoom = 1, revert_to, scr_width, scr_height; int igw_id, crosshairs = 0, chx = -1; float xin, yin, xmg[8]; char cin[40]; /* Subroutine to copy pixmap to drawing area */ void copy_area(void) { if (zoom < 8) { XCopyArea(disp_id, pixmap, window2, xmgc, 0, 0, width, height, 0, 0); XSync(disp_id, False); } } /* copy_area */ /* Callback for the drawingArea2 expose event */ void DAexposeCB(Widget w, XEvent *event, String *params, Cardinal *nparams) { if (zoom < 8) { copy_area(); } else { display_gls(-1); } } /* DAexposeCB */ /* Callback for the drawingArea1 resize event */ void DAresizeCB(Widget w, XEvent *event, String *params, Cardinal *nparams) { disp_dat(1); } /* DAresizeCB */ /* Callback for the drawing area input event */ void DAinputCB(Widget w, XEvent *event, String *params, Cardinal *nparams) { static int incr = 8, control_yes = 0; Window jroot, jchild; int ix, iy, ixi, iyi; unsigned int state, iflag; char response[40]; unsigned int ww, wh, wb, wd; if (w == drawingArea2) { igw_id = 2; (void) XmProcessTraversal(w, XmTRAVERSE_CURRENT); select_gw(igw_id); ww = width; wh = height; } else { igw_id = 1; XGetGeometry(disp_id, window1, &jroot, &ix, &iy, &ww, &wh, &wb, &wd); } ixi = event->xbutton.x; iyi = wh - event->xbutton.y; cvxy(&xin, &yin, &ixi, &iyi, 2); if (igw_id == 2) select_gw(1); if (event->xany.type == ButtonPress) { if (igw_id == 2 && (event->xbutton.state & ShiftMask) != 0) { /* shift-mousebutton -> pan/zoom gls display */ iflag = 1; if (event->xbutton.button == Button2) iflag = 2; if (event->xbutton.button == Button3) iflag = 3; pan_gls(xin, yin, iflag); igw_id = 0; } else { strcpy(cin, "G1"); if (event->xbutton.button == Button2) strcpy(cin, "X2"); if (event->xbutton.button == Button3) strcpy(cin, "X3"); } } else if (event->xany.type == KeyRelease) { igw_id = 0; strcpy(response, XKeysymToString(XLookupKeysym((XKeyEvent *)event,0))); if (!strncmp(response, "Con", 3)) control_yes = 0; } else if (event->xany.type == KeyPress) { strcpy(response, XKeysymToString(XLookupKeysym((XKeyEvent *)event,0))); /* check for