// FH_DATA.H
//
// Copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
//

#if !defined(__FH_DATA_H__)
#define __FH_DATA_H__

#if !defined(__E32STD_H__)
#include <e32std.h>
#endif
#if !defined(__E32BASE_H__)
#include <e32base.h>
#endif

class TZoomFactor;
class CWtlDocument;
class CWtlTokenHTMLFormElement;
class CWtlTokenHTMLFormCheck;
class CWtlTokenHTMLFormButton;
class CWtlTokenHTMLFormText;
class CWtlTokenHTMLFormTextArea;
class CWtlTokenHTMLFormMenu;
class CWtlTokenHTMLFormFile;


class CHtmlFormData : public CBase
	//
	// Base class for passing data to and from the UI
	//
	{
public:
	enum TDataType
		{
		EBool,
		EMenu,
		EButton,
		EText
		};
public:
	inline void SetDocument(CWtlDocument* aDocument);
protected:
	inline CHtmlFormData(CWtlDocument* aDocument,CWtlTokenHTMLFormElement* aToken,TDataType aType) 
															:iDocument(aDocument), iWtlFormToken(aToken), iType(aType) {}
protected:
	CWtlDocument* iDocument;
	CWtlTokenHTMLFormElement* iWtlFormToken;
	TDataType iType;
	};

class CHtmlFormDataBool : public CHtmlFormData
	//
	// Class for passing Boolean data to and from the UI
	// Using for radio buttons and check boxes
	//
	{
public:
	static CHtmlFormDataBool* NewLC(CWtlDocument* aDocument,CWtlTokenHTMLFormElement* aToken);
	static inline CHtmlFormDataBool* Cast(CHtmlFormData* aSelf);
	static inline const CHtmlFormDataBool* Cast(const CHtmlFormData* aSelf);
	IMPORT_C void SubmitDataL(TBool aData);
	IMPORT_C TBool GetDataL() const;		
private:
	inline CHtmlFormDataBool(CWtlDocument* aDocument,CWtlTokenHTMLFormElement* aToken)
			:CHtmlFormData(aDocument,aToken,EBool) {}
	inline CWtlTokenHTMLFormCheck* Token() const;
	};

class CHtmlFormDataButton : public CHtmlFormData
	//
	// Class for passing Button data to and from the UI
	//
	{
public:
	enum TButtonType
		{
		ESubmit,
		EReset
		};
public:
	static CHtmlFormDataButton* NewLC(CWtlTokenHTMLFormButton* aToken);
	static inline CHtmlFormDataButton* Cast(CHtmlFormData* aSelf);
	static inline const CHtmlFormDataButton* Cast(const CHtmlFormData* aSelf);
	IMPORT_C TButtonType ButtonType() const;		
	IMPORT_C TPtrC GetNameL() const;		
private:
	inline CHtmlFormDataButton(CWtlTokenHTMLFormButton* aToken);
	inline CWtlTokenHTMLFormButton* Token() const;
	};

class CHtmlFormDataText : public CHtmlFormData
	//
	// Base Class for passing data about text entry boxes to and from the UI
	//
	{
public:
	static inline CHtmlFormDataText* Cast(CHtmlFormData* aSelf);
	static inline const CHtmlFormDataText* Cast(const CHtmlFormData* aSelf);
	inline void SetZoomFactor(TZoomFactor* aZoomFactor);
	virtual void SubmitTextL(const TDesC& aText)=0;
	virtual TPtrC GetTextL() const=0;
	virtual TInt MaxLength() const=0;
	virtual TInt Lines() const=0;
	virtual TInt Width() const=0;
	IMPORT_C TZoomFactor* ZoomFactor() const;
protected:
	inline CHtmlFormDataText(CWtlDocument* aDocument,CWtlTokenHTMLFormElement* aToken)
				:CHtmlFormData(aDocument,aToken,EText) {}
private:
	TZoomFactor* iZoomFactor;
	};

class CHtmlFormDataTextBox : public CHtmlFormDataText
	//
	// Class for passing data about single line text boxes to and from the UI
	//
	{
public:
	static CHtmlFormDataTextBox* NewLC(CWtlDocument* aDocument,CWtlTokenHTMLFormText* aToken);
//Pure virtual functions from CHtmlFormDataText
	IMPORT_C void SubmitTextL(const TDesC& aText);
	IMPORT_C TPtrC GetTextL() const;
	IMPORT_C TInt MaxLength() const;
	IMPORT_C TInt Lines() const;
	IMPORT_C TInt Width() const;
private:
	inline CHtmlFormDataTextBox(CWtlDocument* aDocument,CWtlTokenHTMLFormText* aToken);
	inline CWtlTokenHTMLFormText* Token() const;
	};

class CHtmlFormDataTextArea : public CHtmlFormDataText
	//
	// Class for passing data about text areas to and from the UI
	//
	{
public:
	static CHtmlFormDataTextArea* NewLC(CWtlDocument* aDocument,CWtlTokenHTMLFormTextArea* aToken);
//Pure virtual functions from CHtmlFormDataText
	IMPORT_C void SubmitTextL(const TDesC& aText);
	IMPORT_C TPtrC GetTextL() const;
	IMPORT_C TInt MaxLength() const;
	IMPORT_C TInt Lines() const;
	IMPORT_C TInt Width() const;
private:
	inline CHtmlFormDataTextArea(CWtlDocument* aDocument,CWtlTokenHTMLFormTextArea* aToken);
	inline CWtlTokenHTMLFormTextArea* Token() const;
	};

