#ifndef _TK_RADIOBUTTON_H_
#define _TK_RADIOBUTTON_H_

#include "tk_base.h"

/**
 * \brief Represent "radiobutton" widget
 * \date 01-12-2006
 *
 * \author Ondrej Svejdar
 *
 * \todo 
 *
 * \bug 
 *
 */
class TkRadioButton:public TkBase,public IStateable,public ITextable
{
	bool selected;
	bool selectedSet;
	string group;
	bool groupSet;
protected:
	void doSerialize(TiXmlElement& element) const;
	void doDeserialize(const TiXmlElement& element);
public:
	static TXmlObject* newObject()
	{
		return new TkRadioButton(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_OVERRELIEF ;
	const static Ptr<TkOptionDef> OPT_PADX ;
	const static Ptr<TkOptionDef> OPT_PADY ;
	const static Ptr<TkOptionDef> OPT_RELIEF ;
	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_VALUE ;
	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();

	TkRadioButton(Ptr<TclInterp>& interp);

	/**
	 * Force this radiobutton to be selected/deselected. NOTE: This may not work
	 * correctly if radiobutton hasn't got a group assigned or is the only one radiobutton
	 * in his group.
	 * \param value if true radiobutton will be selected
	 */
	void setSelected(bool value);

	/**
	 * Return true if radiobutton is selected. NOTE: This may not work
	 * correctly if radiobutton hasn't got a group assigned or is the only one radiobutton
	 * in his group.
	 * \return true if radiobutton is selected
	 */
	bool isSelected() const;

    void create()
	{
		TkBase::create();
		if (groupSet) setGroup(group);
		if (selectedSet) setSelected(selected);
	}

	void setText(const string& text)
	{
		setOption(TkRadioButton::OPT_TEXT,new TkStringOption(text));
	}
	
	const string& getText() const
	{
		return TkBase::getStrOption(TkRadioButton::OPT_TEXT);
	}

	/**
	 * Return name of group to which radiobutton belongs
	 * \return name of group
	 */
	const string& getGroup() const;
	
	
	/**
	 * Assing radiobutton to group named "name". NOTE: The group is identified by parent container and name.
	 * so two radiobuttons with the same name of group, but lying in diferent container will NOT be
	 * in the same group.
	 * \param name group name
	 */
	void setGroup(const string& name);

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

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

#endif/*_TK_RADIOBUTTON_H_*/
