Last change
on this file since 385 was 53, checked in by Nicholas Riley, 22 years ago |
Updated for Pester 1.1a5 (very limited release).
Pester 1.1a4 was never released.
|
File size:
969 bytes
|
Rev | Line | |
---|
[53] | 1 | //
|
---|
| 2 | // NSAttributedString-NJRExtensions.m
|
---|
| 3 | // Pester
|
---|
| 4 | //
|
---|
| 5 | // Created by Nicholas Riley on Mon Dec 16 2002.
|
---|
| 6 | // Copyright (c) 2002 Nicholas Riley. All rights reserved.
|
---|
| 7 | //
|
---|
| 8 |
|
---|
| 9 | #import "NSAttributedString-NJRExtensions.h"
|
---|
| 10 |
|
---|
| 11 | @implementation NSAttributedString (NJRExtensions)
|
---|
| 12 |
|
---|
| 13 | - (float)heightWrappedToWidth:(float)width;
|
---|
| 14 | {
|
---|
| 15 | float height = 0;
|
---|
| 16 | NSTextStorage *storage = [[NSTextStorage alloc] initWithAttributedString: self];
|
---|
| 17 | NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
|
---|
| 18 | NSTextContainer *container = [[NSTextContainer alloc]
|
---|
| 19 | initWithContainerSize: NSMakeSize(width, MAXFLOAT)];
|
---|
| 20 | [layoutManager addTextContainer: container];
|
---|
| 21 | [storage addLayoutManager: layoutManager];
|
---|
| 22 | (void) [layoutManager glyphRangeForTextContainer: container]; // force layout
|
---|
| 23 | height = [layoutManager usedRectForTextContainer: container].size.height;
|
---|
| 24 | [layoutManager release];
|
---|
| 25 | [container release];
|
---|
| 26 | [storage release];
|
---|
| 27 | return height;
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | @end
|
---|
Note:
See
TracBrowser
for help on using the repository browser.