ftp.nice.ch/pub/next/graphics/vector/PencilTWO.s.tar.gz#/PencilTWO/Source/MultipleSelection.m

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

/*
Pencil V2.0, Copyright 1994, 95 by Florian Marquardt.
This program may be distributed under the terms of the GNU general
public license (Start Pencil and select "Copyright" in the Help panel for a copy of the
license).
Pencil has a built-in TCL interpreter (tcl 7.3 by John Ousterhout). This is under a separate
license (see "Copyright").
*/
#import "MultipleSelection.h"

@implementation MultipleSelection
- (BOOL)selected:(NXEvent *)te:(int *)cp:(id)view
{	int i=[slist count]; while(i--) if([[slist objectAt:i] selected:te:cp:view]) return YES; return NO; }
- (BOOL)move:(NXEvent *)te:(int *)cp:(id)view:(float)bsize
{ return NO;  }
- create:(NXEvent *)te:(int *)cp:(id)view:(float)bsize { return self; }
- createPolyFreehand:(NXEvent *)te:(int *)cp:(id)view:(float)bsize { return self; }
- (void)draw:(NXRect *)re
{	int i, c=[slist count]; for(i=0;i<c;i++) [[slist objectAt:i] draw:re]; }
- (void)drawControl:(NXRect *)re:(int)cp:(float)bsize
{	int i, c=[slist count]; for(i=0;i<c;i++) [[slist objectAt:i] drawControl:re:-1:bsize]; }
- initWithSettings:(char *)name:(NXColor)co1:(NXColor)co2:(float)lw:(char *)dm:(char *)fm:(char *)sm:(char *)ud
{ return self; }
- giveSettings:(char **)name:(NXColor *)co1:(NXColor *)co2:(float *)lw:(char **)dmeth:(char **)fillmeth:(char **)strokemeth:(char **)ud { [[slist objectAt:0] giveSettings:name:co1:co2:lw:dmeth:fillmeth:strokemeth:ud]; return self; }
- setMethodname:(char*)name
{ int i=[slist count]; while(i--) [[slist objectAt:i] setMethodname:name]; return self; }
- setDrawingMethod:(char *)name
{ int i=[slist count]; while(i--) [[slist objectAt:i] setDrawingMethod:name]; return self; }
- setStrokeMethod:(char *)name
{ int i=[slist count]; while(i--) [[slist objectAt:i] setStrokeMethod:name]; return self; }
- setFillMethod:(char *)name
{ int i=[slist count]; while(i--) [[slist objectAt:i] setFillMethod:name]; return self; }
- setSpecialAttributes:(char *)name
{ int i=[slist count]; while(i--) [[slist objectAt:i] setSpecialAttributes:name]; return self; }
- setColor1:(NXColor)col
{ int i=[slist count]; while(i--) [[slist objectAt:i] setColor1:col]; return self; }
- setColor2:(NXColor)col
{ int i=[slist count]; while(i--) [[slist objectAt:i] setColor2:col]; return self; }
- setLineWidth:(float)lw
{ int i=[slist count]; while(i--) [[slist objectAt:i] setLineWidth:lw]; return self; }
- addTranslation:(float)dtx:(float)dty
{ int i=[slist count]; while(i--) [[slist objectAt:i] addTranslation:dtx:dty]; return self; }
- (void)rotateAroundCenter:(float)x:(float)y fromPoint:(NXPoint *)pt1 toPoint:(NXPoint *)pt2
{ int i=[slist count]; while(i--) [[slist objectAt:i] rotateAroundCenter:x:y fromPoint:pt1 toPoint:pt2]; }
- insertNextPoint:(int *)cp { return self; }
- insertPoint:(int *)cp { return self; }
- deletePoint:(int *)cp { return self; }
- calculateBoundingBox:(id)view
{
NXRect thebounds; int i=[slist count]-1;
[[slist objectAt:i] calculateBoundingBox:view]; [[slist objectAt:i] giveBounds:&bounds];
while(i--) { [[slist objectAt:i] calculateBoundingBox:view]; [[slist objectAt:i] giveBounds:&thebounds]; NXUnionRect( &thebounds, &bounds); } return self;
}
- giveBounds:(NXRect *)bnd
{  *bnd=bounds; return self; }
- initWithGraphic:(id)graphic
{	[super init]; slist=[[[List alloc] init] addObject:graphic]; return self; }
- initEmpty
{	[super init]; slist=[[List alloc] init]; return self; }
- addToSelection:(id)graphic posFromEnd:(int)pos
{	[slist insertObject:graphic at:[slist count]-pos]; return self; }
- free
{
	int i;
	if(slist)
	{
	i=[slist count];
	while(i--) [[slist objectAt:i] select:NO];
	[slist free];
	}
	return [super free];
}
- freeOrig
{
	return [super free];
}
- select:(BOOL)yesno { if(yesno==NO) { [self free]; } return self; }
- toFrontIn:(id)list
{
	int i, c=[list count]; id g;
	for(i=0;c--;++i) if([g=[list objectAt:i] selected]) { [list removeObjectAt:i];  [list addObject:g]; --i; }
	return self;
}
- toBackIn:(id)list
{
	int i,c=[list count]; id g;
	for(i=c-1;c--;--i) if([g=[list objectAt:i] selected]) { [list removeObjectAt:i];  [list insertObject:g at:0]; ++i; }
	return self;
}
- deleteThemIn:(id)list
{
	int i=[slist count]; id g;
	while(i--) { [list removeObject:g=[slist objectAt:i]]; [g free]; }
	[slist free];
	slist=nil;
	return [self free];
}
- (BOOL)partOfSelection:(id)graphic
{
	if([slist indexOf:graphic]==NX_NOT_IN_LIST) return(NO); else return(YES);
}
- addElementsTo:(id)list
{
	int i, c=[slist count];
	for(i=0;i<c;i++)	[list addObject:[[slist objectAt:i] select:YES]];
	return self;
}

- moveElementsFrom:(id)list1 to:(id)list2
{
	int i, c=[slist count];
	for(i=0;i<c;i++)	{ [list1 removeObject:[slist objectAt:i]]; [list2 addObject:[[slist objectAt:i] select:YES]]; }
	return self;
}

- (void)scaleCenter:(float)cx:(float)cy by:(float)scx:(float)scy
{ int i=[slist count]; while(i--) [[slist objectAt:i] scaleCenter:cx:cy by:scx:scy];
}

- slist { return slist; }

- write:(NXTypedStream *)stream
{
	int i,n;

	[super write:stream];
	n=[slist count];
	NXWriteType(stream, "i", &n);
	for(i=0;i<n;i++)
		NXWriteObject(stream, [slist objectAt:i]);
	return self;
}

- read:(NXTypedStream *)stream
{
	int i,n;

	[super read:stream];
	n=[slist count];
	NXReadType(stream, "i", &n);
	if(slist)	[slist free];
	[slist=[List alloc] setAvailableCapacity:n];
	for(i=0;i<n;i++)
		[slist addObject:NXReadObject(stream)];
	return self;
}
@end

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