/*	XInline.h
 *
 *		This contains the inline editor classes which are used to edit
 *	items inline.
 */

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

  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_XINLINE
#define PandaWave_XINLINE

#include <XConfig.h>
#include <XTextControls.h>

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

class XGPopMenuView;
class XGPopWindow;

/************************************************************************/
/*																		*/
/*	Standard Classes													*/
/*																		*/
/************************************************************************/

/*$	XGInline
 *
 *		A base class which is used by YAAF to manage inline editing.
 *	This is an internal class which provides YAAF the opportunity to
 *	close these in case something is going on
 */

class XGInline {
	public:
								XGInline();
								~XGInline();
		
		/*
		 *	Close me
		 */
		
		static void				Close();
		static void				CloseInline(XGView *parent);

	protected:
		XGView					*fParentEvent;
	private:
		static XGInline			*gInline;
};

/*$	XGInlineEdit
 *
 *		This is an inline editing class. This basically knows how to
 *	self-destruct when it is deactivated or loses focus
 */

class XGInlineEdit : public XGEditText, public XGInline {
	public:
								XGInlineEdit(XGView *parent, XGSEditInitRecord &init);
		virtual					~XGInlineEdit();
		
		/*
		 *	Initialization support
		 */
		
		static XGInlineEdit		*Create(XGView *parent, 
										XRect &where, 
										short font, 
										char *text = NULL,
										bool wrap = false);

		/*
		 *	Delete me
		 */
		
		void					DoActivate(bool);
		void					DoLoseFocus();
		
		DECLAREDISPATCH
		long					DoKey(long, void *);
		
	protected:
		virtual XGDispatch		*GetParentDispatch();
		
	private:
		void					DeleteSelf(bool adjfocus = true);
};

/*$	XGInlinePopup
 *
 *		This is an inline editing class. This basically knows how to
 *	self-destruct when it is deactivated or loses focus
 */

class XGInlinePopup : public XGView, public XGInline {
	public:
								XGInlinePopup(XGView *parent, XGSViewInitRecord &init);
		virtual					~XGInlinePopup();
		
		/*
		 *	Initialization support
		 */
		
		static XGInlinePopup	*Create(XGView *parent, 
										XRect &where,
										short font,
										XGStringList *list,
										short value);

		/*
		 *	Delete me
		 */
		
		void					DoDrawView(XRect);
		void					DoActivate(bool);
		void					DoLoseFocus();
		bool					DoMouseDown(XPoint,short);
		void					DoMouseMove(XPoint,short);
		void					DoMouseUp(XPoint,short);
		void					DoMouseLeave();
		
		DECLAREDISPATCH
		long					DoPeriodic(long, void *);
		long					DoKey(long, void *);
	protected:
		virtual XGDispatch		*GetParentDispatch();
		
	private:
		void					DeleteSelf(bool adjfocus = true);
		XRect					AutoPosWindow(XGDraw &, XPoint size);
		
		bool					fPopQuick;
		long					fPopTime;
		XPoint					fLastPos;
		
		long					fTypeTime;
		short					fTypePos;
		char					fTypeChar[32];

		XGPopMenuView			*fPopView;
		XGPopWindow				*fPopWindow;
};


#endif // PandaWave_XINLINE
