forked from millenomi/afloat
-
Notifications
You must be signed in to change notification settings - Fork 1
/
AfloatPanel.m
62 lines (45 loc) · 1.33 KB
/
AfloatPanel.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
//
// AfloatPanel.m
// AfloatHUD
//
// Created by ∞ on 04/03/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "AfloatPanel.h"
#import <Quartz/Quartz.h>
@interface AfloatPanelBackdropView : NSView {
NSImage* _image;
}
@end
@implementation AfloatPanelBackdropView
- (id) initWithFrame:(NSRect) frame {
if (self = [super initWithFrame:frame]) {
NSString* pathToBackdrop = [[NSBundle bundleForClass:[self class]] pathForImageResource:@"AfloatHUDBackdrop"];
_image = [[NSImage alloc] initWithContentsOfFile:pathToBackdrop];
}
return self;
}
- (void) dealloc {
[_image release];
[super dealloc];
}
- (void) drawRect:(NSRect) r {
[[NSColor clearColor] set]; NSRectFill(r);
[_image drawInRect:r fromRect:r operation:NSCompositeSourceOver fraction:1.0];
}
@end
@implementation AfloatPanel
- (id) initWithContentRect:(NSRect) contentRect styleMask:(NSUInteger) aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag {
self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:bufferingType defer:flag];
if (!self) return nil;
[self setBackgroundColor:[NSColor clearColor]];
[self setOpaque:NO];
[self setHasShadow:YES];
[self setMovableByWindowBackground:NO];
return self;
}
- (NSPoint) frameOrigin {
return [self frame].origin;
}
@dynamic frameOrigin;
@end