/***************************************************************************
 * qcanvasrectanglecm.cpp: implementation of QCanvasRectangleCm class
 *
 * This file is part of KTabEdit, a KDE tabulature editor
 *
 * copyright (C) 2003-2007 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.
 ***************************************************************************/

#include "qcanvasrectanglecm.h"
#include "track/cm.h"
#include "track/qrectcm.h"

QCanvasRectangleCm::QCanvasRectangleCm()
: QGraphicsRectItem(),
  mSize()
{
}

QCanvasRectangleCm::QCanvasRectangleCm(const QRectCm& r)
: QGraphicsRectItem(r.toRect()),
  mSize(r.width(), r.height())
{
}

QCanvasRectangleCm::QCanvasRectangleCm(const Cm& x, const Cm& y, const Cm& width,const Cm& height, QGraphicsItem* canvas)
: QGraphicsRectItem(x.valueOfPixel(), y.valueOfPixel(), width.valueOfPixel() , height.valueOfPixel(), canvas),
  mSize(width, height)
{
}

QCanvasRectangleCm::~QCanvasRectangleCm()
{
}

/*
void QCanvasRectangleCm::setX(const Cm& x)
{
	QCanvasRectangle::setX(x.valueOfPixel());
}

void QCanvasRectangleCm::setY(const Cm& y)
{
	QCanvasRectangle::setY(y.valueOfPixel());
}

void QCanvasRectangleCm::move(const Cm& x, const Cm& y)
{
	QCanvasRectangle::move(x.valueOfPixel(), y.valueOfPixel());
}
*/

void QCanvasRectangleCm::setSize(const QSizeCm& size)
{
	mSize = size;
}

void QCanvasRectangleCm::setSizeInCm(const Cm& width, const Cm& height)
{
	mSize.setWidth(width);
	mSize.setHeight(height);
}

void QCanvasRectangleCm::setPosFromCoord(const Cm& x, const Cm& y)
{
	setRect(x.valueOfPixel(), y.valueOfPixel(), mSize.widthValueOfPixel(), mSize.heightValueOfPixel());
}

void QCanvasRectangleCm::moveBy(const Cm& x, const Cm& y)
{
	setPos(x.valueOfPixel(), y.valueOfPixel());
}
