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

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

#import "drawundo.h"

@interface GridChange(PrivateMethods)

@end

@implementation GridChange

- initGraphicView:aGraphicView
{
    [super init];
    graphicView = aGraphicView;

    return self;
}

- (const char *)changeName
{
    return NXLocalStringFromTable("Operations", "Grid Change", NULL, "The operation of changing the spacing or color of the grid.");
}

- saveBeforeChange
{
    oldSpacing = [graphicView gridSpacing];
    oldGray = [graphicView gridGray];
    oldVisible = [graphicView gridIsVisible];
    oldEnabled = [graphicView gridIsEnabled];
    return self;
}

- undoChange
{
    newSpacing = [graphicView gridSpacing];
    newGray = [graphicView gridGray];
    newVisible = [graphicView gridIsVisible];
    newEnabled = [graphicView gridIsEnabled];

    [[self changeManager] disableChanges:self];
	[graphicView setGridSpacing:oldSpacing andGray:oldGray];
	[graphicView setGridVisible:oldVisible];
	[graphicView setGridEnabled:oldEnabled];
    [[self changeManager] enableChanges:self];
    return [super undoChange];
}

- redoChange
{
    [[self changeManager] disableChanges:self];
	[graphicView setGridSpacing:newSpacing andGray:newGray];
	[graphicView setGridVisible:newVisible];
	[graphicView setGridEnabled:newEnabled];
    [[self changeManager] enableChanges:self];
    return [super redoChange];
}

- (BOOL)subsumeChange:change
/*
 * ChangeManager will call subsumeChange: when we are the last 
 * completed change and a new change has just begun. We override
 * the subsumeChange: because we want to consolidate multiple
 * grid changes into a single change. For example, if the user
 * selects the menu item "Show Grid" and then selects the menu
 * item "Turn Grid On", we'll only leave a single GridChange in
 * the ChangeManager's list of changes.Both changes can then be
 * be undone and redone in one action.
 */
{
    if ([change isKindOf:[GridChange class]]) {
        [self saveBeforeChange];
        return YES;
    } else {
        return NO;
    }
}

@end

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