/***************************************************************************
 *   Copyright (C) 2004 by Hans Oischinger                                 *
 *   hans.oischinger@kdemail.net                                           *
 *                                                                         *
 *   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.,                                       *
 *   51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.             *
 ***************************************************************************/
#ifndef LENGTHATTRIBUTE_H
#define LENGTHATTRIBUTE_H

#include "attribute.h"

class QString;
/**
Any coordinate or length values should be represented by this class
 
@author Hans Oischinger
*/
class LengthAttribute : public Attribute
{
public:
  enum LengthType
  {
    SVG_LENGTHTYPE_UNKNOWN = 0,
    //     SVG_LENGTHTYPE_NUMBER,
    SVG_LENGTHTYPE_PERCENTAGE = 2,
    //     SVG_LENGTHTYPE_EMS,
    //     SVG_LENGTHTYPE_EXS,
    SVG_LENGTHTYPE_PX = 5,
    SVG_LENGTHTYPE_CM = 6,
    SVG_LENGTHTYPE_MM = 7,
    SVG_LENGTHTYPE_IN = 8,
    SVG_LENGTHTYPE_PT = 9,
    SVG_LENGTHTYPE_PC = 10
  };

  static QString LengthUnitText[];

  LengthAttribute();
  LengthAttribute( float value, unsigned int type = SVG_LENGTHTYPE_PX );
  LengthAttribute( const LengthAttribute & );
  ~LengthAttribute();

  LengthAttribute &operator=(const LengthAttribute &);
  bool operator==(const LengthAttribute &);
  bool operator!=(const LengthAttribute &);
  virtual Attribute* clone();

  virtual void accept( AVisitor& );

  unsigned int unitType() const { return m_unitType; }

  void setValue(float value);
  float value() const { return m_value; }

  void setValueInSpecifiedUnits(float valueInSpecifiedUnits);
  float valueInSpecifiedUnits() const { return m_valueInSpecifiedUnits; }

  void newValueSpecifiedUnits(unsigned int unitType, float valueInSpecifiedUnits);
  //   void convertToSpecifiedUnits(LengthType unitType);
  const QString readableSpecifiedUnits() const;

private:
  unsigned int m_unitType;
  float m_valueInSpecifiedUnits;
  float m_value;
};

#endif
