Annotation of Examples/AppKit/Draw/graphicsUndo.subproj/GraphicsChange.m, revision 1.1

1.1     ! root        1: #import "drawundo.h"
        !             2: 
        !             3: /*
        !             4:  * Please refer to external documentation about Draw
        !             5:  * with Undo for information about what GraphicsChange 
        !             6:  * is and where it fits in.
        !             7:  */
        !             8: 
        !             9: @interface GraphicsChange(PrivateMethods)
        !            10: 
        !            11: - undoDetails;
        !            12: - redoDetails;
        !            13: 
        !            14: @end
        !            15: 
        !            16: @implementation GraphicsChange
        !            17: 
        !            18: - initGraphicView:aGraphicView
        !            19: {
        !            20:     [super init];
        !            21:     graphicView = aGraphicView;
        !            22:     graphics = nil;
        !            23:     changeDetails = nil;
        !            24: 
        !            25:     return self;
        !            26: }
        !            27: 
        !            28: - initGraphicView:aGraphicView forChangeToGraphic:aGraphic
        !            29: {
        !            30:     [self initGraphicView:aGraphicView];
        !            31:     graphicsToChange = [[List alloc] initCount:1];
        !            32:     [graphicsToChange addObject:aGraphic];
        !            33:     return self;
        !            34: }
        !            35: 
        !            36: - free
        !            37: {
        !            38:     [graphics free];
        !            39:     [graphicsToChange free];
        !            40:     if (changeDetails != nil) {
        !            41:        [changeDetails freeObjects];
        !            42:        [changeDetails free];
        !            43:     }
        !            44: 
        !            45:     return [super free];
        !            46: }
        !            47: 
        !            48: - saveBeforeChange
        !            49: {
        !            50:     List *selectedGraphics;
        !            51:     int i, count;
        !            52:     id changeDetailClass, changeDetail;
        !            53:     BOOL changeExpected = NO;
        !            54: 
        !            55:     if (!graphicsToChange) {
        !            56:        selectedGraphics = [graphicView selectedGraphics];
        !            57:     } else {
        !            58:        selectedGraphics = graphicsToChange;
        !            59:     }
        !            60:     count = [selectedGraphics count];
        !            61:     if (count == 0) {
        !            62:         [self disable];
        !            63:     } else {
        !            64:        changeDetailClass = [self changeDetailClass];
        !            65:        if (changeDetailClass != nil)
        !            66:            changeDetails = [[List alloc] init];
        !            67:        else
        !            68:            changeExpected = YES;
        !            69:        graphics = [[List alloc] init];
        !            70:        for (i = 0; i < count; i++) {
        !            71:            [graphics addObject:[selectedGraphics objectAt:i]];
        !            72:            if (changeDetailClass != nil) {
        !            73:                changeDetail = [[changeDetailClass alloc] initGraphic:[selectedGraphics objectAt:i] change:self];
        !            74:                changeExpected = changeExpected || [changeDetail changeExpected];
        !            75:                [changeDetails addObject:changeDetail];
        !            76:            }
        !            77:        }
        !            78:     }
        !            79:     
        !            80:     if (!changeExpected)
        !            81:         [self disable];
        !            82:        
        !            83:     return self;
        !            84: }
        !            85: 
        !            86: - undoChange
        !            87: {
        !            88:     [graphicView redrawGraphics:graphics afterChangeAgent:self performs:@selector(undoDetails)];
        !            89:     [[graphicView window] flushWindow];
        !            90:     [[[NXApp inspectorPanel] delegate] loadGraphic:[graphicView selectedGraphic]]; 
        !            91: 
        !            92:     return [super undoChange];
        !            93: }
        !            94: 
        !            95: - redoChange
        !            96: {
        !            97:     [graphicView redrawGraphics:graphics afterChangeAgent:self performs:@selector(redoDetails)];
        !            98:     [[graphicView window] flushWindow];
        !            99:     [[[NXApp inspectorPanel] delegate] loadGraphic:[graphicView selectedGraphic]]; 
        !           100: 
        !           101:     return [super redoChange];
        !           102: }
        !           103: 
        !           104: - changeDetailClass
        !           105: /*
        !           106:  * To be overridden 
        !           107:  */
        !           108: {
        !           109:     return [ChangeDetail class];
        !           110: }
        !           111: 
        !           112: - undoDetails
        !           113: /*
        !           114:  * To be overridden 
        !           115:  */
        !           116: {
        !           117:     return self;
        !           118: }
        !           119: 
        !           120: - redoDetails
        !           121: /*
        !           122:  * To be overridden 
        !           123:  */
        !           124: {
        !           125:     return self;
        !           126: }
        !           127: 
        !           128: @end

unix.superglobalmegacorp.com

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