home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume20 / xpt / part02 < prev    next >
Encoding:
Text File  |  1993-08-04  |  20.1 KB  |  765 lines

  1. Newsgroups: comp.sources.x
  2. From: lordj@rpi.edu (lordj@rpi.edu )
  3. Subject: v20i099:  xpt - An X Periodic Table, Part02/02
  4. Message-ID: <1993Aug4.170000.7405@sparky.sterling.com>
  5. X-Md4-Signature: c3752e8d1a45a1da748f2c1d76dc351f
  6. Sender: chris@sparky.sterling.com (Chris Olson)
  7. Organization: Sterling Software
  8. Date: Wed, 4 Aug 1993 17:00:00 GMT
  9. Approved: chris@sterling.com
  10.  
  11. Submitted-by: lordj@rpi.edu (lordj@rpi.edu )
  12. Posting-number: Volume 20, Issue 99
  13. Archive-name: xpt/part02
  14. Environment: X11
  15. Supersedes: xpt: Volume 19, Issue 69
  16.  
  17. [ This should have been in part 1, but slipped my mind... ]
  18. [     Chris                                               ]
  19.  
  20. This software displays an X periodic table.
  21.  
  22. #! /bin/sh
  23. # This is a shell archive.  Remove anything before this line, then feed it
  24. # into a shell via "sh file" or similar.  To overwrite existing files,
  25. # type "sh file -c".
  26. # Contents:  Imakefile Xprogs.c Xprogs.h init.c table.c version.h xpt.c
  27. # Wrapped by chris@sparky on Wed Aug  4 11:54:22 1993
  28. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  29. echo If this archive is complete, you will see the following message:
  30. echo '          "shar: End of archive 2 (of 2)."'
  31. if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  32.   echo shar: Will not clobber existing file \"'Imakefile'\"
  33. else
  34.   echo shar: Extracting \"'Imakefile'\" \(331 characters\)
  35.   sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
  36. X# @(#)Imakefile 23.7 91/06/11
  37. X# Imakefile - xlock
  38. X#
  39. XTARGETS = xpt
  40. X
  41. XSRCS = xpt.c init.c Xprogs.c table.c
  42. X
  43. XOBJS = xpt.o init.o Xprogs.o table.o
  44. X
  45. XLCL_LIB = XawClientLibs
  46. XDEPLIBS = XawClientDepLibs
  47. XSYS_LIBRARIES = -lm
  48. X
  49. XAllTarget($(TARGETS))
  50. X
  51. XNormalProgramTarget($(TARGETS), $(OBJS), $(DEPLIBS), $(LCL_LIB), $(SYS_LIB))
  52. X
  53. XDependTarget()
  54. END_OF_FILE
  55.   if test 331 -ne `wc -c <'Imakefile'`; then
  56.     echo shar: \"'Imakefile'\" unpacked with wrong size!
  57.   fi
  58.   # end of 'Imakefile'
  59. fi
  60. if test -f 'Xprogs.c' -a "${1}" != "-c" ; then 
  61.   echo shar: Will not clobber existing file \"'Xprogs.c'\"
  62. else
  63.   echo shar: Extracting \"'Xprogs.c'\" \(1678 characters\)
  64.   sed "s/^X//" >'Xprogs.c' <<'END_OF_FILE'
  65. X/**
  66. X *
  67. X * xpt -- An X Periodic Table
  68. X *
  69. X *  Modularized X Windows functions
  70. X *
  71. X * GetColors(name, cmap, def)
  72. X *  Allocates color "name", or uses color "def" if "name" is unavailable
  73. X *  char *name        name of color to be allocated
  74. X *  Colormap cmap    colormap to get "name" from
  75. X *  unsigned long def    default color to use if "name" is unavailable
  76. X *                probably the output from a function like "BlackPixel"
  77. X *
  78. X * XFontStruct *GetFont(fontname)
  79. X *  Load a font for use in X Windows
  80. X *  char *fontname    name of font to load
  81. X *
  82. X * GC CreateGC(window, font, fgcolor, bgcolor)
  83. X *  Create a Graphics Context for a window
  84. X *  Window window;        the window to create the graphics context for
  85. X *  XFontStruct font;        The default font for the window
  86. X *  unsigned long fgcolor, bgcolor;
  87. X *
  88. X *  Joel P. Lord 03/05/93
  89. X *
  90. X**/
  91. X
  92. X#define Xprogs
  93. X#include "Xprogs.h"
  94. X
  95. Xunsigned long GetColors(name, cmap, def)
  96. Xchar *name;
  97. XColormap cmap;
  98. Xunsigned long def;
  99. X{
  100. X  XColor color;
  101. X  unsigned long retval;
  102. X
  103. X  if (XParseColor(p_disp, cmap, name, &color) == 0 || 
  104. X      XAllocColor(p_disp, cmap, &color) == 0)
  105. X    retval = def;
  106. X  else
  107. X    retval = color.pixel;
  108. X  return retval;
  109. X}
  110. X
  111. XXFontStruct *GetFont(fname)
  112. Xchar *fname;
  113. X{
  114. X  XFontStruct *tempfont;
  115. X
  116. X  if ((tempfont = XLoadQueryFont(p_disp,fname)) == NULL)
  117. X    {
  118. X      fputs("Can't open font",stderr);
  119. X      fputs(fname,stderr);
  120. X      exit(1);
  121. X    }
  122. X  return tempfont;
  123. X}
  124. X
  125. XGC CreateGC(wind, fntstruct, fgpix, bgpix)
  126. XWindow wind;
  127. XXFontStruct *fntstruct;
  128. Xunsigned long fgpix, bgpix;
  129. X{
  130. X  XGCValues gcv;
  131. X
  132. X  gcv.font = fntstruct->fid;
  133. X  gcv.foreground = fgpix;
  134. X  gcv.background = bgpix;
  135. X
  136. X  return(XCreateGC(p_disp, wind, (GCFont | GCForeground | GCBackground), &gcv));
  137. X}
  138. END_OF_FILE
  139.   if test 1678 -ne `wc -c <'Xprogs.c'`; then
  140.     echo shar: \"'Xprogs.c'\" unpacked with wrong size!
  141.   fi
  142.   # end of 'Xprogs.c'
  143. fi
  144. if test -f 'Xprogs.h' -a "${1}" != "-c" ; then 
  145.   echo shar: Will not clobber existing file \"'Xprogs.h'\"
  146. else
  147.   echo shar: Extracting \"'Xprogs.h'\" \(1242 characters\)
  148.   sed "s/^X//" >'Xprogs.h' <<'END_OF_FILE'
  149. X/**
  150. X *
  151. X *  Definitions of some useful data types for Xlib programming,
  152. X *    as well as a few necessary variables (display name, etc)
  153. X *
  154. X *
  155. X *  Joel P. Lord 2/6/93
  156. X *
  157. X**/
  158. X
  159. X#include <stdio.h>
  160. X#include <string.h>
  161. X#include <X11/Xlib.h>
  162. X#include <X11/Xutil.h>
  163. X#include <X11/Xresource.h>
  164. X#include <X11/cursorfont.h>
  165. X#include <X11/keysym.h>
  166. X#include "fontlist.h"
  167. X
  168. X#define WP    WhitePixel(p_disp, DefaultScreen(p_disp))
  169. X#define BP    BlackPixel(p_disp, DefaultScreen(p_disp))
  170. X
  171. Xtypedef struct XWIN
  172. X{
  173. X  Window    xid;
  174. X  Window    parent;
  175. X  void        *data;
  176. X  void        (*event_handler)();
  177. X  GC        button_gc;
  178. X} XWIN;
  179. X
  180. Xtypedef struct Pix
  181. X{
  182. X  Pixmap    image;
  183. X  unsigned    width;
  184. X  unsigned    height;
  185. X} Pix;
  186. X
  187. Xtypedef struct D_BUTTON
  188. X{
  189. X  char        *label;
  190. X  int        (*action)();
  191. X  caddr_t    action_args;
  192. X  Pix        *pix;
  193. X} D_BUTTON;
  194. X
  195. X#ifdef MAIN
  196. X
  197. XXFontStruct *mfontstruct;
  198. Xunsigned mfontheight;
  199. XDisplay *p_disp;
  200. XWindow Main;
  201. XGC theGC;
  202. XXEvent theEvent;
  203. Xchar default_geometry[80];
  204. Xunsigned long mbgpix, mfgpix;
  205. XXContext xwin_context;
  206. X
  207. X#else
  208. X
  209. Xextern XFontStruct *mfontstruct;
  210. Xextern unsigned mfontheight;
  211. Xextern Display *p_disp;
  212. Xextern Window Main;
  213. Xextern GC theGC;
  214. Xextern XEvent theEvent;
  215. Xextern char default_geometry[80];
  216. Xextern unsigned long mbgpix, mfgpix;
  217. Xextern XContext xwin_context;
  218. X
  219. X#endif
  220. END_OF_FILE
  221.   if test 1242 -ne `wc -c <'Xprogs.h'`; then
  222.     echo shar: \"'Xprogs.h'\" unpacked with wrong size!
  223.   fi
  224.   # end of 'Xprogs.h'
  225. fi
  226. if test -f 'init.c' -a "${1}" != "-c" ; then 
  227.   echo shar: Will not clobber existing file \"'init.c'\"
  228. else
  229.   echo shar: Extracting \"'init.c'\" \(1047 characters\)
  230.   sed "s/^X//" >'init.c' <<'END_OF_FILE'
  231. X/**
  232. X *
  233. X * xpt -- An X Periodic Table
  234. X *
  235. X * init.c -- initialize the colors needed
  236. X *
  237. X * Written by Joel P. Lord 03/05/93
  238. X *
  239. X *    This software is available for free distribution,
  240. X * under the condition that this not be removed from the
  241. X * source code.
  242. X *
  243. X**/
  244. X
  245. X
  246. X#include "xpt.h"
  247. X
  248. Xunsigned long GetNumColor();
  249. X
  250. Xinit_colors()
  251. X{
  252. X  default_cmap = DefaultColormap(p_disp, DefaultScreen(p_disp));
  253. X
  254. X  mbgpix = GetColors("NavyBlue", default_cmap, BP);
  255. X  mfgpix = GetColors("white", default_cmap, WP);
  256. X  red = GetColors("red", default_cmap, WP);
  257. X  white = mfgpix;
  258. X  slate_grey = GetColors("slategrey", default_cmap, BP);
  259. X}
  260. X
  261. Xunsigned long GetNumColor(num, cmap, def)
  262. Xunsigned long num;
  263. XColormap cmap;
  264. Xunsigned long def;
  265. X{
  266. X  XColor color;
  267. X  unsigned long retval;
  268. X
  269. X  color.pixel = num;
  270. X  color.red = ((num >> 16) * 256);
  271. X  color.green = ((num >> 8) & 0xFF) * 256;
  272. X  color.blue = (num & 0xFF) * 256;
  273. X  color.flags = DoBlue | DoGreen | DoRed;
  274. X
  275. X  if (XAllocColor(p_disp, cmap, &color) == 0)
  276. X    retval = def;
  277. X  else
  278. X    retval = color.pixel;
  279. X
  280. X  return retval;
  281. X}
  282. END_OF_FILE
  283.   if test 1047 -ne `wc -c <'init.c'`; then
  284.     echo shar: \"'init.c'\" unpacked with wrong size!
  285.   fi
  286.   # end of 'init.c'
  287. fi
  288. if test -f 'table.c' -a "${1}" != "-c" ; then 
  289.   echo shar: Will not clobber existing file \"'table.c'\"
  290. else
  291.   echo shar: Extracting \"'table.c'\" \(9996 characters\)
  292.   sed "s/^X//" >'table.c' <<'END_OF_FILE'
  293. X/**
  294. X *
  295. X * xpt -- An X Periodic Table
  296. X *
  297. X * table.c - Create the periodic table, and handle data requests
  298. X *
  299. X * Written bu Joel P. Lord 03/05/93
  300. X *
  301. X *    This software is available for free distribution,
  302. X * under the condition that this not be removed from the
  303. X * source code.
  304. X *
  305. X**/
  306. X
  307. X#include "xpt.h"
  308. X#include <X11/Xaw/AsciiText.h>
  309. X
  310. Xvoid init_table()
  311. X{
  312. X  Widget elements[104];
  313. X  Widget quit_button;
  314. X  int n = 0, i = 0, j = 0, k = 0, horiz_offset = 5;
  315. X  Arg args[20];
  316. X  char title[3];
  317. X  void element_choice(), quit();
  318. X  XEvent tevent;
  319. X  static char *table[] = {
  320. X"H                                 He",
  321. X"LiBe                    B C N O F Ne",
  322. X"NaMg                    AlSiP S ClAr",
  323. X"K CaScTiV CrMnFeCoNiCuZnGaGeAsSeBrKr",
  324. X"RbSrY ZrNbMoTcRuRhPdAgCdInSnSbTeI Xe",
  325. X"CsBaLaHfTaW ReOsIrPtAuHgTlPbBiPoAtRn",
  326. X"FrRaAc                              ",
  327. X"                                    ",
  328. X"        CePrNdPmSmEuGdTbDyHoErTmYbLu",
  329. X"        ThPaU NpPuAmCmBkCfEsFmMdNoLr"
  330. X};
  331. X
  332. X  n = 0;
  333. X  XtSetArg(args[n], XtNfromHoriz, NULL);
  334. X  n++;
  335. X  XtSetArg(args[n], XtNfromVert, NULL);
  336. X  n++;
  337. X  XtSetArg(args[n], XtNhorizDistance, 5);
  338. X  n++;
  339. X  XtSetArg(args[n], XtNvertDistance, 5);
  340. X  n++;
  341. X  XtSetArg(args[n], XtNwidth, 24);
  342. X  n++;
  343. X  XtSetArg(args[n], XtNheight, 32);
  344. X  n++;
  345. X  mbgpix = GetColors("NavyBlue", default_cmap, BP);
  346. X  XtSetArg(args[n], XtNbackground, slate_grey);
  347. X  n++;
  348. X  XtSetArg(args[n], XtNforeground, mfgpix);
  349. X  n++;
  350. X  XtSetArg(args[n], XtNfont, mfontstruct);
  351. X  n++;
  352. X
  353. X  title[2] = 0;
  354. X  for (j = 0; j < 10; j++)
  355. X    {
  356. X      for(i = 0; i < 36; i += 2)
  357. X    {
  358. X      title[0] = table[j][i];
  359. X      title[1] = table[j][i+1];
  360. X      if (title[0] != ' ')
  361. X        {
  362. X          elements[k] = XtCreateWidget(title, commandWidgetClass,
  363. X                       MainW, args, n);
  364. X          XtAddCallback(elements[k], XtNcallback, element_choice, k);
  365. X          XtRealizeWidget(elements[k]);
  366. X          XtManageChild(elements[k]);
  367. X          k++;
  368. X          horiz_offset += 26;
  369. X          XtSetArg(args[2], XtNhorizDistance, horiz_offset);
  370. X        }
  371. X      else
  372. X        {
  373. X          horiz_offset += 26;
  374. X          XtSetArg(args[2], XtNhorizDistance, horiz_offset);
  375. X        }
  376. X    }
  377. X      horiz_offset = 0;
  378. X      XtSetArg(args[0], XtNfromHoriz, NULL);
  379. X      XtSetArg(args[1], XtNfromVert, elements[k-1]);
  380. X      XtSetArg(args[2], XtNhorizDistance, 5);
  381. X      XtSetArg(args[3], XtNvertDistance, 0);
  382. X    }
  383. X
  384. X  XtSetArg(args[0], XtNfromHoriz, NULL);
  385. X  XtSetArg(args[1], XtNfromVert, NULL);
  386. X  XtSetArg(args[2], XtNhorizDistance, 160);
  387. X  XtSetArg(args[3], XtNvertDistance, 5);
  388. X  XtSetArg(args[4], XtNwidth, 49);
  389. X  XtSetArg(args[5], XtNheight, 32);
  390. X  XtSetArg(args[6], XtNbackground, red);
  391. X  XtSetArg(args[7], XtNforeground, white);
  392. X  XtSetArg(args[9], XtNborderColor, red);
  393. X  
  394. X  quit_button = XtCreateManagedWidget("Quit", commandWidgetClass, MainW,
  395. X                      args, n + 1);
  396. X  XtRealizeWidget(quit_button);
  397. X  XtAddCallback(quit_button, XtNcallback, quit, 0);
  398. X}
  399. X
  400. Xstatic destroy_info;
  401. X
  402. Xvoid element_choice(w, element, event)
  403. XWidget w;
  404. Xint element;
  405. XXEvent *event;
  406. X{
  407. X  Widget element_info, ok_button, help_button;
  408. X  Arg args[20];
  409. X  char *data_buf;
  410. X  void ok(), help();
  411. X
  412. X  destroy_info = 0;
  413. X
  414. X  data_buf = (char *)malloc(1000);
  415. X
  416. X  element_info = XtVaCreateManagedWidget("Element Info",formWidgetClass, MainW,
  417. X                       XtNfromHoriz, NULL,
  418. X                       XtNfromVert, NULL,
  419. X                       XtNwidth, 200,
  420. X                       XtNheight, 250,
  421. X                       XtNvertDistance, 60,
  422. X                       XtNhorizDistance, 240,
  423. X                       XtNbackground, mbgpix,
  424. X                       XtNforeground, mfgpix,
  425. X                       XtNfont, mfontstruct,
  426. X                       XtNborderColor, slate_grey, NULL);
  427. X  display_info(element_info, element);
  428. X
  429. X  ok_button = XtVaCreateManagedWidget("Done", commandWidgetClass, element_info,
  430. X                    XtNfromHoriz, NULL,
  431. X                    XtNfromVert, NULL,
  432. X                    XtNwidth, 40,
  433. X                    XtNheight, 32,
  434. X                    XtNvertDistance, 210,
  435. X                    XtNhorizDistance, 100,
  436. X                    XtNbackground, slate_grey,
  437. X                    XtNforeground, mfgpix,
  438. X                    XtNfont, mfontstruct,
  439. X                    XtNborderColor, mbgpix, NULL);
  440. X
  441. X  XtAddCallback(ok_button, XtNcallback, ok, 0);
  442. X
  443. X  help_button = XtVaCreateManagedWidget("Help", commandWidgetClass,
  444. X                    element_info,
  445. X                    XtNfromHoriz, NULL,
  446. X                    XtNfromVert, NULL,
  447. X                    XtNwidth, 40,
  448. X                    XtNheight, 32,
  449. X                    XtNvertDistance, 210,
  450. X                    XtNhorizDistance, 60,
  451. X                    XtNbackground, slate_grey,
  452. X                    XtNforeground, mfgpix,
  453. X                    XtNfont, mfontstruct,
  454. X                    XtNborderColor, mbgpix, NULL);
  455. X  XtAddCallback(help_button, XtNcallback, help, 0);
  456. X
  457. X  while (!destroy_info && !done)
  458. X    {
  459. X      XtNextEvent(&theEvent);
  460. X      XtDispatchEvent(&theEvent);
  461. X      if (theEvent.type == Expose)
  462. X    display_info(element_info, element);
  463. X    }
  464. X  XtDestroyWidget(element_info);
  465. X  free(data_buf);
  466. X}
  467. X
  468. Xvoid ok(w, client_data, call_data)
  469. XWidget w;
  470. XXtPointer client_data, call_data;
  471. X{
  472. X  destroy_info = 1;
  473. X}
  474. X
  475. Xvoid quit(w, client_data, call_data)
  476. XWidget w;
  477. XXtPointer client_data;
  478. XXtPointer call_data;
  479. X{
  480. X  done = 1;
  481. X}
  482. X
  483. Xstatic unsigned destroy_help = 1;
  484. Xstatic Widget help_window;
  485. X
  486. Xvoid help(w, client_data, call_data)
  487. XWidget w;
  488. XXtPointer client_data, call_data;
  489. X{
  490. X  if (!destroy_help)
  491. X    {
  492. X      XtDestroyWidget(help_window);
  493. X      destroy_help = 1;
  494. X    }
  495. X  else
  496. X    {
  497. X      destroy_help = 0;
  498. X
  499. X      help_window = XtVaCreateManagedWidget("Element Info",formWidgetClass,
  500. X                        MainW,
  501. X                        XtNfromHoriz, NULL,
  502. X                        XtNfromVert, NULL,
  503. X                        XtNwidth, 200,
  504. X                        XtNheight, 250,
  505. X                        XtNvertDistance, 60,
  506. X                        XtNhorizDistance, 40,
  507. X                        XtNbackground, mbgpix,
  508. X                        XtNforeground, mfgpix,
  509. X                        XtNfont, mfontstruct,
  510. X                        XtNborderColor, slate_grey, NULL);
  511. X      display_help(help_window);
  512. X      
  513. X      while (!destroy_info && !done && !destroy_help)
  514. X    {
  515. X      XtNextEvent(&theEvent);
  516. X      XtDispatchEvent(&theEvent);
  517. X      if(theEvent.type == Expose)
  518. X        display_help();
  519. X    }
  520. X      XtDestroyWidget(help_window);
  521. X      destroy_help = 1;
  522. X    }
  523. X}
  524. X
  525. Xdisplay_help(w)
  526. XWidget w;
  527. X{
  528. X  XDrawString(p_disp, XtWindow(w), theGC, 10, 10 + mfontheight, "Number", 6);
  529. X  XDrawString(p_disp, XtWindow(w), BigGC,
  530. X          100 - XTextWidth(BigFont, "Sy", 2) / 2, 110 + mfontheight,
  531. X          "Sy", 2);
  532. X  XDrawString(p_disp, XtWindow(w), theGC, 
  533. X          190 - XTextWidth(mfontstruct, "Mass", 4),
  534. X          10 + mfontheight, "Mass", 4);
  535. X  XDrawString(p_disp, XtWindow(w), theGC, 10, 60 + mfontheight, "BP", 2);
  536. X  XDrawString(p_disp, XtWindow(w), theGC, 10, 100 + mfontheight, "MP", 2);
  537. X  XDrawString(p_disp, XtWindow(w), theGC, 10, 140 + mfontheight, "Density", 7);
  538. X
  539. X  XDrawString(p_disp, XtWindow(w), theGC,
  540. X          185 - XTextWidth(mfontstruct, "Atomic", 6),
  541. X          55 + mfontheight, "Atomic", 6);
  542. X  XDrawString(p_disp, XtWindow(w), theGC,
  543. X          190 - XTextWidth(mfontstruct, "Radius", 6),
  544. X          55 + 2 * mfontheight, "Radius", 6);
  545. X
  546. X  XDrawString(p_disp, XtWindow(w), theGC,
  547. X          185 - XTextWidth(mfontstruct, "Covalent", 8),
  548. X          95 + mfontheight, "Covalent", 8);
  549. X  XDrawString(p_disp, XtWindow(w), theGC,
  550. X          190 - XTextWidth(mfontstruct, "Radius", 6),
  551. X          95 + 2 * mfontheight, "Radius", 6);
  552. X
  553. X  XDrawString(p_disp, XtWindow(w), theGC,
  554. X          185 - XTextWidth(mfontstruct, "Atomic", 6),
  555. X          135 + mfontheight, "Atomic", 6);
  556. X  XDrawString(p_disp, XtWindow(w), theGC,
  557. X          190 - XTextWidth(mfontstruct, "Volume", 6),
  558. X          135 + 2 * mfontheight, "Volume", 6);
  559. X
  560. X  XDrawString(p_disp, XtWindow(w), theGC,
  561. X          100 - XTextWidth(mfontstruct, "Name", 4) / 2,
  562. X          190 + mfontheight, "Name", 4);
  563. X}
  564. X
  565. Xdisplay_info(w, element)
  566. XWidget w;
  567. Xunsigned element;
  568. X{
  569. X  char *temp_buf, *temp2;
  570. X
  571. X  temp_buf = (char *)malloc(100);
  572. X
  573. X  sprintf(temp_buf, "%d", p_table[element].atomic_number);
  574. X  XDrawString(p_disp, XtWindow(w), theGC, 10, 10 + mfontheight, temp_buf,
  575. X        strlen(temp_buf));
  576. X
  577. X  sprintf(temp_buf, "%s", p_table[element].symbol);
  578. X  temp2 = strchr(temp_buf, ' ');
  579. X  *temp2 = 0;
  580. X  XDrawString(p_disp, XtWindow(w), BigGC,
  581. X          100 - XTextWidth(BigFont, temp_buf, strlen(temp_buf)) / 2,
  582. X          110 + mfontheight, temp_buf, strlen(temp_buf));
  583. X
  584. X  sprintf(temp_buf, "%1.4lf", p_table[element].atomic_mass);
  585. X  XDrawString(p_disp, XtWindow(w), theGC,
  586. X          190 - XTextWidth(mfontstruct, temp_buf, strlen(temp_buf)),
  587. X          10 + mfontheight, temp_buf, strlen(temp_buf));
  588. X
  589. X  if (p_table[element].boiling_pt > 0.0)
  590. X    sprintf(temp_buf, "%.2lf", p_table[element].boiling_pt);
  591. X  else
  592. X    strcpy(temp_buf, "--");
  593. X  XDrawString(p_disp, XtWindow(w), theGC, 10, 60 + mfontheight, temp_buf,
  594. X          strlen(temp_buf));
  595. X
  596. X  if (p_table[element].melting_pt > 0.0)
  597. X    sprintf(temp_buf, "%.2lf", p_table[element].melting_pt);
  598. X  else
  599. X    strcpy(temp_buf, "--");
  600. X  XDrawString(p_disp, XtWindow(w), theGC, 10, 100 + mfontheight, temp_buf,
  601. X          strlen(temp_buf));
  602. X
  603. X
  604. X  if (p_table[element].density > 0.0)
  605. X    sprintf(temp_buf, "%.2lf", p_table[element].density);
  606. X  else
  607. X    strcpy(temp_buf, "--");
  608. X  XDrawString(p_disp, XtWindow(w), theGC, 10, 140 + mfontheight, temp_buf,
  609. X          strlen(temp_buf));
  610. X
  611. X  if (p_table[element].atomic_radius > 0.0)
  612. X    sprintf(temp_buf, "%.2lf", p_table[element].atomic_radius);
  613. X  else
  614. X    strcpy(temp_buf, "--");
  615. X  XDrawString(p_disp, XtWindow(w), theGC,
  616. X          190 - XTextWidth(mfontstruct, temp_buf, strlen(temp_buf)),
  617. X          60 + mfontheight, temp_buf, strlen(temp_buf));
  618. X
  619. X  if (p_table[element].covalent_radius > 0.0)
  620. X    sprintf(temp_buf, "%.2lf", p_table[element].covalent_radius);
  621. X  else
  622. X    strcpy(temp_buf, "--");
  623. X  XDrawString(p_disp, XtWindow(w), theGC,
  624. X          190 - XTextWidth(mfontstruct, temp_buf, strlen(temp_buf)),
  625. X          100 + mfontheight, temp_buf, strlen(temp_buf));
  626. X
  627. X  if (p_table[element].atomic_volume > 0.0)
  628. X    sprintf(temp_buf, "%.2lf", p_table[element].atomic_volume);
  629. X  else
  630. X    strcpy(temp_buf, "--");
  631. X  XDrawString(p_disp, XtWindow(w), theGC,
  632. X          190 - XTextWidth(mfontstruct, temp_buf, strlen(temp_buf)),
  633. X          140 + mfontheight, temp_buf, strlen(temp_buf));
  634. X
  635. X  strcpy(temp_buf, p_table[element].name);
  636. X  temp2 = strchr(temp_buf, ' ');
  637. X  *temp2 = 0;
  638. X  XDrawString(p_disp, XtWindow(w), theGC,
  639. X          100 - XTextWidth(mfontstruct, temp_buf, strlen(temp_buf)) / 2,
  640. X          190 + mfontheight, temp_buf, strlen(temp_buf));
  641. X
  642. X  free(temp_buf);
  643. X}
  644. END_OF_FILE
  645.   if test 9996 -ne `wc -c <'table.c'`; then
  646.     echo shar: \"'table.c'\" unpacked with wrong size!
  647.   fi
  648.   # end of 'table.c'
  649. fi
  650. if test -f 'version.h' -a "${1}" != "-c" ; then 
  651.   echo shar: Will not clobber existing file \"'version.h'\"
  652. else
  653.   echo shar: Extracting \"'version.h'\" \(104 characters\)
  654.   sed "s/^X//" >'version.h' <<'END_OF_FILE'
  655. X/**
  656. X *
  657. X *  This is a moderately useless file that contains only one thing:
  658. X *
  659. X**/
  660. X
  661. X#define VERSION    1.11
  662. END_OF_FILE
  663.   if test 104 -ne `wc -c <'version.h'`; then
  664.     echo shar: \"'version.h'\" unpacked with wrong size!
  665.   fi
  666.   # end of 'version.h'
  667. fi
  668. if test -f 'xpt.c' -a "${1}" != "-c" ; then 
  669.   echo shar: Will not clobber existing file \"'xpt.c'\"
  670. else
  671.   echo shar: Extracting \"'xpt.c'\" \(1291 characters\)
  672.   sed "s/^X//" >'xpt.c' <<'END_OF_FILE'
  673. X/**
  674. X *
  675. X *  xpt -- An X Periodic Table
  676. X *
  677. X * Written by Joel P. Lord 03/05/93
  678. X *
  679. X *    This software is available for free distribution,
  680. X * under the condition that this not be removed from the
  681. X * source code.
  682. X *
  683. X**/
  684. X
  685. X#define MAIN
  686. X#include <stdio.h>
  687. X#include "xpt.h"
  688. X
  689. Xmain(argc, argv)
  690. Xint argc;
  691. Xchar *argv[];
  692. X{
  693. X  Arg args[20];
  694. X  int n = 0;
  695. X  XGCValues gcv;
  696. X
  697. X  toplevel = XtInitialize("xpt", "X Periodic Table",
  698. X              NULL, 0, &argc, argv);
  699. X
  700. X  p_disp = XtDisplay(toplevel);
  701. X
  702. X  mfontstruct = (XFontStruct *)GetFont(HELV_MEDIUM_12);
  703. X  BigFont = (XFontStruct *)GetFont(HELV_BOLD_24);
  704. X  mfontheight = mfontstruct->max_bounds.ascent +
  705. X    mfontstruct->max_bounds.descent;
  706. X
  707. X  init_colors();
  708. X
  709. X  XtSetArg(args[n], XtNfont, mfontstruct);
  710. X  n++;
  711. X  XtSetArg(args[n], XtNheight, 320);
  712. X  n++;
  713. X  XtSetArg(args[n], XtNwidth, 480);
  714. X  n++;
  715. X  XtSetArg(args[n], XtNbackground, mbgpix);
  716. X  n++;
  717. X  XtSetArg(args[n], XtNforeground, mfgpix);
  718. X  n++;
  719. X
  720. X  MainW = XtCreateManagedWidget("Xpt", formWidgetClass, toplevel, args, n);
  721. X
  722. X  XtRealizeWidget(toplevel);
  723. X
  724. X  theGC = (GC)CreateGC(XtWindow(MainW), mfontstruct, mfgpix, mbgpix);
  725. X  BigGC = (GC)CreateGC(XtWindow(MainW), BigFont, mfgpix, mbgpix);
  726. X
  727. X  init_table();
  728. X
  729. X  done = 0;
  730. X
  731. X  while (!done)
  732. X    {
  733. X      XtNextEvent(&theEvent);
  734. X      XtDispatchEvent(&theEvent);
  735. X    }
  736. X}
  737. END_OF_FILE
  738.   if test 1291 -ne `wc -c <'xpt.c'`; then
  739.     echo shar: \"'xpt.c'\" unpacked with wrong size!
  740.   fi
  741.   # end of 'xpt.c'
  742. fi
  743. echo shar: End of archive 2 \(of 2\).
  744. cp /dev/null ark2isdone
  745. MISSING=""
  746. for I in 1 2 ; do
  747.     if test ! -f ark${I}isdone ; then
  748.     MISSING="${MISSING} ${I}"
  749.     fi
  750. done
  751. if test "${MISSING}" = "" ; then
  752.     echo You have unpacked both archives.
  753.     rm -f ark[1-9]isdone
  754. else
  755.     echo You still must unpack the following archives:
  756.     echo "        " ${MISSING}
  757. fi
  758. exit 0
  759. exit 0 # Just in case...
  760. -- 
  761.   // chris@Sterling.COM           | Send comp.sources.x submissions to:
  762. \X/  Amiga - The only way to fly! |    sources-x@sterling.com
  763.  "It's intuitively obvious to the |
  764.   most casual observer..."        | GCS d+/-- p+ c++ l+ m+ s++/+ g+ w+ t+ r+ x+
  765.