add new sigc++2 directory
[ardour.git] / libs / gtkmm2 / pango / pangomm / attrlist.h
1 // -*- c++ -*-
2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _PANGOMM_ATTRLIST_H
4 #define _PANGOMM_ATTRLIST_H
5
6
7 #include <glibmm.h>
8
9 /* $Id$ */
10
11 /* attrlist.h
12  *
13  * Copyright (C) 1998-1999 The gtkmm Development Team
14  *
15  * This library is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU Library General Public
17  * License as published by the Free Software Foundation; either
18  * version 2 of the License, or (at your option) any later version.
19  *
20  * This library is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23  * Library General Public License for more details.
24  *
25  * You should have received a copy of the GNU Library General Public
26  * License along with this library; if not, write to the Free
27  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28  */
29
30 #include <pangomm/attributes.h>
31 #include <pangomm/attriter.h>
32
33
34 #ifndef DOXYGEN_SHOULD_SKIP_THIS
35 extern "C" { typedef struct _PangoAttrList PangoAttrList; }
36 #endif
37
38 namespace Pango
39 {
40
41 /** A Pango::AttrList represents a list of attributes that apply to a section of text.
42  * The attributes are, in general, allowed to overlap in an arbitrary fashion, however,
43  * if the attributes are manipulated only through Pango::AttrList::change(), the overlap between properties will meet stricter criteria.
44  *
45  * Since the Pango::AttrList structure is stored as a linear list, it is not suitable for storing attributes for large amounts of text.
46  * In general, you should not use a single Pango::AttrList for more than one paragraph of text.
47  *
48  * When obtaining an AttrList, you should check that it is valid. For instance, if(attrlist).
49  */
50 class AttrList
51 {
52   public:
53 #ifndef DOXYGEN_SHOULD_SKIP_THIS
54   typedef AttrList CppObjectType;
55   typedef PangoAttrList BaseObjectType;
56
57   static GType get_type() G_GNUC_CONST;
58 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
59
60   AttrList();
61
62   explicit AttrList(PangoAttrList* gobject, bool make_a_copy = true);
63
64   AttrList(const AttrList& other);
65   AttrList& operator=(const AttrList& other);
66
67   ~AttrList();
68
69   void swap(AttrList& other);
70
71   ///Provides access to the underlying C instance.
72   PangoAttrList*       gobj()       { return gobject_; }
73
74   ///Provides access to the underlying C instance.
75   const PangoAttrList* gobj() const { return gobject_; }
76
77   ///Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.
78   PangoAttrList* gobj_copy() const;
79
80 protected:
81   PangoAttrList* gobject_;
82
83 private:
84
85   
86 public:
87   /** Constructs an attribute list by parsing a marked-up text (see markup format).
88    * If @a accel_marker is nonzero, the given character will mark the character
89    * following it as an accelerator. For example, the accel marker might be an
90    * ampersand or underscore. All characters marked as an accelerator will receive
91    * a Pango::UNDERLINE_LOW attribute.
92    * Two @a accel_marker characters following each other
93    * produce a single literal @a accel_marker character.
94    *
95    * @param markup_text Markup to parse (see markup format).
96    * @param accel_marker Character that precedes an accelerator, or <tt>0</tt> for none.
97    */
98   explicit AttrList(const Glib::ustring& markup_text, gunichar accel_marker=0);
99
100   /** Constructs an attribute list by parsing a marked-up text (see markup format).
101    * @a text is set to the plaintext string.
102    * If @a accel_marker is nonzero, the given character will mark the character 
103    * following it as an accelerator. For example, the accel marker might be an 
104    * ampersand or underscore. All characters marked as an accelerator will receive
105    * a Pango::UNDERLINE_LOW attribute. The first character so marked will be 
106    * returned in @a accel_char. Two @a accel_marker characters following each other 
107    * produce a single literal @a accel_marker character.
108    *
109    * @param markup_text Markup to parse (see markup format).
110    * @param accel_marker Character that precedes an accelerator, or <tt>0</tt> for none.
111    * @param text Return location for text with tags stripped.
112    * @param accel_char Return location for accelerator char.
113    */
114   AttrList(const Glib::ustring& markup_text, gunichar accel_marker, Glib::ustring& text, gunichar& accel_char);
115
116   ///Tests whether the AttrList is valid.
117   operator bool();
118
119   void insert(Attribute& attr);
120    // hand code because we need to pass a copy of the attribute
121   void insert_before(Attribute& attr);
122    // hand code because we need to pass a copy of the attribute
123   void change(Attribute& attr);
124    // hand code because we need to pass a copy of the attribute
125   
126   /** This function opens up a hole in @a list , fills it in with attributes from
127    * the left, and then merges @a other  on top of the hole.
128    * 
129    * This operation is equivalent to stretching every attribute
130    * that applies at position @a pos  in @a list  by an amount @a len ,
131    * and then calling pango_attr_list_change() with a copy
132    * of each attribute in @a other  in sequence (offset in position by @a pos ).
133    * 
134    * This operation proves useful for, for instance, inserting
135    * a pre-edit string in the middle of an edit buffer.
136    * @param other Another Pango::AttrList.
137    * @param pos The position in @a list  at which to insert @a other .
138    * @param len The length of the spliced segment. (Note that this
139    * must be specified since the attributes in @a other 
140    * may only be present at some subsection of this range).
141    */
142   void splice(AttrList& other, int pos, int len);
143   
144   /** Create a iterator initialized to the beginning of the list.
145    *  @a list  must not be modified until this iterator is freed.
146    * @return The newly allocated Pango::AttrIterator, which should
147    * be freed with pango_attr_iterator_destroy().
148    */
149   AttrIter get_iter();
150
151   //TODO: Though it doesn't seem important:
152   //PangoAttrList* pango_attr_list_filter (PangoAttrList* list, PangoAttrFilterFunc  func, gpointer             data)
153
154
155 };
156
157 } //namespace Pango
158
159
160 namespace Pango
161 {
162
163 /** @relates Pango::AttrList
164  * @param lhs The left-hand side
165  * @param rhs The right-hand side
166  */
167 inline void swap(AttrList& lhs, AttrList& rhs)
168   { lhs.swap(rhs); }
169
170 } // namespace Pango
171
172 namespace Glib
173 {
174
175 /** A Glib::wrap() method for this object.
176  * 
177  * @param object The C instance.
178  * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
179  * @result A C++ instance that wraps this C instance.
180  *
181  * @relates Pango::AttrList
182  */
183 Pango::AttrList wrap(PangoAttrList* object, bool take_copy = false);
184
185 #ifndef DOXYGEN_SHOULD_SKIP_THIS
186 template <>
187 class Value<Pango::AttrList> : public Glib::Value_Boxed<Pango::AttrList>
188 {};
189 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
190
191 } // namespace Glib
192
193
194 #endif /* _PANGOMM_ATTRLIST_H */
195