<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
               "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
<!ENTITY % local.common.attrib "xmlns:xi  CDATA  #FIXED 'http://www.w3.org/2003/XInclude'">
<!ENTITY version SYSTEM "version.xml">
]>
<!--ENTITY index-Objects-Grouped SYSTEM "objects_grouped.sgml"-->
<refentry id="GtkPrintContext">
<refmeta>
<refentrytitle role="top_of_page" id="GtkPrintContext.top_of_page">GtkPrintContext</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GTK Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>GtkPrintContext</refname>
<refpurpose>Encapsulates context for drawing pages</refpurpose>
</refnamediv>

<refsynopsisdiv id="GtkPrintContext.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>

#include &lt;gtk/gtk.h&gt;

                    <link linkend="GtkPrintContext-struct">GtkPrintContext</link>;
<link linkend="cairo-t">cairo_t</link> *           <link linkend="gtk-print-context-get-cairo-context">gtk_print_context_get_cairo_context</link> (<link linkend="GtkPrintContext">GtkPrintContext</link> *context);
<link linkend="void">void</link>                <link linkend="gtk-print-context-set-cairo-context">gtk_print_context_set_cairo_context</link> (<link linkend="GtkPrintContext">GtkPrintContext</link> *context,
                                                         <link linkend="cairo-t">cairo_t</link> *cr,
                                                         <link linkend="double">double</link> dpi_x,
                                                         <link linkend="double">double</link> dpi_y);
<link linkend="GtkPageSetup">GtkPageSetup</link> *      <link linkend="gtk-print-context-get-page-setup">gtk_print_context_get_page_setup</link>    (<link linkend="GtkPrintContext">GtkPrintContext</link> *context);
<link linkend="gdouble">gdouble</link>             <link linkend="gtk-print-context-get-width">gtk_print_context_get_width</link>         (<link linkend="GtkPrintContext">GtkPrintContext</link> *context);
<link linkend="gdouble">gdouble</link>             <link linkend="gtk-print-context-get-height">gtk_print_context_get_height</link>        (<link linkend="GtkPrintContext">GtkPrintContext</link> *context);
<link linkend="gdouble">gdouble</link>             <link linkend="gtk-print-context-get-dpi-x">gtk_print_context_get_dpi_x</link>         (<link linkend="GtkPrintContext">GtkPrintContext</link> *context);
<link linkend="gdouble">gdouble</link>             <link linkend="gtk-print-context-get-dpi-y">gtk_print_context_get_dpi_y</link>         (<link linkend="GtkPrintContext">GtkPrintContext</link> *context);
<link linkend="PangoFontMap">PangoFontMap</link> *      <link linkend="gtk-print-context-get-pango-fontmap">gtk_print_context_get_pango_fontmap</link> (<link linkend="GtkPrintContext">GtkPrintContext</link> *context);
<link linkend="PangoContext">PangoContext</link> *      <link linkend="gtk-print-context-create-pango-context">gtk_print_context_create_pango_context</link>
                                                        (<link linkend="GtkPrintContext">GtkPrintContext</link> *context);
<link linkend="PangoLayout">PangoLayout</link> *       <link linkend="gtk-print-context-create-pango-layout">gtk_print_context_create_pango_layout</link>
                                                        (<link linkend="GtkPrintContext">GtkPrintContext</link> *context);
</synopsis>
</refsynopsisdiv>

<refsect1 id="GtkPrintContext.object-hierarchy" role="object_hierarchy">
<title role="object_hierarchy.title">Object Hierarchy</title>
<synopsis>
  <link linkend="GObject">GObject</link>
   +----GtkPrintContext
</synopsis>
</refsect1>








<refsect1 id="GtkPrintContext.description" role="desc">
<title role="desc.title">Description</title>
<para>
A GtkPrintContext encapsulates context information that is required when
drawing pages for printing, such as the cairo context and important
parameters like page size and resolution. It also lets you easily
create <link linkend="PangoLayout"><type>PangoLayout</type></link> and <link linkend="PangoContext"><type>PangoContext</type></link> objects that match the font metrics
of the cairo surface.
</para>
<para>
GtkPrintContext objects gets passed to the ::begin-print, ::end-print,
::request-page-setup and ::draw-page signals on the <link linkend="GtkPrintOperation"><type>GtkPrintOperation</type></link>.
</para>
<example>
<title>Using GtkPrintContext in a ::draw-page callback</title>
<programlisting>
static void
draw_page (GtkPrintOperation *operation,
	   GtkPrintContext   *context,
	   int                page_nr)
{
  cairo_t *cr;
  PangoLayout *layout;
  PangoFontDescription *desc;
  cr = gtk_print_context_get_cairo_context (context);
  /* Draw a red rectangle, as wide as the paper (inside the margins) */
  cairo_set_source_rgb (cr, 1.0, 0, 0);
  cairo_rectangle (cr, 0, 0, gtk_print_context_get_width (context), 50);
  cairo_fill (cr);
  /* Draw some lines */
  cairo_move_to (cr, 20, 10);
  cairo_line_to (cr, 40, 20);
  cairo_arc (cr, 60, 60, 20, 0, M_PI);
  cairo_line_to (cr, 80, 20);
  cairo_set_source_rgb (cr, 0, 0, 0);
  cairo_set_line_width (cr, 5);
  cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
  cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
  cairo_stroke (cr);
  /* Draw some text */
  layout = gtk_print_context_create_layout (context);
  pango_layout_set_text (layout, "Hello World! Printing is easy", -1);
  desc = pango_font_description_from_string ("sans 28");
  pango_layout_set_font_description (layout, desc);
  pango_font_description_free (desc);
  cairo_move_to (cr, 30, 20);
  pango_cairo_layout_path (cr, layout);
  /* Font Outline */
  cairo_set_source_rgb (cr, 0.93, 1.0, 0.47);
  cairo_set_line_width (cr, 0.5);
  cairo_stroke_preserve (cr);
  /* Font Fill */
  cairo_set_source_rgb (cr, 0, 0.0, 1.0);
  cairo_fill (cr);
  g_object_unref (layout);
}
</programlisting>
</example>
<para>
Printing support was added in GTK+ 2.10.
</para>
</refsect1>

