/******************************************************************************
Copyright (C) 2009 Matteo Lucarelli

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
******************************************************************************/

// Widget to plot simple (but fast) bar graph
// NEED: `fltk-config --ldflags`

#if !defined(FL_BARPLOT_H_INCLUDED)
#define FL_BARPLOT_H_INCLUDED

#include <FL/Fl.H>
#include <FL/Fl_Box.H>
#include <FL/fl_draw.H>

#include <stdlib.h>

class Fl_BarPlot : public Fl_Box {

public:
	
	// widget size and position (inside the window)
	Fl_BarPlot(int X, int Y, int W, int H);
	virtual ~Fl_BarPlot();

	// number and range of bars
	// MUST BE CALLED FIRST
	void setBars(int count,float minVal,float maxVal);
	
	// single bar value
	void setBarVal(int index, float val);
	float getBarVal(int index);
	
	// 0 to disable
	// distance in the bars scale
	// thick in pixel
	void setNotch(float distance,int thick=1);
	
	// Fl_Colors
	void setBarColor(Fl_Color val);
	void setBgColor(Fl_Color val);
	
private:

	void draw();

	Fl_Color m_bgColor;
	Fl_Color m_barColor;

	int m_barCount;
	float m_barMin;
	float m_barMax;
	
	float *m_barVal;
	
	float m_NotchDistance;
	int m_NotchThick;
	
};

#endif // !defined(FL_BARPLOT_H_INCLUDED)