19 #include <X11/Intrinsic.h> 20 #include <X11/StringDefs.h> 21 #include <X11/cursorfont.h> 22 #include <X11/Xaw/Paned.h> 23 #include <X11/Xaw/AsciiText.h> 24 #include <X11/Xaw/Box.h> 25 #include <X11/Xaw/Command.h> 26 #include <X11/Xaw/Toggle.h> 27 #include <X11/Xaw/Form.h> 28 #include <X11/Shell.h> 29 #include <X11/keysym.h> 48 void (*drawghost)(int,int,int,int);
56 static void CRaction(Widget,XEvent*,String*,Cardinal*);
57 static void QUaction(Widget,XEvent*,String*,Cardinal*);
58 static void resize(Widget,XtPointer,XEvent*,Boolean*);
59 static void redraw(Widget,XtPointer,XEvent*,Boolean*);
60 static void quit(Widget,XtPointer,XtPointer);
61 static void help(Widget,XtPointer,XtPointer);
62 static void hardcopy(Widget,XtPointer,XtPointer);
63 static void save(Widget,XtPointer,XtPointer);
64 static void DoSave(Widget,XtPointer,XtPointer);
65 static void motion(Widget,XtPointer,XEvent*,Boolean*);
66 static void keypress(Widget,XtPointer,XEvent*,Boolean*);
67 static void grpl_button(Widget,XtPointer,XEvent*,Boolean*);
68 static void graf_addplot(Widget,XtPointer,XtPointer);
69 static void graf_points(Widget,XtPointer,XtPointer);
70 static void graf_x_y(Widget,XtPointer,XtPointer);
71 static void graf_separate(Widget,XtPointer,XtPointer);
72 static void graf_marker(Widget,XtPointer,XtPointer);
73 static void graf_scale1(Widget,XtPointer,XtPointer);
74 static void graf_scale2(Widget,XtPointer,XtPointer);
75 static void initcolors(
GRAPH*);
76 static void slopelocation(
GRAPH*,
int,
int);
77 static void zoomin(
GRAPH*);
78 static void X_ScreentoData(
GRAPH*,
int,
int,
double*,
double*);
87 static void hardcopy();
91 static void keypress();
92 static void grpl_button();
93 static void graf_addplot();
94 static void graf_points();
95 static void graf_x_y();
96 static void graf_separate();
97 static void graf_marker();
98 static void graf_scale1();
99 static void graf_scale2();
100 static void initcolors();
101 static void slopelocation();
102 static void zoomin();
103 static void X_ScreentoData();
108 extern void ToTopOfSced(Widget,XtPointer,XEvent*,Boolean*);
110 extern void ToTopOfSced();
114 #define DEF_FONT "6x10" 115 #define NUMLINESTYLES 8 118 #define NumPrivateColors 16 120 static unsigned long x11_priv_colors[NumPrivateColors];
130 #define NUMCOLORTAB 20 131 static char *colortable[NUMCOLORTAB];
133 #define Resource(str, class, ofst, what) \ 134 {str, class, XtRString, sizeof(char*), ofst*sizeof(char*), XtRString, what} 136 static XtResource resources[] = {
137 Resource(
"color0",
"Color0", 0,
"white"),
138 Resource(
"color1",
"Color1", 1,
"black"),
139 Resource(
"color2",
"Color2", 2,
"red"),
140 Resource(
"color3",
"Color3", 3,
"green"),
141 Resource(
"color4",
"Color4", 4,
"blue"),
142 Resource(
"color5",
"Color5", 5,
"magenta"),
143 Resource(
"color6",
"Color6", 6,
"cyan"),
144 Resource(
"color7",
"Color7", 7,
"violet"),
145 Resource(
"color8",
"Color8", 8,
"sienna"),
146 Resource(
"color9",
"Color9", 9,
"orange"),
147 Resource(
"color10",
"Color10", 10,
"orchid"),
148 Resource(
"color11",
"Color11", 11,
"violet"),
149 Resource(
"color12",
"Color12", 12,
"maroon"),
150 Resource(
"color13",
"Color13", 13,
"turquoise"),
151 Resource(
"color14",
"Color14", 14,
"pink"),
152 Resource(
"color15",
"Color15", 15,
"coral"),
153 Resource(
"color16",
"Color16", 16,
"khaki"),
154 Resource(
"color17",
"Color17", 17,
"yellow"),
155 Resource(
"color18",
"Color18", 18,
"gold"),
156 Resource(
"color19",
"Color19", 19,
"plum")
162 static String fallback_resources[] = {
163 "Jspice3.Form.background: lightgrey",
164 "Jspice3.Form.buttonbox.background: lightblue",
165 "Jspice3.Form.buttonbox.Command.background: yellow",
166 "Jspice3.Form.buttonbox.Toggle.background: yellow",
168 "Jspice3.help.background: lightgrey",
169 "Jspice3.help.Box.background: lightblue",
170 "Jspice3.help.Box.Command.background: yellow",
171 "Jspice3.help.Box.Toggle.background: yellow",
172 "Jspice3.help.Box.Label.background: pink",
173 "Jspice3.help.Label.background: pink",
175 "Jspice3.xeditor.background: lightgrey",
176 "Jspice3.xeditor.buttonbox.background: lightblue",
177 "Jspice3.xeditor.buttonbox.Command.background: yellow",
179 "Jspice3.popup.form.background: lightblue",
180 "Jspice3.popup.form.Command.background: yellow",
181 "Jspice3.popup.form.Label.background: pink",
183 "Jspice3.popup_m.form_m.background: pink",
184 "Jspice3.popup_m.form_m.Command.background: yellow",
185 "Jspice3.popup_e.form_e.background: pink",
186 "Jspice3.popup_e.form_e.Command.background: yellow",
191 static char xlinestyles[NUMLINESTYLES][10] = {
192 {0,4,1,1,1,1,0,0,0,0},
193 {0,4,1,3,1,3,0,0,0,0},
194 {0,4,1,2,1,2,0,0,0,0},
195 {0,4,3,3,3,3,0,0,0,0},
196 {0,4,1,4,6,4,0,0,0,0},
197 {0,4,7,7,7,7,0,0,0,0},
198 {0,4,1,4,4,4,0,0,0,0},
199 {0,4,3,3,7,3,0,0,0,0},
203 #define cursor_width 16 204 #define cursor_height 16 205 #define cursor_x_hot 7 206 #define cursor_y_hot 7 207 static char cursorCross_bits[] = {
208 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
209 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x7e, 0xfc,
210 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
211 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00 };
212 static char cursorCross_mask[] = {
213 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03,
214 0x80, 0x03, 0x80, 0x03, 0x7e, 0xfc, 0x7e, 0xfc,
215 0x7e, 0xfc, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03,
216 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x00, 0x00 };
219 static XtActionsRec actions[] = {
224 static char *
sens_list[] = {
"save", 0 };
225 static char *
wmTranslations =
"<Message>WM_PROTOCOLS: quit_action()";
226 static XtAppContext app_con;
227 static Widget sced_shell;
228 static Widget sced_view;
230 static Colormap sced_colormap;
231 static XVisualInfo *sced_visual_info;
247 argv[1] =
"-display";
253 XtToolkitInitialize();
254 app_con = XtCreateApplicationContext();
255 XtAppSetFallbackResources(app_con, fallback_resources);
263 XtAppAddActions(app_con, actions,
XtNumber(actions));
269 if (numdispplanes < NXPLANES)
285 x11_priv_colors, NumPrivateColors)) {
302 XErrorEvent *errorev;
304 XGetErrorText(display, errorev->error_code,
ErrorMessage, 1024);
311 CRaction(caller, call_data, params, numparams)
319 Widget action = XtNameToWidget(XtParent(caller),
"action");
322 XtCallCallbacks(action, XtNcallback,
NULL);
327 QUaction(caller, call_data, params, numparams)
337 quit = XtNameToWidget(caller,
"help.buttonbox.delete");
339 quit = XtNameToWidget(caller,
"*.buttonbox.quit");
341 quit = XtNameToWidget(caller,
"form.cancel");
343 quit = XtNameToWidget(caller,
"form_m.cancel_m");
345 quit = XtNameToWidget(caller,
"form_e.cancel_e");
348 XtCallCallbacks(quit, XtNcallback,
NULL);
353 X11_NewViewport(
graph)
360 XSetWindowAttributes w_attrs;
366 Dimension width, height;
370 int i, trys, options;
376 switch (graph->graphtype) {
392 graph->devdep =
NULL;
395 graph->devdep =
calloc(1,
sizeof(X11devdep));
396 xd = (X11devdep*)graph->devdep;
401 w->
shell = XtVaAppCreateShell(
NULL,
"Jspice3", applicationShellWidgetClass,
404 XtGetApplicationResources(w->
shell, (XtPointer) colortable,
408 w->
form = XtVaCreateManagedWidget(formname, formWidgetClass, w->
shell,
412 w->
view = XtVaCreateManagedWidget(
"viewport", widgetClass, w->
form,
414 XtNright, XtChainRight,
420 switch (graph->graphtype) {
423 XtAddEventHandler(w->
shell, VisibilityChangeMask,
426 XtVaSetValues(w->
view, XtNwidth, 300, XtNheight, 300,
NULL);
427 XtAddEventHandler(w->
view, ButtonPressMask,
FALSE, grpl_button, graph);
428 XtAddEventHandler(w->
view, KeyPressMask,
FALSE, keypress, graph);
431 w->
butbox = XtVaCreateManagedWidget(
"buttonbox",boxWidgetClass,
433 XtNfromHoriz, w->
view,
434 XtNleft, XtChainRight,
435 XtNright, XtChainRight,
437 XtNbottom, XtChainTop,
442 button = XtVaCreateManagedWidget(
"quit", commandWidgetClass,
446 XtAddCallback(button, XtNcallback, quit, graph);
448 button = XtVaCreateManagedWidget(
"help", commandWidgetClass,
452 XtAddCallback(button, XtNcallback,
help,
"plot");
454 button = XtVaCreateManagedWidget(
"hardcopy", commandWidgetClass,
456 XtNlabel,
"hardcopy",
458 XtAddCallback(button, XtNcallback, hardcopy, graph);
460 button = XtVaCreateManagedWidget(
"save", commandWidgetClass,
464 XtAddCallback(button, XtNcallback, save, graph);
467 (void)XtVaCreateManagedWidget(
"slopetext", asciiTextWidgetClass,
470 XtNfromHoriz, w->
view,
474 XtNdisplayCaret,
False,
480 graf = (
struct gplot *)graph->plotdata;
484 XtAddEventHandler(w->
shell, VisibilityChangeMask,
487 XtVaSetValues(w->
view, XtNwidth, 400, XtNheight, 300,
NULL);
488 XtAddEventHandler(w->
view, PointerMotionMask,
FALSE, motion, graph);
489 XtAddEventHandler(w->
view, ButtonPressMask,
FALSE, grpl_button, graph);
490 XtAddEventHandler(w->
view, KeyPressMask,
FALSE, keypress, graph);
493 w->
butbox = XtVaCreateManagedWidget(
"buttonbox", boxWidgetClass,
495 XtNfromHoriz,w ->
view,
496 XtNleft, XtChainRight,
497 XtNright, XtChainRight,
499 XtNbottom, XtChainTop,
503 button = XtVaCreateManagedWidget(
"quit", commandWidgetClass,
507 XtAddCallback(button, XtNcallback, quit, graph);
509 button = XtVaCreateManagedWidget(
"help", commandWidgetClass,
513 XtAddCallback(button, XtNcallback,
help,
"graf");
515 button = XtVaCreateManagedWidget(
"hardcopy", commandWidgetClass,
517 XtNlabel,
"hardcopy ",
519 XtAddCallback(button, XtNcallback, hardcopy, graph);
521 button = XtVaCreateManagedWidget(
"save", commandWidgetClass,
525 XtAddCallback(button, XtNcallback, save, graph);
535 button = XtVaCreateManagedWidget(
"points", toggleWidgetClass,
537 XtNlabel,
" points ",
540 XtAddCallback(button, XtNcallback, graf_points, graph);
542 if (graf->
numtr > 1) {
543 button = XtVaCreateManagedWidget(
"x-y", toggleWidgetClass,
548 XtAddCallback(button, XtNcallback, graf_x_y, graph);
550 button = XtVaCreateManagedWidget(
"separate", toggleWidgetClass,
552 XtNlabel,
"separate ",
555 XtAddCallback(button, XtNcallback, graf_separate, graph);
558 button = XtVaCreateManagedWidget(
"marker", toggleWidgetClass,
560 XtNlabel,
" marker ",
562 XtAddCallback(button, XtNcallback, graf_marker, graph);
564 for (i = 1; i < graf->
numtr; i++) {
572 button = XtVaCreateManagedWidget(
"onescale", toggleWidgetClass,
574 XtNlabel,
"one scale",
577 XtAddCallback(button, XtNcallback, graf_scale1, graph);
581 button = XtVaCreateManagedWidget(
"onescale", toggleWidgetClass,
583 XtNlabel,
"one scale",
586 XtAddCallback(button, XtNcallback, graf_scale2, graph);
587 button = XtVaCreateManagedWidget(
"grpscale", toggleWidgetClass,
589 XtNlabel,
"grp scale",
590 XtNradioGroup, button,
593 XtAddCallback(button, XtNcallback, graf_scale2, graph);
599 XtAddEventHandler(w->
shell, VisibilityChangeMask,
600 FALSE, ToTopOfSced, graph);
602 XtVaSetValues(w->
view, XtNwidth, 300, XtNheight, 300,
NULL);
603 XtAddEventHandler(w->
view, KeyPressMask,
FALSE, keypress, graph);
606 w->
butbox = XtVaCreateManagedWidget(
"buttonbox", boxWidgetClass,
608 XtNfromHoriz, w->
view,
609 XtNleft, XtChainRight,
610 XtNright, XtChainRight,
612 XtNbottom, XtChainTop,
616 button = XtVaCreateManagedWidget(
"quit", commandWidgetClass,
620 XtAddCallback(button, XtNcallback, quit, graph);
622 button = XtVaCreateManagedWidget(
"help", commandWidgetClass,
626 XtAddCallback(button, XtNcallback,
help,
"mplot");
628 button = XtVaCreateManagedWidget(
"hardcopy", commandWidgetClass,
630 XtNlabel,
"hardcopy",
632 XtAddCallback(button, XtNcallback, hardcopy, graph);
634 button = XtVaCreateManagedWidget(
"save", commandWidgetClass,
638 XtAddCallback(button, XtNcallback, save, graph);
642 sced_shell = w->
shell;
644 XtVaSetValues(w->
view,
649 XtAddEventHandler(w->
view, PointerMotionMask,
FALSE, motion, graph);
651 XtOverrideTranslations(w->
view,
652 XtParseTranslationTable(
"<BtnUp>:\n<BtnDown>:\n<Key>:"));
654 XtVaSetValues(w->
shell, XtNx, 10, XtNy, 10,
NULL);
657 (void)
strcpy(fontname,
"9x15");
664 (void)
strcpy(fontname, DEF_FONT);
669 while (!(xd->font = XLoadQueryFont(
Xdisplay, fontname))) {
671 strcpy(fontname,
"fixed");
679 graph->fontwidth = xd->font->max_bounds.width;
680 graph->fontheight = xd->font->max_bounds.ascent +
681 xd->font->max_bounds.descent;
683 XtRealizeWidget(w->
shell);
687 xd->window = XtWindow(w->
view);
688 w_attrs.bit_gravity = ForgetGravity;
689 XChangeWindowAttributes(
Xdisplay, xd->window, CWBitGravity, &w_attrs);
691 gcvalues.cap_style = CapNotLast;
692 xd->gc = XCreateGC(
Xdisplay, xd->window, GCCapStyle, &gcvalues);
694 gcvalues.function = GXxor;
695 xd->xorgc = XCreateGC(
Xdisplay, xd->window,
696 GCFunction | GCCapStyle, &gcvalues);
698 XSetFont(
Xdisplay,xd->gc, xd->font->fid);
699 XSetFont(
Xdisplay,xd->xorgc, xd->font->fid);
703 if (graph->graphtype ==
GR_SCED) {
704 Pixmap cursor_data, cursor_mask;
713 cursor_data = XCreateBitmapFromData(
Xdisplay, xd->window,
714 cursorCross_bits, cursor_width, cursor_height);
715 cursor_mask = XCreateBitmapFromData(
Xdisplay, xd->window,
716 cursorCross_mask, cursor_width, cursor_height);
717 cursor = XCreatePixmapCursor(
Xdisplay, cursor_data,
718 cursor_mask, &foreg, &backg, cursor_x_hot, cursor_y_hot);
719 XDefineCursor(
Xdisplay, xd->window, cursor);
724 cursor = XCreateFontCursor(
Xdisplay, XC_left_ptr);
725 XDefineCursor(
Xdisplay, xd->window, cursor);
730 if (graph->graphtype ==
GR_SCED &&
733 graph->colors[
NUMCOLORS - NumPrivateColors] ^
734 graph->colors[
NUMCOLORS - NumPrivateColors + 1]);
738 graph->colors[0] ^ graph->colors[1]);
741 XtVaGetValues(w->
view,
747 graph->absolute.xpos =
xpos;
748 graph->absolute.ypos =
ypos;
749 graph->absolute.width = width;
750 graph->absolute.height = height;
758 resize(caller, client_data, event, ctd)
761 XtPointer client_data;
766 X11devdep *xd = (X11devdep*)graph->
devdep;
768 Dimension width, height;
774 (
long) StructureNotifyMask, &ev)) ;
777 XtVaGetValues(caller, XtNwidth, &width, XtNheight, &height,
NULL);
785 redraw(caller, client_data, event, ctd)
788 XtPointer client_data;
794 X11devdep *xd = (X11devdep*)graph->
devdep;
795 XExposeEvent *pev = (XExposeEvent *) event;
797 XRectangle rects[30];
799 Dimension width, height;
802 if (pev->window != xd->window)
805 XtVaGetValues(caller, XtNwidth, &width, XtNheight, &height,
NULL);
812 rects[0].width = pev->width;
813 rects[0].height = pev->height;
816 while (n < 30 && XCheckWindowEvent(
Xdisplay, xd->window,
817 (
long) ExposureMask, &ev)) {
818 pev = (XExposeEvent *) &ev;
821 rects[n].width = pev->width;
822 rects[n].height = pev->height;
825 XSetClipRectangles(
Xdisplay, xd->gc, 0, 0, rects, n, Unsorted);
831 while (XCheckWindowEvent(
Xdisplay, xd->window,
832 (
long) StructureNotifyMask, &ev)) ;
833 XSetClipMask(
Xdisplay, xd->gc, None);
839 quit(caller, client_data, call_data)
842 XtPointer client_data, call_data;
845 X11devdep *xd = (X11devdep*)graph->
devdep;
848 XtDestroyWidget(xd->widgets.shell);
855 help(caller, client_data, call_data)
858 XtPointer client_data, call_data;
863 wl.
wl_word = (
char*)client_data;
870 hardcopy(caller, client_data, call_data)
873 XtPointer client_data, call_data;
876 X11devdep *xd = (X11devdep*)graph->
devdep;
885 save(caller, client_data, call_data)
888 XtPointer client_data, call_data;
891 X11devdep *xd = (X11devdep*)graph->
devdep;
893 xd->widgets.client_data = (XtPointer)graph;
900 DoSave(caller, client_data, call_data)
903 XtPointer client_data, call_data;
911 if (fname && *fname) {
928 motion(caller, clientdata, event, ctd)
931 XtPointer clientdata;
936 X11devdep *xd = (X11devdep*)graph->
devdep;
937 XMotionEvent *motionev = (XMotionEvent *) event;
938 XEvent nextEvent, newEvent;
942 while (XEventsQueued(motionev->display, QueuedAfterReading) > 0) {
943 XPeekEvent(motionev->display, &nextEvent);
944 if (nextEvent.type != MotionNotify)
946 XNextEvent(motionev->display, &newEvent);
947 motionev = &newEvent.xmotion;
954 xd->firstghost =
false;
956 (*xd->drawghost)(xd->lastx, xd->lasty, xd->refx, xd->refy);
958 xd->lastx = motionev->x;
960 (*xd->drawghost)(xd->lastx, xd->lasty, xd->refx, xd->refy);
970 keypress(caller, clientdata, event, ctd)
973 XtPointer clientdata;
978 X11devdep *xd = (X11devdep*)graph->
devdep;
979 XKeyEvent *keyev = (XKeyPressedEvent *) event;
983 nbytes = XLookupString(keyev, text, 4,
NULL,
NULL);
994 XWarpPointer(
Xdisplay, None, xd->window, 0, 0, 0, 0,
995 keyev->x + XTextWidth(xd->font, text, nbytes),
1003 ToTopOfSced(caller, clientdata, event, ctd)
1006 XtPointer clientdata;
1011 XVisibilityEvent *vev = (XVisibilityEvent*)event;
1017 if (vev->state == VisibilityFullyObscured) {
1018 xv.sibling = XtWindow(sced_shell);
1019 xv.stack_mode = Above;
1020 XReconfigureWMWindow(vev->display, vev->window,
1021 DefaultScreen(vev->display), CWSibling|CWStackMode, &xv);
1028 grpl_button(caller, clientdata, event, ctd)
1031 XtPointer clientdata;
1035 XButtonEvent *buttonev = (XButtonEvent *) event;
1037 switch (buttonev->button) {
1039 slopelocation((
GRAPH *) clientdata, buttonev->x, buttonev->y);
1042 zoomin((
GRAPH *) clientdata);
1070 graf_points(caller, client_data, call_data)
1073 XtPointer client_data, call_data;
1086 graf_x_y(caller, client_data, call_data)
1089 XtPointer client_data, call_data;
1102 graf_separate(caller, client_data, call_data)
1105 XtPointer client_data, call_data;
1118 graf_marker(caller, client_data, call_data)
1121 XtPointer client_data, call_data;
1134 graf_scale1(caller, client_data, call_data)
1137 XtPointer client_data, call_data;
1150 graf_scale2(caller, client_data, call_data)
1153 XtPointer client_data, call_data;
1156 X11devdep *xd = (X11devdep*)graph->
devdep;
1160 s = (
char*)XawToggleGetCurrent(
1161 XtNameToWidget(xd->widgets.butbox,
"onescale"));
1167 else if (!strcmp(s,
"onescale")) {
1188 static XVisualInfo *
1189 find_visual(Display *display,
int screen)
1191 XVisualInfo vt, *vl;
1196 vl = XGetVisualInfo(display, VisualScreenMask, &vt, &vmatch);
1197 for (i = 0; i < vmatch; i++)
1198 if (vl[i].visual == DefaultVisual(display, screen))
1200 if (vl[i].
class == PseudoColor && vl[i].depth >= 8)
1202 if (vl[i].
class == TrueColor)
1213 X11devdep *xd = (X11devdep*)graph->
devdep;
1214 XColor visual, exact;
1215 char buf[16], colorstring[
BSIZE_SP];
1217 Pixel b_pixel, f_pixel;
1222 if (!sced_visual_info) {
1223 fprintf(stderr,
"Uh-oh: Graphics mode unsupported.\n");
1237 XtVaGetValues(xd->widgets.view, XtNbackground, &b_pixel,
NULL);
1240 strcpy(colorstring, colortable[0]);
1243 colorstring, &visual, &exact)) {
1244 (void) sprintf(
ErrorMessage,
"can't get color %s\n", colorstring);
1246 graph->colors[0] = b_pixel;
1249 XtVaSetValues(xd->widgets.view, XtNbackground, visual.pixel,
NULL);
1250 graph->colors[0] = visual.pixel;
1259 graph->colors[1] = f_pixel;
1265 for (i = 0; i < NumPrivateColors; i++)
1266 graph->colors[i +
NUMCOLORS - NumPrivateColors] =
1272 for (i = 1; i < numcolors; i++) {
1273 (void) sprintf(buf,
"color%d", i);
1275 strcpy(colorstring, colortable[i]);
1278 colorstring, &visual, &exact)) {
1280 "can't get color %s\n", colorstring);
1282 graph->colors[i] = f_pixel;
1285 if (visual.pixel == b_pixel)
1286 graph->colors[i] = f_pixel;
1288 graph->colors[i] = visual.pixel;
1314 XtDestroyWidget(xd->widgets.shell);
1320 X11_Title(wintitle, icontitle)
1322 char *wintitle, *icontitle;
1326 XtVaSetValues(xd->widgets.shell,
1328 XtNiconName, icontitle,
1342 XDrawPoint(
Xdisplay, xd->window, xd->gc, x,
1349 X11_Line(x1, y1, x2, y2)
1356 XDrawLine(
Xdisplay, xd->window, xd->gc,
1364 X11_Box(x1, y1, x2, y2)
1382 XFillRectangle(
Xdisplay, xd->window, xd->gc, x1,
1390 X11_Arc(x0, y0, radius, theta1, theta2)
1393 double theta1, theta2;
1399 if (theta1 >= theta2)
1400 theta2 = 2 *
M_PI + theta2;
1401 t1 = 64 * (180.0 /
M_PI) * theta1;
1402 t2 = 64 * (180.0 /
M_PI) * theta2 - t1;
1405 XDrawArc(
Xdisplay, xd->window, xd->gc, x0 - radius,
1407 2 * radius, 2 * radius, t1, t2);
1423 pts = (XPoint *)
tmalloc( (
unsigned) (
sizeof(XPoint) *
1424 (p->nvertices+1)) );
1432 Complex, CoordModeOrigin);
1442 X11_Text(text, x, y)
1453 XDrawString(
Xdisplay, xd->window, xd->gc, x,
1455 text, strlen(text));
1461 X11_SetGhost(callback,x,y)
1464 void (*callback)(int,int,int,int);
1474 xd->drawghost = callback;
1479 xd->firstghost =
true;
1482 if (xd->drawghost) {
1483 if (!xd->firstghost) {
1487 (*xd->drawghost)(xd->lastx, xd->lasty, xd->refx, xd->refy);
1490 xd->drawghost =
NULL;
1498 X11_DefineColor(colorid, red, green, blue)
1501 double red, green, blue;
1510 if (sced_visual_info->class == PseudoColor) {
1516 if (colorid < 0 || colorid >= NumPrivateColors)
1521 colorid +=
NUMCOLORS - NumPrivateColors;
1523 newcolor.red = (red * 65535);
1524 newcolor.green = (green * 65535);
1525 newcolor.blue = (blue * 65535);
1526 newcolor.flags = -1;
1533 colorid -=
NUMCOLORS - NumPrivateColors;
1536 XSetWindowBackground(
Xdisplay, xd->window,
1542 XSetForeground(
Xdisplay, xd->xorgc,
1547 else if (sced_visual_info->class == TrueColor) {
1548 if (colorid < 0 || colorid >= NumPrivateColors)
1550 newcolor.red = (red * 65535);
1551 newcolor.green = (green * 65535);
1552 newcolor.blue = (blue * 65535);
1553 newcolor.flags = -1;
1557 XSetForeground(
Xdisplay, xd->gc, newcolor.pixel);
1561 XSetWindowBackground(
Xdisplay, xd->window,
1567 XSetForeground(
Xdisplay, xd->xorgc,
1577 X11_DefineLinestyle(linestyleid, mask)
1586 if (linestyleid < 0 || linestyleid >= NUMLINESTYLES)
1589 if (linestyleid == 0 || (mask & 0xff) == 0xff) {
1590 X11_SetLinestyle(0);
1594 if ((mask & 0xff) == 0)
1597 dash = xlinestyles[linestyleid]+2;
1599 while (!(imask & mask)) {
1605 while (imask && (imask & mask)) {
1612 while (imask && !(imask & mask)) {
1627 xlinestyles[linestyleid][0] = (char)0;
1628 xlinestyles[linestyleid][1] = (char)n;
1629 X11_SetLinestyle(linestyleid);
1636 X11_SetLinestyle(linestyleid)
1643 if (linestyleid < 0 || linestyleid >= NUMLINESTYLES)
1646 if ((linestyleid == 0) ||
1648 linestyleid != 1)) {
1652 values.line_style = LineSolid;
1655 values.line_style = LineOnOffDash;
1660 XSetDashes(
Xdisplay, xd->gc, xlinestyles[linestyleid][0],
1661 &xlinestyles[linestyleid][2], xlinestyles[linestyleid][1]);
1668 X11_SetColor(colorid)
1674 if (xd->gc == xd->xorgc)
1679 if (colorid < 0 || colorid >= NumPrivateColors)
1682 colorid +=
NUMCOLORS - NumPrivateColors;
1718 XClearWindow(
Xdisplay, xd->window);
1744 switch (request->option) {
1748 nfds = ConnectionNumber(
Xdisplay) > fileno(request->fp) ?
1750 fileno(request->fp);
1758 while (XtAppPending(app_con)) {
1759 XtAppNextEvent(app_con, &ev);
1760 XtDispatchEvent(&ev);
1764 FD_SET(ConnectionNumber(
Xdisplay), &readfds);
1766 FD_SET(fileno(request->fp), &readfds);
1772 if (FD_ISSET(ConnectionNumber(
Xdisplay), &readfds)) {
1774 while (XtAppPending(app_con)) {
1775 XtAppNextEvent(app_con, &ev);
1776 if (ev.type == KeyPress && xd &&
1777 ev.xkey.window == xd->window) {
1778 nbytes = XLookupString((XKeyEvent *)&ev, text, 4,
1781 response->
reply.
ch = (int)key;
1783 if (response->
reply.
ch != 0xff51 &&
1784 response->
reply.
ch != 0xff52 &&
1785 response->
reply.
ch != 0xff53 &&
1792 response->
x = ev.xkey.x;
1798 XtDispatchEvent(&ev);
1803 if (FD_ISSET(fileno(request->fp), &readfds)) {
1819 XtAppNextEvent(app_con, &ev);
1821 ev.xbutton.window == xd->window) {
1822 switch (ev.xbutton.button) {
1837 response->
x = ev.xbutton.x;
1843 if (ev.type == KeyPress && xd &&
1844 ev.xkey.window == xd->window) {
1845 nbytes = XLookupString((XKeyEvent *)&ev, text, 4,
1848 response->
reply.
ch = (int)key;
1850 if (response->
reply.
ch != 0xff51 &&
1851 response->
reply.
ch != 0xff52 &&
1852 response->
reply.
ch != 0xff53 &&
1859 response->
x = ev.xkey.x;
1865 XtDispatchEvent(&ev);
1867 if (xd && xd->drawghost && xd->firstghost ==
false) {
1870 (*xd->drawghost)(xd->lastx, xd->lasty, xd->refx, xd->refy);
1872 xd->firstghost =
true;
1880 while (XtAppPending(app_con)) {
1881 XtAppNextEvent(app_con, &ev);
1883 if (ev.type == KeyPress) {
1885 XLookupString((XKeyEvent *)&ev, text, 4, &key,
NULL);
1895 XtDispatchEvent(&ev);
1907 response->
option = request->option;
1913 slopelocation(graph, x0, y0)
1918 X11devdep *xd = (X11devdep*)graph->
devdep;
1919 Window window = xd->window;
1920 GC xorgc = xd->xorgc;
1921 Window rootwindow, childwindow;
1927 double fx0, fx1, fy0, fy1;
1932 if (graph->graphtype ==
GR_GRAF) {
1933 struct gplot *graf = (
struct gplot *)graph->plotdata;
1955 XQueryPointer(
Xdisplay, window, &rootwindow, &childwindow,
1956 &rootx, &rooty, &x, &y, &state);
1957 XDrawLine(
Xdisplay, window, xorgc, x0, y0, x0, y1-1);
1958 XDrawLine(
Xdisplay, window, xorgc, x0, y1, x1, y1);
1959 while (state & Button1Mask) {
1960 if (x != x1 || y != y1) {
1961 XDrawLine(
Xdisplay, window, xorgc, x0, y0, x0, y1-1);
1962 XDrawLine(
Xdisplay, window, xorgc, x0, y1, x1, y1);
1965 XDrawLine(
Xdisplay, window, xorgc, x0, y0, x0, y1-1);
1966 XDrawLine(
Xdisplay, window, xorgc, x0, y1, x1, y1);
1968 XQueryPointer(
Xdisplay, window, &rootwindow,
1969 &childwindow, &rootx, &rooty, &x, &y, &state);
1971 XDrawLine(
Xdisplay, window, xorgc, x0, y0, x0, y1-1);
1972 XDrawLine(
Xdisplay, window, xorgc, x0, y1, x1, y1);
1974 X_ScreentoData(graph, x0, y0, &fx0, &fy0);
1975 X_ScreentoData(graph, x1, y1, &fx1, &fy1);
1977 stw = XtNameToWidget(xd->widgets.form,
"slopetext");
1980 if (x1 == x0 && y1 == y0) {
1982 sprintf(buf,
"x0,y0\n%g\n%g", fx0, fy0);
1986 sprintf(buf,
"x0,y0\n%g\n%g\n\nx1,y1\n%g\n%g\n",
1987 fx0, fy0, fx1, fy1);
1988 sprintf(buf + strlen(buf),
1989 "\ndx,dy\n%g\n%g\n", fx1-fx0, fy1 - fy0);
1990 if (x1 != x0 && y1 != y0) {
1995 sprintf(buf + strlen(buf),
"\ndy/dx,dx/dy\n%g\n%g\n",
1996 (fy1-fy0)/(fx1-fx0), (fx1-fx0)/(fy1-fy0));
1999 XtVaSetValues(stw, XtNstring, buf,
NULL);
2009 X11devdep *xd = (X11devdep*)graph->
devdep;
2011 double fx0, fx1, fy0, fy1, ftemp;
2017 Window rootwindow, childwindow;
2020 int x, y, upperx, uppery, lowerx, lowery;
2021 Window window = xd->window;
2022 GC xorgc = xd->xorgc;
2029 struct gplot *graf = (
struct gplot *)graph->plotdata;
2038 XQueryPointer(
Xdisplay, window, &rootwindow,
2039 &childwindow, &rootx, &rooty, &x0, &y0, &state);
2041 x = lowerx = x1 = x0 + BOXSIZE;
2042 y = lowery = y1 = y0 + BOXSIZE;
2046 XDrawRectangle(
Xdisplay, window, xorgc,
2047 upperx, uppery, lowerx - upperx, lowery - uppery);
2049 XWarpPointer(
Xdisplay, None, xd->window, 0, 0, 0, 0, x1, y1);
2051 while (state & Button3Mask) {
2052 if (x != x1 || y != y1) {
2053 XDrawRectangle(
Xdisplay, window, xorgc,
2054 upperx, uppery, lowerx - upperx, lowery - uppery);
2075 XDrawRectangle(
Xdisplay, window, xorgc,
2076 upperx, uppery, lowerx - upperx, lowery - uppery);
2078 XQueryPointer(
Xdisplay, window, &rootwindow,
2079 &childwindow, &rootx, &rooty, &x, &y, &state);
2081 XDrawRectangle(
Xdisplay, window, xorgc,
2082 upperx, uppery, lowerx - upperx, lowery - uppery);
2084 if (graph->graphtype ==
GR_GRAF) {
2089 X_ScreentoData(graph, x0, y0, &fx0, &fy0);
2090 X_ScreentoData(graph, x1, y1, &fx1, &fy1);
2103 strncpy(buf2, graph->plotname,
sizeof(buf2));
2104 if (
t = strchr(buf2,
':'))
2109 "setplot %s ; %s xlimit %lg %lg ylimit %lg %lg ; setplot $curplot\n",
2110 buf2, graph->commandline, fx0, fx1, fy0, fy1);
2113 (void) sprintf(buf,
"%s xlimit %lg %lg ylimit %lg %lg\n",
2114 graph->commandline, fx0, fx1, fy0, fy1);
2130 X_ScreentoData(graph, x, y, fx, fy)
2139 + graph->datawindow.xmin;
2140 *fy = ((graph->absolute.height - y - 1) - graph->viewportyoff)
2141 * graph->aspectratioy
2142 + graph->datawindow.ymin;
2152 XrmDatabase db = XtDatabase(
Xdisplay);
2154 XrmPutLineResource(&db, str);
2172 s = XtMalloc(cnt + 1);
2190 static XKeyEvent ev;
2195 ev.window = XtWindow(sced_view);
2196 ev.keycode = XKeysymToKeycode(
Xdisplay, XK_Escape);
2197 XSendEvent(
Xdisplay, XtWindow(sced_view),
False, (
long)KeyPressMask,
void cp_pathfix(char *buf)
static char buf[MAXPROMPT]
static char * sens_list[]
struct gtrace tdata[PNUM]
bool cp_getvar(char *n, int t, char *r)
struct graph::@2 absolute
void graf_slopelocation()
internalerror(char *message)
int PopUpErrMessage(File *fp)
void com_setrdb(wordlist *wl)
union response::@11 reply
struct wordlist * wl_prev
while(TDesc->tSucc!=NULL)
static int errorhandler()
static char * wmTranslations
char * index(char *s, char c) const
struct wordlist * wl_next
externalerror(char *message)