home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume37 / mgiccube / part03 < prev    next >
Encoding:
Text File  |  1993-05-15  |  60.7 KB  |  2,037 lines

  1. Newsgroups: comp.sources.misc
  2. From: fleurant@hri.com (P.Fleurant)
  3. Subject: v37i040:  magiccube - a cube simulator for X11/Motif, Part03/05
  4. Message-ID: <1993May10.213158.29157@sparky.imd.sterling.com>
  5. X-Md4-Signature: bfdc115c9148e0b7b11aa2eb2f299581
  6. Date: Mon, 10 May 1993 21:31:58 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: fleurant@hri.com (P.Fleurant)
  10. Posting-number: Volume 37, Issue 40
  11. Archive-name: magiccube/part03
  12. Environment: X11, Motif, ANSI-C
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then feed it
  16. # into a shell via "sh file" or similar.  To overwrite existing files,
  17. # type "sh file -c".
  18. # Contents:  cube/Makefile cube/layer2.c cube/layer3.c cube/ldfile.c
  19. #   cube/ldfile.h cube/lib/menus.c cube/lib/pix_buttons.c
  20. # Wrapped by kent@sparky on Mon May 10 16:15:41 1993
  21. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  22. echo If this archive is complete, you will see the following message:
  23. echo '          "shar: End of archive 3 (of 5)."'
  24. if test -f 'cube/Makefile' -a "${1}" != "-c" ; then 
  25.   echo shar: Will not clobber existing file \"'cube/Makefile'\"
  26. else
  27.   echo shar: Extracting \"'cube/Makefile'\" \(13072 characters\)
  28.   sed "s/^X//" >'cube/Makefile' <<'END_OF_FILE'
  29. X# Makefile generated by imake - do not edit!
  30. X# $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $
  31. X#
  32. X# The cpp used on this machine replaces all newlines and multiple tabs and
  33. X# spaces in a macro expansion with a single space.  Imake tries to compensate
  34. X# for this, but is not always successful.
  35. X#
  36. X
  37. X###########################################################################
  38. X# Makefile generated from "Imake.tmpl" and </tmp/IIf.a02058>
  39. X# $XConsortium: Imake.tmpl,v 1.77 89/12/18 17:01:37 jim Exp $
  40. X#
  41. X# Platform-specific parameters may be set in the appropriate .cf
  42. X# configuration files.  Site-wide parameters may be set in the file
  43. X# site.def.  Full rebuilds are recommended if any parameters are changed.
  44. X#
  45. X# If your C preprocessor doesn't define any unique symbols, you'll need
  46. X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
  47. X# "make Makefile", "make Makefiles", or "make World").
  48. X#
  49. X# If you absolutely can't get imake to work, you'll need to set the
  50. X# variables at the top of each Makefile as well as the dependencies at the
  51. X# bottom (makedepend will do this automatically).
  52. X#
  53. X
  54. X###########################################################################
  55. X# platform-specific configuration parameters - edit sun.cf to change
  56. X
  57. X# platform:  $XConsortium: sun.cf,v 1.38 89/12/23 16:10:10 jim Exp $
  58. X# operating system:  SunOS 4.0.3
  59. X
  60. X###########################################################################
  61. X# site-specific configuration parameters - edit site.def to change
  62. X
  63. X            SHELL = /bin/sh
  64. X
  65. X              TOP = .
  66. X      CURRENT_DIR = .
  67. X
  68. X               AR = ar clq
  69. X  BOOTSTRAPCFLAGS =
  70. X               CC = cc
  71. X
  72. X         COMPRESS = compress
  73. X              CPP = /lib/cpp $(STD_CPP_DEFINES)
  74. X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
  75. X          INSTALL = install
  76. X               LD = ld
  77. X             LINT = lint
  78. X      LINTLIBFLAG = -C
  79. X         LINTOPTS = -axz
  80. X               LN = ln -s
  81. X             MAKE = make
  82. X               MV = mv
  83. X               CP = cp
  84. X           RANLIB = ranlib
  85. X  RANLIBINSTFLAGS =
  86. X               RM = rm -f
  87. X     STD_INCLUDES =
  88. X  STD_CPP_DEFINES =
  89. X      STD_DEFINES =
  90. X EXTRA_LOAD_FLAGS =
  91. X  EXTRA_LIBRARIES =
  92. X             TAGS = ctags
  93. X
  94. X    SHAREDCODEDEF = -DSHAREDCODE
  95. X         SHLIBDEF = -DSUNSHLIB
  96. X
  97. X    PROTO_DEFINES =
  98. X
  99. X     INSTPGMFLAGS =
  100. X
  101. X     INSTBINFLAGS = -m 0755
  102. X     INSTUIDFLAGS = -m 4755
  103. X     INSTLIBFLAGS = -m 0664
  104. X     INSTINCFLAGS = -m 0444
  105. X     INSTMANFLAGS = -m 0444
  106. X     INSTDATFLAGS = -m 0444
  107. X    INSTKMEMFLAGS = -m 4755
  108. X
  109. X          DESTDIR =
  110. X
  111. X     TOP_INCLUDES = -I$(INCROOT)
  112. X
  113. X      CDEBUGFLAGS = -O
  114. X        CCOPTIONS =
  115. X      COMPATFLAGS =
  116. X
  117. X      ALLINCLUDES = $(STD_INCLUDES) $(TOP_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES)
  118. X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(DEFINES) $(COMPATFLAGS)
  119. X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
  120. X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
  121. X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  122. X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS)
  123. X   LDCOMBINEFLAGS = -X -r
  124. X
  125. X        MACROFILE = sun.cf
  126. X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
  127. X
  128. X    IMAKE_DEFINES =
  129. X
  130. X         IRULESRC = $(CONFIGDIR)
  131. X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
  132. X
  133. X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
  134. X            $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
  135. X            $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
  136. X
  137. X###########################################################################
  138. X# X Window System Build Parameters
  139. X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
  140. X
  141. X###########################################################################
  142. X# X Window System make variables; this need to be coordinated with rules
  143. X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $
  144. X
  145. X          PATHSEP = /
  146. X        USRLIBDIR = $(DESTDIR)/usr/lib
  147. X           BINDIR = $(DESTDIR)/usr/bin/X11
  148. X          INCROOT = $(DESTDIR)/usr/include
  149. X     BUILDINCROOT = $(TOP)
  150. X      BUILDINCDIR = $(BUILDINCROOT)/X11
  151. X      BUILDINCTOP = ..
  152. X           INCDIR = $(INCROOT)/X11
  153. X           ADMDIR = $(DESTDIR)/usr/adm
  154. X           LIBDIR = $(USRLIBDIR)/X11
  155. X        CONFIGDIR = $(LIBDIR)/config
  156. X       LINTLIBDIR = $(USRLIBDIR)/lint
  157. X
  158. X          FONTDIR = $(LIBDIR)/fonts
  159. X         XINITDIR = $(LIBDIR)/xinit
  160. X           XDMDIR = $(LIBDIR)/xdm
  161. X           AWMDIR = $(LIBDIR)/awm
  162. X           TWMDIR = $(LIBDIR)/twm
  163. X           GWMDIR = $(LIBDIR)/gwm
  164. X          MANPATH = $(DESTDIR)/usr/man
  165. X    MANSOURCEPATH = $(MANPATH)/man
  166. X           MANDIR = $(MANSOURCEPATH)n
  167. X        LIBMANDIR = $(MANSOURCEPATH)3
  168. X      XAPPLOADDIR = $(LIBDIR)/app-defaults
  169. X
  170. X        SOXLIBREV = 4.2
  171. X          SOXTREV = 4.0
  172. X         SOXAWREV = 4.0
  173. X        SOOLDXREV = 4.0
  174. X         SOXMUREV = 4.0
  175. X        SOXEXTREV = 4.0
  176. X
  177. X       FONTCFLAGS = -t
  178. X
  179. X     INSTAPPFLAGS = $(INSTDATFLAGS)
  180. X
  181. X            IMAKE = imake
  182. X           DEPEND = makedepend
  183. X              RGB = rgb
  184. X            FONTC = bdftosnf
  185. X        MKFONTDIR = mkfontdir
  186. X        MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier.sh
  187. X
  188. X        CONFIGSRC = $(TOP)/config
  189. X        CLIENTSRC = $(TOP)/clients
  190. X          DEMOSRC = $(TOP)/demos
  191. X           LIBSRC = $(TOP)/lib
  192. X          FONTSRC = $(TOP)/fonts
  193. X       INCLUDESRC = $(TOP)/X11
  194. X        SERVERSRC = $(TOP)/server
  195. X          UTILSRC = $(TOP)/util
  196. X        SCRIPTSRC = $(UTILSRC)/scripts
  197. X       EXAMPLESRC = $(TOP)/examples
  198. X       CONTRIBSRC = $(TOP)/../contrib
  199. X           DOCSRC = $(TOP)/doc
  200. X           RGBSRC = $(TOP)/rgb
  201. X        DEPENDSRC = $(UTILSRC)/makedepend
  202. X         IMAKESRC = $(CONFIGSRC)
  203. X         XAUTHSRC = $(LIBSRC)/Xau
  204. X          XLIBSRC = $(LIBSRC)/X
  205. X           XMUSRC = $(LIBSRC)/Xmu
  206. X       TOOLKITSRC = $(LIBSRC)/Xt
  207. X       AWIDGETSRC = $(LIBSRC)/Xaw
  208. X       OLDXLIBSRC = $(LIBSRC)/oldX
  209. X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
  210. X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
  211. X     MKFONTDIRSRC = $(FONTSRC)/mkfontdir
  212. X     EXTENSIONSRC = $(TOP)/extensions
  213. X
  214. X  DEPEXTENSIONLIB =
  215. X     EXTENSIONLIB = -lXext
  216. X
  217. X          DEPXLIB = $(DEPEXTENSIONLIB)
  218. X             XLIB = $(EXTENSIONLIB) -lX11
  219. X
  220. X      DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
  221. X         XAUTHLIB =  -lXau
  222. X
  223. X        DEPXMULIB =
  224. X           XMULIB = -lXmu
  225. X
  226. X       DEPOLDXLIB =
  227. X          OLDXLIB = -loldX
  228. X
  229. X      DEPXTOOLLIB =
  230. X         XTOOLLIB = -lXt
  231. X
  232. X        DEPXAWLIB =
  233. X           XAWLIB = -lXaw
  234. X
  235. X LINTEXTENSIONLIB = $(USRLIBDIR)/llib-lXext.ln
  236. X         LINTXLIB = $(USRLIBDIR)/llib-lX11.ln
  237. X          LINTXMU = $(USRLIBDIR)/llib-lXmu.ln
  238. X        LINTXTOOL = $(USRLIBDIR)/llib-lXt.ln
  239. X          LINTXAW = $(USRLIBDIR)/llib-lXaw.ln
  240. X
  241. X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
  242. X
  243. X         DEPLIBS1 = $(DEPLIBS)
  244. X         DEPLIBS2 = $(DEPLIBS)
  245. X         DEPLIBS3 = $(DEPLIBS)
  246. X
  247. X###########################################################################
  248. X# Imake rules for building libraries, programs, scripts, and data files
  249. X# rules:  $XConsortium: Imake.rules,v 1.67 89/12/18 17:14:15 jim Exp $
  250. X
  251. X###########################################################################
  252. X# start of Imakefile
  253. X
  254. X#
  255. X# Imakefile - magicCube
  256. X#
  257. X#
  258. X
  259. X############################################################################
  260. X#
  261. X#
  262. X#
  263. X
  264. XCC = cc
  265. X#CC = cc #-Aa -D_HPUX_SOURCE
  266. X#CC = cc -Aa -D_HPUX_SOURCE        #HPUX
  267. X#CC = cc -xansi -D__STDC__        #SGI Indigo?
  268. X
  269. XXSLIB = lib/libXs.a
  270. X
  271. XSTD_INCLUDES = -I/usr/local/X11R5/include -I/usr/local/include  -I./lib
  272. XSTD_CPP_DEFINES =
  273. XSTD_DEFINES =
  274. XEXTRA_LOAD_FLAGS = -lXm -lX11 -lXt -lm
  275. XEXTRA_LIBRARIES = -L/usr/local/X11R5/lib -L/usr/lib
  276. X
  277. XCDEBUGFLAGS = -g
  278. X#CDEBUGFLAGS = +O3 +OS +ESlit    #HPUX cc
  279. X#HPUX: CDEBUGFLAGS = +O3 +OS +ESlit ... LDFLAGS: -Wl,-I first, then -Wl,-P
  280. X
  281. X############################################################################
  282. X#
  283. X# Source and object files.
  284. X#
  285. X
  286. XOBJS  = cube.o init_cubik.o taylor.o layer1edge_tf.o layer1edge_tr.o layer1edge_tb.o layer1edge_tl.o \
  287. X       layer1corner.o layer1c_txx.o layer2.o layer3.o layer3twirl.o layer3flip.o ldfile.o
  288. XSRCS  = cube.c init_cubik.c taylor.c layer1edge_tf.c layer1edge_tr.c layer1edge_tb.c layer1edge_tl.c \
  289. X       layer1corner.c layer1c_txx.c layer2.c layer3.c layer3twirl.c layer3flip.c ldfile.c
  290. X
  291. X############################################################################
  292. X#
  293. X# Make subdirectories, Xs
  294. X#
  295. XSUBDIRS = lib
  296. X
  297. Xall::
  298. X    @case '${MFLAGS}' in *[ik]*) set +e;; esac; \
  299. X    for i in $(SUBDIRS) ;\
  300. X    do \
  301. X    (cd $$i ; echo "making" all "in $(CURRENT_DIR)/$$i..."; \
  302. X    $(MAKE) $(MFLAGS) 'CDEBUGFLAGS=$(CDEBUGFLAGS)' all); \
  303. X    done
  304. X
  305. Xdepend::
  306. X    @case '${MFLAGS}' in *[ik]*) set +e;; esac; \
  307. X    for i in $(SUBDIRS) ;\
  308. X    do \
  309. X    (cd $$i ; echo "depending" "in $(CURRENT_DIR)/$$i..."; \
  310. X    $(MAKE) $(MFLAGS)   depend); \
  311. X    done
  312. X
  313. X############################################################################
  314. X#
  315. X#
  316. X#
  317. X
  318. Xall:: magicCube
  319. X
  320. XmagicCube: $(OBJS) $(DEPLIBS)
  321. X    $(RM) $@
  322. X    $(CC) -o $@ $(OBJS) $(LDOPTIONS) $(XSLIB) $(LDLIBS) $(SYS_LIBRARIES) $(EXTRA_LOAD_FLAGS)
  323. X
  324. Xclean::
  325. X    $(RM) magicCube
  326. X
  327. Xadd_resource:
  328. X    xrdb -merge MagicCube
  329. X
  330. X###########################################################################
  331. X# common rules for all Makefiles - do not edit
  332. X
  333. Xemptyrule::
  334. X
  335. Xclean::
  336. X    $(RM_CMD) \#*
  337. X
  338. XMakefile::
  339. X    -@if [ -f Makefile ]; then \
  340. X    echo "    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
  341. X    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
  342. X    else exit 0; fi
  343. X    $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
  344. X
  345. Xtags::
  346. X    $(TAGS) -w *.[ch]
  347. X    $(TAGS) -xw *.[ch] > TAGS
  348. X
  349. Xsaber:
  350. X    #load $(ALLDEFINES) $(SRCS)
  351. X
  352. Xosaber:
  353. X    #load $(ALLDEFINES) $(OBJS)
  354. X
  355. X###########################################################################
  356. X# rules for building in SUBDIRS - do not edit
  357. X
  358. Xinstall::
  359. X    @case '${MFLAGS}' in *[ik]*) set +e;; esac; \
  360. X    for i in $(SUBDIRS) ;\
  361. X    do \
  362. X    (cd $$i ; echo "installing" "in $(CURRENT_DIR)/$$i..."; \
  363. X    $(MAKE) $(MFLAGS) DESTDIR='$(DESTDIR)' install); \
  364. X    done
  365. X
  366. Xinstall.man::
  367. X    @case '${MFLAGS}' in *[ik]*) set +e;; esac; \
  368. X    for i in $(SUBDIRS) ;\
  369. X    do \
  370. X    (cd $$i ; echo "installing man pages" "in $(CURRENT_DIR)/$$i..."; \
  371. X    $(MAKE) $(MFLAGS) DESTDIR='$(DESTDIR)' install.man); \
  372. X    done
  373. X
  374. Xclean::
  375. X    @case '${MFLAGS}' in *[ik]*) set +e;; esac; \
  376. X    for i in $(SUBDIRS) ;\
  377. X    do \
  378. X    (cd $$i ; echo "cleaning" "in $(CURRENT_DIR)/$$i..."; \
  379. X    $(MAKE) $(MFLAGS) RM_CMD='$(RM_CMD)' clean); \
  380. X    done
  381. X
  382. Xtags::
  383. X    @case '${MFLAGS}' in *[ik]*) set +e;; esac; \
  384. X    for i in $(SUBDIRS) ;\
  385. X    do \
  386. X    (cd $$i ; echo "tagging" "in $(CURRENT_DIR)/$$i..."; \
  387. X    $(MAKE) $(MFLAGS) TAGS='$(TAGS)' tags); \
  388. X    done
  389. X
  390. XMakefiles::
  391. X    @case '${MFLAGS}' in *[ik]*) set +e;; esac; \
  392. X    for i in $(SUBDIRS) ;\
  393. X    do \
  394. X    echo "making Makefiles in $(CURRENT_DIR)/$$i..."; \
  395. X    case "$$i" in \
  396. X    ./?*/?*/?*/?*) newtop=../../../../ sub=subsubsubsub;; \
  397. X    ./?*/?*/?*) newtop=../../../ sub=subsubsub;; \
  398. X    ./?*/?*) newtop=../../ sub=subsub;; \
  399. X    ./?*) newtop=../ sub=sub;; \
  400. X    */?*/?*/?*) newtop=../../../../ sub=subsubsubsub;; \
  401. X    */?*/?*) newtop=../../../ sub=subsubsub;; \
  402. X    */?*) newtop=../../ sub=subsub;; \
  403. X    *) newtop=../ sub=sub;; \
  404. X    esac; \
  405. X    case "$(TOP)" in \
  406. X    /?*) newtop= upprefix= ;; \
  407. X    *) upprefix=../ ;; \
  408. X    esac; \
  409. X    $(MAKE) $${sub}dirMakefiles UPPREFIX=$$upprefix NEWTOP=$$newtop \
  410. X    MAKEFILE_SUBDIR=$$i NEW_CURRENT_DIR=$(CURRENT_DIR)/$$i;\
  411. X    done
  412. X
  413. XsubdirMakefiles:
  414. X    $(RM) $(MAKEFILE_SUBDIR)/Makefile.bak
  415. X    -@if [ -f $(MAKEFILE_SUBDIR)/Makefile ]; then \
  416. X    echo "    $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak"; \
  417. X    $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak; \
  418. X    else exit 0; fi
  419. X    cd $(MAKEFILE_SUBDIR); $(IMAKE_CMD) -DTOPDIR=$(UPPREFIX)$(TOP) -DCURDIR=$(NEW_CURRENT_DIR); \
  420. X    $(MAKE) $(MFLAGS) Makefiles
  421. X
  422. XsubsubdirMakefiles:
  423. X    $(RM) $(MAKEFILE_SUBDIR)/Makefile.bak
  424. X    -@if [ -f $(MAKEFILE_SUBDIR)/Makefile ]; then \
  425. X    echo "    $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak"; \
  426. X    $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak; \
  427. X    else exit 0; fi
  428. X    cd $(MAKEFILE_SUBDIR); $(IMAKE_CMD) -DTOPDIR=$(UPPREFIX)$(UPPREFIX)$(TOP) -DCURDIR=$(NEW_CURRENT_DIR); \
  429. X    $(MAKE) $(MFLAGS) Makefiles
  430. X
  431. XsubsubsubdirMakefiles:
  432. X    $(RM) $(MAKEFILE_SUBDIR)/Makefile.bak
  433. X    -@if [ -f $(MAKEFILE_SUBDIR)/Makefile ]; then \
  434. X    echo "    $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak"; \
  435. X    $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak; \
  436. X    else exit 0; fi
  437. X    cd $(MAKEFILE_SUBDIR); $(IMAKE_CMD) -DTOPDIR=$(UPPREFIX)$(UPPREFIX)$(UPPREFIX)$(TOP) -DCURDIR=$(NEW_CURRENT_DIR); \
  438. X    $(MAKE) $(MFLAGS) Makefiles
  439. X
  440. XsubsubsubsubdirMakefiles:
  441. X    $(RM) $(MAKEFILE_SUBDIR)/Makefile.bak
  442. X    -@if [ -f $(MAKEFILE_SUBDIR)/Makefile ]; then \
  443. X    echo "    $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak"; \
  444. X    $(MV) $(MAKEFILE_SUBDIR)/Makefile $(MAKEFILE_SUBDIR)/Makefile.bak; \
  445. X    else exit 0; fi
  446. X    cd $(MAKEFILE_SUBDIR); $(IMAKE_CMD) -DTOPDIR=$(UPPREFIX)$(UPPREFIX)$(UPPREFIX)$(UPPREFIX)$(TOP) -DCURDIR=$(NEW_CURRENT_DIR); \
  447. X    $(MAKE) $(MFLAGS) Makefiles
  448. X
  449. Xincludes::
  450. X    @case '${MFLAGS}' in *[ik]*) set +e;; esac; \
  451. X    for i in $(SUBDIRS) ;\
  452. X    do \
  453. X    (cd $$i ; echo including "in $(CURRENT_DIR)/$$i..."; \
  454. X    $(MAKE) $(MFLAGS)   includes); \
  455. X    done
  456. X
  457. X###########################################################################
  458. X# dependencies generated by makedepend
  459. X
  460. END_OF_FILE
  461.   if test 13072 -ne `wc -c <'cube/Makefile'`; then
  462.     echo shar: \"'cube/Makefile'\" unpacked with wrong size!
  463.   fi
  464.   # end of 'cube/Makefile'
  465. fi
  466. if test -f 'cube/layer2.c' -a "${1}" != "-c" ; then 
  467.   echo shar: Will not clobber existing file \"'cube/layer2.c'\"
  468. else
  469.   echo shar: Extracting \"'cube/layer2.c'\" \(7518 characters\)
  470.   sed "s/^X//" >'cube/layer2.c' <<'END_OF_FILE'
  471. X/* layer2.c
  472. X   This incorporates Don Taylor's solution to the 
  473. X   Buvos Kocka (Hungarian Magic Cube). 
  474. X
  475. X   Middle Layer Cubes
  476. X   
  477. X   The following references were used:
  478. X   "The X Window System Programming And Applications with Xt
  479. X   OSF/MOTIF EDITION"
  480. X   by Douglas A Young 
  481. X   Prentice-Hall, 1990.
  482. X   ISBN 0-13-642786-3
  483. X
  484. X   "Mastering Rubik's Cube"
  485. X   by Don Taylor
  486. X   An Owl Book; Holt, Rinehart and Winston, New York, 1980
  487. X   ISBN 0-03-059941-5
  488. X
  489. X-------------------------------------------------------------------
  490. XCopyright (C) 1993 by Pierre A. Fleurant
  491. XPermission is granted to copy and distribute this program
  492. Xwithout charge, provided this copyright notice is included
  493. Xin the copy.
  494. XThis Software is distributed on an as-is basis. There will be
  495. XABSOLUTELY NO WARRANTY for any part of this software to work
  496. Xcorrect. In no case will the author be liable to you for damages
  497. Xcaused by the usage of this software.
  498. X-------------------------------------------------------------------
  499. X       
  500. X*/   
  501. X
  502. X#include "taylor.h"
  503. X
  504. Xextern void F(); /*  front  */
  505. Xextern void L(); /*  left   */
  506. Xextern void R(); /*  right  */
  507. Xextern void B(); /*  back   */
  508. Xextern void U(); /*  up     */
  509. Xextern void D(); /*  down   */
  510. X
  511. XBoolean middle_layer(w,wdata,call_data) /* These parameters needed for macros */
  512. X     Widget   w;
  513. X     widget_data *wdata;
  514. X     caddr_t  call_data;
  515. X{
  516. X  /* Search for middle edge cubes.
  517. X     Place in bottom layer.
  518. X     Dispatch to middle_layer_[f,r,b,l]t accordingly.
  519. X     */
  520. X
  521. X  /* Find edge cubes in bottom layer that belong 
  522. X   * in  middle layer.
  523. X   */
  524. X  
  525. X  /*1*/
  526. X  if(Front(7) != BOTTOM &&
  527. X     Bottom(1) != BOTTOM){
  528. X    /* Then it is a middle layer edge */
  529. X    /* It is 1 of 8 combinations */
  530. X    if(Front(7)  == FRONT &&
  531. X       Bottom(1) == RIGHT){
  532. X      D(-1);
  533. X      F(1);D(2);L(1);D(1);L(-1);D(2);F(-1); /* 10.3 'top matches left-hand' */
  534. X    }
  535. X    
  536. X    else if(Front(7)  == RIGHT &&
  537. X        Bottom(1) == FRONT){
  538. X      F(1);D(2);L(1);D(-1);L(-1);D(2);F(-1); /* 10.4 'top matches front-hand' */
  539. X    }
  540. X    
  541. X    
  542. X    
  543. X    else if(Front(7)  == RIGHT &&
  544. X        Bottom(1) == BACK){
  545. X      R(1);D(2);F(1);D(1);F(-1);D(2);R(-1); /* 10.3 */
  546. X    }
  547. X    
  548. X    else if(Front(7)  == BACK &&
  549. X        Bottom(1) == RIGHT){
  550. X      D(1);
  551. X      R(1);D(2);F(1);D(-1);F(-1);D(2);R(-1); /* 10.4 */
  552. X    }
  553. X    
  554. X    
  555. X    
  556. X    else if(Front(7)  == BACK &&
  557. X        Bottom(1) == LEFT){
  558. X      D(1);
  559. X      B(1);D(2);R(1);D(1);R(-1);D(2);B(-1); /* 10.3 */
  560. X    }
  561. X    
  562. X    else if(Front(7)  == LEFT &&
  563. X        Bottom(1) == BACK){
  564. X      D(2);
  565. X      B(1);D(2);R(1);D(-1);R(-1);D(2);B(-1);
  566. X    }
  567. X    
  568. X    
  569. X    
  570. X    else if(Front(7)  == LEFT &&
  571. X        Bottom(1) == FRONT){
  572. X      D(2);
  573. X      L(1);D(2);B(1);D(1);B(-1);D(2);L(-1);
  574. X    }
  575. X    
  576. X    else if(Front(7)  == FRONT &&
  577. X        Bottom(1) == LEFT){
  578. X      D(-1);
  579. X      L(1);D(2);B(1);D(-1);B(-1);D(2);L(-1);
  580. X    }
  581. X    return(False);
  582. X  }
  583. X  /*2*/
  584. X  else if(Right(7) != BOTTOM &&
  585. X      Bottom(5) != BOTTOM){
  586. X    /* Then it is a middle layer edge */
  587. X    /* It is 1 of 8 combinations */
  588. X    if(Right(7)  == FRONT &&
  589. X       Bottom(5) == RIGHT){
  590. X      D(2);
  591. X      F(1);D(2);L(1);D(1);L(-1);D(2);F(-1); /* 10.3 'top matches left-hand' */
  592. X    }
  593. X    
  594. X    else if(Right(7)  == RIGHT &&
  595. X        Bottom(5) == FRONT){
  596. X      D(-1);
  597. X      F(1);D(2);L(1);D(-1);L(-1);D(2);F(-1); /* 10.4 'top matches front-hand' */
  598. X    }
  599. X    
  600. X    
  601. X    
  602. X    else if(Right(7)  == RIGHT &&
  603. X        Bottom(5) == BACK){
  604. X      D(-1);
  605. X      R(1);D(2);F(1);D(1);F(-1);D(2);R(-1); /* 10.3 */
  606. X    }
  607. X    
  608. X    else if(Right(7)  == BACK &&
  609. X        Bottom(5) == RIGHT){
  610. X      R(1);D(2);F(1);D(-1);F(-1);D(2);R(-1); /* 10.4 */
  611. X    }
  612. X    
  613. X    
  614. X    
  615. X    else if(Right(7)  == BACK &&
  616. X        Bottom(5) == LEFT){
  617. X      B(1);D(2);R(1);D(1);R(-1);D(2);B(-1); /* 10.3 */
  618. X    }
  619. X    
  620. X    else if(Right(7)  == LEFT &&
  621. X        Bottom(5) == BACK){
  622. X      D(1);
  623. X      B(1);D(2);R(1);D(-1);R(-1);D(2);B(-1);
  624. X    }
  625. X    
  626. X    
  627. X    
  628. X    else if(Right(7)  == LEFT &&
  629. X        Bottom(5) == FRONT){
  630. X      D(1);
  631. X      L(1);D(2);B(1);D(1);B(-1);D(2);L(-1);
  632. X    }
  633. X    
  634. X    else if(Right(7)  == FRONT &&
  635. X        Bottom(5) == LEFT){
  636. X      D(2);
  637. X      L(1);D(2);B(1);D(-1);B(-1);D(2);L(-1);
  638. X    }
  639. X    return(False);
  640. X  }
  641. X  /*3*/
  642. X  else if(Back(7) != BOTTOM &&
  643. X      Bottom(7) != BOTTOM){
  644. X    /* Then it is a middle layer edge */
  645. X    /* It is 1 of 8 combinations */
  646. X    if(Back(7)  == FRONT &&
  647. X       Bottom(7) == RIGHT){
  648. X      D(1);
  649. X      F(1);D(2);L(1);D(1);L(-1);D(2);F(-1); /* 10.3 'top matches left-hand' */
  650. X    }
  651. X    
  652. X    else if(Back(7)  == RIGHT &&
  653. X        Bottom(7) == FRONT){
  654. X      D(2);
  655. X      F(1);D(2);L(1);D(-1);L(-1);D(2);F(-1); /* 10.4 'top matches front-hand' */
  656. X    }
  657. X    
  658. X    
  659. X    
  660. X    else if(Back(7)  == RIGHT &&
  661. X        Bottom(7) == BACK){
  662. X      D(2);
  663. X      R(1);D(2);F(1);D(1);F(-1);D(2);R(-1); /* 10.3 */
  664. X    }
  665. X    
  666. X    else if(Back(7)  == BACK &&
  667. X        Bottom(7) == RIGHT){
  668. X      D(3);
  669. X      R(1);D(2);F(1);D(-1);F(-1);D(2);R(-1); /* 10.4 */
  670. X    }
  671. X    
  672. X    
  673. X    
  674. X    else if(Back(7)  == BACK &&
  675. X        Bottom(7) == LEFT){
  676. X      D(3);
  677. X      B(1);D(2);R(1);D(1);R(-1);D(2);B(-1); /* 10.3 */
  678. X    }
  679. X    
  680. X    else if(Back(7)  == LEFT &&
  681. X        Bottom(7) == BACK){
  682. X      B(1);D(2);R(1);D(-1);R(-1);D(2);B(-1);
  683. X    }
  684. X    
  685. X    
  686. X    
  687. X    else if(Back(7)  == LEFT &&
  688. X        Bottom(7) == FRONT){
  689. X      L(1);D(2);B(1);D(1);B(-1);D(2);L(-1);
  690. X    }
  691. X    
  692. X    else if(Back(7)  == FRONT &&
  693. X        Bottom(7) == LEFT){
  694. X      D(1);
  695. X      L(1);D(2);B(1);D(-1);B(-1);D(2);L(-1);
  696. X    }
  697. X    return(False);
  698. X  }
  699. X  /*4*/
  700. X  else if(Left(7) != BOTTOM &&
  701. X      Bottom(3) != BOTTOM){
  702. X    /* Then it is a middle layer edge */
  703. X    /* It is 1 of 8 combinations */
  704. X    if(Left(7)  == FRONT &&
  705. X       Bottom(3) == RIGHT){
  706. X      F(1);D(2);L(1);D(1);L(-1);D(2);F(-1); /* 10.3 'top matches left-hand' */
  707. X    }
  708. X    
  709. X    else if(Left(7)  == RIGHT &&
  710. X        Bottom(3) == FRONT){
  711. X      D(1);
  712. X      F(1);D(2);L(1);D(-1);L(-1);D(2);F(-1); /* 10.4 'top matches front-hand' */
  713. X    }
  714. X    
  715. X    
  716. X    
  717. X    else if(Left(7)  == RIGHT &&
  718. X        Bottom(3) == BACK){
  719. X      D(1);
  720. X      R(1);D(2);F(1);D(1);F(-1);D(2);R(-1); /* 10.3 */
  721. X    }
  722. X    
  723. X    else if(Left(7)  == BACK &&
  724. X        Bottom(3) == RIGHT){
  725. X      D(2);
  726. X      R(1);D(2);F(1);D(-1);F(-1);D(2);R(-1); /* 10.4 */
  727. X    }
  728. X    
  729. X    
  730. X    
  731. X    else if(Left(7)  == BACK &&
  732. X        Bottom(3) == LEFT){
  733. X      D(2);
  734. X      B(1);D(2);R(1);D(1);R(-1);D(2);B(-1); /* 10.3 */
  735. X    }
  736. X    
  737. X    else if(Left(7)  == LEFT &&
  738. X        Bottom(3) == BACK){
  739. X      D(-1);
  740. X      B(1);D(2);R(1);D(-1);R(-1);D(2);B(-1);
  741. X    }
  742. X    
  743. X    
  744. X    
  745. X    else if(Left(7)  == LEFT &&
  746. X        Bottom(3) == FRONT){
  747. X      D(-1);
  748. X      L(1);D(2);B(1);D(1);B(-1);D(2);L(-1);
  749. X    }
  750. X    
  751. X    else if(Left(7)  == FRONT &&
  752. X        Bottom(3) == LEFT){
  753. X      L(1);D(2);B(1);D(-1);B(-1);D(2);L(-1);
  754. X    }
  755. X    return(False);
  756. X  }
  757. X
  758. X  /* Check if all middle layer cubes in place */
  759. X  else if(Front(5) == FRONT &&
  760. X      Right(3) == RIGHT &&
  761. X      Right(5) == RIGHT &&
  762. X      Back(5) == BACK &&
  763. X      Back(3) == BACK &&
  764. X      Left(5) == LEFT &&
  765. X      Left(3) == LEFT &&
  766. X      Front(3) == FRONT){
  767. X    return(True);
  768. X  }
  769. X  /* Else no middle layer cubes in the bottom layer.
  770. X     * So a middle layer cube must be moved out to the bottom layer.
  771. X     */
  772. X  else {
  773. X    if(Front(5) == RIGHT &&
  774. X       Right(3) == FRONT){
  775. X      F(1);D(2);L(1);D(1);L(-1);D(2);F(-1);     
  776. X    }
  777. X    else if(Right(5) == BACK &&
  778. X        Back(5) == RIGHT){
  779. X      R(1);D(2);F(1);D(1);F(-1);D(2);R(-1); 
  780. X    }
  781. X    else if(Back(3) == LEFT &&
  782. X        Left(5) == BACK){
  783. X      B(1);D(2);R(1);D(1);R(-1);D(2);B(-1); 
  784. X    }
  785. X    else if(Left(3) == FRONT &&
  786. X        Front(3) == LEFT){
  787. X      L(1);D(2);B(1);D(1);B(-1);D(2);L(-1);
  788. X    }
  789. X    return(False);
  790. X  }
  791. X}
  792. END_OF_FILE
  793.   if test 7518 -ne `wc -c <'cube/layer2.c'`; then
  794.     echo shar: \"'cube/layer2.c'\" unpacked with wrong size!
  795.   fi
  796.   # end of 'cube/layer2.c'
  797. fi
  798. if test -f 'cube/layer3.c' -a "${1}" != "-c" ; then 
  799.   echo shar: Will not clobber existing file \"'cube/layer3.c'\"
  800. else
  801.   echo shar: Extracting \"'cube/layer3.c'\" \(12224 characters\)
  802.   sed "s/^X//" >'cube/layer3.c' <<'END_OF_FILE'
  803. X/* layer3.c
  804. X   This incorporates Don Taylor's solution to the 
  805. X   Buvos Kocka (Hungarian Magic Cube). 
  806. X
  807. X   Last Layer Cubes
  808. X
  809. X   a) Down(n) until one corner has correct position
  810. X   b) Move corners into correct position (Section 11; a, b, c, d solutions)
  811. X   c) Move edge cubes into correct position
  812. X       
  813. X
  814. X
  815. XThe following references were used:
  816. X   "The X Window System Programming And Applications with Xt
  817. X   OSF/MOTIF EDITION"
  818. X   by Douglas A Young 
  819. X   Prentice-Hall, 1990.
  820. X   ISBN 0-13-642786-3
  821. X
  822. X   "Mastering Rubik's Cube"
  823. X   by Don Taylor
  824. X   An Owl Book; Holt, Rinehart and Winston, New York, 1980
  825. X   ISBN 0-03-059941-5
  826. X
  827. X-------------------------------------------------------------------
  828. XCopyright (C) 1993 by Pierre A. Fleurant
  829. XPermission is granted to copy and distribute this program
  830. Xwithout charge, provided this copyright notice is included
  831. Xin the copy.
  832. XThis Software is distributed on an as-is basis. There will be
  833. XABSOLUTELY NO WARRANTY for any part of this software to work
  834. Xcorrect. In no case will the author be liable to you for damages
  835. Xcaused by the usage of this software.
  836. X-------------------------------------------------------------------
  837. X*/   
  838. X
  839. X#include "taylor.h"
  840. X
  841. Xextern void F(); /*  front  */
  842. Xextern void L(); /*  left   */
  843. Xextern void R(); /*  right  */
  844. Xextern void B(); /*  back   */
  845. Xextern void U(); /*  up     */
  846. Xextern void D(); /*  down   */
  847. X
  848. Xvoid last_layer(w,wdata,call_data) /* These parameters needed for macros */
  849. X     Widget   w;
  850. X     widget_data *wdata;
  851. X     caddr_t  call_data;
  852. X{
  853. X  /**** Move corners into correct position ****/
  854. X  /* Place correct corner at Back(8)/Right(8)/Bottom(8).
  855. X   * There are only 4 possible locations.
  856. X   */
  857. X  
  858. X  
  859. X  if((Back(6) == BACK   || Back(6) == BOTTOM   || Back(6) == RIGHT) &&
  860. X     (Bottom(6) == BACK || Bottom(6) == BOTTOM || Bottom(6) == RIGHT) &&
  861. X     (Left(8) == BACK   || Left(8) == BOTTOM   || Left(8) == RIGHT)){
  862. X    D(-1);
  863. X  }
  864. X  else if((Front(6) == BACK  || Front(6) == BOTTOM  || Front(6) == RIGHT) &&
  865. X      (Bottom(0) == BACK || Bottom(0) == BOTTOM || Bottom(0) == RIGHT) &&
  866. X      (Left(6) == BACK   || Left(6) == BOTTOM   || Left(6) == RIGHT)){
  867. X    D(2);
  868. X  }
  869. X  else if((Front(8) == BACK  || Front(8) == BOTTOM  || Front(8) == RIGHT) &&
  870. X      (Bottom(2) == BACK || Bottom(2) == BOTTOM || Bottom(2) == RIGHT) &&
  871. X      (Right(6) == BACK  || Right(6) == BOTTOM  || Right(6) == RIGHT)){
  872. X    D(1);
  873. X  }
  874. X  
  875. X  /* Now Back(8)/Right(8)/Bottom(8) is correct and is reference  point.
  876. X   * Place other corner cubes in correct position.
  877. X   * 
  878. X   * Proceed to crack for a, b, c, or d solution.
  879. X   * Using just bottom(n=0,2,6,8) == true to test if cube is in right 
  880. X   * position. The following if/then/else tree is used to crack for
  881. X   * a, b, c,  or d solution.
  882. X   *
  883. X   *  Given that bottom(8) = true now:
  884. X   *          front 
  885. X   *   -------------------
  886. X   *   |     |     |     |
  887. X   *   |     |     |     |
  888. X   *   |  0  |     |  2  |
  889. X   *   -------------------
  890. X   * l |     |     |     |  right 
  891. X   * e |     |     |     |
  892. X   * f |     |     |     |
  893. X   * t  -------------------
  894. X   *   |     |     |     |
  895. X   *   |     |     | ok  |
  896. X   *   |  6  |     |  8  |
  897. X   *   -------------------
  898. X   *          back
  899. X   *
  900. X   *   if(bottom(2) == true){
  901. X   *       if(bottom(0) == true)  
  902. X   *         "then all four courners must be in correct postion"
  903. X   *       else
  904. X   *         "then bottom(6)=false and C solution(swap0-6)"
  905. X   *   }
  906. X   *   else{
  907. X   *       if(bottom(0) == true)
  908. X   *         "then bottom(6)=false and D solution(swap2-6)"
  909. X   *       else{
  910. X   *         if(bottom(6) == true)
  911. X   *          "then C solution(swap0-2)"
  912. X   *         else{
  913. X   *           if(bottom(6) belongs in bottom(0))
  914. X   *              "A solution(2<--0;0<--6;6<--2)"
  915. X   *           else
  916. X   *              "B solution(2<--6;0<--2;6<--0)"
  917. X   *         }
  918. X   *       }
  919. X   *   }
  920. X   */
  921. X
  922. X  if(/* bottom(2) */
  923. X     (Front(8) == FRONT  || Front(8) == BOTTOM  || Front(8) == RIGHT) &&
  924. X     (Bottom(2) == FRONT || Bottom(2) == BOTTOM || Bottom(2) == RIGHT) &&
  925. X     (Right(6) == FRONT  || Right(6) == BOTTOM  || Right(6) == RIGHT)){
  926. X    /* Then this adjacent cube is correct and sub-solution is `c' 
  927. X     * or all corners in correct position.
  928. X     */
  929. X    if(/* bottom(0) */
  930. X       (Front(6) == FRONT  || Front(6) == BOTTOM  || Front(6) == LEFT) &&
  931. X       (Bottom(0) == FRONT || Bottom(0) == BOTTOM || Bottom(0) == LEFT) &&
  932. X       (Left(6) == FRONT   || Left(6) == BOTTOM   || Left(6) == LEFT)){
  933. X      /* all corners must be ok */
  934. X      ;
  935. X    }
  936. X    else{
  937. X      /*          front 
  938. X       *   -------------------
  939. X       *   |  0  |     |  2  |
  940. X       *   | not |     | ok  |
  941. X       *   | ok  |     |     |
  942. X       *   -------------------
  943. X       * l |     |     |     |  right 
  944. X       * e |     |     |     |
  945. X       * f |     |     |     |
  946. X       * t  -------------------
  947. X       *   | not |     |     |
  948. X       *   | ok  |     | ok  |
  949. X       *   |  6  |     |  8  |
  950. X       *   -------------------
  951. X       *          back
  952. X       */
  953. X      /* c solution needed */
  954. X      R(1);D(-1);L(-1);D(1);R(-1);D(-1);L(1);D(2);
  955. X    }
  956. X  }
  957. X  else{
  958. X    if(/* Bottom(0) */
  959. X       (Front(6) == FRONT  || Front(6) == BOTTOM  || Front(6) == LEFT) &&
  960. X       (Bottom(0) == FRONT || Bottom(0) == BOTTOM || Bottom(0) == LEFT) &&
  961. X       (Left(6) == FRONT   || Left(6) == BOTTOM   || Left(6) == LEFT)){
  962. X      /*          front 
  963. X       *   -------------------
  964. X       *   |     |     | not |
  965. X       *   |  ok |     |  ok |
  966. X       *   |  0  |     |  2  |
  967. X       *   -------------------
  968. X       * l |     |     |     |  right 
  969. X       * e |     |     |     |
  970. X       * f |     |     |     |
  971. X       * t -------------------
  972. X       *   | not |     |     |
  973. X       *   | ok  |     | ok  | 
  974. X       *   |  6  |     |  8  |
  975. X       *   -------------------
  976. X       *          back
  977. X       */
  978. X      /* d solution needed */
  979. X      D(1);B(1);D(1);R(1);D(-1);R(-1);B(-1);
  980. X    }
  981. X    else{
  982. X      if(/*bottom(6)*/
  983. X     (Back(6) == BACK   || Back(6) == BOTTOM   || Back(6) == LEFT) &&
  984. X     (Bottom(6) == BACK || Bottom(6) == BOTTOM || Bottom(6) == LEFT) &&
  985. X     (Left(8) == BACK   || Left(8) == BOTTOM   || Left(8) == LEFT)){
  986. X    /*          front 
  987. X     *   -------------------
  988. X     *   | not |     | not |
  989. X     *   |  ok |     |  ok |
  990. X     *   |  0  |     |  2  |
  991. X     *   -------------------
  992. X     * l |     |     |     |  right 
  993. X     * e |     |     |     |
  994. X     * f |     |     |     |
  995. X     * t -------------------
  996. X     *   |     |     |     |
  997. X     *   | ok  |     | ok  | Must be OK
  998. X     *   |  6  |     |  8  |
  999. X     *   -------------------
  1000. X     *          back
  1001. X     */ 
  1002. X    /* c solution needed */
  1003. X    B(1);D(-1);F(-1);D(1);B(-1);D(-1);F(1);D(2);
  1004. X      }
  1005. X      else{ 
  1006. X    if(/*bottom(6)*/
  1007. X     (Back(6) == FRONT   || Back(6) == BOTTOM   || Back(6) == LEFT) &&
  1008. X     (Bottom(6) == FRONT || Bottom(6) == BOTTOM || Bottom(6) == LEFT) &&
  1009. X     (Left(8) == FRONT   || Left(8) == BOTTOM   || Left(8) == LEFT)){
  1010. X      /* bottom(6) belongs in bottom(0) */
  1011. X      /* A solution needed (2<--0;0<--6;6<--2) */
  1012. X      L(-1);D(1);R(1);D(-1);L(1);D(1);R(-1);D(-1);
  1013. X    }
  1014. X    else{
  1015. X      /* bottom(6) belongs in bottom(2) */
  1016. X      /* B solution needed (2<--6;0<--2;6<--0) */
  1017. X      D(1);R(1);D(-1);L(-1);D(1);R(-1);D(-1);L(1);
  1018. X    }
  1019. X      }
  1020. X    }
  1021. X  }
  1022. X
  1023. X  /**** Move edges into correct position ****/
  1024. X  
  1025. X  /* Proceed to crack for a, b, c, or d solution.
  1026. X   * Using just bottom(n=1,3,5,7) == true to test if cube is in right 
  1027. X   * position. The following if/then/else tree is used to crack for
  1028. X   * a, b, c,  or d solution.
  1029. X   *
  1030. X   *          front 
  1031. X   *   -------------------
  1032. X   *   |     |     |     |
  1033. X   *   |     |     |     |
  1034. X   *   |     |  1  |     |
  1035. X   *   -------------------
  1036. X   * l |     |     |     |  right 
  1037. X   * e |     |     |     |
  1038. X   * f |  3  |     |  5  |
  1039. X   * t -------------------
  1040. X   *   |     |     |     |
  1041. X   *   |     |     |     |
  1042. X   *   |     |  7  |     |
  1043. X   *   -------------------
  1044. X   *          back
  1045. X   *
  1046. X   *   if(bottom(1) == true){
  1047. X   *      if(bottom(3) belongs in bottom(5))
  1048. X   *        "A solution(3 to 5 to 7 to 3)"
  1049. X   *      else if(bottom(5) belongs in bottom(3))
  1050. X   *        "B solution(5 to 3 to 7 to 5)"
  1051. X   *      else
  1052. X   *        "No solution needed, all edges  are ok"
  1053. X   *   }else
  1054. X   *   if(bottom(3) == true){
  1055. X   *      if(bottom(7) belongs in bottom(1))
  1056. X   *        "A solution(7 to 1 to 5 to 7)"
  1057. X   *      else if(bottom(1) belongs in bottom(7))
  1058. X   *        "B solution(1 to 7 to 5 to 1)"
  1059. X   *      else
  1060. X   *        "No solution needed, all edges  are ok"
  1061. X   *   }else
  1062. X   *   if(bottom(5) == true){
  1063. X   *      if(bottom(1) belongs in bottom(7))
  1064. X   *        "A solution(1 to 7 to 3 to 1)"
  1065. X   *      else if(bottom(7) belongs in bottom(1))
  1066. X   *        "B solution(7 to 1 to 3 to 7)"
  1067. X   *      else
  1068. X   *        "No solution needed, all edges  are ok"
  1069. X   *   }else
  1070. X   *   if(bottom(7) == true){
  1071. X   *      if(bottom(5) belongs in bottom(3))
  1072. X   *        "A solution(5 to 3 to 1 to 5)"
  1073. X   *      else if(bottom(3) belongs in bottom(5))
  1074. X   *        "B solution(3 to 5 to 1 to 3)"
  1075. X   *      else
  1076. X   *        "No solution needed, all edges  are ok"
  1077. X   *   }else{
  1078. X   *    "No edges are in the correct position."
  1079. X   *    "Find out where bottom(1) belongs and this determines
  1080. X   *     the correct solution"
  1081. X   *     if(bottom(1) belongs in bottom(3))
  1082. X   *       "D solution(1 to 3; 3 to 1; 5 to 7; 7 to 5)"
  1083. X   *     else if(bottom(1) belongs in bottom(7))
  1084. X   *       "C solution(1 to 7; 7 to 1; 3 to 5; 5 to 3)"
  1085. X   *     else if(bottom(1) belongs in bottom(5))
  1086. X   *       "D solution(1 to 5; 5 to 1; 3 to 7; 7 to 3)"
  1087. X   *   }
  1088. X   */ 
  1089. X
  1090. X  if(Front(7) == FRONT || Bottom(1) == FRONT){
  1091. X    /* bottom(1) ok */
  1092. X    if(Left(7) == RIGHT || Bottom(3) == RIGHT){
  1093. X      /* bottom(3) belongs in bottom(5) */
  1094. X      /* A solution(3 to 5 to 7 to 3) */
  1095. X      B(2);D(1);R(-1);L(1);B(2);R(1);L(-1);D(1);B(2);
  1096. X    }
  1097. X    else if(Right(7) == LEFT || Bottom(5) == LEFT){
  1098. X      /* bottom(5) belongs in bottom(3) */
  1099. X      /* B solution(5 to 3 to 7 to 5) */
  1100. X      B(2);D(-1);R(-1);L(1);B(2);R(1);L(-1);D(-1);B(2);
  1101. X    }
  1102. X    else{ ; } /* all edges in proper place */
  1103. X  }
  1104. X
  1105. X  else if(Left(7) == LEFT || Bottom(3) == LEFT){
  1106. X    /* bottom(3) ok */
  1107. X    if(Back(7) == FRONT || Bottom(7) == FRONT){
  1108. X      /* bottom(7) belongs in bottom(1) */
  1109. X      /* A solution(7 to 1 to 5 to 7) */
  1110. X      L(2);D(1);F(-1);B(1);L(2);F(1);B(-1);D(1);L(2);
  1111. X    }
  1112. X    else if(Front(7) == BACK || Bottom(1) == BACK){
  1113. X      /* bottom(1) belongs in bottom(7) */
  1114. X      /* B solution(1 to 7 to 5 to 1) */
  1115. X      L(2);D(-1);F(-1);B(1);L(2);F(1);B(-1);D(-1);L(2);
  1116. X    }
  1117. X    else{ ; } /* all edges in proper place */
  1118. X  }
  1119. X
  1120. X  else if(Right(7) == RIGHT || Bottom(3) == RIGHT){
  1121. X    /* bottom(5) ok */
  1122. X    if(Front(7) == BACK || Bottom(1) == BACK){
  1123. X      /* bottom(1) belongs in bottom(7) */
  1124. X      /* A solution(1 to 7 to 3 to 1) */
  1125. X      L(2);D(1);B(-1);F(1);L(2);B(1);F(-1);D(1);L(2);
  1126. X    }
  1127. X    else if(Back(7) == FRONT || Bottom(7) == FRONT){
  1128. X      /* bottom(7) belongs in bottom(1) */
  1129. X      /* B solution(7 to 1 to 3 to 7) */
  1130. X      L(2);D(-1);B(-1);F(1);L(2);B(1);F(-1);D(-1);L(2);
  1131. X    }
  1132. X    else{ ; } /* all edges in proper place */
  1133. X  }
  1134. X  
  1135. X  else if(Back(7) == BACK || Bottom(3) == BACK){
  1136. X    /* bottom(7) ok */
  1137. X    if(Right(7) == LEFT || Bottom(5) == LEFT){
  1138. X      /* bottom(5) belongs in bottom(3) */
  1139. X      /* A solution(5 to 3 to 1 to 5) */
  1140. X      F(2);D(1);L(-1);R(1);F(2);L(1);R(-1);D(1);F(2);
  1141. X    }
  1142. X    else if(Left(7) == RIGHT || Bottom(3) == RIGHT){
  1143. X      /* bottom(3) belongs in bottom(5) */
  1144. X      /* B solution(3 to 5 to 1 to 3) */
  1145. X      F(2);D(-1);L(-1);R(1);F(2);L(1);R(-1);D(-1);F(2);
  1146. X    }
  1147. X    else{ ; } /* all edges in proper place */
  1148. X  }
  1149. X
  1150. X  else{
  1151. X    /* There are no edges in their proper place. */
  1152. X    if(Front(7) == LEFT || Bottom(1) == LEFT){
  1153. X      /* bottom(1) belongs in bottom(3) */
  1154. X      /* D solution(1 to 3; 3 to 1; 5 to 7; 7 to 5) */
  1155. X      F(1);L(1);D(1);L(-1);D(-1);F(2);R(-1);D(-1);R(1);D(1);F(1);
  1156. X    }
  1157. X    else if(Front(7) == BACK || Bottom(7) == BACK){
  1158. X      /* bottom(1) belongs in bottom(7) */
  1159. X      /* C solution(1 to 7; 7 to 1; 3 to 5; 5 to 3) */
  1160. X      R(2);L(2);U(1);R(2);L(2);D(2);R(2);L(2);U(1);R(2);L(2);
  1161. X    }
  1162. X    else if(Front(7) == RIGHT || Bottom(5) == RIGHT){
  1163. X      /* bottom(1) belongs in bottom(5) */
  1164. X      /* D solution(1 to 5; 5 to 1; 3 to 7; 7 to 3) */
  1165. X      R(1);F(1);D(1);F(-1);D(-1);R(2);B(-1);D(-1);B(1);D(1);R(1);
  1166. X    }
  1167. X    else{
  1168. X      printf("ERROR: layer3 error...");
  1169. X    }
  1170. X  }
  1171. X
  1172. X}
  1173. END_OF_FILE
  1174.   if test 12224 -ne `wc -c <'cube/layer3.c'`; then
  1175.     echo shar: \"'cube/layer3.c'\" unpacked with wrong size!
  1176.   fi
  1177.   # end of 'cube/layer3.c'
  1178. fi
  1179. if test -f 'cube/ldfile.c' -a "${1}" != "-c" ; then 
  1180.   echo shar: Will not clobber existing file \"'cube/ldfile.c'\"
  1181. else
  1182.   echo shar: Extracting \"'cube/ldfile.c'\" \(5589 characters\)
  1183.   sed "s/^X//" >'cube/ldfile.c' <<'END_OF_FILE'
  1184. X/* ldfile.c
  1185. X   This is the callback for the load_file_button.
  1186. X   Files loaded contain a sequence of cube moves that result
  1187. X   in some desired pattern.
  1188. X   Buvos Kocka (Hungarian Magic Cube). 
  1189. X       
  1190. X
  1191. XThe following references were used:
  1192. X   "The X Window System Programming And Applications with Xt
  1193. X   OSF/MOTIF EDITION"
  1194. X   by Douglas A Young 
  1195. X   Prentice-Hall, 1990.
  1196. X   ISBN 0-13-642786-3
  1197. X
  1198. X   "Mastering Rubik's Cube"
  1199. X   by Don Taylor
  1200. X   An Owl Book; Holt, Rinehart and Winston, New York, 1980
  1201. X   ISBN 0-03-059941-5
  1202. X
  1203. X-------------------------------------------------------------------
  1204. XCopyright (C) 1993 by Pierre A. Fleurant
  1205. XPermission is granted to copy and distribute this program
  1206. Xwithout charge, provided this copyright notice is included
  1207. Xin the copy.
  1208. XThis Software is distributed on an as-is basis. There will be
  1209. XABSOLUTELY NO WARRANTY for any part of this software to work
  1210. Xcorrect. In no case will the author be liable to you for damages
  1211. Xcaused by the usage of this software.
  1212. X-------------------------------------------------------------------
  1213. X*/   
  1214. X
  1215. X#include "ldfile.h"
  1216. X
  1217. XXtCallbackProc fileProc;
  1218. X
  1219. Xvoid FileNamePopUp();
  1220. Xvoid okFileNameCallback();
  1221. Xvoid cancelFileNameCallback();
  1222. Xvoid FileNameAction();
  1223. Xvoid ld_sequence_file();
  1224. Xvoid displayMessage();
  1225. X
  1226. Xextern Widget         saved_w;
  1227. Xextern widget_data    *saved_wdata;
  1228. Xextern caddr_t        saved_call_data;
  1229. Xextern int            number_moves;
  1230. X
  1231. Xextern void F(); /*  front  */
  1232. Xextern void L(); /*  left   */
  1233. Xextern void R(); /*  right  */
  1234. Xextern void B(); /*  back   */
  1235. Xextern void U(); /*  up     */
  1236. Xextern void D(); /*  down   */
  1237. X
  1238. X
  1239. Xvoid ldfile(w,wdata,call_data)
  1240. X     Widget   w;
  1241. X     widget_data *wdata;
  1242. X     caddr_t  call_data;
  1243. X{
  1244. X  /* Save 'em in a global so we don't have to pass 'em 
  1245. X   * around all the time.
  1246. X   */
  1247. X  saved_w = w;
  1248. X  saved_wdata = wdata;
  1249. X  saved_call_data = call_data;
  1250. X  number_moves = 1;
  1251. X
  1252. X  FileNamePopUp("Init filename", ld_sequence_file, w, wdata);
  1253. X  
  1254. X}
  1255. X
  1256. Xvoid ld_sequence_file(filename)
  1257. X     char* filename;
  1258. X{
  1259. X  char *tptr, *t1ptr, line[MSG_SIZ], buf[MSG_SIZ], function;
  1260. X  Arg args[1];
  1261. X  FILE *fp;
  1262. X  int i, j, parameter;
  1263. X
  1264. X
  1265. X  
  1266. X  if (filename[0] == '/')
  1267. X    strcpy(buf, filename);
  1268. X  else {
  1269. X    strcpy(buf, "./");
  1270. X    strcat(buf, filename);
  1271. X  }
  1272. X  
  1273. X  if ((fp = fopen(buf, "r")) == NULL) {
  1274. X    strcpy(line, buf);
  1275. X    sprintf(buf,"Can't open %s", line);
  1276. X    displayMessage(buf);
  1277. X    return;
  1278. X  }else{
  1279. X    sprintf(line,"\nSequence filename: %s\n",buf);
  1280. X    displayMessage(line);
  1281. X  }
  1282. X  
  1283. X  /*
  1284. X   * check if file is empty
  1285. X   */
  1286. X  if(!fgets(line, MSG_SIZ, fp)){
  1287. X    /* NULL pointer is returned if eof */
  1288. X    sprintf(buf,"file is empty");
  1289. X    displayMessage(buf);
  1290. X    fclose(fp);
  1291. X    return;
  1292. X  }
  1293. X  do {
  1294. X    /* skip comments */
  1295. X    if(*line == '!')
  1296. X      continue;
  1297. X    /* use tptr because it will get incremented */
  1298. X    tptr = line;
  1299. X
  1300. X      /* parse function commands */
  1301. X      while(sscanf(tptr, "%1s(%d);", &function, ¶meter) == 2){
  1302. X    /* execute it */
  1303. X    switch(function){
  1304. X    case 'F':
  1305. X      F(parameter);
  1306. X      break;
  1307. X    case 'L':
  1308. X      L(parameter);
  1309. X      break;
  1310. X    case 'R':
  1311. X      R(parameter);
  1312. X      break;
  1313. X    case 'B':
  1314. X      B(parameter);
  1315. X      break;
  1316. X    case 'U':
  1317. X      U(parameter);
  1318. X      break;
  1319. X    case 'D':
  1320. X      D(parameter);
  1321. X      break;
  1322. X    default:
  1323. X      sprintf(buf,"file has incorrect syntax");
  1324. X      displayMessage(buf);
  1325. X      fclose(fp);
  1326. X      return;
  1327. X    }      
  1328. X    /* point to next command */
  1329. X    if(!(t1ptr = strchr(tptr,';')))
  1330. X      break;
  1331. X    tptr = t1ptr + 1;
  1332. X      }
  1333. X    
  1334. X  }while (fgets(line, MSG_SIZ, fp)); /* while not eof */
  1335. X  
  1336. X  /* close shop */
  1337. X  fclose(fp);
  1338. X  
  1339. X}
  1340. X
  1341. Xvoid displayMessage(msg)
  1342. X     char* msg;
  1343. X{
  1344. X  printf("%s\n", msg);
  1345. X}
  1346. X
  1347. X/************************************************************************/
  1348. X/** The following is generic stuff for File list popUp windows         **/
  1349. X/************************************************************************/
  1350. X
  1351. X/* The following is a generic routine to popUp a file list for loading. */
  1352. Xvoid FileNamePopUp(label, proc, theParent, wdata)
  1353. X     char *label;
  1354. X     void (*proc)();
  1355. X     Widget theParent;
  1356. X     widget_data *wdata;
  1357. X{
  1358. X  Arg args[4];
  1359. X  Widget popup, dialog;
  1360. X  Position x, y;
  1361. X  Dimension bw_width, pw_width;
  1362. X  int n;
  1363. X  
  1364. X  fileProc = (XtCallbackProc) proc;
  1365. X  
  1366. X  popup = XtCreatePopupShell("ldfile_popup",
  1367. X                 transientShellWidgetClass, theParent, NULL, 0);
  1368. X  
  1369. X  n=0;
  1370. X  XtSetArg(args[n], XtNheight, DIALOG_SIZE);n++;
  1371. X  XtSetArg(args[n], XtNwidth, DIALOG_SIZE);n++;
  1372. X  dialog = XmCreateFileSelectionDialog(popup,label,
  1373. X                       args, n);
  1374. X  
  1375. X  /* Unmanage the help button */
  1376. X  XtUnmanageChild(XmFileSelectionBoxGetChild(dialog,
  1377. X                         XmDIALOG_HELP_BUTTON));
  1378. X  
  1379. X  XtManageChild(dialog);
  1380. X  
  1381. X  XtAddCallback(dialog, XmNokCallback, okFileNameCallback, (XtPointer) dialog);
  1382. X  XtAddCallback(dialog, XmNcancelCallback, cancelFileNameCallback, (XtPointer) dialog);
  1383. X  
  1384. X  XtRealizeWidget(dialog);
  1385. X  
  1386. X  XtSetKeyboardFocus(dialog, popup);
  1387. X}
  1388. X
  1389. X
  1390. Xvoid okFileNameCallback(w, client_data, call_data)
  1391. X     Widget w;
  1392. X     XtPointer client_data, call_data;
  1393. X{
  1394. X  FileNameAction(w, NULL);
  1395. X}
  1396. X
  1397. Xvoid cancelFileNameCallback(w, client_data, call_data)
  1398. X     Widget w;
  1399. X     XtPointer client_data, call_data;
  1400. X{
  1401. X  XtDestroyWidget(w);
  1402. X}
  1403. X
  1404. Xvoid FileNameAction(w, event)
  1405. X     Widget w;
  1406. X     XEvent *event;
  1407. X{
  1408. X  char buf[MSG_SIZ];
  1409. X  String name;
  1410. X  int n;
  1411. X  XmString compoundString;
  1412. X  Arg args[1];
  1413. X  
  1414. X  
  1415. X  n=0;
  1416. X  XtSetArg(args[n], XmNtextString, &compoundString);n++;
  1417. X  XtGetValues(w, args, n);
  1418. X  name = xs_get_string_from_xmstring(compoundString);
  1419. X  XtDestroyWidget(w);
  1420. X  
  1421. X  if ((name != NULL) && (*name != '\0')) {
  1422. X    strcpy(buf, name);
  1423. X    (*fileProc)(buf);     /* I can't see a way not to use a global here [from xboard stuff] */
  1424. X    return;
  1425. X  }
  1426. X  
  1427. X}
  1428. END_OF_FILE
  1429.   if test 5589 -ne `wc -c <'cube/ldfile.c'`; then
  1430.     echo shar: \"'cube/ldfile.c'\" unpacked with wrong size!
  1431.   fi
  1432.   # end of 'cube/ldfile.c'
  1433. fi
  1434. if test -f 'cube/ldfile.h' -a "${1}" != "-c" ; then 
  1435.   echo shar: Will not clobber existing file \"'cube/ldfile.h'\"
  1436. else
  1437.   echo shar: Extracting \"'cube/ldfile.h'\" \(1242 characters\)
  1438.   sed "s/^X//" >'cube/ldfile.h' <<'END_OF_FILE'
  1439. X/* ldfile.h
  1440. X   Header file for ldfile.c 
  1441. X   Buvos Kocka (Hungarian Magic Cube). 
  1442. X
  1443. X
  1444. XThe following references were used:
  1445. X   "The X Window System Programming And Applications with Xt
  1446. X   OSF/MOTIF EDITION"
  1447. X   by Douglas A Young 
  1448. X   Prentice-Hall, 1990.
  1449. X   ISBN 0-13-642786-3
  1450. X
  1451. X   "Mastering Rubik's Cube"
  1452. X   by Don Taylor
  1453. X   An Owl Book; Holt, Rinehart and Winston, New York, 1980
  1454. X   ISBN 0-03-059941-5
  1455. X
  1456. X-------------------------------------------------------------------
  1457. XCopyright (C) 1993 by Pierre A. Fleurant
  1458. XPermission is granted to copy and distribute this program
  1459. Xwithout charge, provided this copyright notice is included
  1460. Xin the copy.
  1461. XThis Software is distributed on an as-is basis. There will be
  1462. XABSOLUTELY NO WARRANTY for any part of this software to work
  1463. Xcorrect. In no case will the author be liable to you for damages
  1464. Xcaused by the usage of this software.
  1465. X-------------------------------------------------------------------
  1466. X*/   
  1467. X
  1468. X#include <X11/StringDefs.h>
  1469. X#include <X11/Intrinsic.h> 
  1470. X#include <X11/Shell.h>
  1471. X#include <Xm/Xm.h>
  1472. X#include <Xm/DialogS.h>
  1473. X#include <Xm/FileSB.h> 
  1474. X
  1475. X#include "common.h"
  1476. X#include "libXs.h"
  1477. X#include <stdio.h>
  1478. X
  1479. X#define DIALOG_SIZE            325
  1480. X#define DIALOG_X            325
  1481. X#define DIALOG_Y            325
  1482. X#define MSG_SIZ                256
  1483. X
  1484. X
  1485. END_OF_FILE
  1486.   if test 1242 -ne `wc -c <'cube/ldfile.h'`; then
  1487.     echo shar: \"'cube/ldfile.h'\" unpacked with wrong size!
  1488.   fi
  1489.   # end of 'cube/ldfile.h'
  1490. fi
  1491. if test -f 'cube/lib/menus.c' -a "${1}" != "-c" ; then 
  1492.   echo shar: Will not clobber existing file \"'cube/lib/menus.c'\"
  1493. else
  1494.   echo shar: Extracting \"'cube/lib/menus.c'\" \(7132 characters\)
  1495.   sed "s/^X//" >'cube/lib/menus.c' <<'END_OF_FILE'
  1496. X/*********************************************************
  1497. X * menus.c: Simple menu package
  1498. X *         From:
  1499. X *                   The X Window System, 
  1500. X *            Programming and Applications with Xt
  1501. X *                   OSF/Motif Edition
  1502. X *         by
  1503. X *                Douglas Young
  1504. X *              Prentice Hall, 1990
  1505. X *
  1506. X *                 Example described on pages:  104-106
  1507. X *
  1508. X *
  1509. X *  Copyright 1989 by Prentice Hall
  1510. X *  All Rights Reserved
  1511. X *
  1512. X * This code is based on the OSF/Motif widget set and the X Window System
  1513. X *
  1514. X * Permission to use, copy, modify, and distribute this software for 
  1515. X * any purpose and without fee is hereby granted, provided that the above
  1516. X * copyright notice appear in all copies and that both the copyright notice
  1517. X * and this permission notice appear in supporting documentation.
  1518. X *
  1519. X * Prentice Hall and the author disclaim all warranties with regard to 
  1520. X * this software, including all implied warranties of merchantability and fitness.
  1521. X * In no event shall Prentice Hall or the author be liable for any special,
  1522. X * indirect or cosequential damages or any damages whatsoever resulting from 
  1523. X * loss of use, data or profits, whether in an action of contract, negligence 
  1524. X * or other tortious action, arising out of or in connection with the use 
  1525. X * or performance of this software.
  1526. X *
  1527. X * Open Software Foundation is a trademark of The Open Software Foundation, Inc.
  1528. X * OSF is a trademark of Open Software Foundation, Inc.
  1529. X * OSF/Motif is a trademark of Open Software Foundation, Inc.
  1530. X * Motif is a trademark of Open Software Foundation, Inc.
  1531. X * DEC is a registered trademark of Digital Equipment Corporation
  1532. X * HP is a registered trademark of the Hewlett Packard Company
  1533. X * DIGITAL is a registered trademark of Digital Equipment Corporation
  1534. X * X Window System is a trademark of the Massachusetts Institute of Technology
  1535. X **********************************************************************************/
  1536. X
  1537. X#include <Xm/BulletinB.h>
  1538. X#include <X11/StringDefs.h>
  1539. X#include <X11/Intrinsic.h>
  1540. X#include <Xm/Xm.h>
  1541. X#include <Xm/Separator.h>
  1542. X#include <Xm/PushB.h>
  1543. X#include <Xm/CascadeB.h>
  1544. X#include <Xm/RowColumn.h>
  1545. X#include <Xm/Label.h>
  1546. X#include "libXs.h"
  1547. X
  1548. Xxs_create_menu_buttons(title, menu, menulist, nitems)
  1549. X     char           *title;
  1550. X     Widget          menu;
  1551. X     xs_menu_struct *menulist;
  1552. X     int             nitems;
  1553. X{
  1554. X  Arg        wargs[1];
  1555. X  int        i;
  1556. X  WidgetList buttons;
  1557. X  int        separators = 0;
  1558. X  /*
  1559. X   * Allocate a widget list to hold all 
  1560. X   * button widgets.
  1561. X   */
  1562. X  buttons = (WidgetList) XtMalloc(nitems * sizeof(Widget));
  1563. X  /*
  1564. X   * If a title is given, create Label and Separator widgets.
  1565. X   */
  1566. X  if(title){
  1567. X    XtCreateManagedWidget(title, xmLabelWidgetClass, menu,
  1568. X                          NULL, 0);
  1569. X    XtCreateManagedWidget("separator", xmSeparatorWidgetClass, menu, NULL, 0);
  1570. X  }
  1571. X  /*
  1572. X   * Create an entry for each item in the menu.
  1573. X   */
  1574. X  for(i=0;i<nitems;i++){
  1575. X    /* 
  1576. X     * A NULL name represents a separator.
  1577. X     */
  1578. X    if(menulist[i].name == NULL){ 
  1579. X      XtCreateManagedWidget("separator", xmSeparatorWidgetClass, menu, NULL, 0);
  1580. X      separators++; /* Count how many entries aren't buttons */
  1581. X    }
  1582. X    /*
  1583. X     * If there is a name and a callback, create a "normal"
  1584. X     * menu entry and register the callback function.
  1585. X     */
  1586. X    else if(menulist[i].func){
  1587. X      buttons[i-separators] = XtCreateWidget(menulist[i].name, xmPushButtonWidgetClass,menu, NULL, 0);
  1588. X      XtAddCallback(buttons[i-separators], XmNactivateCallback,
  1589. X            menulist[i].func, menulist[i].data);
  1590. X    }
  1591. X    /*
  1592. X     * If there is a name, but no callback function, the entry
  1593. X     * must be a label, unless there is a submenu.
  1594. X     */
  1595. X    else if(!menulist[i].sub_menu)
  1596. X      buttons[i-separators] = XtCreateWidget(menulist[i].name,
  1597. X                         xmLabelWidgetClass,
  1598. X                         menu, NULL, 0);
  1599. X    /*
  1600. X     * If we got here, the entry must be a submenu.
  1601. X     * Create a pulldown menu pane and an XmCascadeButton
  1602. X     * widget. Attach the menu pane and make a recursive call
  1603. X     * to create the entries in the submenu.
  1604. X     */
  1605. X    else{  
  1606. X      Widget sub_menu;
  1607. X      sub_menu =XmCreatePulldownMenu(menu,
  1608. X                     menulist[i].sub_menu_title,
  1609. X                     NULL, 0);
  1610. X      XtSetArg(wargs[0], XmNsubMenuId, sub_menu);
  1611. X      buttons[i-separators] =
  1612. X    XtCreateWidget(menulist[i].name,
  1613. X               xmCascadeButtonWidgetClass,
  1614. X               menu, wargs, 1);
  1615. X      xs_create_menu_buttons(menulist[i].sub_menu_title,
  1616. X                 sub_menu, menulist[i].sub_menu,
  1617. X                 menulist[i].n_sub_items);
  1618. X    }
  1619. X  } 
  1620. X  /*
  1621. X   * Manage all button widgets. Menu panes are not managed.
  1622. X   */
  1623. X  XtManageChildren(buttons, nitems - separators);
  1624. X}
  1625. X
  1626. Xxss_create_menu_buttons(title, menu, menulist, nitems, auxdata)
  1627. X     char           *title;
  1628. X     Widget          menu;
  1629. X     xs_menu_struct *menulist;
  1630. X     int             nitems;
  1631. X     caddr_t         auxdata;
  1632. X{
  1633. X  Arg        wargs[1];
  1634. X  int        i;
  1635. X  WidgetList buttons;
  1636. X  int        separators = 0;
  1637. X  /*
  1638. X   * Allocate a widget list to hold all 
  1639. X   * button widgets.
  1640. X   */
  1641. X  buttons = (WidgetList) XtMalloc(nitems * sizeof(Widget));
  1642. X  /*
  1643. X   * If a title is given, create Label and Separator widgets.
  1644. X   */
  1645. X  if(title){
  1646. X    XtCreateManagedWidget(title, xmLabelWidgetClass, menu,
  1647. X                          NULL, 0);
  1648. X    XtCreateManagedWidget("separator", xmSeparatorWidgetClass, menu, NULL, 0);
  1649. X  }
  1650. X  /*
  1651. X   * Create an entry for each item in the menu.
  1652. X   */
  1653. X  for(i=0;i<nitems;i++){
  1654. X    /* 
  1655. X     * A NULL name represents a separator.
  1656. X     */
  1657. X    if(menulist[i].name == NULL){ 
  1658. X      XtCreateManagedWidget("separator", xmSeparatorWidgetClass, menu, NULL, 0);
  1659. X      separators++; /* Count how many entries aren't buttons */
  1660. X    }
  1661. X    /*
  1662. X     * If there is a name and a callback, create a "normal"
  1663. X     * menu entry and register the callback function.
  1664. X     */
  1665. X    else if(menulist[i].func){
  1666. X      buttons[i-separators] = XtCreateWidget(menulist[i].name, xmPushButtonWidgetClass,menu, NULL, 0);
  1667. X      XtAddCallback(buttons[i-separators], XmNactivateCallback,
  1668. X            menulist[i].func, auxdata);
  1669. X    }
  1670. X    /*
  1671. X     * If there is a name, but no callback function, the entry
  1672. X     * must be a label, unless there is a submenu.
  1673. X     */
  1674. X    else if(!menulist[i].sub_menu)
  1675. X      buttons[i-separators] = XtCreateWidget(menulist[i].name,
  1676. X                         xmLabelWidgetClass,
  1677. X                         menu, NULL, 0);
  1678. X    /*
  1679. X     * If we got here, the entry must be a submenu.
  1680. X     * Create a pulldown menu pane and an XmCascadeButton
  1681. X     * widget. Attach the menu pane and make a recursive call
  1682. X     * to create the entries in the submenu.
  1683. X     */
  1684. X    else{  
  1685. X      Widget sub_menu;
  1686. X      sub_menu =XmCreatePulldownMenu(menu,
  1687. X                     menulist[i].sub_menu_title,
  1688. X                     NULL, 0);
  1689. X      XtSetArg(wargs[0], XmNsubMenuId, sub_menu);
  1690. X      buttons[i-separators] =
  1691. X    XtCreateWidget(menulist[i].name,
  1692. X               xmCascadeButtonWidgetClass,
  1693. X               menu, wargs, 1);
  1694. X      xss_create_menu_buttons(menulist[i].sub_menu_title,
  1695. X                  sub_menu, menulist[i].sub_menu,
  1696. X                  menulist[i].n_sub_items,auxdata);
  1697. X    }
  1698. X  } 
  1699. X  /*
  1700. X   * Manage all button widgets. Menu panes are not managed.
  1701. X   */
  1702. X  XtManageChildren(buttons, nitems - separators);
  1703. X}
  1704. END_OF_FILE
  1705.   if test 7132 -ne `wc -c <'cube/lib/menus.c'`; then
  1706.     echo shar: \"'cube/lib/menus.c'\" unpacked with wrong size!
  1707.   fi
  1708.   # end of 'cube/lib/menus.c'
  1709. fi
  1710. if test -f 'cube/lib/pix_buttons.c' -a "${1}" != "-c" ; then 
  1711.   echo shar: Will not clobber existing file \"'cube/lib/pix_buttons.c'\"
  1712. else
  1713.   echo shar: Extracting \"'cube/lib/pix_buttons.c'\" \(9237 characters\)
  1714.   sed "s/^X//" >'cube/lib/pix_buttons.c' <<'END_OF_FILE'
  1715. X/*
  1716. X      pixmap_browser functions
  1717. X   and ... label_wbutton (label with button) function.
  1718. X   
  1719. X           From:
  1720. X                     The X Window System, 
  1721. X              Programming and Applications with Xt
  1722. X                     OSF/Motif Edition
  1723. X           by
  1724. X                  Douglas Young
  1725. X                Prentice Hall, 1990
  1726. X  
  1727. X                   Example described on pages:  200-202
  1728. X  
  1729. X  
  1730. X    Copyright 1989 by Prentice Hall
  1731. X    All Rights Reserved
  1732. X  
  1733. X   This code is based on the OSF/Motif widget set and the X Window System
  1734. X  
  1735. X   Permission to use, copy, modify, and distribute this software for 
  1736. X   any purpose and without fee is hereby granted, provided that the above
  1737. X   copyright notice appear in all copies and that both the copyright notice
  1738. X   and this permission notice appear in supporting documentation.
  1739. X  
  1740. X   Prentice Hall and the author disclaim all warranties with regard to 
  1741. X   this software, including all implied warranties of merchantability and fitness.
  1742. X   In no event shall Prentice Hall or the author be liable for any special,
  1743. X   indirect or cosequential damages or any damages whatsoever resulting from 
  1744. X   loss of use, data or profits, whether in an action of contract, negligence 
  1745. X   or other tortious action, arising out of or in connection with the use 
  1746. X   or performance of this software.
  1747. X  
  1748. X   Open Software Foundation is a trademark of The Open Software Foundation, Inc.
  1749. X   OSF is a trademark of Open Software Foundation, Inc.
  1750. X   OSF/Motif is a trademark of Open Software Foundation, Inc.
  1751. X   Motif is a trademark of Open Software Foundation, Inc.
  1752. X   DEC is a registered trademark of Digital Equipment Corporation
  1753. X   HP is a registered trademark of the Hewlett Packard Company
  1754. X   DIGITAL is a registered trademark of Digital Equipment Corporation
  1755. X   X Window System is a trademark of the Massachusetts Institute of Technology
  1756. X*/
  1757. X#include <X11/StringDefs.h>
  1758. X#include <X11/Intrinsic.h> 
  1759. X#include <Xm/Xm.h>
  1760. X#include <Xm/ToggleB.h>
  1761. X#include <Xm/RowColumn.h>
  1762. X#include "libXs.h"
  1763. X
  1764. X
  1765. XWidget xs_create_pixmap_browser (parent,tiles,n_tiles,callback,data)
  1766. X     Widget     parent;       /* widget to manage the browser */
  1767. X     char      *tiles[];      /* list of tile names           */
  1768. X     int        n_tiles;      /* how many tiles               */
  1769. X     void      (*callback)(); /* invoked when state changes   */
  1770. X     caddr_t    data;         /* data to be passed to callback*/
  1771. X{
  1772. X  Widget     browser;
  1773. X  WidgetList buttons;
  1774. X  int        i;
  1775. X  Arg        wargs[10];
  1776. X  /*
  1777. X   * Malloc room for button widgets.
  1778. X   */
  1779. X  buttons = (WidgetList) XtMalloc(n_tiles * sizeof(Widget));
  1780. X  /*
  1781. X   * Create a "RadioBox" RowColumn widget.
  1782. X   */
  1783. X  XtSetArg(wargs[0], XmNentryClass, xmToggleButtonWidgetClass);
  1784. X  browser = XmCreateRadioBox(parent, "browser", wargs, 1);
  1785. X  /*
  1786. X   * Create a button for each tile. If a callback function
  1787. X   * has been given, register it as an XmNvalueChangedCallback
  1788. X   */
  1789. X  for(i=0;i< n_tiles;i++){
  1790. X    buttons[i] = xs_create_pixmap_button(browser, tiles[i]);
  1791. X    if(callback)
  1792. X      XtAddCallback(buttons[i], XmNvalueChangedCallback, 
  1793. X            callback, data);
  1794. X  }
  1795. X  /*
  1796. X   * Manage all buttons and return the RadioBox widget, which
  1797. X   * is still unmanaged
  1798. X   */ 
  1799. X  XtManageChildren(buttons, n_tiles);
  1800. X  return browser;
  1801. X}
  1802. X
  1803. XWidget xss_create_label_wbutton(parent,names,n_names,callback,data)
  1804. X     Widget     parent;       /* widget to manage the browser */
  1805. X     char      *names[];      /* list of names                */
  1806. X     int        n_names;      /* number of names              */
  1807. X     void      (*callback)(); /* invoked when state changes   */
  1808. X     caddr_t    data;         /* data to be passed to callback*/
  1809. X{
  1810. X  Widget     panel;
  1811. X  WidgetList buttons;
  1812. X  int        i;
  1813. X  Arg        wargs[10];
  1814. X  /*
  1815. X   * Malloc room for button widgets.
  1816. X   */
  1817. X  buttons = (WidgetList) XtMalloc(n_names * sizeof(Widget));
  1818. X  /*
  1819. X   * Create a "RadioBox" RowColumn widget.
  1820. X   */
  1821. X  XtSetArg(wargs[0], XmNentryClass, xmToggleButtonWidgetClass);
  1822. X  panel = XmCreateRadioBox(parent, "panel", wargs, 1);
  1823. X  /*
  1824. X   * Create a button for each name If a callback function
  1825. X   * has been given, register it as an XmNvalueChangedCallback
  1826. X   */
  1827. X  for(i=0;i< n_names;i++){
  1828. X    buttons[i] = xss_create_label_button(panel, names[i], (Cardinal)i);
  1829. X    if(callback)
  1830. X      XtAddCallback(buttons[i], XmNvalueChangedCallback, 
  1831. X            callback, data);
  1832. X  }
  1833. X  /*
  1834. X   * Manage all buttons and return the RadioBox widget, which
  1835. X   * is still unmanaged
  1836. X   */ 
  1837. X  XtManageChildren(buttons, n_names);
  1838. X  return panel;
  1839. X}
  1840. X
  1841. XWidget xs_create_pixmap_button(parent, pattern)
  1842. X     Widget         parent;
  1843. X     char *         pattern;
  1844. X{
  1845. X  Pixmap   tile;
  1846. X  Widget   button;
  1847. X  Arg      wargs[10];
  1848. X  Pixel    foreground, background;
  1849. X  int      n;
  1850. X  
  1851. X  button = XtCreateWidget(pattern, xmToggleButtonWidgetClass,
  1852. X              parent, NULL, 0);
  1853. X  /*
  1854. X   * Retrieve the colors of the widget.
  1855. X   */
  1856. X  n = 0;
  1857. X  XtSetArg(wargs[n], XtNforeground, &foreground);n++;
  1858. X  XtSetArg(wargs[n], XtNbackground, &background);n++;
  1859. X  XtGetValues(button, wargs, n);
  1860. X  /*
  1861. X   * Get a tile corresponding the given pattern.
  1862. X   */
  1863. X  tile = XmGetPixmap (XtScreen(button),  pattern,
  1864. X              foreground, background);
  1865. X  /*
  1866. X   * Display the pixmap in the button and also store it
  1867. X   * so it can be retrieved from the button later.
  1868. X   */
  1869. X  n = 0;
  1870. X  XtSetArg(wargs[n], XmNlabelType,   XmPIXMAP); n++;
  1871. X  XtSetArg(wargs[n], XmNlabelPixmap, tile); n++;
  1872. X  XtSetArg(wargs[n], XmNuserData,    tile); n++;
  1873. X  XtSetValues(button, wargs, n);
  1874. X  /*
  1875. X   * Return the unmanaged button.
  1876. X   */
  1877. X  return button;
  1878. X}
  1879. X
  1880. XWidget xss_create_label_button(parent, name, side_number)
  1881. X     Widget   parent;
  1882. X     char     *name;
  1883. X     Cardinal side_number;
  1884. X{
  1885. X  Widget   button;
  1886. X  Arg      wargs[10];
  1887. X  int      n;
  1888. X  XmString   xmstr;
  1889. X  
  1890. X  button = XtCreateWidget(name, xmToggleButtonWidgetClass,
  1891. X              parent, NULL, 0);
  1892. X  /*
  1893. X   * Display the name in the button and also store it
  1894. X   * so it can be retrieved from the button later.
  1895. X   */
  1896. X
  1897. X  /* Convert name to a compound string. */
  1898. X
  1899. X  xmstr = XmStringCreate(name, XmSTRING_DEFAULT_CHARSET);
  1900. X
  1901. X  n = 0;
  1902. X  XtSetArg(wargs[n], XmNlabelString, xmstr); n++;
  1903. X  XtSetArg(wargs[n], XmNuserData, side_number); n++;
  1904. X  XtSetValues(button, wargs, n);
  1905. X
  1906. X  /*
  1907. X   * Return the unmanaged button.
  1908. X   */
  1909. X  return button;
  1910. X}
  1911. X
  1912. Xxs_register_pattern(w, name, bits, width, height)
  1913. X     Widget         w;
  1914. X     char          *name;
  1915. X     unsigned char *bits;
  1916. X     int            width, height;
  1917. X{
  1918. X  XImage *image;
  1919. X  image = XCreateImage(XtDisplay(w),
  1920. X               DefaultVisualOfScreen(XtScreen(w)), 
  1921. X               1, XYBitmap, 0, 
  1922. X               bits, width, height, 8, 2);
  1923. X  XmInstallImage(image, name);
  1924. X}
  1925. X
  1926. XWidget xss_create_pixmap_browser(parent,tiles,n_tiles,callback,data)
  1927. X     Widget     parent;       /* widget to manage the browser */
  1928. X     char      *tiles[];      /* list of tile names           */
  1929. X     int        n_tiles;      /* how many tiles               */
  1930. X     void      (*callback)(); /* invoked when state changes   */
  1931. X     caddr_t    data;         /* data to be passed to callback*/
  1932. X{
  1933. X  Widget     browser;
  1934. X  WidgetList buttons;
  1935. X  int        i;
  1936. X  Arg        wargs[10];
  1937. X  /*
  1938. X   * Malloc room for button widgets.
  1939. X   */
  1940. X  buttons = (WidgetList) XtMalloc(n_tiles * sizeof(Widget));
  1941. X  /*
  1942. X   * Create a "RadioBox" RowColumn widget.
  1943. X   */
  1944. X  XtSetArg(wargs[0], XmNentryClass, xmToggleButtonWidgetClass);
  1945. X  browser = XmCreateRadioBox(parent, "browser", wargs, 1);
  1946. X  /*
  1947. X   * Create a button for each tile. If a callback function
  1948. X   * has been given, register it as an XmNvalueChangedCallback
  1949. X   */
  1950. X  for(i=0; i< n_tiles; i++){
  1951. X    buttons[i] = xss_create_pixmap_button(browser, tiles[i],i);
  1952. X    if(callback)
  1953. X      XtAddCallback(buttons[i], XmNvalueChangedCallback, 
  1954. X            callback, data);
  1955. X  }
  1956. X  /*
  1957. X   * Manage all buttons and return the RadioBox widget, which
  1958. X   * is still unmanaged
  1959. X   */ 
  1960. X  XtManageChildren(buttons, n_tiles);
  1961. X  return browser;
  1962. X}
  1963. X
  1964. XWidget xss_create_pixmap_button(parent, pattern,i)
  1965. X     Widget         parent;
  1966. X     char          *pattern;
  1967. X     int           i;   /* button number */
  1968. X{
  1969. X  Pixmap   tile;
  1970. X  Widget   button;
  1971. X  Arg      wargs[10];
  1972. X  int      n;
  1973. X  
  1974. X  button = XtCreateWidget(pattern, xmToggleButtonWidgetClass,parent, NULL, 0);
  1975. X  /*
  1976. X   * Get a tile corresponding the given pattern.
  1977. X   */
  1978. X  tile = XmGetPixmap (XtScreen(button),  pattern,
  1979. X              xss_get_pixel_by_name(parent, pattern),
  1980. X              xss_get_pixel_by_name(parent, pattern));
  1981. X  /*
  1982. X   * Display the pixmap in the button and also store it
  1983. X   * so it can be retrieved from the button later.
  1984. X   */
  1985. X  n = 0;
  1986. X  XtSetArg(wargs[n], XmNlabelType,   XmPIXMAP); n++;
  1987. X  XtSetArg(wargs[n], XmNlabelPixmap, tile);     n++;
  1988. X  XtSetArg(wargs[n], XmNuserData,    i);        n++; /* button number */
  1989. X  XtSetValues(button, wargs, n);
  1990. X  /*
  1991. X   * Return the unmanaged button.
  1992. X   */
  1993. X  return button;
  1994. X}
  1995. X
  1996. XPixel xss_get_pixel_by_name(w, colorname)
  1997. X     Widget w;
  1998. X     char  *colorname;
  1999. X{
  2000. X  Display *dpy  = XtDisplay(w);
  2001. X  int      scr  = DefaultScreen(dpy);
  2002. X  Colormap cmap = DefaultColormap(dpy, scr);
  2003. X  XColor   color, ignore;
  2004. X  /* 
  2005. X   * Allocate the named color.
  2006. X   */
  2007. X  if(XAllocNamedColor(dpy, cmap, colorname, &color, &ignore))
  2008. X    return (color.pixel);
  2009. X  else{
  2010. X    printf("Warning: Couldn't allocate color %s\n", colorname);
  2011. X    return (BlackPixel(dpy, scr));
  2012. X  }
  2013. X}
  2014. END_OF_FILE
  2015.   if test 9237 -ne `wc -c <'cube/lib/pix_buttons.c'`; then
  2016.     echo shar: \"'cube/lib/pix_buttons.c'\" unpacked with wrong size!
  2017.   fi
  2018.   # end of 'cube/lib/pix_buttons.c'
  2019. fi
  2020. echo shar: End of archive 3 \(of 5\).
  2021. cp /dev/null ark3isdone
  2022. MISSING=""
  2023. for I in 1 2 3 4 5 ; do
  2024.     if test ! -f ark${I}isdone ; then
  2025.     MISSING="${MISSING} ${I}"
  2026.     fi
  2027. done
  2028. if test "${MISSING}" = "" ; then
  2029.     echo You have unpacked all 5 archives.
  2030.     rm -f ark[1-9]isdone
  2031. else
  2032.     echo You still must unpack the following archives:
  2033.     echo "        " ${MISSING}
  2034. fi
  2035. exit 0
  2036. exit 0 # Just in case...
  2037.