<?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-gdkrectangle">
  <refnamediv>
    <refname>gtk.gdk.Rectangle</refname>
    <refpurpose>an object holding data about a rectangle</refpurpose>
  </refnamediv>

  <refsect1>
    <title>Synopsis</title>

    <classsynopsis language="python">
      <ooclass><classname>gtk.gdk.Rectangle</classname></ooclass>
      <ooclass><classname>gobject.GBoxed</classname></ooclass>
      <constructorsynopsis language="python">
	<methodname><link
linkend="constructor-gdkrectangle">gtk.gdk.Rectangle</link></methodname>
	<methodparam><parameter
		       role="keyword">x</parameter>
	  <initializer>0</initializer></methodparam>
	<methodparam><parameter
		       role="keyword">y</parameter>
	  <initializer>0</initializer></methodparam>
	<methodparam><parameter
		       role="keyword">width</parameter>
	  <initializer>0</initializer></methodparam>
	<methodparam><parameter
		       role="keyword">height</parameter>
	  <initializer>0</initializer></methodparam>
      </constructorsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gdkrectangle--intersect">intersect</link></methodname>
	<methodparam><parameter
		       role="keyword">src</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link
linkend="method-gdkrectangle--union">union</link></methodname>
	<methodparam><parameter
		       role="keyword">src</parameter></methodparam>
      </methodsynopsis>

    </classsynopsis>

  </refsect1>

  <refsect1>
    <title>Attributes</title>

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

	    <row valign="top">
	      <entry>"x"</entry>
	      <entry>Read-Write</entry>
	      <entry>The X coordinate of the top left corner of the
rectangle.</entry>
	    </row>

	    <row valign="top">
	      <entry>"y"</entry>
	      <entry>Read-Write</entry>
	      <entry>The Y coordinate of the top left corner of the
rectangle.</entry>
	    </row>

	    <row valign="top">
	      <entry>"width"</entry>
	      <entry>Read-Write</entry>
	      <entry>The width of the rectangle.</entry>
	    </row>

	    <row valign="top">
	      <entry>"height"</entry>
	      <entry>Read-Write</entry>
	      <entry>The height of the rectangle.</entry>
	    </row>

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

  </refsect1>

  <refsect1>
    <title>Description</title>

    <para>A <link
linkend="class-gdkrectangle"><classname>gtk.gdk.Rectangle</classname></link>
holds the position and size of a rectangle. The position is specified by the
"x" and "y" attributes and the size, by the "width" and "height"
attributes.</para>

    <para>
      Starting with PyGTK 2.14 <classname>gtk.gdk.Rectangle</classname> objects are
      properly comparable.  By Python rules, rectangles (being mutable) are now
      unhashable.  If you need to use them as dictionary keys, convert rectangle objects
      to tuples first.  You can convert such tuples back
      to <classname>gtk.gdk.Rectangle</classname> using the following code:
    </para>

    <programlisting>
  rectangle = gtk.gdk.Rectangle(*tuple)
    </programlisting>

    <para>
      Also beginning with PyGTK 2.14 <classname>gtk.gdk.Rectangle</classname> objects have
      custom support for <function>repr</function> Python function.  For any rectangle it
      holds that:
    </para>

    <programlisting>
  rectangle == eval(repr(rectangle))
    </programlisting>

  </refsect1>

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

    <programlisting><constructorsynopsis language="python">
	<methodname>gtk.gdk.Rectangle</methodname>
	<methodparam><parameter
		       role="keyword">x</parameter>
	  <initializer>0</initializer></methodparam>
	<methodparam><parameter
		       role="keyword">y</parameter>
	  <initializer>0</initializer></methodparam>
	<methodparam><parameter
		       role="keyword">width</parameter>
	  <initializer>0</initializer></methodparam>
	<methodparam><parameter
		       role="keyword">height</parameter>
	  <initializer>0</initializer></methodparam>
      </constructorsynopsis></programlisting>
    <variablelist>
      <varlistentry>
	<term><parameter role="keyword">x</parameter>&nbsp;:</term>
	<listitem><simpara>the X coordinate of the top left corner of the
