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
|
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>gtk.gdk.PangoRenderer</title><link rel="stylesheet" href="style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.75.2"><link rel="home" href="index.html" title="PyGTK 2.0 Reference Manual"><link rel="up" href="gdk-class-reference.html" title="The gtk.gdk Class Reference"><link rel="prev" href="class-gdkkeymap.html" title="gtk.gdk.Keymap"><link rel="next" href="class-gdkpixbuf.html" title="gtk.gdk.Pixbuf"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">gtk.gdk.PangoRenderer</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="class-gdkkeymap.html">Prev</a> </td><th width="60%" align="center">The gtk.gdk Class Reference</th><td width="20%" align="right"> <a accesskey="n" href="class-gdkpixbuf.html">Next</a></td></tr></table><hr></div><div class="refentry" title="gtk.gdk.PangoRenderer"><a name="class-gdkpangorenderer"></a><div class="titlepage"></div><div class="refnamediv"><h2>gtk.gdk.PangoRenderer</h2><p>gtk.gdk.PangoRenderer — an object providing use of Pango in GDK (new in PyGTK
2.8)</p></div><div class="refsect1" title="Synopsis"><a name="id3335439"></a><h2>Synopsis</h2><table bgcolor="#D0E0F0" width="100%"><tr><td><pre class="classsynopsis">class <span class="ooclass"><span class="classname">gtk.gdk.PangoRenderer</span></span>(<span class="ooclass"><span class="classname"><a class="link" href="class-pangorenderer.html" title="pango.Renderer">pango.Renderer</a></span></span>):
<code class="constructorsynopsis"> <span class="methodname">pango.Renderer</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>screen</code></strong></span><span class="initializer">=None</span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gdkpangorenderer.html#method-gdkpangorenderer--set-drawable" title="gtk.gdk.PangoRenderer.set_drawable">set_drawable</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>drawable</code></strong></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gdkpangorenderer.html#method-gdkpangorenderer--set-gc" title="gtk.gdk.PangoRenderer.set_gc">set_gc</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>gc</code></strong></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gdkpangorenderer.html#method-gdkpangorenderer--set-stipple" title="gtk.gdk.PangoRenderer.set_stipple">set_stipple</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>part</code></strong></span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>stipple</code></strong></span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gdkpangorenderer.html#method-gdkpangorenderer--set-override-color" title="gtk.gdk.PangoRenderer.set_override_color">set_override_color</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>part</code></strong></span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>color</code></strong></span></span>)</code><br></pre></td></tr></table><pre class="programlisting">
<span class="bold"><strong>Functions</strong></span>
<code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gdkpangorenderer.html#function-gdk--gdk-pango-renderer-get-default" title="gtk.gdk.gdk_pango_renderer_get_default">gtk.gdk.gdk_pango_renderer_get_default</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>screen</code></strong></span></span>)</code></pre></div><div class="refsect1" title="Ancestry"><a name="id3458447"></a><h2>Ancestry</h2><pre class="synopsis">+-- <PYGTKDOCLINK HREF="class-gobject">gobject.GObject</PYGTKDOCLINK>
+-- <a class="link" href="class-pangorenderer.html" title="pango.Renderer">pango.Renderer</a>
+-- <a class="link" href="class-gdkpangorenderer.html" title="gtk.gdk.PangoRenderer">gtkgdk.PangoRenderer</a>
</pre></div><div class="refsect1" title="Properties"><a name="id3458479"></a><h2>Properties</h2><div class="blockquote"><table width="100%" border="0" bgcolor="#E0E0E0"><tr><td valign="top"><div class="informaltable"><table width="100%" border="0"><colgroup><col width="1in"><col width="1in"><col width="4in"></colgroup><tbody><tr valign="top"><td valign="top">"screen"</td><td valign="top">Read-Write-Construct Only</td><td valign="top">The <a class="link" href="class-gdkscreen.html" title="gtk.gdk.Screen"><code class="classname">gtk.gdk.Screen</code></a>
for the renderer. Available in GTK+ 2.8 and above.</td></tr></tbody></table></div></td></tr></table></div></div><div class="refsect1" title="Description"><a name="id3458556"></a><h2>Description</h2><p>Pango is the text layout system used by PyGTK (via GDK and
GTK+). The functions and types in this section are used to render Pango
objects to <a class="link" href="class-gdkdrawable.html" title="gtk.gdk.Drawable"><code class="classname">gtk.gdk.Drawable</code></a>
objects, and also extend the set of Pango attributes to include stippling
and embossing.</p><p>Creating a <a class="link" href="class-pangolayout.html" title="pango.Layout"><code class="classname">pango.Layout</code></a>
object is the first step in rendering text, and requires getting a handle to
a <a class="link" href="class-pangocontext.html" title="pango.Context"><code class="classname">pango.Context</code></a>.
For PyGTK programs, you'll usually want to use the <a class="link" href="class-gtkwidget.html#method-gtkwidget--get-pango-context" title="gtk.Widget.get_pango_context"><code class="methodname">gtk.Widget.get_pango_context</code>()</a>
method, or the <a class="link" href="class-gtkwidget.html#method-gtkwidget--create-pango-layout" title="gtk.Widget.create_pango_layout"><code class="methodname">create_pango_layout</code>()</a>)
method, rather than using the lowlevel <PYGTKDOCLINK HREF="function-gdk--gdk-pango-context-get-for-screen"><code class="function">gtk.gdk.gdk_pango_context_get_for_screen</code>()</PYGTKDOCLINK>
function. Once you have a <a class="link" href="class-pangolayout.html" title="pango.Layout"><code class="classname">pango.Layout</code></a>, you
can set the text and attributes of it with Pango methods like <a class="link" href="class-pangolayout.html#method-pangolayout--set-text" title="pango.Layout.set_text"><code class="methodname">pango.Layout.set_text</code>()</a>
and get its size using the <a class="link" href="class-pangolayout.html#method-pangolayout--get-size" title="pango.Layout.get_size"><code class="methodname">get_size</code>()</a>
method. (Note that Pango uses a fixed point system internally, so convert
between Pango units and pixels using <code class="literal">pango.SCALE</code> or the
<a class="link" href="class-pangofont.html#function-pango--PIXELS" title="pango.PIXELS"><code class="function">pango.PIXELS</code>()</a>
function.)</p><p>Rendering a Pango layout is done most simply with the <a class="link" href="class-gdkdrawable.html#method-gdkdrawable--draw-layout" title="gtk.gdk.Drawable.draw_layout"><code class="methodname">draw_layout</code>()</a>
method; you can also draw pieces of the layout with the <a class="link" href="class-gdkdrawable.html#method-gdkdrawable--draw-layout" title="gtk.gdk.Drawable.draw_layout"><code class="methodname">draw_layout</code>()</a>
method or the <a class="link" href="class-gdkdrawable.html#method-gdkdrawable--draw-glyphs" title="gtk.gdk.Drawable.draw_glyphs"><code class="methodname">draw_glyphs</code>()</a>
method.</p><p><a class="link" href="class-gdkpangorenderer.html" title="gtk.gdk.PangoRenderer"><code class="classname">gtk.gdk.PangoRenderer</code></a>
is a subclass of <a class="link" href="class-pangorenderer.html" title="pango.Renderer"><code class="classname">pango.Renderer</code></a>
that is used internally to implement these functions. Using it directly or
subclassing it can be useful in some cases. The default renderer for a
particular screen is obtained with the <a class="link" href="class-gdkpangorenderer.html#function-gdk--gdk-pango-renderer-get-default" title="gtk.gdk.gdk_pango_renderer_get_default"><code class="function">gtk.gdk.gdk_pango_renderer_get_default</code>()</a>
function. Pango methods like <a class="link" href="class-pangorenderer.html#method-pangorenderer--draw-layout" title="pango.Renderer.draw_layout"><code class="methodname">pango.Renderer.draw_layout</code>()</a>
and <a class="link" href="class-pangorenderer.html#method-pangorenderer--draw-layout-line" title="pango.Renderer.draw_layout_line"><code class="methodname">pango.Renderer.draw_layout_line</code>()</a>
are then used to draw objects with the renderer.</p><p>In most simple cases, applications can just use the <a class="link" href="class-gdkdrawable.html#method-gdkdrawable--draw-layout" title="gtk.gdk.Drawable.draw_layout"><code class="methodname">draw_layout</code>()</a>
method, and don't need to directly use <a class="link" href="class-gdkpangorenderer.html" title="gtk.gdk.PangoRenderer"><code class="classname">gtk.gdk.PangoRenderer</code></a>
at all. Using the <a class="link" href="class-gdkpangorenderer.html" title="gtk.gdk.PangoRenderer"><code class="classname">gtk.gdk.PangoRenderer</code></a>
directly is most useful when working with a transformation such as a
rotation, because the Pango drawing functions take user space coordinates
(coordinates before the transformation) instead of device
coordinates.</p><p>In certain cases it can be useful to subclass <a class="link" href="class-gdkpangorenderer.html" title="gtk.gdk.PangoRenderer"><code class="classname">gtk.gdk.PangoRenderer</code></a>. Examples
of reasons to do this are to add handling of custom attributes by overriding
'prepare_run' or to do custom drawing of embedded objects by overriding
'draw_shape'.</p></div><div class="refsect1" title="Constructor"><a name="id3458787"></a><h2>Constructor</h2><pre class="programlisting"><code class="constructorsynopsis"> <span class="methodname">gtk.gdk.PangoRenderer</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>screen</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>screen</code></strong> :</span></p></td><td>a <a class="link" href="class-gdkscreen.html" title="gtk.gdk.Screen"><code class="classname">gtk.gdk.Screen</code></a></td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>a new <a class="link" href="class-gdkpangorenderer.html" title="gtk.gdk.PangoRenderer"><code class="classname">gtk.gdk.PangoRenderer</code></a>
object</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This constructor is available in PyGTK 2.8 and above.</p></div><p>Creates a new <a class="link" href="class-gdkpangorenderer.html" title="gtk.gdk.PangoRenderer"><code class="classname">gtk.gdk.PangoRenderer</code></a>
object for the <a class="link" href="class-gdkscreen.html" title="gtk.gdk.Screen"><code class="classname">gtk.gdk.Screen</code></a>
specified by screen. Normally you can use the results of the <a class="link" href="class-gdkpangorenderer.html#function-gdk--gdk-pango-renderer-get-default" title="gtk.gdk.gdk_pango_renderer_get_default"><code class="function">gtk.gdk.gdk_pango_renderer_get_default</code>()</a>
function rather than creating a new renderer.</p></div><div class="refsect1" title="Methods"><a name="id3458910"></a><h2>Methods</h2><div class="refsect2" title="gtk.gdk.PangoRenderer.set_drawable"><a name="method-gdkpangorenderer--set-drawable"></a><h3>gtk.gdk.PangoRenderer.set_drawable</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_drawable</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>drawable</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>drawable</code></strong> :</span></p></td><td>the new target <a class="link" href="class-gdkdrawable.html" title="gtk.gdk.Drawable"><code class="classname">gtk.gdk.Drawable</code></a> or
<code class="literal">None</code>.</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.8 and above.</p></div><p>The <code class="methodname">set_drawable</code>() method sets the
<a class="link" href="class-gdkdrawable.html" title="gtk.gdk.Drawable"><code class="classname">gtk.gdk.Drawable</code></a>
specified by <em class="parameter"><code>drawable</code></em> as the drawable for
rendering.</p><p>In PyGTK 2.10, <em class="parameter"><code>drawable</code></em> may be
<code class="literal">None</code> to unset the drawable.</p></div><div class="refsect2" title="gtk.gdk.PangoRenderer.set_gc"><a name="method-gdkpangorenderer--set-gc"></a><h3>gtk.gdk.PangoRenderer.set_gc</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_gc</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>gc</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>gc</code></strong> :</span></p></td><td>a <a class="link" href="class-gdkgc.html" title="gtk.gdk.GC"><code class="classname">gtk.gdk.GC</code></a> or
<code class="literal">None</code>.</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.8 and above.</p></div><p>The <code class="methodname">set_gc</code>() method sets the graphics
context the renderer draws with to the <a class="link" href="class-gdkgc.html" title="gtk.gdk.GC"><code class="classname">gtk.gdk.GC</code></a> specified by
<em class="parameter"><code>gc</code></em>.</p><p>In PyGTK 2.10, <em class="parameter"><code>gc</code></em> may be
<code class="literal">None</code> to unset the gc to use for drawing.</p></div><div class="refsect2" title="gtk.gdk.PangoRenderer.set_stipple"><a name="method-gdkpangorenderer--set-stipple"></a><h3>gtk.gdk.PangoRenderer.set_stipple</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_stipple</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>part</code></strong></span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>stipple</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>part</code></strong> :</span></p></td><td> the part to render with the
stipple</td></tr><tr><td><p><span class="term"><strong class="parameter"><code>stipple</code></strong> :</span></p></td><td><p class="simpara"> the new stipple bitmap</p> or
<code class="literal">None</code>.</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.8 and above.</p></div><p>The <code class="methodname">set_stipple</code>() method sets the
stipple for one render part (foreground, background, underline,
strikethrough) to the bitmap specified by
<em class="parameter"><code>stipple</code></em>. The value of part must be one of the <a class="xref" href="pango-constants.html#pango-render-part-constants" title="Pango Render Part Constants">Pango Render Part Constants</a>. Note that this is
overwritten when iterating through the individual styled runs of a <a class="link" href="class-pangolayout.html" title="pango.Layout"><code class="classname">pango.Layout</code></a> or
<a class="link" href="class-pangolayoutline.html" title="pango.LayoutLine"><code class="classname">pango.LayoutLine</code></a>. This
method is thus only useful when you call low level methods like <a class="link" href="class-pangorenderer.html#method-pangorenderer--draw-glyphs" title="pango.Renderer.draw_glyphs"><code class="methodname">draw_glyphs</code>()</a>
directly, or in the 'prepare_run' virtual function of a subclass of <a class="link" href="class-gdkpangorenderer.html" title="gtk.gdk.PangoRenderer"><code class="classname">gtk.gdk.PangoRenderer</code></a>.</p><p>In PyGTK 2.10 <em class="parameter"><code>stipple</code></em> may be set to
<code class="literal">None</code>.</p></div><div class="refsect2" title="gtk.gdk.PangoRenderer.set_override_color"><a name="method-gdkpangorenderer--set-override-color"></a><h3>gtk.gdk.PangoRenderer.set_override_color</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">set_override_color</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>part</code></strong></span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>color</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>part</code></strong> :</span></p></td><td> the part to render with
<em class="parameter"><code>color</code></em></td></tr><tr><td><p><span class="term"><strong class="parameter"><code>color</code></strong> :</span></p></td><td>a <a class="link" href="class-gdkcolor.html" title="gtk.gdk.Color"><code class="classname">gtk.gdk.Color</code></a> or
<code class="literal">None</code>.</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.8 and above.</p></div><p>The <code class="methodname">set_override_color</code>() method sets
the color for a particular render part (foreground, background, underline,
strikethrough.) to the <a class="link" href="class-gdkcolor.html" title="gtk.gdk.Color"><code class="classname">gtk.gdk.Color</code></a>
specified by <em class="parameter"><code>color</code></em>, overriding any attributes on the
layouts renderered with this renderer.</p><p>In PyGTK 2.10 <em class="parameter"><code>color</code></em> may be set to
<code class="literal">None</code>.</p></div></div><div class="refsect1" title="Functions"><a name="id3466939"></a><h2>Functions</h2><div class="refsect2" title="gtk.gdk.gdk_pango_renderer_get_default"><a name="function-gdk--gdk-pango-renderer-get-default"></a><h3>gtk.gdk.gdk_pango_renderer_get_default</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">gtk.gdk.gdk_pango_renderer_get_default</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>screen</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>screen</code></strong> :</span></p></td><td>a <a class="link" href="class-gdkscreen.html" title="gtk.gdk.Screen"><code class="classname">gtk.gdk.Screen</code></a></td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>the default <a class="link" href="class-gdkpangorenderer.html" title="gtk.gdk.PangoRenderer"><code class="classname">gtk.gdk.PangoRenderer</code></a>
object for <em class="parameter"><code>screen</code></em>.</td></tr></tbody></table><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This function is available in PyGTK 2.8 and above.</p></div><p>The
<code class="function">gtk.gdk.gdk_pango_renderer_get_default</code>() function
returns the default <a class="link" href="class-gdkpangorenderer.html" title="gtk.gdk.PangoRenderer"><code class="classname">gtk.gdk.PangoRenderer</code></a>
for the <a class="link" href="class-gdkscreen.html" title="gtk.gdk.Screen"><code class="classname">gtk.gdk.Screen</code></a>
specified by <em class="parameter"><code>screen</code></em>. This default renderer is shared
by all users of the display, so properties such as the color or
transformation matrix set for the renderer may be overwritten by methods
such as <a class="link" href="class-gdkdrawable.html#method-gdkdrawable--draw-layout" title="gtk.gdk.Drawable.draw_layout"><code class="methodname">gtk.gdk.Drawable.draw_layout</code>()</a>.</p><p>Before using the renderer, you need to call the <a class="link" href="class-gdkpangorenderer.html#method-gdkpangorenderer--set-drawable" title="gtk.gdk.PangoRenderer.set_drawable"><code class="methodname">set_drawable</code>()</a>
and <a class="link" href="class-gdkpangorenderer.html#method-gdkpangorenderer--set-gc" title="gtk.gdk.PangoRenderer.set_gc"><code class="methodname">set_gc</code>()</a>
methods to set the drawable and graphics context to use for drawing.</p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="class-gdkkeymap.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="gdk-class-reference.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="class-gdkpixbuf.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">gtk.gdk.Keymap </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> gtk.gdk.Pixbuf</td></tr></table></div></body></html>
|