class CHtmlFormDataMenu : public CHtmlFormData
	//
	// Class for passing data about menus to and from the UI
	//
	{
public:
	static CHtmlFormDataMenu* NewLC(CWtlDocument* aDocument,CWtlTokenHTMLFormMenu* aToken);
	static inline CHtmlFormDataMenu* Cast(CHtmlFormData* aSelf);
	static inline const CHtmlFormDataMenu* Cast(const CHtmlFormData* aSelf);
	inline void SetNamesNeedUpdating();
	inline void SetLastOptionSet(TInt aLastOption);
	inline TInt LastOptionSet();
	IMPORT_C TBool NamesNeedUpdating() const;
	IMPORT_C TInt NumberOptionsL() const;
	IMPORT_C TPtrC GetOptionNameL(TInt aOption) const;
	IMPORT_C TBool OptionSetL(TInt aOption) const;
	IMPORT_C void SetOptionL(TInt aOption,TBool aSet);
	IMPORT_C TInt SelectedL() const;		//Returns the first item selected
	IMPORT_C TInt Lines() const;
private:
	inline CHtmlFormDataMenu(CWtlDocument* aDocument,CWtlTokenHTMLFormMenu* aToken);
	inline CWtlTokenHTMLFormMenu* Token() const;
private:
	TBool iNamesNeedUpdating;
	TInt iLastOptionSet;
	};


class CHtmlFormDataFile : public CHtmlFormDataText
	{
public:
	static inline CHtmlFormDataFile* CastFile(CHtmlFormData* aSelf);
	static CHtmlFormDataFile* NewLC(CWtlDocument* aDocument,CWtlTokenHTMLFormFile* aToken);
//Pure virtual functions from CHtmlFormDataText
	IMPORT_C void SubmitTextL(const TDesC& aText);
	IMPORT_C TPtrC GetTextL() const;
	IMPORT_C TInt MaxLength() const;
	IMPORT_C TInt Lines() const;
	IMPORT_C TInt Width() const;
private:
	inline CHtmlFormDataFile(CWtlDocument* aDocument,CWtlTokenHTMLFormFile* aToken);
	inline CWtlTokenHTMLFormFile* Token() const;
	};



/*CHtmlFormData*/

inline void CHtmlFormData::SetDocument(CWtlDocument* aDocument) 
	//
	{

	iDocument=aDocument;
	}


/*CHtmlFormDataBool*/

inline CHtmlFormDataBool* CHtmlFormDataBool::Cast(CHtmlFormData* aSelf)
	//
	{

	return (CHtmlFormDataBool*) aSelf;
	}

inline const CHtmlFormDataBool* CHtmlFormDataBool::Cast(const CHtmlFormData* aSelf)
	//
	{

	return (const CHtmlFormDataBool*) aSelf;
	}


/*CHtmlFormDataButton*/

inline CHtmlFormDataButton* CHtmlFormDataButton::Cast(CHtmlFormData* aSelf)
	//
	{

	return (CHtmlFormDataButton*) aSelf;
	}

inline const CHtmlFormDataButton* CHtmlFormDataButton::Cast(const CHtmlFormData* aSelf)
	//
	{

	return (const CHtmlFormDataButton*) aSelf;
	}


/*CHtmlFormDataText*/

inline CHtmlFormDataText* CHtmlFormDataText::Cast(CHtmlFormData* aSelf)
	//
	{

	return (CHtmlFormDataText*) aSelf;
	}

inline const CHtmlFormDataText* CHtmlFormDataText::Cast(const CHtmlFormData* aSelf)
	//
	{

	return (const CHtmlFormDataText*) aSelf;
	}

inline void CHtmlFormDataText::SetZoomFactor(TZoomFactor* aZoomFactor)
	//
	{

	iZoomFactor=aZoomFactor;
	}


/*CHtmlFormDataMenu*/

inline CHtmlFormDataMenu* CHtmlFormDataMenu::Cast(CHtmlFormData* aSelf)
	//
	{
	
	return (CHtmlFormDataMenu*) aSelf;
	}

inline const CHtmlFormDataMenu* CHtmlFormDataMenu::Cast(const CHtmlFormData* aSelf)
	//
	{
	
	return (const CHtmlFormDataMenu*) aSelf;
	}

inline void CHtmlFormDataMenu::SetNamesNeedUpdating()
	//
	{
	
	iNamesNeedUpdating=ETrue;
	}

inline void CHtmlFormDataMenu::SetLastOptionSet(TInt aLastOption)
	//
	{
	
	iLastOptionSet=aLastOption;
	}

inline TInt CHtmlFormDataMenu::LastOptionSet()
	//
	{
	
	return iLastOptionSet;
	}

inline CHtmlFormDataFile* CHtmlFormDataFile::CastFile(CHtmlFormData* aSelf)
	{
	return (CHtmlFormDataFile*)aSelf;
	}

#endif