gboolean box_expose(GtkWidget *wi, GdkEventExpose *ev, gpointer data)
{
cairo_t *cr;
// create a cairo context //
cr = gdk_cairo_create(wi->window);
double x0 = wi->allocation.x;
double y0 = wi->allocation.y;
double rect_width = wi->allocation.width;
double rect_height = wi->allocation.height;
cairo_rectangle (cr, x0,y0,rect_width,rect_height+3);
cairo_set_source_rgba (cr, 0, 0, 0, 0.5); // a set the opacity
level
cairo_fill (cr);
cairo_destroy(cr);
}
draw a transparent black rectangle to the calling widget.
You can connect it with to make sure it will redraw when needed.
g_signal_connect(widget, "expose-event", G_CALLBACK(box_expose), NULL);
more examples you could found here
http://cairographics.org/samples/
regards hermann
Am Montag, den 28.12.2009, 04:30 +1100 schrieb Patrick Shirkey:
Hi,
Does anyone have an example in c of drawing a gdk_rectangle with opacity
in the foreground color?
There's several examples in python floating around that use the cairo
but I can't find a nice example in c.
Cheers.