2012-07-21 12:23:40 +08:00
|
|
|
/****************************************************************************
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
|
|
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
2012-07-21 12:23:40 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#import "CCWindow.h"
|
2012-07-21 17:19:03 +08:00
|
|
|
#import "EAGLView.h"
|
2012-07-21 12:23:40 +08:00
|
|
|
|
|
|
|
@implementation CCWindow
|
|
|
|
|
|
|
|
- (id) initWithFrame:(NSRect)frame fullscreen:(BOOL)fullscreen
|
|
|
|
{
|
|
|
|
int styleMask = fullscreen ? NSBackingStoreBuffered : ( NSTitledWindowMask | NSClosableWindowMask );
|
|
|
|
self = [self initWithContentRect:frame
|
|
|
|
styleMask:styleMask
|
|
|
|
backing:NSBackingStoreBuffered
|
|
|
|
defer:YES];
|
|
|
|
|
|
|
|
if (self != nil)
|
|
|
|
{
|
|
|
|
if(fullscreen)
|
|
|
|
{
|
|
|
|
[self setLevel:NSMainMenuWindowLevel+1];
|
|
|
|
[self setHidesOnDeactivate:YES];
|
|
|
|
[self setHasShadow:NO];
|
|
|
|
}
|
|
|
|
|
|
|
|
[self setAcceptsMouseMovedEvents:NO];
|
|
|
|
[self setOpaque:YES];
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) canBecomeKeyWindow
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) canBecomeMainWindow
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
2012-07-21 17:19:03 +08:00
|
|
|
|
|
|
|
- (void) keyDown:(NSEvent *)event
|
|
|
|
{
|
|
|
|
// exit fullscreen if user pressed esc
|
|
|
|
if([event keyCode] == 53)
|
|
|
|
{
|
2013-06-21 08:46:22 +08:00
|
|
|
CCEAGLView* eaglView = [CCEAGLView sharedEGLView];
|
2012-07-21 17:19:03 +08:00
|
|
|
|
|
|
|
// cancel full screen
|
|
|
|
if( [eaglView isFullScreen] )
|
|
|
|
[eaglView setFullScreen:NO];
|
|
|
|
|
|
|
|
// let another responder take it
|
|
|
|
else
|
|
|
|
[super keyDown:event];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-21 12:23:40 +08:00
|
|
|
@end
|
|
|
|
|