aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/BWToolkitFramework.framework/BWTransparentTableView.m
diff options
context:
space:
mode:
authoravenjamin <avenjamin@gmail.com>2009-06-24 15:46:27 +0000
committeravenjamin <avenjamin@gmail.com>2009-06-24 15:46:27 +0000
commit5b05f3f15aa0676f91bc1d127d31f4fd95ef9f40 (patch)
treef0eaf423f2c13f2091fe9cfceaa2e0a6f2169723 /Frameworks/BWToolkitFramework.framework/BWTransparentTableView.m
parent37bd86b2879c107ebb026954693540979cf25e2a (diff)
downloadsequelpro-5b05f3f15aa0676f91bc1d127d31f4fd95ef9f40.tar.gz
sequelpro-5b05f3f15aa0676f91bc1d127d31f4fd95ef9f40.tar.bz2
sequelpro-5b05f3f15aa0676f91bc1d127d31f4fd95ef9f40.zip
- 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
Diffstat (limited to 'Frameworks/BWToolkitFramework.framework/BWTransparentTableView.m')
-rw-r--r--Frameworks/BWToolkitFramework.framework/BWTransparentTableView.m103
1 files changed, 103 insertions, 0 deletions
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