GtkDrawingArea mouse events



My program has a GtkDrawingArea in a resizable window. The drawing
area needs a 2D array of integers, sized so that there is 1 integer
per pixel. When the user moves his mouse over the DrawingArea, I want
the program status bar to show the value from the array corresponding
to the pixel under the mouse.

I have two questions:
1) I am currently trapping the "configure-event" signal and resizing
the array there. Is this the best approach? In my past life, I used to
program for the Windows API, I'm basically looking for a replacement
for WM_SIZE.
2) I had a bug in my program in which I would occasionally get a mouse
cursor position outside the drawing area (for eg: the last time
configure-event was called, I got a 400x400 window, but I'd get pixel
values of, say, x = 403). I handle these by bounds-checking before I
access the array, but why would I get such values in the first place?
This is why I wonder if trapping "configure-event" was the right thing
to do.

Thanks, all.

-Jim



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