home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / SourceCode / Inspectors / InspectMe / InspectMeDoc.m < prev    next >
Encoding:
Text File  |  1992-07-31  |  2.4 KB  |  92 lines

  1. #import "InspectMeDoc.h"
  2. #import "InspectMeApp.h"
  3. #import "InspectorManager.h"
  4. #import "ThingInspector.h"
  5. #import "ColorInspector.h"
  6. #import <appkit/Window.h>        // for disableFlushWindow
  7. #import "Thing1.h"
  8. #import "Tank.h"
  9.  
  10.  
  11. @implementation InspectMeDoc
  12.  
  13. static int tileCountMain = 0;    // just one per class 
  14.  
  15. - init
  16. {
  17.     NXRect    tempFrame;
  18.     char    buffer[30];
  19.  
  20.     [super init];
  21.     [NXApp loadNibSection:"InspectMeDoc.nib" owner:self];
  22.     [window getFrame:&tempFrame];
  23.     tempFrame.origin.x += ((tileCountMain%8)*23);
  24.     tempFrame.origin.y -= ((tileCountMain%8)*23);
  25.     if (tempFrame.origin.y < 0) 
  26.         tempFrame.origin.y = 0;
  27.     tileCountMain++;
  28.     [window moveTo:tempFrame.origin.x :tempFrame.origin.y];
  29.     sprintf(buffer,"Window # %d", tileCountMain);
  30.     [window setTitle:buffer];
  31.     [window makeKeyAndOrderFront:self];
  32.     return self;
  33. }
  34.  
  35. - windowDidBecomeKey:sender
  36. {
  37.     // while this window is main, receive messages from inspector
  38.     [[NXApp inspectorManager] setDelegate:self];
  39.     [self groupChanged:self to:[[NXApp inspectorManager] group]];
  40.     return self;
  41. }
  42.  
  43. - groupChanged:sender to:(int)newGroup 
  44. {
  45.     id    im;
  46.     BOOL    inspectorShown=NO;
  47.     im=[NXApp inspectorManager];
  48.     [[ColorInspector new] setCurrentParameterReceiver:selectedObject];
  49.     [[ThingInspector new] setCurrentParameterReceiver:selectedObject];
  50.     if (newGroup == ATTRIBUTESGROUP) {
  51.         [[im panel] disableFlushWindow];
  52.         if([selectedObject isKindOf:[Thing1 class]]) {
  53.                 [im switchToInspector:
  54.                         [[ThingInspector new] thing1InspectorNum]];
  55.                 [[ThingInspector new] reflectThing1Attributes:selectedObject];
  56.                 inspectorShown=YES;
  57.             }
  58.         if([selectedObject isKindOf:[Tank class]]) {
  59.                 [im switchToInspector:
  60.                         [[ThingInspector new] tankInspectorNum]];
  61.                 [[ThingInspector new] reflectTankAttributes:selectedObject];
  62.                 inspectorShown=YES;
  63.             }
  64.         if(!inspectorShown)
  65.             [im showMessage:"No Selection"];
  66.         [[[im panel] reenableFlushWindow] flushWindowIfNeeded];
  67.         }
  68.     else 
  69.         if([selectedObject isKindOf:[Thing1 class]]) {
  70.             [im switchToInspector:
  71.                     [[ColorInspector new] bkgndColorInspectorNum]];
  72.             [[ColorInspector new] reflectbkgndColorAttributes:selectedObject];
  73.             inspectorShown=YES;
  74.             }
  75.         else
  76.             [im showMessage:"Not\nApplicable"];
  77.     return self;
  78. }
  79.  
  80. - setSelectedObject:theObject;
  81. {
  82.     if (selectedObject != theObject) {
  83.         [selectedObject setSelected:NO];
  84.         [theObject setSelected:YES];
  85.         selectedObject = theObject;
  86.         [self groupChanged:self to: [[NXApp inspectorManager] group]];
  87.         }
  88.     return self;
  89. }
  90.  
  91. @end
  92.