<refsect1 id="GtkPrintContext.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="GtkPrintContext-struct" role="struct">
<title>GtkPrintContext</title>
<indexterm zone="GtkPrintContext-struct"><primary sortas="PrintContext">GtkPrintContext</primary></indexterm><programlisting>typedef struct _GtkPrintContext GtkPrintContext;</programlisting>
<para>
</para></refsect2>
<refsect2 id="gtk-print-context-get-cairo-context" role="function" condition="since:2.10">
<title>gtk_print_context_get_cairo_context ()</title>
<indexterm zone="gtk-print-context-get-cairo-context" role="2.10"><primary sortas="print_context_get_cairo_context">gtk_print_context_get_cairo_context</primary></indexterm><programlisting><link linkend="cairo-t">cairo_t</link> *           gtk_print_context_get_cairo_context (<link linkend="GtkPrintContext">GtkPrintContext</link> *context);</programlisting>
<para>
Obtains the cairo context that is associated with the
<link linkend="GtkPrintContext"><type>GtkPrintContext</type></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GtkPrintContext"><type>GtkPrintContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the cairo context of <parameter>context</parameter>

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.10</para></refsect2>
<refsect2 id="gtk-print-context-set-cairo-context" role="function" condition="since:2.10">
<title>gtk_print_context_set_cairo_context ()</title>
<indexterm zone="gtk-print-context-set-cairo-context" role="2.10"><primary sortas="print_context_set_cairo_context">gtk_print_context_set_cairo_context</primary></indexterm><programlisting><link linkend="void">void</link>                gtk_print_context_set_cairo_context (<link linkend="GtkPrintContext">GtkPrintContext</link> *context,
                                                         <link linkend="cairo-t">cairo_t</link> *cr,
                                                         <link linkend="double">double</link> dpi_x,
                                                         <link linkend="double">double</link> dpi_y);</programlisting>
