//--------------------------------------------------------------------------␊ |
- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView␊ |
{␊ |
NSSize contentSize = [self cellSize];␊ |
cellFrame.origin.y += (cellFrame.size.height - contentSize.height) / 2.0;␊ |
cellFrame.size.height = contentSize.height;␊ |
␉␊ |
␉NSAttributedString *drawString = [self attributedStringValue];␊ |
␉␊ |
␉NSRange range;␊ |
␉NSDictionary *attributes = [drawString attributesAtIndex:0 effectiveRange:&range];␊ |
␉␊ |
␉float maxWidth = cellFrame.size.width;␊ |
␉float stringWidth = [drawString size].width;␊ |
␉␊ |
␉if (maxWidth < stringWidth)␊ |
␉{␊ |
␉␉int i;␊ |
␉␉␊ |
␉␉for (i = 0;i <= [drawString length];i++)␊ |
␉␉{␊ |
␉␉␉if ([[drawString attributedSubstringFromRange:NSMakeRange(0,i)]size].width >= maxWidth)␊ |
␉␉␉{␉␊ |
␉␉␉␉drawString = [[NSMutableAttributedString alloc] initWithString:␊ |
␉␉␉␉␉␉␉ [[[drawString attributedSubstringFromRange:NSMakeRange(0,i-3)]string] stringByAppendingString:@"..."]attributes:attributes];␊ |
␉␉␉␉[drawString autorelease];␊ |
␉␉␉}␊ |
␉␉}␊ |
␉}␊ |
␉␊ |
␉[drawString drawInRect:cellFrame];␊ |
␉␊ |
NSSize contentSize = [self cellSize];␊ |
cellFrame.origin.y += (cellFrame.size.height - contentSize.height) / 2.0;␊ |
cellFrame.size.height = contentSize.height;␊ |
␊ |
[super drawInteriorWithFrame:cellFrame inView:controlView];␊ |
}␊ |
␊ |
@end␊ |