/* Lawrenceville Press
	Implements a button which can be clicked on
	October 1997                                */
	
using namespace std;	// October 5, 2001

class ButtonClass {
	public:
	ButtonClass(lvpstring Text, int X1,int Y1, int X2, int Y2);
	/* Creates a button with upper left corner at X1,Y1 and lower
	right corner at X2,Y2 with Text centered in box */
	void Paint();
	bool IsHit(int x, int y);
	/* Returns true if and only if (x,y) is on the button */
	private:
		int MyX1, MyY1, MyX2, MyY2;
		lvpstring MyText;
	};
//-------------------------------------------------------------------
ButtonClass::ButtonClass(lvpstring Text, int X1,int Y1, int X2, int Y2):
	MyText(Text), MyX1(X1), MyY1(Y1), MyX2(X2), MyY2(Y2)
/* Creates a button with upper left corner at X1,Y1 and lower
	right corner at X2,Y2 with Text centered in box */
{}
//-------------------------------------------------------------------
void ButtonClass::Paint()
{
	SetColor(BLACK);
   SetThickness(2);
	Rectangle(MyX1,MyY1,MyX2,MyY2);
	gotoxy((MyX1+MyX2)/2, 5+(MyY1+MyY2)/2);
	DrawCenteredText(MyText);
}
//-------------------------------------------------------------------
bool ButtonClass::IsHit(int x, int y)
/* Returns true if and only if point (x,y) is on the button */
{
	return (x >= MyX1 && x <= MyX2 && y >= MyY1 && y <= MyY2);
}


