Adium

Changeset 14255

Show
Ignore:
Timestamp:
11/30/2005 07:58:49 PM (3 years ago)
Author:
boredzo
Message:

We no longer use AppleGothic to draw the arrow badges on icons in the File Transfers window. Instead, we draw the arrow ourselves. Fixes #2300.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/adium-0.8/Frameworks/Adium Framework/ESFileTransfer.m

    r14111 r14255  
    1919#import "ESFileTransfer.h" 
    2020 
    21  
    22 #define UPLOAD_ARROW            [NSString stringWithFormat:@"%C", 0x2B06] 
    23 #define DOWNLOAD_ARROW          [NSString stringWithFormat:@"%C", 0x2B07] 
    24  
     21static NSBezierPath *arrowPath = nil; 
    2522 
    2623@implementation ESFileTransfer 
     
    271268        if (extension && [extension length]) {           
    272269                NSImage         *systemIcon = [[NSWorkspace sharedWorkspace] iconForFileType:extension]; 
    273                 NSString        *badgeArrow = nil;  
    274270                NSFont          *appleGothicFont = [NSFont fontWithName:@"AppleGothic" size:24]; 
    275271 
    276                 switch (type) { 
    277                         case Incoming_FileTransfer: 
    278                                 badgeArrow = DOWNLOAD_ARROW; 
    279                                 break; 
    280                         case Outgoing_FileTransfer: 
    281                                 badgeArrow = UPLOAD_ARROW;                       
    282                                 break; 
    283                         case Unknown_FileTransfer: 
    284                         default: 
    285                                 break; 
    286                 } 
    287                  
    288                 if (!badgeArrow || !appleGothicFont) 
    289                         return systemIcon; 
    290                  
     272                BOOL pointingDown = (type == Incoming_FileTransfer); 
     273                BOOL drawArrow = pointingDown || (type == Outgoing_FileTransfer); 
     274 
    291275                // If type is Incoming (*down*load) or Outgoing (*up*load), overlay an arrow in a circle. 
    292276                iconImage = [[NSImage alloc] initWithSize:[systemIcon size]]; 
    293277                 
    294278                NSRect  rect = { NSZeroPoint, [iconImage size] }; 
    295                 NSRect  bottomRight = NSMakeRect(NSMidX(rect), ([iconImage isFlipped] ? NSMidY(rect) : NSMinY(rect)), (NSWidth(rect)/2.0), (NSHeight(rect)/2.0));                
    296  
    297                 NSMutableDictionary *atts = [(NSMutableDictionary *)[[NSDictionary dictionaryWithObjectsAndKeys: 
    298                         [NSColor alternateSelectedControlColor], NSForegroundColorAttributeName, 
    299                         appleGothicFont, NSFontAttributeName, // AppleGothic has our arrow glyphs 
    300                         nil] mutableCopy] autorelease]; 
    301                  
    302                 NSSize arrowSize = [badgeArrow sizeWithAttributes:atts]; 
    303                 while (arrowSize.height > NSHeight(bottomRight)*0.9) { // shrink arrow to fit 
    304                         NSFont *tempFont = (NSFont *)[atts objectForKey:NSFontAttributeName]; 
    305                         [atts setObject:[NSFont fontWithName:[tempFont fontName] size:[tempFont pointSize]*0.99] forKey:NSFontAttributeName]; 
    306                         arrowSize = [badgeArrow sizeWithAttributes:atts]; 
    307                 } 
    308                  
     279                NSRect  bottomRight = NSMakeRect(NSMidX(rect),  
     280                                                                                 ([iconImage isFlipped] ? NSMidY(rect) : NSMinY(rect)),  
     281                                                                                 (NSWidth(rect)/2.0), 
     282                                                                                 (NSHeight(rect)/2.0));          
     283 
    309284                [iconImage lockFocus]; 
    310285                 
    311                 [systemIcon compositeToPoint:NSMakePoint(0.0,0.0) operation:NSCompositeSourceOver]; 
     286                [systemIcon compositeToPoint:NSZeroPoint operation:NSCompositeSourceOver]; 
    312287                 
    313288                float line = ((NSWidth(bottomRight) / 15) + ((NSHeight(bottomRight) / 15) / 2)); 
     
    317292                                                                                NSHeight(bottomRight) - (line)); 
    318293 
     294                //draw our circle background... 
    319295                NSBezierPath *circle = [NSBezierPath bezierPathWithOvalInRect:circleRect]; 
    320296                [circle setLineWidth:line]; 
     
    323299                [circle fill]; 
    324300                [circle stroke]; 
    325                  
    326                 NSMutableParagraphStyle *mps = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; 
    327                 [mps setAlignment:NSCenterTextAlignment]; 
    328                 float lineheight = NSHeight(circleRect) * 0.99; 
    329                 [mps setMaximumLineHeight:lineheight]; 
    330                 [mps setMinimumLineHeight:lineheight]; 
    331                 [mps setLineHeightMultiple:lineheight]; 
    332                 [atts setObject:mps forKey:NSParagraphStyleAttributeName]; 
    333                 [mps release]; 
    334  
    335                 [badgeArrow drawInRect:circleRect withAttributes:atts]; 
     301 
     302                //and the arrow on top of it. 
     303                if(drawArrow) { 
     304                        NSBezierPath *arrow = [self arrowPathInSize:bottomRight.size pointingDown:pointingDown]; 
     305 
     306                        //bring it into position. 
     307                        NSAffineTransform *transform = [NSAffineTransform transform]; 
     308                        [transform translateXBy:circleRect.origin.x yBy:circleRect.origin.y]; 
     309                        [arrow transformUsingAffineTransform:transform]; 
     310 
     311                        [[NSColor alternateSelectedControlColor] setFill]; 
     312                        [arrow fill]; 
     313                } 
    336314                 
    337315                [iconImage unlockFocus];