<?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-gdkpangorenderer">
  <refnamediv>
    <refname>gtk.gdk.PangoRenderer</refname>
    <refpurpose>an object providing use of Pango in GDK (new in PyGTK
2.8)</refpurpose>
  </refnamediv>

  <refsect1>
    <title>Synopsis</title>

<classsynopsis language="python">
  <ooclass><classname>gtk.gdk.PangoRenderer</classname></ooclass>
  <ooclass><classname><link linkend="class-pangorenderer">pango.Renderer</link></classname></ooclass>
<constructorsynopsis language="python">
    <methodname>pango.Renderer</methodname>
    <methodparam><parameter role="keyword">screen</parameter><initializer>None</initializer></methodparam>
  </constructorsynopsis>
<methodsynopsis language="python">
    <methodname><link linkend="method-gdkpangorenderer--set-drawable">set_drawable</link></methodname>
    <methodparam><parameter role="keyword">drawable</parameter></methodparam>
  </methodsynopsis>
<methodsynopsis language="python">
    <methodname><link linkend="method-gdkpangorenderer--set-gc">set_gc</link></methodname>
    <methodparam><parameter role="keyword">gc</parameter></methodparam>
  </methodsynopsis>
<methodsynopsis language="python">
    <methodname><link linkend="method-gdkpangorenderer--set-stipple">set_stipple</link></methodname>
    <methodparam><parameter role="keyword">part</parameter></methodparam>
    <methodparam><parameter role="keyword">stipple</parameter></methodparam>
  </methodsynopsis>
<methodsynopsis language="python">
    <methodname><link linkend="method-gdkpangorenderer--set-override-color">set_override_color</link></methodname>
    <methodparam><parameter role="keyword">part</parameter></methodparam>
    <methodparam><parameter role="keyword">color</parameter></methodparam>
  </methodsynopsis>
</classsynopsis>

<programlisting>
<emphasis role="bold">Functions</emphasis>

<methodsynopsis language="python">
    <methodname><link linkend="function-gdk--gdk-pango-renderer-get-default">gtk.gdk.gdk_pango_renderer_get_default</link></methodname>
    <methodparam><parameter role="keyword">screen</parameter></methodparam>
  </methodsynopsis></programlisting>

</refsect1>

  <refsect1>
    <title>Ancestry</title>

<synopsis>+-- <link linkend="class-gobject">gobject.GObject</link>
  +-- <link linkend="class-pangorenderer">pango.Renderer</link>
    +-- <link linkend="class-gdkpangorenderer">gtkgdk.PangoRenderer</link>
</synopsis>

  </refsect1>

  <refsect1>
    <title>Properties</title>

    <blockquote role="properties">
      <informaltable pgwide="1" frame="none">
	<tgroup cols="3">
	  <colspec column="1" colwidth="1in"/>
	  <colspec column="2" colwidth="1in"/>
	  <colspec column="3" colwidth="4in"/>
	  <tbody>

	    <row valign="top">
	      <entry>"screen"</entry>
	      <entry>Read-Write-Construct Only</entry>
	      <entry>The <link
linkend="class-gdkscreen"><classname>gtk.gdk.Screen</classname></link>
for the renderer. Available in GTK+ 2.8 and above.</entry>
	    </row>

	  </tbody>
	</tgroup>
      </informaltable>
    </blockquote>

  </refsect1>

  <refsect1>
    <title>Description</title>

    <para>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 <link
linkend="class-gdkdrawable"><classname>gtk.gdk.Drawable</classname></link>
objects, and also extend the set of Pango attributes to include stippling
and embossing.</para>

    <para>Creating a <link
linkend="class-pangolayout"><classname>pango.Layout</classname></link>
object is the first step in rendering text, and requires getting a handle to
a <link
linkend="class-pangocontext"><classname>pango.Context</classname></link>.
For PyGTK programs, you'll usually want to use the <link
linkend="method-gtkwidget--get-pango-context"><methodname>gtk.Widget.get_pango_context</methodname>()</link>
method, or the <link
linkend="method-gtkwidget--create-pango-layout"><methodname>create_pango_layout</methodname>()</link>)
method, rather than using the lowlevel <link
linkend="function-gdk--gdk-pango-context-get-for-screen"><function>gtk.gdk.gdk_pango_context_get_for_screen</function>()</link>
function. Once you have a <link
linkend="class-pangolayout"><classname>pango.Layout</classname></link>, you
can set the text and attributes of it with Pango methods like <link
linkend="method-pangolayout--set-text"><methodname>pango.Layout.set_text</methodname>()</link>
and get its size using the <link
linkend="method-pangolayout--get-size"><methodname>get_size</methodname>()</link>
method. (Note that Pango uses a fixed point system internally, so convert
between Pango units and pixels using <literal>pango.SCALE</literal> or the
<link
linkend="function-pango--PIXELS"><function>pango.PIXELS</function>()</link>
function.)</para>

    <para>Rendering a Pango layout is done most simply with the <link
