Mercurial > sdl-ios-xcode
annotate src/main/macosx/SDLMain.m @ 1663:11775724e3fe SDL-1.3
fine tuning indent output
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:29:03 +0000 |
parents | 782fd950bd46 |
children | cd3db072ba8a |
rev | line source |
---|---|
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* SDLMain.m - main entry point for our Cocoa-ized SDL app |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
2 Initial Version: Darrell Walisser <dwaliss1@purdue.edu> |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
3 Non-NIB-Code & other changes: Max Horn <max@quendi.de> |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 Feel free to customize this file to suit your needs |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 */ |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 #import "SDL.h" |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 #import "SDLMain.h" |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
10 #import <sys/param.h> /* for MAXPATHLEN */ |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 #import <unistd.h> |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 |
1591
24247fe40188
Close off warning about setAppleMenu on Mac OS X 10.4 SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
1572
diff
changeset
|
13 /* For some reaon, Apple removed setAppleMenu from the headers in 10.4, |
24247fe40188
Close off warning about setAppleMenu on Mac OS X 10.4 SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
1572
diff
changeset
|
14 but the method still is there and works. To avoid warnings, we declare |
24247fe40188
Close off warning about setAppleMenu on Mac OS X 10.4 SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
1572
diff
changeset
|
15 it ourselves here. */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
16 @ interface NSApplication (SDL_Missing_Methods) - (void) setAppleMenu:(NSMenu |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
17 *) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
18 menu; |
1591
24247fe40188
Close off warning about setAppleMenu on Mac OS X 10.4 SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
1572
diff
changeset
|
19 @end |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
20 /* Use this flag to determine whether we use SDLMain.nib or not */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
21 #define SDL_USE_NIB_FILE 0 |
476
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
22 /* Use this flag to determine whether we use CPS (docking) or not */ |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
23 #define SDL_USE_CPS 1 |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
24 #ifdef SDL_USE_CPS |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
25 /* Portions of CPS.h */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
26 typedef struct CPSProcessSerNum |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
27 { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
28 UInt32 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
29 lo; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
30 UInt32 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
31 hi; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
32 } CPSProcessSerNum; |
476
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
33 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
34 extern |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
35 OSErr |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
36 CPSGetCurrentProcess (CPSProcessSerNum * psn); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
37 extern |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
38 OSErr |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
39 CPSEnableForegroundOperation (CPSProcessSerNum * psn, UInt32 _arg2, |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
40 UInt32 _arg3, UInt32 _arg4, UInt32 _arg5); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
41 extern |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
42 OSErr |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
43 CPSSetFrontProcess (CPSProcessSerNum * psn); |
476
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
44 |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
45 #endif /* SDL_USE_CPS */ |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
46 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
47 static int |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
48 gArgc; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
49 static char ** |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
50 gArgv; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
51 static |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
52 BOOL |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
53 gFinderLaunch; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
54 static |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
55 BOOL |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
56 gCalledAppMainline = FALSE; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
58 static NSString * |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
59 getApplicationName (void) |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
60 { |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
61 NSDictionary *dict; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
62 NSString *appName = 0; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
63 |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
64 /* Determine the application name */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
65 dict = |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
66 (NSDictionary *) CFBundleGetInfoDictionary (CFBundleGetMainBundle ()); |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
67 if (dict) |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
68 appName =[dict objectForKey:@"CFBundleName"]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
69 |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
70 if (![appName length]) |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
71 appName =[[NSProcessInfo processInfo] processName]; |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
72 |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
73 return appName; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
74 } |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
75 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
76 #if SDL_USE_NIB_FILE |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
77 /* A helper category for NSString */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
78 @interface NSString (ReplaceSubString) - (NSString *) stringByReplacingRange:(NSRange) |
1663
11775724e3fe
fine tuning indent output
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
79 aRange |
11775724e3fe
fine tuning indent output
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
80 with:(NSString *) |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
81 aString; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 @end |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
83 #endif |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
84 @ interface SDLApplication:NSApplication |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
85 @ end @ implementation SDLApplication |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
86 /* Invoked from the Quit menu item */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
87 - (void) terminate:(id) sender |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
88 { |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
89 /* Post a SDL_QUIT event */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
90 SDL_Event event; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
91 event.type = SDL_QUIT; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
92 SDL_PushEvent (&event); |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
93 } |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
95 @end |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 /* The main class of the application, the application's delegate */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
97 @ implementation SDLMain |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 /* Set the working directory to the .app's parent directory */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
99 - (void) setupWorkingDirectory:(BOOL) shouldChdir { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
100 if (shouldChdir) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
101 char parentdir[MAXPATHLEN]; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
102 CFURLRef url = CFBundleCopyBundleURL (CFBundleGetMainBundle ()); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
103 CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent (0, url); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
104 if (CFURLGetFileSystemRepresentation |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
105 (url2, true, (UInt8 *) parentdir, MAXPATHLEN)) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
106 assert (chdir (parentdir) == 0); /* chdir to the binary app's parent */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
107 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
108 CFRelease (url); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
109 CFRelease (url2); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
110 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
111 |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 } |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
114 #if SDL_USE_NIB_FILE |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
115 |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 /* Fix menu to contain the real app name instead of "SDL App" */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
117 -(void) fixMenu:(NSMenu *) |
1663
11775724e3fe
fine tuning indent output
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
118 aMenu |
11775724e3fe
fine tuning indent output
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
119 withAppName:(NSString *) |
11775724e3fe
fine tuning indent output
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
120 appName |
11775724e3fe
fine tuning indent output
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
121 { |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 NSRange aRange; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 NSEnumerator *enumerator; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 NSMenuItem *menuItem; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
126 aRange =[[aMenu title] rangeOfString:@"SDL App"]; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 if (aRange.length != 0) |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
128 [aMenu setTitle: [[aMenu title] stringByReplacingRange: aRange with:appName]]; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
130 enumerator =[[aMenu itemArray] objectEnumerator]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
131 while ((menuItem =[enumerator nextObject])) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
132 aRange =[[menuItem title] rangeOfString:@"SDL App"]; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 if (aRange.length != 0) |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
134 [menuItem setTitle: [[menuItem title] stringByReplacingRange: aRange with:appName]]; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 if ([menuItem hasSubmenu]) |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
136 [self fixMenu: [menuItem submenu] withAppName:appName]; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
138 [aMenu sizeToFit]; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 } |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
141 #else |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
142 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
143 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
144 setApplicationMenu (void) |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
145 { |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
146 /* warning: this code is very odd */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
147 NSMenu *appleMenu; |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
148 NSMenuItem *menuItem; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
149 NSString *title; |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
150 NSString *appName; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
151 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
152 appName = getApplicationName (); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
153 appleMenu =[[NSMenu alloc] initWithTitle:@""]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
154 |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
155 /* Add menu items */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
156 title =[@"About " stringByAppendingString:appName]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
157 [appleMenu addItemWithTitle: title action: @selector (orderFrontStandardAboutPanel: )keyEquivalent:@""]; |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
158 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
159 [appleMenu addItem:[NSMenuItem separatorItem]]; |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
160 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
161 title =[@"Hide " stringByAppendingString:appName]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
162 [appleMenu addItemWithTitle: title action: @selector (hide: )keyEquivalent:@"h"]; |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
163 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
164 menuItem = (NSMenuItem *)[appleMenu addItemWithTitle: @"Hide Others" action: @selector (hideOtherApplications: )keyEquivalent:@"h"]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
165 [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask | |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
166 NSCommandKeyMask)]; |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
167 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
168 [appleMenu addItemWithTitle: @"Show All" action: @selector (unhideAllApplications: )keyEquivalent:@""]; |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
169 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
170 [appleMenu addItem:[NSMenuItem separatorItem]]; |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
171 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
172 title =[@"Quit " stringByAppendingString:appName]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
173 [appleMenu addItemWithTitle: title action: @selector (terminate: )keyEquivalent:@"q"]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
174 |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
175 |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
176 /* Put menu into the menubar */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
177 menuItem =[[NSMenuItem alloc] initWithTitle: @"" action: nil keyEquivalent:@""]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
178 [menuItem setSubmenu:appleMenu]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
179 [[NSApp mainMenu] addItem:menuItem]; |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
180 |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
181 /* Tell the application object that this is now the application menu */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
182 [NSApp setAppleMenu:appleMenu]; |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
183 |
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
184 /* Finally give up our references to the objects */ |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
185 [appleMenu release]; |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
186 [menuItem release]; |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
187 } |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
188 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
189 /* Create a window menu */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
190 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
191 setupWindowMenu (void) |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
192 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
193 NSMenu *windowMenu; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
194 NSMenuItem *windowMenuItem; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
195 NSMenuItem *menuItem; |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
196 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
197 windowMenu =[[NSMenu alloc] initWithTitle:@"Window"]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
198 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
199 /* "Minimize" item */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
200 menuItem =[[NSMenuItem alloc] initWithTitle: @"Minimize" action: @selector (performMiniaturize: )keyEquivalent:@"m"]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
201 [windowMenu addItem:menuItem]; |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
202 [menuItem release]; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
203 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
204 /* Put menu into the menubar */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
205 windowMenuItem =[[NSMenuItem alloc] initWithTitle: @"Window" action: nil keyEquivalent:@""]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
206 [windowMenuItem setSubmenu:windowMenu]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
207 [[NSApp mainMenu] addItem:windowMenuItem]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
208 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
209 /* Tell the application object that this is now the window menu */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
210 [NSApp setWindowsMenu:windowMenu]; |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
211 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
212 /* Finally give up our references to the objects */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
213 [windowMenu release]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
214 [windowMenuItem release]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
215 } |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
216 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
217 /* Replacement for NSApplicationMain */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
218 static void |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
219 CustomApplicationMain (int argc, char **argv) |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
220 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
221 NSAutoreleasePool *pool =[[NSAutoreleasePool alloc] init]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
222 SDLMain *sdlMain; |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
223 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
224 /* Ensure the application object is initialised */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
225 [SDLApplication sharedApplication]; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
226 |
476
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
227 #ifdef SDL_USE_CPS |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
228 { |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
229 CPSProcessSerNum PSN; |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
230 /* Tell the dock about us */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
231 if (!CPSGetCurrentProcess (&PSN)) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
232 if (!CPSEnableForegroundOperation |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
233 (&PSN, 0x03, 0x3C, 0x2C, 0x1103)) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
234 if (!CPSSetFrontProcess (&PSN)) |
476
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
235 [SDLApplication sharedApplication]; |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
236 } |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
237 #endif /* SDL_USE_CPS */ |
a7129c0083f4
Tell the dock about command-line launched applications
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
238 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
239 /* Set up the menubar */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
240 [NSApp setMainMenu:[[NSMenu alloc] init]]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
241 setApplicationMenu (); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
242 setupWindowMenu (); |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
243 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
244 /* Create SDLMain and make it the app delegate */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
245 sdlMain =[[SDLMain alloc] init]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
246 [NSApp setDelegate:sdlMain]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
247 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
248 /* Start the main event loop */ |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
249 [NSApp run]; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
250 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
251 [sdlMain release]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
252 [pool release]; |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
253 } |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
254 |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
255 #endif |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
256 |
1113
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
257 |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
258 /* |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
259 * Catch document open requests...this lets us notice files when the app |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
260 * was launched by double-clicking a document, or when a document was |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
261 * dragged/dropped on the app's icon. You need to have a |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
262 * CFBundleDocumentsType section in your Info.plist to get this message, |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
263 * apparently. |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
264 * |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
265 * Files are added to gArgv, so to the app, they'll look like command line |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
266 * arguments. Previously, apps launched from the finder had nothing but |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
267 * an argv[0]. |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
268 * |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
269 * This message may be received multiple times to open several docs on launch. |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
270 * |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
271 * This message is ignored once the app's mainline has been called. |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
272 */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
273 -(BOOL) application:(NSApplication *) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
274 theApplication openFile:(NSString *) filename |
1113
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
275 { |
1659 | 276 const char *temparg; |
277 size_t arglen; | |
278 char *arg; | |
279 char **newargv; | |
280 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
281 if (!gFinderLaunch) /* MacOS is passing command line args. */ |
1125
a6011e1394d9
Apparently MacOS X will sometimes pass command line arguments to a Cocoa
Ryan C. Gordon <icculus@icculus.org>
parents:
1113
diff
changeset
|
282 return FALSE; |
a6011e1394d9
Apparently MacOS X will sometimes pass command line arguments to a Cocoa
Ryan C. Gordon <icculus@icculus.org>
parents:
1113
diff
changeset
|
283 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
284 if (gCalledAppMainline) /* app has started, ignore this document. */ |
1113
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
285 return FALSE; |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
286 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
287 temparg =[filename UTF8String]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
288 arglen = SDL_strlen (temparg) + 1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
289 arg = (char *) SDL_malloc (arglen); |
1113
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
290 if (arg == NULL) |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
291 return FALSE; |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
292 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
293 newargv = (char **) realloc (gArgv, sizeof (char *) * (gArgc + 2)); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
294 if (newargv == NULL) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
295 SDL_free (arg); |
1113
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
296 return FALSE; |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
297 } |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
298 gArgv = newargv; |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
299 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
300 SDL_strlcpy (arg, temparg, arglen); |
1211 | 301 gArgv[gArgc++] = arg; |
302 gArgv[gArgc] = NULL; | |
303 return TRUE; | |
1113
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
304 } |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
305 |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
306 |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 /* Called when the internal event loop has just started running */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
308 -(void) applicationDidFinishLaunching:(NSNotification *) note { |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 int status; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 /* Set the working directory to the .app's parent directory */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
312 [self setupWorkingDirectory:gFinderLaunch]; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
314 #if SDL_USE_NIB_FILE |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 /* Set the main menu to contain the real app name instead of "SDL App" */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
316 [self fixMenu: [NSApp mainMenu] withAppName:getApplicationName ()]; |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
317 #endif |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 /* Hand off to main application code */ |
1113
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
320 gCalledAppMainline = TRUE; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 status = SDL_main (gArgc, gArgv); |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 /* We're done, thank you for playing */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
324 exit (status); |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 } |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
327 @end @ implementation NSString (ReplaceSubString) - (NSString *) stringByReplacingRange:(NSRange) |
1663
11775724e3fe
fine tuning indent output
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
328 aRange |
11775724e3fe
fine tuning indent output
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
329 with:(NSString *) |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
330 aString |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 { |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 unsigned int bufferSize; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
333 unsigned int selfLen =[self length]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
334 unsigned int aStringLen =[aString length]; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 unichar *buffer; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 NSRange localRange; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 NSString *result; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 bufferSize = selfLen + aStringLen - aRange.length; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
340 buffer = NSAllocateMemoryPages (bufferSize * sizeof (unichar)); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
341 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
342 /* Get first part into buffer */ |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 localRange.location = 0; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 localRange.length = aRange.location; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
345 [self getCharacters: buffer range:localRange]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
346 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
347 /* Get middle part into buffer */ |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 localRange.location = 0; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 localRange.length = aStringLen; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
350 [aString getCharacters: (buffer + aRange.location) range:localRange]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
351 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
352 /* Get last part into buffer */ |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 localRange.location = aRange.location + aRange.length; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 localRange.length = selfLen - localRange.location; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
355 [self getCharacters: (buffer + aRange.location + aStringLen) range:localRange]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
356 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
357 /* Build output string */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
358 result =[NSString stringWithCharacters: buffer length:bufferSize]; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
359 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
360 NSDeallocateMemoryPages (buffer, bufferSize); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
361 |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
362 return result; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
363 } |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
364 |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
365 @end |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 #ifdef main |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 # undef main |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 #endif |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
369 /* Main entry point to executable - should *not* be SDL_main! */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
370 int |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
371 main (int argc, char **argv) |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
372 { |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
373 /* Copy the arguments into a global variable */ |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
374 /* This is passed if we are launched by double-clicking */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
375 if (argc >= 2 && strncmp (argv[1], "-psn", 4) == 0) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
376 gArgv = (char **) SDL_malloc (sizeof (char *) * 2); |
1113
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
377 gArgv[0] = argv[0]; |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
378 gArgv[1] = NULL; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
379 gArgc = 1; |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
380 gFinderLaunch = YES; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
381 } else { |
1113
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
382 int i; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 gArgc = argc; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
384 gArgv = (char **) SDL_malloc (sizeof (char *) * (argc + 1)); |
1113
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
385 for (i = 0; i <= argc; i++) |
39408f59a0f7
In MacOSX, when drag'n'dropping a document on an SDL app, or double-clicking a
Ryan C. Gordon <icculus@icculus.org>
parents:
958
diff
changeset
|
386 gArgv[i] = argv[i]; |
957
217f119a19a0
Date: Thu, 2 Sep 2004 19:35:51 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
476
diff
changeset
|
387 gFinderLaunch = NO; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
388 } |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
389 |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
390 #if SDL_USE_NIB_FILE |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
391 [SDLApplication poseAsClass:[NSApplication class]]; |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
392 NSApplicationMain (argc, argv); |
221
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
393 #else |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
394 CustomApplicationMain (argc, argv); |
50620ec9c86a
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
194
diff
changeset
|
395 #endif |
194
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
396 return 0; |
ba9e0fcc2ae2
Oops, back out that SDL_main -> SDLMain conversion
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
397 } |