From: Jason Persampieri Date: 2002-12-11T08:06:51+09:00 Subject: Re: FXRuby : Setting Default Height/Width in an FXList ok, that worked (although I ended up using a slightly different approach). I really need to get my brain latched on to the idea of modifying classes so easily ;) Now, I need to be able to add widgets at runtime. This 'seems' to work ok as parentFrame.numChildren returns the correct value, but the widgets just aren't appearing. I've tried all sorts of stuff like recalc, resize, hide then show, raise, etc on all widgets involved (parents and children). What the heck am I missing? On a side note, you show FXListItem as being written in Ruby... I've been trying to look through the FXRuby source to find where all of these classes are defined but I can't seem to find them...... Jason Persampieri Tools Programmer Kush Games --- Lyle Johnson wrote: > Jason Persampieri wrote: > > > I'm attempting to create a vertical, single-column > > list of text items to match up with a vertical > > single-column FXHeader. Is there any way to > change > > the height of individual items within a list? > > By default, the height of a list item is determined > by the greater of > the height of its font or the height of its icon, > plus some extra > inter-item padding, i.e. > > class FXListItem > def getHeight(aList) > textHeight = 0 > iconHeight = 0 > unless text.empty? > textHeight = aList.font.fontHeight > end > unless icon.nil? > iconHeight = icon.height > end > LINE_SPACING + [textHeight, iconHeight].max > end > end > > So if you want to fix the list items' height at some > particular value, > one way would be to subclass FXListItem and override > the getHeight() method: > > class FixedHeightListItem < FXListItem > def initialize(theHeight, theText, > theIcon=nil, theData=nil) > super(theText, theIcon, theData) > @myFixedHeight = theFixedHeight > end > def getHeight(aList) > @myFixedHeight > end > end > > And then to add items of this class to your list: > > myList = FXList.new(...) > myList.appendItem(FixedHeightListItem.new(20, > "Tall Item")) > myList.appendItem(FixedHeightListItem.new(50, > "Really Tall Item")) > > Hope this helps, > > Lyle > >