Re: GtkDrawingArea mouse events



Jim George wrote:
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

Jim,

I implemented something similar for picking purpose. For your questions,
I'll let you know what I did :

1) used the "expose" event, don't know if this is better than your
"configure-event" but it works
2) I got the same problem and cropped the values

This is perfect for what I had to do.

Best regards,
Yann



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