home *** CD-ROM | disk | FTP | other *** search
/ OpenStep (Enterprise) / OpenStepENTCD.toast / OEDEV / DEV.Z / CreateGraphicsChange.m < prev    next >
Encoding:
Text File  |  1995-11-28  |  1.7 KB  |  72 lines

  1. #import "drawundo.h"
  2.  
  3. @interface CreateGraphicsChange(PrivateMethods)
  4.  
  5. @end
  6.  
  7. @implementation CreateGraphicsChange
  8.  
  9. - initGraphicView:aGraphicView graphic:aGraphic
  10. {
  11.     [super init];
  12.     graphicView = aGraphicView;
  13.     graphic = aGraphic;
  14.     startEditingChange = nil;
  15.  
  16.     return self;
  17. }
  18.  
  19. - (void)dealloc
  20. {
  21.     if (![self hasBeenDone])
  22.         [graphic release];
  23.     if (startEditingChange)
  24.         [startEditingChange release];
  25.     [super dealloc];
  26. }
  27.  
  28. - (NSString *)changeName
  29. {
  30.     return [NSString stringWithFormat:NEW_CHANGE_OP, [graphic title]];
  31. }
  32.  
  33. - (void)undoChange
  34. {
  35.     if (startEditingChange)
  36.         [startEditingChange undoChange];
  37.     [graphicView removeGraphic:graphic];
  38.     [[[NSApp inspectorPanel] delegate] loadGraphic:[graphicView selectedGraphic]]; 
  39.     [super undoChange]; 
  40. }
  41.  
  42. - (void)redoChange
  43. {
  44.     [graphicView insertGraphic:graphic];
  45.     [[[NSApp inspectorPanel] delegate] loadGraphic:[graphicView selectedGraphic]];
  46.     if (startEditingChange)
  47.         [startEditingChange redoChange];
  48.     [super redoChange]; 
  49. }
  50.  
  51. - (BOOL)incorporateChange:change
  52. /*
  53.  * ChangeManager will call incorporateChange: if another change
  54.  * is started while we are still in progress (after we've 
  55.  * been sent startChange but before we've been sent endChange). 
  56.  * We override incorporateChange: because we want to
  57.  * incorporate a StartEditingGraphicsChange if it happens.
  58.  * Rather than know how to undo and redo the start-editing stuff,
  59.  * we'll simply keep a pointer to the StartEditingGraphicsChange
  60.  * and ask it to undo and redo whenever we undo or redo.
  61.  */
  62. {
  63.     if ([change isKindOfClass:[StartEditingGraphicsChange class]]) {
  64.         startEditingChange = change;
  65.         return YES;
  66.     } else {
  67.         return NO;
  68.     }
  69. }
  70.  
  71. @end
  72.