-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathRoundRecTextField.m
51 lines (42 loc) · 1.42 KB
/
RoundRecTextField.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// RoundedTextField.m
// Jumpcut
//
// Created by steve on Wed Dec 17 2003.
// Copyright (c) 2003 Steve Cook. All rights reserved.
//
// This code is open-source software subject to the MIT License; see the homepage
// at <http://jumpcut.sourceforge.net/> for details.
#import "RoundRecTextField.h"
#import "RoundRecBezierPath.h"
// Okay, on doing some reading, the -best- way to handle this is probably to cache
// an NSImage on the init and then (as needed) composite it to the back of the view.
// We can then turn the rectangles on and off by compositing or not compositing the
// images.
// This can wait for another time.
@implementation RoundRecTextField
// We may want to make this a more flexible class sometime by taking radius as an argument.
// Until then, this is kind of useless code.
/*
- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
// Initialization code here.
}
return self;
}
*/
- (BOOL)isOpaque {
return NO;
}
- (void)drawRect:(NSRect)rect {
// Oh, the hackishness.
NSBezierPath *roundedRec = [NSBezierPath bezierPathWithRoundRectInRect:rect radius:8];
[[self backgroundColor] set];
[roundedRec fill];
[self setDrawsBackground:NO];
// We might eventually want to pass [super drawRect] something smaller than rect, to ensure that we don't bleed over the corners
[super drawRect:rect];
[self setDrawsBackground:YES];
}
@end