// © Copyright 1995, Joseph Bergin.  All rights reserved. 

#ifndef __Display__
#define __Display__

#include "TwoDimArray.h"

#define __FasterLists__
#ifdef __FasterLists__
#include "FastList.h"
#define List FastList
#else
#include "List.h"
#endif

class Display;

class DisplayCell
{	public:
		DisplayCell(double x, double y, char what);
	private:
		double _x;
		double _y;
		char _what;
		void scale(int cols, int rows);
	friend class Display;
	friend ostream & operator<<(ostream & os, const DisplayCell);
};

class Display
{	public:
		Display(int cols = 72, int rows = 24);
		void draw( List<DisplayCell> & L); // L will be empty at end.
	private:
		TwoDimensionArray<char> _display;
		const int _displayRows;
		const int _displayCols;
		void clear();
};

// To display a two dimensional graph create a List<DisplayCells>.
// Create DispllayCells with the x and y coordinates you want 
// marked with "what" characters. Insert the cells into the list. 
// Insert a cell D into a displayList DL with DL = D + DL;
// Pass this "DisplayList" to the Display::draw() function. 
// Draw will clear and rescale the display before processing the 
// display list.  
// Display::draw() sets its argument to the empty list.  If you need
// to retain this list, you must make a copy before you call draw.   
// The display algorithm is very naive, doing only simple scaling
// to a 24 row by 72 column (or other) rectangle.  
#endif
