aboutsummaryrefslogtreecommitdiff
path: root/SDLMain.m
diff options
context:
space:
mode:
Diffstat (limited to 'SDLMain.m')
-rw-r--r--SDLMain.m62
1 files changed, 31 insertions, 31 deletions
diff --git a/SDLMain.m b/SDLMain.m
index 2931eef..830d25e 100644
--- a/SDLMain.m
+++ b/SDLMain.m
@@ -5,7 +5,7 @@
Feel free to customize this file to suit your needs
*/
-#include "SDL/SDL.h"
+#include "SDL.h"
#include "SDLMain.h"
#include <sys/param.h> /* for MAXPATHLEN */
#include <unistd.h>
@@ -45,7 +45,7 @@ static NSString *getApplicationName(void)
{
const NSDictionary *dict;
NSString *appName = 0;
-
+
/* Determine the application name */
dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
if (dict)
@@ -53,7 +53,7 @@ static NSString *getApplicationName(void)
if (![appName length])
appName = [[NSProcessInfo processInfo] processName];
-
+
return appName;
}
@@ -105,11 +105,11 @@ static NSString *getApplicationName(void)
NSRange aRange;
NSEnumerator *enumerator;
NSMenuItem *menuItem;
-
+
aRange = [[aMenu title] rangeOfString:@"SDL App"];
if (aRange.length != 0)
[aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:appName]];
-
+
enumerator = [[aMenu itemArray] objectEnumerator];
while ((menuItem = [enumerator nextObject]))
{
@@ -137,31 +137,31 @@ static void setApplicationMenu(void)
/* Add menu items */
title = [@"About " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
-
+
[appleMenu addItem:[NSMenuItem separatorItem]];
-
+
title = [@"Hide " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
-
+
menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
[menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
-
+
[appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
-
+
[appleMenu addItem:[NSMenuItem separatorItem]];
-
+
title = [@"Quit " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
-
+
/* Put menu into the menubar */
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
[menuItem setSubmenu:appleMenu];
[[NSApp mainMenu] addItem:menuItem];
-
+
/* Tell the application object that this is now the application menu */
[NSApp setAppleMenu:appleMenu];
-
+
/* Finally give up our references to the objects */
[appleMenu release];
[menuItem release];
@@ -173,7 +173,7 @@ static void setupWindowMenu(void)
NSMenu *windowMenu;
NSMenuItem *windowMenuItem;
NSMenuItem *menuItem;
-
+
windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
/* "Minimize" item */
@@ -188,7 +188,7 @@ static void setupWindowMenu(void)
/* Tell the application object that this is now the window menu */
[NSApp setWindowsMenu:windowMenu];
-
+
/* Finally give up our references to the objects */
[windowMenu release];
[windowMenuItem release];
@@ -199,7 +199,7 @@ static void CustomApplicationMain (int argc, char **argv)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
SDLMain *sdlMain;
-
+
/* Ensure the application object is initialised */
[NSApplication sharedApplication];
@@ -213,12 +213,12 @@ static void CustomApplicationMain (int argc, char **argv)
[NSApplication sharedApplication];
}
#endif /* SDL_USE_CPS */
-
+
/* Set up the menubar */
[NSApp setMainMenu:[[NSMenu alloc] init]];
setApplicationMenu();
setupWindowMenu();
-
+
/* Create SDLMain and make it the app delegate */
sdlMain = [[SDLMain alloc] init];
[NSApp setDelegate:sdlMain];
@@ -254,19 +254,19 @@ static void CustomApplicationMain (int argc, char **argv)
size_t arglen;
char *arg;
char **newargv;
-
+
if (!gFinderLaunch) /* MacOS is passing command line args. */
return FALSE;
-
+
if (gCalledAppMainline) /* app has started, ignore this document. */
return FALSE;
-
+
temparg = [filename UTF8String];
arglen = SDL_strlen(temparg) + 1;
arg = (char *) SDL_malloc(arglen);
if (arg == NULL)
return FALSE;
-
+
newargv = (char **) realloc(gArgv, sizeof (char *) * (gArgc + 2));
if (newargv == NULL)
{
@@ -274,7 +274,7 @@ static void CustomApplicationMain (int argc, char **argv)
return FALSE;
}
gArgv = newargv;
-
+
SDL_strlcpy(arg, temparg, arglen);
gArgv[gArgc++] = arg;
gArgv[gArgc] = NULL;
@@ -286,19 +286,19 @@ static void CustomApplicationMain (int argc, char **argv)
- (void) applicationDidFinishLaunching: (NSNotification *) note
{
int status;
-
+
/* Set the working directory to the .app's parent directory */
[self setupWorkingDirectory:gFinderLaunch];
-
+
#if SDL_USE_NIB_FILE
/* Set the main menu to contain the real app name instead of "SDL App" */
[self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()];
#endif
-
+
/* Hand off to main application code */
gCalledAppMainline = TRUE;
status = SDL_main (gArgc, gArgv);
-
+
/* We're done, thank you for playing */
exit(status);
}
@@ -315,7 +315,7 @@ static void CustomApplicationMain (int argc, char **argv)
unichar *buffer;
NSRange localRange;
NSString *result;
-
+
bufferSize = selfLen + aStringLen - aRange.length;
buffer = (unichar *)NSAllocateMemoryPages(bufferSize*sizeof(unichar));
@@ -328,7 +328,7 @@ static void CustomApplicationMain (int argc, char **argv)
localRange.location = 0;
localRange.length = aStringLen;
[aString getCharacters:(buffer+aRange.location) range:localRange];
-
+
/* Get last part into buffer */
localRange.location = aRange.location + aRange.length;
localRange.length = selfLen - localRange.location;
@@ -370,7 +370,7 @@ int main (int argc, char **argv)
gArgv[i] = argv[i];
gFinderLaunch = NO;
}
-
+
#if SDL_USE_NIB_FILE
NSApplicationMain (argc, argv);
#else