Changeset 9217
- Timestamp:
- Sep 28, 2009, 5:42:24 PM (13 years ago)
- Location:
- trunk/macosx
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/FileNameCell.m
r9201 r9217 42 42 - (NSRect) rectForStatusWithString: (NSAttributedString *) string withTitleRect: (NSRect) titleRect inBounds: (NSRect) bounds; 43 43 44 - (NSAttributedString *) attributedTitle WithColor: (NSColor *) color;45 - (NSAttributedString *) attributedStatus WithColor: (NSColor *) color;44 - (NSAttributedString *) attributedTitle; 45 - (NSAttributedString *) attributedStatus; 46 46 47 47 @end … … 125 125 - (NSRect) titleRectForBounds: (NSRect) bounds 126 126 { 127 return [self rectForTitleWithString: [self attributedTitle WithColor: nil] inBounds: bounds];127 return [self rectForTitleWithString: [self attributedTitle] inBounds: bounds]; 128 128 } 129 129 130 130 - (NSRect) statusRectForBounds: (NSRect) bounds 131 131 { 132 return [self rectForStatusWithString: [self attributedStatus WithColor: nil]132 return [self rectForStatusWithString: [self attributedStatus] 133 133 withTitleRect: [(FileListNode *)[self objectValue] isFolder] ? [self titleRectForBounds: bounds] : NSZeroRect 134 134 inBounds: bounds]; … … 151 151 } 152 152 153 [fTitleAttributes setObject: titleColor forKey: NSForegroundColorAttributeName]; 154 [fStatusAttributes setObject: statusColor forKey: NSForegroundColorAttributeName]; 155 153 156 //title 154 NSAttributedString * titleString = [self attributedTitle WithColor: titleColor];157 NSAttributedString * titleString = [self attributedTitle]; 155 158 NSRect titleRect = [self rectForTitleWithString: titleString inBounds: cellFrame]; 156 159 [titleString drawInRect: titleRect]; 157 160 158 161 //status 159 NSAttributedString * statusString = [self attributedStatus WithColor: statusColor];162 NSAttributedString * statusString = [self attributedStatus]; 160 163 NSRect statusRect = [self rectForStatusWithString: statusString withTitleRect: titleRect inBounds: cellFrame]; 161 164 [statusString drawInRect: statusRect]; … … 210 213 } 211 214 212 - (NSAttributedString *) attributedTitleWithColor: (NSColor *) color 213 { 214 if (color) 215 [fTitleAttributes setObject: color forKey: NSForegroundColorAttributeName]; 216 215 - (NSAttributedString *) attributedTitle 216 { 217 217 NSString * title = [(FileListNode *)[self objectValue] name]; 218 218 return [[[NSAttributedString alloc] initWithString: title attributes: fTitleAttributes] autorelease]; 219 219 } 220 220 221 - (NSAttributedString *) attributedStatusWithColor: (NSColor *) color 222 { 223 if (color) 224 [fStatusAttributes setObject: color forKey: NSForegroundColorAttributeName]; 225 221 - (NSAttributedString *) attributedStatus 222 { 226 223 Torrent * torrent = [(FileOutlineView *)[self controlView] torrent]; 227 224 FileListNode * node = (FileListNode *)[self objectValue]; -
trunk/macosx/TorrentCell.m
r9050 r9217 74 74 - (NSRect) rectForStatusWithString: (NSAttributedString *) string inBounds: (NSRect) bounds; 75 75 76 - (NSAttributedString *) attributedTitle WithColor: (NSColor *) color;77 - (NSAttributedString *) attributedStatusString: (NSString *) string withColor: (NSColor *) color;76 - (NSAttributedString *) attributedTitle; 77 - (NSAttributedString *) attributedStatusString: (NSString *) string; 78 78 79 79 - (NSString *) buttonString; … … 131 131 - (NSRect) titleRectForBounds: (NSRect) bounds 132 132 { 133 return [self rectForTitleWithString: [self attributedTitle WithColor: nil]133 return [self rectForTitleWithString: [self attributedTitle] 134 134 basedOnMinimalStatusRect: [self minimalStatusRectForBounds: bounds] inBounds: bounds]; 135 135 } … … 140 140 return NSZeroRect; 141 141 142 return [self rectForMinimalStatusWithString: [self attributedStatusString: [self minimalStatusString] withColor: nil]142 return [self rectForMinimalStatusWithString: [self attributedStatusString: [self minimalStatusString]] 143 143 inBounds: bounds]; 144 144 } … … 149 149 return NSZeroRect; 150 150 151 return [self rectForProgressWithString: [self attributedStatusString: [[self representedObject] progressString] withColor: nil]151 return [self rectForProgressWithString: [self attributedStatusString: [[self representedObject] progressString]] 152 152 inBounds: bounds]; 153 153 } … … 177 177 return NSZeroRect; 178 178 179 return [self rectForStatusWithString: [self attributedStatusString: [self statusString] withColor: nil] inBounds: bounds];179 return [self rectForStatusWithString: [self attributedStatusString: [self statusString]] inBounds: bounds]; 180 180 } 181 181 … … 457 457 } 458 458 459 [fTitleAttributes setObject: titleColor forKey: NSForegroundColorAttributeName]; 460 [fStatusAttributes setObject: statusColor forKey: NSForegroundColorAttributeName]; 461 459 462 //minimal status 460 463 NSRect minimalStatusRect; 461 464 if (minimal) 462 465 { 463 NSAttributedString * minimalString = [self attributedStatusString: [self minimalStatusString] withColor: statusColor];466 NSAttributedString * minimalString = [self attributedStatusString: [self minimalStatusString]]; 464 467 minimalStatusRect = [self rectForMinimalStatusWithString: minimalString inBounds: cellFrame]; 465 468 … … 468 471 469 472 //title 470 NSAttributedString * titleString = [self attributedTitle WithColor: titleColor];473 NSAttributedString * titleString = [self attributedTitle]; 471 474 NSRect titleRect = [self rectForTitleWithString: titleString basedOnMinimalStatusRect: minimalStatusRect inBounds: cellFrame]; 472 475 [titleString drawInRect: titleRect]; … … 486 489 if (!minimal) 487 490 { 488 NSAttributedString * progressString = [self attributedStatusString: [torrent progressString] withColor: statusColor];491 NSAttributedString * progressString = [self attributedStatusString: [torrent progressString]]; 489 492 NSRect progressRect = [self rectForProgressWithString: progressString inBounds: cellFrame]; 490 493 … … 549 552 if (!minimal) 550 553 { 551 NSAttributedString * statusString = [self attributedStatusString: [self statusString] withColor: statusColor];554 NSAttributedString * statusString = [self attributedStatusString: [self statusString]]; 552 555 [statusString drawInRect: [self rectForStatusWithString: statusString inBounds: cellFrame]]; 553 556 } … … 745 748 } 746 749 747 - (NSAttributedString *) attributedTitleWithColor: (NSColor *) color 748 { 749 if (color) 750 [fTitleAttributes setObject: color forKey: NSForegroundColorAttributeName]; 751 750 - (NSAttributedString *) attributedTitle 751 { 752 752 NSString * title = [[self representedObject] name]; 753 753 return [[[NSAttributedString alloc] initWithString: title attributes: fTitleAttributes] autorelease]; 754 754 } 755 755 756 - (NSAttributedString *) attributedStatusString: (NSString *) string withColor: (NSColor *) color 757 { 758 if (color) 759 [fStatusAttributes setObject: color forKey: NSForegroundColorAttributeName]; 760 756 - (NSAttributedString *) attributedStatusString: (NSString *) string 757 { 761 758 return [[[NSAttributedString alloc] initWithString: string attributes: fStatusAttributes] autorelease]; 762 759 } -
trunk/macosx/TrackerCell.m
r9215 r9217 34 34 #define PADDING_ABOVE_NAME 2.0 35 35 #define PADDING_BETWEEN_LINES 1.0 36 #define PADDING_BETWEEN_LINES_ON_SAME_LINE 3.036 #define PADDING_BETWEEN_LINES_ON_SAME_LINE 4.0 37 37 #define COUNT_WIDTH 40.0 38 38 … … 49 49 inBounds: (NSRect) bounds; 50 50 51 - (NSAttributedString *) attributedName WithColor: (NSColor *) color;52 - (NSAttributedString *) attributedStatusWithString: (NSString *) statusString color: (NSColor *) color;53 - (NSAttributedString *) attributedCount: (NSInteger) count color: (NSColor *) color;51 - (NSAttributedString *) attributedName; 52 - (NSAttributedString *) attributedStatusWithString: (NSString *) statusString; 53 - (NSAttributedString *) attributedCount: (NSInteger) count; 54 54 55 55 @end … … 119 119 } 120 120 121 121 //set table colors 122 122 NSColor * nameColor, * statusColor; 123 123 if ([self backgroundStyle] == NSBackgroundStyleDark) … … 129 129 } 130 130 131 [fNameAttributes setObject: nameColor forKey: NSForegroundColorAttributeName]; 132 [fStatusAttributes setObject: statusColor forKey: NSForegroundColorAttributeName]; 133 131 134 TrackerNode * node = (TrackerNode *)[self objectValue]; 132 135 133 136 //name 134 NSAttributedString * nameString = [self attributedName WithColor: nameColor];137 NSAttributedString * nameString = [self attributedName]; 135 138 const NSRect nameRect = [self rectForNameWithString: nameString inBounds: cellFrame]; 136 139 [nameString drawInRect: nameRect]; 137 140 138 141 //count strings 139 NSAttributedString * seederString = [self attributedCount: [node totalSeeders] color: statusColor];142 NSAttributedString * seederString = [self attributedCount: [node totalSeeders]]; 140 143 const NSRect seederRect = [self rectForCountWithString: seederString withAboveRect: nameRect inBounds: cellFrame]; 141 144 [seederString drawInRect: seederRect]; 142 145 143 NSAttributedString * leecherString = [self attributedCount: [node totalLeechers] color: statusColor];146 NSAttributedString * leecherString = [self attributedCount: [node totalLeechers]]; 144 147 const NSRect leecherRect = [self rectForCountWithString: leecherString withAboveRect: seederRect inBounds: cellFrame]; 145 148 [leecherString drawInRect: leecherRect]; 146 149 147 NSAttributedString * downloadedString = [self attributedCount: [node totalDownloaded] color: statusColor];150 NSAttributedString * downloadedString = [self attributedCount: [node totalDownloaded]]; 148 151 const NSRect downloadedRect = [self rectForCountWithString: downloadedString withAboveRect: leecherRect inBounds: cellFrame]; 149 152 [downloadedString drawInRect: downloadedRect]; … … 151 154 //count label strings 152 155 NSString * seederLabelBaseString = [NSLocalizedString(@"Seeders", "tracker peer stat") stringByAppendingFormat: @": "]; 153 NSAttributedString * seederLabelString = [self attributedStatusWithString: seederLabelBaseString color: statusColor];156 NSAttributedString * seederLabelString = [self attributedStatusWithString: seederLabelBaseString]; 154 157 const NSRect seederLabelRect = [self rectForCountLabelWithString: seederLabelString withRightRect: seederRect 155 158 inBounds: cellFrame]; … … 157 160 158 161 NSString * leecherLabelBaseString = [NSLocalizedString(@"Leechers", "tracker peer stat") stringByAppendingFormat: @": "]; 159 NSAttributedString * leecherLabelString = [self attributedStatusWithString: leecherLabelBaseString color: statusColor];162 NSAttributedString * leecherLabelString = [self attributedStatusWithString: leecherLabelBaseString]; 160 163 const NSRect leecherLabelRect = [self rectForCountLabelWithString: leecherLabelString withRightRect: leecherRect 161 164 inBounds: cellFrame]; … … 163 166 164 167 NSString * downloadedLabelBaseString = [NSLocalizedString(@"Downloaded", "tracker peer stat") stringByAppendingFormat: @": "]; 165 NSAttributedString * downloadedLabelString = [self attributedStatusWithString: downloadedLabelBaseString color: statusColor];168 NSAttributedString * downloadedLabelString = [self attributedStatusWithString: downloadedLabelBaseString]; 166 169 const NSRect downloadedLabelRect = [self rectForCountLabelWithString: downloadedLabelString withRightRect: downloadedRect 167 170 inBounds: cellFrame]; … … 169 172 170 173 //status strings 171 NSAttributedString * lastAnnounceString = [self attributedStatusWithString: [node lastAnnounceStatusString] color: statusColor];174 NSAttributedString * lastAnnounceString = [self attributedStatusWithString: [node lastAnnounceStatusString]]; 172 175 const NSRect lastAnnounceRect = [self rectForStatusWithString: lastAnnounceString withAboveRect: nameRect 173 176 withRightRect: seederLabelRect inBounds: cellFrame]; 174 177 [lastAnnounceString drawInRect: lastAnnounceRect]; 175 178 176 NSAttributedString * nextAnnounceString = [self attributedStatusWithString: [node nextAnnounceStatusString] color: statusColor];179 NSAttributedString * nextAnnounceString = [self attributedStatusWithString: [node nextAnnounceStatusString]]; 177 180 const NSRect nextAnnounceRect = [self rectForStatusWithString: nextAnnounceString withAboveRect: lastAnnounceRect 178 181 withRightRect: leecherLabelRect inBounds: cellFrame]; 179 182 [nextAnnounceString drawInRect: nextAnnounceRect]; 180 183 181 NSAttributedString * lastScrapeString = [self attributedStatusWithString: [node lastScrapeStatusString] color: statusColor];184 NSAttributedString * lastScrapeString = [self attributedStatusWithString: [node lastScrapeStatusString]]; 182 185 const NSRect lastScrapeRect = [self rectForStatusWithString: lastScrapeString withAboveRect: nextAnnounceRect 183 186 withRightRect: downloadedLabelRect inBounds: cellFrame]; … … 291 294 } 292 295 293 - (NSAttributedString *) attributedNameWithColor: (NSColor *) color 294 { 295 [fNameAttributes setObject: color forKey: NSForegroundColorAttributeName]; 296 296 - (NSAttributedString *) attributedName 297 { 297 298 NSString * name = [(TrackerNode *)[self objectValue] host]; 298 299 return [[[NSAttributedString alloc] initWithString: name attributes: fNameAttributes] autorelease]; 299 300 } 300 301 301 - (NSAttributedString *) attributedStatusWithString: (NSString *) statusString color: (NSColor *) color 302 { 303 [fStatusAttributes setObject: color forKey: NSForegroundColorAttributeName]; 304 302 - (NSAttributedString *) attributedStatusWithString: (NSString *) statusString 303 { 305 304 return [[[NSAttributedString alloc] initWithString: statusString attributes: fStatusAttributes] autorelease]; 306 305 } 307 306 308 - (NSAttributedString *) attributedCount: (NSInteger) count color: (NSColor *) color 309 { 310 [fStatusAttributes setObject: color forKey: NSForegroundColorAttributeName]; 311 307 - (NSAttributedString *) attributedCount: (NSInteger) count 308 { 312 309 NSString * countString = count != -1 ? [NSString stringWithFormat: @"%d", count] : NSLocalizedString(@"N/A", "tracker peer stat"); 313 310 return [[[NSAttributedString alloc] initWithString: countString attributes: fStatusAttributes] autorelease];
Note: See TracChangeset
for help on using the changeset viewer.