/* Copyright (C) 2023 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, see <http://www.gnu.org/licenses/>.
 */

#include <gtkmm/listitem.h>

_DEFS(gtkmm,gtk)
_PINCLUDE(gtkmm/private/listitem_p.h)

namespace Gtk
{
/** %Gtk::ColumnViewCell is used by Gtk::ColumnViewColumn to represent items
 * in a cell in Gtk::ColumnView.
 *
 * The %Gtk::ColumnViewCells are managed by the columnview widget (with its factory)
 * and cannot be created by applications, but they need to be populated
 * by application code. This is done by calling set_child().
 *
 * %Gtk::ColumnViewCells exist in 2 stages:
 *
 * 1. The unbound stage where the listitem is not currently connected to
 *    an item in the list. In that case, property_item() is not set.
 *
 * 2. The bound stage where the listitem references an item from the list.
 *    property_item() is set.
 *
 * @ingroup ListView
 * @newin{4,12}
 */
class GTKMM_API ColumnViewCell : public ListItem
{
  _CLASS_GOBJECT(ColumnViewCell, GtkColumnViewCell, GTK_COLUMN_VIEW_CELL, Gtk::ListItem, GtkListItem, , , GTKMM_API)
  _DO_NOT_DERIVE_GTYPE dnl// GtkColumnViewCell is an internal type

public:
  // Don't use Glib::RefPtr<Glib::Object> Glib::wrap(GObject* object, bool take_copy).
  // The object may be an interface object, e.g. Gio::AppInfo. Such an object can't be
  // cast to Glib::Object. https://gitlab.gnome.org/GNOME/glibmm/-/issues/93
#m4 _CONVERSION(`gpointer',`Glib::RefPtr<Glib::ObjectBase>',`Glib::make_refptr_for_instance<Glib::ObjectBase>(Glib::wrap_auto(G_OBJECT($3)))')
  _WRAP_METHOD(Glib::RefPtr<Glib::ObjectBase> get_item(), gtk_column_view_cell_get_item, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const Glib::ObjectBase> get_item() const, gtk_column_view_cell_get_item, refreturn, constversion)
  _WRAP_METHOD(guint get_position() const, gtk_column_view_cell_get_position)
  _WRAP_METHOD(bool get_selected() const, gtk_column_view_cell_get_selected)
  _WRAP_METHOD(bool get_focusable() const, gtk_column_view_cell_get_focusable)
  _WRAP_METHOD(void set_focusable(bool focusable = true), gtk_column_view_cell_set_focusable)
  _WRAP_METHOD(void set_child(Widget& child), gtk_column_view_cell_set_child)
  void unset_child();
  _WRAP_METHOD(Widget* get_child(), gtk_column_view_cell_get_child)
  _WRAP_METHOD(const Widget* get_child() const, gtk_column_view_cell_get_child, constversion)

  _WRAP_PROPERTY("child", Widget*)
  _WRAP_PROPERTY("focusable",bool)
  _WRAP_PROPERTY("item", Glib::RefPtr<Glib::ObjectBase>)
  _WRAP_PROPERTY("position", guint)
  _WRAP_PROPERTY("selected", bool)
};

} // namespace Gtk
