#include "LutView.H"
#include <FL/fl_draw.H>

LutView::LutView( int x, int y, int w, int h, const char* label )
	: Fl_Widget( x, y, w, h, label )
{
	m_lut = 0;
}
LutView::~LutView()
{
}
void LutView::draw()
{
	if ( !m_lut ) {
		return;
	}
	fl_draw_box( FL_DOWN_BOX, x(), y(), w(), h(), FL_BACKGROUND_COLOR );
	fl_push_clip( x() + 2, y() + 2,  w() - 4, h() - 4 );
	fl_push_matrix();

	fl_translate( x()+2, y()+2 );
	fl_scale( (w() - 4) / 256.0, (h() - 4) / 256.0 );

	fl_color( FL_FOREGROUND_COLOR );
	fl_line_style( FL_SOLID, 2 );

	fl_begin_line();
	for ( int i = 0; i < 256; i++ ) {
		fl_vertex( i, 255 - m_lut[i] );
	}
	fl_end_line();
	fl_line_style( FL_SOLID, 1 );

	fl_pop_matrix();
	fl_pop_clip();
}


