diff options
author | avenjamin <avenjamin@gmail.com> | 2009-06-24 15:46:27 +0000 |
---|---|---|
committer | avenjamin <avenjamin@gmail.com> | 2009-06-24 15:46:27 +0000 |
commit | 5b05f3f15aa0676f91bc1d127d31f4fd95ef9f40 (patch) | |
tree | f0eaf423f2c13f2091fe9cfceaa2e0a6f2169723 /Frameworks/BWToolkitFramework.framework/BWTransparentTableViewCell.m | |
parent | 37bd86b2879c107ebb026954693540979cf25e2a (diff) | |
download | sequelpro-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/BWTransparentTableViewCell.m')
-rw-r--r-- | Frameworks/BWToolkitFramework.framework/BWTransparentTableViewCell.m | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/Frameworks/BWToolkitFramework.framework/BWTransparentTableViewCell.m b/Frameworks/BWToolkitFramework.framework/BWTransparentTableViewCell.m new file mode 100644 index 00000000..33f13e02 --- /dev/null +++ b/Frameworks/BWToolkitFramework.framework/BWTransparentTableViewCell.m @@ -0,0 +1,85 @@ +// +// BWTransparentTableViewCell.m +// BWToolkit +// +// Created by Brandon Walkin (www.brandonwalkin.com) +// All code is provided under the New BSD license. +// + +#import "BWTransparentTableViewCell.h" + +@implementation BWTransparentTableViewCell + +- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView +{ + if (![[self title] isEqualToString:@""]) + { + NSColor *textColor; + + if (!self.isHighlighted) + textColor = [NSColor colorWithCalibratedWhite:(198.0f / 255.0f) alpha:1]; + else + textColor = [NSColor whiteColor]; + + NSMutableDictionary *attributes = [[[NSMutableDictionary alloc] init] autorelease]; + [attributes addEntriesFromDictionary:[[self attributedStringValue] attributesAtIndex:0 effectiveRange:NULL]]; + [attributes setObject:textColor forKey:NSForegroundColorAttributeName]; + [attributes setObject:[NSFont systemFontOfSize:11] forKey:NSFontAttributeName]; + + NSMutableAttributedString *string = [[[NSMutableAttributedString alloc] initWithString:[self title] attributes:attributes] autorelease]; + [self setAttributedStringValue:string]; + } + + cellFrame.size.width -= 1; + cellFrame.origin.x += 1; + [super drawInteriorWithFrame:cellFrame inView:controlView]; +} + +#pragma mark RSVerticallyCenteredTextFieldCell +// RSVerticallyCenteredTextFieldCell courtesy of Daniel Jalkut +// http://www.red-sweater.com/blog/148/what-a-difference-a-cell-makes + +- (NSRect)drawingRectForBounds:(NSRect)theRect +{ + // Get the parent's idea of where we should draw + NSRect newRect = [super drawingRectForBounds:theRect]; + + // When the text field is being + // edited or selected, we have to turn off the magic because it screws up + // the configuration of the field editor. We sneak around this by + // intercepting selectWithFrame and editWithFrame and sneaking a + // reduced, centered rect in at the last minute. + if (mIsEditingOrSelecting == NO) + { + // Get our ideal size for current text + NSSize textSize = [self cellSizeForBounds:theRect]; + + // Center that in the proposed rect + float heightDelta = newRect.size.height - textSize.height; + if (heightDelta > 0) + { + newRect.size.height -= heightDelta; + newRect.origin.y += (heightDelta / 2); + } + } + + return newRect; +} + +- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(NSInteger)selStart length:(NSInteger)selLength +{ + aRect = [self drawingRectForBounds:aRect]; + mIsEditingOrSelecting = YES; + [super selectWithFrame:aRect inView:controlView editor:textObj delegate:anObject start:selStart length:selLength]; + mIsEditingOrSelecting = NO; +} + +- (void)editWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject event:(NSEvent *)theEvent +{ + aRect = [self drawingRectForBounds:aRect]; + mIsEditingOrSelecting = YES; + [super editWithFrame:aRect inView:controlView editor:textObj delegate:anObject event:theEvent]; + mIsEditingOrSelecting = NO; +} + +@end |