/***************************************************************************
 * cm.h: implementation of Cm 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.
 ***************************************************************************/

#ifndef CM_H
#define CM_H

#include "unit.h"

#include "inches.h"
#include "pixel.h"

class Cm : public Unit {
public:
	Cm(double cm, uint dpi) : Unit(dpi), mCm(cm) {};
	~Cm() {};
	
	Inches toInches() const { return Inches(mCm / inchesForACm(), dpi()); };
	Pixel toPixel() const { return Pixel(static_cast<uint>(static_cast<double>(dpi()) * (mCm / inchesForACm())), dpi()); };
	
	double value() const { return mCm; };
	uint valueOfPixel() const { return toPixel().value(); };
	
	Cm operator-() const {
		Cm copy(*this);
		
		copy.mCm = -copy.mCm;
		
		return copy;
	};
	
	Cm operator+(const Cm& b) const { return Cm(this->mCm + b.mCm, dpi()); };
	Cm operator-(const Cm& b) const { return Cm(this->mCm - b.mCm, dpi()); };
	
	Cm operator*(const Cm& b) const { return Cm(this->mCm * b.mCm, dpi()); };
	Cm operator*(double b) const { return Cm(this->mCm * b, dpi()); };
	
	Cm operator/(const Cm& b) const { return Cm(this->mCm / b.mCm, dpi()); };
	Cm operator/(double b) const { return Cm(this->mCm / b, dpi()); };
	
	Cm& operator+=(const Cm& b) {
		this->mCm = this->mCm + b.mCm;
		
		return *this;
	};
	Cm& operator-=(const Cm& b) {
		this->mCm = this->mCm - b.mCm;
		
		return *this;
	};
	
	bool operator==(const Cm& b) const { return (this->mCm == b.mCm); };
	bool operator<(const Cm& b) const { return (this->mCm < b.mCm); };
	bool operator>(const Cm& b) const { return (this->mCm > b.mCm); };
	bool operator<=(const Cm& b) const { return (this->mCm <= b.mCm); };
	bool operator>=(const Cm& b) const { return (this->mCm >= b.mCm); };
private:
	double mCm;
};

/*class Cm : public Unit {
public:
	Cm(double cm, uint dpi) : Unit(dpi), mCm(cm) {};
	virtual ~Cm() {};
	
	virtual Inches toInches() const { return Inches(mCm / inchesForACm(), dpi()); };
	virtual Pixel toPixel() const { return Pixel(static_cast<uint>(static_cast<double>(dpi()) * (mCm / inchesForACm())), dpi()); };
	
	virtual double value() const { return mCm; };
	virtual uint valueOfPixel() const { return toPixel().value(); };
	
	virtual Cm operator-() const {
		Cm copy(*this);
		
		copy.mCm = -copy.mCm;
		
		return copy;
	};
	
	virtual Cm operator+(const Cm& b) const { return Cm(this->mCm + b.mCm, dpi()); };
	virtual Cm operator-(const Cm& b) const { return Cm(this->mCm - b.mCm, dpi()); };
	
	virtual Cm operator*(const Cm& b) const { return Cm(this->mCm * b.mCm, dpi()); };
	virtual Cm operator*(double b) const { return Cm(this->mCm * b, dpi()); };
	
	virtual Cm operator/(const Cm& b) const { return Cm(this->mCm / b.mCm, dpi()); };
	virtual Cm operator/(double b) const { return Cm(this->mCm / b, dpi()); };
	
	virtual Cm& operator+=(const Cm& b) {
		this->mCm = this->mCm + b.mCm;
		
		return *this;
	};
	virtual Cm& operator-=(const Cm& b) {
		this->mCm = this->mCm - b.mCm;
		
		return *this;
	};
	
	virtual bool operator==(const Cm& b) const { return (this->mCm == b.mCm); };
	virtual bool operator<(const Cm& b) const { return (this->mCm < b.mCm); };
	virtual bool operator>(const Cm& b) const { return (this->mCm > b.mCm); };
	virtual bool operator<=(const Cm& b) const { return (this->mCm <= b.mCm); };
	virtual bool operator>=(const Cm& b) const { return (this->mCm >= b.mCm); };
private:
	double mCm;
};*/

#endif
