//////////////////////////////////////////////////////////////////////
// XLogical - A puzzle game
//
// Copyright (C) 2000 Neil Brown, Tom Warkentin
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
// or at the website: http://www.gnu.org
//
////////////////////////////////////////////////////////////////////////



#ifndef MENUBASE_H
#define MENUBASE_H

#include <vector>
#include "defs.h"
#include "graph.h"

#ifdef WIN32
using namespace std;
#endif

class CMenuBase
{
public:
	CMenuBase( void );
	virtual ~CMenuBase( void );

	void AddChild( class CMenuBase * );
	int Height( void );
	bool IsHilightable( void );
	bool IsManager( void );
	class CMenuBase * Parent( void );
	class CMenuBase * ChildManager( void );
	class CMenuBase * ParentManager( void );
	void_func DrawFunc( void );
	void_func RestoreFunc( void );

	virtual void SetHilighted( bool );
	void SetPos( int aX, int aY );
	void Start(
		int aWidth, int aHeight,
		void_func aDrawFunc=NULL,
		void_func aRestoreFunc=NULL );
	int Width( void );
	int X( void ) { return fX; };
	int Y( void ) { return fY; };

	// user must write these
	virtual void Click( int aX, int aY, int aButton );
	virtual void Draw( void )=0;
	virtual void Keypress( keysyms aKeyval );
	virtual void Manage( void );
	virtual void Realize( void )=0;
	virtual void Selected( void )=0;

protected:
	typedef vector<class CMenuBase *> Children;

	bool fHilightable;
	bool fHilighted;
	bool fManager;
	class CMenuBase *fParent;
	int fHeight;
	int fWidth;
	static int fMainHeight;
	static int fMainWidth;
	int fX;
	int fY;
	Children fChildren;
	static class CMenuBase *gTop;
	void_func fDrawFunc;
	void_func fRestoreFunc;

private:
	static void HandleClick( int aX, int aY, int aButton );
	static void HandleLoop( void );
	static void HandleKeyPress( keysyms aKeyval );

};

#endif
// $Id: menubase.h,v 1.5 2001/02/16 21:00:00 tom Exp $
//
// $Log: menubase.h,v $
// Revision 1.5  2001/02/16 21:00:00  tom
// did some WIN32 porting work on the code... just a few more files to go.
//
// Revision 1.4  2001/01/20 17:32:29  brown
// Working toward Windows integration
//
// Revision 1.3  2000/10/06 19:29:09  brown
// Added autoconf stuff
// Added GPL header to files
// Added WON scroller
// Added GPL to about screen
//
// Revision 1.2  2000/10/03 01:50:28  tom
// removed unused code
//
// Revision 1.1.1.1  2000/09/28 02:17:52  tom
// imported sources
//
// Revision 1.7  2000/01/23 06:11:39  tom
// - changed menu stuff to take 1 call back that is called to restore the
//   graphDriver state and do whatever else is necessary to switch states.
// - created centralized state switching routines to make it easier to hook in
//   mod changing, etc.
// - xlogical now supports intro.mod, pregame.mod, ingame.mod, & user mods
//   (still need to hook in highscore.mod and endgame.mod)
//
// Revision 1.6  1999/12/25 08:18:37  tom
// Added "Id" and "Log" CVS keywords to source code.
//
