home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Examples / AppKit / Draw / graphicsUndo.subproj / PasteGraphicsChange.m < prev    next >
Text File  |  1992-02-09  |  2KB  |  91 lines

  1. #import "drawundo.h"
  2.  
  3. @interface PasteGraphicsChange(PrivateMethods)
  4.  
  5. - undoDetails;
  6. - redoDetails;
  7.  
  8. @end
  9.  
  10. @implementation PasteGraphicsChange
  11.  
  12. - initGraphicView:aGraphicView graphics:theGraphics
  13. {
  14.     int i, count;
  15.     
  16.     [super initGraphicView:aGraphicView];
  17.     graphics = [[List alloc] init];
  18.     count = [theGraphics count];
  19.     for (i = 0; i < count; i++) {
  20.     [graphics addObject:[theGraphics objectAt:i]];
  21.     }
  22.  
  23.     return self;
  24. }
  25.  
  26. - free
  27. {
  28.     if (![self hasBeenDone])
  29.         [graphics freeObjects];
  30.     return [super free];
  31. }
  32.  
  33. - (const char *)changeName
  34. {
  35.     return PASTE_OPERATION;
  36. }
  37.  
  38. - saveBeforeChange
  39. {
  40.     return self;
  41. }
  42.  
  43. - changeDetailClass
  44. {
  45.     return nil;
  46. }
  47.  
  48. - undoDetails
  49. {
  50.     int count, i;
  51.     id graphic;
  52.     List *selectedGraphics;
  53.     List *allGraphics;
  54.  
  55.     selectedGraphics = [graphicView selectedGraphics];
  56.     allGraphics = [graphicView graphics];
  57.     count = [graphics count];
  58.     for (i = 0; i < count; i++) {
  59.     graphic = [graphics objectAt:i];
  60.         [selectedGraphics removeObject:graphic];
  61.         [allGraphics removeObject:graphic];
  62.     [graphic wasRemovedFrom:graphicView];
  63.     }
  64.     [graphicView resetGroupInSlist];
  65.     return self;
  66. }
  67.  
  68. - redoDetails
  69. {
  70.     int count, i;
  71.     id graphic;
  72.     List *selectedGraphics;
  73.     List *allGraphics;
  74.  
  75.     selectedGraphics = [graphicView selectedGraphics];
  76.     allGraphics = [graphicView graphics];
  77.     count = [graphics count];
  78.     i = count;
  79.     while (i--) {
  80.     graphic = [graphics objectAt:i];
  81.     [selectedGraphics insertObject:graphic at:0];
  82.     [allGraphics insertObject:graphic at:0];
  83.     [graphic wasAddedTo:graphicView];
  84.         if ([graphic isKindOf:[Group class]]) [graphicView setGroupInSlist:YES];
  85.     }
  86.  
  87.     return self;
  88. }
  89.  
  90. @end
  91.