/*	XGMenuView.h
 *
 *		Menu bar view. This is how I deal with the menu
 *	bar inside of X Windows.
 */

/*  YAAF - Yet another application framework
 *  Copyright (C) 1997, 1998 William Edward Woody
 *  
 *  This library is free software; you can redistribute it
 *  and/or modify it under the terms of the GNU Library
 *  General Public License as published by the Free Software
 *  Foundation; either version 2 of the License, or any
 *  later version.
 *  
 *  This library is distributed in the hope that it will be
 *  useful, but WITHOUT ANY WARRANTY; without even the implied
 *  warranty of MERCHANTABIILITY or FITNESS FOR A PARTICULAR
 *  PURPOSE. See the GNU Library General Public License for
 *  more details.
 *  
 *  You should have received a copy of the GNU Library General
 *  Public License along with this library; if not, write to the
 *  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 *  Boston, MA 02111-1307, USA.
 *  
 *  To contact the author, either e-mail me at woody@pandawave.com, 
 *	or write to
 *  
 *          William Edward Woody
 *          In Phase Consulting
 *          1545 Ard Eevin Avenue
 *          Glendale, CA 91202
 *
 *	Or visit us on the web at http://www.pandawave.com
 */

#ifndef PandaWave_XGMENUVIEW
#define PandaWave_XGMENUVIEW
#endif

#include <XView.h>

#if OPT_XWIN

/************************************************************************/
/*																		*/
/*	Forwards															*/
/*																		*/
/************************************************************************/

class XGMenu;
class XGMenuBar;
class XGPopWindow;
class XGFocus;

/************************************************************************/
/*																		*/
/*	XGMenuView object													*/
/*																		*/
/************************************************************************/

/*	XGMenuPopup
 *
 *		How to draw the popup menu
 */

class XGMenuPop : public XGView {
	public:
								XGMenuPop(XGMenu *);
		virtual					~XGMenuPop();
		
		/*
		 *	Preflight size
		 */
		
		Point					GetPopSize(XGDraw &);
		
		/*
		 *	Drawing/mouse movement
		 */
		
		void					DoDrawView(Rect);
		void					DoMouseMove(Point,short);
		short					GetLocation()
									{
										return fLocation;
									}
		XGMenu					*GetMenu()
									{
										return fMenu;
									}
	private:
		void					DrawLine(XGDraw &,short,bool);
		
		short					fLocation;
		XGMenu					*fMenu;
};

/*	XGMenuView
 *
 *		How to draw a menu bar
 */

class XGMenuView : public XGView {
	public:
								XGMenuView(XGFocus *, XGMenuBar *);
		virtual					~XGMenuView();
		
		/*
		 *	Drawing
		 */
		
		void					DoDrawView(Rect);
		bool					DoMouseDown(Point,short);
		void					DoMouseMove(Point,short);
		void					DoMouseUp(Point,short);

	private:
		Rect					CalcLocation(short);
		
		void					PopDownMenu(short);
		bool					TrackPopMenu(Point);
		
		XGFocus					*fFocus;
		XGMenuBar				*fMenuBar;
		short					fIndex;
		short					fWidth[32];			// 32 menus max
		
		XGPopWindow				*fPop;				// up to 5 popups
		XGMenuPop				*fView;				// and 5 views
};


#endif
