This is Clock.m in view mode; [Download] [Up]
#import <appkit/appkit.h>
#import "Clock.h"
static renderHand(float col,float len,int minute)
{
PSgsave();
PSsetgray(col);
PStranslate(31.0,32.0);
PSrotate(-6.0*minute);
PSmoveto(0.0,0.0);
PSrlineto(0.0,len);
PSstroke();
PSgrestore();
return;
}
@implementation Clock
+ newFrame:(NXRect const *)theFrame
{
NXRect f;
f = *theFrame;
f.size.width = 64.0;
f.size.height = 64.0;
self = [super newFrame: &f];
background = [Bitmap findBitmapFor: "clock"];
return self;
}
- setSeconds:(int)s { seconds = s; }
- (int)getSeconds { return seconds; }
- drawSelf:(NXRect *)rects :(int)rectCount
{
NXPoint p;
p.x = p.y = 0.0;
PSgsave();
[background composite: NX_COPY toPoint: &p];
renderHand(0.333,20.0,seconds%60);
renderHand(0.0,20.0,seconds/60);
renderHand(0.,16.,seconds/3600);
PSgrestore();
return self;
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.