/***************************************************************************
 *   Copyright (C) 2005 by Ian Reinhart Geiser                             *
 *   geiseri@sourcextreme.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.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef DHW_PAGE_H
#define DHW_PAGE_H
#include <QByteArray>
#include <QSizeF>
#include <QPolygonF>
#include <QList>
#include <QColor>
#include <QPicture>

class QPainter;

struct DHWLayer
{
	int number;
	QList<QPolygonF> polyList;
};

class DHWPage
{
public:
	enum PageTypes {A5 = 0, A4 = 1, B5 = 8, B4= 9 };
	enum ByteType { PenDown, PenUp, TimeStamp, Layer, Data, Invalid };

	DHWPage( const QByteArray &array );
	DHWPage();
	void setBytes(const QByteArray &array);
	virtual ~DHWPage();
	virtual QSizeF readPageSize(  ) const;
	PageTypes readPageType(  ) const;
	int readVersion(  ) const;

	ByteType idBytes( int idx) const;
	QPointF readPoint( int start ) const;
	QColor readColor( int idx ) const;
	int size() const;
	virtual QList<DHWLayer> readLayerData() const;

	virtual void drawLayer( const QSizeF &painterSize, QPainter *dev, bool aa = false )  const;
	virtual void drawSection(const QSizeF &painterSize,
		const QRectF &painterRect, QPainter *painter, bool aa = false )  const;

	QImage drawImage( const QSizeF &pgSize, const QRectF &area = QRectF() ) const;

	int layers() const;
	QSizeF scaleTo( const QSizeF &size  ) const;
	virtual QPicture picture( ) const;

private:
	QByteArray mBytes;
	QList<DHWLayer> mLayers;
	QPicture mPicture;
};

#endif

