home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
g
/
gina15.zip
/
demos
/
sleuth
/
CardView.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-02-27
|
2KB
|
106 lines
// This may look like C code, but it is really -*- C++ -*-
// Module : CardView.C Version 1.2
// LastSCCS : 2/26/92 16:37:51
// LastEdit : "Thu Nov 7 16:34:55 1991"
// Description :
// Author :
// Copyright : GMD Schloss Birlinghoven
CardView::
CardView(SleuthDocument* doc)
: SleuthView( doc )
{
}
void CardView ::
button_press(int , int , int x, int y)
{
int f_color, f_shape, f_value;
//cout << "You hit ";
switch( WhatsUnder(x, y, f_shape, f_color, f_value) ) {
case eTableNothing:
break;
case ePlayer:
//cout << "the player label";
break;
case eShapeRow:
//cout << "shape " << f_shape;
break;
case eValueRow:
//cout << "value " << f_value << " for shape " << f_shape;
break;
case eColorColumn:
//cout << "color " << f_color;
break;
case eField:
//cout << "field " << f_shape << " " << f_color << " " << f_value;
break;
}
}
void CardView::
draw(int, int, int, Dimension, Dimension)
{
REQUIRE(DrawingIsPossible(), "Drawing into X Window is possible");
Update();
}
void CardView::
UpdateCard(Card *card)
{
REQUIRE(DrawingIsPossible(), "Drawing into X Window is possible");
char *str = card->GetPlayer() != 0 ? card->GetPlayer()->GetName() : "";
DrawFilledString(str, strlen(str),
foreground, background,
InnerX(FieldX(card->GetShape(), card->GetValue())),
InnerY(FieldY(card->GetColor())),
InnerWidth(TableFieldWidth()),
InnerHeight(TableFieldHeight()));
}
void CardView::
DrawGameName()
{
REQUIRE(DrawingIsPossible(), "Drawing into X Window is possible");
DrawFilledString(document->GetGameName(),
strlen(document->GetGameName()),
foreground, background,
InnerX(TableX()), InnerY(TableY()),
InnerWidth(CardColorColumnWidth()),
InnerHeight(2*TableFieldHeight()));
}
void CardView::
Update()
{
REQUIRE(DrawingIsPossible(), "Drawing into X Window is possible");
int i, j, k;
DrawEmptyTable();
DrawGameName();
for( i = 0; i < 3; i++)
for( j = 0; j < 4; j++)
for( k = 0; k < 3; k++)
UpdateCard(document->GetCard(i, j, k));
}
void CardView::
UpdateGameName()
{
if( DrawingIsPossible() )
DrawGameName();
}