|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /usr/share/gtk-doc/html/gtk/ |
Upload File : |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>GtkDrawingArea</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.69.1">
<link rel="start" href="index.html" title="GTK+ Reference Manual">
<link rel="up" href="MiscObjects.html" title="Miscellaneous">
<link rel="prev" href="GtkCalendar.html" title="GtkCalendar">
<link rel="next" href="GtkEventBox.html" title="GtkEventBox">
<meta name="generator" content="GTK-Doc V1.6 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="part" href="gtk.html" title="Part I. GTK+ Overview">
<link rel="part" href="gtkbase.html" title="Part II. GTK+ Core Reference">
<link rel="part" href="gtkobjects.html" title="Part III. GTK+ Widgets and Objects">
<link rel="chapter" href="ch01.html" title="Object Hierarchy">
<link rel="chapter" href="ch02.html" title="Widget Gallery">
<link rel="chapter" href="WindowWidgets.html" title="Windows">
<link rel="chapter" href="DisplayWidgets.html" title="Display Widgets">
<link rel="chapter" href="ButtonWidgets.html" title="Buttons and Toggles">
<link rel="chapter" href="NumericEntry.html" title="Numeric/Text Data Entry">
<link rel="chapter" href="TextWidgetObjects.html" title="Multiline Text Editor">
<link rel="chapter" href="TreeWidgetObjects.html" title="Tree, List and Icon Grid Widgets">
<link rel="chapter" href="MenusAndCombos.html" title="Menus, Combo Box, Toolbar">
<link rel="chapter" href="Actions.html" title="Action-based menus and toolbars">
<link rel="chapter" href="SelectorWidgets.html" title="Selectors (File/Font/Color/Input Devices)">
<link rel="chapter" href="LayoutContainers.html" title="Layout Containers">
<link rel="chapter" href="Ornaments.html" title="Ornaments">
<link rel="chapter" href="ScrollingWidgets.html" title="Scrolling">
<link rel="chapter" href="Printing.html" title="Printing">
<link rel="chapter" href="MiscObjects.html" title="Miscellaneous">
<link rel="chapter" href="AbstractObjects.html" title="Abstract Base Classes">
<link rel="chapter" href="PlugSocket.html" title="Cross-process Embedding">
<link rel="chapter" href="SpecialObjects.html" title="Special-purpose features">
<link rel="chapter" href="RecentDocuments.html" title="Recently Used Documents">
<link rel="chapter" href="DeprecatedObjects.html" title="Deprecated">
<link rel="part" href="migrating.html" title="Part IV. Migrating from Previous Versions of GTK+">
<link rel="chapter" href="gtk-migrating-checklist.html" title="Migration Checklist">
<link rel="chapter" href="gtk-migrating-GtkFileChooser.html" title="Migrating from GtkFileSelection to GtkFileChooser">
<link rel="chapter" href="gtk-migrating-GtkAction.html" title="Migrating from old menu and toolbar systems to GtkAction">
<link rel="chapter" href="gtk-migrating-GtkComboBox.html" title="Migrating from GtkOptionMenu and GtkCombo to GtkComboBox and
GtkComboBoxEntry">
<link rel="chapter" href="gtk-migrating-GtkIconView.html" title="Migrating from GnomeIconList to GtkIconView">
<link rel="chapter" href="gtk-migrating-GtkAboutDialog.html" title="Migrating from GnomeAbout to GtkAboutDialog">
<link rel="chapter" href="gtk-migrating-GtkColorButton.html" title="Migrating from GnomeColorPicker to GtkColorButton">
<link rel="chapter" href="gtk-migrating-GtkAssistant.html" title="Migrating from GnomeDruid to GtkAssistant">
<link rel="chapter" href="gtk-migrating-GtkRecentChooser.html" title="Migrating from EggRecent to GtkRecentChooser">
<link rel="chapter" href="gtk-migrating-GtkLinkButton.html" title="Migrating from GnomeHRef to GtkLinkButton">
<link rel="part" href="pt05.html" title="Part V. GTK+ Tools">
<link rel="glossary" href="glossary.html" title="Glossary">
<link rel="index" href="ix01.html" title="Index">
<link rel="index" href="ix02.html" title="Index of deprecated symbols">
<link rel="index" href="ix03.html" title="Index of new symbols in 2.2">
<link rel="index" href="ix04.html" title="Index of new symbols in 2.4">
<link rel="index" href="ix05.html" title="Index of new symbols in 2.6">
<link rel="index" href="ix06.html" title="Index of new symbols in 2.8">
<link rel="index" href="ix07.html" title="Index of new symbols in 2.10">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="GtkCalendar.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="MiscObjects.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GTK+ Reference Manual</th>
<td><a accesskey="n" href="GtkEventBox.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id3602965" class="shortcut">Top</a>
 | 
