On Sat, Jan 26, 2013 at 11:06 AM, Mark Miesfeld <miesfeld@gmail.com> wrote:

On Sat, Jan 26, 2013 at 10:38 AM, Art Heimsoth <artstore@artheimsoth.com> wrote:
Is there more to determining the pixel size of the text string?  In using
your example, the largest pixel string value was 557, and varied from
224 to 557, yet the text strings being added to the listbox fill the
horizontal width of the box.  It is a formatted content, and tab characters
are used to position each column of data.

You are correct, if you have tabs in there, the actual width of the string will not be correct.  The operating system API being used does nothing special for tabs.  I think, I'm not sure.  

It turns out the API being used by ooDialog does not take into account tabs.  However, there  is another API that does.  This is not available in ooDialog though, so it doesn't help you today.

This second API can be given a list of the actual tab stop positions, which is probably what you would need for your list box usage.  But, if it is not given the list, it simply calculates a tab's width as 8 times the average width of a character.

So, my suggestion to calculate the width of 'eeeeeeee' separately and add that width times the number of tabs you have in your string to the initial width you get from getTextSizePx() should give you a pretty accurate width.

At some point if I run out of things to do, I may add a getTabbedTextSize() method.

Mark Miesfeld