This is LPCView.m in view mode; [Download] [Up]
/* Generated by Interface Builder */
#import "LPCView.h"
#import "LPCPlot.h"
#import <appkit/Window.h>
#import <appkit/Application.h>
#import <dpsclient/wraps.h>
#import <dpsclient/dpsclient.h>
/*
* Shorthand for drawing a hairline cursor
*/
#define CURSORL(w) PScompositerect(cursorloc, 0, w, NX_HEIGHT(&frame), NX_HIGHLIGHT);
@implementation LPCView
+ newFrame:(const NXRect *)frameRect
{
self = [super newFrame:frameRect];
width = 0.0;
cursorloc = 0.0;
[self setCursor:NO];
[self setCursorType:HAIRLINE];
return self;
}
- drawSelf:(const NXRect *)rects :(int)rectCount
{
PSsetgray(NX_WHITE);
[self lockFocus];
[self unlockFocus];
[self setCursor:NO];
width = 0.0;
if (parent)
[parent drawData];
[self drawCurs];
return self;
}
#define DRAG_MASK (NX_MOUSEUPMASK|NX_MOUSEDRAGGEDMASK)
- mouseDown:(NXEvent *)event
{
int oldMask;
NXPoint p;
[self lockFocus];
oldMask = [[self window] addToEventMask:DRAG_MASK];
if ([self cursorOn]) {
CURSORL(width); // off
}
cursorloc = -1.0;
width = 1.0;
[self setCursor:YES];
p = event->location;
[self convertPoint:&p fromView:nil];
p.x = (p.x < 0.0) ? 0.0 : p.x;
p.x = (p.x > NX_WIDTH(&bounds)) ? NX_WIDTH(&bounds) : p.x;
cursorloc = p.x;
CURSORL(width); // on
for (;;) {
event = [NXApp getNextEvent:DRAG_MASK];
switch (event->type) {
case NX_MOUSEDRAGGED :
switch([self cursorType]) {
case SELECTION :
p = event->location;
[self convertPoint:&p fromView:nil];
p.x = (p.x < 0.0) ? 0.0 : p.x;
p.x = (p.x > NX_WIDTH(&bounds)) ? NX_WIDTH(&bounds) : p.x;
CURSORL(width); // off
width = (p.x - cursorloc);
CURSORL(width); // on
break;
case HAIRLINE :
p = event->location;
[self convertPoint:&p fromView:nil];
p.x = (p.x < 0.0) ? 0.0 : p.x;
p.x = (p.x > NX_WIDTH(&bounds)) ? NX_WIDTH(&bounds) : p.x;
CURSORL(width); // off
width = 1.0;
cursorloc = p.x;
CURSORL(width); // on
break;
}
break;
case NX_MOUSEUP :
goto done;
break;
}
[parent updateCursor:self];
[[self window] flushWindow];
NXPing(); // use only if there is a speed problem
}
done: [[self window] setEventMask:oldMask];
[self unlockFocus];
[parent updateCursor:self];
return self;
}
- drawCurs
{
[self lockFocus];
CURSORL(width);
[[self window] flushWindow];
[self unlockFocus];
[self setCursor:YES];
return self;
}
- changeCurs:(float)loc:(float)wid
{
[self lockFocus];
if ([self cursorOn]) {
CURSORL(width); // off
}
cursorloc = loc;
width = wid;
CURSORL(width);
[[self window] flushWindow];
NXPing();
[self unlockFocus];
return self;
}
- drawPlot:(float *)data :(char *)ops :(float *)bbox :(int) num :(float) scale
{
if (!num)
return self;
[self lockFocus];
PSsetgray(scale);
DPSDoUserPath((void *)data, num*4, dps_float, ops, num*2, (void *)bbox, dps_ustroke);
[self unlockFocus];
return self;
}
- setCursor:(BOOL)val
{
displayCursor = val;
return self;
}
- (BOOL) cursorOn
{
return displayCursor;
}
- (BOOL) acceptsFirstResponder
{
return YES;
}
- setDelegate:anObject
{
delegate = anObject;
return self;
}
- setParent:par
{
parent = par;
return self;
}
- (int) getcurPos
{
return cursorloc;
}
- (int) getWidth
{
return width;
}
- setCursorType:(int)type
{
cursortype = type;
return self;
}
- (int)cursorType
{
return cursortype;
}
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.