This is RectangleCell.m in view mode; [Download] [Up]
#import "RectangleCell.h" // which imports appkit
#import "RectangleCellWraps.h"
@implementation RectangleCell
- init
{
id returnval=[super init];
line_width=4;
line_gray=0;
fill_gray=1;
rectangle_size.width=30;
rectangle_size.height=20;
return returnval;
}
- drawSelf:(const NXRect*) rects:(int) rectCount
{
RectangleCell_draw(coord.x, coord.y,
rectangle_size.width, rectangle_size.height,
line_width, line_gray, fill_gray);
return self;
}
- (BOOL) hit:(NXEvent*) theEvent
{
NXPoint start=theEvent->location;
NXRect temp_rect;
// Load temp_rect with size and coordinates
temp_rect.size=rectangle_size;
temp_rect.origin=coord;
// convert event's point into view coordinate system
[view convertPoint:&start fromView:nil];
return NXPointInRect(&start, &temp_rect);
}
- mouseDown:(NXEvent*) theEvent
{
return [super mouseDown:theEvent];
}
- mouseDragged:(NXEvent*) theEvent
{
NXPoint start=theEvent->location;
[view convertPoint:&start fromView:nil];
coord=start;
return [super mouseDragged:theEvent];
}
- mouseUp:(NXEvent*) theEvent
{
return [super mouseUp:theEvent];
}
@endThese are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.