File: pygtk-pangocairocairocontext.xml

package info (click to toggle)
pygtk 2.24.0-5.1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 26,760 kB
  • ctags: 8,260
  • sloc: xml: 182,079; sh: 10,297; python: 10,161; ansic: 2,861; makefile: 1,358
file content (433 lines) | stat: -rw-r--r-- 17,916 bytes parent folder | download | duplicates (5)
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
<?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-pangocairocairocontext">
  <refnamediv>
    <refname>pangocairo.CairoContext</refname>
    <refpurpose>object providing support for using Cairo (new in
PyGTK 2.8)</refpurpose>
  </refnamediv>

  <refsect1>
    <title>Synopsis</title>

    <classsynopsis language="python">
      <ooclass><classname>pangocairo.CairoContext</classname></ooclass>
      <ooclass><classname><link linkend="class-cairocontext">cairo.Context</link></classname></ooclass>
      <constructorsynopsis language="python">
        <methodname><link linkend="constructor-pangocairocairocontext">pangocairo.CairoContext</link></methodname>
        <methodparam><parameter role="keyword">cr</parameter></methodparam>
      </constructorsynopsis>
      <methodsynopsis language="python">
        <methodname><link linkend="method-pangocairocairocontext--update-context">update_context</link></methodname>
        <methodparam><parameter role="keyword">context</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
        <methodname><link linkend="method-pangocairocairocontext--create-layout">create_layout</link></methodname>
      </methodsynopsis>
      <methodsynopsis language="python">
        <methodname><link linkend="method-pangocairocairocontext--update-layout">update_layout</link></methodname>
        <methodparam><parameter role="keyword">layout</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
        <methodname><link linkend="method-pangocairocairocontext--show-glyph-string">show_glyph_string</link></methodname>
        <methodparam><parameter role="keyword">font</parameter></methodparam>
        <methodparam><parameter role="keyword">glyphs</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
        <methodname><link linkend="method-pangocairocairocontext--show-layout-line">show_layout_line</link></methodname>
        <methodparam><parameter role="keyword">line</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
        <methodname><link linkend="method-pangocairocairocontext--show-layout">show_layout</link></methodname>
        <methodparam><parameter role="keyword">layout</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
        <methodname><link linkend="method-pangocairocairocontext--glyph-string-path">glyph_string_path</link></methodname>
        <methodparam><parameter role="keyword">font</parameter></methodparam>
        <methodparam><parameter role="keyword">glyphs</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
        <methodname><link linkend="method-pangocairocairocontext--layout-line-path">layout_line_path</link></methodname>
        <methodparam><parameter role="keyword">line</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
        <methodname><link linkend="method-pangocairocairocontext--layout-path">layout_path</link></methodname>
        <methodparam><parameter role="keyword">layout</parameter></methodparam>
      </methodsynopsis>
    </classsynopsis>

  </refsect1>

  <refsect1>
    <title>Ancestry</title>

<synopsis>+-- cairo.Context
  +-- <link linkend="class-pangocairocairocontext">pangocairo.CairoContext</link>
</synopsis>

  </refsect1>

  <refsect1>
    <title>Description</title>

    <para>Cairo is a graphics library that supports vector graphics and
image compositing that can be used with PyGTK. Since 2.8, GTK+ and Pango do
most of their drawing using Cairo. The Cairo drawing model and primitives
are similar to PostScript which uses an imaging model of painting on a two
dimensional surface. There is a Python module that wraps the Cairo API that
is used by PyGTK via subclassing of the cairo.Context class by the <link
linkend="class-pangocairocairocontext"><classname>pangocairo.CairoContext</classname></link>
class. The cairo.Context class provides most of the drawing primitives used
for drawing on Cairo surfaces.</para>

    <para>PyGTK (and GTK+ and GDK) does not wrap the Cairo API, instead
<link
linkend="class-gdkcairocontext"><classname>gtk.gdk.CairoContext</classname></link>
objects can be used to draw on <link
linkend="class-gdkdrawable"><classname>gtk.gdk.Drawable</classname></link>
objects. A <link
linkend="class-gdkcairocontext"><classname>gtk.gdk.CairoContext</classname></link>
is created using the <link
linkend="method-gdkdrawable--cairo-create"><methodname>gtk.gdk.Drawable.cairo_create</methodname>()</link>
method. See the <link
linkend="class-gdkcairocontext"><classname>gtk.gdk.CairoContext</classname></link>
and Python cairo module documentation for additional methods.</para>

  </refsect1>
  
  <refsect1 id="constructor-pangocairocairocontext">
    <title>Constructor</title>

    <programlisting><constructorsynopsis language="python">
	<methodname>pangocairo.CairoContext</methodname>
	<methodparam><parameter role="keyword">cr</parameter></methodparam>
      </constructorsynopsis></programlisting>
    <variablelist>
      <varlistentry>
	<term><parameter role="keyword">cr</parameter>&nbsp;:</term>
        <listitem><simpara>a <classname><link linkend="class-cairocontext">cairo.Context</link></classname>
        </simpara></listitem>
      </varlistentry>
      <varlistentry>
	<term><emphasis>Returns</emphasis>&nbsp;:</term>
	<listitem><simpara>a new <link
