3 * Copyright 1998-1999 The Gtk-- Development Team
4 * Copyright 2001 Free Software Foundation
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the Free
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 AttrIter::AttrIter(const AttrIter& src)
31 gobject_(src.gobject_ ? pango_attr_iterator_copy(src.gobject_) : 0)
34 AttrIter::AttrIter(PangoAttrIterator* castitem, bool take_copy)
39 gobject_ = pango_attr_iterator_copy(castitem);
52 pango_attr_iterator_destroy(gobject_);
55 AttrIter& AttrIter::operator=(const AttrIter& src)
57 PangoAttrIterator *const new_gobject = (src.gobject_ ? pango_attr_iterator_copy(src.gobject_) : 0);
60 pango_attr_iterator_destroy(gobject_);
61 gobject_ = new_gobject;
66 AttrIter& AttrIter::operator++()
72 const AttrIter AttrIter::operator++(int)
74 AttrIter previous(*this);
79 /* operator bool() cannot be implemented to work properly if a Pango::AttrIter is created
80 * from an already invalid PangoAttrIterator* because there is no way to validate it.
81 * Otherwise the iterator can only become invalid after some call to Pango::AttrIter::next()
82 * in which case gobject_ is destroyed thus marking the iterator as invalid.
84 AttrIter::operator bool() const
86 return (gobject_ != 0);
91 if(!pango_attr_iterator_next(gobj()))
93 pango_attr_iterator_destroy(gobject_);
94 gobject_ = 0; // Mark as invalid. There is no other way to determine whether the iterator is valid later.
101 FontDescription AttrIter::get_font_desc() const
103 FontDescription desc;
104 pango_attr_iterator_get_font(const_cast<PangoAttrIterator*>(gobj()), desc.gobj(), 0, 0);
106 // See pango ref docs for pango_attr_iterator_get_font.
107 pango_font_description_set_family(desc.gobj(), pango_font_description_get_family(desc.gobj()));
112 Language AttrIter::get_language() const
114 FontDescription desc;
115 PangoLanguage* language = 0;
117 pango_attr_iterator_get_font(const_cast<PangoAttrIterator*>(gobj()), desc.gobj(), &language, 0);
119 return Language(language, true);
122 SListHandle_Attribute AttrIter::get_extra_attrs() const
124 FontDescription desc;
125 GSList* extra_attrs = 0;
127 pango_attr_iterator_get_font(const_cast<PangoAttrIterator*>(gobj()), desc.gobj(), 0, &extra_attrs);
129 return SListHandle_Attribute(extra_attrs, Glib::OWNERSHIP_DEEP);
132 SListHandle_Attribute AttrIter::get_attrs() const
134 GSList* attrs = pango_attr_iterator_get_attrs( const_cast<PangoAttrIterator*>(gobj()) );
135 return SListHandle_Attribute(attrs, Glib::OWNERSHIP_DEEP);
139 } /* namespace Pango */
145 Pango::AttrIter wrap(PangoAttrIterator* object, bool take_copy)
147 return Pango::AttrIter(object, take_copy);
150 } /* namespace Glib */