[Gambas-user] Wiki: ScrollArea (gb3)

Benoît Minisini gambas at ...1...
Sun Feb 20 18:58:07 CET 2011


> I fought with this for a while: The wiki says, you have to draw the image
> inside the Draw event handler of ScrollArea. So I did:
> Draw.Image(hImg, 0, 0, Width, Height), where 0,0 is X and Y.
> 
> But when using the ScrollBars, the Drawing event is raised again, and so
> the image is redrawn in the original state. No scrolling ever possible.
> 
> I found a workaround defining X/Y with the scroll positions:
> Draw.Image(hImg, - ScrollArea1.ScrollX, - ScrollArea1.ScrollY, W, H)
> 

It's not a workaround, it's the way it should work.

> This works, but scrolling is quite slow.

An Image is stored in the process memory. So calling Draw.Image needs it to be 
transfered to the X11 server first, which is slow. Use Draw.Picture() instead.

gb.gtk does the following optimization : Image and Picture are actually the 
same internal object. Then it tries to put the image data in memory, or in the 
X11 server according to the method used on the Image or Picture. So, there, 
Draw.Image() will be the first time only. The next time, the image data are 
actually on the X11 server.

So, anyway, use Draw.Picture() to be sure.

-- 
Benoît Minisini




More information about the User mailing list