/* Copyright (C) 2020 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/listbase.h>
#include <gtkmm/selectionmodel.h>
#include <gtkmm/listitemfactory.h>

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

namespace Gtk
{

/** A widget for displaying grids.
 *
 * %Gtk::GridView is a widget to present a view into a large dynamic grid of items.
 *
 * %Gtk::GridView uses its factory to generate one child widget for each visible item
 * and shows them in a grid. The orientation of the grid view determines if the
 * grid reflows vertically or horizontally.
 *
 * %Gtk::GridView allows the user to select items according to the selection
 * characteristics of the model. For models that allow multiple selected items,
 * it is possible to turn on _rubberband selection_, using set_enable_rubberband().
 *
 * @see Gtk::SelectionModel, Gtk::ListView, Gtk::ColumnView
 *
 * @ingroup Widgets
 *
 * @newin{3,98}
 */
class GTKMM_API GridView : public ListBase
{
  _CLASS_GTKOBJECT(GridView, GtkGridView, GTK_GRID_VIEW, ListBase, GtkListBase, , , GTKMM_API)

public:
  _WRAP_CTOR(GridView(const Glib::RefPtr<SelectionModel>& model = {}, const Glib::RefPtr<ListItemFactory>& factory = {}), gtk_grid_view_new)

  _WRAP_METHOD(Glib::RefPtr<SelectionModel> get_model(), gtk_grid_view_get_model, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const SelectionModel> get_model() const, gtk_grid_view_get_model, refreturn, constversion)
  _WRAP_METHOD(void set_model(const Glib::RefPtr<SelectionModel>& model), gtk_grid_view_set_model)
  _WRAP_METHOD(void set_factory(const Glib::RefPtr<ListItemFactory>& factory), gtk_grid_view_set_factory)
  _WRAP_METHOD(Glib::RefPtr<ListItemFactory> get_factory(), gtk_grid_view_get_factory, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const ListItemFactory> get_factory() const, gtk_grid_view_get_factory, refreturn, constversion)
  _WRAP_METHOD(guint get_min_columns() const, gtk_grid_view_get_min_columns)
  _WRAP_METHOD(void set_min_columns(guint min_columns), gtk_grid_view_set_min_columns)
  _WRAP_METHOD(guint get_max_columns() const, gtk_grid_view_get_max_columns)
  _WRAP_METHOD(void set_max_columns(guint max_columns), gtk_grid_view_set_max_columns)
  _WRAP_METHOD(void set_enable_rubberband(bool enable_rubberband = true), gtk_grid_view_set_enable_rubberband)
  _WRAP_METHOD(bool get_enable_rubberband() const, gtk_grid_view_get_enable_rubberband)
  _WRAP_METHOD(void set_single_click_activate(bool single_click_activate = true), gtk_grid_view_set_single_click_activate)
  _WRAP_METHOD(bool get_single_click_activate() const, gtk_grid_view_get_single_click_activate)

  _WRAP_PROPERTY("factory", Glib::RefPtr<ListItemFactory>)
  _WRAP_PROPERTY("max-columns", guint)
  _WRAP_PROPERTY("min-columns", guint)
  _WRAP_PROPERTY("model", Glib::RefPtr<SelectionModel>)
  _WRAP_PROPERTY("single-click-activate", bool)
  _WRAP_PROPERTY("enable-rubberband", bool)

  // no_default_handler because GtkGridViewClass is private.
  _WRAP_SIGNAL(void activate(guint position), "activate", no_default_handler)
};

} // namespace Gtk
