From 5b05f3f15aa0676f91bc1d127d31f4fd95ef9f40 Mon Sep 17 00:00:00 2001 From: avenjamin Date: Wed, 24 Jun 2009 15:46:27 +0000 Subject: - Changed the way the BWToolkit framework was included to allow modifications to be made easily. - Fixed show/hide info pane toggle button image states to now show correctly --- .../BWTransparentTableView.m | 103 +++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 Frameworks/BWToolkitFramework.framework/BWTransparentTableView.m (limited to 'Frameworks/BWToolkitFramework.framework/BWTransparentTableView.m') diff --git a/Frameworks/BWToolkitFramework.framework/BWTransparentTableView.m b/Frameworks/BWToolkitFramework.framework/BWTransparentTableView.m new file mode 100644 index 00000000..53fe23f9 --- /dev/null +++ b/Frameworks/BWToolkitFramework.framework/BWTransparentTableView.m @@ -0,0 +1,103 @@ +// +// BWTransparentTableView.m +// BWToolkit +// +// Created by Brandon Walkin (www.brandonwalkin.com) +// All code is provided under the New BSD license. +// + +#import "BWTransparentTableView.h" +#import "BWTransparentTableViewCell.h" +#import "BWTransparentCheckboxCell.h" + +static NSColor *rowColor, *altRowColor, *highlightColor; + +@interface BWTransparentTableView (BWTTVPrivate) +- (void)addObject:(id)object toParent:(id)parent; +- (void)removeObject:(id)object; +@end + +@implementation BWTransparentTableView + ++ (void)initialize; +{ + rowColor = [[NSColor colorWithCalibratedWhite:0.13 alpha:0.855] retain]; + altRowColor = [[NSColor colorWithCalibratedWhite:0.16 alpha:0.855] retain]; + highlightColor = [[NSColor colorWithCalibratedWhite:(75.0 / 255.0) alpha:0.855] retain]; +} + +- (void)addTableColumn:(NSTableColumn *)aColumn +{ + [super addTableColumn:aColumn]; + + if ([[[aColumn dataCell] className] isEqualToString:@"NSTextFieldCell"]) + { + BWTransparentTableViewCell *cell = [[BWTransparentTableViewCell alloc] init]; + + [self removeObject:[aColumn dataCell]]; + [aColumn setDataCell:cell]; + [self addObject:cell toParent:aColumn]; + } +} + ++ (Class)cellClass +{ + return [BWTransparentTableViewCell class]; +} + +// We make this a no-op when there are no alt rows so that the background color is not drawn on top of the window +- (void)drawBackgroundInClipRect:(NSRect)clipRect +{ + if ([self usesAlternatingRowBackgroundColors]) + [super drawBackgroundInClipRect:clipRect]; +} + +// Color shown when a cell is edited +- (NSColor *)backgroundColor +{ + return rowColor; +} + +- (NSArray *)_alternatingRowBackgroundColors +{ + NSArray *colors = [NSArray arrayWithObjects:rowColor,altRowColor,nil]; + + return colors; +} + +- (NSColor *)_highlightColorForCell:(NSCell *)cell +{ + return nil; +} + +- (void)highlightSelectionInClipRect:(NSRect)theClipRect +{ + NSRange aVisibleRowIndexes = [self rowsInRect:theClipRect]; + NSIndexSet * aSelectedRowIndexes = [self selectedRowIndexes]; + int aRow = aVisibleRowIndexes.location; + int anEndRow = aRow + aVisibleRowIndexes.length; + + for (aRow; aRow < anEndRow; aRow++) + { + if([aSelectedRowIndexes containsIndex:aRow]) + { + NSRect aRowRect = [self rectOfRow:aRow]; + aRowRect.size.height--; + + [NSGraphicsContext saveGraphicsState]; + + [[NSGraphicsContext currentContext] setCompositingOperation:NSCompositeCopy]; + + NSColor *startColor = [NSColor colorWithCalibratedWhite:(85.0 / 255.0) alpha:0.855]; + NSColor *endColor = [NSColor colorWithCalibratedWhite:(70.0 / 255.0) alpha:0.855]; + + NSGradient *gradient = [[[NSGradient alloc] initWithStartingColor:startColor endingColor:endColor] autorelease]; + + [gradient drawInRect:aRowRect angle:90]; + + [NSGraphicsContext restoreGraphicsState]; + } + } +} + +@end -- cgit v1.2.3