-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContentSizedTextView.m
37 lines (29 loc) · 1.1 KB
/
ContentSizedTextView.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#import "ContentSizedTextView.h"
@implementation ContentSizedTextView
- (id)initWithFrame:(NSRect)frameRect {
self = [super initWithFrame:frameRect];
if (self) {
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
[style setDefaultTabInterval:28.0];
[style setTabStops:[NSArray array]];
[self setAllowsUndo:FALSE];
[self setBackgroundColor: [NSColor clearColor]];
[self setDefaultParagraphStyle:style];
[self setEditable:FALSE];
[self setFieldEditor:FALSE];
[self setFont:[NSFont fontWithName:@"Menlo" size:12.0]];
[self setHorizontallyResizable:FALSE];
[self setSelectable:FALSE];
[self setTextColor:[[NSColor whiteColor] colorWithAlphaComponent:0.5]];
[self setVerticallyResizable:FALSE];
[[self textContainer] setHeightTracksTextView:FALSE];
[[self textContainer] setWidthTracksTextView:FALSE];
}
return self;
}
- (NSSize)textSize {
// Trigger a layout, otherwise we just get 0,0 for dimensions!?
[[self layoutManager] glyphRangeForTextContainer:[self textContainer]];
return [[self layoutManager] usedRectForTextContainer:[self textContainer]].size;
}
@end