#include "SlideShowWindow.h" #include #include #include static SlideShowWindow *sharedSlideShowWindow = nil; // @interface MenuButton: NSButton // -(BOOL) isOpaque; // @end // @implementation MenuButton // -(BOOL) isOpaque // { // NSLog(@"isOpaque"); // return YES; // } // @end // @interface SlideShowWindow (Private) // -(void) _showMenu; // @end // @implementation SlideShowWindow (Private) // -(void) _showMenu // { // MenuButton *nextButton = [[MenuButton alloc] initWithFrame:NSMakeRect(250,350,70,0)]; // [nextButton setTitle: @"Next"]; // [nextButton setTarget: self]; // [nextButton setAction: @selector(next:)]; // [[self contentView] addSubview: nextButton]; // [nextButton autorelease]; // [[self contentView] setNeedsDisplay:YES]; // } // @end @implementation SlideShowWindow - (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag { if ( sharedSlideShowWindow ) { [self dealloc]; return sharedSlideShowWindow; } if ( ! ( self = [super initWithContentRect:[[NSScreen mainScreen] frame] styleMask: NSBorderlessWindowMask backing: NSBackingStoreBuffered defer:NO] ) ) return nil; #warning FIXME NSMenu is still visible !!! [sharedSlideShowWindow setLevel:NSScreenSaverWindowLevel]; #warning FIXME should be a param [sharedSlideShowWindow setBackgroundColor:[NSColor blueColor]]; sharedSlideShowWindow = self; [self setLevel:NSScreenSaverWindowLevel]; return sharedSlideShowWindow; } -(void) dealloc { NSLog(@"dealloc SlideShowWindow"); [super dealloc]; } +(id) sharedSlideShowWindow { if ( ! sharedSlideShowWindow ) return [[self alloc] initWithContentRect:NSMakeRect(0,0,0,0) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]; else return sharedSlideShowWindow; } - (void) keyDown: (NSEvent *)theEvent { if ( _forwardEvent ) { [_forwardEvent keyEvent:theEvent]; } else printf("send to delegate keyPressed\n"); } - (void)scrollWheel:(NSEvent *)theEvent { if ( _forwardEvent ) [_forwardEvent scrollWheelEvent : theEvent]; } - (void) mouseUp: (NSEvent *)theEvent { if ( ! _forwardEvent ) printf("do nothing\n"); else printf("send to delegate keyPressed\n"); } -(void) setDelegate: (id) delegate { _forwardEvent = delegate; } - (BOOL) canBecomeKeyWindow { return YES; } - (BOOL) canBecomeMainWindow { return YES; } @end