#include #include #include #include struct textpair { Widget in, out; }; void submit_cb(Widget w, void *d); void string_cb(Widget w, char *s, void *data); void quit(Widget w, void *d) {exit(0);} void pollin_cb(XtPointer client_data, int *source, XtInputId *id); int setup_sx(int argc, char **argv, Widget w[4]) { XtAppContext app; struct textpair tp; Widget w[4]; if (OpenDisplay(argc, argv) == 0) { fprintf(stderr, "couldn't open display\n"); return 1; } w[0] = MakeTextWidget("", 0, 0, 300, 200); w[1] = MakeStringEntry(NULL, 200, string_cb, w[0]); tp.in = w[1]; tp.out = w[0]; w[2] = MakeButton("Submit", submit_cb, &tp); w[3] = MakeButton("Quit", quit, NULL); SetWidgetPos(w[1], PLACE_UNDER, w[0], NO_CARE, NULL); SetWidgetPos(w[2], PLACE_RIGHT, w[1], PLACE_UNDER, w[0]); SetWidgetPos(w[3], PLACE_RIGHT, w[2], PLACE_UNDER, w[0]); if (!w[0] || !w[1]) return 1; app = XtWidgetToApplicationContext(w[0]); if (app == NULL) return 1; XtAppAddInput(app, /* stdin */ 0, XtInputReadMask, pollin_cb, w[0]); return 0; } int main(int argc, char **argv) { if (setup_sx(argc, argv, w) != 0) return 1; ShowDisplay(); GetStandardColors(); MainLoop(); return 0; }