//// BWTransparentTableViewCell.m// BWToolkit//// Created by Brandon Walkin (www.brandonwalkin.com)// All code is provided under the New BSD license.//#import "BWTransparentTableViewCell.h"@implementationBWTransparentTableViewCell-(void)drawInteriorWithFrame:(NSRect)cellFrameinView:(NSView*)controlView{if(![[selftitle]isEqualToString:@""]){NSColor*textColor;if(!self.isHighlighted)textColor=[NSColorcolorWithCalibratedWhite:(198.0f/255.0f)alpha:1];elsetextColor=[NSColorwhiteColor];NSMutableDictionary*attributes=[[[NSMutableDictionaryalloc]init]autorelease];[attributesaddEntriesFromDictionary:[[selfattributedStringValue]attributesAtIndex:0effectiveRange:NULL]];[attributessetObject:textColorforKey:NSForegroundColorAttributeName];[attributessetObject:[NSFontsystemFontOfSize:11]forKey:NSFontAttributeName];NSMutableAttributedString*string=[[[NSMutableAttributedStringalloc]initWithString:[selftitle]attributes:attributes]autorelease];[selfsetAttributedStringValue:string];}cellFrame.size.width-=1;cellFrame.origin.x+=1;[superdrawInteriorWithFrame:cellFrameinView: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 drawNSRectnewRect=[superdrawingRectForBounds: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 textNSSizetextSize=[selfcellSizeForBounds:theRect];// Center that in the proposed rectfloatheightDelta=newRect.size.height-textSize.height;if(heightDelta>0){newRect.size.height-=heightDelta;newRect.origin.y+=(heightDelta/2);}}returnnewRect;}-(void)selectWithFrame:(NSRect)aRectinView:(NSView*)controlVieweditor:(NSText*)textObjdelegate:(id)anObjectstart:(NSInteger)selStartlength:(NSInteger)selLength{aRect=[selfdrawingRectForBounds:aRect];mIsEditingOrSelecting=YES;[superselectWithFrame:aRectinView:controlVieweditor:textObjdelegate:anObjectstart:selStartlength:selLength];mIsEditingOrSelecting=NO;}-(void)editWithFrame:(NSRect)aRectinView:(NSView*)controlVieweditor:(NSText*)textObjdelegate:(id)anObjectevent:(NSEvent*)theEvent{aRect=[selfdrawingRectForBounds:aRect];mIsEditingOrSelecting=YES;[supereditWithFrame:aRectinView:controlVieweditor:textObjdelegate:anObjectevent:theEvent];mIsEditingOrSelecting=NO;}@end