home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / SourceCode / Palettes / ConnectDemo / ConnectBrowserCell.m < prev    next >
Encoding:
Text File  |  1993-01-14  |  1.8 KB  |  94 lines

  1.  
  2. #import "ConnectBrowserCell.h"
  3.  
  4. @implementation ConnectBrowserCell
  5.  
  6. - initTextCell:(const char *)aString
  7. {
  8.     if ([super initTextCell:aString] == nil)
  9.         return nil;
  10.     branchImage = nil;
  11.     branchImageH = nil;
  12.     return self;
  13. }
  14.  
  15. - setBranchImage:image
  16. {
  17.     branchImage = image;
  18.     return self;
  19. }
  20.  
  21. - setBranchImageH:image
  22. {
  23.     branchImageH = image;
  24.     return self;
  25. }
  26.  
  27. - branchImage
  28. {
  29.     return branchImage;
  30. }
  31.  
  32. - branchImageH
  33. {
  34.     return branchImageH;
  35. }
  36.  
  37. - drawInside:(const NXRect *)cellFrame inView:aView
  38. {
  39.     [super drawInside:cellFrame inView:aView];
  40.     [self drawImage:cellFrame inView:aView usingImage:
  41.         (branchImageH!=nil && [self state]) ? branchImageH:branchImage];
  42.  
  43.     return self;
  44. }
  45.  
  46. - drawSelf:(const NXRect *)cellFrame inView:aView
  47. {
  48.     [self drawInside:cellFrame inView:aView];
  49.     return self;
  50. }
  51.  
  52. - highlight:(const NXRect *)cellFrame inView:aView lit:(BOOL)lit
  53. {
  54.     [super highlight:cellFrame inView:aView lit:lit];
  55.     if (lit)
  56.         [self drawImage:cellFrame inView:aView usingImage:
  57.             (branchImageH==nil)?branchImage:branchImageH];
  58.  
  59.     return self;
  60. }
  61.  
  62. - drawImage:(const NXRect *)cellFrame inView:aView usingImage:image
  63. {
  64.     NXRect    bounds;
  65.     NXPoint    point;
  66.  
  67.     if (image != nil)
  68.     {
  69.         point.x = point.y = 0;
  70.         [image getSize:&bounds.size];
  71.         if (bounds.size.height > cellFrame->size.height)
  72.             bounds.size.height = cellFrame->size.height;
  73.         point.y = cellFrame->origin.y + cellFrame->size.height -
  74.             (cellFrame->size.height-bounds.size.height)/2;
  75.         if (bounds.size.width > cellFrame->size.width)
  76.         {
  77.             bounds.size.width = cellFrame->size.width;
  78.             point.x = 0;
  79.         }
  80.         else
  81.         {
  82.             point.x = cellFrame->size.width-bounds.size.width;
  83.             if (bounds.size.width < 20)
  84.                 point.x -= (20-bounds.size.width)/2;
  85.         }
  86. //        [image composite:NX_COPY fromRect:&bounds toPoint:&point];
  87.         [image composite:NX_COPY toPoint:&point];
  88.     }
  89.  
  90.     return self;
  91. }
  92.  
  93. @end
  94.