[pangomm/pangomm-2-46] Attribute: Add Overline and ShowFlags enums and some create*() methods



commit 9975ea85b4020ff6630aece3a907f9f8764814a5
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Fri Jan 15 17:33:24 2021 +0100

    Attribute: Add Overline and ShowFlags enums and some create*() methods
    
    See #9

 configure.ac              |  2 +-
 meson.build               |  2 +-
 pango/src/attributes.ccg  | 32 ++++++++++++++++--
 pango/src/attributes.hg   | 85 ++++++++++++++++++++++++++++++++++++++++++-----
 tools/m4/convert_pango.m4 |  2 ++
 5 files changed, 111 insertions(+), 12 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9126ec1..df1f28d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,7 +49,7 @@ MM_AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory])
 AC_DISABLE_STATIC
 LT_INIT([win32-dll])
 
-AC_SUBST([PANGOMM_MODULES], ['glibmm-2.4 >= 2.48.0 cairomm-1.0 >= 1.2.2 pangocairo >= 1.41.0'])
+AC_SUBST([PANGOMM_MODULES], ['glibmm-2.4 >= 2.48.0 cairomm-1.0 >= 1.2.2 pangocairo >= 1.45.1'])
 AC_SUBST([MSVC_TOOLSET_VER], [''])
 PKG_CHECK_MODULES([PANGOMM], [$PANGOMM_MODULES])
 
diff --git a/meson.build b/meson.build
index ae01eb7..38ecddd 100644
--- a/meson.build
+++ b/meson.build
@@ -100,7 +100,7 @@ glibmm_req = '>= 2.48.0'
 
 # Pango supported pkg-config files on MSVC files for a good while,
 # so just use that
-pangocairo_req = '>= 1.41.0'
+pangocairo_req = '>= 1.45.1'
 pangocairo_dep = dependency('pangocairo', version: pangocairo_req)
 
 glibmm_req_minor_ver = '4'
diff --git a/pango/src/attributes.ccg b/pango/src/attributes.ccg
index 9759bce..2e1bcfe 100644
--- a/pango/src/attributes.ccg
+++ b/pango/src/attributes.ccg
@@ -1,5 +1,4 @@
 /*
- *
  * Copyright 2002 Free Software Foundation
  *
  * This library is free software; you can redistribute it and/or
@@ -74,6 +73,11 @@ AttrType Attribute::register_type(const Glib::ustring& name)
   return (AttrType)pango_attr_type_register(name.c_str());
 }
 
+Glib::ustring Attribute::get_type_name(AttrType type)
+{
+  return Glib::convert_const_gchar_ptr_to_ustring(pango_attr_type_get_name((PangoAttrType)type));
+}
+
 AttrString Attribute::create_attr_family(const Glib::ustring& family)
 {
   return Glib::wrap((PangoAttrString*)pango_attr_family_new(family.c_str()));
@@ -149,6 +153,16 @@ AttrColor Attribute::create_attr_underline_color(guint16 red, guint16 green, gui
   return Glib::wrap((PangoAttrColor*)pango_attr_underline_color_new(red, green, blue));
 }
 
+AttrInt Attribute::create_attr_overline(Overline overline)
+{
+  return Glib::wrap((PangoAttrInt*)pango_attr_overline_new((PangoOverline)overline));
+}
+
+AttrColor Attribute::create_attr_overline_color(guint16 red, guint16 green, guint16 blue)
+{
+  return Glib::wrap((PangoAttrColor*)pango_attr_overline_color_new(red, green, blue));
+}
+
 AttrInt Attribute::create_attr_strikethrough(bool strikethrough)
 {
   return Glib::wrap((PangoAttrInt*)pango_attr_strikethrough_new(strikethrough));
@@ -199,6 +213,21 @@ AttrString Attribute::create_attr_font_features(const Glib::ustring& features)
   return Glib::wrap((PangoAttrString*)pango_attr_font_features_new(features.c_str()));
 }
 
+AttrInt Attribute::create_attr_allow_breaks(bool allow_breaks)
+{
+  return Glib::wrap((PangoAttrInt*)pango_attr_allow_breaks_new(allow_breaks));
+}
+
+AttrInt Attribute::create_attr_insert_hyphens(bool insert_hyphens)
+{
+  return Glib::wrap((PangoAttrInt*)pango_attr_insert_hyphens_new(insert_hyphens));
+}
+
+AttrInt Attribute::create_attr_show(ShowFlags show)
+{
+  return Glib::wrap((PangoAttrInt*)pango_attr_show_new((PangoShowFlags)show));
+}
+
 
 AttrString::AttrString()
 {}
@@ -398,4 +427,3 @@ Pango::AttrShape wrap(PangoAttrShape* object, bool take_copy)
 }
 
 } //namespace Glib
-
diff --git a/pango/src/attributes.hg b/pango/src/attributes.hg
index fa8c0c7..e234497 100644
--- a/pango/src/attributes.hg
+++ b/pango/src/attributes.hg
@@ -34,21 +34,19 @@ _CC_INCLUDE(pango/pango-enum-types.h)
 /** Pango::AttrType distinguishes between different types of attributes.
  * Along with the predefined values, it is possible to allocate additional values for
  * custom attributes using Pango::Attribute::register_type(). The predefined values
- * are given below.
+ * are given below. The type of structure used to store the
+ * attribute is listed in parentheses after the description.
  */
 _WRAP_ENUM(AttrType, PangoAttrType, decl_prefix PANGOMM_API)
 
