/* Copyright (C) 1998-2006 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <goocanvaspolyline.h>
#include <goocanvasmm/points.h>

_DEFS(goocanvasmm,libgoocanvas)
_PINCLUDE(glibmm/private/object_p.h)

namespace Goocanvas
{

Points::Points(int num_points)
  :
   gobject_(goo_canvas_points_new(num_points)) 
{
}

Points::Points(int num_points, const double* coords)
  :
   gobject_(goo_canvas_points_new(num_points)) 
{
  if( coords != NULL )
  {
    //I assume memcpy isn't portable enough.
    for( int i = 0 ; i < num_points*2 ; i++ )
    {
      gobj()->coords[i] = coords[i] ;
    }
  }
}

int
Points::get_num_points() const
{
  return gobj()->num_points ;
}

void
Points::Points::set_coordinate( int index, double x, double y )
{
  gobj()->coords[2*index] = x ;
  gobj()->coords[2*index+1] = y ;
}

void
Points::get_coordinate( int index, double& x, double& y ) const
{
  x = gobj()->coords[2*index] ;
  y = gobj()->coords[2*index+1] ;
}

}
