This is PlotView.m in view mode; [Download] [Up]
/* Generated by Interface Builder */
#import "PlotView.h"
@implementation PlotView
-initFrame: (const NXRect *)aRect
{
[super initFrame:aRect];
[self setFlipped:YES];
return self;
}
#define X(x) ((NXCoord)x * xscale)
#define Y(y) ((NXCoord)(4095 - y) * yscale)
-display_commands: (char **)cmds : (int)ncmds
{
int i, x, y;
char *cmd, *str;
/*
* Clear screen and set scale factors.
*/
[self op_clear];
xscale = NX_WIDTH(&bounds) / 4096.0;
yscale = NX_HEIGHT(&bounds) / 4096.0;
for (i = 0; i < ncmds; i++) {
cmd = cmds[i];
switch (cmd[0]) {
case 'M':
sscanf(cmd, "M%4d%4d", &cx, &cy);
break;
case 'V':
sscanf(cmd, "V%4d%4d", &x, &y);
[self op_vector: x : y];
break;
case 'T':
sscanf(cmd, "T%4d%4d", &x, &y);
str = cmd + 9;
[self op_text: x : y : str];
break;
case 'J':
sscanf(cmd, "J%4d", &jmode);
break;
default:
;
}
}
NXPing();
return self;
}
/* clear window */
-op_clear
{
[self lockFocus];
PSsetgray(NX_WHITE);
NXRectFill(&bounds);
[self unlockFocus];
cx = cy = jmode = ltype = 0;
return self;
}
/* draw a line from cx,cy to x,y */
-op_vector: (int)x : (int)y
{
[self lockFocus];
PSsetgray(NX_BLACK);
draw_line(X(cx), Y(cy), X(x), Y(y));
[self unlockFocus];
cx = x; cy = y;
return self;
}
-op_text: (int)x : (int)y : (char *)str
{
int len = strlen(str);
[self lockFocus];
PSsetgray(NX_BLACK);
switch (jmode) {
case 0: /* left justified */
show_lj(X(x), Y(y), str, len);
break;
case 1: /* centered */
show_ctr(X(x), Y(y), str, len);
break;
case 2: /* right justified */
show_rj(X(x), Y(y), str, len);
}
[self unlockFocus];
return self;
}
-op_linetype: (int)ltype
{
return self;
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.