-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoundedView.m
More file actions
53 lines (40 loc) · 1.39 KB
/
RoundedView.m
File metadata and controls
53 lines (40 loc) · 1.39 KB
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
52
53
//
// RoundedView.m
// Drama Button
//
// Created by Martin Schend on 06.04.10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "RoundedView.h"
@implementation RoundedView
- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
// Initialization code here.
NSTrackingArea *trackingArea = [[NSTrackingArea alloc]
initWithRect:frame
options:(NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways | NSTrackingInVisibleRect)
owner:self userInfo:nil];
[self addTrackingArea:trackingArea];
}
return self;
}
- (void)drawRect:(NSRect)dirtyRect {
// Drawing code here.
[super drawRect:dirtyRect];
NSRect rect = [self bounds];
NSRect newRect = NSMakeRect(rect.origin.x+2, rect.origin.y+2, rect.size.width-3, rect.size.height-3);
NSBezierPath *textViewSurround = [NSBezierPath bezierPathWithRoundedRect:newRect xRadius:10 yRadius:10];
[textViewSurround setLineWidth:2.0];
[[NSColor colorWithCalibratedWhite:0.1 alpha:0.7] set];
[textViewSurround fill];
[[NSColor whiteColor] set];
[textViewSurround stroke];
}
- (void)mouseEntered:(NSEvent *)theEvent {
[[NSNotificationCenter defaultCenter] postNotificationName:@"mouseEntered" object:nil];
}
- (void)mouseExited:(NSEvent *)theEvent {
[[NSNotificationCenter defaultCenter] postNotificationName:@"mouseExited" object:nil];
}
@end