/* 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 <glibmm/object.h>
#include <gtkmm/enums.h>

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

namespace Gtk
{

/** Sorting items.
 *
 * %Gtk::Sorter is the way to describe sorting criteria.
 * Its primary user is Gtk::SortListModel.
 *
 * The model will use a sorter to determine the order in which its items should appear
 * by calling compare() for pairs of items.
 *
 * Sorters may change their sorting behavior through their lifetime. In that case,
 * they will emit the signal_changed() signal to notify that the sort order is
 * no longer valid and should be updated by calling compare() again.
 *
 * GTK provides various pre-made sorter implementations for common sorting operations.
 * Gtk::ColumnView has built-in support for sorting lists via the
 * Gtk::ColumnViewColumn::property_sorter(), where the user can change the sorting by
 * clicking on list headers.
 *
 * Of course, in particular for large lists, it is also possible to subclass %Gtk::Sorter
 * and provide one's own sorter.
 *
 * @see Gtk::SortListModel
 * @ingroup ListView
 * @newin{3,98}
 */
class GTKMM_API Sorter : public Glib::Object
{
  _CLASS_GOBJECT(Sorter, GtkSorter, GTK_SORTER, Glib::Object, GObject, , , GTKMM_API)

protected:
  _CTOR_DEFAULT

public:
  _WRAP_ENUM(Order, GtkSorterOrder, decl_prefix GTKMM_API)
  _WRAP_ENUM(Change, GtkSorterChange, decl_prefix GTKMM_API)

  _WRAP_METHOD(Ordering compare(gpointer item1, gpointer item2), gtk_sorter_compare)
  _WRAP_METHOD(Order get_order() const, gtk_sorter_get_order)
  _WRAP_METHOD(void changed(Change change), gtk_sorter_changed)

  _WRAP_SIGNAL(void changed(Change change), "changed", no_default_handler)

protected:
  _WRAP_VFUNC(Ordering compare(gpointer item1, gpointer item2), compare)
  _WRAP_VFUNC(Order get_order(), get_order)
};

} // namespace Gtk
