summaryrefslogtreecommitdiff
path: root/docs/reference/pygtk-pangolayoutiter.xml
blob: a6a0c71c102a04541023e71dc7243ae2c4547d85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
<?xml version="1.0" standalone="no"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
    "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<refentry id="class-pangolayoutiter">
  <refnamediv>
    <refname>pango.LayoutIter</refname>
    <refpurpose>an object used to iterate over the visual extents of a
<link
linkend="class-pangolayout"><classname>pango.Layout</classname></link>
(new in PyGTK 2.6)</refpurpose>
  </refnamediv>

  <refsect1>
    <title>Synopsis</title>

    <classsynopsis language="python">
      <ooclass><classname>pango.LayoutIter</classname></ooclass>
      <ooclass><classname><link
linkend="class-gobjectgboxed">gobject.GBoxed</link></classname></ooclass>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-pangolayoutiter--free">free</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-pangolayoutiter--next-char">next_char</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-pangolayoutiter--next-cluster">next_cluster</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-pangolayoutiter--next-line">next_line</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-pangolayoutiter--next-run">next_run</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-pangolayoutiter--at-last-line">at_last_line</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-pangolayoutiter--get-index">get_index</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-pangolayoutiter--get-baseline">get_baseline</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-pangolayoutiter--get-char-extents">get_char_extents</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-pangolayoutiter--get-cluster-extents">get_cluster_extents</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-pangolayoutiter--get-layout-extents">get_layout_extents</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-pangolayoutiter--get-line-extents">get_line_extents</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-pangolayoutiter--get-run-extents">get_run_extents</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-pangolayoutiter--get-line-yrange">get_line_yrange</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-pangolayoutiter--get-line-yrange">get_line</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>

    </classsynopsis>

  </refsect1>

  <refsect1>
    <title>Ancestry</title>

<synopsis>+-- <link linkend="class-gobjectgboxed">gobject.GBoxed</link>
  +-- <link linkend="class-pangolayoutiter">pango.LayoutIter</link>
</synopsis>

  </refsect1>

  <refsect1>
    <title>Description</title>

    <para>A <link
linkend="class-pangolayoutiter"><classname>pango.LayoutIter</classname></link>
object can be used to iterate over the visual elements of a <link
linkend="class-pangolayout"><classname>pango.Layout</classname></link>. A
<link
linkend="class-pangolayoutiter"><classname>pango.LayoutIter</classname></link>
is created using the <link
linkend="method-pangolayout--get-iter"><methodname>pango.Layout.get_iter</methodname>()</link>
method.</para>

  </refsect1>

  <refsect1>
    <title>Methods</title>

  <refsect2 id="method-pangolayoutiter--free">
      <title>pango.LayoutIter.free</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>free</methodname>
	  <methodparam></methodparam>  </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a new <link
linkend="class-pangolayout"><classname>pango.Layout</classname></link> that
is a copy of the layout</simpara></listitem>
	</varlistentry>
      </variablelist>

      <warning>
        <para>This method is deprecated and should not be used since it may
crash your application.</para>
      </warning>

      <para>The <methodname>free</methodname>() method frees the <link
linkend="class-pangolayoutiter"><classname>pango.LayoutIter</classname></link>
object.</para>

    </refsect2>

    <refsect2 id="method-pangolayoutiter--next-char">
      <title>pango.LayoutIter.next_char</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>next_char</methodname>
	  <methodparam></methodparam>
        </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara><literal>TRUE</literal> if the iter was
moved.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>next_char</methodname>() method returns
<literal>TRUE</literal> if the <link
linkend="class-pangolayoutiter"><classname>pango.LayoutIter</classname></link>
is moved to the next character in visual order. If the iter was already at
the end of the layout this method returns <literal>FALSE</literal>.</para>

    </refsect2>

    <refsect2 id="method-pangolayoutiter--next-cluster">
      <title>pango.LayoutIter.next_cluster</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>next_cluster</methodname>
	  <methodparam></methodparam>
        </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara><literal>TRUE</literal> if the iter was
moved.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>next_cluster</methodname>() method returns
<literal>TRUE</literal> if the <link
linkend="class-pangolayoutiter"><classname>pango.LayoutIter</classname></link>
is moved to the next cluster in visual order. If the iter was already at the
end of the layout this method returns <literal>FALSE</literal>.</para>

    </refsect2>

    <refsect2 id="method-pangolayoutiter--next-line">
      <title>pango.LayoutIter.next_line</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>next_line</methodname>
	  <methodparam></methodparam>
        </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara><literal>TRUE</literal> if the iter was
moved.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>next_line</methodname>() method returns
<literal>TRUE</literal> if the <link
linkend="class-pangolayoutiter"><classname>pango.LayoutIter</classname></link>
is moved to the next line in visual order. If the iter was already at the
end of the layout this method returns <literal>FALSE</literal>.</para>

    </refsect2>

    <refsect2 id="method-pangolayoutiter--next-run">
      <title>pango.LayoutIter.next_run</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>next_run</methodname>
	  <methodparam></methodparam>
        </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara><literal>TRUE</literal> if the iter was
