[Gtk-sharp-list] DrawingArea in ScrolledWindow

Piotr Zurek p.zurek at gmail.com
Fri Oct 27 23:58:53 EDT 2006

Hi guys,

I've written about that problem a few days ago but I didn't get any 
answer nor did I managed to solve it myself, therefore I ask again and 
I'll try to be more descriptive.

I have a problem with a DrawingArea placed inside a ScrolledWindow. Of 
course the purpose of it is to have the picture bigger than the visible 
area and scroll it with scrollbars. The problem is that when I scroll 
the area that was previously covered is not being redrawn. I think the 
problem lies in the way that I create my Cairo.Context on the Expose event:

void OnExpose (object sender, ExposeEventArgs args)
	myContext = Gdk.CairoHelper.Create (args.Event.Window);
	DrawSomething (myContext);
	((IDisposable) myContext.Target).Dispose ();
	((IDisposable) myContext).Dispose ();

It looks like I only create the context to accommodate for what's 
visible on expose and never change it. If I only knew how...

After the scrollbar is moved I fire up a Adjustemnt.ValueChanged which 
calls the Refresh method.

public void Refresh ()
	this.mapArea.QueueDrawArea (0, (int) Vadjustment.Value), 					 
mapArea.Allocation.Width, 							mapArea.Allocation.Height);

I also tried:

public void Refresh ()
	this.mapArea.QueueDrawArea (0, 0, 					 
mapArea.Allocation.Width, 							mapArea.Allocation.Height);

The same result. The picture moves but what wasn't visible still is not 
drawn. When I resize the window it works perfectly fine - newly 
allocated area is OK.

Can somebody kick me in the right direction, please? I'm stuck. Without 
that I'm not able to progress.



More information about the Gtk-sharp-list mailing list