/* 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 <goocanvastable.h>

_PINCLUDE(goocanvasmm/private/group_p.h)

namespace Goocanvas
{

void Table::attach(const Glib::RefPtr<Item>& item, guint left_attach, guint right_attach, guint top_attach, guint bottom_attach, Gtk::AttachOptions xoptions, Gtk::AttachOptions yoptions, double left_padding, double right_padding, double top_padding, double bottom_padding)
{
  const gboolean x_expand = (xoptions & Gtk::EXPAND) != 0;
  const gboolean x_fill = (xoptions & Gtk::FILL) != 0;
  const gboolean x_shrink = (xoptions & Gtk::SHRINK) != 0;
  const gboolean y_expand = (yoptions & Gtk::EXPAND) != 0;
  const gboolean y_fill = (yoptions & Gtk::FILL) != 0;
  const gboolean y_shrink = (yoptions & Gtk::SHRINK) != 0;

  add_child(item);
  goo_canvas_item_set_child_properties(GOO_CANVAS_ITEM(gobj()), item->gobj(),
                                       "column", left_attach,
                                       "columns", right_attach - left_attach,
                                       "row", top_attach,
                                       "rows", bottom_attach - top_attach,
                                       "x-fill", x_fill,
                                       "x-expand", x_expand,
                                       "x-shrink", x_shrink,
                                       "y-fill", y_fill,
                                       "y-expand", y_expand,
                                       "y-shrink", y_shrink,
                                       "left-padding", left_padding,
                                       "right-padding", right_padding,
                                       "top-padding", top_padding,
                                       "bottom-padding", bottom_padding,
                                       static_cast<void*>(0));
}

void Table::set_align(const Glib::RefPtr<Item>& child, double xalign, double yalign)
{
  goo_canvas_item_set_child_properties(GOO_CANVAS_ITEM(gobj()), child->gobj(),
                                       "xalign", xalign,
                                       "yalign", yalign,
                                       static_cast<void*>(0));
}

void Table::set_align(const Glib::RefPtr<Item>& child, Gtk::Align xalign, Gtk::Align yalign)
{
  set_align(child, _gtkmm_align_float_from_enum(xalign), _gtkmm_align_float_from_enum(yalign));
}

} //namspace Goocanvas

