[fxruby-users] Dynamic resize of drawing canvas and FXImage
Jeroen van der Zijp
jeroen at fox-toolkit.org
Fri Feb 8 11:29:40 EST 2008
On Friday 08 February 2008, Lyle Johnson wrote:
> On Feb 8, 2008, at 6:58 AM, Ranieri Teixeira wrote:
> > How can I use the drawing canvas and its off-screen image buffer, say
> > FXImage, to dynamically resize or have its width and height attributes
> > changed in reply to user interaction with the main window
> > (FXMainWindow)?
> > It seems that whem I put initial values to W and H of the canvas or
> > FXImage,
> > they remain with its initial values no matter what I do whem
> > resizing the
> > main window.
> If you want the image to be as large as the canvas, you need to call
> resize() on the image whenever the canvas size changes.
When you manage off-screen FXImage, typically the following steps are
layout() is overloaded to resize the off-screen image if the
widget has changed size.
If the widget has changed size, OR if the content has changed,
it is redrawn.
onPaint() is reimplemented to simply peform a copy-draw of the
image to the widget (e.g. dc.drawImage()). Thus repainting is
Note that the layout() routine is usually called in the following cases:
When the window changed size.
When the window was flagged DIRTY.
It is triggered in response to recalc(). The layout() is not called
immediately, but only when the event stream is empty (it is invoked
by a chore). Thus, as you interactively resize a widget the image
will be resized as fast as possible, but only as fast as the system
can catch up with the event stream.
For reference I refer to the source code for some of the double-buffered
widgets like FXGradientBar or FXChart.
Hope this helps,
More information about the fxruby-users