home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume20 / xball / part04 < prev    next >
Encoding:
Text File  |  1993-05-26  |  80.6 KB  |  2,429 lines

  1. Newsgroups: comp.sources.x
  2. From: daven@ctron.com ("David N. Nedde")
  3. Subject: v20i004:  xball - simulate bouncing balls in a window, Part04/05
  4. Message-ID: <1993May24.202909.24274@sparky.imd.sterling.com>
  5. X-Md4-Signature: 24313c58a7cc0e2830cde92407fead99
  6. Sender: chris@sparky.imd.sterling.com (Chris Olson)
  7. Organization: Sterling Software
  8. Date: Mon, 24 May 1993 20:29:09 GMT
  9. Approved: chris@sparky.imd.sterling.com
  10.  
  11. Submitted-by: daven@ctron.com ("David N. Nedde")
  12. Posting-number: Volume 20, Issue 4
  13. Archive-name: xball/part04
  14. Environment: X11, OSF/Motif, Athena
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then unpack
  18. # it by saving it into a file and typing "sh file".  To overwrite existing
  19. # files, type "sh file -c".  You can also feed this as standard input via
  20. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  21. # will see the following message at the end:
  22. #        "End of archive 4 (of 5)."
  23. # Contents:  xball.c xball_sys.c color_l.h demo.h fallback.h file_sel.h
  24. #   item.h items.h list.h menu.h misc.h names.h room.h scrollbar.h
  25. #   sim.h table.h xball_sys.h act_area.c act_area.h filemenu.c
  26. #   gen_fallback run_demos xball.man
  27. # Wrapped by daven@osiris on Tue May  4 16:35:08 1993
  28. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  29. if test -f 'xball.c' -a "${1}" != "-c" ; then 
  30.   echo shar: Will not clobber existing file \"'xball.c'\"
  31. else
  32. echo shar: Extracting \"'xball.c'\" \(3794 characters\)
  33. sed "s/^X//" >'xball.c' <<'END_OF_FILE'
  34. X/**********************************************************************
  35. X/* XBall.c - Written by David Nedde (daven@ivy.wpi.edu) 5/93
  36. X/* Features: Motif or Athena widget interface
  37. X/*           Item collision detection
  38. X/*           Window resize -> boundry change
  39. X/*           Kind-of Randomly colored balls
  40. X/*         Shaded 3-D-looking balls
  41. X/*           Different ball creation algorithms
  42. X/*
  43. X/* Copyright 1991, 1993 David Nedde
  44. X/*
  45. X * Permission to use, copy, modify, and distribute this software
  46. X * and its documentation for any purpose and without fee is granted
  47. X * provided that the above copyright notice appears in all copies.
  48. X * It is provided "as is" without express or implied warranty.
  49. X/**********************************************************************/
  50. X
  51. X/* System Headers */
  52. X#include <stdio.h>
  53. X#include <X11/Intrinsic.h>
  54. X
  55. X/* Local headers */
  56. X#include "xball_sys.h"
  57. X#include "miscx.h"
  58. X#include "patchlevel.h"
  59. X
  60. X/* Macros */
  61. X#define VERSION 3
  62. X
  63. X
  64. X/*** Start of main program ***/
  65. Xmain(argc,argv)
  66. Xunsigned argc;
  67. Xchar * * argv;
  68. X{
  69. X    /* Use the app-defaults file as a set of strings for the fallback */
  70. X    static String fallback_resources[] = {
  71. X#include "fallback.h"
  72. X    };
  73. X    Widget            toplevel;
  74. X    XtAppContext      app_context;
  75. X    xball_system_type xball_system;
  76. X
  77. X
  78. X    static XrmOptionDescRec options[] = {
  79. X        {"-delay",      "*delay",      XrmoptionSepArg, NULL },
  80. X        {"-gravity",    "*gravity",    XrmoptionSepArg, NULL },
  81. X        {"-elasticity", "*elasticity", XrmoptionSepArg, NULL },
  82. X        {"-itemWidth",  "*itemWidth",  XrmoptionSepArg, NULL },
  83. X        {"-itemHeight", "*itemHeight", XrmoptionSepArg, NULL },
  84. X        {"-rgbTxt",     "*rgbTxt",     XrmoptionSepArg, NULL },
  85. X        {"-help",       "*help",       XrmoptionNoArg, "True"},
  86. X        {"-collide",    "*collide",    XrmoptionNoArg, "True"},
  87. X        {"-perpetual",  "*perpetual",  XrmoptionNoArg, "True"},
  88. X        {"-haltSim",    "*haltSim",    XrmoptionNoArg, "True"},
  89. X        {"-demoFile",   "*demoFile",   XrmoptionSepArg, NULL}
  90. X    };
  91. X
  92. X
  93. X    if (argc > 1 && strncmp(argv[1],"-help", strlen(argv[1])) == 0)
  94. X    {
  95. X        printf("XBall - version %d, patchlevel %d.\n\n", VERSION, PATCHLEVEL);
  96. X        puts("Usage:\n\txball [-options ...]\n\nWhere options include:");
  97. X        puts(" Option          Default  Resource    Meaning");
  98. X        puts(" -help                                Print out this message");
  99. X        puts(" -delay number      0     delay       Default delay setting to slow program");
  100. X        puts(" -gravity          10     gravity     Default gravity setting");
  101. X        puts(" -elasticity       90     elasticity  Default elasticity value");
  102. X        puts(" -itemWidth        10     itemWidth   Width of the drawn item");
  103. X        puts(" -itemHeight       10     itemHeight  Height of the drawn item");
  104. X        puts(" -collide                 collide     Balls hit each other if specified");
  105. X        puts(" -perpetual               perpetual   Balls do not die if specified");
  106. X        puts(" -haltSim                 haltSim     Starts w/simulation halted if specified");
  107. X        puts(" -demoFile                demoFile    A demo file to run at startup");
  108. X        puts(" -rgbTxt         /usr/lib/X11/app-defaults/rgb.txt");
  109. X        puts("                          rgbTxt      Path of the rgb.txt file");
  110. X
  111. X        exit(0);
  112. X    }
  113. X
  114. X    toplevel = XtAppInitialize(&app_context,"XBall",
  115. X                               options, XtNumber( options),
  116. X                               &argc, argv,     
  117. X                               fallback_resources,
  118. X                               /*args*/(ArgList)NULL, /*num_args*/(Cardinal)0);
  119. X    setupConverters();
  120. X
  121. X    xball_system = xball_system__create( toplevel);
  122. X
  123. X    XtRealizeWidget(toplevel);
  124. X
  125. X    XtAppMainLoop(app_context);
  126. X
  127. X    return 0;
  128. X}
  129. END_OF_FILE
  130. if test 3794 -ne `wc -c <'xball.c'`; then
  131.     echo shar: \"'xball.c'\" unpacked with wrong size!
  132. fi
  133. # end of 'xball.c'
  134. fi
  135. if test -f 'xball_sys.c' -a "${1}" != "-c" ; then 
  136.   echo shar: Will not clobber existing file \"'xball_sys.c'\"
  137. else
  138. echo shar: Extracting \"'xball_sys.c'\" \(6487 characters\)
  139. sed "s/^X//" >'xball_sys.c' <<'END_OF_FILE'
  140. X/**********************************************************************
  141. X * xball_sys.c - xball system object definition.
  142. X *
  143. X * Copyright 1993, David Nedde
  144. X *
  145. X * Permission to use, copy, modify, and distribute this software
  146. X * and its documentation for any purpose and without fee is granted
  147. X * provided that the above copyright notice appears in all copies.
  148. X * It is provided "as is" without express or implied warranty.
  149. X **********************************************************************/
  150. X
  151. X/* System Headers */
  152. X#include <X11/StringDefs.h>
  153. X#include <X11/Intrinsic.h>
  154. X
  155. X#ifdef MOTIF
  156. X#include <Xm/Form.h>
  157. X#include <Xm/Label.h>
  158. X#endif
  159. X
  160. X#ifdef ATHENA
  161. X#include <X11/Xaw/Form.h>
  162. X#endif
  163. X
  164. X/* Local headers */
  165. X#include "xball_sys.h"
  166. X#include "names.h"
  167. X#include "misc.h"
  168. X
  169. X
  170. X/* Creates the xball system.  This object holds together the other
  171. X   objects in the system. */
  172. Xxball_system_type xball_system__create( w)
  173. XWidget w;
  174. X{
  175. X    xball_system_type xball_system;
  176. X    menu_type         menu;
  177. X    room_type         room;
  178. X    demo_type         demo;
  179. X    help_type         help;
  180. X    sim_type          sim;
  181. X    items_type        items;
  182. X    file_sel_type     file_sel;
  183. X    scrollbar_type    gravity_bar;
  184. X    scrollbar_type    elasticity_bar;
  185. X    Widget            form_widget;
  186. X
  187. X
  188. X    typedef struct {
  189. X        int gravity;
  190. X        int elasticity;
  191. X        Boolean ball_collide;
  192. X        Boolean perpetual;
  193. X        Boolean halt_sim;
  194. X    } app_data,*app_data_ptr;
  195. X    app_data res_data;
  196. X    static XtResource resources[] = {
  197. X    { "gravity", "Gravity", XtRInt, sizeof(int),
  198. X          XtOffset(app_data_ptr,gravity), XtRImmediate, (caddr_t)GRAVITY },
  199. X    { "elasticity", "Elasticity", XtRInt, sizeof(int),
  200. X          XtOffset(app_data_ptr,elasticity), XtRImmediate,(caddr_t)ELASTICITY },
  201. X    { "collide", "Collide", XtRBoolean, sizeof(Boolean),
  202. X    XtOffset(app_data_ptr,ball_collide), XtRString, "False"},
  203. X    { "perpetual", "Perpetual", XtRBoolean, sizeof(Boolean),
  204. X    XtOffset(app_data_ptr,perpetual), XtRString, "False"},
  205. X    { "haltSim", "HaltSim", XtRBoolean, sizeof(Boolean),
  206. X    XtOffset(app_data_ptr,halt_sim), XtRString, "False"}
  207. X    };
  208. X
  209. X
  210. X    XtGetApplicationResources(w, (XtPointer)&res_data, 
  211. X                              resources, XtNumber(resources), 
  212. X                              (ArgList)NULL,(Cardinal)0);
  213. X
  214. X    xball_system = XtNew( xball_system_struct);
  215. X
  216. X
  217. X    /* Create the various objects in the system */
  218. X
  219. X#ifdef MOTIF
  220. X    xball_system->form_w = form_widget = 
  221. X        XtCreateWidget("form", xmFormWidgetClass, w, NULL,0);
  222. X#endif
  223. X
  224. X#ifdef ATHENA
  225. X    xball_system->form_w = form_widget = 
  226. X        XtVaCreateWidget( "formAW", formWidgetClass, w, NULL);
  227. X#endif
  228. X
  229. X    xball_system->menu = menu = menu__create( form_widget);
  230. X
  231. X    xball_system->elasticity_bar = elasticity_bar =
  232. X        scrollbar__create( form_widget, ELASTICITY_BAR);
  233. X
  234. X    xball_system->gravity_bar = gravity_bar =
  235. X        scrollbar__create( form_widget, GRAVITY_BAR);
  236. X
  237. X    item__set_perpetual( menu__get_toggle( menu, PERPETUAL));
  238. X    item__set_ball_collide( menu__get_toggle( menu, BALL_COLLIDE));
  239. X
  240. X    xball_system->file_sel = file_sel = file_sel__create(w);
  241. X
  242. X    xball_system->items = items = items__create();
  243. X    xball_system->room = room = room__create( form_widget, items, file_sel);
  244. X
  245. X    xball_system->demo = demo = demo__create(w, menu, gravity_bar,
  246. X                                             elasticity_bar, file_sel,
  247. X                                             items, room);
  248. X
  249. X    xball_system->sim = sim = sim__create(w, menu, items, room, demo);
  250. X
  251. X    xball_system->help = help = help__create(w);
  252. X
  253. X
  254. X    XtManageChild( form_widget);
  255. X
  256. X
  257. X    /* Add the scrollbar callbacks and set their values */
  258. X
  259. X    scrollbar__add_callback( xball_system->gravity_bar,
  260. X                             room__set_gravity_cb,
  261. X                             (XtPointer)xball_system->room);
  262. X    scrollbar__set_value( xball_system->gravity_bar, res_data.gravity);
  263. X
  264. X    scrollbar__add_callback( xball_system->elasticity_bar,
  265. X                             item__set_elasticity_cb,
  266. X                             (XtPointer)NULL);
  267. X    scrollbar__set_value( xball_system->elasticity_bar, res_data.elasticity);
  268. X
  269. X
  270. X    /* Register avaliable menu callbacks */
  271. X
  272. X    menu__add_callback(menu, "runDemo",  demo__run_mcb,  demo);
  273. X    menu__add_callback(menu, "stopDemo", demo__stop_mcb, demo);
  274. X
  275. X    menu__add_callback(menu, "clear",      room__clear_mcb,       room);
  276. X    menu__add_callback(menu, "randomize",  room__randomize_mcb,   room);
  277. X    menu__add_callback(menu, "loadBitmap", room__load_bitmap_mcb, room);
  278. X
  279. X    menu__add_callback(menu, "quit",   xball_system__quit_mcb,   xball_system);
  280. X
  281. X    menu__add_callback(menu, "perpetual",   item__perpetual_mcb, NULL);
  282. X    menu__add_callback(menu, "ballCollide", item__collide_mcb,   NULL);
  283. X    menu__add_callback(menu, "haltSim",     sim__halt_mcb,       sim);
  284. X    menu__add_callback(menu, "stepSim",     sim__step_mcb,       sim);
  285. X
  286. X    /* Set the values of these menu toggle widgets */
  287. X    menu__set_toggle( menu, PERPETUAL,     res_data.perpetual);
  288. X    menu__set_toggle( menu, BALL_COLLIDE,  res_data.ball_collide);
  289. X    menu__set_toggle( menu, HALT_SIM,      res_data.halt_sim);
  290. X
  291. X
  292. X    menu__add_callback(menu, "about",     help__display_mcb, help);
  293. X    menu__add_callback(menu, "onMenus",   help__display_mcb, help);
  294. X    menu__add_callback(menu, "onScroll",  help__display_mcb, help);
  295. X    menu__add_callback(menu, "onButtons", help__display_mcb, help);
  296. X    menu__add_callback(menu, "onDemos",   help__display_mcb, help);
  297. X    menu__add_callback(menu, "onParams",  help__display_mcb, help);
  298. X
  299. X    return xball_system;
  300. X}
  301. X
  302. X
  303. X/* Free the xball system object */
  304. Xvoid xball_system__destroy(xball_system)
  305. Xxball_system_type xball_system;
  306. X{
  307. X    file_sel__destroy( xball_system->file_sel);
  308. X    help__destroy( xball_system->help);
  309. X    demo__destroy( xball_system->demo);
  310. X    room__destroy( xball_system->room);
  311. X    sim__destroy( xball_system->sim);
  312. X    items__destroy( xball_system->items);
  313. X    scrollbar__destroy( xball_system->elasticity_bar);
  314. X    scrollbar__destroy( xball_system->gravity_bar);
  315. X    menu__destroy( xball_system->menu);
  316. X
  317. X    XtDestroyWidget( xball_system->form_w);
  318. X
  319. X
  320. X
  321. X    XtFree( (char *)xball_system);
  322. X}
  323. X
  324. X
  325. X/* Called if the user selects the quit menu item */
  326. Xvoid xball_system__quit_mcb( w, xball_system, call_data, extra)
  327. XWidget            w;
  328. Xxball_system_type xball_system;
  329. Xcaddr_t           call_data;
  330. Xchar *            extra;
  331. X{
  332. X    XtCloseDisplay(XtDisplay(xball_system->form_w));
  333. X
  334. X    exit(EXIT_SUCCESS);
  335. X}
  336. END_OF_FILE
  337. if test 6487 -ne `wc -c <'xball_sys.c'`; then
  338.     echo shar: \"'xball_sys.c'\" unpacked with wrong size!
  339. fi
  340. # end of 'xball_sys.c'
  341. fi
  342. if test -f 'color_l.h' -a "${1}" != "-c" ; then 
  343.   echo shar: Will not clobber existing file \"'color_l.h'\"
  344. else
  345. echo shar: Extracting \"'color_l.h'\" \(1347 characters\)
  346. sed "s/^X//" >'color_l.h' <<'END_OF_FILE'
  347. X/**********************************************************************
  348. X * color_l.h - Color list object declaration
  349. X *
  350. X * Copyright 1993, David Nedde
  351. X *
  352. X * Permission to use, copy, modify, and distribute this software
  353. X * and its documentation for any purpose and without fee is granted
  354. X * provided that the above copyright notice appears in all copies.
  355. X * It is provided "as is" without express or implied warranty.
  356. X **********************************************************************/
  357. X
  358. X#ifndef __COLOR_L_H__
  359. X#define __COLOR_L_H__
  360. X
  361. X#include "list.h"
  362. X
  363. X
  364. X#define SHADES 4  /* Number of shades for colors in the rgb.txt file */
  365. X
  366. X
  367. Xtypedef struct {
  368. X    list_type shaded_4_list;
  369. X} color_list_struct, *color_list_type;
  370. X
  371. Xtypedef struct {
  372. X    int    r,g,b;
  373. X    char * name;
  374. X    int    last_char;
  375. X} color_struct, *color_type;
  376. X
  377. X
  378. Xcolor_list_type color_list__create(/*filename*/);
  379. Xvoid            color_list__destroy(/*color_list*/);
  380. Xcolor_type      color_list__remove(/* color_list, index*/);
  381. Xint             color_list__get_count(/* color_list*/);
  382. Xcolor_type      color_list__get_last(/* color_list*/);
  383. Xcolor_type      color_list__get_prev(/* color_list*/);
  384. Xchar *          color__get_shade(/* color, shade_num*/);
  385. X
  386. X/* Inline functions */
  387. X#define color_list__get_cell(list, index) \
  388. X    ((color_type)list__get_cell((list)->shaded_4_list, index))
  389. X
  390. X
  391. X#endif
  392. END_OF_FILE
  393. if test 1347 -ne `wc -c <'color_l.h'`; then
  394.     echo shar: \"'color_l.h'\" unpacked with wrong size!
  395. fi
  396. # end of 'color_l.h'
  397. fi
  398. if test -f 'demo.h' -a "${1}" != "-c" ; then 
  399.   echo shar: Will not clobber existing file \"'demo.h'\"
  400. else
  401. echo shar: Extracting \"'demo.h'\" \(1826 characters\)
  402. sed "s/^X//" >'demo.h' <<'END_OF_FILE'
  403. X/**********************************************************************
  404. X * demo.h - declares the demo object
  405. X *
  406. X * Copyright 1993, David Nedde
  407. X *
  408. X * Permission to use, copy, modify, and distribute this software
  409. X * and its documentation for any purpose and without fee is granted
  410. X * provided that the above copyright notice appears in all copies.
  411. X * It is provided "as is" without express or implied warranty.
  412. X **********************************************************************/
  413. X
  414. X#ifndef __DEMO_H__
  415. X#define __DEMO_H__
  416. X
  417. X#include <stdio.h>
  418. X#include <X11/Intrinsic.h>
  419. X
  420. X#include "menu.h"
  421. X#include "scrollbar.h"
  422. X#include "file_sel.h"
  423. X#include "items.h"
  424. X#include "room.h"
  425. X
  426. X
  427. Xtypedef struct {
  428. X    Bool interactive;           /* Demo 'exit' will not exit program if 
  429. X                                   interactive is True */
  430. X    scrollbar_type gravity;     /* Gravity scrollbar */
  431. X    scrollbar_type elasticity;  /* Elasticity acrollbar */
  432. X    menu_type      menu;
  433. X    file_sel_type  file_sel;    /* To query user for demo file */
  434. X    items_type     items;
  435. X    room_type      room;
  436. X
  437. X    FILE *   file_ptr;      /* The file pointer for the current demo file */
  438. X    char *   file_name;     /* The name of the current demo file */
  439. X    unsigned iterations;    /* Number of iterations we are currently pausing */
  440. X} demo_struct_type, *demo_type;
  441. X
  442. X
  443. X/* Public methods */
  444. Xdemo_type demo__create(/* w, menu, gravity, elasticity, file_sel, items, 
  445. X                       room*/);
  446. Xvoid      demo__destroy(/* demo*/);
  447. Xvoid      demo__run_mcb(/* w, demo, call_data, extra*/);
  448. Xvoid      demo__stop_mcb(/* w, demo, call_data, extra*/);
  449. Xvoid      demo__stop(/* demo*/);
  450. XBool      demo__running(/*demo*/);
  451. Xvoid      demo__process(/*demo*/);
  452. X
  453. X/* Inline functions */
  454. X#define demo__set_interactive( demo, inter) ((demo)->interactive = (inter))
  455. X
  456. X
  457. X#endif
  458. END_OF_FILE
  459. if test 1826 -ne `wc -c <'demo.h'`; then
  460.     echo shar: \"'demo.h'\" unpacked with wrong size!
  461. fi
  462. # end of 'demo.h'
  463. fi
  464. if test -f 'fallback.h' -a "${1}" != "-c" ; then 
  465.   echo shar: Will not clobber existing file \"'fallback.h'\"
  466. else
  467. echo shar: Extracting \"'fallback.h'\" \(17606 characters\)
  468. sed "s/^X//" >'fallback.h' <<'END_OF_FILE'
  469. X/* fallback.h generated by gen_fallback from XBall.ad - do not edit! */
  470. X
  471. X"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
  472. X"! XBall.ad - xball resource file",
  473. X"!",
  474. X"! Copyright 1991, David Nedde",
  475. X"!",
  476. X"! Permission to use, copy, modify, and distribute this",
  477. X"! software and its documentation for any purpose and without fee",
  478. X"! is granted provided that the above copyright notice appears in all copies.",
  479. X"! It is provided 'as is' without express or implied warranty.",
  480. X"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
  481. X"",
  482. X"XBall.title: XBall - Written by David Nedde",
  483. X"",
  484. X"XBall*form.horizontalSpacing:   2",
  485. X"XBall*form.verticalSpacing:     2",
  486. X"XBall*form.width:               400",
  487. X"XBall*form.height:              400",
  488. X"XBall.allowShellResize:     True",
  489. X"XBall*resizable:                True",
  490. X"",
  491. X"",
  492. X"!!!!!!!!!!",
  493. X"! Menu Bar",
  494. X"!!!!!!!!!!",
  495. X"",
  496. X"XBall*menuBar.rightAttachment:  ATTACH_FORM",
  497. X"XBall*menuBar.leftAttachment:   ATTACH_FORM",
  498. X"! Athena resources",
  499. X"XBall*menuBar*MenuButton.borderWidth: 0",
  500. X"XBall*menuBar.borderWidth:            1",
  501. X"XBall.formAW*translations: #override        \n\
  502. X        <Key>q: menu_action( quit)        \n\
  503. X        Ctrl<Key>q: menu_action( quit)    \n\
  504. X        Ctrl<Key>c: menu_action( quit)    \n\
  505. X        <Key>c: menu_action( clear)       \n\
  506. X        <Key>r: menu_action( randomize)   \n\
  507. X        <Key>s: menu_action( stepSim)     \n\
  508. X        <Key>p: menu_action( perpetual)   \n\
  509. X        <Key>b: menu_action( ballCollide) \n\
  510. X        <Key>h: menu_action( haltSim)     \n\
  511. X        <Key>l: menu_action( loadBitmap)  \n\
  512. X        <Key>d: menu_action( runDemo)     \n\
  513. X        <Key>a: menu_action( about)       \n\
  514. X",
  515. X"",
  516. X"",
  517. X"! File Submenu",
  518. X"XBall*file.labelString:         File",
  519. X"XBall*file.label:               File",
  520. X"XBall*file.mnemonic:            F",
  521. X"XBall*about.labelString:        About...",
  522. X"XBall*about.label:              About...        A",
  523. X"XBall*about.mnemonic:           A",
  524. X"XBall*about.accelerator:        <Key>A",
  525. X"XBall*about.acceleratorText:    A",
  526. X"XBall*runDemo.labelString:      Run Demo...",
  527. X"XBall*runDemo.label:            Run Demo...     D",
  528. X"XBall*runDemo.mnemonic:             D",
  529. X"XBall*runDemo.accelerator:      <Key>D",
  530. X"XBall*runDemo.acceleratorText:  D",
  531. X"XBall*loadBitmap.labelString:   Load Bitmap...",
  532. X"XBall*loadBitmap.label:         Load Bitmap...  L",
  533. X"XBall*loadBitmap.mnemonic:      L",
  534. X"XBall*loadBitmap.accelerator:   <Key>L",
  535. X"XBall*loadBitmap.acceleratorText: L",
  536. X"XBall*quit.labelString:         Quit",
  537. X"XBall*quit.label:               Quit            Q",
  538. X"XBall*quit.mnemonic:            Q",
  539. X"XBall*quit.accelerator:         <Key>Q",
  540. X"XBall*quit.acceleratorText:     Q",
  541. X"",
  542. X"! Action Submenu",
  543. X"XBall*actions.labelString:      Actions",
  544. X"XBall*actions.label:            Actions",
  545. X"XBall*actions.mnemonic:         A",
  546. X"XBall*clear.labelString:        Clear",
  547. X"XBall*clear.label:              Clear            C",
  548. X"XBall*clear.mnemonic:           C",
  549. X"XBall*clear.acceleratorText:    C",
  550. X"XBall*clear.accelerator:        <Key>C",
  551. X"XBall*randomize.labelString:    Randomize",
  552. X"XBall*randomize.label:          Randomize        R",
  553. X"XBall*randomize.mnemonic:       R",
  554. X"XBall*randomize.acceleratorText:R",
  555. X"XBall*randomize.accelerator:    <Key>R",
  556. X"XBall*stopDemo.labelString:     Stop Demo",
  557. X"XBall*stopDemo.label:           Stop Demo",
  558. X"XBall*stepSim.labelString:      Step Simulation",
  559. X"XBall*stepSim.label:            Step Simulation  S",
  560. X"XBall*stepSim.mnemonic:         S",
  561. X"XBall*stepSim.acceleratorText:  S",
  562. X"XBall*stepSim.accelerator:      <Key>S",
  563. X"",
  564. X"! Options Submenu",
  565. X"XBall*options.labelString:              Options",
  566. X"XBall*options.label:                    Options",
  567. X"XBall*options.mnemonic:                 O",
  568. X"XBall*perpetual.labelString:            Perpetual",
  569. X"XBall*perpetual.label:                  Perpetual        P",
  570. X"XBall*perpetual.mnemonic:               P",
  571. X"XBall*perpetual.acceleratorText:        P",
  572. X"XBall*perpetual.accelerator:            <Key>P",
  573. X"XBall*ballCollide.labelString:          Ball Collide",
  574. X"XBall*ballCollide.label:                Ball Collide     B",
  575. X"XBall*ballCollide.mnemonic:             B",
  576. X"XBall*ballCollide.acceleratorText:      B",
  577. X"XBall*ballCollide.accelerator:          <Key>B",
  578. X"XBall*haltSim.labelString:              Halt Simulation",
  579. X"XBall*haltSim.label:                    Halt Simulation  H",
  580. X"XBall*haltSim.mnemonic:                 H",
  581. X"XBall*haltSim.acceleratorText:          H",
  582. X"XBall*haltSim.accelerator:              <Key>H",
  583. X"",
  584. X"! Help Submenu",
  585. X"XBall*help.labelString:         Help",
  586. X"XBall*help.label:               Help",
  587. X"XBall*help.mnemonic:            H",
  588. X"XBall*onAuthor.labelString:     On Author...",
  589. X"XBall*onAuthor.label:           On Author...",
  590. X"XBall*onMenus.labelString:      On Menus...",
  591. X"XBall*onMenus.label:            On Menus...",
  592. X"XBall*onScroll.labelString:     On Scrollbars...",
  593. X"XBall*onScroll.label:           On Scrollbars...",
  594. X"XBall*onButtons.labelString:    On Buttons...",
  595. X"XBall*onButtons.label:          On Buttons...",
  596. X"XBall*onDemos.labelString:      On Demos...",
  597. X"XBall*onDemos.label:            On Demos...",
  598. X"XBall*onParams.labelString:     On Parameters...",
  599. X"XBall*onParams.label:           On Parameters...",
  600. X"",
  601. X"",
  602. X"XBall*elasticityBar.topAttachment:      ATTACH_WIDGET",
  603. X"XBall*elasticityBar.topWidget:          menuBar",
  604. X"XBall*elasticityBar.leftAttachment:     ATTACH_FORM",
  605. X"",
  606. X"XBall*elasticityBar.label.labelString:          Elasticity",
  607. X"XBall*elasticityBar.label.leftAttachment:       ATTACH_FORM",
  608. X"XBall*elasticityBar.label.leftOffset:           10",
  609. X"XBall*elasticityBar.label.topAttachment:        ATTACH_FORM",
  610. X"XBall*elasticityBar.label.bottomAttachment:     ATTACH_FORM",
  611. X"! Athena resources",
  612. X"XBall*elasticityBar.fromVert:                   menuBar",
  613. X"XBall*elasticityBar.label.label:                Elasticity",
  614. X"XBall*elasticityBar.label.borderWidth:          0",
  615. X"",
  616. X"XBall*elasticityBar.bar.width:          100",
  617. X"XBall*elasticityBar.bar.orientation:    HORIZONTAL",
  618. X"XBall*elasticityBar.bar.maximum:        100",
  619. X"XBall*elasticityBar.bar.minimum:        0",
  620. X"XBall*elasticityBar.bar.showValue:      True",
  621. X"! Athena resources",
  622. X"XBall*elasticityBar.bar.shown:          0.1",
  623. X"XBall*elasticityBar.borderWidth:        0",
  624. X"XBall*elasticityBar.label.borderWidth:  0",
  625. X"XBall*elasticityBar.feedback.borderWidth: 0",
  626. X"XBall*elasticityBar.defaultDistance:    0",
  627. X"",
  628. X"",
  629. X"",
  630. X"XBall*gravityBar.label.labelString:      Gravity",
  631. X"XBall*gravityBar.label.leftAttachment:   ATTACH_FORM",
  632. X"XBall*gravityBar.label.topAttachment:    ATTACH_FORM",
  633. X"XBall*gravityBar.label.bottomAttachment: ATTACH_FORM",
  634. X"! Athena resources",
  635. X"XBall*gravityBar.label.label:           Gravity",
  636. X"XBall*gravityBar.label.borderWidth:     0",
  637. X"",
  638. X"XBall*gravityBar.leftAttachment:        ATTACH_WIDGET",
  639. X"XBall*gravityBar.leftWidget:            elasticityBar",
  640. X"XBall*gravityBar.leftOffset:            20",
  641. X"XBall*gravityBar.topAttachment:         ATTACH_WIDGET",
  642. X"XBall*gravityBar.topWidget:             menuBar",
  643. X"XBall*gravityBar.bar.width:             100",
  644. X"XBall*gravityBar.bar.orientation:       HORIZONTAL",
  645. X"XBall*gravityBar.bar.maximum:           100",
  646. X"XBall*gravityBar.bar.minimum:           0",
  647. X"XBall*gravityBar.bar.showValue:         True",
  648. X"! Athena resources",
  649. X"XBall*gravityBar.fromVert:              menuBar",
  650. X"XBall*gravityBar.horizDistance:         20",
  651. X"XBall*gravityBar.fromHoriz:             elasticityBar",
  652. X"XBall*gravityBar.bar.shown:             0.1",
  653. X"XBall*gravityBar.borderWidth:           0",
  654. X"XBall*gravityBar.label.borderWidth:     0",
  655. X"XBall*gravityBar.feedback.borderWidth:  0",
  656. X"XBall*gravityBar.defaultDistance:       0",
  657. X"",
  658. X"XBall*canvas.resizable:                 True",
  659. X"XBall*canvas.borderWidth:               1",
  660. X"XBall*canvas.topAttachment:             ATTACH_WIDGET",
  661. X"XBall*canvas.topWidget:                 gravityBar",
  662. X"XBall*canvas.bottomAttachment:          ATTACH_FORM",
  663. X"XBall*canvas.rightAttachment:           ATTACH_FORM",
  664. X"XBall*canvas.leftAttachment:            ATTACH_FORM",
  665. X"! Athena resources",
  666. X"XBall*canvas.fromVert:                  gravityBar",
  667. X"XBall*canvas.width:                     400",
  668. X"XBall*canvas.height:                    330",
  669. X"",
  670. X"",
  671. X"XBall*help_dialog_popup.title:                      XBall Information",
  672. X"XBall*help_dialog_action_area.leftAttachment:       ATTACH_FORM",
  673. X"XBall*help_dialog_action_area.rightAttachment:      ATTACH_FORM",
  674. X"XBall*help_dialog_action_area.bottomAttachment:     ATTACH_FORM",
  675. X"XBall*help_dialog_action_area.close.labelString:    Close",
  676. X"XBall*help_dialog.close.label:                      Close",
  677. X"XBall*help_dialog.separator.rightAttachment:        ATTACH_FORM",
  678. X"XBall*help_dialog.separator.leftAttachment:         ATTACH_FORM",
  679. X"XBall*help_dialog.separator.topOffset:              5",
  680. X"XBall*help_dialog.separator.bottomAttachment:       ATTACH_WIDGET",
  681. X"XBall*help_dialog.separator.bottomWidget:           help_dialog_action_area",
  682. X"XBall*help_dialog*help_text.rows:                   12",
  683. X"XBall*help_dialog*help_text.columns:                60",
  684. X"! Athena Resources",
  685. X"XBall*help_dialog*help_textAW.displayCaret:         False",
  686. X"XBall*help_dialog*help_textAW.height:               150",
  687. X"XBall*help_dialog*help_textAW.width:                470",
  688. X"XBall*help_dialog*help_textAW.scrollHorizontal:     WhenNeeded",
  689. X"XBall*help_dialog*help_textAW.scrollVertical:       WhenNeeded",
  690. X"",
  691. X"XBall*help_dialog*close.accelerators: \
  692. X        <KeyPress>Escape: set() notify() unset() \n\
  693. X        <KeyPress>Return: set() notify() unset() \n\
  694. X",
  695. X"",
  696. X"",
  697. X"",
  698. X"!!!!!!!!!!!",
  699. X"! Help text",
  700. X"!!!!!!!!!!!",
  701. X"!",
  702. X"! Note that since fallback resources cannot handle \n in the text,",
  703. X"! a ~ is used to indicate a newline.",
  704. X"!",
  705. X"!!!!!!!!!!",
  706. X"",
  707. X"XBall.pointerHelp: \
  708. X                   MOUSE BUTTON USAGE ~~~\
  709. XButton 1: o Hold down to create a ball. ~\
  710. X          o Throw the ball by moving the mouse and ~\
  711. X            letting go of button 1. ~\
  712. X          o The ball will be going the speed of the ~\
  713. X            pointer at release time. ~\
  714. XButton 2: o Hold down and move the mouse to create ~\
  715. X            random velocity balls. ~\
  716. XButton 3: o Hold down and move the mouse to create ~\
  717. X            zero velocity balls. \
  718. X",
  719. X"",
  720. X"XBall.menuHelp: \
  721. X                   PULLDOWN MENU USAGE~~~\
  722. XFile~\
  723. X  About...        A description of the program and author~\
  724. X  Run Demo...     Allows you to execute XBall demo files~\
  725. X                  See 'Help On Demos' for demo file format~\
  726. X  Load Bitmap...  Load an X bitmap as a set of balls~\
  727. X                  Analogous Demo command: ~\
  728. X                    bitmap filename posx,posy~\
  729. X  Quit            Exits the program~~\
  730. XActions~\
  731. X  Clear           Clear the screen of balls~\
  732. X                  Analogous Demo command: clear~\
  733. X  Randomize       Give each ball a random velocity~\
  734. X                  Analogous Demo command: ~\
  735. X                    randomize minx,maxx,miny,maxy~\
  736. X  Stop Demo       Stops the execution of a demo in progress~\
  737. X                  Enabled by the Run Demo... menu option~\
  738. X                  Analogous Demo command: stop~\
  739. X  Step Simulation Perform one step of the Halted simulation~\
  740. X                  Enabled by the Halt Simulation menu option~~\
  741. XOptions~\
  742. X  Perpetual       If toggled on, balls will live forever~\
  743. X                  Analogous Demo command: perpetual on|off~\
  744. X                  Command line option: -perpetual True|False~\
  745. X  Ball Collide    If on, balls will collide with one another~\
  746. X                  Analogous Demo command: collide on|off~\
  747. X                  Command line option: -collide True|False~~\
  748. X  Help Simulation Stop the simulation.  You can then step the~\
  749. X                  simulation using Step Simulation menu option~~\
  750. XHelp~\
  751. X  On Menus      Help using the menu system~\
  752. X  On Scrollbars Help on the Elasticity and Gravity bars~\
  753. X  On Buttons    Help on using the mouse buttons to create balls~\
  754. X  On Demos      Help on the Demo language and how to run demos~\
  755. X  On Parameters Help with command-line arguments to xball \
  756. X",
  757. X"",
  758. X"",
  759. X"XBall.scrollbarHelp: \
  760. X                      SCROLLBAR USAGE~~~\
  761. XElasticity~\
  762. X  o This scrollbar controls the balls' elasticity, or how~\
  763. X    much energy is lost each time the balls hit the ground.~\
  764. X  o Scrollbar to left:  low elasticity (eggs)~\
  765. X  o Scrollbar to right: high elasticity (superballs)~\
  766. X  o Demo command: elasticity %d~\
  767. X  o Command line options: -elasticity %d~~~\
  768. XGravity~\
  769. X  o This scrollbar controls the gravity, or how~\
  770. X    much vertical velocity is added (subtracted)~\
  771. X    from the balls for each iteration.~\
  772. X  o Scrollbar to the left:  Zero gravity (outer space)~\
  773. X  o Scrollbar to the right: Large gravity (Jupiter)~\
  774. X  o Demo command: gravity %d~\
  775. X  o Command line options: -gravity %d \
  776. X",
  777. X"",
  778. X"",
  779. X"XBall.demoHelp: \
  780. X                     DEMO FILE COMMANDS~~\
  781. X  %s1, %s2... - Replace with a string~\
  782. X  %d1, %d2... - Replace with an integer~~\
  783. X  create %d1,%d2,%d3,%d4: Create a ball with x,y position~\
  784. X                          %d1,%d2 and an x & y velocity~\
  785. X                          of %d2,%d4~\
  786. X  randomize %d1,%d2,%d3,%d4: randomize velocities of all ~\
  787. X                balls on screen with:~\
  788. X                a max negative x velocity of %d1,~\
  789. X                a max positive x velocity of %d2,~\
  790. X                a max negative y velocity of %d3,~\
  791. X                a max positive y velocity of %d4,~\
  792. X  load_bitmap %s %d1,%d2: load a bitmap file (where %s is~\
  793. X                         the file path) to an x,y position~\
  794. X                         of %d1,%d2 on the screen~\
  795. X  set_velocity %s %d1,%d2: set ball velocities (%s is~\
  796. X                         relative or absolute) to the x ~\
  797. X                         and y velocities %d1,%d2~\
  798. X  gravity %d: set gravity to %d~\
  799. X  elasticity %d: set elasticity to %d~\
  800. X  backwards %d: Run simulation backwards %d iterations~\
  801. X  visible %s: Make ball display 'on' or 'off'~\
  802. X  iterate %d: simulate for %d iterations~\
  803. X  sleep %d: sleep for %d seconds~\
  804. X  perpetual %s: toggle perpetual (%s is 'on' or 'off')~\
  805. X  collide %s: toggle ball collision (%s is 'on' or 'off')~\
  806. X  window_width %d: Change window width to %d~\
  807. X  window_height %d: Change window height to %d~\
  808. X  backwards %d: Iterate backwards %d steps~\
  809. X  clear: delete all balls in window~\
  810. X  create_random %d1,%d2: create %d1 random balls with a ~\
  811. X                         max velocity of %d2~\
  812. X  exit or quit: quit the xball program if demo is not~\
  813. X                interactive~\
  814. X  stop: stop demo but leave program alive \
  815. X",
  816. X"",
  817. X"XBall.startupHelp: \
  818. X                PROGRAM STARTUP PARAMETERS~~~\
  819. X Run xball -help for a list of command-line startup~\
  820. X",
  821. X" parameters",
  822. X"",
  823. X"XBall.aboutString: \
  824. XXBall Version 3.0~~\
  825. X  April 1993~~\
  826. XThe Premire Ball Bouncing Software~~\
  827. X  Allows you to throw 3-D balls around in a 2-D space.~~\
  828. XAuthor (Send bugs, comments, and interesting demos to):~\
  829. X  David Nedde~\
  830. X  daven@ivy.wpi.edu~\
  831. X  Computer Science Department~\
  832. X  Worcester Polytechnic Institute~\
  833. X  Worcester, MA 01609~~\
  834. XCopyright 1990, 1993 David Nedde~\
  835. XPermission to use, copy, modify, and distribute this~\
  836. Xsoftware and its documentation for any purpose and~\
  837. Xwithout fee is granted provided that the above~\
  838. Xcopyright notice appears in all copies.  It is~\
  839. Xprovided \"as is\" without express or implied warranty. \
  840. X",
  841. X"",
  842. X"",
  843. X"!!!!!!!!!!!!!!!!!",
  844. X"! Menu Definition",
  845. X"!!!!!!!!!!!!!!!!!",
  846. X"!",
  847. X"! Format:",
  848. X"!   pulldownName~",
  849. X"!     widgetName,widgetClass,menuCallbackName,optionalParams...~",
  850. X"!",
  851. X"! The widgetName is referenced above to set the menu's label.",
  852. X"!",
  853. X"! Note that the pulldownName of 'help' is automatically used as the help ",
  854. X"! pulldown.",
  855. X"!",
  856. X"! Avaliable WidgetClasses are:",
  857. X"!   PushButton   - push it and cause the action",
  858. X"!   ToggleButton - Push it and toggle the state",
  859. X"!   Separator    - A line in the menu",
  860. X"!",
  861. X"! Avaliable menuCallbackNames avaliable (none take optional parameters):",
  862. X"!   runDemo       - Lets user select a demo and run the demo",
  863. X"!   loadBitmap    - Lets user load a bitmap file",
  864. X"!   quit          - quits xball program",
  865. X"!   clear         - Clear all balls from the screen",
  866. X"!   randomize     - Randomize all balls from the screen",
  867. X"!   stopDemo      - Stop a demo in progress",
  868. X"!   stepSim       - Steps the simulation once (if simulation halted)",
  869. X"!   perpetual     - Toggles perpetual balls state",
  870. X"!   ballCollide   - Toggles colliding ball state",
  871. X"!   haltSim       - Toggles halting the simulation",
  872. X"!   about         - Displays help about the program",
  873. X"!   onMenus       - Displays help on the menus",
  874. X"!   onScroll      - Displays help on setting elasticity and gravity",
  875. X"!   onButtons     - Displays help on using the mouse buttons to create balls",
  876. X"!   onDemos       - Displays help on writing a demo",
  877. X"!   onParams      - Displays help on command-line arguments",
  878. X"!",
  879. X"!!!!!!!!!!!!!!!!!",
  880. X"",
  881. X"XBall.menuDef: \
  882. X\
  883. X    file~\
  884. X    about,PushButton,about~\
  885. X    runDemo,PushButton,runDemo~\
  886. X    loadBitmap,PushButton,loadBitmap~\
  887. X    separator,Separator~\
  888. X    quit,PushButton,quit~\
  889. X    actions~\
  890. X    clear,PushButton,clear~\
  891. X    randomize,PushButton,randomize~\
  892. X    stopDemo,PushButton,stopDemo~\
  893. X    stepSim,PushButton,stepSim~\
  894. X    options~\
  895. X    perpetual,ToggleButton,perpetual~\
  896. X    ballCollide,ToggleButton,ballCollide~\
  897. X    haltSim,ToggleButton,haltSim~\
  898. X    help~\
  899. X    about,PushButton,about~\
  900. X    onMenus,PushButton,onMenus~\
  901. X    onScroll,PushButton,onScroll~\
  902. X    onButtons,PushButton,onButtons~\
  903. X    onDemos,PushButton,onDemos~\
  904. X    onParams,PushButton,onParams~\
  905. X",
  906. X"",
  907. XNULL
  908. END_OF_FILE
  909. if test 17606 -ne `wc -c <'fallback.h'`; then
  910.     echo shar: \"'fallback.h'\" unpacked with wrong size!
  911. fi
  912. # end of 'fallback.h'
  913. fi
  914. if test -f 'file_sel.h' -a "${1}" != "-c" ; then 
  915.   echo shar: Will not clobber existing file \"'file_sel.h'\"
  916. else
  917. echo shar: Extracting \"'file_sel.h'\" \(1504 characters\)
  918. sed "s/^X//" >'file_sel.h' <<'END_OF_FILE'
  919. X/**********************************************************************
  920. X * file_sel.h - Public interface to the file_sel object.
  921. X * 
  922. X * Copyright 1992, David Nedde
  923. X *
  924. X * Permission to use, copy, modify, and distribute this software
  925. X * and its documentation for any purpose and without fee is granted
  926. X * provided that the above copyright notice appears in all copies.
  927. X * It is provided "as is" without express or implied warranty.
  928. X **********************************************************************/
  929. X
  930. X/**********************************************************************
  931. X * File Sel Object
  932. X *
  933. X * The file object is allows you to request a file from the user.
  934. X *
  935. X * Public methods:
  936. X *
  937. X *   void file_sel__init(file_sel_type *file_sel, help_type *help)
  938. X *     Initialise the file_sel object.
  939. X *
  940. X *   void file_sel__free( file_sel_type *file_sel)
  941. X *     Free data associated with file_sel object
  942. X *
  943. X *   char *file_sel__display(file_sel_type *file_sel, char *title)
  944. X *     Display the file selection box and return selected file
  945. X *
  946. X **********************************************************************/
  947. X
  948. X#ifndef __FILE_SEL_H__
  949. X#define __FILE_SEL_H__
  950. X
  951. X#include <X11/Intrinsic.h>
  952. X
  953. Xtypedef struct {
  954. X    Widget dialog_w;
  955. X    Bool   searching;
  956. X    char * filename;
  957. X
  958. X    Widget toplevel;
  959. X} file_sel_struct_type, *file_sel_type;
  960. X
  961. X
  962. Xfile_sel_type file_sel__create(/*toplevel*/);
  963. Xvoid          file_sel__destroy(/*file_sel*/);
  964. Xchar         *file_sel__display(/*file_sel, title*/);
  965. X
  966. X#endif /* __FILE_SEL_H__ */
  967. END_OF_FILE
  968. if test 1504 -ne `wc -c <'file_sel.h'`; then
  969.     echo shar: \"'file_sel.h'\" unpacked with wrong size!
  970. fi
  971. # end of 'file_sel.h'
  972. fi
  973. if test -f 'item.h' -a "${1}" != "-c" ; then 
  974.   echo shar: Will not clobber existing file \"'item.h'\"
  975. else
  976. echo shar: Extracting \"'item.h'\" \(3604 characters\)
  977. sed "s/^X//" >'item.h' <<'END_OF_FILE'
  978. X/**********************************************************************
  979. X * item.h - item (ball) declaration
  980. X *
  981. X * Copyright 1993, David Nedde
  982. X *
  983. X * Permission to use, copy, modify, and distribute this software
  984. X * and its documentation for any purpose and without fee is granted
  985. X * provided that the above copyright notice appears in all copies.
  986. X * It is provided "as is" without express or implied warranty.
  987. X **********************************************************************/
  988. X
  989. X#ifndef __ITEM_H__
  990. X#define __ITEM_H__
  991. X
  992. X#include <X11/Xlib.h>
  993. X#include <X11/Intrinsic.h>
  994. X
  995. X#include "misc.h"
  996. X#include "intf.h"
  997. X
  998. X#define MAX_COLORS 256
  999. X
  1000. X#ifndef ELASTICITY
  1001. X#define ELASTICITY  90  /* Default */
  1002. X#endif
  1003. X
  1004. X
  1005. X/* Static data shared for all items */
  1006. Xtypedef struct {
  1007. X    int    width;
  1008. X    int    height;
  1009. X    int    half_width;  /* Precalculated for copying pixmap offset */
  1010. X    int    half_height;
  1011. X    double elasticity;
  1012. X    Bool   ball_collide;
  1013. X    Bool   perpetual;
  1014. X    Bool   visible;
  1015. X    char * rgb_txt;
  1016. X
  1017. X    Display * display;
  1018. X    Window    window;
  1019. X    Pixel     background;
  1020. X    GC        gc;
  1021. X    Pixmap    pixmaps[ MAX_COLORS];/* Holds all item drawings */
  1022. X    int       num_colors;          /* Holds number of colors/pixmaps used */
  1023. X    int       curr_pixmap;         /* Holds pixmap index to use for next item*/
  1024. X} item_static_struct_type, *item_static_type;
  1025. X
  1026. X
  1027. Xtypedef struct {
  1028. X    item_static_type static_data;
  1029. X
  1030. X    Display *display;
  1031. X    Window   window;
  1032. X    intf     x,y;              /* Location of items center */
  1033. X    intf     y_vel;            /* vel < 0 means dropping, > 0 means climbing */
  1034. X    intf     x_vel;            /* vel < 0 means to left, > 0 means to right */
  1035. X    int      rebounded;        /* Used to determine if item collision */
  1036. X                               /* had already been calculated for this item */
  1037. X    Bool     shown;            /* True if items image is visible */
  1038. X    Pixmap   pixmap;           /* Pixel map to use for drawing item */
  1039. X} item_struct_type, *item_type;
  1040. X
  1041. X
  1042. Xitem_type item__create(/* display, window, x, y, x_vel, y_vel*/);
  1043. Xvoid      item__init(/*display, window, background*/);
  1044. XBool      item__initted(/**/);
  1045. Xvoid      item__destroy(/* item*/);
  1046. Xvoid      item__draw(/* item*/);
  1047. Xvoid      item__undraw(/* item, x, y*/);
  1048. Xvoid      item__redraw(/* item*/);
  1049. Xvoid      item__erase(/* item*/);
  1050. Xvoid      item__redraw(/* item*/);
  1051. Xvoid      item__move_pos(/* item, x, y*/);
  1052. Xvoid      item__randomize(/* item, min_x_vel, max_x_vel, 
  1053. X                 min_y_vel, max_y_vel*/);
  1054. Xvoid      item__move(/* item, room, items*/);
  1055. Xvoid      item__rebound_item(/* moved_item, fixed_item*/);
  1056. Xvoid      item__set_elasticity_cb(/*w, datap_ptr, call_data*/);
  1057. Xint       item__get_width(/**/);
  1058. Xint       item__get_height(/**/);
  1059. Xvoid      item__perpetual_mcb(/*w, item, call_data, extra*/);
  1060. Xvoid      item__collide_mcb(/*w, item, call_data, extra*/);
  1061. Xvoid      item__set_perpetual(/* set */);
  1062. Xvoid      item__set_ball_collide(/* set*/);
  1063. Xvoid      item__set_visible(/*visible*/);;
  1064. X
  1065. X
  1066. X/* Inline functions */
  1067. X#define item__set_x_vel( item, vel) ((item)->x_vel = int2intf(vel))
  1068. X#define item__set_y_vel( item, vel) ((item)->y_vel = int2intf(vel))
  1069. X#define item__get_x_vel( item) (intf2int((item)->x_vel))
  1070. X#define item__get_y_vel( item) (intf2int((item)->y_vel))
  1071. X#define item__get_x( item) (intf2int((item)->x))
  1072. X#define item__get_y( item) (intf2int((item)->y))
  1073. X#define item__erase( item) (item__undraw( (item), (item)->x, (item)->y))
  1074. X#define item__stopped(item, room) \
  1075. X     (item->y_vel == 0)  && \
  1076. X     (ABS(item->y) >= room__get_floor(room) - room__get_gravity(room)) && \
  1077. X     (item->x_vel == 0)
  1078. X
  1079. X
  1080. X#endif
  1081. END_OF_FILE
  1082. if test 3604 -ne `wc -c <'item.h'`; then
  1083.     echo shar: \"'item.h'\" unpacked with wrong size!
  1084. fi
  1085. # end of 'item.h'
  1086. fi
  1087. if test -f 'items.h' -a "${1}" != "-c" ; then 
  1088.   echo shar: Will not clobber existing file \"'items.h'\"
  1089. else
  1090. echo shar: Extracting \"'items.h'\" \(1283 characters\)
  1091. sed "s/^X//" >'items.h' <<'END_OF_FILE'
  1092. X/**********************************************************************
  1093. X * file - description
  1094. X *
  1095. X * Copyright 1993, David Nedde
  1096. X *
  1097. X * Permission to use, copy, modify, and distribute this software
  1098. X * and its documentation for any purpose and without fee is granted
  1099. X * provided that the above copyright notice appears in all copies.
  1100. X * It is provided "as is" without express or implied warranty.
  1101. X **********************************************************************/
  1102. X
  1103. X#ifndef __ITEMS_H__
  1104. X#define __ITEMS_H__
  1105. X
  1106. X#include "list.h"
  1107. X#include "item.h"
  1108. X
  1109. Xtypedef struct {
  1110. X    list_type list;
  1111. X    int current;  /* Used to increase efficiency */
  1112. X} items_struct_type, *items_type;
  1113. X
  1114. Xitems_type items__create(/**/);
  1115. Xitems_type items__destroy(/*items*/);
  1116. Xitem_type  items__get_first(/* items */);
  1117. Xitem_type  items__get_next(/* items */);
  1118. Xvoid       items__add(/* items, item */);
  1119. Xvoid       items__destroy_all(/* items*/);
  1120. Xvoid       items__new_item(/* items, x, y, x_vel, y_vel */);
  1121. Xvoid       items__move_items(/* items, room*/);
  1122. Xvoid       items__move_items_backwards(/* items, room, count*/);
  1123. Xvoid       items__rebound_items(/* items, item*/);
  1124. Xvoid       items__set_visible( /*items, visible*/);
  1125. X
  1126. X/* Inline functions */
  1127. X#define items__get_count( items) (list__get_count((items)->list))
  1128. X
  1129. X#endif
  1130. END_OF_FILE
  1131. if test 1283 -ne `wc -c <'items.h'`; then
  1132.     echo shar: \"'items.h'\" unpacked with wrong size!
  1133. fi
  1134. # end of 'items.h'
  1135. fi
  1136. if test -f 'list.h' -a "${1}" != "-c" ; then 
  1137.   echo shar: Will not clobber existing file \"'list.h'\"
  1138. else
  1139. echo shar: Extracting \"'list.h'\" \(1446 characters\)
  1140. sed "s/^X//" >'list.h' <<'END_OF_FILE'
  1141. X/**********************************************************************
  1142. X * list.h - declares the list object
  1143. X *
  1144. X * Copyright 1993, David Nedde
  1145. X *
  1146. X * Permission to use, copy, modify, and distribute this software
  1147. X * and its documentation for any purpose and without fee is granted
  1148. X * provided that the above copyright notice appears in all copies.
  1149. X * It is provided "as is" without express or implied warranty.
  1150. X **********************************************************************/
  1151. X
  1152. X#ifndef __LIST_H__
  1153. X#define __LIST_H__
  1154. X
  1155. Xtypedef struct {
  1156. X    void      **data;
  1157. X    int         count;
  1158. X    int         max_count;
  1159. X    int         curr_item;
  1160. X} list_struct, *list_type;
  1161. X
  1162. X#define LIST_INITIAL_SIZE 100
  1163. X
  1164. Xlist_type       list__create();
  1165. Xvoid            list__destroy(/* list */);
  1166. Xvoid *          list__add_start(/* list, data_item */);
  1167. Xvoid *          list__add_end(/* list, data_item */);
  1168. Xvoid *          list__get_first(/* list */);
  1169. Xvoid *          list__get_next(/* list */);
  1170. Xvoid *          list__get_last(/* list */);
  1171. Xvoid *          list__get_prev(/* list */);
  1172. Xvoid *          list__remove_last(/* list */);
  1173. Xvoid *          list__remove_first(/* list */);
  1174. Xvoid            list__remove_all(/* list */);
  1175. Xvoid *          list__remove(/* list, index */);
  1176. X
  1177. X/* Inline functions */
  1178. X#define list__get_cell(list, index) ((list)->data[ index])
  1179. X#define list__set_cell(list, index) ((list)->data[ index])
  1180. X#define list__get_count(list) ((list)->count)
  1181. X
  1182. X
  1183. X#endif
  1184. END_OF_FILE
  1185. if test 1446 -ne `wc -c <'list.h'`; then
  1186.     echo shar: \"'list.h'\" unpacked with wrong size!
  1187. fi
  1188. # end of 'list.h'
  1189. fi
  1190. if test -f 'menu.h' -a "${1}" != "-c" ; then 
  1191.   echo shar: Will not clobber existing file \"'menu.h'\"
  1192. else
  1193. echo shar: Extracting \"'menu.h'\" \(1410 characters\)
  1194. sed "s/^X//" >'menu.h' <<'END_OF_FILE'
  1195. X/**********************************************************************
  1196. X * menu,h - Menu system declarations
  1197. X *
  1198. X * Copyright 1993, David Nedde
  1199. X *
  1200. X * Permission to use, copy, modify, and distribute this software
  1201. X * and its documentation for any purpose and without fee is granted
  1202. X * provided that the above copyright notice appears in all copies.
  1203. X * It is provided "as is" without express or implied warranty.
  1204. X **********************************************************************/
  1205. X
  1206. X#ifndef __MENU_H__
  1207. X#define __MENU_H__
  1208. X
  1209. X#include <X11/Intrinsic.h>
  1210. X
  1211. X#include "table.h"
  1212. X
  1213. Xtypedef struct {
  1214. X    table_type mc_table;      /* Table of callbacks avalibale for use */
  1215. X    table_type closure_table; /* Table of callbacks added */
  1216. X    Widget     menubar;
  1217. X#ifdef ATHENA
  1218. X    Pixmap     on_bitmap;
  1219. X    Pixmap     off_bitmap;
  1220. X#endif
  1221. X} menu_struct_type, *menu_type;
  1222. X
  1223. X
  1224. Xtypedef struct {
  1225. X    int      set;
  1226. X} menuCallbackStruct;
  1227. X
  1228. X
  1229. Xtypedef void (*menuCallbackProc)(/* Widget, caddr_t, 
  1230. X                                    menuCallbackStruct *, char * */);
  1231. X
  1232. X
  1233. Xmenu_type menu__create(/* form */);
  1234. Xvoid      menu__destroy(/*menu*/);
  1235. Xvoid      menu__add_callback(/* menu, action_name, 
  1236. X                             menu_callback_proc, user_data */);
  1237. Xvoid      menu__set_toggle(/* menu, widget_name, set*/);
  1238. XBool      menu__get_toggle(/* menu, widget_name*/);
  1239. Xvoid      menu__set_sensitivity(/* menu, widget_name, sensitive*/);
  1240. X
  1241. X#endif
  1242. END_OF_FILE
  1243. if test 1410 -ne `wc -c <'menu.h'`; then
  1244.     echo shar: \"'menu.h'\" unpacked with wrong size!
  1245. fi
  1246. # end of 'menu.h'
  1247. fi
  1248. if test -f 'misc.h' -a "${1}" != "-c" ; then 
  1249.   echo shar: Will not clobber existing file \"'misc.h'\"
  1250. else
  1251. echo shar: Extracting \"'misc.h'\" \(986 characters\)
  1252. sed "s/^X//" >'misc.h' <<'END_OF_FILE'
  1253. X/**********************************************************************
  1254. X * misc.h - misc function declarations
  1255. X *
  1256. X * Copyright 1993, David Nedde
  1257. X *
  1258. X * Permission to use, copy, modify, and distribute this software
  1259. X * and its documentation for any purpose and without fee is granted
  1260. X * provided that the above copyright notice appears in all copies.
  1261. X * It is provided "as is" without express or implied warranty.
  1262. X **********************************************************************/
  1263. X#ifndef __MISC_H__
  1264. X#define __MISC_H__
  1265. X
  1266. X#include <malloc.h>
  1267. X
  1268. Xchar * get_string(/* char *str */);
  1269. Xchar * my_strdup(/* char *str */);
  1270. Xint    rand_range(/* min, max*/);
  1271. Xvoid   convert_newlines(/* str*/);
  1272. X
  1273. X#define ABS(x) ((x) < 0 ? -(x) : (x))
  1274. X#define SWAP(x,y,type) { type t; t = (x); (x) = (y); (y) = t; }
  1275. X
  1276. X#undef MIN
  1277. X#undef MAX
  1278. X#define MIN(x,y) ((x) > (y) ? (y) : (x))
  1279. X#define MAX(x,y) ((x) < (y) ? (y) : (x))
  1280. X
  1281. X#ifndef EXIT_FAILURE
  1282. X#define EXIT_FAILURE (int)1
  1283. X#define EXIT_SUCCESS (int)0
  1284. X#endif
  1285. X
  1286. X
  1287. X#endif
  1288. END_OF_FILE
  1289. if test 986 -ne `wc -c <'misc.h'`; then
  1290.     echo shar: \"'misc.h'\" unpacked with wrong size!
  1291. fi
  1292. # end of 'misc.h'
  1293. fi
  1294. if test -f 'names.h' -a "${1}" != "-c" ; then 
  1295.   echo shar: Will not clobber existing file \"'names.h'\"
  1296. else
  1297. echo shar: Extracting \"'names.h'\" \(703 characters\)
  1298. sed "s/^X//" >'names.h' <<'END_OF_FILE'
  1299. X#ifndef __NAMES_H__
  1300. X#define __NAMES_H__
  1301. X
  1302. X#define GRAVITY_BAR     "gravityBar"
  1303. X#define ELASTICITY_BAR  "elasticityBar"
  1304. X#define FILE_SB         "fileSB"
  1305. X#define HELP_DIALOG     "help_dialog"
  1306. X
  1307. X#define RUN_DEMO     "runDemo"
  1308. X#define STOP_DEMO    "stopDemo"
  1309. X#define CLEAR        "clear"
  1310. X#define RANDOMIZE    "randomize"
  1311. X#define LOAD_BITMAP  "loadBitmap"
  1312. X#define QUIT         "quit"
  1313. X#define PERPETUAL    "perpetual"
  1314. X#define BALL_COLLIDE "ballCollide"
  1315. X#define STEP_SIM     "stepSim"
  1316. X#define HALT_SIM     "haltSim"
  1317. X#define ABOUT        "about"
  1318. X#define ON_MENUS     "onMenus"
  1319. X#define ON_SCROLL    "onScroll"
  1320. X#define ON_BUTTONS   "onButtons"
  1321. X#define ON_DEMOS     "onDemos"
  1322. X#define ON_PARAMS    "onParams"
  1323. X
  1324. X#endif
  1325. END_OF_FILE
  1326. if test 703 -ne `wc -c <'names.h'`; then
  1327.     echo shar: \"'names.h'\" unpacked with wrong size!
  1328. fi
  1329. # end of 'names.h'
  1330. fi
  1331. if test -f 'room.h' -a "${1}" != "-c" ; then 
  1332.   echo shar: Will not clobber existing file \"'room.h'\"
  1333. else
  1334. echo shar: Extracting \"'room.h'\" \(2448 characters\)
  1335. sed "s/^X//" >'room.h' <<'END_OF_FILE'
  1336. X/**********************************************************************
  1337. X * room.h - room object declaration
  1338. X *
  1339. X * Copyright 1993, David Nedde
  1340. X *
  1341. X * Permission to use, copy, modify, and distribute this software
  1342. X * and its documentation for any purpose and without fee is granted
  1343. X * provided that the above copyright notice appears in all copies.
  1344. X * It is provided "as is" without express or implied warranty.
  1345. X **********************************************************************/
  1346. X
  1347. X#ifndef __ROOM_H__
  1348. X#define __ROOM_H__
  1349. X
  1350. X#include <X11/Intrinsic.h>
  1351. X
  1352. X#include "item.h"
  1353. X#include "items.h"
  1354. X#include "file_sel.h"
  1355. X#include "intf.h"
  1356. X
  1357. Xtypedef struct {
  1358. X    Widget      canvas;
  1359. X    Pixel       background;
  1360. X
  1361. X    int         gravity;
  1362. X
  1363. X    items_type  items;       /* List of items in the rooom */
  1364. X    item_type   item;        /* Item currently being created by user */
  1365. X    file_sel_type file_sel;  /* Used to query for a bitmap file */
  1366. X
  1367. X    /* Input state */
  1368. X    int         oldx,oldy;
  1369. X    int         newx,newy;
  1370. X    Bool        button1,button2,button3;
  1371. X
  1372. X    /* Locations of room structures */
  1373. X    intf        right_wall; 
  1374. X    intf        left_wall;
  1375. X    intf        ceiling;
  1376. X    intf        floor;
  1377. X
  1378. X    /* Used to wait for window resize when caused by the program */
  1379. X    Boolean resized;
  1380. X} room_struct_type, *room_type;
  1381. X
  1382. X
  1383. X#ifndef GRAVITY
  1384. X#define GRAVITY      8          /* Default gravity */
  1385. X#endif
  1386. X
  1387. Xroom_type room__create(/* form_w */);
  1388. Xvoid      room__destroy(/* room */);
  1389. Xvoid      room__set_gravity_cb(/*w, room, call_data */);
  1390. Xvoid      room__clear_mcb(/*w, room, call_data, extra */);
  1391. Xvoid      room__randomize_mcb(/*w, room, call_data, extra */);
  1392. Xvoid      room__load_bitmap_mcb(/*w, room, call_data, extra */);
  1393. Xvoid      room__load_bitmap(/*room, filename, pos_x, pos_y*/);
  1394. Xvoid      room__set_height(/*room, height*/);
  1395. Xvoid      room__set_width(/*room, width*/);
  1396. X
  1397. X/* Inline functions */
  1398. X/* Note that values passed and returned are of type intf */
  1399. X#define room__get_item( room)       ((room)->item)
  1400. X#define room__get_ceiling( room)    ((room)->ceiling)
  1401. X#define room__get_left_wall( room)  ((room)->left_wall)
  1402. X#define room__get_right_wall( room) ((room)->right_wall)
  1403. X#define room__get_floor( room)      ((room)->floor)
  1404. X#define room__flush( room)          (XFlush( XtDisplay(room->canvas)))
  1405. X
  1406. X
  1407. X/* gravity is of type int */
  1408. X#define room__get_gravity( room)       ((room)->gravity)
  1409. X#define room__set_gravity( room, grav) ((room)->gravity = (grav))
  1410. X
  1411. X
  1412. X#endif
  1413. END_OF_FILE
  1414. if test 2448 -ne `wc -c <'room.h'`; then
  1415.     echo shar: \"'room.h'\" unpacked with wrong size!
  1416. fi
  1417. # end of 'room.h'
  1418. fi
  1419. if test -f 'scrollbar.h' -a "${1}" != "-c" ; then 
  1420.   echo shar: Will not clobber existing file \"'scrollbar.h'\"
  1421. else
  1422. echo shar: Extracting \"'scrollbar.h'\" \(1715 characters\)
  1423. sed "s/^X//" >'scrollbar.h' <<'END_OF_FILE'
  1424. X/**********************************************************************
  1425. X * scrollbar.h - declares scrollbar object
  1426. X *
  1427. X * Copyright 1993, David Nedde
  1428. X *
  1429. X * Permission to use, copy, modify, and distribute this software
  1430. X * and its documentation for any purpose and without fee is granted
  1431. X * provided that the above copyright notice appears in all copies.
  1432. X * It is provided "as is" without express or implied warranty.
  1433. X **********************************************************************/
  1434. X
  1435. X#ifndef __SCROLLBAR_H__
  1436. X#define __SCROLLBAR_H__
  1437. X
  1438. X#include <X11/Intrinsic.h>
  1439. X
  1440. X#include "list.h"
  1441. X
  1442. Xtypedef struct {
  1443. X    Widget    form;
  1444. X    Widget    label;
  1445. X    Widget    scale;
  1446. X#ifdef ATHENA
  1447. X    Widget    feedback;   /* Used to display value like Motif scale widget */
  1448. X#endif
  1449. X
  1450. X    int       value;      /* Current value of the scrollbar */
  1451. X    list_type callbacks;  /* List of callbacks on this scrollbar */
  1452. X} scrollbar_struct, *scrollbar_type;
  1453. X
  1454. X
  1455. X/* We need to make the callbacks ourself, because the callback data is
  1456. X   so different between Motif and Athena */
  1457. Xtypedef struct {
  1458. X    int      reason;
  1459. X    XEvent * event;
  1460. X    int      value;
  1461. X    int      pixel;
  1462. X} scrollbarCallbackStruct;
  1463. X
  1464. X
  1465. Xtypedef void (*scrollbarCallbackProc)(/* Widget, caddr_t closure,
  1466. X                                         scrollbarCallbackStruct call_data */);
  1467. X
  1468. X
  1469. X/* Inline functions */
  1470. X#define         scrollbar__get_value( scrollbar) ((scrollbar)->value)
  1471. X
  1472. X/* Regular functions */
  1473. Xscrollbar_type  scrollbar__create(/* Widget w */);
  1474. Xvoid            scrollbar__destroy(/* scrollbar_type scrollbar */);
  1475. Xvoid            scrollbar__set_value(/* scrollbar_type *, int value */);
  1476. Xvoid            scrollbar__add_callback(/* scrollbar, proc, closure*/);
  1477. X
  1478. X
  1479. X#endif
  1480. END_OF_FILE
  1481. if test 1715 -ne `wc -c <'scrollbar.h'`; then
  1482.     echo shar: \"'scrollbar.h'\" unpacked with wrong size!
  1483. fi
  1484. # end of 'scrollbar.h'
  1485. fi
  1486. if test -f 'sim.h' -a "${1}" != "-c" ; then 
  1487.   echo shar: Will not clobber existing file \"'sim.h'\"
  1488. else
  1489. echo shar: Extracting \"'sim.h'\" \(1169 characters\)
  1490. sed "s/^X//" >'sim.h' <<'END_OF_FILE'
  1491. X/**********************************************************************
  1492. X * sim.h - simulation object declarations
  1493. X *
  1494. X * Copyright 1993, David Nedde
  1495. X *
  1496. X * Permission to use, copy, modify, and distribute this software
  1497. X * and its documentation for any purpose and without fee is granted
  1498. X * provided that the above copyright notice appears in all copies.
  1499. X * It is provided "as is" without express or implied warranty.
  1500. X **********************************************************************/
  1501. X
  1502. X#ifndef __SIM_H__
  1503. X#define __SIM_H__
  1504. X
  1505. X#include <X11/Intrinsic.h>
  1506. X
  1507. X#include "items.h"
  1508. X#include "room.h"
  1509. X#include "demo.h"
  1510. X#include "menu.h"
  1511. X
  1512. Xtypedef struct {
  1513. X    menu_type    menu;
  1514. X    items_type   items;
  1515. X    room_type    room;
  1516. X    demo_type    demo;
  1517. X
  1518. X    XtWorkProcId wpid;             /* Work process id */
  1519. X    int          delay;            /* Amount of delay we should do */
  1520. X    Bool         step_simulation;  /* True if we are steeping the simulation */
  1521. X} sim_struct_type, *sim_type;
  1522. X
  1523. X
  1524. Xsim_type sim__create(/*w, items, room*/);
  1525. Xvoid     sim__destroy(/*sim*/);
  1526. Xvoid     sim__step_mcb(/*w, sim, call_data, extra*/);
  1527. Xvoid     sim__halt_mcb(/*w, sim, call_data, extra*/);
  1528. X
  1529. X
  1530. X#endif
  1531. X
  1532. END_OF_FILE
  1533. if test 1169 -ne `wc -c <'sim.h'`; then
  1534.     echo shar: \"'sim.h'\" unpacked with wrong size!
  1535. fi
  1536. # end of 'sim.h'
  1537. fi
  1538. if test -f 'table.h' -a "${1}" != "-c" ; then 
  1539.   echo shar: Will not clobber existing file \"'table.h'\"
  1540. else
  1541. echo shar: Extracting \"'table.h'\" \(772 characters\)
  1542. sed "s/^X//" >'table.h' <<'END_OF_FILE'
  1543. X/**********************************************************************
  1544. X * file - description
  1545. X *
  1546. X * Copyright 1993, David Nedde
  1547. X *
  1548. X * Permission to use, copy, modify, and distribute this software
  1549. X * and its documentation for any purpose and without fee is granted
  1550. X * provided that the above copyright notice appears in all copies.
  1551. X * It is provided "as is" without express or implied warranty.
  1552. X **********************************************************************/
  1553. X
  1554. X#ifndef __TABLE_H__
  1555. X#define __TABLE_H__
  1556. X
  1557. X#include "list.h"
  1558. X
  1559. Xtypedef struct {
  1560. X   list_type list;
  1561. X} table_struct_type, *table_type;
  1562. X
  1563. X
  1564. Xtable_type table__create();
  1565. Xvoid       table__destroy(/* table */);
  1566. Xvoid       table__store(/* table, key, data */);
  1567. Xvoid *     table__retrieve(/* table, key */);
  1568. X
  1569. X
  1570. X#endif
  1571. END_OF_FILE
  1572. if test 772 -ne `wc -c <'table.h'`; then
  1573.     echo shar: \"'table.h'\" unpacked with wrong size!
  1574. fi
  1575. # end of 'table.h'
  1576. fi
  1577. if test -f 'xball_sys.h' -a "${1}" != "-c" ; then 
  1578.   echo shar: Will not clobber existing file \"'xball_sys.h'\"
  1579. else
  1580. echo shar: Extracting \"'xball_sys.h'\" \(1337 characters\)
  1581. sed "s/^X//" >'xball_sys.h' <<'END_OF_FILE'
  1582. X/**********************************************************************
  1583. X * xball_sys.h - xball system object declarations
  1584. X *
  1585. X * Copyright 1993, David Nedde
  1586. X *
  1587. X * Permission to use, copy, modify, and distribute this software
  1588. X * and its documentation for any purpose and without fee is granted
  1589. X * provided that the above copyright notice appears in all copies.
  1590. X * It is provided "as is" without express or implied warranty.
  1591. X **********************************************************************/
  1592. X
  1593. X#ifndef __XBALL_SYS_H__
  1594. X#define __XBALL_SYS_H__
  1595. X
  1596. X#include <X11/Intrinsic.h>
  1597. X
  1598. X#include "menu.h"
  1599. X#include "demo.h"
  1600. X#include "room.h"
  1601. X#include "items.h"
  1602. X#include "sim.h"
  1603. X#include "scrollbar.h"
  1604. X#include "file_sel.h"
  1605. X#include "help.h"
  1606. X
  1607. Xtypedef struct {
  1608. X    Widget              form_w;
  1609. X    Widget              pane_w;
  1610. X    menu_type           menu;
  1611. X    demo_type           demo;
  1612. X    items_type          items;
  1613. X    room_type           room;
  1614. X    sim_type            sim;
  1615. X    help_type           help;
  1616. X    scrollbar_type      gravity_bar;
  1617. X    scrollbar_type      elasticity_bar;
  1618. X    file_sel_type       file_sel;
  1619. X} xball_system_struct, *xball_system_type;
  1620. X
  1621. Xxball_system_type xball_system__create(/* w*/);
  1622. Xvoid              xball_system__destroy(/*xball_system*/);
  1623. Xvoid              xball_system__quit_mcb(/* w, datap_ptr, call_data, extra*/);
  1624. X
  1625. X#endif
  1626. END_OF_FILE
  1627. if test 1337 -ne `wc -c <'xball_sys.h'`; then
  1628.     echo shar: \"'xball_sys.h'\" unpacked with wrong size!
  1629. fi
  1630. # end of 'xball_sys.h'
  1631. fi
  1632. if test -f 'act_area.c' -a "${1}" != "-c" ; then 
  1633.   echo shar: Will not clobber existing file \"'act_area.c'\"
  1634. else
  1635. echo shar: Extracting \"'act_area.c'\" \(2635 characters\)
  1636. sed "s/^X//" >'act_area.c' <<'END_OF_FILE'
  1637. X/**********************************************************************
  1638. X * act_area.c - Creates an action area
  1639. X *
  1640. X * An action area is a form widget holding an array of button widgets.
  1641. X * The name of the action area for is <name of the parent widget>_action_area.
  1642. X *
  1643. X **********************************************************************/
  1644. X
  1645. X/* Written by Dan Heller.  Copyright 1991, O'Reilly && Associates.
  1646. X * This program is freely distributable without licensing fees and
  1647. X * is provided without guarantee or warrantee expressed or implied.
  1648. X * This program is -not- in the public domain.
  1649. X */
  1650. X
  1651. X#include <X11/Intrinsic.h>
  1652. X#include <Xm/Form.h>
  1653. X#include <Xm/PushB.h>
  1654. X#include <stdio.h>
  1655. X
  1656. X#include "act_area.h"
  1657. X
  1658. X#define TIGHTNESS 20
  1659. X
  1660. XWidget
  1661. XCreateActionArea(parent, actions, num_actions)
  1662. XWidget          parent;
  1663. XActionAreaItem *actions;
  1664. XCardinal        num_actions;
  1665. X{
  1666. X    Widget action_area, widget;
  1667. X    char name[50];
  1668. X    int i;
  1669. X
  1670. X
  1671. X    sprintf(name,"%s_action_area", XtName(parent));
  1672. X    action_area = 
  1673. X        XtVaCreateWidget(name, xmFormWidgetClass, parent,
  1674. X                         XmNfractionBase, TIGHTNESS*num_actions - 1,
  1675. X                         XmNmarginHeight, 10,
  1676. X                         XmNmarginWidth,  10,
  1677. X                         NULL);
  1678. X
  1679. X    for (i = 0; i < num_actions; i++) {
  1680. X        widget = XtVaCreateManagedWidget(actions[i].label,
  1681. X            xmPushButtonWidgetClass, action_area,
  1682. X            XmNleftAttachment,       i? XmATTACH_POSITION : XmATTACH_FORM,
  1683. X            XmNleftPosition,         TIGHTNESS*i,
  1684. X            XmNtopAttachment,        XmATTACH_FORM,
  1685. X            XmNbottomAttachment,     XmATTACH_FORM,
  1686. X            XmNrightAttachment,
  1687. X                    i != num_actions-1? XmATTACH_POSITION : XmATTACH_FORM,
  1688. X            XmNrightPosition,        TIGHTNESS*i + (TIGHTNESS-1),
  1689. X            XmNshowAsDefault,        i == 0,
  1690. X            XmNdefaultButtonShadowThickness, 1,
  1691. X            NULL);
  1692. X        if (actions[i].callback)
  1693. X            XtAddCallback(widget, XmNactivateCallback,
  1694. X                actions[i].callback, (XtPointer)actions[i].data);
  1695. X        if (i == 0 ) {
  1696. X            /* Set the action_area's default button to the first widget
  1697. X             * created (or, make the index a parameter to the function
  1698. X             * or have it be part of the data structure). Also, set the
  1699. X             * pane window constraint for max and min heights so this
  1700. X             * particular pane in the PanedWindow is not resizable.
  1701. X             */
  1702. X            XtVaSetValues(parent,
  1703. X                XmNdefaultButton, widget,
  1704. X                NULL);
  1705. X        }
  1706. X    }
  1707. X
  1708. X    XtManageChild(action_area);
  1709. X
  1710. X    return action_area;
  1711. X}
  1712. END_OF_FILE
  1713. if test 2635 -ne `wc -c <'act_area.c'`; then
  1714.     echo shar: \"'act_area.c'\" unpacked with wrong size!
  1715. fi
  1716. # end of 'act_area.c'
  1717. fi
  1718. if test -f 'act_area.h' -a "${1}" != "-c" ; then 
  1719.   echo shar: Will not clobber existing file \"'act_area.h'\"
  1720. else
  1721. echo shar: Extracting \"'act_area.h'\" \(313 characters\)
  1722. sed "s/^X//" >'act_area.h' <<'END_OF_FILE'
  1723. X#ifndef __ACT_AREA_H__
  1724. X#define __ACT_AREA_H__
  1725. X
  1726. Xtypedef struct {
  1727. X    char *label;                /* Button widget's name */
  1728. X    void (*callback)();         /* Button widget's callback */
  1729. X    caddr_t data;               /* Callback data */
  1730. X} ActionAreaItem;
  1731. X
  1732. XWidget CreateActionArea();
  1733. X
  1734. X#endif /* __ACT_AREA_H__ */
  1735. END_OF_FILE
  1736. if test 313 -ne `wc -c <'act_area.h'`; then
  1737.     echo shar: \"'act_area.h'\" unpacked with wrong size!
  1738. fi
  1739. # end of 'act_area.h'
  1740. fi
  1741. if test -f 'filemenu.c' -a "${1}" != "-c" ; then 
  1742.   echo shar: Will not clobber existing file \"'filemenu.c'\"
  1743. else
  1744. echo shar: Extracting \"'filemenu.c'\" \(14879 characters\)
  1745. sed "s/^X//" >'filemenu.c' <<'END_OF_FILE'
  1746. X/**********************************************************************
  1747. X * filemenu.c
  1748. X * 
  1749. X * See SelFile() header for interface description.
  1750. X *
  1751. X * Copyright 1990, David Nedde
  1752. X *
  1753. X * Permission to use, copy, modify, and distribute this software
  1754. X * and its documentation for any purpose and without fee is granted
  1755. X * provided that the above copyright notice appears in all copies.
  1756. X * It is provided "as is" without express or implied warranty.
  1757. X *
  1758. X * This source is derived from xdbx source with the following disclaimer:
  1759. X **********************************************************************/
  1760. X/*****************************************************************************
  1761. X *
  1762. X *  xdbx - X Window System interface to the dbx debugger
  1763. X *
  1764. X *  Copyright 1989 The University of Texas at Austin
  1765. X *  Copyright 1990 Microelectronics and Computer Technology Corporation
  1766. X *
  1767. X *  Permission to use, copy, modify, and distribute this software and its
  1768. X *  documentation for any purpose and without fee is hereby granted,
  1769. X *  provided that the above copyright notice appear in all copies and that
  1770. X *  both that copyright notice and this permission notice appear in
  1771. X *  supporting documentation, and that the name of The University of Texas
  1772. X *  and Microelectronics and Computer Technology Corporation (MCC) not be 
  1773. X *  used in advertising or publicity pertaining to distribution of
  1774. X *  the software without specific, written prior permission.  The
  1775. X *  University of Texas and MCC makes no representations about the 
  1776. X *  suitability of this software for any purpose.  It is provided "as is" 
  1777. X *  without express or implied warranty.
  1778. X *
  1779. X *  THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1780. X *  THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1781. X *  FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR
  1782. X *  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  1783. X *  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
  1784. X *  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  1785. X *  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1786. X *
  1787. X *  Author:      Po Cheung
  1788. X *  Created:       March 10, 1989
  1789. X *
  1790. X *****************************************************************************/
  1791. X
  1792. X/* filemenu.c
  1793. X *
  1794. X *  Construct a file menu (directory browser) which allows a user to go
  1795. X *  up and down the directory tree, to select files.
  1796. X *  The file menu is popped up by the 'file' command button.
  1797. X *  Duane Voth (duanev@mcc.com) contributed to the layout of the file menu, 
  1798. X *  plus some code and ideas.
  1799. X *
  1800. X *  changeDir():    Record the current working directory.
  1801. X *  InList():        Select files to be displayed in the menu.
  1802. X *  ScanDir():        Scan the directory and record selected filenames.
  1803. X *  DisplayMenuFile():    Callback for the file menu.
  1804. X *  CancelFileMenu():    Pop down the file menu.
  1805. X *  SetUpFileMenu():    Create the file menu popupshell.
  1806. X *  UpdateFileMenu():    Update entries in the file menu.
  1807. X *  File():        Command callback for the 'file' command button.
  1808. X */
  1809. X
  1810. X#include <ctype.h>
  1811. X#include <X11/Xos.h>
  1812. X#include <X11/Intrinsic.h>
  1813. X#include <X11/StringDefs.h>
  1814. X#include <X11/Shell.h>
  1815. X#include <X11/Xaw/Command.h>
  1816. X#include <X11/Xaw/Dialog.h>
  1817. X#include <X11/Xaw/Label.h>
  1818. X#include <X11/Xaw/List.h>
  1819. X#include <X11/Xaw/Paned.h>
  1820. X#include <sys/stat.h>
  1821. X#include <sys/param.h>
  1822. X#ifdef SUNOS4
  1823. X#include <dirent.h>
  1824. X#else
  1825. X#include <sys/dir.h>
  1826. X#endif
  1827. X/*#include "global.h"*/
  1828. X
  1829. X#ifdef SUNOS4
  1830. Xtypedef struct dirent     Directory;
  1831. X#else
  1832. Xtypedef struct direct     Directory;
  1833. X#endif
  1834. X
  1835. X#define MAXPATHLEN    1024
  1836. X#define LINESIZ        512
  1837. X#define LASTCH(s)    (s[strlen(s)-1])
  1838. X#define SECLASTCH(s)    (s[strlen(s)-2])
  1839. X
  1840. X#define MAXCOLUMNS      8     /* max number of columns in file menu */
  1841. X#define MAXARGS        20    /* max number of args */
  1842. X#define FILES_PER_COL   10     /* # of files per column in file menu */
  1843. X
  1844. X#define    INVALID        (-2)
  1845. X#define CANCELED    (-1)
  1846. X#define OK        0
  1847. Xstatic int    glob_status;
  1848. Xstatic char    **glob_path;
  1849. Xstatic Widget    parent_w;
  1850. X
  1851. X
  1852. Xchar        cwd[MAXPATHLEN] = "";    /* current working directory */
  1853. Xstatic char    fileMenuDir[MAXPATHLEN];/* current directory of file menu */
  1854. Xstatic char      **filelist;         /* list of file names in fileMenu */
  1855. Xstatic int    nfiles = 0;        /* number of files in filelist */
  1856. Xstatic Widget    popupshell,        /* parent of popup */
  1857. X        popup,             /* vpane widget containing file menu */
  1858. X        fileMenu,         /* list widget as file menu */
  1859. X        fileMenuLabel;         /* label widget as file menu label */
  1860. X
  1861. Xvoid        File();
  1862. Xstatic int    UpdateFileMenu();
  1863. Xstatic void     CancelFileMenu();
  1864. X
  1865. X/*  Change working directory to 'dir'.
  1866. X *  Modify static global variable, cwd, to keep track of 
  1867. X *  current working directory.
  1868. X */
  1869. Xstatic void changeDir(dir)
  1870. Xchar *dir;
  1871. X{
  1872. X    int i;
  1873. X
  1874. X    if (strcmp(dir, "./") == NULL) 
  1875. X    return;
  1876. X    if (dir[0] == '/' || dir[0] == '~') 
  1877. X    strcpy(cwd, dir);
  1878. X    if (strcmp(dir, "../") == NULL) {
  1879. X    for (i=strlen(cwd); cwd[i] != '/' && i > 0; i--);
  1880. X    cwd[i] = '\0';
  1881. X    if (strcmp(cwd, "") == NULL)
  1882. X        strcpy(cwd, "/");
  1883. X    }
  1884. X    else {
  1885. X    sprintf(cwd, "%s/%s", cwd, dir);
  1886. X    LASTCH(cwd) = '\0';
  1887. X    }
  1888. X}
  1889. X
  1890. X
  1891. X/*  Determines if a directory entry should appear in the file menu. 
  1892. X *  The files included in the menu are :
  1893. X *    ..  (parent directory)
  1894. X *    directories
  1895. X *    text files 
  1896. X *    executable files
  1897. X */
  1898. Xstatic int InList(entry)
  1899. XDirectory *entry;
  1900. X{
  1901. X    char pathname[LINESIZ];
  1902. X    struct stat statbuf;
  1903. X
  1904. X    if (strcmp(entry->d_name, ".") == NULL ||     /* ignore current directory */
  1905. X    LASTCH(entry->d_name) == '~' ||        /* ignore Emacs backup files */
  1906. X    entry->d_name[0] == '#' ||        /* Ignore emacs backup files */
  1907. X    (LASTCH(entry->d_name) == 'o' && SECLASTCH(entry->d_name) == '.'))
  1908. X                        /* ignore object files */
  1909. X    return False;
  1910. X    if (entry->d_name[0] == '.' && entry->d_name[1] != '.')
  1911. X    return False;                /* ignore hidden files */
  1912. X    if (strcmp(cwd, ""))             /* give full path name */
  1913. X        sprintf(pathname, "%s/%s", cwd, entry->d_name);
  1914. X    else
  1915. X        strcpy(pathname, entry->d_name);
  1916. X    if (stat(pathname, &statbuf) == -1) 
  1917. X    return False;
  1918. X    if (statbuf.st_mode & S_IFDIR) {        /* is directory */
  1919. X    strcat(entry->d_name, "/");
  1920. X    ++(entry->d_namlen);
  1921. X    return True;
  1922. X    }
  1923. X    if (statbuf.st_mode & S_IEXEC) {        /* is executable */
  1924. X    strcat(entry->d_name, "*");
  1925. X    ++(entry->d_namlen);
  1926. X    return True;
  1927. X    }
  1928. X    return True;
  1929. X}
  1930. X
  1931. X
  1932. X/*  Scans the working directory for files selected by InList(), sorted
  1933. X *  alphabetically, and stored in an array of pointers to directory
  1934. X *  entries called namelist.
  1935. X *  The names of the selected files are stored in filelist.
  1936. X */
  1937. Xstatic int ScanDir(dir)
  1938. Xchar *dir;
  1939. X{
  1940. X    extern     alphasort();
  1941. X    Directory   **namelist;
  1942. X    int        i, j;
  1943. X    char    *format_static();
  1944. X
  1945. X    nfiles = scandir(dir, &namelist, InList, alphasort);
  1946. X    if (nfiles <= 0) {
  1947. X      XBell(XtDisplay(popupshell),0);
  1948. X      return(INVALID);
  1949. X    }
  1950. X    if (filelist) {
  1951. X    for (i=0; filelist[i]; i++)
  1952. X        XtFree(filelist[i]);
  1953. X    XtFree((char *)filelist);
  1954. X    }
  1955. X    filelist = (char **) XtMalloc((nfiles+1) * sizeof(char *));
  1956. X    i = 0;
  1957. X    for (j=0; j<nfiles; j++) {
  1958. X    filelist[i++] = XtNewString(namelist[j]->d_name);
  1959. X        XtFree((char *)namelist[j]);
  1960. X    }
  1961. X    filelist[i++] = NULL;
  1962. X    XtFree((char *)namelist);
  1963. X    return(OK);
  1964. X}
  1965. X    
  1966. X
  1967. X/* Delete the current directory prefix from the passed path */
  1968. Xchar *remove_current_prefix(path)
  1969. Xchar *path;
  1970. X{
  1971. X  char    wd[MAXPATHLEN];
  1972. X  char    *temp_str;
  1973. X
  1974. X
  1975. X  getwd(wd);
  1976. X  if (!strncmp(wd,path,strlen(wd)))
  1977. X  {
  1978. X    /* wd matches path prefix */
  1979. X    temp_str = &path[strlen(wd)];
  1980. X    if (temp_str[0] == '/')
  1981. X      /* If first char of prefix is a '/',     *
  1982. X       * remove it since we want a relative path */
  1983. X      temp_str++;
  1984. X    return(temp_str);
  1985. X  }
  1986. X
  1987. X  /* Couldn't find the prefix -- return the whole path */
  1988. X  return(path);
  1989. X}
  1990. X
  1991. X
  1992. X/*  Callback for the fileMenu list widget.
  1993. X *  >  if the selected item is a directory, display contents of that directory.
  1994. X *  >  if the selected item is a readable file, return the file name
  1995. X */
  1996. X/* ARGSUSED */
  1997. Xstatic void DisplayMenuFile(w, popupshell, call_data)
  1998. X    Widget w;
  1999. X    Widget popupshell;
  2000. X    XawListReturnStruct *call_data;
  2001. X{
  2002. X    char *filename;
  2003. X
  2004. X    XtPopdown(popupshell);
  2005. X    filename = call_data->string;
  2006. X    if (filename == NULL) return;
  2007. X    if (LASTCH(filename) == '/') {
  2008. X    changeDir(filename);
  2009. X    XtDestroyWidget(popupshell);
  2010. X
  2011. X    if (UpdateFileMenu() == INVALID)
  2012. X      changeDir("../");
  2013. X
  2014. X    /* create new menu */
  2015. X    File(w,(XtPointer )0,(XtPointer )0);            /* pop it up */
  2016. X    }
  2017. X    else {
  2018. X      *glob_path = XtMalloc(strlen(filename)+strlen(cwd)+2);
  2019. X      strcpy(*glob_path, remove_current_prefix(cwd));
  2020. X      if (strlen(*glob_path) != 0)
  2021. X    strcat(*glob_path, "/");
  2022. X      strcat(*glob_path, filename);
  2023. X      glob_status = OK;
  2024. X    }
  2025. X}
  2026. X
  2027. X
  2028. X/*  Callback to popdown the file menu
  2029. X */
  2030. X/* ARGSUSED */
  2031. Xstatic void CancelFileMenu(w, popupshell, call_data)
  2032. X    Widget w;
  2033. X    Widget popupshell;
  2034. X    XtPointer call_data;
  2035. X{
  2036. X    XtPopdown(popupshell);
  2037. X    glob_status = CANCELED;
  2038. X}
  2039. X
  2040. X
  2041. X
  2042. Xvoid DisableWindowResize(w)
  2043. XWidget w;
  2044. X{
  2045. X    Arg args[MAXARGS];
  2046. X    Cardinal n;
  2047. X    Dimension height;
  2048. X
  2049. X    n = 0;
  2050. X    XtSetArg(args[n], XtNheight, &height);                       n++;
  2051. X    XtGetValues(w, args, n);
  2052. X    XawPanedSetMinMax(w, height, height);
  2053. X    XawPanedAllowResize(w, False);
  2054. X}
  2055. X
  2056. X
  2057. X/*  Creates a popup shell with its child being a vpane widget containing
  2058. X *  a file menu label, a file menu containing file names returned from 
  2059. X *  ScanDir(), and a cancel command button.
  2060. X *  When an item in the list is selected, DisplayMenuFile is called.
  2061. X */
  2062. Xstatic int SetUpFileMenu(dir) 
  2063. Xchar *dir;
  2064. X{
  2065. X    Widget    cancelButton;
  2066. X    Arg     args[MAXARGS];
  2067. X    Cardinal    n;
  2068. X    char    menulabel[LINESIZ];
  2069. X    int        ncolumns;
  2070. X
  2071. X    n = 0;
  2072. X    popupshell = XtCreatePopupShell("File Directory", transientShellWidgetClass,
  2073. X                    parent_w, args, n);
  2074. X
  2075. X    n = 0;
  2076. X    popup = XtCreateManagedWidget("popup", panedWidgetClass, popupshell,
  2077. X                  args, n);
  2078. X    if (ScanDir(dir) == OK)
  2079. X      /* It worked OK */
  2080. X      strcpy(fileMenuDir, dir);
  2081. X    else
  2082. X      return(INVALID);
  2083. X
  2084. X    n = 0;
  2085. X    sprintf(menulabel, "   %s   ", dir);
  2086. X    XtSetArg(args[n], XtNlabel, (XtArgVal) menulabel);             n++;
  2087. X    XtSetArg(args[n], XtNjustify, (XtArgVal) XtJustifyCenter);          n++;
  2088. X    fileMenuLabel = XtCreateManagedWidget("fileMenuLabel", labelWidgetClass,
  2089. X                                          popup, args, n);
  2090. X
  2091. X    n = 0;
  2092. X    ncolumns = nfiles/FILES_PER_COL + 1;
  2093. X    ncolumns = MIN(ncolumns, MAXCOLUMNS);
  2094. X    XtSetArg(args[n], XtNlist, filelist);                n++;
  2095. X    XtSetArg(args[n], XtNverticalList, True);                n++;
  2096. X    XtSetArg(args[n], XtNdefaultColumns, (XtArgVal) ncolumns);        n++;
  2097. X    fileMenu = XtCreateManagedWidget("fileMenu", listWidgetClass, 
  2098. X                     popup, args, n);
  2099. X    XtAddCallback(fileMenu, XtNcallback, DisplayMenuFile,(XtPointer)popupshell);
  2100. X
  2101. X    n = 0;
  2102. X    XtSetArg(args[n], XtNresize, False);                n++;
  2103. X    XtSetArg(args[n], XtNlabel, "CANCEL");                n++;
  2104. X    cancelButton = XtCreateManagedWidget("cancelButton", commandWidgetClass,
  2105. X                     popup, args, n);
  2106. X    XtAddCallback(cancelButton, XtNcallback, CancelFileMenu, 
  2107. X                  (XtPointer)popupshell);
  2108. X
  2109. X    DisableWindowResize(fileMenuLabel);
  2110. X    DisableWindowResize(cancelButton);
  2111. X    return(OK);
  2112. X}
  2113. X
  2114. X
  2115. X/*  This routine is called when there is a a change in current directory.
  2116. X *  It destroys the existing popup shell and creates a new file menu based
  2117. X *  on the new current directory.  A new directory list is created.
  2118. X */
  2119. Xstatic int UpdateFileMenu()
  2120. X{
  2121. X    return(SetUpFileMenu(cwd));
  2122. X}
  2123. X
  2124. X
  2125. X/*  File command button callback.
  2126. X */
  2127. X/* ARGSUSED */
  2128. Xvoid File(w, client_data, call_data)
  2129. X    Widget w;
  2130. X    XtPointer client_data;
  2131. X    XtPointer call_data;
  2132. X{
  2133. X    Arg     args[MAXARGS];
  2134. X    Cardinal    n;
  2135. X    Dimension    fileMenu_width, fileMenuLabel_width, border_width;
  2136. X    Dimension    fileMenu_height, fileMenuLabel_height;
  2137. X    Dimension   dialog_width, dialog_height;
  2138. X    int         width, height;
  2139. X    int         x_offset, y_offset;
  2140. X    Position    x,y;
  2141. X
  2142. X/*    if (strcmp(fileMenuDir, cwd))*/
  2143. X      if (UpdateFileMenu() != OK)
  2144. X    return;
  2145. X
  2146. X
  2147. X    n = 0;
  2148. X    XtSetArg(args[n], XtNwidth, &fileMenu_width);        n++;
  2149. X    XtSetArg(args[n], XtNheight, &fileMenu_height);        n++;
  2150. X    XtSetArg(args[n], XtNborderWidth, &border_width);        n++;
  2151. X    XtGetValues(fileMenu, args, n);
  2152. X
  2153. X    n = 0;
  2154. X    XtSetArg(args[n], XtNwidth, &fileMenuLabel_width);        n++;
  2155. X    XtSetArg(args[n], XtNheight, &fileMenuLabel_height);    n++;
  2156. X    XtGetValues(fileMenuLabel, args, n);
  2157. X
  2158. X    
  2159. X    /* Place the popup window centered on parent */
  2160. X    n = 0;
  2161. X    XtSetArg(args[n], XtNwidth,  &dialog_width);        n++;
  2162. X    XtSetArg(args[n], XtNheight, &dialog_height);        n++;
  2163. X    XtGetValues(parent_w, args, n);
  2164. X
  2165. X    width = MAX(fileMenu_width, fileMenuLabel_width);
  2166. X    x_offset = (Position) (dialog_width - width - border_width) / 2;
  2167. X
  2168. X    height = fileMenu_height + fileMenuLabel_height;
  2169. X    y_offset = (Position) (dialog_height - height - border_width) / 2;
  2170. X
  2171. X    XtTranslateCoords(parent_w, x_offset, y_offset, &x, &y);
  2172. X
  2173. X    x = MAX(0, x);
  2174. X    y = MAX(0, y);
  2175. X
  2176. X    n = 0;
  2177. X    XtSetArg(args[n], XtNx, x);                    n++;
  2178. X    XtSetArg(args[n], XtNy, y);                    n++;
  2179. X    XtSetValues(popupshell, args, n);
  2180. X
  2181. X
  2182. X    /*XtManageChild( popupshell);*/
  2183. X    XtPopup(popupshell, XtGrabNonexclusive);
  2184. X
  2185. X    /*UpdateMessageWindow("Select a file or directory");*/
  2186. X}
  2187. X
  2188. X
  2189. X/**********************************************************************
  2190. X * SelFile
  2191. X *
  2192. X * Pop up a window, letting the user select a file.  When the file
  2193. X * is selected, the string is returned to the caller.
  2194. X *
  2195. X * If the init_path is NULL and this is the first call, the current
  2196. X *   directory is used, else the previous call's directory is used.
  2197. X * If the init_path is an empty string, the current directory is used.
  2198. X * A passed init path will have the current dir prepended if the path
  2199. X *   doesn't start with a '/'.
  2200. X * If the popup is canceled, -1 is returned, otherwise 0 is returned.
  2201. X **********************************************************************/
  2202. Xint SelFile(w,prompt,cancel,init_path,show_entry,path_return)
  2203. XWidget        w;
  2204. Xchar        *prompt;        /* Not used yet */
  2205. Xchar        *cancel;        /* Not used yet */
  2206. Xchar        *init_path;
  2207. Xint        *(*show_entry)();    /* Not used yet */
  2208. Xchar        **path_return;
  2209. X{
  2210. X  XtAppContext app_context;
  2211. X  XEvent event;
  2212. X
  2213. X
  2214. X  parent_w = w;
  2215. X  glob_path = path_return;
  2216. X
  2217. X  if (init_path == (char *)0 || init_path[0] == '\0')
  2218. X  {
  2219. X    /* No init_path -- Use the current working directory */
  2220. X    if (cwd[0] == '\0' || init_path == (char *)0 || init_path[0] == '\0')
  2221. X      getwd(cwd);
  2222. X  }
  2223. X  else
  2224. X  if (strcmp(cwd,init_path))
  2225. X  {
  2226. X    /* They are different -- copy requested starting dir in */
  2227. X    /* Prefix with wd if init_path is a relative path */
  2228. X    if (init_path[0] != '/')
  2229. X    {
  2230. X      getwd(cwd);
  2231. X      strcat(cwd,"/");
  2232. X    }
  2233. X    else
  2234. X      cwd[0] = '\0';
  2235. X    strcat(cwd,init_path);
  2236. X  }
  2237. X
  2238. X  glob_status = INVALID;
  2239. X  File(w, (XtPointer )0, (XtPointer )0);
  2240. X
  2241. X  app_context = XtWidgetToApplicationContext( w);
  2242. X  while (glob_status == INVALID)
  2243. X  {
  2244. X    XtAppNextEvent(app_context, &event);
  2245. X    XtDispatchEvent(&event);
  2246. X  }
  2247. X
  2248. X  return(glob_status);
  2249. X}
  2250. X
  2251. END_OF_FILE
  2252. if test 14879 -ne `wc -c <'filemenu.c'`; then
  2253.     echo shar: \"'filemenu.c'\" unpacked with wrong size!
  2254. fi
  2255. # end of 'filemenu.c'
  2256. fi
  2257. if test -f 'gen_fallback' -a "${1}" != "-c" ; then 
  2258.   echo shar: Will not clobber existing file \"'gen_fallback'\"
  2259. else
  2260. echo shar: Extracting \"'gen_fallback'\" \(698 characters\)
  2261. sed "s/^X//" >'gen_fallback' <<'END_OF_FILE'
  2262. X#!/bin/sh
  2263. X
  2264. X# Usage: gen_fallback app-defaults-file
  2265. X#        Generates a list of fallback resources suitable for including
  2266. X#        in the fallback resources array
  2267. X
  2268. X# This shellscript just echos each line in the source file with a " at
  2269. X# the beginning of the line, and a ", at the and of the line.
  2270. X
  2271. Xecho '/* fallback.h generated by gen_fallback from '$1' - do not edit! */'
  2272. Xecho ""
  2273. Xcat $1 | awk ' \
  2274. X  BEGIN { first = 1 } \
  2275. X  /\\$/ && first == 0 { printf("%s\n", $0); } \
  2276. X  /\\$/ && first == 1 { first = 0; printf("\"%s\n", $0); } \
  2277. X  $0 !~ /\\$/ && first == 1  { printf("\"%s\",\n", $0); } \
  2278. X  $0 !~ /\\$/ && first == 0  { first = 1 ; printf("\",\n\"%s\",\n", $0); } \
  2279. X  END  { printf("NULL\n"); }'
  2280. END_OF_FILE
  2281. if test 698 -ne `wc -c <'gen_fallback'`; then
  2282.     echo shar: \"'gen_fallback'\" unpacked with wrong size!
  2283. fi
  2284. chmod +x 'gen_fallback'
  2285. # end of 'gen_fallback'
  2286. fi
  2287. if test -f 'run_demos' -a "${1}" != "-c" ; then 
  2288.   echo shar: Will not clobber existing file \"'run_demos'\"
  2289. else
  2290. echo shar: Extracting \"'run_demos'\" \(306 characters\)
  2291. sed "s/^X//" >'run_demos' <<'END_OF_FILE'
  2292. X#!/bin/sh
  2293. X
  2294. Xecho '*** Xball Demos ***'
  2295. Xecho "Hit 'q' in the xball window to exit a demo early"
  2296. Xecho ""
  2297. X
  2298. Xfor f in demo1 demo2 demo3 demo4 demo5 demo6 demo7 demo8 demo9 demo10 demo11 \
  2299. X         demo12 demo13 demo14
  2300. Xdo
  2301. X  echo "Running demo: $f"
  2302. X  xball -demo $f
  2303. X  sleep 1  # Let X catch up with events...
  2304. Xdone
  2305. END_OF_FILE
  2306. if test 306 -ne `wc -c <'run_demos'`; then
  2307.     echo shar: \"'run_demos'\" unpacked with wrong size!
  2308. fi
  2309. chmod +x 'run_demos'
  2310. # end of 'run_demos'
  2311. fi
  2312. if test -f 'xball.man' -a "${1}" != "-c" ; then 
  2313.   echo shar: Will not clobber existing file \"'xball.man'\"
  2314. else
  2315. echo shar: Extracting \"'xball.man'\" \(2080 characters\)
  2316. sed "s/^X//" >'xball.man' <<'END_OF_FILE'
  2317. X.TH XBALL 6 "1/5/93" " "
  2318. X.SH NAME
  2319. Xxball \- bounce colored balls on the screen
  2320. X.SH SYNOPSIS
  2321. X.B xball
  2322. X[ -help -delay
  2323. X.I delay
  2324. X-gravity
  2325. X.I percent-gravity
  2326. X-elasticity
  2327. X.I percent-elasticity
  2328. X-itemWidth
  2329. X.I ball-width
  2330. X-itemHeight
  2331. X.I ball-height
  2332. X-collide -perpetual -haltSim -demoFile
  2333. X.I demo-file
  2334. X-rgbTxt
  2335. X.I rgb.txt-file
  2336. X]
  2337. X[XToolkit options]
  2338. X.sp
  2339. X.SH DESCRIPTION
  2340. X.PP
  2341. X.I XBall
  2342. Xallows the user to create colored, 3-d shaded balls, or to write and
  2343. Xrun demo which create and manipulate the balls in various ways.
  2344. XDocumentation is included on-line via the Help menu and is not
  2345. Xreproduced here.
  2346. X.SH OPTIONS
  2347. XRun xball -help for a decription of the command line options
  2348. X.SH DEMOS
  2349. XSeveral demo files are included with the distribution.  To run all the
  2350. Xdemos, run 'run_demos'.
  2351. X.SH RESOURCES
  2352. XMost resources are avaliable for user modification.  See the XBall
  2353. Xapp-defaults file for a complete listing of widgets,
  2354. X.sp
  2355. XFollowing is a list of the most useful resources:
  2356. X.RS
  2357. X.TP 3
  2358. X\fBXBall*canvas.width, height\fR
  2359. XThe default width and height of the window in which balls bounce in.
  2360. X.TP 3
  2361. X\fBXBall.delay\fR
  2362. XThe amount to slow the simulation, in case the computer is too fast.
  2363. XA reasonable range is 0 to 200.
  2364. X.TP 3
  2365. X\fBXBall.itemWidth, itemHeight\fR
  2366. XThe default width and height of the balls.
  2367. X.TP 3
  2368. X\fBXBall.collide\fR
  2369. XIf true, balls are colliding on startup.
  2370. X.TP 3
  2371. X\fBXBall.perpetual\fR
  2372. XIf true, balls are perpetual on startup.
  2373. X.TP 3
  2374. X\fBXBall.haltSim\fR
  2375. XIf true, simulation is halted on startup.
  2376. X.TP 3
  2377. X\fBXBall.demoFile\fR
  2378. XSpecified the file to run as a demo on startup.
  2379. X.TP 3
  2380. X\fBXBall.rgbTxt\fR
  2381. XSpecified the file to load for the colors.  The default file is
  2382. X/usr/lib/X11/app-defaults/rgb.txt
  2383. X.SH FILES
  2384. X.TP
  2385. X/usr/lib/X11/rgb.txt
  2386. XX11 color names and values.
  2387. X.sp
  2388. X.SH AUTHOR
  2389. X.PP
  2390. XDavid Nedde (daven@ivy.wpi.edu).
  2391. X.sp
  2392. X.SH COPYRIGHT
  2393. XCopyright 1991, 1993 David Nedde.
  2394. X.br
  2395. XPermission to use, copy, modify, and distribute this
  2396. Xsoftware and its documentation for any purpose and without
  2397. Xfee provided that the above copyright notice appears in all copies.
  2398. XIt is provided "as is" without express or implied warranty.
  2399. END_OF_FILE
  2400. if test 2080 -ne `wc -c <'xball.man'`; then
  2401.     echo shar: \"'xball.man'\" unpacked with wrong size!
  2402. fi
  2403. # end of 'xball.man'
  2404. fi
  2405. echo shar: End of archive 4 \(of 5\).
  2406. cp /dev/null ark4isdone
  2407. MISSING=""
  2408. for I in 1 2 3 4 5 ; do
  2409.     if test ! -f ark${I}isdone ; then
  2410.     MISSING="${MISSING} ${I}"
  2411.     fi
  2412. done
  2413. if test "${MISSING}" = "" ; then
  2414.     echo You have unpacked all 5 archives.
  2415.     rm -f ark[1-9]isdone
  2416. else
  2417.     echo You still need to unpack the following archives:
  2418.     echo "        " ${MISSING}
  2419. fi
  2420. ##  End of shell archive.
  2421. exit 0
  2422.  
  2423. exit 0 # Just in case...
  2424. -- 
  2425.   // chris@IMD.Sterling.COM       | Send comp.sources.x submissions to:
  2426. \X/  Amiga - The only way to fly! |    sources-x@imd.sterling.com
  2427.  "It's intuitively obvious to the |
  2428.   most casual observer..."        | GCS d+/-- p+ c++ l+ m+ s++/+ g+ w+ t+ r+ x+
  2429.