Re: imagmap

The mapping of a coordinate to a callback may be easily done
by creating a so called label image that has the following properties:

  * It has the same size as the image map being displayed
  * For each pixel it contains either 0 if there is no callback
    associated with that pixel or a callback index otherwise.

Since all GdkPixbufs are 24 bits deep it means that you have 2^24-1 
possible callbacks that you may encode in RGB, which should be more
than enough.;-). Note that the label image is never shown to the user.
(There is nothing to show really...)

Once you have the label image you just catch the click callback on the
image map, get its coordinate, lookup the rgb value of the corresponding
pixel on the label image, and then call the callback indexed by



On Sat, Aug 27, 2005 at 08:58:34PM +0200, A. Pagaltzis wrote:
* Gábor Szabó <szabgab gmail com> [2005-08-27 18:25]:
Is there a way to create a clickable imagemap in GTK+
(preferably without Gnome so it can run on Windows as well)

Intercepting clicks on an image requires wrapping a GtkImage in
GtkEventBox and handling the `clicked` signal of the EventBox.

If you don???t have hundreds of different clickable spots and
they???re all rectangular, you could simply use a suitable bunch of

If you have many or non-rectangular clickable areas, you will use
only a single EventBox covering the entire image, and then you
must bust out the math and manually check whether the X/Y
coordinates of the click fell into a clickable area.

There is no easier solution than this.

There should be, really, since it???s useful enough and requested
frequently enough that having a stock tool for this in the box
would be nice.

Aristotle Pagaltzis // <>
gtk-perl-list mailing list
gtk-perl-list gnome org

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