blob: c5efc46406e01497b1652771616bf1d6879ccf2e [file] [log] [blame]
bsalomon@google.comf75b84e2011-09-29 14:58:28 +00001
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
yangsu@google.com12d177d2011-08-01 17:07:12 +00009#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
commit-bot@chromium.org5d7ca952013-04-22 20:26:44 +000028 start:(NSInteger)selStart
29 length:(NSInteger)selLength {
yangsu@google.com12d177d2011-08-01 17:07:12 +000030 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