[fxruby-users] resizing main window on the fly

Don Wilde dwilde1 at gmail.com
Fri Nov 7 08:45:23 EST 2008


[snip]
>
>
> I don't get the point you insist in using that @mainWindowWidth, when
> you could just use width.
>
> On the other hand, you could simplify the whole above to the following:
>
> ###
>
> winWidth = FXListBox.new(blk1, :opts => LISTBOX_NORMAL)
> [800, 1024].each { |w| winWidth.appendItem(w) }
> winWindth.connect(SEL_COMMAND) do |sender, selector, data|
>        resize(winWidth.getItemText.to_i, height)
> end
>
> ###
>
> This could save you some typing and looks (at least to me) more
> readable.
>
> Here "height" is actually a method from FXWindow, which returns the
> current height of this window's instance. The same is true for "width",
> so you wouldn't need to store the window's current width in an external
> variable.
>

More good advice. I hadn't thought to ask the Window for its size, and
getItemText is much preferable to the external array. It took a few more
type conversions to work, but still is much less code than my earlier
solution.

###
    winWidth = FXListBox.new(blk1, :opts => LISTBOX_NORMAL)
    ["800", "1024"].each { |w| winWidth.appendItem( w ) }
    winWidth.connect(SEL_COMMAND) do |sender, selector, data|
       resize(winWidth.getItemText( data.to_i ).to_i, height)
    end
###

Again, thanks for the suggestions!

-- :D
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20081107/7177da7d/attachment-0001.html>


More information about the fxruby-users mailing list