NSTextContainer with fixed width and growing height

  • Hi,

    I am using a NSTextView. The corresponding NSTextContainer should have a fixed
    width (which is smaller than the textviews width).
    The height of the container should grow with text it should show.
    My first try was to set the containerSize to a fixed size and I wanted to
    resize the containers height if it is to small to show the whole text.
    Therefore I tried a several things
    - the usedRectForTextContainer from NSTextLayout doesn't seem to work the way I
    wanted because it seems that the rect is never greater than the containerSize
    - boundingRectForGlyphRange didn't work either
    - locationForGlyphAtIndex and glyphRangeForTextContainer didn't help
    I think there exists an easy way to check if the attributedString does fit into
    the textContainer and I hope perhaps someone can help me.
    Searching the web I found an ObjectiveC-method size() for NSAttributedString
    but this method doesn't exists in Java :-(
    Of course I can walk through the lines of the string and count each lines
    height, add the container insets... but I think there is a better way.

    Thanks for help

    Vera
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
  • On Aug 25, 2004, at 8:12 AM, Vera Wahler wrote:

    > I am using a NSTextView. The corresponding NSTextContainer should have
    > a fixed
    > width (which is smaller than the textviews width).
    > The height of the container should grow with text it should show.

    This is provided for automatically.  See the TextSizingExample for
    details.

    Douglas Davidson
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
  • Hi Douglas Davidson,

    The TextSizingExample is not what I need. I have got a different problem.
    My NSTextView has a fixed width (for example 500). But the corresponding
    NSTextContainer should only have a width of 200.
    The size of the NSTextView never changes so I can't work with
    setHeightTracksTextView().
    In my case only the NSTextStorage changes and I want to know if the
    NSTextStorage fits into the NSTextContainer.
    Another try was NSGraphics.sizeOfAttributedString().
    My NSTextStorage consists of multiple lines and different Fonts and Sizes and
    it seems that the above method can't handle this.

    Vera
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
previous month august 2004 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
MindNode
MindNode offered a free license !