some changes to the way text is drawn to the table
This commit is contained in:
parent
3e6d071e0d
commit
2944a10d60
Binary file not shown.
|
@ -43,16 +43,14 @@
|
||||||
[NSFont messageFontOfSize: 12.0], NSFontAttributeName,
|
[NSFont messageFontOfSize: 12.0], NSFontAttributeName,
|
||||||
paragraphStyle, NSParagraphStyleAttributeName, nil];
|
paragraphStyle, NSParagraphStyleAttributeName, nil];
|
||||||
|
|
||||||
float textHeight = [(NSTableView *)controlView rowHeight];
|
NSString * nameString = [item objectForKey: @"Name"];
|
||||||
NSRect textRect = NSMakeRect(NSMaxX(imageRect) + SPACE, cellFrame.origin.y + 1.0,
|
NSRect nameTextRect = NSMakeRect(NSMaxX(imageRect) + SPACE, cellFrame.origin.y + 1.0,
|
||||||
NSMaxX(cellFrame) - NSMaxX(imageRect) - 2.0 * SPACE, textHeight);
|
NSMaxX(cellFrame) - NSMaxX(imageRect) - 2.0 * SPACE, [nameString sizeWithAttributes: nameAttributes].height);
|
||||||
|
|
||||||
NSAttributedString * text = [[NSAttributedString alloc] initWithString: [item objectForKey: @"Name"]
|
[nameString drawInRect: nameTextRect withAttributes: nameAttributes];
|
||||||
attributes: nameAttributes];
|
[nameAttributes release];
|
||||||
[text drawInRect: textRect];
|
|
||||||
[text release];
|
|
||||||
|
|
||||||
//bottomText
|
//status text
|
||||||
if (![[item objectForKey: @"IsFolder"] boolValue])
|
if (![[item objectForKey: @"IsFolder"] boolValue])
|
||||||
{
|
{
|
||||||
NSDictionary * statusAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
|
NSDictionary * statusAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||||
|
@ -60,22 +58,17 @@
|
||||||
[NSFont messageFontOfSize: 9.0], NSFontAttributeName,
|
[NSFont messageFontOfSize: 9.0], NSFontAttributeName,
|
||||||
paragraphStyle, NSParagraphStyleAttributeName, nil];
|
paragraphStyle, NSParagraphStyleAttributeName, nil];
|
||||||
|
|
||||||
NSRect bottomTextRect = textRect;
|
NSString * statusString = [NSString stringForFileSize: [[item objectForKey: @"Size"] unsignedLongLongValue]];
|
||||||
bottomTextRect.origin.y += textHeight;
|
|
||||||
bottomTextRect.size.height = cellFrame.size.height - textHeight;
|
|
||||||
|
|
||||||
NSMutableAttributedString * bottomText = [[NSMutableAttributedString alloc] initWithString:
|
NSRect statusTextRect = nameTextRect;
|
||||||
[NSString stringForFileSize: [[item objectForKey: @"Size"] unsignedLongLongValue]]
|
statusTextRect.size.height = [statusString sizeWithAttributes: statusAttributes].height;
|
||||||
attributes: statusAttributes];
|
statusTextRect.origin.y += (cellFrame.size.height + nameTextRect.size.height - statusTextRect.size.height) * 0.5 - 1.0;
|
||||||
|
|
||||||
[bottomText drawInRect: bottomTextRect];
|
|
||||||
[bottomText release];
|
|
||||||
|
|
||||||
|
[statusString drawInRect: statusTextRect withAttributes: statusAttributes];
|
||||||
[statusAttributes release];
|
[statusAttributes release];
|
||||||
}
|
}
|
||||||
|
|
||||||
[paragraphStyle release];
|
[paragraphStyle release];
|
||||||
[nameAttributes release];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -218,20 +218,20 @@
|
||||||
pen.x += iconSize.width + PADDING + EXTRA_NAME_SHIFT;
|
pen.x += iconSize.width + PADDING + EXTRA_NAME_SHIFT;
|
||||||
pen.y = cellFrame.origin.y + PADDING;
|
pen.y = cellFrame.origin.y + PADDING;
|
||||||
|
|
||||||
NSAttributedString * nameString = [[NSAttributedString alloc] initWithString: [info objectForKey: @"Name"]
|
NSString * nameString = [info objectForKey: @"Name"];
|
||||||
attributes: nameAttributes];
|
NSSize nameSize = [nameString sizeWithAttributes: nameAttributes];
|
||||||
[nameString drawInRect: NSMakeRect(pen.x, pen.y, mainWidth, [nameString size].height)];
|
[nameString drawInRect: NSMakeRect(pen.x, pen.y, mainWidth, nameSize.height) withAttributes: nameAttributes];
|
||||||
|
|
||||||
//progress string
|
//progress string
|
||||||
pen.y += [nameString size].height + LINE_PADDING - 1.0;
|
pen.y += nameSize.height + LINE_PADDING - 1.0;
|
||||||
|
|
||||||
NSAttributedString * progressString = [[NSAttributedString alloc] initWithString:
|
NSString * progressString = [info objectForKey: @"ProgressString"];
|
||||||
[info objectForKey: @"ProgressString"] attributes: statusAttributes];
|
NSSize progressSize = [progressString sizeWithAttributes: statusAttributes];
|
||||||
[progressString drawInRect: NSMakeRect(pen.x, pen.y, mainWidth, [progressString size].height)];
|
[progressString drawInRect: NSMakeRect(pen.x, pen.y, mainWidth, progressSize.height) withAttributes: statusAttributes];
|
||||||
|
|
||||||
//progress bar
|
//progress bar
|
||||||
pen.x -= EXTRA_NAME_SHIFT;
|
pen.x -= EXTRA_NAME_SHIFT;
|
||||||
pen.y += [progressString size].height + LINE_PADDING + BAR_HEIGHT;
|
pen.y += progressSize.height + LINE_PADDING + BAR_HEIGHT;
|
||||||
|
|
||||||
float barWidth = mainWidth + EXTRA_NAME_SHIFT - BUTTONS_TOTAL_WIDTH + PADDING;
|
float barWidth = mainWidth + EXTRA_NAME_SHIFT - BUTTONS_TOTAL_WIDTH + PADDING;
|
||||||
|
|
||||||
|
@ -244,13 +244,9 @@
|
||||||
pen.x += EXTRA_NAME_SHIFT;
|
pen.x += EXTRA_NAME_SHIFT;
|
||||||
pen.y += LINE_PADDING;
|
pen.y += LINE_PADDING;
|
||||||
|
|
||||||
NSAttributedString * statusString = [[NSAttributedString alloc] initWithString:
|
NSString * statusString = [info objectForKey: @"StatusString"];
|
||||||
[info objectForKey: @"StatusString"] attributes: statusAttributes];
|
NSSize statusSize = [statusString sizeWithAttributes: statusAttributes];
|
||||||
[statusString drawInRect: NSMakeRect(pen.x, pen.y, mainWidth, [statusString size].height)];
|
[statusString drawInRect: NSMakeRect(pen.x, pen.y, mainWidth, statusSize.height) withAttributes: statusAttributes];
|
||||||
|
|
||||||
[nameString release];
|
|
||||||
[progressString release];
|
|
||||||
[statusString release];
|
|
||||||
}
|
}
|
||||||
else //small size
|
else //small size
|
||||||
{
|
{
|
||||||
|
@ -266,32 +262,32 @@
|
||||||
|
|
||||||
//name and status string
|
//name and status string
|
||||||
float mainWidth = cellFrame.size.width - iconSize.width - 3.0 * PADDING - EXTRA_NAME_SHIFT;
|
float mainWidth = cellFrame.size.width - iconSize.width - 3.0 * PADDING - EXTRA_NAME_SHIFT;
|
||||||
|
|
||||||
NSString * realStatusString = !fStatusRegular && [[info objectForKey: @"Active"] boolValue]
|
|
||||||
? [info objectForKey: @"RemainingTimeString"]
|
|
||||||
: [info objectForKey: @"ShortStatusString"];
|
|
||||||
|
|
||||||
NSAttributedString * statusString = [[NSAttributedString alloc] initWithString: realStatusString
|
|
||||||
attributes: statusAttributes];
|
|
||||||
NSAttributedString * nameString = [[NSAttributedString alloc] initWithString:
|
|
||||||
[info objectForKey: @"Name"] attributes: nameAttributes];
|
|
||||||
|
|
||||||
//place name string
|
//place name string
|
||||||
pen.x += iconSize.width + PADDING + EXTRA_NAME_SHIFT;
|
pen.x += iconSize.width + PADDING + EXTRA_NAME_SHIFT;
|
||||||
pen.y = cellFrame.origin.y + LINE_PADDING;
|
pen.y = cellFrame.origin.y + LINE_PADDING;
|
||||||
|
|
||||||
[nameString drawInRect: NSMakeRect(pen.x, pen.y, mainWidth - [statusString size].width - LINE_PADDING,
|
NSString * nameString = [info objectForKey: @"Name"];
|
||||||
[nameString size].height)];
|
NSSize nameSize = [nameString sizeWithAttributes: nameAttributes];
|
||||||
|
|
||||||
|
NSString * statusString = !fStatusRegular && [[info objectForKey: @"Active"] boolValue]
|
||||||
|
? [info objectForKey: @"RemainingTimeString"]
|
||||||
|
: [info objectForKey: @"ShortStatusString"];
|
||||||
|
NSSize statusSize = [statusString sizeWithAttributes: statusAttributes];
|
||||||
|
|
||||||
|
[nameString drawInRect: NSMakeRect(pen.x, pen.y, mainWidth - statusSize.width - 2.0 * LINE_PADDING, nameSize.height)
|
||||||
|
withAttributes: nameAttributes];
|
||||||
|
|
||||||
//place status string
|
//place status string
|
||||||
pen.x = NSMaxX(cellFrame) - PADDING - [statusString size].width;
|
pen.x = NSMaxX(cellFrame) - PADDING - statusSize.width;
|
||||||
pen.y += ([nameString size].height - [statusString size].height) * 0.5;
|
pen.y += (nameSize.height - statusSize.height) * 0.5;
|
||||||
|
|
||||||
[statusString drawAtPoint: pen];
|
[statusString drawInRect: NSMakeRect(pen.x, pen.y, statusSize.width, statusSize.height)
|
||||||
|
withAttributes: statusAttributes];
|
||||||
|
|
||||||
//progress bar
|
//progress bar
|
||||||
pen.x = cellFrame.origin.x + iconSize.width + 2.0 * PADDING;
|
pen.x = cellFrame.origin.x + iconSize.width + 2.0 * PADDING;
|
||||||
pen.y = cellFrame.origin.y + [nameString size].height + LINE_PADDING + PADDING + BAR_HEIGHT;
|
pen.y = cellFrame.origin.y + nameSize.height + LINE_PADDING + PADDING + BAR_HEIGHT;
|
||||||
|
|
||||||
float barWidth = mainWidth + EXTRA_NAME_SHIFT - BUTTONS_TOTAL_WIDTH + PADDING;
|
float barWidth = mainWidth + EXTRA_NAME_SHIFT - BUTTONS_TOTAL_WIDTH + PADDING;
|
||||||
|
|
||||||
|
@ -299,9 +295,6 @@
|
||||||
[self buildAdvancedBar: barWidth point: pen];
|
[self buildAdvancedBar: barWidth point: pen];
|
||||||
else
|
else
|
||||||
[self buildSimpleBar: barWidth point: pen];
|
[self buildSimpleBar: barWidth point: pen];
|
||||||
|
|
||||||
[nameString release];
|
|
||||||
[statusString release];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[nameAttributes release];
|
[nameAttributes release];
|
||||||
|
|
Loading…
Reference in New Issue