[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-pim
Subject:    Re: [Kde-pim] [PATCH] KOrganizer: squeezing text in monthview, 2nd
From:       Tim Jansen <ml () tjansen ! de>
Date:       2003-07-11 21:40:09
[Download RAW message or body]

On Friday 11 July 2003 12:56, David Faure wrote:
> If it does, then Qt will take care of it. Notice that we ask for the width
> of each char using fm.charWidth( str, i ), so QFontMetrics has the
> "context".

Oh, I see...

> But yes, it wraps at word boundaries, that was the whole point of it :}
> I was just surprised that you needed iterations - if you're cutting at the
> char that doesn't fit, then that's a straightforward thing... what's the
> reason for the iterations?

It's just a different way of doing it, somewhat inspired by KSqueezedLabel. 
I know the width of the cell in pixels (cw), and can calculate the width of 
the complete text in pixels (tw), so I can guess that I should resize the 
text to text.lenght() * cw / tw. This value is not always accurate because 
the character width in the string may vary, so I do a few iterations with the 
estimated text until I am done. To keep the code shorter I try to always 
overestimate, and there's also a small learning factor to use less iterations 
in extreme situations. 

> (I'm trying to figure out if there's a feature for KWordWrap here :)

No, as adding charWidth() works that is at least as good (probably better, if 
FontMetric::boundaryRect() behaves o(n)).

bye...

_______________________________________________
kde-pim mailing list
kde-pim@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic