home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / Rhapsody / Graphics / Morph-2.0a / MorphLineInspector.m < prev    next >
Encoding:
Text File  |  1998-01-07  |  4.7 KB  |  120 lines

  1. // MorphLineInspector.m 
  2. //
  3. // created by Martin Wennerberg on Mon 05-Jan-1998
  4. //
  5. // when        who    modification
  6.  
  7. #import "MorphLineInspector.h"
  8. #import "MorphLine.h"
  9. #import "InspectorController.h"
  10.  
  11. @implementation MorphLineInspector
  12. - (NSView *) view
  13. {
  14.     if ([super view] == nil)
  15.         [NSBundle loadNibNamed:@"MorphLineInspector.nib" owner: self];
  16.     
  17.     return [super view];
  18. }
  19.  
  20. - (BOOL) isValidInspectorForTargets:(NSArray *)inspectedObjects
  21. {
  22.     NSEnumerator *objEnum = [inspectedObjects objectEnumerator];
  23.     id            obj;
  24.  
  25.     if ([inspectedObjects count] == 0)
  26.         return NO;
  27.  
  28.     while ((obj = [objEnum nextObject]))
  29.         if (![obj isKindOfClass:[MorphLine class]])
  30.             return NO;
  31.     
  32.     return YES;
  33. }
  34.  
  35. - (void) revert:sender
  36. {
  37.     NSArray        *lines = [self targets];
  38.     MorphLine    *line = [lines lastObject];
  39.  
  40.     if (line == nil)
  41.         return;
  42.  
  43.     [startX0Field setStringValue:[NSString stringWithFormat:@"%.2f", [line startPointAtDelta:0].x * 100.0]];
  44.     [startY0Field setStringValue:[NSString stringWithFormat:@"%.2f", [line startPointAtDelta:0].y * 100.0]];
  45.     [startX1Field setStringValue:[NSString stringWithFormat:@"%.2f", [line startPointAtDelta:1].x * 100.0]];
  46.     [startY1Field setStringValue:[NSString stringWithFormat:@"%.2f", [line startPointAtDelta:1].y * 100.0]];
  47.     [endX0Field setStringValue:[NSString stringWithFormat:@"%.2f", [line endPointAtDelta:0].x * 100.0]];
  48.     [endY0Field setStringValue:[NSString stringWithFormat:@"%.2f", [line endPointAtDelta:0].y * 100.0]];
  49.     [endX1Field setStringValue:[NSString stringWithFormat:@"%.2f", [line endPointAtDelta:1].x * 100.0]];
  50.     [endY1Field setStringValue:[NSString stringWithFormat:@"%.2f", [line endPointAtDelta:1].y * 100.0]];
  51.  
  52.     [(NSMatrix *)[startX0Field controlView] setEnabled:([lines count] == 1)];
  53.     [(NSMatrix *)[endX0Field controlView] setEnabled:([lines count] == 1)];
  54.     
  55.     [moveStartControl     setFloatValue:[line moveStartDelta]];    
  56.     [moveEndControl       setFloatValue:[line moveEndDelta]];
  57.     [dissolveStartControl setFloatValue:[line dissolveStartDelta]];
  58.     [dissolveEndControl   setFloatValue:[line dissolveEndDelta]];
  59.     [[self view] setNeedsDisplay:YES];
  60. }
  61.  
  62. - (void) setValues:sender
  63. {
  64.     NSPoint       start0, end0, start1, end1;
  65.     float         moveStart, moveEnd, dissolveStart, dissolveEnd;
  66.     NSArray      *targets = [self targets];
  67.     NSEnumerator *lineEnum = [targets objectEnumerator];
  68.     MorphLine     *line;
  69.     NSCell         *cell = nil;
  70.  
  71.     if ([sender isKindOfClass:[NSCell class]])
  72.         cell = sender;
  73.     else if ([sender respondsToSelector:@selector(selectedCell)])
  74.         cell = [sender selectedCell];
  75.  
  76.     start0.x = [startX0Field floatValue] / 100.0;
  77.     start0.y = [startY0Field floatValue] / 100.0;
  78.     end0.x   = [endX0Field floatValue] / 100.0;
  79.     end0.y   = [endY0Field floatValue] / 100.0;
  80.     start1.x = [startX1Field floatValue] / 100.0;
  81.     start1.y = [startY1Field floatValue] / 100.0;
  82.     end1.x   = [endX1Field floatValue] / 100.0;
  83.     end1.y   = [endY1Field floatValue] / 100.0;
  84.  
  85.     moveStart     = [moveStartControl floatValue];
  86.     moveEnd       = [moveEndControl floatValue];
  87.     dissolveStart = [dissolveStartControl floatValue];
  88.     dissolveEnd   = [dissolveEndControl floatValue];
  89.  
  90.     while ((line = [lineEnum nextObject]))
  91.     {
  92.         if (cell == startX0Field || cell == startY0Field)
  93.             [line setStartPoint:start0 atDelta:0];
  94.         else if (cell == startX1Field || cell == startY1Field)
  95.             [line setStartPoint:start1 atDelta:1];
  96.         else if (cell == endX0Field || cell == endY0Field)
  97.             [line setEndPoint:end0 atDelta:0];
  98.         else if (cell == endX1Field || cell == endY1Field)
  99.             [line setEndPoint:end1 atDelta:1];
  100.         else if (cell == moveStartControl)
  101.             [line setMoveStartDelta:moveStart];
  102.         else if (cell == moveEndControl)
  103.             [line setMoveEndDelta:moveEnd];
  104.         else if (cell == dissolveStartControl)
  105.             [line setDissolveStartDelta:dissolveStart];
  106.         else if (cell == dissolveEndControl)
  107.             [line setDissolveEndDelta:dissolveEnd];
  108.         else
  109.             NSLog (@"Warning:[MorphLineInspector setValues:] Unknown sender %@", sender);
  110.     }
  111.     [[NSNotificationQueue defaultQueue] enqueueNotification:[NSNotification notificationWithName:NOTIFICATION_SELECTION_CHANGED
  112.                                                                                           object:[[[NSApplication sharedApplication] mainWindow] delegate]]
  113.                                                postingStyle:NSPostWhenIdle
  114.                                                coalesceMask:NSNotificationCoalescingOnName
  115.                                                    forModes:nil];
  116. }
  117.  
  118.  
  119. @end
  120.