ftp.nice.ch/pub/next/games/card/NEXTVegas3.0.src.tar.gz#/NEXTVegas/Documentation/BetView/ChipPile.rtf

This is ChipPile.rtf in view mode; [Download] [Up]

ChipPile

Inherits From:	Object

Declared In:	ChipPile.h


Class Description

The ChipPile class is a (hopefully) general purpose object to manage and display piles of chips.  It is to be used in conjunction with a View.

ChipPiles are not exactly what they seem - they are not really a collection of chips (like CardPiles are a collection of Card objects).  Instead, ChipPiles are rather abstract - you define how many chips are displayed and what their total value is.  For all intents and purposes, however, ChipPiles can be treated as a pile of chips, just don't expect them to display the exact number of chips you've specified or added to the pile.  Its all just for effect, anyway.  Perhaps future versions of the class will depend on a Chip class, and will behave exactly as the CardSet.  Perhaps.


Instance Variables

int 	ownerIndex;

int 	amount;
BOOL isOn;
int	chipType;
int	chipSize;
int	tag;
int	draggedFromRow;
int	draggedFromColumn;
float	xOffset, yOffset;
float	maxWidth, maxHeight;
int	numChipsToDraw, numChipsDrawn;
BOOL showValueInsteadOfTotal;
int	chipValue;


ownerIndex	An integer used to differentiate piles.

amount	The total value of the pile.

isOn	If YES, draws its value.  If NO, draws "OFF".

chipType	Constant that defines the look of the chips in the pile.

chipSize	Constant that defines the size of the chips in the pile.

tag	An integer used to differentiate piles.

draggedFromRow	Not used by the pile but by objects using the pile.  Tells where the pile came from.

draggedFromColumn	Not used by the pile but by objects using the pile.  Tells where the pile came from.

xOffset	The amount used to offset one chip from another in the x direction.

yOffset	The amount used to offset one chip from another in the y direction.

maxWidth	The maximum width a pile is allowed achieve.

maxHeight	The maximum height a pile is allowed achieve.

numChipsToDraw	The number of chips a pile wants to draw.

numChipsDrawn	The number of chips actually drawn by the pile.

showValueInsteadOfTotal	If YES, chipValue will be displayed rather than amount when rendering the pile.

chipValue	The supposed value of the chips in the pile.



Method Types

Creating new instances	- init;
	- initType:(int)cpType size:(int)cpSize value:(int)cpValue;
	- copyFromZone:(NXZone *)zone;

General aspects of the pile	- setChipType:(int)aValue;
	- (int)chipType;
	- setChipSize:(int)aValue;
	- (int)chipSize;
	- setChipValue:(int)aValue;
	- (int)chipValue;
	- setOwnerIndex:(int)aPlayerIndex;
	- (int)ownerIndex;
	- setTag:(int)aTag;
	- (int)tag;
	- getChipSize:(NXSize *)size;
	- getPileSize:(NXSize *)size;
	- setNumChips:(int)numtodraw;
	- (int)numChips;

Manipulating the pile	- addChips:(int)numChips;
	- removeChips:(int)numChips;
	- setAmount:(int)aValue;
	- (int)amount;
	- addAmount:(int)units;
	- multiplyBy:(float)units;
	- empty;
	- setOn:(BOOL)isOn;
	- (BOOL)isOn;
	- showValueInsteadOfTotal:(BOOL)flag;
	- (BOOL)showsValue;
	- flip;
	- addPile:aPile;
	- removePile:aPile;

Rendering the pile	- drawChipPileAt:(NXPoint *)aPoint;
	- drawContentsAt:(NXPoint *)aPoint;
	- drawOutlineAt:(NXPoint *)aPoint;
	- setXOffset:(float)xoffset yOffset:(float)yoffset;
	- setMaxWidth:(float)maxwidth maxHeight:(float)maxheight;


Drag And Drop	- drawDragPile:sender;
	- tempDragImage;
	- setDragRow:(int)row col:(int)col;
	- getDragRow:(int *)row col:(int *)col;

Archiving the pile	- read:(NXTypedStream *)theStream;
	- write:(NXTypedStream *)theStream;

Debugging methods	- printToStderr;

Class Methods

Instance Methods

