home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Examples / AppKit / Draw / graphicsUndo.subproj / DeleteGraphicsChange.m < prev    next >
Text File  |  1995-11-28  |  2KB  |  73 lines

  1. #import "drawundo.h"
  2.  
  3. @interface DeleteGraphicsChange(PrivateMethods)
  4.  
  5. - (void)undoDetails;
  6. - (void)redoDetails;
  7.  
  8. @end
  9.  
  10. @implementation DeleteGraphicsChange
  11.  
  12. - (void)dealloc
  13. {
  14.     if ([self hasBeenDone])
  15.         [graphics removeAllObjects];
  16.     [super dealloc];
  17. }
  18.  
  19. - (NSString *)changeName
  20. {
  21.     return DELETE_OP;
  22. }
  23.  
  24. - (void)saveBeforeChange
  25. {
  26.     [super saveBeforeChange];
  27.     [changeDetails makeObjectsPerform:@selector(recordGraphicPositionIn:) withObject:[graphicView graphics]]; 
  28. }
  29.  
  30. - (void)undoDetails
  31. {
  32.     int count, i;
  33.     id detail, graphic;
  34.     NSMutableArray *allGraphics;
  35.  
  36.     count = [changeDetails count];
  37.     allGraphics = [graphicView graphics];
  38.     for (i = 0; i < count; i++) {
  39.     detail = [changeDetails objectAtIndex:i];
  40.     graphic = [detail graphic];
  41.         [allGraphics insertObject:graphic atIndex:[detail graphicPosition]];
  42.     [graphic wasAddedTo:graphicView];
  43.     }
  44.     [graphicView getSelection]; 
  45. }
  46.  
  47. - (void)redoDetails
  48. {
  49.     int count, i;
  50.     id detail, graphic;
  51.     NSMutableArray *selectedGraphics;
  52.     NSMutableArray *allGraphics;
  53.  
  54.     selectedGraphics = [graphicView selectedGraphics];
  55.     allGraphics = [graphicView graphics];
  56.     count = [changeDetails count];
  57.     for (i = 0; i < count; i++) {
  58.     detail = [changeDetails objectAtIndex:i];
  59.     graphic = [detail graphic];
  60.         [selectedGraphics removeObject:graphic];
  61.         [allGraphics removeObject:graphic];
  62.     [graphic wasRemovedFrom:graphicView];
  63.     }
  64.     [graphicView resetGroupInSlist]; 
  65. }
  66.  
  67. - (Class)changeDetailClass
  68. {
  69.     return [OrderChangeDetail class];
  70. }
  71.  
  72. @end
  73.