/***************************************************************************
 * songprint.cpp: implementation of SongPrint class
 *
 * This file is part of KTabEdit, a KDE tabulature editor
 *
 * copyright (C) 2004-2006 the KTabEdit development team <mrgwen@gmail.com>
 * copyright (C) 2002-2004 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.
 ***************************************************************************/

#include "songprint.h"

#include <Q3Canvas>
#include <QPainter>

#include <QtGui/QPrinter>
#include <QtGui/QPrintDialog>

#include "tablature/tabbeateffects.h"
#include "tablature/tabchord.h"
#include "tablature/tabduration.h"

#include "tablature/tabbend.h"
#include "tablature/tabdynamic.h"

#include "tablature/tabgracenotetransition.h"
#include "tablature/tabgracenote.h"

#include "tablature/tabharmonic.h"
#include "tablature/tabslide.h"
#include "tablature/tabtrill.h"
#include "tablature/tabnoteeffect.h"

#include "tablature/tabnote.h"

#include "tablature/songkey.h"
#include "tablature/timesignature.h"

#include "tablature/tabmixtablechanges.h"
#include "tablature/tabtimes.h"
#include "tablature/tabbarproperties.h"

#include "tablature/tabbar.h"

#include "tablature/trackmidiproperties.h"
#include "tablature/trackproperties.h"

#include "tablature/tabtrack.h"

#include "tablature/tablyrics.h"
#include "tablature/tabproperties.h"

#include "accidentals.h"
#include "tablature/tabsong.h"
#include "settings.h"
#include "track/trackview.h"




// SongPrint constructor
//
SongPrint::SongPrint()
{
}

// SongPrint destructor

SongPrint::~SongPrint()
{
}

// print TabSong song on QPrinter printer
//
void SongPrint::printSong(QPrinter *printer, TabSong *song)
{
	uint nbPages = 0;
	const int dpi = 0;//printer->resolution();
	QSize trackResolution(static_cast<int>(8.26 * dpi), static_cast<int>(11.7 * dpi));
	QPainter painter(printer);
	QWMatrix matrix;
	//QCanvas* printCanvas = new QCanvas();
//	Q3Canvas* printCanvas = new Q3Canvas();
	QRect i;
/*	TrackView* trackPrint = new TrackView(printCanvas, song, dpi, 1.016, 1.016, trackResolution, false);
	
	trackPrint->setDrawEffects(false);
	trackPrint->setCurrentTrack(song->first());
	
	const QRect canvasRect(printCanvas->rect());
	
	i.setTop(0);
	i.setBottom(trackResolution.height());
	
	i.setLeft(0);
	i.setRight(canvasRect.right());
	
	QPaintDeviceMetrics pdm(printer);
	
	kDebug() << "Page size : " << printer->pageSize() << "\n";
	kDebug() << "Margins : " << printer->margins() << "\n";
	kDebug() << "\n";
	kDebug() << "Height : " << pdm.height() << "\n";
	kDebug() << "Width : " << pdm.width() << "\n";
	kDebug() << "resolution : " << dpi << "\n";
	kDebug() << "\n";
	kDebug() << "Height : " << trackResolution.height() << "\n";
	kDebug() << "Width : " << trackResolution.width() << "\n";
	
// 	matrix.scale(static_cast<double>(pdm.width()) / static_cast<double>(trackResolution.width()),
// 				 static_cast<double>(pdm.height()) / static_cast<double>(trackResolution.height()));
// 	painter.setWorldMatrix(matrix);
	
	while (nbPages < trackPrint->pages()) {
		printCanvas->drawArea(i, &painter, false);
		
		painter.translate(0, -trackResolution.height());
		
		nbPages++;
		
		i.setTop(nbPages * trackResolution.height());
		i.setBottom((nbPages + 1) * trackResolution.height());
		
		if (nbPages < trackPrint->pages())
			printer->newPage();
	}
	
	delete trackPrint;
	delete printCanvas;*/
}
