Widget offset




I have an GtkImage in a GtkEventBox.  The event box is in a
GtkScrolledWindow via a viewport.  When the scrolled window is expanded
larger than the image, the image is centered in the window, with a gray
background around it.

I want to report to the user the mouse position relative to the corner of
the image by connecting to a motion_notify_event.

The event box fills all the area that the scrolled window allocates to it.
So, I seem to have two options:

1) Find out the offset of the actual displayed image relative to the event
box, and then subtract this from the event coordinates.
2) Keep the event box from filling the viewport.

For option 1, I tried printing out the allocation.x, allocation.y fields
of all widgets up the parent tree, beginning with the image, but they are
all zero.  The GTK_MISC(my_image)->xpad/ypad fields are also zero.

I don't know how to implement option 2.

Any help sincerely appreciated.

--josh

----------------------------------------------------------------
                       Joshua Richardson
Dept. Cognitive and Neural Systems / Center for Adaptive Systems
                       Boston University
----------------------------------------------------------------

scrngrab.jpg



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