|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
dynamically resizing a windowIs 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. Regards, Eric. _______________________________________________ fxruby-users mailing list fxruby-users@... http://rubyforge.org/mailman/listinfo/fxruby-users |
|
|
Re: dynamically resizing a windowOn Tue, Sep 15, 2009 at 10:37 PM, Eric Hutton <eric.hutton@...> wrote: Is there a way to dynamically resize a window in response to dynamically added content? here is a small snippet that should do the trick for most layouts: # Free packing extension for fxruby. Copyright (c) 2006, henon <meinrad.recheis@...> module Fox::Packing attr_accessor :dont_pack def pack w, h = self.width, self.height w, h = get_packedsize unless @dont_pack rw = self.getRoot.width - 40 rh = self.getRoot.height - 80 w = rw if w > rw h = rh if h > rh self.resize(w, h) end def get_packedsize return self.maxChildWidth + xpadding, self.maxChildHeight + ypadding end def xpadding 4 end def ypadding 4 end end class Fox::FXTopWindow include Fox::Packing def xpadding self.padLeft+self.padRight end def ypadding self.padTop+self.padBottom end end class Fox::FXPopup include Fox::Packing end class Fox::FXScrollWindow def getDefaultWidth self.maxChildWidth end def getDefaultHeight self.maxChildHeight end end require this code snippet and call #pack on your top level window to resize it to its content. it is provided AS IS, WITHOUT ANY WARRANTY ... blah bla :) this is pasted out from one of my older applicatios, hope it does still work. hth, -- henon Git# --> Git for .NET _______________________________________________ fxruby-users mailing list fxruby-users@... http://rubyforge.org/mailman/listinfo/fxruby-users |
|
|
Re: dynamically resizing a windowOn 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() See footnote. 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, - Jeroen Footnote: the size computed by getDefaultWidth() and getDefaultHeight() will be the minimum fit of the window around its contents. _______________________________________________ fxruby-users mailing list fxruby-users@... http://rubyforge.org/mailman/listinfo/fxruby-users |
|
|
Re: dynamically resizing a windowThanks guys! Both good tips. I figured it would involve manually determining the size of the new window and then resizing it, I was just hoping there might already be some automatic procedure for doing so. I'll see what I can do with this pack routine...
On Tue, Sep 15, 2009 at 5:18 PM, Meinrad Recheis <meinrad.recheis@...> wrote:
_______________________________________________ fxruby-users mailing list fxruby-users@... http://rubyforge.org/mailman/listinfo/fxruby-users |
| Free embeddable forum powered by Nabble | Forum Help |