/***************************************************************************
 * fretboard.h: implementation of FretBoard class
 *
 * This file is part of KTabEdit, a KDE tabulature editor
 *
 * copyright (C) 2003-2006 the KTabEdit development team <mrgwen@gmail.com>
 * copyright (C) 2002-2003 the KGuitar development team <mrgwen@gmail.com>
 ***************************************************************************/

/***************************************************************************
 * 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.
 *
 * See the file COPYING for more information.
 ***************************************************************************/

#ifndef FRETBOARD_H
#define FRETBOARD_H

#include <QWidget>
#include <QVector>
#include <QImage>
#include <QPixmap>
#include <QPaintEvent>

#include "global.h"

class TabTime;
class TrackProperties;

/**
@brief Class that handles the drawing etc. of the fretboard
*/
class Fretboard : public QWidget {
	Q_OBJECT
public:
	Fretboard(const TrackProperties* trackProperties, QWidget* parent);
	virtual ~Fretboard();

public slots:
	virtual void setTrackProperties(const TrackProperties* trackProperties);
	virtual void setTabTime(const TabTime* tabTime);
	
	virtual void setTonic(int);
	virtual void setMode(int);
	
	virtual void drawBackground(QPainter* painter);
	virtual void drawScaleBack(QPainter* painter);
	virtual void drawTime(QPainter* painter);
	
signals:
	void buttonPress(int, int, Qt::ButtonState);
	void buttonRelease(Qt::ButtonState);

protected:
	virtual void paintEvent(QPaintEvent *);
	/*virtual void mousePressEvent(QMouseEvent *);
	virtual void mouseMoveEvent(QMouseEvent *);
	virtual void mouseReleaseEvent(QMouseEvent *);
	virtual void resizeEvent(QResizeEvent *);
	virtual QSizePolicy sizePolicy();*/

private:
	void handleMouse(QMouseEvent *);
	void recalculateSizes();
	
	static const uchar sStringHeight;
	static const double sFretDivisor;
	static const uchar sZeroFretWidth;
	static const uchar sInlayRadius;
	static const uchar sFingerRadius;
	static const uchar sSideBorder;
	static const uchar sScaleBorder;
	static const uchar sScaleRound;
	
	static const QColor sInlayFillColor;
	static const QColor sFretColor1;
	static const QColor sFretColor2;
	static const QColor sStringColor1;
	static const QColor sStringColor2;
	static const QColor sFingerColor;
	
	const TrackProperties* mTrackProperties;
	const TabTime* mTabTime;
	
	QVector<double> mCalculateSizes;
	QPixmap* mWood;
	QImage* mFret;
	QImage* mZeroFret;
	int mTonic;
	int mMode;
};

#endif
