home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume16 / xabacus / part04 < prev    next >
Encoding:
Internet Message Format  |  1992-02-04  |  10.7 KB

  1. Path: uunet!cs.utexas.edu!swrinde!mips!msi!dcmartin
  2. From: lfernand@ee.ryerson.ca (luis fernandes)
  3. Newsgroups: comp.sources.x
  4. Subject: v16i045: X abacus, Part04/04
  5. Message-ID: <1992Feb5.150000.21043@msi.com>
  6. Date: 5 Feb 92 15:00:00 GMT
  7. References: <csx-16i042-xabacus@uunet.UU.NET>
  8. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  9. Organization: Molecular Simulations, Inc.
  10. Lines: 392
  11. Approved: dcmartin@msi.com
  12. Originator: dcmartin@fascet
  13.  
  14. Submitted-by: lfernand@ee.ryerson.ca (luis fernandes)
  15. Posting-number: Volume 16, Issue 45
  16. Archive-name: xabacus/part04
  17.  
  18. # into a shell via "sh file" or similar.  To overwrite existing files,
  19. # type "sh file -c".
  20. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  21. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  22. # If this archive is complete, you will see the following message at the end:
  23. #        "End of archive 4 (of 4)."
  24. # Contents:  Imakefile Lesson2.cmd Lesson3.cmd demo.c maindefs.h
  25. #   patchlevel.h
  26. # Wrapped by dcmartin@snoopy on Mon Jan 13 16:06:32 1992
  27. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  28. if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'Imakefile'\"
  30. else
  31. echo shar: Extracting \"'Imakefile'\" \(1026 characters\)
  32. sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
  33. X#
  34. X# run makedepend for dependancies 
  35. X# -g enable dbx debugging info; 
  36. XCDEBUGFLAGS = -g
  37. X
  38. X#-DDEBUG will '#define DEBUG' statements (trace)
  39. X#CDEBUGFLAGS = -DDEBUG
  40. X
  41. X#Optimize
  42. X#CDEBUGFLAGS = -O 
  43. X
  44. X# -lm enables the math lib (needed if you #include <math.h>)
  45. X#EXTRA_LOAD_FLAGS = -lm
  46. X
  47. XSRCS= main.c Xinit.c aba.c demo.c 
  48. XOBJS= main.o Xinit.o aba.o demo.o
  49. X
  50. XLOCAL_LIBRARIES = $(XLIB) $(XTOOLLIB)
  51. X
  52. XComplexProgramTarget(xabacus)
  53. X
  54. X# Distribution: Make the shar-files ~no bigger than 64K
  55. Xshar: main.c Xinit.c aba.c demo.c Imakefile Makefile README xabacus.man XAbacus.ad icon.bm Lesson1.cmd Lesson2.cmd Lesson3.cmd xabacus.man XAbacus.ad
  56. X    shar -s 64000 README *.[ch] xabacus.man I* Makefile icon.bm *.cmd XAbacus.ad 
  57. X# Distribution: split the PS file into 2 files & shar them assuming the source
  58. X# can be contained in shar1 & shar2 
  59. Xpsshar: abacus.ps
  60. X    split -2500 abacus.ps abacus.ps
  61. X    shar -h shar3 abacus.psaa
  62. X    shar -h shar4 abacus.psab
  63. X
  64. X# join 2 PS files to create Abacus.ps
  65. Xps:
  66. X    cat abacus.psaa abacus.psab >Abacus.ps
  67. X    rm -f abacus.ps??
  68. X
  69. END_OF_FILE
  70. if test 1026 -ne `wc -c <'Imakefile'`; then
  71.     echo shar: \"'Imakefile'\" unpacked with wrong size!
  72. fi
  73. # end of 'Imakefile'
  74. fi
  75. if test -f 'Lesson2.cmd' -a "${1}" != "-c" ; then 
  76.   echo shar: Will not clobber existing file \"'Lesson2.cmd'\"
  77. else
  78. echo shar: Extracting \"'Lesson2.cmd'\" \(1707 characters\)
  79. sed "s/^X//" >'Lesson2.cmd' <<'END_OF_FILE'
  80. X16
  81. X-1 6 4
  82. XLesson 2: Addition 
  83. XThis Lesson demonstrates 2 addition problems: 
  84. X6+5 & 23+9
  85. XPress Space-bar to Begin
  86. X1 6 4
  87. XLesson 2: Addition (6+5)
  88. XWe Represent 6 by Adding 5...
  89. X(pending operation)
  90. XPress Space-bar to Continue
  91. X4 6 4
  92. XLesson 2: Addition (6+5)
  93. X...and 1.
  94. X(This is 6)
  95. XPress Space-bar to Continue
  96. X0 6 4
  97. XLesson 2: Addition (6+5)
  98. XAdding the 5...
  99. X(Requires a Carry)... 
  100. XPress Space-bar to Continue
  101. X4 5 4
  102. XLesson 2: Addition (6+5)
  103. X...So We Carry to the Previous Column...
  104. X(The 10's Column)
  105. XPress Space-bar to Continue
  106. X2 6 4
  107. XLesson 2: Addition (6+5)
  108. X...We Reset The Upper-deck and Obtain The Answer.
  109. X10 in the Previous Column + 1 in the Current= 11.
  110. XPress Space-bar to Continue
  111. X3 5 4
  112. XLesson 2: Addition
  113. XThat was a Straight-forward Example...
  114. X
  115. XPress Space-bar
  116. X3 6 4
  117. XLesson 2: Addition
  118. XThe following one is a bit more complicated. 
  119. XSo, pay attention...
  120. XPress Space-bar to Begin
  121. X5 5 4
  122. XLesson 2: Addition (23+9)
  123. X20... (begin to represent 23)
  124. X
  125. XPress Space-bar
  126. X6 6 4
  127. XLesson 2: Addition (23+9)
  128. X...+3, represents 23.
  129. X
  130. XPress Space-bar
  131. X0 6 4
  132. XLesson 2: Addition (23+9)
  133. XRepresent 9 as +10 -1.    So, 2 Beads on upper-deck= 10...
  134. X(pending carry to the 10's column)
  135. XPress Space-bar
  136. X6 5 4
  137. XLesson 2: Addition (23+9)
  138. X...carry to 10's column...
  139. X
  140. XPress Space-bar
  141. X2 6 4
  142. XLesson 2: Addition (23+9)
  143. XReset Upper-deck of Current-column...
  144. X(Pending the `-1' of +10-1= +9)
  145. XPress Space-bar
  146. X5 6 4
  147. XLesson 2: Addition (23+9)
  148. X... -1 (Current-column) completes +9
  149. XResulting in the answer: 32
  150. XPress Space-bar
  151. X-5 6 4
  152. XConclusion: (continued)
  153. XTo perform addition, move beads towards the 
  154. Xmid-beam; to subtract, move beads away from it.
  155. XPress Space-bar
  156. X-5 6 4
  157. XConclusion: (End)
  158. XTo gain profiency in using the abacus, practice !
  159. X
  160. XPress Space-bar
  161. END_OF_FILE
  162. if test 1707 -ne `wc -c <'Lesson2.cmd'`; then
  163.     echo shar: \"'Lesson2.cmd'\" unpacked with wrong size!
  164. fi
  165. # end of 'Lesson2.cmd'
  166. fi
  167. if test -f 'Lesson3.cmd' -a "${1}" != "-c" ; then 
  168.   echo shar: Will not clobber existing file \"'Lesson3.cmd'\"
  169. else
  170. echo shar: Extracting \"'Lesson3.cmd'\" \(725 characters\)
  171. sed "s/^X//" >'Lesson3.cmd' <<'END_OF_FILE'
  172. X7
  173. X-4 5 4
  174. XLesson 3: Subtraction
  175. XThis Lesson demonstrates subtracting 7 from 11
  176. X
  177. XPress Space-bar to Begin
  178. X4 5 4
  179. XLesson 3: Subtraction (11-7)
  180. XFirst Represent 11 as 10...
  181. X(pending operation)
  182. XPress Space-bar to Continue
  183. X4 6 4
  184. XLesson 3: Subtraction (11-7)
  185. X...and 1.
  186. X(This is 11)
  187. XPress Space-bar to Continue
  188. X-3 5 4
  189. XLesson 3: Subtraction (11-7)
  190. XWe Represent -7 as -10+3, so...
  191. X
  192. XPress Space-bar to Continue
  193. X3 5 4
  194. XLesson 3: Subtraction (11-7)
  195. X-10 ...
  196. X(pending operation +3)
  197. XPress Space-bar to Continue
  198. X7 6 4
  199. XLesson 3: Subtraction (11-7)
  200. X...+3 Completes The Operation
  201. XThe Answer is +4.
  202. XPress Space-bar
  203. X-7 6 4
  204. XConclusion: (End)
  205. XTo perform addition, move beads towards the 
  206. Xmid-beam; to subtract, move beads away from it.
  207. XPress Space-bar
  208. END_OF_FILE
  209. if test 725 -ne `wc -c <'Lesson3.cmd'`; then
  210.     echo shar: \"'Lesson3.cmd'\" unpacked with wrong size!
  211. fi
  212. # end of 'Lesson3.cmd'
  213. fi
  214. if test -f 'demo.c' -a "${1}" != "-c" ; then 
  215.   echo shar: Will not clobber existing file \"'demo.c'\"
  216. else
  217. echo shar: Extracting \"'demo.c'\" \(1568 characters\)
  218. sed "s/^X//" >'demo.c' <<'END_OF_FILE'
  219. X#include <stdio.h>
  220. X#include <string.h>
  221. X#include "main.h"
  222. X
  223. X#define drawText(x,y,str) XDrawString(display,demobase,gc[FRAME],x,y,str,strlen(str));
  224. X
  225. X
  226. X/* This array represents 4 lines of text that are to be displayed in the
  227. X * demo window; the module drawDemoWindow() will be passed a pointer to this
  228. X * array */
  229. Xchar displaytext[4][64];
  230. X
  231. Xchar *introtext[]={
  232. X    "Place this window below the abacus, then click & leave",
  233. X    "the pointer in the abacus window to begin the demo.",
  234. X    "During the demo, use the Space-bar to step.",
  235. X    "Type `q' to quit the demo.",
  236. X};
  237. X
  238. Xchar *querytext[]={
  239. X    "Type:",
  240. X    "  `c' to continue to next lesson",
  241. X    /*"                               ",*/
  242. X    "  `r' to repeat previous lesson",
  243. X    "  `q' to quit the demo",
  244. X};
  245. X
  246. Xint font_height;
  247. X
  248. XdrawIntro()
  249. X{
  250. Xint i;
  251. X
  252. X#ifdef DEBUG
  253. X    (void)fprintf(stderr," DEBUG drawIntro():\n");
  254. X#endif
  255. X
  256. X    font_height = font_info->max_bounds.ascent + font_info->max_bounds.descent;
  257. X
  258. X    for(i=0; i<4; i++){
  259. X        drawText(1,font_height+(font_height*i),introtext[i]); 
  260. X        XFlush(display);
  261. X    }
  262. X
  263. X}/*drawIntro*/
  264. X
  265. X/* drawQuery & drawDemoWindow do look identical. Why, I hear you asking, didn't
  266. X * he just pass a pointer to the text that needs to be displayed ?
  267. X * Good question.
  268. X */
  269. XdrawQuery()
  270. X{
  271. Xint i;
  272. X
  273. X    XClearWindow(display,demobase);
  274. X
  275. X    for(i=0; i<4; i++){
  276. X        drawText(1,font_height+(font_height*i),querytext[i]);
  277. X        XFlush(display);
  278. X    }
  279. X
  280. X}/* draw_Query */
  281. X
  282. XdrawDemoWindow()
  283. X{
  284. Xint i;
  285. X
  286. X    XClearWindow(display,demobase);
  287. X
  288. X    for(i=0; i<4; i++){
  289. X        drawText(1,font_height+(font_height*i),displaytext[i]);
  290. X        XFlush(display);
  291. X    }
  292. X
  293. X}/*drawDemoWindow*/
  294. X
  295. END_OF_FILE
  296. if test 1568 -ne `wc -c <'demo.c'`; then
  297.     echo shar: \"'demo.c'\" unpacked with wrong size!
  298. fi
  299. # end of 'demo.c'
  300. fi
  301. if test -f 'maindefs.h' -a "${1}" != "-c" ; then 
  302.   echo shar: Will not clobber existing file \"'maindefs.h'\"
  303. else
  304. echo shar: Extracting \"'maindefs.h'\" \(1745 characters\)
  305. sed "s/^X//" >'maindefs.h' <<'END_OF_FILE'
  306. X#include <X11/Xlib.h>
  307. X#include <X11/Xutil.h>
  308. X#include <X11/Xos.h>
  309. X#include <X11/Intrinsic.h>
  310. X#include <X11/StringDefs.h>
  311. X
  312. X/* name of the application when iconified & on window*/
  313. X#define APPNAME     "xabacus"
  314. X#define DEMOWINAME  "xabacus-demo"
  315. X#define DEMOCOL        6
  316. X
  317. X#define KEYBUFFERSIZE   10
  318. X/* size of windows*/
  319. X#define SMALL   1
  320. X#define OK      0
  321. X
  322. X#define MAXCOLORS   4          /* the number of colors (GC's) required*/
  323. X#define COLORSTRLEN    32            /* length of a color name */
  324. X
  325. X#define BDWINCOLOR  "white" /* border color for windows*/
  326. X
  327. X/* attributes of topLevel window for bogus WM's*/
  328. X#define INITPOSX    15
  329. X#define INITPOSY    15
  330. X
  331. X/* initial attributes of the abacus, in pixels*/
  332. X#define BEADHEIGHT    20
  333. X#define BEADWIDTH    30
  334. X#define FRAMEWIDTH    10        /* thickness of the frame*/
  335. X
  336. X#define COLGAP        2                /* gap between 2 cols*/
  337. X#define ROWGAP        2                /* gap between 2 cols*/
  338. X
  339. X#define NTOPROWS    3                /*(2 beads, 1 gap on top-deck)*/
  340. X#define NBOTROWS    6                /*(5 beads, 1 gap on top-deck)*/
  341. X
  342. X#define MAXCOLS        100                /* maximum number of columns*/
  343. X#define NCOLS        13                /* number of columns*/
  344. X#define NROWS        (NTOPROWS+NBOTROWS)
  345. X
  346. X#define MIDFRAME    (FRAMEWIDTH+(NTOPROWS*BEADHEIGHT)+((NTOPROWS+1)*ROWGAP))
  347. X
  348. X/* width/height of window depends on attributes of the abacus*/
  349. X#define INITWIDTH    ((2*FRAMEWIDTH)+(NCOLS*BEADWIDTH)+((NCOLS+1)*COLGAP))
  350. X#define INITHEIGHT    ((3*FRAMEWIDTH)+(NROWS*BEADHEIGHT)+((NROWS+1)*ROWGAP))
  351. X
  352. X#define DEMOINITWIDTH    INITWIDTH
  353. X#define DEMOINITHEIGHT    100
  354. X
  355. X#define MINWIDTH    INITWIDTH         /* minimum size of application */
  356. X#define MINHEIGHT    INITHEIGHT         
  357. X
  358. Xenum { FRAME,BACKGROUND,BEADS,RAILS};    /* for referring to the gc's*/
  359. X
  360. X/*return TRUE if row 'r' in col 'c' is occupied by a bead*/
  361. X#define RowOccupied(r,c)    ((c & 1<<(r))?1:0)
  362. X
  363. END_OF_FILE
  364. if test 1745 -ne `wc -c <'maindefs.h'`; then
  365.     echo shar: \"'maindefs.h'\" unpacked with wrong size!
  366. fi
  367. # end of 'maindefs.h'
  368. fi
  369. if test -f 'patchlevel.h' -a "${1}" != "-c" ; then 
  370.   echo shar: Will not clobber existing file \"'patchlevel.h'\"
  371. else
  372. echo shar: Extracting \"'patchlevel.h'\" \(88 characters\)
  373. sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
  374. X/* xabacus: Begun on Mon Jun 24 1991 */
  375. X
  376. X#define RELEASENUM    "1.0"
  377. X#define PATCHLEVEL    0
  378. X
  379. END_OF_FILE
  380. if test 88 -ne `wc -c <'patchlevel.h'`; then
  381.     echo shar: \"'patchlevel.h'\" unpacked with wrong size!
  382. fi
  383. # end of 'patchlevel.h'
  384. fi
  385. echo shar: End of archive 4 \(of 4\).
  386. cp /dev/null ark4isdone
  387. MISSING=""
  388. for I in 1 2 3 4 ; do
  389.     if test ! -f ark${I}isdone ; then
  390.     MISSING="${MISSING} ${I}"
  391.     fi
  392. done
  393. if test "${MISSING}" = "" ; then
  394.     echo You have unpacked all 4 archives.
  395.     rm -f ark[1-9]isdone
  396. else
  397.     echo You still need to unpack the following archives:
  398.     echo "        " ${MISSING}
  399. fi
  400. ##  End of shell archive.
  401. exit 0
  402. -- 
  403. Molecular Simulations, Inc.             mail: dcmartin@msi.com
  404. 796 N. Pastoria Avenue                  uucp: uunet!dcmartin
  405. Sunnyvale, California 94086             at&t: 408/522-9236
  406.