/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* * This file is part of the libpagemaker project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef LIBPAGEMAKER_UNITS_H #define LIBPAGEMAKER_UNITS_H #include // TODO: remove this pointless abstraction. namespace libpagemaker { const unsigned SHAPE_UNITS_PER_INCH = 1440; template class LengthUnit { typedef LengthUnit T; public: int m_value; LengthUnit(int value) : m_value(value) { } double toInches() const { return m_value / ((double)PER_INCH); } }; template const LengthUnit operator+(LengthUnit left, LengthUnit right) { return LengthUnit(left.m_value + right.m_value); } template const LengthUnit operator*(LengthUnit left, int right) { return LengthUnit(left.m_value * right); } template const LengthUnit operator*(int left, LengthUnit right) { return right * left; } template const LengthUnit operator-(LengthUnit left, LengthUnit right) { return LengthUnit(left.m_value - right.m_value); } typedef LengthUnit PMDShapeUnit; } #endif /* LIBPAGEMAKER_UNITS_H */ /* vim:set shiftwidth=2 softtabstop=2 expandtab: */