/* 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/filter.h>
#include <gtkmm/expression.h>

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

namespace Gtk
{

/** Filtering by strings.
 *
 * %Gtk::StringFilter determines whether to include items by looking
 * at strings and comparing them to a fixed search term. The strings
 * are obtained from the items by evaluating a Gtk::Expression.
 *
 * %Gtk::StringFilter has several different modes of comparison - it
 * can match the whole string, just a prefix, or any substring.
 *
 * @newin{3,98}
 */
class GTKMM_API StringFilter : public Filter
{
  _CLASS_GOBJECT(StringFilter, GtkStringFilter, GTK_STRING_FILTER, Gtk::Filter, GtkFilter, , , GTKMM_API)
  _STRUCT_NOT_HIDDEN

protected:
  _WRAP_CTOR(StringFilter(const Glib::RefPtr<Expression<Glib::ustring>>& expression), gtk_string_filter_new)

public:
  _WRAP_ENUM(MatchMode, GtkStringFilterMatchMode, decl_prefix GTKMM_API)

  _WRAP_CREATE(const Glib::RefPtr<Expression<Glib::ustring>>& expression)

  _WRAP_METHOD(Glib::ustring get_search() const, gtk_string_filter_get_search)
  _WRAP_METHOD(void set_search(const Glib::ustring& search), gtk_string_filter_set_search)
  _WRAP_METHOD(Glib::RefPtr<Expression<Glib::ustring>> get_expression(), gtk_string_filter_get_expression, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const Expression<Glib::ustring>> get_expression() const, gtk_string_filter_get_expression, refreturn)
  _WRAP_METHOD(void set_expression(const Glib::RefPtr<Expression<Glib::ustring>>& expression), gtk_string_filter_set_expression)
  _WRAP_METHOD(bool get_ignore_case() const, gtk_string_filter_get_ignore_case)
  _WRAP_METHOD(void set_ignore_case(bool ignore_case = true), gtk_string_filter_set_ignore_case)
  _WRAP_METHOD(MatchMode get_match_mode() const, gtk_string_filter_get_match_mode)
  _WRAP_METHOD(void set_match_mode(MatchMode mode), gtk_string_filter_set_match_mode)

  _WRAP_PROPERTY("expression", Glib::RefPtr<Expression<Glib::ustring>>)
  _WRAP_PROPERTY("ignore-case", bool)
  _WRAP_PROPERTY("match-mode", MatchMode)
  _WRAP_PROPERTY("search", Glib::ustring)
};

} // namespace Gtk
