#include "grid.h"

Grid::Grid( Screen* newScreen, int x0, int y0 )
        : Bitmap( newScreen, x0, y0, 0, 0 )
{
  dx = 0;
  dy = 0;
  size = 0;
}

Grid::~Grid()
{
  restoreBackground();
}

void Grid::draw()
{
  screen->mouseOff();
  saveBackground();
  for( int i = 0; i < size; i++ )
    for( int j = 0; j < size; j++ )
    {
      screen->drawLine( x+i*dx, y+j*dy, x+i*dx, y+(size-1)*dy, color );
      screen->drawLine( x+j*dx, y+i*dy, x+(size-1)*dx, y+i*dy, color );
    }
  screen->mouseOn();
}

void Grid::setScale( int ndx, int ndy, int nsize )
{
  dx = ndx;
  dy = ndy;
  size = nsize;
  setWidth( dx*size-dx );
  setHeight( dy*size-dy );
}
