Annotation of Examples/AppKit/Draw/graphicsUndo.subproj/GridChange.m, revision 1.1.1.1

1.1       root        1: #import "drawundo.h"
                      2: 
                      3: @interface GridChange(PrivateMethods)
                      4: 
                      5: @end
                      6: 
                      7: @implementation GridChange
                      8: 
                      9: - initGraphicView:aGraphicView
                     10: {
                     11:     [super init];
                     12:     graphicView = aGraphicView;
                     13: 
                     14:     return self;
                     15: }
                     16: 
                     17: - (const char *)changeName
                     18: {
                     19:     return NXLocalStringFromTable("Operations", "Grid Change", NULL, "The operation of changing the spacing or color of the grid.");
                     20: }
                     21: 
                     22: - saveBeforeChange
                     23: {
                     24:     oldSpacing = [graphicView gridSpacing];
                     25:     oldGray = [graphicView gridGray];
                     26:     oldVisible = [graphicView gridIsVisible];
                     27:     oldEnabled = [graphicView gridIsEnabled];
                     28:     return self;
                     29: }
                     30: 
                     31: - undoChange
                     32: {
                     33:     newSpacing = [graphicView gridSpacing];
                     34:     newGray = [graphicView gridGray];
                     35:     newVisible = [graphicView gridIsVisible];
                     36:     newEnabled = [graphicView gridIsEnabled];
                     37: 
                     38:     [[self changeManager] disableChanges:self];
                     39:        [graphicView setGridSpacing:oldSpacing andGray:oldGray];
                     40:        [graphicView setGridVisible:oldVisible];
                     41:        [graphicView setGridEnabled:oldEnabled];
                     42:     [[self changeManager] enableChanges:self];
                     43:     return [super undoChange];
                     44: }
                     45: 
                     46: - redoChange
                     47: {
                     48:     [[self changeManager] disableChanges:self];
                     49:        [graphicView setGridSpacing:newSpacing andGray:newGray];
                     50:        [graphicView setGridVisible:newVisible];
                     51:        [graphicView setGridEnabled:newEnabled];
                     52:     [[self changeManager] enableChanges:self];
                     53:     return [super redoChange];
                     54: }
                     55: 
                     56: - (BOOL)subsumeChange:change
                     57: /*
                     58:  * ChangeManager will call subsumeChange: when we are the last 
                     59:  * completed change and a new change has just begun. We override
                     60:  * the subsumeChange: because we want to consolidate multiple
                     61:  * grid changes into a single change. For example, if the user
                     62:  * selects the menu item "Show Grid" and then selects the menu
                     63:  * item "Turn Grid On", we'll only leave a single GridChange in
                     64:  * the ChangeManager's list of changes.Both changes can then be
                     65:  * be undone and redone in one action.
                     66:  */
                     67: {
                     68:     if ([change isKindOf:[GridChange class]]) {
                     69:         [self saveBeforeChange];
                     70:         return YES;
                     71:     } else {
                     72:         return NO;
                     73:     }
                     74: }
                     75: 
                     76: @end

unix.superglobalmegacorp.com

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