/*
 * Module:
 *	HostSpinSingle
 *
 * Author:
 *	Doug "Kareth" McClure
 *	asd@cc.purdue.edu
 *	XASD@PURCCVM.BITNET
 *
 * Version: 1.0
*/

#import "HostSpinSingleView.h"
#import "Thinker.h"
#import "HostSpinWraps.h"
#import <appkit/NXImage.h>
#import <appkit/Window.h>
#import <appkit/Panel.h>                // for NXRunAlertPanel()
#import <dpsclient/wraps.h>
#import <libc.h>
#import <math.h>

@implementation HostSpinSingleView

- oneStep
{
  static int rota = 0, letter = 0;
  static float currentSpectrum = 0.0;
  static char junk[2] = { ' ', '\0' };

  junk[0] = hostName[letter];
  
  currentSpectrum += 0.01;
  if ( currentSpectrum > 1.0 )
    {
      currentSpectrum = 0.0;
    }
  PSsethsbcolor(currentSpectrum, 1.0, 1.0);

  PSsendstring(junk);
  PSsendint(rota);
  PSsendfloat(ySize);
  PSsendfloat(xSize);
  psHostSpinRun();

  rota += 2;
  if ( rota > 360 )
    {
      rota = 0;
      if ( ++letter == lenHostName )
	{
	  letter = 0;
	}
    }

  return self;
}


- initFrame:(NXRect *)frameRect
{
  [super initFrame:frameRect];
  [self newSize];
  gethostname(hostName, 128);
  lenHostName = strlen(hostName);

  return self;
}


- sizeTo:(NXCoord)width :(NXCoord)height
{
  [super sizeTo:width :height];
  [self newSize];

  return self;
}


- newSize
{
  xSize = bounds.size.width;
  ySize = bounds.size.height;

  return self;
}

@end
