1/*
2	File:		MBCFloatingBoardWindow.mm
3	Contains:	The board window for the floating board
4	Copyright:	� 2003 by Apple Inc., all rights reserved.
5
6	IMPORTANT: This Apple software is supplied to you by Apple Computer,
7	Inc.  ("Apple") in consideration of your agreement to the following
8	terms, and your use, installation, modification or redistribution of
9	this Apple software constitutes acceptance of these terms.  If you do
10	not agree with these terms, please do not use, install, modify or
11	redistribute this Apple software.
12
13	In consideration of your agreement to abide by the following terms,
14	and subject to these terms, Apple grants you a personal, non-exclusive
15	license, under Apple's copyrights in this original Apple software (the
16	"Apple Software"), to use, reproduce, modify and redistribute the
17	Apple Software, with or without modifications, in source and/or binary
18	forms; provided that if you redistribute the Apple Software in its
19	entirety and without modifications, you must retain this notice and
20	the following text and disclaimers in all such redistributions of the
21	Apple Software.  Neither the name, trademarks, service marks or logos
22	of Apple Inc. may be used to endorse or promote products
23	derived from the Apple Software without specific prior written
24	permission from Apple.  Except as expressly stated in this notice, no
25	other rights or licenses, express or implied, are granted by Apple
26	herein, including but not limited to any patent rights that may be
27	infringed by your derivative works or by other works in which the
28	Apple Software may be incorporated.
29
30	The Apple Software is provided by Apple on an "AS IS" basis.  APPLE
31	MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
32	THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND
33	FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS
34	USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
35
36	IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT,
37	INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
38	PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
39	PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE,
40	REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE,
41	HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
42	NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
43	ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44*/
45
46#import "MBCFloatingBoardWindow.h"
47
48@implementation MBCFloatingBoardWindow
49
50//
51// Adapted from RoundTransparentWindow sample code
52//
53- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle
54				  backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag
55{
56	//
57    // Call NSWindow's version of this function, but pass in the all-important
58	// value of NSBorderlessWindowMask for the styleMask so that the window
59	// doesn't have a title bar
60	//
61    MBCFloatingBoardWindow* result =
62		[super initWithContentRect: contentRect
63			   styleMask: NSBorderlessWindowMask
64			   backing: bufferingType defer: flag];
65	//
66    // Set the background color to clear so that (along with the setOpaque
67	// call below) we can see through the parts of the window that we're not		// drawing into.
68	//
69    [result setBackgroundColor: [NSColor clearColor]];
70	//
71    // Let's start with no transparency for all drawing into the window
72	//
73    [result setAlphaValue:0.999];
74	//
75    // but let's turn off opaqueness so that we can see through the parts of
76	// the window that we're not drawing into
77	//
78    [result setOpaque:NO];
79	//
80    // and while we're at it, make sure the window has a shadow, which will
81	// automatically be the shape of our custom content.
82	//
83    [result setHasShadow: YES];
84    return result;
85}
86
87//
88// Custom windows that use the NSBorderlessWindowMask can't become key by
89// default.  Therefore, controls in such windows won't ever be enabled by
90// default.  Thus, we override this method to change that.
91//
92- (BOOL) canBecomeKeyWindow
93{
94    return YES;
95}
96
97@end
98