addAmount:

- addAmount:(int)units

Adds units to the value of the pile by calling:
	[self setAmount:amount + units].
Returns self.

See also:  - setAmount


addChips:

- addChips:(int)numChips

Increases the number of chips that the pile wants to draw by numChips, and increases the pile's value by numChips * the chips in the pile's value.  Returns self.

See also:  - removeChips


addPile:

- addPile:aPile

Adds the amount of aPile and the number of chips in aPile to the pile.  Returns self.

See also:  - removePile


amount

- (int)amount

Returns the value of the pile.

See also:  - setAmount


chipSize

- (int)chipSize

Returns a constant indicating the size of the chips in the pile, either NV_CHIPSIZESMALL or NV_CHIPSIZELARGE.

See also:  - setChipSize:


chipType

- (int)chipType

Returns a constant indicating the boarder used for the chips in the pile.

See also:  - setChipType:


chipValue

- (int)chipValue

Returns the value set through the setChipValue: method.

See also:  - setChipValue:


copyFromZone:

- copyFromZone:(NXZone *)zone

Returns a copy of the pile created from zone zone.




drawChipPileAt:

- drawChipPileAt:(NXPoint *)aPoint

If the value of the pile is greater than 0, calling this method will render the pile by passing aPoint to drawOutlineAt: and drawContentsAt:.  Returns self.

See also:  - drawContentsAt:, - drawOutlineAt:


drawContentsAt:

- drawContentsAt:(NXPoint *)aPoint

Renders the contents of the pile (that is, either the value of the pile, the chip value of the pile, or the word "OFF") at aPoint.  aPoint should be the same point used in drawOutlineAt:  Returns self.

See also:  - drawOutlineAt:


drawDragPile:

- drawDragPile:sender

Draws the pile, regardles of its value.  Used when dragging a pile.  Returns self.




drawOutlineAt:

- drawOutlineAt:(NXPoint *)aPoint

Starting with the point aPoint, tries to render as many chips as are in the pile, by offseting them by the values set with the method setOffset::, until it reaches the bounds set by setMaxHeight: and setMaxWidth:.  aPoint should be the same point used in drawContentsAt:.  Returns self.

See also:  - drawContentsAt:


empty

- empty

Sets the value of the pile to 0.  Returns self.

See also:  - setAmount


flip

- flip

Turn the pile off if it is on, and on if it is off.  Returns self.

See also:  - setOn


getChipSize:

- getChipSize:(NXSize *)size

Sets size to the actual size of the chips used in the pile.  Returns self.

See also:  - setChipSize:


getDragRow:col:

- getDragRow:(int *)row col:(int *)col

You can find out where on a BetView a pile was dragged from by calling this method (assuming that the drag row and column where previously set with setDragRow:col:).  Returns self.

See also:  - setDragRow:col:


getPileSize:

- getPileSize:(NXSize *)size

Sets size to the actual size of the pile as rendered on screen.  Returns self.




init

- init

Returns  [self initType:NV_CHIPTYPE1 size:NV_CHIPSIZESMALL value:0].

See also:  - initType:size:value:


initType:size:value:

- initType:(int)cpType size:(int)cpSize value:(int)cpValue

This is the designated initializer for the class.  cpType designates the chip boarder and can be one of the following:

Constant	Chip Boarder
NV_CHIPTYPE0	White 
NV_CHIPTYPE1	White/Light gray 
NV_CHIPTYPE2	Light gray 
NV_CHIPTYPE3	Light gray/ Dark gray
NV_CHIPTYPE4	Dark gray

cpSize designates the size of the chip and can be either NV_CHIPSIZELARGE or NV_CHIPSIZESMALL.

value is the total value of the pile when it is created.

Returns self.

See also:  - init


isOn

- (BOOL)isOn

Returns YES if the pile is on, NO if not.

See also:  - setOn:


multiplyBy:

- multiplyBy:(float)units

Multiplies the value of the pile by units.  Calls:
	[self setAmount:amount*units].
Returns self.

See also:  - setAmount


numChips

- (int)numChips

Returns the number of chips that the pile wants to draw (but not the actual number of chips drawn).

See also:  - setNumChips:


ownerIndex

- (int)ownerIndex

