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.
109 lines
2.3 KiB
109 lines
2.3 KiB
11 years ago
|
//
|
||
|
//
|
||
|
// iOSGLEssentials
|
||
|
//
|
||
|
// Copied from the Apple GLEssentials
|
||
|
//
|
||
|
//
|
||
|
|
||
|
#import "GLEssentialsWindowController.h"
|
||
|
#import "GLEssentialsFullscreenWindow.h"
|
||
|
#import "GLEssentialsGLView.h"
|
||
|
|
||
|
@interface GLEssentialsWindowController () {
|
||
|
GLEssentialsFullscreenWindow *fullscreenWindow; // Fullscreen window
|
||
|
NSWindow* standardWindow; // Non-Fullscreen window (also the initial window)
|
||
|
}
|
||
|
|
||
|
@end
|
||
|
|
||
|
|
||
|
@implementation GLEssentialsWindowController
|
||
|
|
||
|
- (id)initWithWindow:(NSWindow *) window{
|
||
|
if (self = [super initWithWindow:window]){
|
||
|
fullscreenWindow = nil;
|
||
|
}
|
||
|
|
||
|
return self;
|
||
|
}
|
||
|
|
||
|
- (void)goFullscreen{
|
||
|
if(fullscreenWindow){
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
// Allocate a new fullscreen window
|
||
|
fullscreenWindow = [[GLEssentialsFullscreenWindow alloc] init];
|
||
|
|
||
|
// 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
|