[fxruby-users] FXTable::fitColumnsToContents

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


On May 19, 2008, at 1:56 PM, David Toll wrote:

> I have tried your suggested replacement for fitColumnsToContents.   
> While it is better than the "standard" version, it does not  
> completely cure my problem.  It does not get a large enough value  
> for the width of the heading text, and so far I have not determined  
> why. I found that if I increase this size estimate by 1/3 then the  
> display looks about right.  That is, the line that determines "hw"  
> is now:
>
>       hw =  
> columnHeader.font.getTextWidth(columnHeader.getItemText(c))*4/3
>
> However, this is a somewhat arbitrary solution to the problem, I am  
> hoping someone knows why the call to font.getTextWidth does not  
> return an adequate value.

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.

Hope this helps,

Lyle

---
"FXRuby: Create Lean and Mean GUIs with Ruby"
Now available from the Pragmatic Bookshelf!
http://www.pragprog.com/titles/fxruby





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/fxruby-users/attachments/20080519/f9d94ae4/attachment.html>


More information about the fxruby-users mailing list