ftp.nice.ch/pub/next/games/card/Cribbage.1.1.s.tar.gz#/Cribbage/Cribbage-1.1/ScoreBoardBackground.m

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

// ScoreBoardBackground.m
// Project: Cribbage
// Stephan Wacker
// 93-10-13


#import "ScoreBoardBackground.h"


@implementation ScoreBoardBackground


- makeImage: (BOOL) fromScratch
{
    NXRect	rect;
    
    if( fromScratch ) {
	[image free];
	image = nil;
    }
    
    if( !icon ) return nil;

    [icon getSize: &rect.size];
    rect.origin.x = rect.origin.y = 0;
    
    if( !image ) {
	image = [[NXImage alloc] initSize: &rect.size];
	[image useCacheWithDepth: NX_TwelveBitRGBDepth];
    }
    
    [image lockFocus];
    [icon composite: NX_COPY toPoint: &rect.origin];
    [decoration composite: NX_SOVER toPoint: &rect.origin];
    [image unlockFocus];
    
    return self;
}


- setIcon: (const char *) iconName
{
    id		newIcon = [NXImage findImageNamed: iconName];
    
    if( newIcon ) {
	icon = newIcon;
	[self makeImage: YES];
	[self displayFromOpaqueAncestor: &bounds : 1 : YES];
    }
    
    return self;
}


- setDecoration: (const char *) decorationName
{
    id		newDecoration = [NXImage findImageNamed: decorationName];
    
    if( newDecoration ) {
	decoration = newDecoration;
	[self makeImage: NO];
	[self displayFromOpaqueAncestor: &bounds : 1 : YES];
    }
    
    return self;
}


- initFrame: (const NXRect *) frameRect
{
    [super initFrame: frameRect];
    [self setOpaque: NO];
    
    icon = [NXImage findImageNamed: "board"];
    decoration = [NXImage findImageNamed: "boardDecoration"];
    [self makeImage: YES];
    
    return self;
}


- drawSelf: (const NXRect *) rects : (int) nRect
{
    if( nRect == 3 ) {
	[self drawSelf: rects+1 : 1];
	[self drawSelf: rects+2 : 1];
    } else {
	[image composite: NX_SOVER fromRect: rects toPoint: &rects->origin];
    }
    
    return self;
}


@end	// ScoreBoardBackground

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