/* Copyright (C) 2026 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 Gio::ListModel representing values of a given enum.
 *
 * %Gtk::EnumList contains objects of type Gtk::EnumListItem.
 *
 * A simple way to use a %Gtk::EnumList is to populate a Gtk::DropDown
 * widget using the short name (or "nick") of the values of an
 * enumeration type:
 *
 * @code
 * GType enum_type = Glib::Value<Gtk::Justification>::value_type(); // an example
 * Glib::RefPtr<Gtk::EnumList> enum_list = Gtk::EnumList::create(enum_type);
 * Glib::RefPtr<Gtk::PropertyExpression> expression =
 *   Gtk::PropertyExpression::create(Gtk::EnumListItem::get_type(), "nick");
 * Gtk::DropDown* drop_down = Gtk::make_managed<Gtk::DropDown>(enum_list, expression);
 * @endcode
 *
 * All variables in the code snippet can be declared <b>auto</b>. The full types
 * are shown to make it clear what they are.
 *
 * @see Gio::ListModel
 * @ingroup ListView
 * @newin{4,24}
 */
class GTKMM_API EnumList : public Glib::Object, public Gio::ListModel
{
  _CLASS_GOBJECT(EnumList, GtkEnumList, GTK_ENUM_LIST, Glib::Object, GObject, , , GTKMM_API)
  _IMPLEMENTS_INTERFACE(Gio::ListModel)
  _DO_NOT_DERIVE_GTYPE dnl// GtkEnumList is a final type
  _STRUCT_NOT_HIDDEN

protected:
  _WRAP_CTOR(EnumList(GType enum_type), gtk_enum_list_new)

public:
  _WRAP_METHOD_DOCS_ONLY(gtk_enum_list_new)
  _WRAP_CREATE(GType enum_type)

  _WRAP_METHOD(GType get_enum_type() const, gtk_enum_list_get_enum_type)

  /** Finds the position of a given enum value in this %EnumList.
   *
   * If the value is not found, GTK_INVALID_LIST_POSITION is returned.
   *
   * @newin{4,24}
   *
   * @param value An enum value. If the enum is an enum class, use
   *   static_cast<int>(value) to convert the value to an int.
   * @return The position of the value.
   */
  _WRAP_METHOD(unsigned int find(int value) const, gtk_enum_list_find)

  _WRAP_PROPERTY("enum-type", GType)
  _WRAP_PROPERTY("item-type", GType)
  _WRAP_PROPERTY("n-items", unsigned int)
};

} // namespace Gtk
