gfx/skia/trunk/src/views/mac/SkTextFieldCell.m

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/views/mac/SkTextFieldCell.m	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,56 @@
     1.4 +
     1.5 +/*
     1.6 + * Copyright 2011 Google Inc.
     1.7 + *
     1.8 + * Use of this source code is governed by a BSD-style license that can be
     1.9 + * found in the LICENSE file.
    1.10 + */
    1.11 + 
    1.12 +#import "SkTextFieldCell.h"
    1.13 +@implementation SkTextFieldCell
    1.14 +- (NSRect)drawingRectForBounds:(NSRect)theRect {
    1.15 +    NSRect newRect = [super drawingRectForBounds:theRect];
    1.16 +    if (selectingOrEditing == NO) {
    1.17 +        NSSize textSize = [self cellSizeForBounds:theRect];
    1.18 +        float heightDelta = newRect.size.height - textSize.height;      
    1.19 +        if (heightDelta > 0) {
    1.20 +            newRect.size.height -= heightDelta;
    1.21 +            newRect.origin.y += (heightDelta / 2);
    1.22 +        }
    1.23 +    }
    1.24 +    return newRect;
    1.25 +}
    1.26 +
    1.27 +- (void)selectWithFrame:(NSRect)aRect 
    1.28 +                 inView:(NSView *)controlView 
    1.29 +                 editor:(NSText *)textObj 
    1.30 +               delegate:(id)anObject 
    1.31 +                  start:(NSInteger)selStart 
    1.32 +                 length:(NSInteger)selLength {
    1.33 +	aRect = [self drawingRectForBounds:aRect];
    1.34 +	selectingOrEditing = YES;	
    1.35 +	[super selectWithFrame:aRect 
    1.36 +                    inView:controlView 
    1.37 +                    editor:textObj 
    1.38 +                  delegate:anObject 
    1.39 +                     start:selStart 
    1.40 +                    length:selLength];
    1.41 +	selectingOrEditing = NO;
    1.42 +}
    1.43 +
    1.44 +- (void)editWithFrame:(NSRect)aRect 
    1.45 +               inView:(NSView *)controlView 
    1.46 +               editor:(NSText *)textObj 
    1.47 +             delegate:(id)anObject 
    1.48 +                event:(NSEvent *)theEvent {	
    1.49 +	aRect = [self drawingRectForBounds:aRect];
    1.50 +	selectingOrEditing = YES;
    1.51 +	[super editWithFrame:aRect 
    1.52 +                  inView:controlView 
    1.53 +                  editor:textObj 
    1.54 +                delegate:anObject 
    1.55 +                   event:theEvent];
    1.56 +	selectingOrEditing = NO;
    1.57 +}
    1.58 +
    1.59 +@end

mercurial