linkend="method-gdkdrawable--draw-layout"><methodname>draw_layout</methodname>()</link>
method; you can also draw pieces of the layout with the <link
linkend="method-gdkdrawable--draw-layout"><methodname>draw_layout</methodname>()</link>
method or the <link
linkend="method-gdkdrawable--draw-glyphs"><methodname>draw_glyphs</methodname>()</link>
method.</para>

    <para><link
linkend="class-gdkpangorenderer"><classname>gtk.gdk.PangoRenderer</classname></link>
is a subclass of <link
linkend="class-pangorenderer"><classname>pango.Renderer</classname></link>
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 <link
linkend="function-gdk--gdk-pango-renderer-get-default"><function>gtk.gdk.gdk_pango_renderer_get_default</function>()</link>
function. Pango methods like <link
linkend="method-pangorenderer--draw-layout"><methodname>pango.Renderer.draw_layout</methodname>()</link>
and <link
linkend="method-pangorenderer--draw-layout-line"><methodname>pango.Renderer.draw_layout_line</methodname>()</link>
are then used to draw objects with the renderer.</para>

    <para>In most simple cases, applications can just use the <link
linkend="method-gdkdrawable--draw-layout"><methodname>draw_layout</methodname>()</link>
method, and don't need to directly use <link
linkend="class-gdkpangorenderer"><classname>gtk.gdk.PangoRenderer</classname></link>
at all. Using the <link
linkend="class-gdkpangorenderer"><classname>gtk.gdk.PangoRenderer</classname></link>
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.</para>

    <para>In certain cases it can be useful to subclass <link
linkend="class-gdkpangorenderer"><classname>gtk.gdk.PangoRenderer</classname></link>. 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'.</para>

  </refsect1>

  <refsect1>
    <title>Constructor</title>

    <programlisting><constructorsynopsis language="python">
	<methodname>gtk.gdk.PangoRenderer</methodname>
	<methodparam><parameter
		       role="keyword">screen</parameter></methodparam>
      </constructorsynopsis></programlisting>
    <variablelist>
      <varlistentry>
	<term><parameter role="keyword">screen</parameter>&nbsp;:</term>
	<listitem><simpara>a <link
linkend="class-gdkscreen"><classname>gtk.gdk.Screen</classname></link></simpara></listitem>
      </varlistentry>
      <varlistentry>
	<term><emphasis>Returns</emphasis>&nbsp;:</term>
	<listitem><simpara>a new <link
linkend="class-gdkpangorenderer"><classname>gtk.gdk.PangoRenderer</classname></link>
object</simpara></listitem>
      </varlistentry>
    </variablelist>

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

    <para>Creates a new <link
linkend="class-gdkpangorenderer"><classname>gtk.gdk.PangoRenderer</classname></link>
object for the <link
linkend="class-gdkscreen"><classname>gtk.gdk.Screen</classname></link>
specified by screen. Normally you can use the results of the <link
linkend="function-gdk--gdk-pango-renderer-get-default"><function>gtk.gdk.gdk_pango_renderer_get_default</function>()</link>
function rather than creating a new renderer.</para>

  </refsect1>

  <refsect1>
    <title>Methods</title>

    <refsect2 id="method-gdkpangorenderer--set-drawable">
      <title>gtk.gdk.PangoRenderer.set_drawable</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>set_drawable</methodname>
	  <methodparam><parameter
			 role="keyword">drawable</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">drawable</parameter>&nbsp;:</term>
	  <listitem><simpara>the new target <link
linkend="class-gdkdrawable"><classname>gtk.gdk.Drawable</classname></link> or
          <literal>None</literal>.</simpara></listitem>
	</varlistentry>
      </variablelist>

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

      <para>The <methodname>set_drawable</methodname>() method sets the
<link
linkend="class-gdkdrawable"><classname>gtk.gdk.Drawable</classname></link>
specified by <parameter>drawable</parameter> as the drawable for
rendering.</para>

<para>In PyGTK 2.10, <parameter>drawable</parameter> may be
<literal>None</literal> to unset the drawable.</para>

    </refsect2>

    <refsect2 id="method-gdkpangorenderer--set-gc">
      <title>gtk.gdk.PangoRenderer.set_gc</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>set_gc</methodname>
	  <methodparam><parameter
			 role="keyword">gc</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">gc</parameter>&nbsp;:</term>
	  <listitem><simpara>a <link
linkend="class-gdkgc"><classname>gtk.gdk.GC</classname></link> or
          <literal>None</literal>.</simpara></listitem>
	</varlistentry>
      </variablelist>

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

      <para>The <methodname>set_gc</methodname>() method sets the graphics
