ftp.nice.ch/pub/next/games/board/Risk.0.97.s.tar.gz#/RiskSource0.97/Risk/DeckView.m

This is DeckView.m in view mode; [Download] [Up]

// DeckView.m
// Part of Risk by Mike Ferris

#import "DeckView.h"
#import <objc/List.h>
#import <appkit/TextFieldCell.h>
#import <appkit/Text.h>
#import <appkit/Font.h>
#import "Card.h"
#import "CardManager.h"

@implementation DeckView

+ initialize
{
	if (self == [DeckView class])  {
		[self setVersion:1];
	}
	return self;
}

- initFrame:(const NXRect *)f
{
	[super initFrame:f];
	myTextCell = [[TextFieldCell allocFromZone:[self zone]] init];
	[myTextCell setBackgroundGray:NX_LTGRAY];
	[myTextCell setBezeled:NO];
	[myTextCell setBordered:NO];
	[myTextCell setFont:[Font newFont:"Times-Roman" size:10.0]];
	[myTextCell setAlignment:NX_LEFTALIGNED];
	[myTextCell setEditable:NO];
	[myTextCell setSelectable:NO];
	[myTextCell setTextGray:NX_BLACK];
	
	return self;
}

- free
{
	[myTextCell free];
	return [super free];
}

- setDeck:anObject
{
	myDeck = anObject;
	return self;
}

#define X_INIT		6.0
#define Y_INIT		7.0
#define RECTWIDTH	20.0
#define RECTHEIGHT	14.0
- drawSelf:(const NXRect *)rects :(int)rectCount
{
	int listCount, i;
	NXRect f;
	
	
	NXDrawGrayBezel(&bounds, NULL);
	f.origin.x = X_INIT;
	f.origin.y = Y_INIT;
	f.size.width = RECTWIDTH;
	f.size.height = RECTHEIGHT;
	if (myDeck==nil)  {
		f.size.width = bounds.size.width-(X_INIT*2);
		[myTextCell setStringValue:"No Deck"];
		[myTextCell drawSelf:&f inView:self];
		return self;
	}
	listCount=[myDeck count];
	if (listCount==0)  {
		f.size.width = bounds.size.width-(X_INIT*2);
		[myTextCell setStringValue:"List Empty"];
		[myTextCell drawSelf:&f inView:self];
		return self;
	}
	for (i=0;i<listCount;i++)  {
		[myTextCell setIntValue:[[myDeck objectAt:i] countryNum]];
		[myTextCell drawSelf:&f inView:self];
		f.origin.x += RECTWIDTH;
	}
	return self;
}

@end

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