This is a good question.  I've run into the same problem you are having, and
what I do is use a list drawing callback function that truncates strings to
a particular width and then draws the strings at a particular x offset.  You
can use FntCharsWidth/FntCharsInWidth in the callback to figure out how many
chars you can draw in the amount of space you have available.

Say you have a list that needs to show first name, last name and phone #
spaced in the list row in three columns.  In your callback function, you can
grab the first name string to display and set its width in pixels,
truncating if necessary.   Say we were going to have a very narrow first
column for first name (only enough pixels for around 3 letters), then your
code would use FntCharsInWidth, specify the string and the max width in
pixels for that column, and you would be told how many chars from that
string you can print in that space.  Then call WinDrawChars, and away you
go.

The truncation would look something like the following for "dane avilla" and
"alexej jerschow"

dan avilla   123.456.7890 
ale jerschow 987.645.3120

If you want to get fancy, you can add "..." at the end of a string that has
been truncated, but I'll leave that to your discretion :)

Cheers,

-DGA

> -----Original Message-----
> From: Alexej Jerschow [mailto:[EMAIL PROTECTED]]
> Sent: Friday, January 25, 2002 12:25 PM
> To: Palm Developer Forum
> Subject: fixed width formatting in list
> 
> How can I achieve propper formatting of list items (PalmOS3.5, 4)? It
> seems there is no fixed-width font available. While I can format the
> strings of the list items properly, they do not appear formatted when
> displayed in the list, because the font does not have a fixed width. I
> tried all the fonts available in Constructor, the symbol font seems to
> be fixed width but obviously lacks the letters.
> Any ideas?
> Thank you
> Alexej Jerschow

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to