/* Copyright (C) 2014 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/refptr.h>
#include <glibmm/bytes.h>
#include <giomm/file.h>
#include <gtkmm/csslocation.h>

_DEFS(gtkmm,gtk)

#ifndef DOXYGEN_SHOULD_SKIP_THIS
typedef struct _GtkCssSection GtkCssSection;
#endif

namespace Gtk
{

/** Defines a part of a CSS document.
 * Because sections are nested into one another, you can use get_parent()
 * to get the containing region.
 *
 * A %CssSection is input data to a Gtk::CssProvider::signal_parsing_error() handler.
 *
 * @newin{3,16}
 */
class GTKMM_API CssSection final
{
  _CLASS_OPAQUE_REFCOUNTED(CssSection, GtkCssSection, NONE, gtk_css_section_ref, gtk_css_section_unref, GTKMM_API)
  _IGNORE(gtk_css_section_ref, gtk_css_section_unref)

public:
  _WRAP_METHOD(static Glib::RefPtr<CssSection> create(const Glib::RefPtr<Gio::File>& file,
    const CssLocation& start, const CssLocation& end), gtk_css_section_new)
  _WRAP_METHOD(static Glib::RefPtr<CssSection> create(const Glib::RefPtr<Gio::File>& file,
    const Glib::RefPtr<const Glib::Bytes>& bytes,
    const CssLocation& start, const CssLocation& end), gtk_css_section_new_with_bytes)

  /** Prints the section into a human-readable text form.
   *
   * This is a form like `gtk.css:32:1-23` to denote line 32,
   * characters 1 to 23 in the file gtk.css.
   *
   * @return A new string.
   */
  _WRAP_METHOD(Glib::ustring to_string() const, gtk_css_section_to_string)
  _IGNORE(gtk_css_section_print)
  _WRAP_METHOD(Glib::RefPtr<CssSection> get_parent(), gtk_css_section_get_parent, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const CssSection> get_parent() const, gtk_css_section_get_parent, refreturn, constversion)
  _WRAP_METHOD(Glib::RefPtr<Gio::File> get_file(), gtk_css_section_get_file, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const Gio::File> get_file() const, gtk_css_section_get_file, refreturn, constversion)
  // Glib::Bytes is immutable. No need for a non-const get-method.
  _WRAP_METHOD(Glib::RefPtr<Glib::Bytes> get_bytes() const, gtk_css_section_get_bytes, refreturn)
  _WRAP_METHOD(CssLocation get_start_location() const, gtk_css_section_get_start_location)
  _WRAP_METHOD(CssLocation get_end_location() const, gtk_css_section_get_end_location)
};

} // namespace Gtk
