/* fontdescription.h
 *
 * Copyright (C) 1998-2002 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 <https://www.gnu.org/licenses/>.
 */

_CONFIGINCLUDE(pangommconfig.h)

#include <glibmm/value.h>
#include <pango/pango.h>

_DEFS(pangomm,pango)

namespace Pango
{

_WRAP_ENUM(Style, PangoStyle, decl_prefix PANGOMM_API)
_WRAP_ENUM(Variant, PangoVariant, decl_prefix PANGOMM_API)
_WRAP_ENUM(Stretch, PangoStretch, decl_prefix PANGOMM_API)
_WRAP_ENUM(Weight, PangoWeight, decl_prefix PANGOMM_API)
_WRAP_ENUM(FontMask, PangoFontMask, decl_prefix PANGOMM_API)
_WRAP_ENUM(Gravity, PangoGravity, decl_prefix PANGOMM_API)

/** A Pango::FontDescription represents the description of an ideal font.
 * It is used both to list what fonts are available on the system and also for specifying the characteristics of a font to load.
 */
class PANGOMM_API FontDescription
{
  _CLASS_BOXEDTYPE(FontDescription, PangoFontDescription, pango_font_description_new, pango_font_description_copy, pango_font_description_free, PANGOMM_API)
  _IGNORE(pango_font_description_free, pango_font_description_copy, pango_font_description_copy_static, pango_font_description_equal)

  /* These functions are dangerous! The first casts the "const" from the parameter away
   * copying the pointer and keep it hanging around.
   * So desc.set_family_static("some_family") would lead to a segfault.
   * The latter makes a shallow copy of the parameter's "family" data member.
   * So if the FontDescription you passed in dies, a pointer to its (deleted)
   * family data member still hangs around!
   * This is why we can't wrap these functions!
   */
  _IGNORE(pango_font_description_set_family_static, pango_font_description_merge_static)

public:
  /** Constructs a font description from a string representation.
   * @a font_name must have the form
   * "[FAMILY-LIST] [STYLE-OPTIONS] [SIZE]", where FAMILY-LIST is a comma separated
   * list of families optionally terminated by a comma, STYLE_OPTIONS is a whitespace
   * separated list of words where each WORD describes one of style, variant, weight,
   * or stretch, and SIZE is an decimal number (size in points). Any one of the
   * options may be absent. If FAMILY-LIST is absent, then the family_name field
   * of the resulting font description will be initialized to 0. If STYLE-OPTIONS
   * is missing, then all style options will be set to the default values. If SIZE
   * is missing, the size in the resulting font description will be set to 0.
   * @param font_name String representation of a font description.
   */
  explicit FontDescription(const Glib::ustring& font_name);

  _WRAP_METHOD(guint hash() const, pango_font_description_hash)
  _WRAP_METHOD(void set_family(const Glib::ustring& family), pango_font_description_set_family)
  _WRAP_METHOD(Glib::ustring get_family() const, pango_font_description_get_family)
  _WRAP_METHOD(void set_style(Style style), pango_font_description_set_style)
  _WRAP_METHOD(Style get_style() const, pango_font_description_get_style)
  _WRAP_METHOD(void set_variant(Variant variant),pango_font_description_set_variant)
  _WRAP_METHOD(Variant get_variant() const, pango_font_description_get_variant)
  _WRAP_METHOD(void set_weight(Weight weight), pango_font_description_set_weight)
  _WRAP_METHOD(Weight get_weight() const, pango_font_description_get_weight)
  _WRAP_METHOD(void set_stretch(Stretch stretch), pango_font_description_set_stretch)
  _WRAP_METHOD(Stretch get_stretch() const, pango_font_description_get_stretch)
  _WRAP_METHOD(void set_size(int size), pango_font_description_set_size)
  _WRAP_METHOD(int get_size() const, pango_font_description_get_size)
  _WRAP_METHOD(void set_absolute_size(double size), pango_font_description_set_absolute_size)
  _WRAP_METHOD(bool get_size_is_absolute() const, pango_font_description_get_size_is_absolute)
  _WRAP_METHOD(void set_gravity(Gravity gravity), pango_font_description_set_gravity)
  _WRAP_METHOD(Gravity get_gravity() const, pango_font_description_get_gravity)
  _IGNORE(pango_font_description_set_variations_static)
  _WRAP_METHOD(void set_variations(const Glib::ustring& settings), pango_font_description_set_variations)
  _WRAP_METHOD(Glib::ustring get_variations() const, pango_font_description_get_variations)
  _WRAP_METHOD(FontMask get_set_fields() const, pango_font_description_get_set_fields)
  _WRAP_METHOD(void unset_fields(FontMask to_unset), pango_font_description_unset_fields)
  _WRAP_METHOD(void merge(const FontDescription& desc_to_merge, bool replace_existing), pango_font_description_merge)
  _WRAP_METHOD(bool better_match(const FontDescription& old_match, const FontDescription& new_match) const, pango_font_description_better_match)
  _WRAP_METHOD(Glib::ustring to_string() const, pango_font_description_to_string)
  _WRAP_METHOD(Glib::ustring to_filename() const, pango_font_description_to_filename)

#m4begin
  _WRAP_EQUAL(pango_font_description_equal, , PANGOMM_API)
#m4end
};

} //namespace Pango
