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

/**********************************************************************

  YAAF is Copyright 1997-1999 by William Woody.

  Redistribution and use in source and binary forms, with or without 
  modification, are permitted provided that the following conditions 
  are met:

  Redistributions of source code must retain the above copyright notice, 
  this list of conditions and the following disclaimer.

  Neither the name of the copyright holder or other contributors may
  be used to promote products derived from this software without
  specific written prior permission.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
  SOFTWARE.
  
  Contact:   woody@alumni.caltech.edu
  Web page:  http://www.pandawave.com/yaaf/

**********************************************************************/

#ifndef PandaWave_XGMENUVIEW
#define PandaWave_XGMENUVIEW
#endif

#include <XView.h>

#if OPT_XWIN

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

class XGMenu;
class XGMenuBar;
class XGPopWindow;
class XGDispatch;

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

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

class XGMenuPop : public XGView {
	public:
								XGMenuPop(XGMenu *);
		virtual					~XGMenuPop();
		
		/*
		 *	Preflight size
		 */
		
		XPoint					GetPopSize(XGDraw &);
		
		/*
		 *	Drawing/mouse movement
		 */
		
		void					DoDrawView(XRect);
		void					DoMouseMove(XPoint,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(XGDispatch *, XGMenuBar *);
		virtual					~XGMenuView();
		
		/*
		 *	Drawing
		 */
		
		void					DoDrawView(XRect);
		bool					DoMouseDown(XPoint,short);
		void					DoMouseMove(XPoint,short);
		void					DoMouseUp(XPoint,short);

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


#endif
