#ifndef PLOT_PROPERTIES_H
#define PLOT_PROPERTIES_H

#include <QtGui>

#include "Plot.h"
#include "my_signal.h"
#include "SignalProperties.h"

class Plot;	//<- Forward declaration for compiler...

/*
 * General Class to be extended ...
 * Hold all common staff of all tabs in 
 * Properties Dialog, so no Specific casting
 * is needed.
 */
class PlotPropTab : public QWidget{
	Q_OBJECT
	protected:
		bool mod;
	public:
		PlotPropTab(QWidget * parent=0);
		virtual ~PlotPropTab();
		
		virtual bool isModified();
		
	public slots:
		virtual void applyChanges(Plot * plot);
		
	signals:
		void modified();
};

// Statistics Tab
class StatsTab : public PlotPropTab{
	Q_OBJECT
	private:
		QLabel * mean;
		QLabel * variance;
		QLabel * stdDeviation;
		QLabel * avgDeviation;
		QLabel * skewness;
		QLabel * kurtosis;
		QLabel * maxY;
		QLabel * maxX;
		QLabel * minY;
		QLabel * minX;

	public:
		StatsTab(QWidget * parent=0);
		virtual ~StatsTab();
		
		void updateForSignal(Signal &sig);
};

// Edit Tab
class EditTab : public PlotPropTab{
	Q_OBJECT
	private:
		QLineEdit * horMove;
		QLineEdit * verMove;
		QLineEdit * percent;
		QLabel * currentPos;
		QLabel * currentNoise;
		
	public:
		EditTab(QWidget * parent=0);
		virtual ~EditTab();
		
		void updateSignalProperties(SignalProperties &prop);
		
	public slots:
		void setModified();
		virtual void applyChanges(Plot * plot);

};

// Settings Tab
class SettingsTab : public PlotPropTab{
	Q_OBJECT
	private:
		QLineEdit * gridSpace;
		QLineEdit * border;
		QPushButton * signalColor;
		QPushButton * bgColor;
		QPushButton * axesColor;
		QPushButton * gridColor;
		QPushButton * linesColor;
		QColor * defButColor;
		QSlider * animSpeed;
		
		void chColor(QPushButton *but,QColor c);
		QColor getButColor(QPushButton * but);
		
	public:
		SettingsTab(QWidget * parent=0);
		virtual ~SettingsTab();
		
		void updateSettings(Plot *plot);
		
	public slots:
		void setModified();
		virtual void applyChanges(Plot * plot);
		void choseColor(QAbstractButton *);
		void animSpeedChanged(int v);
		
	signals:
		void speedChanged(int v);
};

// THE DIALOG
class PlotProperties : public QDialog{
	Q_OBJECT
	//Variables
	private:
		Plot * plot;
		QTabWidget * tabs;
		StatsTab * statsTb;
		EditTab * editTb;
		SettingsTab * setTb;
		QDialogButtonBox *buttonBox;
		
	// Methods - Constructors
	public:
		PlotProperties (QWidget *parent,Qt::WindowFlags f=0);
		virtual ~PlotProperties();
		
		void updateContents();
	
	// Methods
	private:
		void createUI();
		void connectSlots();
		
	public slots:
		void okClicked();
		void manageApply();
		void applyClicked();
		void changeAnimSpeed(int value);
		
};//:~)

#endif
