Genetic generation of cars in a 2D environment
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

109 lines
2.2 KiB

11 years ago
//
//
// OSX GLEssentials
11 years ago
//
// Copied from the Apple GLEssentials
//
//
#import "WindowController.h"
#import "FullscreenWindow.h"
#import "GLView.h"
11 years ago
@interface WindowController () {
FullscreenWindow *fullscreenWindow; // Fullscreen window
11 years ago
NSWindow* standardWindow; // Non-Fullscreen window (also the initial window)
}
@end
@implementation WindowController
11 years ago
- (id)initWithWindow:(NSWindow *) window{
if (self = [super initWithWindow:window]){
fullscreenWindow = nil;
}
return self;
}
- (void)goFullscreen{
if(fullscreenWindow){
return;
}
// Allocate a new fullscreen window
fullscreenWindow = [[FullscreenWindow alloc] init];
11 years ago
// Resize the view to screensize
view.frame = fullscreenWindow.frame;
// Set the view in the fullscreen window
fullscreenWindow.contentView = view;
// keep a referene to the old window
standardWindow = self.window;
// Hide non-fullscreen window so it doesn't show up when switching out
// of this app (i.e. with CMD-TAB)
[standardWindow orderOut:self];
// Set controller to the fullscreen window so that all input will go to
// this controller (self)
self.window = fullscreenWindow;
// Show the window and make it the key window for input
[fullscreenWindow makeKeyAndOrderFront:self];
}
- (void)goWindow{
if(!fullscreenWindow){
return;
}
// Resize the view to the window size
view.frame = standardWindow.frame;
// Set controller to the standard window so that all input will go to
// this controller (self)
self.window = standardWindow;
// Set the content of the orginal window to the view
self.window.contentView = view;
// Show the window and make it the key window for input
[[self window] makeKeyAndOrderFront:self];
// release fullscreenWindow
fullscreenWindow = nil;
}
- (void)keyDown:(NSEvent *)event{
unichar c = [[event charactersIgnoringModifiers] characterAtIndex:0];
switch (c){
// Handle [ESC] key
case 27:
if(fullscreenWindow){
[self goWindow];
}
return;
// Have f key toggle fullscreen
case 'f':
if(fullscreenWindow){
[self goWindow];
} else {
[self goFullscreen];
}
return;
}
// Allow other character to be handled (or not and beep)
[super keyDown:event];
}
@end