#ifndef SELECTIONWIDGET_H
#define SELECTIONWIDGET_H

#include <string>
#include <vector>
#include <map>
#include <qobject.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qevent.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include "ui_SelectionWidget.h"
#include "softProj\render\SpaceStructures.h"

///ProgressBar based on QLabel class
class MyProgressBar: public QLabel
{
	Q_OBJECT
private:
	unsigned int percentageProgress;

protected:
	virtual void paintEvent(QPaintEvent *);

public:
	MyProgressBar( QWidget *parent = NULL ): QLabel( parent ) { percentageProgress = 0; };

public slots:
	void progressSlot( unsigned int percentageProgress );
};

///Button based on QPushButton
class MyPushButton: public QPushButton
{
	Q_OBJECT

public:
	QString myText;
	unsigned int slotIdx;

	MyPushButton( unsigned int slotIdx, QWidget * parent = 0 ): QPushButton( parent ) { this->slotIdx = slotIdx;  }

public slots:
	void mousePressEvent ( QMouseEvent * e ) 
	{ 
		if ( e->button() == Qt::LeftButton) emit clickedSignal( slotIdx ); 
		QPushButton::mousePressEvent( e );
	};

protected:
	virtual void paintEvent ( QPaintEvent *);
	

signals:
	void clickedSignal( unsigned int id );
};

///Consist of array of buttons and its functionality. 
class SelectionWidget: public QWidget
{
	Q_OBJECT

private:
	std::vector< MyPushButton* >  itemArray;

	SelectionWidget( const SelectionWidget& );	// undefined
	SelectionWidget& operator=( const SelectionWidget ); //undefined
	
public:
	SelectionWidget( QWidget *parent );

	void init(  unsigned int maxButtons, unsigned int buttonSizeX = 50, unsigned int buttonSizeY=50, unsigned int space=0  );
	void clear( void );

	~SelectionWidget();

	MyPushButton &getItem(unsigned int id ); 
	unsigned int getArraySize(void);

public slots:
	void buttonSelectedSlot( unsigned int id );

signals:
	void selectedItem( unsigned int id );
	
};






#endif