rectangle</simpara></listitem>
      </varlistentry>
      <varlistentry>
	<term><parameter role="keyword">y</parameter>&nbsp;:</term>
	<listitem><simpara>the Y coordinate of the top left corner of the
rectangle</simpara></listitem>
      </varlistentry>
      <varlistentry>
	<term><parameter role="keyword">width</parameter>&nbsp;:</term>
	<listitem><simpara>the width of the rectangle</simpara></listitem>
      </varlistentry>
      <varlistentry>
	<term><parameter role="keyword">height</parameter>&nbsp;:</term>
	<listitem><simpara>the height of the rectangle</simpara></listitem>
      </varlistentry>
      <varlistentry>
	<term><emphasis>Returns</emphasis>&nbsp;:</term>
	<listitem><simpara>a new <link
linkend="class-gdkrectangle"><classname>gtk.gdk.Rectangle</classname></link>
object</simpara></listitem>
      </varlistentry>
    </variablelist>

    <para>Creates a new <link
linkend="class-gdkrectangle"><classname>gtk.gdk.Rectangle</classname></link>
with the attributes specified by <parameter>x</parameter>,
<parameter>y</parameter>, <parameter>width</parameter> and
<parameter>height</parameter>. Any unspecified attributes default to
0.</para>

  </refsect1>

  <refsect1>
    <title>Methods</title>

    <refsect2 id="method-gdkrectangle--intersect">
      <title>gtk.gdk.Rectangle.intersect</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>intersect</methodname>
	  <methodparam><parameter
			 role="keyword">src</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">src</parameter>&nbsp;:</term>
	  <listitem><simpara>a <link
linkend="class-gdkrectangle"><classname>gtk.gdk.Rectangle</classname></link>
of a 4-tuple specifying the attributes of a rectangle as (x, y, width,
height)</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a <link
linkend="class-gdkrectangle"><classname>gtk.gdk.Rectangle</classname></link>
that is the intersection of <parameter>src</parameter> and the
rectangle</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>intersect</methodname>() method returns a <link
linkend="class-gdkrectangle"><classname>gtk.gdk.Rectangle</classname></link>
that is the intersection of this rectangle and the <link
linkend="class-gdkrectangle"><classname>gtk.gdk.Rectangle</classname></link>
specified by <parameter>src</parameter>. The value of
<parameter>src</parameter> is either a <link
linkend="class-gdkrectangle"><classname>gtk.gdk.Rectangle</classname></link>
or a 4-tuple containing the position and size of a rectangle. If the
rectangles do not intersect the returned <link
linkend="class-gdkrectangle"><classname>gtk.gdk.Rectangle</classname></link>
will have all attributes set to 0.</para>

    </refsect2>

    <refsect2 id="method-gdkrectangle--union">
      <title>gtk.gdk.Rectangle.union</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>union</methodname>
	  <methodparam><parameter
			 role="keyword">src</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">src</parameter>&nbsp;:</term>
	  <listitem><simpara>a <link
linkend="class-gdkrectangle"><classname>gtk.gdk.Rectangle</classname></link>
of a 4-tuple specifying the attributes of a rectangle as (x, y, width,
height)</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a <link
linkend="class-gdkrectangle"><classname>gtk.gdk.Rectangle</classname></link>
that includes both <parameter>src</parameter> and the
rectangle</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>union</methodname>() method returns a <link
linkend="class-gdkrectangle"><classname>gtk.gdk.Rectangle</classname></link>
that is the smallest rectangle containing both this rectangle and the <link
linkend="class-gdkrectangle"><classname>gtk.gdk.Rectangle</classname></link>
specified by <parameter>src</parameter>. The value of
<parameter>src</parameter> is either a <link
linkend="class-gdkrectangle"><classname>gtk.gdk.Rectangle</classname></link>
or a 4-tuple containing the position and size of a rectangle.</para>

    </refsect2>

  </refsect1>

 </refentry>