moved.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>next_run</methodname>() method returns
<literal>TRUE</literal> if the <link
linkend="class-pangolayoutiter"><classname>pango.LayoutIter</classname></link>
is moved to the next run in visual order. If the iter was already at the end
of the layout this method returns <literal>FALSE</literal>.</para>

    </refsect2>

    <refsect2 id="method-pangolayoutiter--at-last-line">
      <title>pango.LayoutIter.at_last_line</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>at_last_line</methodname>
	  <methodparam></methodparam>
        </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara><literal>TRUE</literal> if the iter is in the
last line.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>at_last_line</methodname>() method returns
<literal>TRUE</literal> if the <link
linkend="class-pangolayoutiter"><classname>pango.LayoutIter</classname></link>
points to a position in the last line of the layout.</para>

    </refsect2>

    <refsect2 id="method-pangolayoutiter--get-index">
      <title>pango.LayoutIter.get_index</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_index</methodname>
	  <methodparam></methodparam>
        </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>the current byte index</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>get_index</methodname>() method returns the
current byte index. Note that iterating forward by char moves in visual
order, not logical order, so indexes may not be sequential. Also, the index
may be equal to the length of the text in the layout.</para>

    </refsect2>

    <refsect2 id="method-pangolayoutiter--get-baseline">
      <title>pango.LayoutIter.get_baseline</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_baseline</methodname>
	  <methodparam></methodparam>
        </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>the baseline of the current
line.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>get_baseline</methodname>() method returns the y
position of the current line's baseline, in layout coordinates (origin at
top left of the entire layout).</para>

    </refsect2>

    <refsect2 id="method-pangolayoutiter--get-char-extents">
      <title>pango.LayoutIter.get_char_extents</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_char_extents</methodname>
	  <methodparam></methodparam>
        </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a 4-tuple containing the logical extents of the
character at the iter position.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>get_char_extents</methodname>() method returns a
4-tuple (x, y, width, height) containing the logical extents of the current
character, in layout coordinates (origin is the top left of the entire
layout). Only logical extents can sensibly be obtained for characters; ink
extents make sense only down to the level of clusters.</para>

    </refsect2>

    <refsect2 id="method-pangolayoutiter--get-cluster-extents">
      <title>pango.LayoutIter.get_cluster_extents</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_cluster_extents</methodname>
	  <methodparam></methodparam>
        </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a 2-tuple containing containing the
ink and logical extents as 4-tuples.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>get_cluster_extents</methodname>() method
returns a 2-tuple containing the ink and logical extents (as 4-tuples: x, y,
width, height) of the cluster at the iter position.</para>

    </refsect2>

    <refsect2 id="method-pangolayoutiter--get-layout-extents">
      <title>pango.LayoutIter.get_layout_extents</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_layout_extents</methodname>
	  <methodparam></methodparam>
        </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a 2-tuple containing containing the
ink and logical extents as 4-tuples.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>get_layout_extents</methodname>() method returns
a 2-tuple containing the ink and logical extents (as 4-tuples: x, y, width,
height) of the layout at the iter position.</para>

    </refsect2>

    <refsect2 id="method-pangolayoutiter--get-line-extents">
      <title>pango.LayoutIter.get_line_extents</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_line_extents</methodname>
	  <methodparam></methodparam>
        </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a 2-tuple containing containing the
ink and logical extents as 4-tuples.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>get_line_extents</methodname>() method returns a
2-tuple containing the ink and logical extents (as 4-tuples: x, y, width,
height) of the line at the iter position.</para>

    </refsect2>

    <refsect2 id="method-pangolayoutiter--get-run-extents">
      <title>pango.LayoutIter.get_run_extents</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_run_extents</methodname>
	  <methodparam></methodparam>
        </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a 2-tuple containing containing the
ink and logical extents as 4-tuples.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>get_run_extents</methodname>() method returns a
2-tuple containing the ink and logical extents (as 4-tuples: x, y, width,
height) of the run at the iter position.</para>

    </refsect2>

    <refsect2 id="method-pangolayoutiter--get-line-yrange">
      <title>pango.LayoutIter.get_line_yrange</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_line_yrange</methodname>
	  <methodparam></methodparam>
        </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a 2-tuple containing the start and end of the
layout line.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>get_line_yrange</methodname>() method returns a
2-tuple containing the start and end y positions of the layout line. The
vertical space in the <link
linkend="class-pangolayout"><classname>pango.Layout</classname></link>
associated with the iter is devided between the lines in the layout, the
space belonging to the current line is returned in the 2-tuple. A line's
range includes the line's logical extents, plus half of the spacing above
and below the line, if the <link
linkend="method-pangolayout--set-spacing"><methodname>pango.Layout.set_spacing</methodname>()</link>
method has been called to set the layout spacing. The y positions are in layout
coordinates (origin at top left of the entire layout).</para>

    </refsect2>

    <refsect2 id="method-pangolayoutiter--get-line">
      <title>pango.LayoutIter.get_line</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_line</methodname>
	  <methodparam></methodparam>
        </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a <link
linkend="class-pangolayoutline"><classname>pango.LayoutLine</classname></link>
containing the current line.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
        <para>This method is available in PyGTK 2.8 and above.</para>
      </note>

      <para>The <methodname>get_line</methodname>() method returns a <link
linkend="class-pangolayoutline"><classname>pango.LayoutLine</classname></link>
containing the current line.</para>

    </refsect2>

  </refsect1>

</refentry>