forked from pixmeo/osirix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLoupeWindow.m
65 lines (53 loc) · 2.08 KB
/
LoupeWindow.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
/*=========================================================================
Program: OsiriX
Copyright (c) OsiriX Team
All rights reserved.
Distributed under GNU - GPL
See http://www.osirix-viewer.com/copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
=========================================================================*/
#import "LoupeWindow.h"
#import <AppKit/AppKit.h>
@implementation LoupeWindow
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag
{
//Call NSWindow's version of this function, but pass in the all-important value of NSBorderlessWindowMask
//for the styleMask so that the window doesn't have a title bar
self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
//Set the background color to clear so that (along with the setOpaque call below) we can see through the parts
//of the window that we're not drawing into
[self setBackgroundColor:[NSColor clearColor]];
//This next line pulls the window up to the front on top of other system windows. This is how the Clock app behaves;
//generally you wouldn't do this for windows unless you really wanted them to float above everything.
[self setLevel:NSNormalWindowLevel];
//Let's start with no transparency for all drawing into the window
[self setAlphaValue:1.0];
//but let's turn off opaqueness so that we can see through the parts of the window that we're not drawing into
[self setOpaque:NO];
//and while we're at it, make sure the window has a shadow, which will automatically be the shape of our custom content.
[self setHasShadow:YES];
return self;
}
- (BOOL)canBecomeKeyWindow
{
return NO;
}
- (BOOL)canBecomeMainWindow
{
return NO;
}
- (BOOL)acceptsMouseMovedEvents
{
return NO;
}
- (BOOL)acceptsFirstResponder
{
return NO;
}
- (BOOL)ignoresMouseEvents
{
return YES;
}
@end