linkend="class-pangocairocairocontext"><classname>pangocairo.CairoContext</classname></link>.</simpara></listitem>
      </varlistentry>
    </variablelist>

    <para>Creates a new <link
linkend="class-pangocairocairocontext"><classname>pangocairo.CairoContext</classname></link></para>


  </refsect1>

  <refsect1>
    <title>Methods</title>

    <refsect2 id="method-pangocairocairocontext--update-context">
      <title>pangocairo.CairoContext.update_context</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>update_context</methodname>
	  <methodparam><parameter
			 role="keyword">context</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">context</parameter>&nbsp;:</term>
	  <listitem><simpara>a <link
linkend="class-pangocontext"><classname>pango.Context</classname></link>
created by the <link
linkend="method-pangocairocairofontmap--create-context"><methodname>pangocairo.CairoFontMap.create_context</methodname>()</link>
method</simpara></listitem>
	</varlistentry>
      </variablelist>

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

      <para>The <methodname>update_context</methodname>() method updates a
<link
linkend="class-pangocontext"><classname>pango.Context</classname></link>
previously created for use with Cairo to match the current transformation
and target surface of a Cairo context. If any layouts have been created for
the context, it's necessary to call the <link
linkend="method-pangolayout--context-changed"><methodname>pango.Layout.context_changed</methodname>()</link>
method on those layouts.</para>

    </refsect2>

    <refsect2 id="method-pangocairocairocontext--create-layout">
      <title>pangocairo.CairoContext.create_layout</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>create_layout</methodname>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	<term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a new <link
linkend="class-pangolayout"><classname>pango.Layout</classname></link>
object.</simpara></listitem>
	</varlistentry>
      </variablelist>

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

      <para>The <methodname>create_layout</methodname>() method creates a
<link linkend="class-pangolayout"><classname>pango.Layout</classname></link>
object set up to match the current transformation and target surface of the
Cairo context. This layout can then be used for text measurement with
methods like <link
linkend="method-pangolayout--get-size"><methodname>pango.Layout.get_size</methodname>()</link>
or for drawing with methods like <link
linkend="method-pangocairocairocontext--show-layout"><methodname>show_layout</methodname>()</link>. If
you change the transformation or target surface for the context, you need to
call the <link
linkend="method-pangocairocairocontext--update-layout"><methodname>update_layout</methodname>()</link>
method.</para>

      <para>This method is the most convenient way to use Cairo with Pango,
however it is slightly inefficient since it creates a separate <link
linkend="class-pangocontext"><classname>pango.Context</classname></link>
object for each layout. This might be of concern in an application laying
out large amounts of text.</para>

    </refsect2>

    <refsect2 id="method-pangocairocairocontext--update-layout">
      <title>pangocairo.CairoContext.update_layout</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>update_layout</methodname>
	  <methodparam><parameter
			 role="keyword">layout</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">layout</parameter>&nbsp;:</term>
	  <listitem><simpara>a <link
linkend="class-pangolayout"><classname>pango.Layout</classname></link>
created by the <link
linkend="method-pangocairocairocontext--create-layout"><methodname>create_layout</methodname>()</link>
method</simpara></listitem>
	</varlistentry>
      </variablelist>

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

      <para>The <methodname>update_layout</methodname>() method updates the
private <link
linkend="class-pangocontext"><classname>pango.Context</classname></link> of
the <link
linkend="class-pangolayout"><classname>pango.Layout</classname></link>
(specified by <parameter>layout</parameter>) that was created with the <link
linkend="method-pangocairocairocontext--create-layout"><methodname>create_layout</methodname>()</link>
method to match the current transformation and target surface of a Cairo
context.</para>

    </refsect2>

    <refsect2 id="method-pangocairocairocontext--show-glyph-string">
      <title>pangocairo.CairoContext.show_glyph_string</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>show_glyph_string</methodname>
	  <methodparam><parameter
			 role="keyword">font</parameter></methodparam>
	  <methodparam><parameter
			 role="keyword">glyphs</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">font</parameter>&nbsp;:</term>
	  <listitem><simpara>a <link
linkend="class-pangofont"><classname>pango.Font</classname></link></simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter role="keyword">glyphs</parameter>&nbsp;:</term>
	  <listitem><simpara>a <link
linkend="class-pangoglyphstring"><classname>pango.GlyphString</classname></link></simpara></listitem>
	</varlistentry>
      </variablelist>

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

      <para>The <methodname>show_glyph_string</methodname>() method draws
