This is PARuler.m in view mode; [Download] [Up]
#import "PARuler.h"
@implementation PARuler : View
- initFrame:(const NXRect *)rect
{
[super initFrame:rect];
return self;
}
- (int)direction { return direction; }
- setDirection:(int)value { direction = value; return self; }
- (BOOL)isHorizontal { return direction == DIRECTION_HORIZONTAL; }
- setHorizontal { return [self setDirection:DIRECTION_HORIZONTAL]; }
- (BOOL)isVertical { return direction == DIRECTION_VERTICAL; }
- setVertical { return [self setDirection:DIRECTION_VERTICAL]; }
- drawSelf:(const NXRect *)rect :(int)count
{
int i;
NXSetColor(NX_COLORLTGRAY);
NXRectFill(rect);
NXRectClip(rect);
if([self isHorizontal]) {
PSnewpath();
for(i=NX_X(&bounds); i<NX_MAXX(&bounds); i+=20) {
PSmoveto(i, NX_Y(&bounds));
PSlineto(i, NX_MAXY(&bounds)/2);
}
PSgsave();
NXSetColor(NX_COLORDKGRAY);
PSstroke();
PSgrestore();
PStranslate(1,0);
NXSetColor(NX_COLORWHITE);
PSstroke();
}
else {
PSnewpath();
for(i=NX_Y(&bounds); i<NX_MAXY(&bounds); i+=20) {
PSmoveto(NX_X(&bounds), i);
PSlineto(NX_MAXX(&bounds)/2, i);
}
PSgsave();
NXSetColor(NX_COLORDKGRAY);
PSstroke();
PSgrestore();
PStranslate(0,-1);
NXSetColor(NX_COLORWHITE);
PSstroke();
}
return self;
}
- write:(NXTypedStream *)stream
{
[super write:stream];
NXWriteType(stream, "i", &direction);
return self;
}
- read:(NXTypedStream *)stream
{
[super read:stream];
NXReadType(stream, "i", &direction);
return self;
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.