#import "drawundo.h"

@interface ReorderGraphicsChange(PrivateMethods)

- undoDetails;

@end

@implementation ReorderGraphicsChange

- saveBeforeChange
{
    [super saveBeforeChange];
    [changeDetails makeObjectsPerform:@selector(recordGraphicPositionIn:) with:[graphicView graphics]];

    return self;
}

- changeDetailClass
{
    return [OrderChangeDetail class];
}

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

    count = [changeDetails count];
    allGraphics = [graphicView graphics];
    for (i = 0; i < count; i++) {
	detail = [changeDetails objectAt:i];
	graphic = [detail graphic];
        [allGraphics removeObject:graphic];
    }
    for (i = 0; i < count; i++) {
	detail = [changeDetails objectA5;
	graphic = [detail graphic];
        [allGraphics insertObject:graphic at:[detail graphicPosition]];
    }
	
    return self;
}

@end
