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

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