// This may look like C code, but it's really -*- C++ -*-
/*
 * Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
 *
 * See the LICENSE file for terms of use.
 */
#ifndef WPOlYGON_AREA_H_
#define WPOLYGON_AREA_H_

#include <Wt/WAbstractArea>
#include <Wt/WPoint>

namespace Wt {

class WPointF;

/*! \class WPolygonArea Wt/WPolygonArea Wt/WPolygonArea
 *  \brief An interactive area in a widget, specified by a polygon.
 *
 * The area may be added to a WImage or WPaintedWidget. The polygon is
 * specified in pixel coordinates, and uses an even-odd winding rule
 * (overlaps create holes).
 *
 * \sa WImage::addArea(), WPaintedWidget::addArea()
 * \sa WCircleArea, WRectArea
 */
class WT_API WPolygonArea : public WAbstractArea
{
public:
  /*! \brief Default constructor.
   *
   * Defines an empty polygon. 
   */
  WPolygonArea();

  /*! \brief Construct a polygon area with given vertices.
   *
   * The polygon is defined with vertices corresponding to
   * <i>points</i>. The polygon is closed by connecting the last point
   * with the first point.
   */
  WPolygonArea(const std::vector<WPoint>& points);

  /*! \brief Construct a polygon area with given vertices.
   *
   * The polygon is defined with vertices corresponding to
   * <i>points</i>. The polygon is closed by connecting the last point
   * with the first point.
   */
  WPolygonArea(const std::vector<WPointF>& points);

  /*! \brief Add a point.
   */
  void addPoint(int x, int y);

  /*! \brief Add a point.
   */
  void addPoint(const WPoint& point);

  /*! \brief Add a point.
   */
  void addPoint(const WPointF& point);

  /*! \brief Set the polygon vertices. 
   *
   * The polygon is defined with vertices corresponding to
   * <i>points</i>. The polygon is closed by connecting the last point
   * with the first point.
   */
  void setPoints(const std::vector<WPoint>& points);

  /*! \brief Set the polygon vertices. 
   *
   * The polygon is defined with vertices corresponding to
   * <i>points</i>. The polygon is closed by connecting the last point
   * with the first point.
   */
  void setPoints(const std::vector<WPointF>& points);

  /*! \brief Returns the polygon vertices.
   *
   * \sa setPoints()
   */
  const std::vector<WPoint>& points() const { return points_; }

private:
  std::vector<WPoint> points_;

protected:
  virtual void updateDom(DomElement& element, bool all);
};

}

#endif // WPOLYGON_AREA_H_
