[fxruby-users] resizing main window on the fly

angico angico at angico.org
Fri Nov 7 03:30:39 EST 2008


Em Qui, 2008-11-06 às 20:19 -0600, Don Wilde escreveu:

>  
>  Hi, Angico -
> 
> 
> You definitely put me on the right track.
> 
> One further refinement necessary, for the record.
> 
> FXListBox returns a zero-based index into the list, not the text.
> FXComboBox (according to Lyle) can be inspected with sender.text, but
> FXListBox is a bit more primitive.
> 
> 
> My working solution, retaining the variable so I can intelligently
> size and position things:
> 
>     availWinWidths = Array["800", "1024"]
>     winWidth = FXListBox.new( blk1, :opts => LISTBOX_NORMAL ) 
>     availWinWidths.each { | w | winWidth.appendItem( w ) }
>     winWidth.connect( SEL_COMMAND ) do | sender, sel, data |
>       wSel = availWinWidths[ data.to_i ]
>       @mainWindowWidth = wSel.to_i
>       resize(@mainWindowWidth, 600 )
>     end
> 
> It works marvelously well. Thank you for the big nudge in the right
> direction! 
> 

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.

Regards,

-- 

angico
------
home page: www.angico.org
Gnu/Linux, FLOSS, Espiritismo, e eu por mim mesmo 8^I
------
contatos:
email: angico at angico.org
skype: an.gi.co
------



More information about the fxruby-users mailing list