/***************************************************************************
 * trackpageview.h: implementation of TrackPageView class
 *
 * This file is part of KTabEdit, a KDE tabulature editor
 *
 * copyright (C) 2003-2006 the KTabEdit 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 TRACKPAGEVIEW_H
#define TRACKPAGEVIEW_H

#include <QList>

#include "tablature/tabproperties.h"

#include "drawingitem.h"
#include "cm.h"
#include "qsizecm.h"

class TabNote;
class TabSong;
class TabTime;
class TabTrack;
class TrackPos;
class TrackSystemView;
class TrackTuningView;
class TrackTitleView;
class TrackWordsAndMusicView;
class TabBar;
class QCanvasRectangleCm;
class QCanvasTextCm;
class TrackBarView;

class TrackPageView : public DrawingItem
{
public:
	TrackPageView(uint dpi);
	virtual ~TrackPageView();
	
	virtual void setSongProperties(const TabProperties* songProperties);
	virtual const TabProperties* songProperties() const;
	
	virtual void setTabTrack(const TabTrack* tabTrack);
	virtual const TabTrack* tabTrack() const;
	
	virtual void setPageSize(const QSizeCm& pageSize);
	virtual QSizeCm pageSize() const;
	
	virtual void setLeftMargins(Cm margins);
	virtual Cm leftMargins() const;
	
	virtual void setTopMargins(Cm margins);
	virtual Cm topMargins() const;
	
	virtual Cm pageWidth() const;
	
	virtual void setPageNumber(uint pageNumber);
	virtual uint pageNumber() const;
	
	virtual void addSystem(TrackSystemView* systemView);
	
	virtual void hide();
	virtual void show();
	virtual void refresh();
	virtual void refreshSongProperties();
	virtual void refreshBarAt(uint barNumber, const TabBar* tabBar);
	virtual void refreshTimeAt(uint bar, uint time, const TabTime* tabTime);
	virtual void refreshNoteAt(const TrackPos& position, const TabNote* tabNote);
	
	virtual bool hasBarNumber(uint barNumber) const;
	virtual TrackBarView* barAt(uint barNumber) const;
	
	virtual void displayTitle(bool b);
	virtual bool isDisplayTitle() const;
	
	virtual void displayWordsAndMusic(bool b);
	virtual bool isDisplayWordsAndMusic() const;
	
	virtual void displayTuning(bool b);
	virtual bool isDisplayTuning() const;
	
	virtual TrackPos cursorPositionAt(const QPointCm& point);
	virtual bool isPointInPage(const QPointCm& point) const;
	
	virtual QRectCm boundingRect() const;
	virtual Cm height() const;
	virtual Cm width() const;
	virtual Cm headersHeight() const;
	
	virtual void deleteTitleView();
	virtual void deleteWordsAndMusicView();
	virtual void deleteTuningView();
	virtual void deletePageView();
	
	virtual void drawAndAddHeight(bool condition, DrawingItem* canvasItem, QPointCm* point);
	
	virtual QRectCm pageRectangle() const;
	virtual Cm rigthPositionOfPageRect() const;
	virtual Cm bottomPositionOfPageRect() const;
	
	virtual int lengthOfFeeder() const;
	virtual QString feederOfPage() const;
	
	virtual void drawPage();
	virtual void drawHeaders();
	virtual void hideHeaders();
private:
	typedef QList<TrackSystemView*>::const_iterator const_iterator;
	typedef QList<TrackSystemView*>::iterator iterator;
	
	const TabProperties* mSongProperties;
	const TabTrack* mTabTrack;
	
	QSizeCm mPageSize;
	
	Cm mLeftMargins;
	Cm mTopMargins;
	
	uint mPageNumber;
	
	bool mTitle;
	bool mWordsAndMusic;
	bool mTuning;
	
	QCanvasRectangleCm* mCanvasRectangle;
	QCanvasTextCm* mCanvasText;
	TrackTitleView* mTitleView;
	TrackWordsAndMusicView* mWordsAndMusicView;
	TrackTuningView* mTuningView;
	
	QList<TrackSystemView*> mTrackSystemView;
};

#endif
