This is TGIFCell.m in view mode; [Download] [Up]
#import "TGIFCell.h"
#import "TGIF.h"
#import "ListCell.h"
#import "miscutil.h"
#import <appkit/Font.h>
#import <appkit/SelectionCell.h>
#import <appkit/Text.h>
#import <appkit/View.h>
#import <appkit/graphics.h>
#import <dpsclient/psops.h>
#import <string.h>
extern void free();
@implementation TGIFCell : ListCell
-init
{
[super init];
number1=-1;
number2=-1;
number3=-1;
return self;
}
-(char *)emitCmd
{
char cmd[100];
char tmp[30];
strcpy(cmd, command);
if(number1!=-1){
sprintf(tmp, " %d", number1);
strcat(cmd, tmp);
}
if(number2!=-1){
sprintf(tmp, " %d", number2);
strcat(cmd, tmp);
}
if(number3!=-1){
strcat(cmd, tmp);
sprintf(tmp, " %d", number3);
}
strcat(cmd, "\n");
return cmd;
}
- free
{
// since command isn't mallocced, but assigned, we don't have to free()
// free(command);
return [super free];
}
#define FIRST_COLUMN_START 5.0
#define SECOND_COLUMN_START (FIRST_COLUMN_START+70)
#define THIRD_COLUMN_START (SECOND_COLUMN_START+30)
#define FOURTH_COLUMN_START (THIRD_COLUMN_START+30)
- drawInside:(const NXRect *)cellFrame inView:controlView
{
char hitInfo[200];
/* set the font according to our drawing status */
if (NXDrawingStatus != NX_DRAWING) {
[support set];
} else {
[[support screenFont] set];
}
/* erase the cell */
PSsetgray((cFlags1.state || cFlags1.highlighted) ? NX_WHITE : NX_LTGRAY);
NXRectFill(cellFrame);
PSsetgray(NX_BLACK);
PSmoveto(NX_X(cellFrame) + FIRST_COLUMN_START,
NX_Y(cellFrame) + lineHeight - descender);
PSshow(command);
/* draw the number of hits */
if(number1!=-1){
sprintf(hitInfo, "%d", number1);
PSmoveto(NX_X(cellFrame) + SECOND_COLUMN_START,
NX_Y(cellFrame) + lineHeight - descender);
PSshow(hitInfo);
}
if(number2!=-1){
sprintf(hitInfo, "%d", number2);
PSmoveto(NX_X(cellFrame) + THIRD_COLUMN_START,
NX_Y(cellFrame) + lineHeight - descender);
PSshow(hitInfo);
}
if(number3!=-1){
sprintf(hitInfo, "%d", number3);
PSmoveto(NX_X(cellFrame) + FOURTH_COLUMN_START,
NX_Y(cellFrame) + lineHeight - descender);
PSshow(hitInfo);
}
// draw the cell generic stuff
[super drawInside:(const NXRect *)cellFrame inView:controlView];
return self;
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.