[fxruby-users] dynamically resizing a window
Jeroen van der Zijp
jeroen at fox-toolkit.org
Tue Sep 15 17:34:19 EDT 2009
On Tuesday 15 September 2009, Eric Hutton wrote:
> Is there a way to dynamically resize a window in response to dynamically
> added content?
> Take the "dynamic.rb" example from Lyle's Create Lean and Mean GUIs book,
> after hitting the add row button a number of times, the added rows extend
> beyond the bottom of the window. Is there a way to get the window to try
> and resize itself according to the dynamically added content? I messed
> around with .layout and .repaint, but to no effect.
The steps should be roughly as follows:
1) change the contents of the window (dialog box or toplevel window).
2) compute the new size, based on layout parameters and sizes of the
widgets; use the topwindow's getDefaultWidth() and getDefaultHeight()
3) Change the toplevel window's size according to the values computed
in step 2, calling resize() on the topwindow. Note, the borders will
be added by the interface between FOX and your windowmanager.
The resize() will lead to a new call to layout(), since the window will have changed
size. This will also result in a bunch of repaint messages which your program must
be allowed to handle before the window will be properly drawn to the screen.
Hope this helps,
Footnote: the size computed by getDefaultWidth() and getDefaultHeight() will be the
minimum fit of the window around its contents.
More information about the fxruby-users