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

_CONFIGINCLUDE(gtkmmconfig.h)

#include <giomm/listmodel.h>
#include <gtk/gtk.h>

_DEFS(gtkmm,gtk)
_PINCLUDE(glibmm/private/object_p.h)

namespace Gtk
{

/** A list model that presents a slice out of a larger list.
 *
 * %Gtk::SliceListModel is a list model that takes a list model and presents a
 * slice of that model.
 *
 * This is useful when implementing paging by setting the size to the number
 * of elements per page and updating the offset whenever a different page is
 * opened.
 *
 * @see Gio::ListModel
 * @newin{3,98}
 */
class GTKMM_API SliceListModel : public Glib::Object, public Gio::ListModel
{
  _CLASS_GOBJECT(SliceListModel, GtkSliceListModel, GTK_SLICE_LIST_MODEL, Glib::Object, GObject, , , GTKMM_API)
  _IMPLEMENTS_INTERFACE(Gio::ListModel)
  _STRUCT_NOT_HIDDEN

protected:
  _WRAP_CTOR(SliceListModel(const Glib::RefPtr<Gio::ListModel>& model, guint offset, guint size), gtk_slice_list_model_new)

public:
  _WRAP_CREATE(const Glib::RefPtr<Gio::ListModel>& model, guint offset, guint size)

  _WRAP_METHOD(void set_model(const Glib::RefPtr<Gio::ListModel>& model), gtk_slice_list_model_set_model)
  _WRAP_METHOD(Glib::RefPtr<Gio::ListModel> get_model(), gtk_slice_list_model_get_model, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const Gio::ListModel> get_model() const, gtk_slice_list_model_get_model, refreturn, constversion)
  _WRAP_METHOD(void set_offset(guint offset), gtk_slice_list_model_set_offset)
  _WRAP_METHOD(guint get_offset() const, gtk_slice_list_model_get_offset)
  _WRAP_METHOD(void set_size(guint size), gtk_slice_list_model_set_size)
  _WRAP_METHOD(guint get_size() const, gtk_slice_list_model_get_size)

  _WRAP_PROPERTY("model", Glib::RefPtr<Gio::ListModel>)
  _WRAP_PROPERTY("offset", guint)
  _WRAP_PROPERTY("size", guint)
};

} // namespace Gtk
