Re: [Fxruby-users] controlling a FXComboBox size
Status: Inactive
Brought to you by:
lyle
From: Sander J. <sa...@kn...> - 2003-12-04 03:18:38
|
In my experience, for FXComboBox I use the LAYOUT_FILL_X style since it may resize itself based on the string it is displaying (so unless you have set to biggest string it will have to display, it always adjust its size... very annoying). Sander On Wednesday 03 December 2003 08:15 pm, Lyle Johnson wrote: 0> On Dec 3, 2003, at 4:09 PM, Brett S Hallett wrote: > > Find attached a few (small :-) example programs that I generated , the > > only > > one that produces a "correct" combobox is the one (testfox.rb) which > > explicitly uses the coordinate AND size parameters, in every other > > case I get > > a VERY narrow displayed field ( and drop down field). > > > > I suspect that I am simply not using the correct opts= parameters to > > get the > > desired effect, which is : > > > > a) let the user define the width & height of the combobox field > > b) let the field fall into its 'natural' position depending upon the > > frame > > type declared. > > When you specify an explicit (a.k.a. fixed) width for the combo-box, > there is obviously no question as to which size the layout manager > should assign to that combo-box. But if you don't specify a fixed > width, the layout manager needs some other way to determine an > appropriate default size for it. (This is of course true for any child > widget, but today we're talking about combo-boxes ;) > > For the combo-box (as well as text fields, and some other widgets) the > default size depends on the number of columns passed in as an argument > to the constructor. In the case of your examples, you're passing in 1 > as the number of columns, e.g. > > postcode = FXComboBox.new(combo, 1, 10, nil, 0, > FRAME_SUNKEN|FRAME_THICK|COMBOBOX_NORMAL) > > which causes the combo-box to report a very small default width, since > it thinks it only needs to be wide enough to display a string that is > one character long. To quickly prove this to yourself, simply change > the above line (from testfox1.rb) to read something like: > > postcode = FXComboBox.new(combo, 8, 10, nil, 0, > FRAME_SUNKEN|FRAME_THICK|COMBOBOX_NORMAL) > > and you should like the result better. Of course, the "right" number of > columns is going to depend on the lengths of the items' text, which you > don't know in advance. Some people get around this by adjusting the > number of columns after all of the items have been added, e.g. > > comboBox = FXComboBox.new(p, 1, ...) > maxStringLen = 0 > itemStrings.each do |itemString| > comboBox.appendItem(itemString) > maxStringLen = [maxStringLen, itemString.length].max > end > comboBox.numColumns = maxStringLen > > > Also note the file "testfox.fxs" which is FOX Script Language I am > > developing > > to see if this shorthand technique of describing forms is a viable > > technique. > > Although I've had plenty of experience with DELPHI, et al, I'm not > > convinced > > that a GUI IDE is necessarly the most efficient method for describing > > forms > > when the developers Language (Ruby) is using a independent GUI tool. > > Delphi > > works well because of the very tight intergration of Form/Language. > > I've never used Delphi itself, but have used Borland C++ Builder which > is closely related, and yes, it is very nice. A lot of people are > interested in "GUI building" tools for FOX and FXRuby (see for example > http://fox-tool.rubyforge.org) and so I'm glad you're investigating > this alternative approach. > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > Does SourceForge.net help you be more productive? Does it > help you create better code? SHARE THE LOVE, and help us help > YOU! Click Here: http://sourceforge.net/donate/ > _______________________________________________ > Fxruby-users mailing list > Fxr...@li... > https://lists.sourceforge.net/lists/listinfo/fxruby-users -- "I've had a wonderful time, but this wasn't it." - Groucho Marx (1895-1977) |