Re: gtk+2 drawing on top of widgets



>> I have a window with some widgets inside and I would like to draw on top
>> of these widgets.
>
>There is basically no supported way to do this - no one has thought
>about how it would work at all. So don't be surprised if it's
>impossible or difficult - but maybe you can figure out some hack. ;-)

i wrote a widget called GtkTransparency that uses shape masks and
double buffering to do precisely this. the model was of one those
clear plastic sheets you use with an overhead projector. you draw a
bunch of things on it, then "project" them. the widget is opaque only
where it was actually drawn upon. it was written for GTK+ 1.[0-2]. 
it worked by providing a complete set of GDK functions for drawing
into the window to replace the standard ones, each of which generated
shape masks etc. the result was quite nice. i used it to draw complex
elliptical curves representing patch cords on a modular
synthesizer.

however, since then i have become enamored with the Canvas object that
is sort of part of GNOME, sort of part of GTK+. i don't think i would
bother with the stuff i did for GtkTransparency if i was trying to do
this again (which in fact, i soon will be). the Canvas is much nicer
(and much faster) for this sort of thing, as Owen and others advised
me at the time. these days it seems to me a shame that the whole of
GTK+ was not built around the Canvas, rather it just being another
widget (inheriting from GtkLayout, in fact) ...

if you are already using GTK+ 1.3/2.0, using the GnomeCanvas is a snap
- it has no other GNOME dependencies except libart_lgpl.

---p



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]