mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 03:11:18 +00:00
Fix string drawing based on Apple functionality
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_testplant_branch@40214 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
056c24bf98
commit
37b37b1558
1 changed files with 22 additions and 2 deletions
|
@ -450,8 +450,28 @@ glyphs to be drawn upside-down, so we need to tell NSFont to flip the fonts.
|
|||
|
||||
- (void) drawInRect: (NSRect)rect
|
||||
{
|
||||
[self drawWithRect: rect
|
||||
options: NSStringDrawingUsesLineFragmentOrigin];
|
||||
NSAttributedString *attrstring = self;
|
||||
|
||||
// Redo string to fit in rectangle...
|
||||
// Apple drawing does this by default...
|
||||
NSSize titleSize = [self size];
|
||||
|
||||
if (titleSize.width > rect.size.width && [self length] > 4)
|
||||
{
|
||||
{
|
||||
attrstring = [[self mutableCopy] autorelease];
|
||||
|
||||
//unichar ell = 0x2026;
|
||||
NSString *ellipsis = @"...";
|
||||
do
|
||||
{
|
||||
NSRange replaceRange = NSMakeRange(([attrstring length] / 2)-2, 4);
|
||||
[(NSMutableAttributedString *)attrstring replaceCharactersInRange:replaceRange withString:ellipsis];
|
||||
} while ([attrstring length] > 4 && [attrstring size].width > rect.size.width);
|
||||
}
|
||||
}
|
||||
|
||||
[attrstring drawWithRect: rect options: NSStringDrawingUsesLineFragmentOrigin];
|
||||
}
|
||||
|
||||
- (void) drawWithRect: (NSRect)rect
|
||||
|
|
Loading…
Reference in a new issue