Ranieri Teixeira
2008-Feb-08 12:58 UTC
[fxruby-users] Dynamic resize of drawing canvas and FXImage
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. -- Ranieri Barros Teixeira Ci?ncia da Computa??o - Faculdade de Computa??o - Universidade Federal do Par? (UFPA) http://rubyxchart.rubyforge.org http://rubytags.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/fxruby-users/attachments/20080208/7785edb8/attachment.html
Lyle Johnson
2008-Feb-08 15:28 UTC
[fxruby-users] Dynamic resize of drawing canvas and FXImage
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.
Jeroen van der Zijp
2008-Feb-08 16:29 UTC
[fxruby-users] Dynamic resize of drawing canvas and FXImage
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 performed: 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 very fast. 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, - Jeroen