Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# Inti::Pango::AttrList Class Reference

A PangoAttrList C++ wrapper class. More...

`#include <inti/pango/attributes.h>`

Inheritance diagram for Inti::Pango::AttrList:

List of all members.

## Public Types

- typedef Slot1< bool, const
  Attribute & > AttrFilterSlot
    Signature of the callback slot used by filter() to filter out a subset of attributes for a list.

## Public Member Functions

Constructors

- AttrList ()
    Construct a new empty attribute list.
- AttrList (PangoAttrList *list)
    Construct a new attribute list from an existing PangoAttrList.
- AttrList (PangoAttrList *list, bool copy)
    Construct a new attribute list from an existing PangoAttrList.
- AttrList (const AttrList &src)
    Copy constructor.
- ~AttrList ()
    Destructor.
- AttrList & operator= (const AttrList &src)
    Assignment operator.

Accessors

- PangoAttrList * pango_attr_list () const
    Get a pointer to the PangoAttrList structure.
- operator PangoAttrList * () const
    Conversion operator; safely converts an AttrList to a PangoAttrList pointer.
- Pointer< AttrIterator > get_iterator () const
    Creates an iterator initialized to the beginning of the list.

Methods

- void insert (Attribute &attr, bool before=false)
    Insert the given attribute into the list.
- void change (Attribute &attr)
    Insert the given attribute into the list.
- void splice (AttrList &other, int pos, int length)
    This method splices the other attribute list into this list.
- Pointer< AttrList > filter (const AttrFilterSlot *slot)
    Given an AttrList and callback slot, this method removes any elements of list for which slot returns true and inserts them into a new list.

## Detailed Description

A PangoAttrList C++ wrapper class.

AttrList represents a list of attributes that apply to a section of text. The attributes are, in general, allowed to overlap in an arbitrary fashion, however, if the attributes are manipulated only through change(), the overlap between properties will meet stricter criteria.

Since the wrapped PangoAttrList structure is stored as a linear list, it is not suitable for storing attributes for large amounts of text. In general, you should not use a single AttrList for more than one paragraph of text.

## Member Typedef Documentation

typedef Slot1<bool, const Attribute&> Inti::Pango::AttrList::AttrFilterSlot

Signature of the callback slot used by filter() to filter out a subset of attributes for a list.

Example: Method signature for AttrFilterSlot.

                 bool method(const Attibute& attr);

                 // attr: A Pango::Attribute.
                 // return: true if the attribute should be filtered out.

## Constructor & Destructor Documentation

Inti::Pango::AttrList::AttrList | ( | PangoAttrList * | list | ) | `[explicit]`

Construct a new attribute list from an existing PangoAttrList.

Parameters:

  list | A pointer to a PangoAttrList.

The list can be a newly created PangoAttrList or an existing PangoAttrList. The AttrList object created is a temporary object. It doesn't take over the ownership of PangoAttrList and PangoAttrList is not freed by the destructor.

Inti::Pango::AttrList::AttrList | ( | PangoAttrList * | list,
|  | bool | copy
| ) |

Construct a new attribute list from an existing PangoAttrList.

Parameters:

  list | A pointer to a PangoAttrList.
  copy | Whether the AttrList object should make a copy of PangoAttrList or not.

The list can be a newly created PangoAttrList or an existing PangoAttrList. If copy is true AttrList will make a copy of PangoAttrList. If copy is false AttrList wont make a copy but instead takes over the ownership of PangoAttrList. Either way, the destructor will free PangoAttrList when the AttrList object is destroyed. This constructor is used by G::Boxed::wrap() to wrap PangoAttrList objects in a C++ wrapper.

Inti::Pango::AttrList::AttrList | ( | const AttrList & | src | ) |

Copy constructor.

Parameters:

  src | The source attribute list.

## Member Function Documentation

void Inti::Pango::AttrList::change | ( | Attribute & | attr | ) |

Insert the given attribute into the list.

Parameters:

  attr | The attribute to insert. Ownership of this value is assumed by the list.

It will replace any attributes of the same type on that segment and be merged with any adjoining attributes that are identical. This function is slower than insert() for creating an attribute list in order (potentially much slower for large lists). However, insert() is not suitable for continually changing a set of attributes since it never removes or combines existing attributes.

Pointer<AttrList> Inti::Pango::AttrList::filter | ( | const AttrFilterSlot * | slot | ) |

Given an AttrList and callback slot, this method removes any elements of list for which slot returns true and inserts them into a new list.

Parameters:

  slot | A callback slot; returns true if an atttribute should be filtered out.

Returns:
  A smart pointer to a newly allocated AttrList, or null if no attributes of the given types were found.

Pointer<AttrIterator> Inti::Pango::AttrList::get_iterator | ( |  | ) | const

Creates an iterator initialized to the beginning of the list.

Returns:
  A smart pointer to a new attribute iterator.

The list must not be modified until the smart pointer has gone out of scope (i.e. the iterator has been destroyed).

void Inti::Pango::AttrList::insert | ( | Attribute & | attr,
|  | bool | before = false
| ) |

Insert the given attribute into the list.

Parameters:

  attr | The attribute to insert. Ownership of this value is assumed by the list.
  before | Set true if attr should be inserted before other attributes.

If before is false attr will be inserted after all other attributes with a matching start_index. If before is true attr will be inserted before all other attributes with a matching start_index.

AttrList& Inti::Pango::AttrList::operator= | ( | const AttrList & | src | ) |

Assignment operator.

Parameters:

  src | The source attribute list.

void Inti::Pango::AttrList::splice | ( | AttrList & | other,
|  | int | pos,
|  | int | length
| ) |

This method splices the other attribute list into this list.

Parameters:

  other | Another attribute list.
  pos | The position in list at which to insert other.
  length | The length of the spliced segment.

This operation is equivalent to stretching every attribute that applies at position pos in list by an amount len, and then calling change() with a copy of each attribute in other in sequence (offset in position by pos).

This operation proves useful for, for instance, inserting a preedit string in the middle of an edit buffer.

Note: length must be specified since the attributes in other may only be present at some subsection of this range.

The documentation for this class was generated from the following file:

- attributes.h

Main Page - Footer