Adium

Changeset 87

Show
Ignore:
Timestamp:
12/22/2002 03:48:36 PM (6 years ago)
Author:
adamiser
Message:

- Message view now has time stamps
- Cleaned up the message view classes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/adium/Adium.pbproj/project.pbxproj

    r83 r87  
    35613561                        target = F50F252D03B0425301A80202; 
    35623562                }; 
     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                }; 
    35633587                F56621A503AD02AC01A8010A = { 
    35643588                        fileEncoding = 30; 
     
    58015825                                F5793993033E75B001A8010A, 
    58025826                                F5793995033E75B001A8010A, 
     5827                                F55F696303B62F8F01A8010A, 
    58035828                        ); 
    58045829                        isa = PBXGroup; 
     
    62666291                                F570A60C03704EBA01A8010A, 
    62676292                                F55B415103AB89E301A8010A, 
     6293                                F55F696403B62F8F01A8010A, 
    62686294                        ); 
    62696295                        isa = PBXGroup; 
     
    62796305                                F570A60D03704EBA01A8010A, 
    62806306                                F55B415203AB89E301A8010A, 
     6307                                F55F696503B62F8F01A8010A, 
    62816308                        ); 
    62826309                        isa = PBXHeadersBuildPhase; 
     
    62976324                                F570A60E03704EBA01A8010A, 
    62986325                                F55B415303AB89E301A8010A, 
     6326                                F55F696603B62F8F01A8010A, 
    62996327                        ); 
    63006328                        isa = PBXSourcesBuildPhase; 
  • trunk/adium/Plugins/Standard Message View/AISMTextView.h

    r4 r87  
    2424    NSMutableArray      *messageCellArray; 
    2525    NSMutableArray      *contentArray; 
     26    NSMutableArray      *timeCellArray; 
     27    float               maxTimeWidth; 
    2628     
    2729    NSMutableArray      *senderArray; 
  • trunk/adium/Plugins/Standard Message View/AISMTextView.m

    r77 r87  
    2020#import "AISMVMessageCell.h" 
    2121#import "AISMVSenderCell.h" 
     22#import "AISMVTimeCell.h" 
    2223 
    2324#define AUTOSCROLL_CATCH_SIZE   20      //The distance (in pixels) that the scrollview must be within (from the bottom) for auto-scroll to kick in. 
     
    4748- (void)drawRect:(NSRect)rect 
    4849{ 
    49     NSEnumerator                *cellEnumerator, *contentEnumerator; 
     50    NSEnumerator                *cellEnumerator, *contentEnumerator, *timeCellEnumerator; 
     51    NSRect                      cellFrame, documentVisibleRect; 
     52 
     53    NSString                    *previousTimeString; 
     54    id                          previousSource; 
     55 
    5056    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 
    5660     
    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]; 
    5864    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 
    6669    [NSBezierPath setDefaultLineWidth:1.0]; 
    6770    [NSBezierPath setDefaultLineCapStyle:NSButtLineCapStyle]; 
    6871 
     72    cellEnumerator = [messageCellArray objectEnumerator]; 
     73    timeCellEnumerator = [timeCellArray objectEnumerator]; 
     74    contentEnumerator = [contentArray objectEnumerator]; 
     75 
    6976    //Loop through, and draw, each cell 
    70     cellEnumerator = [messageCellArray objectEnumerator]
    71     contentEnumerator = [contentArray objectEnumerator]
     77    previousSource = nil
     78    previousTimeString = nil
    7279    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]; 
    7386        contentObject = [contentEnumerator nextObject]; 
    74  
     87        cellFrame.size.height = [textCell cellSize].height; 
    7588        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; 
    8094             
    8195            //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 
    105126                [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)]; 
    126129            } 
    127130        } 
     
    129132        //Next.. 
    130133        cellFrame.origin.y += cellFrame.size.height; 
     134        previousTimeString = timeString; 
    131135        previousSource = source; 
    132136    } 
     
    159163    senderArray = [[NSMutableArray alloc] init]; 
    160164    senderCellArray = [[NSMutableArray alloc] init]; 
     165    timeCellArray = [[NSMutableArray alloc] init]; 
    161166    contentsHeight = 0; 
    162167    maxSenderWidth = 0; 
     
    199204    [senderArray release]; 
    200205    [senderCellArray release]; 
     206    [timeCellArray release]; 
    201207 
    202208    [super dealloc]; 
     
    207213    return(YES); 
    208214} 
    209  
    210  
    211 //Called after we're inserted in a window 
    212 /*- (void)viewDidMoveToSuperview 
    213 { 
    214     //Recalculate the cell dimensions and redisplay 
    215     [self resizeToFillContainerView]; 
    216     [self resizeCells]; 
    217     [self setNeedsDisplay:YES]; 
    218 }*/ 
    219  
    220 //Called before we're inserted in a window 
    221 /*- (void)viewWillMoveToSuperview:(NSView *)newSuperview 
    222 { 
    223     //force a cell resize 
    224      
    225 }*/ 
    226215 
    227216//Called when the frame changes.  Adjust to fill the new frame 
     
    234223} 
    235224 
    236 //Called after the view is resized.  Re-calculate the cell dimensions 
    237 /*- (void)viewDidEndLiveResize 
    238 { 
    239     //Recalculate the cell dimensions and redisplay 
    240     [self resizeToFillContainerView]; 
    241     [self resizeCells]; 
    242     [self setNeedsDisplay:YES]; 
    243 }*/ 
    244  
    245225//Flush and completely rebuild the message cell array 
    246226- (void)buildMessageCellArray 
     
    259239        [self addCellsForContactObject:object]; 
    260240    } 
    261  
    262241} 
    263242 
     
    265244- (void)addCellsForContactObject:(NSObject<AIContentObject> *)object 
    266245{ 
     246    AISMVSenderCell     *senderCell; 
    267247    AISMVMessageCell    *messageCell; 
    268     float              width;// = [self frame].size.width - maxSenderWidth
     248    AISMVTimeCell      *timeCell
    269249     
    270250    if([[object type] compare:CONTENT_MESSAGE_TYPE] == 0){ //Message content 
    271         NSMutableParagraphStyle *paragraphStyle = [[[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy] autorelease]; 
    272251        AIContentMessage        *contentMessage = (AIContentMessage *)object; 
    273252        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]; 
    275257 
    276258        //Create a sender cell (if one doesn't already exist) 
    277259        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]]; 
    290265            }else{ 
    291                 senderName = [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]]; 
    295270            } 
    296271             
    297             //Create the cell 
    298             [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  
    304272            //Cache it 
    305273            [senderArray addObject:messageSource]; 
    306274            [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 
    309277                maxSenderWidth = [senderCell cellSize].width; 
    310                 [self resizeCells]; //resize our cells so they adjust to the new sender width 
     278                [self resizeCells]; 
    311279            } 
    312280        } 
    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         
    323297        //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)]; 
    334300        [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; 
    337305 
    338306    }else{ //Unknown content 
     
    351319    //Determine our width 
    352320    enclosingScrollView = [self enclosingScrollView]; 
    353     width = [enclosingScrollView documentVisibleRect].size.width - maxSenderWidth
     321    width = [enclosingScrollView documentVisibleRect].size.width - maxSenderWidth - maxTimeWidth
    354322 
    355323    //Resize our cells 
     
    392360@end 
    393361 
    394  
    395  
    396  
    397  
    398  
    399  
    400  
  • trunk/adium/Plugins/Standard Message View/AISMVMessageCell.h

    r4 r87  
    3131} 
    3232 
    33 + (AISMVMessageCell *)messageCellWithString:(NSAttributedString *)inString
     33+ (AISMVMessageCell *)messageCellWithString:(NSAttributedString *)inString backgroundColor:(NSColor *)inBackgroundColor
    3434- (NSSize)sizeCellForWidth:(float)inWidth; 
    3535- (NSSize)cellSize; 
    3636- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView; 
    37 - (void)setBackgroundColor:(NSColor *)inColor; 
    3837 
    3938@end 
  • trunk/adium/Plugins/Standard Message View/AISMVMessageCell.m

    r75 r87  
    2121 
    2222@interface AISMVMessageCell (PRIVATE) 
    23 - (AISMVMessageCell *)initMessageCellWithString:(NSAttributedString *)inString
     23- (AISMVMessageCell *)initMessageCellWithString:(NSAttributedString *)inString backgroundColor:(NSColor *)inBackgroundColor
    2424@end 
    2525 
     
    3232 
    3333//Create a new cell 
    34 + (AISMVMessageCell *)messageCellWithString:(NSAttributedString *)inString 
     34+ (AISMVMessageCell *)messageCellWithString:(NSAttributedString *)inString backgroundColor:(NSColor *)inBackgroundColor 
    3535{ 
    36     return([[[self alloc] initMessageCellWithString:inString] autorelease]); 
     36    return([[[self alloc] initMessageCellWithString:inString backgroundColor:inBackgroundColor] autorelease]); 
    3737} 
    3838 
     
    5353- (NSSize)cellSize{ 
    5454    return(cellSize); 
    55 } 
    56  
    57 //Set the background color of this cell 
    58 - (void)setBackgroundColor:(NSColor *)inColor 
    59 { 
    60     backgroundColor = [inColor retain]; 
    6155} 
    6256 
     
    8074 
    8175//Private -------------------------------------------------------------------------------- 
    82 - (AISMVMessageCell *)initMessageCellWithString:(NSAttributedString *)inString 
     76- (AISMVMessageCell *)initMessageCellWithString:(NSAttributedString *)inString backgroundColor:(NSColor *)inBackgroundColor 
    8377{ 
    8478    [super init]; 
     
    8680    //Init 
    8781    string = [inString retain]; 
    88     backgroundColor = nil
     82    backgroundColor = [inBackgroundColor retain]
    8983     
    9084    //Setup the layout manager and text container 
     
    114108@end 
    115109 
    116  
    117  
    118  
    119  
    120 /* 
    121  
    122 //Return the layout manager for our message text 
    123 - (NSLayoutManager *)messageLayoutManagerWithWidth:(int)inWidth 
    124 { 
    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 container 
    132         textStorage = [[NSTextStorage alloc] initWithAttributedString:[self messageString]]; 
    133         textContainer = [[NSTextContainer alloc] initWithContainerSize:NSMakeSize(inWidth, 1e7)]; 
    134         messageLayoutManager = [[NSLayoutManager alloc] init]; 
    135          
    136         //Configure 
    137         [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 sender 
    149 - (NSAttributedString *)senderString 
    150 { 
    151     if(!senderString){ 
    152         AIContactHandle         *source; 
    153         NSString                        *senderNameString; 
    154         NSColor                 *senderColor; 
    155         BOOL                    incoming; 
    156         NSMutableParagraphStyle *style; 
    157      
    158         //Get the sender information 
    159         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 attributes 
    169         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         //Create 
    179         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 Gradient 
    199     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 string 
    208     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 background 
    215     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 string 
    226     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  
    1818 
    1919@interface AISMVSenderCell : NSCell { 
    20     NSAttributedString  *string; 
    21      
     20    NSAttributedString  *attributedSenderString; 
     21 
    2222    NSSize              cellSize; 
    2323    NSColor             *backgroundColor; 
     24    NSColor             *darkBackgroundColor; 
     25     
    2426} 
    2527 
    26 + (AISMVSenderCell *)senderCellWithString:(NSAttributedString *)inString; 
    27 //- (NSSize)sizeCellForWidth:(float)inWidth; 
     28+ (AISMVSenderCell *)senderCellWithString:(NSString *)inString textColor:(NSColor *)inTextColor backgroundColor:(NSColor *)inBackColor font:(NSFont *)inFont; 
    2829- (NSSize)cellSize; 
    2930- (void)drawWithFrame:(NSRect)cellFrame showName:(BOOL)showName inView:(NSView *)controlView; 
    30 - (void)setBackgroundColor:(NSColor *)inColor; 
    3131 
    3232@end 
  • trunk/adium/Plugins/Standard Message View/AISMVSenderCell.m

    r4 r87  
    2222 
    2323@interface AISMVSenderCell (PRIVATE) 
    24 - (AISMVSenderCell *)initSenderCellWithString:(NSAttributedString *)inString
     24- (AISMVSenderCell *)initSenderCellWithString:(NSString *)inString textColor:(NSColor *)inTextColor backgroundColor:(NSColor *)inBackColor font:(NSFont *)inFont
    2525@end 
    2626 
     
    2828 
    2929//Create a new cell 
    30 + (AISMVSenderCell *)senderCellWithString:(NSAttributedString *)inString 
     30+ (AISMVSenderCell *)senderCellWithString:(NSString *)inString textColor:(NSColor *)inTextColor backgroundColor:(NSColor *)inBackColor font:(NSFont *)inFont 
    3131{ 
    32     return([[[self alloc] initSenderCellWithString:inString] autorelease]); 
     32    return([[[self alloc] initSenderCellWithString:inString textColor:inTextColor backgroundColor:inBackColor font:inFont] autorelease]); 
    3333} 
    3434 
    3535//Returns the last calculated cellSize (so, the last value returned by cellSizeForBounds) 
    36 - (NSSize)cellSize{ 
     36- (NSSize)cellSize 
     37
    3738    return(cellSize); 
    38 } 
    39  
    40 //Set the background color of this cell 
    41 - (void)setBackgroundColor:(NSColor *)inColor 
    42 { 
    43     backgroundColor = [inColor retain]; 
    4439} 
    4540 
     
    4843{ 
    4944    //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 
    5647    //Draw the name string 
    5748    if(showName){ 
     
    5950        cellFrame.origin.x += SENDER_PADDING_L; 
    6051 
    61         [string drawInRect:cellFrame]; 
     52        [attributedSenderString drawInRect:cellFrame]; 
    6253    } 
    6354} 
    6455 
    6556//Private -------------------------------------------------------------------------------- 
    66 - (AISMVSenderCell *)initSenderCellWithString:(NSAttributedString *)inString 
     57- (AISMVSenderCell *)initSenderCellWithString:(NSString *)inString textColor:(NSColor *)inTextColor backgroundColor:(NSColor *)inBackColor font:(NSFont *)inFont 
    6758{ 
    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]; 
    6967 
    70     [super init]; 
     68    //Apply attributes to the name 
     69    paragraphStyle = [[[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy] autorelease]; 
     70    [paragraphStyle setAlignment:NSRightTextAlignment]; 
    7171 
    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); 
    7983 
    8084    return(self); 
     
    8488{ 
    8589    [backgroundColor release]; 
    86     [string release]; 
     90    [attributedSenderString release]; 
     91    [darkBackgroundColor release]; 
    8792 
    8893    [super dealloc];