<para>
Sets a new cairo context on a print context. 
</para>
<para>
This function is intended to be used when implementing
an internal print preview, it is not needed for printing,
since GTK+ itself creates a suitable cairo context in that
case.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GtkPrintContext"><type>GtkPrintContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>cr</parameter>&#160;:</term>
<listitem><simpara> the cairo context
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dpi_x</parameter>&#160;:</term>
<listitem><simpara> the horizontal resolution to use with <parameter>cr</parameter>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>dpi_y</parameter>&#160;:</term>
<listitem><simpara> the vertical resolution to use with <parameter>cr</parameter>
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.10</para></refsect2>
<refsect2 id="gtk-print-context-get-page-setup" role="function" condition="since:2.10">
<title>gtk_print_context_get_page_setup ()</title>
<indexterm zone="gtk-print-context-get-page-setup" role="2.10"><primary sortas="print_context_get_page_setup">gtk_print_context_get_page_setup</primary></indexterm><programlisting><link linkend="GtkPageSetup">GtkPageSetup</link> *      gtk_print_context_get_page_setup    (<link linkend="GtkPrintContext">GtkPrintContext</link> *context);</programlisting>
<para>
Obtains the <link linkend="GtkPageSetup"><type>GtkPageSetup</type></link> that determines the page
dimensions of the <link linkend="GtkPrintContext"><type>GtkPrintContext</type></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GtkPrintContext"><type>GtkPrintContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the page setup of <parameter>context</parameter>

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.10</para></refsect2>
<refsect2 id="gtk-print-context-get-width" role="function" condition="since:2.10">
<title>gtk_print_context_get_width ()</title>
<indexterm zone="gtk-print-context-get-width" role="2.10"><primary sortas="print_context_get_width">gtk_print_context_get_width</primary></indexterm><programlisting><link linkend="gdouble">gdouble</link>             gtk_print_context_get_width         (<link linkend="GtkPrintContext">GtkPrintContext</link> *context);</programlisting>
<para>
Obtains the width of the <link linkend="GtkPrintContext"><type>GtkPrintContext</type></link>, in pixels.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GtkPrintContext"><type>GtkPrintContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the width of <parameter>context</parameter>

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.10</para></refsect2>
<refsect2 id="gtk-print-context-get-height" role="function" condition="since:2.10">
<title>gtk_print_context_get_height ()</title>
<indexterm zone="gtk-print-context-get-height" role="2.10"><primary sortas="print_context_get_height">gtk_print_context_get_height</primary></indexterm><programlisting><link linkend="gdouble">gdouble</link>             gtk_print_context_get_height        (<link linkend="GtkPrintContext">GtkPrintContext</link> *context);</programlisting>
<para>
Obtains the height of the <link linkend="GtkPrintContext"><type>GtkPrintContext</type></link>, in pixels.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GtkPrintContext"><type>GtkPrintContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the height of <parameter>context</parameter>

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.10</para></refsect2>
<refsect2 id="gtk-print-context-get-dpi-x" role="function" condition="since:2.10">
<title>gtk_print_context_get_dpi_x ()</title>
<indexterm zone="gtk-print-context-get-dpi-x" role="2.10"><primary sortas="print_context_get_dpi_x">gtk_print_context_get_dpi_x</primary></indexterm><programlisting><link linkend="gdouble">gdouble</link>             gtk_print_context_get_dpi_x         (<link linkend="GtkPrintContext">GtkPrintContext</link> *context);</programlisting>
<para>
Obtains the horizontal resolution of the <link linkend="GtkPrintContext"><type>GtkPrintContext</type></link>,
in dots per inch.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GtkPrintContext"><type>GtkPrintContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the horizontal resolution of <parameter>context</parameter>

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.10</para></refsect2>
<refsect2 id="gtk-print-context-get-dpi-y" role="function" condition="since:2.10">
<title>gtk_print_context_get_dpi_y ()</title>
<indexterm zone="gtk-print-context-get-dpi-y" role="2.10"><primary sortas="print_context_get_dpi_y">gtk_print_context_get_dpi_y</primary></indexterm><programlisting><link linkend="gdouble">gdouble</link>             gtk_print_context_get_dpi_y         (<link linkend="GtkPrintContext">GtkPrintContext</link> *context);</programlisting>
<para>
Obtains the vertical resolution of the <link linkend="GtkPrintContext"><type>GtkPrintContext</type></link>,
in dots per inch.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GtkPrintContext"><type>GtkPrintContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the vertical resolution of <parameter>context</parameter>

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.10</para></refsect2>
<refsect2 id="gtk-print-context-get-pango-fontmap" role="function" condition="since:2.10">
<title>gtk_print_context_get_pango_fontmap ()</title>
<indexterm zone="gtk-print-context-get-pango-fontmap" role="2.10"><primary sortas="print_context_get_pango_fontmap">gtk_print_context_get_pango_fontmap</primary></indexterm><programlisting><link linkend="PangoFontMap">PangoFontMap</link> *      gtk_print_context_get_pango_fontmap (<link linkend="GtkPrintContext">GtkPrintContext</link> *context);</programlisting>
<para>
Returns a <link linkend="PangoFontMap"><type>PangoFontMap</type></link> that is suitable for use 
with the <link linkend="GtkPrintContext"><type>GtkPrintContext</type></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GtkPrintContext"><type>GtkPrintContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the font map of <parameter>context</parameter>

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.10</para></refsect2>
<refsect2 id="gtk-print-context-create-pango-context" role="function" condition="since:2.10">
<title>gtk_print_context_create_pango_context ()</title>
<indexterm zone="gtk-print-context-create-pango-context" role="2.10"><primary sortas="print_context_create_pango_context">gtk_print_context_create_pango_context</primary></indexterm><programlisting><link linkend="PangoContext">PangoContext</link> *      gtk_print_context_create_pango_context
                                                        (<link linkend="GtkPrintContext">GtkPrintContext</link> *context);</programlisting>
<para>
Creates a new <link linkend="PangoContext"><type>PangoContext</type></link> that can be used with the
<link linkend="GtkPrintContext"><type>GtkPrintContext</type></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GtkPrintContext"><type>GtkPrintContext</type></link> 
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a new Pango context for <parameter>context</parameter>

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.10</para></refsect2>
<refsect2 id="gtk-print-context-create-pango-layout" role="function" condition="since:2.10">
<title>gtk_print_context_create_pango_layout ()</title>
<indexterm zone="gtk-print-context-create-pango-layout" role="2.10"><primary sortas="print_context_create_pango_layout">gtk_print_context_create_pango_layout</primary></indexterm><programlisting><link linkend="PangoLayout">PangoLayout</link> *       gtk_print_context_create_pango_layout
                                                        (<link linkend="GtkPrintContext">GtkPrintContext</link> *context);</programlisting>
<para>
Creates a new <link linkend="PangoLayout"><type>PangoLayout</type></link> that is suitable for use
with the <link linkend="GtkPrintContext"><type>GtkPrintContext</type></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>context</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GtkPrintContext"><type>GtkPrintContext</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> a new Pango layout for <parameter>context</parameter>

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.10</para></refsect2>

</refsect1>




</refentry>
