// This may look like C code, but it's really -*- C++ -*-
/*
 * Copyright (C) 2005 Koen Deforche, Kessel-Lo, Belgium.
 *
 * See the LICENSE file for terms of use.
 */
#ifndef WLENGTH_H_
#define WLENGTH_H_

#include <string>
#include "WDllDefs.h"

namespace Wt {

/*! \class WLength WLength WLength
 *  \brief Class specifying a length with a unit.
 */
class WT_API WLength
{
public:
  /*! \brief The unit
   */
  enum Unit {FontEm,     //!< The height of the font
	     FontEx,     //!< The widht of an 'x' in the font
	     Pixel,      //!< Pixel, relative to canvas resolution
	     Inch,       //!< Inche
	     Centimeter, //!< Centimeter
	     Millimeter, //!< Millimeter
	     Point,      //!< Point (1/72 Inch)
	     Pica,       //!< Pica (12 Point)
	     Percentage  //!< Percentage (meaning context-sensitive)
  };

  /*! \brief Automatic length
   *
   * Specifies an 'auto' length.
   */
  WLength();

  /*! \brief Length with value and unit.
   */
  WLength(double value, Unit unit = Pixel);

  /*! \brief Length is unspecified, hence automatic ?
   */
  bool isAuto() const { return auto_; }

  /*! \brief Get te value.
   */
  double value() const { return value_; }

  /*! \brief Get te unit.
   */
  Unit unit() const { return unit_; }

  const std::string cssText() const;

  bool operator== (const WLength& other) const;
  
private:
  bool auto_;
  Unit unit_;
  double value_;
};

}

#endif // WLENGTH
