Changeset 87
- Timestamp:
- 12/22/2002 03:48:36 PM (6 years ago)
- Files:
-
- trunk/adium/Adium.pbproj/project.pbxproj (modified) (5 diffs)
- trunk/adium/Plugins/Standard Message View/AISMTextView.h (modified) (1 diff)
- trunk/adium/Plugins/Standard Message View/AISMTextView.m (modified) (11 diffs)
- trunk/adium/Plugins/Standard Message View/AISMVMessageCell.h (modified) (1 diff)
- trunk/adium/Plugins/Standard Message View/AISMVMessageCell.m (modified) (6 diffs)
- trunk/adium/Plugins/Standard Message View/AISMVSenderCell.h (modified) (1 diff)
- trunk/adium/Plugins/Standard Message View/AISMVSenderCell.m (modified) (5 diffs)
- trunk/adium/Plugins/Standard Message View/AISMVTimeCell.h (added)
- trunk/adium/Plugins/Standard Message View/AISMVTimeCell.m (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/adium/Adium.pbproj/project.pbxproj
r83 r87 3561 3561 target = F50F252D03B0425301A80202; 3562 3562 }; 3563 F55F696303B62F8F01A8010A = { 3564 isa = PBXFileReference; 3565 name = AISMVTimeCell.h; 3566 path = "Plugins/Standard Message View/AISMVTimeCell.h"; 3567 refType = 4; 3568 }; 3569 F55F696403B62F8F01A8010A = { 3570 isa = PBXFileReference; 3571 name = AISMVTimeCell.m; 3572 path = "Plugins/Standard Message View/AISMVTimeCell.m"; 3573 refType = 4; 3574 }; 3575 F55F696503B62F8F01A8010A = { 3576 fileRef = F55F696303B62F8F01A8010A; 3577 isa = PBXBuildFile; 3578 settings = { 3579 }; 3580 }; 3581 F55F696603B62F8F01A8010A = { 3582 fileRef = F55F696403B62F8F01A8010A; 3583 isa = PBXBuildFile; 3584 settings = { 3585 }; 3586 }; 3563 3587 F56621A503AD02AC01A8010A = { 3564 3588 fileEncoding = 30; … … 5801 5825 F5793993033E75B001A8010A, 5802 5826 F5793995033E75B001A8010A, 5827 F55F696303B62F8F01A8010A, 5803 5828 ); 5804 5829 isa = PBXGroup; … … 6266 6291 F570A60C03704EBA01A8010A, 6267 6292 F55B415103AB89E301A8010A, 6293 F55F696403B62F8F01A8010A, 6268 6294 ); 6269 6295 isa = PBXGroup; … … 6279 6305 F570A60D03704EBA01A8010A, 6280 6306 F55B415203AB89E301A8010A, 6307 F55F696503B62F8F01A8010A, 6281 6308 ); 6282 6309 isa = PBXHeadersBuildPhase; … … 6297 6324 F570A60E03704EBA01A8010A, 6298 6325 F55B415303AB89E301A8010A, 6326 F55F696603B62F8F01A8010A, 6299 6327 ); 6300 6328 isa = PBXSourcesBuildPhase; trunk/adium/Plugins/Standard Message View/AISMTextView.h
r4 r87 24 24 NSMutableArray *messageCellArray; 25 25 NSMutableArray *contentArray; 26 NSMutableArray *timeCellArray; 27 float maxTimeWidth; 26 28 27 29 NSMutableArray *senderArray; trunk/adium/Plugins/Standard Message View/AISMTextView.m
r77 r87 20 20 #import "AISMVMessageCell.h" 21 21 #import "AISMVSenderCell.h" 22 #import "AISMVTimeCell.h" 22 23 23 24 #define AUTOSCROLL_CATCH_SIZE 20 //The distance (in pixels) that the scrollview must be within (from the bottom) for auto-scroll to kick in. … … 47 48 - (void)drawRect:(NSRect)rect 48 49 { 49 NSEnumerator *cellEnumerator, *contentEnumerator; 50 NSEnumerator *cellEnumerator, *contentEnumerator, *timeCellEnumerator; 51 NSRect cellFrame, documentVisibleRect; 52 53 NSString *previousTimeString; 54 id previousSource; 55 50 56 AISMVMessageCell *textCell; 51 AIContentMessage *contentObject; 52 NSRect cellFrame = NSMakeRect(0, 0, [self frame].size.width, 0); 53 NSRect documentVisibleRect = [[self enclosingScrollView] documentVisibleRect]; 54 id previousSource = nil; 55 id source; 57 AISMVTimeCell *timeCell; 58 59 56 60 57 //If there isn't enough content to fill our entire view, we draw a section of blankness, and move down, so the content is bottom-aligned 61 //If there isn't enough content to fill our entire view, we move down so the content is bottom-aligned 62 cellFrame = NSMakeRect(0, 0, [self frame].size.width, 0); 63 documentVisibleRect = [[self enclosingScrollView] documentVisibleRect]; 58 64 if(contentsHeight < documentVisibleRect.size.height){ 59 int gapSize = documentVisibleRect.size.height - contentsHeight; 60 61 //Move down so we're bottom aligned 62 cellFrame.origin.y += gapSize; 63 } 64 65 //Set up the bezier paths 65 cellFrame.origin.y += (documentVisibleRect.size.height - contentsHeight); 66 } 67 68 //Prepare for drawing 66 69 [NSBezierPath setDefaultLineWidth:1.0]; 67 70 [NSBezierPath setDefaultLineCapStyle:NSButtLineCapStyle]; 68 71 72 cellEnumerator = [messageCellArray objectEnumerator]; 73 timeCellEnumerator = [timeCellArray objectEnumerator]; 74 contentEnumerator = [contentArray objectEnumerator]; 75 69 76 //Loop through, and draw, each cell 70 cellEnumerator = [messageCellArray objectEnumerator];71 contentEnumerator = [contentArray objectEnumerator];77 previousSource = nil; 78 previousTimeString = nil; 72 79 while((textCell = [cellEnumerator nextObject])){ 80 AIContentMessage *contentObject; 81 NSString *timeString; 82 id source; 83 84 //Fetch all the information needed to display 85 timeCell = [timeCellEnumerator nextObject]; 73 86 contentObject = [contentEnumerator nextObject]; 74 87 cellFrame.size.height = [textCell cellSize].height; 75 88 source = [contentObject source]; 76 77 cellFrame.size.height = [textCell cellSize].height; 78 if(NSIntersectsRect(documentVisibleRect,cellFrame)){ 79 NSRect subFrame; 89 timeString = [timeCell timeString]; 90 91 if(NSIntersectsRect(documentVisibleRect,cellFrame)){ //Only draw visible cells 92 NSSize cellSize; 93 AISMVSenderCell *senderCell; 80 94 81 95 //Draw the text cell 82 subFrame = cellFrame; 83 subFrame.size.width -= maxSenderWidth; 84 subFrame.origin.x += maxSenderWidth; 85 [textCell drawWithFrame:subFrame inView:self]; 86 87 //Draw the divider line and sender string 88 // (we offset 0.5 pixels to achieve a simple 1 pixel aliased line) 89 90 if(source != previousSource){ 91 int senderCellIndex; 92 93 //Draw the sender cell 94 senderCellIndex = [senderArray indexOfObject:source]; 95 if(senderCellIndex != NSNotFound){ 96 AISMVSenderCell *senderCell = [senderCellArray objectAtIndex:senderCellIndex]; 97 98 subFrame = cellFrame; 99 subFrame.size.width = maxSenderWidth; 100 subFrame.origin.x = 0; 101 [senderCell drawWithFrame:subFrame showName:YES inView:self]; 102 } 103 104 //Left portion of the line 96 cellSize = [textCell cellSize]; 97 [textCell drawWithFrame:NSMakeRect(cellFrame.origin.x + maxSenderWidth, 98 cellFrame.origin.y, 99 cellSize.width, 100 cellFrame.size.height) 101 inView:self]; 102 103 //Draw the sender cell 104 senderCell = [senderCellArray objectAtIndex:[senderArray indexOfObject:source]]; 105 [senderCell drawWithFrame:NSMakeRect(cellFrame.origin.x, 106 cellFrame.origin.y, 107 maxSenderWidth, 108 cellFrame.size.height) 109 showName:(source != previousSource) 110 inView:self]; 111 112 //Draw the time cell 113 [timeCell drawWithFrame:NSMakeRect(cellFrame.origin.x + cellFrame.size.width - maxTimeWidth, 114 cellFrame.origin.y, 115 maxTimeWidth, 116 cellFrame.size.height) 117 showTime:([timeString compare:previousTimeString] != 0) 118 inView:self]; 119 120 //Draw the divider line (offset 0.5 pixels for an aliased line) 121 if(source != previousSource){ 122 [lineColorDarkDivider set]; 123 [NSBezierPath strokeLineFromPoint:NSMakePoint(cellFrame.origin.x, cellFrame.origin.y + 0.5) 124 toPoint:NSMakePoint(cellFrame.origin.x + maxSenderWidth, cellFrame.origin.y + 0.5)]; 125 105 126 [lineColorDivider set]; 106 [lineColorDarkDivider set]; 107 [NSBezierPath strokeLineFromPoint:NSMakePoint(cellFrame.origin.x, cellFrame.origin.y + 0.5) toPoint:NSMakePoint(cellFrame.origin.x + cellFrame.size.width, cellFrame.origin.y + 0.5)]; 108 109 //Right portion of the line 110 [lineColorDivider set]; 111 [NSBezierPath strokeLineFromPoint:NSMakePoint(cellFrame.origin.x, cellFrame.origin.y + 0.5) toPoint:NSMakePoint(cellFrame.origin.x + cellFrame.size.width, cellFrame.origin.y + 0.5)]; 112 113 }else{ 114 int senderCellIndex; 115 116 //Draw an empty sender cell 117 senderCellIndex = [senderArray indexOfObject:source]; 118 if(senderCellIndex != NSNotFound){ 119 AISMVSenderCell *senderCell = [senderCellArray objectAtIndex:senderCellIndex]; 120 121 subFrame = cellFrame; 122 subFrame.size.width = maxSenderWidth; 123 subFrame.origin.x = 0; 124 [senderCell drawWithFrame:subFrame showName:NO inView:self]; 125 } 127 [NSBezierPath strokeLineFromPoint:NSMakePoint(cellFrame.origin.x + maxSenderWidth, cellFrame.origin.y + 0.5) 128 toPoint:NSMakePoint(cellFrame.origin.x + maxSenderWidth + cellFrame.size.width, cellFrame.origin.y + 0.5)]; 126 129 } 127 130 } … … 129 132 //Next.. 130 133 cellFrame.origin.y += cellFrame.size.height; 134 previousTimeString = timeString; 131 135 previousSource = source; 132 136 } … … 159 163 senderArray = [[NSMutableArray alloc] init]; 160 164 senderCellArray = [[NSMutableArray alloc] init]; 165 timeCellArray = [[NSMutableArray alloc] init]; 161 166 contentsHeight = 0; 162 167 maxSenderWidth = 0; … … 199 204 [senderArray release]; 200 205 [senderCellArray release]; 206 [timeCellArray release]; 201 207 202 208 [super dealloc]; … … 207 213 return(YES); 208 214 } 209 210 211 //Called after we're inserted in a window212 /*- (void)viewDidMoveToSuperview213 {214 //Recalculate the cell dimensions and redisplay215 [self resizeToFillContainerView];216 [self resizeCells];217 [self setNeedsDisplay:YES];218 }*/219 220 //Called before we're inserted in a window221 /*- (void)viewWillMoveToSuperview:(NSView *)newSuperview222 {223 //force a cell resize224 225 }*/226 215 227 216 //Called when the frame changes. Adjust to fill the new frame … … 234 223 } 235 224 236 //Called after the view is resized. Re-calculate the cell dimensions237 /*- (void)viewDidEndLiveResize238 {239 //Recalculate the cell dimensions and redisplay240 [self resizeToFillContainerView];241 [self resizeCells];242 [self setNeedsDisplay:YES];243 }*/244 245 225 //Flush and completely rebuild the message cell array 246 226 - (void)buildMessageCellArray … … 259 239 [self addCellsForContactObject:object]; 260 240 } 261 262 241 } 263 242 … … 265 244 - (void)addCellsForContactObject:(NSObject<AIContentObject> *)object 266 245 { 246 AISMVSenderCell *senderCell; 267 247 AISMVMessageCell *messageCell; 268 float width;// = [self frame].size.width - maxSenderWidth;248 AISMVTimeCell *timeCell; 269 249 270 250 if([[object type] compare:CONTENT_MESSAGE_TYPE] == 0){ //Message content 271 NSMutableParagraphStyle *paragraphStyle = [[[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];272 251 AIContentMessage *contentMessage = (AIContentMessage *)object; 273 252 id messageSource = [contentMessage source]; 274 float height; 253 BOOL outgoing = ([messageSource isKindOfClass:[AIAccount class]]); 254 255 //Add it to our content array 256 [contentArray addObject:object]; 275 257 276 258 //Create a sender cell (if one doesn't already exist) 277 259 if([senderArray indexOfObject:messageSource] == NSNotFound){ 278 AISMVSenderCell *senderCell; 279 NSDictionary *attributes; 280 NSAttributedString *attributedName; 281 NSString *senderName; 282 NSColor *backgroundColor; 283 NSColor *textColor; 284 285 if([messageSource isKindOfClass:[AIAccount class]]){ 286 senderName = [NSString stringWithFormat:@"%@:",[(AIAccount *)messageSource accountDescription]]; 287 backgroundColor = backColorOut; 288 textColor = outgoingSourceColor; 289 260 if(outgoing){ 261 senderCell = [AISMVSenderCell senderCellWithString:[NSString stringWithFormat:@"%@:",[(AIAccount *)messageSource accountDescription]] 262 textColor:outgoingSourceColor 263 backgroundColor:backColorOut 264 font:[NSFont systemFontOfSize:11]]; 290 265 }else{ 291 sender Name = [NSString stringWithFormat:@"%@:",[(AIContactHandle *)messageSource displayName]];292 backgroundColor = backColorIn;293 textColor = incomingSourceColor;294 266 senderCell = [AISMVSenderCell senderCellWithString:[NSString stringWithFormat:@"%@:",[(AIContactHandle *)messageSource displayName]] 267 textColor:incomingSourceColor 268 backgroundColor:backColorIn 269 font:[NSFont systemFontOfSize:11]]; 295 270 } 296 271 297 //Create the cell298 [paragraphStyle setAlignment:NSRightTextAlignment];299 attributes = [NSDictionary dictionaryWithObjectsAndKeys:textColor,NSForegroundColorAttributeName,[NSFont systemFontOfSize:11],NSFontAttributeName,paragraphStyle,NSParagraphStyleAttributeName,nil];300 attributedName = [[[NSAttributedString alloc] initWithString:senderName attributes:attributes] autorelease];301 senderCell = [AISMVSenderCell senderCellWithString:attributedName];302 [senderCell setBackgroundColor:backgroundColor];303 304 272 //Cache it 305 273 [senderArray addObject:messageSource]; 306 274 [senderCellArray addObject:senderCell]; 307 308 if([senderCell cellSize].width > maxSenderWidth){ 275 276 if([senderCell cellSize].width > maxSenderWidth){ //Resize the sender cells if this one is wider 309 277 maxSenderWidth = [senderCell cellSize].width; 310 [self resizeCells]; //resize our cells so they adjust to the new sender width278 [self resizeCells]; 311 279 } 312 280 } 313 314 //if([ 315 //left line = 194 316 //Dark name zone = 208 317 //light name zone = 234 318 //vertical divider = 207 319 320 //track it in our content array 321 [contentArray addObject:object]; 322 281 282 283 //Create a time cell 284 //User's localized date format: [[NSUserDefaults standardUserDefaults] objectForKey:NSTimeFormatString] w/ seconds 285 timeCell = [AISMVTimeCell timeCellWithDate:[contentMessage date] 286 format:@"%1I:%M" 287 textColor:[NSColor grayColor] 288 backgroundColor:(outgoing ? backColorOut : backColorIn) 289 font:[NSFont fontWithName:@"Helvetica" size:10]]; 290 [timeCellArray addObject:timeCell]; 291 if([timeCell cellSize].width > maxTimeWidth){ //Resize the time cells if this one is wider 292 maxTimeWidth = [timeCell cellSize].width; 293 [self resizeCells]; 294 } 295 296 323 297 //Create a message cell 324 messageCell = [AISMVMessageCell messageCellWithString:[contentMessage message]]; 325 width = [self frame].size.width - maxSenderWidth; 326 height = [messageCell sizeCellForWidth:width].height; 327 if([messageSource isKindOfClass:[AIAccount class]]){ 328 [messageCell setBackgroundColor:backColorOut]; 329 }else{ 330 [messageCell setBackgroundColor:backColorIn]; 331 } 332 333 298 messageCell = [AISMVMessageCell messageCellWithString:[contentMessage message] 299 backgroundColor:(outgoing ? backColorOut : backColorIn)]; 334 300 [messageCellArray addObject:messageCell]; 335 contentsHeight += height; 336 301 302 303 //Increase our height to fit this new cell 304 contentsHeight += [messageCell sizeCellForWidth:([self frame].size.width - maxSenderWidth - maxTimeWidth) ].height; 337 305 338 306 }else{ //Unknown content … … 351 319 //Determine our width 352 320 enclosingScrollView = [self enclosingScrollView]; 353 width = [enclosingScrollView documentVisibleRect].size.width - maxSenderWidth ;321 width = [enclosingScrollView documentVisibleRect].size.width - maxSenderWidth - maxTimeWidth; 354 322 355 323 //Resize our cells … … 392 360 @end 393 361 394 395 396 397 398 399 400 trunk/adium/Plugins/Standard Message View/AISMVMessageCell.h
r4 r87 31 31 } 32 32 33 + (AISMVMessageCell *)messageCellWithString:(NSAttributedString *)inString ;33 + (AISMVMessageCell *)messageCellWithString:(NSAttributedString *)inString backgroundColor:(NSColor *)inBackgroundColor; 34 34 - (NSSize)sizeCellForWidth:(float)inWidth; 35 35 - (NSSize)cellSize; 36 36 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView; 37 - (void)setBackgroundColor:(NSColor *)inColor;38 37 39 38 @end trunk/adium/Plugins/Standard Message View/AISMVMessageCell.m
r75 r87 21 21 22 22 @interface AISMVMessageCell (PRIVATE) 23 - (AISMVMessageCell *)initMessageCellWithString:(NSAttributedString *)inString ;23 - (AISMVMessageCell *)initMessageCellWithString:(NSAttributedString *)inString backgroundColor:(NSColor *)inBackgroundColor; 24 24 @end 25 25 … … 32 32 33 33 //Create a new cell 34 + (AISMVMessageCell *)messageCellWithString:(NSAttributedString *)inString 34 + (AISMVMessageCell *)messageCellWithString:(NSAttributedString *)inString backgroundColor:(NSColor *)inBackgroundColor 35 35 { 36 return([[[self alloc] initMessageCellWithString:inString ] autorelease]);36 return([[[self alloc] initMessageCellWithString:inString backgroundColor:inBackgroundColor] autorelease]); 37 37 } 38 38 … … 53 53 - (NSSize)cellSize{ 54 54 return(cellSize); 55 }56 57 //Set the background color of this cell58 - (void)setBackgroundColor:(NSColor *)inColor59 {60 backgroundColor = [inColor retain];61 55 } 62 56 … … 80 74 81 75 //Private -------------------------------------------------------------------------------- 82 - (AISMVMessageCell *)initMessageCellWithString:(NSAttributedString *)inString 76 - (AISMVMessageCell *)initMessageCellWithString:(NSAttributedString *)inString backgroundColor:(NSColor *)inBackgroundColor 83 77 { 84 78 [super init]; … … 86 80 //Init 87 81 string = [inString retain]; 88 backgroundColor = nil;82 backgroundColor = [inBackgroundColor retain]; 89 83 90 84 //Setup the layout manager and text container … … 114 108 @end 115 109 116 117 118 119 120 /*121 122 //Return the layout manager for our message text123 - (NSLayoutManager *)messageLayoutManagerWithWidth:(int)inWidth124 {125 if(!messageLayoutManager || messageLayoutWidth != inWidth){126 NSTextStorage *textStorage;127 NSTextContainer *textContainer;128 129 // NSLog(@"layout width %i",(int)inWidth);130 131 //Setup the layout manager and text container132 textStorage = [[NSTextStorage alloc] initWithAttributedString:[self messageString]];133 textContainer = [[NSTextContainer alloc] initWithContainerSize:NSMakeSize(inWidth, 1e7)];134 messageLayoutManager = [[NSLayoutManager alloc] init];135 136 //Configure137 [textContainer setLineFragmentPadding:0.0];138 [messageLayoutManager addTextContainer:textContainer];139 [textStorage addLayoutManager:messageLayoutManager];140 141 messageGlyphRange = [messageLayoutManager glyphRangeForTextContainer:textContainer];142 messageLayoutWidth = inWidth;143 }144 145 return(messageLayoutManager);146 }147 148 //Return the string of our sender149 - (NSAttributedString *)senderString150 {151 if(!senderString){152 AIContactHandle *source;153 NSString *senderNameString;154 NSColor *senderColor;155 BOOL incoming;156 NSMutableParagraphStyle *style;157 158 //Get the sender information159 source = [object source];160 161 if([source isKindOfClass:[AIAccount class]]){162 senderNameString = [(AIAccount *)source accountDescription];163 }else{164 senderNameString = [source displayName];165 }166 incoming = ![source isKindOfClass:[AIAccount class]];167 168 //Prepare some attributes169 style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];170 [style setAlignment:NSRightTextAlignment];171 172 if(incoming){173 senderColor = [[[owner preferenceController] preferenceForKey:@"message_incoming_darkPrefixColor" group:PREF_GROUP_GENERAL object:source] representedColor];174 }else{175 senderColor = [[[owner preferenceController] preferenceForKey:@"message_outgoing_darkPrefixColor" group:PREF_GROUP_GENERAL object:source] representedColor];176 }177 178 //Create179 senderString = [[NSAttributedString alloc] initWithString:senderNameString attributes:[NSDictionary dictionaryWithObjectsAndKeys:[NSFont boldSystemFontOfSize:12], NSFontAttributeName, style, NSParagraphStyleAttributeName, senderColor, NSForegroundColorAttributeName, nil]];180 }181 182 return(senderString);183 }184 */185 186 /* NSRect segmentRect;187 AIContactHandle *sender;188 BOOL incoming;189 190 NSColor *messageRowIn = [[preferenceController preferenceForKey:@"message_incoming_backgroundColor" group:PREF_GROUP_GENERAL object:sender] representedColor];191 NSColor *messageRowOut = [[preferenceController preferenceForKey:@"message_outgoing_backgroundColor" group:PREF_GROUP_GENERAL object:sender] representedColor];192 193 194 sender = [object source];195 incoming = ![[object source] isKindOfClass:[AIAccount class]];196 197 198 //Draw the sender Gradient199 segmentRect = cellFrame;200 segmentRect.size.width = senderWidth;201 if(incoming){202 [AIGradient drawGradientInRect:segmentRect from:messageRowIn to:[messageRowIn darkenBy:0.10]];203 }else{204 [AIGradient drawGradientInRect:segmentRect from:messageRowOut to:[messageRowOut darkenBy:0.10]];205 }206 207 //Draw sender string208 if(drawSource){209 segmentRect.size.width -= SENDER_PADDING;210 [[self senderString] drawInRect:segmentRect];211 segmentRect.size.width += SENDER_PADDING;212 }213 214 //Draw the message background215 segmentRect.origin.x += segmentRect.size.width;216 segmentRect.size.width = cellFrame.size.width - segmentRect.origin.x;217 218 if(incoming){219 [messageRowIn set];220 }else{221 [messageRowOut set];222 }223 [NSBezierPath fillRect:segmentRect];224 225 //Draw the message string226 segmentRect.origin.x += MESSAGE_PADDING;227 228 [[self messageLayoutManagerWithWidth:(lastCellSize.width - senderWidth - MESSAGE_PADDING * 2)] drawGlyphsForGlyphRange:messageGlyphRange atPoint:segmentRect.origin];*/trunk/adium/Plugins/Standard Message View/AISMVSenderCell.h
r4 r87 18 18 19 19 @interface AISMVSenderCell : NSCell { 20 NSAttributedString * string;21 20 NSAttributedString *attributedSenderString; 21 22 22 NSSize cellSize; 23 23 NSColor *backgroundColor; 24 NSColor *darkBackgroundColor; 25 24 26 } 25 27 26 + (AISMVSenderCell *)senderCellWithString:(NSAttributedString *)inString; 27 //- (NSSize)sizeCellForWidth:(float)inWidth; 28 + (AISMVSenderCell *)senderCellWithString:(NSString *)inString textColor:(NSColor *)inTextColor backgroundColor:(NSColor *)inBackColor font:(NSFont *)inFont; 28 29 - (NSSize)cellSize; 29 30 - (void)drawWithFrame:(NSRect)cellFrame showName:(BOOL)showName inView:(NSView *)controlView; 30 - (void)setBackgroundColor:(NSColor *)inColor;31 31 32 32 @end trunk/adium/Plugins/Standard Message View/AISMVSenderCell.m
r4 r87 22 22 23 23 @interface AISMVSenderCell (PRIVATE) 24 - (AISMVSenderCell *)initSenderCellWithString:(NS AttributedString *)inString;24 - (AISMVSenderCell *)initSenderCellWithString:(NSString *)inString textColor:(NSColor *)inTextColor backgroundColor:(NSColor *)inBackColor font:(NSFont *)inFont; 25 25 @end 26 26 … … 28 28 29 29 //Create a new cell 30 + (AISMVSenderCell *)senderCellWithString:(NS AttributedString *)inString30 + (AISMVSenderCell *)senderCellWithString:(NSString *)inString textColor:(NSColor *)inTextColor backgroundColor:(NSColor *)inBackColor font:(NSFont *)inFont 31 31 { 32 return([[[self alloc] initSenderCellWithString:inString ] autorelease]);32 return([[[self alloc] initSenderCellWithString:inString textColor:inTextColor backgroundColor:inBackColor font:inFont] autorelease]); 33 33 } 34 34 35 35 //Returns the last calculated cellSize (so, the last value returned by cellSizeForBounds) 36 - (NSSize)cellSize{ 36 - (NSSize)cellSize 37 { 37 38 return(cellSize); 38 }39 40 //Set the background color of this cell41 - (void)setBackgroundColor:(NSColor *)inColor42 {43 backgroundColor = [inColor retain];44 39 } 45 40 … … 48 43 { 49 44 //Draw our background 50 if(backgroundColor){ 51 [AIGradient drawGradientInRect:cellFrame from:backgroundColor to:[backgroundColor darkenBy:0.09]]; 52 }else{ 53 [AIGradient drawGradientInRect:cellFrame from:[NSColor whiteColor] to:[NSColor redColor]]; 54 } 55 45 [AIGradient drawGradientInRect:cellFrame from:backgroundColor to:darkBackgroundColor]; 46 56 47 //Draw the name string 57 48 if(showName){ … … 59 50 cellFrame.origin.x += SENDER_PADDING_L; 60 51 61 [ string drawInRect:cellFrame];52 [attributedSenderString drawInRect:cellFrame]; 62 53 } 63 54 } 64 55 65 56 //Private -------------------------------------------------------------------------------- 66 - (AISMVSenderCell *)initSenderCellWithString:(NS AttributedString *)inString57 - (AISMVSenderCell *)initSenderCellWithString:(NSString *)inString textColor:(NSColor *)inTextColor backgroundColor:(NSColor *)inBackColor font:(NSFont *)inFont 67 58 { 68 NSSize stringSize; 59 NSMutableParagraphStyle *paragraphStyle; 60 NSDictionary *attributes; 61 NSSize stringSize; 62 63 //Init 64 [super init]; 65 backgroundColor = [inBackColor retain]; 66 darkBackgroundColor = [[backgroundColor darkenBy:0.09] retain]; 69 67 70 [super init]; 68 //Apply attributes to the name 69 paragraphStyle = [[[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy] autorelease]; 70 [paragraphStyle setAlignment:NSRightTextAlignment]; 71 71 72 //Init 73 string = [inString retain]; 74 backgroundColor = nil; 75 76 //Precalc our cell size 77 stringSize = [string size]; 78 cellSize = NSMakeSize(stringSize.width + SENDER_PADDING_L + SENDER_PADDING_R + STRING_ROUNDOFF_PADDING, stringSize.height); 72 attributes = [NSDictionary dictionaryWithObjectsAndKeys: 73 inTextColor, NSForegroundColorAttributeName, 74 inFont, NSFontAttributeName, 75 paragraphStyle, NSParagraphStyleAttributeName, 76 nil]; 77 78 attributedSenderString = [[NSAttributedString alloc] initWithString:inString attributes:attributes]; 79 80 //Pre-calculate the cell size 81 stringSize = [attributedSenderString size]; 82 cellSize = NSMakeSize((int)stringSize.width + SENDER_PADDING_L + SENDER_PADDING_R + STRING_ROUNDOFF_PADDING, stringSize.height); 79 83 80 84 return(self); … … 84 88 { 85 89 [backgroundColor release]; 86 [string release]; 90 [attributedSenderString release]; 91 [darkBackgroundColor release]; 87 92 88 93 [super dealloc];