xball-3.1.0/000077500000000000000000000000001411065647700126305ustar00rootroot00000000000000xball-3.1.0/AUTHORS000066400000000000000000000003571411065647700137050ustar00rootroot00000000000000Xball Authors xball: David Nedde act_area.c: Written by Dan Heller filemenu.c: Po Cheung Debian Packaging, 2004apr29: Stephen Birch automake Package, 2021aug23: Joe Da Silva xball-3.1.0/COPYING000066400000000000000000000036511411065647700136700ustar00rootroot00000000000000ISC License (ISC) Copyright 1993 David Nedde Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is granted provided that the above copyright notice appears in all copies. It is provided "as is" without express or implied warranty. One file has additional copying policies: filemenu.c Copyright 1989 The University of Texas at Austin Copyright 1990 Microelectronics and Computer Technology Corporation Author: Po Cheung Copyright 1989 The University of Texas at Austin Copyright 1990 Microelectronics and Computer Technology Corporation Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of The University of Texas and Microelectronics and Computer Technology Corporation (MCC) not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. The University of Texas and MCC makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. Author: Po Cheung Created: March 10, 1989 xball-3.1.0/ChangeLog000066400000000000000000000175771411065647700144230ustar00rootroot00000000000000xball (3.1.0) * Debian Orphaned xball brought up to date and is buildable with current PCs. * Dropped Debian packaging and reworked xball to be built with configure make. * 'make dist' builds package that can be built by user using ./configure make. * xball.pc package file added. * freedesktop configuration added and improved to include *.xball to be seen as xball scripts. You click demo.xball and it automatically runs xball demo Also added desktop files for 64x64, 128x128, 256x256 icon files. * run_demo is installed in same directory as xball and demo scripts are kept in xball data directory. * Corrected COPYING from boilerplate to what appears to be ISC license. * xball manual is installed as xball.6 in games manual directory. * rgb.txt now searched and found in /usr/X11 directory. * Due to the upgrades, bumped minor value from 0 to 1, making this ver 3.1.0 -- Joe Da Silva Mon, 23 Aug 2021 1:32:00 +0800 xball (3.0.1-2) unstable; urgency=medium * QA upload. * Change maintainer to Debian QA Group because the package has been orphaned. * Acknowledge NMU by Luk Claes. Thanks! (Closes: #722945) * Switch to compat level 10. * wrap-and-sort -sa. * Declare compliance with Debian Policy 4.1.0. * Drop deprecated menu file. Convert xpm icon to png and install it into the hicolor icon directory. * Drop debian/README. No longer useful. * Simplify debian/rules and use dh sequencer. * Provide a desktop file. (Closes: #738054) * Fix FTBFS with the clang compiler. Thanks to Piotr SokoĊ‚owski for the patch. (Closes: #742972) * Homepage field: Point to tracker.debian.org. * Add man-page-spelling.patch and fix a minor spelling mistake in xball.man. * export DEB_CFLAGS_MAINT_APPEND = -std=gnu89 otherwise the game will segfault with newer versions of the C standard. * Install data files into /usr/share/games/xball. * Add implicit-declaration.patch and fix various compiler warnings about implicit declarations. -- Markus Koschany Wed, 13 Sep 2017 05:24:18 +0200 xball (3.0.1-1.2) unstable; urgency=low * Non-maintainer upload. * Drop dependency on menu (Closes: #647387, #624857). * Transition from lesstif2 to motif (Closes: #714673). -- Luk Claes Sat, 14 Sep 2013 18:56:07 +0200 xball (3.0.1-1.1) unstable; urgency=low [ Jari Aalto ] * Non-maintainer upload. - Move to packaging format "3.0 (quilt)". * debian/compat - Update to 7. * debian/control - (Build-Depends): update obsolete xutils to xutils-dev (important; Closes: #578967). Update to debhelper 7.1. Add autotools-dev. - (Depends): add ${misc:Depends}. - (Standards-Version): Update to 3.8.4. - (xball::Section): Remove duplicate section. * debian/patches - (Number 10): Fix spelling errors. * debian/rules - (configure-stamp): use newest config.* files. - (install): Change dh_clean to dh_prep. * debian/source/format - New file -- Jari Aalto Sat, 08 May 2010 22:50:10 +0300 xball (3.0.1-1) unstable; urgency=low * New upstream release, consolidates all 3.0 patches - Change debhelper compat from 4 to 5 - Change standards version to 3.7.3 - Change to three part numbering, new version is 3.0.1 - Get xball version number from changelog, see rules file for details - Cleanup some of the old pre-autoconf cruft - Fix rules, Lintian was giving debian-rules-ignores-make-clean-error * upload sponsored by Branden Robinson -- Stephen Birch Sun, 9 Dec 2007 22:01:23 +0000 xball (3.0-18) unstable; urgency=low * Remove strange vi file from debian directory, :visual -- Stephen Birch Wed, 21 Nov 2007 22:34:23 +0000 xball (3.0-17) unstable; urgency=low * Apply NMU patch, merge with upstream * Change standards version to 3.7.2 -- Stephen Birch Tue, 20 Nov 2007 00:37:52 +0000 xball (3.0-16.1) unstable; urgency=low * NMU to fix RGB_TXT and all other references to point to /etc/X11/rgb.txt, as it is in x11-common. (Closes: #377652). * Added the demo files to the documentation. -- Margarita Manterola Thu, 13 Jul 2006 19:32:23 -0300 xball (3.0-16) unstable; urgency=high * Update to add patch in "NMU" 3.0-15.1 (closes: #303337) -- Stephen Birch Thu, 14 Apr 2005 11:38:18 +0100 xball (3.0-15.1) unstable; urgency=low * NMU - Thanks Paul for the patch! (SGB) * Adds 'rm -rf .deps' to debian/rules clean (closes: #303337) -- Paul Brossier Wed, 13 Apr 2005 03:09:43 +0100 xball (3.0-15) unstable; urgency=low * Add libxt-dev to build-depends to arm can build -- Stephen Birch Wed, 23 Mar 2005 14:38:15 +0000 xball (3.0-14) unstable; urgency=low * Make demo_start() static declaration (closes: #288656) * Added config.guess and config.sub from automake1.4 * Added content to NEWS and ChaneLog so patch creates them -- Stephen Birch Wed, 23 Feb 2005 08:51:33 +0000 xball (3.0-13) unstable; urgency=low * Use gettimeofday() to compute consistant delay -- Stephen Birch Tue, 21 Dec 2004 15:06:29 +0000 xball (3.0-12) unstable; urgency=low * chmod +x missing to rules (closes: #283269) * Run 'make distclean' from clean target in rules -- Stephen Birch Sun, 28 Nov 2004 08:28:49 -0500 xball (3.0-11) unstable; urgency=low * Fix more automake problems (NEWS and ChangeLog files) -- Stephen Birch Sun, 28 Nov 2004 08:26:19 -0500 xball (3.0-10) unstable; urgency=low * Make configure executable in rules file -- Stephen Birch Thu, 25 Nov 2004 12:48:31 +0000 xball (3.0-9) unstable; urgency=low * More minor changes to makefile system -- Stephen Birch Mon, 22 Nov 2004 17:34:48 +0000 xball (3.0-8) unstable; urgency=low * Run autoconf prior to uploading to debian * Remove automake, autoconf1.9 dependency -- Stephen Birch Mon, 22 Nov 2004 17:09:48 +0000 xball (3.0-7) unstable; urgency=low * hard code automake to automake1.9 (closes: #272239) -- Stephen Birch Mon, 1 Nov 2004 04:41:45 -0500 xball (3.0-6) unstable; urgency=low * Compile againt lesstif2 instead of lesstif (closes: #269285) * Change automaken dependancy to automake -- Stephen Birch Fri, 3 Sep 2004 11:29:57 +0100 xball (3.0-5) unstable; urgency=low * Remove postinst and preinst file, not required * Update rules file to be policy complient * Closes: #244289: Package includes non-free source code. * Closes: #256422: Missing Build-Depends -- Stephen Birch Sun, 27 Jun 2004 11:06:34 +0100 xball (3.0-4) unstable; urgency=low * Change bootstrap to make '/xball-3.0/missing' executable * Add automaken to the list of compile dependencies -- Stephen Birch Sun, 28 Mar 2004 14:27:22 -0500 xball (3.0-3) unstable; urgency=low * Add comment to README telling user where to find program (usr/games) * Re-release with correct orig.tar.gz, removing .svn directories -- Stephen Birch Fri, 26 Mar 2004 11:49:14 -0500 xball (3.0-2) unstable; urgency=low * Move xball binary to /usr/games per 11.11 of policy * Quote all sections of xball.menu to help lintian -- Stephen Birch Fri, 19 Mar 2004 15:31:52 +0000 xball (3.0-1) unstable; urgency=low * Initial Release (closes: 230942) * Define scale_set_value in scrollbar.c to prevent compiler warning * Removed gcc from Build-Depends * Spell checked and improved descriptions * Converted from Imake to GNU automake/autoconf * Remove Makefile and configure from debian sources * Add menu system -- Stephen Birch Sat, 31 Jan 2004 10:55:51 +0000 xball-3.1.0/INSTALL000066400000000000000000000174051411065647700136700ustar00rootroot00000000000000Before you begin compiling, you should create the configure script by running the shall script 'bootstrap'. Basic Installation ================== These are generic installation instructions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, a file `config.cache' that saves the results of its tests to speed up reconfiguring, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.in' is used to create `configure' by a program called `autoconf'. You only need `configure.in' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. You can give `configure' initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this: CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure Or on systems that have the `env' program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not supports the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=PATH' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' can not figure out automatically, but needs to determine by the type of host the package will run on. Usually `configure' can figure that out, but if it prints a message saying it can not guess the host type, give it the `--host=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name with three fields: CPU-COMPANY-SYSTEM See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the host type. If you are building compiler tools for cross-compiling, you can also use the `--target=TYPE' option to select the type of system they will produce code for and the `--build=TYPE' option to select the type of system on which you are compiling the package. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Operation Controls ================== `configure' recognizes the following options to control how it operates. `--cache-file=FILE' Use and save the results of the tests in FILE instead of `./config.cache'. Set FILE to `/dev/null' to disable caching, for debugging `configure'. `--help' Print a summary of the options to `configure', and exit. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--version' Print the version of Autoconf used to generate the `configure' script, and exit. `configure' also accepts some other, not widely useful, options. xball-3.1.0/Makefile.am000066400000000000000000000051441411065647700146700ustar00rootroot00000000000000## IMPORTANT - If you change this file, run the bootstrap script again SUBDIRS = desktop X11/Xaw_d man_MANS = xball.6 bin_PROGRAMS = xball xball_SOURCES = xball.c color_l.c demo.c file_sel.c sim.c \ help.c item.c items.c list.c menu.c misc.c miscx.c room.c \ table.c xball_sys.c scrollbar.c noinst_HEADERS = act_area.h color_l.h demo.h fallback.h file_sel.h \ help.h intf.h item.h items.h list.h menu.h misc.h miscx.h \ names.h patchlevel.h room.h scrollbar.h sim.h table.h \ xball_sys.h xball_LDADD = -L/usr/X11R6/lib -lXm -lXmu -lXt -lX11 RUN_DEMOS_HEADER = "d=${datarootdir}/xball" nodist_bin_SCRIPTS = run_demos run_demos: run_demos.in echo "#!/bin/sh" > run_demos echo "d=${datarootdir}/xball" >> run_demos cat ${srcdir}/run_demos.in >> run_demos chmod +x run_demos do_subst = sed -e 's,[@]xball[@],$(datarootdir)\/xball,' $< > $@ demo1.xball : demo1.xball.in $(do_subst) < $(srcdir)/demo1.xball.in > demo1.xball demo2.xball : demo2.xball.in $(do_subst) < $(srcdir)/demo2.xball.in > demo2.xball demo3.xball : demo3.xball.in $(do_subst) < $(srcdir)/demo3.xball.in > demo3.xball demo4.xball : demo4.xball.in $(do_subst) < $(srcdir)/demo4.xball.in > demo4.xball demo5.xball : demo5.xball.in $(do_subst) < $(srcdir)/demo5.xball.in > demo5.xball demo6.xball : demo6.xball.in $(do_subst) < $(srcdir)/demo6.xball.in > demo6.xball demo12.xball : demo12.xball.in $(do_subst) < $(srcdir)/demo12.xball.in > demo12.xball demo13.xball : demo13.xball.in $(do_subst) < $(srcdir)/demo13.xball.in > demo13.xball demo14.xball : demo14.xball.in $(do_subst) < $(srcdir)/demo14.xball.in > demo14.xball # example demo programs dist_DEMOSin = demo1.xball.in demo2.xball.in demo3.xball.in demo4.xball.in \ demo5.xball.in demo6.xball.in demo12.xball.in demo13.xball.in \ demo14.xball.in nodist_DEMOS = demo1.xball demo2.xball demo3.xball demo4.xball demo5.xball \ demo6.xball demo12.xball demo13.xball demo14.xball dist_DEMOS = demo7.xball demo8.xball demo9.xball demo10.xball demo11.xball IMAGES = xball-a.xbm xball-b.xbm xball-l.xbm xball.xbm xball-x.xbm \ man.xbm off.xbm on.xbm sgi.xbm demosdir = ${datarootdir}/xball demos_DATA = ${dist_DEMOS} ${nodist_DEMOS} ${IMAGES} EXTRA_DIST = run_demos.in ${dist_DEMOS} ${dist_DEMOSin} ${IMAGES} \ act_area.c bootstrap filemenu.c gen_fallback good_bitmaps \ stipple.xbm XBall.ad xball.6 ${noinst_HEADERS} MOSTLYCLEANFILES = run_demos DISTCLEANFILES = run_demos uninstall-hook: if test -d ${datarootdir}/xball; then rmdir ${datarootdir}/xball; fi clean-local: -rm -rf run_demos ${nodist_DEMOS} distclean-local: -rm *~ -rm -rf autom4te.cache -rm -rf .deps -rm -rf ${nodist_DEMOS} xball-3.1.0/NEWS000066400000000000000000000003511411065647700133260ustar00rootroot000000000000002005-02-23 I have been unable to locate the upstream author of xball and plan to take over this project. If anyone knows the location of the author I would be grateful if you could email me at sgbirch@imsmail.org. Thanks, Steve xball-3.1.0/README000066400000000000000000000046471411065647700135230ustar00rootroot00000000000000 This program simulates bouncing balls in a window. You create the balls in a variety of ways, and can set the gravity, elasticity, whether balls collide or not, etc. Since the last version, I have added Motif support, 3-d shaded balls, and a demo running facility. Software features user-configurable menus, and a DrawingArea widget for use with other Athena widgets. XBall compiles using either Motif or Athena Widgets (See the Imakefile to select the one you want). It been compiled and run on a Sun Sparc, IBM RS6000, SGI Iris and DecStation 5000, using their standard C compiler. The Athena version works using X11R4 or X11R5. To compile, run xmkmf (and Make Makefiles if Athena widgets used). Then make. A standard Make.motif and Make.athena have been provided if you do not have xmkmf. If you have undefined symbols, such as usleep or regex, see the Imakefile for symbols to define, xmkmf, remove the *.o files, and recompile. All resources are contained within the program as fallback resources, so, it is not strictly neccessary to install the app-defaults file, except that when using Athena widgets, since the keyboard accelertors will not work if the app-defauls file is not installed. To run the included demos, type 'run_demos'. Here are the recommended values for the delay to slow down balls. This delay can be set in the Imakefile, or when run as xball -delay 1000. Sun Sparc 100 IBM RS6000 10000 SGI Iris 100 (Uncomment MYLDLIBS in Imakefile if using Motif) DecStation 5000 180 (Comment out HAVE_USLEEP in Imakefile) Please send bugs, comments, suggestions, and interesting demos to: daven@ivy.wpi.edu. Copying Policy: Copyright 1993 David Nedde Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is granted provided that the above copyright notice appears in all copies. It is provided "as is" without express or implied warranty. Two files have additional copying policies: act_area.c: Written by Dan Heller. Copyright 1991, O'Reilly && Associates. This program is freely distributable without licensing fees and is provided without guarantee or warrantee expressed or implied. This program is -not- in the public domain. filemenu.c Copyright 1989 The University of Texas at Austin Copyright 1990 Microelectronics and Computer Technology Corporation Author: Po Cheung xball-3.1.0/X11/000077500000000000000000000000001411065647700132015ustar00rootroot00000000000000xball-3.1.0/X11/Xaw_d/000077500000000000000000000000001411065647700142435ustar00rootroot00000000000000xball-3.1.0/X11/Xaw_d/DrawingA.c000066400000000000000000000120061411065647700161020ustar00rootroot00000000000000/* DrawingA.c: The DrawingArea Widget Methods */ /* Copyright 1990, David Nedde /* /* Permission to use, copy, modify, and distribute this /* software and its documentation for any purpose and without fee /* is granted provided that the above copyright notice appears in all copies. /* It is provided "as is" without express or implied warranty. */ #include #include #include #include #include "DrawingAP.h" static void Initialize(); static void Destroy(); static void Redisplay(); static void input_draw(); static void motion_draw(); static void resize_draw(); static char defaultTranslations[] = ": input() \n : input() \n : input() \n : input() \n : motion() \n : resize()"; static XtActionsRec actionsList[] = { { "input", (XtActionProc)input_draw }, { "motion", (XtActionProc)motion_draw }, { "resize", (XtActionProc)resize_draw }, }; /* Default instance record values */ static XtResource resources[] = { {XtNexposeCallback, XtCCallback, XtRCallback, sizeof(caddr_t), XtOffset(DrawingAreaWidget, drawing_area.expose_callback), XtRCallback, NULL }, {XtNinputCallback, XtCCallback, XtRCallback, sizeof(caddr_t), XtOffset(DrawingAreaWidget, drawing_area.input_callback), XtRCallback, NULL }, {XtNmotionCallback, XtCCallback, XtRCallback, sizeof(caddr_t), XtOffset(DrawingAreaWidget, drawing_area.motion_callback), XtRCallback, NULL }, {XtNresizeCallback, XtCCallback, XtRCallback, sizeof(caddr_t), XtOffset(DrawingAreaWidget, drawing_area.resize_callback), XtRCallback, NULL }, }; DrawingAreaClassRec drawingAreaClassRec = { /* CoreClassPart */ { (WidgetClass) &simpleClassRec, /* superclass */ "DrawingArea", /* class_name */ sizeof(DrawingAreaRec), /* size */ NULL, /* class_initialize */ NULL, /* class_part_initialize */ FALSE, /* class_inited */ Initialize, /* initialize */ NULL, /* initialize_hook */ XtInheritRealize, /* realize */ actionsList, /* actions */ XtNumber(actionsList), /* num_actions */ resources, /* resources */ XtNumber(resources), /* resource_count */ NULLQUARK, /* xrm_class */ FALSE, /* compress_motion */ FALSE, /* compress_exposure */ TRUE, /* compress_enterleave */ FALSE, /* visible_interest */ Destroy, /* destroy */ NULL, /* resize */ Redisplay, /* expose */ NULL, /* set_values */ NULL, /* set_values_hook */ XtInheritSetValuesAlmost, /* set_values_almost */ NULL, /* get_values_hook */ NULL, /* accept_focus */ XtVersion, /* version */ NULL, /* callback_private */ defaultTranslations, /* tm_table */ XtInheritQueryGeometry, /* query_geometry */ XtInheritDisplayAccelerator, /* display_accelerator */ NULL /* extension */ }, /* CoreClass fields initialization */ { /* change_sensitive */ XtInheritChangeSensitive }, /* SimpleClass fields initialization */ { 0, /* field not used */ }, /* DrawingAreaClass fields initialization */ }; WidgetClass drawingAreaWidgetClass = (WidgetClass)&drawingAreaClassRec; static void Initialize( request, new) DrawingAreaWidget request, new; { if (request->core.width == 0) new->core.width = 100; if (request->core.height == 0) new->core.height = 100; } static void Destroy( w) DrawingAreaWidget w; { XtRemoveAllCallbacks((Widget)w, XtNexposeCallback); XtRemoveAllCallbacks((Widget)w, XtNinputCallback); XtRemoveAllCallbacks((Widget)w, XtNmotionCallback); XtRemoveAllCallbacks((Widget)w, XtNresizeCallback); } /* Invoke expose callbacks */ static void Redisplay(w, event, region) DrawingAreaWidget w; XEvent *event; Region region; { XawDrawingAreaCallbackStruct cb; cb.reason = XawCR_EXPOSE; cb.event = event; cb.window = XtWindow(w); XtCallCallbacks((Widget)w, XtNexposeCallback, (char *)&cb); } /* Invoke resize callbacks */ static void resize_draw(w, event, args, n_args) DrawingAreaWidget w; XEvent *event; char *args[]; int n_args; { XawDrawingAreaCallbackStruct cb; cb.reason = XawCR_RESIZE; cb.event = event; cb.window = XtWindow(w); XtCallCallbacks((Widget)w, XtNresizeCallback, (char *)&cb); } /* Invoke input callbacks */ static void input_draw(w, event, args, n_args) DrawingAreaWidget w; XEvent *event; char *args[]; int n_args; { XawDrawingAreaCallbackStruct cb; cb.reason = XawCR_INPUT; cb.event = event; cb.window = XtWindow(w); XtCallCallbacks((Widget)w, XtNinputCallback, (char *)&cb); } /* Invoke motion callbacks */ static void motion_draw(w, event, args, n_args) DrawingAreaWidget w; XEvent *event; char *args[]; int n_args; { XawDrawingAreaCallbackStruct cb; cb.reason = XawCR_MOTION; cb.event = event; cb.window = XtWindow(w); XtCallCallbacks((Widget)w, XtNmotionCallback, (char *)&cb); } xball-3.1.0/X11/Xaw_d/DrawingA.doc000066400000000000000000000101361411065647700164270ustar00rootroot00000000000000DrawingArea Widget SYNOPSIS Application header file Class header file Class drawingAreaWidgetClass Class Name DrawingArea Superclass Simple OVERVIEW This widget was needed to allow a drawing area in the Athena widget set that doesn't require hacking up the Label widget by adding complicated actions. This widget follows Motif's DrawingArea widget closely, except that it follows Athena's naming conventions and there is no resize policy. Also, Motif's Drawing area is a composite widget, while this one is a simple widget. This widget is NOT officially part of the Athena widget set. DESCRIPTION The DrawingArea widget is modeled after Motif's DrawingArea widget. The DrawingArea widget is an empty widget that is easily adaptable to a variety of purposes. It does no drawing and defines no behavior except for invoking callbacks. Callbacks notify the application when graphics need to be drawn (exposure events or widget resize) and when the widget receives input from the keyboard or mouse. Applications are responsible for defining appearence and behavior as needed in response to DrawingArea callbacks. Classes DrawingArea inherits behavior and resources from the Core and Simple classes. The class pointer is DrawingAreaWidgetClass. The class name is DrawingArea. New Resources Name Class RepType Default Value ---- ----- ------- ------------- exposeCallback Callback Pointer NULL inputCallback Callback Pointer NULL motionCallback Callback Pointer NULL resizeCallback Callback Pointer NULL XtNexposeCallback Specifies list of callbacks that is called when DrawingArea recieves an exposure event. The callback reason is XawCR_EXPOSE. XtNinputCallback Specifies list of callbacks that is called when DrawingArea recieves an keyboard or mouse event (key or button, up or down). The callback reason is XawCR_INPUT. XtNmotionCallback Specifies list of callbacks that is called when DrawingArea recieves a mouse motion event. The callback reason is XawCR_MOTION. XtNresizeCallback Specifies list of callbacks that is called when the DrawingArea is resized. The callback reason is XawCR_RESIZE. Inherited Resources, Changed defaults Name Class RepType Default Value ---- ----- ------- ------------- height Height Dimension 100 width Width Dimension 100 Callback Information A pointer to the following structure is returned with each callback. typedef struct { int reason; XEvent *event; Window window; } XawDrawingAreaCallbackStruct; reason: Indicates why the callback was invoked event: Points to the XEvent that triggered the callback window: Is set to the widget window Behavior ,,,: The callbacks for XtNinputCallback are called when a key or button is pressed or released. : The callbacks for XtNexposeCallbacks are called when the widget recieves an exposure event. : The callbacks for XtNresizeCallbacks are called when the widget is resized. : The callbacks for XtNmotionCallbacks are called when the widget recieves a pointer motion event. Default Translations : input() : input() : input() : input() : motion() : resize() SEE ALSO OSF/Motif Programmer's reference: XmDrawingArea Open Software Foundation Athena Widget Set - C Language Interface Rel 4: 3.6 Simple Widget Chris D. Peterson X Toolkit Intrinsics - C Language Interface Joel McCormack, Paul Asenta, Ralph R. Swick The X Window System, programming and Applications with Xt, OSF/Motif Edition Douglas A. Young COPYRIGHT Copyright 1990, David Nedde Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is provided that the above copyright notice appears in all copies. It is provided "as is" without express or implied warranty. AUTHOR David Nedde, daven@maxine.wpi.edu xball-3.1.0/X11/Xaw_d/DrawingA.h000066400000000000000000000025671411065647700161220ustar00rootroot00000000000000/* DrawingA.h - Public Header file */ /* Copyright 1990, David Nedde /* /* Permission to use, copy, modify, and distribute this /* software and its documentation for any purpose and without fee /* is granted provided that the above copyright notice appears in all copies. /* It is provided "as is" without express or implied warranty. */ /* Define widget's class pointer and strings used to specify resources */ #ifndef _XawDrawingArea_h #define _XawDrawingArea_h /* Resources ADDED to label widget: Name Class RepType Default Value ---- ----- ------- ------------- exposeCallback Callback Pointer NULL inputCallback Callback Pointer NULL motionCallback Callback Pointer NULL resizeCallback Callback Pointer NULL */ extern WidgetClass drawingAreaWidgetClass; typedef struct _DrawingAreaClassRec *DrawingAreaWidgetClass; typedef struct _DrawingAreaRec *DrawingAreaWidget; /* Resource strings */ #define XtNexposeCallback "exposeCallback" #define XtNinputCallback "inputCallback" #define XtNmotionCallback "motionCallback" #define XtNresizeCallback "resizeCallback" typedef struct _XawDrawingAreaCallbackStruct { int reason; XEvent *event; Window window; } XawDrawingAreaCallbackStruct; /* Reasons */ #define XawCR_EXPOSE 1 #define XawCR_INPUT 2 #define XawCR_MOTION 3 #define XawCR_RESIZE 4 #endif /* _XawDrawingArea_h */ xball-3.1.0/X11/Xaw_d/DrawingAP.h000066400000000000000000000025251411065647700162340ustar00rootroot00000000000000/* DrawingArea Private header file */ /* Copyright 1990, David Nedde /* /* Permission to use, copy, modify, and distribute this /* software and its documentation for any purpose and without fee /* is granted provided that the above copyright notice appears in all copies. /* It is provided "as is" without express or implied warranty. */ #ifndef _XawDrawingAreaP_h #define _XawDrawingAreaP_h #include "DrawingA.h" #ifdef X11_R3 #include #else #include #endif /* The drawing area's contribution to the class record */ typedef struct _DrawingAreaClassPart { int ignore; } DrawingAreaClassPart; /* Drawing area's full class record */ typedef struct _DrawingAreaClassRec { CoreClassPart core_class; SimpleClassPart simple_class; DrawingAreaClassPart drawing_area; } DrawingAreaClassRec; extern DrawingAreaClassRec drawingAreaClassRec; /* Resources added and status of drawing area widget */ typedef struct _XsDrawingAreaPart { /* Resources */ XtCallbackList expose_callback; XtCallbackList input_callback; XtCallbackList motion_callback; XtCallbackList resize_callback; } DrawingAreaPart; /* Drawing area's instance record */ typedef struct _DrawingAreaRec { CorePart core; SimplePart simple; DrawingAreaPart drawing_area; } DrawingAreaRec; #endif /* _XawDrawingAreaP_h */ xball-3.1.0/X11/Xaw_d/Imakefile000066400000000000000000000014741411065647700160620ustar00rootroot00000000000000/**/# /**/# Imakefile for Xaw_d : Dave Nedde (daven@ivy.wpi.edu) /**/# INCLUDES = -I../.. DEMO_SRCS = demo.c DEMO_OBJS = demo.o LOCAL_LIBRARIES = -lXaw_d LDOPTIONS = -L. LDLIBS = -lXaw_d -lXaw -lXt -lXmu -lXext -lX11 NormalLibraryTarget(Xaw_d,DrawingA.o) SRCS = $(DEMO_SRCS) OBJS = $(DEMO_OBJS) ComplexProgramTarget(demo) DIST = \ X11 \ X11/Xaw_d \ X11/Xaw_d/DrawingA.c \ X11/Xaw_d/DrawingA.h \ X11/Xaw_d/DrawingAP.h \ X11/Xaw_d/DrawingA.doc \ X11/Xaw_d/Imakefile \ X11/Xaw_d/Makefile.std \ X11/Xaw_d/patchlevel.h \ X11/Xaw_d/demo.c \ X11/Xaw_d/README shar: ( cd ../.. ; makekit -s75k -p $(DIST) ; mv Part* X11/Xaw_d ) tar: ( cd ../.. ; tar cvf - $(DIST) | compress -v > X11/Xaw_d/xball.tar.Z ) xball-3.1.0/X11/Xaw_d/Makefile.am000066400000000000000000000011231411065647700162740ustar00rootroot00000000000000# Copyright 2021, Jose Da Silva # # Permission to use, copy, modify, and distribute this software # and its documentation for any purpose and without fee is granted # provided that the above copyright notice appears in all copies. # It is provided "as is" without express or implied warranty. EXTRA_DIST = DrawingA.doc DrawingA.h DrawingAP.h Imakefile Makefile.std README noinst_PROGRAMS = demo_SOURCES = demo_LDADD = if ADD_DEMOXAW noinst_PROGRAMS += demo demo_SOURCES += demo.c DrawingA.c demo_LDADD += -L/usr/X11R6/lib -lXaw -lXm -lXmu -lXt -lX11 else EXTRA_DIST += demo.c DrawingA.c endif xball-3.1.0/X11/Xaw_d/Makefile.std000066400000000000000000000245761411065647700165120ustar00rootroot00000000000000# Makefile generated by imake - do not edit! # $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $ # # The cpp used on this machine replaces all newlines and multiple tabs and # spaces in a macro expansion with a single space. Imake tries to compensate # for this, but is not always successful. # ########################################################################### # Makefile generated from "Imake.tmpl" and # $XConsortium: Imake.tmpl,v 1.77 89/12/18 17:01:37 jim Exp $ # # Platform-specific parameters may be set in the appropriate .cf # configuration files. Site-wide parameters may be set in the file # site.def. Full rebuilds are recommended if any parameters are changed. # # If your C preprocessor doesn't define any unique symbols, you'll need # to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing # "make Makefile", "make Makefiles", or "make World"). # # If you absolutely can't get imake to work, you'll need to set the # variables at the top of each Makefile as well as the dependencies at the # bottom (makedepend will do this automatically). # ########################################################################### # platform-specific configuration parameters - edit sun.cf to change SYSLIBS=-lXt -lX11 MWM_DEFINES=-DSHAPE -DOPAQUE SYSLIBS=$(MTOOLKITSRC)/libXt.a $(XLIBSRC)/libX11.a # platform: $XConsortium: sun.cf,v 1.38 89/12/23 16:10:10 jim Exp $ # operating system: SunOS 4.1 ########################################################################### # site-specific configuration parameters - edit site.def to change # site: $XConsortium: site.def,v 1.21 89/12/06 11:46:50 jim Exp $ SHELL = /bin/sh TOP = . CURRENT_DIR = . AR = ar cq BOOTSTRAPCFLAGS = CC = cc COMPRESS = compress CPP = /lib/cpp $(STD_CPP_DEFINES) PREPROCESSCMD = cc -E $(STD_CPP_DEFINES) INSTALL = install LD = ld LINT = lint LINTLIBFLAG = -C LINTOPTS = -axz LN = ln -s MAKE = make MV = mv CP = cp RANLIB = ranlib RANLIBINSTFLAGS = RM = rm -f STD_INCLUDES = STD_CPP_DEFINES = STD_DEFINES = EXTRA_LOAD_FLAGS = EXTRA_LIBRARIES = TAGS = ctags SHAREDCODEDEF = -DSHAREDCODE SHLIBDEF = -DSUNSHLIB PROTO_DEFINES = INSTPGMFLAGS = INSTBINFLAGS = -m 0755 INSTUIDFLAGS = -m 4755 INSTLIBFLAGS = -m 0664 INSTINCFLAGS = -m 0444 INSTMANFLAGS = -m 0444 INSTDATFLAGS = -m 0444 INSTKMEMFLAGS = -m 4755 DESTDIR = TOP_INCLUDES = -I$(INCROOT) CDEBUGFLAGS = -O CCOPTIONS = -D_NO_PROTO -DSTRINGS_ALIGNED -DNO_REGEX -DNO_ISDIR -DUSE_RE_COMP -DUSE_GETWD COMPATFLAGS = ALLINCLUDES = $(STD_INCLUDES) $(TOP_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES) ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(DEFINES) $(COMPATFLAGS) CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES) LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES) LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) LDCOMBINEFLAGS = -X -r MACROFILE = sun.cf RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut IMAKE_DEFINES = IRULESRC = $(CONFIGDIR) IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES) ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \ $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \ $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES) ########################################################################### # X Window System Build Parameters # $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $ ########################################################################### # X Window System make variables; this need to be coordinated with rules # $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $ PATHSEP = / USRLIBDIR = $(DESTDIR)/usr/lib BINDIR = $(DESTDIR)/usr/bin/X11 INCROOT = $(DESTDIR)/usr/include BUILDINCROOT = $(TOP) BUILDINCDIR = $(BUILDINCROOT)/X11 BUILDINCTOP = .. INCDIR = $(INCROOT)/X11 ADMDIR = $(DESTDIR)/usr/adm LIBDIR = $(USRLIBDIR)/X11 CONFIGDIR = $(LIBDIR)/config LINTLIBDIR = $(USRLIBDIR)/lint FONTDIR = $(LIBDIR)/fonts XINITDIR = $(LIBDIR)/xinit XDMDIR = $(LIBDIR)/xdm AWMDIR = $(LIBDIR)/awm TWMDIR = $(LIBDIR)/twm GWMDIR = $(LIBDIR)/gwm MANPATH = $(DESTDIR)/usr/man MANSOURCEPATH = $(MANPATH)/man MANDIR = $(MANSOURCEPATH)n LIBMANDIR = $(MANSOURCEPATH)3 XAPPLOADDIR = $(LIBDIR)/app-defaults SOXLIBREV = 4.2 SOXTREV = 4.0 SOXAWREV = 4.0 SOOLDXREV = 4.0 SOXMUREV = 4.0 SOXEXTREV = 4.0 FONTCFLAGS = -t INSTAPPFLAGS = $(INSTDATFLAGS) IMAKE = imake DEPEND = makedepend RGB = rgb FONTC = bdftosnf MKFONTDIR = mkfontdir MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier.sh CONFIGSRC = $(TOP)/config CLIENTSRC = $(TOP)/clients DEMOSRC = $(TOP)/demos LIBSRC = $(TOP)/lib FONTSRC = $(TOP)/fonts INCLUDESRC = $(TOP)/X11 SERVERSRC = $(TOP)/server UTILSRC = $(TOP)/util SCRIPTSRC = $(UTILSRC)/scripts EXAMPLESRC = $(TOP)/examples CONTRIBSRC = $(TOP)/../contrib DOCSRC = $(TOP)/doc RGBSRC = $(TOP)/rgb DEPENDSRC = $(UTILSRC)/makedepend IMAKESRC = $(CONFIGSRC) XAUTHSRC = $(LIBSRC)/Xau XLIBSRC = $(LIBSRC)/X XMUSRC = $(LIBSRC)/Xmu TOOLKITSRC = $(LIBSRC)/Xt AWIDGETSRC = $(LIBSRC)/Xaw OLDXLIBSRC = $(LIBSRC)/oldX XDMCPLIBSRC = $(LIBSRC)/Xdmcp BDFTOSNFSRC = $(FONTSRC)/bdftosnf MKFONTDIRSRC = $(FONTSRC)/mkfontdir EXTENSIONSRC = $(TOP)/extensions DEPEXTENSIONLIB = $(USRLIBDIR)/libXext.a EXTENSIONLIB = -lXext DEPXLIB = $(DEPEXTENSIONLIB) XLIB = $(EXTENSIONLIB) -lX11 DEPXAUTHLIB = $(USRLIBDIR)/libXau.a XAUTHLIB = -lXau DEPXMULIB = XMULIB = -lXmu DEPOLDXLIB = OLDXLIB = -loldX DEPXTOOLLIB = XTOOLLIB = -lXt DEPXAWLIB = XAWLIB = -lXaw LINTEXTENSIONLIB = $(USRLIBDIR)/llib-lXext.ln LINTXLIB = $(USRLIBDIR)/llib-lX11.ln LINTXMU = $(USRLIBDIR)/llib-lXmu.ln LINTXTOOL = $(USRLIBDIR)/llib-lXt.ln LINTXAW = $(USRLIBDIR)/llib-lXaw.ln DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB) DEPLIBS1 = $(DEPLIBS) DEPLIBS2 = $(DEPLIBS) DEPLIBS3 = $(DEPLIBS) USRINCDIR = $(DESTDIR)/usr/include TESTSRC = $(TOP)/tests TESTSRCLIB = $(TESTSRC)/lib TESTSRCBIN = $(TESTSRC)/bin COMMONPP = $(TESTSRCBIN)/Commonpp TESTCOMSRC = $(TESTSRCLIB)/Common MTOOLKITSRC = $(LIBSRC)/Xt MWIDGETSRC = $(LIBSRC)/Xm MRESOURCESRC = $(LIBSRC)/Mrm UILSRC = $(CLIENTSRC)/uil UIL = $(UILSRC)/uil XMTOOLLIB = $(MTOOLKITSRC)/libXt.a XMLIB = $(MWIDGETSRC)/libXm.a MRESOURCELIB = $(MRESOURCESRC)/libMrm.a UILLIB = $(UILSRC)/libUil.a TESTCOMLIB = $(TESTCOMSRC)/libCommon.a LINTMRESOURCE = $(MRESOURCESRC)/libMrm.a LINTXMWIDGETLIB = $(MWIDGETSRC)/llib-l/Xm.ln LINTXMTOOL = $(MTOOLKITSRC)/llib-lXt.ln LINTUILLIB = $(UILSRC)/llib-lUil.ln DEPLIBS = DEPLIBS1 = $(DEPLIBS) DEPLIBS2 = $(DEPLIBS) DEPLIBS3 = $(DEPLIBS) ########################################################################### # Imake rules for building libraries, programs, scripts, and data files # rules: $XConsortium: Imake.rules,v 1.67 89/12/18 17:14:15 jim Exp $ ########################################################################### # start of Imakefile # # Imakefile for Xaw_d : Dave Nedde (daven@ivy.wpi.edu) # INCLUDES = -I../.. DEMO_SRCS = demo.c DEMO_OBJS = demo.o LOCAL_LIBRARIES = -lXaw_d LDOPTIONS = -L. LDLIBS = -lXaw_d -lXaw -lXt -lXmu -lXext -lX11 all:: libXaw_d.a libXaw_d.a: DrawingA.o $(RM) $@ $(AR) $@ DrawingA.o $(RANLIB) $@ SRCS = $(DEMO_SRCS) OBJS = $(DEMO_OBJS) PROGRAM = demo all:: demo demo: $(OBJS) $(DEPLIBS) $(RM) $@ $(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS) saber_demo: #load $(ALLDEFINES) $(SRCS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) osaber_demo: #load $(ALLDEFINES) $(OBJS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) install:: demo $(INSTALL) -c $(INSTPGMFLAGS) demo $(BINDIR) install.man:: demo.man $(INSTALL) -c $(INSTMANFLAGS) demo.man $(MANDIR)/demo.n depend:: $(DEPEND) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS) lint: $(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS) lint1: $(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS) clean:: $(RM) $(PROGRAM) DIST = \ X11 \ X11/Xaw_d \ X11/Xaw_d/DrawingA.c \ X11/Xaw_d/DrawingA.h \ X11/Xaw_d/DrawingAP.h \ X11/Xaw_d/DrawingA.doc \ X11/Xaw_d/Imakefile \ X11/Xaw_d/Makefile.std \ X11/Xaw_d/patchlevel.h \ X11/Xaw_d/demo.c \ X11/Xaw_d/README shar: ( cd ../.. ; makekit -s75k -p $(DIST) ; mv Part* X11/Xaw_d ) tar: ( cd ../.. ; tar cvf - $(DIST) | compress -v > X11/Xaw_d/xball.tar.Z ) ########################################################################### # common rules for all Makefiles - do not edit emptyrule:: clean:: $(RM_CMD) \#* Makefile:: -@if [ -f Makefile ]; then \ echo " $(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \ $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \ else exit 0; fi $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR) tags:: $(TAGS) -w *.[ch] $(TAGS) -xw *.[ch] > TAGS saber: #load $(ALLDEFINES) $(SRCS) osaber: #load $(ALLDEFINES) $(OBJS) ########################################################################### # empty rules for directories that do not have SUBDIRS - do not edit install:: @echo "install in $(CURRENT_DIR) done" install.man:: @echo "install.man in $(CURRENT_DIR) done" Makefiles:: includes:: ########################################################################### # dependencies generated by makedepend xball-3.1.0/X11/Xaw_d/README000066400000000000000000000011411411065647700151200ustar00rootroot00000000000000Drawing Area Widget and Demo The drawingArea widget is an Athena-style widget that has callbacks for expose, input, motion and resize events. Included is a demo program that uses the drawingArea widget. To compile and run: xmkmf make If you do not have xmkmf: make -f Makefile.std Copying: Copyright 1993, David Nedde Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is granted provided that the above copyright notice appears in all copies. It is provided "as is" without express or implied warranty. xball-3.1.0/X11/Xaw_d/demo.c000066400000000000000000000055471411065647700153460ustar00rootroot00000000000000/********************************************************************** * demo.c - Demo the drawing area widget * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ #include #include #include #include #include #include #include "DrawingAP.h" #include #include #include GC gc = 0; /*** Start of main program ***/ int main(argc, argv) int argc; char **argv; { XtAppContext app_context; Widget toplevel; /* The core widget */ Arg wargs[20]; /* Used to set widget resources */ int n; toplevel = XtAppInitialize(&app_context,"Demo", NULL, 0, (Cardinal *)&argc, argv, NULL, /*args*/(ArgList)NULL, /*num_args*/(Cardinal)0); setup_widgets( toplevel); XtRealizeWidget(toplevel); XtAppMainLoop(app_context); } static void redisplay_cb(w, closure, call_data) Widget w; XtPointer closure; XawDrawingAreaCallbackStruct * call_data; { int x = 10; int y = 10; int width = 30; int height = 30; if (gc == 0) { gc = XCreateGC(XtDisplay(w), XtWindow(w), 0, 0); XSetForeground(XtDisplay(w), gc, BlackPixel(XtDisplay(w), DefaultScreen(XtDisplay(w)))); } XDrawArc(XtDisplay(w), XtWindow(w), gc, x, y, width, height, 0, 360*64); XFillArc(XtDisplay(w), XtWindow(w), gc, x, y, width, height, 0, 360*64); } static void quit_cb(w, closure, call_data) Widget w; XtPointer closure; XtPointer call_data; { exit(0); } setup_widgets( toplevel ) Widget toplevel; { Widget button; Widget form_widget = XtCreateManagedWidget("form", formWidgetClass, toplevel, NULL,0); Widget canvas = XtVaCreateManagedWidget("canvas", drawingAreaWidgetClass, form_widget, XtNwidth, 200, XtNheight, 200, NULL); XtAddCallback(canvas,XtNexposeCallback,redisplay_cb, NULL); button = XtVaCreateManagedWidget("Quit", commandWidgetClass, form_widget, XtNfromVert, canvas, NULL); XtAddCallback(button,XtNcallback,quit_cb, NULL); } xball-3.1.0/XBall.ad000066400000000000000000000410271411065647700141440ustar00rootroot00000000000000!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! XBall.ad - xball resource file ! ! Copyright 1991, David Nedde ! ! Permission to use, copy, modify, and distribute this ! software and its documentation for any purpose and without fee ! is granted provided that the above copyright notice appears in all copies. ! It is provided 'as is' without express or implied warranty. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! XBall.delay: 100 XBall.gravity: 8 XBall.elasticity: 90 XBall.itemWidth: 10 XBall.itemHeight: 10 XBall.collide: False XBall.perpetual: False XBall.haltSim: False XBall.title: XBall - Written by David Nedde XBall*form.horizontalSpacing: 2 XBall*form.verticalSpacing: 2 XBall*form.width: 400 XBall*form.height: 400 XBall.allowShellResize: True XBall*resizable: True !!!!!!!!!! ! Menu Bar !!!!!!!!!! XBall*menuBar.rightAttachment: ATTACH_FORM XBall*menuBar.leftAttachment: ATTACH_FORM ! Athena resources XBall*menuBar*MenuButton.borderWidth: 0 XBall*menuBar.borderWidth: 1 XBall.formAW*translations: #override \n\ q: menu_action( quit) \n\ Ctrlq: menu_action( quit) \n\ Ctrlc: menu_action( quit) \n\ c: menu_action( clear) \n\ r: menu_action( randomize) \n\ s: menu_action( stepSim) \n\ p: menu_action( perpetual) \n\ b: menu_action( ballCollide) \n\ h: menu_action( haltSim) \n\ l: menu_action( loadBitmap) \n\ d: menu_action( runDemo) \n\ a: menu_action( about) \n\ ! File Submenu XBall*file.labelString: File XBall*file.label: File XBall*file.mnemonic: F XBall*about.labelString: About... XBall*about.label: About... A XBall*about.mnemonic: A XBall*about.accelerator: A XBall*about.acceleratorText: A XBall*runDemo.labelString: Run Demo... XBall*runDemo.label: Run Demo... D XBall*runDemo.mnemonic: D XBall*runDemo.accelerator: D XBall*runDemo.acceleratorText: D XBall*loadBitmap.labelString: Load Bitmap... XBall*loadBitmap.label: Load Bitmap... L XBall*loadBitmap.mnemonic: L XBall*loadBitmap.accelerator: L XBall*loadBitmap.acceleratorText: L XBall*quit.labelString: Quit XBall*quit.label: Quit Q XBall*quit.mnemonic: Q XBall*quit.accelerator: Q XBall*quit.acceleratorText: Q ! Action Submenu XBall*actions.labelString: Actions XBall*actions.label: Actions XBall*actions.mnemonic: A XBall*clear.labelString: Clear XBall*clear.label: Clear C XBall*clear.mnemonic: C XBall*clear.acceleratorText: C XBall*clear.accelerator: C XBall*randomize.labelString: Randomize XBall*randomize.label: Randomize R XBall*randomize.mnemonic: R XBall*randomize.acceleratorText:R XBall*randomize.accelerator: R XBall*stopDemo.labelString: Stop Demo XBall*stopDemo.label: Stop Demo XBall*stepSim.labelString: Step Simulation XBall*stepSim.label: Step Simulation S XBall*stepSim.mnemonic: S XBall*stepSim.acceleratorText: S XBall*stepSim.accelerator: S ! Options Submenu XBall*options.labelString: Options XBall*options.label: Options XBall*options.mnemonic: O XBall*perpetual.labelString: Perpetual XBall*perpetual.label: Perpetual P XBall*perpetual.mnemonic: P XBall*perpetual.acceleratorText: P XBall*perpetual.accelerator: P XBall*ballCollide.labelString: Ball Collide XBall*ballCollide.label: Ball Collide B XBall*ballCollide.mnemonic: B XBall*ballCollide.acceleratorText: B XBall*ballCollide.accelerator: B XBall*haltSim.labelString: Halt Simulation XBall*haltSim.label: Halt Simulation H XBall*haltSim.mnemonic: H XBall*haltSim.acceleratorText: H XBall*haltSim.accelerator: H ! Help Submenu XBall*help.labelString: Help XBall*help.label: Help XBall*help.mnemonic: H XBall*onAuthor.labelString: On Author... XBall*onAuthor.label: On Author... XBall*onMenus.labelString: On Menus... XBall*onMenus.label: On Menus... XBall*onScroll.labelString: On Scrollbars... XBall*onScroll.label: On Scrollbars... XBall*onButtons.labelString: On Buttons... XBall*onButtons.label: On Buttons... XBall*onDemos.labelString: On Demos... XBall*onDemos.label: On Demos... XBall*onParams.labelString: On Parameters... XBall*onParams.label: On Parameters... XBall*elasticityBar.topAttachment: ATTACH_WIDGET XBall*elasticityBar.topWidget: menuBar XBall*elasticityBar.leftAttachment: ATTACH_FORM XBall*elasticityBar.label.labelString: Elasticity XBall*elasticityBar.label.leftAttachment: ATTACH_FORM XBall*elasticityBar.label.leftOffset: 10 XBall*elasticityBar.label.topAttachment: ATTACH_FORM XBall*elasticityBar.label.bottomAttachment: ATTACH_FORM ! Athena resources XBall*elasticityBar.fromVert: menuBar XBall*elasticityBar.label.label: Elasticity XBall*elasticityBar.label.borderWidth: 0 XBall*elasticityBar.bar.width: 100 XBall*elasticityBar.bar.orientation: HORIZONTAL XBall*elasticityBar.bar.maximum: 100 XBall*elasticityBar.bar.minimum: 0 XBall*elasticityBar.bar.showValue: True ! Athena resources XBall*elasticityBar.bar.shown: 0.1 XBall*elasticityBar.borderWidth: 0 XBall*elasticityBar.label.borderWidth: 0 XBall*elasticityBar.feedback.borderWidth: 0 XBall*elasticityBar.defaultDistance: 0 XBall*gravityBar.label.labelString: Gravity XBall*gravityBar.label.leftAttachment: ATTACH_FORM XBall*gravityBar.label.topAttachment: ATTACH_FORM XBall*gravityBar.label.bottomAttachment: ATTACH_FORM ! Athena resources XBall*gravityBar.label.label: Gravity XBall*gravityBar.label.borderWidth: 0 XBall*gravityBar.leftAttachment: ATTACH_WIDGET XBall*gravityBar.leftWidget: elasticityBar XBall*gravityBar.leftOffset: 20 XBall*gravityBar.topAttachment: ATTACH_WIDGET XBall*gravityBar.topWidget: menuBar XBall*gravityBar.bar.width: 100 XBall*gravityBar.bar.orientation: HORIZONTAL XBall*gravityBar.bar.maximum: 100 XBall*gravityBar.bar.minimum: 0 XBall*gravityBar.bar.showValue: True ! Athena resources XBall*gravityBar.fromVert: menuBar XBall*gravityBar.horizDistance: 20 XBall*gravityBar.fromHoriz: elasticityBar XBall*gravityBar.bar.shown: 0.1 XBall*gravityBar.borderWidth: 0 XBall*gravityBar.label.borderWidth: 0 XBall*gravityBar.feedback.borderWidth: 0 XBall*gravityBar.defaultDistance: 0 XBall*canvas.resizable: True XBall*canvas.borderWidth: 1 XBall*canvas.topAttachment: ATTACH_WIDGET XBall*canvas.topWidget: gravityBar XBall*canvas.bottomAttachment: ATTACH_FORM XBall*canvas.rightAttachment: ATTACH_FORM XBall*canvas.leftAttachment: ATTACH_FORM ! Athena resources XBall*canvas.fromVert: gravityBar XBall*canvas.width: 400 XBall*canvas.height: 330 XBall*help_dialog_popup.title: XBall Information XBall*help_dialog_action_area.leftAttachment: ATTACH_FORM XBall*help_dialog_action_area.rightAttachment: ATTACH_FORM XBall*help_dialog_action_area.bottomAttachment: ATTACH_FORM XBall*help_dialog_action_area.close.labelString: Close XBall*help_dialog.close.label: Close XBall*help_dialog.separator.rightAttachment: ATTACH_FORM XBall*help_dialog.separator.leftAttachment: ATTACH_FORM XBall*help_dialog.separator.topOffset: 5 XBall*help_dialog.separator.bottomAttachment: ATTACH_WIDGET XBall*help_dialog.separator.bottomWidget: help_dialog_action_area XBall*help_dialog*help_text.rows: 12 XBall*help_dialog*help_text.columns: 60 ! Athena Resources XBall*help_dialog*help_textAW.displayCaret: False XBall*help_dialog*help_textAW.height: 150 XBall*help_dialog*help_textAW.width: 470 XBall*help_dialog*help_textAW.scrollHorizontal: WhenNeeded XBall*help_dialog*help_textAW.scrollVertical: WhenNeeded XBall*help_dialog*close.accelerators: \ Escape: set() notify() unset() \n\ Return: set() notify() unset() \n\ !!!!!!!!!!! ! Help text !!!!!!!!!!! ! ! Note that since fallback resources cannot handle \n in the text, ! a ~ is used to indicate a newline. ! !!!!!!!!!! XBall.pointerHelp: \ MOUSE BUTTON USAGE ~~~\ Button 1: o Hold down to create a ball. ~\ o Throw the ball by moving the mouse and ~\ letting go of button 1. ~\ o The ball will be going the speed of the ~\ pointer at release time. ~\ Button 2: o Hold down and move the mouse to create ~\ random velocity balls. ~\ Button 3: o Hold down and move the mouse to create ~\ zero velocity balls. \ XBall.menuHelp: \ PULLDOWN MENU USAGE~~~\ File~\ About... A description of the program and author~\ Run Demo... Allows you to execute XBall demo files~\ See 'Help On Demos' for demo file format~\ Load Bitmap... Load an X bitmap as a set of balls~\ Analogous Demo command: ~\ bitmap filename posx,posy~\ Quit Exits the program~~\ Actions~\ Clear Clear the screen of balls~\ Analogous Demo command: clear~\ Randomize Give each ball a random velocity~\ Analogous Demo command: ~\ randomize minx,maxx,miny,maxy~\ Stop Demo Stops the execution of a demo in progress~\ Enabled by the Run Demo... menu option~\ Analogous Demo command: stop~\ Step Simulation Perform one step of the Halted simulation~\ Enabled by the Halt Simulation menu option~~\ Options~\ Perpetual If toggled on, balls will live forever~\ Analogous Demo command: perpetual on|off~\ Command line option: -perpetual True|False~\ Ball Collide If on, balls will collide with one another~\ Analogous Demo command: collide on|off~\ Command line option: -collide True|False~~\ Help Simulation Stop the simulation. You can then step the~\ simulation using Step Simulation menu option~~\ Help~\ On Menus Help using the menu system~\ On Scrollbars Help on the Elasticity and Gravity bars~\ On Buttons Help on using the mouse buttons to create balls~\ On Demos Help on the Demo language and how to run demos~\ On Parameters Help with command-line arguments to xball \ XBall.scrollbarHelp: \ SCROLLBAR USAGE~~~\ Elasticity~\ o This scrollbar controls the balls' elasticity, or how~\ much energy is lost each time the balls hit the ground.~\ o Scrollbar to left: low elasticity (eggs)~\ o Scrollbar to right: high elasticity (superballs)~\ o Demo command: elasticity %d~\ o Command line options: -elasticity %d~~~\ Gravity~\ o This scrollbar controls the gravity, or how~\ much vertical velocity is added (subtracted)~\ from the balls for each iteration.~\ o Scrollbar to the left: Zero gravity (outer space)~\ o Scrollbar to the right: Large gravity (Jupiter)~\ o Demo command: gravity %d~\ o Command line options: -gravity %d \ XBall.demoHelp: \ DEMO FILE COMMANDS~~\ %s1, %s2... - Replace with a string~\ %d1, %d2... - Replace with an integer~~\ create %d1,%d2,%d3,%d4: Create a ball with x,y position~\ %d1,%d2 and an x & y velocity~\ of %d2,%d4~\ randomize %d1,%d2,%d3,%d4: randomize velocities of all ~\ balls on screen with:~\ a max negative x velocity of %d1,~\ a max positive x velocity of %d2,~\ a max negative y velocity of %d3,~\ a max positive y velocity of %d4,~\ load_bitmap %s %d1,%d2: load a bitmap file (where %s is~\ the file path) to an x,y position~\ of %d1,%d2 on the screen~\ set_velocity %s %d1,%d2: set ball velocities (%s is~\ relative or absolute) to the x ~\ and y velocities %d1,%d2~\ gravity %d: set gravity to %d~\ elasticity %d: set elasticity to %d~\ backwards %d: Run simulation backwards %d iterations~\ visible %s: Make ball display 'on' or 'off'~\ iterate %d: simulate for %d iterations~\ sleep %d: sleep for %d seconds~\ perpetual %s: toggle perpetual (%s is 'on' or 'off')~\ collide %s: toggle ball collision (%s is 'on' or 'off')~\ window_width %d: Change window width to %d~\ window_height %d: Change window height to %d~\ backwards %d: Iterate backwards %d steps~\ clear: delete all balls in window~\ create_random %d1,%d2: create %d1 random balls with a ~\ max velocity of %d2~\ exit or quit: quit the xball program if demo is not~\ interactive~\ stop: stop demo but leave program alive \ XBall.startupHelp: \ PROGRAM STARTUP PARAMETERS~~~\ Run xball -help for a list of command-line startup~\ parameters XBall.aboutString: \ XBall Version 0.3.0~~\ April 1993~~\ The Premire Ball Bouncing Software~~\ Allows you to throw 3-D balls around in a 2-D space.~~\ Author (Send bugs, comments, and interesting demos to):~\ David Nedde~\ daven@ivy.wpi.edu~\ Computer Science Department~\ Worcester Polytechnic Institute~\ Worcester, MA 01609~~\ Copyright 1990, 1993 David Nedde~\ Permission to use, copy, modify, and distribute this~\ software and its documentation for any purpose and~\ without fee is granted provided that the above~\ copyright notice appears in all copies. It is~\ provided \"as is\" without express or implied warranty. \ !!!!!!!!!!!!!!!!! ! Menu Definition !!!!!!!!!!!!!!!!! ! ! Format: ! pulldownName~ ! widgetName,widgetClass,menuCallbackName,optionalParams...~ ! ! The widgetName is referenced above to set the menu's label. ! ! Note that the pulldownName of 'help' is automatically used as the help ! pulldown. ! ! Avaliable WidgetClasses are: ! PushButton - push it and cause the action ! ToggleButton - Push it and toggle the state ! Separator - A line in the menu ! ! Avaliable menuCallbackNames available (none take optional parameters): ! runDemo - Lets user select a demo and run the demo ! loadBitmap - Lets user load a bitmap file ! quit - quits xball program ! clear - Clear all balls from the screen ! randomize - Randomize all balls from the screen ! stopDemo - Stop a demo in progress ! stepSim - Steps the simulation once (if simulation halted) ! perpetual - Toggles perpetual balls state ! ballCollide - Toggles colliding ball state ! haltSim - Toggles halting the simulation ! about - Displays help about the program ! onMenus - Displays help on the menus ! onScroll - Displays help on setting elasticity and gravity ! onButtons - Displays help on using the mouse buttons to create balls ! onDemos - Displays help on writing a demo ! onParams - Displays help on command-line arguments ! !!!!!!!!!!!!!!!!! XBall.menuDef: \ \ file~\ about,PushButton,about~\ runDemo,PushButton,runDemo~\ loadBitmap,PushButton,loadBitmap~\ separator,Separator~\ quit,PushButton,quit~\ actions~\ clear,PushButton,clear~\ randomize,PushButton,randomize~\ stopDemo,PushButton,stopDemo~\ stepSim,PushButton,stepSim~\ options~\ perpetual,ToggleButton,perpetual~\ ballCollide,ToggleButton,ballCollide~\ haltSim,ToggleButton,haltSim~\ help~\ about,PushButton,about~\ onMenus,PushButton,onMenus~\ onScroll,PushButton,onScroll~\ onButtons,PushButton,onButtons~\ onDemos,PushButton,onDemos~\ onParams,PushButton,onParams~\ xball-3.1.0/bootstrap000077500000000000000000000001671411065647700145770ustar00rootroot00000000000000#!/usr/bin/env bash # # Input files are Makefile.am and configure.ac # aclocal autoconf automake --gnu --add-missing xball-3.1.0/color_l.c000066400000000000000000000141761411065647700144360ustar00rootroot00000000000000/********************************************************************** * color_l.c - Color list object definition * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ /* System Headers */ #include #include #include #include /* Local headers */ #include "color_l.h" #include "misc.h" /* Functions */ static void get_rgb4_names(); /* Public object methods */ /* Constructs the color_list object */ color_list_type color_list__create(filename) char *filename; { color_list_type color_list; color_list = XtNew( color_list_struct); color_list->shaded_4_list = list__create(); get_rgb4_names( color_list, filename); return color_list; } /* Destroys the color_list object */ void color_list__destroy(color_list) color_list_type color_list; { color_type color; /* 2003-04-10 This doesn't work correctly, for ** now, I have just removed the code. It only gets ** called once, so we just waste a little memory. */ return; for (color = color_list__get_last( color_list); color != (color_type)0; color = color_list__get_prev( color_list)) { XtFree( color->name); XtFree( (char *)color); } list__destroy(color_list->shaded_4_list); XtFree( (char *)color_list); } /* Remove a specified node from the colored list */ color_type color_list__remove( color_list, ind) color_list_type color_list; int ind; { return (color_type)list__remove( color_list->shaded_4_list, ind); } /* Returns the number of nodes in the color list */ int color_list__get_count( color_list) color_list_type color_list; { return list__get_count( color_list->shaded_4_list); } /* Private object methods */ /********************************************************************** /* /* get_rgb4_colors - Extract the names of all colors from rgb.txt that /* have 4 shades of the same color. /* /* void get_rgb4_colors( color_list, passed_file_name) /* /* list_type color_list <- a list of found colors /* char * passed_file_name -> The path of the rgb.txt file. If this parameter /* is NULL, the RGB.TXT #define is used. /* /**********************************************************************/ static void get_rgb4_names(color_list, passed_file_name) color_list_type color_list; char *passed_file_name; { FILE *rgb; /* File pointer for rgb.txt */ char colorname[50]; /* Temp color name string */ int r,g,b; color_type color; color_type colors[SHADES]; int color_index; int shade_index; /*** Find the number of system colors */ if (!(rgb = fopen(passed_file_name, "r"))) { /* Problem opening file */ fprintf(stderr,"color_list::get_rgb4_names: Opening rgb.txt file: "); perror(passed_file_name); exit( EXIT_FAILURE); } /* Count the number of 4-shaded colors in the rgb.txt file */ while (4 == fscanf(rgb, "%d %d %d %49[^\n]\n", &r, &g, &b, colorname)) { color = XtNew( color_struct); color->r = r; color->g = g; color->b = b; color->name = XtNewString( colorname); color->last_char = strlen( color->name) - 1; list__add_end( color_list->shaded_4_list, (void *)color); } fclose(rgb); /* Now, remove all colors that do not have color, color2, color3, color4 in the list */ color_index = color_list__get_count( color_list) - 1; while (color_index >= SHADES - 1) { for (shade_index = 0; shade_index < SHADES; shade_index++) { colors[ shade_index] = color_list__get_cell( color_list, color_index - shade_index); if (colors[ shade_index]->name[ colors[ shade_index]->last_char] != '0' + SHADES - shade_index) { /* all 4 colors are not there */ int saveindex = color_index; color_index -= shade_index + 1; while( shade_index >= 0) { XtFree( colors[ shade_index]->name); XtFree( (char *)colors[ shade_index]); color_list__remove( color_list, saveindex + shade_index); shade_index--; } break; } } if (shade_index == SHADES) color_index -= SHADES; } /* delete any remaning colors... */ while (color_index >= 0) { color = color_list__get_cell( color_list, color_index); XtFree( color->name); XtFree( (char *)color); color_list__remove( color_list, color_index); color_index--; } } /* Gets the last node in the color list */ color_type color_list__get_last( color_list) color_list_type color_list; { return (color_type)list__get_last( color_list->shaded_4_list); } /* Get the previous node in the color list */ color_type color_list__get_prev( color_list) color_list_type color_list; { return (color_type)list__get_prev( color_list->shaded_4_list); } #ifdef NOT_USED char *color__get_shade( color, shade_num) color_type color; int shade_num; { color->name[ color->last_char] = '0' + shade_num; return color->name; } /********************************************************************** /* /* is_4_shaded_color - Returns True if the colorname passed is one of /* the colors that has 4 shades. /* /* Bool is_4_shaded_color( colorname) /* /* Bool return <- True if the colorname is a color with 4 shades /* char *colorname -> The colorname to check /* /**********************************************************************/ static Bool is_4_shaded_color( colorname) char *colorname; { /* A color with '4' as it's last character that isn't a /* grey color (e.g. grey14) is how we determine that we /* have found a color that has 4 shades. */ return (colorname[strlen(colorname)-1] == '4' && (strncmp(colorname,"grey",4) != 0 && strncmp(colorname,"gray",4) != 0)); } #endif xball-3.1.0/color_l.h000066400000000000000000000025031411065647700144320ustar00rootroot00000000000000/********************************************************************** * color_l.h - Color list object declaration * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ #ifndef __COLOR_L_H__ #define __COLOR_L_H__ #include "list.h" #define SHADES 4 /* Number of shades for colors in the rgb.txt file */ typedef struct { list_type shaded_4_list; } color_list_struct, *color_list_type; typedef struct { int r,g,b; char * name; int last_char; } color_struct, *color_type; color_list_type color_list__create(/*filename*/); void color_list__destroy(/*color_list*/); color_type color_list__remove(/* color_list, index*/); int color_list__get_count(/* color_list*/); color_type color_list__get_last(/* color_list*/); color_type color_list__get_prev(/* color_list*/); char * color__get_shade(/* color, shade_num*/); /* Inline functions */ #define color_list__get_cell(list, index) \ ((color_type)list__get_cell((list)->shaded_4_list, index)) #endif xball-3.1.0/configure.ac000066400000000000000000000036531411065647700151250ustar00rootroot00000000000000# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) m4_define([xball_version], [3.1.0]) AC_INIT([xball],[xball_version],[packages@qa.debian.org], [xball],[https://packages.debian.org/sid/xball]) AM_INIT_AUTOMAKE([foreign -Wall]) AC_DEFINE(MOTIF, HAVE_MOTIF) AC_SUBST([XBALL_VERSION],[xball_version]) AC_PROG_CC AC_PROG_RANLIB AC_PROG_INSTALL # Required development include files (and associated libraries) AC_MSG_CHECKING([Check for X11 and Motif required developer header files]) AC_CHECK_HEADER([X11/Intrinsic.h],[],[AC_MSG_FAILURE([ERROR: Missing X11/Intrinsic.h, Please install Developer version of libxt-devel or lib64xt-devel],[1])]) AC_CHECK_HEADER([Xm/Xm.h],[],[AC_MSG_FAILURE([ERROR: Missing Xm/Xmu.h, Please install Developer version of libxmotif-devel or lib64motif-devel],[1])]) AC_CHECK_HEADER([X11/Xmu/Converters.h],[],[AC_MSG_FAILURE([ERROR: Missing X11/Xmu/Converters.h, Please install Developer version of libxmu-devel or lib64xmu-devel],[1])]) # Build optional demo in directory ./X11/Xaw/ AC_ARG_ENABLE([Xaw], [AS_HELP_STRING([--enable-Xaw], [Build optional Xaw demo program @<:@default=check@:>@])], [],[enable_Xaw=check]) makeXaw=no if test "x$enable_Xaw" != xno ; then AC_CHECK_HEADER([X11/Xaw/Form.h],[makeXaw=yes], [if test "x$enable_Xaw" != xcheck; then AC_MSG_FAILURE( [ERROR: Missing X11/Xaw/Form.h, Please install Developer version of libxaw-devel or lib64xaw-devel],[1]) fi ]) fi AM_CONDITIONAL([ADD_DEMOXAW],[test x${makeXaw} = xyes]) #update-mime-database /usr/local/share/mime/ AC_CONFIG_FILES([Makefile xball.pc desktop/Makefile X11/Xaw_d/Makefile]) AC_OUTPUT AC_MSG_NOTICE([ Configuration: Source code location ${srcdir} Build code location ${builddir} Destination prefix ${prefix} Build extra Xaw demo ${enable_Xaw} ${makeXaw} Compiler ${CC} Config CFLAGS "${CFLAGS}" ]) xball-3.1.0/demo.c000066400000000000000000000335411411065647700137260ustar00rootroot00000000000000/********************************************************************** * demo.c - defines the demo object * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ /* System Headers */ #include #include #include #ifdef MOTIF #include #endif /* Local headers */ #include "demo.h" #include "names.h" #include "intf.h" #include "miscx.h" #include /* Structures */ typedef struct { char *demo_file; } app_data,*app_data_ptr; static app_data res_data; static XtResource resources[] = { { "demoFile", "DemoFile", XtRString, sizeof(char *), XtOffset( app_data_ptr, demo_file), XtRString, NULL} }; /* Functions */ static void demo_start(/* demo*/); /* Public object methods */ /* Create the demo object */ demo_type demo__create( w, menu, gravity, elasticity, file_sel, items, room) Widget w; menu_type menu; scrollbar_type gravity; scrollbar_type elasticity; file_sel_type file_sel; items_type items; room_type room; { demo_type demo = XtNew( demo_struct_type); demo->menu = menu; demo->gravity = gravity; demo->elasticity = elasticity; demo->file_sel = file_sel; demo->items = items; demo->room = room; XtGetApplicationResources(get_toplevel(w), (XtPointer)&res_data, resources, XtNumber(resources), (ArgList)NULL,(Cardinal)0); if (res_data.demo_file != 0) { demo->file_name = XtNewString( res_data.demo_file); demo_start( demo); demo->interactive = False; } else { demo->file_name = (char *)0; demo->file_ptr = (FILE *)0; demo->iterations = 0; demo->interactive = True; /* The 'Stop Demo' menu item is greyed since demo is not running */ menu__set_sensitivity( demo->menu, STOP_DEMO, False); } return demo; } /* Destroy the demo object */ void demo__destroy( demo) demo_type demo; { demo__stop( demo); XtFree( (char *)demo); } /* A menu callback (mcb) which queries the user for a filename, and then */ /* loads and runs the selected demo. */ void demo__run_mcb( w, demo, call_data, extra) Widget w; demo_type demo; XtPointer call_data; char * extra; { char *file_name = file_sel__display( demo->file_sel, "Load Demo"); if (file_name != (char *)0) { demo__stop(demo); /* Stop a demo if one is in progress */ demo->file_name = XtNewString(file_name); demo_start( demo); } } /* A menu callback (mcb) which stops the currently running demo */ void demo__stop_mcb( w, demo, call_data, extra) Widget w; demo_type demo; XtPointer call_data; char * extra; { demo__stop( demo); } /* If a demo is running, stops it by reseting the menu sensitivity, and cleaning up the demo file */ void demo__stop( demo) demo_type demo; { if (!demo__running(demo)) return; /* The 'Stop Demo' menu item is greyed since menu is not running */ menu__set_sensitivity( demo->menu, STOP_DEMO, False); /* Set the file_name member to NULL to tell background_processing() that * there is not a demo in progress */ if (demo->file_name != (char *)0) { XtFree( demo->file_name); demo->file_name = (char *)0; } /* Close the demo file */ if (demo->file_ptr != (FILE *)0) { fclose(demo->file_ptr); demo->file_ptr = (FILE *)0; } } /* Returns True if a demo is currently running */ Bool demo__running(demo) demo_type demo; { return demo->file_name != (char *)0; } /* demo language: (have 'quit demo' button) create %d,%d,%d,%d: create a ball with x,y, x & y velocity randomize: randomize velocities of all balls on screen load_bitmap %s %d,%d: load a bitmap to an x,y on the screen set_velocity %s %d,%d: set ball velocities (rel or abs) gravity %d: set gravity to something elasticity %d: set elasticity to something iterate %d: pause for n iterations perpetual on|off: turn perpetual balls on or off collide on|off: turn ball collision on or off item_width %d: change item width item_height %d: change item height window_width %d: Change window width window_height %d: Change window height clear: clear screen create_random %d,%d: create count random balls with a velocity_factor label %s: A label goto %s: Goto label exit: quit the xball program quit: quit the xball program stop: stop demo but leave program alive */ #define MAX_LEN 100 #define is_command(comm) (strncmp(comm,in_line,strlen(comm)) == 0) /* Performs one iteration of the currently running demo */ void demo__process(demo) demo_type demo; { char in_line[MAX_LEN]; /* The current demo file line read in */ /* Used to extract parameters from in_line */ char str[MAX_LEN]; int x,y; int x_vel,y_vel; int width,height; int count; int velocity; item_type item; /* Do not run the demo until the item static data has been initialized */ if (!item__initted()) return; if (demo->iterations > 0) { /* Pause for another iteration */ demo->iterations--; return; } /* Read the next line of the demo */ while (fgets(in_line,MAX_LEN,demo->file_ptr) != (char *)NULL) { if (in_line[0] == '#' || in_line[0] == '\n') { /* Comment */ continue; } else if (is_command("create_random")) { /* create_random %d1,%d2 */ /* create %d1 random balls with a max velocity of %d2 */ sscanf(in_line,"create_random %d,%d", &count, &velocity); for (x = 0; x < count; x++) { items__new_item(demo->items, rand_range(intf2int(room__get_left_wall( demo->room)), intf2int(room__get_right_wall( demo->room))), rand_range(intf2int(room__get_ceiling( demo->room)), intf2int(room__get_floor( demo->room))), rand_range( -velocity, velocity), rand_range( -velocity, velocity)); } } else if (is_command("create")) { /* create %d1,%d2,%d3,%d4 */ /* Create a ball with x,y position %d1,%d2 and an x & y velocity of %d2,%d4 */ sscanf(in_line,"create %d,%d,%d,%d\n", &x,&y, &x_vel,&y_vel); items__new_item(demo->items, x, y, x_vel, y_vel); } else if (is_command("randomize")) { int min_x,max_x,min_y,max_y; /* randomize %d,%d,%d,%d */ /* randomize velocities of all balls on screen with a max velocity of %d */ min_x = max_x = min_y = max_y = 0; sscanf(in_line,"randomize %d,%d,%d,%d", &min_x,&max_x,&min_y,&max_y); for (item = items__get_first( demo->items); item != (item_type)0; item = items__get_next( demo->items)) { item__randomize( item, min_x, max_x, min_y, max_y); } } else if (is_command("load_bitmap")) { /* load_bitmap %s %d1,%d2 */ /* load a bitmap file (where %s is the file path) to an x,y position of %d1,%d2 on the screen */ sscanf(in_line,"load_bitmap %s %d,%d", str,&x,&y); room__load_bitmap(demo->room, str, x, y); } else if (is_command("set_velocity")) { /* set_velocity %s %d1,%d2 */ /* set ball velocities (%s is relative or absolute) to the x and y velocities %d1,%d2 */ sscanf(in_line,"set_velocity %s %d,%d", str,&x_vel,&y_vel); if (strncmp(str,"rel",3) == 0) { for (item = items__get_first( demo->items); item != (item_type)0; item = items__get_next( demo->items)) { item__set_x_vel( item, item__get_x_vel(item) + x_vel); item__set_y_vel( item, item__get_y_vel(item) + y_vel); } } else if (strncmp(str,"abs",3) == 0) { for (item = items__get_first( demo->items); item != (item_type)0; item = items__get_next( demo->items)) { item__set_x_vel( item, x_vel); item__set_y_vel( item, y_vel); } room__flush( demo->room); } else fprintf(stderr, "Unrecognized set_velocity mode '%s'.\nValid modes: 'abs' or 'rel'.\n", str); } else if (is_command("gravity")) { /* gravity %d */ /* set gravity to %d */ int gravity_value; sscanf(in_line,"gravity %d", &gravity_value); scrollbar__set_value( demo->gravity, gravity_value); } else if (is_command("elasticity")) { /* elasticity %d */ /* set elasticity to %d */ int elasticity_value; sscanf(in_line,"elasticity %d", &elasticity_value); scrollbar__set_value( demo->elasticity, elasticity_value); } else if (is_command("iterate")) { /* iterate %d */ /* pause for %d iterations */ sscanf(in_line,"iterate %d", &demo->iterations); if (demo->iterations) /* We are pausing - exit read loop */ return; } else if (is_command("perpetual")) { /* perpetual %s */ /* toggle perpetual (%s is 'on' or 'off') */ sscanf(in_line,"%*s %s", str); menu__set_toggle( demo->menu, PERPETUAL, strcmp("on",str) == 0); } else if (is_command("collide")) { /* collide %s */ /* toggle ball collision (%s is 'on' or 'off') */ sscanf(in_line,"%*s %s", str); menu__set_toggle( demo->menu, BALL_COLLIDE, strcmp("on",str) == 0); } else #if 0 if (is_command("item_size")) { /* item_width %d */ /* change item size to %d,%d */ sscanf(in_line,"item_size %d,%d", &width, &height); items__set_visible( demo->items, False); item__set_size( width, height); items__set_visible( demo->items, True); } else #endif if (is_command("window_width")) { /* window_width %d */ /* Change window width to %d */ sscanf(in_line,"window_width %d", &width); room__set_width( demo->room, width); } else if (is_command("window_height")) { /* window_height %d */ /* Change window height to %d */ sscanf(in_line,"window_height %d", &height); room__set_height( demo->room, (Dimension)height); } else if (is_command("clear")) { /* clear */ /* delete all balls in window */ items__destroy_all( demo->items); } #if 0 else if (is_command("goto") || is_command("label")) { /* goto %s */ /* Goto label %s */ /* label %s */ /* The label %s */ printf("Not implemented\n"); } #endif else if (is_command("exit") || is_command("quit")) { /* exit */ /* quit */ /* quit the xball program */ if (!demo->interactive) { demo__stop( demo); exit(0); } } else if (is_command("stop")) { /* stop */ /* stop demo but leave program alive */ demo__stop( demo); return; } else if (is_command("backwards")) { sscanf(in_line,"backwards %d", &count); items__move_items_backwards( demo->items, demo->room, count); } else if (is_command("visible")) { sscanf(in_line,"visible %s", str); items__set_visible( demo->items, strcmp("on",str) == 0); } else if (is_command("sleep")) { sscanf(in_line,"sleep %u", &count); sleep( (unsigned)count); } else { /* Could not recognize demo command */ in_line[strlen(in_line)-1] = '\0'; /* Kill newline */ printf("Unrecognized command '%s'\n", in_line); } } if (feof(demo->file_ptr)) { /* At the end of the demo file. Stop processing the demo */ demo__stop( demo); } } /* Private object methods */ /* Loads the currently specified demo program and sensitises the stop demo menu */ static void demo_start( demo) demo_type demo; { demo->iterations = 0; /* Start up the demo file */ if ((demo->file_ptr = fopen(demo->file_name, "r")) == (FILE *)0) { /* Problem opening demo file */ fprintf(stderr,"Opening demo file: "); perror( demo->file_name); XtFree( demo->file_name); demo->file_name = (char *)0; return; } else { menu__set_sensitivity( demo->menu, STOP_DEMO, True); } } xball-3.1.0/demo.h000066400000000000000000000034421411065647700137300ustar00rootroot00000000000000/********************************************************************** * demo.h - declares the demo object * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ #ifndef __DEMO_H__ #define __DEMO_H__ #include #include #include "menu.h" #include "scrollbar.h" #include "file_sel.h" #include "items.h" #include "room.h" typedef struct { Bool interactive; /* Demo 'exit' will not exit program if interactive is True */ scrollbar_type gravity; /* Gravity scrollbar */ scrollbar_type elasticity; /* Elasticity acrollbar */ menu_type menu; file_sel_type file_sel; /* To query user for demo file */ items_type items; room_type room; FILE * file_ptr; /* The file pointer for the current demo file */ char * file_name; /* The name of the current demo file */ unsigned iterations; /* Number of iterations we are currently pausing */ } demo_struct_type, *demo_type; /* Public methods */ demo_type demo__create(/* w, menu, gravity, elasticity, file_sel, items, room*/); void demo__destroy(/* demo*/); void demo__run_mcb(/* w, demo, call_data, extra*/); void demo__stop_mcb(/* w, demo, call_data, extra*/); void demo__stop(/* demo*/); Bool demo__running(/*demo*/); void demo__process(/*demo*/); /* Inline functions */ #define demo__set_interactive( demo, inter) ((demo)->interactive = (inter)) #endif xball-3.1.0/demo1.xball.in000066400000000000000000000005561411065647700152740ustar00rootroot00000000000000# Load a bitmap, randomize, and let fall through once. collide off perpetual off load_bitmap @xball@/xball.xbm 10,10 #load_bitmap /usr/include/X11/bitmaps/left_ptr 0,0 gravity 0 iterate 50 sleep 1 gravity 10 randomize -10,10,-10,10 perpetual on iterate 30 elasticity 80 gravity 30 iterate 200 perpetual off iterate 200 exit xball-3.1.0/demo10.xball000066400000000000000000000141261411065647700147450ustar00rootroot00000000000000# Draw word and then drop it # This demo was made by uncommenting the printf in item.c: item__create. # Then, run xball, redirecting output to your demo file. # Set the gravity to 0, then draw something with mouse button 3. # Quit xball, modify the demo a little, and you are dome gravity 0 elasticity 60 window_width 650 create 33,60,0,0 iterate 1 create 33,82,0,0 iterate 1 create 35,108,0,0 iterate 1 create 37,132,0,0 iterate 1 create 39,150,0,0 iterate 1 create 39,164,0,0 iterate 1 create 40,176,0,0 iterate 1 create 41,179,0,0 iterate 1 create 34,58,0,0 iterate 1 create 40,56,0,0 iterate 1 create 62,55,0,0 iterate 1 create 82,55,0,0 iterate 1 create 92,58,0,0 iterate 1 create 108,70,0,0 iterate 1 create 124,86,0,0 iterate 1 create 136,102,0,0 iterate 1 create 139,122,0,0 iterate 1 create 136,140,0,0 iterate 1 create 128,160,0,0 iterate 1 create 122,176,0,0 iterate 1 create 114,186,0,0 iterate 1 create 98,192,0,0 iterate 1 create 82,195,0,0 iterate 1 create 72,196,0,0 iterate 1 create 69,197,0,0 iterate 10 create 147,183,0,0 iterate 10 create 218,185,0,0 iterate 1 create 217,177,0,0 iterate 1 create 217,165,0,0 iterate 1 create 217,153,0,0 iterate 1 create 218,141,0,0 iterate 1 create 218,127,0,0 iterate 1 create 219,115,0,0 iterate 1 create 219,101,0,0 iterate 1 create 218,85,0,0 iterate 1 create 217,73,0,0 iterate 1 create 217,65,0,0 iterate 1 create 218,57,0,0 iterate 1 create 221,53,0,0 iterate 1 create 225,51,0,0 iterate 1 create 231,52,0,0 iterate 1 create 239,60,0,0 iterate 1 create 243,74,0,0 iterate 1 create 247,90,0,0 iterate 1 create 250,106,0,0 iterate 1 create 252,120,0,0 iterate 1 create 255,134,0,0 iterate 1 create 258,146,0,0 iterate 1 create 260,156,0,0 iterate 1 create 263,164,0,0 iterate 1 create 265,167,0,0 iterate 1 create 267,171,0,0 iterate 1 create 269,173,0,0 iterate 1 create 271,175,0,0 iterate 1 create 272,176,0,0 iterate 1 create 274,173,0,0 iterate 1 create 276,163,0,0 iterate 1 create 278,147,0,0 iterate 1 create 278,133,0,0 iterate 1 create 279,123,0,0 iterate 1 create 278,113,0,0 iterate 1 create 276,101,0,0 iterate 1 create 275,91,0,0 iterate 1 create 275,81,0,0 iterate 1 create 275,73,0,0 iterate 1 create 276,69,0,0 iterate 1 create 277,67,0,0 iterate 1 create 278,63,0,0 iterate 10 create 321,134,0,0 iterate 1 create 327,135,0,0 iterate 1 create 337,133,0,0 iterate 1 create 345,131,0,0 iterate 1 create 351,128,0,0 iterate 1 create 353,124,0,0 iterate 1 create 354,118,0,0 iterate 1 create 350,108,0,0 iterate 1 create 348,98,0,0 iterate 1 create 344,95,0,0 iterate 1 create 341,96,0,0 iterate 1 create 333,97,0,0 iterate 1 create 327,100,0,0 iterate 1 create 317,106,0,0 iterate 1 create 309,116,0,0 iterate 1 create 307,128,0,0 iterate 1 create 308,140,0,0 iterate 1 create 312,150,0,0 iterate 1 create 315,160,0,0 iterate 1 create 323,166,0,0 iterate 1 create 335,168,0,0 iterate 1 create 355,170,0,0 iterate 1 create 365,170,0,0 iterate 1 create 365,168,0,0 iterate 1 create 368,168,0,0 iterate 10 create 425,110,0,0 iterate 1 create 419,112,0,0 iterate 1 create 409,116,0,0 iterate 1 create 401,119,0,0 iterate 1 create 395,125,0,0 iterate 1 create 392,131,0,0 iterate 1 create 390,139,0,0 iterate 1 create 392,145,0,0 iterate 1 create 396,153,0,0 iterate 1 create 404,161,0,0 iterate 1 create 407,163,0,0 iterate 1 create 411,165,0,0 iterate 1 create 431,169,0,0 iterate 1 create 447,173,0,0 iterate 1 create 440,57,0,0 iterate 1 create 439,63,0,0 iterate 1 create 437,73,0,0 iterate 1 create 436,85,0,0 iterate 1 create 437,95,0,0 iterate 1 create 438,107,0,0 iterate 1 create 440,119,0,0 iterate 1 create 442,133,0,0 iterate 1 create 445,145,0,0 iterate 1 create 446,153,0,0 iterate 1 create 449,161,0,0 iterate 1 create 453,169,0,0 iterate 1 create 457,173,0,0 iterate 1 create 461,176,0,0 iterate 10 create 521,102,0,0 iterate 1 create 519,103,0,0 iterate 1 create 515,104,0,0 iterate 1 create 509,106,0,0 iterate 1 create 501,109,0,0 iterate 1 create 495,113,0,0 iterate 1 create 489,119,0,0 iterate 1 create 486,129,0,0 iterate 1 create 483,139,0,0 iterate 1 create 482,149,0,0 iterate 1 create 485,155,0,0 iterate 1 create 491,158,0,0 iterate 1 create 503,161,0,0 iterate 1 create 519,163,0,0 iterate 1 create 527,164,0,0 iterate 1 create 531,162,0,0 iterate 1 create 533,56,0,0 iterate 1 create 531,66,0,0 iterate 1 create 529,74,0,0 iterate 1 create 528,82,0,0 iterate 1 create 526,92,0,0 iterate 1 create 527,104,0,0 iterate 1 create 528,114,0,0 iterate 1 create 530,124,0,0 iterate 1 create 532,134,0,0 iterate 1 create 534,144,0,0 iterate 1 create 538,152,0,0 iterate 1 create 541,155,0,0 iterate 1 create 542,155,0,0 iterate 1 create 570,113,0,0 iterate 1 create 582,115,0,0 iterate 1 create 594,115,0,0 iterate 1 create 608,114,0,0 iterate 1 create 618,111,0,0 iterate 1 create 621,107,0,0 iterate 1 create 623,103,0,0 iterate 1 create 621,95,0,0 iterate 1 create 619,89,0,0 iterate 1 create 616,87,0,0 iterate 1 create 610,85,0,0 iterate 1 create 602,85,0,0 iterate 1 create 598,86,0,0 iterate 1 create 595,89,0,0 iterate 1 create 587,97,0,0 iterate 1 create 579,105,0,0 iterate 1 create 573,113,0,0 iterate 1 create 571,121,0,0 iterate 1 create 570,125,0,0 iterate 1 create 570,131,0,0 iterate 1 create 572,135,0,0 iterate 1 create 575,138,0,0 iterate 1 create 583,142,0,0 iterate 1 create 591,145,0,0 iterate 1 create 605,146,0,0 iterate 1 create 619,148,0,0 iterate 1 create 631,149,0,0 iterate 1 create 637,148,0,0 iterate 1 create 640,147,0,0 iterate 1 create 652,155,0,0 iterate 1 create 75,241,0,0 iterate 1 create 119,237,0,0 iterate 1 create 167,233,0,0 iterate 1 create 213,227,0,0 iterate 1 create 253,224,0,0 iterate 1 create 287,223,0,0 iterate 1 create 319,225,0,0 iterate 1 create 337,231,0,0 iterate 1 create 337,233,0,0 iterate 1 create 334,245,0,0 iterate 1 create 331,259,0,0 iterate 1 create 333,261,0,0 iterate 1 create 336,262,0,0 iterate 1 create 346,264,0,0 iterate 1 create 368,266,0,0 iterate 1 create 396,266,0,0 iterate 1 create 430,264,0,0 iterate 1 create 468,260,0,0 iterate 1 create 510,257,0,0 iterate 1 create 564,257,0,0 iterate 1 create 596,254,0,0 iterate 1 create 618,251,0,0 iterate 1 create 656,253,0,0 iterate 1 create 657,253,0,0 iterate 30 set_velocity rel 0,-7 gravity 10 iterate 150 exit xball-3.1.0/demo11.xball000066400000000000000000000016421411065647700147450ustar00rootroot00000000000000collide on create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 184,25,0,0 create 14,53,1,0 iterate 300 exit xball-3.1.0/demo12.xball.in000066400000000000000000000004001411065647700153420ustar00rootroot00000000000000 load_bitmap @xball@/xball-x.xbm 10,10 iterate 10 load_bitmap @xball@/xball-b.xbm 90,10 iterate 10 load_bitmap @xball@/xball-a.xbm 170,10 iterate 10 load_bitmap @xball@/xball-l.xbm 250,10 iterate 10 load_bitmap @xball@/xball-l.xbm 310,10 iterate 200 exit xball-3.1.0/demo13.xball.in000066400000000000000000000004131411065647700153470ustar00rootroot00000000000000elasticity 50 load_bitmap @xball@/xball-x.xbm 10,10 iterate 20 load_bitmap @xball@/xball-b.xbm 10,10 iterate 20 load_bitmap @xball@/xball-a.xbm 10,10 iterate 20 load_bitmap @xball@/xball-l.xbm 10,10 iterate 20 load_bitmap @xball@/xball-l.xbm 10,10 iterate 200 exit xball-3.1.0/demo14.xball.in000066400000000000000000000002361411065647700153530ustar00rootroot00000000000000elasticity 90 load_bitmap @xball@/man.xbm 10,10 iterate 60 load_bitmap @xball@/man.xbm 160,10 iterate 60 load_bitmap @xball@/man.xbm 310,10 iterate 400 exit xball-3.1.0/demo2.xball.in000066400000000000000000000005711411065647700152720ustar00rootroot00000000000000# Put up xball bitmap with random balls not colliding in zero gravity # Turn on collide so bitmap image gets destroyed # turn on gravity collide off elasticity 100 load_bitmap @xball@/xball.xbm 0,0 gravity 0 create_random 30,15 iterate 160 elasticity 50 collide on iterate 50 gravity 40 iterate 10 gravity 50 iterate 10 gravity 60 iterate 10 gravity 70 iterate 100 exit xball-3.1.0/demo3.xball.in000066400000000000000000000004241411065647700152700ustar00rootroot00000000000000# Load bitmap with all balls having the same velocity # After they bounce down, have them fall through # once collide off load_bitmap @xball@/xball.xbm 0,0 set_velocity abs 3,-10 gravity 10 elasticity 85 perpetual on iterate 700 perpetual off gravity 20 iterate 200 exit xball-3.1.0/demo4.xball.in000066400000000000000000000004351411065647700152730ustar00rootroot00000000000000# have random balls form xball visible off collide off elasticity 100 gravity 0 load_bitmap @xball@/xball.xbm 0,0 randomize -10,10,-10,10 backwards 100 visible on iterate 99 set_velocity abs 0,0 gravity 0 sleep 1 randomize -10,10,-13,7 gravity 10 elasticity 85 iterate 300 exit xball-3.1.0/demo5.xball.in000066400000000000000000000004611411065647700152730ustar00rootroot00000000000000# Backwards with gravity into xball bitmap visible off collide off elasticity 100 load_bitmap @xball@/xball.xbm 0,-60 gravity 10 randomize -3,3,0,3 #set_velocity rel 0,1 iterate 20 visible on backwards 21 set_velocity abs 0,0 gravity 0 sleep 1 randomize 10 gravity 20 elasticity 85 iterate 200 exit xball-3.1.0/demo6.xball.in000066400000000000000000000004301411065647700152700ustar00rootroot00000000000000# Xball word collides with itself horizontally load_bitmap @xball@/xball.xbm 0,0 #load_bitmap /usr/include/X11/bitmaps/left_ptr 0,0 collide off set_velocity abs 10,0 gravity 0 elasticity 100 iterate 100 collide on iterate 150 elasticity 80 gravity 30 iterate 300 exit xball-3.1.0/demo7.xball000066400000000000000000000002211411065647700146620ustar00rootroot00000000000000# Tall window of raining balls window_width 190 window_height 700 elasticity 80 collide off create_random 50,30 perpetual on iterate 500 exit xball-3.1.0/demo8.xball000066400000000000000000000017131411065647700146720ustar00rootroot00000000000000collide on create 200,20,0,0 iterate 40 create 200,20,0,0 iterate 80 create 200,20,0,0 iterate 40 create 200,20,0,0 iterate 40 create 200,20,0,0 iterate 20 create 200,20,0,0 iterate 20 create 200,20,0,0 iterate 10 create 200,20,0,0 iterate 10 create 200,20,0,0 iterate 5 create 200,20,0,0 iterate 5 create 200,20,0,0 iterate 5 create 200,20,0,0 iterate 5 create 200,20,0,0 iterate 5 create 200,20,0,0 iterate 5 create 200,20,0,0 iterate 5 create 200,20,0,0 iterate 5 create 200,20,0,0 iterate 5 create 200,20,0,0 iterate 5 create 200,20,0,0 iterate 5 create 200,20,0,0 iterate 5 create 200,20,0,0 iterate 5 create 200,20,0,0 iterate 5 create 200,20,0,0 iterate 5 create 200,20,0,0 iterate 5 create 200,20,0,0 iterate 5 create 200,20,0,0 create 200,20,0,0 iterate 5 create 200,20,0,0 iterate 5 create 200,20,0,0 iterate 5 create 200,20,0,0 iterate 5 create 200,20,0,0 iterate 5 create 200,20,0,0 iterate 5 create 200,20,0,0 iterate 50 create 0,0,4,0 iterate 400 exit xball-3.1.0/demo9.xball000066400000000000000000000024101411065647700146660ustar00rootroot00000000000000collide off gravity 10 elasticity 90 window_width 400 create 10,20,0,0 iterate 3 create 20,20,0,0 iterate 3 create 30,20,0,0 iterate 3 create 40,20,0,0 iterate 3 create 50,20,0,0 iterate 3 create 60,20,0,0 iterate 3 create 70,20,0,0 iterate 3 create 80,20,0,0 iterate 3 create 90,20,0,0 iterate 3 create 100,20,0,0 iterate 3 create 110,20,0,0 iterate 3 create 120,20,0,0 iterate 3 create 130,20,0,0 iterate 3 create 140,20,0,0 iterate 3 create 150,20,0,0 iterate 3 create 160,20,0,0 iterate 3 create 170,20,0,0 iterate 3 create 180,20,0,0 iterate 3 create 190,20,0,0 iterate 3 create 200,20,0,0 iterate 3 create 210,20,0,0 iterate 3 create 220,20,0,0 iterate 3 create 230,20,0,0 iterate 3 create 240,20,0,0 iterate 3 create 250,20,0,0 iterate 3 create 260,20,0,0 iterate 3 create 270,20,0,0 iterate 3 create 280,20,0,0 iterate 3 create 290,20,0,0 iterate 3 create 300,20,0,0 iterate 3 create 310,20,0,0 iterate 3 create 320,20,0,0 iterate 3 create 330,20,0,0 iterate 3 create 340,20,0,0 iterate 3 create 350,20,0,0 iterate 3 create 360,20,0,0 iterate 3 create 370,20,0,0 iterate 3 create 380,20,0,0 iterate 3 create 390,20,0,0 iterate 60 create 0,310,3,0 perpetual off iterate 40 iterate 300 perpetual on iterate 300 perpetual off collide on create 5,20,0,0 iterate 200 exit xball-3.1.0/depcomp000066400000000000000000000330521411065647700142050ustar00rootroot00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects # Copyright 1999, 2000, 2003 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # `libtool' can also be set to `yes' or `no'. if test -z "$depfile"; then base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'` dir=`echo "$object" | sed 's,/.*$,/,'` if test "$dir" = "$object"; then dir= fi # FIXME: should be _deps on DOS. depfile="$dir.deps/$base" fi tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' ' ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as ## well. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> $depfile echo >> $depfile # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> $depfile else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts `$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` tmpdepfile="$stripped.u" if test "$libtool" = yes; then "$@" -Wc,-M else "$@" -M fi stat=$? if test -f "$tmpdepfile"; then : else stripped=`echo "$stripped" | sed 's,^.*/,,'` tmpdepfile="$stripped.u" fi if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi if test -f "$tmpdepfile"; then outname="$stripped.o" # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; icc) # Intel's C compiler understands `-MD -MF file'. However on # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c # ICC 7.0 will fill foo.d with something like # foo.o: sub/foo.c # foo.o: sub/foo.h # which is wrong. We want: # sub/foo.o: sub/foo.c # sub/foo.o: sub/foo.h # sub/foo.c: # sub/foo.h: # ICC 7.1 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using \ : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1="$dir.libs/$base.lo.d" tmpdepfile2="$dir.libs/$base.d" "$@" -Wc,-MD else tmpdepfile1="$dir$base.o.d" tmpdepfile2="$dir$base.d" "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi if test -f "$tmpdepfile1"; then tmpdepfile="$tmpdepfile1" else tmpdepfile="$tmpdepfile2" fi if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test $1 != '--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for `:' # in the target name. This is to cope with DOS-style filenames: # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. "$@" $dashmflag | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test $1 != '--mode=compile'; do shift done shift fi # X makedepend shift cleared=no for arg in "$@"; do case $cleared in no) set ""; shift cleared=yes ;; esac case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix="`echo $object | sed 's/^.*\././'`" touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test $1 != '--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E | sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o, # because we must use -o when running libtool. "$@" || exit $? IFS=" " for arg do case "$arg" in "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 xball-3.1.0/desktop/000077500000000000000000000000001411065647700143015ustar00rootroot00000000000000xball-3.1.0/desktop/128x128/000077500000000000000000000000001411065647700152365ustar00rootroot00000000000000xball-3.1.0/desktop/128x128/xball.png000066400000000000000000000030221411065647700170430ustar00rootroot00000000000000‰PNG  IHDR€€ôà‘ùPLTE3f™Ì˙3333f3™3Ì3˙ff3fff™fÌf˙™™3™f™™™Ì™˙ÌÌ3Ìf̙ÌÌÌ˙˙˙3˙f˙™˙Ì˙˙3333f3™3Ì3˙3333333f33™33Ì33˙3f3f33ff3f™3fÌ3f˙3™3™33™f3™™3™Ì3™˙3Ì3Ì33Ìf3̙3ÌÌ3Ì˙3˙3˙33˙f3˙™3˙Ì3˙˙ff3fff™fÌf˙f3f33f3ff3™f3Ìf3˙ffff3fffff™ffÌff˙f™f™3f™ff™™f™Ìf™˙fÌfÌ3fÌff̙fÌÌfÌ˙f˙f˙3f˙ff˙™f˙Ìf˙˙™™3™f™™™Ì™˙™3™33™3f™3™™3̙3˙™f™f3™ff™f™™f̙f˙™™™™3™™f™™™™™Ì™™˙™Ì™Ì3™Ìf™Ì™™Ì̙Ì˙™˙™˙3™˙f™˙™™˙̙˙˙ÌÌ3Ìf̙ÌÌÌ˙Ì3Ì33Ì3fÌ3™Ì3ÌÌ3˙ÌfÌf3ÌffÌf™ÌfÌÌf˙̙̙3̙f̙™Ì™Ì̙˙ÌÌÌÌ3ÌÌfÌ̙ÌÌÌÌÌ˙Ì˙Ì˙3Ì˙fÌ˙™Ì˙ÌÌ˙˙˙˙3˙f˙™˙Ì˙˙˙3˙33˙3f˙3™˙3Ì˙3˙˙f˙f3˙ff˙f™˙fÌ˙f˙˙™˙™3˙™f˙™™˙™Ì˙™˙˙Ì˙Ì3˙Ìf˙̙˙ÌÌ˙Ì˙˙˙˙˙3˙˙f˙˙™˙˙Ì˙˙˙ez|tRNS˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙əj pHYs  Äc ?Ú%tEXtdate:create2017-09-13T05:09:14+02:00[÷<%tEXtdate:modify2017-09-13T05:09:14+02:00mO€JIDATxœíĜÉ1 DQò!ò!òp@U4%Œ,Öĵü½ƒËöxs*²Y8ġ4Xşx@ ğKIŽ.Y?›@?€²ÈŻS"´Ĝ_@mp´eŭ˘úèPÑa•lŽZ_ó,ö[cô âĠ ‹Ûk7àŬĜ\[ó´yiÚÜĉaс`>@s²‹ €9şFs˜à?LŒ Q-7$cʏΠùʅ` €-,+lŭ#€Ú˘vc,Ùf³ĝ"°*À<.ž 6@Ÿĝ•²è B­ö?€ñ–èÑI–E!€&µd’Ŭ÷0àY´Yù…  }€żtm>ڈü°fÌ ¸Ġ `m€6k!îêĝ7à Á+Z_UÎüIENDB`‚xball-3.1.0/desktop/256x256/000077500000000000000000000000001411065647700152425ustar00rootroot00000000000000xball-3.1.0/desktop/256x256/xball.png000066400000000000000000000034221411065647700170530ustar00rootroot00000000000000‰PNG  IHDRkĴXTPLTE3f™Ì˙3333f3™3Ì3˙ff3fff™fÌf˙™™3™f™™™Ì™˙ÌÌ3Ìf̙ÌÌÌ˙˙˙3˙f˙™˙Ì˙˙3333f3™3Ì3˙3333333f33™33Ì33˙3f3f33ff3f™3fÌ3f˙3™3™33™f3™™3™Ì3™˙3Ì3Ì33Ìf3̙3ÌÌ3Ì˙3˙3˙33˙f3˙™3˙Ì3˙˙ff3fff™fÌf˙f3f33f3ff3™f3Ìf3˙ffff3fffff™ffÌff˙f™f™3f™ff™™f™Ìf™˙fÌfÌ3fÌff̙fÌÌfÌ˙f˙f˙3f˙ff˙™f˙Ìf˙˙™™3™f™™™Ì™˙™3™33™3f™3™™3̙3˙™f™f3™ff™f™™f̙f˙™™™™3™™f™™™™™Ì™™˙™Ì™Ì3™Ìf™Ì™™Ì̙Ì˙™˙™˙3™˙f™˙™™˙̙˙˙ÌÌ3Ìf̙ÌÌÌ˙Ì3Ì33Ì3fÌ3™Ì3ÌÌ3˙ÌfÌf3ÌffÌf™ÌfÌÌf˙̙̙3̙f̙™Ì™Ì̙˙ÌÌÌÌ3ÌÌfÌ̙ÌÌÌÌÌ˙Ì˙Ì˙3Ì˙fÌ˙™Ì˙ÌÌ˙˙˙˙3˙f˙™˙Ì˙˙˙3˙33˙3f˙3™˙3Ì˙3˙˙f˙f3˙ff˙f™˙fÌ˙f˙˙™˙™3˙™f˙™™˙™Ì˙™˙˙Ì˙Ì3˙Ìf˙̙˙ÌÌ˙Ì˙˙˙˙˙3˙˙f˙˙™˙˙Ì˙˙˙ez|tRNS˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙əj pHYs  Äc ?Ú%tEXtdate:create2017-09-13T05:09:14+02:00[÷<%tEXtdate:modify2017-09-13T05:09:14+02:00mO€JIDATxœíÛ˕Â0 PúĦúĦú™)g6h#ĈǎC>vî[BäHwċ#fnż•ÜOu>Àtƒ—(ä‚Ç;ŻÎüÒ{^)Ñ'à{µAΞ  |çèAzĜ /,ÖRZ„ÔêûDc”µÑÇÒsóDâûüÀ~bíà5ˆ{Jì°u˘Ż Ì ĉ Q^ĉˆäĊKô;ŭE(\ ÀĝùÂÓZ úÈ?|Ôê< İĠŽˆEF ġüx>˙AdmA8 Î)ŭ£c+@î/>œ .,1pœß ëZëÇDz_„€ J?x”ŠóZŸï}`{€ĝŝž ~  7€íò@şÏÎ yԞ{Ĥ {ʃXšV°ÖúÒ9€óĴMô•*/8rĜ˙¸.Àn à³p=€y9şÑ­¨ÌQœ¸.ÀÖÏiˆ;Ì0IENDB`‚xball-3.1.0/desktop/32x32/000077500000000000000000000000001411065647700150625ustar00rootroot00000000000000xball-3.1.0/desktop/32x32/xball.png000066400000000000000000000017331411065647700166760ustar00rootroot00000000000000‰PNG  IHDR D¤ŠĈgAMAħ üa cHRMz&€„ú€èu0ê`:˜pœşQ<ƒPLTEVVXÛÛÛĠĠĠÍÍÍÄÄÄÉÉÉïïïúúúöööáááÔÔÔĜĜĜżżżrtt˙˙˙ĞĞĞ›››ĉĉĉÀÀÀòòòËË˳³³ÈÈÈ  Ÿ   pppwwwŭŭŭñññ§§§eeeRRR]]]˘˘˘ċċċžžž333444yyyŒíí톆†...###@@@‹‹ŒŜŜŜqqq>>>YYY“““ŻŻŻŬŬŬ“—˜ÏÏÏèè荑’êêꖖ–zzzİİİ÷÷÷çççlllQQQvvvùùùÑÑÑUUUĦĦĦCCCÚÚÚ°°°III\\\uuuĊĊĊ)));;;ĝĝĝ777<< c #D4D4D4", ", c #D8D8D8", "' c #BFBFBF", ") c #727474", "! c #131313", "~ c #080808", "{ c #FFFFFF", "] c #ABABAB", "^ c #9B9B9B", "/ c #E6E6E6", "( c #C0C0C0", "_ c #F2F2F2", ": c #CBCBCB", "< c #B3B3B3", "[ c #C8C8C8", "} c #F0F0F0", "| c #A0A09F", "1 c #7F7F7F", "2 c #A0A0A0", "3 c #707070", "4 c #777777", "5 c #FDFDFD", "6 c #F1F1F1", "7 c #A7A7A7", "8 c #656565", "9 c #525252", "0 c #5D5D5D", "a c #A2A2A2", "b c #E5E5E5", "c c #9E9E9E", "d c #333333", "e c #343434", "f c #797979", "g c #E3E3E3", "h c #8C8F90", "i c #EDEDED", "j c #868686", "k c #2E2E2E", "l c #232323", "m c #404040", "n c #8B8B8C", "o c #DEDEDE", "p c #717171", "q c #3E3E3E", "r c #595959", "s c #AEAEAE", "t c #939393", "u c #AFAFAF", "v c #DDDDDD", "w c #939798", "x c #CFCFCF", "y c #E8E8E8", "z c #8D9192", "A c #EAEAEA", "B c #969696", "C c #7A7A7A", "D c #A9A9A9", "E c #F7F7F7", "F c #E7E7E7", "G c #6C6C6C", "H c #515151", "I c #767676", "J c #F9F9F9", "K c #D1D1D1", "L c #555555", "M c #A1A1A1", "N c #434343", "O c #DADADA", "P c #B0B0B0", "Q c #1F1F1F", "R c #494949", "S c #5C5C5C", "T c #141414", "U c #191919", "V c #757575", "W c #C5C5C5", "X c #292929", "Y c #161616", "Z c #3B3B3B", "` c #F8F8F8", " . c #373737", ".. c #3C3C3C", "+. c #545454", "@. c #101010", "#. c #0F0F0F", "$. c #585858", "%. c #C6C6C6", "&. c #696969", "*. c #BABABA", "=. c #919191", "-. c #4D4D4D", ";. c #BCBCBC", ">. c #6E6E6E", ",. c #6F6F6F", "'. c #929292", "). c #414141", "!. c #3F3F3F", "~. c #7E7E7E", "{. c #9F9F9F", "]. c #B2B2B2", "^. c #505050", "/. c #B1B1B1", "(. c #616161", "_. c #646464", ":. c #AAAAAA", "<. c #CECECE", "[. c #EBEBEB", "}. c #D6D6D6", "|. c #8B8B8B", "1. c #F5F5F5", "2. c #D2D2D2", "3. c #B4B4B4", "4. c #CCCCCC", "5. c #898989", "6. c #E2E2E2", "7. c #535353", "8. c #070808", " . . . . . . . . . . . . . . . . . . . . . . . . ", " . . . . . . . . . . . . . . . . . . . . . . . . . . . ", " . . + @ @ # $ % & @ * = - ; > , , , , , > & ' ) ! ~ . . ", " . . ' { { { { { { { { { { { { { { { { { { { { { { { . . . ", " . . ] { { { { { { { { { { { { { { { { { { { { { { { . . . ", " . . ^ { { { { { / ( ( / { { { { { { _ : < [ } { { { . . . ", " . . | { { { { { ( 1 1 ( { { { { { { / 2 3 4 ( 5 { { . . . ", " . . | { { { { { ( 1 1 ( { { { { { { 6 7 8 9 0 a b { . . . ", " . . ^ { { { { { / ( ( / { { { { { { { / c 9 d e f g . . . ", " . . h { { { { { { { { { { { { { { { { { i j k l m < . . . ", " . . n { { { { { { { { { { { { { { { { { { o p q r s . . . ", " . . t { { { { { { { { { { { { { { { { { { { g < u v . . . ", " . . ^ { { { { { { { { { { { { { { { { { { { { { { { . . . ", " . . w { { { { { { { { { { { { { { { = o x y { { { { . . . ", " . . z { { { { { { { { { { { { { { { A B C D { { { { . . . ", " . . z { { { { { { { { E F F E { { { F G H I J { { { . . . ", " . . z { { { { { { { { K 3 L M { { { - p N 0 O { { { . . . ", " . . z { { { { { { { { P k Q R { { { { S T U V { { { . . . ", " . . z { { { { { { { { W X Y Z ` { { { .~ ~ ..{ { { . . . ", " . . z { { { { { { { { 6 r d H ; { { { +.@.#.$.{ { { . . . ", " . . h { { { %.3 &.*.{ { =.-.&.$ { { { ;.>.,.' { { { . . . ", " . . h { { { '.).!.~.{ { {.0 0 *.{ { { { { { { { { { . . . ", " . . h { { { ].L ^.a { { /.(._.:.{ { { { { { { { { { . . . ", " . . h { { { * <.: [.{ { }.=.|.' { { { { { { { { { { . . . ", " . . n { { { { { { { { { 1.O 2.[.{ { { { { O 3.4.1.{ . . . ", " . . n { { { { { { { { { { { { { { { { { { {.4 5.6.{ . . . ", " . . ) { { { { { { { { { { { { { { { { { { {.4 5.6.{ . . . ", " . . 7.{ { { { { { { { { { { { { { { { { { O 3.4.1.{ . . . ", " . . . . . . . . . . . . . . . . . . . . . . . . ! 8.. . . ", " . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", " . . . . . . . . . . . . . . . . . . . . . . . . . . . ", " . . . . . . . . . . . . . . . . . . . . . . . . . "}; xball-3.1.0/desktop/64x64/000077500000000000000000000000001411065647700150745ustar00rootroot00000000000000xball-3.1.0/desktop/64x64/xball.png000066400000000000000000000027021411065647700167050ustar00rootroot00000000000000‰PNG  IHDR@@·ìPLTE3f™Ì˙3333f3™3Ì3˙ff3fff™fÌf˙™™3™f™™™Ì™˙ÌÌ3Ìf̙ÌÌÌ˙˙˙3˙f˙™˙Ì˙˙3333f3™3Ì3˙3333333f33™33Ì33˙3f3f33ff3f™3fÌ3f˙3™3™33™f3™™3™Ì3™˙3Ì3Ì33Ìf3̙3ÌÌ3Ì˙3˙3˙33˙f3˙™3˙Ì3˙˙ff3fff™fÌf˙f3f33f3ff3™f3Ìf3˙ffff3fffff™ffÌff˙f™f™3f™ff™™f™Ìf™˙fÌfÌ3fÌff̙fÌÌfÌ˙f˙f˙3f˙ff˙™f˙Ìf˙˙™™3™f™™™Ì™˙™3™33™3f™3™™3̙3˙™f™f3™ff™f™™f̙f˙™™™™3™™f™™™™™Ì™™˙™Ì™Ì3™Ìf™Ì™™Ì̙Ì˙™˙™˙3™˙f™˙™™˙̙˙˙ÌÌ3Ìf̙ÌÌÌ˙Ì3Ì33Ì3fÌ3™Ì3ÌÌ3˙ÌfÌf3ÌffÌf™ÌfÌÌf˙̙̙3̙f̙™Ì™Ì̙˙ÌÌÌÌ3ÌÌfÌ̙ÌÌÌÌÌ˙Ì˙Ì˙3Ì˙fÌ˙™Ì˙ÌÌ˙˙˙˙3˙f˙™˙Ì˙˙˙3˙33˙3f˙3™˙3Ì˙3˙˙f˙f3˙ff˙f™˙fÌ˙f˙˙™˙™3˙™f˙™™˙™Ì˙™˙˙Ì˙Ì3˙Ìf˙̙˙ÌÌ˙Ì˙˙˙˙˙3˙˙f˙˙™˙˙Ì˙˙˙ez|tRNS˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙əj pHYs  Äc ?Ú%tEXtdate:create2017-09-13T05:09:14+02:00[÷<%tEXtdate:modify2017-09-13T05:09:14+02:00mO€úIDATX…Í×Ûƒ `öaöÉ>ìӎcc¤!Û-‰˙SĦòıŜWÂ`í6£ÍÙ`!,ò:“o’’PšôĤû€g<Œ²Žkuœ*œV Ôµ~@Jĝ.p?ˆDÄO×~ žñpxħ ^ /N¤PâÈĊċàBĉĞ<z˜-ÚV¸žqזĥ (.x]鄐sŒ!0€%.[í° wa¨y˜ÉF É£•€Œ&À ¸ŝmÔ[nàt˜ÛuÚcž_´Ĵ€6´ħvĵâLĵ]>ĝ3ˆËÀ\ĵñѵĝıÎWğUà––‘û†tŭIENDB`‚xball-3.1.0/desktop/Makefile.am000066400000000000000000000027221411065647700163400ustar00rootroot00000000000000# Makefile.am - build XBall freedesktop files # # Copyright 2021, Jose Da Silva # # Permission to use, copy, modify, and distribute this software # and its documentation for any purpose and without fee is granted # provided that the above copyright notice appears in all copies. # It is provided "as is" without express or implied warranty. # Where .desktop files go. desktopdir = ${datarootdir}/applications desktop_DATA = xball.desktop # Where appdata and metainfo xml files go appdatadir = ${datarootdir}/appdata appdata_DATA = xball.appdata.xml metainfodir = ${datarootdir}/metainfo metainfo_DATA = xball.metainfo.xml # Where MIME data goes (Support for .xball files, for instance). mimedir = ${datarootdir}/mime mimepackagesdir = ${datarootdir}/mime/packages mimepackages_DATA = xball.xml #update-mime-database ${mimedir} ICONSDIR = ${datarootdir}/icons HICOLORDIR = ${datarootdir}/icons/hicolor hicolor32x32dir = $(HICOLORDIR)/32x32/apps hicolor64x64dir = $(HICOLORDIR)/64x64/apps hicolor128x128dir = $(HICOLORDIR)/128x128/apps hicolor256x256dir = $(HICOLORDIR)/256x256/apps hicolor32x32_DATA = 32x32/xball.png hicolor64x64_DATA = 64x64/xball.png hicolor128x128_DATA = 128x128/xball.png hicolor256x256_DATA = 256x256/xball.png deskpixsdir = ${datarootdir}/pixmaps deskpixs_DATA = 32x32/xball.xpm 32x32/xball.png EXTRA_DIST = xball.desktop xball.appdata.xml xball.metainfo.xml xball.xml \ 32x32/xball.xpm 32x32/xball.png 64x64/xball.png 128x128/xball.png \ 256x256/xball.png xball-3.1.0/desktop/xball.appdata.xml000066400000000000000000000016001411065647700175330ustar00rootroot00000000000000 xball.desktop CC0-1.0 XBall

This program simulates bouncing balls in a window. You create the balls in a variety of ways, and can set the gravity, elasticity, whether balls collide or not, etc.

Young children enjoy watching the balls bounce around the screen and are fascinated by the program. This is an ideal program for teaching rudimentary mouse skills to very young children.

To run the 14 included demo scripts, open a console terminal and type 'run_demos' to see each demo one after the next.

https://tracker.debian.org/pkg/xball
xball-3.1.0/desktop/xball.desktop000066400000000000000000000007531411065647700170030ustar00rootroot00000000000000[Desktop Entry] Version=1.0 Name=XBall GenericName=X11 ball simulation Comment=Simulate bouncing balls in a window Comment[de]=Simuliere springende B¤lle in einem Fenster Comment[fr]=Simulez des balles rebondissantes dans une fenŞtre simulİe Comment[pt]=Simular bolas rebatidas em uma janela simulada TryExec=xball Exec=xball -demo %U Icon=xball StartupNotify=true Terminal=false Type=Application Categories=Game;Simulation; MimeType=application/x-xball Keywords=balls;X;window;bouncing; xball-3.1.0/desktop/xball.metainfo.xml000066400000000000000000000034321411065647700177300ustar00rootroot00000000000000 xball xball.desktop CC0-1.0 XBall Simulates bouncing balls in a window

This program simulates bouncing balls in a window. You create the balls in a variety of ways, and can set the gravity, elasticity, whether balls collide or not, etc.

Software features user-configurable menus, and a DrawingArea widget for use with other Athena widgets.

All resources are contained within the program as fallback resources, so, it is not strictly neccessary to install the app-defaults file, except that when using Athena widgets, since the keyboard accelertors will not work if the app-defauls file is not installed.

To run the included demos, open a console terminal and type 'run_demos'.

https://tracker.debian.org/pkg/xball https://packages.debian.org/unstable/xball https://bugs.debian.org/xball https://www.debian.org/donations packages@qa.debian.org ISC David Nedde https://screenshots.debian.net/shrine/screenshot/8154/simage/thumb-d5b1a6d95759fdf917ba37251d9d98cc.png
xball-3.1.0/desktop/xball.xml000066400000000000000000000005151411065647700161260ustar00rootroot00000000000000 XBall script xball-3.1.0/fallback.h000066400000000000000000000423101411065647700145400ustar00rootroot00000000000000/* fallback.h generated by gen_fallback from XBall.ad - do not edit! */ "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", "! XBall.ad - xball resource file", "!", "! Copyright 1991, David Nedde", "!", "! Permission to use, copy, modify, and distribute this", "! software and its documentation for any purpose and without fee", "! is granted provided that the above copyright notice appears in all copies.", "! It is provided 'as is' without express or implied warranty.", "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", "", "XBall.title: XBall - Written by David Nedde", "", "XBall*form.horizontalSpacing: 2", "XBall*form.verticalSpacing: 2", "XBall*form.width: 400", "XBall*form.height: 400", "XBall.allowShellResize: True", "XBall*resizable: True", "", "", "!!!!!!!!!!", "! Menu Bar", "!!!!!!!!!!", "", "XBall*menuBar.rightAttachment: ATTACH_FORM", "XBall*menuBar.leftAttachment: ATTACH_FORM", "! Athena resources", "XBall*menuBar*MenuButton.borderWidth: 0", "XBall*menuBar.borderWidth: 1", "XBall.formAW*translations: #override \n\ q: menu_action( quit) \n\ Ctrlq: menu_action( quit) \n\ Ctrlc: menu_action( quit) \n\ c: menu_action( clear) \n\ r: menu_action( randomize) \n\ s: menu_action( stepSim) \n\ p: menu_action( perpetual) \n\ b: menu_action( ballCollide) \n\ h: menu_action( haltSim) \n\ l: menu_action( loadBitmap) \n\ d: menu_action( runDemo) \n\ a: menu_action( about) \n\ ", "", "", "! File Submenu", "XBall*file.labelString: File", "XBall*file.label: File", "XBall*file.mnemonic: F", "XBall*about.labelString: About...", "XBall*about.label: About... A", "XBall*about.mnemonic: A", "XBall*about.accelerator: A", "XBall*about.acceleratorText: A", "XBall*runDemo.labelString: Run Demo...", "XBall*runDemo.label: Run Demo... D", "XBall*runDemo.mnemonic: D", "XBall*runDemo.accelerator: D", "XBall*runDemo.acceleratorText: D", "XBall*loadBitmap.labelString: Load Bitmap...", "XBall*loadBitmap.label: Load Bitmap... L", "XBall*loadBitmap.mnemonic: L", "XBall*loadBitmap.accelerator: L", "XBall*loadBitmap.acceleratorText: L", "XBall*quit.labelString: Quit", "XBall*quit.label: Quit Q", "XBall*quit.mnemonic: Q", "XBall*quit.accelerator: Q", "XBall*quit.acceleratorText: Q", "", "! Action Submenu", "XBall*actions.labelString: Actions", "XBall*actions.label: Actions", "XBall*actions.mnemonic: A", "XBall*clear.labelString: Clear", "XBall*clear.label: Clear C", "XBall*clear.mnemonic: C", "XBall*clear.acceleratorText: C", "XBall*clear.accelerator: C", "XBall*randomize.labelString: Randomize", "XBall*randomize.label: Randomize R", "XBall*randomize.mnemonic: R", "XBall*randomize.acceleratorText:R", "XBall*randomize.accelerator: R", "XBall*stopDemo.labelString: Stop Demo", "XBall*stopDemo.label: Stop Demo", "XBall*stepSim.labelString: Step Simulation", "XBall*stepSim.label: Step Simulation S", "XBall*stepSim.mnemonic: S", "XBall*stepSim.acceleratorText: S", "XBall*stepSim.accelerator: S", "", "! Options Submenu", "XBall*options.labelString: Options", "XBall*options.label: Options", "XBall*options.mnemonic: O", "XBall*perpetual.labelString: Perpetual", "XBall*perpetual.label: Perpetual P", "XBall*perpetual.mnemonic: P", "XBall*perpetual.acceleratorText: P", "XBall*perpetual.accelerator: P", "XBall*ballCollide.labelString: Ball Collide", "XBall*ballCollide.label: Ball Collide B", "XBall*ballCollide.mnemonic: B", "XBall*ballCollide.acceleratorText: B", "XBall*ballCollide.accelerator: B", "XBall*haltSim.labelString: Halt Simulation", "XBall*haltSim.label: Halt Simulation H", "XBall*haltSim.mnemonic: H", "XBall*haltSim.acceleratorText: H", "XBall*haltSim.accelerator: H", "", "! Help Submenu", "XBall*help.labelString: Help", "XBall*help.label: Help", "XBall*help.mnemonic: H", "XBall*onAuthor.labelString: On Author...", "XBall*onAuthor.label: On Author...", "XBall*onMenus.labelString: On Menus...", "XBall*onMenus.label: On Menus...", "XBall*onScroll.labelString: On Scrollbars...", "XBall*onScroll.label: On Scrollbars...", "XBall*onButtons.labelString: On Buttons...", "XBall*onButtons.label: On Buttons...", "XBall*onDemos.labelString: On Demos...", "XBall*onDemos.label: On Demos...", "XBall*onParams.labelString: On Parameters...", "XBall*onParams.label: On Parameters...", "", "", "XBall*elasticityBar.topAttachment: ATTACH_WIDGET", "XBall*elasticityBar.topWidget: menuBar", "XBall*elasticityBar.leftAttachment: ATTACH_FORM", "", "XBall*elasticityBar.label.labelString: Elasticity", "XBall*elasticityBar.label.leftAttachment: ATTACH_FORM", "XBall*elasticityBar.label.leftOffset: 10", "XBall*elasticityBar.label.topAttachment: ATTACH_FORM", "XBall*elasticityBar.label.bottomAttachment: ATTACH_FORM", "! Athena resources", "XBall*elasticityBar.fromVert: menuBar", "XBall*elasticityBar.label.label: Elasticity", "XBall*elasticityBar.label.borderWidth: 0", "", "XBall*elasticityBar.bar.width: 100", "XBall*elasticityBar.bar.orientation: HORIZONTAL", "XBall*elasticityBar.bar.maximum: 100", "XBall*elasticityBar.bar.minimum: 0", "XBall*elasticityBar.bar.showValue: True", "! Athena resources", "XBall*elasticityBar.bar.shown: 0.1", "XBall*elasticityBar.borderWidth: 0", "XBall*elasticityBar.label.borderWidth: 0", "XBall*elasticityBar.feedback.borderWidth: 0", "XBall*elasticityBar.defaultDistance: 0", "", "", "", "XBall*gravityBar.label.labelString: Gravity", "XBall*gravityBar.label.leftAttachment: ATTACH_FORM", "XBall*gravityBar.label.topAttachment: ATTACH_FORM", "XBall*gravityBar.label.bottomAttachment: ATTACH_FORM", "! Athena resources", "XBall*gravityBar.label.label: Gravity", "XBall*gravityBar.label.borderWidth: 0", "", "XBall*gravityBar.leftAttachment: ATTACH_WIDGET", "XBall*gravityBar.leftWidget: elasticityBar", "XBall*gravityBar.leftOffset: 20", "XBall*gravityBar.topAttachment: ATTACH_WIDGET", "XBall*gravityBar.topWidget: menuBar", "XBall*gravityBar.bar.width: 100", "XBall*gravityBar.bar.orientation: HORIZONTAL", "XBall*gravityBar.bar.maximum: 100", "XBall*gravityBar.bar.minimum: 0", "XBall*gravityBar.bar.showValue: True", "! Athena resources", "XBall*gravityBar.fromVert: menuBar", "XBall*gravityBar.horizDistance: 20", "XBall*gravityBar.fromHoriz: elasticityBar", "XBall*gravityBar.bar.shown: 0.1", "XBall*gravityBar.borderWidth: 0", "XBall*gravityBar.label.borderWidth: 0", "XBall*gravityBar.feedback.borderWidth: 0", "XBall*gravityBar.defaultDistance: 0", "", "XBall*canvas.resizable: True", "XBall*canvas.borderWidth: 1", "XBall*canvas.topAttachment: ATTACH_WIDGET", "XBall*canvas.topWidget: gravityBar", "XBall*canvas.bottomAttachment: ATTACH_FORM", "XBall*canvas.rightAttachment: ATTACH_FORM", "XBall*canvas.leftAttachment: ATTACH_FORM", "! Athena resources", "XBall*canvas.fromVert: gravityBar", "XBall*canvas.width: 400", "XBall*canvas.height: 330", "", "", "XBall*help_dialog_popup.title: XBall Information", "XBall*help_dialog_action_area.leftAttachment: ATTACH_FORM", "XBall*help_dialog_action_area.rightAttachment: ATTACH_FORM", "XBall*help_dialog_action_area.bottomAttachment: ATTACH_FORM", "XBall*help_dialog_action_area.close.labelString: Close", "XBall*help_dialog.close.label: Close", "XBall*help_dialog.separator.rightAttachment: ATTACH_FORM", "XBall*help_dialog.separator.leftAttachment: ATTACH_FORM", "XBall*help_dialog.separator.topOffset: 5", "XBall*help_dialog.separator.bottomAttachment: ATTACH_WIDGET", "XBall*help_dialog.separator.bottomWidget: help_dialog_action_area", "XBall*help_dialog*help_text.rows: 12", "XBall*help_dialog*help_text.columns: 60", "! Athena Resources", "XBall*help_dialog*help_textAW.displayCaret: False", "XBall*help_dialog*help_textAW.height: 150", "XBall*help_dialog*help_textAW.width: 470", "XBall*help_dialog*help_textAW.scrollHorizontal: WhenNeeded", "XBall*help_dialog*help_textAW.scrollVertical: WhenNeeded", "", "XBall*help_dialog*close.accelerators: \ Escape: set() notify() unset() \n\ Return: set() notify() unset() \n\ ", "", "", "", "!!!!!!!!!!!", "! Help text", "!!!!!!!!!!!", "!", "! Note that since fallback resources cannot handle \n in the text,", "! a ~ is used to indicate a newline.", "!", "!!!!!!!!!!", "", "XBall.pointerHelp: \ MOUSE BUTTON USAGE ~~~\ Button 1: o Hold down to create a ball. ~\ o Throw the ball by moving the mouse and ~\ letting go of button 1. ~\ o The ball will be going the speed of the ~\ pointer at release time. ~\ Button 2: o Hold down and move the mouse to create ~\ random velocity balls. ~\ Button 3: o Hold down and move the mouse to create ~\ zero velocity balls. \ ", "", "XBall.menuHelp: \ PULLDOWN MENU USAGE~~~\ File~\ About... A description of the program and author~\ Run Demo... Allows you to execute XBall demo files~\ See 'Help On Demos' for demo file format~\ Load Bitmap... Load an X bitmap as a set of balls~\ Analogous Demo command: ~\ bitmap filename posx,posy~\ Quit Exits the program~~\ Actions~\ Clear Clear the screen of balls~\ Analogous Demo command: clear~\ Randomize Give each ball a random velocity~\ Analogous Demo command: ~\ randomize minx,maxx,miny,maxy~\ Stop Demo Stops the execution of a demo in progress~\ Enabled by the Run Demo... menu option~\ Analogous Demo command: stop~\ Step Simulation Perform one step of the Halted simulation~\ Enabled by the Halt Simulation menu option~~\ Options~\ Perpetual If toggled on, balls will live forever~\ Analogous Demo command: perpetual on|off~\ Command line option: -perpetual True|False~\ Ball Collide If on, balls will collide with one another~\ Analogous Demo command: collide on|off~\ Command line option: -collide True|False~~\ Help Simulation Stop the simulation. You can then step the~\ simulation using Step Simulation menu option~~\ Help~\ On Menus Help using the menu system~\ On Scrollbars Help on the Elasticity and Gravity bars~\ On Buttons Help on using the mouse buttons to create balls~\ On Demos Help on the Demo language and how to run demos~\ On Parameters Help with command-line arguments to xball \ ", "", "", "XBall.scrollbarHelp: \ SCROLLBAR USAGE~~~\ Elasticity~\ o This scrollbar controls the balls' elasticity, or how~\ much energy is lost each time the balls hit the ground.~\ o Scrollbar to left: low elasticity (eggs)~\ o Scrollbar to right: high elasticity (superballs)~\ o Demo command: elasticity %d~\ o Command line options: -elasticity %d~~~\ Gravity~\ o This scrollbar controls the gravity, or how~\ much vertical velocity is added (subtracted)~\ from the balls for each iteration.~\ o Scrollbar to the left: Zero gravity (outer space)~\ o Scrollbar to the right: Large gravity (Jupiter)~\ o Demo command: gravity %d~\ o Command line options: -gravity %d \ ", "", "", "XBall.demoHelp: \ DEMO FILE COMMANDS~~\ %s1, %s2... - Replace with a string~\ %d1, %d2... - Replace with an integer~~\ create %d1,%d2,%d3,%d4: Create a ball with x,y position~\ %d1,%d2 and an x & y velocity~\ of %d2,%d4~\ randomize %d1,%d2,%d3,%d4: randomize velocities of all ~\ balls on screen with:~\ a max negative x velocity of %d1,~\ a max positive x velocity of %d2,~\ a max negative y velocity of %d3,~\ a max positive y velocity of %d4,~\ load_bitmap %s %d1,%d2: load a bitmap file (where %s is~\ the file path) to an x,y position~\ of %d1,%d2 on the screen~\ set_velocity %s %d1,%d2: set ball velocities (%s is~\ relative or absolute) to the x ~\ and y velocities %d1,%d2~\ gravity %d: set gravity to %d~\ elasticity %d: set elasticity to %d~\ backwards %d: Run simulation backwards %d iterations~\ visible %s: Make ball display 'on' or 'off'~\ iterate %d: simulate for %d iterations~\ sleep %d: sleep for %d seconds~\ perpetual %s: toggle perpetual (%s is 'on' or 'off')~\ collide %s: toggle ball collision (%s is 'on' or 'off')~\ window_width %d: Change window width to %d~\ window_height %d: Change window height to %d~\ backwards %d: Iterate backwards %d steps~\ clear: delete all balls in window~\ create_random %d1,%d2: create %d1 random balls with a ~\ max velocity of %d2~\ exit or quit: quit the xball program if demo is not~\ interactive~\ stop: stop demo but leave program alive \ ", "", "XBall.startupHelp: \ PROGRAM STARTUP PARAMETERS~~~\ Run xball -help for a list of command-line startup~\ ", " parameters", "", "XBall.aboutString: \ XBall Version 3.0.1~~\ April 1993~~\ The Premire Ball Bouncing Software~~\ Allows you to throw 3-D balls around in a 2-D space.~~\ Author (Send bugs, comments, and interesting demos to):~\ David Nedde~\ daven@ivy.wpi.edu~\ Computer Science Department~\ Worcester Polytechnic Institute~\ Worcester, MA 01609~~\ Copyright 1990, 1993 David Nedde~\ Permission to use, copy, modify, and distribute this~\ software and its documentation for any purpose and~\ without fee is granted provided that the above~\ copyright notice appears in all copies. It is~\ provided \"as is\" without express or implied warranty. \ ", "", "", "!!!!!!!!!!!!!!!!!", "! Menu Definition", "!!!!!!!!!!!!!!!!!", "!", "! Format:", "! pulldownName~", "! widgetName,widgetClass,menuCallbackName,optionalParams...~", "!", "! The widgetName is referenced above to set the menu's label.", "!", "! Note that the pulldownName of 'help' is automatically used as the help ", "! pulldown.", "!", "! Available WidgetClasses are:", "! PushButton - push it and cause the action", "! ToggleButton - Push it and toggle the state", "! Separator - A line in the menu", "!", "! Available menuCallbackNames available (none take optional parameters):", "! runDemo - Lets user select a demo and run the demo", "! loadBitmap - Lets user load a bitmap file", "! quit - quits xball program", "! clear - Clear all balls from the screen", "! randomize - Randomize all balls from the screen", "! stopDemo - Stop a demo in progress", "! stepSim - Steps the simulation once (if simulation halted)", "! perpetual - Toggles perpetual balls state", "! ballCollide - Toggles colliding ball state", "! haltSim - Toggles halting the simulation", "! about - Displays help about the program", "! onMenus - Displays help on the menus", "! onScroll - Displays help on setting elasticity and gravity", "! onButtons - Displays help on using the mouse buttons to create balls", "! onDemos - Displays help on writing a demo", "! onParams - Displays help on command-line arguments", "!", "!!!!!!!!!!!!!!!!!", "", "XBall.menuDef: \ \ file~\ about,PushButton,about~\ runDemo,PushButton,runDemo~\ loadBitmap,PushButton,loadBitmap~\ separator,Separator~\ quit,PushButton,quit~\ actions~\ clear,PushButton,clear~\ randomize,PushButton,randomize~\ stopDemo,PushButton,stopDemo~\ stepSim,PushButton,stepSim~\ options~\ perpetual,ToggleButton,perpetual~\ ballCollide,ToggleButton,ballCollide~\ haltSim,ToggleButton,haltSim~\ help~\ about,PushButton,about~\ onMenus,PushButton,onMenus~\ onScroll,PushButton,onScroll~\ onButtons,PushButton,onButtons~\ onDemos,PushButton,onDemos~\ onParams,PushButton,onParams~\ ", "", NULL xball-3.1.0/file_sel.c000066400000000000000000000144451411065647700145660ustar00rootroot00000000000000/********************************************************************** * file_sel.c - Object that asks the user for a filename. * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ /********************************************************************** * File_sel Object * * Private Methods: * * XtCallbackProc button_cb * Callback if the user presses a button in the selection dialog. * * * Private Data: * * Bool searching - True while the dialog is up. * char *filename - Filename the user selected. * Widget dialog_w - the dialog widget. * **********************************************************************/ /* System headers */ #include #include #ifdef MOTIF #include #include #endif /* Local headers */ #include "file_sel.h" #include "miscx.h" #include "names.h" /* Functions */ static void display_dialog(/* file_sel, title*/); /* Create the file_sel object */ file_sel_type file_sel__create(toplevel) Widget toplevel; { file_sel_type file_sel = XtNew( file_sel_struct_type); file_sel->toplevel = toplevel; file_sel->searching = False; file_sel->filename = (char *)0; file_sel->dialog_w = (Widget)0; return file_sel; } /********************************************************************** * file_sel__free - Free data associated with file_sel object * * void file_sel__free( file_sel_type file_sel) * * * file_sel - the file_sel object * **********************************************************************/ void file_sel__destroy(file_sel) file_sel_type file_sel; { if (file_sel->filename != (char *)0) { XtFree( file_sel->filename); } if (file_sel->dialog_w != (Widget)0) { XtDestroyWidget( file_sel->dialog_w); } XtFree( (char *)file_sel); } /********************************************************************** * file_sel__display - Display the file selection box and return selected file * * char *file_sel__display(file_sel_type file_sel, char *title) * * * file_sel - the file_sel object * title - the string used for the dialog's popup window title * Returns - the filename selected by the user, or (char *)0 if canceled * * Description: * If the title is (char *)0, a default title will be used. * the returned string is not to be freed by the caller. * The method only returns when the user is done with the dialog. * **********************************************************************/ char *file_sel__display(file_sel, title) file_sel_type file_sel; char * title; { /* Free filename if it was set in previous calls */ if (file_sel->filename != (char *)0) { XtFree(file_sel->filename); file_sel->filename = (char *)0; } /* Display dialog to user and set the filename member */ display_dialog( file_sel, title); return file_sel->filename; } /* Private object methods */ #ifdef MOTIF static void button_cb(/*w, file_sel, call_data*/); static void display_dialog( file_sel, title) file_sel_type file_sel; char * title; { XEvent event; XtAppContext app_context; file_sel->searching = True; if (file_sel->dialog_w == (Widget)0) { file_sel->dialog_w = XmCreateFileSelectionDialog(file_sel->toplevel, FILE_SB, NULL, 0); XtAddCallback(file_sel->dialog_w, XmNcancelCallback, button_cb, (XtPointer)file_sel); XtAddCallback(file_sel->dialog_w,XmNokCallback, button_cb, (XtPointer)file_sel); XtAddCallback(file_sel->dialog_w,XmNhelpCallback, button_cb, (XtPointer)file_sel); } app_context = XtWidgetToApplicationContext( file_sel->dialog_w); if (title == (char *)0) title = "Select File"; XtVaSetValues( file_sel->dialog_w, XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL, XtVaTypedArg, XmNdialogTitle, XmRString, title, sizeof(char *), NULL); XmFileSelectionDoSearch( file_sel->dialog_w, NULL); XtManageChild( file_sel->dialog_w); /* Manage the file selection widget */ /* Keep processing Xt events until one of the callbacks resets the searching data member */ while (file_sel->searching) { XtAppNextEvent(app_context, &event); XtDispatchEvent(&event); } } /********************************************************************** * button_cb - Callback if the user presses a button in the selection dialog. * * XtCallbackProc button_cb * * Description: * Brings down the file selection dialog. * If the OK button was pressed, the selected string is saved. * If the Cancel button was pressed... **********************************************************************/ static void button_cb(w, file_sel, call_data) Widget w; file_sel_type file_sel; XmFileSelectionBoxCallbackStruct *call_data; { XtUnmanageChild(w); /* Bring down the file selection dialog */ switch (call_data->reason) { case XmCR_OK: /* Get the selected filename as a (char *) */ if (!XmStringGetLtoR(call_data->value, XmSTRING_DEFAULT_CHARSET, &file_sel->filename)) /* Internal error - couldn't get the selected filename */ break; if (file_sel->filename[0] == '\0') { /* No string was selected */ XtFree( file_sel->filename); file_sel->filename = (char *)0; } break; case XmCR_HELP: break; case XmCR_CANCEL: break; } file_sel->searching = False; /* Exit file_sel__display() routine */ } #endif #ifdef ATHENA /* Display the file dialog to the user. Call SelFile in filemenu.c */ static void display_dialog( file_sel, title) file_sel_type file_sel; char * title; { SelFile( file_sel->toplevel, /*prompt=*/NULL, /*cancel=*/NULL, /*init_path=*/NULL, /*show_entry=*/NULL, &file_sel->filename); } #endif xball-3.1.0/file_sel.h000066400000000000000000000027401411065647700145660ustar00rootroot00000000000000/********************************************************************** * file_sel.h - Public interface to the file_sel object. * * Copyright 1992, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ /********************************************************************** * File Sel Object * * The file object is allows you to request a file from the user. * * Public methods: * * void file_sel__init(file_sel_type *file_sel, help_type *help) * Initialise the file_sel object. * * void file_sel__free( file_sel_type *file_sel) * Free data associated with file_sel object * * char *file_sel__display(file_sel_type *file_sel, char *title) * Display the file selection box and return selected file * **********************************************************************/ #ifndef __FILE_SEL_H__ #define __FILE_SEL_H__ #include typedef struct { Widget dialog_w; Bool searching; char * filename; Widget toplevel; } file_sel_struct_type, *file_sel_type; file_sel_type file_sel__create(/*toplevel*/); void file_sel__destroy(/*file_sel*/); char *file_sel__display(/*file_sel, title*/); #endif /* __FILE_SEL_H__ */ xball-3.1.0/filemenu.c000066400000000000000000000350371411065647700146100ustar00rootroot00000000000000/********************************************************************** * filemenu.c * * See SelFile() header for interface description. * * Copyright 1990, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. * * This source is derived from xdbx source with the following disclaimer: **********************************************************************/ /***************************************************************************** * * xdbx - X Window System interface to the dbx debugger * * Copyright 1989 The University of Texas at Austin * Copyright 1990 Microelectronics and Computer Technology Corporation * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation, and that the name of The University of Texas * and Microelectronics and Computer Technology Corporation (MCC) not be * used in advertising or publicity pertaining to distribution of * the software without specific, written prior permission. The * University of Texas and MCC makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * THE UNIVERSITY OF TEXAS AND MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR MCC BE LIABLE FOR * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Po Cheung * Created: March 10, 1989 * *****************************************************************************/ /* filemenu.c * * Construct a file menu (directory browser) which allows a user to go * up and down the directory tree, to select files. * The file menu is popped up by the 'file' command button. * Duane Voth (duanev@mcc.com) contributed to the layout of the file menu, * plus some code and ideas. * * changeDir(): Record the current working directory. * InList(): Select files to be displayed in the menu. * ScanDir(): Scan the directory and record selected filenames. * DisplayMenuFile(): Callback for the file menu. * CancelFileMenu(): Pop down the file menu. * SetUpFileMenu(): Create the file menu popupshell. * UpdateFileMenu(): Update entries in the file menu. * File(): Command callback for the 'file' command button. */ #include #include #include #include #include #include #include #include #include #include #include #include #ifdef SUNOS4 #include #else #include #endif /*#include "global.h"*/ #ifdef SUNOS4 typedef struct dirent Directory; #else typedef struct direct Directory; #endif #define MAXPATHLEN 1024 #define LINESIZ 512 #define LASTCH(s) (s[strlen(s)-1]) #define SECLASTCH(s) (s[strlen(s)-2]) #define MAXCOLUMNS 8 /* max number of columns in file menu */ #define MAXARGS 20 /* max number of args */ #define FILES_PER_COL 10 /* # of files per column in file menu */ #define INVALID (-2) #define CANCELED (-1) #define OK 0 static int glob_status; static char **glob_path; static Widget parent_w; char cwd[MAXPATHLEN] = ""; /* current working directory */ static char fileMenuDir[MAXPATHLEN];/* current directory of file menu */ static char **filelist; /* list of file names in fileMenu */ static int nfiles = 0; /* number of files in filelist */ static Widget popupshell, /* parent of popup */ popup, /* vpane widget containing file menu */ fileMenu, /* list widget as file menu */ fileMenuLabel; /* label widget as file menu label */ void File(); static int UpdateFileMenu(); static void CancelFileMenu(); /* Change working directory to 'dir'. * Modify static global variable, cwd, to keep track of * current working directory. */ static void changeDir(dir) char *dir; { int i; if (strcmp(dir, "./") == NULL) return; if (dir[0] == '/' || dir[0] == '~') strcpy(cwd, dir); if (strcmp(dir, "../") == NULL) { for (i=strlen(cwd); cwd[i] != '/' && i > 0; i--); cwd[i] = '\0'; if (strcmp(cwd, "") == NULL) strcpy(cwd, "/"); } else { sprintf(cwd, "%s/%s", cwd, dir); LASTCH(cwd) = '\0'; } } /* Determines if a directory entry should appear in the file menu. * The files included in the menu are : * .. (parent directory) * directories * text files * executable files */ static int InList(entry) Directory *entry; { char pathname[LINESIZ]; struct stat statbuf; if (strcmp(entry->d_name, ".") == NULL || /* ignore current directory */ LASTCH(entry->d_name) == '~' || /* ignore Emacs backup files */ entry->d_name[0] == '#' || /* Ignore emacs backup files */ (LASTCH(entry->d_name) == 'o' && SECLASTCH(entry->d_name) == '.')) /* ignore object files */ return False; if (entry->d_name[0] == '.' && entry->d_name[1] != '.') return False; /* ignore hidden files */ if (strcmp(cwd, "")) /* give full path name */ sprintf(pathname, "%s/%s", cwd, entry->d_name); else strcpy(pathname, entry->d_name); if (stat(pathname, &statbuf) == -1) return False; if (statbuf.st_mode & S_IFDIR) { /* is directory */ strcat(entry->d_name, "/"); ++(entry->d_namlen); return True; } if (statbuf.st_mode & S_IEXEC) { /* is executable */ strcat(entry->d_name, "*"); ++(entry->d_namlen); return True; } return True; } /* Scans the working directory for files selected by InList(), sorted * alphabetically, and stored in an array of pointers to directory * entries called namelist. * The names of the selected files are stored in filelist. */ static int ScanDir(dir) char *dir; { extern alphasort(); Directory **namelist; int i, j; char *format_static(); nfiles = scandir(dir, &namelist, InList, alphasort); if (nfiles <= 0) { XBell(XtDisplay(popupshell),0); return(INVALID); } if (filelist) { for (i=0; filelist[i]; i++) XtFree(filelist[i]); XtFree((char *)filelist); } filelist = (char **) XtMalloc((nfiles+1) * sizeof(char *)); i = 0; for (j=0; jd_name); XtFree((char *)namelist[j]); } filelist[i++] = NULL; XtFree((char *)namelist); return(OK); } /* Delete the current directory prefix from the passed path */ char *remove_current_prefix(path) char *path; { char wd[MAXPATHLEN]; char *temp_str; getwd(wd); if (!strncmp(wd,path,strlen(wd))) { /* wd matches path prefix */ temp_str = &path[strlen(wd)]; if (temp_str[0] == '/') /* If first char of prefix is a '/', * * remove it since we want a relative path */ temp_str++; return(temp_str); } /* Couldn't find the prefix -- return the whole path */ return(path); } /* Callback for the fileMenu list widget. * > if the selected item is a directory, display contents of that directory. * > if the selected item is a readable file, return the file name */ /* ARGSUSED */ static void DisplayMenuFile(w, popupshell, call_data) Widget w; Widget popupshell; XawListReturnStruct *call_data; { char *filename; XtPopdown(popupshell); filename = call_data->string; if (filename == NULL) return; if (LASTCH(filename) == '/') { changeDir(filename); XtDestroyWidget(popupshell); if (UpdateFileMenu() == INVALID) changeDir("../"); /* create new menu */ File(w,(XtPointer )0,(XtPointer )0); /* pop it up */ } else { *glob_path = XtMalloc(strlen(filename)+strlen(cwd)+2); strcpy(*glob_path, remove_current_prefix(cwd)); if (strlen(*glob_path) != 0) strcat(*glob_path, "/"); strcat(*glob_path, filename); glob_status = OK; } } /* Callback to popdown the file menu */ /* ARGSUSED */ static void CancelFileMenu(w, popupshell, call_data) Widget w; Widget popupshell; XtPointer call_data; { XtPopdown(popupshell); glob_status = CANCELED; } void DisableWindowResize(w) Widget w; { Arg args[MAXARGS]; Cardinal n; Dimension height; n = 0; XtSetArg(args[n], XtNheight, &height); n++; XtGetValues(w, args, n); XawPanedSetMinMax(w, height, height); XawPanedAllowResize(w, False); } /* Creates a popup shell with its child being a vpane widget containing * a file menu label, a file menu containing file names returned from * ScanDir(), and a cancel command button. * When an item in the list is selected, DisplayMenuFile is called. */ static int SetUpFileMenu(dir) char *dir; { Widget cancelButton; Arg args[MAXARGS]; Cardinal n; char menulabel[LINESIZ]; int ncolumns; n = 0; popupshell = XtCreatePopupShell("File Directory", transientShellWidgetClass, parent_w, args, n); n = 0; popup = XtCreateManagedWidget("popup", panedWidgetClass, popupshell, args, n); if (ScanDir(dir) == OK) /* It worked OK */ strcpy(fileMenuDir, dir); else return(INVALID); n = 0; sprintf(menulabel, " %s ", dir); XtSetArg(args[n], XtNlabel, (XtArgVal) menulabel); n++; XtSetArg(args[n], XtNjustify, (XtArgVal) XtJustifyCenter); n++; fileMenuLabel = XtCreateManagedWidget("fileMenuLabel", labelWidgetClass, popup, args, n); n = 0; ncolumns = nfiles/FILES_PER_COL + 1; ncolumns = MIN(ncolumns, MAXCOLUMNS); XtSetArg(args[n], XtNlist, filelist); n++; XtSetArg(args[n], XtNverticalList, True); n++; XtSetArg(args[n], XtNdefaultColumns, (XtArgVal) ncolumns); n++; fileMenu = XtCreateManagedWidget("fileMenu", listWidgetClass, popup, args, n); XtAddCallback(fileMenu, XtNcallback, DisplayMenuFile,(XtPointer)popupshell); n = 0; XtSetArg(args[n], XtNresize, False); n++; XtSetArg(args[n], XtNlabel, "CANCEL"); n++; cancelButton = XtCreateManagedWidget("cancelButton", commandWidgetClass, popup, args, n); XtAddCallback(cancelButton, XtNcallback, CancelFileMenu, (XtPointer)popupshell); DisableWindowResize(fileMenuLabel); DisableWindowResize(cancelButton); return(OK); } /* This routine is called when there is a a change in current directory. * It destroys the existing popup shell and creates a new file menu based * on the new current directory. A new directory list is created. */ static int UpdateFileMenu() { return(SetUpFileMenu(cwd)); } /* File command button callback. */ /* ARGSUSED */ void File(w, client_data, call_data) Widget w; XtPointer client_data; XtPointer call_data; { Arg args[MAXARGS]; Cardinal n; Dimension fileMenu_width, fileMenuLabel_width, border_width; Dimension fileMenu_height, fileMenuLabel_height; Dimension dialog_width, dialog_height; int width, height; int x_offset, y_offset; Position x,y; /* if (strcmp(fileMenuDir, cwd))*/ if (UpdateFileMenu() != OK) return; n = 0; XtSetArg(args[n], XtNwidth, &fileMenu_width); n++; XtSetArg(args[n], XtNheight, &fileMenu_height); n++; XtSetArg(args[n], XtNborderWidth, &border_width); n++; XtGetValues(fileMenu, args, n); n = 0; XtSetArg(args[n], XtNwidth, &fileMenuLabel_width); n++; XtSetArg(args[n], XtNheight, &fileMenuLabel_height); n++; XtGetValues(fileMenuLabel, args, n); /* Place the popup window centered on parent */ n = 0; XtSetArg(args[n], XtNwidth, &dialog_width); n++; XtSetArg(args[n], XtNheight, &dialog_height); n++; XtGetValues(parent_w, args, n); width = MAX(fileMenu_width, fileMenuLabel_width); x_offset = (Position) (dialog_width - width - border_width) / 2; height = fileMenu_height + fileMenuLabel_height; y_offset = (Position) (dialog_height - height - border_width) / 2; XtTranslateCoords(parent_w, x_offset, y_offset, &x, &y); x = MAX(0, x); y = MAX(0, y); n = 0; XtSetArg(args[n], XtNx, x); n++; XtSetArg(args[n], XtNy, y); n++; XtSetValues(popupshell, args, n); /*XtManageChild( popupshell);*/ XtPopup(popupshell, XtGrabNonexclusive); /*UpdateMessageWindow("Select a file or directory");*/ } /********************************************************************** * SelFile * * Pop up a window, letting the user select a file. When the file * is selected, the string is returned to the caller. * * If the init_path is NULL and this is the first call, the current * directory is used, else the previous call's directory is used. * If the init_path is an empty string, the current directory is used. * A passed init path will have the current dir prepended if the path * doesn't start with a '/'. * If the popup is canceled, -1 is returned, otherwise 0 is returned. **********************************************************************/ int SelFile(w,prompt,cancel,init_path,show_entry,path_return) Widget w; char *prompt; /* Not used yet */ char *cancel; /* Not used yet */ char *init_path; int *(*show_entry)(); /* Not used yet */ char **path_return; { XtAppContext app_context; XEvent event; parent_w = w; glob_path = path_return; if (init_path == (char *)0 || init_path[0] == '\0') { /* No init_path -- Use the current working directory */ if (cwd[0] == '\0' || init_path == (char *)0 || init_path[0] == '\0') getwd(cwd); } else if (strcmp(cwd,init_path)) { /* They are different -- copy requested starting dir in */ /* Prefix with wd if init_path is a relative path */ if (init_path[0] != '/') { getwd(cwd); strcat(cwd,"/"); } else cwd[0] = '\0'; strcat(cwd,init_path); } glob_status = INVALID; File(w, (XtPointer )0, (XtPointer )0); app_context = XtWidgetToApplicationContext( w); while (glob_status == INVALID) { XtAppNextEvent(app_context, &event); XtDispatchEvent(&event); } return(glob_status); } xball-3.1.0/gen_fallback000077500000000000000000000012721411065647700151500ustar00rootroot00000000000000#!/bin/sh # Usage: gen_fallback app-defaults-file # Generates a list of fallback resources suitable for including # in the fallback resources array # This shellscript just echos each line in the source file with a " at # the beginning of the line, and a ", at the and of the line. echo '/* fallback.h generated by gen_fallback from '$1' - do not edit! */' echo "" cat $1 | awk ' \ BEGIN { first = 1 } \ /\\$/ && first == 0 { printf("%s\n", $0); } \ /\\$/ && first == 1 { first = 0; printf("\"%s\n", $0); } \ $0 !~ /\\$/ && first == 1 { printf("\"%s\",\n", $0); } \ $0 !~ /\\$/ && first == 0 { first = 1 ; printf("\",\n\"%s\",\n", $0); } \ END { printf("NULL\n"); }' xball-3.1.0/good_bitmaps000066400000000000000000000004011411065647700152150ustar00rootroot00000000000000A list of bitmaps that are interesting when loaded as balls. These files should be in /usr/include/X11/bitmaps: 2x2 boxes cntr_ptr cross_weave dot keyboard16 left_ptr right_ptr scales sipb star target xlogo11 xlogo16 xlogo32 xball-3.1.0/help.c000066400000000000000000000233431411065647700137310ustar00rootroot00000000000000/********************************************************************** * help.c - help object definition * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ /* System Headers */ #include #ifdef MOTIF #include #include #include #include #include typedef struct { char *label; /* Button widget's name */ void (*callback)(); /* Button widget's callback */ caddr_t data; /* Callback data */ } HelpButtonItem; #endif #ifdef ATHENA #include #include #include #include #include #endif /* Local headers */ #include "help.h" #include "names.h" #include "misc.h" #include "miscx.h" /* File scope variables */ typedef struct { char *menu_help; char *scrollbar_help; char *pointer_help; char *demo_help; char *startup_help; char *about_help; } app_data,*app_data_ptr; static app_data res_data = { 0, 0, 0, 0, 0, 0 }; static XtResource resources[] = { { "menuHelp", "MenuHelp", XtRString, sizeof(char *), XtOffset( app_data_ptr, menu_help), XtRString, NULL}, { "scrollbarHelp", "ScrollbarHelp", XtRString, sizeof(char *), XtOffset( app_data_ptr, scrollbar_help), XtRString, NULL}, { "pointerHelp", "PointerHelp", XtRString, sizeof(char *), XtOffset( app_data_ptr, pointer_help), XtRString, NULL}, { "demoHelp", "DemoHelp", XtRString, sizeof(char *), XtOffset( app_data_ptr, demo_help), XtRString, NULL}, { "startupHelp", "StartupHelp", XtRString, sizeof(char *), XtOffset( app_data_ptr, startup_help), XtRString, NULL}, { "aboutString", "AboutString", XtRString, sizeof(char *), XtOffset( app_data_ptr, about_help), XtRString, NULL} }; /* Functions */ static void close_cb(/*w, help, call_data*/); static void display_help_dialog(/*help, message*/); static void create_help_dialog(/* help*/); static void set_help_text(/* help, message*/); /* Public object methods */ /* Create the help object */ help_type help__create(w) Widget w; { help_type help = XtNew( help_struct_type); help->toplevel = w; help->dialog_w = (Widget)0; return help; } /* Destroy the help object */ void help__destroy(help) help_type help; { XtDestroyWidget( help->dialog_w); XtFree( (char *)help); } /* A menu callback (mcb) that displayshelp to the user, based on the name of the menu button used to invoke the callback */ void help__display_mcb(w, help, call_data, extra) Widget w; help_type help; XtPointer call_data; char * extra; { char * help_text; char * widget_name = XtName(w); if (res_data.menu_help == 0) { /* Read help text resources */ XtGetApplicationResources(get_toplevel(w), (XtPointer)&res_data, resources, XtNumber(resources), (ArgList)NULL,(Cardinal)0); /* We have to convert the ~ to newlines because fallback resources do not work if they have newlines embedded in them */ /* convert_newlines is in misc.c */ convert_newlines( res_data.menu_help); convert_newlines( res_data.scrollbar_help); convert_newlines( res_data.pointer_help); convert_newlines( res_data.demo_help); convert_newlines( res_data.startup_help); convert_newlines( res_data.about_help); } if (strcmp( widget_name, ON_MENUS) == 0) help_text = res_data.menu_help; else if (strcmp( widget_name, ON_SCROLL) == 0) help_text = res_data.scrollbar_help; else if (strcmp( widget_name, ON_BUTTONS) == 0) help_text = res_data.pointer_help; else if (strcmp( widget_name, ON_DEMOS) == 0) help_text = res_data.demo_help; else if (strcmp( widget_name, ON_PARAMS) == 0) help_text = res_data.startup_help; else if (strcmp( widget_name, ABOUT) == 0) help_text = res_data.about_help; /* Display the help dialog */ display_help_dialog(help, help_text); } /* Private object methods */ /* Called when the user wants to close the help dialog */ static void close_cb(w, help, call_data) Widget w; help_type help; XtPointer call_data; { XtUnmanageChild( help->dialog_w); } /* Displays the passed message in the help dialog */ static void display_help_dialog(help, message) help_type help; char *message; { if (help->dialog_w == (Widget)0) { create_help_dialog( help); } set_help_text( help, message); XtManageChild( help->dialog_w); } #ifdef MOTIF static Widget create_help_button(parent, action) Widget parent; HelpButtonItem *action; { char txt[100]; Widget button, widget; sprintf(txt,"%s_action_area", XtName(parent)); button = XtVaCreateWidget(txt, xmFormWidgetClass, parent, XmNfractionBase, 0, XmNmarginHeight, 10, XmNmarginWidth, 10, NULL); widget = XtVaCreateManagedWidget(action->label, xmPushButtonWidgetClass, button, XmNleftAttachment, XmATTACH_FORM, XmNleftPosition, 0, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNrightPosition, 19, XmNshowAsDefault, 1, XmNdefaultButtonShadowThickness, 1, NULL); if (action->callback) XtAddCallback(widget, XmNactivateCallback, action->callback, (XtPointer)action->data); // Default button should be first widget XtVaSetValues(parent, XmNdefaultButton, widget, NULL); XtManageChild(button); return button; } /* Motif help dialog */ static void create_help_dialog(help) help_type help; { Widget sep; Arg wargs[10]; int n; static HelpButtonItem action_item = { "close", close_cb, NULL }; help->dialog_w = XmCreateFormDialog( help->toplevel, HELP_DIALOG, NULL, 0); /* Create the action area */ action_item.data = (XtPointer )help; create_help_button( help->dialog_w, &action_item); sep = XtVaCreateManagedWidget("separator", xmSeparatorWidgetClass, help->dialog_w, NULL); n = 0; XtSetArg(wargs[n], XmNeditMode, XmMULTI_LINE_EDIT); n++; XtSetArg(wargs[n], XmNeditable, False); n++; XtSetArg(wargs[n], XmNverifyBell, False); n++; XtSetArg(wargs[n], XmNtopAttachment, XmATTACH_FORM); n++; XtSetArg(wargs[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(wargs[n], XmNrightAttachment, XmATTACH_FORM); n++; XtSetArg(wargs[n], XmNbottomAttachment, XmATTACH_WIDGET); n++; XtSetArg(wargs[n], XmNbottomWidget, sep); n++; help->text_w = XmCreateScrolledText( help->dialog_w, "help_text", wargs, n); XtManageChild( help->text_w); } /* Sets the help text in the Motif dialog */ static void set_help_text( help, message) help_type help; char * message; { XmTextSetString( help->text_w, message); } #endif #ifdef ATHENA /* Creates the Athena help dialog */ static void create_help_dialog( help) help_type help; { Widget form; Widget button; char buff[50]; Dimension border_width; Dimension top_width; Dimension top_height; Dimension dialog_width; Dimension dialog_height; int x_offset, y_offset; Position x,y; sprintf(buff, "%s_popup", HELP_DIALOG); help->dialog_w = XtVaCreateWidget( buff, transientShellWidgetClass, help->toplevel, XtNtransientFor, help->toplevel, XtNmappedWhenManaged, False, NULL); form = XtVaCreateManagedWidget( HELP_DIALOG, formWidgetClass, help->dialog_w, NULL); help->text_w = XtVaCreateManagedWidget( "help_textAW", asciiTextWidgetClass, form, NULL); button = XtVaCreateManagedWidget( "close", commandWidgetClass, form, XtNfromVert, help->text_w, NULL); XtAddCallback( button, XtNcallback, close_cb, (XtPointer)help); XtInstallAccelerators( form, button); /* Manage so the shell widget's width and height will be set */ XtManageChild( help->dialog_w); /* Position centered over the toplevel window */ XtVaGetValues( help->toplevel, XtNwidth, &top_width, XtNheight, &top_height, XtNborderWidth, &border_width, NULL); XtVaGetValues( help->dialog_w, XtNwidth, &dialog_width, XtNheight, &dialog_height, NULL); x_offset = (top_width - dialog_width ) / 2; y_offset = (top_height - dialog_height) / 2; XtTranslateCoords(help->toplevel, x_offset, y_offset, &x, &y); XtUnmanageChild( help->dialog_w); XtVaSetValues( help->dialog_w, XtNx, x, XtNy, y, XtNmappedWhenManaged, True, NULL); } /* Set the help string in the Athena help dialog */ static void set_help_text( help, message) help_type help; char * message; { XtVaSetValues( help->text_w, XtNstring, message, NULL); } #endif xball-3.1.0/help.h000066400000000000000000000014451411065647700137350ustar00rootroot00000000000000/********************************************************************** * file - description * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ #ifndef __HELP_H__ #define __HELP_H__ #include typedef struct { Widget toplevel; Widget dialog_w; Widget text_w; } help_struct_type, *help_type; /* Public methods */ help_type help__create(/*w*/); void help__destroy(/*help*/); void help__display_mcb(/*w, help, call_data, extra*/); #endif xball-3.1.0/install-sh000066400000000000000000000157221411065647700146400ustar00rootroot00000000000000#!/bin/sh # # install - install a program, script, or datafile # # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd=$cpprog shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd=$stripprog shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "$0: no input file specified" >&2 exit 1 else : fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d "$dst" ]; then instcmd=: chmodcmd="" else instcmd=$mkdirprog fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f "$src" ] || [ -d "$src" ] then : else echo "$0: $src does not exist" >&2 exit 1 fi if [ x"$dst" = x ] then echo "$0: no destination specified" >&2 exit 1 else : fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d "$dst" ] then dst=$dst/`basename "$src"` else : fi fi ## this sed command emulates the dirname command dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-$defaultIFS}" oIFS=$IFS # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` IFS=$oIFS pathcomp='' while [ $# -ne 0 ] ; do pathcomp=$pathcomp$1 shift if [ ! -d "$pathcomp" ] ; then $mkdirprog "$pathcomp" else : fi pathcomp=$pathcomp/ done fi if [ x"$dir_arg" != x ] then $doit $instcmd "$dst" && if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename "$dst"` else dstfile=`basename "$dst" $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename "$dst"` else : fi # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up temp files at exit. trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0 trap '(exit $?); exit' 1 2 13 15 # Move or copy the file name to the temp name $doit $instcmd "$src" "$dsttmp" && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi && # Now remove or move aside any old file at destination location. We try this # two ways since rm can't unlink itself on some systems and the destination # file might be busy for other reasons. In this case, the final cleanup # might fail but the new file should still install successfully. { if [ -f "$dstdir/$dstfile" ] then $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null || { echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 (exit 1); exit } else : fi } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" fi && # The final little trick to "correctly" pass the exit status to the exit trap. { (exit 0); exit } xball-3.1.0/intf.h000066400000000000000000000003521411065647700137410ustar00rootroot00000000000000#ifndef __INTF_H__ #define __INTF_H__ #define INTFAC 16 /* Multiplied to everything but velocities */ typedef long intf; #define int2intf( val) ((intf)((val)*INTFAC)) #define intf2int( val) ((long)((val)/INTFAC)) #endif xball-3.1.0/item.c000066400000000000000000000536031411065647700137410ustar00rootroot00000000000000/********************************************************************** * item.c - defines the item object * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ /* System Headers */ #include #include #ifdef MOTIF #include #endif /* Local headers */ #include "item.h" #include "room.h" #include "scrollbar.h" #include "color_l.h" #include "menu.h" #include "misc.h" #include "stipple.xbm" /* Macros */ #define SHADES 4 /* Number of shades for colors in the rgb.txt file */ #define ITEM_WIDTH 10 /* The item's default size */ #define ITEM_HEIGHT 10 #ifndef RGB_TXT #define RGB_TXT "/usr/share/X11/rgb.txt" #endif /* put_pixmap - Draws the item's pixmap to the specified location */ #define put_pixmap( item, x, y) \ XCopyArea(item->display, item->pixmap, item->window, \ item->static_data->gc, \ 0, 0, \ item->static_data->width, \ item->static_data->height, \ intf2int(x) - item->static_data->half_width, \ intf2int(y) - item->static_data->half_height) /* File scope variables */ static item_static_struct_type static_struct; /* Item object static data */ item_static_type static_data = &static_struct; static Bool static_data_initted = False; /* Resources */ typedef struct { int item_width; int item_height; char * rgb_txt; int elasticity; } app_data,*app_data_ptr; static app_data res_data; static XtResource resources[] = { { "itemWidth", "ItemWidth", XtRInt, sizeof(int), XtOffset(app_data_ptr,item_width), XtRImmediate, (caddr_t)ITEM_WIDTH }, { "itemHeight", "ItemHeight", XtRInt, sizeof(int), XtOffset(app_data_ptr,item_height),XtRImmediate, (caddr_t)ITEM_HEIGHT}, { "rgbTxt", "RgbTxt", XtRString, sizeof(char *), XtOffset(app_data_ptr,rgb_txt), XtRString, RGB_TXT} }; /* Functions */ static item_static_type static_data__create(/*display, window, background*/); static void draw_item(/* static_data, display, clear_gc, colors, pixmap, background*/); static void draw_circle(/* display, pixmap, x_offset, y_offset, width, height*/); static void draw_black_ball(/* display, background*/); static void draw_ball(/* display, pixmap, x_offset, y_offset, width, height*/); /* Public object methods */ /* Create the item object. The item is the thing that bounces on the screen */ /* The item is drawn to the screen after it is created */ item_type item__create( x, y, x_vel, y_vel) int x; int y; int x_vel; int y_vel; { item_type item; item = (item_type)malloc( sizeof( item_struct_type)); item->static_data = static_data; item->display = static_data->display; item->window = static_data->window; /* Draw with the next available pixmap image (color) */ static_data->curr_pixmap = (static_data->curr_pixmap + 1) % static_data->num_colors; item->pixmap = static_data->pixmaps[ static_data->curr_pixmap]; /* Position are stored as intf (int-floats) to get more precision out of an int */ item->x = int2intf( x); item->y = int2intf( y); item->x_vel = int2intf( x_vel); item->y_vel = int2intf( y_vel); item->shown = False; item->rebounded = False; item__draw( item); #if 0 /* To generate demos */ printf("create %d,%d,%d,%d\n", intf2int(item->x),intf2int(item->y), intf2int(item->x_vel),intf2int(item->y_vel)); #endif return item; } /* Initializes the item's static data. This can only be done once there is a window, sice we have to get the background color. Thus, we are called from room's first refresh callback */ void item__init(toplevel, display, window, background) Widget toplevel; Display * display; Window window; Pixel background; { static_data = static_data__create( toplevel, display, window, background); static_data_initted = True; } /* Returns true of the item's static data is initialized */ Bool item__initted() { return static_data_initted; } /* Destroys an item */ void item__destroy( item) item_type item; { item__undraw( item, item->x, item->y); /* Erase item from screen */ free( (char *)item); } /* Draws the item to the screen if it is visible. Handles the case where the item was already visible on the screen. */ void item__draw( item) item_type item; { if (!item->shown && item->static_data->visible) { put_pixmap( item, item->x, item->y); item->shown = True; } } /* Erases the item from the screen */ void item__undraw( item, x, y) item_type item; intf x,y; { if (item->shown && item->static_data->visible) { put_pixmap( item, x, y); item->shown = False; } } /* Redraws the item on the screen, regardless of whether it is shown. This method shoulw be used when the window has to be refreshed. invisible items will not be drawn. */ void item__redraw( item) item_type item; { if (item->static_data->visible) { put_pixmap( item, item->x, item->y); item->shown = True; } } /* Move an item's image to a new location */ void item__move_pos( item, x, y) item_type item; int x,y; { item__undraw( item, item->x, item->y); item->x = int2intf(x); item->y = int2intf(y); item__draw( item); } /* Give an item a random velocity, based on the passed ranges */ void item__randomize( item, min_x_vel, max_x_vel, min_y_vel, max_y_vel) item_type item; int min_x_vel; int max_x_vel; int min_y_vel; int max_y_vel; { item->x_vel = int2intf(rand_range( min_x_vel, max_x_vel)); item->y_vel = int2intf(rand_range( min_y_vel, max_y_vel)); } /* Perform one item movement iteration, taking into account other balls, gravity, elasticity, and the room boundaries. The item's new position is calculated and the item's image is moved to the new location. Invisible items are not redrawn. */ void item__move( item, room, items) item_type item; room_type room; items_type items; { /* Calculate new position of item */ intf oldx = item->x; intf oldy = item->y; /* Calculate new y position */ /* Gravity adds to velocity */ if ((item->y < room__get_floor( room)) || (item->y_vel != 0)) { item->y_vel += room__get_gravity( room); } /* Move vertically based on velocity */ item->y += item->y_vel; if (item->y >= room__get_floor( room)) { /* item hit floor -- bounce off floor */ /* Reverse ball velocity */ item->y_vel = -item->y_vel; item->y += item->y_vel; if (ABS(item->y_vel) < room__get_gravity(room)) /* This helps dampen rounding errors that cause balls to bounce forever */ item->y_vel = 0; else { /* Ball velocity is reduced by the percentage elasticity */ item->y_vel *= item->static_data->elasticity; #if 1 item->y = room__get_floor( room) - (room__get_floor( room) - item->y) * item->static_data->elasticity; #else item->y = -item->y + room__get_floor( room)*2; #endif } } else if (item->y < room__get_ceiling( room)) { /* Reverse ball velocity */ item->y_vel = -item->y_vel; /* Ball velocity is reduced by the percentage elasticity */ item->y_vel *= item->static_data->elasticity; /* Bounce off the wall */ item->y = -item->y + room__get_ceiling( room)*2; } /* Calculate new x position */ /* Move horizontally based on velocity */ item->x += item->x_vel; if (item->x > room__get_right_wall(room)) { /* Hit right wall */ /* Reverse ball velocity */ item->x_vel = -item->x_vel; /* Ball velocity is reduced by the percentage elasticity */ item->x_vel *= item->static_data->elasticity; /* Bounce off the wall */ item->x = -item->x + room__get_right_wall( room)*2; } else if (item->x < room__get_left_wall( room)) { /* Hit left wall */ /* Reverse ball velocity */ item->x_vel = -item->x_vel; /* Ball velocity is reduced by the percentage elasticity */ item->x_vel *= item->static_data->elasticity; /* Bounce off the wall */ item->x = -item->x + room__get_left_wall( room)*2; } /* Slow ball if it is rolling on the floor */ if (ABS(item->y) >= room__get_floor(room) - room__get_gravity(room) && item->y_vel == 0) item->x_vel *= item->static_data->elasticity; /* Collide with other balls or ball being created */ if (item->static_data->ball_collide) { /* See if collided with the ball under the pointer being created */ item_type room_item = room__get_item( room); if (room_item != (item_type)0) { item__rebound_item(item, room_item); } /* See if collided with another item */ items__rebound_items( item, items); } /* See if item has come to a peaceful rest */ if (item__stopped(item, room)) { /* on floor && Not bouncing */ if (item->static_data->perpetual) { /* Just drop the ball from the ceiling */ item->y = room__get_ceiling( room); } else { if (item__stopped( item, room)) { item__undraw( item, oldx, oldy); return; /* Don't draw item */ } /* Slow down velocity once rolling based on elasticity */ if (item->x_vel > 0) item->x_vel *= item->static_data->elasticity; } } /* If item moved, redraw it in the new position */ if ((item->y != oldy || item->x != oldx) && static_data->visible) { /* Erase old object */ item__undraw( item, oldx, oldy); item__draw( item); } } /* See if items have hit and rebound them if they have. Moved_item is assumed to have just been moved. Only the moved item will have its x,y positions potentially changed. */ void item__rebound_item( moved_item, fixed_item) item_type moved_item; item_type fixed_item; { intf xdiff,ydiff; xdiff = moved_item->x - fixed_item->x; ydiff = moved_item->y - fixed_item->y; if (ABS(xdiff) < int2intf(moved_item->static_data->width) && ABS(ydiff) < int2intf(moved_item->static_data->height)) { SWAP( moved_item->x_vel, fixed_item->x_vel, intf); SWAP( moved_item->y_vel, fixed_item->y_vel, intf); if (moved_item->y_vel <= int2intf(moved_item->static_data->height) && fixed_item->y_vel <= int2intf(moved_item->static_data->height)) { moved_item->y += moved_item->y_vel; moved_item->y_vel += ydiff * moved_item->static_data->elasticity/10; fixed_item->y_vel -= ydiff * moved_item->static_data->elasticity/10; } if (moved_item->x_vel <= int2intf(moved_item->static_data->width) && fixed_item->x_vel <= int2intf(moved_item->static_data->width)) { moved_item->x += moved_item->x_vel; moved_item->x_vel += xdiff * moved_item->static_data->elasticity/10; fixed_item->x_vel -= xdiff * moved_item->static_data->elasticity/10; } } } /* A scrollbar callback method that sets all the balls' elasticity */ void item__set_elasticity_cb(w, closure, call_data) Widget w; caddr_t closure; scrollbarCallbackStruct * call_data; { static_data->elasticity = call_data->value / 100.0; } /* Return all items' width */ int item__get_width() { return static_data->width; } /* Return all items' height */ int item__get_height() { return static_data->height; } /* A menu callback (mcb) that sets all items' perpetual status */ void item__perpetual_mcb(w, closure, call_data, extra) Widget w; caddr_t closure; menuCallbackStruct * call_data; char * extra; { static_data->perpetual = call_data->set; } /* A menu callback (mcb) that sets all items' collide status */ void item__collide_mcb(w, closure, call_data, extra) Widget w; caddr_t closure; menuCallbackStruct * call_data; char *extra; { static_data->ball_collide = call_data->set; } /* Semi-private object methods */ /* Sets all items' perpetual status */ /* Note that the toggle must be set properly also */ void item__set_perpetual(set) Bool set; { static_data->perpetual = set; } /* Sets all items' collide status */ /* Note that the toggle must be set properly also */ void item__set_ball_collide(set) Bool set; { static_data->ball_collide = set; } /* Set all item's visible status */ /* Note that all items must be undrawn from the screen */ void item__set_visible(visible) Bool visible; { static_data->visible = visible; } /* Private object methods */ /* Load items resources */ static void get_resources( toplevel, display, window, background) Widget toplevel; Display *display; Window window; Pixel background; { XtGetApplicationResources(toplevel, (XtPointer)&res_data, resources, XtNumber(resources), (ArgList)NULL,(Cardinal)0); static_data->width = res_data.item_width; static_data->height = res_data.item_height; static_data->half_width = static_data->width / 2; static_data->half_height = static_data->height / 2; static_data->rgb_txt = res_data.rgb_txt; } /* Initialize the item's static data object */ static item_static_type static_data__create( toplevel, display, window, background) Widget toplevel; Display * display; Window window; Pixel background; { GC clear_gc; /* The following already set in xball_sys object: static_data->elasticity static_data->ball_collide static_data->perpetual */ get_resources( toplevel, display, window, background); static_data->visible = True; static_data->background = background; static_data->display = display; static_data->window = window; static_data->gc = XCreateGC(display, window, 0, 0); clear_gc = XCreateGC(display, window, 0, 0); static_data->curr_pixmap = 0; if (DisplayCells( display, DefaultScreen(display)) > 2) { /* Non-monochrome system */ color_list_type color_list = color_list__create(static_data->rgb_txt); color_type color; Colormap colormap = DefaultColormap(display, DefaultScreen(display)); XColor colors[ SHADES]; /* The color shades */ Pixel cells[ SHADES]; int pixmap_index; int shade; for (shade = 0; shade < SHADES; shade++) colors[ shade].flags = DoRed | DoGreen | DoBlue; for (color = color_list__get_last( color_list), pixmap_index = 0; color != (color_type)0; pixmap_index++) { if (!XAllocColorCells( display, colormap, /*contig =*/True, /*plane_masks=*/NULL, /*nplanes=*/0, /*pixels =*/cells, /*ncolors=*/SHADES)) break; /* All out of colors */ for (shade = SHADES-1; shade >= 0; shade--) { colors[ shade].red = color->r * 65535 / 255; colors[ shade].green = color->g * 65535 / 255; colors[ shade].blue = color->b * 65535 / 255; colors[ shade].pixel = cells[ shade]; color = color_list__get_prev( color_list); } if (shade == -1) { XStoreColors( display, colormap, colors, SHADES); } else { /* Problem with color list */ pixmap_index--; XFreeColors( display, colormap, cells, SHADES, /*nplanes=*/0); break; } static_data->pixmaps[ pixmap_index] = XCreatePixmap(display, window, static_data->width,static_data->height, DefaultDepth(display, DefaultScreen(display))); /* Draw the item onto the pixmap */ draw_item(static_data, display, clear_gc, colors, static_data->pixmaps[ pixmap_index], background); } /* printf("Created %d different colored balls (%d possible).\n", pixmap_index, color_list__get_count( color_list) / 4); */ color_list__destroy( color_list); static_data->num_colors = pixmap_index; } if ((static_data->num_colors == 0) || (DisplayCells( display, DefaultScreen(display)) == 2)) { /* Monochrome system or cannot allocate colors - just have 1 pixmap of a black ball */ draw_black_ball( display, background); } XFreeGC( display, clear_gc); XSetFunction( display, static_data->gc, GXxor); return static_data; } /* Draw an item in the passed colors on the passed pixmap */ static void draw_item( static_data, display, clear_gc, colors, pixmap, background) item_static_type static_data; Display *display; GC clear_gc; XColor *colors; Pixmap pixmap; Pixel background; { static struct { double x_offset, y_offset; /* The circle's offset on the item */ double width, height; /* The width & height of the circle */ } offsets[SHADES-1] = { 0.2, 0.2, 0.3, 0.3, 0.1, 0.1, 0.5, 0.5, 0.0, 0.0, 0.8, 0.8 }; int x; /* Clear pixmap */ XFillRectangle(display, pixmap, clear_gc, 0, 0, static_data->width, static_data->height); XSetForeground( display, static_data->gc, colors[SHADES-1].pixel ^ background); draw_circle(display, pixmap, static_data->gc, 0, 0, static_data->width-1, static_data->height-1); /* Draw the circles in the different shades. Shade SHADES-1 is darkest. */ for (x = SHADES-2; x >= 0; x--) { XSetForeground(display, static_data->gc, colors[x].pixel ^ background); draw_ball( display, pixmap, offsets[x].x_offset, offsets[x].y_offset, offsets[x].width, offsets[x].height); } /* Draw a white specularity smallest and offset */ XSetForeground(display, static_data->gc, WhitePixel(display, DefaultScreen(display)) ^ background); draw_ball( display, pixmap, 0.3, 0.3, 0.1, 0.1); /* Draw a little black shadow in the lower right corner */ XSetForeground(display, static_data->gc, BlackPixel(display, DefaultScreen(display)) ^ background); XDrawArc(display, pixmap, static_data->gc, 0, 0, static_data->width - 1, static_data->height - 1, 300*64, 35*64); } /* Draw a circle outline and filling at the size and offet determined by the ball's size */ static void draw_ball( display, pixmap, x_offset, y_offset, width, height) Display * display; Pixmap pixmap; double x_offset, y_offset; double width, height; { draw_circle( display, pixmap, static_data->gc, (int)(static_data->width * x_offset), (int)(static_data->height * y_offset), (int)(static_data->width * width), (int)(static_data->height * height)); } /* Draw a filled circle of the specified size and position */ static void draw_circle( display, pixmap, gc, x, y, width, height) Display * display; Pixmap pixmap; GC gc; int x, y; int width, height; { XDrawArc(display, pixmap, static_data->gc, x, y, width, height, 0, 360*64); XFillArc(display, pixmap, static_data->gc, x, y, width, height, 0, 360*64); } /* Draw a black ball onto the first pixmap */ static void draw_black_ball( display, background) Display * display; Pixel background; { Pixmap stipple_bitmap = XCreateBitmapFromData( display, RootWindow( display, DefaultScreen( display)), stipple_bits, stipple_width, stipple_height); static_data->pixmaps[ 0] = XCreatePixmap(display, RootWindow(display, DefaultScreen(display)), static_data->width, static_data->height, DefaultDepth( display, DefaultScreen(display))); /* Reset all pixels in the background so they will not have any effect when the pixmap is xor-copied */ XSetBackground(display, static_data->gc, 0); XFillRectangle(display, static_data->pixmaps[0], static_data->gc, 0, 0, static_data->width, static_data->height); XSetForeground(display, static_data->gc, BlackPixel(display,DefaultScreen(display)) ^background); /* Draw item */ draw_circle( display, static_data->pixmaps[0], static_data->gc, 0, 0, static_data->width-1, static_data->height-1); /* draw a grey specularity small and offset */ XSetStipple( display, static_data->gc, stipple_bitmap); XSetFillStyle( display, static_data->gc, FillOpaqueStippled); draw_ball( display, static_data->pixmaps[0], 0.2, 0.2, 0.3, 0.3); XSetFillStyle( display, static_data->gc, FillSolid); /* draw a white specularity smallest and offset */ XSetForeground(display, static_data->gc, WhitePixel(display,DefaultScreen(display)) ^background); draw_ball( display, static_data->pixmaps[0], 0.3, 0.3, 0.1, 0.1); static_data->num_colors = 1; XFreePixmap( display, stipple_bitmap); } #ifdef DEBUG item__print( item) item_type item; { printf("x,y_pos: %4d,%4d; x,y_vel: %4d,%4d, collide = %d\n", item__get_x( item), item__get_y( item), item__get_x_vel( item), item__get_y_vel( item), (int)static_data->ball_collide); } #endif xball-3.1.0/item.h000066400000000000000000000070241411065647700137420ustar00rootroot00000000000000/********************************************************************** * item.h - item (ball) declaration * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ #ifndef __ITEM_H__ #define __ITEM_H__ #include #include #include "misc.h" #include "intf.h" #define MAX_COLORS 256 #ifndef ELASTICITY #define ELASTICITY 90 /* Default */ #endif /* Static data shared for all items */ typedef struct { int width; int height; int half_width; /* Precalculated for copying pixmap offset */ int half_height; double elasticity; Bool ball_collide; Bool perpetual; Bool visible; char * rgb_txt; Display * display; Window window; Pixel background; GC gc; Pixmap pixmaps[ MAX_COLORS];/* Holds all item drawings */ int num_colors; /* Holds number of colors/pixmaps used */ int curr_pixmap; /* Holds pixmap index to use for next item*/ } item_static_struct_type, *item_static_type; typedef struct { item_static_type static_data; Display *display; Window window; intf x,y; /* Location of items center */ intf y_vel; /* vel < 0 means dropping, > 0 means climbing */ intf x_vel; /* vel < 0 means to left, > 0 means to right */ int rebounded; /* Used to determine if item collision */ /* had already been calculated for this item */ Bool shown; /* True if items image is visible */ Pixmap pixmap; /* Pixel map to use for drawing item */ } item_struct_type, *item_type; item_type item__create(/* display, window, x, y, x_vel, y_vel*/); void item__init(/*display, window, background*/); Bool item__initted(/**/); void item__destroy(/* item*/); void item__draw(/* item*/); void item__undraw(/* item, x, y*/); void item__redraw(/* item*/); void item__erase(/* item*/); void item__redraw(/* item*/); void item__move_pos(/* item, x, y*/); void item__randomize(/* item, min_x_vel, max_x_vel, min_y_vel, max_y_vel*/); void item__move(/* item, room, items*/); void item__rebound_item(/* moved_item, fixed_item*/); void item__set_elasticity_cb(/*w, datap_ptr, call_data*/); int item__get_width(/**/); int item__get_height(/**/); void item__perpetual_mcb(/*w, item, call_data, extra*/); void item__collide_mcb(/*w, item, call_data, extra*/); void item__set_perpetual(/* set */); void item__set_ball_collide(/* set*/); void item__set_visible(/*visible*/);; /* Inline functions */ #define item__set_x_vel( item, vel) ((item)->x_vel = int2intf(vel)) #define item__set_y_vel( item, vel) ((item)->y_vel = int2intf(vel)) #define item__get_x_vel( item) (intf2int((item)->x_vel)) #define item__get_y_vel( item) (intf2int((item)->y_vel)) #define item__get_x( item) (intf2int((item)->x)) #define item__get_y( item) (intf2int((item)->y)) #define item__erase( item) (item__undraw( (item), (item)->x, (item)->y)) #define item__stopped(item, room) \ (item->y_vel == 0) && \ (ABS(item->y) >= room__get_floor(room) - room__get_gravity(room)) && \ (item->x_vel == 0) #endif xball-3.1.0/items.c000066400000000000000000000122451411065647700141210ustar00rootroot00000000000000/********************************************************************** * items.c - definition of item list object. * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ /* System Headers */ #include /* Local headers */ #include "items.h" #include "room.h" #if 0 /* External variables */ extern item_static_type static_data; #endif /* Create the items object */ items_type items__create() { items_type items = (items_type)malloc( sizeof( items_struct_type)); items->list = list__create(); return items; } /* Destroy the items object */ items_type items__destroy(items) items_type items; { items__destroy_all( items); list__destroy( items->list); free( items); } /* Return the first item in the list */ item_type items__get_first( items) items_type items; { return (item_type)list__get_first(items->list); } /* Return the next item in the list */ item_type items__get_next( items) items_type items; { return (item_type)list__get_next(items->list); } /* Add an item to the list of items */ void items__add( items, item) items_type items; item_type item; { list__add_end( items->list, (void *)item); } /* Destroy all items in the item list */ void items__destroy_all( items) items_type items; { item_type item; for (item = (item_type)list__remove_last( items->list); item != (item_type)0; item = (item_type)list__remove_last( items->list)) { item__destroy( item); } } /* Create a new item and add it to the item list */ void items__new_item( items, x, y, x_vel, y_vel) items_type items; int x,y; int x_vel,y_vel; { list__add_end( items->list, (void *)item__create(x, y, x_vel, y_vel)); } /* Perform the iterative simulation movement for all items on the list */ /* If an item dies, destroy it */ void items__move_items( items, room) items_type items; room_type room; { item_type item; /* Move each item on the screen */ for (items->current = 0; items->current < list__get_count( items->list); items->current++) { item = (item_type)list__get_cell(items->list, items->current); item__move( item, room, items); if (item__stopped( item, room)) { list__remove( items->list, items->current); items->current--; item__destroy( item); } } } /* Simulate moving the items backwards count iterations */ /* The iterations are not shown in the screen */ /* Note that gravity and elastivity are not handled */ void items__move_items_backwards( items, room, count) items_type items; room_type room; int count; { item_type item; /* Reverse all items' velocities and erase them from the screen */ for (items->current = 0; items->current < list__get_count( items->list); items->current++) { item = (item_type)list__get_cell(items->list, items->current); item->x_vel = -item->x_vel; item->y_vel = -item->y_vel; item__erase( item); } /* Move them all count iterations (they will go backwards) */ while (count-- > 0) { /* Move each item on the screen */ for (items->current = 0; items->current < list__get_count( items->list); items->current++) { item = (item_type)list__get_cell(items->list, items->current); item__move( item, room, items); } } /* Reverse all the items' velocities again and draw them */ for (items->current = 0; items->current < list__get_count( items->list); items->current++) { item = (item_type)list__get_cell(items->list, items->current); item->x_vel = -item->x_vel; item->y_vel = -item->y_vel; item__draw( item); } } /* Make all items visible or invisible */ void items__set_visible( items, visible) items_type items; Bool visible; { if (visible) item__set_visible( True); for (items->current = 0; items->current < list__get_count( items->list); items->current++) { if (visible) item__draw( (item_type)list__get_cell(items->list,items->current)); else item__erase((item_type)list__get_cell(items->list,items->current)); } if (!visible) item__set_visible( False); } /* Rebound the given item again all items in the item list */ void items__rebound_items( item, items) item_type item; items_type items; { int i; for (i = items->current+1; i < list__get_count( items->list); i++) { item__rebound_item(item, (item_type)list__get_cell(items->list, i)); } } #ifdef DEBUG void items__print( items) items_type items; { int i; for (i = 0; i < list__get_count( items->list); i++) { printf("%4d: ", i); item__print( (item_type)list__get_cell(items->list, i)); } } #endif xball-3.1.0/items.h000066400000000000000000000024031411065647700141210ustar00rootroot00000000000000/********************************************************************** * file - description * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ #ifndef __ITEMS_H__ #define __ITEMS_H__ #include "list.h" #include "item.h" typedef struct { list_type list; int current; /* Used to increase efficiency */ } items_struct_type, *items_type; items_type items__create(/**/); items_type items__destroy(/*items*/); item_type items__get_first(/* items */); item_type items__get_next(/* items */); void items__add(/* items, item */); void items__destroy_all(/* items*/); void items__new_item(/* items, x, y, x_vel, y_vel */); void items__move_items(/* items, room*/); void items__move_items_backwards(/* items, room, count*/); void items__rebound_items(/* items, item*/); void items__set_visible( /*items, visible*/); /* Inline functions */ #define items__get_count( items) (list__get_count((items)->list)) #endif xball-3.1.0/list.c000066400000000000000000000122421411065647700137500ustar00rootroot00000000000000/********************************************************************** * list.c - defines a void * list object * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ /* System Headers */ #include /* Local headers */ #include "list.h" /* Functions */ static void list_double(/* list*/); static void *get_item(/* list, index*/); /* Public object methods */ /* Create the list object */ list_type list__create() { list_type list; list = (list_type)malloc( sizeof( list_struct)); list->count = 0; list->curr_item = 0; list->max_count = LIST_INITIAL_SIZE; list->data = (void **)malloc( sizeof( void *) * list->max_count); return list; } /* Destroy the list object. Items in the list are not freed */ void list__destroy( list) list_type list; { free( list->data); free( list); } /* Add an item to the start of the list */ void *list__add_start( list, data_item) list_type list; void *data_item; { int i; if (list->count == list->max_count) list_double( list); /* Copy all item down by one */ for (i = list->count-1; i > 0; i--) list->data[ i] = list->data[ i - 1]; list->data[ 0] = data_item; list->count++; return data_item; } /* Add an item to the end of the list */ void *list__add_end( list, data_item) list_type list; void *data_item; { if (list->count == list->max_count) list_double( list); list->data[ list->count] = data_item; list->count++; return data_item; } /* Get the first item in the list */ void *list__get_first( list) list_type list; { list->curr_item = 0; return get_item( list, list->curr_item); } /* Get the next item in the list. NULL is returned if there are no more items in the list */ void *list__get_next( list) list_type list; { list->curr_item++; return get_item( list, list->curr_item); } /* Return the last item in the list */ void *list__get_last( list) list_type list; { list->curr_item = list->count - 1; return get_item( list, list->curr_item); } /* Return the previous item in the list. If there are no more items, return NULL. */ void *list__get_prev( list) list_type list; { if (list->curr_item > 0) { list->curr_item--; return get_item( list, list->curr_item); } else return (void *)0; } /* Remove the last item in the list. The item removed is returned. */ void *list__remove_last( list) list_type list; { void *data_item = (void *)0; if (list->count > 0) { list->count--; data_item = list->data[ list->count]; list->data[ list->count] = (void *)0; } return data_item; } /* Remove the first item in the list. The item removed is returned. */ void *list__remove_first( list) list_type list; { int i; void *data_item = (void *)0; if (list->count > 0) { list->count--; data_item = list->data[ 0]; /* Shift data pointers up one */ for (i = 0; i < list->count; i++) list->data[ i] = list->data[ i+1]; list->data[ list->count] = (void *)0; } return data_item; } /* Remove the current item in the list, as positioned by get_first, next, last, prev. The current item is now the item after the one removed */ void *list__remove_curr( list) list_type list; { int i; void *data_item = (void *)0; if (list->curr_item < list->count) { data_item = list->data[ list->curr_item]; for (i = list->curr_item; i < list->count; i++) list->data[ i] = list->data[ i+1]; list->data[ list->count] = (void *)0; } return data_item; } /* Remove an item at the specified position in the list */ void *list__remove( list, ind) list_type list; int ind; { int i; void *data_item = (void *)0; if (ind >= 0 && ind < list->count) { data_item = list->data[ ind]; for (i = ind; i < list->count - 1; i++) list->data[ i] = list->data[ i+1]; list->data[ list->count] = (void *)0; } list->count--; return data_item; } /* Remove all items in the list. The objects are not freed */ void list__remove_all( list) list_type list; { int i; for (i = 0; i < list->count; i++) list->data[ i] = (void *)0; list->count = 0; } /* Private object methods */ /* Return the specified object at a specified position */ static void *get_item( list, ind) list_type list; int ind; { if (ind < list->count) return list->data[ ind]; else return (void *)0; } /* Double the size of the list */ static void list_double( list) list_type list; { int i; /* Double the list's size */ void **tmp_data = list->data; list->max_count *= 2; list->data = (void **)malloc( sizeof( void *) * list->max_count); for (i = 0; i < list->count; i++) list->data[ i] = tmp_data[ i]; free( tmp_data); } xball-3.1.0/list.h000066400000000000000000000026461411065647700137640ustar00rootroot00000000000000/********************************************************************** * list.h - declares the list object * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ #ifndef __LIST_H__ #define __LIST_H__ typedef struct { void **data; int count; int max_count; int curr_item; } list_struct, *list_type; #define LIST_INITIAL_SIZE 100 list_type list__create(); void list__destroy(/* list */); void * list__add_start(/* list, data_item */); void * list__add_end(/* list, data_item */); void * list__get_first(/* list */); void * list__get_next(/* list */); void * list__get_last(/* list */); void * list__get_prev(/* list */); void * list__remove_last(/* list */); void * list__remove_first(/* list */); void list__remove_all(/* list */); void * list__remove(/* list, index */); /* Inline functions */ #define list__get_cell(list, index) ((list)->data[ index]) #define list__set_cell(list, index) ((list)->data[ index]) #define list__get_count(list) ((list)->count) #endif xball-3.1.0/man.xbm000066400000000000000000000001621411065647700141120ustar00rootroot00000000000000#define man_width 5 #define man_height 7 static char man_bits[] = { 0x11, 0x11, 0x0a, 0x04, 0x0e, 0x15, 0x15}; xball-3.1.0/menu.c000066400000000000000000000431311411065647700137420ustar00rootroot00000000000000/********************************************************************** * menu.c - defines the menu object * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ /* System Headers */ #include #include #include #include /* For isspace */ #include #include #ifdef MOTIF #include #include #include #include #include #include #endif #ifdef ATHENA #include #include #include #include #include #include #endif /* Local headers */ #include "menu.h" #include "misc.h" #include "table.h" #include "miscx.h" #ifdef ATHENA #include "on.xbm" #include "off.xbm" #endif /* Macros */ #define WPATH_LEN 40 /* File scope variables */ typedef struct { char *menu_def; } app_data,*app_data_ptr; static app_data res_data; static XtResource resources[] = { { "menuDef", "MenuDef", XtRString, sizeof(char *), XtOffset( app_data_ptr, menu_def), XtRString, NULL} }; /* Structures */ typedef struct { char * name; menuCallbackProc proc; caddr_t closure; } menuCallback; typedef struct { char * menu_callback_name; char * optional_params; char * widget_class; } closure_type; /* Functions */ static void menu_callback(/* w, menu, call_data*/); static void create_menus(/*menu, menubar, menu_def*/); static void create_menubar(/* menu, form, name*/); static void set_widget_and_do_callback(/* menu, w, set*/); static void set_widget_state(/* menu, w, state*/); static Widget get_menu_widget(/* menu, widget_name*/); static Bool get_widget_state(/* menu, w*/); static Widget create_pulldown(/* menubar, menu_button_name, pull_down_name*/); static WidgetClass * get_pushbutton_class(/**/); static char * get_pushbutton_callback(/**/); static WidgetClass * get_separator_class(/**/); static char * get_separator_callback(/**/); static WidgetClass * get_togglebutton_class(/**/); static char * get_togglebutton_callback(/**/); /* Public object methods */ /* Create the menu object. The menubar definition resource is loaded and used to create the widgets that make up the menu system. */ menu_type menu__create( form) Widget form; { menu_type menu = XtNew( menu_struct_type); menu->mc_table = table__create(); menu->closure_table = table__create(); create_menubar( menu, form, "menuBar"); XtGetApplicationResources(get_toplevel(form), (XtPointer)&res_data, resources, XtNumber(resources), (ArgList)NULL,(Cardinal)0); convert_newlines( res_data.menu_def); create_menus( menu, menu->menubar, res_data.menu_def); XtManageChild( menu->menubar); return menu; } /* Destroy the menu system object */ void menu__destroy(menu) menu_type menu; { table__destroy( menu->mc_table); table__destroy( menu->closure_table); XtDestroyWidget( menu->menubar); XtFree( (char *)menu); } /* Registers an available callback. This callback can then be referenced by the menu definition resource. If the callback is referenced, the menuCallbackProc is invoked. */ void menu__add_callback( menu, action_name, menu_callback_proc, user_data) menu_type menu; char *action_name; menuCallbackProc menu_callback_proc; caddr_t user_data; { /* Store available callback into table */ menuCallback *menu_node = XtNew( menuCallback); menu_node->name = my_strdup( action_name); menu_node->proc = menu_callback_proc; menu_node->closure = user_data; table__store( menu->mc_table, menu_node->name, (void *)menu_node); } /* Given the menu item widget name, toggles the widget's state and performs any menu callbacks registered for the callback that the widget references */ void menu__set_toggle( menu, widget_name, set) menu_type menu; char * widget_name; Bool set; { Widget w = get_menu_widget( menu, widget_name); if (w == (Widget)0) return; set_widget_and_do_callback( menu, w, set); } /* Return the state of the named widget's toggle state */ Bool menu__get_toggle( menu, widget_name) menu_type menu; char *widget_name; { Widget w = get_menu_widget( menu, widget_name); if (w == (Widget)0) return False; return get_widget_state( menu, w); } /* Set or unset the sensitivity of the specified menu widget */ void menu__set_sensitivity( menu, widget_name, sensitive) menu_type menu; char * widget_name; Boolean sensitive; { Widget w = get_menu_widget( menu, widget_name); if (w == (Widget)0) return; XtVaSetValues( w, XtNsensitive, sensitive, NULL); } /* Returned the named menu widget, or NULL if not found */ static Widget get_menu_widget( menu, widget_name) menu_type menu; char * widget_name; { Widget w; char widget_path[50]; sprintf(widget_path,"*%s", widget_name); w = XtNameToWidget( menu->menubar, widget_path); if (w == (Widget)0) { fprintf(stderr,"get_menu_widget: Cannot find menu widget '%s'\n", widget_name); } return w; } /* menu_callback Called for any menu item that is selected. Sets up the parameters and makes the callback to the proper menuCallbackProc function. */ static void menu_callback( w, menu, call_data) Widget w; menu_type menu; caddr_t * call_data; { closure_type * closure; menuCallback * mc_node; menuCallbackStruct menu_cbs; /* Get data passed when callback was referenced in menu configuration */ closure = (closure_type *)table__retrieve( menu->closure_table, XtName(w)); if (closure == (closure_type *)0) { fprintf(stderr,"Cannot find menu callback closure for widget %s.\n", XtName(w)); return; } if (strcmp( closure->widget_class, "ToggleButton") == 0) { #ifdef ATHENA /* We have to toggle the athena widget by hand */ set_widget_state( menu, w, !get_widget_state( menu, w)); #endif menu_cbs.set = get_widget_state( menu, w); } else /* Non-toggle button - just put any value there */ menu_cbs.set = True; /* Get the callback information stored when the callback was registered */ mc_node = (menuCallback *)table__retrieve( menu->mc_table, closure->menu_callback_name); if (mc_node == (menuCallback *)0) { fprintf(stderr,"Cannot find menu callback '%s'\n", closure->menu_callback_name); return; } /* Call the menu callback function */ (*mc_node->proc)(w, mc_node->closure, &menu_cbs, closure->optional_params); } /********************************************************************** * Menu config text format: * * XBall.menu: * pulldownName~ * widgetName,widgetClass,menuCallbackName,optionalParams...~ * . * . * . * pulldownName2~ * widgetName,widgetClass,menuCallbackName,optionalParams...~ * . * . * . **********************************************************************/ static void create_menus(menu, menubar, menu_def) menu_type menu; Widget menubar; char * menu_def; { Widget pull_down; Widget button; char pull_down_name[30]; char * curr_pt = menu_def; char * comma; char * newline; char * next_pt; WidgetClass * w_class_p; Arg args[10]; int n; while (curr_pt != NULL) { /*next_pt = strpbrk( curr_pt, "\"{}");*/ /* Search for first non-space */ for (next_pt = curr_pt; next_pt != '\0' && isspace( *next_pt); next_pt++) /* Do nothing*/; if (*next_pt == '\0') break; switch (*next_pt) { case '{': printf("Sorry - '{' not yet implemented\n"); curr_pt = strchr( next_pt, '\n'); /* Go to next line */ break; case '}': printf("Sorry - '}' not yet implemented\n"); curr_pt = strchr( next_pt, '\n'); /* Go to next line */ break; default: comma = strchr( next_pt, ','); newline = strpbrk( next_pt, "\n "); /*newline = strchr( next_pt, '\n');*/ if (newline == NULL || comma == NULL || newline < comma) { /* At a menu header since no commas before the next newline */ char *menu_button_name = get_string( next_pt); sprintf(pull_down_name, "%sPullDown", menu_button_name); pull_down = create_pulldown( menubar, menu_button_name, pull_down_name); free( menu_button_name); curr_pt = strchr( next_pt, '\n'); /* Go to next line */ } else { /* At a menu item. Get the parameters */ char *item_str = get_string( next_pt); char *w_name; char *w_class; char *menu_callback_name; char *optional_params; char *callback; w_name = strtok( item_str, ","); w_class = strtok( (char *)0, ","); menu_callback_name = strtok( (char *)0, ","); optional_params = strtok( (char *)0, "\n"); n = 0; if (strcmp( w_class, "PushButton") == 0) { w_class_p = get_pushbutton_class(); callback = get_pushbutton_callback(); } else if (strcmp( w_class, "Separator") == 0) { w_class_p = get_separator_class(); callback = get_separator_callback(); } else if (strcmp( w_class, "ToggleButton") == 0) { w_class_p = get_togglebutton_class(); callback = get_togglebutton_callback(); #ifdef ATHENA /* Need to initialize some values for the athena toggle */ XtSetArg(args[n], XtNleftBitmap, menu->off_bitmap); n++; XtSetArg(args[n], XtNleftMargin, off_width+4); n++; XtSetArg(args[n], XtNvertSpace, 50); n++; #endif } button = XtCreateManagedWidget( w_name, *w_class_p, pull_down, args, n); if (callback != (char *)0) { closure_type * closure; if (optional_params == (char *)0) optional_params = ""; closure = (closure_type *)XtNew( closure_type); closure->menu_callback_name= my_strdup(menu_callback_name); closure->optional_params = my_strdup( optional_params); closure->widget_class = my_strdup( w_class); XtAddCallback( button, callback,menu_callback, (XtPointer)menu); table__store( menu->closure_table, w_name,(void *)closure); } free( item_str); curr_pt = strchr( next_pt, '\n'); /* Go to next line */ } break; } } } /* Private object methods */ #ifdef MOTIF static void create_menubar( menu, form, name) menu_type menu; Widget form; char * name; { menu->menubar = XmCreateMenuBar( form, name, NULL, 0); } /* Sets the toggle widget to the specified value and performs menu callbacks to inform of the new value */ static void set_widget_and_do_callback( menu, w, set) menu_type menu; Widget w; Bool set; { set_widget_state( menu, w, set); XtCallCallbacks( w, XmNvalueChangedCallback, (char *)0); } /* Ser the state of the Motif menu "toggle" widget */ static void set_widget_state( menu, w, state) menu_type menu; Widget w; Bool state; { XtVaSetValues( w, XmNset, state, NULL); } /* Returns the state of the Motif menu widget */ static Bool get_widget_state( menu, w) menu_type menu; Widget w; { return XmToggleButtonGadgetGetState( w); } /* Create the pull down menu for Motif. If the menu_button is named "help", it is designated the menu help button. */ static Widget create_pulldown( menubar, menu_button_name, pull_down_name) Widget menubar; char * menu_button_name; char * pull_down_name; { Widget pull_down; Widget button; pull_down = XmCreatePulldownMenu( menubar, pull_down_name, NULL, 0); button = XtVaCreateManagedWidget( menu_button_name, xmCascadeButtonWidgetClass, menubar, XmNsubMenuId, pull_down, NULL); if (strcmp( menu_button_name, "help") == 0) { XtVaSetValues(menubar, XmNmenuHelpWidget, button, NULL); } return pull_down; } static WidgetClass * get_pushbutton_class() { return &xmPushButtonGadgetClass; } static char * get_pushbutton_callback() { return XmNactivateCallback; } static WidgetClass * get_separator_class() { return &xmSeparatorGadgetClass; } static char * get_separator_callback() { return (char *)0; } static WidgetClass * get_togglebutton_class() { return &xmToggleButtonGadgetClass; } static char * get_togglebutton_callback() { return XmNvalueChangedCallback; } #endif #ifdef ATHENA menu_type global_action_menu; /* We need to have a global menu object, because actions do not pass client_data */ static void menu_action(/* w, event, params, num_params*/); static void create_menubar( menu, form, name) menu_type menu; Widget form; char * name; { XtActionsRec action; menu->menubar = XtVaCreateManagedWidget( name, boxWidgetClass, form, XtNorientation, XtorientHorizontal, XtNresizable, True, NULL); menu->off_bitmap = XCreateBitmapFromData( XtDisplay( form), RootWindowOfScreen( XtScreen( form)), off_bits, off_width, off_height); menu->on_bitmap = XCreateBitmapFromData( XtDisplay( form), RootWindowOfScreen( XtScreen( form)), on_bits, on_width, on_height); global_action_menu = menu; /* Add a global action for menu actions */ /* Athena needs global actions to implement "menu accelerators" */ action.string = "menu_action"; action.proc = menu_action; XtAppAddActions( XtWidgetToApplicationContext( menu->menubar), &action, (Cardinal)1); } /* Sets the toggle widget to the specified value and performs menu callbacks to inform of the new value */ static void set_widget_and_do_callback( menu, w, set) menu_type menu; Widget w; Bool set; { /* We set the toggle to the opposite of what we finally want, because of the way the Athena menu callback works with toggles is that it toggles the value for each callback. */ set_widget_state( menu, w, !set); XtCallCallbacks( w, XtNcallback, (char *)0); } /* Set the state of the athena menu "toggle" widget */ static void set_widget_state( menu, w, state) menu_type menu; Widget w; Bool state; { XtVaSetValues(w, XtNleftBitmap, state ? menu->on_bitmap : menu->off_bitmap, NULL); } /* Returns the state of the Athena menu "toggle" widget */ static Bool get_widget_state( menu, w) menu_type menu; Widget w; { Pixmap pixmap_set; XtVaGetValues( w, XtNleftBitmap, &pixmap_set, NULL); return (pixmap_set == menu->on_bitmap); } /* Create the Athena pulldown widget */ static Widget create_pulldown( menubar, menu_button_name, pull_down_name) Widget menubar; char * menu_button_name; char * pull_down_name; { Widget button; Widget pull_down; button = XtVaCreateManagedWidget( menu_button_name, menuButtonWidgetClass, menubar, NULL); pull_down = XtCreatePopupShell( "menu", simpleMenuWidgetClass, button, NULL, 0); return pull_down; } static WidgetClass * get_pushbutton_class() { return &smeBSBObjectClass; } static char * get_pushbutton_callback() { return XtNcallback; } static WidgetClass * get_separator_class() { return &smeLineObjectClass; } static char * get_separator_callback() { return (char *)0; } static WidgetClass * get_togglebutton_class() { return &smeBSBObjectClass; } static char *get_togglebutton_callback() { return XtNcallback; } /* This global action is used to implement keyboard accelerators in Athena. To get a keyboard accelerator, a widget sets it translations to call the global "menu_callback" action, passing the menu action they want to perform. */ static void menu_action( w, event, params, num_params) Widget w; XEvent * event; String * params; Cardinal num_params; { char buff[50]; menu_type menu = global_action_menu; /* Get the action name passed to the menu_action */ if (num_params < 1) { fprintf(stderr, "No menu action name passed to the menu_action action\n"); return; } /* Type of menu action is passed to the action */ w = get_menu_widget( menu, params[0]); if (w == (Widget)0) return; menu_callback( w, menu, NULL); } #endif xball-3.1.0/menu.h000066400000000000000000000026021411065647700137450ustar00rootroot00000000000000/********************************************************************** * menu,h - Menu system declarations * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ #ifndef __MENU_H__ #define __MENU_H__ #include #include "table.h" typedef struct { table_type mc_table; /* Table of callbacks avalibale for use */ table_type closure_table; /* Table of callbacks added */ Widget menubar; #ifdef ATHENA Pixmap on_bitmap; Pixmap off_bitmap; #endif } menu_struct_type, *menu_type; typedef struct { int set; } menuCallbackStruct; typedef void (*menuCallbackProc)(/* Widget, caddr_t, menuCallbackStruct *, char * */); menu_type menu__create(/* form */); void menu__destroy(/*menu*/); void menu__add_callback(/* menu, action_name, menu_callback_proc, user_data */); void menu__set_toggle(/* menu, widget_name, set*/); Bool menu__get_toggle(/* menu, widget_name*/); void menu__set_sensitivity(/* menu, widget_name, sensitive*/); #endif xball-3.1.0/misc.c000066400000000000000000000031311411065647700137250ustar00rootroot00000000000000/********************************************************************** * misc.c - Misc functions * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ /* System Headers */ #include #include #include /* Given a string 'text\nmore text', allocates and returns the string before the newline. */ char *get_string( str) char *str; { char *tmp; char *newline = strchr(str,'\n'); int len; if (newline == (char *)0) return (char *)0; len = newline - str; tmp = malloc( len + 1); strncpy( tmp, str, len + 1); tmp[ len] = '\0'; return tmp; } /* Because some systems do not have strdup */ char *my_strdup( str) char *str; { char *ret_str = malloc( strlen( str) + 1); strcpy( ret_str, str); return ret_str; } /* Return a random value in the specified range */ long rand_range( min, max) long min, max; { if (min == max) return min; else return random() % (max - min) + min; } /* Change '~' to \n in the passed string */ /* This silliness is due to fallback resources not handling \n in the resource string */ void convert_newlines( str) char *str; { char *curr = strchr( str, '~'); while (curr != 0) { *curr = '\n'; curr = strchr( curr, '~'); } } xball-3.1.0/misc.h000066400000000000000000000017321411065647700137370ustar00rootroot00000000000000/********************************************************************** * misc.h - misc function declarations * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ #ifndef __MISC_H__ #define __MISC_H__ #include char * get_string(/* char *str */); char * my_strdup(/* char *str */); int rand_range(/* min, max*/); void convert_newlines(/* str*/); #define ABS(x) ((x) < 0 ? -(x) : (x)) #define SWAP(x,y,type) { type t; t = (x); (x) = (y); (y) = t; } #undef MIN #undef MAX #define MIN(x,y) ((x) > (y) ? (y) : (x)) #define MAX(x,y) ((x) < (y) ? (y) : (x)) #ifndef EXIT_FAILURE #define EXIT_FAILURE (int)1 #define EXIT_SUCCESS (int)0 #endif #endif xball-3.1.0/miscx.c000066400000000000000000000033071411065647700141220ustar00rootroot00000000000000/********************************************************************** * miscx.c - Misc X, Xt and Xmu related functions * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ /* System Headers */ #include #include #include #include /********************************************************************** * setupCoverters - Setup user-defined Xt type converters. * * void setupConverters() * * Description: * Sets up string to widget converter. **********************************************************************/ void setupConverters() { static XtConvertArgRec parentCvtArgs[] = { {XtBaseOffset, (caddr_t)XtOffset(Widget, core.parent), sizeof(Widget)} }; XtAddConverter(XtRString, XtRWindow, XmuCvtStringToWidget, parentCvtArgs, XtNumber(parentCvtArgs)); } /********************************************************************** * get_toplevel - Return the toplevel widget in the widget heirarchy. * * Widget get_toplevel(Widget w) * * * w - Any widget in the heirarchy * **********************************************************************/ Widget get_toplevel(w) Widget w; { /* Get the toplevel shell widget to change the cursor for all windows */ while (!XtIsTopLevelShell( w)) w = XtParent( w); return w; } xball-3.1.0/miscx.h000066400000000000000000000011301411065647700141170ustar00rootroot00000000000000/********************************************************************** * miscx.h - Misc X, Xt and Xmu related functions * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ #ifndef __MISCX_H__ #define __MISCX_H__ void setupConverters(); Widget get_toplevel(/*w*/); #endif xball-3.1.0/missing000077500000000000000000000240321411065647700142300ustar00rootroot00000000000000#! /bin/sh # Common stub for a few missing GNU programs while installing. # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi case "$1" in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case "$1" in -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file tar try tar, gnutar, gtar, then tar without non-portable flags yacc create \`y.tab.[ch]', if possible, from existing .[ch]" ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing 0.4 - GNU automake" ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; aclocal*) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case "$f" in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is needed, and you do not seem to have it handy on your system. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison|yacc) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.h fi ;; esac fi if [ ! -f y.tab.h ]; then echo >y.tab.h fi if [ ! -f y.tab.c ]; then echo 'main() { return 0; }' >y.tab.c fi ;; lex|flex) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if [ ! -f lex.yy.c ]; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` fi if [ -f "$file" ]; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit 1 fi ;; makeinfo) if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then # We have makeinfo, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` fi touch $file ;; tar) shift if test -n "$run"; then echo 1>&2 "ERROR: \`tar' requires --run" exit 1 fi # We have already tried tar in the generic part. # Look for gnutar/gtar before invocation to avoid ugly error # messages. if (gnutar --version > /dev/null 2>&1); then gnutar "$@" && exit 0 fi if (gtar --version > /dev/null 2>&1); then gtar "$@" && exit 0 fi firstarg="$1" if shift; then case "$firstarg" in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" "$@" && exit 0 ;; esac case "$firstarg" in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" "$@" && exit 0 ;; esac fi echo 1>&2 "\ WARNING: I can't seem to be able to run \`tar' with the given arguments. You may want to install GNU tar or Free paxutils, or check the command line arguments." exit 1 ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and you do not seem to have it handy on your system. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 xball-3.1.0/mkinstalldirs000066400000000000000000000037041411065647700154370ustar00rootroot00000000000000#! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Public domain errstatus=0 dirmode="" usage="\ Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." # process command line arguments while test $# -gt 0 ; do case $1 in -h | --help | --h*) # -h for help echo "$usage" 1>&2 exit 0 ;; -m) # -m PERM arg shift test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } dirmode=$1 shift ;; --) # stop option processing shift break ;; -*) # unknown option echo "$usage" 1>&2 exit 1 ;; *) # first non-opt arg break ;; esac done for file do if test -d "$file"; then shift else break fi done case $# in 0) exit 0 ;; esac case $dirmode in '') if mkdir -p -- . 2>/dev/null; then echo "mkdir -p -- $*" exec mkdir -p -- "$@" fi ;; *) if mkdir -m "$dirmode" -p -- . 2>/dev/null; then echo "mkdir -m $dirmode -p -- $*" exec mkdir -m "$dirmode" -p -- "$@" fi ;; esac for file do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d do pathcomp="$pathcomp$d" case $pathcomp in -*) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr else if test ! -z "$dirmode"; then echo "chmod $dirmode $pathcomp" lasterr="" chmod "$dirmode" "$pathcomp" || lasterr=$? if test ! -z "$lasterr"; then errstatus=$lasterr fi fi fi fi pathcomp="$pathcomp/" done done exit $errstatus # Local Variables: # mode: shell-script # sh-indentation: 2 # End: # mkinstalldirs ends here xball-3.1.0/names.h000066400000000000000000000012771411065647700141130ustar00rootroot00000000000000#ifndef __NAMES_H__ #define __NAMES_H__ #define GRAVITY_BAR "gravityBar" #define ELASTICITY_BAR "elasticityBar" #define FILE_SB "fileSB" #define HELP_DIALOG "help_dialog" #define RUN_DEMO "runDemo" #define STOP_DEMO "stopDemo" #define CLEAR "clear" #define RANDOMIZE "randomize" #define LOAD_BITMAP "loadBitmap" #define QUIT "quit" #define PERPETUAL "perpetual" #define BALL_COLLIDE "ballCollide" #define STEP_SIM "stepSim" #define HALT_SIM "haltSim" #define ABOUT "about" #define ON_MENUS "onMenus" #define ON_SCROLL "onScroll" #define ON_BUTTONS "onButtons" #define ON_DEMOS "onDemos" #define ON_PARAMS "onParams" #endif xball-3.1.0/off.xbm000066400000000000000000000003051411065647700141100ustar00rootroot00000000000000#define off_width 10 #define off_height 10 static char off_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; xball-3.1.0/on.xbm000066400000000000000000000003021411065647700137470ustar00rootroot00000000000000#define on_width 10 #define on_height 10 static char on_bits[] = { 0x00, 0x03, 0x80, 0x01, 0x80, 0x00, 0xc0, 0x00, 0x40, 0x00, 0x61, 0x00, 0x23, 0x00, 0x36, 0x00, 0x1c, 0x00, 0x18, 0x00}; xball-3.1.0/patchlevel.h000066400000000000000000000000251411065647700151250ustar00rootroot00000000000000#define PATCHLEVEL 0 xball-3.1.0/room.c000066400000000000000000000355331411065647700137610ustar00rootroot00000000000000/********************************************************************** * room.c - Room object definition * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ /* System Headers */ #include #include #include #include #ifdef MOTIF #include #endif #ifdef ATHENA #include #endif /* Local headers */ #include "room.h" #include "misc.h" #include "miscx.h" #include "scrollbar.h" /* Macros */ /* This is the spacing between the balls representing pixels on the bitmap */ #define SF 1.5 /* FIX - make a resource */ /* Functions */ static void redisplay_cb(/*w, room, call_data*/); static void resize_cb(/*w, datap_ptr, call_data*/); static void process_input_cb(/*w, room, call_data*/); static void wait_for_resize(/* room*/); static Widget create_canvas(/* parent, name*/); /* Object public methods */ /* Create the room object */ room_type room__create( form_w, items, file_sel) Widget form_w; items_type items; file_sel_type file_sel; { Dimension right_wall; Dimension floor; Widget canvas; room_type room = XtNew( room_struct_type); room->item = (item_type)0; room->items = items; room->file_sel = file_sel; room->left_wall = int2intf(0); room->ceiling = int2intf(0); /* room->gravity is set in xball_sys via scrollbar callback */ room->button1 = False; room->button2 = False; room->button3 = False; room->canvas = canvas = create_canvas( room, form_w, "canvas"); XtVaGetValues(canvas, XtNbackground, &room->background, XtNwidth, &right_wall, XtNheight, &floor, NULL); room->right_wall = int2intf( right_wall); room->floor = int2intf( floor); return room; } /* Destroy the room object */ void room__destroy( room) room_type room; { XtDestroyWidget( room->canvas); XtFree( (char *)room); } /* Called when the scrollbar changes. Sets the gravity value */ void room__set_gravity_cb(w, room, call_data) Widget w; room_type room; scrollbarCallbackStruct * call_data; { room->gravity = call_data->value; } /* A menu callback that clears the room of all balls */ void room__clear_mcb(w, room, call_data, extra) Widget w; room_type room; caddr_t call_data; char * extra; { items__destroy_all( room->items); } /* A menu callback that randomizes all balls in the room */ void room__randomize_mcb(w, room, call_data, extra) Widget w; room_type room; caddr_t call_data; char * extra; { item_type item; for (item = items__get_first( room->items); item != (item_type)0; item = items__get_next( room->items)) { item__randomize( item, -16, 16, -16, 16); } } /* A menu callback that queries the user for a bitmap and then loads it */ void room__load_bitmap_mcb(w, room, call_data, extra) Widget w; room_type room; caddr_t call_data; char * extra; { char *file_name = file_sel__display( room->file_sel, "Load Bitmap"); if (file_name != (char *)0) room__load_bitmap( room, file_name, 10, 10); } /* Loads the specified bitmap file at the specified position in the room */ void room__load_bitmap(room, filename, pos_x, pos_y) room_type room; char * filename; int pos_x; int pos_y; { unsigned width, height; /* Bitmap dimensions */ int x_hot, y_hot; Pixmap bitmap; /* The bitmap as a pixmap */ XImage * ximage; /* The bitmap as an image */ int x, y; int status; Dimension new_width, new_height; status = XReadBitmapFile(XtDisplay(room->canvas), XtWindow(room->canvas), filename, &width, &height, &bitmap, &x_hot, &y_hot); switch (status) { case BitmapOpenFailed: fprintf(stderr, "room__load_bitmap: Could not open bitmap file %s\n",filename); return; break; case BitmapFileInvalid: fprintf(stderr, "room__load_bitmap: Bitmap file %s does not contain valid data\n", filename); return; break; case BitmapNoMemory: fprintf(stderr, "room__load_bitmap: Not enough memory to open bitmap file %s\n", filename); return; break; } /* Get a local copy of the pixmap so we can query the pixel values */ ximage = XGetImage(XtDisplay(room->canvas), bitmap,0,0,width,height,AllPlanes,XYPixmap); if (ximage == NULL) { fprintf(stderr,"room__load_bitmap: Problem getting bitmap image\n"); return; } new_width = MAX( intf2int(room->right_wall), pos_x + width * item__get_width() * SF+10); new_height = MAX( intf2int(room->floor), pos_y + height * item__get_height() * SF+10); if (new_width != intf2int(room->right_wall) || new_height != intf2int(room->floor)) { room->resized = False; /* Set the window width and height so the balls fit on it */ XtVaSetValues(room->canvas, XtNwidth, new_width, XtNheight, new_height, NULL); wait_for_resize( room); } /* Create a ball for each pixel set in the bitmap */ for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { if (XGetPixel(ximage, x, y)) items__new_item(room->items, (int)(x * item__get_width() * SF + pos_x), (int)(y * item__get_height() * SF + pos_y), /*x_vel*/0, /*y_vel*/0); } } } /* Set the room's width and wait for the window to resize before returning */ void room__set_width(room, width) room_type room; int width; { Dimension d_width = width; if (intf2int(room->right_wall) == width) return; room->resized = False; XtVaSetValues(room->canvas, XtNwidth, d_width, NULL); /* room->right_wall = int2intf(width); Set in window resize callback */ wait_for_resize( room); } /* Set the height of the room, resize the actual room and wait for it to resize before returning. */ void room__set_height(room, height) room_type room; Dimension height; { Dimension d_height = height; if (intf2int(room->floor) == height) return; room->resized = False; XtVaSetValues(room->canvas, XtNheight, d_height, NULL); /* room->floor = int2intf(height); set in the window resize callback */ wait_for_resize( room); } /* Private object methods */ /********************************************************************** * redisplay - Called when DrawingArea canvas gets an expose event * Redraws all balls in room **********************************************************************/ static void redisplay(room, event) room_type room; XEvent * event; { Display * display = XtDisplay( room->canvas); Window window = XtWindow ( room->canvas); if (!item__initted()) { Cursor cursor = XCreateFontCursor( display, XC_watch ); XDefineCursor( display, window, cursor); item__init( get_toplevel( room->canvas), display, window, room->background); XFreeCursor( display, cursor); XUndefineCursor( display, window); } if (event->xexpose.count == 0) /* Wait until last expose event*/ { item_type item; XClearWindow( display, window); for (item = items__get_first( room->items); item != (item_type)0; item = items__get_next( room->items)) { item__redraw( item); } } } /********************************************************************** * resize_cb - Called when DrawingArea canvas is resized * Adjusts the right wall and floor **********************************************************************/ static void resize_cb(w, room, call_data) Widget w; room_type room; caddr_t call_data; { Dimension width,height; XtVaGetValues(w, XtNwidth, &width, XtNheight, &height, NULL); room->right_wall = int2intf(width); room->floor = int2intf(height); /* Set flag in case someone is waiting for the resize */ room->resized = True; } /* Waits for the window to actually resize. This depends on the resize callback code setting the room->resized flag to True. Callers should set the room->resized flag to False before calling. */ static void wait_for_resize( room) room_type room; { XEvent event; XtAppContext app_context; app_context = XtWidgetToApplicationContext( room->canvas); /* Wait for the window resize to occur */ while (!room->resized) { XtAppNextEvent(app_context, &event); XtDispatchEvent(&event); } } /********************************************************************** * process_input - Called when DrawingArea canvas has input * Handles mouse button events **********************************************************************/ static void process_input( room, event) room_type room; XEvent * event; { switch (event->type) { /* Process mouse button events */ case ButtonPress: switch (event->xbutton.button) { case 1: /* Button 1 - Create 1 item under the pointer */ room->oldx = room->newx = event->xbutton.x; room->oldy = room->newy = event->xbutton.y; /* Create an item under the pointer */ room->item = item__create(event->xbutton.x, event->xbutton.y, /*x,y velocity*/ 0, 0); room->button1 = True; break; /* Remember the button we have pressed (used in mouse motion) */ case 2: room->button2 = True; break; case 3: room->button3 = True; break; } break; case ButtonRelease: switch (event->xbutton.button) { /* button 1 release - move item to items list */ case 1: item__set_x_vel( room->item, room->newx - room->oldx); item__set_y_vel( room->item, room->newy - room->oldy); items__add( room->items, room->item); room->item = (item_type)0; room->button1 = False; break; /* Remember the button we have unpressed (used in mouse motion) */ case 2: room->button2 = False; break; case 3: room->button3 = False; break; } } } /********************************************************************** * process_motion - Called when DrawingArea canvas have pointer motion events **********************************************************************/ static void process_motion( room, event) room_type room; XEvent * event; { if (room->button1) { /* When button 1 pressed during movement */ /* Save 'speed' of pointer for when the button is released */ room->oldx = room->newx; room->oldy = room->newy; room->newx = event->xmotion.x; room->newy = event->xmotion.y; item__set_x_vel( room->item, (room->newx - room->oldx)); item__set_y_vel( room->item, (room->newy - room->oldy)); item__move_pos( room->item, event->xmotion.x, event->xmotion.y); } else if (room->button2) { /* Create a random velocity ball */ items__new_item(room->items, event->xmotion.x, event->xmotion.y, rand_range( -8, 8), rand_range( -8, 0)); } else if (room->button3) { items__new_item(room->items, event->xmotion.x, event->xmotion.y, 0, 0); } } #ifdef MOTIF static void process_motion_act(/*w, datap_ptr, event*/); /* Create motif canvas as a DrawingArea Widget */ static Widget create_canvas( room, parent, name) room_type room; Widget parent; char * name; { Widget canvas = XtCreateManagedWidget("canvas", xmDrawingAreaWidgetClass, parent, NULL, 0); XtAddCallback(canvas, XmNexposeCallback, redisplay_cb, (XtPointer)room); XtAddCallback(canvas, XmNinputCallback, process_input_cb,(XtPointer)room); XtAddCallback(canvas, XmNresizeCallback, resize_cb, (XtPointer)room); XtAddEventHandler(canvas, ButtonMotionMask, FALSE, process_motion_act, (XtPointer)room); return canvas; } static void redisplay_cb(w, room, call_data) Widget w; room_type room; XmDrawingAreaCallbackStruct * call_data; { redisplay( room, call_data->event); } static void process_input_cb(w, room, call_data) Widget w; room_type room; XmDrawingAreaCallbackStruct * call_data; { process_input( room, call_data->event); } static void process_motion_act(w, room, event) Widget w; room_type room; XEvent * event; { process_motion( room, event); } #endif #ifdef ATHENA static void process_motion_cb(/*w, room, call_data*/); /* Create canvas as a DrawingArea widget */ static Widget create_canvas( room, parent, name) room_type room; Widget parent; char * name; { Widget canvas = XtCreateManagedWidget("canvas", drawingAreaWidgetClass, parent, NULL, 0); XtAddCallback(canvas,XtNexposeCallback,redisplay_cb, (XtPointer)room); XtAddCallback(canvas,XtNinputCallback, process_input_cb, (XtPointer)room); XtAddCallback(canvas,XtNresizeCallback,resize_cb, (XtPointer)room); XtAddCallback(canvas,XtNmotionCallback,process_motion_cb, (XtPointer)room); return canvas; } static void redisplay_cb(w, room, call_data) Widget w; room_type room; XawDrawingAreaCallbackStruct * call_data; { redisplay( room, call_data->event); } static void process_input_cb(w, room, call_data) Widget w; room_type room; XawDrawingAreaCallbackStruct * call_data; { process_input( room, call_data->event); } static void process_motion_cb(w, room, call_data) Widget w; room_type room; XawDrawingAreaCallbackStruct * call_data; { process_motion( room, call_data->event); } #endif xball-3.1.0/room.h000066400000000000000000000046201411065647700137570ustar00rootroot00000000000000/********************************************************************** * room.h - room object declaration * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ #ifndef __ROOM_H__ #define __ROOM_H__ #include #include "item.h" #include "items.h" #include "file_sel.h" #include "intf.h" typedef struct { Widget canvas; Pixel background; int gravity; items_type items; /* List of items in the rooom */ item_type item; /* Item currently being created by user */ file_sel_type file_sel; /* Used to query for a bitmap file */ /* Input state */ int oldx,oldy; int newx,newy; Bool button1,button2,button3; /* Locations of room structures */ intf right_wall; intf left_wall; intf ceiling; intf floor; /* Used to wait for window resize when caused by the program */ Boolean resized; } room_struct_type, *room_type; #ifndef GRAVITY #define GRAVITY 8 /* Default gravity */ #endif room_type room__create(/* form_w */); void room__destroy(/* room */); void room__set_gravity_cb(/*w, room, call_data */); void room__clear_mcb(/*w, room, call_data, extra */); void room__randomize_mcb(/*w, room, call_data, extra */); void room__load_bitmap_mcb(/*w, room, call_data, extra */); void room__load_bitmap(/*room, filename, pos_x, pos_y*/); void room__set_height(/*room, height*/); void room__set_width(/*room, width*/); /* Inline functions */ /* Note that values passed and returned are of type intf */ #define room__get_item( room) ((room)->item) #define room__get_ceiling( room) ((room)->ceiling) #define room__get_left_wall( room) ((room)->left_wall) #define room__get_right_wall( room) ((room)->right_wall) #define room__get_floor( room) ((room)->floor) #define room__flush( room) (XFlush( XtDisplay(room->canvas))) /* gravity is of type int */ #define room__get_gravity( room) ((room)->gravity) #define room__set_gravity( room, grav) ((room)->gravity = (grav)) #endif xball-3.1.0/run_demos.in000066400000000000000000000006151411065647700151550ustar00rootroot00000000000000 echo '*** Xball Demos ***' echo "Hit 'q' in the xball window to exit a demo early" echo "" for f in demo1.xball demo2.xball demo3.xball demo4.xball demo5.xball \ demo6.xball demo7.xball demo8.xball demo9.xball demo10.xball \ demo11.xball demo12.xball demo13.xball demo14.xball do echo "Running demo: $d/$f" xball -demo $d/$f sleep 1 # Let X catch up with events... done xball-3.1.0/scrollbar.c000066400000000000000000000245031411065647700147630ustar00rootroot00000000000000/********************************************************************** * scrollbar.c * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ /* System Headers */ #ifdef MOTIF #include #include #include #endif #ifdef ATHENA #include #include #include #include #include #include #endif /* Local headers */ #include "scrollbar.h" #include "misc.h" /* Structures */ /* A node in the scrollbar callbacks list */ typedef struct { scrollbarCallbackProc proc; caddr_t closure; } callback_node; /* Functions */ void create_widgets(/* scrollbar, parent, name*/); static void call_callbacks(/* scrollbar, value*/); static int scale_set_value(/*scrollbar, value */); /* Public object methods */ /* Creates a scrollbar object. Consists of a label, a scrollbar and a label giving feedback to the user */ scrollbar_type scrollbar__create( parent, name) Widget parent; char * name; { scrollbar_type scrollbar; scrollbar = XtNew( scrollbar_struct); /* We need to have our own callback list, because callbacks from Motif and Athea are so different */ scrollbar->callbacks = list__create(); create_widgets( scrollbar, parent, name); return scrollbar; } /* Destroy the scrollbar object */ void scrollbar__destroy( scrollbar) scrollbar_type scrollbar; { int i; for (i = 0; i < list__get_count( scrollbar->callbacks); i++) { free( list__get_cell( scrollbar->callbacks, i)); } list__destroy( scrollbar->callbacks); XtDestroyWidget( scrollbar->scale); XtDestroyWidget( scrollbar->label); XtFree( (char *)scrollbar); } /* Set the value of the scrollbar and make any callbacks */ void scrollbar__set_value( scrollbar, value) scrollbar_type scrollbar; int value; { scrollbar->value = value; scale_set_value( scrollbar, value); call_callbacks( scrollbar, value); } /* Add a scrollbar callback. When the scrollbar value changes, the proc will be called back with a scrollbarCallbackStruct. */ void scrollbar__add_callback( scrollbar, proc, closure) scrollbar_type scrollbar; XtCallbackProc proc; XtPointer closure; { callback_node *node_ptr = (callback_node *)malloc( sizeof( callback_node)); node_ptr->proc = proc; node_ptr->closure = closure; list__add_end( scrollbar->callbacks, node_ptr); } /* Private object methods */ /* Make the scrollbar callbacks */ static void call_callbacks( scrollbar, value) scrollbar_type scrollbar; int value; { int i; callback_node * node_ptr; scrollbarCallbackStruct scrollbar_call_data; scrollbar_call_data.reason = 0; scrollbar_call_data.event = 0; scrollbar_call_data.pixel = 0; scrollbar_call_data.value = value; for (i = 0; i < list__get_count( scrollbar->callbacks); i++) { node_ptr = (callback_node *)list__get_cell( scrollbar->callbacks, i); (*node_ptr->proc)( scrollbar->scale, node_ptr->closure, &scrollbar_call_data); } } #ifdef MOTIF /* Called when the motif scrollbar moves. Makes all registered scrollbar callbacks */ static void scrollbar_callback( w, scrollbar, call_data) Widget w; scrollbar_type scrollbar; caddr_t call_data; { call_callbacks( scrollbar, ((XmScaleCallbackStruct *)call_data)->value); } #ifdef NOTUSED /* Returns the scrollbar widget's value */ static int scrollbar_get_value( scrollbar) scrollbar_type scrollbar; { int value; XmScaleGetValue( scrollbar->scale, &value); return value; } #endif /* Sets the scrollbar widget's value */ static int scale_set_value( scrollbar, value) scrollbar_type scrollbar; int value; { XmScaleSetValue( scrollbar->scale, value); } /* Creates the scrollbar widgets */ void create_widgets( scrollbar, parent, name) scrollbar_type scrollbar; Widget parent; char * name; { scrollbar->form = XtVaCreateManagedWidget(name, xmFormWidgetClass, parent, NULL); scrollbar->label = XtVaCreateManagedWidget("label", xmLabelWidgetClass, scrollbar->form, NULL); scrollbar->scale = XtVaCreateManagedWidget("bar", xmScaleWidgetClass, scrollbar->form, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, scrollbar->label, NULL); XmScaleGetValue( scrollbar->scale, &scrollbar->value); XtAddCallback( scrollbar->scale, XmNvalueChangedCallback, scrollbar_callback, (XtPointer)scrollbar); XtAddCallback( scrollbar->scale, XmNdragCallback, scrollbar_callback, (XtPointer)scrollbar); } #endif #ifdef ATHENA /* Functions */ static void set_feedback_value(/* scrollbar, value*/); static void move_thumb(/* scrollbar, thumb, shown*/); static void set_label_value(/* label_w, value*/); /* Macros */ #define SB_MAX 100.0 #define SB_MIN 0.0 #define thumb_to_value( thumb, shown) \ ((int)((thumb) / (1-(shown))* (SB_MAX - SB_MIN) + 0.5 - SB_MIN)) #define value_to_thumb( value, shown) \ ((value)*(1-(shown) + SB_MIN) / (SB_MAX - SB_MIN)) /* Called when the athena scrollbar is scrolled incrementally. Updates the feedback value and makes all registered callbacks. */ static void scrollbar_scroll_callback( w, scrollbar, position_ptr) Widget w; scrollbar_type scrollbar; XtPointer position_ptr; { Dimension length; float thumb; float shown; int position = (int)position_ptr; float change; /* 0.0 .. 1.0 - percentage of full-page change we should do */ /* Position is the number of pixels from left of scrollbar pointer is. Position > 0 indicates button 1, position < 0 indicates button 3 */ XtVaGetValues( scrollbar->scale, XtNlength, &length, XtNtopOfThumb, &thumb, XtNshown, &shown, NULL); change = (float)position / length; /* Scroll by the amount of thumb shown * amount of change we should for the given pointer position */ thumb += shown * change; move_thumb( scrollbar, thumb, shown); } /* Called when the athena scrollbar is moved in a jumpy fashion. Updates the feedback value and makes all registered callbacks. */ static void scrollbar_jump_callback( w, scrollbar, percent_ptr) Widget w; scrollbar_type scrollbar; float * percent_ptr; { float shown; float thumb = *percent_ptr; XtVaGetValues( scrollbar->scale, XtNshown, &shown, NULL); move_thumb( scrollbar, thumb, shown); } /* Moves thumb within valid values and updates the feedback value */ static void move_thumb( scrollbar, thumb, shown) scrollbar_type scrollbar; double thumb; double shown; { int value; /* Keep the value within the proper range */ if (thumb >= 1 - shown) /* Keep below 1, otherwise thumb stops redrawing due to Athena bug */ thumb = 1 - shown; else if (thumb < 0) thumb = 0; /* Set the thumb to the new position */ XawScrollbarSetThumb( scrollbar->scale, thumb, -1.0); value = thumb_to_value( thumb, shown); set_feedback_value( scrollbar, value); call_callbacks( scrollbar, value); } /* Returns the value of the scrollbar */ static int scrollbar_get_value( scrollbar) scrollbar_type scrollbar; { float thumb; float shown; XtVaGetValues( scrollbar->scale, XtNtopOfThumb, &thumb, XtNshown, &shown, NULL); return thumb_to_value( thumb, shown); } /* Sets the value of the scrollbar - updates thumb and feedback value */ static int scale_set_value( scrollbar, value) scrollbar_type scrollbar; int value; { float shown; XtVaGetValues( scrollbar->scale, XtNshown, &shown, NULL); /* Set the thumb to the new position */ XawScrollbarSetThumb( scrollbar->scale, value_to_thumb( value, shown), -1.0); set_feedback_value( scrollbar, value); } /* Updates the feedback label to the passed value */ static void set_feedback_value( scrollbar, value) scrollbar_type scrollbar; int value; { set_label_value( scrollbar->feedback, value); } /* Sets an athena label so it displays the passed value */ static void set_label_value( label_w, value) Widget label_w; int value; { char buff[15]; sprintf(buff,"%d", value); XtVaSetValues( label_w, XtNlabel, buff, NULL); } /* Create Athena widgets to simulate a scale witget with a label */ void create_widgets( scrollbar, parent, name) scrollbar_type scrollbar; Widget parent; char * name; { scrollbar->form = XtVaCreateWidget(name, formWidgetClass, parent, NULL); scrollbar->label = XtVaCreateManagedWidget("label", labelWidgetClass, scrollbar->form, NULL); scrollbar->feedback = XtVaCreateManagedWidget("feedback", labelWidgetClass, scrollbar->form, XtNfromHoriz, scrollbar->label, NULL); scrollbar->scale = XtVaCreateManagedWidget("bar", scrollbarWidgetClass, scrollbar->form, XtNfromVert, scrollbar->label, XtNfromHoriz, scrollbar->label, NULL); scrollbar->value = scrollbar_get_value( scrollbar); set_feedback_value( scrollbar, scrollbar->value); XtAddCallback( scrollbar->scale, XtNscrollProc, scrollbar_scroll_callback, (XtPointer)scrollbar); XtAddCallback( scrollbar->scale, XtNjumpProc, scrollbar_jump_callback, (XtPointer)scrollbar); XtManageChild( scrollbar->form); } #endif xball-3.1.0/scrollbar.h000066400000000000000000000032631411065647700147700ustar00rootroot00000000000000/********************************************************************** * scrollbar.h - declares scrollbar object * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ #ifndef __SCROLLBAR_H__ #define __SCROLLBAR_H__ #include #include "list.h" typedef struct { Widget form; Widget label; Widget scale; #ifdef ATHENA Widget feedback; /* Used to display value like Motif scale widget */ #endif int value; /* Current value of the scrollbar */ list_type callbacks; /* List of callbacks on this scrollbar */ } scrollbar_struct, *scrollbar_type; /* We need to make the callbacks ourself, because the callback data is so different between Motif and Athena */ typedef struct { int reason; XEvent * event; int value; int pixel; } scrollbarCallbackStruct; typedef void (*scrollbarCallbackProc)(/* Widget, caddr_t closure, scrollbarCallbackStruct call_data */); /* Inline functions */ #define scrollbar__get_value( scrollbar) ((scrollbar)->value) /* Regular functions */ scrollbar_type scrollbar__create(/* Widget w */); void scrollbar__destroy(/* scrollbar_type scrollbar */); void scrollbar__set_value(/* scrollbar_type *, int value */); void scrollbar__add_callback(/* scrollbar, proc, closure*/); #endif xball-3.1.0/sgi.xbm000066400000000000000000000006761411065647700141330ustar00rootroot00000000000000#define sgi_width 20 #define sgi_height 20 static char sgi_bits[] = { 0x80, 0x08, 0x00, 0x60, 0x35, 0x00, 0x18, 0xc5, 0x00, 0x06, 0x05, 0x03, 0x04, 0x05, 0x01, 0x18, 0xc5, 0x00, 0x60, 0x30, 0x00, 0x84, 0x0d, 0x01, 0x1a, 0xc2, 0x02, 0x62, 0x30, 0x02, 0x82, 0x0d, 0x02, 0x32, 0x65, 0x02, 0x0c, 0x85, 0x01, 0x60, 0x35, 0x00, 0x18, 0xc5, 0x00, 0x04, 0x05, 0x01, 0x04, 0x05, 0x01, 0x18, 0xc5, 0x00, 0x60, 0x35, 0x00, 0x80, 0x08, 0x00}; xball-3.1.0/sim.c000066400000000000000000000101071411065647700135630ustar00rootroot00000000000000/********************************************************************** * sim.c - definition of the sim object - controls the simulation * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ /* Local headers */ #include "sim.h" #include "misc.h" #include "names.h" /* System Headers */ #include #include #include #include #include /* Macros */ #define INVALID_WPID 0 #ifndef DELAY #define DELAY 0 #endif /* Structures */ typedef struct { int delay; } app_data,*app_data_ptr; static app_data res_data; static XtResource resources[] = { { "delay", "Delay", XtRInt, sizeof(int), XtOffset(app_data_ptr,delay), XtRImmediate, (caddr_t)DELAY} }; /* Functions */ static Boolean background_processing(/*sim*/); static int delay(); static int process_invisible_backwards(/*datap_ptr*/); /* Public object methods */ /* Create the simulation object */ sim_type sim__create(w, menu, items, room, demo) Widget w; menu_type menu; items_type items; room_type room; demo_type demo; { sim_type sim = (sim_type)malloc( sizeof( sim_struct_type)); sim->menu = menu; sim->items = items; sim->room = room; sim->demo = demo; XtGetApplicationResources(w, (XtPointer)&res_data, resources, XtNumber(resources), (ArgList)NULL,(Cardinal)0); sim->step_simulation = False; sim->delay = res_data.delay; sim->wpid = INVALID_WPID; return sim; } /* Destroys the simulation object */ void sim__destroy(sim) sim_type sim; { XtRemoveWorkProc(sim->wpid); free( sim); } /* Steps the simulation one iteration */ void sim__step_mcb(w, sim, call_data, extra) Widget w; sim_type sim; caddr_t call_data; char * extra; { background_processing( sim); } /* Halts the simulation */ void sim__halt_mcb(w, sim, call_data, extra) Widget w; sim_type sim; menuCallbackStruct * call_data; char * extra; { sim->step_simulation = call_data->set; if (!sim->step_simulation) { /* Stepping currently turned off */ /* Add background processing to perform simulation in real-time */ sim->wpid = XtAppAddWorkProc(XtWidgetToApplicationContext(w), background_processing, (char *)sim); /* The 'Step simulation' menu item is greyed since sim is running */ menu__set_sensitivity( sim->menu, STEP_SIM, /*sensitive=*/False); } else { /* Stepping turned on - remove the work proc if it has been started */ if (sim->wpid != INVALID_WPID) XtRemoveWorkProc(sim->wpid); sim->wpid = INVALID_WPID; /* The 'Step simulation' menu item is ungreyed since sim not running */ menu__set_sensitivity( sim->menu, STEP_SIM, /*sensitive=*/True); } } /* Private object methods */ /* Performs one iteration of the demo and simulation */ static Boolean background_processing(sim) sim_type sim; { room_type room = sim->room; if (demo__running(sim->demo)) demo__process( sim->demo); /* Delay */ delay(); items__move_items( sim->items, room); return /*remove work procedure=*/False; } /* Slow the simulation some amount */ /* Slow more if there are less balls, less if there are more balls */ static int delay( ) { static int first_flag = 1; static struct timeval last = {0,0}; struct timeval tv; struct timezone tz; const int STEP = (10 * 1000); //10mSec gettimeofday(&tv, &tz); if (first_flag) { first_flag = 0; last = tv; } // Compute required delay int delta = tv.tv_usec - last.tv_usec; if (tv.tv_sec != last.tv_sec) { delta += (tv.tv_sec - last.tv_sec) * 1000000; } if (delta < STEP) { usleep(STEP - delta); } last = tv; } xball-3.1.0/sim.h000066400000000000000000000022211411065647700135660ustar00rootroot00000000000000/********************************************************************** * sim.h - simulation object declarations * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ #ifndef __SIM_H__ #define __SIM_H__ #include #include "items.h" #include "room.h" #include "demo.h" #include "menu.h" typedef struct { menu_type menu; items_type items; room_type room; demo_type demo; XtWorkProcId wpid; /* Work process id */ int delay; /* Amount of delay we should do */ Bool step_simulation; /* True if we are steeping the simulation */ } sim_struct_type, *sim_type; sim_type sim__create(/*w, items, room*/); void sim__destroy(/*sim*/); void sim__step_mcb(/*w, sim, call_data, extra*/); void sim__halt_mcb(/*w, sim, call_data, extra*/); #endif xball-3.1.0/stipple.xbm000066400000000000000000000001401411065647700150130ustar00rootroot00000000000000#define stipple_width 2 #define stipple_height 2 static char stipple_bits[] = { 0x01, 0x02}; xball-3.1.0/table.c000066400000000000000000000047471411065647700140770ustar00rootroot00000000000000/********************************************************************** * table.c - table object definition * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ /* System Headers */ #include #include /* Local headers */ #include "misc.h" #include "table.h" /* Structures */ typedef struct { char *key; void *data; } table_node_struct_type, *table_node_type; /* Public object methods */ /* Create a table object */ table_type table__create() { table_type table = (table_type)malloc( sizeof(table_struct_type)); table->list = list__create(); return table; } /* Free table but not the data contained by the table */ void table__destroy( table) table_type table; { table_node_type table_node; while ((table_node = (table_node_type)list__remove_last(table->list)) != (table_node_type)0) { free( table_node->key); free( table_node); } list__destroy( table->list); free( table); } /* Store data in the table by key */ void table__store( table, key, data) table_type table; char * key; void * data; { table_node_type table_node = (table_node_type)malloc( sizeof(table_node_struct_type)); table_node->key = my_strdup( key); table_node->data = data; list__add_end( table->list, (void *)table_node); } /* Get a value out of the table, given its key */ void *table__retrieve( table, key) table_type table; char * key; { table_node_type table_node; for (table_node = (table_node_type)list__get_first( table->list); table_node != (table_node_type)0; table_node = (table_node_type)list__get_next( table->list)) { if (strcmp( table_node->key, key) == 0) return table_node->data; } return (void *)0; } #ifdef DEBUG void table__dump( table) table_type table; { table_node_type table_node; for (table_node = (table_node_type)list__get_first( table->list); table_node != (table_node_type)0; table_node = (table_node_type)list__get_next( table->list)) { printf("key = %s\n", table_node->key); } } #endif xball-3.1.0/table.h000066400000000000000000000014041411065647700140670ustar00rootroot00000000000000/********************************************************************** * file - description * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ #ifndef __TABLE_H__ #define __TABLE_H__ #include "list.h" typedef struct { list_type list; } table_struct_type, *table_type; table_type table__create(); void table__destroy(/* table */); void table__store(/* table, key, data */); void * table__retrieve(/* table, key */); #endif xball-3.1.0/xball-a.xbm000066400000000000000000000001761411065647700146640ustar00rootroot00000000000000#define xball_a_width 5 #define xball_a_height 7 static char xball_a_bits[] = { 0x00, 0x00, 0x0e, 0x10, 0x1e, 0x11, 0x1e}; xball-3.1.0/xball-b.xbm000066400000000000000000000001761411065647700146650ustar00rootroot00000000000000#define xball_b_width 5 #define xball_b_height 7 static char xball_b_bits[] = { 0x0f, 0x12, 0x12, 0x0e, 0x12, 0x12, 0x0f}; xball-3.1.0/xball-l.xbm000066400000000000000000000001761411065647700146770ustar00rootroot00000000000000#define xball_l_width 4 #define xball_l_height 7 static char xball_l_bits[] = { 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0e}; xball-3.1.0/xball-x.xbm000066400000000000000000000001761411065647700147130ustar00rootroot00000000000000#define xball_b_width 5 #define xball_b_height 7 static char xball_b_bits[] = { 0x11, 0x11, 0x0a, 0x04, 0x0a, 0x11, 0x11}; xball-3.1.0/xball.6000066400000000000000000000041421411065647700140220ustar00rootroot00000000000000.TH XBALL 6x "1/5/93" " " .SH NAME xball \- bounce balls on the screen .SH SYNOPSIS .B xball [ \-help \-delay .I delay \-gravity .I percent-gravity \-elasticity .I percent-elasticity \-itemWidth .I ball-width \-itemHeight .I ball-height \-collide \-perpetual \-haltSim \-demoFile .I demo-file \-rgbTxt .I rgb.txt-file ] [XToolkit options] .sp .SH DESCRIPTION .PP .I XBall allows the user to create 3-d shaded balls, or to write and run demo which create and manipulate the balls in various ways. Documentation is included on-line via the Help menu and is not reproduced here. .SH OPTIONS Run xball \-help for a description of the command line options .SH DEMOS Several demo files are included with the distribution. To run all the demos, run 'run_demos'. .SH RESOURCES Most resources are available for user modification. See the XBall app-defaults file for a complete listing of widgets, .sp Following is a list of the most useful resources: .RS .TP 3 \fBXBall*canvas.width, height\fR The default width and height of the window in which balls bounce in. .TP 3 \fBXBall.delay\fR The amount to slow the simulation, in case the computer is too fast. A reasonable range is 0 to 200. .TP 3 \fBXBall.itemWidth, itemHeight\fR The default width and height of the balls. .TP 3 \fBXBall.collide\fR If true, balls are colliding on startup. .TP 3 \fBXBall.perpetual\fR If true, balls are perpetual on startup. .TP 3 \fBXBall.haltSim\fR If true, simulation is halted on startup. .TP 3 \fBXBall.demoFile\fR Specified the file to run as a demo on startup. .TP 3 \fBXBall.rgbTxt\fR Specified the file to load for the colors. The default file is /usr/share/X11/rgb.txt .SH FILES .TP /usr/share/X11/rgb.txt X11 color names and values. .sp .SH AUTHOR .PP David Nedde (daven@ivy.wpi.edu). .br Packaged for the Debian project by Stephen Birch . .sp .SH COPYRIGHT Copyright 1991, 1993 David Nedde. .br Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee provided that the above copyright notice appears in all copies. It is provided "as is" without express or implied warranty. xball-3.1.0/xball.c000066400000000000000000000072161411065647700141040ustar00rootroot00000000000000/********************************************************************** /* XBall.c - Written by David Nedde (daven@ivy.wpi.edu) 5/93 /* Features: Motif or Athena widget interface /* Item collision detection /* Window resize -> boundry change /* Kind-of Randomly colored balls /* Shaded 3-D-looking balls /* Different ball creation algorithms /* /* Copyright 1991, 1993 David Nedde /* * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. /**********************************************************************/ /* System Headers */ #include #include /* Local headers */ #include "xball_sys.h" #include "miscx.h" #include "patchlevel.h" #include /*** Start of main program ***/ int main(argc,argv) int argc; char **argv; { /* Use the app-defaults file as a set of strings for the fallback */ static String fallback_resources[] = { #include "fallback.h" }; Widget toplevel; XtAppContext app_context; xball_system_type xball_system; static XrmOptionDescRec options[] = { {"-delay", "*delay", XrmoptionSepArg, NULL }, {"-gravity", "*gravity", XrmoptionSepArg, NULL }, {"-elasticity", "*elasticity", XrmoptionSepArg, NULL }, {"-itemWidth", "*itemWidth", XrmoptionSepArg, NULL }, {"-itemHeight", "*itemHeight", XrmoptionSepArg, NULL }, {"-rgbTxt", "*rgbTxt", XrmoptionSepArg, NULL }, {"-help", "*help", XrmoptionNoArg, "True"}, {"-collide", "*collide", XrmoptionNoArg, "True"}, {"-perpetual", "*perpetual", XrmoptionNoArg, "True"}, {"-haltSim", "*haltSim", XrmoptionNoArg, "True"}, {"-demoFile", "*demoFile", XrmoptionSepArg, NULL} }; if (argc > 1 && strncmp(argv[1],"-help", strlen(argv[1])) == 0) { printf("XBall - version %s, patchlevel %d.\n\n", VERSION, PATCHLEVEL); puts("Usage:\n\txball [-options ...]\n\nWhere options include:"); puts(" Option Default Resource Meaning"); puts(" -help Print out this message"); puts(" -delay number 0 delay Default delay setting to slow program"); puts(" -gravity 10 gravity Default gravity setting"); puts(" -elasticity 90 elasticity Default elasticity value"); puts(" -itemWidth 10 itemWidth Width of the drawn item"); puts(" -itemHeight 10 itemHeight Height of the drawn item"); puts(" -collide collide Balls hit each other if specified"); puts(" -perpetual perpetual Balls do not die if specified"); puts(" -haltSim haltSim Starts w/simulation halted if specified"); puts(" -demoFile demoFile A demo file to run at startup"); puts(" -rgbTxt /usr/share/X11/rgb.txt Path to rgb file"); exit(0); } toplevel = XtAppInitialize(&app_context,"XBall", options, XtNumber( options), &argc, argv, fallback_resources, /*args*/(ArgList)NULL, /*num_args*/(Cardinal)0); setupConverters(); xball_system = xball_system__create( toplevel); XtRealizeWidget(toplevel); XtAppMainLoop(app_context); return 0; } xball-3.1.0/xball.pc.in000066400000000000000000000004341411065647700146640ustar00rootroot00000000000000prefix=@prefix@ exec_prefix=@exec_prefix@ bindir=@bindir@ libdir=@libdir@ includedir=@includedir@ datarootdir=@datarootdir@ mandir=@mandir@ localedir=@localedir@ Name: xball Description: bounce balls on the screen. URL: https://packages.debian.org/sid/xball Version: @XBALL_VERSION@ xball-3.1.0/xball.xbm000066400000000000000000000007371411065647700144510ustar00rootroot00000000000000#define xball_width 32 #define xball_height 16 static char xball_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x1e, 0xc0, 0x18, 0x88, 0x24, 0x80, 0x10, 0x50, 0x24, 0x87, 0x10, 0x20, 0x1c, 0x88, 0x10, 0x50, 0x24, 0x8f, 0x10, 0x88, 0xa4, 0x88, 0x10, 0x88, 0x1e, 0xcf, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; xball-3.1.0/xball_sys.c000066400000000000000000000145531411065647700150040ustar00rootroot00000000000000/********************************************************************** * xball_sys.c - xball system object definition. * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ /* System Headers */ #include #include #ifdef MOTIF #include #include #endif #ifdef ATHENA #include #endif /* Local headers */ #include "xball_sys.h" #include "names.h" #include "misc.h" #include /* Creates the xball system. This object holds together the other objects in the system. */ xball_system_type xball_system__create( w) Widget w; { xball_system_type xball_system; menu_type menu; room_type room; demo_type demo; help_type help; sim_type sim; items_type items; file_sel_type file_sel; scrollbar_type gravity_bar; scrollbar_type elasticity_bar; Widget form_widget; typedef struct { int gravity; int elasticity; Boolean ball_collide; Boolean perpetual; Boolean halt_sim; } app_data,*app_data_ptr; app_data res_data; static XtResource resources[] = { { "gravity", "Gravity", XtRInt, sizeof(int), XtOffset(app_data_ptr,gravity), XtRImmediate, (caddr_t)GRAVITY }, { "elasticity", "Elasticity", XtRInt, sizeof(int), XtOffset(app_data_ptr,elasticity), XtRImmediate,(caddr_t)ELASTICITY }, { "collide", "Collide", XtRBoolean, sizeof(Boolean), XtOffset(app_data_ptr,ball_collide), XtRString, "False"}, { "perpetual", "Perpetual", XtRBoolean, sizeof(Boolean), XtOffset(app_data_ptr,perpetual), XtRString, "False"}, { "haltSim", "HaltSim", XtRBoolean, sizeof(Boolean), XtOffset(app_data_ptr,halt_sim), XtRString, "False"} }; XtGetApplicationResources(w, (XtPointer)&res_data, resources, XtNumber(resources), (ArgList)NULL,(Cardinal)0); xball_system = XtNew( xball_system_struct); /* Create the various objects in the system */ #ifdef MOTIF xball_system->form_w = form_widget = XtCreateWidget("form", xmFormWidgetClass, w, NULL,0); #endif #ifdef ATHENA xball_system->form_w = form_widget = XtVaCreateWidget( "formAW", formWidgetClass, w, NULL); #endif xball_system->menu = menu = menu__create( form_widget); xball_system->elasticity_bar = elasticity_bar = scrollbar__create( form_widget, ELASTICITY_BAR); xball_system->gravity_bar = gravity_bar = scrollbar__create( form_widget, GRAVITY_BAR); item__set_perpetual( menu__get_toggle( menu, PERPETUAL)); item__set_ball_collide( menu__get_toggle( menu, BALL_COLLIDE)); xball_system->file_sel = file_sel = file_sel__create(w); xball_system->items = items = items__create(); xball_system->room = room = room__create( form_widget, items, file_sel); xball_system->demo = demo = demo__create(w, menu, gravity_bar, elasticity_bar, file_sel, items, room); xball_system->sim = sim = sim__create(w, menu, items, room, demo); xball_system->help = help = help__create(w); XtManageChild( form_widget); /* Add the scrollbar callbacks and set their values */ scrollbar__add_callback( xball_system->gravity_bar, room__set_gravity_cb, (XtPointer)xball_system->room); scrollbar__set_value( xball_system->gravity_bar, res_data.gravity); scrollbar__add_callback( xball_system->elasticity_bar, item__set_elasticity_cb, (XtPointer)NULL); scrollbar__set_value( xball_system->elasticity_bar, res_data.elasticity); /* Register available menu callbacks */ menu__add_callback(menu, "runDemo", demo__run_mcb, demo); menu__add_callback(menu, "stopDemo", demo__stop_mcb, demo); menu__add_callback(menu, "clear", room__clear_mcb, room); menu__add_callback(menu, "randomize", room__randomize_mcb, room); menu__add_callback(menu, "loadBitmap", room__load_bitmap_mcb, room); menu__add_callback(menu, "quit", xball_system__quit_mcb, xball_system); menu__add_callback(menu, "perpetual", item__perpetual_mcb, NULL); menu__add_callback(menu, "ballCollide", item__collide_mcb, NULL); menu__add_callback(menu, "haltSim", sim__halt_mcb, sim); menu__add_callback(menu, "stepSim", sim__step_mcb, sim); /* Set the values of these menu toggle widgets */ menu__set_toggle( menu, PERPETUAL, res_data.perpetual); menu__set_toggle( menu, BALL_COLLIDE, res_data.ball_collide); menu__set_toggle( menu, HALT_SIM, res_data.halt_sim); menu__add_callback(menu, "about", help__display_mcb, help); menu__add_callback(menu, "onMenus", help__display_mcb, help); menu__add_callback(menu, "onScroll", help__display_mcb, help); menu__add_callback(menu, "onButtons", help__display_mcb, help); menu__add_callback(menu, "onDemos", help__display_mcb, help); menu__add_callback(menu, "onParams", help__display_mcb, help); return xball_system; } /* Free the xball system object */ void xball_system__destroy(xball_system) xball_system_type xball_system; { file_sel__destroy( xball_system->file_sel); help__destroy( xball_system->help); demo__destroy( xball_system->demo); room__destroy( xball_system->room); sim__destroy( xball_system->sim); items__destroy( xball_system->items); scrollbar__destroy( xball_system->elasticity_bar); scrollbar__destroy( xball_system->gravity_bar); menu__destroy( xball_system->menu); XtDestroyWidget( xball_system->form_w); XtFree( (char *)xball_system); } /* Called if the user selects the quit menu item */ void xball_system__quit_mcb( w, xball_system, call_data, extra) Widget w; xball_system_type xball_system; caddr_t call_data; char * extra; { XtCloseDisplay(XtDisplay(xball_system->form_w)); exit(EXIT_SUCCESS); } xball-3.1.0/xball_sys.h000066400000000000000000000024711411065647700150050ustar00rootroot00000000000000/********************************************************************** * xball_sys.h - xball system object declarations * * Copyright 1993, David Nedde * * Permission to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is granted * provided that the above copyright notice appears in all copies. * It is provided "as is" without express or implied warranty. **********************************************************************/ #ifndef __XBALL_SYS_H__ #define __XBALL_SYS_H__ #include #include "menu.h" #include "demo.h" #include "room.h" #include "items.h" #include "sim.h" #include "scrollbar.h" #include "file_sel.h" #include "help.h" typedef struct { Widget form_w; Widget pane_w; menu_type menu; demo_type demo; items_type items; room_type room; sim_type sim; help_type help; scrollbar_type gravity_bar; scrollbar_type elasticity_bar; file_sel_type file_sel; } xball_system_struct, *xball_system_type; xball_system_type xball_system__create(/* w*/); void xball_system__destroy(/*xball_system*/); void xball_system__quit_mcb(/* w, datap_ptr, call_data, extra*/); #endif