pkg://kgames-1.0-2.src.rpm:545037/kgames-1.0.tar.gz
info downloads
kgames-1.0/ 40755 20717 2432 0 6515035106 7210 5 ustar kgames-1.0/HPUX.Install 100644 20717 2432 5076 6121566725 11442 0 ustar Files Changed:
Xkw/CardsUtil.c Caters for HPUX equivalents of random and srandom
dominos/dominos.c Caters for HPUX equivalents of random and srandom
dominos/util.c Caters for HPUX equivalents of random and srandom
kcanfield/canfield.c Caters for HPUX equivalents of random and srandom
kcribbage/xt.c Caters for HPUX equivalents of random and srandom
Comments out one entry which caused a problem
kklondike/klondike.c Caters for HPUX equivalents of random and srandom
kmontana/montana.c Caters for HPUX equivalents of random and srandom
kspider/spider.c Caters for HPUX equivalents of random and srandom
kthieves/thieves.c Caters for HPUX equivalents of random and srandom
ktowers/ktowers.c Caters for HPUX equivalents of random and srandom
mc/mc.c Caters for HPUX equivalents of random and srandom
Corrects errors on addressing when writing messages
slyfox/slyfox.c Caters for HPUX equivalents of random and srandom
xmille/mille.c Caters for HPUX equivalents of random and srandom
xmille/roll.c Caters for HPUX equivalents of random and srandom
To Build it:
Just type in
$ xmkmf -a
$ make
To Install:
$ make install install.man
The above makes everything. If you just wish to make one of the games do the
following.
$ xmkmf -a
$ cd Xkw
$ make
$ cd to the games directory you want (eg kmontana)
$ make
This will make the program you wish to run.
All these games have application default files which must be loaded before the
game is run. The instructions below show what must be done for each game.
dominos :-
$ xrdb -load Dominos-color.ad
$ dominos
$ xrdb -remove
kcanfield :-
$ xrdb -load Kcanfield-color.ad
$ kcanfield
$ xrdb -remove
kcribbage :-
$ xrdb -load Cribbage.ad
$ kcribbage
$ xrdb -remove
kklondike :-
$ xrdb -load Kklondike.ad
$ kklondike
$ xrdb -remove
kmontana :-
$ xrdb -load Kmontana.ad
$ kmontana
$ xrdb -remove
kspider :-
$ xrdb -load Kspider-color.ad
$ kspider
$ xrdb -remove
kthieves :-
$ xrdb -load Kthieves-color.ad
$ kthieves
$ xrdb -remove
ktowers :-
$ xrdb -load Ktowers.ad
$ ktowers
$ xrdb -remove
mcarlo :-
$ xrdb -load MonteCarlo.ad
$ mcarlo
$ xrdb -remove
xreversi :-
$ xrdb -load Xreversi.ad
$ xreversi
$ xrdb -remove
slyfox :-
This game has two different application default files. One of these is
for a normal version of the game, the other is for a harder version of
the game.
for the normal game do
$ xrdb -load SlyFox.ad
$ slyfox
$ xrdb -remove
for the harder game do
$ xrdb -load SlyFox-hard.ad
$ slyfox
$ xrdb -remove
xmille :-
$ xrdb -load Mille.ad
$ xmille
$ xrdb -remove
kgames-1.0/Imakefile 100644 20717 2432 445 6121566725 11112 0 ustar #define IHaveSubdirs
#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
/* Not building reversi - it was too slow on our machines */
SUBDIRS = Xkw kspider kcanfield kklondike kmontana xmille \
ktowers kthieves kcribbage dominos slyfox mc
MakeSubdirs($(SUBDIRS))
DependSubdirs($(SUBDIRS))
kgames-1.0/README 100644 20717 2432 4136 6121566726 10203 0 ustar This is a collection of games, and some useful widgets which
have been used in their construction.
I've tested everything here with the original R6 release, but only
on a Sparc-10 running SunOS 4.
The Widgets (Xkw/):
Layout a constraint based geometry widget. Included in
this release is some code purported to make it work
with Motif; I cannot test that as I do not have access
to Motif.
Hand, Cards Playing card management widget; does all of the
nasty redisplay and layout of stacks of overlapping
cards. Cards is a subclass and deals with regular
playing cards.
Message Utilities which allow a printf-style interface
to the Athena Label widget.
Pad A text display widget; handles scrolling and
simple repaint. More powerful than Label as
it optimizes repaint, but it only handles
char cell fonts.
Thermo Displays a "thermometer" for indicating a
bounded-range value. Draws tick-marks and
numbers. Handles both vertical and horizontal
orientation.
The Games (everything else). For rules on how to play them,
consult Hoyle or just play around and see what they'll let you do.
dominos Double 9 dominos against the computer.
kcanfield Standard Canfield solitare.
kcribbage Cribbage against the computer. The
score keeping widget is not very pretty.
kklondike "Regular" solitaire.
kmontana An interesting single-deck solitaire. Stolen
from the Macintosh game of the same name.
kspider The classic double-deck solitaire. Probably
the most interesting game here.
kthieves 40-thieves. I've only seen this won a few times.
ktowers A perfect-knowledge single deck game. Nearly every
configuration can be eventually solved.
mcarlo Monte-carlo. A very simple matching solitaire.
Written by Dave Lemke
reversi Or "Othello", except that that name is copywritten.
slyfox Any easier double-deck solitaire. This one includes
instructions; see slyfox-rules.
Written by Dave Lemke
xmille My first X program. Doesn't look much like the
original anymore, except for the gory pictures.
Keith Packard
keithp@ncd.com
June 6, 1994
kgames-1.0/README.HPPD 100644 20717 2432 732 6121575304 10703 0 ustar Package name: kgames
Version number: 1.0
Original author: Keith Packard <keithp@ncd.com>
Report bugs to: workexp@csc.liv.ac.uk
Tested on: HP 9000/735/125 running HP-UX 9.03
C compiler used: Version A.09.77
Purpose:
Kgames is a compendium of games. The games are mostly solitaire games but
versions of dominos, cribbage, reversi (othello) and mille bourne are included.
Date archived: Wed 13 Mar 1996
Special notes: Read HPUX.Install for further info.
kgames-1.0/Xkw/ 40755 20717 2432 0 6515035111 7755 5 ustar kgames-1.0/Xkw/Animate.c 100644 20717 2432 13362 6121566726 11637 0 ustar /*
* $NCD$
*
* Copyright 1992 Network Computing Devices
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, 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 NCD. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. NCD. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
* 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: Keith Packard, Network Computing Devices
*/
# include <X11/Xlib.h>
# include <math.h>
# include <X11/Intrinsic.h>
# include <X11/StringDefs.h>
# include <X11/Xos.h>
# include "Cards.h"
#define DEFAULT_ANIMATION_SPEED 20
double animation_speed = DEFAULT_ANIMATION_SPEED;
static Dimension width, height;
static Pixel xor_value;
AnimateSetSpeed (i)
int i;
{
if (i < 0)
i = DEFAULT_ANIMATION_SPEED;
animation_speed = i;
}
Animate (srcWidget, srcRow, srcCol, dstWidget, dstRow, dstCol)
Widget srcWidget;
int srcRow, srcCol;
Widget dstWidget;
int dstRow, dstCol;
{
int ox, oy, dx, dy;
Arg arg[4];
Pixel obverse, black;
if (!animation_speed) return;
XtSetArg (arg[0], XtNcardWidth, &width);
XtSetArg (arg[1], XtNcardHeight, &height);
XtSetArg (arg[2], XtNobverseColor, &obverse);
XtSetArg (arg[3], XtNblackColor, &black);
XtGetValues (srcWidget, arg, 4);
xor_value = obverse ^ black;
compute_position (srcWidget, srcRow, srcCol, XtParent(srcWidget), &ox, &oy);
compute_position (dstWidget, dstRow, dstCol, XtParent(srcWidget), &dx, &dy);
do_animate (XtParent(srcWidget), ox, oy, dx, dy);
}
# define abs(x) ((x) < 0 ? -(x) : (x))
/*
* bigger numbers make it go faster
*/
# define accerate(v,r) ((v) + (speed/25 * (r)))
static
msleep (ms)
{
struct { int s, us; } t;
int f = 0;
t.s = ms / 1000;
t.us = (ms % 1000) * 1000;
select (1, &f, 0, 0, &t);
}
static
do_animate (widget, ox, oy, dx, dy)
Widget widget;
{
Display *dpy = XtDisplay (widget);
double x, y;
double xc, yc;
int xd, yd;
int xp, yp;
int x1, y1, x2, y2, x3, y3, x4, y4;
int ix, iy;
double dist;
double rx, ry;
double speed;
x = ox;
y = oy;
xd = dx - ox;
yd = dy - oy;
dist = sqrt ((double) xd * xd + yd * yd);
rx = (double) xd / dist;
ry = (double) yd / dist;
speed = animation_speed;
xc = speed * rx;
yc = speed * ry;
xp = yp = -32767;
XFlush (dpy);
while (abs(dx - x) > abs (xc) || abs(dy - y) > abs (yc)) {
ix = x;
iy = y;
if (xp == -32767)
draw_square (widget, ix, iy, ix + width, iy + height);
else {
if (xp < ix) {
x1 = xp + width;
x2 = ix + width;
x3 = ix;
x4 = ix + width;
} else if (xp > ix) {
x1 = ix;
x2 = xp;
x3 = ix;
x4 = ix + width;
} else {
x1 = -32767;
x2 = -32767;
x3 = ix;
x4 = ix + width;
}
if (yp < iy) {
y1 = iy;
y2 = yp + height;
y3 = yp + height;
y4 = iy + height;
} else if (yp > iy) {
y1 = yp;
y2 = iy + height;
y3 = iy;
y4 = yp;
} else {
y1 = iy;
y2 = iy + height;
y3 = -32767;
y4 = -32767;
}
if (x1 != -32767 && y1 != -32767)
draw_square (widget, x1, y1, x2, y2);
if (x3 != -32767 && y3 != -32767)
draw_square (widget, x3, y3, x4, y4);
if (ix < xp) {
x1 = ix + width;
x2 = xp + width;
x3 = xp;
x4 = xp + width;
} else if (ix > xp) {
x1 = xp;
x2 = ix;
x3 = xp;
x4 = xp + width;
} else {
x1 = -32767;
x2 = -32767;
x3 = xp;
x4 = xp + width;
}
if (iy < yp) {
y1 = yp;
y2 = iy + height;
y3 = iy + height;
y4 = yp + height;
} else if (iy > yp) {
y1 = iy;
y2 = yp + height;
y3 = yp;
y4 = iy;
} else {
y1 = yp;
y2 = yp + height;
y3 = -32767;
y4 = -32767;
}
if (x1 != -32767 && y1 != -32767)
draw_square (widget, x1, y1, x2, y2);
if (x3 != -32767 && y3 != -32767)
draw_square (widget, x3, y3, x4, y4);
}
xp = ix;
yp = iy;
if (abs (dx - x) > xc)
x += xc;
if (abs (dy - y) > yc)
y += yc;
xc = accerate(xc, rx);
yc = accerate(yc, ry);
XFlush (dpy);
msleep (10);
}
draw_square (widget, xp, yp, xp+width, yp+height);
XFlush (dpy);
}
static
draw_square (widget, x1, y1, x2, y2)
Widget widget;
{
static GC gc;
static Widget oldw;
static Pixel oldp;
XGCValues gcv;
if (gc && (oldw != widget || oldp != xor_value))
{
XtReleaseGC (oldw, gc);
gc = 0;
}
if (!gc)
{
gcv.function = GXxor;
gcv.foreground = xor_value;
gcv.subwindow_mode = IncludeInferiors;
gc = XtGetGC (widget, GCForeground | GCFunction | GCSubwindowMode, &gcv);
oldw = widget;
}
XFillRectangle (XtDisplay (widget), XtWindow(widget),
gc, x1, y1, x2-x1, y2-y1);
}
static
compute_position (w, row, col, animate, xp, yp)
Widget w;
int row, col;
Widget animate;
int *xp, *yp;
{
XRectangle r;
Position x, y;
Arg args[2];
HandRectangleForPos (w, row, col, &r);
XtSetArg (args[0], XtNx, &x);
XtSetArg (args[1], XtNy, &y);
XtGetValues (w, args, 2);
*xp = r.x + x;
*yp = r.y + y;
}
kgames-1.0/Xkw/Cards.c 100644 20717 2432 122320 6121566726 11330 0 ustar /*
* $NCD$
*
* Copyright 1992 Network Computing Devices
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, 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 NCD. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. NCD. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
* 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: Keith Packard, Network Computing Devices
*/
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/Xmu/Converters.h>
#include <stdio.h>
#include <ctype.h>
#include "CardsP.h"
#define offset(field) XtOffsetOf(CardsRec, cards.field)
#define COLOR_UNSET 10
static XtResource resources[] = {
{XtNroundCards, XtCRoundCards, XtRBoolean, sizeof (Boolean),
offset(round_cards), XtRImmediate, (XtPointer) True},
{XtNoverlap, XtCOverlap, XtRCardsOverlap, sizeof (CardsOverlap),
offset(overlap), XtRImmediate, (XtPointer) CardsOverlapNeither},
{XtNsmallCards, XtCSmallCards, XtRBoolean, sizeof (Boolean),
offset(small_cards), XtRImmediate, (XtPointer) False},
{XtNuseTile, XtCUseTile, XtRBoolean, sizeof (Boolean),
offset(use_tile), XtRImmediate, (XtPointer) False},
{XtNback, XtCBack, XtRBitmap, sizeof (Pixmap),
offset(back), XtRString, (XtPointer) "playing_card" },
{XtNtrademark, XtCTrademark, XtRBitmap, sizeof (Pixmap),
offset(trademark), XtRString, (XtPointer) "spade_lg" },
{XtNobverseColor, XtNobverseColor, XtRPixel, sizeof (Pixel),
offset(obverse_color), XtRString, (XtPointer) "white"},
{XtNbackground, XtCBackground, XtRPixel, sizeof (Pixel),
offset(empty_color), XtRString, XtDefaultBackground},
{XtNblackColor, XtCBlackColor, XtRPixel, sizeof (Pixel),
offset(black_color), XtRString, (XtPointer) "black"},
{XtNredColor, XtCRedColor, XtRPixel, sizeof (Pixel),
offset(red_color), XtRString, (XtPointer) "red"},
{XtNinverseColor, XtCInverseColor, XtRPixel, sizeof (Pixel),
offset(inverse_color), XtRString, (XtPointer) "Sea Green"},
{XtNcolor, XtCColor, XtRBoolean, sizeof (Boolean),
offset(color), XtRImmediate, (XtPointer) COLOR_UNSET },
};
#undef offset
#undef hoffset
#include <X11/Xmu/Drawing.h>
#define ROUND_W 7
#define ROUND_H 7
#define INSET 1
/* substitue gray1 for Green on mono */
#define gray_width 2
#define gray_height 2
static char gray_bits[] = {0x01, 0x02};
#include "rank.bm"
#include "face.bm"
#include "suit.bm"
#include "playing_card"
#define NUM_RANKS 13
#define NUM_SUITS 4
#define CARDS_PER_DECK 52
static Pixmap rank_map[NUM_RANKS], rank_r_map[NUM_RANKS];
static Pixmap rank_map_red[NUM_RANKS], rank_r_map_red[NUM_RANKS];
static Pixmap suit_map[NUM_SUITS], suit_r_map[NUM_SUITS];
static Pixmap suit_sm_map[NUM_SUITS], suit_sm_r_map[NUM_SUITS];
static Pixmap suit_lg_map[NUM_SUITS];
static Pixmap jack_map[NUM_SUITS], queen_map[NUM_SUITS], king_map[NUM_SUITS];
static unsigned int trademark_width, trademark_height;
#include "cards.bm"
static Pixmap card_bitmaps[CARDS_PER_DECK];
static Pixmap gray_bitmap, gray_pixmap;
#define SuperClass ((HandWidgetClass)&handClassRec)
static void ClassInitialize (), Initialize (), Destroy ();
static Boolean SetValues ();
CardsClassRec cardsClassRec = {
{ /* core fields */
/* superclass */ (WidgetClass) SuperClass,
/* class_name */ "Cards",
/* widget_size */ sizeof(CardsRec),
/* class_initialize */ ClassInitialize,
/* class_part_initialize */ NULL,
/* class_inited */ FALSE,
/* initialize */ Initialize,
/* initialize_hook */ NULL,
/* realize */ XtInheritRealize,
/* actions */ NULL,
/* num_actions */ 0,
/* resources */ resources,
/* num_resources */ XtNumber(resources),
/* xrm_class */ NULLQUARK,
/* compress_motion */ TRUE,
/* compress_exposure */ TRUE,
/* compress_enterleave */ TRUE,
/* visible_interest */ FALSE,
/* destroy */ Destroy,
/* resize */ XtInheritResize,
/* expose */ XtInheritExpose,
/* set_values */ SetValues,
/* set_values_hook */ NULL,
/* set_values_almost */ NULL,
/* get_values_hook */ NULL,
/* accept_focus */ NULL,
/* version */ XtVersion,
/* callback_private */ NULL,
/* tm_table */ NULL,
/* query_geometry */ XtInheritQueryGeometry,
/* display_accelerator */ XtInheritDisplayAccelerator,
/* extension */ NULL
},
{ /* simple fields */
/* change_sensitive */ XtInheritChangeSensitive
},
{ /* hand fields */
/* ignore */ 0
},
{ /* cards fields */
/* ignore */ 0
},
};
WidgetClass cardsWidgetClass = (WidgetClass) &cardsClassRec;
static void DisplayCallback ();
static Status
GetSize (dpy, p, widthp, heightp)
Display *dpy;
Pixmap p;
unsigned int *widthp, *heightp;
{
int x, y, borderWidth, depth;
Window root;
return XGetGeometry (dpy, p, &root, &x, &y, widthp, heightp, &borderWidth, &depth);
}
#define SMALL_CARD_HEIGHT 60
#define SMALL_CARD_WIDTH 40
#define LARGE_CARD_HEIGHT 123
#define LARGE_CARD_WIDTH 79
#define FACECARD_WIDTH 47
#define FACECARD_HEIGHT 92
#define RANK_WIDTH 9
#define RANK_HEIGHT 14
#define RANK_LOC_X 4
#define RANK_LOC_Y 7
#define SMALL_LOC_X 4
#define SMALL_LOC_Y (RANK_HEIGHT + RANK_LOC_Y + 3)
#define MID_CARD_X (LARGE_CARD_WIDTH/2)
#define MID_CARD_Y (LARGE_CARD_HEIGHT/2)
#define CARD_COL1_X (3 * LARGE_CARD_WIDTH/10)
#define CARD_COL2_X (LARGE_CARD_WIDTH/2)
#define CARD_COL3_X (7 * LARGE_CARD_WIDTH/10)
/* 5 diff rows for the two main columns */
/* 1 and 5 are top and bottom, 3 is the middle */
/* 2 & 4 are for the 10 & 9 */
#define CARD_ROW1_Y (LARGE_CARD_HEIGHT/5)
#define CARD_ROW2_Y (2 * LARGE_CARD_HEIGHT/5)
#define CARD_ROW3_Y (LARGE_CARD_HEIGHT/2)
#define CARD_ROW4_Y (LARGE_CARD_HEIGHT - 2 * LARGE_CARD_HEIGHT/5)
#define CARD_ROW5_Y (LARGE_CARD_HEIGHT - LARGE_CARD_HEIGHT/5)
/* between 1 & 3, 3 & 5 */
#define CARD_SEVEN_Y (7 * LARGE_CARD_HEIGHT/20)
#define CARD_EIGHT_Y (LARGE_CARD_HEIGHT - 7 * LARGE_CARD_HEIGHT/20)
/* between rows 1 & 2, 4 & 5 */
#define CARD_TEN_Y1 (3 * LARGE_CARD_HEIGHT/10)
#define CARD_TEN_Y2 (LARGE_CARD_HEIGHT - 3 * LARGE_CARD_HEIGHT/10)
/* card positioning */
#define CARD_INSET_X 10
#define CARD_INSET_Y (LARGE_CARD_HEIGHT/8)
#define CARD_WIDTH(w) ((w)->cards.small_cards ? SMALL_CARD_WIDTH : LARGE_CARD_WIDTH)
#define CARD_HEIGHT(w) ((w)->cards.small_cards ? SMALL_CARD_HEIGHT : LARGE_CARD_HEIGHT)
#define ScreenNo(w) XScreenNumberOfScreen (XtScreen (w))
static int cardsRef = 0;
static void make_card_maps ();
static void
setSizeVars (req, new)
CardsWidget req, new;
{
Arg args[10];
int i = 0;
int width = CARD_WIDTH(req);
int height = CARD_HEIGHT(req);
int col_offset, row_offset;
int display_x, display_y, display_width, display_height;
Boolean row_major;
Boolean row_major_set;
XtSetArg (args[i], XtNcardWidth, width); i++;
XtSetArg (args[i], XtNcardHeight, height); i++;
display_x = 0;
display_y = 0;
display_width = width;
display_height = height;
new->cards.offset_other = XkwHandDefaultOffset;
row_major_set = False;
if (req->cards.overlap & CardsOverlapHorizontal)
{
row_major = True;
row_major_set = True;
if (req->cards.small_cards)
{
col_offset = 16;
new->cards.offset_other = 8;
}
else
{
col_offset = RANK_LOC_X + RANK_WIDTH + RANK_WIDTH / 3;
new->cards.offset_other = ROUND_W + LARGE_CARD_HEIGHT / 30;
}
if (req->cards.round_cards && !req->cards.small_cards)
{
display_x = ROUND_W;
display_width -= display_x * 2;
}
}
else
{
if (req->cards.round_cards && !req->cards.small_cards)
{
display_y = ROUND_H;
display_height -= display_y * 2;
}
col_offset = width + width / 10;
}
if (req->cards.overlap & CardsOverlapVertical)
{
if (!row_major_set)
{
row_major = False;
row_major_set = True;
}
if (req->cards.small_cards)
{
row_offset = 20;
if (!row_major)
new->cards.offset_other = 10;
}
else
{
row_offset = SMALL_LOC_Y + spade_sm_height;
if (!row_major)
new->cards.offset_other = ROUND_H + LARGE_CARD_HEIGHT/30;
}
}
else
row_offset = height + width / 10;
XtSetArg (args[i], XtNcolOffset, col_offset); i++;
XtSetArg (args[i], XtNrowOffset, row_offset); i++;
XtSetArg (args[i], XtNinternalBorderWidth, width / 20); i++;
XtSetArg (args[i], XtNdisplayX, display_x); i++;
XtSetArg (args[i], XtNdisplayY, display_y); i++;
XtSetArg (args[i], XtNdisplayWidth, display_width); i++;
XtSetArg (args[i], XtNdisplayHeight, display_height); i++;
if (row_major_set)
{
XtSetArg (args[i], XtNrowMajor, row_major); i++;
}
XtSetValues (new, args, i);
}
static Bool
CvtStringToCardsOverlap (dpy, args, num_args, from, to, converter_data)
Display *dpy;
XrmValue *args;
Cardinal *num_args;
XrmValue *from, *to;
XtPointer *converter_data;
{
char *s = (char *) from->addr;
CardsOverlap *result = (CardsOverlap *) to->addr;
if (!strcmp (s, "neither"))
*result = CardsOverlapNeither;
else if (!strcmp (s, "vertical"))
*result = CardsOverlapVertical;
else if (!strcmp (s, "horizontal"))
*result = CardsOverlapHorizontal;
else if (!strcmp (s, "both"))
*result = CardsOverlapBoth;
else
return FALSE;
return TRUE;
}
static void
ClassInitialize()
{
XtSetTypeConverter ( XtRString, XtRCardsOverlap, CvtStringToCardsOverlap,
NULL, (Cardinal)0, XtCacheNone,
(XtDestructor)NULL );
}
#define CardOffset(w,card) ((card)->suit > CardsSpade ? (w)->cards.offset_other : XkwHandDefaultOffset)
XtPointer
CardsAddCard (gw, card, row, col)
Widget gw;
CardsCardPtr card;
int row, col;
{
CardsWidget w = (CardsWidget) gw;
return HandAddCard (gw, (XtPointer) card, row, col, CardOffset(w,card));
}
void
CardsReplaceCard (gw, data, card)
Widget gw;
XtPointer data;
CardsCardPtr card;
{
CardsWidget w = (CardsWidget) gw;
HandReplaceCard (gw, data, (XtPointer) card, CardOffset(w,card));
}
#define UsualSuspects(w) Display *dpy = XtDisplay ((Widget) w); \
Window window = XtWindow ((Widget) w)
#define CardGC(w,suit) GC cardgc = ((suit) == CardsSpade || \
(suit) == CardsClub) ? \
(w)->cards.blackgc : (w)->cards.redgc; \
Boolean *hasp = ((suit) == CardsSpade || \
(suit) == CardsClub) ? \
&(w)->cards.blackHasClip : \
&(w)->cards.redHasClip
#define GetScreen(w) int screen = ScreenNo(w)
#define SetClip(dpy,gc,clip,has) if (((clip) != NULL) != *(has)) {\
if (*(has) = ((clip) != NULL)) \
XSetClipRectangles(dpy, gc, 0, 0, \
clip, 1, YXBanded); \
else \
XSetClipMask(dpy,gc,None); \
}
CheckCopyPlane(dpy, src, dst, gc, width, height, dstx, dsty, clip)
Display *dpy;
Pixmap src;
Window dst;
GC gc;
int width, height, dstx, dsty;
XRectangle *clip;
{
int srcx = 0, srcy = 0;
if (clip)
{
if (dstx < clip->x) {
srcx = clip->x - dstx;
dstx += srcx;
width -= srcx;
}
if (clip->x + clip->width < dstx + width)
width = clip->x + clip->width - dstx;
if (dsty < clip->y) {
srcy = clip->y - dsty;
dsty += srcy;
height -= srcy;
}
if (clip->y + clip->height < dsty + height)
height = clip->y + clip->height - dsty;
}
if (width > 0 && height > 0)
XCopyPlane (dpy, src, dst, gc, srcx, srcy,
width, height, dstx, dsty, 1);
}
static void
GetGCs (w)
CardsWidget w;
{
UsualSuspects(w);
GetScreen(w);
XGCValues gcv;
XtGCMask mask, tmask;
unsigned width, height;
mask = GCForeground | GCBackground | GCGraphicsExposures;
gcv.graphics_exposures = False;
/* white GC */
gcv.foreground = w->cards.obverse_color;
gcv.background = w->cards.black_color;
w->cards.whitegc = XtGetGC (w, mask, &gcv);
w->cards.whiteHasClip = False;
/* black GC */
gcv.foreground = w->cards.black_color;
gcv.background = w->cards.obverse_color;
gcv.line_width = INSET;
if (INSET == 1)
gcv.line_width = 0;
w->cards.blackgc = XtGetGC (w, mask | GCLineWidth, &gcv);
w->cards.blackHasClip = False;
/* empty GC */
gcv.foreground = w->cards.empty_color;
gcv.background = w->cards.black_color;
w->cards.emptygc = XtGetGC (w, mask, &gcv);
/* red GC */
if (w->cards.color)
{
gcv.foreground = w->cards.red_color;
gcv.background = w->cards.obverse_color;
w->cards.redgc = XtGetGC (w, mask, &gcv);
}
else
{
if (!gray_bitmap)
gray_bitmap = XCreateBitmapFromData (dpy, RootWindow (dpy, screen),
gray_bits, gray_width, gray_height);
gcv.foreground = w->cards.black_color;
gcv.background = w->cards.obverse_color;
gcv.stipple = gray_bitmap;
gcv.fill_style = FillOpaqueStippled;
tmask = mask | GCFillStyle | GCStipple;
w->cards.redgc = XtGetGC (w, mask | GCFillStyle | GCStipple,
&gcv);
}
w->cards.redHasClip = False;
/* back GC */
if (w->cards.back)
{
gcv.stipple = w->cards.back;
GetSize (dpy, w->cards.back, &width, &height);
}
else
{
gcv.stipple = XCreateBitmapFromData (dpy, RootWindow (dpy, screen),
playing_card_bits, playing_card_width, playing_card_height);
width = playing_card_width;
height = playing_card_height;
}
w->cards.back_delta_x = (CARD_WIDTH(w) - width) / 2;
w->cards.back_delta_y = (CARD_HEIGHT(w) - height) / 2;
if (w->cards.color)
gcv.foreground = w->cards.inverse_color;
else
gcv.foreground = w->cards.black_color;
gcv.background = w->cards.obverse_color;
gcv.fill_style = FillOpaqueStippled;
tmask = mask | GCFillStyle | GCStipple;
if (w->cards.use_tile)
{
GC tgc = XtGetGC (w, tmask, &gcv);
if (w->cards.backTile)
XFreePixmap (dpy, w->cards.backTile);
w->cards.backTile = XCreatePixmap (dpy, RootWindow (dpy, screen),
width, height, w->core.depth);
XFillRectangle (dpy, w->cards.backTile, tgc, 0, 0, width, height);
XtReleaseGC (w, tgc);
gcv.tile = w->cards.backTile;
gcv.fill_style = FillTiled;
tmask = mask | GCFillStyle | GCTile;
}
w->cards.backgc = XtGetGC (w, tmask, &gcv);
w->cards.backHasClip = False;
}
static void
ReleaseGCs (w)
CardsWidget w;
{
XtReleaseGC (w, w->cards.whitegc);
XtReleaseGC (w, w->cards.blackgc);
XtReleaseGC (w, w->cards.emptygc);
XtReleaseGC (w, w->cards.redgc);
XtReleaseGC (w, w->cards.backgc);
}
static void
Initialize (greq, gnew)
Widget greq, gnew;
{
CardsWidget req = (CardsWidget) greq,
new = (CardsWidget) gnew;
XGCValues gcv;
XtGCMask mask;
unsigned width, height;
Display *dpy;
int screen;
dpy = XtDisplay (new);
screen = ScreenNo(new);
if (new->cards.color == COLOR_UNSET)
{
if (DisplayCells (dpy, screen) > 2)
new->cards.color = True;
else
new->cards.color = False;
}
new->cards.redgc = 0;
new->cards.blackgc = 0;
new->cards.whitegc = 0;
new->cards.backgc = 0;
new->cards.backTile = 0;
setSizeVars (req, new);
XtAddCallback (gnew, XtNdisplayCallback, DisplayCallback, (XtPointer) gnew);
GetGCs (new);
if (cardsRef++ == 0)
make_card_maps (new);
}
static void
Destroy (gw)
Widget gw;
{
CardsWidget w = (CardsWidget) gw;
ReleaseGCs (w);
if (--cardsRef == 0) {
/* destroy_card_maps (w); */
;
}
}
static Boolean
SetValues (gcur, greq, gnew)
Widget gcur, greq, gnew;
{
CardsWidget cur = (CardsWidget) gcur,
req = (CardsWidget) greq,
new = (CardsWidget) gnew;
if (req->cards.small_cards != cur->cards.small_cards ||
req->cards.overlap != cur->cards.overlap)
{
setSizeVars (req, new);
return TRUE;
}
if (new->cards.blackgc)
{
ReleaseGCs (cur);
GetGCs (new);
}
return TRUE;
}
/*
* make a 'red' pixmap by copying the bits and then stippling
* white over it
*/
static Pixmap
make_red_map(w, bits, width, height)
CardsWidget w;
char *bits;
int width, height;
{
UsualSuspects(w);
GetScreen(w);
Pixmap tmpmap, newmap;
static GC depth1gc;
XGCValues gcv;
tmpmap = XCreateBitmapFromData(dpy, RootWindow(dpy, screen),
bits, width, height);
newmap = XCreatePixmap(dpy, RootWindow(dpy, screen), width, height, 1);
if (!depth1gc)
{
gcv.stipple = gray_bitmap;
gcv.foreground = 1;
gcv.background = 0;
gcv.fill_style = FillStippled;
depth1gc = XCreateGC (dpy, newmap,
GCBackground|GCStipple|GCFillStyle, &gcv);
}
XSetForeground (dpy, depth1gc, 1);
XCopyPlane (dpy, tmpmap, newmap, depth1gc,
0, 0, width, height, 0, 0, 1);
XSetForeground (dpy, depth1gc, 0);
XFillRectangle(dpy, newmap, depth1gc, 0, 0, width, height);
XFreePixmap(dpy, tmpmap);
return (newmap);
}
static void flip_bits (), rot_180 ();
static void
make_card_maps(w)
CardsWidget w;
{
UsualSuspects(w);
GetScreen(w);
unsigned char *new_bits;
CardsRank rank;
CardsSuit suit;
int r;
int i;
for (rank = CardsAce; rank <= CardsKing; rank++)
{
r = CardsRankToInt (rank);
rank_map[r] = XCreateBitmapFromData(dpy,
RootWindow(dpy, screen),
rank_bits[r], rank_width, rank_height);
if (w->cards.color)
rank_map_red[r] = XCreateBitmapFromData(dpy,
RootWindow(dpy, screen),
rank_bits[r], rank_width, rank_height);
else
rank_map_red[r] = make_red_map(w, rank_bits[r],
rank_width, rank_height);
new_bits = (unsigned char *) calloc(sizeof(rank_bits[r]), 1);
rot_180((unsigned char *)rank_bits[r], new_bits,
rank_width, rank_height);
rank_r_map[r] = XCreateBitmapFromData(dpy,
RootWindow(dpy, screen),
new_bits, rank_width, rank_height);
if (w->cards.color)
rank_r_map_red[r] = XCreateBitmapFromData(dpy,
RootWindow(dpy, screen),
new_bits, rank_width, rank_height);
else
rank_r_map_red[r] = make_red_map(w, (char *)new_bits,
rank_width, rank_height);
free((char *)new_bits);
}
i = CardsSuitToInt (CardsSpade);
/* make all the card bitmaps */
suit_map[i] = XCreateBitmapFromData(dpy,
RootWindow(dpy, screen),
spade_bits, spade_width, spade_height);
new_bits = (unsigned char *) calloc(sizeof(spade_bits), 1);
flip_bits((unsigned char *)spade_bits, new_bits, spade_width,
spade_height);
suit_r_map[i] = XCreateBitmapFromData(dpy, RootWindow(dpy, screen),
new_bits, spade_width, spade_height);
free((char *)new_bits);
suit_sm_map[i] = XCreateBitmapFromData(dpy, RootWindow(dpy, screen),
spade_sm_bits, spade_sm_width, spade_sm_height);
new_bits = (unsigned char *) calloc(sizeof(spade_sm_bits), 1);
flip_bits((unsigned char *)spade_sm_bits, new_bits, spade_sm_width,
spade_sm_height);
suit_sm_r_map[i] = XCreateBitmapFromData(dpy, RootWindow(dpy, screen),
new_bits, spade_sm_width, spade_sm_height);
free((char *)new_bits);
if (w->cards.trademark)
{
suit_lg_map[i] = w->cards.trademark;
GetSize (dpy, w->cards.trademark, &trademark_width, &trademark_height);
}
else
{
suit_lg_map[i] = XCreateBitmapFromData(dpy, RootWindow(dpy, screen),
spade_lg_bits, spade_lg_width, spade_lg_height);
trademark_width = spade_lg_width;
trademark_height = spade_lg_height;
}
jack_map[i] = XCreateBitmapFromData(dpy, RootWindow(dpy, screen),
jack_s_bits, jack_s_width, jack_s_height);
queen_map[i] = XCreateBitmapFromData(dpy, RootWindow(dpy, screen),
queen_s_bits, queen_s_width, queen_s_height);
king_map[i] = XCreateBitmapFromData(dpy, RootWindow(dpy, screen),
king_s_bits, king_s_width, king_s_height);
i = CardsSuitToInt(CardsHeart);
/* make all the card bitmaps */
new_bits = (unsigned char *) calloc(sizeof(heart_bits), 1);
flip_bits((unsigned char *)heart_bits, new_bits, heart_width,
heart_height);
if (w->cards.color) {
suit_map[i] = XCreateBitmapFromData(dpy,
RootWindow(dpy, screen),
heart_bits, heart_width, heart_height);
suit_r_map[i] = XCreateBitmapFromData(dpy,
RootWindow(dpy, screen),
new_bits, heart_width, heart_height);
} else {
suit_map[i] = make_red_map(w, heart_bits, heart_width,
heart_height);
suit_r_map[i] = make_red_map(w, (char *)new_bits, heart_width,
heart_height);
}
free((char *)new_bits);
new_bits = (unsigned char *) calloc(sizeof(heart_sm_bits), 1);
flip_bits((unsigned char *)heart_sm_bits, new_bits, heart_sm_width,
heart_sm_height);
suit_sm_r_map[i] = XCreateBitmapFromData(dpy, RootWindow(dpy, screen),
new_bits, heart_sm_width, heart_sm_height);
if (w->cards.color) {
suit_sm_map[i] = XCreateBitmapFromData(dpy,
RootWindow(dpy, screen),
heart_sm_bits, heart_sm_width, heart_sm_height);
suit_sm_r_map[i] = XCreateBitmapFromData(dpy,
RootWindow(dpy, screen),
new_bits, heart_sm_width, heart_sm_height);
} else {
suit_sm_map[i] = make_red_map(w, heart_sm_bits, heart_sm_width,
heart_height);
suit_sm_r_map[i] = make_red_map(w, (char *)new_bits,
heart_sm_width, heart_sm_height);
}
free((char *)new_bits);
suit_lg_map[i] = suit_map[i];
if (w->cards.color)
{
jack_map[i] = XCreateBitmapFromData(dpy,
RootWindow(dpy, screen),
jack_h_bits, jack_h_width, jack_h_height);
queen_map[i] = XCreateBitmapFromData(dpy,
RootWindow(dpy, screen),
queen_h_bits, queen_h_width, queen_h_height);
king_map[i] = XCreateBitmapFromData(dpy,
RootWindow(dpy, screen),
king_h_bits, king_h_width, king_h_height);
} else {
jack_map[i] = make_red_map(w, jack_h_bits, jack_h_width,
jack_h_height);
queen_map[i] = make_red_map(w, queen_h_bits, queen_h_width,
queen_h_height);
king_map[i] = make_red_map(w, king_h_bits, king_h_width,
king_h_height);
}
i = CardsSuitToInt(CardsDiamond);
/* make all the card bitmaps */
new_bits = (unsigned char *) calloc(sizeof(diamond_bits), 1);
flip_bits((unsigned char *)diamond_bits, new_bits, diamond_width,
diamond_height);
if (w->cards.color) {
suit_map[i] = XCreateBitmapFromData(dpy,
RootWindow(dpy, screen),
diamond_bits, diamond_width, diamond_height);
suit_r_map[i] = XCreateBitmapFromData(dpy,
RootWindow(dpy, screen),
new_bits, diamond_width, diamond_height);
} else {
suit_map[i] = make_red_map(w, diamond_bits, diamond_width,
diamond_height);
suit_r_map[i] = make_red_map(w, (char *)new_bits, diamond_width,
diamond_height);
}
free((char *)new_bits);
new_bits = (unsigned char *) calloc(sizeof(diamond_sm_bits), 1);
flip_bits((unsigned char *)diamond_sm_bits, new_bits,
diamond_sm_width, diamond_sm_height);
suit_sm_r_map[i] = XCreateBitmapFromData(dpy, RootWindow(dpy, screen),
new_bits, diamond_sm_width, diamond_sm_height);
if (w->cards.color) {
suit_sm_map[i] = XCreateBitmapFromData(dpy,
RootWindow(dpy, screen),
diamond_sm_bits, diamond_sm_width, diamond_sm_height);
suit_sm_r_map[i] = XCreateBitmapFromData(dpy,
RootWindow(dpy, screen),
new_bits, diamond_sm_width, diamond_sm_height);
} else {
suit_sm_map[i] = make_red_map(w, diamond_sm_bits, diamond_sm_width,
diamond_height);
suit_sm_r_map[i] = make_red_map(w, (char *)new_bits,
diamond_sm_width, diamond_sm_height);
}
free((char *)new_bits);
suit_lg_map[i] = suit_map[i];
if (w->cards.color) {
jack_map[i] = XCreateBitmapFromData(dpy,
RootWindow(dpy, screen),
jack_d_bits, jack_d_width, jack_d_height);
queen_map[i] = XCreateBitmapFromData(dpy,
RootWindow(dpy, screen),
queen_d_bits, queen_d_width, queen_d_height);
king_map[i] = XCreateBitmapFromData(dpy,
RootWindow(dpy, screen),
king_d_bits, king_d_width, king_d_height);
} else {
jack_map[i] = make_red_map(w, jack_d_bits, jack_d_width,
jack_d_height);
queen_map[i] = make_red_map(w, queen_d_bits, queen_d_width,
queen_d_height);
king_map[i] = make_red_map(w, king_d_bits, king_d_width,
king_d_height);
}
i = CardsSuitToInt(CardsClub);
/* make all the card bitmaps */
suit_map[i] = XCreateBitmapFromData(dpy,
RootWindow(dpy, screen),
club_bits, club_width, club_height);
new_bits = (unsigned char *) calloc(sizeof(club_bits), 1);
flip_bits((unsigned char *)club_bits, new_bits, club_width,
club_height);
suit_r_map[i] = XCreateBitmapFromData(dpy, RootWindow(dpy, screen),
new_bits, club_width, club_height);
free((char *)new_bits);
suit_sm_map[i] = XCreateBitmapFromData(dpy, RootWindow(dpy, screen),
club_sm_bits, club_sm_width, club_sm_height);
new_bits = (unsigned char *) calloc(sizeof(club_sm_bits), 1);
flip_bits((unsigned char *)club_sm_bits, new_bits, club_sm_width,
club_sm_height);
suit_sm_r_map[i] = XCreateBitmapFromData(dpy, RootWindow(dpy, screen),
new_bits, club_sm_width, club_sm_height);
free((char *)new_bits);
suit_lg_map[i] = suit_map[i];
jack_map[i] = XCreateBitmapFromData(dpy, RootWindow(dpy, screen),
jack_c_bits, jack_c_width, jack_c_height);
queen_map[i] = XCreateBitmapFromData(dpy, RootWindow(dpy, screen),
queen_c_bits, queen_c_width, queen_c_height);
king_map[i] = XCreateBitmapFromData(dpy, RootWindow(dpy, screen),
king_c_bits, king_c_width, king_c_height);
for (i = 0; i < CARDS_PER_DECK; i++)
{
card_bitmaps[i] = XCreateBitmapFromData(dpy,
RootWindow(dpy, screen),
card_bits[i],
SMALL_CARD_WIDTH, SMALL_CARD_HEIGHT);
}
}
/*
* paints individual card
*/
static void paint_small_card (), paint_large_card ();
static void draw_king (), draw_queen (), draw_jack ();
static void draw_pip (), draw_did (), draw_eight_pips ();
static void draw_center_pip ();
static void draw_rank ();
static void
OutlineCard (w, x, y, clip)
CardsWidget w;
int x, y;
XRectangle *clip;
{
UsualSuspects(w);
int width, height;
width = CARD_WIDTH(w);
height = CARD_HEIGHT(w);
SetClip (dpy, w->cards.blackgc, clip, &w->cards.blackHasClip);
if (w->cards.round_cards && !w->cards.small_cards)
{
XmuDrawRoundedRectangle (dpy, window, w->cards.blackgc,
x + INSET/2, y + INSET/2,
width - INSET, height - INSET,
ROUND_W, ROUND_H);
}
else
{
XDrawRectangle (dpy, window, w->cards.blackgc,
x + INSET/2, y + INSET/2,
width - INSET, height - INSET);
}
}
static void
FillCard (w, x, y, gc, hasp, clip)
CardsWidget w;
int x, y;
GC gc;
Boolean *hasp;
XRectangle *clip;
{
UsualSuspects(w);
int width, height;
width = CARD_WIDTH(w);
height = CARD_HEIGHT(w);
SetClip (dpy, gc, clip, hasp);
if (w->cards.round_cards && !w->cards.small_cards)
{
XmuFillRoundedRectangle(dpy, window, gc,
x + INSET, y + INSET,
width - 2*INSET, height - 2 * INSET,
ROUND_W, ROUND_H);
}
else
{
XFillRectangle(dpy, window, gc,
x + INSET, y + INSET,
width - 2*INSET, height - 2*INSET);
}
OutlineCard (w, x, y, clip);
}
static void
DisplayCallback (gw, closure, data)
Widget gw;
XtPointer closure;
XtPointer data;
{
CardsWidget w = (CardsWidget) gw;
Display *dpy = XtDisplay (w);
Window window = XtWindow (w);
HandDisplayPtr display = (HandDisplayPtr) data;
CardsCardPtr card = (CardsCardPtr) display->private;
int x, y, width, height;
XRectangle *clip;
x = display->x;
y = display->y;
width = CARD_WIDTH(w);
height = CARD_HEIGHT(w);
clip = NULL;
if (display->clipped)
clip = &display->clip;
switch (card->suit) {
case CardsEmpty:
FillCard (w, x, y, w->cards.emptygc, &w->cards.emptyHasClip, clip);
break;
case CardsBack:
/* change the origin so cards will have the same back anywhere
* on the table
*/
XSetTSOrigin(dpy, w->cards.backgc,
x + w->cards.back_delta_x, y + w->cards.back_delta_y);
FillCard (w, x, y, w->cards.backgc, &w->cards.backHasClip, clip);
break;
case CardsNone:
break;
default:
if (w->cards.small_cards)
paint_small_card (w, x, y, card->rank, card->suit, clip);
else
paint_large_card (w, x, y, card->rank, card->suit, clip);
break;
}
SetClip (dpy, w->cards.redgc, (XRectangle *) 0, &w->cards.redHasClip);
SetClip (dpy, w->cards.blackgc, (XRectangle *) 0, &w->cards.blackHasClip);
SetClip (dpy, w->cards.whitegc, (XRectangle *) 0, &w->cards.whiteHasClip);
SetClip (dpy, w->cards.emptygc, (XRectangle *) 0, &w->cards.emptyHasClip);
SetClip (dpy, w->cards.backgc, (XRectangle *) 0, &w->cards.backHasClip);
}
static void
paint_large_card(w, x, y, rank, suit, clip)
CardsWidget w;
int x,y;
CardsRank rank;
CardsSuit suit;
XRectangle *clip;
{
UsualSuspects(w);
FillCard (w, x, y, w->cards.whitegc, &w->cards.whiteHasClip, clip);
switch (rank)
{
case CardsKing:
draw_king(w, suit, x, y, clip);
break;
case CardsQueen:
draw_queen(w, suit, x, y, clip);
break;
case CardsJack:
draw_jack(w, suit, x, y, clip);
break;
case Cards10:
draw_pip(w, suit, MID_CARD_X + x, CARD_TEN_Y1 + y, clip);
draw_did(w, suit, MID_CARD_X + x, CARD_TEN_Y2 + y, clip);
draw_eight_pips(w, suit, x, y, clip);
break;
case Cards9:
draw_pip(w, suit, x + MID_CARD_X, y + MID_CARD_Y, clip);
draw_eight_pips(w, suit, x, y, clip);
break;
case Cards8:
draw_did(w, suit, x + MID_CARD_X, y + CARD_EIGHT_Y, clip);
/* fall thru */
case Cards7:
draw_pip(w, suit, MID_CARD_X + x, CARD_SEVEN_Y + y, clip);
/* fall thru */
case Cards6:
draw_pip(w, suit, x + CARD_COL1_X, y + CARD_ROW1_Y, clip);
draw_pip(w, suit, x + CARD_COL3_X, y + CARD_ROW1_Y, clip);
draw_pip(w, suit, x + CARD_COL1_X, y + CARD_ROW3_Y, clip);
draw_did(w, suit, x + CARD_COL1_X, y + CARD_ROW5_Y, clip);
draw_pip(w, suit, x + CARD_COL3_X, y + CARD_ROW3_Y, clip);
draw_did(w, suit, x + CARD_COL3_X, y + CARD_ROW5_Y, clip);
break;
case Cards5:
draw_pip(w, suit, x + MID_CARD_X, y + MID_CARD_Y, clip);
/* fall thru */
case Cards4:
draw_pip(w, suit, x + CARD_COL1_X, y + CARD_ROW1_Y, clip);
draw_did(w, suit, x + CARD_COL1_X, y + CARD_ROW5_Y, clip);
draw_pip(w, suit, x + CARD_COL3_X, y + CARD_ROW1_Y, clip);
draw_did(w, suit, x + CARD_COL3_X, y + CARD_ROW5_Y, clip);
break;
case Cards3:
draw_pip(w, suit, x + MID_CARD_X, y + MID_CARD_Y, clip);
/* fall thru */
case Cards2:
draw_pip(w, suit, x + MID_CARD_X, y + CARD_ROW1_Y, clip);
draw_did(w, suit, x + MID_CARD_X, y + CARD_ROW5_Y, clip);
break;
case CardsAce:
draw_center_pip(w, suit, x + MID_CARD_X, y + MID_CARD_Y, clip);
break;
}
draw_rank(w, x, y, rank, suit, clip);
}
/*
* NOTE -- for all the pip drawers except the one that actually plots the
* bits, the location is the card's location. the drawer's take the
* pip's center as location.
*/
/*
* draws right-side-up pip
*
* location is for center of pip
*/
static void
draw_pip(w, suit, x, y, clip)
CardsWidget w;
CardsSuit suit;
int x, y;
XRectangle *clip;
{
UsualSuspects (w);
CardGC (w, suit);
int width, height;
int s = CardsSuitToInt(suit);
switch(suit)
{
case CardsSpade:
width = spade_width;
height = spade_height;
break;
case CardsDiamond:
x++;
width = diamond_width;
height = diamond_height;
break;
case CardsHeart:
y++;
width = heart_width;
height = heart_height;
break;
case CardsClub:
y++;
width = club_width;
height = club_height;
break;
default:
return;
}
CheckCopyPlane(dpy, suit_map[s], window, cardgc,
width, height,
x - width/2, y - height/2, clip);
}
/*
* draws upside-down pip
*
* location is for center of pip
*/
static void
draw_did(w, suit, x, y, clip)
CardsWidget w;
CardsSuit suit;
int x,y;
XRectangle *clip;
{
UsualSuspects (w);
CardGC (w,suit);
int width, height;
int s = CardsSuitToInt(suit);
switch(suit)
{
case CardsSpade:
width = spade_width;
height = spade_height;
break;
case CardsDiamond:
x++;
width = diamond_width;
height = diamond_height;
break;
case CardsHeart:
y++;
width = heart_width;
height = heart_height;
break;
case CardsClub:
y++;
width = club_width;
height = club_height;
break;
}
CheckCopyPlane(dpy, suit_r_map[s], window, cardgc,
width, height, x - width/2, y - height/2, clip);
}
/*
* draws big center pip
*/
static void
draw_center_pip(w, suit, x, y, clip)
CardsWidget w;
CardsSuit suit;
int x,y;
XRectangle *clip;
{
UsualSuspects(w);
int width, height;
CardGC(w,suit);
int s = CardsSuitToInt(suit);
switch(suit)
{
case CardsSpade:
width = trademark_width;
height = trademark_height;
break;
case CardsDiamond:
width = diamond_width;
height = diamond_height;
break;
case CardsHeart:
width = heart_width;
height = heart_height;
break;
case CardsClub:
width = club_width;
height = club_height;
break;
}
CheckCopyPlane(dpy, suit_lg_map[s], window, cardgc,
width, height, x - width/2, y - height/2, clip);
}
static void
draw_eight_pips(w, suit, x, y, clip)
CardsWidget w;
CardsSuit suit;
int x,y;
XRectangle *clip;
{
draw_pip(w, suit, x + CARD_COL1_X, y + CARD_ROW1_Y, clip);
draw_pip(w, suit, x + CARD_COL3_X, y + CARD_ROW1_Y, clip);
draw_pip(w, suit, x + CARD_COL1_X, y + CARD_ROW2_Y, clip);
draw_did(w, suit, x + CARD_COL1_X, y + CARD_ROW4_Y, clip);
draw_did(w, suit, x + CARD_COL1_X, y + CARD_ROW5_Y, clip);
draw_pip(w, suit, x + CARD_COL3_X, y + CARD_ROW2_Y, clip);
draw_did(w, suit, x + CARD_COL3_X, y + CARD_ROW4_Y, clip);
draw_did(w, suit, x + CARD_COL3_X, y + CARD_ROW5_Y, clip);
}
static void
draw_jack(w, suit, x, y, clip)
CardsWidget w;
CardsSuit suit;
int x,y;
XRectangle *clip;
{
UsualSuspects(w);
CardGC(w, suit);
int s = CardsSuitToInt(suit);
CheckCopyPlane(dpy, jack_map[s], window, cardgc,
FACECARD_WIDTH, FACECARD_HEIGHT,
x + (LARGE_CARD_WIDTH - FACECARD_WIDTH)/2,
y + (LARGE_CARD_HEIGHT - FACECARD_HEIGHT)/2, clip);
SetClip (dpy, cardgc, clip, hasp);
XDrawRectangle(dpy, window, cardgc,
x + (LARGE_CARD_WIDTH - FACECARD_WIDTH)/2,
y + (LARGE_CARD_HEIGHT - FACECARD_HEIGHT)/2,
FACECARD_WIDTH, FACECARD_HEIGHT);
}
static void
draw_queen(w, suit, x, y, clip)
CardsWidget w;
CardsSuit suit;
int x,y;
XRectangle *clip;
{
UsualSuspects(w);
CardGC(w, suit);
int s = CardsSuitToInt(suit);
CheckCopyPlane(dpy, queen_map[s], window, cardgc,
FACECARD_WIDTH, FACECARD_HEIGHT,
x + (LARGE_CARD_WIDTH - FACECARD_WIDTH)/2,
y + (LARGE_CARD_HEIGHT - FACECARD_HEIGHT)/2, clip);
SetClip (dpy, cardgc, clip, hasp);
XDrawRectangle(dpy, window, cardgc,
x + (LARGE_CARD_WIDTH - FACECARD_WIDTH)/2,
y + (LARGE_CARD_HEIGHT - FACECARD_HEIGHT)/2,
FACECARD_WIDTH, FACECARD_HEIGHT);
}
static void
draw_king(w, suit, x, y, clip)
CardsWidget w;
CardsSuit suit;
int x,y;
XRectangle *clip;
{
UsualSuspects(w);
CardGC(w, suit);
int s = CardsSuitToInt(suit);
CheckCopyPlane(dpy, king_map[s], window, cardgc,
FACECARD_WIDTH, FACECARD_HEIGHT,
x + (LARGE_CARD_WIDTH - FACECARD_WIDTH)/2,
y + (LARGE_CARD_HEIGHT - FACECARD_HEIGHT)/2, clip);
SetClip (dpy, cardgc, clip, hasp);
XDrawRectangle(dpy, window, cardgc,
x + (LARGE_CARD_WIDTH - FACECARD_WIDTH)/2,
y + (LARGE_CARD_HEIGHT - FACECARD_HEIGHT)/2,
FACECARD_WIDTH, FACECARD_HEIGHT);
}
static void
draw_rank(w, x, y, rank, suit, clip)
CardsWidget w;
int x, y;
CardsRank rank;
CardsSuit suit;
XRectangle *clip;
{
UsualSuspects(w);
int width, height;
int r, s;
CardGC(w, suit);
Pixmap top, bottom;
r = CardsRankToInt(rank);
s = CardsSuitToInt(suit);
if (suit == CardsHeart || suit == CardsDiamond)
{
top = rank_map_red[r];
bottom = rank_r_map_red[r];
}
else
{
top = rank_map[r];
bottom = rank_r_map[r];
}
CheckCopyPlane(dpy, top, window, cardgc,
RANK_WIDTH, RANK_HEIGHT,
x + RANK_LOC_X, y + RANK_LOC_Y, clip);
CheckCopyPlane(dpy, bottom, window, cardgc,
RANK_WIDTH, RANK_HEIGHT,
x + (LARGE_CARD_WIDTH - RANK_WIDTH - RANK_LOC_X),
y + (LARGE_CARD_HEIGHT - RANK_HEIGHT - RANK_LOC_Y), clip);
switch (suit)
{
case CardsSpade:
width = spade_sm_width;
height = spade_sm_height;
break;
case CardsHeart:
width = heart_sm_width;
height = heart_sm_height;
break;
case CardsDiamond:
x++; /* offset the smaller width */
width = diamond_sm_width;
height = diamond_sm_height;
break;
case CardsClub:
width = club_sm_width;
height = club_sm_height;
break;
}
CheckCopyPlane(dpy, suit_sm_map[s], window, cardgc,
width, height,
x + SMALL_LOC_X, y + SMALL_LOC_Y, clip);
CheckCopyPlane(dpy, suit_sm_r_map[s], window, cardgc,
width, height,
x + (LARGE_CARD_WIDTH - width - SMALL_LOC_X),
y + (LARGE_CARD_HEIGHT - height - SMALL_LOC_Y), clip);
}
static void
paint_small_card(w, x, y, rank, suit, clip)
CardsWidget w;
int x, y;
CardsRank rank;
CardsSuit suit;
XRectangle *clip;
{
UsualSuspects(w);
int card_number;
GC cardgc;
Boolean *hasp;
if (suit == CardsSpade || suit == CardsClub)
{
cardgc = w->cards.blackgc;
hasp = &w->cards.blackHasClip;
}
else if (w->cards.color) {
cardgc = w->cards.redgc;
hasp = &w->cards.redHasClip;
}
else
{
cardgc = w->cards.whitegc;
hasp = &w->cards.whiteHasClip;
}
/* this is messy cause these are just straight xsol cards */
switch (suit)
{
case CardsSpade:
card_number = 3 * NUM_RANKS;
break;
case CardsHeart:
card_number = 0;
break;
case CardsClub:
card_number = 2 * NUM_RANKS;
break;
case CardsDiamond:
card_number = NUM_RANKS;
break;
}
card_number += CardsRankToInt (rank);
CheckCopyPlane(dpy, card_bitmaps[card_number], window, cardgc,
SMALL_CARD_WIDTH, SMALL_CARD_HEIGHT, x, y, clip);
}
static unsigned char _reverse_byte[0x100] = {
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
};
#define S(x,y) src[(H-1-(y))*W+(x)]
#define D(x,y) dst[(H-1-(y))*W+(x)]
static void
flip_bits(src, dst, W, H)
unsigned char *src, *dst;
int W, H;
{
int x, y;
W = (W + 7)/8;
for (y = 0; y < H; y++) {
for (x = 0; x < W; x++) {
D (x, y) = S (x, H - 1 - y);
}
}
}
static void
rot_180(src, dst, W, H)
unsigned char *src, *dst;
int W, H;
{
int x, y;
int width = W;
unsigned char *new;
int bit;
W = (W + 7)/8;
for (y = 0; y < H; y++) {
for (x = 0; x < W; x++) {
D (x, y) = _reverse_byte[S (W - 1 - x, H - 1 - y)];
}
}
/* shift it over */
new = (unsigned char *)calloc((unsigned)W*H, (unsigned)1);
for (y = 0; y < H; y++) {
for (x = 0; x < W*8; x++) {
bit = (*(dst + (x + (W*8 - width))/8 + y * W)
& (1 << ((x + (W*8 - width)) % 8))) ? 1 : 0;
*(new + x/8 + y*W) = (bit << (x%8)) |
(*(new + x/8 + y*W) & ~(1 << (x%8)));
}
}
bcopy((char *)new, (char *)dst, W*H);
free((char *)new);
}
kgames-1.0/Xkw/Cards.h 100644 20717 2432 6743 6121566726 11307 0 ustar /*
* $NCD$
*
* Copyright 1992 Network Computing Devices
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, 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 NCD. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. NCD. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
* 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: Keith Packard, Network Computing Devices
*/
#ifndef _XtCards_h
#define _XtCards_h
#include "Hand.h"
typedef enum _CardsRank {
CardsAce = 1,
Cards2 = 2,
Cards3 = 3,
Cards4 = 4,
Cards5 = 5,
Cards6 = 6,
Cards7 = 7,
Cards8 = 8,
Cards9 = 9,
Cards10 = 10,
CardsJack = 11,
CardsQueen = 12,
CardsKing = 13
} CardsRank;
typedef enum _CardsOverlap {
CardsOverlapNeither = 0,
CardsOverlapVertical = 1,
CardsOverlapHorizontal = 2,
CardsOverlapBoth = 3
} CardsOverlap;
#define CardsRankToInt(c) ((int) (c) - 1)
#define IntToCardsRank(i) ((CardsRank) ((i) + 1))
typedef enum _CardsSuit {
CardsClub, CardsDiamond, CardsHeart, CardsSpade,
CardsBack, CardsEmpty, CardsNone
} CardsSuit;
#define CardsSuitToInt(s) ((int) (s))
#define IntToCardsSuit(i) ((int) (i))
typedef struct {
CardsRank rank;
CardsSuit suit;
} CardsCardRec, *CardsCardPtr;
/* define exposed functions */
extern XtPointer CardsAddCard(/* Widget, CardsCardPtr, int row, int col */);
extern void CardsReplaceCard(/* Widget, XtPointer, CardsCardPtr */);
/* Add aliases to stuff which is simply inherited from the Hand widget */
#define CardsRemoveCard HandRemoveCard
#define CardsRectangleForCard HandRectangleForCard
#define CardsRectangleForPos HandRectangleForPos
#define CardsRemoveAllCards HandRemoveAllCards
#define CardsXYToPos HandXYToPos
#define CardsUpdateDisplay HandUpdateDisplay
#define CardsInputRec HandInputRec
#define CardsInputPtr HandInputPtr
typedef struct _CardsRec *CardsWidget;
typedef struct _CardsClassRec *CardsWidgetClass;
extern WidgetClass cardsWidgetClass;
#define XtNroundCards "roundCards"
#define XtCRoundCards "RoundCards"
#define XtNsmallCards "smallCards"
#define XtCSmallCards "SmallCards"
#define XtNback "back"
#define XtCBack "Back"
#define XtNtrademark "trademark"
#define XtCTrademark "Trademark"
#define XtNobverseColor "obverseColor"
#define XtCObverseColor "ObverseColor"
#define XtNblackColor "blackColor"
#define XtCBlackColor "BlackColor"
#define XtNredColor "redColor"
#define XtCRedColor "RedColor"
#define XtNinverseColor "inverseColor"
#define XtCInverseColor "InverseColor"
#define XtNcolor "color"
#define XtNoverlap "overlap"
#define XtCOverlap "Overlap"
#define XtNuseTile "useTile"
#define XtCUseTile "UseTile"
#define XtRCardsOverlap "CardsOverlap"
#endif /* _XtCards_h */
kgames-1.0/Xkw/CardsP.h 100644 20717 2432 5422 6121566726 11420 0 ustar /*
* $NCD$
*
* Copyright 1992 Network Computing Devices
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, 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 NCD. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. NCD. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
* 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: Keith Packard, Network Computing Devices
*/
#ifndef _XtCardsP_h
#define _XtCardsP_h
#include "Cards.h"
#include "HandP.h"
/************************************
*
* Class structure
*
***********************************/
/*
* New fields for the Cards widget class record
*/
typedef struct _CardsClass {
int makes_compiler_happy; /* not used */
} CardsClassPart;
/*
* Full class record declaration
*/
typedef struct _CardsClassRec {
CoreClassPart core_class;
SimpleClassPart simple_class;
HandClassPart hand_class;
CardsClassPart cards_class;
} CardsClassRec;
extern CardsClassRec cardsClassRec;
typedef struct {
/* resources */
Boolean round_cards; /* rounded corners */
Boolean small_cards; /* small cards */
Boolean use_tile; /* use tiles instead of stipples */
CardsOverlap overlap;
Pixmap back;
Pixmap trademark;
Pixel obverse_color;
Pixel black_color;
Pixel red_color;
Pixel inverse_color;
Pixel empty_color;
Boolean color;
/* private state */
int offset_face;
int offset_other;
GC redgc;
Boolean redHasClip;
GC blackgc;
Boolean blackHasClip;
GC whitegc;
Boolean whiteHasClip;
GC backgc;
Boolean backHasClip;
GC emptygc;
Boolean emptyHasClip;
Pixmap backTile;
int back_delta_x;
int back_delta_y;
} CardsPart;
/*
* Full widget declaration
*/
typedef struct _CardsRec {
CorePart core;
SimplePart simple;
HandPart hand;
CardsPart cards;
} CardsRec;
#endif /* _XtCardsP_h */
kgames-1.0/Xkw/CardsUtil.c 100644 20717 2432 30465 6121566726 12156 0 ustar /*
* $NCD$
*
* Copyright 1992 Network Computing Devices
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, 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 NCD. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. NCD. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
* 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: Keith Packard, Network Computing Devices
*/
# include <X11/Intrinsic.h>
# include <X11/StringDefs.h>
# include <X11/Xos.h>
# include <X11/Xutil.h>
# include "Cards.h"
# include "CardsUtil.h"
#if defined(hpux)|| defined(__hpux)
#define srandom srand48
#define random lrand48
#endif
typedef struct _CardHistory *CardHistoryPtr;
typedef enum {
HistoryMove, HistoryTurn, HistoryCallback, HistoryShuffle
} CardHistoryType;
typedef struct _CardHistory {
CardHistoryPtr prev;
CardHistoryType type;
int serial;
union {
struct {
CardPtr card;
CardFace face;
} turn;
struct {
CardStackPtr source;
CardStackPtr dest;
CardPtr before;
CardPtr first;
CardPtr last;
} move;
struct {
void (*func)();
char *closure;
} callback;
struct {
CardStackPtr stack;
CardPtr *cards;
int numCards;
} shuffle;
} u;
} CardHistoryRec;
static CardHistoryPtr history;
static int historySerial;
static Boolean canAnimate = True;
static void
SetShoulds (stack)
CardStackPtr stack;
{
CardPtr card;
if (!stack->first)
return;
switch (stack->display) {
case CardDisplayTop:
card = stack->last;
card->shouldBeUp = True;
for (card = card->prev; card; card = card->prev)
card->shouldBeUp = False;
break;
case CardDisplayBottom:
card = stack->first;
card->shouldBeUp = True;
for (card = card->next; card; card = card->next)
card->shouldBeUp = False;
break;
case CardDisplayAll:
for (card = stack->first; card; card = card->next)
card->shouldBeUp = True;
break;
case CardDisplayNone:
for (card = stack->first; card; card = card->next)
card->shouldBeUp = False;
break;
}
}
static void
DisplayCards (stack, c)
CardStackPtr stack;
CardPtr c;
{
int row, col;
int pos;
CardsSuit suit;
Boolean animated = !canAnimate;
int mode;
if (stack->horizontal)
row = stack->position;
else
col = stack->position;
pos = stack->basePosition;;
while (c)
{
if (stack->horizontal)
col = pos;
else
row = pos;
if (c->face == CardFaceDown)
suit = CardsBack;
else
suit = c->card.suit;
if (c->isUp && c->shouldBeUp &&
c->widget == stack->widget &&
row == c->row && col == c->col && c->data)
{
if (suit != c->display.suit)
{
c->display.suit = suit;
CardsReplaceCard (c->widget, c->data, &c->display);
}
}
else
{
if (c->data)
{
if (c->shouldBeUp && !animated)
{
Animate (c->widget, c->row, c->col,
stack->widget, row, col);
animated = True;
}
CardsRemoveCard (c->widget, c->data);
c->data = 0;
}
if (c->shouldBeUp)
{
c->display.suit = suit;
c->display.rank = c->card.rank;
c->row = row;
c->col = col;
c->widget = stack->widget;
mode = Below;
c->data = CardsAddCard (c->widget, &c->display, row, col);
}
c->isUp = c->shouldBeUp;
}
if (c->isUp)
pos++;
c = c->next;
}
}
Boolean
CardIsInOrder (a, b)
CardPtr a, b;
{
return a->face == b->face &&
a->card.rank + 1 == b->card.rank;
}
Boolean
CardIsInSuitOrder (a, b)
CardPtr a, b;
{
return a->face == b->face &&
a->card.suit == b->card.suit &&
CardIsInOrder (a, b);
}
CardPtr
CardInSuitOrder (card)
CardPtr card;
{
while (card->next && CardIsInSuitOrder (card->next, card))
card = card->next;
return card;
}
CardPtr
CardInOrder (card)
CardPtr card;
{
while (card->next && CardIsInOrder (card->next, card))
card = card->next;
return card;
}
CardPtr
CardInReverseSuitOrder (card)
CardPtr card;
{
while (card->prev && CardIsInSuitOrder (card, card->prev))
card = card->prev;
return card;
}
CardPtr
CardInReverseOrder (card)
CardPtr card;
{
while (card->prev && CardIsInOrder (card, card->prev))
card = card->prev;
return card;
}
static Boolean
IsAlternateSuit (a, b)
CardsSuit a, b;
{
return (a == CardsSpade || a == CardsClub) ^
(b == CardsSpade || b == CardsClub);
}
Boolean
CardIsInAlternatingSuitOrder (a, b)
CardPtr a, b;
{
return CardIsInOrder (a,b) &&
IsAlternateSuit (a->card.suit, b->card.suit);
}
CardPtr
CardInAlternatingSuitOrder (card)
CardPtr card;
{
while (card->next && CardIsInAlternatingSuitOrder (card->next, card))
card = card->next;
return card;
}
CardPtr
CardInReverseAlternatingSuitOrder (card)
CardPtr card;
{
while (card->prev && CardIsInAlternatingSuitOrder (card, card->prev))
card = card->prev;
return card;
}
void
CardSetAnimate (animate)
Boolean animate;
{
canAnimate = animate;
}
void
CardDisplayStack (stack)
CardStackPtr stack;
{
stack->empty.shouldBeUp = stack->first ||
stack->empty.card.suit == CardsNone ? False : True;
SetShoulds (stack);
DisplayCards (stack, stack->first);
DisplayCards (stack, &stack->empty);
}
void
CardTurn (card, face, remember)
CardPtr card;
CardFace face;
Boolean remember;
{
if (remember)
{
CardHistoryPtr h = New(CardHistoryRec);
h->u.turn.card = card;
h->u.turn.face = card->face;
h->type = HistoryTurn;
h->prev = history;
h->serial = historySerial;
history = h;
}
card->face = face;
}
void
CardMove (from_stack, from_card, to_stack, remember)
CardStackPtr from_stack;
CardPtr from_card;
CardStackPtr to_stack;
Boolean remember;
{
CardMoveCards (from_stack, from_card, from_stack->last, to_stack, to_stack->last, remember);
}
static void
RemoveStack (stack, first, last)
CardStackPtr stack;
CardPtr first, last;
{
if (first->prev)
first->prev->next = last->next;
else
stack->first = last->next;
if (last->next)
last->next->prev = first->prev;
else
stack->last = first->prev;
first->prev = 0;
last->next = 0;
}
static void
AddStack (stack, first, last, before)
CardStackPtr stack;
CardPtr first, last, before;
{
CardPtr after;
first->prev = before;
if (before)
{
last->next = before->next;
before->next = first;
}
else
{
last->next = stack->first;
stack->first = first;
}
if (last->next)
last->next->prev = last;
else
stack->last = last;
}
void
CardMoveCards (from_stack, first_card, last_card, to_stack, to_card, remember)
CardStackPtr from_stack;
CardPtr first_card, last_card;
CardStackPtr to_stack;
CardPtr to_card;
Boolean remember;
{
if (remember)
{
CardHistoryPtr h = New(CardHistoryRec);
h->u.move.source = from_stack;
h->u.move.dest = to_stack;
h->u.move.before = first_card->prev;
h->u.move.first = first_card;
h->u.move.last = last_card;
h->type = HistoryMove;
h->prev = history;
h->serial = historySerial;
history = h;
}
RemoveStack (from_stack, first_card, last_card);
AddStack (to_stack, first_card, last_card, to_card);
}
void
CardInitStack (stack, widget, emptySuit, horizontal, position, display)
CardStackPtr stack;
Widget widget;
CardsSuit emptySuit;
Boolean horizontal;
int position;
CardDisplay display;
{
CardPtr empty;
stack->first = stack->last = 0;
stack->widget = widget;
stack->horizontal = horizontal;
stack->position = position;
stack->basePosition = 0;
stack->display = display;
empty = &stack->empty;
empty->card.suit = emptySuit;
empty->card.rank = CardsAce;
empty->display.suit = emptySuit;
empty->display.rank = CardsAce;
empty->isUp = False;
empty->face = CardFaceUp;
empty->next = 0;
empty->prev = 0;
empty->row = 0;
empty->col = 0;
empty->data = 0;
}
void
CardGenerateStandardDeck (card)
CardPtr card;
{
CardsSuit suit;
CardsRank rank;
for (suit = CardsClub; suit <= CardsSpade; suit++)
{
for (rank = CardsAce; rank <= CardsKing; rank++)
{
card->next = card + 1;
card->prev = card - 1;
card->card.suit = suit;
card->card.rank = rank;
card->row = -1;
card->data = 0;
card->face = CardFaceDown;
card->shouldBeUp = True;
card->isUp = False;
card++;
}
}
card[-1].next = 0;
card[-52].prev = 0;
}
typedef struct _CardShuffle {
int value;
CardPtr card;
} CardShuffleRec, *CardShufflePtr;
static int
ShuffleCompare (a,b)
CardShufflePtr a,b;
{
return a->value - b->value;
}
void
CardShuffle (stack, remember)
CardStackPtr stack;
Boolean remember;
{
CardPtr card, *save;
int numCards;
CardShufflePtr shuffle, shuf;
int i;
numCards = 0;
for (card = stack->first; card; card = card->next)
++numCards;
save = 0;
if (remember)
{
CardHistoryPtr h = New(CardHistoryRec);
h->u.shuffle.stack = stack;
h->u.shuffle.cards = Some (CardPtr, numCards);
h->u.shuffle.numCards = numCards;
h->type = HistoryShuffle;
h->prev = history;
h->serial = historySerial;
history = h;
save = h->u.shuffle.cards;
}
shuffle = Some (CardShuffleRec, numCards);
shuf = shuffle;
for (card = stack->first; card; card = card->next)
{
if (save)
*save++ = card;
shuf->card = card;
shuf->value = random ();
++shuf;
}
qsort ((char *) shuffle, numCards, sizeof *shuffle, ShuffleCompare);
shuf = shuffle;
stack->first = shuffle[0].card;
stack->last = shuffle[numCards-1].card;
for (i = 0; i < numCards; i++)
{
if (i < numCards - 1)
shuf[0].card->next = shuf[1].card;
else
shuf[0].card->next = 0;
if (i > 0)
shuf[0].card->prev = shuf[-1].card;
else
shuf[0].card->prev = 0;
shuf++;
}
}
static void
Unshuffle (stack, cards, numCards)
CardStackPtr stack;
CardPtr *cards;
int numCards;
{
int i;
stack->first = cards[0];
stack->last = cards[numCards-1];
for (i = 0; i < numCards; i++, cards++)
{
if (i > 0)
cards[0]->prev = cards[-1];
else
cards[0]->prev = 0;
if (i < numCards-1)
cards[0]->next = cards[1];
else
cards[0]->next = 0;
}
}
void
CardInitHistory ()
{
CardHistoryPtr h, p;
for (h = history; h; h = p)
{
p = h->prev;
Dispose (h);
}
history = 0;
historySerial = 0;
}
void
CardRecordHistoryCallback (func, closure)
void (*func) ();
char *closure;
{
CardHistoryPtr h = New(CardHistoryRec);
h->u.callback.func = func;
h->u.callback.closure = closure;
h->type = HistoryCallback;
h->prev = history;
h->serial = historySerial;
history = h;
}
Boolean
CardUndo ()
{
CardHistoryPtr h, p;
int serial;
if (!history)
return False;
serial = history->serial;
for (h = history; h && h->serial == serial; h = p)
{
p = h->prev;
switch (h->type)
{
case HistoryMove:
CardMoveCards (h->u.move.dest, h->u.move.first, h->u.move.last,
h->u.move.source, h->u.move.before, False);
break;
case HistoryTurn:
h->u.turn.card->face = h->u.turn.face;
break;
case HistoryCallback:
(*h->u.callback.func) (h->u.callback.closure);
break;
case HistoryShuffle:
Unshuffle (h->u.shuffle.stack, h->u.shuffle.cards, h->u.shuffle.numCards);
Dispose (h->u.shuffle.cards);
break;
}
Dispose (h);
}
history = h;
return True;
}
int
CardNextHistory ()
{
return historySerial++;
}
kgames-1.0/Xkw/CardsUtil.h 100644 20717 2432 6406 6121566726 12141 0 ustar /*
* $NCD$
*
* Copyright 1992 Network Computing Devices
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, 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 NCD. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. NCD. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
* 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: Keith Packard, Network Computing Devices
*/
typedef struct _Card *CardPtr;
typedef enum _CardFace { CardFaceUp, CardFaceDown } CardFace;
typedef enum _CardDisplay {
CardDisplayTop, CardDisplayBottom, CardDisplayAll,
CardDisplaySome, CardDisplayNone
} CardDisplay;
typedef struct _Card {
CardPtr next, prev;
CardsCardRec card;
CardsCardRec display;
CardFace face;
Boolean shouldBeUp;
Boolean isUp;
Widget widget;
int row, col;
XtPointer data;
} CardRec;
typedef struct _CardStack *CardStackPtr;
typedef struct _CardStack {
Widget widget;
Boolean horizontal;
CardDisplay display;
int position;
int basePosition;
CardPtr first, last;
CardRec empty;
} CardStackRec;
#define New(t) (t *) malloc(sizeof (t))
#define Dispose(p) free((char *) p)
#define Some(t,n) (t*) malloc(sizeof(t) * n)
#define More(p,t,n) ((p)? (t *) realloc((char *) p, sizeof(t)*n):Some(t,n))
extern Boolean CardIsInOrder (/* CardPtr, CardPtr */);
extern Boolean CardIsInSuitOrder (/* CardPtr, CardPtr */);
extern Boolean CardIsInAlternatingSuitOrder (/* CardPtr, CardPtr */);
extern CardPtr CardInOrder (/* CardPtr */);
extern CardPtr CardInSuitOrder (/* CardPtr */);
extern CardPtr CardInAlternatingSuitOrder (/* CardPtr */);
extern CardPtr CardInReverseOrder (/* CardPtr */);
extern CardPtr CardInReverseSuitOrder (/* CardPtr */);
extern CardPtr CardInReverseAlternatingSuitOrder (/* CardPtr */);
extern void CardDisplayStack (/* CardStackPtr */);
extern void CardTurn (/* CardPtr, CardFace, Boolean */);
extern void CardMove (/* CardStackPtr, CardPtr, CardStackPtr, Boolean */);
extern void CardMoveCards (/* CardStackPtr, CardPtr, CardPtr, CardStackPtr, CardPtr, Boolean */);
extern void CardRecordHistoryCallback (/* void (*)(), char * */);
extern Boolean CardUndo (/* void */);
extern void CardInitStack (/* CardStackPtr, Widget, CardsSuit, Boolean, Boolean, int */);
extern void CardGenerateStandardDeck (/* CardPtr */);
extern void CardShuffle (/* CardStackPtr */);
extern void CardInitHistory (/* void */);
extern int CardNextHistory (/* void */);
kgames-1.0/Xkw/Imakefile 100644 20717 2432 2720 6515033644 11675 0 ustar #define DoNormalLib YES
#include <Library.tmpl>
PROJECTROOT=/usr/X11
BINDIR =$(PROJECTROOT)/bin
LIBDIR = $(PROJECTROOT)/lib/X11
MANPATH = $(PROJECTROOT)/man
TEMP_ROOT=/usr/X11/bin
INSTALL=/bin/install
MKDIRHIER = /bin/sh $(TEMP_ROOT)/mkdirhier
/*
MYTOP=..
INCLUDES = -I$(MYTOP)
XKW=$(MYTOP)/Xkw
XKWLIB=$(XKW)/libXkw.a
*/
INCLUDES=-I..
HEADERS = Cards.h CardsP.h CardsUtil.h SuitCards.h Hand.h HandP.h \
Thermo.h ThermoP.h Layout.h LayoutP.h Pad.h PadP.h
SRCS = Cards.c Hand.c Thermo.c Layout.c laygram.c laylex.c \
CardsUtil.c SuitCards.c Animate.c Message.c Pad.c
OBJS = Cards.o Hand.o Thermo.o Layout.o laygram.o laylex.o \
CardsUtil.o SuitCards.o Animate.o Message.o Pad.o
CARDS_BITMAPS = playing_card bob spade_lg
all::
depend :: laygram.c laylex.c
LibraryObjectRule()
/*
InstallMultiple($(HEADERS),$(INCDIR)/Xkw)
InstallMultiple($(CARDS_BITMAPS),$(INCDIR)/bitmaps)
*/
NormalLibraryTarget(Xkw,$(OBJS))
/*
InstallLibrary(Xkw,$(LIBDIR)/Xkw)
*/
laygram.c : laygram.y
yacc -d laygram.y
sed 's/yy/LayYY/g' y.tab.c > laygram.c
sed 's/yy/LayYY/g' y.tab.h > laygram.h
rm y.tab.c y.tab.h
clean::
-rm laygram.c laygram.h
laylex.c: laylex.l
lex laylex.l
sed 's/yy/LayYY/g' lex.yy.c > laylex.c
rm lex.yy.c
clean::
-rm laylex.c
DependTarget()
NormalProgramTarget(layout,layout.o,libXkw.a XawClientDepLibs,libXkw.a XawClientLibs,)
NormalProgramTarget(padtest,padtest.o,libXkw.a XawClientDepLibs,libXkw.a XawClientLibs,)
kgames-1.0/Xkw/Hand.c 100644 20717 2432 66445 6121566726 11145 0 ustar /* $XConsortium: Hand.c,v 1.18 91/07/26 15:21:52 keith Exp $ */
/*
* Copyright 1991 Massachusetts Institute of Technology
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, 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 M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
* 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.
*
*/
/*
* Hand - display collection of cards
*/
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/Xmu/Converters.h>
#include <stdio.h>
#include <ctype.h>
#include "HandP.h"
#define offset(field) XtOffsetOf(HandRec, hand.field)
static XtResource resources[] = {
{XtNcardWidth, XtCCardWidth, XtRDimension, sizeof (Dimension),
offset(card_width), XtRImmediate, (XtPointer) 0 },
{XtNcardHeight, XtCCardHeight, XtRDimension, sizeof (Dimension),
offset(card_height), XtRImmediate, (XtPointer) 0 },
{XtNdisplayWidth, XtCDisplayWidth, XtRDimension, sizeof (Dimension),
offset(display_width), XtRImmediate, (XtPointer) 0 },
{XtNdisplayHeight, XtCDisplayHeight, XtRDimension, sizeof (Dimension),
offset(display_height), XtRImmediate, (XtPointer) 0 },
{XtNdisplayX, XtCDisplayX, XtRDimension, sizeof (Dimension),
offset(display_x), XtRImmediate, (XtPointer) 0 },
{XtNdisplayY, XtCDisplayY, XtRDimension, sizeof (Dimension),
offset(display_y), XtRImmediate, (XtPointer) 0 },
{XtNinternalBorderWidth, XtCInternalBorderWidth, XtRDimension, sizeof (Dimension),
offset(internal_border), XtRImmediate, (XtPointer) 0},
{XtNnumRows, XtCNumRows, XtRDimension, sizeof (Dimension),
offset(num_rows), XtRImmediate, (XtPointer) 0 },
{XtNnumCols, XtCNumCols, XtRDimension, sizeof (Dimension),
offset(num_cols), XtRImmediate, (XtPointer) 0 },
{XtNrowsHint, XtCRowsHint, XtRBoolean, sizeof (Boolean),
offset(rows_hint), XtRImmediate, (XtPointer) False},
{XtNcolsHint, XtCColsHint, XtRBoolean, sizeof (Boolean),
offset(cols_hint), XtRImmediate, (XtPointer) False},
{XtNrowOffset, XtCRowOffset, XtRDimension, sizeof (Dimension),
offset(row_offset), XtRImmediate, (XtPointer) 0 },
{XtNcolOffset, XtCColOffset, XtRDimension, sizeof (Dimension),
offset(col_offset), XtRImmediate, (XtPointer) 0 },
{XtNrowMajor, XtCRowMajor, XtRBoolean, sizeof (Boolean),
offset(row_major), XtRImmediate, (XtPointer) False },
{XtNdisplayCallback, XtCDisplayCallback, XtRCallback, sizeof (XtPointer),
offset(display_callback), XtRCallback, (XtPointer) NULL},
{XtNinputCallback, XtCInputCallback, XtRCallback, sizeof (XtPointer),
offset(input_callback), XtRCallback, (XtPointer) NULL},
{XtNrowInsert, XtCInsert, XtRBoolean, sizeof (Boolean),
offset(row_insert), XtRImmediate, (XtPointer) False},
{XtNcolInsert, XtCInsert, XtRBoolean, sizeof (Boolean),
offset(col_insert), XtRImmediate, (XtPointer) False},
{XtNimmediateUpdate, XtCImmediateUpdate, XtRBoolean, sizeof (Boolean),
offset(immediate_update), XtRImmediate, (XtPointer) True},
};
#undef offset
static void Initialize (); /* set default sizes */
static void Destroy (); /* free card records */
static void Resize (); /* set widget size */
static void Realize (); /* realize widget */
static void Redisplay (); /* draw */
void HandUpdateDisplay (); /* display */
static XtGeometryResult QueryGeometry (); /* query_geometry */
static Boolean SetValues (); /* set resource values */
static char defaultTranslations[] =
"<BtnDown>: select()";
static void ActionSelect();
static XtActionsRec actions[] = {
{ "select", ActionSelect }, /* select card */
};
#define SuperClass ((SimpleWidgetClass)&simpleClassRec)
HandClassRec handClassRec = {
{ /* core fields */
/* superclass */ (WidgetClass) SuperClass,
/* class_name */ "Hand",
/* widget_size */ sizeof(HandRec),
/* class_initialize */ NULL,
/* class_part_initialize */ NULL,
/* class_inited */ FALSE,
/* initialize */ Initialize,
/* initialize_hook */ NULL,
/* realize */ Realize,
/* actions */ actions,
/* num_actions */ XtNumber(actions),
/* resources */ resources,
/* num_resources */ XtNumber(resources),
/* xrm_class */ NULLQUARK,
/* compress_motion */ TRUE,
/* compress_exposure */ FALSE,
/* compress_enterleave */ TRUE,
/* visible_interest */ FALSE,
/* destroy */ Destroy,
/* resize */ Resize,
/* expose */ Redisplay,
/* set_values */ SetValues,
/* set_values_hook */ NULL,
/* set_values_almost */ NULL,
/* get_values_hook */ NULL,
/* accept_focus */ NULL,
/* version */ XtVersion,
/* callback_private */ NULL,
/* tm_table */ defaultTranslations,
/* query_geometry */ QueryGeometry,
/* display_accelerator */ XtInheritDisplayAccelerator,
/* extension */ NULL
},
{ /* simple fields */
/* change_sensitive */ XtInheritChangeSensitive
},
{ /* hand fields */
/* ignore */ 0
}
};
WidgetClass handWidgetClass = (WidgetClass) &handClassRec;
static int
BestOffset (want, have, desired, item_size, num_items)
int want, have, desired, item_size, num_items;
{
int val, min;
int last_showing;
if (want <= have || num_items <= 1)
return desired;
if (have < 0)
have = 0;
last_showing = item_size;
min = item_size / 4;
do {
last_showing /= 2;
val = (have - last_showing) / (num_items - 1);
} while (val < min && val < last_showing);
if (val > desired)
val = desired;
return val;
}
static int
BestColOffset (w, num_cols)
HandWidget w;
int num_cols;
{
int borders = 2 * w->hand.internal_border;
return BestOffset (handWidth (w, num_cols) - borders,
w->core.width - borders,
w->hand.col_offset, w->hand.card_width,
num_cols);
}
static int
BestRowOffset (w, num_rows)
HandWidget w;
int num_rows;
{
int borders = 2 * w->hand.internal_border;
return BestOffset (handHeight (w, num_rows) - borders,
w->core.height - borders,
w->hand.row_offset, w->hand.card_height,
num_rows);
}
static int
ColsInRow (w, row)
HandWidget w;
int row;
{
int maxCol = -1;
CardPtr c;
for (c = w->hand.bottomCard; c; c = c->prev)
if (c->row == row && c->col > maxCol)
maxCol = c->col;
return maxCol;
}
static int
RowsInCol (w, col)
HandWidget w;
int col;
{
int maxRow = -1;
CardPtr c;
for (c = w->hand.bottomCard; c; c = c->prev)
if (c->col == col && c->row > maxRow)
maxRow = c->row;
return maxRow;
}
static int
XPos (w, row, col)
HandWidget w;
int row, col;
{
int offset;
CardPtr c;
int numCol;
int numDefault;
int defaultOffset;
int lastCol;
if (w->hand.row_major)
{
numCol = ColsInRow (w, row) + 1;
if (w->hand.cols_hint)
defaultOffset = BestColOffset (w, numCol);
else
defaultOffset = w->hand.real_col_offset;
lastCol = 0;
offset = 0;
numDefault = 0;
for (c = w->hand.bottomCard; c; c = c->prev)
{
if (c->row == row && c->col >= lastCol && c->col < col)
{
numDefault += (c->col - lastCol);
if (c->offset == XkwHandDefaultOffset ||
c->offset > defaultOffset)
numDefault++;
else
offset += c->offset;
lastCol = c->col + 1;
}
}
if (col > lastCol)
numDefault += (col - lastCol);
if (numDefault)
offset += numDefault * defaultOffset;
}
else
offset = col * w->hand.real_col_offset;
return offset + w->hand.internal_border;
}
static int
ColFromX (w, x, row)
HandWidget w;
int x;
int row;
{
int offset;
int adjust;
int x1, x2;
int col;
if (w->hand.row_major)
{
x2 = w->hand.internal_border;
for (col = 1; ; col++)
{
x1 = x2;
x2 = XPos (w, row, col);
adjust = 0;
if (x2 - x1 > w->hand.card_width)
adjust = ((x2 - x1) - w->hand.card_width) / 2;
if (x < x2 - adjust)
return col - 1;
}
}
else
{
offset = w->hand.real_col_offset;
adjust = -w->hand.internal_border;
if (offset > w->hand.card_width)
adjust += (offset - w->hand.card_width) / 2;
return (x + adjust) / offset;
}
}
static int
YPos (w, row, col)
HandWidget w;
int row, col;
{
CardPtr c;
int offset;
int numRow;
int numDefault;
int defaultOffset;
int lastRow;
if (!w->hand.row_major)
{
numRow = RowsInCol (w, col) + 1;
if (w->hand.rows_hint)
defaultOffset = BestRowOffset (w, numRow);
else
defaultOffset = w->hand.real_row_offset;
lastRow = 0;
offset = 0;
numDefault = 0;
for (c = w->hand.bottomCard; c; c = c->prev)
{
if (c->col == col && c->row >= lastRow && c->row < row)
{
numDefault += (c->row - lastRow);
if (c->offset == XkwHandDefaultOffset ||
c->offset > defaultOffset)
numDefault++;
else
offset += c->offset;
lastRow = c->row + 1;
}
}
if (row > lastRow)
numDefault += (row - lastRow);
if (numDefault)
offset += numDefault * defaultOffset;
}
else
offset = row * w->hand.real_row_offset;
return offset + w->hand.internal_border;
}
static int
RowFromY (w, y, col)
HandWidget w;
int y;
int col;
{
int offset;
int adjust;
int y1, y2;
int row;
if (!w->hand.row_major)
{
y2 = w->hand.internal_border;
for (row = 1; ; row++)
{
y1 = y2;
y2 = YPos (w, row, col);
adjust = 0;
if (y2 - y1 > w->hand.card_height)
adjust = ((y2 - y1) - w->hand.card_height) / 2;
if (y < y2 - adjust)
return row - 1;
}
}
else
{
offset = w->hand.real_row_offset;
adjust = -w->hand.internal_border;
if (offset > w->hand.card_height)
adjust += (offset - w->hand.card_height) / 2;
return (y + adjust) / offset;
}
}
static int
handWidth (w, num_cols)
HandWidget w;
int num_cols;
{
return w->hand.card_width + 2 * w->hand.internal_border +
(num_cols - 1) * w->hand.col_offset;
}
static int
handHeight (w, num_rows)
HandWidget w;
int num_rows;
{
return w->hand.card_height + 2 * w->hand.internal_border +
(num_rows - 1) * w->hand.row_offset;
}
static void
getHandSize (w, widthp, heightp)
HandWidget w;
Dimension *widthp, *heightp;
{
*widthp = handWidth (w, w->hand.num_cols);
*heightp = handHeight (w, w->hand.num_rows);
}
static void Initialize (greq, gnew)
Widget greq, gnew;
{
HandWidget req = (HandWidget) greq,
new = (HandWidget) gnew;
getHandSize (req, &new->core.width, &new->core.height);
new->hand.real_row_offset = new->hand.row_offset;
new->hand.real_col_offset = new->hand.col_offset;
new->hand.topCard = NULL;
new->hand.bottomCard = NULL;
new->hand.erased = NULL;
new->hand.exposeTime = 0;
}
#define MotionMask ( \
PointerMotionMask | Button1MotionMask | \
Button2MotionMask | Button3MotionMask | Button4MotionMask | \
Button5MotionMask | ButtonMotionMask )
#define PointerGrabMask ( \
ButtonPressMask | ButtonReleaseMask | \
EnterWindowMask | LeaveWindowMask | \
PointerMotionHintMask | KeymapStateMask | \
MotionMask )
static void Realize (widget, value_mask, attributes)
Widget widget;
XtValueMask *value_mask;
XSetWindowAttributes *attributes;
{
unsigned int event_mask = 0;
#define MAX_BUT 256
unsigned char mapping[MAX_BUT];
int i, max;
(*SuperClass->core_class.realize)(widget, value_mask, attributes);
if (*value_mask & CWEventMask)
event_mask = attributes->event_mask;
event_mask &= PointerGrabMask;
if (event_mask & ButtonPressMask)
{
max = XGetPointerMapping (XtDisplay (widget), mapping, MAX_BUT);
for (i = 0; i < max; i++)
{
if (mapping[i] != 0)
XtGrabButton (widget, i, AnyModifier, True, event_mask,
GrabModeAsync, GrabModeAsync, None, None);
}
}
}
static void Destroy (gw)
Widget gw;
{
HandWidget w = (HandWidget) gw;
CardPtr c, n;
for (c = w->hand.topCard; c; c = n) {
n = c->next;
Dispose (c);
}
}
static XtGeometryResult QueryGeometry (gw, intended, prefered)
Widget gw;
XtWidgetGeometry *intended, *prefered;
{
HandWidget w = (HandWidget) gw;
Dimension width, height;
XtGeometryResult result;
getHandSize (w, &width, &height);
result = XtGeometryYes;
prefered->request_mode = 0;
if (intended->request_mode & CWWidth) {
if (intended->width != width) {
if (width == w->core.width) {
result = XtGeometryNo;
} else if (result != XtGeometryNo) {
prefered->request_mode |= CWWidth;
prefered->width = width;
result = XtGeometryAlmost;
}
}
}
if (intended->request_mode & CWHeight) {
if (intended->height != height) {
if (height == w->core.height) {
result = XtGeometryNo;
} else if (result != XtGeometryNo) {
prefered->request_mode |= CWHeight;
prefered->height = height;
result = XtGeometryAlmost;
}
}
}
return result;
}
static Bool XYInCard (w, c, x, y)
HandWidget w;
CardPtr c;
int x, y;
{
return c->x <= x && x < c->x + w->hand.card_width &&
c->y <= y && y < c->y + w->hand.card_height;
}
static CardPtr XYToCard (w, x, y)
HandWidget w;
int x, y;
{
CardPtr c;
for (c = w->hand.topCard; c; c = c->next) {
if (XYInCard (w, c, x, y))
return c;
}
return NULL;
}
static void ActionSelect (gw, event, params, num_params)
Widget gw;
XEvent *event;
String *params;
Cardinal *num_params;
{
HandWidget w = (HandWidget) gw;
CardPtr c;
HandInputRec input;
int row, col;
XtPointer private;
c = XYToCard (w, event->xbutton.x, event->xbutton.y);
if (c)
{
row = c->row;
col = c->col;
private = c->private;
}
else
{
if (w->hand.row_major)
{
row = RowFromY (w, event->xbutton.y, -1);
col = ColFromX (w, event->xbutton.x, row);
}
else
{
col = ColFromX (w, event->xbutton.x, -1);
row = RowFromY (w, event->xbutton.y, col);
}
if (row < 0)
row = 0;
else if (w->hand.row_major && w->hand.num_rows <= row)
row = w->hand.num_rows - 1;
if (col < 0)
col = 0;
else if (!w->hand.row_major && w->hand.num_cols <= col)
col = w->hand.num_cols - 1;
private = 0;
}
input.w = gw;
input.row = row;
input.col = col;
input.private = private;
input.params = params;
input.event = *event;
input.num_params = num_params;
XtCallCallbackList ((Widget) w, w->hand.input_callback, (XtPointer) &input);
}
static Bool CardInRect (w, rect, c)
HandWidget w;
XRectangle *rect;
CardPtr c;
{
XRectangle *card = &c->clip;
return rect->x < card->x + card->width &&
card->x < rect->x + rect->width &&
rect->y < card->y + card->height &&
card->y < rect->y + rect->height;
}
#define ClipRects(allClipped) { \
if (cx1 <= x1 && x2 <= cx2) \
{ \
if (cy1 <= y1 && y1 < cy2) \
y1 = cy2; \
if (cy1 < y2 && y2 <= cy2) \
y2 = cy1; \
if (y2 < y1) \
y2 = y1; \
if (y1 == y2) \
allClipped; \
} \
if (cy1 <= y1 && y2 <= cy2) \
{ \
if (cx1 <= x1 && x1 < cx2) \
x1 = cx2; \
if (cx1 < x2 && x2 <= cx2) \
x2 = cx1; \
if (x2 < x1) \
x2 = x1; \
if (x1 == x2) \
allClipped; \
} \
}
static void MarkCard (w, c)
HandWidget w;
CardPtr c;
{
XRectangle *r;
ErasedPtr e, n, *p;
int cx1, cy1, cx2, cy2;
int x1, y1, x2, y2;
Boolean allClipped;
c->redisplay = TRUE;
if (w->hand.erased)
{
cx1 = c->x + w->hand.display_x;
cy1 = c->y + w->hand.display_y;
cx2 = cx1 + w->hand.display_width;
cy2 = cy1 + w->hand.display_height;
if (cx1 < c->clip.x)
cx1 = c->clip.x;
if (cx2 > c->clip.x + c->clip.width)
cx2 = c->clip.x + c->clip.width;
if (cy1 < c->clip.y)
cy1 = c->clip.y;
if (cy2 > c->clip.y + c->clip.height)
cy2 = c->clip.y + c->clip.height;
p = &w->hand.erased;
for (e = w->hand.erased; e; e = n)
{
n = e->next;
allClipped = False;
x1 = e->r.x;
x2 = x1 + e->r.width;
y1 = e->r.y;
y2 = y1 + e->r.height;
ClipRects (allClipped = True);
if (allClipped)
{
Dispose (e);
*p = n;
}
else
{
e->r.x = x1;
e->r.y = y1;
e->r.width = x2 - x1;
e->r.height = y2 - y1;
p = &e->next;
}
}
}
r = &c->clip;
for (c = c->prev; c; c = c->prev)
if (!c->redisplay && CardInRect (w, r, c))
MarkCard (w, c);
}
static void MarkRectangle (w, r)
HandWidget w;
XRectangle *r;
{
CardPtr c;
for (c = w->hand.bottomCard; c; c = c->prev)
if (!c->redisplay && CardInRect (w, r, c))
MarkCard (w, c);
}
static void
EraseCard (w, c)
HandWidget w;
CardPtr c;
{
ErasedPtr e = New(ErasedRec);
e->r = c->clip;
e->next = w->hand.erased;
e->fill = True;
e->isCard = True;
e->cardX = c->x;
e->cardY = c->y;
w->hand.erased = e;
}
Boolean
ComputeClip (w, card)
HandWidget w;
CardPtr card;
{
int x1, y1, x2, y2;
int cx1, cy1, cx2, cy2;
int ox1, oy1, ox2, oy2;
CardPtr c;
ox1 = x1 = card->x;
oy1 = y1 = card->y;
ox2 = x2 = x1 + w->hand.card_width;
oy2 = y2 = y1 + w->hand.card_height;
c = card;
while (c = c->prev)
{
if (!c->shouldBeUp)
continue;
cx1 = c->x + w->hand.display_x;
cy1 = c->y + w->hand.display_y;
cx2 = cx1 + w->hand.display_width;
cy2 = cy1 + w->hand.display_height;
ClipRects (break);
}
card->clip.x = x1;
card->clip.y = y1;
card->clip.width = x2 - x1;
card->clip.height = y2 - y1;
if (x1 == ox1 && y1 == oy1 && x2 == ox2 && y2 == oy2)
card->clipped = ClipUnclipped;
else if (x2 > x1 && y2 > y1)
card->clipped = ClipPartclipped;
else
card->clipped = ClipAllclipped;
}
void
HandUpdateDisplay (gw)
Widget gw;
{
HandWidget w = (HandWidget) gw;
CardPtr c, nc;
ErasedPtr e, ne;
HandDisplayRec display;
int x, y;
if (!XtIsRealized (gw))
return;
/* Mark cards for redisplay */
for (c = w->hand.topCard; c; c = nc)
{
nc = c->next;
if (c->shouldBeUp)
{
x = XPos (w, c->row, c->col);
y = YPos (w, c->row, c->col);
if (c->isUp)
{
if (c->x != x || c->y != y)
{
EraseCard (w, c);
c->isUp = False;
}
}
c->x = x;
c->y = y;
ComputeClip (w, c);
}
else if (c->isUp)
EraseCard (w, c);
if (c->delete)
{
if (c->prev)
c->prev->next = c->next;
else
w->hand.topCard = c->next;
if (c->next)
c->next->prev = c->prev;
else
w->hand.bottomCard = c->prev;
Dispose (c);
}
}
/* mark effects of redisplay */
for (c = w->hand.bottomCard; c; c = c->prev)
{
if (c->shouldBeUp && !c->isUp || c->forceRedraw)
{
MarkCard (w, c);
c->isUp = True;
c->forceRedraw = False;
}
}
/* clear out the blank areas */
for (e = w->hand.erased; e; Dispose(e), e = ne)
{
ne = e->next;
if (e->isCard)
{
for (c = w->hand.bottomCard; c; c = c->prev)
if (c->redisplay && c->x == e->cardX && c->y == e->cardY)
break;
if (c)
continue;
}
MarkRectangle (w, &e->r);
if (e->fill)
{
XClearArea (XtDisplay(w), XtWindow (w),
e->r.x, e->r.y, e->r.width, e->r.height, False);
}
}
w->hand.erased = NULL;
/* redisplay cards */
for (c = w->hand.bottomCard; c; c = c->prev)
if (c->redisplay)
{
if (c->clipped != ClipAllclipped)
{
display.w = (Widget) w;
display.x = c->x;
display.y = c->y;
display.private = c->private;
display.clipped = False;
display.clip = c->clip;
if (c->clipped == ClipPartclipped)
display.clipped = True;
XtCallCallbackList ((Widget) w, w->hand.display_callback, (XtPointer) &display);
}
c->redisplay = FALSE;
}
}
/*
* widget was resized, adjust row and column offsets. The expose
* event will cause the card positions to get recomputed which will
* then cause them all to be redrawn
*/
static void Resize (gw)
Widget gw;
{
HandWidget w = (HandWidget) gw;
w->hand.real_col_offset = BestColOffset (w, w->hand.num_cols);
w->hand.real_row_offset = BestRowOffset (w, w->hand.num_rows);
w->hand.exposeTime = 0;
}
/*
* Redisplay function. Queue the rectangle as an erased area
* and redisplay when we've gotten all of the events
*/
static void Redisplay (gw, event, region)
Widget gw;
XEvent *event;
Region region;
{
HandWidget w = (HandWidget) gw;
CardPtr c;
XRectangle r;
ErasedPtr e;
int cx1, cy1, cx2, cy2;
int x1, y1, x2, y2;
x1 = event->xexpose.x;
x2 = x1 + event->xexpose.width;
y1 = event->xexpose.y;
y2 = y1 + event->xexpose.height;
if (event->xexpose.serial <= w->hand.exposeTime)
{
cx1 = w->hand.lastExpose.x;
cy1 = w->hand.lastExpose.y;
cx2 = cx1 + w->hand.lastExpose.width;
cy2 = cy1 + w->hand.lastExpose.height;
ClipRects (return)
}
e = New(ErasedRec);
e->r.x = x1;
e->r.y = y1;
e->r.width = x2 - x1;
e->r.height = y2 - y1;
e->next = w->hand.erased;
e->fill = False;
e->isCard = False;
w->hand.erased = e;
if (event->xexpose.count == 0) {
w->hand.exposeTime = NextRequest (XtDisplay (w));
w->hand.lastExpose.x = x1;
w->hand.lastExpose.y = y1;
w->hand.lastExpose.width = x2 - x1;
w->hand.lastExpose.height = y2 - y1;
HandUpdateDisplay (w);
}
}
/*
* When values are set which change the desired size, ask for
* the new size
*/
static Boolean SetValues (gcur, greq, gnew)
Widget gcur, greq, gnew;
{
HandWidget cur = (HandWidget) gcur,
req = (HandWidget) greq,
new = (HandWidget) gnew;
Dimension curwidth, curheight, reqwidth, reqheight;
Dimension width, height;
getHandSize (cur, &curwidth, &curheight);
getHandSize (req, &reqwidth, &reqheight);
if (curwidth != reqwidth || curheight != reqheight)
{
XtMakeResizeRequest (gnew, reqwidth, reqheight, &width, &height);
if (width != curwidth || height != curheight)
Resize (gnew);
}
new->hand.exposeTime = 0;
return TRUE;
}
/* Insert a card */
XtPointer
HandAddCard (gw, private, row, col, offset)
Widget gw;
XtPointer private;
int row;
int col;
int offset;
{
HandWidget w = (HandWidget) gw;
CardPtr c, sib;
int maxPos;
/* compute values for row/col if requested */
if (row == InsertRow)
{
maxPos = -1;
for (c = w->hand.topCard; c; c = c->next)
{
if (w->hand.row_major)
{
if (c->row > maxPos)
maxPos = c->row;
}
else
{
if (c->col == col && c->row > maxPos)
maxPos = c->row;
}
}
row = maxPos + 1;
}
if (col == InsertCol)
{
maxPos = -1;
for (c = w->hand.topCard; c; c = c->next)
{
if (!w->hand.row_major)
{
if (c->col > maxPos)
maxPos = c->col;
}
else
{
if (c->row == row && c->col > maxPos)
maxPos = c->col;
}
}
col = maxPos + 1;
}
/* find the card below this one */
sib = NULL;
for (c = w->hand.bottomCard; c; c = c->prev)
{
if (w->hand.row_major)
{
if ((c->row == row && c->col <= col) || c->row < row)
sib = c;
else
break;
}
else
{
if ((c->col == col && c->row <= row) || c->col < col)
sib = c;
else
break;
}
}
c = New(CardRec);
c->redisplay = False;
c->forceRedraw = False;
c->isUp = False;
c->shouldBeUp = True;
c->delete = False;
c->private = private;
c->row = row;
c->col = col;
c->offset = offset;
/* insert the new card on the list */
c->next = sib; /* c is above sib */
if (sib)
c->prev = sib->prev;
else
c->prev = w->hand.bottomCard;
if (c->next)
c->next->prev = c;
else
w->hand.bottomCard = c;
if (c->prev)
c->prev->next = c;
else
w->hand.topCard = c;
/* adjust higher cards rows */
if (w->hand.row_insert)
{
for (sib = c->prev; sib; sib = sib->prev)
if (sib->col == c->col && sib->row == row)
sib->row = ++row;
}
/* adjust higher cards columns */
if (w->hand.col_insert)
{
for (sib = c->prev; sib; sib = sib->prev)
if (sib->row == c->row && sib->col == col)
sib->col = ++col;
}
w->hand.exposeTime = 0;
if (XtIsRealized(gw) && w->hand.immediate_update)
HandUpdateDisplay (gw);
return (XtPointer) c;
}
/* remove a card */
void
HandRemoveCard (gw, card)
Widget gw;
XtPointer card;
{
HandWidget w = (HandWidget) gw;
CardPtr c, sib;
int row, col;
for (c = w->hand.topCard; c; c = c->next)
if (c == (CardPtr) card)
break;
if (!c)
return;
c->shouldBeUp = False;
c->delete = True;
if (w->hand.row_insert)
{
row = c->row;
for (sib = c->prev; sib; sib = sib->prev)
if (sib->col == c->col && sib->row == row + 1)
sib->row = row++;
}
if (w->hand.col_insert)
{
col = c->col;
for (sib = c->prev; sib; sib = sib->prev)
if (sib->row == c->row && sib->col == col + 1)
sib->col = col++;
}
w->hand.exposeTime = 0;
if (XtIsRealized (gw) && w->hand.immediate_update)
HandUpdateDisplay (gw);
}
/* change the private value for a card and force a redisplay */
void
HandReplaceCard (gw, card, private, offset)
Widget gw;
XtPointer card;
XtPointer private;
{
HandWidget w = (HandWidget) gw;
CardPtr c;
for (c = w->hand.topCard; c; c = c->next)
if (c == (CardPtr) card)
break;
if (!c)
return;
c->private = private;
c->forceRedraw = True;
c->offset = offset;
w->hand.exposeTime = 0;
if (XtIsRealized (gw) && w->hand.immediate_update)
HandUpdateDisplay (w);
}
void
HandRectangleForPos (gw, row, col, r)
Widget gw;
int row, col;
XRectangle *r;
{
HandWidget w = (HandWidget) gw;
r->x = XPos (w, row, col);
r->y = YPos (w, row, col);
r->width = w->hand.card_width;
r->height = w->hand.card_height;
}
void
HandRectangleForCard (gw, card, r)
Widget gw;
XtPointer card;
XRectangle *r;
{
HandWidget w = (HandWidget) gw;
CardPtr c;
for (c = w->hand.topCard; c; c = c->next)
if (c == (CardPtr) card)
break;
if (!c)
{
r->x = 0;
r->y = 0;
r->width = 0;
r->height = 0;
}
else
HandRectangleForPos (gw, c->row, c->col, r);
}
Boolean
HandXYToPos (gw, x, y, rowp, colp)
Widget gw;
int x, y;
int *rowp, *colp;
{
HandWidget w = (HandWidget) gw;
CardPtr c;
c = XYToCard (w, x, y);
if (c)
{
*rowp = c->row;
*colp = c->col;
return True;
}
return False;
}
void
HandRemoveAllCards (gw)
Widget gw;
{
HandWidget w = (HandWidget) gw;
CardPtr c, n;
for (c = w->hand.topCard; c; c = n) {
n = c->next;
free ((char *) c);
}
w->hand.topCard = 0;
w->hand.bottomCard = 0;
w->hand.exposeTime = 0;
if (XtIsRealized (gw))
XClearWindow (XtDisplay (w), XtWindow (w));
}
kgames-1.0/Xkw/Hand.h 100644 20717 2432 6501 6121566726 11115 0 ustar /*
* $XConsortium: Hand.h,v 1.5 91/07/25 21:33:53 keith Exp $
*/
#ifndef _XtHand_h
#define _XtHand_h
#include <X11/Xaw/Simple.h>
/***********************************************************************
*
* Hand Widget
*
***********************************************************************/
/* Parameters:
Name Class RepType Default Value
---- ----- ------- -------------
background Background pixel XtDefaultForeground
cardWidth CardWidth Dimension 0
cardHeight CardHeight Dimension 0
displayWidth DisplayWidth Dimension 0
displayHeight DisplayHeight Dimension 0
displayX DisplayX Position 0
displayY DisplayY Position 0
internalBorderWidthInternalBorderWidth Dimension 0
numRows NumRows Dimension 0
numCols NumCols Dimension 0
rowsHint RowsHint Boolean False
colsHint ColsHint Boolean False
rowOffset RowOffset Dimension 0
colOffset ColOffset Dimension 0
displayCallback DisplayCallback Callback NULL
inputCallback InputCallback Callback NULL
rowInsert Insert Boolean False
colInsert Insert Boolean False
immediateUpdate ImmediateUpdate Boolean True
*/
typedef struct _HandRec *HandWidget; /* completely defined in HandPrivate.h */
typedef struct _HandClassRec *HandWidgetClass; /* completely defined in HandPrivate.h */
extern WidgetClass handWidgetClass;
typedef struct _HandDisplay {
Widget w;
Position x, y;
XRectangle clip;
Boolean clipped;
XtPointer private;
} HandDisplayRec, *HandDisplayPtr;
typedef struct _HandInput {
Widget w;
Position row, col;
XEvent event;
XtPointer private;
String *params;
Cardinal *num_params;
} HandInputRec, *HandInputPtr;
extern XtPointer HandAddCard ();
extern void HandRemoveCard ();
#define InsertRow -1
#define InsertCol -1
#define XkwHandDefaultOffset -32767
#define XtNcardWidth "cardWidth"
#define XtCCardWidth "CardWidth"
#define XtNcardHeight "cardHeight"
#define XtCCardHeight "CardHeight"
#define XtNdisplayWidth "displayWidth"
#define XtCDisplayWidth "DisplayWidth"
#define XtNdisplayHeight "displayHeight"
#define XtCDisplayHeight "DisplayHeight"
#define XtNdisplayX "displayX"
#define XtCDisplayX "DisplayX"
#define XtNdisplayY "displayY"
#define XtCDisplayY "DisplayY"
#define XtNinternalBorderWidth "internalBorderWidth"
#define XtCInternalBorderWidth "InternalBorderWidth"
#define XtNnumRows "numRows"
#define XtCNumRows "NumRows"
#define XtNnumCols "numCols"
#define XtCNumCols "NumCols"
#define XtNrowsHint "rowsHint"
#define XtCRowsHint "RowsHint"
#define XtNcolsHint "colsHint"
#define XtCColsHint "ColsHint"
#define XtNcolOffset "colOffset"
#define XtCColOffset "ColOffset"
#define XtNrowOffset "rowOffset"
#define XtCRowOffset "RowOffset"
#define XtNredisplay "redisplay"
#define XtCRedisplay "Redisplay"
#define XtNrowMajor "rowMajor"
#define XtCRowMajor "RowMajor"
#define XtNdisplayCallback "displayCallback"
#define XtCDisplayCallback "DisplayCallback"
#define XtNinputCallback "inputCallback"
#define XtCInputCallback "InputCallback"
#define XtNrowInsert "rowInsert"
#define XtNcolInsert "colInsert"
#define XtCInsert "Insert"
#define XtNimmediateUpdate "immediateUpdate"
#define XtCImmediateUpdate "ImmediateUpdate"
#endif /* _XtHand_h */
/* DON'T ADD STUFF AFTER THIS #endif */
kgames-1.0/Xkw/HandP.h 100644 20717 2432 7227 6121566726 11243 0 ustar /*
* $XConsortium: HandP.h,v 1.9 91/07/26 15:21:49 keith Exp $
*/
/*
* HandP.h - Private definitions for Hand widget
*/
#ifndef _XtHandP_h
#define _XtHandP_h
#include "Hand.h"
#include <X11/Xaw/SimpleP.h>
/***********************************************************************
*
* Hand Widget Private Data
*
***********************************************************************/
/************************************
*
* Class structure
*
***********************************/
/*
* New fields for the Hand widget class record
*/
typedef struct _HandClass {
int makes_compiler_happy; /* not used */
} HandClassPart;
/*
* Full class record declaration
*/
typedef struct _HandClassRec {
CoreClassPart core_class;
SimpleClassPart simple_class;
HandClassPart hand_class;
} HandClassRec;
extern HandClassRec handClassRec;
/***************************************
*
* Instance (widget) structure
*
**************************************/
/*
* New fields for the Hand widget record
*/
#define New(t) (t *) malloc(sizeof (t))
#define Dispose(p) free((char *) p)
#define Some(t,n) (t*) malloc(sizeof(t) * n)
#define More(p,t,n) ((p)? (t *) realloc((char *) p, sizeof(t)*n):Some(t,n)
typedef enum { ClipUnclipped, ClipPartclipped, ClipAllclipped } HandClip;
typedef struct _Card {
struct _Card *next, *prev;
Boolean redisplay; /* temp for redisplay routine */
Boolean isUp;
Boolean shouldBeUp;
Boolean delete;
Boolean forceRedraw;
XRectangle clip;
HandClip clipped;
XtPointer private;
int row, col;
int offset;
int x, y;
} CardRec, *CardPtr;
typedef struct _Erased {
struct _Erased *next;
XRectangle r;
Bool fill;
Bool isCard;
int cardX, cardY;
} ErasedRec, *ErasedPtr;
typedef struct {
/*
* Resource specifiable values
*/
Dimension card_width; /* area occupied by card */
Dimension card_height; /* */
Dimension internal_border; /* space around entire hand */
Dimension num_cols; /* number of columns */
Dimension num_rows; /* number of rows */
Dimension col_offset; /* distance to space columns apart */
Dimension row_offset; /* distance to space rows apart */
Position display_x; /* inside display rectangle, */
Position display_y; /* the display func will fill */
Dimension display_width; /* the entire space. Used to */
Dimension display_height; /* optimize redisplay */
Boolean cols_hint; /* number of columns is only a hint */
Boolean rows_hint; /* number of rows is only a hint */
Boolean row_insert; /* when inserting cards, those on */
Boolean col_insert; /* top get moved down/right */
Boolean immediate_update; /* redisplay after every edit */
Boolean row_major; /* stack cards in cols */
XtCallbackList display_callback; /* func to display cards */
XtCallbackList input_callback; /* func called on button press */
/* List of cards could be changed by resource, but easier by func */
CardPtr topCard, bottomCard;/* list of cards */
Dimension real_col_offset; /* when widget gets reshaped, */
Dimension real_row_offset; /* the offset values are adjusted */
ErasedPtr erased; /* list of areas erased; for redisplay*/
XExposeEvent lastExpose; /* last rectangle exposed */
unsigned long exposeTime; /* serial number when exposed */
} HandPart;
/*
* Full widget declaration
*/
typedef struct _HandRec {
CorePart core;
SimplePart simple;
HandPart hand;
} HandRec;
#endif /* _XtHandP_h */
kgames-1.0/Xkw/Makefile 100644 0 1 71241 6515034260 13420 0 ustar root daemon # Makefile generated by imake - do not edit!
# $TOG: imake.c /main/97 1997/06/20 20:23:51 kaleb $
# ----------------------------------------------------------------------
# Makefile generated from "Imake.tmpl" and <Imakefile>
# $TOG: Imake.tmpl /main/245 1997/05/20 10:05:47 kaleb $
#
all::
.SUFFIXES: .i
# $TOG: Imake.cf /main/28 1997/06/25 08:31:36 barstow $
# -----------------------------------------------------------------------
# site-specific configuration parameters that need to come before
# the platform-specific parameters - edit site.def to change
# site: $XConsortium: site.def /main/revisionist/4 1996/12/31 08:02:07 kaleb $
# ----------------------------------------------------------------------
# platform-specific configuration parameters - edit sun.cf to change
# platform: $TOG: sun.cf /main/163 1997/06/08 20:08:23 kaleb $
# operating system: SunOS 4.1.3_U1 1 sun4c (4.1.3)
# $XConsortium: sunLib.rules /main/15 1996/09/28 16:13:16 rws $
# ----------------------------------------------------------------------
# site-specific configuration parameters that go after
# the platform-specific parameters - edit site.def to change
# site: $XConsortium: site.def /main/revisionist/4 1996/12/31 08:02:07 kaleb $
# ---------------------------------------------------------------------
# Imake rules for building libraries, programs, scripts, and data files
# rules: $TOG: Imake.rules /main/220 1997/06/05 18:05:16 kaleb $
PATHSEP = /
SHELL = /bin/sh
TOP = ..
CURRENT_DIR = Xkw
IMAKE = imake
DEPEND = makedepend
MKDIRHIER = mkdirhier
EXPORTLISTGEN = exportlistgen
CONFIGSRC = $(TOP)/config
IMAKESRC = $(CONFIGSRC)/imake
DEPENDSRC = $(CONFIGSRC)/makedepend
INCROOT = /usr/X11R6.3/include
USRLIBDIR = /usr/X11R6.3/lib
SHLIBDIR = /usr/X11R6.3/lib
LINTLIBDIR = $(USRLIBDIR)/lint
MANPATH = /usr/X11R6.3/man
MANSOURCEPATH = $(MANPATH)/man
MANDIR = $(MANSOURCEPATH)$(MANSUFFIX)
LIBMANDIR = $(MANSOURCEPATH)$(LIBMANSUFFIX)
FILEMANDIR = $(MANSOURCEPATH)$(FILEMANSUFFIX)
AR = ar clq
BOOTSTRAPCFLAGS =
CC = gcc -fpcc-struct-return
AS = as
COMPRESS = compress
GZIPCMD = gzip
CPP = /lib/cpp $(STD_CPP_DEFINES)
PREPROCESSCMD = gcc -fpcc-struct-return -E $(STD_CPP_DEFINES)
INSTALL = install
INSTALLFLAGS = -c
LD = ld
LEX = lex
LEXLIB = -ll
YACC = yacc
CCYACC = yacc
LINT = lint
LINTLIBFLAG = -C
LINTOPTS = -axz
LN = ln -s
MAKE = make
MV = mv
CP = cp
RANLIB = ranlib
RANLIBINSTFLAGS =
RM = rm -f
MANSUFFIX = n
LIBMANSUFFIX = 3
FILEMANSUFFIX = 5
TROFF = psroff
NROFF = nroff
MSMACROS = -ms
MANMACROS = -man
TBL = tbl
EQN = eqn
NEQN = neqn
COL = col
DVIPS = dvips
LATEX = latex
STD_INCLUDES =
STD_CPP_DEFINES = $(PROJECT_DEFINES)
STD_DEFINES = $(PROJECT_DEFINES)
EXTRA_LOAD_FLAGS =
EXTRA_LDOPTIONS =
EXTRA_LIBRARIES =
TAGS = ctags
SHAREDCODEDEF = -DSHAREDCODE
SHLIBDEF = -DSUNSHLIB
SHLIBLDFLAGS = -assert pure-text
PICFLAGS = -fpic
CXXPICFLAGS = -pic
PROTO_DEFINES =
INSTPGMFLAGS =
INSTBINFLAGS = -m 0755
INSTUIDFLAGS = -m 4711
INSTLIBFLAGS = -m 0644
INSTINCFLAGS = -m 0444
INSTMANFLAGS = -m 0444
INSTDATFLAGS = -m 0444
INSTKMEMFLAGS = -g kmem -m 2711
PROJECTROOT = /usr/X11R6.3
CDEBUGFLAGS = -O2
CCOPTIONS =
ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES)
ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(THREADS_DEFINES) $(DEFINES)
CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(THREADS_CFLAGS) $(ALLDEFINES)
LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES) $(DEPEND_DEFINES)
LDPRELIB = -L$(USRLIBDIR)
LDPOSTLIB =
LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) $(EXTRA_LDOPTIONS) $(THREADS_LDFLAGS) $(LOCAL_LDFLAGS) $(LDPRELIBS)
CXXLDOPTIONS = $(CXXDEBUGFLAGS) $(CXXOPTIONS) $(EXTRA_LDOPTIONS) $(THREADS_CXXLDFLAGS) $(LOCAL_LDFLAGS) $(LDPRELIBS)
LDLIBS = $(LDPOSTLIBS) $(THREADS_LIBS) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
CCLINK = $(CC)
CXXLINK = $(CXX)
LDSTRIPFLAGS = -x
LDCOMBINEFLAGS = -X -r
DEPENDFLAGS =
MACROFILE = sun.cf
RM_CMD = $(RM)
IMAKE_DEFINES =
IRULESRC = $(CONFIGDIR)
IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/X11.tmpl \
$(IRULESRC)/site.def $(IRULESRC)/$(MACROFILE) \
$(EXTRA_ICONFIGFILES)
# $TOG: X11.rules /main/4 1997/04/30 15:23:24 kaleb $
# ----------------------------------------------------------------------
# X Window System Build Parameters and Rules
# $TOG: X11.tmpl /main/292 1997/05/20 10:05:59 kaleb $
# -----------------------------------------------------------------------
# X Window System make variables; these need to be coordinated with rules
XTOP = $(TOP)
BINDIR = /usr/X11R6.3/bin
BUILDINCROOT = $(TOP)/exports
BUILDINCDIR = $(BUILDINCROOT)/include
BUILDINCTOP = ../..
BUILDLIBDIR = $(TOP)/exports/lib
BUILDLIBTOP = ../..
BUILDBINDIR = $(TOP)/exports/bin
BUILDBINTOP = ../..
XBUILDINCROOT = $(XTOP)/exports
XBUILDINCDIR = $(XBUILDINCROOT)/include/X11
XBUILDINCTOP = ../../..
XBUILDBINDIR = $(XBUILDINCROOT)/bin
INCDIR = $(INCROOT)
ADMDIR = /usr/adm
LIBDIR = $(USRLIBDIR)/X11
TOP_X_INCLUDES = -I$(XPROJECTROOT)/include
FONTDIR = $(LIBDIR)/fonts
XINITDIR = $(LIBDIR)/xinit
XDMDIR = $(LIBDIR)/xdm
TWMDIR = $(LIBDIR)/twm
XSMDIR = $(LIBDIR)/xsm
NLSDIR = $(LIBDIR)/nls
XLOCALEDIR = $(LIBDIR)/locale
PEXAPIDIR = $(LIBDIR)/PEX
LBXPROXYDIR = $(LIBDIR)/lbxproxy
PROXYMANAGERDIR = $(LIBDIR)/proxymngr
XPRINTDIR = $(LIBDIR)
XAPPLOADDIR = $(LIBDIR)/app-defaults
FONTCFLAGS = -t
INSTAPPFLAGS = $(INSTDATFLAGS)
RGB = rgb
FONTC = bdftopcf
MKFONTDIR = mkfontdir
DOCUTILSRC = $(XTOP)/doc/util
XDOCMACROS = $(DOCUTILSRC)/macros.t
XIDXMACROS = $(DOCUTILSRC)/indexmacros.t
PROGRAMSRC = $(TOP)/programs
LIBSRC = $(XTOP)/lib
FONTSRC = $(XTOP)/fonts
INCLUDESRC = $(BUILDINCROOT)/include
XINCLUDESRC = $(INCLUDESRC)/X11
SERVERSRC = $(XTOP)/programs/Xserver
CONTRIBSRC = $(XTOP)/../contrib
UNSUPPORTEDSRC = $(XTOP)/unsupported
DOCSRC = $(XTOP)/doc
RGBSRC = $(XTOP)/programs/rgb
BDFTOPCFSRC = $(PROGRAMSRC)/bdftopcf
MKFONTDIRSRC = $(PROGRAMSRC)/mkfontdir
FONTSERVERSRC = $(PROGRAMSRC)/xfs
FONTINCSRC = $(XTOP)/include/fonts
EXTINCSRC = $(XTOP)/include/extensions
TRANSCOMMSRC = $(LIBSRC)/xtrans
TRANS_INCLUDES = -I$(TRANSCOMMSRC)
XENVLIBDIR = $(USRLIBDIR)
CLIENTENVSETUP = LD_LIBRARY_PATH=$(XENVLIBDIR)
# $TOG: sunLib.tmpl /main/45 1997/02/13 13:52:59 kaleb $
XLIBSRC = $(LIBSRC)/X11
SOXLIBREV = 4.30
DEPXONLYLIB =
XONLYLIB = -lX11
LINTXONLY = $(LINTLIBDIR)/llib-lX11.ln
XLIBONLY = $(XONLYLIB)
XEXTLIBSRC = $(LIBSRC)/Xext
SOXEXTREV = 4.40
DEPEXTENSIONLIB =
EXTENSIONLIB = -lXext
LINTEXTENSION = $(LINTLIBDIR)/llib-lXext.ln
LINTEXTENSIONLIB = $(LINTEXTENSION)
DEPXLIB = $(DEPEXTENSIONLIB) $(DEPXONLYLIB)
XLIB = $(EXTENSIONLIB) $(XONLYLIB)
LINTXLIB = $(LINTXONLYLIB)
XAUTHSRC = $(LIBSRC)/Xau
DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
XAUTHLIB = -lXau
LINTXAUTH = $(LINTLIBDIR)/llib-lXau.ln
XDMCPLIBSRC = $(LIBSRC)/Xdmcp
DEPXDMCPLIB = $(USRLIBDIR)/libXdmcp.a
XDMCPLIB = -lXdmcp
LINTXDMCP = $(LINTLIBDIR)/llib-lXdmcp.ln
XMUSRC = $(LIBSRC)/Xmu
SOXMUREV = 4.20
DEPXMULIB = $(USRLIBDIR)/libXmu.sa.$(SOXMUREV)
XMULIB = -lXmu
LINTXMU = $(LINTLIBDIR)/llib-lXmu.ln
OLDXLIBSRC = $(LIBSRC)/oldX
SOOLDXREV = 4.20
DEPOLDXLIB =
OLDXLIB = -loldX
LINTOLDX = $(LINTLIBDIR)/llib-loldX.ln
XPLIBSRC = $(LIBSRC)/Xp
SOXPREV = 6.2
DEPXPLIB =
XPLIB = -lXp
LINTXP = $(LINTLIBDIR)/llib-lXp.ln
TOOLKITSRC = $(LIBSRC)/Xt
SOXTREV = 4.20
DEPXTOOLONLYLIB = $(USRLIBDIR)/libXt.sa.$(SOXTREV)
XTOOLONLYLIB = -lXt
LINTXTOOLONLY = $(LINTLIBDIR)/llib-lXt.ln
DEPXTOOLLIB = $(DEPXTOOLONLYLIB) $(DEPSMLIB) $(DEPICELIB)
XTOOLLIB = $(XTOOLONLYLIB) $(SMLIB) $(ICELIB)
LINTXTOOLLIB = $(LINTXTOOLONLYLIB)
XALIBSRC = $(LIBSRC)/Xa
DEPXALIB = $(USRLIBDIR)/libXa.a
XALIB = -lXa
LINTXA = $(LINTLIBDIR)/llib-lXa.ln
AWIDGETSRC = $(LIBSRC)/Xaw
SOXAWREV = 6.10
DEPXAWLIB = $(USRLIBDIR)/libXaw.sa.$(SOXAWREV)
XAWLIB = -lXaw
LINTXAW = $(LINTLIBDIR)/llib-lXaw.ln
XILIBSRC = $(LIBSRC)/Xi
SOXINPUTREV = 4.20
DEPXILIB =
XILIB = -lXi
LINTXI = $(LINTLIBDIR)/llib-lXi.ln
XTESTLIBSRC = $(LIBSRC)/Xtst
SOXTESTREV = 1.20
DEPXTESTLIB =
XTESTLIB = -lXtst
LINTXTEST = $(LINTLIBDIR)/llib-lXtst.ln
PEXLIBSRC = $(LIBSRC)/PEX5
SOPEXREV = 1.10
DEPPEXLIB =
PEXLIB = -lPEX5
LINTPEX = $(LINTLIBDIR)/llib-lPEX5.ln
XIELIBSRC = $(LIBSRC)/XIE
SOXIEREV = 6.0
DEPXIELIB =
XIELIB = -lXIE
LINTXIE = $(LINTLIBDIR)/llib-lXIE.ln
PHIGSLIBSRC = $(LIBSRC)/PHIGS
DEPPHIGSLIB = $(USRLIBDIR)/libphigs.a
PHIGSLIB = -lphigs
LINTPHIGS = $(LINTLIBDIR)/llib-lphigs.ln
DEPXBSDLIB = $(USRLIBDIR)/libXbsd.a
XBSDLIB = -lXbsd
LINTXBSD = $(LINTLIBDIR)/llib-lXbsd.ln
ICESRC = $(LIBSRC)/ICE
SOICEREV = 6.3
DEPICELIB =
ICELIB = -lICE
LINTICE = $(LINTLIBDIR)/llib-lICE.ln
SMSRC = $(LIBSRC)/SM
SOSMREV = 6.0
DEPSMLIB =
SMLIB = -lSM
LINTSM = $(LINTLIBDIR)/llib-lSM.ln
XKEYSRC = $(LIBSRC)/Xkey
SOXKEYREV = 6.0
DEPXKEYLIB =
XKEYLIB = -lXkey
LINTXKEY = $(LINTLIBDIR)/llib-lXkey.ln
FSLIBSRC = $(LIBSRC)/FS
DEPFSLIB = $(USRLIBDIR)/libFS.a
FSLIB = -lFS
LINTFS = $(LINTLIBDIR)/llib-lFS.ln
FONTLIBSRC = $(LIBSRC)/font
DEPFONTLIB = $(USRLIBDIR)/libfont.a
FONTLIB = -lfont
LINTFONT = $(LINTLIBDIR)/llib-lfont.ln
XKBFILELIBSRC = $(LIBSRC)/xkbfile
DEPXKBFILELIB = $(USRLIBDIR)/libxkbfile.a
XKBFILELIB = -lxkbfile
LINTXKBFILE = $(LINTLIBDIR)/llib-lxkbfile.ln
XKBCOMPCMD = xkbcomp
DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
DEPLIBS1 = $(DEPLIBS)
DEPLIBS2 = $(DEPLIBS)
DEPLIBS3 = $(DEPLIBS)
DEPLIBS4 = $(DEPLIBS)
DEPLIBS5 = $(DEPLIBS)
DEPLIBS6 = $(DEPLIBS)
DEPLIBS7 = $(DEPLIBS)
DEPLIBS8 = $(DEPLIBS)
DEPLIBS9 = $(DEPLIBS)
DEPLIBS10 = $(DEPLIBS)
CONFIGDIR = $(LIBDIR)/config
USRLIBDIRPATH = $(USRLIBDIR)
LDPRELIBS = -L$(USRLIBDIR)
LDPOSTLIBS =
TOP_INCLUDES = -I$(INCROOT) $(TOP_X_INCLUDES)
PROJECT_DEFINES =
# ----------------------------------------------------------------------
# start of Imakefile
# $TOG: Library.tmpl /main/44 1997/04/28 11:47:53 kaleb $
CC = gcc -fpcc-struct-return
CCOPTIONS =
STD_DEFINES = $(PROJECT_DEFINES)
CDEBUGFLAGS = -O2
LIB_MT_DEFINES = LibraryMTDefines
PROJECTROOT=/usr/X11
BINDIR =$(PROJECTROOT)/bin
LIBDIR = $(PROJECTROOT)/lib/X11
MANPATH = $(PROJECTROOT)/man
TEMP_ROOT=/usr/X11/bin
INSTALL=/bin/install
MKDIRHIER = /bin/sh $(TEMP_ROOT)/mkdirhier
INCLUDES=-I..
HEADERS = Cards.h CardsP.h CardsUtil.h SuitCards.h Hand.h HandP.h \
Thermo.h ThermoP.h Layout.h LayoutP.h Pad.h PadP.h
SRCS = Cards.c Hand.c Thermo.c Layout.c laygram.c laylex.c \
CardsUtil.c SuitCards.c Animate.c Message.c Pad.c
OBJS = Cards.o Hand.o Thermo.o Layout.o laygram.o laylex.o \
CardsUtil.o SuitCards.o Animate.o Message.o Pad.o
CARDS_BITMAPS = playing_card bob spade_lg
all::
depend :: laygram.c laylex.c
all::
$(_NULLCMD_)
$(_NULLCMD_)
$(_NULLCMD_)
includes::
$(_NULLCMD_)
$(_NULLCMD_)
$(_NULLCMD_)
.c.o:
$(_NULLCMD_)
$(_NULLCMD_)
$(RM) $@
$(CC) -c $(CFLAGS) $(_NOOP_) $*.c
$(_NULLCMD_)
clean::
$(_NULLCMD_)
$(_NULLCMD_)
$(_NULLCMD_)
all:: libXkw.a
libXkw.a: $(OBJS) $(EXTRALIBRARYDEPS)
$(RM) $@
$(AR) $@ $(OBJS)
$(RANLIB) $@
$(_NULLCMD_)
laygram.c : laygram.y
yacc -d laygram.y
sed 's/yy/LayYY/g' y.tab.c > laygram.c
sed 's/yy/LayYY/g' y.tab.h > laygram.h
rm y.tab.c y.tab.h
clean::
-rm laygram.c laygram.h
laylex.c: laylex.l
lex laylex.l
sed 's/yy/LayYY/g' lex.yy.c > laylex.c
rm lex.yy.c
clean::
-rm laylex.c
depend::
$(DEPEND) $(DEPENDFLAGS) -- $(ALLDEFINES) $(DEPEND_DEFINES) -- $(SRCS)
layout: layout.o libXkw.a $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
$(RM) $@
$(CCLINK) -o $@ $(LDOPTIONS) layout.o libXkw.a $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB) $(LDLIBS) $(EXTRA_LOAD_FLAGS)
clean::
$(RM) layout
padtest: padtest.o libXkw.a $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
$(RM) $@
$(CCLINK) -o $@ $(LDOPTIONS) padtest.o libXkw.a $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB) $(LDLIBS) $(EXTRA_LOAD_FLAGS)
clean::
$(RM) padtest
# ----------------------------------------------------------------------
# common rules for all Makefiles - do not edit
.c.i:
$(RM) $@
$(CC) -E $(CFLAGS) $(_NOOP_) $*.c > $@
emptyrule::
clean::
$(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut "#"*
Makefile::
-@if [ -f Makefile ]; then set -x; \
$(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
man_keywords::
catman -M $(DESTDIR)$(MANPATH) -w
# ----------------------------------------------------------------------
# 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"
install.linkkit::
@echo "install.linkkit in $(CURRENT_DIR) done"
Makefiles::
includes::
depend::
# ----------------------------------------------------------------------
# dependencies generated by makedepend
# DO NOT DELETE
Cards.o: /usr/X11R6.3/include/X11/IntrinsicP.h
Cards.o: /usr/X11R6.3/include/X11/Intrinsic.h /usr/X11R6.3/include/X11/Xlib.h
Cards.o: /usr/local/lib/gcc-include/sys/types.h
Cards.o: /usr/local/lib/gcc-include/sys/stdtypes.h
Cards.o: /usr/include/sys/sysmacros.h /usr/X11R6.3/include/X11/X.h
Cards.o: /usr/X11R6.3/include/X11/Xfuncproto.h
Cards.o: /usr/X11R6.3/include/X11/Xosdefs.h
Cards.o: /usr/local/lib/gcc-include/stddef.h /usr/X11R6.3/include/X11/Xutil.h
Cards.o: /usr/X11R6.3/include/X11/Xresource.h
Cards.o: /usr/local/lib/gcc-include/string.h /usr/X11R6.3/include/X11/Core.h
Cards.o: /usr/X11R6.3/include/X11/Composite.h
Cards.o: /usr/X11R6.3/include/X11/Constraint.h
Cards.o: /usr/X11R6.3/include/X11/Object.h /usr/X11R6.3/include/X11/RectObj.h
Cards.o: /usr/X11R6.3/include/X11/CoreP.h
Cards.o: /usr/X11R6.3/include/X11/CompositeP.h
Cards.o: /usr/X11R6.3/include/X11/ConstrainP.h
Cards.o: /usr/X11R6.3/include/X11/ObjectP.h
Cards.o: /usr/X11R6.3/include/X11/RectObjP.h
Cards.o: /usr/X11R6.3/include/X11/StringDefs.h
Cards.o: /usr/X11R6.3/include/X11/Xmu/Converters.h
Cards.o: /usr/local/lib/gcc-include/stdio.h
Cards.o: /usr/local/lib/gcc-include/stdarg.h
Cards.o: /usr/local/lib/gcc-include/va-sparc.h
Cards.o: /usr/local/lib/gcc-include/ctype.h CardsP.h Cards.h Hand.h
Cards.o: /usr/X11R6.3/include/X11/Xaw/Simple.h HandP.h
Cards.o: /usr/X11R6.3/include/X11/Xaw/SimpleP.h
Cards.o: /usr/X11R6.3/include/X11/Xmu/Drawing.h rank.bm face.bm suit.bm
Cards.o: playing_card cards.bm
Hand.o: /usr/X11R6.3/include/X11/IntrinsicP.h
Hand.o: /usr/X11R6.3/include/X11/Intrinsic.h /usr/X11R6.3/include/X11/Xlib.h
Hand.o: /usr/local/lib/gcc-include/sys/types.h
Hand.o: /usr/local/lib/gcc-include/sys/stdtypes.h
Hand.o: /usr/include/sys/sysmacros.h /usr/X11R6.3/include/X11/X.h
Hand.o: /usr/X11R6.3/include/X11/Xfuncproto.h
Hand.o: /usr/X11R6.3/include/X11/Xosdefs.h
Hand.o: /usr/local/lib/gcc-include/stddef.h /usr/X11R6.3/include/X11/Xutil.h
Hand.o: /usr/X11R6.3/include/X11/Xresource.h
Hand.o: /usr/local/lib/gcc-include/string.h /usr/X11R6.3/include/X11/Core.h
Hand.o: /usr/X11R6.3/include/X11/Composite.h
Hand.o: /usr/X11R6.3/include/X11/Constraint.h
Hand.o: /usr/X11R6.3/include/X11/Object.h /usr/X11R6.3/include/X11/RectObj.h
Hand.o: /usr/X11R6.3/include/X11/CoreP.h
Hand.o: /usr/X11R6.3/include/X11/CompositeP.h
Hand.o: /usr/X11R6.3/include/X11/ConstrainP.h
Hand.o: /usr/X11R6.3/include/X11/ObjectP.h
Hand.o: /usr/X11R6.3/include/X11/RectObjP.h
Hand.o: /usr/X11R6.3/include/X11/StringDefs.h
Hand.o: /usr/X11R6.3/include/X11/Xmu/Converters.h
Hand.o: /usr/local/lib/gcc-include/stdio.h
Hand.o: /usr/local/lib/gcc-include/stdarg.h
Hand.o: /usr/local/lib/gcc-include/va-sparc.h
Hand.o: /usr/local/lib/gcc-include/ctype.h HandP.h Hand.h
Hand.o: /usr/X11R6.3/include/X11/Xaw/Simple.h
Hand.o: /usr/X11R6.3/include/X11/Xaw/SimpleP.h
Thermo.o: /usr/X11R6.3/include/X11/IntrinsicP.h
Thermo.o: /usr/X11R6.3/include/X11/Intrinsic.h
Thermo.o: /usr/X11R6.3/include/X11/Xlib.h
Thermo.o: /usr/local/lib/gcc-include/sys/types.h
Thermo.o: /usr/local/lib/gcc-include/sys/stdtypes.h
Thermo.o: /usr/include/sys/sysmacros.h /usr/X11R6.3/include/X11/X.h
Thermo.o: /usr/X11R6.3/include/X11/Xfuncproto.h
Thermo.o: /usr/X11R6.3/include/X11/Xosdefs.h
Thermo.o: /usr/local/lib/gcc-include/stddef.h
Thermo.o: /usr/X11R6.3/include/X11/Xutil.h
Thermo.o: /usr/X11R6.3/include/X11/Xresource.h
Thermo.o: /usr/local/lib/gcc-include/string.h /usr/X11R6.3/include/X11/Core.h
Thermo.o: /usr/X11R6.3/include/X11/Composite.h
Thermo.o: /usr/X11R6.3/include/X11/Constraint.h
Thermo.o: /usr/X11R6.3/include/X11/Object.h
Thermo.o: /usr/X11R6.3/include/X11/RectObj.h /usr/X11R6.3/include/X11/CoreP.h
Thermo.o: /usr/X11R6.3/include/X11/CompositeP.h
Thermo.o: /usr/X11R6.3/include/X11/ConstrainP.h
Thermo.o: /usr/X11R6.3/include/X11/ObjectP.h
Thermo.o: /usr/X11R6.3/include/X11/RectObjP.h
Thermo.o: /usr/X11R6.3/include/X11/StringDefs.h ThermoP.h Thermo.h
Thermo.o: /usr/X11R6.3/include/X11/Xaw/SimpleP.h
Thermo.o: /usr/X11R6.3/include/X11/Xaw/Simple.h
Thermo.o: /usr/X11R6.3/include/X11/Xmu/Converters.h
Layout.o: /usr/X11R6.3/include/X11/IntrinsicP.h
Layout.o: /usr/X11R6.3/include/X11/Intrinsic.h
Layout.o: /usr/X11R6.3/include/X11/Xlib.h
Layout.o: /usr/local/lib/gcc-include/sys/types.h
Layout.o: /usr/local/lib/gcc-include/sys/stdtypes.h
Layout.o: /usr/include/sys/sysmacros.h /usr/X11R6.3/include/X11/X.h
Layout.o: /usr/X11R6.3/include/X11/Xfuncproto.h
Layout.o: /usr/X11R6.3/include/X11/Xosdefs.h
Layout.o: /usr/local/lib/gcc-include/stddef.h
Layout.o: /usr/X11R6.3/include/X11/Xutil.h
Layout.o: /usr/X11R6.3/include/X11/Xresource.h
Layout.o: /usr/local/lib/gcc-include/string.h /usr/X11R6.3/include/X11/Core.h
Layout.o: /usr/X11R6.3/include/X11/Composite.h
Layout.o: /usr/X11R6.3/include/X11/Constraint.h
Layout.o: /usr/X11R6.3/include/X11/Object.h
Layout.o: /usr/X11R6.3/include/X11/RectObj.h /usr/X11R6.3/include/X11/CoreP.h
Layout.o: /usr/X11R6.3/include/X11/CompositeP.h
Layout.o: /usr/X11R6.3/include/X11/ConstrainP.h
Layout.o: /usr/X11R6.3/include/X11/ObjectP.h
Layout.o: /usr/X11R6.3/include/X11/RectObjP.h
Layout.o: /usr/X11R6.3/include/X11/StringDefs.h
Layout.o: /usr/X11R6.3/include/X11/Xmu/Misc.h
Layout.o: /usr/X11R6.3/include/X11/Xmu/Converters.h LayoutP.h Layout.h
Layout.o: /usr/local/lib/gcc-include/ctype.h
Layout.o: /usr/local/lib/gcc-include/stdio.h
Layout.o: /usr/local/lib/gcc-include/stdarg.h
Layout.o: /usr/local/lib/gcc-include/va-sparc.h
laygram.o: /usr/X11R6.3/include/X11/Xlib.h
laygram.o: /usr/local/lib/gcc-include/sys/types.h
laygram.o: /usr/local/lib/gcc-include/sys/stdtypes.h
laygram.o: /usr/include/sys/sysmacros.h /usr/X11R6.3/include/X11/X.h
laygram.o: /usr/X11R6.3/include/X11/Xfuncproto.h
laygram.o: /usr/X11R6.3/include/X11/Xosdefs.h
laygram.o: /usr/local/lib/gcc-include/stddef.h
laygram.o: /usr/X11R6.3/include/X11/Xresource.h
laygram.o: /usr/local/lib/gcc-include/stdio.h
laygram.o: /usr/local/lib/gcc-include/stdarg.h
laygram.o: /usr/local/lib/gcc-include/va-sparc.h
laygram.o: /usr/X11R6.3/include/X11/IntrinsicP.h
laygram.o: /usr/X11R6.3/include/X11/Intrinsic.h
laygram.o: /usr/X11R6.3/include/X11/Xutil.h
laygram.o: /usr/local/lib/gcc-include/string.h
laygram.o: /usr/X11R6.3/include/X11/Core.h
laygram.o: /usr/X11R6.3/include/X11/Composite.h
laygram.o: /usr/X11R6.3/include/X11/Constraint.h
laygram.o: /usr/X11R6.3/include/X11/Object.h
laygram.o: /usr/X11R6.3/include/X11/RectObj.h
laygram.o: /usr/X11R6.3/include/X11/CoreP.h
laygram.o: /usr/X11R6.3/include/X11/CompositeP.h
laygram.o: /usr/X11R6.3/include/X11/ConstrainP.h
laygram.o: /usr/X11R6.3/include/X11/ObjectP.h
laygram.o: /usr/X11R6.3/include/X11/RectObjP.h
laygram.o: /usr/X11R6.3/include/X11/cursorfont.h
laygram.o: /usr/X11R6.3/include/X11/StringDefs.h
laygram.o: /usr/X11R6.3/include/X11/Xmu/Misc.h
laygram.o: /usr/X11R6.3/include/X11/Xmu/Converters.h LayoutP.h Layout.h
laylex.o: /usr/local/lib/gcc-include/stdio.h
laylex.o: /usr/local/lib/gcc-include/stdarg.h
laylex.o: /usr/local/lib/gcc-include/va-sparc.h
laylex.o: /usr/X11R6.3/include/X11/Xlib.h
laylex.o: /usr/local/lib/gcc-include/sys/types.h
laylex.o: /usr/local/lib/gcc-include/sys/stdtypes.h
laylex.o: /usr/include/sys/sysmacros.h /usr/X11R6.3/include/X11/X.h
laylex.o: /usr/X11R6.3/include/X11/Xfuncproto.h
laylex.o: /usr/X11R6.3/include/X11/Xosdefs.h
laylex.o: /usr/local/lib/gcc-include/stddef.h
laylex.o: /usr/X11R6.3/include/X11/Xresource.h
laylex.o: /usr/X11R6.3/include/X11/IntrinsicP.h
laylex.o: /usr/X11R6.3/include/X11/Intrinsic.h
laylex.o: /usr/X11R6.3/include/X11/Xutil.h
laylex.o: /usr/local/lib/gcc-include/string.h /usr/X11R6.3/include/X11/Core.h
laylex.o: /usr/X11R6.3/include/X11/Composite.h
laylex.o: /usr/X11R6.3/include/X11/Constraint.h
laylex.o: /usr/X11R6.3/include/X11/Object.h
laylex.o: /usr/X11R6.3/include/X11/RectObj.h /usr/X11R6.3/include/X11/CoreP.h
laylex.o: /usr/X11R6.3/include/X11/CompositeP.h
laylex.o: /usr/X11R6.3/include/X11/ConstrainP.h
laylex.o: /usr/X11R6.3/include/X11/ObjectP.h
laylex.o: /usr/X11R6.3/include/X11/RectObjP.h
laylex.o: /usr/X11R6.3/include/X11/StringDefs.h
laylex.o: /usr/local/lib/gcc-include/ctype.h LayoutP.h Layout.h laygram.h
CardsUtil.o: /usr/X11R6.3/include/X11/Intrinsic.h
CardsUtil.o: /usr/X11R6.3/include/X11/Xlib.h
CardsUtil.o: /usr/local/lib/gcc-include/sys/types.h
CardsUtil.o: /usr/local/lib/gcc-include/sys/stdtypes.h
CardsUtil.o: /usr/include/sys/sysmacros.h /usr/X11R6.3/include/X11/X.h
CardsUtil.o: /usr/X11R6.3/include/X11/Xfuncproto.h
CardsUtil.o: /usr/X11R6.3/include/X11/Xosdefs.h
CardsUtil.o: /usr/local/lib/gcc-include/stddef.h
CardsUtil.o: /usr/X11R6.3/include/X11/Xutil.h
CardsUtil.o: /usr/X11R6.3/include/X11/Xresource.h
CardsUtil.o: /usr/local/lib/gcc-include/string.h
CardsUtil.o: /usr/X11R6.3/include/X11/Core.h
CardsUtil.o: /usr/X11R6.3/include/X11/Composite.h
CardsUtil.o: /usr/X11R6.3/include/X11/Constraint.h
CardsUtil.o: /usr/X11R6.3/include/X11/Object.h
CardsUtil.o: /usr/X11R6.3/include/X11/RectObj.h
CardsUtil.o: /usr/X11R6.3/include/X11/StringDefs.h
CardsUtil.o: /usr/X11R6.3/include/X11/Xos.h /usr/include/fcntl.h
CardsUtil.o: /usr/local/lib/gcc-include/sys/fcntlcom.h
CardsUtil.o: /usr/local/lib/gcc-include/sys/stat.h
CardsUtil.o: /usr/local/lib/gcc-include/unistd.h
CardsUtil.o: /usr/local/lib/gcc-include/sys/time.h
CardsUtil.o: /usr/local/lib/gcc-include/time.h Cards.h Hand.h
CardsUtil.o: /usr/X11R6.3/include/X11/Xaw/Simple.h
CardsUtil.o: /usr/X11R6.3/include/X11/Xmu/Converters.h CardsUtil.h
SuitCards.o: /usr/X11R6.3/include/X11/Intrinsic.h
SuitCards.o: /usr/X11R6.3/include/X11/Xlib.h
SuitCards.o: /usr/local/lib/gcc-include/sys/types.h
SuitCards.o: /usr/local/lib/gcc-include/sys/stdtypes.h
SuitCards.o: /usr/include/sys/sysmacros.h /usr/X11R6.3/include/X11/X.h
SuitCards.o: /usr/X11R6.3/include/X11/Xfuncproto.h
SuitCards.o: /usr/X11R6.3/include/X11/Xosdefs.h
SuitCards.o: /usr/local/lib/gcc-include/stddef.h
SuitCards.o: /usr/X11R6.3/include/X11/Xutil.h
SuitCards.o: /usr/X11R6.3/include/X11/Xresource.h
SuitCards.o: /usr/local/lib/gcc-include/string.h
SuitCards.o: /usr/X11R6.3/include/X11/Core.h
SuitCards.o: /usr/X11R6.3/include/X11/Composite.h
SuitCards.o: /usr/X11R6.3/include/X11/Constraint.h
SuitCards.o: /usr/X11R6.3/include/X11/Object.h
SuitCards.o: /usr/X11R6.3/include/X11/RectObj.h
SuitCards.o: /usr/X11R6.3/include/X11/StringDefs.h
SuitCards.o: /usr/X11R6.3/include/X11/Xos.h /usr/include/fcntl.h
SuitCards.o: /usr/local/lib/gcc-include/sys/fcntlcom.h
SuitCards.o: /usr/local/lib/gcc-include/sys/stat.h
SuitCards.o: /usr/local/lib/gcc-include/unistd.h
SuitCards.o: /usr/local/lib/gcc-include/sys/time.h
SuitCards.o: /usr/local/lib/gcc-include/time.h ../Xkw/Cards.h Hand.h
SuitCards.o: /usr/X11R6.3/include/X11/Xaw/Simple.h
SuitCards.o: /usr/X11R6.3/include/X11/Xmu/Converters.h ../Xkw/SuitCards.h
SuitCards.o: ../Xkw/CardsUtil.h
Animate.o: /usr/X11R6.3/include/X11/Xlib.h
Animate.o: /usr/local/lib/gcc-include/sys/types.h
Animate.o: /usr/local/lib/gcc-include/sys/stdtypes.h
Animate.o: /usr/include/sys/sysmacros.h /usr/X11R6.3/include/X11/X.h
Animate.o: /usr/X11R6.3/include/X11/Xfuncproto.h
Animate.o: /usr/X11R6.3/include/X11/Xosdefs.h
Animate.o: /usr/local/lib/gcc-include/stddef.h
Animate.o: /usr/local/lib/gcc-include/math.h
Animate.o: /usr/local/lib/gcc-include/floatingpoint.h
Animate.o: /usr/local/lib/gcc-include/sys/ieeefp.h
Animate.o: /usr/X11R6.3/include/X11/Intrinsic.h
Animate.o: /usr/X11R6.3/include/X11/Xutil.h
Animate.o: /usr/X11R6.3/include/X11/Xresource.h
Animate.o: /usr/local/lib/gcc-include/string.h
Animate.o: /usr/X11R6.3/include/X11/Core.h
Animate.o: /usr/X11R6.3/include/X11/Composite.h
Animate.o: /usr/X11R6.3/include/X11/Constraint.h
Animate.o: /usr/X11R6.3/include/X11/Object.h
Animate.o: /usr/X11R6.3/include/X11/RectObj.h
Animate.o: /usr/X11R6.3/include/X11/StringDefs.h
Animate.o: /usr/X11R6.3/include/X11/Xos.h /usr/include/fcntl.h
Animate.o: /usr/local/lib/gcc-include/sys/fcntlcom.h
Animate.o: /usr/local/lib/gcc-include/sys/stat.h
Animate.o: /usr/local/lib/gcc-include/unistd.h
Animate.o: /usr/local/lib/gcc-include/sys/time.h
Animate.o: /usr/local/lib/gcc-include/time.h Cards.h Hand.h
Animate.o: /usr/X11R6.3/include/X11/Xaw/Simple.h
Animate.o: /usr/X11R6.3/include/X11/Xmu/Converters.h
Message.o: /usr/X11R6.3/include/X11/Intrinsic.h
Message.o: /usr/X11R6.3/include/X11/Xlib.h
Message.o: /usr/local/lib/gcc-include/sys/types.h
Message.o: /usr/local/lib/gcc-include/sys/stdtypes.h
Message.o: /usr/include/sys/sysmacros.h /usr/X11R6.3/include/X11/X.h
Message.o: /usr/X11R6.3/include/X11/Xfuncproto.h
Message.o: /usr/X11R6.3/include/X11/Xosdefs.h
Message.o: /usr/local/lib/gcc-include/stddef.h
Message.o: /usr/X11R6.3/include/X11/Xutil.h
Message.o: /usr/X11R6.3/include/X11/Xresource.h
Message.o: /usr/local/lib/gcc-include/string.h
Message.o: /usr/X11R6.3/include/X11/Core.h
Message.o: /usr/X11R6.3/include/X11/Composite.h
Message.o: /usr/X11R6.3/include/X11/Constraint.h
Message.o: /usr/X11R6.3/include/X11/Object.h
Message.o: /usr/X11R6.3/include/X11/RectObj.h
Message.o: /usr/X11R6.3/include/X11/StringDefs.h
Message.o: /usr/X11R6.3/include/X11/Xos.h /usr/include/fcntl.h
Message.o: /usr/local/lib/gcc-include/sys/fcntlcom.h
Message.o: /usr/local/lib/gcc-include/sys/stat.h
Message.o: /usr/local/lib/gcc-include/unistd.h
Message.o: /usr/local/lib/gcc-include/sys/time.h
Message.o: /usr/local/lib/gcc-include/time.h
Message.o: /usr/X11R6.3/include/X11/Xaw/Label.h
Message.o: /usr/X11R6.3/include/X11/Xaw/Simple.h
Message.o: /usr/X11R6.3/include/X11/Xmu/Converters.h
Message.o: /usr/X11R6.3/include/X11/Xaw/Cardinals.h Cards.h Hand.h
Message.o: /usr/local/lib/gcc-include/varargs.h
Message.o: /usr/local/lib/gcc-include/va-sparc.h
Pad.o: /usr/X11R6.3/include/X11/IntrinsicP.h
Pad.o: /usr/X11R6.3/include/X11/Intrinsic.h /usr/X11R6.3/include/X11/Xlib.h
Pad.o: /usr/local/lib/gcc-include/sys/types.h
Pad.o: /usr/local/lib/gcc-include/sys/stdtypes.h /usr/include/sys/sysmacros.h
Pad.o: /usr/X11R6.3/include/X11/X.h /usr/X11R6.3/include/X11/Xfuncproto.h
Pad.o: /usr/X11R6.3/include/X11/Xosdefs.h /usr/local/lib/gcc-include/stddef.h
Pad.o: /usr/X11R6.3/include/X11/Xutil.h /usr/X11R6.3/include/X11/Xresource.h
Pad.o: /usr/local/lib/gcc-include/string.h /usr/X11R6.3/include/X11/Core.h
Pad.o: /usr/X11R6.3/include/X11/Composite.h
Pad.o: /usr/X11R6.3/include/X11/Constraint.h
Pad.o: /usr/X11R6.3/include/X11/Object.h /usr/X11R6.3/include/X11/RectObj.h
Pad.o: /usr/X11R6.3/include/X11/CoreP.h /usr/X11R6.3/include/X11/CompositeP.h
Pad.o: /usr/X11R6.3/include/X11/ConstrainP.h
Pad.o: /usr/X11R6.3/include/X11/ObjectP.h /usr/X11R6.3/include/X11/RectObjP.h
Pad.o: /usr/X11R6.3/include/X11/StringDefs.h /usr/X11R6.3/include/X11/Xatom.h
Pad.o: PadP.h Pad.h /usr/X11R6.3/include/X11/Xaw/SimpleP.h
Pad.o: /usr/X11R6.3/include/X11/Xaw/Simple.h
Pad.o: /usr/X11R6.3/include/X11/Xmu/Converters.h
kgames-1.0/Xkw/Layout.ad 100644 20717 2432 1034 6121566726 13741 0 ustar root daemon *allowShellResize: true
*label1.label: Label 1 Label 1
*label2.label: Label 2 Label 2
*label3.label: Label 3 Label 3
*cards.numRows: 12
*cards.numCols: 2
*cards.overlap: vertical
*cards.smallCards: false
*cards.rowsHint: true
*layout: vertical { \
NormalSpace = (25 % of height cards) \
NormalAdjust = 25% \
horizontal {\
$NormalSpace < +infinity -$NormalSpace > \
label1 label2 label3 \
$NormalSpace < +infinity -$NormalSpace > \
} \
horizontal {\
cards < * +infinity -$NormalAdjust > \
0 < +infinity > \
} \
}
kgames-1.0/Xkw/Layout.c 100644 20717 2432 62062 6121566726 13627 0 ustar root daemon /*
* $XConsortium: Layout.c,v 1.1 91/09/13 18:51:44 keith Exp $
*
* Copyright 1991 Massachusetts Institute of Technology
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, 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 M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
* 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: Keith Packard, MIT X Consortium
*/
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/Xmu/Misc.h>
#include <X11/Xmu/Converters.h>
#include "LayoutP.h"
#include <ctype.h>
#include <stdio.h>
/*****************************************************************************
*
* Full instance record declaration
*
****************************************************************************/
#define offset(field) XtOffsetOf(LayoutRec, layout.field)
static XtResource resources[] = {
{XtNlayout, XtCLayout, XtRLayout, sizeof (BoxPtr),
offset(layout), XtRLayout, NULL },
{XtNdebug, XtCBoolean, XtRBoolean, sizeof(Boolean),
offset(debug), XtRImmediate, (XtPointer) FALSE},
};
#undef offset
static void ClassInitialize(), Initialize();
static void Resize();
static Boolean SetValues();
static XtGeometryResult GeometryManager();
static void ChangeManaged();
static void InsertChild();
static XtGeometryResult QueryGeometry ();
static Boolean ChildSetValues();
static Widget Widg ();
static void GetDesiredSize ();
static void LayoutLayout ();
static void LayoutGetNaturalSize ();
static void LayoutFreeLayout ();
#ifdef MOTIF
#define SuperClass ((ConstraintWidgetClass)&xmManagerClassRec)
#else
#define SuperClass ((ConstraintWidgetClass)&constraintClassRec)
#endif
LayoutClassRec layoutClassRec = {
{
/* core class fields */
/* superclass */ (WidgetClass) SuperClass,
/* class name */ "Layout",
/* size */ sizeof(LayoutRec),
/* class_initialize */ ClassInitialize,
/* class_part init */ NULL,
/* class_inited */ FALSE,
/* initialize */ Initialize,
/* initialize_hook */ NULL,
/* realize */ XtInheritRealize,
/* actions */ NULL,
/* num_actions */ 0,
/* resources */ resources,
/* resource_count */ XtNumber(resources),
/* xrm_class */ NULLQUARK,
/* compress_motion */ NULL,
/* compress_exposure */ NULL,
/* compress_enterleave*/ NULL,
/* visible_interest */ FALSE,
/* destroy */ NULL,
/* resize */ Resize,
/* expose */ NULL,
/* set_values */ SetValues,
/* set_values_hook */ NULL,
/* set_values_almost */ XtInheritSetValuesAlmost,
/* get_values_hook */ NULL,
/* accept_focus */ NULL,
/* version */ XtVersion,
/* callback_private */ NULL,
/* tm_table */ NULL,
/* query_geometry */ QueryGeometry,
/* display_accelerator*/ XtInheritDisplayAccelerator,
/* extension */ NULL
}, {
/* composite class fields */
/* geometry_manager */ GeometryManager,
/* change_managed */ ChangeManaged,
/* insert_child */ InsertChild,
/* delete_child */ XtInheritDeleteChild,
/* extension */ NULL
}, {
/* constraint class fields */
/* subresources */ NULL,
/* subresource_count */ 0,
/* constraint_size */ sizeof(LayoutConstraintsRec),
/* initialize */ NULL,
/* destroy */ NULL,
/* set_values */ NULL,
/* extension */ NULL
},
#ifdef MOTIF
/* manager class fields */
{
/* stolen from the one minute manager's Template.c */
XtInheritTranslations, /* translations */
NULL, /* syn_resources */
0, /* num_syn_resources */
NULL, /* syn_constraint_resources */
0, /* num_syn_constraint_resources */ XmInheritParentProcess, /* parent_process */
NULL, /* extension */
},
#endif /* MOTIF */
};
WidgetClass layoutWidgetClass = (WidgetClass) &layoutClassRec;
/************************************************************
*
* Semi-public routines.
*
************************************************************/
/* Function Name: ClassInitialize
* Description: The Layout widgets class initialization proc.
* Arguments: none.
* Returns: none.
*/
/*ARGSUSED*/
static Boolean
CvtStringToLayout (dpy, args, num_args, from, to, converter_data)
Display *dpy;
XrmValue *args;
Cardinal *num_args;
XrmValue *from, *to;
XtPointer *converter_data;
{
LayYYsetsource ((char *) from->addr);
LayYYsetdest ((BoxPtr *) to->addr);
if (LayYYparse () == 0)
return TRUE;
else
return FALSE;
}
/*ARGSUSED*/
static void
DisposeLayout (app, to, data, args, num_args)
XtAppContext app;
XrmValue *to;
XtPointer data;
XrmValuePtr args;
Cardinal *num_args;
{
LayoutFreeLayout (* (LayoutPtr *) to->addr);
}
static void
ClassInitialize()
{
XtSetTypeConverter ( XtRString, XtRLayout, CvtStringToLayout,
NULL, (Cardinal)0, XtCacheNone,
DisposeLayout );
}
/*ARGSUSED*/
static XtGeometryResult GeometryManager(child, request, reply)
Widget child;
XtWidgetGeometry *request, *reply;
{
LayoutWidget w = (LayoutWidget) XtParent(child);
SubInfoPtr p = SubInfo(child);
int bw;
Bool changed, bwChanged;
bw = p->naturalBw;
changed = FALSE;
bwChanged = FALSE;
if (request->request_mode & CWBorderWidth &&
request->border_width != child->core.border_width)
{
p->naturalBw = bw;
bw = request->border_width;
changed = TRUE;
bwChanged = TRUE;
}
if (bwChanged || request->request_mode & CWWidth &&
request->width != child->core.width)
{
p->naturalSize[LayoutHorizontal] = request->width + bw * 2;
changed = TRUE;
}
if (bwChanged || request->request_mode & CWHeight &&
request->height != child->core.height)
{
p->naturalSize[LayoutVertical] = request->height + bw * 2;
changed = TRUE;
}
if (changed)
LayoutLayout (w, TRUE);
return XtGeometryDone;
}
/* ARGSUSED */
static void Initialize(request, new)
Widget request, new;
{
/* LayoutWidget w = (LayoutWidget)new; */
}
static void ChangeManaged(gw)
Widget gw;
{
LayoutWidget w = (LayoutWidget) gw;
Widget *children;
ForAllChildren (w, children)
GetDesiredSize (*children);
LayoutLayout ((LayoutWidget) w, TRUE);
}
static void
GetDesiredSize (child)
Widget child;
{
XtWidgetGeometry desired;
SubInfoPtr p;
XtQueryGeometry (child, (XtWidgetGeometry *) NULL, &desired);
p = SubInfo (child);
p->naturalBw = desired.border_width;
p->naturalSize[LayoutHorizontal] = desired.width + desired.border_width * 2;
p->naturalSize[LayoutVertical] = desired.height + desired.border_width * 2;
}
static void InsertChild (child)
Widget child;
{
SubInfoPtr p;
int bw;
(*SuperClass->composite_class.insert_child) (child);
GetDesiredSize (child);
}
static void
Resize(gw)
Widget gw;
{
LayoutLayout ((LayoutWidget) gw, FALSE);
}
/* ARGSUSED */
static Boolean
SetValues(gold, greq, gnew)
Widget gold, greq, gnew;
{
LayoutWidget old = (LayoutWidget) gold,
req = (LayoutWidget) greq,
new = (LayoutWidget) gnew;
Boolean refigure = FALSE;
if (old->layout.layout != new->layout.layout)
LayoutLayout (new, TRUE);
return FALSE;
} /* SetValues */
static XtGeometryResult
QueryGeometry (gw, request, prefered_return)
Widget gw;
XtWidgetGeometry *request, *prefered_return;
{
LayoutWidget w = (LayoutWidget) gw;
XtGeometryResult result;
XtWidgetGeometry prefered_size;
if (request && !(request->request_mode & CWWidth|CWHeight))
return XtGeometryYes;
LayoutGetNaturalSize (w, &prefered_size.width, &prefered_size.height);
prefered_return->request_mode = 0;
result = XtGeometryYes;
if (!request) {
prefered_return->width = prefered_size.width;
prefered_return->height= prefered_size.height;
if (prefered_size.width != w->core.width) {
prefered_return->request_mode |= CWWidth;
result = XtGeometryAlmost;
}
if (prefered_size.height != w->core.height) {
prefered_return->request_mode |= CWHeight;
result = XtGeometryAlmost;
}
} else {
if (request->request_mode & CWWidth) {
if (prefered_size.width > request->width)
{
if (prefered_size.width == w->core.width)
result = XtGeometryNo;
else if (result != XtGeometryNo) {
result = XtGeometryAlmost;
prefered_return->request_mode |= CWWidth;
prefered_return->width = prefered_size.width;
}
}
}
if (request->request_mode & CWHeight) {
if (prefered_size.height > request->height)
{
if (prefered_size.height == w->core.height)
result = XtGeometryNo;
else if (result != XtGeometryNo) {
result = XtGeometryAlmost;
prefered_return->request_mode |= CWHeight;
prefered_return->height = prefered_size.height;
}
}
}
}
return result;
}
/*
* Layout section. Exports LayoutGetNaturalSize and
* LayoutLayout to above section
*/
static void
PrintGlue (g)
GlueRec g;
{
if (g.order == 0 || g.value != 1.0)
printf ("%g", g.value);
if (g.order > 0)
{
printf (" inf");
if (g.order > 1);
printf (" %d", g.order);
}
}
static void
PrintDirection (dir)
LayoutDirection dir;
{
switch (dir) {
case LayoutHorizontal:
printf ("horizontal");
break;
case LayoutVertical:
printf ("vertical");
break;
default:
printf ("Unknown layout direction %d\n", dir);
break;
}
}
static void
TabTo(level)
int level;
{
while (level--)
printf (" ");
}
static void
PrintBox (box, level)
BoxPtr box;
{
BoxPtr child;
Widget w;
SubInfoPtr p;
TabTo (level);
printf ("< ");
printf (" + "); PrintGlue (box->params.stretch[LayoutHorizontal]);
printf (" - "); PrintGlue (box->params.shrink[LayoutHorizontal]);
printf (" * ");
printf (" + "); PrintGlue (box->params.stretch[LayoutVertical]);
printf (" - "); PrintGlue (box->params.shrink[LayoutVertical]);
printf (" >");
printf (" size: %d x %d", box->size[0], box->size[1]);
printf (" natural: %d x %d ", box->natural[0], box->natural[1]);
switch (box->type) {
case BoxBox:
PrintDirection (box->u.box.dir);
printf ("\n");
for (child = box->u.box.firstChild; child; child = child->nextSibling)
PrintBox (child, level+1);
break;
case WidgetBox:
printf (" %s\n", XrmQuarkToString (box->u.widget.quark));
break;
case GlueBox:
printf (" glue\n");
break;
case VariableBox:
printf (" variable %s\n", XrmQuarkToString (box->u.variable.quark));
break;
}
}
ExprPtr
LookupVariable (child, quark)
BoxPtr child;
XrmQuark quark;
{
BoxPtr parent, box;
while (parent = child->parent)
{
for (box = parent->u.box.firstChild;
box != child;
box = box->nextSibling)
{
if (box->type == VariableBox && box->u.variable.quark == quark)
return box->u.variable.expr;
}
child = parent;
}
return 0;
}
static double
Evaluate (l, box, expr, natural)
LayoutWidget l;
BoxPtr box;
ExprPtr expr;
double natural;
{
double left, right, down;
Widget widget;
SubInfoPtr info;
switch (expr->type) {
case Constant:
return expr->u.constant;
case Binary:
left = Evaluate (l, box, expr->u.binary.left, natural);
right = Evaluate (l, box, expr->u.binary.right, natural);
switch (expr->u.binary.op) {
case Plus:
return left + right;
case Minus:
return left - right;
case Times:
return left * right;
case Divide:
return left / right;
case Percent:
return right * left / 100.0;
case Minimum:
if (right < left)
return right;
return left;
case Maximum:
if (right > left)
return right;
return left;
}
case Unary:
down = Evaluate (l, box, expr->u.unary.down, natural);
switch (expr->u.unary.op) {
case Percent:
return natural * down / 100.0;
case Minus:
return -down;
case Minimum:
case Maximum:
return down;
}
case Width:
widget = QuarkToWidget (l, expr->u.width);
if (!widget)
return 0;
info = SubInfo (widget);
return info->naturalSize[LayoutHorizontal];
case Height:
widget = QuarkToWidget (l, expr->u.height);
if (!widget)
return 0;
info = SubInfo (widget);
return info->naturalSize[LayoutVertical];
case Variable:
expr = LookupVariable (box, expr->u.variable);
if (!expr)
{
char buf[256];
sprintf (buf, "Layout: undefined variable %s\n",
XrmQuarkToString (expr->u.variable));
XtError (buf);
return 0.0;
}
return Evaluate (l, box, expr, natural);
}
}
static void
DisposeExpr (expr)
ExprPtr expr;
{
if (!expr)
return;
switch (expr->type) {
case Constant:
break;
case Binary:
DisposeExpr (expr->u.binary.left);
DisposeExpr (expr->u.binary.right);
break;
case Unary:
DisposeExpr (expr->u.unary.down);
break;
case Width:
break;
case Height:
break;
}
Dispose (expr);
}
#define CheckGlue(l, box, glue, n) { \
if (glue.expr) \
glue.value = Evaluate (l, box, glue.expr, n); \
if (glue.order == 0 && glue.value == 0) \
glue.order = -1; \
else if (glue.order == -1 && glue.value != 0) \
glue.order = 0; \
}
#define DoStretch(l, box, dir) \
CheckGlue (l, box, box->params.stretch[dir], (double) box->natural[dir]);
#define DoShrink(l, box, dir) \
CheckGlue (l, box, box->params.shrink[dir], (double) box->natural[dir])
/* compute the natural sizes of a box */
static void
ComputeNaturalSizes (l, box, dir)
LayoutWidget l;
BoxPtr box;
LayoutDirection dir;
{
BoxPtr child;
Widget w;
SubInfoPtr info;
int minStretchOrder, minShrinkOrder;
int shrinkSize;
int stretchSize;
LayoutDirection thisDir;
switch (box->type) {
case WidgetBox:
w = box->u.widget.widget = QuarkToWidget (l, box->u.widget.quark);
if (!w)
{
box->natural[LayoutHorizontal] = 0;
box->natural[LayoutVertical] = 0;
}
else
{
info = SubInfo (w);
box->natural[LayoutHorizontal] = info->naturalSize[LayoutHorizontal];
box->natural[LayoutVertical] = info->naturalSize[LayoutVertical];
}
DoStretch (l, box, dir);
DoShrink (l, box, dir);
DoStretch (l, box, !dir);
DoShrink (l, box, !dir);
break;
case GlueBox:
if (box->u.glue.expr[1])
{
box->natural[LayoutHorizontal] = Evaluate(l, box, box->u.glue.expr[LayoutHorizontal], 0.0);
box->natural[LayoutVertical] = Evaluate(l, box, box->u.glue.expr[LayoutVertical], 0.0);
DoStretch (l, box, !dir);
DoShrink (l, box, !dir);
}
else
{
box->natural[dir] = Evaluate (l, box, box->u.glue.expr[0], 0.0);
box->natural[!dir] = 0;
}
DoStretch (l, box, dir);
DoShrink (l, box, dir);
break;
case BoxBox:
thisDir = box->u.box.dir;
box->natural[0] = 0;
box->natural[1] = 0;
minStretchOrder = 100000;
minShrinkOrder = 100000;
ZeroGlue (box->params.shrink[thisDir]);
ZeroGlue (box->params.stretch[thisDir]);
box->params.shrink[!thisDir].order = 100000;
box->params.stretch[!thisDir].order = 100000;
for (child = box->u.box.firstChild; child; child = child->nextSibling)
{
if (child->type == VariableBox)
continue;
ComputeNaturalSizes (l, child, thisDir);
/*
* along box axis:
* normal size += child normal size
* shrink += child shrink
* stretch += child stretch
*/
box->natural[thisDir] += child->natural[thisDir];
AddGlue (box->params.shrink[thisDir],
box->params.shrink[thisDir],
child->params.shrink[thisDir]);
AddGlue (box->params.stretch[thisDir],
box->params.stretch[thisDir],
child->params.stretch[thisDir]);
/*
* normal to box axis:
* normal size = maximum child normal size of minimum shrink order
* shrink = difference between normal size and minimum shrink
* stretch = minimum child stretch
*/
if (box->natural[!thisDir] >= child->natural[!thisDir])
{
if (child->params.stretch[!thisDir].order < minShrinkOrder)
{
box->natural[!thisDir] = child->natural[!thisDir];
minStretchOrder = child->params.stretch[!thisDir].order;
if (child->params.shrink[!thisDir].order < minShrinkOrder)
minShrinkOrder = child->params.shrink[!thisDir].order;
}
}
else
{
if (child->params.shrink[!thisDir].order <= minStretchOrder)
{
box->natural[!thisDir] = child->natural[!thisDir];
minShrinkOrder = child->params.shrink[!thisDir].order;
if (child->params.stretch[!thisDir].order < minStretchOrder)
minStretchOrder = child->params.stretch[!thisDir].order;
}
}
MinGlue (box->params.stretch[!thisDir],
box->params.stretch[!thisDir],
child->params.stretch[!thisDir]);
MinGlue (box->params.shrink[!thisDir],
box->params.shrink[!thisDir],
child->params.shrink[!thisDir]);
}
if (box->params.shrink[!thisDir].order <= 0)
{
int minSize;
int largestMinSize;
largestMinSize = 0;
for (child = box->u.box.firstChild; child; child = child->nextSibling)
{
if (child->type == VariableBox)
continue;
if (child->params.shrink[!thisDir].order <= 0)
{
minSize = child->natural[!thisDir] -
child->params.shrink[!thisDir].value;
if (minSize > largestMinSize)
largestMinSize = minSize;
}
}
box->params.shrink[!thisDir].value = box->natural[!thisDir] -
largestMinSize;
if (box->params.shrink[!thisDir].value == 0)
box->params.shrink[!thisDir].order = -1;
else
box->params.shrink[!thisDir].order = 0;
}
}
}
/* given the boxs geometry, set the geometry of the pieces */
#define GluePart(a,b,dist) ((a) ? ((int) (((a) * (dist)) / (b) + \
((dist >= 0) ? 0.5 : -0.5))) : 0)
static Bool
ComputeSizes (box)
BoxPtr box;
{
LayoutDirection dir;
BoxPtr child;
GlueRec stretch;
GlueRec shrink;
GlueRec totalGlue[2];
double remainingGlue;
GluePtr glue;
int base;
int size;
int totalSizes;
int totalChange[2];
int change;
int remainingChange;
Bool shrinking;
Bool happy;
int i;
int maxGlue;
dir = box->u.box.dir;
size = box->size[dir];
stretch = box->params.stretch[dir];
shrink = box->params.shrink[dir];
/* pick the correct adjustment parameters based on the change direction */
totalChange[0] = size - box->natural[dir];
shrinking = totalChange[0] < 0;
totalChange[1] = 0;
totalGlue[1].order = 100000;
totalGlue[1].value = 0;
maxGlue = 1;
if (shrinking)
{
totalGlue[0] = shrink;
/* for first-order infinites, shrink it to zero and then
* shrink the zero-orders
*/
if (shrink.order == 1) {
totalSizes = 0;
remainingGlue = 0;
for (child = box->u.box.firstChild;
child;
child = child->nextSibling)
{
if (child->type == VariableBox)
continue;
switch (child->params.shrink[dir].order) {
case 0:
remainingGlue += child->params.shrink[dir].value;
break;
case 1:
totalSizes += child->natural[dir];
break;
}
}
/*
* If the amount of first-order shrinkability is less
* than the change in size, shrink the zero-order objects
* by the difference
*/
if (totalSizes < -totalChange[0])
{
totalGlue[1] = shrink;
totalGlue[0].order = 0;
totalGlue[0].value = remainingGlue;
totalChange[1] = -totalSizes;
totalChange[0] = totalChange[0] - totalChange[1];
/*
* whoa -- running out of both zero and first order
* shrink; shrink zero by max, shrink first by rest
*/
if (remainingGlue < -totalChange[0])
{
totalChange[1] += (totalChange[0] + remainingGlue);
totalChange[0] = -remainingGlue;
}
maxGlue = 2;
}
}
if (totalGlue[0].order <= 0 &&
-totalChange[0] > totalGlue[0].value)
{
totalChange[0] = -totalGlue[0].value;
}
}
else
totalGlue[0] = stretch;
/* adjust each box */
totalSizes = 0;
remainingGlue = totalGlue[0].value + totalGlue[1].value;
remainingChange = totalChange[0] + totalChange[1];
happy = True;
for (child = box->u.box.firstChild; child; child = child->nextSibling)
{
if (child->type == VariableBox)
continue;
if (shrinking)
glue = &child->params.shrink[dir];
else
glue = &child->params.stretch[dir];
child->size[dir] = child->natural[dir];
for (i = 0; i < maxGlue; i++)
{
if (glue->order == totalGlue[i].order)
{
remainingGlue -= glue->value;
if (remainingGlue <= 0)
change = remainingChange;
else
change = GluePart (glue->value,
totalGlue[i].value,
totalChange[i]);
child->size[dir] += change;
remainingChange -= change;
}
}
child->size[!dir] = box->size[!dir];
totalSizes += child->size[dir];
if (child->type == BoxBox)
if (!ComputeSizes (child))
happy = False;
}
return totalSizes == box->size[dir] && happy;
}
static void
SetSizes (box, x, y)
BoxPtr box;
Position x, y;
{
BoxPtr child;
int width, height;
int bw;
Widget w;
SubInfoPtr info;
switch (box->type) {
case WidgetBox:
w = box->u.widget.widget;
if (w)
{
info = (SubInfoPtr) w->core.constraints;
width = box->size[LayoutHorizontal];
height = box->size[LayoutVertical];
bw = info->naturalBw;
width -= bw * 2;
height -= bw * 2;
/* Widgets which grow too small are placed off screen */
if (width <= 0 || height <= 0)
{
width = 1;
height = 1;
bw = 0;
x = -1;
y = -1;
}
XtConfigureWidget (w, x, y, width, height, bw);
}
break;
case GlueBox:
break;
case BoxBox:
for (child = box->u.box.firstChild; child; child = child->nextSibling)
{
if (child->type == VariableBox)
continue;
SetSizes (child, x, y);
if (box->u.box.dir == LayoutHorizontal)
x += child->size[LayoutHorizontal];
else
y += child->size[LayoutVertical];
}
break;
}
}
static void
LayoutFreeLayout (box)
BoxPtr box;
{
BoxPtr child, next;
switch (box->type) {
case BoxBox:
for (child = box->u.box.firstChild; child; child = next)
{
next = child->nextSibling;
LayoutFreeLayout (child);
}
break;
case GlueBox:
DisposeExpr (box->u.glue.expr[LayoutHorizontal]);
DisposeExpr (box->u.glue.expr[LayoutVertical]);
break;
}
DisposeExpr (box->params.stretch[LayoutHorizontal].expr);
DisposeExpr (box->params.shrink[LayoutHorizontal].expr);
DisposeExpr (box->params.stretch[LayoutVertical].expr);
DisposeExpr (box->params.shrink[LayoutVertical].expr);
Dispose (box);
}
static void
LayoutGetNaturalSize (l, widthp, heightp)
LayoutWidget l;
Dimension *widthp, *heightp;
{
BoxPtr box;
SubInfoPtr p;
Widget child, *children;
XtWidgetGeometry desired;
box = l->layout.layout;
if (box)
{
ComputeNaturalSizes (l, box, LayoutHorizontal);
*widthp = box->natural[LayoutHorizontal];
*heightp = box->natural[LayoutVertical];
}
else
{
*widthp = 0;
*heightp = 0;
}
}
static void
LayoutLayout (l, attemptResize)
LayoutWidget l;
Bool attemptResize;
{
BoxPtr box;
Dimension width, height;
Dimension prefered_width, prefered_height;
box = l->layout.layout;
if (!box)
return;
LayoutGetNaturalSize (l, &prefered_width, &prefered_height);
if (l->core.width == 0 || l->core.height == 0)
{
l->core.width = prefered_width;
l->core.height = prefered_height;
}
box->size[LayoutHorizontal] = l->core.width;
box->size[LayoutVertical] = l->core.height;
if (!ComputeSizes (box) && attemptResize)
{
XtMakeResizeRequest ((Widget) l,
prefered_width, prefered_height,
NULL, NULL);
if (l->core.width != box->size[LayoutHorizontal] ||
l->core.height != box->size[LayoutVertical])
{
box->size[LayoutHorizontal] = l->core.width;
box->size[LayoutVertical] = l->core.height;
ComputeSizes (box);
}
}
if (l->layout.debug)
{
PrintBox (box, 0);
fflush (stdout);
}
SetSizes (box, 0, 0);
}
kgames-1.0/Xkw/Layout.h 100644 20717 2432 6352 6121566726 13614 0 ustar root daemon /*
* $XConsortium: Layout.h,v 1.2 92/01/22 18:03:05 keith Exp $
*
* Copyright 1991 Massachusetts Institute of Technology
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, 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 M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
* 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: Keith Packard, MIT X Consortium
*/
#ifndef _Layout_h
#define _Layout_h
#include <X11/Constraint.h>
#include <X11/Xfuncproto.h>
/****************************************************************
*
* Layout Widget (SubClass of CompositeClass)
*
****************************************************************/
/* RESOURCES:
Name Class RepType Default Value
---- ----- ------- -------------
background Background Pixel XtDefaultBackground
border BorderColor Pixel XtDefaultForeground
borderWidth BorderWidth Dimension 1
cursor Cursor Cursor None
destroyCallback Callback Pointer NULL
height Height Dimension 0
mappedWhenManaged MappedWhenManaged Boolean True
sensitive Sensitive Boolean True
width Width Dimension 0
x Position Position 0
y Position Position 0
layout Layout Layout NULL
*/
/*
* Syntax of layout resource
*
* *layout:\
* <widget-name>.<edge>,<widget-name>.<edge>: distance + stretch-factor\n\
* ...
* where the null widget-name is taken to be the Layout widget
*
* e.g:
*
* *label-1.hStretch: 0
* *label-2.vStretch: 1
* *layout:\
* .left, label-1.left: 10 + 0\n\
* label-1.right, label-2.left: 10 + 1\n\
* label-2.right, .right: 10 + 0
*
* This layout causes label-1 to be set 10 pixels from the left edge
* and be whatever size the label widget requests, while label-2 will
* be set 10 pixels from the right edge, and take up half of the remaining
* space to 10 pixels from the right edge of label-1.
*/
/* New Fields */
#define XtNlayout "layout"
#define XtCLayout "Layout"
#define XtRLayout "Layout"
#define XtNdebug "debug"
/* Class record constant */
extern WidgetClass layoutWidgetClass;
typedef struct _LayoutClassRec *LayoutWidgetClass;
typedef struct _LayoutRec *LayoutWidget;
#endif /* _Layout_h */
/* DON'T ADD STUFF AFTER THIS #endif */
kgames-1.0/Xkw/LayoutP.h 100644 20717 2432 13174 6121566726 13754 0 ustar root daemon /*
* $XConsortium: LayoutP.h,v 1.2 92/01/22 18:03:08 keith Exp $
*
* Copyright 1991 Massachusetts Institute of Technology
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, 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 M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
* 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: Keith Packard, MIT X Consortium
*/
#ifndef _LayoutP_h
#define _LayoutP_h
#include "Layout.h"
#ifdef MOTIF
#include <Xm/ManagerP.h>
#endif
#define GlueEqual(a,b) ((a).order == (b).order && (a).value == (b).value)
#define AddGlue(r,a,b) if (a.order == b.order) { \
r.order = a.order; \
r.value = a.value + b.value; \
} else { \
if (a.order > b.order) \
r = a; \
else \
r = b; \
}
#define MinGlue(r,a,b) if (a.order == b.order) { \
r.order = a.order; \
if (a.value > b.value) \
r.value = b.value; \
else \
r.value = a.value; \
} else { \
if (a.order > b.order) \
r = b; \
else \
r = a; \
}
#define SubGlue(r,a,b) if (a.order == b.order) { \
r.order = a.order; \
r.value = a.value - b.value; \
} else { \
if (a.order > b.order) \
r = a; \
else { \
r.order = b.order; \
r.value = -b.value; \
} \
}
#define ZeroGlue(g) ((g).value = 0, (g).order = -1, (g).expr = 0)
#define IsZeroGlue(g) ((g).value == 0)
#define QuarkToWidget(l,q) XtNameToWidget((Widget) l, \
(char *) XrmQuarkToString(q));
typedef enum _BoxType { BoxBox, WidgetBox, GlueBox, VariableBox } BoxType;
typedef enum _LayoutDirection {
LayoutHorizontal = 0, LayoutVertical = 1
} LayoutDirection;
typedef enum _Operator {
Plus, Minus, Times, Divide, Percent, Minimum, Maximum
} Operator;
typedef enum _ExprType {
Constant,
Binary,
Unary,
Width,
Height,
Variable
} ExprType;
typedef struct _Expr *ExprPtr;
typedef struct _Expr {
ExprType type;
union {
double constant;
struct {
Operator op;
ExprPtr left, right;
} binary;
struct {
Operator op;
ExprPtr down;
} unary;
XrmQuark width;
XrmQuark height;
XrmQuark variable;
} u;
} ExprRec;
typedef struct _Glue {
int order;
double value;
ExprPtr expr;
} GlueRec, *GluePtr;
typedef struct _BoxParams {
GlueRec stretch[2];
GlueRec shrink[2];
} BoxParamsRec, *BoxParamsPtr;
typedef struct _Box *BoxPtr;
typedef BoxPtr LayoutPtr;
typedef struct _Box {
BoxPtr nextSibling;
BoxPtr parent;
BoxParamsRec params;
int size[2];
int natural[2];
BoxType type;
union {
struct {
BoxPtr firstChild;
LayoutDirection dir;
} box;
struct {
XrmQuark quark;
Widget widget;
} widget;
struct {
ExprPtr expr[2];
} glue;
struct {
XrmQuark quark;
ExprPtr expr;
} variable;
} u;
} BoxRec;
typedef struct _SubInfo {
int naturalSize[2];
int naturalBw;
} SubInfoRec, *SubInfoPtr;
#define New(t) (t *) malloc(sizeof (t))
#define Dispose(p) free((char *) p)
#define Some(t,n) (t*) malloc(sizeof(t) * n)
#define More(p,t,n) ((p)? (t *) realloc((char *) p, sizeof(t)*n):Some(t,n)
#define ForAllChildren(pw, childP) \
for ( (childP) = (pw)->composite.children ; \
(childP) < (pw)->composite.children + (pw)->composite.num_children ; \
(childP)++ ) if (!XtIsManaged(*childP)) ; else
/*********************************************************************
*
* Layout Widget Private Data
*
*********************************************************************/
/* New fields for the Layout widget class record */
typedef struct _LayoutClassPart {
int foo; /* keep compiler happy. */
} LayoutClassPart;
/* Full Class record declaration */
typedef struct _LayoutClassRec {
CoreClassPart core_class;
CompositeClassPart composite_class;
ConstraintClassPart constraint_class;
#ifdef MOTIF
XmManagerClassPart manager_class;
#endif
LayoutClassPart layout_class;
} LayoutClassRec;
extern LayoutClassRec layoutClassRec;
typedef struct _LayoutConstraintsRec {
SubInfoRec layout;
} LayoutConstraintsRec, *LayoutConstraints;
#define SubInfo(w) (&(((LayoutConstraints) (w)->core.constraints)->layout))
/* New Fields for the Layout widget record */
typedef struct {
/* resources */
LayoutPtr layout;
Boolean debug;
} LayoutPart;
/**************************************************************************
*
* Full instance record declaration
*
**************************************************************************/
typedef struct _LayoutRec {
CorePart core;
CompositePart composite;
ConstraintPart constraint;
#ifdef MOTIF
XmManagerPart manager;
#endif
LayoutPart layout;
} LayoutRec;
#endif
kgames-1.0/Xkw/Message.c 100644 20717 2432 10033 6121566727 13726 0 ustar root daemon /*
* $NCD$
*
* Copyright 1992 Network Computing Devices
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, 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 NCD. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. NCD. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
* 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: Keith Packard, Network Computing Devices
*/
# include <X11/Intrinsic.h>
# include <X11/StringDefs.h>
# include <X11/Xos.h>
# include <X11/Xaw/Label.h>
# include <X11/Xaw/Cardinals.h>
# include "Cards.h"
# include <X11/Xutil.h>
# include <varargs.h>
char *
CardsSuitName (s)
CardsSuit s;
{
switch (s) {
case CardsSpade:
return "Spade";
case CardsHeart:
return "Heart";
case CardsDiamond:
return "Diamond";
case CardsClub:
return "Club";
default:
return "???";
}
}
char *
CardsRankName (r)
CardsRank r;
{
static char num[10];
switch (r) {
case CardsAce:
return "Ace";
case Cards2:
return "Deuce";
case Cards3:
return "Three";
case Cards4:
return "Four";
case Cards5:
return "Five";
case Cards6:
return "Six";
case Cards7:
return "Seven";
case Cards8:
return "Eight";
case Cards9:
return "Nine";
case Cards10:
return "Ten";
case CardsJack:
return "Jack";
case CardsQueen:
return "Queen";
case CardsKing:
return "King";
default:
return "???";
}
}
static char *
MessageCard (s, c)
char *s;
CardsCardPtr c;
{
sprintf (s, "%s of %ss", CardsRankName (c->rank), CardsSuitName (c->suit));
return s + strlen(s);
}
static char *
MessageShortCard (s, c)
char *s;
CardsCardPtr c;
{
char suit;
suit = *CardsSuitName(c->suit) - ('A' - 'a');
if (Cards2 <= c->rank && c->rank <= Cards10)
sprintf (s, "%d%c", c->rank, suit);
else
sprintf (s, "%c%c", *CardsRankName(c->rank), suit);
return s + strlen(s);
}
static char *
MessageInt (s, i)
char *s;
int i;
{
sprintf (s, "%d", i);
return s + strlen(s);
}
static char MessageBuffer[1024];
static char *MessagePtr;
static
append (format, args)
char *format;
va_list args;
{
char *m;
m = MessagePtr;
while (*format) {
if (*format == '%') switch (*++format) {
case 's':
strcpy (m, va_arg(args, char *));
m += strlen (m);
break;
case 'c':
*m++ = va_arg(args, int);
break;
case 'd':
m = MessageInt (m, va_arg(args, int));
break;
case 'p':
m = MessageShortCard (m, va_arg(args, CardsCardPtr));
break;
case 'P':
m = MessageCard (m, va_arg(args, CardsCardPtr));
break;
default:
*m++ = *format;
} else
*m++ = *format;
format++;
}
MessagePtr = m;
}
MessageStart ()
{
MessagePtr = MessageBuffer;
}
MessageEnd (w)
Widget w;
{
Arg arg[1];
*MessagePtr = '\0';
XtSetArg (arg[0], XtNlabel, MessageBuffer);
XtSetValues (w, arg, 1);
}
MessageAppend (format, va_alist)
char *format;
va_dcl
{
va_list args;
va_start (args);
append (format, args);
va_end (args);
}
Message (w, format, va_alist)
Widget w;
char *format;
va_dcl
{
va_list args;
MessageStart ();
va_start (args);
append (format, args);
va_end (args);
MessageEnd (w);
}
kgames-1.0/Xkw/Pad.c 100644 20717 2432 52660 6121566727 13062 0 ustar root daemon /*
* $NCD$
*
* Copyright 1992 Network Computing Devices
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, 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 NCD. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. NCD. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
* 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: Keith Packard, Network Computing Devices
*/
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/Xatom.h>
#include "PadP.h"
static XtResource resources[] = {
#define offset(field) XtOffsetOf(PadRec, pad.field)
/* {name, class, type, size, offset, default_type, default_addr}, */
{ XtNfont, XtCFont, XtRFontStruct, sizeof (XFontStruct *),
offset (font), XtRString, XtDefaultFont },
{ XtNforeground, XtCForeground, XtRPixel, sizeof (unsigned long),
offset (foreground_pixel), XtRString, XtDefaultForeground },
{ XtNnumRows, XtCNumRows, XtRDimension, sizeof (Dimension),
offset (rows), XtRImmediate, (XtPointer) 1},
{ XtNnumCols, XtCNumCols, XtRDimension, sizeof (Dimension),
offset (cols), XtRImmediate, (XtPointer) 1},
{XtNinternalBorderWidth, XtCInternalBorderWidth, XtRDimension, sizeof (Dimension),
offset(internal_border), XtRImmediate, (XtPointer) 2},
#undef offset
};
static void Initialize(), Destroy (), Redisplay (), Resize ();
static Boolean SetValues ();
PadClassRec padClassRec = {
{ /* core fields */
/* superclass */ (WidgetClass) &widgetClassRec,
/* class_name */ "Pad",
/* widget_size */ sizeof(PadRec),
/* class_initialize */ NULL,
/* class_part_initialize */ NULL,
/* class_inited */ FALSE,
/* initialize */ Initialize,
/* initialize_hook */ NULL,
/* realize */ XtInheritRealize,
/* actions */ NULL,
/* num_actions */ 0,
/* resources */ resources,
/* num_resources */ XtNumber(resources),
/* xrm_class */ NULLQUARK,
/* compress_motion */ TRUE,
/* compress_exposure */ XtExposeCompressSeries|XtExposeGraphicsExpose|XtExposeNoExpose,
/* compress_enterleave */ TRUE,
/* visible_interest */ FALSE,
/* destroy */ Destroy,
/* resize */ Resize,
/* expose */ Redisplay,
/* set_values */ SetValues,
/* set_values_hook */ NULL,
/* set_values_almost */ XtInheritSetValuesAlmost,
/* get_values_hook */ NULL,
/* accept_focus */ NULL,
/* version */ XtVersion,
/* callback_private */ NULL,
/* tm_table */ NULL,
/* query_geometry */ XtInheritQueryGeometry,
/* display_accelerator */ XtInheritDisplayAccelerator,
/* extension */ NULL
},
{ /* simple fields */
/* empty */ 0
},
{ /* pad fields */
/* empty */ 0
}
};
WidgetClass padWidgetClass = (WidgetClass)&padClassRec;
static void
Clear (l, n)
PadLinePtr l;
{
char *t, *a;
t = l->text;
a = l->attr;
while (n--) {
*t++ = ' ';
*a++ = XkwPadNormal;
}
*t = '\0';
l->serial = 0;
}
static void
ResizeBuffer (bp, old_rows, old_cols, new_rows, new_cols)
PadLinePtr *bp;
Dimension old_rows, old_cols, new_rows, new_cols;
{
PadLinePtr oldb;
PadLinePtr b;
int row, col;
int max_row, max_col;
b = Some(PadLineRec, new_rows);
for (row = 0; row < new_rows; row++)
AllocText (&b[row], new_cols);
oldb = *bp;
if (oldb)
{
max_col = new_cols;
if (max_col > old_cols)
max_col = old_cols;
max_row = new_rows;
if (max_row > old_rows)
max_row = old_rows;
for (row = 0; row < max_row; row++)
{
CopyText (&oldb[row], &b[row], 0, max_col);
b[row].serial = oldb[row].serial;
b[row].id = oldb[row].id;
}
for (; row < old_rows; row++)
DisposeText (&oldb[row]);
Dispose (oldb);
}
*bp = b;
}
static void
ResizeText (w, rows, cols)
PadWidget w;
Dimension rows, cols;
{
int row;
ResizeBuffer (&w->pad.is, w->pad.rows, w->pad.cols, rows, cols);
ResizeBuffer (&w->pad.want, w->pad.rows, w->pad.cols, rows, cols);
w->pad.rows = rows;
w->pad.cols = cols;
for (row = 0; row < rows; row++)
w->pad.is[row].id = w->pad.want[row].id = NextSerial (w);
}
static void
getSize (w, widthp, heightp)
PadWidget w;
Dimension *widthp, *heightp;
{
int size;
unsigned long value, value2;
Atom UNDERLINE_POSITION, UNDERLINE_THICKNESS;
int dir, font_ascent, font_descent;
XCharStruct overall;
w->pad.fixed_width = (w->pad.font->max_bounds.width ==
w->pad.font->min_bounds.width);
if (XGetFontProperty (w->pad.font, XA_UNDERLINE_POSITION, &value))
w->pad.underline_pos = (int) value;
else
w->pad.underline_pos = (w->pad.font->max_bounds.descent + 1) >> 1;
if (XGetFontProperty (w->pad.font, XA_UNDERLINE_THICKNESS, &value))
w->pad.underline_thickness = (int) value;
else if (XGetFontProperty (w->pad.font, XA_WEIGHT, &value) &&
XGetFontProperty (w->pad.font, XInternAtom (XtDisplay (w),
"CAP_HEIGHT",
False), &value2))
{
w->pad.underline_thickness = (int) value * value2 / 1000;
}
else
{
/* this is not quite right -- the thickness of an underscore
* may not be what we want, but it should work OK
*/
XTextExtents (w->pad.font, "_", 1, &dir, &font_ascent, &font_descent,
&overall);
size = overall.ascent + overall.descent;
if (size < (font_ascent + font_descent) / 2)
w->pad.underline_thickness = size;
else
w->pad.underline_thickness = (font_ascent + font_descent) / 2;
}
if (w->pad.underline_thickness <= 0)
w->pad.underline_thickness = 1;
if (w->pad.underline_pos + w->pad.underline_thickness > w->pad.font->descent)
{
if (w->pad.underline_pos > 1)
w->pad.underline_pos = w->pad.font->descent - w->pad.underline_thickness;
if (w->pad.underline_pos <= 1)
{
if (w->pad.underline_pos < 0)
w->pad.underline_pos = 0;
w->pad.underline_thickness = w->pad.font->descent - w->pad.underline_pos;
}
}
w->pad.char_width = XTextWidth (w->pad.font, "0", 1);
w->pad.char_height = w->pad.font->ascent + w->pad.font->descent;
w->pad.char_vAdjust = w->pad.font->ascent;
w->pad.char_hAdjust = 0;
*widthp = w->pad.char_width * w->pad.cols + 2 * w->pad.internal_border;
*heightp = w->pad.char_height * w->pad.rows + 2 * w->pad.internal_border;
}
static void
setSize (w)
PadWidget w;
{
Dimension rows, cols;
rows = (w->core.height - 2 * w->pad.internal_border) / w->pad.char_height;
cols = (w->core.width - 2 * w->pad.internal_border) / w->pad.char_width;
ResizeText (w, rows, cols);
}
static void Initialize (greq, gnew)
Widget greq, gnew;
{
PadWidget req = (PadWidget) greq,
new = (PadWidget) gnew;
XGCValues gcv;
getSize (new, &new->core.width, &new->core.height);
gcv.foreground = new->pad.foreground_pixel;
gcv.background = new->core.background_pixel;
gcv.font = new->pad.font->fid;
new->pad.normal_gc = XtGetGC (gnew, GCForeground|GCBackground|GCFont, &gcv);
gcv.foreground = new->core.background_pixel;
gcv.background = new->pad.foreground_pixel;
gcv.font = new->pad.font->fid;
new->pad.inverse_gc = XtGetGC (gnew, GCForeground|GCBackground|GCFont, &gcv);
new->pad.is = 0;
new->pad.want = 0;
new->pad.serial = 0;
new->pad.copy = 0;
ResizeText (new, new->pad.rows, new->pad.cols);
}
static void
Destroy (gw)
Widget gw;
{
PadWidget w = (PadWidget) gw;
XtReleaseGC (gw, w->pad.normal_gc);
XtReleaseGC (gw, w->pad.inverse_gc);
}
static int
XToCol(w, row, x)
PadWidget w;
int row;
int x;
{
char *c;
int col;
c = w->pad.is[row].text;
for (col = 0; col < w->pad.cols - 1; col++)
if (x < XTextWidth (w->pad.font, c, col))
break;
return col;
}
static void
DrawText (w, row, start_col, end_col)
PadWidget w;
{
GC gc;
Display *dpy = XtDisplay(w);
Window win = XtWindow (w);
int change_col;
char attr;
char *is_a, *is_t;
PadLinePtr is;
int x, y;
int width;
is = &w->pad.is[row];
is_a = is->attr + start_col;
is_t = is->text + start_col;
change_col = start_col;
x = TextX (w, start_col);
y = TextY (w, row);
while (start_col < end_col) {
attr = *is_a;
do {
++is_a;
++change_col;
} while (change_col < end_col && *is_a == attr);
gc = w->pad.normal_gc;
if (attr & XkwPadInverse)
gc = w->pad.inverse_gc;
XDrawImageString (dpy, win, gc, x, y,
is_t, change_col - start_col);
if (w->pad.fixed_width)
width = (change_col - start_col) * w->pad.char_width;
else
width = XTextWidth (w->pad.font, is_t, change_col - start_col);
if (attr & XkwPadUnderline)
{
XFillRectangle (dpy, win, gc,
x, y + w->pad.underline_pos,
width, w->pad.underline_thickness);
}
x += width;
is_t += (change_col - start_col);
start_col = change_col;
}
}
static void
RedrawText (w, row, start_col, end_col)
PadWidget w;
{
char *t, *a;
t = w->pad.is[row].text + start_col;
a = w->pad.is[row].attr + start_col;
while (start_col < end_col && *t++ == ' ' && *a++ == XkwPadNormal)
start_col++;
t = w->pad.is[row].text + end_col;
a = w->pad.is[row].attr + end_col;
while (end_col > start_col && *--t == ' ' && *--a == XkwPadNormal)
end_col--;
if (start_col < end_col)
DrawText (w, row, start_col, end_col);
}
static int
UntilEqual(w, start)
PadWidget w;
int start;
{
PadLinePtr want = &w->pad.want[start],
is = &w->pad.is[start];
while (start < w->pad.rows && want->id != is->id) {
want++;
is++;
start++;
}
return start;
}
static void
CopyLines (w, top, bottom, count)
PadWidget w;
int top, bottom, count;
{
int src, dst, amt;
PadCopyPtr copy, *prev;
if (count < 0)
{
src = top - count;
dst = top;
count = -count;
}
else
{
src = top;
dst = top + count;
}
amt = bottom - top - count;
copy = New(PadCopyRec);
copy->next = 0;
copy->src = src;
copy->dst = dst;
copy->amt = amt;
copy->copy_serial = NextRequest (XtDisplay (w));
prev = &w->pad.copy;
while (*prev)
prev = &(*prev)->next;
*prev = copy;
XCopyArea (XtDisplay (w), XtWindow (w), XtWindow (w), w->pad.normal_gc,
0, YPos(w, src), w->core.width, amt * w->pad.char_height,
0, YPos(w, dst));
}
static void
ClearLines (w, start, amt)
PadWidget w;
int start, amt;
{
XClearArea (XtDisplay (w), XtWindow (w),
0, YPos (w, start), w->core.width, amt * w->pad.char_height,
False);
}
static void
ScrollBuffer (w, b, start_row, end_row, dist)
PadWidget w;
PadLinePtr b;
int start_row, end_row, dist;
{
int first_row, row, next_row;
PadLineRec tmp1, tmp2;
int n;
if (end_row <= start_row)
return;
n = end_row - start_row;
first_row = start_row;
while (n) {
tmp2 = b[first_row];
row = first_row;
do
{
next_row = row + dist;
if (next_row < start_row)
next_row = next_row + end_row - start_row;
else if (next_row >= end_row)
next_row = next_row - end_row + start_row;
tmp1 = b[next_row];
b[next_row] = tmp2;
tmp2 = tmp1;
n--;
row = next_row;
} while (row != first_row);
first_row++;
}
n = dist;
if (n < 0)
{
n = -n;
row = end_row - n;
}
else
row = start_row;
while (n--)
{
Clear (&b[row], w->pad.cols);
row++;
}
}
static Boolean
AddLines(w, at, num)
PadWidget w;
int at, num;
{
int i;
int bottom = UntilEqual(w, at + num);
if (num == 0 || num >= ((bottom - 1) - at))
return False; /* We did nothing */
CopyLines (w, at, bottom, num);
ClearLines (w, at, num);
ScrollBuffer (w, w->pad.is, at, bottom, num);
return True; /* We did something. */
}
static Boolean
DelLines(w, at, num)
PadWidget w;
int at, num;
{
register int i;
int bottom = UntilEqual(w, at + num);
if (num == 0 || num >= ((bottom - 1) - at))
return False;
CopyLines (w, at, bottom, -num);
ClearLines (w, bottom - num, num);
ScrollBuffer (w, w->pad.is, at, bottom, -num);
return True;
}
static void
DoInsertDelete (w, start)
PadWidget w;
{
PadLinePtr is, want;
int i, j;
/* Some changes have been made. Try for insert or delete lines.
If either case has happened, Addlines and/or DelLines will do
necessary scrolling, also CONVERTING w->pad.is to account for the
physical changes. The comparison continues from where the
insertion/deletion takes place; this doesn't happen very often,
usually it happens with more than one window with the same
buffer. */
is = &w->pad.is[start];
want = &w->pad.want[start];
for (i = start; i < w->pad.rows; i++, is++, want++)
if (want->id != is->id)
break;
for (; i < w->pad.rows; i++) {
for (j = i + 1; j < w->pad.rows; j++) {
want = &w->pad.want[j];
is = &w->pad.is[j];
if (want->id == is->id)
break;
if (want->id == w->pad.is[i].id) {
if (AddLines(w, i, j - i)) {
DoInsertDelete(w, j);
return;
}
break;
}
if ((want = &w->pad.want[i])->id == is->id) {
if (DelLines(w, i, j - i)) {
DoInsertDelete(w, i);
return;
}
break;
}
}
}
}
/*
* Redisplay -- repaint damaged areas on the screen
* This is complicated by the CopyArea calls which may have
* copied exposed regions on the screen
*/
static void
Redisplay (gw, event, region)
Widget gw;
XEvent *event;
Region region;
{
PadWidget w = (PadWidget) gw;
int start_row, end_row, row;
int start_col, end_col;
PadCopyPtr copy;
unsigned long expose_serial;
Boolean *repaint;
int amt;
Boolean *r;
if (!XtIsRealized (gw))
return;
if (event->type != NoExpose)
{
/* Mark rows for redisplay */
repaint = Some (Boolean, w->pad.rows);
for (row = 0; row < w->pad.rows; row++) repaint[row] = False;
start_row = RowPos (w, event->xexpose.y);
if (start_row < 0)
start_row = 0;
end_row = RowPos (w, event->xexpose.y + event->xexpose.height - 1);
if (end_row >= w->pad.rows)
end_row = w->pad.rows - 1;
for (row = start_row; row <= end_row; row++)
repaint[row] = True;
/* Track effects of CopyArea calls on exposure events */
copy = w->pad.copy;
expose_serial = event->xexpose.serial;
for (copy = w->pad.copy; copy; copy = copy->next)
if (copy->copy_serial > expose_serial)
break;
for (; copy; copy = copy->next)
{
bcopy (repaint + copy->src, repaint + copy->dst, copy->amt * sizeof (Boolean));
r = repaint;
if (copy->src > copy->dst)
r += copy->dst + copy->amt;
else
r += copy->src;
amt = copy->amt;
while (amt--)
*r++ = False;
}
/* repaint the resultant rows */
if (w->pad.fixed_width)
{
start_col = ColPos (w, event->xexpose.x);
if (start_col < 0)
start_col = 0;
end_col = ColPos (w, event->xexpose.x + event->xexpose.width - 1);
if (end_col >= w->pad.cols)
end_col = w->pad.cols - 1;
}
for (row = 0; row < w->pad.rows; row++)
{
if (!repaint[row])
continue;
if (!w->pad.fixed_width)
{
start_col = XToCol (w, row, event->xexpose.x);
end_col = XToCol (w, row, event->xexpose.x + event->xexpose.width - 1);
}
RedrawText (w, row, start_col, end_col + 1);
}
Dispose (repaint);
if (event->xexpose.count != 0)
return;
}
if (event->type != Expose)
{
copy = w->pad.copy;
if (!copy)
abort ();
if (event->xexpose.serial != copy->copy_serial)
abort ();
w->pad.copy = copy->next;
Dispose (copy);
}
}
static void
Resize (gw)
Widget gw;
{
PadWidget w = (PadWidget) gw;
setSize (w);
}
void
XkwPadUpdate (gw)
Widget gw;
{
Display *dpy = XtDisplay (gw);
Window win = XtWindow (gw);
PadWidget w = (PadWidget) gw;
int row, start_col, end_col;
int cols;
PadLinePtr is, want;
char *is_t, *want_t, *is_a, *want_a;
Boolean DoneInsertDelete = False;
if (!XtIsRealized (gw))
return;
is = w->pad.is;
want = w->pad.want;
cols = w->pad.cols;
for (row = 0; row < w->pad.rows; row++, is++, want++)
{
if (is->serial == want->serial)
continue;
if (is->id != want->id && !DoneInsertDelete)
{
DoInsertDelete (w, row);
DoneInsertDelete = True;
}
/*
* This is simplistic -- painting a single range of
* text which covers all the changed characters
*/
/* search for start of mismatching characters */
is_t = is->text;
is_a = is->attr;
want_t = want->text;
want_a = want->attr;
for (start_col = 0; start_col < cols; start_col++)
if (*is_t++ != *want_t++ || *is_a++ != *want_a++)
break;
/* search for end of mismatching characters */
is_t = is->text + cols;
is_a = is->attr + cols;
want_t = want->text + cols;
want_a = want->attr + cols;
for (end_col = cols; end_col > start_col; end_col--)
if (*--is_t != *--want_t || *--is_a != *--want_a)
break;
/* paint the range of mismatching characters */
if (start_col < end_col)
{
CopyText (want, is, start_col, end_col - start_col);
if (!w->pad.fixed_width)
{
start_col = 0;
end_col = w->pad.cols;
XClearArea (dpy, win, 0, YPos(w, row),
w->core.width, w->pad.char_height, False);
}
DrawText (w, row, start_col, end_col);
}
is->serial = want->serial;
is->id = want->id;
}
}
void
XkwPadText (gw, row, col, text, len)
Widget gw;
int row, col;
char *text;
int len;
{
PadWidget w = (PadWidget) gw;
PadLinePtr want;
if (row >= w->pad.rows || col >= w->pad.cols)
return;
want = &w->pad.want[row];
if (col + len > w->pad.cols)
len = w->pad.cols - col;
bcopy (text, want->text + col, len);
want->serial = NextSerial(w);
}
XkwPadAttributes (gw, row, col, attr, len)
Widget gw;
int row, col;
char *attr;
int len;
{
PadWidget w = (PadWidget) gw;
PadLinePtr want;
if (row >= w->pad.rows || col >= w->pad.cols)
return;
want = &w->pad.want[row];
if (col + len > w->pad.cols)
len = w->pad.cols - col;
bcopy (attr, want->attr + col, len);
want->serial = NextSerial(w);
}
XkwPadTextAndAttributes (gw, row, col, text, attr, len)
Widget gw;
int row, col;
char *text, *attr;
int len;
{
PadWidget w = (PadWidget) gw;
PadLinePtr want;
if (row >= w->pad.rows || col >= w->pad.cols)
return;
want = &w->pad.want[row];
if (col + len > w->pad.cols)
len = w->pad.cols - col;
bcopy (text, want->text + col, len);
bcopy (attr, want->attr + col, len);
want->serial = NextSerial(w);
}
void
XkwPadClearToEnd (gw, row, col)
Widget gw;
int row, col;
{
PadWidget w = (PadWidget) gw;
PadLinePtr want;
char *t, *a;
if (row >= w->pad.rows || col >= w->pad.cols)
return;
want = &w->pad.want[row];
t = want->text + col;
a = want->attr + col;
col = w->pad.cols - col;
while (col--)
{
*t++ = ' ';
*a++ = XkwPadNormal;
}
want->serial = NextSerial (w);
}
void
XkwPadClear (gw)
Widget gw;
{
PadWidget w = (PadWidget) gw;
int row;
for (row = 0; row < w->pad.rows; row++)
XkwPadClearToEnd (gw, row, 0);
}
void
XkwPadScroll (gw, start_row, end_row, dist)
Widget gw;
int start_row, end_row, dist;
{
PadWidget w = (PadWidget) gw;
ScrollBuffer (w, w->pad.want, start_row, end_row, dist);
}
void
XkwPadXYToRowCol (gw, x, y, rowp, colp)
Widget gw;
int x, y;
int *rowp, *colp;
{
PadWidget w = (PadWidget) gw;
int row, col;
row = RowPos (w, y);
if (row < 0)
row = 0;
if (row >= w->pad.rows)
row = w->pad.rows - 1;
if (w->pad.fixed_width)
col = ColPos (w, x);
else
col = XToCol (w, row, x);
if (col < 0)
col = 0;
if (col >= w->pad.cols)
col = w->pad.cols - 1;
*rowp = row;
*colp = col;
}
static Boolean
SetValues (gcur, greq, gnew)
Widget gcur, greq, gnew;
{
PadWidget cur = (PadWidget) gcur,
req = (PadWidget) greq,
new = (PadWidget) gnew;
XGCValues gcv;
Boolean redraw = FALSE, newgc = FALSE, newsize = FALSE;
Dimension width, height;
if (req->pad.foreground_pixel != cur->pad.foreground_pixel)
newgc = TRUE;
if (req->pad.font != cur->pad.font)
newgc = newsize = TRUE;
if (req->pad.rows != cur->pad.rows ||
req->pad.cols != cur->pad.cols)
{
newsize = TRUE;
ResizeText (new, req->pad.rows, req->pad.cols);
}
if (newgc)
{
XtReleaseGC (gcur, cur->pad.normal_gc);
gcv.foreground = req->pad.foreground_pixel;
gcv.font = req->pad.font->fid;
new->pad.normal_gc = XtGetGC (gnew, GCForeground|GCFont, &gcv);
redraw = TRUE;
}
if (newsize)
{
getSize (new, &width, &height);
XtMakeResizeRequest (gnew, width, height, &width, &height);
if (width != cur->core.width || height != cur->core.height)
setSize (new, width, height);
redraw = TRUE;
}
return redraw;
}
kgames-1.0/Xkw/Pad.h 100644 20717 2432 5517 6121566727 13046 0 ustar root daemon /* $XConsortium: Pad.h,v 1.5 90/12/19 18:46:00 converse Exp $ */
/* Copyright Massachusetts Institute of Technology 1987, 1988
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, 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 M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
* 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.
*
*/
#ifndef _Pad_h
#define _Pad_h
/****************************************************************
*
* Pad widget
*
****************************************************************/
/* Resources:
Name Class RepType Default Value
---- ----- ------- -------------
background Background Pixel XtDefaultBackground
border BorderColor Pixel XtDefaultForeground
borderWidth BorderWidth Dimension 1
destroyCallback Callback Pointer NULL
height Height Dimension 0
mappedWhenManaged MappedWhenManaged Boolean True
sensitive Sensitive Boolean True
width Width Dimension 0
x Position Position 0
y Position Position 0
*/
/* define any special resource names here that are not in <X11/StringDefs.h> */
#define XtNinternalBorderWidth "internalBorderWidth"
#define XtCInternalBorderWidth "InternalBorderWidth"
#define XtNnumRows "numRows"
#define XtCNumRows "NumRows"
#define XtNnumCols "numCols"
#define XtCNumCols "NumCols"
/* declare the class constant */
extern WidgetClass padWidgetClass;
/* declare class-specific functions */
#define XkwPadNormal 0
#define XkwPadInverse 1
#define XkwPadBold 2
#define XkwPadUnderline 4
#define XkwPadBlink 8
extern void XkwPadUpdate (/* Widget gw */);
extern void XkwPadString (/* Widget gw, int row, int col, char *string */);
extern void XkwPadClearToEnd (/* Widget gw, int row, int col */);
extern void XkwPadClear (/* Widget gw */);
extern void XkwPadScroll (/* Widget gw, int start_row, int end_row, int dist */);
extern void XkwPadXYToRowCol (/* Widget gw, int x, int y, int *rowp, int *colp */);
#endif /* _Pad_h */
kgames-1.0/Xkw/PadP.h 100644 20717 2432 7170 6121566727 13163 0 ustar root daemon /*
* $NCD$
*
* Copyright 1992 Network Computing Devices
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, 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 NCD. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. NCD. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
* 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: Keith Packard, Network Computing Devices
*/
#ifndef _PadP_h
#define _PadP_h
#include "Pad.h"
/* include superclass private header file */
#include <X11/Xaw/SimpleP.h>
typedef struct {
int empty;
} PadClassPart;
typedef struct _PadClassRec {
CoreClassPart core_class;
SimpleClassPart simple_class;
PadClassPart pad_class;
} PadClassRec;
extern PadClassRec padClassRec;
typedef struct _PadLine {
long serial;
long id;
char *text;
char *attr;
} PadLineRec, *PadLinePtr;
typedef struct _PadCopy {
struct _PadCopy *next;
int src, dst, amt;
unsigned long copy_serial;
} PadCopyRec, *PadCopyPtr;
typedef struct {
/* resources */
XFontStruct *font;
unsigned long foreground_pixel;
Dimension rows, cols;
Dimension internal_border;
/* private state */
GC normal_gc;
GC inverse_gc;
PadLinePtr is;
PadLinePtr want;
int underline_pos;
int underline_thickness;
int char_width;
int char_height;
int char_vAdjust;
int char_hAdjust;
unsigned long serial;
Boolean fixed_width;
PadCopyPtr copy;
} PadPart;
#define New(t) (t *) malloc(sizeof (t))
#define Dispose(p) free((char *) p)
#define Some(t,n) (t*) malloc(sizeof(t) * n)
#define More(p,t,n) ((p)? (t *) realloc((char *) p, sizeof(t)*n):Some(t,n)
#define AllocText(b, cols) (\
(b)->text = Some(char, (cols)+1),\
(b)->attr = Some(char, (cols)+1),\
Clear (b, cols))
#define DisposeText(b) (Dispose ((b)->text), Dispose ((b)->attr))
#define CopyText(fromb, tob, col, num) (\
bcopy((fromb)->text + col, (tob)->text + col, num), \
bcopy((fromb)->attr + col, (tob)->attr + col, num))
#define NextSerial(w) (++(w)->pad.serial)
#define XPos(w,col) ((w)->pad.internal_border + (col) * (w)->pad.char_width)
#define YPos(w,row) ((w)->pad.internal_border + (row) * (w)->pad.char_height)
#define TextX(w,col) ((w)->pad.char_hAdjust + XPos(w, col))
#define TextY(w,row) ((w)->pad.char_vAdjust + YPos(w, row))
#define ColPos(w,x) (((x)-(int)(w)->pad.internal_border) /\
(int)(w)->pad.char_width)
#define RowPos(w,y) (((y)-(int)(w)->pad.internal_border) /\
(int)(w)->pad.char_height)
typedef struct _PadRec {
CorePart core;
SimplePart simple;
PadPart pad;
} PadRec;
/* declare specific PadWidget class and instance datatypes */
typedef struct _PadClassRec* PadWidgetClass;
typedef struct _PadRec* PadWidget;
#endif /* _PadP_h */
kgames-1.0/Xkw/PadTest.ad 100644 20717 2432 42 6121566727 13767 0 ustar root daemon *pad.numRows: 24
*pad.numCols: 80
kgames-1.0/Xkw/SuitCards.c 100644 20717 2432 10745 6121566727 14255 0 ustar root daemon /*
* $NCD$
*
* Copyright 1992 Network Computing Devices
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, 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 NCD. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. NCD. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
* 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: Keith Packard, Network Computing Devices
*/
# include <X11/Intrinsic.h>
# include <X11/StringDefs.h>
# include <X11/Xos.h>
# include <X11/Xutil.h>
# include <Xkw/Cards.h>
# include <Xkw/SuitCards.h>
SuitCardsInit (s, under, widget, emptySuit, horizontal, row, col, display)
SuitCardsPtr s;
CardStackPtr under;
Widget widget;
CardsSuit emptySuit;
Boolean horizontal;
int row, col;
CardDisplay display;
{
int position;
int basePosition;
CardsSuit suit;
CardStackPtr stack;
if (horizontal)
{
position = col;
basePosition = row;
}
else
{
position = row;
basePosition = col;
}
for (suit = CardsClub; suit <= CardsSpade; suit++)
{
stack = &s->suits[CardsSuitToInt(suit)];
CardInitStack (stack, under, widget, emptySuit,
!horizontal, position, display);
stack->basePosition = basePosition;
under