This is DecodeCell.m in view mode; [Download] [Up]
#import <appkit/appkit.h>
#import "DecodeCell.h"
static NXImage * successImage = nil;
static NXImage * failImage = nil;
@implementation DecodeCell
+ (void) initialize
{
successImage = [NXImage findImageNamed:"Success.tiff"];
failImage = [NXImage findImageNamed:"Failure.tiff"];
}
- init
{
[super init];
articleIndex = 0;
decodeStatus = NOT_DECODED;
return self;
}
- (int) articleIndex
{
return articleIndex;
}
- (void) setArticleIndex:(int)index
{
articleIndex = index;
}
- (SuccessType_t) decodeStatus
{
return decodeStatus;
}
- (void) setDecodeStatus:(SuccessType_t)status
{
decodeStatus = status;
}
- drawSelf:(const NXRect *)frameRect inView:controlView
{
NXRect textRect = *frameRect;
NXImage * imageToUse = nil;
PSsetgray(NX_LTGRAY);
NXRectFill(frameRect);
NX_X(&textRect) += 20.0;
NX_WIDTH(&textRect) -= 20.0;
[super drawSelf:&textRect inView:controlView];
// Draw the correct image if one has been set.
if ([self decodeStatus] == DECODE_SUCCESSFUL) {
imageToUse = successImage;
}
else if ([self decodeStatus] == DECODE_FAILED) {
imageToUse = failImage;
}
if (imageToUse != nil) {
NXPoint imageOrigin;
NXSize imageSize;
[imageToUse getSize:&imageSize];
imageOrigin.x = NX_X(frameRect) + 2.0;
imageOrigin.y = NX_Y(frameRect) + NX_HEIGHT(frameRect) +
((NX_HEIGHT(frameRect) - imageSize.height) / 2.0);
[imageToUse composite:NX_SOVER toPoint:&imageOrigin];
}
return self;
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.