<a href="#id3603117" class="shortcut">Description</a>
 | 
<a href="#id3603040" class="shortcut">Object Hierarchy</a>
 | 
<a href="#id3603094" class="shortcut">Implemented Interfaces</a></nobr></td></tr>
</table>
<div class="refentry" lang="en">
<a name="GtkDrawingArea"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2>
<a name="id3602965"></a><span class="refentrytitle">GtkDrawingArea</span>
</h2>
<p>GtkDrawingArea — A widget for custom user interface elements</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<h2>Synopsis</h2>
<pre class="synopsis">
#include <gtk/gtk.h>
<a href="GtkDrawingArea.html#GtkDrawingArea-struct">GtkDrawingArea</a>;
<a href="GtkWidget.html" title="GtkWidget">GtkWidget</a>* <a href="GtkDrawingArea.html#gtk-drawing-area-new">gtk_drawing_area_new</a> (void);
void <a href="GtkDrawingArea.html#gtk-drawing-area-size">gtk_drawing_area_size</a> (<a href="GtkDrawingArea.html" title="GtkDrawingArea">GtkDrawingArea</a> *darea,
<a
href="../glib/glib-Basic-Types.html#gint"
>gint</a> width,
<a
href="../glib/glib-Basic-Types.html#gint"
>gint</a> height);
</pre>
</div>
<div class="refsect1" lang="en">
<a name="id3603040"></a><h2>Object Hierarchy</h2>
<pre class="synopsis">
<a
href="../gobject/gobject-The-Base-Object-Type.html#GObject"
>GObject</a>
+----<a
href="../gobject/gobject-The-Base-Object-Type.html#GInitiallyUnowned"
>GInitiallyUnowned</a>
+----<a href="GtkObject.html" title="GtkObject">GtkObject</a>
+----<a href="GtkWidget.html" title="GtkWidget">GtkWidget</a>
+----GtkDrawingArea
+----<a href="GtkCurve.html" title="GtkCurve">GtkCurve</a>
</pre>
</div>
<div class="refsect1" lang="en">
<a name="id3603094"></a><h2>Implemented Interfaces</h2>
<p>
GtkDrawingArea implements
AtkImplementorIface.</p>
</div>
<div class="refsect1" lang="en">
<a name="id3603117"></a><h2>Description</h2>
<p>
The <a href="GtkDrawingArea.html" title="GtkDrawingArea"><span class="type">GtkDrawingArea</span></a> widget is used for creating custom user interface
elements. It's essentially a blank widget; you can draw on
<code class="literal">widget->window</code>. After creating a drawing area,
the application may want to connect to:
</p>
<div class="itemizedlist"><ul type="disc">
<li><p>
Mouse and button press signals to respond to input from
the user. (Use <a href="GtkWidget.html#gtk-widget-add-events"><code class="function">gtk_widget_add_events()</code></a> to enable events
you wish to receive.)
</p></li>
<li><p>
The "realize" signal to take any necessary actions
when the widget is instantiated on a particular display.
(Create GDK resources in response to this signal.)
</p></li>
<li><p>
The "configure_event" signal to take any necessary actions
when the widget changes size.
</p></li>
<li><p>
The "expose_event" signal to handle redrawing the
contents of the widget.
</p></li>
</ul></div>
<p>
</p>
<p>
The following code portion demonstrates using a drawing
area to display a circle in the normal widget foreground
color.
Note that GDK automatically clears the exposed area
to the background color before sending the expose event, and
that drawing is implicitly clipped to the exposed area.
</p>
<div class="example">
<a name="id3603206"></a><p class="title"><b>Example 1. Simple <span class="structname">GtkDrawingArea</span> usage.</b></p>
<pre class="programlisting">
gboolean
expose_event_callback (GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
gdk_draw_arc (widget->window,
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
TRUE,
0, 0, widget->allocation.width, widget->allocation.height,
0, 64 * 360);
return TRUE;
}
[...]
GtkWidget *drawing_area = gtk_drawing_area_new ();
gtk_widget_set_size_request (drawing_area, 100, 100);
g_signal_connect (G_OBJECT (drawing_area), "expose_event",
G_CALLBACK (expose_event_callback), NULL);
</pre>
</div>
<p>
Expose events are normally delivered when a drawing area first comes
onscreen, 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; <a href="GtkWidget.html#gtk-widget-queue-draw-area"><code class="function">gtk_widget_queue_draw_area()</code></a> and
<a
href="../gdk/gdk-Windows.html#gdk-window-invalidate-rect"
><code class="function">gdk_window_invalidate_rect()</code></a> are equally good ways to do this. You'll
then get an expose event for the invalid region.
</p>
<p>
The available routines for drawing are documented on the <a
href="../gdk/gdk-Drawing-Primitives.html"
>GDK Drawing Primitives</a> page.
See also <a
href="../gdk/gdk-Pixbufs.html#gdk-pixbuf-render-to-drawable"
><code class="function">gdk_pixbuf_render_to_drawable()</code></a> for drawing a <a
href="../gdk-pixbuf/gdk-pixbuf-gdk-pixbuf.html#GdkPixbuf"
><span class="type">GdkPixbuf</span></a>.
</p>
<p>
To receive mouse events on a drawing area, you will need to enable
them with <a href="GtkWidget.html#gtk-widget-add-events"><code class="function">gtk_widget_add_events()</code></a>. To receive keyboard events, you
will need to set the <a href="GtkWidget.html#GTK-CAN-FOCUS:CAPS"><span class="type">GTK_CAN_FOCUS</span></a> flag on the drawing area, and
should probably draw some user-visible indication that the drawing
area is focused. Use the <a href="GtkWidget.html#GTK-HAS-FOCUS:CAPS"><code class="function">GTK_HAS_FOCUS()</code></a> macro in your expose event
handler to decide whether to draw the focus indicator. See
<a href="GtkStyle.html#gtk-paint-focus"><code class="function">gtk_paint_focus()</code></a> for one way to draw focus.
</p>
</div>
<div class="refsect1" lang="en">
<a name="id3603355"></a><h2>Details</h2>
<div class="refsect2" lang="en">
<a name="id3603365"></a><h3>
<a name="GtkDrawingArea-struct"></a>GtkDrawingArea</h3>
<a class="indexterm" name="id3603379"></a><pre class="programlisting">typedef struct _GtkDrawingArea GtkDrawingArea;</pre>
<p>
The <a href="GtkDrawingArea.html" title="GtkDrawingArea"><span class="type">GtkDrawingArea</span></a> struct contains private data only, and
should be accessed using the functions below.
</p>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3603404"></a><h3>
<a name="gtk-drawing-area-new"></a>gtk_drawing_area_new ()</h3>
<a class="indexterm" name="id3603417"></a><pre class="programlisting"><a href="GtkWidget.html" title="GtkWidget">GtkWidget</a>* gtk_drawing_area_new (void);</pre>
<p>
Creates a new drawing area.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td>
<span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td>
<td>a new <a href="GtkDrawingArea.html" title="GtkDrawingArea"><span class="type">GtkDrawingArea</span></a>
</td>
</tr></tbody>
</table></div>
</div>
<hr>
<div class="refsect2" lang="en">
<a name="id3603462"></a><h3>
<a name="gtk-drawing-area-size"></a>gtk_drawing_area_size ()</h3>
<a class="indexterm" name="id3603478"></a><pre class="programlisting">void gtk_drawing_area_size (<a href="GtkDrawingArea.html" title="GtkDrawingArea">GtkDrawingArea</a> *darea,
<a
href="../glib/glib-Basic-Types.html#gint"
>gint</a> width,
<a
href="../glib/glib-Basic-Types.html#gint"
>gint</a> height);</pre>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">gtk_drawing_area_size</code> is deprecated and should not be used in newly-written code.</p>
</div>
<p>
(Use <a href="GtkWidget.html#gtk-widget-set-size-request"><code class="function">gtk_widget_set_size_request()</code></a> instead.)
Sets the size that the drawing area will request
in response to a "size_request" signal. The
drawing area may actually be allocated a size
larger than this depending on how it is packed
within the enclosing containers.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td>
<span class="term"><em class="parameter"><code>darea</code></em> :</span></td>
<td>a <a href="GtkDrawingArea.html" title="GtkDrawingArea"><span class="type">GtkDrawingArea</span></a>.
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>width</code></em> :</span></td>
<td>the width to request.
</td>
</tr>
<tr>
<td>
<span class="term"><em class="parameter"><code>height</code></em> :</span></td>
<td>the height to request.
</td>
</tr>
</tbody>
</table></div>
</div>
</div>
<div class="refsect1" lang="en">
<a name="id3603605"></a><h2>See Also</h2>
<p>
Sometimes <a href="GtkImage.html" title="GtkImage"><span class="type">GtkImage</span></a> is a useful alternative to a drawing area.
You can put a <a
href="../gdk/gdk-Bitmaps-and-Pixmaps.html#GdkPixmap"
><span class="type">GdkPixmap</span></a> in the <a href="GtkImage.html" title="GtkImage"><span class="type">GtkImage</span></a> and draw to the <a
href="../gdk/gdk-Bitmaps-and-Pixmaps.html#GdkPixmap"
><span class="type">GdkPixmap</span></a>,
calling <a href="GtkWidget.html#gtk-widget-queue-draw"><code class="function">gtk_widget_queue_draw()</code></a> on the <a href="GtkImage.html" title="GtkImage"><span class="type">GtkImage</span></a> when you want to
refresh to the screen.
</p>
</div>
</div>
</body>
</html>