File:  [NeXTSTEP 3.3 examples] / Examples / AppKit / Draw / graphicsUndo.subproj / PasteGraphicsChange.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 "drawundo.h"

@interface PasteGraphicsChange(PrivateMethods)

- undoDetails;
- redoDetails;

@end

@implementation PasteGraphicsChange

- initGraphicView:aGraphicView graphics:theGraphics
{
    int i, count;
    
    [super initGraphicView:aGraphicView];
    graphics = [[List alloc] init];
    count = [theGraphics count];
    for (i = 0; i < count; i++) {
	[graphics addObject:[theGraphics objectAt:i]];
    }

    return self;
}

- free
{
    if (![self hasBeenDone])
        [graphics freeObjects];
    return [super free];
}

- (const char *)changeName
{
    return PASTE_OPERATION;
}

- saveBeforeChange
{
    return self;
}

- changeDetailClass
{
    return nil;
}

- undoDetails
{
    int count, i;
    id graphic;
    List *selectedGraphics;
    List *allGraphics;

    selectedGraphics = [graphicView selectedGraphics];
    allGraphics = [graphicView graphics];
    count = [graphics count];
    for (i = 0; i < count; i++) {
	graphic = [graphics objectAt:i];
        [selectedGraphics removeObject:graphic];
        [allGraphics removeObject:graphic];
	[graphic wasRemovedFrom:graphicView];
    }
    [graphicView resetGroupInSlist];
    return self;
}

- redoDetails
{
    int count, i;
    id graphic;
    List *selectedGraphics;
    List *allGraphics;

    selectedGraphics = [graphicView selectedGraphics];
    allGraphics = [graphicView graphics];
    count = [graphics count];
    i = count;
    while (i--) {
	graphic = [graphics objectAt:i];
	[selectedGraphics insertObject:graphic at:0];
	[allGraphics insertObject:graphic at:0];
	[graphic wasAddedTo:graphicView];
        if ([graphic isKindOf:[Group class]]) [graphicView setGroupInSlist:YES];
    }

    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.