yangsu@google.com | 12d177d | 2011-08-01 17:07:12 +0000 | [diff] [blame^] | 1 | #import "SkTextFieldCell.h" |
| 2 | @implementation SkTextFieldCell |
| 3 | - (NSRect)drawingRectForBounds:(NSRect)theRect { |
| 4 | NSRect newRect = [super drawingRectForBounds:theRect]; |
| 5 | if (selectingOrEditing == NO) { |
| 6 | NSSize textSize = [self cellSizeForBounds:theRect]; |
| 7 | float heightDelta = newRect.size.height - textSize.height; |
| 8 | if (heightDelta > 0) { |
| 9 | newRect.size.height -= heightDelta; |
| 10 | newRect.origin.y += (heightDelta / 2); |
| 11 | } |
| 12 | } |
| 13 | return newRect; |
| 14 | } |
| 15 | |
| 16 | - (void)selectWithFrame:(NSRect)aRect |
| 17 | inView:(NSView *)controlView |
| 18 | editor:(NSText *)textObj |
| 19 | delegate:(id)anObject |
| 20 | start:(int)selStart |
| 21 | length:(int)selLength { |
| 22 | aRect = [self drawingRectForBounds:aRect]; |
| 23 | selectingOrEditing = YES; |
| 24 | [super selectWithFrame:aRect |
| 25 | inView:controlView |
| 26 | editor:textObj |
| 27 | delegate:anObject |
| 28 | start:selStart |
| 29 | length:selLength]; |
| 30 | selectingOrEditing = NO; |
| 31 | } |
| 32 | |
| 33 | - (void)editWithFrame:(NSRect)aRect |
| 34 | inView:(NSView *)controlView |
| 35 | editor:(NSText *)textObj |
| 36 | delegate:(id)anObject |
| 37 | event:(NSEvent *)theEvent { |
| 38 | aRect = [self drawingRectForBounds:aRect]; |
| 39 | selectingOrEditing = YES; |
| 40 | [super editWithFrame:aRect |
| 41 | inView:controlView |
| 42 | editor:textObj |
| 43 | delegate:anObject |
| 44 | event:theEvent]; |
| 45 | selectingOrEditing = NO; |
| 46 | } |
| 47 | |
| 48 | @end |