#ifndef _TK_ENTRY_H_
#define _TK_ENTRY_H_

#include "tk_base.h"

/**
 * \brief Represent "entry" widget
 *
 * \date 01-12-2006
 *
 * \author Ondrej Svejdar
 *
 * \todo 
 *
 * \bug 
 *
 */
class TkEntry:public TkBase,public IStateable,public ITextable,public IInnerVariable
{
	TclStringVar var;
protected:
	void doSerialize(TiXmlElement& element) const;
	void doDeserialize(const TiXmlElement& element);
public:
	static TXmlObject* newObject()
	{
		return new TkEntry(TclInterp::defaultInterp);
	}

	const static Ptr<TkOptionDef> OPT_BACKGROUND;
	const static Ptr<TkOptionDef> OPT_BORDERWIDTH;
	const static Ptr<TkOptionDef> OPT_CURSOR;
	const static Ptr<TkOptionDef> OPT_DISABLEDBACKGROUND;
	const static Ptr<TkOptionDef> OPT_DISABLEDFOREGROUND;
	const static Ptr<TkOptionDef> OPT_EXPORTSELECTION;
	const static Ptr<TkOptionDef> OPT_FONT;
	const static Ptr<TkOptionDef> OPT_FOREGROUND;
	const static Ptr<TkOptionDef> OPT_HIGHLIGHTBACKGROUND;
	const static Ptr<TkOptionDef> OPT_HIGHLIGHTCOLOR;
	const static Ptr<TkOptionDef> OPT_HIGHLIGHTTHICKNESS;
	const static Ptr<TkOptionDef> OPT_INSERTBACKGROUND;
	const static Ptr<TkOptionDef> OPT_INSERTBORDERWIDTH;
	const static Ptr<TkOptionDef> OPT_INSERTONTIME;
	const static Ptr<TkOptionDef> OPT_INSERTWIDTH;
	const static Ptr<TkOptionDef> OPT_INVALIDCOMMAND;
	const static Ptr<TkOptionDef> OPT_JUSTIFY;
	const static Ptr<TkOptionDef> OPT_READONLYBACKGROUND;
	const static Ptr<TkOptionDef> OPT_RELIEF;
	const static Ptr<TkOptionDef> OPT_SELECTBACKGROUND;
	const static Ptr<TkOptionDef> OPT_SELECTBORDERWIDTH;
	const static Ptr<TkOptionDef> OPT_SELECTFOREGROUND;
	const static Ptr<TkOptionDef> OPT_SHOW;
	const static Ptr<TkOptionDef> OPT_STATE;
	const static Ptr<TkOptionDef> OPT_TAKEFOCUS;
	const static Ptr<TkOptionDef> OPT_TEXTVARIABLE;
	const static Ptr<TkOptionDef> OPT_VALIDATE;
	const static Ptr<TkOptionDef> OPT_VALIDATECOMMAND;
	const static Ptr<TkOptionDef> OPT_WIDTH;
	const static Ptr<TkOptionDef> OPT_XSCROLLCOMMAND;

	const static Ptr<TkOptionDef> optAll[];
	const static char* type;
	const static char* tkClass;

	const Ptr<TkOptionDef>* getOptionAll() const;
	const char* getType() const;
	const char* getTkClass() const;

	TObject* clone();

	TkEntry(Ptr<TclInterp>& interp);
	TkEntry(Ptr<TclInterp>& interp,const string& text);

	void setText(const string& value);
	
	/**
	 * Only entering double value into the entry will be allowed 
	 */
	void setValidationDouble();
	
	
	/**
	 * Only entering integer value into the entry will be allowed
	 */
	void setValidationInt();
	
	
	/**
	 * Entry would accept any value
	 */
	void setValidationNone();
	
	const string& getText() const;

	TclVar* getDefaultVar() 
	{
		return &var;
	}	

	/**
	 *
	 * \return content of entry as double
	 */
	double doubleValue() const;

	void setEnabled(bool value);
	bool isEnabled() const;

	void addValueListenter(TclVarListener* listener);

	/**
	 * Set entry into the third state - entering value will be prohibited,
	 * but user can copy content
	 */
	void setReadonly();

	void setEventsEnabled(bool value)
	{
		TkBase::setEventsEnabled(value);
		var.setEventsEnabled(value);
	}

	void setBackgroundColor(TkColorOption* color);
	Ptr<TkColorOption>& getBackgroundColor() const;
};

#endif/*_TK_ENTRY_H_*/
