ftp.nice.ch/pub/next/science/mathematics/HippoDraw.2.0.s.tar.gz#/HippoDraw/Hippo.bproj/Draw.subproj/undo.subproj/MultipleChange.m

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

#import "change.h"

@implementation MultipleChange

- init
{
    [super init];
    lastChange = nil;
    changes = [[List alloc] init];
    name = NULL;

    return self;
}

- initChangeName:(const char *)changeName
{
    [self init];
    name = changeName;
    return self;
}

- free
{
    [[changes freeObjects] free];
    return [super free];
}

- (const char *)changeName
{
    if (name != NULL)
        return name;

    if (lastChange != nil)
	return [lastChange changeName];

    return("");
}

- undoChange
{
    int i;

    for (i = [changes count] - 1; i >= 0; i--) {
	[[changes objectAt:i] undoChange];
    }

    return [super undoChange];
}

- redoChange
{
    int i, count;

    count = [changes count];
    for (i = 0; i < count; i++) {
	[[changes objectAt:i] redoChange];
    }

    return [super redoChange];
}

- (BOOL)subsumeChange:change
{
    if (lastChange != nil) {
	return [lastChange subsumeChange:change];
    } else {
	return NO;
    }
}

- (BOOL)incorporateChange:change
{
    if (lastChange != nil && [lastChange incorporateChange:change]) {
	return YES;
    }

    [changes addObject:change];
    lastChange = change;
    return YES;
}

- finishChange
{
    if (lastChange != nil) {
	[lastChange finishChange];
    }

    return self;
}

@end

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