/***************************************************************************
 * trackview.h: implementation of TrackView class
 *
 * This file is part of KTabEdit, a KDE tabulature editor
 *
 * copyright (C) 2003-2007 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 TRACKVIEW_H
#define TRACKVIEW_H

#include <QPoint>
#include <QRect>
#include <QSize>
#include <QGraphicsScene>
#include <Q3Canvas>

#include "tablature/tabduration.h"
#include "tablature/trackpos.h"

#include "trackpagelist.h"

class Cm;
class TabProperties;
class TabTrack;
class TrackBarView;
class TrackCursorView;
class TrackPageView;
class TrackSystemView;

class TrackView/* : public Unit*/ {
public:
	//TODO Q3Canvas deprecated
	TrackView(Q3Canvas* canvas, const TabProperties& tabProperties, const TabTrack& tabTrack, int dpi, const Cm& left, const Cm& bottom, const QSize& displayResolution, bool landscapeView);
	
	virtual ~TrackView();
	void setVisible(bool yes);
	void show();
	void hide();
	void refreshCursor(const TrackPos& cursorPos);
	QPoint cursorPosition() const;
	
	uint pages() const
	{ return nbPages; }
	
	void setDrawEffects(bool b)
	{ drawEffects = b; }
	
	bool isDrawEffects() const
	{ return drawEffects; }
	
	TrackPos mousePressEvent(const QPoint &position);
	
	void setViewScore(bool b, const TrackPos& cursorPos);
	bool viewScore() const;

private:
	void drawPages(uint nbPages);
	TrackBarView * barViewCreate(uint nb, uint firstBar);
	void refreshProperties();
	void refreshView(uint from);

	QGraphicsScene* canvasView;
	const TabProperties& mTabProperties;
	const TabTrack& mTabTrack;
	const uint mDpi;
	const QSize trackResolution;
	bool landscape;
	bool mVisible; /**< Show or hide the track */
	const int leftMargins, bottomMargins; /**< Margins */
	QRect trackBody; /**< Resolution of the track with the margins */
	QPoint trackPos; /**< Position of the tablature on the screen */
	TrackCursorView* cursorView;
	uint nbPages; /**< Number of pages */
	bool drawEffects;
	bool drawScore;
	static QFont clefFont;
	static QFont timeFont;
	// List all of the pages in the current track
	//QPtrList<TrackPageView> pageList;
	
	// List all of systems  in the current track
	//TrackSystemList systemList;
};

#endif