context the renderer draws with to the <link
linkend="class-gdkgc"><classname>gtk.gdk.GC</classname></link> specified by
<parameter>gc</parameter>.</para>

<para>In PyGTK 2.10, <parameter>gc</parameter> may be
<literal>None</literal> to unset the gc to use for drawing.</para>

    </refsect2>

    <refsect2 id="method-gdkpangorenderer--set-stipple">
      <title>gtk.gdk.PangoRenderer.set_stipple</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>set_stipple</methodname>
	  <methodparam><parameter
			 role="keyword">part</parameter></methodparam>
	  <methodparam><parameter
			 role="keyword">stipple</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">part</parameter>&nbsp;:</term>
	  <listitem><simpara> the part to render with the
stipple</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter role="keyword">stipple</parameter>&nbsp;:</term>
	  <listitem><simpara> the new stipple bitmap</simpara> or
          <literal>None</literal>.</listitem>
	</varlistentry>
      </variablelist>

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

      <para>The <methodname>set_stipple</methodname>() method sets the
stipple for one render part (foreground, background, underline,
strikethrough) to the bitmap specified by
<parameter>stipple</parameter>. The value of part must be one of the <xref
linkend="pango-render-part-constants"
endterm="pango-render-part-constants-title"></xref>. Note that this is
overwritten when iterating through the individual styled runs of a <link
linkend="class-pangolayout"><classname>pango.Layout</classname></link> or
<link
linkend="class-pangolayoutline"><classname>pango.LayoutLine</classname></link>. This
method is thus only useful when you call low level methods like <link
linkend="method-pangorenderer--draw-glyphs"><methodname>draw_glyphs</methodname>()</link>
directly, or in the 'prepare_run' virtual function of a subclass of <link
linkend="class-gdkpangorenderer"><classname>gtk.gdk.PangoRenderer</classname></link>.</para>

<para>In PyGTK 2.10 <parameter>stipple</parameter> may be set to
<literal>None</literal>.</para>

    </refsect2>

    <refsect2 id="method-gdkpangorenderer--set-override-color">
      <title>gtk.gdk.PangoRenderer.set_override_color</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>set_override_color</methodname>
	  <methodparam><parameter
			 role="keyword">part</parameter></methodparam>
	  <methodparam><parameter
			 role="keyword">color</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">part</parameter>&nbsp;:</term>
	  <listitem><simpara> the part to render with
<parameter>color</parameter></simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter role="keyword">color</parameter>&nbsp;:</term>
	  <listitem><simpara>a <link
linkend="class-gdkcolor"><classname>gtk.gdk.Color</classname></link> or
          <literal>None</literal>.</simpara></listitem>
	</varlistentry>
      </variablelist>

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

      <para>The <methodname>set_override_color</methodname>() method sets
the color for a particular render part (foreground, background, underline,
strikethrough.) to the <link
linkend="class-gdkcolor"><classname>gtk.gdk.Color</classname></link>
specified by <parameter>color</parameter>, overriding any attributes on the
layouts renderered with this renderer.</para>

<para>In PyGTK 2.10 <parameter>color</parameter> may be set to
<literal>None</literal>.</para>

    </refsect2>

  </refsect1>

  <refsect1>
    <title>Functions</title>

    <refsect2 id="function-gdk--gdk-pango-renderer-get-default">
      <title>gtk.gdk.gdk_pango_renderer_get_default</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>gtk.gdk.gdk_pango_renderer_get_default</methodname>
	  <methodparam><parameter
			 role="keyword">screen</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">screen</parameter>&nbsp;:</term>
	  <listitem><simpara>a <link
linkend="class-gdkscreen"><classname>gtk.gdk.Screen</classname></link></simpara></listitem>
	</varlistentry>
	<varlistentry>
	<term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>the default <link
linkend="class-gdkpangorenderer"><classname>gtk.gdk.PangoRenderer</classname></link>
object for <parameter>screen</parameter>.</simpara></listitem>
	</varlistentry>
      </variablelist>

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

      <para>The
<function>gtk.gdk.gdk_pango_renderer_get_default</function>() function
returns the default <link
linkend="class-gdkpangorenderer"><classname>gtk.gdk.PangoRenderer</classname></link>
for the <link
linkend="class-gdkscreen"><classname>gtk.gdk.Screen</classname></link>
specified by <parameter>screen</parameter>. 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 <link
linkend="method-gdkdrawable--draw-layout"><methodname>gtk.gdk.Drawable.draw_layout</methodname>()</link>.</para>

      <para>Before using the renderer, you need to call the <link
linkend="method-gdkpangorenderer--set-drawable"><methodname>set_drawable</methodname>()</link>
and <link
linkend="method-gdkpangorenderer--set-gc"><methodname>set_gc</methodname>()</link>
methods to set the drawable and graphics context to use for drawing.</para>

    </refsect2>

  </refsect1>

</refentry>
