summaryrefslogtreecommitdiff
path: root/docs/reference/pygtk-gtkdrawingarea.xml
blob: bf3ea5d470795e0569e43097431213a9ab794a0d (plain)
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
<?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-gtkdrawingarea">
  <refnamediv>
    <refname>gtk.DrawingArea</refname>
    <refpurpose>a widget for custom user interface elements.</refpurpose>
  </refnamediv>

  <refsect1>
    <title>Synopsis</title>

    <classsynopsis language="python">
      <ooclass><classname>gtk.DrawingArea</classname></ooclass>
      <ooclass><classname><link
linkend="class-gtkwidget">gtk.Widget</link></classname></ooclass>
      <constructorsynopsis language="python">
	<methodname><link
linkend="constructor-gtkdrawingarea">gtk.DrawingArea</link></methodname>
	<methodparam></methodparam>  </constructorsynopsis>
    </classsynopsis>

  </refsect1>

  <refsect1>
    <title>Ancestry</title>

<synopsis>+-- <link linkend="class-gobject">gobject.GObject</link>
  +-- <link linkend="class-gtkobject">gtk.Object</link>
    +-- <link linkend="class-gtkwidget">gtk.Widget</link>
      +-- <link linkend="class-gtkdrawingarea">gtk.DrawingArea</link>
</synopsis>

  </refsect1>
  
  <refsect1>
		<title>Implemented Interfaces</title>
		<para>
			<link linkend="class-gtkdrawingarea"><classname>gtk.DrawingArea</classname></link>
			implements 
			<link linkend="class-gtkbuildable"><classname>gtk.Buildable</classname></link>
		</para>
	</refsect1>

  <refsect1 id="properties-gtkdrawingarea">
    <title>gtk.DrawingArea Properties</title>

    <para><link linkend="properties-gtkobject">gtk.Object Properties</link></para>
    <para><link linkend="properties-gtkwidget">gtk.Widget Properties</link></para>

  </refsect1>

  <refsect1 id="style-properties-gtkdrawingarea">
    <title>gtk.DrawingArea Style Properties</title>

    <para><link linkend="style-properties-gtkwidget">gtk.Widget Style Properties</link></para>

  </refsect1>

  <refsect1 id="signal-prototypes-gtkdrawingarea">
    <title>gtk.DrawingArea Signal Prototypes</title>

    <para><link linkend="signal-prototypes-gobject">gobject.GObject Signal Prototypes</link></para>
    <para><link linkend="signal-prototypes-gtkobject">gtk.Object Signal Prototypes</link></para>
    <para><link linkend="signal-prototypes-gtkwidget">gtk.Widget Signal Prototypes</link></para>
</refsect1>

  <refsect1>
    <title>Description</title>

    <para>The <link
linkend="class-gtkdrawingarea"><classname>gtk.DrawingArea</classname></link>
widget is used for creating custom user interface elements. It's essentially
a blank widget containing a <link
linkend="class-gdkwindow"><classname>gtk.gdk.Window</classname></link> that
you can draw on. The contained <link
linkend="class-gdkwindow"><classname>gtk.gdk.Window</classname></link> is
accessed using the <link
linkend="class-gtkwidget"><classname>gtk.Widget</classname></link> "window"
attribute as:</para>

    <programlisting>
  gdkwindow = drawingarea.window
</programlisting>

    <para>Since a <link
    linkend="class-gdkwindow"><classname>gtk.gdk.Window</classname></link>
    is a subclass of <link
    linkend="class-gdkdrawable"><classname>gtk.gdk.Drawable</classname></link>,
    all of the <link
    linkend="class-gdkdrawable"><classname>gtk.gdk.Drawable</classname></link>
    methods are available for drawing on the <link
    linkend="class-gtkdrawingarea"><classname>gtk.DrawingArea</classname></link>'s
    gdkwindow.</para>

    <para>After creating a drawing area, the application may want to
connect to:</para>

    <itemizedlist>
      <listitem>
	<para>Mouse and button press signals to respond to input from the
user. Use the <link
linkend="method-gtkwidget--add-events"><methodname>gtk.Widget.add_events</methodname>()</link>
method to enable events you wish to receive. To receive keyboard events, you
will need to set the <literal>gtk.CAN_FOCUS</literal> flag on the drawing
area</para>
      </listitem>

      <listitem>
	<para>The "realize" signal to take any necessary actions when the
widget is instantiated on a particular display.</para>
      </listitem>

      <listitem>
	<para>The "configure_event" signal to take any necessary actions
when the widget changes size.</para>
      </listitem>

      <listitem>
	<para>The "expose_event" signal to handle redrawing the contents of
the widget when a drawing area first comes on screen, or when it's covered by
another window and then uncovered (exposed). You can also force an expose
event by adding to the "damage region" of the drawing area's window using
the <link
linkend="method-gtkwidget--queue-draw-area"><methodname>gtk.Widget.queue_draw_area</methodname>()</link>
method.</para>
      </listitem>
    </itemizedlist>

    <para>See the <ulink
url="http://www.pygtk.org/pygtk2tutorial/ch-DrawingArea.html">Drawing
Area</ulink> chapter in the tutorial for more information on using a <link
linkend="class-gtkdrawingarea"><classname>gtk.DrawingArea</classname></link>.</para>

    <para>Sometimes a <link
linkend="class-gtkimage"><classname>gtk.Image</classname></link> is a useful
alternative to a drawing area. You can put a <link
linkend="class-gdkpixmap"><classname>gtk.gdk.Pixmap</classname></link> in
the <link linkend="class-gtkimage"><classname>gtk.Image</classname></link>
and draw to the <link
linkend="class-gdkpixmap"><classname>gtk.gdk.Pixmap</classname></link>,
calling the <link
linkend="method-gtkwidget--queue-draw"><methodname>gtk.Widget.queue_draw</methodname>()</link>
method on the <link
linkend="class-gtkimage"><classname>gtk.Image</classname></link> when you
want to refresh to the screen.</para>

  </refsect1>

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

    <programlisting><constructorsynopsis language="python">
	<methodname>gtk.DrawingArea</methodname>
	<methodparam></methodparam>  </constructorsynopsis></programlisting>
    <variablelist>
      <varlistentry>
	<term><emphasis>Returns</emphasis>&nbsp;:</term>
	<listitem><simpara>a new drawingarea widget</simpara></listitem>
      </varlistentry>
    </variablelist>

    <para>Creates a new <link
linkend="class-gtkdrawingarea"><classname>gtk.DrawingArea</classname></link>
widget.</para>

  </refsect1>

</refentry>