// // DKTextFieldCell.m // DarkKit // // Created by Chad Weider on 3/21/08. // Copyright (c) 2008 Chad Weider // Some rights reserved: // // This software is provided 'as-is', without any express or implied warranty. // In no event will the authors be held liable for any damages arising from the // use of this software. // // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it // freely, subject to the following restrictions: // // 1. The origin of this software must not be misrepresented; you must not // claim that you wrote the original software. If you use this software in a // product, an acknowledgment in the product documentation would be appreciated // but is not required. // // 2. Altered source versions must be plainly marked as such, and must not be // misrepresented as being the original software. // // 3. This notice may not be removed or altered from any source distribution. // #import "DKTextFieldCell.h" #import "NSBezierPath+PXRoundedRectangleAdditions.h" #import "CTGradient.h" @implementation DKTextFieldCell - (id)initTextCell:(NSString *)aString { if(self = [super initTextCell:aString]) { [self setTextColor:[NSColor colorWithDeviceWhite:DKTextWhite alpha:1]]; [self setTextColor:[NSColor blackColor]]; } return self; } - (NSText *)setUpFieldEditorAttributes:(NSText *)textObj { textObj = [super setUpFieldEditorAttributes:textObj]; if([textObj isKindOfClass:[NSTextView class]]) { [(NSTextView *)textObj setInsertionPointColor:[NSColor colorWithDeviceWhite:DKTextWhite alpha:1]]; [(NSTextView *)textObj setSelectedTextAttributes:[NSDictionary dictionaryWithObject:[NSColor colorWithDeviceWhite:.38 alpha:1] forKey:@"NSBackgroundColor"]]; } return textObj; } - (void)_drawThemeBezelWithFrame:(NSRect)rect inView:(NSView *)controlView { [[self backgroundColor] set]; NSRectFill(rect); NSRect topLine, rightLine, bottomLine, leftLine, topLineShadow, remainder; NSDivideRect(rect, &bottomLine, &remainder, 1, NSMaxYEdge); NSDivideRect(rect, &rightLine, &remainder, 1, NSMaxXEdge); NSDivideRect(rect, &leftLine, &remainder, 1, NSMinXEdge); NSDivideRect(rect, &topLine, &remainder, 1, NSMinYEdge); NSDivideRect(remainder, &topLineShadow, &remainder, 1, NSMinYEdge); topLineShadow = NSInsetRect(topLineShadow, 1, 0); [[NSColor colorWithDeviceWhite:1 alpha:.75] set]; NSRectFill(bottomLine); [[NSColor colorWithDeviceWhite:1 alpha:.85] set]; NSRectFill(rightLine); [[NSColor colorWithDeviceWhite:1 alpha:.85] set]; NSRectFill(leftLine); [[NSColor colorWithDeviceWhite:1 alpha:1] set]; NSRectFill(topLine); [[NSColor colorWithDeviceWhite:1 alpha:.25] set]; NSRectFill(topLineShadow); } @end