1 2/* 3 * Copyright 2011 Google Inc. 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9#import "SkTextFieldCell.h" 10@implementation SkTextFieldCell 11- (NSRect)drawingRectForBounds:(NSRect)theRect { 12 NSRect newRect = [super drawingRectForBounds:theRect]; 13 if (selectingOrEditing == NO) { 14 NSSize textSize = [self cellSizeForBounds:theRect]; 15 float heightDelta = newRect.size.height - textSize.height; 16 if (heightDelta > 0) { 17 newRect.size.height -= heightDelta; 18 newRect.origin.y += (heightDelta / 2); 19 } 20 } 21 return newRect; 22} 23 24- (void)selectWithFrame:(NSRect)aRect 25 inView:(NSView *)controlView 26 editor:(NSText *)textObj 27 delegate:(id)anObject 28 start:(NSInteger)selStart 29 length:(NSInteger)selLength { 30 aRect = [self drawingRectForBounds:aRect]; 31 selectingOrEditing = YES; 32 [super selectWithFrame:aRect 33 inView:controlView 34 editor:textObj 35 delegate:anObject 36 start:selStart 37 length:selLength]; 38 selectingOrEditing = NO; 39} 40 41- (void)editWithFrame:(NSRect)aRect 42 inView:(NSView *)controlView 43 editor:(NSText *)textObj 44 delegate:(id)anObject 45 event:(NSEvent *)theEvent { 46 aRect = [self drawingRectForBounds:aRect]; 47 selectingOrEditing = YES; 48 [super editWithFrame:aRect 49 inView:controlView 50 editor:textObj 51 delegate:anObject 52 event:theEvent]; 53 selectingOrEditing = NO; 54} 55 56@end 57