forked from chockenberry/iPulse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InfoView.m
executable file
·65 lines (49 loc) · 1.35 KB
/
InfoView.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// InfoView.m
//
#import "InfoView.h"
#import "Preferences.h"
#define USE_INTERPOLATION 0
@implementation InfoView
- (id)initWithFrame:(NSRect)frameRect
{
self = [super initWithFrame:frameRect];
theContentDrawer = nil;
return self;
}
- (void)drawRect:(NSRect)rect
{
#if USE_INTERPOLATION
NSGraphicsContext* graphicsContext;
BOOL wasAntialiasing;
NSImageInterpolation previousImageInterpolation;
#endif
#if USE_INTERPOLATION
// set current graphics context to use antialiasing and high-quality image scaling.
graphicsContext = [NSGraphicsContext currentContext];
wasAntialiasing = [graphicsContext shouldAntialias];
previousImageInterpolation = [graphicsContext imageInterpolation];
[graphicsContext setShouldAntialias:YES];
[graphicsContext setImageInterpolation:NSImageInterpolationHigh];
#endif
// draw the content
if (theContentDrawer != nil)
{
[theContentDrawer performSelector:theContentDrawingMethod];
}
#if USE_INTERPOLATION
// restore previous graphics context settings.
[graphicsContext setShouldAntialias:wasAntialiasing];
[graphicsContext setImageInterpolation:previousImageInterpolation];
#endif
}
- (BOOL)isOpaque
{
return YES; // view covers rect -- AppKit won't try to draw behind
}
- (void)setContentDrawer:(id)theDrawer method:(SEL)theMethod
{
theContentDrawer = theDrawer;
theContentDrawingMethod = theMethod;
}
@end