File: checklist-gdkeventexpose-region.html

package info (click to toggle)
gtk%2B2.0 2.24.33-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie, trixie-proposed-updates, trixie-updates
  • size: 124,860 kB
  • sloc: ansic: 574,091; makefile: 5,171; sh: 4,618; xml: 1,193; python: 1,117; perl: 749; awk: 49; cpp: 34
file content (83 lines) | stat: -rw-r--r-- 3,966 bytes parent folder | download | duplicates (3)
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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Use GdkEventExpose.region: GTK+ 2 Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="index.html" title="GTK+ 2 Reference Manual">
<link rel="up" href="gtk-migrating-checklist.html" title="Migration Checklist">
<link rel="prev" href="gtk-migrating-checklist.html" title="Migration Checklist">
<link rel="next" href="checklist-modifiers.html" title="Test for modifier keys correctly">
<meta name="generator" content="GTK-Doc V1.33.0 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</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="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="gtk-migrating-checklist.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="gtk-migrating-checklist.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="checklist-modifiers.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="checklist-gdkeventexpose-region"></a>Use GdkEventExpose.region</h2></div></div></div>
<p><b>Why. </b>
	The <em class="structfield"><code>region</code></em> field of
	<span class="structname">GdkEventExpose</span> allows you to redraw
	less than the traditional
	<em class="structfield"><code>GdkEventRegion.area</code></em>.
      </p>
<p>
      In GTK+ 1.x, the <span class="structname">GdkEventExpose</span>
      structure only had an <em class="structfield"><code>area</code></em> field to
      let you determine the region that you needed to redraw.  In GTK+
      2.x, this field exists for compatibility and as a simple
      interface.  However, there is also a
      <em class="structfield"><code>region</code></em> field which contains a
      fine-grained region.  The <em class="structfield"><code>area</code></em> field
      is simply the bounding rectangle of the
      <em class="structfield"><code>region</code></em>.
    </p>
<p>
      Widgets that are very expensive to re-render, such as an image
      editor, may prefer to use the
      <em class="structfield"><code>GdkEventExpose.region</code></em> field to paint
      as little as possible.  Widgets that just use a few drawing
      primitives, such as labels and buttons, may prefer to use the
      traditional <em class="structfield"><code>GdkEventExpose.area</code></em> field
      for simplicity.
    </p>
<p>
      Regions have an internal representation that is accessible as a
      list of rectangles.  To turn the 
      <em class="structfield"><code>GdkEventExpose.region</code></em> field into such
      a list, use <a href="../html/gdk2-Points-Rectangles-and-Regions.html#gdk-region-get-rectangles"><code class="function">gdk_region_get_rectangles()</code></a>:
    </p>
<a name="gdkregion-get-rectangles"></a><pre class="programlisting">
static gboolean
my_widget_expose_event_handler (GtkWidget *widget, GdkEventExpose *event)
{
  GdkRectangle *rects;
  int n_rects;
  int i;

  gdk_region_get_rectangles (event-&gt;region, &amp;rects, &amp;n_rects);

  for (i = 0; i &lt; n_rects; i++)
    {
      /* Repaint rectangle: (rects[i].x, rects[i].y), 
       *                    (rects[i].width, rects[i].height)
       */
    }

  g_free (rects);

  return FALSE;
}
    </pre>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.33.0</div>
</body>
</html>