2009-01-12 20:52:45 +00:00
|
|
|
#import "cocoaApp.h"
|
|
|
|
|
|
|
|
@implementation NSApplication(i)
|
|
|
|
- (void)appRunning
|
|
|
|
{
|
|
|
|
_running = 1;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface cocoaAppDelegate : NSObject
|
|
|
|
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation cocoaAppDelegate : NSObject
|
|
|
|
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
|
|
|
|
{
|
|
|
|
return NSTerminateCancel;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
void cocoaCreateApp()
|
|
|
|
{
|
|
|
|
ProcessSerialNumber psn;
|
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
|
|
|
|
if (!GetCurrentProcess(&psn)) {
|
|
|
|
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
|
|
|
SetFrontProcess(&psn);
|
|
|
|
}
|
|
|
|
|
|
|
|
pool = [[NSAutoreleasePool alloc] init];
|
|
|
|
|
|
|
|
if (NSApp == nil) {
|
|
|
|
[NSApplication sharedApplication];
|
|
|
|
//TODO : Create menu
|
|
|
|
[NSApp finishLaunching];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ([NSApp delegate] == nil) {
|
|
|
|
[NSApp setDelegate:[[cocoaAppDelegate alloc] init]];
|
|
|
|
}
|
|
|
|
|
|
|
|
[NSApp appRunning];
|
|
|
|
|
|
|
|
[pool release];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-01-12 23:59:27 +00:00
|
|
|
void cocoaKeyCode(NSEvent *event)
|
|
|
|
{
|
|
|
|
|
|
|
|
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
|
|
|
|
|
|
|
NSConnection *connec = [NSConnection defaultConnection];
|
|
|
|
|
|
|
|
[connec setRootObject: event];
|
|
|
|
if ([connec registerName: @"DolphinCocoaEvent"] == NO)
|
|
|
|
{
|
2009-01-13 00:34:36 +00:00
|
|
|
//printf("error creating nsconnection\n");
|
2009-01-12 23:59:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[pool release];
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void cocoaSendEvent(NSEvent *event)
|
|
|
|
{
|
|
|
|
|
|
|
|
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
|
|
|
|
|
|
|
if ( event != nil ) {
|
|
|
|
switch ([event type]) {
|
|
|
|
case NSKeyDown:
|
|
|
|
case NSKeyUp:
|
2009-01-13 14:30:05 +00:00
|
|
|
cocoaKeyCode(event);
|
2009-01-12 23:59:27 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
[NSApp sendEvent:event];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[pool release];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|