/*	XPopup.h
 *
 *		Popup list management
 */

/*  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_XPOPUP
#define PandaWave_XPOPUP

#include <XConfig.h>
#include <XHandle.h>
#include <XControls.h>
#include <XView.h>

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

class XGPopWindow;
class XGPopControl;
class XGDraw;
class XGFont;

/************************************************************************/
/*																		*/
/*	Class Declarations													*/
/*																		*/
/************************************************************************/

/*	@C"XGPopMenuView"
 *	@D"XGView"
 *	@H"XPopup.h"
 *	@I
 *
 *		The view that gets popped up in the XGPopControl popup control.
 */

class XGPopMenuView : public XGView {
	public:
								XGPopMenuView(XGStringList *, short font, short def);
		virtual					~XGPopMenuView();
		
		/*
		 *	Init support
		 */
		
		Point					GetPopSize(XGDraw &);
		short					GetLocation()
									{
										return fLocation;
									}
		
		/*
		 *	Events
		 */
		
		void					DoDrawView(Rect);
		void					DoMouseMove(Point,short);
	private:
		short					fDefault;
		short					fLocation;
		short					fFont;
		XGStringList			*fList;
		
		void					DrawLine(XGDraw &,short,bool);
};

/*	@C"XGPopControl"
 *	@D"XGControl"
 *	@H"XPopup.h"
 *	@I
 *
 *		The popup control
 */

class XGPopControl : public XGControl {
	public:
								XGPopControl(XGOwner *o, XGArgStream &s);
		virtual					~XGPopControl();
		
		enum {
			kClassID = 'popm'
		};
		
		/*
		 *	View event overrides
		 */
		 
		void					DoDrawView(Rect);
		void					DoActivate(bool);
		bool					DoMouseDown(Point,short);
		void					DoMouseMove(Point,short);
		void					DoMouseUp(Point,short);

		/*
		 *	Events
		 */
		
		long					GetValue();
		void					SetValue(long);
		void					GainFocus();
		void					LoseFocus();
		
		/*
		 *	Lists
		 */
		
		void					GetItem(long,char *) const;
		long					Length() const;
		void					Insert(long,const char *);
		void					Delete(long);
		void					DeleteAll();
		
		DECLAREDISPATCH
		long					DoKey(long,void *);

	private:
		XGPopMenuView			*fView;
		XGPopWindow				*fPop;
		XGFont					*fFont;
		short					fFontID;
		long					fValue;
		XGStringList			fList;
	
	friend class XGPopMenuView;
};
		
#endif // PandaWave_XPOPUP
