git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4392 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1999-06-11 05:07:11 +00:00
parent 82e0f3f712
commit 8aba8fdfb4

View file

@ -64,18 +64,18 @@
#include <AppKit/IMLoading.h> #include <AppKit/IMLoading.h>
#include <AppKit/DPSOperators.h> #include <AppKit/DPSOperators.h>
// /*
// Types * Types
// */
struct _NSModalSession { struct _NSModalSession {
int runState; int runState;
NSWindow *window; NSWindow *window;
NSModalSession previous; NSModalSession previous;
}; };
// /*
// Class variables * Class variables
// */
static BOOL gnustep_gui_app_is_in_dealloc; static BOOL gnustep_gui_app_is_in_dealloc;
static NSEvent *null_event; static NSEvent *null_event;
static NSString *NSAbortModalException = @"NSAbortModalException"; static NSString *NSAbortModalException = @"NSAbortModalException";
@ -84,9 +84,9 @@ NSApplication *NSApp = nil;
@implementation NSApplication @implementation NSApplication
// /*
// Class methods * Class methods
// */
+ (void) initialize + (void) initialize
{ {
if (self == [NSApplication class]) if (self == [NSApplication class])
@ -111,19 +111,24 @@ NSApplication *NSApp = nil;
} }
+ (NSApplication *) sharedApplication + (NSApplication *) sharedApplication
{ // If the global application does {
if (!NSApp) // not yet exist then create it /* If the global application does not yet exist then create it */
if (!NSApp)
{ {
NSApp = [self alloc]; // Don't combine the following two /*
[NSApp init]; // statements into one to avoid * Don't combine the following two statements into one to avoid
} // problems with some classes' * problems with some classes' initialization code that tries
// initialization code that tries * to get the shared application.
return NSApp; // to get the shared application. */
NSApp = [self alloc];
[NSApp init];
}
return NSApp;
} }
// /*
// Instance methods * Instance methods
// */
- (id) init - (id) init
{ {
if (NSApp != self) if (NSApp != self)
@ -226,9 +231,9 @@ NSApplication *NSApp = nil;
[super dealloc]; [super dealloc];
} }
// /*
// Changing the active application * Changing the active application
// */
- (void) activateIgnoringOtherApps: (BOOL)flag - (void) activateIgnoringOtherApps: (BOOL)flag
{ {
if (app_is_active == NO) if (app_is_active == NO)
@ -278,9 +283,9 @@ NSApplication *NSApp = nil;
return app_is_active; return app_is_active;
} }
// /*
// Running the main event loop * Running the main event loop
// */
- (void) run - (void) run
{ {
NSEvent *e; NSEvent *e;
@ -331,9 +336,9 @@ NSApplication *NSApp = nil;
return app_is_running; return app_is_running;
} }
// /*
// Running modal event loops * Running modal event loops
// */
- (void) abortModal - (void) abortModal
{ {
if (session == 0) if (session == 0)
@ -365,8 +370,7 @@ NSApplication *NSApp = nil;
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"null pointer passed to endModalSession: "]; format: @"null pointer passed to endModalSession: "];
// Remove this session from /* Remove this session from linked list of sessions. */
// linked list of sessions.
while (tmp && tmp != theSession) while (tmp && tmp != theSession)
tmp = tmp->previous; tmp = tmp->previous;
@ -524,9 +528,9 @@ NSApplication *NSApp = nil;
session->runState = returnCode; session->runState = returnCode;
} }
// /*
// Getting, removing, and posting events * Getting, removing, and posting events
// */
- (void) sendEvent: (NSEvent *)theEvent - (void) sendEvent: (NSEvent *)theEvent
{ {
if (theEvent == null_event) if (theEvent == null_event)
@ -575,8 +579,8 @@ NSApplication *NSApp = nil;
static NSMenu *copyOfMainMenu = nil; static NSMenu *copyOfMainMenu = nil;
NSWindow *copyMenuWindow; NSWindow *copyMenuWindow;
if (!copyOfMainMenu) // display the menu if (!copyOfMainMenu) /* display the menu under the mouse */
copyOfMainMenu = [main_menu copy]; // under the mouse copyOfMainMenu = [main_menu copy];
copyMenuWindow = [copyOfMainMenu menuWindow]; copyMenuWindow = [copyOfMainMenu menuWindow];
[copyOfMainMenu _rightMouseDisplay]; [copyOfMainMenu _rightMouseDisplay];
[copyMenuWindow _captureMouse: self]; [copyMenuWindow _captureMouse: self];
@ -659,9 +663,9 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
DPSPostEvent(GSCurrentContext(), event, flag); DPSPostEvent(GSCurrentContext(), event, flag);
} }
// /*
// Sending action messages * Sending action messages
// */
- (BOOL) sendAction: (SEL)aSelector to: aTarget from: sender - (BOOL) sendAction: (SEL)aSelector to: aTarget from: sender
{ {
/* /*
@ -775,9 +779,9 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
return app_icon; return app_icon;
} }
// /*
// Hiding and arranging windows * Hiding and arranging windows
// */
- (void) hide: (id)sender - (void) hide: (id)sender
{ {
if (app_is_hidden == NO) if (app_is_hidden == NO)
@ -882,7 +886,7 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
} }
} }
- (void) arrangeInFront: (id)sender // preliminary FIX ME - (void) arrangeInFront: (id)sender
{ {
NSMenu *menu; NSMenu *menu;
@ -907,9 +911,9 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
} }
} }
// /*
// Managing windows * Managing windows
// */
- (NSWindow*) keyWindow - (NSWindow*) keyWindow
{ {
NSArray *window_list = [self windows]; NSArray *window_list = [self windows];
@ -1039,9 +1043,9 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
return nil; return nil;
} }
// /*
// Showing Standard Panels * Showing Standard Panels
// */
- (void) orderFrontColorPanel: sender - (void) orderFrontColorPanel: sender
{ {
} }
@ -1058,9 +1062,9 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
{ {
} }
// /*
// Getting the main menu * Getting the main menu
// */
- (NSMenu*) mainMenu - (NSMenu*) mainMenu
{ {
return main_menu; return main_menu;
@ -1085,15 +1089,15 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
mc = [mi objectAtIndex: i]; mc = [mi objectAtIndex: i];
if ([[mc stringValue] compare: @"Windows"] == NSOrderedSame) if ([[mc stringValue] compare: @"Windows"] == NSOrderedSame)
{ {
windows_menu = mc; // Found it! windows_menu = mc;
break; break;
} }
} }
} }
// /*
// Managing the Windows menu * Managing the Windows menu
// */
- (void) addWindowsItem: (NSWindow*)aWindow - (void) addWindowsItem: (NSWindow*)aWindow
title: (NSString*)aString title: (NSString*)aString
filename: (BOOL)isFilename filename: (BOOL)isFilename
@ -1355,9 +1359,9 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
return nil; return nil;
} }
// /*
// Managing the Service menu * Managing the Service menu
// */
- (void) registerServicesMenuSendTypes: (NSArray *)sendTypes - (void) registerServicesMenuSendTypes: (NSArray *)sendTypes
returnTypes: (NSArray *)returnTypes returnTypes: (NSArray *)returnTypes
{ {
@ -1397,14 +1401,14 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
} }
- (void) reportException: (NSException *)anException - (void) reportException: (NSException *)anException
{ // Reporting an exception {
if (anException) if (anException)
NSLog(@"reported exception - %@", anException); NSLog(@"reported exception - %@", anException);
} }
// /*
// Terminating the application * Terminating the application
// */
- (void) terminate: (id)sender - (void) terminate: (id)sender
{ {
if ([self applicationShouldTerminate: self]) if ([self applicationShouldTerminate: self])
@ -1418,7 +1422,7 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
} }
} }
- (id) delegate // Assigning a delegate - (id) delegate
{ {
return delegate; return delegate;
} }
@ -1451,9 +1455,9 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
SET_DELEGATE_NOTIFICATION(WillUpdate); SET_DELEGATE_NOTIFICATION(WillUpdate);
} }
// /*
// Implemented by the delegate * Implemented by the delegate
// */
- (BOOL) application: sender openFileWithoutUI: (NSString *)filename - (BOOL) application: sender openFileWithoutUI: (NSString *)filename
{ {
BOOL result = NO; BOOL result = NO;
@ -1576,9 +1580,9 @@ NSAssert([event retainCount] > 0, NSInternalInconsistencyException);
[delegate applicationWillUpdate: aNotification]; [delegate applicationWillUpdate: aNotification];
} }
// /*
// NSCoding protocol * NSCoding protocol
// */
- (void) encodeWithCoder: (NSCoder*)aCoder - (void) encodeWithCoder: (NSCoder*)aCoder
{ {
[super encodeWithCoder: aCoder]; [super encodeWithCoder: aCoder];