ftp.nice.ch/pub/next/developer/objc/appkit/NMK.NIHS.bs.tar.gz#/NMK/Recorders/SliderCellCover.m

This is SliderCellCover.m in view mode; [Download] [Up]

/***** SliderCellCover.m -- SliderCellCover object implementation
	NeXTstep Measurement Kit
	by Alex Meyer <ameyer@phoenix.Princeton.EDU>
	for computer science senior thesis
	18 April 1992 -- created
	20 April 1992 -- role of RSliderCell absorbed
	23 April 1992 -- this file changed from RSlider.m to RSliderCell.m
		utilizes late connect approach & LINKERNAME
	24 April 1992 -- renamed from RSliderCell.m to SliderCellCover.m
		uses object name link to RSliderVars
*****/

#import <sys/time.h>
#import <appkit/Application.h>
#import "RSliderVars.h"
#import "SliderCellCover.h"

#define VARSNAME ("SliderVars")

#define MICRO (1000000.0)
#define DOUBLETIME(stv) ((double) (((unsigned long) (stv).tv_sec) \
	+ (((unsigned long) (stv).tv_usec) / MICRO)))

@implementation SliderCellCover

- makeVarsRect:(const NXRect *)rect
{
	id vars;

	if (!(rect))
		rect = &trackRect;
	vars = [RSliderVars alloc];
	[vars initString:contents
		tag:tag
		rect:rect];
	NXNameObject(VARSNAME,vars,self);
	return (vars);
}


- (BOOL)trackMouse:(NXEvent *)theEvent
	inRect:(const NXRect *)cellFrame
	ofView:controlView
{
	id vars;
	BOOL res;
	int index;
	double time0,time1;
	struct timeval start,finish;
	struct timezone zone;

	gettimeofday(&start,&zone);
	res = [super trackMouse:theEvent
		inRect:cellFrame
		ofView:controlView];
	gettimeofday(&finish,&zone);
	time0 = DOUBLETIME(start);
	time1 = DOUBLETIME(finish);
	if (!(contents))	/* propagate name of Slider */
		contents = NXGetObjectName(controlView);
	vars = NXGetNamedObject(VARSNAME,self);
	if (!(vars))
		vars = [self makeVarsRect:cellFrame];
	[vars incHits];
	[vars timeFrom:time0
		to:time1];
	index = (value - minValue) / (maxValue - minValue) * SLIDERHIST;
	if (index >= SLIDERHIST)
		index = SLIDERHIST - 1;
	[vars incHist:index];
	return (res);
}

@end

#undef DOUBLETIME
#undef MICRO
#undef VARSNAME

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.