Ticket #1134: Colloquy-1134.patch

File Colloquy-1134.patch, 5.2 kB (added by eschaton, 9 months ago)
  • Views/JVSideOutlineView.m

    old new  
    1010                outData[i] = ( 1. - a ) * dark[i] + a * light[i]; 
    1111} 
    1212 
     13@interface NSOutlineView (InternalMethodsColloquyOverridesPreLeopard) 
     14- (NSColor *)_highlightColorForCell:(NSCell *)cell; 
     15- (void)_highlightRow:(int)row clipRect:(NSRect)clip; 
     16@end 
     17 
    1318@implementation JVSideOutlineView 
     19 
    1420- (NSColor *) _highlightColorForCell:(NSCell *) cell { 
    15     // return nil to prevent normal selection drawing 
    16     return nil; 
     21        NSColor *highlightColor = nil; 
     22         
     23        if ((floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_4) && [NSOutlineView instancesRespondToSelector:@selector(_highlightColorForCell:)]) { 
     24                highlightColor = [super _highlightColorForCell:cell]; 
     25        } else { 
     26                // return nil to prevent normal selection drawing 
     27                highlightColor = nil; 
     28        } 
     29         
     30    return highlightColor; 
    1731} 
    1832 
    1933- (void) _highlightRow:(int) row clipRect:(NSRect) clip { 
    20         NSRect highlight = [self rectOfRow:row]; 
    21  
    22         struct CGFunctionCallbacks callbacks = { 0, gradientInterpolate, NULL }; 
    23         CGFunctionRef function = CGFunctionCreate( NULL, 1, NULL, 4, NULL, &callbacks ); 
    24         CGColorSpaceRef cspace = CGColorSpaceCreateDeviceRGB(); 
    25  
    26         CGShadingRef shading = CGShadingCreateAxial( cspace, CGPointMake( NSMinX( highlight ), NSMaxY( highlight ) ), CGPointMake( NSMinX( highlight ), NSMinY( highlight ) ), function, false, false ); 
    27         CGContextDrawShading( [[NSGraphicsContext currentContext] graphicsPort], shading ); 
    28  
    29         CGShadingRelease( shading ); 
    30         CGColorSpaceRelease( cspace ); 
    31         CGFunctionRelease( function ); 
    32  
    33         static NSColor *rowBottomLine = nil; 
    34         if( ! rowBottomLine ) 
    35                 rowBottomLine = [[NSColor colorWithCalibratedRed:( 140. / 255. ) green:( 152. / 255. ) blue:( 176. / 255. ) alpha:1.] retain]; 
    36  
    37         [rowBottomLine set]; 
    38  
    39         NSRect bottomLine = NSMakeRect( NSMinX( highlight ), NSMaxY( highlight ) - 1., NSWidth( highlight ), 1. ); 
    40         NSRectFill( bottomLine ); 
     34        if ((floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_4) && [NSOutlineView instancesRespondToSelector:@selector(_highlightRow:clipRect:)]) { 
     35                [super _highlightRow:row clipRect:clip]; 
     36        } else { 
     37                NSRect highlight = [self rectOfRow:row]; 
     38                 
     39                struct CGFunctionCallbacks callbacks = { 0, gradientInterpolate, NULL }; 
     40                CGFunctionRef function = CGFunctionCreate( NULL, 1, NULL, 4, NULL, &callbacks ); 
     41                CGColorSpaceRef cspace = CGColorSpaceCreateDeviceRGB(); 
     42                 
     43                CGShadingRef shading = CGShadingCreateAxial( cspace, CGPointMake( NSMinX( highlight ), NSMaxY( highlight ) ), CGPointMake( NSMinX( highlight ), NSMinY( highlight ) ), function, false, false ); 
     44                CGContextDrawShading( [[NSGraphicsContext currentContext] graphicsPort], shading ); 
     45                 
     46                CGShadingRelease( shading ); 
     47                CGColorSpaceRelease( cspace ); 
     48                CGFunctionRelease( function ); 
     49                 
     50                static NSColor *rowBottomLine = nil; 
     51                if( ! rowBottomLine ) 
     52                        rowBottomLine = [[NSColor colorWithCalibratedRed:( 140. / 255. ) green:( 152. / 255. ) blue:( 176. / 255. ) alpha:1.] retain]; 
     53                 
     54                [rowBottomLine set]; 
     55                 
     56                NSRect bottomLine = NSMakeRect( NSMinX( highlight ), NSMaxY( highlight ) - 1., NSWidth( highlight ), 1. ); 
     57                NSRectFill( bottomLine ); 
     58        } 
    4159} 
    4260 
    4361- (void) drawBackgroundInClipRect:(NSRect) clipRect { 
    44         static NSColor *backgroundColor = nil; 
    45         if( ! backgroundColor ) 
    46                 backgroundColor = [[NSColor colorWithCalibratedRed:( 229. / 255. ) green:( 237. / 255. ) blue:( 247. / 255. ) alpha:1.] retain]; 
    47         [backgroundColor set]; 
    48         NSRectFill( clipRect ); 
     62        if ((floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_4) && [NSOutlineView instancesRespondToSelector:@selector(_highlightRow:clipRect:)]) { 
     63                [super drawBackgroundInClipRect:clipRect]; 
     64        } else { 
     65                static NSColor *backgroundColor = nil; 
     66                if( ! backgroundColor ) 
     67                        backgroundColor = [[NSColor colorWithCalibratedRed:( 229. / 255. ) green:( 237. / 255. ) blue:( 247. / 255. ) alpha:1.] retain]; 
     68                [backgroundColor set]; 
     69                NSRectFill( clipRect ); 
     70        } 
    4971} 
     72 
    5073@end 
  • Controllers/JVChatWindowController.m

    old new  
    1212NSString *JVToolbarToggleChatDrawerItemIdentifier = @"JVToolbarToggleChatDrawerItem"; 
    1313NSString *JVChatViewPboardType = @"Colloquy Chat View v1.0 pasteboard type"; 
    1414 
     15#pragma mark - 
     16 
     17#if !defined(MAC_OS_X_VERSION_10_5) || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5) 
     18@interface NSTableView (LeopardMethodsForBuildingWithPreLeopardSDK) 
     19- (void)setSelectionHighlightStyle:(int)value; 
     20@end 
     21#endif 
     22 
    1523@interface NSToolbar (NSToolbarPrivate) 
    1624- (NSView *) _toolbarView; 
    1725@end 
     
    7280        [chatViewsOutlineView registerForDraggedTypes:[NSArray arrayWithObjects:JVChatViewPboardType, NSFilenamesPboardType, nil]]; 
    7381        [chatViewsOutlineView setMenu:[[[NSMenu allocWithZone:nil] initWithTitle:@""] autorelease]]; 
    7482 
     83#if 1 
     84        if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_4) { 
     85                [chatViewsOutlineView setSelectionHighlightStyle:1]; 
     86        } 
     87#endif 
     88         
    7589        [favoritesButton setMenu:[MVConnectionsController favoritesMenu]]; 
    7690 
    7791        [self setShouldCascadeWindows:NO];