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