-
-/** A Pango::Underline is used to specify whether text should be underlined, and if so, the type of 
underlining.
- */
 _WRAP_ENUM(Underline, PangoUnderline, decl_prefix PANGOMM_API)
-
+_WRAP_ENUM(Overline, PangoOverline, decl_prefix PANGOMM_API)
+_WRAP_ENUM(ShowFlags, PangoShowFlags, decl_prefix PANGOMM_API)
 
 /** A Pango::LogAttr stores information about the attributes of a single character.
  */
 typedef PangoLogAttr LogAttr;
 
-
 class PANGOMM_API AttrString;
 class PANGOMM_API AttrLanguage;
 class PANGOMM_API AttrColor;
@@ -86,11 +84,27 @@ public:
   AttrType get_type() const;
 
   /** Allocate a new attribute type ID.
-   * @param name An identifier for the type (currently unused).
+   *
+   * The attribute type name can be accessed later by using get_type_name().
+   *
+   * @param name An identifier for the type.
    * @return The new type ID.
    */
   static AttrType register_type(const Glib::ustring& name);
 
+  /** Fetches the attribute type name passed in when registering the type using
+   * register_type().
+   *
+   * @newin{2,46}
+   *
+   * @param type An attribute type ID to fetch the name for.
+   * @return The type ID name (which may be an empty string), or an empty string
+   *         if @a type is a built-in Pango attribute type or invalid.
+   */
+  static Glib::ustring get_type_name(AttrType type);
+  // _WRAP_METHOD() can't be used here, because glibmm/tools/defs_gen/h2def.py
+  // assumes that pango_attr_type_get_name() is a method of a class named PangoAttrType.
+
   /** Gets the start index of the range.
    * @return The start index of the range.
    */
@@ -221,6 +235,29 @@ public:
    */
   static AttrColor create_attr_underline_color(guint16 red, guint16 green, guint16 blue);
 
+  /** Create a new overline-style object.
+   *
+   * @newin{2,46}
+   *
+   * @param overline The overline style.
+   * @return An attribute of type AttrInt.
+   */
+  static AttrInt create_attr_overline(Overline overline);
+
+  /** Create a new overline color attribute.
+   *
+   * This attribute modifies the color of overlines. If not set,
+   * overlines will use the foreground color.
+   *
+   * @newin{2,46}
+   *
+   * @param red The red value (ranging from 0 to 65535).
+   * @param green The green value (ranging from 0 to 65535).
+   * @param blue The blue value (ranging from 0 to 65535).
+   * @return An attribute of type AttrColor.
+   */
+  static AttrColor create_attr_overline_color(guint16 red, guint16 green, guint16 blue);
+
   /** Create a new font strike-through attribute.
    * @param strikethrough True indicates the text should be struck-through.
    * @return An attribute of type AttrInt.
@@ -312,6 +349,39 @@ public:
    */
   static AttrString create_attr_font_features(const Glib::ustring& features);
 
+  /** Create a new allow-breaks attribute.
+   *
+   * If breaks are disabled, the range will be kept in a
+   * single run, as far as possible.
+   *
+   * @newin{2,46}
+   *
+   * @param allow_breaks <tt>true</tt> if line breaks are allowed.
+   * @return An attribute of type AttrInt.
+   */
+  static AttrInt create_attr_allow_breaks(bool allow_breaks);
+
+  /** Create a new insert-hyphens attribute.
+   *
+   * Pangomm will insert hyphens when breaking lines in the middle
+   * of a word. This attribute can be used to suppress the hyphen.
+   *
+   * @newin{2,46}
+   *
+   * @param insert_hyphens <tt>true</tt> if hyphens should be inserted.
+   * @return An attribute of type AttrInt.
+   */
+  static AttrInt create_attr_insert_hyphens(bool insert_hyphens);
+
+  /** Create a new attribute that influences how invisible characters are rendered.
+   *
+   * @newin{2,46}
+   *
+   * @param flags Pango::ShowFlags to apply.
+   * @return An attribute of type AttrInt.
+   */
+  static AttrInt create_attr_show(ShowFlags show);
+
 protected:
   PangoAttribute* gobject_;
 };
@@ -609,4 +679,3 @@ PANGOMM_API
 Pango::AttrShape wrap(PangoAttrShape* object, bool take_copy = false);
 
 } //namespace Glib
-
diff --git a/tools/m4/convert_pango.m4 b/tools/m4/convert_pango.m4
index a1b72d1..2219d03 100644
--- a/tools/m4/convert_pango.m4
+++ b/tools/m4/convert_pango.m4
@@ -2,6 +2,8 @@
 # Enums:
 _CONV_ENUM(Pango,AttrType)
 _CONV_ENUM(Pango,Underline)
+_CONV_ENUM(Pango,Overline)
+_CONV_ENUM(Pango,ShowFlags)
 _CONV_ENUM(Pango,Direction)
 _CONV_ENUM(Pango,CoverageLevel)
 _CONV_ENUM(Pango,Style)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]