/Volumes/Plantain/MyDocuments/Projects/MacTrek/MacTrek/Luky/Gui/FullScreenBackgroundWindow.m

00001 //
00002 //  FullScreenBackgroundWindow.m
00003 //  MacTrek
00004 //
00005 //  Created by Aqua on 16/04/2006.
00006 //  Copyright 2006 __MyCompanyName__. All rights reserved.
00007 //
00008 
00009 #import "FullScreenBackgroundWindow.h"
00010 
00011 
00012 @implementation FullScreenBackgroundWindow
00013 
00014 //In Interface Builder we set CustomWindow to be the class for our window, so our own initializer is called here.
00015 - (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)aStyle 
00016                   backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag {
00017    
00018     // default we can become key
00019     // Custom windows that use the NSBorderlessWindowMask can't become key by default.  Therefore, controls in such windows
00020     // won't ever be enabled by default.  Thus, we override this method to change that.
00021     canBecomeKeyWindow = YES;
00022     
00023     NSWindow *result;
00024     
00025         //Call NSWindow's version of this function, but pass in the all-important value of NSBorderlessWindowMask
00026         //for the styleMask so that the window doesn't have a title bar
00027         result = [super initWithContentRect:contentRect 
00028                               styleMask:NSBorderlessWindowMask 
00029                                 backing:NSBackingStoreBuffered 
00030                                   defer:NO];
00031     
00032     //Set the background color to clear so that (along with the setOpaque call below) we can see through the parts
00033     //of the window that we're not drawing into
00034     //[result setBackgroundColor: [NSColor clearColor]];
00035     // create a black background
00036     [result setBackgroundColor: [NSColor clearColor]];
00037     
00038     //This next line pulls the window up to the front on top of other system windows.  This is how the Clock app behaves;
00039     //generally you wouldn't do this for windows unless you really wanted them to float above everything.
00040     //[result setLevel: NSScreenSaverWindowLevel];
00041     //[result setLevel:NSMainMenuWindowLevel];
00042     
00043     // make sure we track the mouse
00044     [result setAcceptsMouseMovedEvents:YES];
00045     [result setIgnoresMouseEvents:NO];
00046     
00047     //Let's start with no transparency for all drawing into the window
00048     [result setAlphaValue:1.0];
00049     
00050     //but let's turn off opaqueness so that we can see through the parts of the window that we're not drawing into
00051     //[result setOpaque:NO];
00052     [result setOpaque:YES];
00053     
00054     //and while we're at it, make sure the window has no shadow
00055     [result setHasShadow:NO];
00056     
00057     //the menu was hidden anyway but remove it
00058     [NSMenu setMenuBarVisible:NO];
00059     
00060     // store the pointer
00061     //self = result;    
00062     
00063         return result;
00064 }
00065 
00066 - (void) awakeFromNib {
00067     
00068     //set the screenframe          
00069     //-----------------------------------------------------------
00070     // Disable this to debug normal size
00071     //-----------------------------------------------------------
00072     NSRect  screenFrame = [[NSScreen mainScreen] frame];
00073     //[self setFrame:screenFrame display:YES];
00074     //-----------------------------------------------------------
00075 }
00076 
00077 
00078 - (BOOL) canBecomeKeyWindow
00079 {
00080         return canBecomeKeyWindow;
00081 }
00082 
00083 - (void) setCanBecomeKeyWindow:(bool)can {
00084     canBecomeKeyWindow = can;
00085 }
00086 
00087 @end

Generated on Fri Jul 28 19:15:22 2006 for MacTrek by  doxygen 1.4.7