main.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. /*
  2. Copyright (c) 1991 X Consortium
  3. Permission is hereby granted, free of charge, to any person obtaining
  4. a copy of this software and associated documentation files (the
  5. "Software"), to deal in the Software without restriction, including
  6. without limitation the rights to use, copy, modify, merge, publish,
  7. distribute, sublicense, and/or sell copies of the Software, and to
  8. permit persons to whom the Software is furnished to do so, subject to
  9. the following conditions:
  10. The above copyright notice and this permission notice shall be included
  11. in all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  13. OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  15. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
  16. OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  17. ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  18. OTHER DEALINGS IN THE SOFTWARE.
  19. Except as contained in this notice, the name of the X Consortium shall
  20. not be used in advertising or otherwise to promote the sale, use or
  21. other dealings in this Software without prior written authorization
  22. from the X Consortium.
  23. */
  24. /* xgc
  25. **
  26. ** main.c
  27. **
  28. ** Contains the bare minimum necessary to oversee the whole operation.
  29. */
  30. #include <X11/Intrinsic.h>
  31. #include <X11/StringDefs.h>
  32. #include <X11/Xaw/Form.h>
  33. #include <X11/Xaw/Command.h>
  34. #include <X11/Xaw/AsciiText.h>
  35. #include <X11/Shell.h>
  36. #include <stdio.h>
  37. #include <stdlib.h>
  38. #include "xgc.h"
  39. #define DEFINE_TILE
  40. #include "tile"
  41. static void fill_up_commandform(Widget);
  42. static void quit(void);
  43. static void quitAction(Widget, XEvent *, String *, Cardinal *);
  44. static void clear_test_window(void);
  45. static void clear_result_window(void);
  46. static void set_foreground_and_background(void);
  47. /* The three columns in the XgcData arrays are:
  48. ** name: the name of the toggle button
  49. ** text: the corresponding text in the xgc syntax
  50. ** code: the integer that the text corresponds to, for sending stuff
  51. ** to X calls, etc.
  52. */
  53. static XgcData FunctionData[NUM_FUNCTIONS] = {
  54. {"clear", "clear", GXclear},
  55. {"and", "and", GXand},
  56. {"andReverse", "andReverse", GXandReverse},
  57. {"copy", "copy", GXcopy},
  58. {"andInverted", "andInverted", GXandInverted},
  59. {"noop", "noop", GXnoop},
  60. {"xor", "xor", GXxor},
  61. {"or", "or", GXor},
  62. {"nor", "nor", GXnor},
  63. {"equiv", "equiv", GXequiv},
  64. {"invert", "invert", GXinvert},
  65. {"orReverse", "orReverse", GXorReverse},
  66. {"copyInverted", "copyInverted", GXcopyInverted},
  67. {"orInverted", "orInverted", GXorInverted},
  68. {"nand", "nand", GXnand},
  69. {"set", "set", GXset}
  70. };
  71. /* The two rows in the XgcStuff structure are:
  72. ** name of label, xgc syntax text, # of toggles, # of columns of toggles
  73. ** (0 columns means 1 row, as many columns as necessary)
  74. ** appropriate XgcData
  75. */
  76. XgcStuff FunctionStuff = {
  77. {"Function","function",NUM_FUNCTIONS,4},
  78. FunctionData
  79. };
  80. static XgcData TestData[NUM_TESTS] = {
  81. {"Copy Area", "CopyArea", CopyArea},
  82. {"Copy Plane", "CopyPlane", CopyPlane},
  83. {"Points", "PolyPoint", PolyPoint},
  84. {"Lines", "PolyLine", PolyLine},
  85. {"Segments", "PolySegment", PolySegment},
  86. {"Rectangles", "PolyRectangle", PolyRectangle},
  87. {"Arcs", "PolyArc", PolyArc},
  88. {"(Filled Polygons)", "FillPolygon", FillPolygon},
  89. {"Filled Rectangles", "PolyFillRect", PolyFillRect},
  90. {"Filled Arcs", "PolyFillArc", PolyFillArc},
  91. {"Put Image", "PutImage", PutImage},
  92. {"(Get Image)", "GetImage", GetImage},
  93. {"Text 8", "PolyText8", PolyText8},
  94. {"Image Text 8", "ImageText8", ImageText8},
  95. {"Text 16", "PolyText16", PolyText16},
  96. {"Image Text 16", "ImageText16", ImageText16}
  97. };
  98. XgcStuff TestStuff = {
  99. {"Test","test",NUM_TESTS,2},
  100. TestData
  101. };
  102. static XgcData LinestyleData[NUM_LINESTYLES] = {
  103. {"Solid", "Solid", LineSolid},
  104. {"OnOffDash", "OnOffDash", LineOnOffDash},
  105. {"DoubleDash", "DoubleDash", LineDoubleDash}
  106. };
  107. XgcStuff LinestyleStuff = {
  108. {"LineStyle","linestyle",NUM_LINESTYLES,0},
  109. LinestyleData
  110. };
  111. static XgcData CapstyleData[NUM_CAPSTYLES] = {
  112. {"NotLast", "NotLast", CapNotLast},
  113. {"Butt", "Butt", CapButt},
  114. {"Round", "Round", CapRound},
  115. {"Projecting", "Projecting", CapProjecting}
  116. };
  117. XgcStuff CapstyleStuff = {
  118. {"CapStyle","capstyle",NUM_CAPSTYLES,2},
  119. CapstyleData
  120. };
  121. static XgcData JoinstyleData[NUM_JOINSTYLES] = {
  122. {"Miter", "Miter", JoinMiter},
  123. {"Round", "Round", JoinRound},
  124. {"Bevel", "Bevel", JoinBevel}
  125. };
  126. XgcStuff JoinstyleStuff = {
  127. {"JoinStyle","joinstyle",NUM_JOINSTYLES,0},
  128. JoinstyleData
  129. };
  130. static XgcData FillstyleData[NUM_FILLSTYLES] = {
  131. {"Solid", "Solid", FillSolid},
  132. {"Tiled", "Tiled", FillTiled},
  133. {"Stippled", "Stippled", FillStippled},
  134. {"OpaqueStippled", "OpaqueStippled", FillOpaqueStippled}
  135. };
  136. XgcStuff FillstyleStuff = {
  137. {"FillStyle","fillstyle",NUM_FILLSTYLES,2},
  138. FillstyleData
  139. };
  140. static XgcData FillruleData[NUM_FILLRULES] = {
  141. {"EvenOdd", "EvenOdd", EvenOddRule},
  142. {"Winding", "Winding", WindingRule}
  143. };
  144. XgcStuff FillruleStuff = {
  145. {"FillRule","fillrule",NUM_FILLRULES,0},
  146. FillruleData
  147. };
  148. static XgcData ArcmodeData[NUM_ARCMODES] = {
  149. {"Chord", "Chord", ArcChord},
  150. {"PieSlice", "PieSlice", ArcPieSlice}
  151. };
  152. XgcStuff ArcmodeStuff = {
  153. {"ArcMode","arcmode",NUM_ARCMODES,0},
  154. ArcmodeData
  155. };
  156. /* Pointers to all the Xgcstuffs so we can run them through a loop */
  157. static XgcStuff *Everything[8] = {
  158. &FunctionStuff,
  159. &LinestyleStuff,
  160. &CapstyleStuff,
  161. &JoinstyleStuff,
  162. &FillstyleStuff,
  163. &FillruleStuff,
  164. &ArcmodeStuff,
  165. &TestStuff
  166. };
  167. #ifdef notdef
  168. int fildes[2]; /* for pipe */
  169. FILE *outend;
  170. #endif
  171. XStuff X; /* GC stuff plus some global variables */
  172. Boolean recording = FALSE; /* Whether we're recording into a file */
  173. XtAppContext appcontext; /* To make Xt happy */
  174. static Atom wm_delete_window;
  175. static XtActionsRec actions[] = {
  176. {"quit", quitAction}
  177. };
  178. static Widget bigdaddy; /* the top level widget */
  179. Widget topform; /* form surrounding the whole thing */
  180. Widget GCform; /* form in which you choose the GC */
  181. static Widget Testform; /* form in which you choose the test */
  182. Widget testchoiceform; /* form inside that */
  183. ChoiceDesc *testchoicedesc; /* record of what widgets are in the
  184. test choice form */
  185. static Widget commandform; /* form with run, quit, clear, etc. */
  186. Widget test; /* where the test is run */
  187. Widget result; /* where the results are displayed */
  188. static Widget runbutton; /* command for running */
  189. static Widget clearbutton; /* command for clearing the test window */
  190. Widget recordbutton; /* start/stop recording */
  191. static Widget playbackbutton; /* playback from file */
  192. static Widget keyinputbutton; /* start reading from keyboard */
  193. static Widget GCchoices[NUMCHOICES]; /* all the forms that contain stuff
  194. for changing GC's*/
  195. ChoiceDesc *GCdescs[NUMCHOICES]; /* record of the widgets inside
  196. the choice widgets */
  197. Widget planemaskchoice; /* form for choosing the plane mask */
  198. Widget dashlistchoice; /* form for choosing the dash list */
  199. static Widget linewidthchoice; /* form for choosing line width */
  200. Widget linewidthtext; /* text widget within that */
  201. static Widget fontchoice; /* form for choosing the font */
  202. Widget fonttext; /* text widget within that */
  203. static Widget foregroundchoice; /* form for choosing foreground */
  204. Widget foregroundtext; /* text widget within that */
  205. static Widget backgroundchoice; /* form for choosing background */
  206. Widget backgroundtext; /* text widget within that */
  207. static Widget percentchoice; /* form for choosing percentage of test */
  208. /* main(argc.argv)
  209. ** ---------------
  210. ** Initializes the toolkit, initializes data, puts up the widgets,
  211. ** starts the event loop.
  212. */
  213. int
  214. main(int argc, char *argv[])
  215. {
  216. static Arg shellargs[] = {
  217. {XtNinput, (XtArgVal) True}
  218. };
  219. static Arg testformargs[] = {
  220. {XtNfromVert, (XtArgVal) NULL} /* put it under GCform */
  221. };
  222. static Arg commandformargs[] = {
  223. {XtNfromVert, (XtArgVal) NULL}, /* put it under GCform */
  224. {XtNfromHoriz, (XtArgVal) NULL} /* and to the right of Testform */
  225. };
  226. static Arg testargs[] = {
  227. {XtNheight, (XtArgVal) 400},
  228. {XtNwidth, (XtArgVal) 400},
  229. {XtNfromHoriz, (XtArgVal) NULL} /* put it to the right of GCform */
  230. };
  231. static Arg resultargs[] = {
  232. {XtNheight, (XtArgVal) 50},
  233. {XtNwidth, (XtArgVal) 400},
  234. {XtNfromHoriz, (XtArgVal) NULL}, /* put it to the right of GCform */
  235. {XtNfromVert, (XtArgVal) NULL} /* and under test */
  236. };
  237. static Arg gcchoiceargs[] = {
  238. {XtNfromVert, (XtArgVal) NULL}, /* put it under the one above it */
  239. {XtNfromHoriz, (XtArgVal) NULL}, /* and next to that one */
  240. {XtNborderWidth, (XtArgVal) 0} /* no ugly borders */
  241. };
  242. static Arg testchoiceargs[] = {
  243. {XtNborderWidth, (XtArgVal) 0}
  244. };
  245. int i; /* counter */
  246. /* Open the pipe */
  247. #ifdef notdef
  248. pipe(fildes);
  249. outend = fdopen(fildes[0],"r");
  250. #endif
  251. /* Initialize toolkit stuff */
  252. XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL);
  253. bigdaddy = XtAppInitialize(&appcontext, "Xgc", (XrmOptionDescList) NULL,
  254. (Cardinal) 0, &argc, argv, (String *) NULL,
  255. shellargs, XtNumber(shellargs));
  256. X.dpy = XtDisplay(bigdaddy);
  257. XtAppAddActions(appcontext, actions, XtNumber(actions));
  258. XtOverrideTranslations
  259. (bigdaddy, XtParseTranslationTable("<Message>WM_PROTOCOLS: quit()"));
  260. /* Initialize GC stuff */
  261. X.scr = DefaultScreenOfDisplay(X.dpy);
  262. X.gc = XCreateGC(X.dpy,RootWindowOfScreen(X.scr),0,(XGCValues *) NULL);
  263. X.miscgc = XCreateGC(X.dpy,RootWindowOfScreen(X.scr),0,(XGCValues *) NULL);
  264. /* Find out what the foreground & background are, and update the GC
  265. ** accordingly */
  266. set_foreground_and_background();
  267. topform = XtCreateManagedWidget("topform",formWidgetClass,bigdaddy,
  268. NULL,0);
  269. GCform = XtCreateManagedWidget("GCform",formWidgetClass,topform,
  270. NULL,0);
  271. /* create all the GCchoices forms */
  272. for (i=0;i<NUMCHOICES;++i) {
  273. if (i==0) /* on top */
  274. gcchoiceargs[0].value = (XtArgVal) NULL;
  275. else /* under the last one */
  276. gcchoiceargs[0].value = (XtArgVal) GCchoices[i-1];
  277. GCchoices[i] = XtCreateManagedWidget(Everything[i]->choice.text,
  278. formWidgetClass,GCform,
  279. gcchoiceargs,XtNumber(gcchoiceargs));
  280. /* now fill up that form */
  281. GCdescs[i] = create_choice(GCchoices[i],Everything[i]);
  282. }
  283. /* put the planemask choice under the bottom GC choice */
  284. gcchoiceargs[0].value = (XtArgVal) GCchoices[NUMCHOICES-1];
  285. planemaskchoice = XtCreateManagedWidget("planemask",formWidgetClass,GCform,
  286. gcchoiceargs,XtNumber(gcchoiceargs));
  287. /* fill it up */
  288. create_planemask_choice(planemaskchoice);
  289. /* put the dashlist choice under the planemask choice */
  290. gcchoiceargs[0].value = (XtArgVal) planemaskchoice;
  291. dashlistchoice = XtCreateManagedWidget("dashlist",formWidgetClass,GCform,
  292. gcchoiceargs,XtNumber(gcchoiceargs));
  293. /* fill it up */
  294. create_dashlist_choice(dashlistchoice);
  295. /* put the linewidth choice under the dashlist choice */
  296. gcchoiceargs[0].value = (XtArgVal) dashlistchoice;
  297. linewidthchoice = XtCreateManagedWidget("linewidth",formWidgetClass,GCform,
  298. gcchoiceargs,XtNumber(gcchoiceargs));
  299. /* fill it up */
  300. linewidthtext = create_text_choice(linewidthchoice,TLineWidth,2,30);
  301. /* put the font choice under the linewidth choice */
  302. gcchoiceargs[0].value = (XtArgVal) linewidthchoice;
  303. fontchoice = XtCreateManagedWidget("font",formWidgetClass,GCform,
  304. gcchoiceargs,XtNumber(gcchoiceargs));
  305. /* fill it up */
  306. fonttext = create_text_choice(fontchoice,TFont,80,300);
  307. gcchoiceargs[0].value = (XtArgVal) fontchoice;
  308. foregroundchoice = XtCreateManagedWidget("foreground",formWidgetClass,GCform,
  309. gcchoiceargs,XtNumber(gcchoiceargs));
  310. foregroundtext = create_text_choice(foregroundchoice,TForeground,9,50);
  311. /* FIXME 9 characters may not be the proper choice; really it
  312. * should understand a more proper pixel specification... */
  313. gcchoiceargs[1].value = (XtArgVal) foregroundchoice;
  314. backgroundchoice = XtCreateManagedWidget("background",formWidgetClass,GCform,
  315. gcchoiceargs,XtNumber(gcchoiceargs));
  316. backgroundtext = create_text_choice(backgroundchoice,TBackground,9,50);
  317. gcchoiceargs[1].value = (XtArgVal) NULL;
  318. gcchoiceargs[0].value = (XtArgVal) foregroundchoice;
  319. percentchoice = XtCreateManagedWidget("testpercent",formWidgetClass,GCform,
  320. gcchoiceargs,XtNumber(gcchoiceargs));
  321. X.percent = 1.0;
  322. create_testfrac_choice(percentchoice);
  323. /* make all the labels inside the choices line up nicely */
  324. line_up_labels(GCdescs,(int) XtNumber(GCdescs));
  325. /* put the test form under the GC form */
  326. testformargs[0].value = (XtArgVal) GCform;
  327. Testform = XtCreateManagedWidget("Testform",formWidgetClass,topform,
  328. testformargs,XtNumber(testformargs));
  329. testchoiceform = XtCreateManagedWidget("testchoiceform",formWidgetClass,
  330. Testform,testchoiceargs,XtNumber(testchoiceargs));
  331. testchoicedesc = create_choice(testchoiceform,Everything[CTest]);
  332. commandformargs[0].value = (XtArgVal) GCform;
  333. commandformargs[1].value = (XtArgVal) Testform;
  334. commandform = XtCreateManagedWidget("commandform",formWidgetClass,topform,
  335. commandformargs,XtNumber(commandformargs));
  336. /* Put the appropriate command buttons in the command form */
  337. fill_up_commandform(commandform);
  338. testargs[2].value = (XtArgVal) GCform; /* to the right of */
  339. test = XtCreateManagedWidget("test",widgetClass,topform,
  340. testargs,XtNumber(testargs));
  341. resultargs[2].value = (XtArgVal) GCform; /* to the right of */
  342. resultargs[3].value = (XtArgVal) test; /* under */
  343. result = XtCreateManagedWidget("result",asciiTextWidgetClass,topform,
  344. resultargs,XtNumber(resultargs));
  345. /* Now realize all the widgets */
  346. XtRealizeWidget(bigdaddy);
  347. /* Now do things we couldn't do until we had a window available */
  348. X.win = XtWindow(test);
  349. X.tile = XCreatePixmap(X.dpy,X.win,tile_width,tile_height,
  350. DefaultDepthOfScreen(X.scr));
  351. X.tile = XCreatePixmapFromBitmapData(X.dpy,X.win,
  352. (char *)tile_bits,tile_width,
  353. tile_height,Black,White,
  354. DefaultDepthOfScreen(X.scr));
  355. X.stipple = XCreateBitmapFromData(X.dpy,X.win,(char *)tile_bits,tile_width,
  356. tile_height);
  357. XSetStipple(X.dpy,X.gc,X.stipple);
  358. XSetStipple(X.dpy,X.miscgc,X.stipple);
  359. GC_change_foreground(X.foreground,TRUE);
  360. GC_change_background(X.background,TRUE);
  361. wm_delete_window = XInternAtom(X.dpy, "WM_DELETE_WINDOW", False);
  362. (void) XSetWMProtocols(X.dpy, XtWindow(bigdaddy), &wm_delete_window, 1);
  363. /* Act like the user picked the first choice in each group */
  364. choose_defaults(GCdescs,(int)XtNumber(GCdescs));
  365. choose_defaults(&testchoicedesc,1);
  366. /* Loop forever, dealing with events */
  367. XtAppMainLoop(appcontext);
  368. return 0;
  369. }
  370. /* fill_up_commandform(w)
  371. ** ----------------------
  372. ** Put the appropriate command buttons in the command form (w).
  373. */
  374. static void
  375. fill_up_commandform(Widget w)
  376. {
  377. static XtCallbackRec runcallbacklist[] = {
  378. {(XtCallbackProc) run_test, NULL},
  379. {NULL, NULL}
  380. };
  381. static XtCallbackRec quitcallbacklist[] = {
  382. {(XtCallbackProc) quit, NULL},
  383. {NULL, NULL}
  384. };
  385. static XtCallbackRec clearcallbacklist[] = {
  386. {(XtCallbackProc) clear_test_window, NULL},
  387. {(XtCallbackProc) clear_result_window, NULL},
  388. {NULL, NULL}
  389. };
  390. static XtCallbackRec playbackcallbacklist[] = {
  391. {(XtCallbackProc) start_playback, NULL},
  392. {NULL, NULL}
  393. };
  394. static XtCallbackRec keyinputcallbacklist[] = {
  395. {(XtCallbackProc) read_from_keyboard, NULL},
  396. {NULL, NULL}
  397. };
  398. static XtCallbackRec recordcallbacklist[] = {
  399. {(XtCallbackProc) toggle_recordbutton, NULL},
  400. {NULL, NULL}
  401. };
  402. static Arg runargs[] = {
  403. {XtNcallback, (XtArgVal) NULL}
  404. };
  405. static Arg clearargs[] = {
  406. {XtNcallback, (XtArgVal) NULL},
  407. {XtNfromVert, (XtArgVal) NULL}, /* put it under runbutton */
  408. {XtNvertDistance,(XtArgVal) 10}
  409. };
  410. static Arg recordargs[] = {
  411. {XtNcallback, (XtArgVal) NULL},
  412. {XtNfromVert, (XtArgVal) NULL}, /* put it under clearbutton */
  413. {XtNvertDistance,(XtArgVal) 10},
  414. {XtNresizable, (XtArgVal) True} /* so we can change the name */
  415. };
  416. static Arg playbackargs[] = {
  417. {XtNcallback, (XtArgVal) NULL},
  418. {XtNfromVert, (XtArgVal) NULL} /* put it under recordbutton */
  419. };
  420. static Arg keyinputargs[] = {
  421. {XtNcallback, (XtArgVal) NULL},
  422. {XtNfromVert, (XtArgVal) NULL} /* put it under playbackbutton */
  423. };
  424. static Arg quitargs[] = {
  425. {XtNcallback, (XtArgVal) NULL},
  426. {XtNfromVert, (XtArgVal) NULL}, /* put it under keyinputbutton */
  427. {XtNvertDistance,(XtArgVal) 10}
  428. };
  429. runargs[0].value = (XtArgVal) runcallbacklist;
  430. runbutton = XtCreateManagedWidget("Run",commandWidgetClass,
  431. w,runargs,XtNumber(runargs));
  432. clearargs[0].value = (XtArgVal) clearcallbacklist;
  433. clearargs[1].value = (XtArgVal) runbutton; /* under */
  434. clearbutton = XtCreateManagedWidget("Clear window",commandWidgetClass,
  435. w,clearargs,XtNumber(clearargs));
  436. recordargs[0].value = (XtArgVal) recordcallbacklist;
  437. recordargs[1].value = (XtArgVal) clearbutton; /* under */
  438. recordbutton = XtCreateManagedWidget("Record",commandWidgetClass,
  439. w,recordargs,XtNumber(recordargs));
  440. playbackargs[0].value = (XtArgVal) playbackcallbacklist;
  441. playbackargs[1].value = (XtArgVal) recordbutton; /* under */
  442. playbackbutton = XtCreateManagedWidget("Playback",commandWidgetClass,
  443. w,playbackargs,XtNumber(playbackargs));
  444. keyinputargs[0].value = (XtArgVal) keyinputcallbacklist;
  445. keyinputargs[1].value = (XtArgVal) playbackbutton;
  446. keyinputbutton = XtCreateManagedWidget("Read Input",commandWidgetClass,
  447. w,keyinputargs,XtNumber(keyinputargs));
  448. quitargs[0].value = (XtArgVal) quitcallbacklist;
  449. quitargs[1].value = (XtArgVal) keyinputbutton; /* under */
  450. (void) XtCreateManagedWidget("Quit",commandWidgetClass,
  451. w,quitargs,XtNumber(quitargs));
  452. }
  453. /* quit()
  454. ** ------
  455. ** Leave the program nicely.
  456. */
  457. static void
  458. quit(void)
  459. {
  460. close_file_if_recording();
  461. exit(0);
  462. }
  463. static void quitAction(Widget w, XEvent *e, String *p, Cardinal *n)
  464. {
  465. if (e->type == ClientMessage && e->xclient.data.l[0] != wm_delete_window)
  466. XBell(XtDisplay(w), 0);
  467. else
  468. quit();
  469. }
  470. /* clear_test_window()
  471. ** -------------------
  472. ** Clear the test window.
  473. */
  474. static void
  475. clear_test_window(void)
  476. {
  477. XClearWindow(X.dpy,XtWindow(test));
  478. }
  479. /* clear_result_window()
  480. ** ---------------------
  481. ** Clear the result window.
  482. */
  483. static void
  484. clear_result_window(void)
  485. {
  486. set_text(result, "");
  487. }
  488. /* set_foreground_and_background()
  489. ** -------------------------------
  490. ** Finds the user-specified foreground and background by querying
  491. ** the resource manager, and sets state accordingly. Also specifies
  492. ** the initial font for text tests.
  493. */
  494. static void
  495. set_foreground_and_background(void)
  496. {
  497. X.gcv.foreground = X.foreground = 0;
  498. X.gcv.background = X.background = 0xffffffff;
  499. X.fontname = "6x10";
  500. GC_change_font(X.fontname,FALSE);
  501. }