ftp.nice.ch/pub/next/tools/business/Stopwatch.2.3.NIHS.bs.tar.gz#/Stopwatch2.3/Source/ColCell.m

This is ColCell.m in view mode; [Download] [Up]

/*
 * For legal stuff see the file COPYRIGHT
 */
#import "ColCell.h"
#import "Session.h"		/* this is bogus!!! fix it!! TBD */
#import "Expense.h"		/* this is bogus!!! fix it!! TBD */

#define DATE_OFFSET	3.0

/* For sessions */
#define TIME_OFFSET	62.0
#define MINS_OFFSET	104.0
#define TASK_OFFSET	136.0

/* For expenses */
#define AMOUNT_OFFSET	62.0
#define DESC_OFFSET	116.0

/* Font info */
static NXCoord ascender, descender, lineHeight;

@implementation ColCell

- (void)setCellData:obj
{
  [self setStringValue:""];
  data = obj;
}

- cellData
{
  return data;
}

- setFont:fontObj
{
  [super setFont:fontObj];
  /*
   * save this info so we don't have to look it up every time we draw
   * Note:  support for a TextCell is a font object
   */
  NXTextFontInfo(support, &ascender, &descender, &lineHeight);
  return self;
}    

/*
 * Override the drawing method to put the data in two columns
 */
- drawInside:(const NXRect *)cellFrame inView:controlView
{
  NXCoord baseX, baseY;
  char buf[80];

  baseX = NX_X(cellFrame);
  baseY = NX_Y(cellFrame) + lineHeight - descender;

  [super drawInside:cellFrame inView:controlView];
  PSsetgray(NX_BLACK);

  /********* CLEAN THIS UP!! *********/

  if ( [data class] == [Session class] ) {
    PSmoveto( baseX + DATE_OFFSET, baseY );
    PSshow( [data startDateString] );

    PSmoveto( baseX + TIME_OFFSET, baseY );
    PSshow( [data startTimeString] );

    PSmoveto( baseX + MINS_OFFSET, baseY );
    sprintf( buf, "%d", [data minutes] );
    PSshow( buf );

    PSmoveto( baseX + TASK_OFFSET, baseY );
    PSshow( [data description] );

  } else {			/* otherwise, it's an Expense object */

    PSmoveto( baseX + DATE_OFFSET, baseY );
    PSshow( [data dateString] );

    PSmoveto( baseX + AMOUNT_OFFSET, baseY );
    sprintf( buf, "%.2f", [data amount] );
    PSshow( buf );

    PSmoveto( baseX + DESC_OFFSET, baseY );
    PSshow( [data description] );
  }

  return self;
}

- copyFromZone:(NXZone *)zone
{
  ColCell *copy;

  copy = [super copyFromZone:zone];
  copy->data = data;
  return copy;
}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.