home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Education Sampler 1992 [NeXTSTEP]
/
Education_1992_Sampler.iso
/
NeXT
/
GnuSource
/
Chess-9
/
Clock.m
< prev
next >
Wrap
Text File
|
1992-03-07
|
891b
|
53 lines
#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