/*
 * You may freely copy, distribute, and reuse the code in this example.
 * NeXT disclaims any warranty of any kind, expressed or  implied, as to its
 * fitness for any particular use.
 */


#import "FooCell.h"
#import "FooObject.h"
#import <appkit/Text.h>
#import <dpsclient/psops.h>
#import <objc/hashtable.h>
#import <stdlib.h>
#import <stdio.h>

#import "VISCA.h"

#define FIELD1_LMARGIN 4.0
#define FIELD2_LMARGIN 34.0

@implementation FooCell

- init
{
  [super init];
  [self setType:NX_TEXTCELL];
  return self;
}

- fooObject
{
  return fooObject;
}

- setFooObject:anObject
{
  fooObject = anObject;
  return self;
}

- 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;
}    

- drawInside:(const NXRect *)cellFrame inView:controlView
{
	char		buf[100];
	NXCoord	baseX, baseY;
	struct ct_hmsf *pos1, *pos2;
	char *comment;
	
  baseX = NX_X(cellFrame);
  baseY = NX_Y(cellFrame) + lineHeight - descender;
     
  /* erase the cell */
  PSsetgray((cFlags1.state || cFlags1.highlighted) ? NX_WHITE : NX_LTGRAY);
  NXRectFill(cellFrame);

  PSsetgray(NX_BLACK);
  /* draw the start, duration, and mark name in black */
  PSmoveto(baseX + FIELD1_LMARGIN, baseY);
  sprintf(buf,"%d",[fooObject tag]);
  PSshow(buf);
  PSmoveto(baseX + FIELD2_LMARGIN, baseY);
	pos1 = [fooObject startFrame];
	pos2 = [fooObject endFrame];
	comment = [fooObject comment];
	sprintf(buf,"%02X:%02X:%02X:%02X -> %02X:%02X:%02X:%02X    %s", 
  	pos1->hh, pos1->mm, pos1->ss, pos1->ff,
	pos2->hh, pos2->mm, pos2->ss, pos2->ff, comment);
	PSshow(buf);

  return self;
}

@end