the <link
linkend="class-pangoglyphstring"><classname>pango.GlyphString</classname></link>
specified by <parameter>glyphs</parameter> in the cairo context using the
<link linkend="class-pangofont"><classname>pango.Font</classname></link>
specified by <parameter>font</parameter>. The origin of the glyphs (the left
edge of the baseline) will be drawn at the current point of the cairo
context.</para>

    </refsect2>

    <refsect2 id="method-pangocairocairocontext--show-layout-line">
      <title>pangocairo.CairoContext.show_layout_line</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>show_layout_line</methodname>
	  <methodparam><parameter
			 role="keyword">line</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">line</parameter>&nbsp;:</term>
	  <listitem><simpara>a <link
linkend="class-pangolayoutline"><classname>pango.LayoutLine</classname></link></simpara></listitem>
	</varlistentry>
      </variablelist>

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

      <para>The <methodname>show_layout_line</methodname>() method draws the
<link
linkend="class-pangolayoutline"><classname>pango.LayoutLine</classname></link>
specified by <parameter>line</parameter> in the cairo context. The origin of
the glyphs (the left edge of the line) will be drawn at the current point of
the cairo context.</para>

    </refsect2>

    <refsect2 id="method-pangocairocairocontext--show-layout">
      <title>pangocairo.CairoContext.show_layout</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>show_layout</methodname>
	  <methodparam><parameter
			 role="keyword">layout</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">layout</parameter>&nbsp;:</term>
	  <listitem><simpara>a <link
linkend="class-pangolayout"><classname>pango.Layout</classname></link></simpara></listitem>
	</varlistentry>
      </variablelist>

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

      <para>The <methodname>show_layout</methodname>() method draws the
<link linkend="class-pangolayout"><classname>pango.Layout</classname></link>
specified by <parameter>layout</parameter> in the cairo context. The
top-left corner of the <link
linkend="class-pangolayout"><classname>pango.Layout</classname></link> will
be drawn at the current point of the cairo context.</para>

    </refsect2>

    <refsect2 id="method-pangocairocairocontext--glyph-string-path">
      <title>pangocairo.CairoContext.glyph_string_path</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>glyph_string_path</methodname>
	  <methodparam><parameter
			 role="keyword">font</parameter></methodparam>
	  <methodparam><parameter
			 role="keyword">glyphs</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">font</parameter>&nbsp;:</term>
	  <listitem><simpara>a <link
linkend="class-pangofont"><classname>pango.Font</classname></link></simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter role="keyword">glyphs</parameter>&nbsp;:</term>
	  <listitem><simpara>a <link
linkend="class-pangoglyphstring"><classname>pango.GlyphString</classname></link></simpara></listitem>
	</varlistentry>
      </variablelist>

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

      <para>The <methodname>glyph_string_path</methodname>() method adds the
<link
linkend="class-pangoglyphstring"><classname>pango.GlyphString</classname></link>
specified by <parameter>glyphs</parameter> to the current path in the cairo
context using the <link
linkend="class-pangofont"><classname>pango.Font</classname></link> specified
by font. The origin of the added glyphs (the left edge of the baseline) will
be at the current point of the cairo context.</para>

    </refsect2>

    <refsect2 id="method-pangocairocairocontext--layout-line-path">
      <title>pangocairo.CairoContext.layout_line_path</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>layout_line_path</methodname>
	  <methodparam><parameter
			 role="keyword">line</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">line</parameter>&nbsp;:</term>
	  <listitem><simpara>a <link
linkend="class-pangolayoutline"><classname>pango.LayoutLine</classname></link></simpara></listitem>
	</varlistentry>
      </variablelist>

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

      <para>The <methodname>layout_line_path</methodname>() method adds the
text in the <link
linkend="class-pangolayoutline"><classname>pango.LayoutLine</classname></link>
specified by <parameter>line</parameter> to the current path in the
specified cairo context. The origin of the glyphs (the left edge of the
line) will be at the current point of the cairo context.</para>

    </refsect2>

    <refsect2 id="method-pangocairocairocontext--layout-path">
      <title>pangocairo.CairoContext.layout_path</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>layout_path</methodname>
	  <methodparam><parameter
			 role="keyword">layout</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">layout</parameter>&nbsp;:</term>
	  <listitem><simpara>a <link
linkend="class-pangolayout"><classname>pango.Layout</classname></link></simpara></listitem>
	</varlistentry>
      </variablelist>

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

      <para>The <methodname>layout_path</methodname>() method adds the text
in the <link
linkend="class-pangolayout"><classname>pango.Layout</classname></link>
specified by <parameter>layout</parameter> to the current path in the
specified cairo context. The top-left corner of the <link
linkend="class-pangolayout"><classname>pango.Layout</classname></link> will
be at the current point of the cairo context.</para>

    </refsect2>

  </refsect1>

</refentry>