#ifndef _TK_CHECKBUTTON_H_
#define _TK_CHECKBUTTON_H_

#include "tk_base.h"

/**
 * \brief Represent "checkbutton" widget
 *
 * TkCheckButton is bind to inner bool variable, via which can user
 * set TkCheckButton checked/unchecked. TkCheckButton also contains some methods to
 * retrieve/set this variable.
 *
 * \date 01-12-2006
 *
 * \author Ondrej Svejdar
 *
 * \todo 
 *
 * \bug 
 *
 */
class TkCheckButton:public TkBase,public IStateable,public ITextable,public IInnerVariable
{
	Ptr<TclBoolVar> defaultVar,var;
protected:
	void doSerialize(TiXmlElement& element) const;
	void doDeserialize(const TiXmlElement& element);
public:
	static TXmlObject* newObject()
	{
		return new TkCheckButton(TclInterp::defaultInterp);
	}

	const static Ptr<TkOptionDef> OPT_ACTIVEBACKGROUND ;
	const static Ptr<TkOptionDef> OPT_ACTIVEFOREGROUND ;
	const static Ptr<TkOptionDef> OPT_ANCHOR ;
	const static Ptr<TkOptionDef> OPT_BACKGROUND ;
	const static Ptr<TkOptionDef> OPT_BITMAP ;
	const static Ptr<TkOptionDef> OPT_BORDERWIDTH ;
	const static Ptr<TkOptionDef> OPT_COMMAND ;
	const static Ptr<TkOptionDef> OPT_COMPOUND ;
	const static Ptr<TkOptionDef> OPT_CURSOR ;
	const static Ptr<TkOptionDef> OPT_DISABLEDFOREGROUND ;
	const static Ptr<TkOptionDef> OPT_FONT ;
	const static Ptr<TkOptionDef> OPT_FOREGROUND ;
	const static Ptr<TkOptionDef> OPT_HEIGHT ;
	const static Ptr<TkOptionDef> OPT_HIGHLIGHTBACKGROUND ;
	const static Ptr<TkOptionDef> OPT_HIGHLIGHTCOLOR ;
	const static Ptr<TkOptionDef> OPT_HIGHLIGHTTHICKNESS ;
	const static Ptr<TkOptionDef> OPT_IMAGE;
	const static Ptr<TkOptionDef> OPT_INDICATORON;
	const static Ptr<TkOptionDef> OPT_JUSTIFY ;
	const static Ptr<TkOptionDef> OPT_OFFVALUE ;
	const static Ptr<TkOptionDef> OPT_OVERRELIEF ;
	const static Ptr<TkOptionDef> OPT_PADX ;
	const static Ptr<TkOptionDef> OPT_PADY ;
	const static Ptr<TkOptionDef> OPT_RELIEF ;
	const static Ptr<TkOptionDef> OPT_SELECTCOLOR ;
	const static Ptr<TkOptionDef> OPT_SELECTIMAGE ;
	const static Ptr<TkOptionDef> OPT_STATE ;
	const static Ptr<TkOptionDef> OPT_TAKEFOCUS ;
	const static Ptr<TkOptionDef> OPT_TEXT ;
	const static Ptr<TkOptionDef> OPT_TEXTVARIABLE ;
	const static Ptr<TkOptionDef> OPT_UNDERLINE ;
	const static Ptr<TkOptionDef> OPT_VARIABLE ;
	const static Ptr<TkOptionDef> OPT_WIDTH ;
	const static Ptr<TkOptionDef> OPT_WRAPLENGTH ;

	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();

	TkCheckButton(Ptr<TclInterp>& interp);

	/**
	 * Add listener to inner variable (TclBoolVar)
	 * \param listener listener
	 */
	void addValueListener(TclVarListener* listener);

	/**
	 * Force checkbutton to be checked/unchecked
	 * \param value if true, button will be checked
	 */
	void setSelected(bool value);

	/**
	 * \return true if checkbutton is checked
	 */
	bool isSelected() const;

	void setText(const string& text);
	const string& getText() const;

	
	/**
	 * Replace default inner variable with user-defined one
	 * \param var variable to be set
	 */
	void setVariable(TclBoolVar* var);
	
	/**
	 * \return default inner variable
	 */
	TclVar* getDefaultVar();

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

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

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

#endif/*_TK_CHECKBUTTON_H_*/
