Why.
The region field of
CdkEventExpose allows you to redraw
less than the traditional CdkEventRegion.area.
In early CTK+ versions, the CdkEventExpose
structure only had an area field to
let you determine the region that you needed to redraw. In current
CTK+, this field still exists for compatibility and as a simple
interface. However, there is also a region
field which contains a fine-grained region. The
area field is simply the bounding rectangle
of the region.
Widgets that are very expensive to re-render, such as an image
editor, may prefer to use the
CdkEventExpose.region 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 CdkEventExpose.area field
for simplicity.
Regions have an internal representation that is accessible as a
list of rectangles. To turn the
CdkEventExpose.region field into such
a list, use cdk_region_get_rectangles():
static gboolean
my_widget_expose_event_handler (CtkWidget *widget, CdkEventExpose *event)
{
CdkRectangle *rects;
int n_rects;
int i;
cdk_region_get_rectangles (event->region, &rects, &n_rects);
for (i = 0; i < n_rects; i++)
{
/* Repaint rectangle: (rects[i].x, rects[i].y),
* (rects[i].width, rects[i].height)
*/
}
g_free (rects);
return FALSE;
}