[fxruby-users] FXTable::fitColumnsToContents

Lyle Johnson lyle at lylejohnson.name
Mon May 19 21:43:22 EDT 2008

On May 19, 2008, at 8:34 PM, Lyle Johnson wrote:

> I see part of the problem, now that I look at it again. We're not  
> taking into account the cell margin values. So if you change the  
> calculation of "hw" to this:
> 	hw = columnHeader.font.getTextWidth(columnHeader.getItemText(c)) +  
> marginLeft + marginRight
> You get a bit closer to the correct width. But for the particular  
> big font that I'm trying it's still a little short. I don't know if  
> this indicates a bug in FXFont::getTextWidth(), or if there's still  
> some factor that I'm overlooking.

Wait, I've got it now. The spacing's different because it's a header  
item and not a table item. Here's the correct formula:

	hw = columnHeader.font.getTextWidth(columnHeader.getItemText(c)) +
		2*columnHeader.borderWidth + columnHeader.padLeft +  

That looks right here, for the font that I'm testing with. Let me know  
what you think!

-- Lyle

"FXRuby: Create Lean and Mean GUIs with Ruby"
Now available from the Pragmatic Bookshelf!

More information about the fxruby-users mailing list