Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 88 lines (74 sloc) 2.238 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
//
// customTextFieldCell.m
// ControlPanel
//
// Created by Han on 9/23/10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "CustomTextFieldCell.h"

#define kLeftMargin 5.0
#define kTopMargin 5.0

@implementation CustomTextFieldCell

//- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView
//{
// if([self isHighlighted]) {
// [[NSColor colorWithCalibratedRed:0.131 green:0.297 blue:0.458 alpha:1.000] set];
// } else {
// [[NSColor colorWithCalibratedRed:0.709 green:0.791 blue:0.815 alpha:1.000] set];
// }
// cellFrame.size.width += 5;
// NSRectFill(cellFrame);
//
//// [[self title] drawInRect:cellFrame withAttributes:nil];
//}

- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
if( [self isHighlighted] ) {
[[NSColor colorWithCalibratedRed:0.131 green:0.297 blue:0.458 alpha:1.000] set];
NSRectFill(cellFrame);
// [super drawWithFrame:cellFrame inView:controlView];
NSColor *oldColor = [self textColor];
[self setTextColor:[NSColor alternateSelectedControlTextColor]];
[super drawWithFrame:cellFrame inView:controlView];
[self setTextColor:oldColor];
} else {
[super drawWithFrame:cellFrame inView:controlView];
}
}

- (NSColor *)highlightColorWithFrame:(NSRect)cellFrame inView:(NSView
*)controlView {
return nil;
}



 - (void)drawInteriorWithFrame:(NSRect)cellFrame
inView:(NSView *)controlView
{
cellFrame.origin.x += kLeftMargin;
cellFrame.size.width -= kLeftMargin;
cellFrame.origin.y += kTopMargin;
cellFrame.size.height -= kTopMargin;

[super drawInteriorWithFrame:cellFrame
inView:controlView];
}
 
 - (void)selectWithFrame:(NSRect)aRect
inView:(NSView *)controlView
editor:(NSText *)textObj
delegate:(id)anObject
start:(NSInteger)selStart
length:(NSInteger)selLength
{
aRect.origin.x += kLeftMargin;
aRect.size.width -= kLeftMargin;
aRect.origin.y += kTopMargin;
aRect.size.height -= kTopMargin;

[super selectWithFrame:aRect
inView:controlView
editor:textObj
delegate:anObject
start:selStart
length:selLength];
}
 
 - (NSRect)_focusRingFrameForFrame:(NSRect)frame
cellFrame:(NSRect)cellFrame
{
return [[self controlView] bounds];
}

@end
Something went wrong with that request. Please try again.