Playing with GtkLayout
Programming Gtk+ can be fun, but sometimes you need some magic
tricks. Like when you want to put out items, the user should be
able to move. A GtkLayout allows you to place GtkWidgets with
total freedom, but in general it stops there. The main usage is
probably to emulate how things works with win32-controls etc. for
projects like Lazarus/Free Pascal (Delphi clone, allowing delphi
source code to be compiled for other OS'es).
First you have to enable the needed events in the GtkLayout (mouse clicks,
and mouse moves). It will not be possible to see the events for widgets that
swallows them, like buttons, but if the button is places within a frame, it
should be possible to move it, dragging the frame.
Bézier curve and Gtk+ 2.0
Old versions of Gtk+ 2.0 can't nativly draw bézier curves. So I then
took maters into my own hands. Later I learned that cairo has this implemented,
but it is named cairo_curve_to, not mentioning bézier anywhere.
The animation provided here is inspired from
wikipedia. Later I
have used the same code detecting distance between mouse-clicks and bézier
curves, since I have verified that the lines drawned are the same (cubic version).