Returns the index set through the setOwnerIndex: method.

See also:  - setOwnerIndex


printToStderr

- printToStderr

Prints to stderr the instance variables tag, amount, numChipsToDraw, chipType, chipSize, isOn, xOffset, and yOffset.  Returns self.

See also:  - printToStderr (BetView)


read:

- read:(NXTypedStream *)theStream

Unarchives the pile from theStream.   Returns self.

See also:  - write:


removeChips:

- removeChips:(int)numChips

Decreases the number of chips the pile tries to draw by numChips, and decreases the piles value by (numChips*chipValue).  Returns self.

See also:  - addChips:


removePile:

- removePile:aPile

Decreases the value of the pile by the amount of aPile, and decreases the number of chips drawn by the number of chips drawn in aPile.  Returns self.

See also:  - addPile:


setAmount:

- setAmount:(int)aValue

Sets the value of the pile to aValue, and increases the number of chips the pile tries to draw by one (if aValue is positive).  Returns self.

See also:  - amount


setChipSize:

- setChipSize:(int)aValue

Sets the size of the NXImage used to display the chips in the pile.  aValue is either NV_CHIPSIZELARGE or NV_CHIPSIZESMALL.  Currently, only NV_CHIPSIZESMALL is implemented.  Returns self.

See also:  - chipSize


setChipType:

- setChipType:(int)aValue

Defines the look of the chips used in the pile.  aValue is one of the following constants:

Constant	Chip Boarder
NV_CHIPTYPE0	White 
NV_CHIPTYPE1	White/Light gray 
NV_CHIPTYPE2	Light gray 
NV_CHIPTYPE3	Light gray/ Dark gray
NV_CHIPTYPE4	Dark gray

Returns self.

See also:  - chipType:


setChipValue:

- setChipValue:(int)aValue

Sets the value of the chips in the pile.   When you add chips with the addChips: method, the value of the pile will increase by the number of chips specified * aValue.  Returns self.

See also:  - chipValue, - addChips:


setDragRow:col:

- setDragRow:(int)row col:(int)col

When dragging a pile, you may want to set the row and column of the BetView you're dragging from, so that later you can tell where or whom it came from.  After creating the drag image with tempDragImage, call this method and send it the row and column that its being dragged from.  Later, when the pile is dropped on a BetView, you can tell where it came from by calling getDragRow:col:.  Returns self.

See also:  - getDragRow:col:


setMaxWidth:maxHeight:

- setMaxWidth:(float)maxwidth maxHeight:(float)maxheight

Sets the maximum width and height that the chips will stack in either the x or y directions.  Returns self.




setNumChips:

- setNumChips:(int)numtodraw

Sets the number of chips that the pile will try and draw to numtodraw.  Returns self.

See also:  - numChips


setOn:

- setOn:(BOOL)isOn

If isOn is YES, the pile will display its value, if NO the pile will display the word "OFF".  Returns self.

See also:  - isOn


setOwnerIndex:

- setOwnerIndex:(int)aPlayerIndex

Gives the pile an owner, but doesn't do anything functionally.  You can use it to differentiate one pile from another.  Returns self.

See also:  - ownerIndex


setTag:

- setTag:(int)aTag

Sets the tag of the pile to aTag.  Returns self.

See also:  - tag


setXOffset:yOffset:

- setXOffset:(float)xoffset yOffset:(float)yoffset

Sets the amount that each chip will be offset from each other in the pile.  Returns self.



showValueInsteadOfTotal:

- showValueInsteadOfTotal:(BOOL)flag

If flag is YES, the pile will display the value set with the setChipValue: method rather than the total value of the pile.  Returns self.

See also:  - showsValue, - setChipValue:


showsValue

- (BOOL)showsValue

Returns YES if the pile shows the chipValue rather than the total value of the pile, NO if not.

See also:  - showValueInsteadOfTotal


tag

- (int)tag

Returns the tag of the pile

See also:  - setTag


tempDragImage

- tempDragImage

Creates and returns an NXImage for the pile, setting its drawing method to drawDragPile:.

See also:  - drawDragPile:


write:

- write:(NXTypedStream *)theStream

Archives the pile to theStream.  Returns self.

See also:  - read:


These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.