1 /*-
2 # X-BASED PANEX(tm)
3 #
4 #  PanexP.h
5 #
6 ###
7 #
8 #  Copyright (c) 1996 - 99	David Albert Bagley, bagleyd@tux.org
9 #
10 #                   All Rights Reserved
11 #
12 #  Permission to use, copy, modify, and distribute this software and
13 #  its documentation for any purpose and without fee is hereby granted,
14 #  provided that the above copyright notice appear in all copies and
15 #  that both that copyright notice and this permission notice appear in
16 #  supporting documentation, and that the name of the author not be
17 #  used in advertising or publicity pertaining to distribution of the
18 #  software without specific, written prior permission.
19 #
20 #  This program is distributed in the hope that it will be "playable",
21 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
22 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23 #
24 */
25 
26 /* Private header file for Panex */
27 
28 #ifndef _PanexP_h
29 #define _PanexP_h
30 
31 #include "Panex.h"
32 
33 #define SYMBOL ':'
34 
35 /* The following are in xpanex.c also */
36 #define MINTILES 1
37 #define HANOI 0
38 #define PANEX 1
39 #define MAXMODES 2
40 
41 #define DEFAULTMODE PANEX
42 #define DEFAULTTILES 10
43 #define MAXSTACKS 3
44 #define UP 1
45 #define DOWN 0
46 
47 #define ABS(a) (((a)<0)?(-a):(a))
48 #define SIGN(a) (((a)<0)?-1:1)
49 #define MIN(a,b) (((int)(a)<(int)(b))?(int)(a):(int)(b))
50 #define MAX(a,b) (((int)(a)>(int)(b))?(int)(a):(int)(b))
51 
52 typedef struct _PanexLoc {
53 	int         stack, loc;
54 } PanexLoc;
55 
56 typedef struct _PanexPart {
57 	Pixel       foreground;
58 	Pixel       tileColor, borderColor;
59 	Pixel       pyramidColor[MAXSTACKS - 1];
60 	PanexLoc   *tileOfPosition[MAXSTACKS];
61 	PanexLoc   *positionOfTile[MAXSTACKS];
62 	Position    height;
63 	int         currentStack, currentPosition;
64 	Boolean     started, mono, reverse;
65 	int         depth;
66 	int         mode, tiles;
67 	int         delay;
68 	Position    width;
69 	XPoint      tileSize;
70 	XPoint      pos;
71 	XPoint      delta, puzzleOffset, letterOffset;
72 	GC          pyramidGC[MAXSTACKS - 1];
73 	GC          puzzleGC;
74 	GC          stackGC;
75 	GC          tileGC;
76 	GC          borderGC;
77 	GC          inverseGC;
78 	String      pyramidName[MAXSTACKS - 1];
79 	char       *username;
80 	XtCallbackList select;
81 } PanexPart;
82 
83 typedef struct _PanexRec {
84 	CorePart    core;
85 	PanexPart   panex;
86 } PanexRec;
87 
88 /* This gets around C's inability to do inheritance */
89 typedef struct _PanexClassPart {
90 	int         ignore;
91 } PanexClassPart;
92 
93 typedef struct _PanexClassRec {
94 	CoreClassPart core_class;
95 	PanexClassPart panex_class;
96 } PanexClassRec;
97 
98 extern PanexClassRec panexClassRec;
99 extern PanexLoc *startLoc[MAXSTACKS - 1];
100 
101 extern int  MovePanex(PanexWidget w, int fromStack, int fromPosition, int toStack);
102 
103 extern void SolveTiles(PanexWidget w);
104 extern void DrawAllTiles(PanexWidget w);
105 extern int  TopOfStack(PanexWidget w, int stack);
106 extern Boolean CheckMiddle(PanexWidget w);
107 extern Boolean CheckSolved(PanexWidget w);
108 extern void InitMoves(void);
109 extern void PutMove(int from, int to);
110 extern void GetMove(int *from, int *to);
111 extern int  MadeMoves(void);
112 extern void FlushMoves(PanexWidget w);
113 extern int  NumMoves(void);
114 extern void ScanMoves(FILE * fp, PanexWidget w, int moves);
115 extern void PrintMoves(FILE * fp);
116 extern void ScanStartPosition(FILE * fp, PanexWidget w);
117 extern void PrintStartPosition(FILE * fp, PanexWidget w);
118 extern void SetStartPosition(PanexWidget w);
119 
120 #endif /* _PanexP_h */
121