/***************************************************************************
 * qrectcm.cpp: implementation of QRectCm 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 "qrectcm.h"

#include "qsizecm.h"
#include "qpointcm.h"

QRectCm::QRectCm()
: mLeft(0, 72),
  mTop(0, 72),
  mWidth(0, 72),
  mHeight(0, 72)
{
}

QRectCm::QRectCm(const QPointCm& topLeft, const QPointCm& bottomRight)
: mLeft(topLeft.x()),
  mTop(topLeft.y()),
  mWidth(bottomRight.x() - topLeft.x()),
  mHeight(bottomRight.y() - topLeft.y())
{
}

QRectCm::QRectCm(const QPointCm& topLeft, const QSizeCm& size)
: mLeft(topLeft.x()),
  mTop(topLeft.y()),
  mWidth(size.width()),
  mHeight(size.height())
{
}

QRectCm::QRectCm(const Cm& left, const Cm& top, const Cm& width, const Cm& height)
: mLeft(left),
  mTop(top),
  mWidth(width),
  mHeight(height)
{
}

QRectCm::~QRectCm()
{
}

QRect QRectCm::toRect() const
{
	return QRect(mLeft.valueOfPixel(), mTop.valueOfPixel(), mWidth.valueOfPixel(), mHeight.valueOfPixel());
}

void QRectCm::setRect(const Cm& x, const Cm& y, const Cm& width, const Cm& height)
{
	mLeft = x;
	mTop = y;
	mWidth = width;
	mHeight = height;
}

void QRectCm::setLeft(const Cm& pos)
{
	mLeft = pos;
}

Cm QRectCm::left() const
{
	return mLeft;
}

void QRectCm::setTop(const Cm& pos)
{
	mTop = pos;
}

Cm QRectCm::top() const
{
	return mTop;
}

void QRectCm::setRight(const Cm& pos)
{
	mWidth = pos - mLeft;
}

Cm QRectCm::right() const
{
	return mLeft + mWidth;
}

void QRectCm::setBottom(const Cm& pos)
{
	mHeight = pos - mTop;
}

Cm QRectCm::bottom() const
{
	return mTop + mHeight;
}

void QRectCm::setX(const Cm& x)
{
	mLeft = x;
}

Cm QRectCm::x() const
{
	return mLeft;
}

void QRectCm::setY(const Cm& y)
{
	mTop = y;
}

Cm QRectCm::y() const
{
	return mTop;
}

void QRectCm::setWidth(const Cm& w)
{
	mWidth = w;
}

Cm QRectCm::width() const
{
	return mWidth;
}

void QRectCm::setHeight(const Cm& h)
{
	mHeight = h;
}

Cm QRectCm::height() const
{
	return mHeight;
}
