//
//  PTTLabel.m
//  GMEDemoAudio
//
//  Created by RoonieChen on 2020/12/1.
//  Copyright © 2020 tobinchen. All rights reserved.
//

#import "PTTLabel.h"

@implementation PTTLabel


- (instancetype)initWithCoder:(NSCoder *)coder{
    self = [super initWithCoder:coder];
    if (self) {
        [self commonInit];
    }
    return self;
}

- (instancetype)initWithFrame:(NSRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self commonInit];
    }
    return self;
}

- (void)commonInit {
    self.backgroundColor = [NSColor clearColor];
    self.editable = NO;
    self.selectable = YES;
    self.drawsBackground = NO;
}

- (void)setStringValue:(NSString *)stringValue {
    if (stringValue.length <= 0) {
        return;
    }

    NSAttributedString *att = [[NSMutableAttributedString alloc]initWithString:stringValue];
    [self.textStorage setAttributedString:att];
}

- (NSString *)stringValue {
    return [self.textStorage string];
}

- (void)clearContent {
    [self setStringValue:@""];
}

- (void)setTextEditable:(BOOL)textEditable {
    self.editable = textEditable;
}

//- (NSView *)hitTest:(NSPoint)point {
//    return nil;
//}

- (void)drawRect:(NSRect)dirtyRect {
    [super drawRect:dirtyRect];
    
    // Drawing code here.
}

@end
