File:  [NeXTSTEP 3.3 examples] / Examples / AppKit / Draw / undo.subproj / MultipleChange.m
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:48:39 2018 UTC (8 years, 1 month ago) by root
Branches: NeXT, MAIN
CVS tags: NeXTSTEP33, HEAD
Sample Programs from NeXSTEP 3.3

#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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.