/**************************************************************************** EDITSS: A shipshape editor for XPilot shipshapes V2.1 Copyright (C) 1994 Ronald In 't Velt This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Right now, it is impossible to reach me via E-Mail. When I will have an account again somewhere, I will post a notice in alt.games.xpilot (or rec.games.xpilot in case this newgroup is accepted into rec.). XSTUFF.C: Xwindows interface routines ****************************************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "curkill.xbm" #include "curnose.xbm" #include "currear.xbm" #include "cursplit.xbm" #include "cureng.xbm" #include "curmis.xbm" #include "const.h" /* constants */ #include "types.h" #include "vars.h" #include "xstuff.h" #include "actions.h" #include "editss.h" #include "pship.h" /****************************************************************************/ /* Draw rearpoint / nosepoint */ void circle(point p, GC *gc) { if ((p.x>-16)&&(p.x<16)&&(p.y>-16)&&(p.y<16)) { if (colorok) XFillArc(XtDisplay(toplevel),pm_area,*gc,cx(p.x)-5,cy(p.y)-5,10,10,0,360*64); else XDrawArc(XtDisplay(toplevel),pm_area,*gc,cx(p.x)-5,cy(p.y)-5,10,10,0,360*64); } } void square(point p, GC *gc) { if ((p.x>-16)&&(p.x<16)&&(p.y>-16)&&(p.y<16)) { XDrawRectangle(XtDisplay(toplevel),pm_area,*gc,cx(p.x)-6,cy(p.y)-6,12,12); } } void cross(point p, GC *gc) { if ((p.x>-16)&&(p.x<16)&&(p.y>-16)&&(p.y<16)) { XDrawLine(XtDisplay(toplevel),pm_area,*gc,cx(p.x)-5,cy(p.y)-5,cx(p.x)+5,cy(p.y)+5); XDrawLine(XtDisplay(toplevel),pm_area,*gc,cx(p.x)-5,cy(p.y)+5,cx(p.x)+5,cy(p.y)-5); } } void arrow(point p, GC *gc) { if ((p.x>-16)&&(p.x<16)&&(p.y>-16)&&(p.y<16)) { XDrawLine(XtDisplay(toplevel),pm_area,*gc,cx(p.x)-5,cy(p.y)-5,cx(p.x)+5,cy(p.y)); XDrawLine(XtDisplay(toplevel),pm_area,*gc,cx(p.x)-5,cy(p.y)+5,cx(p.x)+5,cy(p.y)); } } /* Delete a line */ void rmvline(int kp1, GC *dgc) { int kp2; if (kp1>=sh_ed.n-1) kp2=0; else kp2=kp1+1; if (kp1<0) { kp1=sh_ed.n-1; kp2=0; } XDrawLine(XtDisplay(toplevel),pm_area,*dgc,cx(sh_ed.p[kp1].x),cy(sh_ed.p[kp1].y),cx(sh_ed.p[kp2].x),cy(sh_ed.p[kp2].y)); } /* Display some values and set button sensitivity */ void showvalues(void) { char a[100]; int ok = strlen(validateship(&sh_ed)); if (strstr(validateship(&sh_ed),"Warn")) ok=0; sprintf(a,"%2i points ",sh_ed.n); XtVaSetValues(l_size, XtNlabel, a, NULL); XtVaSetValues(l_sizeok, XtNlabel, validateship(&sh_ed), NULL); if (!callfrom) XtSetSensitive(b_print, (ok==0)); XtSetSensitive(b_write, (ok==0)); XtSetSensitive(b_mg, (sh_ed.mg.x==NOPOINT)); XtSetSensitive(b_en, (sh_ed.en.x==NOPOINT)); XtSetSensitive(b_lg, (sh_ed.nlg2)&&(drawmode==DM_NONE)) XDrawLine(XtDisplay(toplevel),pm_area,gc_ship,cx(sh_ed.p[sh_ed.n-1].x),cy(sh_ed.p[sh_ed.n-1].y),cx(sh_ed.p[0].x),cy(sh_ed.p[0].y)); arrow(sh_ed.mg, &gc_main); square(sh_ed.en, &gc_main); for (i=0; i2) XDrawLine(XtDisplay(toplevel),pm_small,gc_clear,rs(sh_ed.p[0].x),rs(-sh_ed.p[0].y),rs(sh_ed.p[sh_ed.n-1].x),rs(-sh_ed.p[sh_ed.n-1].y)); XCopyArea(XtDisplay(small), pm_small, XtWindow(small), DefaultGCOfScreen(XtScreen(toplevel)), 0, 0, SPM_SIZE, SPM_SIZE, 0,0); } /* Erase the drawingarea */ void cleararea(void) { int i, j; XFillRectangle(XtDisplay(toplevel),pm_area,gc_clear,0,0,pm_area_w,pm_area_h); a_redrawarea(NULL, NULL, NULL, NULL); XDrawLine(XtDisplay(toplevel),pm_area,gc_grid,cx(0),cy(-15),cx(0),cy(15)); XDrawLine(XtDisplay(toplevel),pm_area,gc_grid,cx(-15),cy(0),cx(15),cy(0)); XDrawRectangle(XtDisplay(toplevel),pm_area,gc_grid,cx(-8),cy(8),(Dimension)((pm_area_w-20)*16/30),(Dimension)((pm_area_h-20)*16/30)); for (i=-15; i<16; i++) for (j=-15; j<16; j++) XDrawPoint(XtDisplay(toplevel),pm_area,gc_draw,cx(i),cy(j)); } /* Change contents of label */ void x_label(Widget w, char *s) { XtVaSetValues(w, XtNlabel, s, NULL); x_doevents(); /* try to display it NOW */ } /* Initialize colors */ void x_initcolors(void) { Display *d; Screen *s; XColor c, cs; Pixel b, w; colorok = TRUE; d = XtDisplay(toplevel); s = XDefaultScreenOfDisplay(d); scr_num = XScreenNumberOfScreen(s); scr_depth = DefaultDepth(d, scr_num); b = BlackPixelOfScreen(s); w = WhitePixelOfScreen(s); bb_b=w; bb_f=b; nl_b=w; nl_f=b; st_b=w; st_f=b; bh_b=w; bh_f=b; bt_b=w; bt_f=b; ba_b=w; ba_f=b; pmc=b; plc=b; prc=b; XAllocNamedColor(d,DefaultColormap(d,scr_num), "Black",&col_black,&c); XAllocNamedColor(d,DefaultColormap(d,scr_num), "White",&col_white,&c); if (scr_depth>3) { if (XAllocNamedColor(d,DefaultColormap(d,scr_num), bb_bs,&cs,&c)) bb_b=cs.pixel; if (XAllocNamedColor(d,DefaultColormap(d,scr_num), bb_fs,&cs,&c)) bb_f=cs.pixel; if (XAllocNamedColor(d,DefaultColormap(d,scr_num), nl_bs,&cs,&c)) nl_b=cs.pixel; if (XAllocNamedColor(d,DefaultColormap(d,scr_num), nl_fs,&cs,&c)) nl_f=cs.pixel; if (XAllocNamedColor(d,DefaultColormap(d,scr_num), st_bs,&cs,&c)) st_b=cs.pixel; if (XAllocNamedColor(d,DefaultColormap(d,scr_num), st_fs,&cs,&c)) st_f=cs.pixel; if (XAllocNamedColor(d,DefaultColormap(d,scr_num), bh_bs,&cs,&c)) bh_b=cs.pixel; if (XAllocNamedColor(d,DefaultColormap(d,scr_num), bh_fs,&cs,&c)) bh_f=cs.pixel; if (XAllocNamedColor(d,DefaultColormap(d,scr_num), bt_bs,&cs,&c)) bt_b=cs.pixel; if (XAllocNamedColor(d,DefaultColormap(d,scr_num), bt_fs,&cs,&c)) bt_f=cs.pixel; if (XAllocNamedColor(d,DefaultColormap(d,scr_num), ba_bs,&cs,&c)) ba_b=cs.pixel; if (XAllocNamedColor(d,DefaultColormap(d,scr_num), ba_fs,&cs,&c)) ba_f=cs.pixel; if (XAllocNamedColor(d,DefaultColormap(d,scr_num), mc,&cs,&c)) pmc=cs.pixel; if (XAllocNamedColor(d,DefaultColormap(d,scr_num), lc,&cs,&c)) plc=cs.pixel; if (XAllocNamedColor(d,DefaultColormap(d,scr_num), rc,&cs,&c)) prc=cs.pixel; } else { colorok=FALSE; if (bb_bor==0) bb_bor=1; if (va_bor==1) va_bor=0; } } /* Initialize GC's */ void x_initgc(void) { XGCValues values; values.background=WhitePixel(XtDisplay(toplevel),scr_num); values.foreground=WhitePixel(XtDisplay(toplevel),scr_num); gc_draw = XCreateGC(XtDisplay(toplevel),RootWindowOfScreen(XtScreen(toplevel)),GCForeground|GCBackground,&values); gc_ship = XCreateGC(XtDisplay(toplevel),RootWindowOfScreen(XtScreen(toplevel)),GCForeground|GCBackground,&values); gc_clear = XCreateGC(XtDisplay(toplevel),RootWindowOfScreen(XtScreen(toplevel)),GCForeground|GCBackground,&values); gc_main = XCreateGC(XtDisplay(toplevel),RootWindowOfScreen(XtScreen(toplevel)),GCForeground|GCBackground,&values); gc_left = XCreateGC(XtDisplay(toplevel),RootWindowOfScreen(XtScreen(toplevel)),GCForeground|GCBackground,&values); gc_right = XCreateGC(XtDisplay(toplevel),RootWindowOfScreen(XtScreen(toplevel)),GCForeground|GCBackground,&values); gc_grid = XCreateGC(XtDisplay(toplevel),RootWindowOfScreen(XtScreen(toplevel)),GCForeground|GCBackground,&values); gc_xor = XCreateGC(XtDisplay(toplevel),RootWindowOfScreen(XtScreen(toplevel)),GCForeground|GCBackground,&values); XSetForeground(XtDisplay(toplevel),gc_draw,BlackPixel(XtDisplay(toplevel),scr_num)); XSetForeground(XtDisplay(toplevel),gc_ship,BlackPixel(XtDisplay(toplevel),scr_num)); XSetForeground(XtDisplay(toplevel),gc_xor,BlackPixel(XtDisplay(toplevel),scr_num)); XSetForeground(XtDisplay(toplevel),gc_clear,WhitePixel(XtDisplay(toplevel),scr_num)); XSetFunction(XtDisplay(toplevel),gc_xor,GXinvert); if (colorok) { XSetForeground(XtDisplay(toplevel),gc_grid,bt_f); XSetForeground(XtDisplay(toplevel),gc_main,pmc); XSetForeground(XtDisplay(toplevel),gc_left,plc); XSetForeground(XtDisplay(toplevel),gc_right,prc); XSetLineAttributes(XtDisplay(toplevel),gc_left,2,LineSolid,CapNotLast,JoinMiter); XSetLineAttributes(XtDisplay(toplevel),gc_right,2,LineSolid,CapNotLast,JoinMiter); XSetLineAttributes(XtDisplay(toplevel),gc_main,2,LineSolid,CapNotLast,JoinMiter); } else { XSetForeground(XtDisplay(toplevel),gc_grid,BlackPixel(XtDisplay(toplevel),scr_num)); XSetForeground(XtDisplay(toplevel),gc_main,BlackPixel(XtDisplay(toplevel),scr_num)); XSetForeground(XtDisplay(toplevel),gc_left,BlackPixel(XtDisplay(toplevel),scr_num)); XSetForeground(XtDisplay(toplevel),gc_right,BlackPixel(XtDisplay(toplevel),scr_num)); XSetLineAttributes(XtDisplay(toplevel),gc_grid,1,LineOnOffDash,CapNotLast,JoinMiter); XSetLineAttributes(XtDisplay(toplevel),gc_left,2,LineSolid,CapNotLast,JoinMiter); XSetLineAttributes(XtDisplay(toplevel),gc_right,1,LineSolid,CapNotLast,JoinMiter); XSetLineAttributes(XtDisplay(toplevel),gc_main,3,LineOnOffDash,CapNotLast,JoinMiter); } XSetLineAttributes(XtDisplay(toplevel),gc_ship,2,LineSolid,CapNotLast,JoinMiter); } /* Load a small font */ void x_initsmallfont(void) { font_small = XLoadQueryFont(XtDisplay(toplevel),fontname); } void x_init(int argc, char **argv) /* Start xwindows */ { Dimension x, y; static XtActionsRec window_actions[] = { {"redrawsmall", a_redrawsmall}, {"redrawarea", a_redrawarea}, {"redrawdir", a_redrawdir}, {"buttonp", a_buttonp}, {"buttonpd", a_buttondir} }; static String transsbm = ": redrawsmall()"; static String transbpbm = ": buttonp()\n: redrawarea()"; static String transdbm = ": buttonpd()\n: redrawdir()"; if ((argc>=3)&&(argv[2][0]=='X')) { callfrom=TRUE; if (argc==5) { strcpy(shiplib,argv[3]); strcpy(shipname,argv[4]); } } /* Initialize Widgets */ toplevel = XtVaAppInitialize( &app_context, "XXPMS", NULL, 0, #if defined(XtSpecificationRelease) && (XtSpecificationRelease == 4) (Cardinal *)&argc, argv, #else &argc, argv, #endif NULL, NULL); x_initcolors(); x_initsmallfont(); mainw = XtVaCreateManagedWidget( "XXPMS", boxWidgetClass, toplevel, XtNorientation, XtorientHorizontal, XtNforeground, bb_f, XtNbackground, bb_b, NULL); shipview = XtVaCreateManagedWidget( "view", viewportWidgetClass, mainw, XtNallowVert, TRUE, XtNforceBars, TRUE, XtNwidth, SPM_SIZE+14, XtNheight, 100, XtNforeground, WhitePixel(XtDisplay(toplevel),scr_num), XtNbackground, BlackPixel(XtDisplay(toplevel),scr_num), NULL); shipbm = XtVaCreateManagedWidget( "Smallship", coreWidgetClass, shipview, XtNwidth, SPM_SIZE, XtNheight, SPM_SIZE*nrships, XtNtranslations, XtParseTranslationTable(transdbm), XtNforeground, WhitePixel(XtDisplay(toplevel),scr_num), XtNbackground, BlackPixel(XtDisplay(toplevel),scr_num), NULL); b_box = XtVaCreateManagedWidget( "buttons", formWidgetClass, mainw, XtNforeground, bb_f, XtNbackground, bb_b, XtNborderWidth, 0, XtNorientation, XtorientHorizontal, NULL); b_quit = XtVaCreateManagedWidget( "Quit", commandWidgetClass, b_box, XtNforeground, ba_f, XtNbackground, ba_b, XtNshapeStyle, XawShapeOval, NULL); b_default = XtVaCreateManagedWidget( "Load", commandWidgetClass, b_box, XtNforeground, ba_f, XtNbackground, ba_b, XtNshapeStyle, XawShapeOval, XtNfromHoriz, b_quit, NULL); b_clear = XtVaCreateManagedWidget( "Clear", commandWidgetClass, b_box, XtNforeground, ba_f, XtNbackground, ba_b, XtNshapeStyle, XawShapeOval, XtNfromHoriz, b_default, NULL); if (callfrom) b_print = XtVaCreateManagedWidget( "Use ", commandWidgetClass, b_box, XtNforeground, ba_f, XtNbackground, ba_b, XtNshapeStyle, XawShapeOval, XtNfromVert, b_quit, NULL); else b_print = XtVaCreateManagedWidget( "Type", commandWidgetClass, b_box, XtNforeground, ba_f, XtNbackground, ba_b, XtNshapeStyle, XawShapeOval, XtNfromVert, b_quit, NULL); b_write = XtVaCreateManagedWidget( "Save", commandWidgetClass, b_box, XtNforeground, ba_f, XtNbackground, ba_b, XtNshapeStyle, XawShapeOval, XtNfromHoriz, b_print, XtNfromVert, b_quit, NULL); b_psout = XtVaCreateManagedWidget( "Print", commandWidgetClass, b_box, XtNforeground, bt_f, XtNbackground, bt_b, XtNshapeStyle, XawShapeOval, XtNfromHoriz, b_write, XtNfromVert, b_quit, NULL); b_draw = XtVaCreateManagedWidget( "Draw", toggleWidgetClass, b_box, XtNforeground, bt_f, XtNbackground, bt_b, XtNshapeStyle, XawShapeOval, XtNstate, TRUE, XtNradioData, &dr_val[0], XtNfromVert, b_print, XtNvertDistance, 20, NULL); b_kill = XtVaCreateManagedWidget( "Kill", toggleWidgetClass, b_box, XtNforeground, bt_f, XtNbackground, bt_b, XtNshapeStyle, XawShapeOval, XtNradioData, &dr_val[1], XtNradioGroup, b_draw, XtNfromHoriz, b_draw, XtNfromVert, b_print, XtNvertDistance, 20, NULL); b_split = XtVaCreateManagedWidget( "Split", toggleWidgetClass, b_box, XtNforeground, bt_f, XtNbackground, bt_b, XtNshapeStyle, XawShapeOval, XtNradioData, &dr_val[2], XtNradioGroup, b_kill, XtNfromHoriz, b_kill, XtNfromVert, b_print, XtNvertDistance, 20, NULL); b_mg = XtVaCreateManagedWidget( " Mgun ", toggleWidgetClass, b_box, XtNforeground, bt_f, XtNbackground, st_b, XtNradioData, &dr_val[3], XtNradioGroup, b_split, XtNfromVert, b_draw, NULL); b_lg = XtVaCreateManagedWidget( " Lgun ", toggleWidgetClass, b_box, XtNforeground, bt_f, XtNbackground, st_b, XtNradioData, &dr_val[4], XtNradioGroup, b_mg, XtNfromHoriz, b_mg, XtNhorizDistance, -1, XtNfromVert, b_draw, NULL); b_rg = XtVaCreateManagedWidget( " Rgun ", toggleWidgetClass, b_box, XtNforeground, bt_f, XtNbackground, st_b, XtNradioData, &dr_val[5], XtNradioGroup, b_lg, XtNfromHoriz, b_lg, XtNhorizDistance, -1, XtNfromVert, b_draw, NULL); b_ll = XtVaCreateManagedWidget( "Llight", toggleWidgetClass, b_box, XtNforeground, bt_f, XtNbackground, st_b, XtNradioData, &dr_val[6], XtNradioGroup, b_rg, XtNfromVert, b_mg, XtNvertDistance, -1, NULL); b_rl = XtVaCreateManagedWidget( "Rlight", toggleWidgetClass, b_box, XtNforeground, bt_f, XtNbackground, st_b, XtNradioData, &dr_val[7], XtNradioGroup, b_ll, XtNfromHoriz, b_ll, XtNhorizDistance, -1, XtNfromVert, b_mg, XtNvertDistance, -1, NULL); b_mr = XtVaCreateManagedWidget( "mrack ", toggleWidgetClass, b_box, XtNforeground, bt_f, XtNbackground, st_b, XtNradioData, &dr_val[8], XtNradioGroup, b_rl, XtNfromVert, b_ll, XtNvertDistance, -1, NULL); b_en = XtVaCreateManagedWidget( "engine", toggleWidgetClass, b_box, XtNforeground, bt_f, XtNbackground, st_b, XtNradioData, &dr_val[9], XtNradioGroup, b_mr, XtNfromHoriz, b_mr, XtNhorizDistance, -1, XtNfromVert, b_ll, XtNvertDistance, -1, NULL); area = XtVaCreateManagedWidget( "Draw", coreWidgetClass, mainw, XtNwidth, 420, XtNheight, 420, XtNtranslations, XtParseTranslationTable(transbpbm), NULL); small = XtVaCreateManagedWidget( "Smallship", coreWidgetClass, b_box, XtNwidth, SPM_SIZE, XtNheight, SPM_SIZE, XtNtranslations, XtParseTranslationTable(transsbm), XtNfromVert, b_mg, XtNvertDistance, 50, NULL); l_size = XtVaCreateManagedWidget( "sn", labelWidgetClass, b_box, XtNlabel,"-- points ", XtNforeground, bb_f, XtNbackground, bb_b, XtNborderWidth, 0, XtNfromVert, b_mg, XtNvertDistance, 50, XtNfromHoriz, small, XtNhorizDistance, 20, NULL); l_prob = XtVaCreateManagedWidget( "sl", labelWidgetClass, b_box, XtNlabel,"Problem:", XtNforeground, bb_f, XtNbackground, bb_b, XtNborderWidth, 0, XtNfromVert, small, XtNvertDistance, 20, NULL); l_sizeok = XtVaCreateManagedWidget( "size", labelWidgetClass, b_box, XtNlabel,"-- ", XtNforeground, st_f, XtNbackground, st_b, XtNborderWidth, 1, XtNfromVert, l_prob, XtNleft, XtChainLeft, XtNright, XtChainRight, NULL); l_sl = XtVaCreateManagedWidget( "sl", labelWidgetClass, b_box, XtNlabel,"Ship library file:", XtNforeground, bb_f, XtNbackground, bb_b, XtNborderWidth, 0, XtNfromVert, l_sizeok, XtNvertDistance, 20, NULL); b_shiplib = XtVaCreateManagedWidget( "shiplib", asciiTextWidgetClass, b_box, XtNforeground, st_f, XtNbackground, st_b, XtNborderWidth, 1, XtNfromVert, l_sl, XtNleft, XtChainLeft, XtNright, XtChainRight, XtNstring,shiplib, XtNeditType, XawtextEdit, NULL); l_sn = XtVaCreateManagedWidget( "sn", labelWidgetClass, b_box, XtNlabel,"Shipname / Author", XtNforeground, bb_f, XtNbackground, bb_b, XtNborderWidth, 0, XtNfromVert, b_shiplib, XtNvertDistance, 20, NULL); b_shipname = XtVaCreateManagedWidget( "shipname", asciiTextWidgetClass, b_box, XtNforeground, st_f, XtNbackground, st_b, XtNborderWidth, 1, XtNfromVert, l_sn, XtNleft, XtChainLeft, XtNright, XtChainRight, XtNstring,shipname, XtNeditType, XawtextEdit, NULL); b_shipaut = XtVaCreateManagedWidget( "author", asciiTextWidgetClass, b_box, XtNforeground, st_f, XtNbackground, st_b, XtNborderWidth, 1, XtNfromVert, b_shipname, XtNleft, XtChainLeft, XtNright, XtChainRight, XtNstring,shipaut, XtNeditType, XawtextEdit, NULL); sn_source = XtVaCreateWidget("src", asciiSrcObjectClass, b_shipname, XtNpieceSize, 25, XtNstring, shipname, XtNuseStringInPlace, TRUE, NULL); sn_sink = XtVaCreateWidget("sink", asciiSinkObjectClass, b_shipname, XtNpieceSize, 25, XtNstring, shipname, XtNuseStringInPlace, TRUE, NULL); sl_source = XtVaCreateWidget("src", asciiSrcObjectClass, b_shipname, XtNpieceSize, 25, XtNstring, shiplib, XtNuseStringInPlace, TRUE, NULL); sl_sink = XtVaCreateWidget("sink", asciiSinkObjectClass, b_shipname, XtNpieceSize, 25, XtNstring, shiplib, XtNuseStringInPlace, TRUE, NULL); sa_source = XtVaCreateWidget("src", asciiSrcObjectClass, b_shipaut, XtNpieceSize, 25, XtNstring, shipaut, XtNuseStringInPlace, TRUE, NULL); sa_sink = XtVaCreateWidget("sink", asciiSinkObjectClass, b_shipaut, XtNpieceSize, 25, XtNstring, shipaut, XtNuseStringInPlace, TRUE, NULL); if (font_small) XtVaSetValues(l_sizeok, XtNfont, font_small, NULL); if (font_small) XtVaSetValues(b_shipname, XtNfont, font_small, NULL); if (font_small) XtVaSetValues(b_shipaut, XtNfont, font_small, NULL); if (font_small) XtVaSetValues(b_shiplib, XtNfont, font_small, NULL); XtAddEventHandler(mainw, StructureNotifyMask, FALSE, (XtEventHandler)a_resize, NULL); XtAddEventHandler(area, PointerMotionMask, FALSE, (XtEventHandler)a_motion, NULL); XtAddEventHandler(b_shipname, KeyPressMask, FALSE, (XtEventHandler)a_key, NULL); XtAddEventHandler(b_shiplib, KeyPressMask, FALSE, (XtEventHandler)a_key, NULL); XtAddEventHandler(b_shipaut, KeyPressMask, FALSE, (XtEventHandler)a_key, NULL); XtAppAddActions(app_context, window_actions, XtNumber(window_actions)); XtVaGetValues(area, XtNwidth, &pm_area_w, XtNheight, &pm_area_h, NULL); pm_area = XCreatePixmap(XtDisplay(toplevel), RootWindowOfScreen(XtScreen(toplevel)), PM_MAX,PM_MAX,scr_depth); pm_small = XCreatePixmap(XtDisplay(toplevel), RootWindowOfScreen(XtScreen(toplevel)), SPM_SIZE,SPM_SIZE,scr_depth); x_initgc(); XtAddCallback(b_quit, XtNcallback, a_quit, 0); XtAddCallback(b_print, XtNcallback, a_dump, 0); XtAddCallback(b_write, XtNcallback, a_dump, 0); XtAddCallback(b_default, XtNcallback, a_load, 0); XtAddCallback(b_clear, XtNcallback, a_clear, 0); XtAddCallback(b_draw, XtNcallback, a_drawmode, 0); XtAddCallback(b_psout, XtNcallback, a_psout, 0); XtAddCallback(b_kill, XtNcallback, a_drawmode, 0); XtAddCallback(b_split, XtNcallback, a_drawmode, 0); XtAddCallback(b_mg, XtNcallback, a_drawmode, 0); XtAddCallback(b_lg, XtNcallback, a_drawmode, 0); XtAddCallback(b_rg, XtNcallback, a_drawmode, 0); XtAddCallback(b_ll, XtNcallback, a_drawmode, 0); XtAddCallback(b_rl, XtNcallback, a_drawmode, 0); XtAddCallback(b_en, XtNcallback, a_drawmode, 0); XtAddCallback(b_mr, XtNcallback, a_drawmode, 0); XtRealizeWidget(toplevel); pm_kill = XCreatePixmapFromBitmapData(XtDisplay(mainw),XtWindow(mainw), curkill_bits, curkill_width, curkill_height, 1, 0, 1); pm_nose = XCreatePixmapFromBitmapData(XtDisplay(mainw),XtWindow(mainw), curnose_bits, curnose_width, curnose_height, 1, 0, 1); pm_rear = XCreatePixmapFromBitmapData(XtDisplay(mainw),XtWindow(mainw), currear_bits, currear_width, currear_height, 1, 0, 1); pm_split = XCreatePixmapFromBitmapData(XtDisplay(mainw),XtWindow(mainw), cursplit_bits, cursplit_width, cursplit_height, 1, 0, 1); pm_eng = XCreatePixmapFromBitmapData(XtDisplay(mainw),XtWindow(mainw), cureng_bits, cureng_width, cureng_height, 1, 0, 1); pm_mis = XCreatePixmapFromBitmapData(XtDisplay(mainw),XtWindow(mainw), curmis_bits, curmis_width, curmis_height, 1, 0, 1); cur_kill = XCreatePixmapCursor(XtDisplay(mainw),pm_kill,pm_kill,&col_black,&col_white,curkill_x_hot,curkill_y_hot); cur_nose = XCreatePixmapCursor(XtDisplay(mainw),pm_nose,pm_nose,&col_black,&col_white,curnose_x_hot,curnose_y_hot); cur_rear = XCreatePixmapCursor(XtDisplay(mainw),pm_rear,pm_rear,&col_black,&col_white,currear_x_hot,currear_y_hot); cur_eng = XCreatePixmapCursor(XtDisplay(mainw),pm_eng,pm_eng,&col_black,&col_white,cureng_x_hot,cureng_y_hot); cur_mis = XCreatePixmapCursor(XtDisplay(mainw),pm_mis,pm_mis,&col_black,&col_white,curmis_x_hot,curmis_y_hot); cur_split = XCreatePixmapCursor(XtDisplay(mainw),pm_split,pm_split,&col_black,&col_white,cursplit_x_hot,cursplit_y_hot); cur_draw = XCreateFontCursor(XtDisplay(mainw),XC_crosshair); font = XQueryFont(XtDisplay(mainw),XGContextFromGC(DefaultGC(XtDisplay(mainw), XScreenNumberOfScreen(XDefaultScreenOfDisplay(XtDisplay(mainw)))))); if (font==NULL) { f_w = 8; /* fill in some value */ f_h = 10; } else { f_h = font->max_bounds.ascent+font->max_bounds.descent+2; f_w = font->max_bounds.rbearing-font->max_bounds.lbearing; } getdir(); cleararea(); if ((argc==5)&&(callfrom)) a_load(NULL, NULL, NULL); XtVaGetValues(b_box, XtNwidth, &x, NULL); XtVaGetValues(l_sizeok, XtNheight, &y, NULL); XtResizeWidget(l_sizeok, x-10, y, 1); XtResizeWidget(b_shipname, x-10, y, 1); XtResizeWidget(b_shipaut, x-10, y, 1); XtResizeWidget(b_shiplib, x-10, y, 1); } void x_doevents(void) /* Flush the X-event buffer */ { while (XtAppPending(XtWidgetToApplicationContext(toplevel))==XtIMXEvent) { XtAppProcessEvent(XtWidgetToApplicationContext(toplevel),XtIMXEvent); } }