reposition DrawingArea inside a Scrollbar after enlarging



Hi,

what is the preferred way to reposition a GtkDrawingArea inside a
GtkScrollbar just after the GtkDrawingArea has been enlarged?

In detail: I have a DrawingArea (in Gtk 2.20) that gets now and
then enlarged when new elements are drawn on it. For enlarging it
I use gtk_widget_set_size_request. The DrawingArea sits inside a
Scrollbar. After enlarging the DrawingArea I want to make sure
that the new element that I am drawing in the new region is
visible. I therefore call gtk_adjustment_clamp_page on both
scroll bars with appropriate lower and upper values. I then
call gtk_widget_queue_clear on the DrawingArea and let it redraw
when the exposure event arrives.

The trouble is that the new element is often outside the visible
portion of the DrawingArea. So gtk_adjustment_clamp_page does not
work in this case. AFAICS the problem is that the size
do not change immediately when I call gtk_widget_set_size_request
and therefore the call of gtk_adjustment_clamp_page works with
the old sizes. When the adjustments finally get the new size they
forgot about my clamp_page request and the new region with the
new element in it remains invisible.

When and how should I change the adjustments so that the new
region in the DrawingArea becomes visible?

Using the size-allocate signal does not work, because apparently
it is only emitted if my size request is larger then the current
size.

Changing the adjustment in the handler of the exposure event does
also not work reliably. Sometimes the DrawingArea receives
exposure events before the size has changed. Therefore I would
have to set the adjustment on every exposure event, which would
break the function of the scroll bars.

Bye,

Hendrik



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