// WEBEVHDL.H
//
// Copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
//

// The MWebEventHandler class.
//
//=============================================================================
// A class for handling logical events passing between the Engine and the user interface.
//
//=============================================================================
//=============================================================================

#ifndef __WEBEVHDL_H__
#define __WEBEVHDL_H__

#include <w32std.h>
#include <e32base.h>

#include "webdef.h"

class MWebPlugIn;

class MWebEventHandler
	{
public:

	// Event types
	enum TEventType
		{
		EEventNone,					// used to enquire about the current selection
		EEventPointer,
		EEventUp,
		EEventDown,
		EEventLeft,
		EEventRight
		};

	// Select actions
	enum TSelectAction
		{
		ESelectNone,				// don't select anything, but record the position
		ESelectObject,				// select any selectable object at the new position
		ESelectExtend,				// extend the selection to the new position
		ESelectFromStart,			// select all text from the start to the new position
		ESelectToEnd,				// select all text from the new position to the end
		ESelectAll					// select everything
		};

	/* Class TEventInput 
	Event information passed into HandleEventL
	*/
	class TEventInput
		{
	public:
		IMPORT_C TEventInput();
		IMPORT_C void Clear();

		TEventType iType;			// type of event
		TPoint iPoint;				// if this is a pointer event, coords of pointer,
									// relative to the origin of the object
		TSelectAction iSelectAction;// what happens to the selection
		};

	// Hypertext link types
	enum TLinkType
		{
		ELinkNone,							// not a hypertext link
		ELinkNearLabel,						// a near link (to a #-label)
		ELinkNearID	,						// a near link (to a tag id)
		ELinkFar							// a far link (to another URL)
		};

	// Image types
	enum TImageType
		{
		EImageNone,								// not an image
		EImagePlaceHolder,						// a placeholder for an image not yet loaded
		EImage,									// a completely-loaded ordinary image
		EImageAnimated,							// a completely-loaded animated image
		EImageIncomplete,						// a partially-loaded image
		EImageProgressiveIncomplete,				// a partially-loaded progressive image
		EImageMap,									// a fully loaded image map
		};

	// Form element types
	enum TFormType
		{
		EFormNone,						// not a form element
		EFormText,						// one-line text entry field
		EFormTextArea,					// multi-line text entry field
		EFormButton,					// submit or reset button
		EFormImageButton,				// submit or reset button made from an image
		EFormRadioButton,				// radio button
		EFormCheckBox,					// checkbox
		EFormMenu,						// menu or listbox
		EFormFile,						// control allowing the user to attach a file
		EFormIsIndex					// Form control for the ISINDEX tag
		};

	enum TObjectType
		{
		EObjectNone,						// Not an object (mime handler)
		EObjectPlaceHolder,				// placeholder for a not yet loaded object
		EObject,									// a completely-loaded object
		EObjectIncomplete,						// a partially-loaded object
		EObjectApplet,						// an applet
		};

	/* Class TObjectInfo
	Information about an object in the text (a hypertext link, image, form element, etc.)
	*/
	class TObjectInfo
		{
	public:
		IMPORT_C TObjectInfo();
		IMPORT_C TObjectInfo(TObjectInfo& aSource);
		IMPORT_C TObjectInfo& operator=(const TObjectInfo& aSource);
		IMPORT_C void Clear();

		TLinkType iLinkType;				// type of hypertext link if any
		TImageType iImageType;				// type of image if any
		TFormType iFormType;				// type of form elment if any
		TObjectType iObjectType;			// type of object if any
		TPtrC iLinkDest;					// destination of link, if this is a link
		TPtrC iImageUrl;					// URL of image, or object, if this is an image or object

		TInt  iTargetFrameID;				// ID of the target frame or -1 if not known
		TPtrC iTargetFrameName;				// Name of the target frame or empty if none

		MWebPlugIn* iHandler;			//Pointer to a plugin handler for this object, if appropriate
		TAny* iData;						//Generic data object
		TAny* iValue;						//Generic value object
		};

	// Event information returned by HandleEventL
	class TEventOutput: public TObjectInfo
		{
	public:
		IMPORT_C TEventOutput();
		IMPORT_C void Clear();

		TBool iLinkSelected;			// was the link selected before the event?
		TBool iImageSelected;			// was the image selected before the event?
		TBool iObjectSelected;			// was the object selected before the event?
		};
	
	IMPORT_C virtual TBool HandleRawPointerEventL(const TPointerEvent& aEvent,TPoint aObjectPos) = 0;
	IMPORT_C virtual void  HandlePointerEventL   (const TEventInput& aEventInput,TEventOutput& aEventOutput, TBool aRedraw = ETrue) = 0;
	IMPORT_C virtual void  HandleEventL          (const TEventInput& aEventInput,TEventOutput& aEventOutput, TBool aRedraw = ETrue) = 0;
	
	IMPORT_C virtual void MWebEventHandler_Reserved1();
	IMPORT_C virtual void MWebEventHandler_Reserved2();
	};


#endif __WEBEVHDL_H__