NSTextTable column width calculations?

  • Hi,

    I am using an NSTextTable to display (and edit) some tabular data.
    The nature of this data calls for some columns to adjust their width
    to the maximum width of the unwrapped text contained in any cell of
    these columns, while other columns just use what's left over.

    Programmatically controlling column width is no big deal (by setting
    the width of all NSTextTableBlocks of that column), but what is the
    best way to first determine the maximum width of any text in that
    column?

    And as a side question, what is the meaning of
    NSTextTableLayoutAlgorithm, which can be set to
    NSTextTableAutomaticLayoutAlgorithm or
    NSTextTableFixedLayoutAlgorithm? May this help me with my task in any
    way?

    Thanks in advance
    Kai
  • On Oct 5, 2007, at 2:47 AM, Kai BrĂ¼ning wrote:

    > Programmatically controlling column width is no big deal (by
    > setting the width of all NSTextTableBlocks of that column), but
    > what is the best way to first determine the maximum width of any
    > text in that column?

    You can go through the text using -rangeOfTextBlock:atIndex: to get
    ranges for the blocks.  You can use e.g. -
    boundingRectWithSize:options: to calculate sizes.

    Douglas Davidson
previous month october 2007 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today