home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / Apps / Utilities / Unix / aa_m68k_Intel_Only / UNIX-HatersTool.0.1 / MiscSwapKitPalette.BETA / MiscSwapKitPalette.m < prev    next >
Encoding:
Text File  |  1994-09-25  |  2.1 KB  |  82 lines

  1.  
  2. #import "MiscSwapKitPalette.h"
  3.  
  4. @implementation MiscSwapKitPalette
  5.  
  6.  
  7. - finishInstantiate 
  8. {    
  9.     id    idBundle;
  10.     char buf[MAXPATHLEN + 1];
  11.  
  12.     // Put the image on the button that will represent the controller
  13.     // on the palette, then associate it with the object that is the
  14.     // real controller.
  15.     
  16.     [super finishInstantiate];
  17.     
  18.     idBundle = [NXBundle bundleForClass:[self class]];
  19.  
  20.     if ([idBundle getPath:buf forResource:"MiscSCC" ofType:"tiff"])
  21.         [swapImageView setImage:[ [NXImage alloc] initFromFile:buf] ];
  22.      
  23.     [self associateObject:realSwapObject 
  24.         type:IBObjectPboardType with:swapImageView];
  25.         
  26.     return self;
  27. }
  28.  
  29. @end
  30.  
  31.  
  32. @implementation MiscSwapView (IBDisplaying)
  33.  
  34. // Displays a bezel around the view and writes their class name
  35. // in the center to identify subclasses, since otherwise you cannot
  36. // even see where the view is (on the palette and after being dragged).
  37.  
  38. - drawSelf:(const NXRect *)rects :(int)rectCount
  39. {
  40.       if ([NXApp conformsTo: @protocol(IB)])
  41.         if ([NXApp isTestingInterface] == NO)
  42.         {
  43.           id  font = [Font boldSystemFontOfSize: 12.0 
  44.                           matrix: NX_IDENTITYMATRIX];            
  45.           float  x;
  46.             float  gray = [self backgroundGray];
  47.             float  grays[4] = {NX_BLACK, NX_DKGRAY, NX_LTGRAY, NX_WHITE};
  48.           int  i = 0;
  49.           char  *className = (char *)[ [self class] name];
  50.           NXRect  indent;
  51.           
  52.               while (i<4 && gray != grays[i])
  53.                 i++;
  54.  
  55.             // fill background with same color as will be used at runtime
  56.             PSsetgray (gray);
  57.             NXRectFill (&bounds);
  58.             
  59.             // choose an offset gray for border and text
  60.             PSsetgray (grays[(i+2)%3]);
  61.             NX_X (&indent) = NX_X (&bounds) + 2.0;
  62.             NX_Y (&indent) = NX_Y (&bounds) + 2.0;
  63.             NX_WIDTH (&indent) = NX_WIDTH (&bounds) - 4.0;
  64.             NX_HEIGHT (&indent) = NX_HEIGHT (&bounds) - 4.0;
  65.             NXFrameRect (&indent);
  66.  
  67.             [font set];
  68.             if ([font getWidthOf: className] > indent.size.width)
  69.                 x = 10.0;
  70.             else
  71.                 x = (indent.size.width - [font getWidthOf: className])/2; 
  72.             PSmoveto (x, (indent.size.height-[font pointSize])/2);
  73.             PSshow (className);
  74.          }
  75.     else
  76.         [self swapContentView: [self trigger] ];
  77.          
  78.     return self;
  79. }
  80.  
  81. @end
  82.