#ifndef QT_NODE_WIDGET
#define QT_NODE_WIDGET

#include <qwidget.h>
#include <qobject.h>
#include <qpainter.h>
#include <qframe.h>
#include <qlabel.h>
#include <string>

class ScienceNode;

/** Widget for displaying tree node */
class NodeWidget : public QFrame
{
	Q_OBJECT
public:
	/** Constructor
	* @param parent Parent widget
	*/
    NodeWidget(QWidget * parent);

	/** Sets reference to logical node for this widget
	* @param logicalNode Logical node for this widget
	*/
	void setLogicalNode(ScienceNode * logicalNode);

	/** Sets label for this widget
	* @param label Label for this widget
	*/
	void setLabel(QLabel * label);

	/** Gets logical node for this widget
	* @return Logical node for this widget
	*/
	ScienceNode * getLogicalNode();

	/** Setups size required for representing amount of points for logical node */
	void setupPointsSize();

	/** Setups size required for representing amount of tokens for logical node */
	void setupTokensSize();

	/** Setups rest of size of component minus size for points and tokens  */
	void setupRestSize();

	/** Setups node width ratio, that means width of one point or token in widget */
	void setupNodeWidthRatio();

signals:
	void mousePressSignal(NodeWidget * clickedNode);

protected:
	 virtual void mousePressEvent(QMouseEvent * mouseEvent); 
	 virtual void enterEvent(QEvent * mouseEvent);
	 virtual void leaveEvent(QEvent * mouseEvent);
	 virtual void resizeEvent(QResizeEvent * resizeEvent);
	 void paintEvent(QPaintEvent * paintEvent);

private:
	ScienceNode * logicalNode_;
	int pointsWidth_;
	int tokensWidth_;
	int tokensHeight_;	
	int pointsHeight_;
	int restWidth_;
	QLabel * label_;
	double nodeWidthRatio_;
};

#endif