1996-05-30 20:03:15 +00:00
|
|
|
/*
|
|
|
|
NSApplication.m
|
|
|
|
|
|
|
|
The one and only application class
|
|
|
|
|
|
|
|
Copyright (C) 1996 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Author: Scott Christley <scottc@net-community.com>
|
|
|
|
Date: 1996
|
|
|
|
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
1996-10-18 17:14:13 +00:00
|
|
|
License along with this library; see the file COPYING.LIB.
|
|
|
|
If not, write to the Free Software Foundation,
|
|
|
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1996-05-30 20:03:15 +00:00
|
|
|
*/
|
|
|
|
|
1997-09-23 22:43:24 +00:00
|
|
|
#include <gnustep/gui/config.h>
|
1996-05-30 20:03:15 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
1997-02-18 00:29:25 +00:00
|
|
|
#include <Foundation/NSArray.h>
|
1998-01-09 22:28:14 +00:00
|
|
|
#include <Foundation/NSDictionary.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
#include <Foundation/NSNotification.h>
|
1997-04-22 18:23:58 +00:00
|
|
|
#include <Foundation/NSRunLoop.h>
|
1997-07-07 16:56:52 +00:00
|
|
|
#include <Foundation/NSAutoreleasePool.h>
|
1997-10-09 22:55:31 +00:00
|
|
|
#include <Foundation/NSTimer.h>
|
1998-01-09 22:28:14 +00:00
|
|
|
#include <Foundation/NSProcessInfo.h>
|
|
|
|
#include <Foundation/NSFileManager.h>
|
1997-07-07 16:56:52 +00:00
|
|
|
|
1997-10-09 22:55:31 +00:00
|
|
|
#ifndef LIB_FOUNDATION_LIBRARY
|
1997-08-27 21:20:19 +00:00
|
|
|
# include <Foundation/NSConnection.h>
|
|
|
|
#endif
|
|
|
|
|
1998-01-09 22:28:14 +00:00
|
|
|
#include <AppKit/NSDPSContext.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
#include <AppKit/NSApplication.h>
|
|
|
|
#include <AppKit/NSPopUpButton.h>
|
|
|
|
#include <AppKit/NSPanel.h>
|
|
|
|
#include <AppKit/NSEvent.h>
|
|
|
|
#include <AppKit/NSImage.h>
|
|
|
|
#include <AppKit/NSMenu.h>
|
1997-07-07 16:56:52 +00:00
|
|
|
#include <AppKit/NSMenuItem.h>
|
1997-03-05 01:11:17 +00:00
|
|
|
#include <AppKit/NSCursor.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
|
1998-01-09 22:28:14 +00:00
|
|
|
#include <AppKit/IMLoading.h>
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1997-08-04 20:42:56 +00:00
|
|
|
// Class variables
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1997-08-04 20:42:56 +00:00
|
|
|
static BOOL gnustep_gui_app_is_in_dealloc;
|
1997-08-16 23:47:24 +00:00
|
|
|
static NSEvent *gnustep_gui_null_event;
|
|
|
|
static id NSApp;
|
|
|
|
|
1997-10-09 22:55:31 +00:00
|
|
|
#define ASSIGN(a, b) \
|
|
|
|
[b retain]; \
|
|
|
|
[a release]; \
|
|
|
|
a = b;
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
@implementation NSApplication
|
|
|
|
|
|
|
|
//
|
|
|
|
// Class methods
|
|
|
|
//
|
|
|
|
+ (void)initialize
|
|
|
|
{
|
|
|
|
if (self == [NSApplication class])
|
|
|
|
{
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"Initialize NSApplication class\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
// Initial version
|
|
|
|
[self setVersion:1];
|
1996-06-06 13:55:06 +00:00
|
|
|
|
|
|
|
// So the application knows its within dealloc
|
|
|
|
// and can prevent -release loops.
|
|
|
|
gnustep_gui_app_is_in_dealloc = NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (NSApplication *)sharedApplication
|
|
|
|
{
|
|
|
|
// If the global application does not exist yet then create it
|
1997-10-09 22:55:31 +00:00
|
|
|
if (!NSApp) {
|
|
|
|
/* Don't combine the following two statements into one to avoid problems
|
|
|
|
with some classes initialization code that tries to get the shared
|
|
|
|
application. */
|
|
|
|
NSApp = [self alloc];
|
|
|
|
[NSApp init];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
return NSApp;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Instance methods
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// Creating and initializing the NSApplication
|
|
|
|
//
|
|
|
|
- init
|
|
|
|
{
|
|
|
|
[super init];
|
|
|
|
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"Begin of NSApplication -init\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
// allocate the window list
|
1997-10-09 22:55:31 +00:00
|
|
|
window_list = [NSMutableArray new];
|
1996-05-30 20:03:15 +00:00
|
|
|
window_count = 1;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Event handling setup
|
|
|
|
//
|
|
|
|
// allocate the event queue
|
1997-10-09 22:55:31 +00:00
|
|
|
event_queue = [NSMutableArray new];
|
1996-05-30 20:03:15 +00:00
|
|
|
// No current event
|
|
|
|
current_event = nil;
|
|
|
|
// The NULL event
|
1997-10-09 22:55:31 +00:00
|
|
|
gnustep_gui_null_event = [NSEvent new];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// We are the end of the responder chain
|
|
|
|
//
|
|
|
|
[self setNextResponder:NULL];
|
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
/* Set up the run loop object for the current thread */
|
|
|
|
[self setupRunLoopInputSourcesForMode:NSDefaultRunLoopMode];
|
|
|
|
[self setupRunLoopInputSourcesForMode:NSConnectionReplyMode];
|
|
|
|
[self setupRunLoopInputSourcesForMode:NSModalPanelRunLoopMode];
|
|
|
|
[self setupRunLoopInputSourcesForMode:NSEventTrackingRunLoopMode];
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)finishLaunching
|
|
|
|
{
|
1996-10-03 18:45:41 +00:00
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
1998-01-09 22:28:14 +00:00
|
|
|
NSBundle* mainBundle = [NSBundle mainBundle];
|
|
|
|
NSString* resourcePath = [mainBundle resourcePath];
|
|
|
|
NSString* infoFilePath
|
|
|
|
= [resourcePath stringByAppendingPathComponent:@"Info-gnustep.plist"];
|
|
|
|
NSDictionary* infoDict = [[NSString stringWithContentsOfFile:infoFilePath]
|
|
|
|
propertyList];
|
|
|
|
NSString* mainModelFile = [infoDict objectForKey:@"NSMainNibFile"];
|
|
|
|
|
1998-01-30 00:34:25 +00:00
|
|
|
if (mainModelFile && ![mainModelFile isEqual:@""]) {
|
1998-01-09 22:28:14 +00:00
|
|
|
if (![GMModel loadIMFile:mainModelFile
|
|
|
|
owner:[NSApplication sharedApplication]])
|
|
|
|
NSLog (@"Cannot load the main model file '%@", mainModelFile);
|
|
|
|
}
|
1996-10-03 18:45:41 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
// notify that we will finish the launching
|
1996-10-03 18:45:41 +00:00
|
|
|
[nc postNotificationName: NSApplicationWillFinishLaunchingNotification
|
|
|
|
object: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1996-10-03 18:45:41 +00:00
|
|
|
// finish the launching
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1996-10-03 18:45:41 +00:00
|
|
|
// notify that the launching has finished
|
|
|
|
[nc postNotificationName: NSApplicationDidFinishLaunchingNotification
|
|
|
|
object: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dealloc
|
|
|
|
{
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"Freeing NSApplication\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1996-06-06 13:55:06 +00:00
|
|
|
// Let ourselves know we are within dealloc
|
|
|
|
gnustep_gui_app_is_in_dealloc = YES;
|
|
|
|
|
1997-10-09 22:55:31 +00:00
|
|
|
[window_list release];
|
1996-05-30 20:03:15 +00:00
|
|
|
[event_queue release];
|
|
|
|
[current_event release];
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Changing the active application
|
|
|
|
//
|
|
|
|
- (void)activateIgnoringOtherApps:(BOOL)flag
|
|
|
|
{
|
|
|
|
app_is_active = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)deactivate
|
|
|
|
{
|
|
|
|
app_is_active = NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isActive
|
|
|
|
{
|
|
|
|
return app_is_active;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Running the event loop
|
|
|
|
//
|
|
|
|
- (void)abortModal
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSModalSession)beginModalSessionForWindow:(NSWindow *)theWindow
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)endModalSession:(NSModalSession)theSession
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isRunning
|
|
|
|
{
|
|
|
|
return app_is_running;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)run
|
|
|
|
{
|
|
|
|
NSEvent *e;
|
1997-07-07 16:56:52 +00:00
|
|
|
NSAutoreleasePool* pool;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"NSApplication -run\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
[self finishLaunching];
|
|
|
|
|
|
|
|
app_should_quit = NO;
|
|
|
|
app_is_running = YES;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
1997-07-07 16:56:52 +00:00
|
|
|
pool = [NSAutoreleasePool new];
|
1997-11-14 21:32:31 +00:00
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
e = [self nextEventMatchingMask:NSAnyEventMask
|
|
|
|
untilDate:[NSDate distantFuture]
|
|
|
|
inMode:NSDefaultRunLoopMode dequeue:YES];
|
|
|
|
if (e)
|
1997-03-05 01:11:17 +00:00
|
|
|
[self sendEvent: e];
|
1996-05-30 20:03:15 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Null event
|
|
|
|
// Call the back-end method to handle it
|
|
|
|
[self handleNullEvent];
|
|
|
|
}
|
1997-07-07 16:56:52 +00:00
|
|
|
[pool release];
|
1996-05-30 20:03:15 +00:00
|
|
|
} while (!app_should_quit);
|
|
|
|
app_is_running = YES;
|
|
|
|
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"NSApplication end of run loop\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int)runModalForWindow:(NSWindow *)theWindow
|
|
|
|
{
|
1998-08-19 09:00:26 +00:00
|
|
|
[theWindow display];
|
|
|
|
[theWindow makeKeyAndOrderFront: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int)runModalSession:(NSModalSession)theSession
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)sendEvent:(NSEvent *)theEvent
|
|
|
|
{
|
|
|
|
// Don't send the null event
|
1997-03-29 20:03:45 +00:00
|
|
|
if (theEvent == gnustep_gui_null_event)
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"Not sending the Null Event\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// What is the event type
|
|
|
|
switch ([theEvent type])
|
|
|
|
{
|
|
|
|
|
|
|
|
//
|
|
|
|
// NSApplication traps the periodic events
|
|
|
|
//
|
|
|
|
case NSPeriodic:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSKeyDown:
|
|
|
|
{
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"send key down event\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
[[theEvent window] sendEvent:theEvent];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NSKeyUp:
|
|
|
|
{
|
|
|
|
NSDebugLog(@"send key up event\n");
|
|
|
|
[[theEvent window] sendEvent:theEvent];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// All others get passed to the window
|
|
|
|
//
|
|
|
|
default:
|
|
|
|
{
|
1997-10-09 22:55:31 +00:00
|
|
|
NSWindow* window = [theEvent window];
|
|
|
|
|
1996-07-11 00:59:30 +00:00
|
|
|
if (!theEvent) NSDebugLog(@"NSEvent is nil!\n");
|
1997-10-09 22:55:31 +00:00
|
|
|
NSDebugLog(@"NSEvent type: %d", [theEvent type]);
|
|
|
|
NSDebugLog(@"send event to window");
|
|
|
|
NSDebugLog([window description]);
|
|
|
|
if (!window)
|
|
|
|
NSDebugLog(@"no window");
|
|
|
|
[window sendEvent:theEvent];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)stop:sender
|
|
|
|
{
|
|
|
|
app_is_running = NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)stopModal
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)stopModalWithCode:(int)returnCode
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Getting, removing, and posting events
|
|
|
|
//
|
|
|
|
- (BOOL)event:(NSEvent *)theEvent matchMask:(unsigned int)mask
|
|
|
|
{
|
|
|
|
NSEventType t;
|
|
|
|
|
|
|
|
// If mask is for any event then return success
|
|
|
|
if (mask == NSAnyEventMask)
|
|
|
|
return YES;
|
|
|
|
|
|
|
|
if (!theEvent) return NO;
|
|
|
|
|
1996-10-03 18:45:41 +00:00
|
|
|
// Don't check the null event
|
1997-03-29 20:03:45 +00:00
|
|
|
if (theEvent == gnustep_gui_null_event) return NO;
|
1996-10-03 18:45:41 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
t = [theEvent type];
|
|
|
|
|
|
|
|
if ((t == NSLeftMouseDown) && (mask & NSLeftMouseDownMask))
|
|
|
|
return YES;
|
|
|
|
|
|
|
|
if ((t == NSLeftMouseUp) && (mask & NSLeftMouseUpMask))
|
|
|
|
return YES;
|
|
|
|
|
|
|
|
if ((t == NSRightMouseDown) && (mask & NSRightMouseDownMask))
|
|
|
|
return YES;
|
|
|
|
|
|
|
|
if ((t == NSRightMouseUp) && (mask & NSRightMouseUpMask))
|
|
|
|
return YES;
|
|
|
|
|
|
|
|
if ((t == NSMouseMoved) && (mask & NSMouseMovedMask))
|
|
|
|
return YES;
|
|
|
|
|
|
|
|
if ((t == NSMouseEntered) && (mask & NSMouseEnteredMask))
|
|
|
|
return YES;
|
|
|
|
|
|
|
|
if ((t == NSMouseExited) && (mask & NSMouseExitedMask))
|
|
|
|
return YES;
|
|
|
|
|
|
|
|
if ((t == NSLeftMouseDragged) && (mask & NSLeftMouseDraggedMask))
|
|
|
|
return YES;
|
|
|
|
|
|
|
|
if ((t == NSRightMouseDragged) && (mask & NSRightMouseDraggedMask))
|
|
|
|
return YES;
|
|
|
|
|
|
|
|
if ((t == NSKeyDown) && (mask & NSKeyDownMask))
|
|
|
|
return YES;
|
|
|
|
|
|
|
|
if ((t == NSKeyUp) && (mask & NSKeyUpMask))
|
|
|
|
return YES;
|
|
|
|
|
|
|
|
if ((t == NSFlagsChanged) && (mask & NSFlagsChangedMask))
|
|
|
|
return YES;
|
|
|
|
|
|
|
|
if ((t == NSPeriodic) && (mask & NSPeriodicMask))
|
|
|
|
return YES;
|
|
|
|
|
|
|
|
if ((t == NSCursorUpdate) && (mask & NSCursorUpdateMask))
|
|
|
|
return YES;
|
|
|
|
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
1997-10-09 22:55:31 +00:00
|
|
|
- (void)setCurrentEvent:(NSEvent *)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
[theEvent retain];
|
|
|
|
[current_event release];
|
|
|
|
current_event = theEvent;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSEvent *)currentEvent;
|
|
|
|
{
|
|
|
|
return current_event;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)discardEventsMatchingMask:(unsigned int)mask
|
|
|
|
beforeEvent:(NSEvent *)lastEvent
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1997-07-07 16:56:52 +00:00
|
|
|
- (NSEvent*)_eventMatchingMask:(unsigned int)mask
|
|
|
|
{
|
|
|
|
NSEvent* event;
|
1997-12-04 01:58:57 +00:00
|
|
|
int i, count = [event_queue count];
|
1997-07-07 16:56:52 +00:00
|
|
|
|
1997-11-14 21:32:31 +00:00
|
|
|
[self getNextEvent];
|
|
|
|
|
1997-07-07 16:56:52 +00:00
|
|
|
/* Get an event from the events queue */
|
|
|
|
if ((count = [event_queue count])) {
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
event = [event_queue objectAtIndex:i];
|
|
|
|
if ([self event:event matchMask:mask]) {
|
|
|
|
[event retain];
|
|
|
|
[event_queue removeObjectAtIndex:i];
|
|
|
|
[self setCurrentEvent:event];
|
|
|
|
return [event autorelease];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
- (NSEvent *)nextEventMatchingMask:(unsigned int)mask
|
|
|
|
untilDate:(NSDate *)expiration
|
|
|
|
inMode:(NSString *)mode
|
|
|
|
dequeue:(BOOL)flag
|
|
|
|
{
|
1997-07-07 16:56:52 +00:00
|
|
|
NSRunLoop* currentLoop = [NSRunLoop currentRunLoop];
|
|
|
|
NSEventType type;
|
|
|
|
NSEvent *event;
|
|
|
|
BOOL done = NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-07-07 16:56:52 +00:00
|
|
|
event = [self _eventMatchingMask:mask];
|
|
|
|
if (event)
|
|
|
|
done = YES;
|
1997-10-09 22:55:31 +00:00
|
|
|
else if (!expiration)
|
|
|
|
expiration = [NSDate distantFuture];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
// Not in queue so wait for next event
|
1997-07-07 16:56:52 +00:00
|
|
|
while (!done) {
|
1997-11-14 21:32:31 +00:00
|
|
|
NSDate *limitDate, *originalLimitDate;
|
|
|
|
|
|
|
|
// flush any windows that need it
|
|
|
|
[NSWindow _flushWindows];
|
|
|
|
[self _flushCommunicationChannels];
|
|
|
|
|
1997-10-28 20:44:38 +00:00
|
|
|
/* Retain the limitDate so it doesn't get release accidentally by
|
|
|
|
runMode:beforeDate: if a timer which has this date as fire date gets
|
|
|
|
released. */
|
1997-11-14 21:32:31 +00:00
|
|
|
limitDate = [[currentLoop limitDateForMode:mode] retain];
|
|
|
|
originalLimitDate = limitDate;
|
1997-04-22 18:23:58 +00:00
|
|
|
|
1997-08-06 20:29:07 +00:00
|
|
|
event = [self _eventMatchingMask:mask];
|
1997-10-28 20:44:38 +00:00
|
|
|
if (event) {
|
|
|
|
[limitDate release];
|
1997-08-06 20:29:07 +00:00
|
|
|
break;
|
1997-10-28 20:44:38 +00:00
|
|
|
}
|
1997-07-07 16:56:52 +00:00
|
|
|
|
|
|
|
if (limitDate)
|
|
|
|
limitDate = [expiration earlierDate:limitDate];
|
|
|
|
else
|
|
|
|
limitDate = expiration;
|
|
|
|
|
|
|
|
[currentLoop runMode:mode beforeDate:limitDate];
|
1997-10-28 20:44:38 +00:00
|
|
|
[originalLimitDate release];
|
1997-11-14 21:32:31 +00:00
|
|
|
|
1997-07-07 16:56:52 +00:00
|
|
|
event = [self _eventMatchingMask:mask];
|
|
|
|
if (event)
|
1997-08-06 20:29:07 +00:00
|
|
|
break;
|
1997-07-07 16:56:52 +00:00
|
|
|
}
|
|
|
|
|
1997-12-04 01:58:57 +00:00
|
|
|
// flush any windows that need it
|
|
|
|
[NSWindow _flushWindows];
|
|
|
|
[self _flushCommunicationChannels];
|
|
|
|
|
1997-07-07 16:56:52 +00:00
|
|
|
type = [event type];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-03-05 01:11:17 +00:00
|
|
|
// Unhide the cursor if necessary
|
1997-03-29 20:03:45 +00:00
|
|
|
// but only if its not a null event
|
1997-07-07 16:56:52 +00:00
|
|
|
if (event != gnustep_gui_null_event)
|
1997-03-29 20:03:45 +00:00
|
|
|
{
|
|
|
|
// Only if we should unhide when mouse moves
|
|
|
|
if ([NSCursor isHiddenUntilMouseMoves])
|
|
|
|
{
|
|
|
|
// Make sure the event is a mouse event before unhiding
|
|
|
|
if ((type == NSLeftMouseDown) || (type == NSLeftMouseUp)
|
|
|
|
|| (type == NSRightMouseDown) || (type == NSRightMouseUp)
|
|
|
|
|| (type == NSMouseMoved))
|
|
|
|
[NSCursor unhide];
|
|
|
|
}
|
|
|
|
}
|
1997-03-05 01:11:17 +00:00
|
|
|
|
1997-07-07 16:56:52 +00:00
|
|
|
return event;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1997-03-27 17:47:03 +00:00
|
|
|
- (NSEvent *)peekEventMatchingMask:(unsigned int)mask
|
|
|
|
untilDate:(NSDate *)expiration
|
|
|
|
inMode:(NSString *)mode
|
|
|
|
dequeue:(BOOL)flag
|
|
|
|
{
|
1997-08-16 23:47:24 +00:00
|
|
|
NSEvent *event = nil;
|
1997-03-27 17:47:03 +00:00
|
|
|
|
1997-08-16 23:47:24 +00:00
|
|
|
event = [self _eventMatchingMask:mask];
|
1997-03-27 17:47:03 +00:00
|
|
|
|
1997-08-16 23:47:24 +00:00
|
|
|
if (!event)
|
1997-03-27 17:47:03 +00:00
|
|
|
{
|
1997-08-16 23:47:24 +00:00
|
|
|
// Not in queue so peek for event
|
|
|
|
event = [self peekNextEvent];
|
|
|
|
|
|
|
|
event = [self _eventMatchingMask:mask];
|
1997-03-27 17:47:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Unhide the cursor if necessary
|
1997-08-16 23:47:24 +00:00
|
|
|
if (event && (event != gnustep_gui_null_event))
|
1997-03-29 20:03:45 +00:00
|
|
|
{
|
|
|
|
NSEventType type;
|
1997-03-27 17:47:03 +00:00
|
|
|
|
1997-03-29 20:03:45 +00:00
|
|
|
// Only if we should unhide when mouse moves
|
|
|
|
if ([NSCursor isHiddenUntilMouseMoves])
|
|
|
|
{
|
|
|
|
// Make sure the event is a mouse event before unhiding
|
1997-08-16 23:47:24 +00:00
|
|
|
type = [event type];
|
1997-03-29 20:03:45 +00:00
|
|
|
if ((type == NSLeftMouseDown) || (type == NSLeftMouseUp)
|
|
|
|
|| (type == NSRightMouseDown) || (type == NSRightMouseUp)
|
|
|
|
|| (type == NSMouseMoved))
|
|
|
|
[NSCursor unhide];
|
|
|
|
}
|
|
|
|
}
|
1997-03-27 17:47:03 +00:00
|
|
|
|
1997-08-16 23:47:24 +00:00
|
|
|
return event;
|
1997-03-27 17:47:03 +00:00
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
- (void)postEvent:(NSEvent *)event atStart:(BOOL)flag
|
|
|
|
{
|
1997-10-09 22:55:31 +00:00
|
|
|
if (!flag)
|
1997-03-05 01:11:17 +00:00
|
|
|
[event_queue addObject: event];
|
|
|
|
else
|
|
|
|
[event_queue insertObject: event atIndex: 0];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Sending action messages
|
|
|
|
//
|
|
|
|
- (BOOL)sendAction:(SEL)aSelector
|
|
|
|
to:aTarget
|
|
|
|
from:sender
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// If the target responds to the selector
|
|
|
|
// then have it perform it
|
|
|
|
//
|
|
|
|
if ([aTarget respondsToSelector:aSelector])
|
|
|
|
{
|
1997-08-27 21:20:19 +00:00
|
|
|
[aTarget performSelector:aSelector withObject:sender];
|
1996-05-30 20:03:15 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Otherwise traverse the responder chain
|
|
|
|
//
|
|
|
|
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- targetForAction:(SEL)aSelector
|
|
|
|
{
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)tryToPerform:(SEL)aSelector
|
|
|
|
with:anObject
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Setting the application's icon
|
|
|
|
- (void)setApplicationIconImage:(NSImage *)anImage
|
|
|
|
{
|
|
|
|
if (app_icon != nil)
|
|
|
|
{
|
|
|
|
[app_icon release];
|
|
|
|
}
|
|
|
|
|
|
|
|
app_icon = [anImage retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSImage *)applicationIconImage
|
|
|
|
{
|
|
|
|
return app_icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Hiding all windows
|
|
|
|
//
|
|
|
|
- (void)hide:sender
|
|
|
|
{
|
1997-10-09 22:55:31 +00:00
|
|
|
int i, count;
|
1997-10-28 20:44:38 +00:00
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
|
|
|
|
|
|
|
// notify that we will hide
|
|
|
|
[nc postNotificationName: NSApplicationWillHideNotification
|
|
|
|
object: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-08-16 23:47:24 +00:00
|
|
|
// TODO: hide the menu
|
|
|
|
|
|
|
|
// Tell the windows to hide
|
1997-10-09 22:55:31 +00:00
|
|
|
for (i = 0, count = [window_list count]; i < count; i++)
|
|
|
|
[[window_list objectAtIndex:i] performHide:sender];
|
1997-08-16 23:47:24 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
app_is_hidden = YES;
|
1997-10-28 20:44:38 +00:00
|
|
|
|
|
|
|
// notify that we did hide
|
|
|
|
[nc postNotificationName: NSApplicationDidHideNotification
|
|
|
|
object: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isHidden
|
|
|
|
{
|
|
|
|
return app_is_hidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)unhide:sender
|
|
|
|
{
|
1997-10-09 22:55:31 +00:00
|
|
|
int i, count;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-08-16 23:47:24 +00:00
|
|
|
// Tell the windows to unhide
|
1997-10-09 22:55:31 +00:00
|
|
|
for (i = 0, count = [window_list count]; i < count; i++)
|
|
|
|
[[window_list objectAtIndex:i] performUnhide:sender];
|
1997-08-16 23:47:24 +00:00
|
|
|
|
|
|
|
// TODO: unhide the menu
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
app_is_hidden = NO;
|
|
|
|
|
1997-08-16 23:47:24 +00:00
|
|
|
// Bring the key window to the front
|
1996-05-30 20:03:15 +00:00
|
|
|
[[self keyWindow] makeKeyAndOrderFront:self];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)unhideWithoutActivation
|
|
|
|
{
|
1997-10-28 20:44:38 +00:00
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
|
|
|
|
|
|
|
// notify that we will unhide
|
|
|
|
[nc postNotificationName: NSApplicationWillUnhideNotification
|
|
|
|
object: self];
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
[self unhide: self];
|
1997-10-28 20:44:38 +00:00
|
|
|
|
|
|
|
// notify that we did unhide
|
|
|
|
[nc postNotificationName: NSApplicationDidUnhideNotification
|
|
|
|
object: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Managing windows
|
|
|
|
//
|
|
|
|
- (NSWindow *)keyWindow
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
id w;
|
|
|
|
|
|
|
|
j = [window_list count];
|
|
|
|
for (i = 0;i < j; ++i)
|
|
|
|
{
|
|
|
|
w = [window_list objectAtIndex:i];
|
|
|
|
if ([w isKeyWindow]) return w;
|
|
|
|
}
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSWindow *)mainWindow
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
id w;
|
|
|
|
|
|
|
|
j = [window_list count];
|
|
|
|
for (i = 0;i < j; ++i)
|
|
|
|
{
|
|
|
|
w = [window_list objectAtIndex:i];
|
|
|
|
if ([w isMainWindow]) return w;
|
|
|
|
}
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSWindow *)makeWindowsPerform:(SEL)aSelector
|
|
|
|
inOrder:(BOOL)flag
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)miniaturizeAll:sender
|
|
|
|
{
|
1997-10-09 22:55:31 +00:00
|
|
|
int i, count;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-10-09 22:55:31 +00:00
|
|
|
for (i = 0, count = [window_list count]; i < count; i++)
|
|
|
|
[[window_list objectAtIndex:i] miniaturize:sender];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)preventWindowOrdering
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setWindowsNeedUpdate:(BOOL)flag
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)updateWindows
|
|
|
|
{
|
1997-10-09 22:55:31 +00:00
|
|
|
int i, count;
|
1997-10-28 20:44:38 +00:00
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
|
|
|
|
|
|
|
// notify that we will update
|
|
|
|
[nc postNotificationName: NSApplicationWillUpdateNotification
|
|
|
|
object: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-10-09 22:55:31 +00:00
|
|
|
for (i = 0, count = [window_list count]; i < count; i++)
|
|
|
|
[[window_list objectAtIndex:i] update];
|
1997-10-28 20:44:38 +00:00
|
|
|
|
|
|
|
// notify that we did update
|
|
|
|
[nc postNotificationName: NSApplicationDidUpdateNotification
|
|
|
|
object: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *)windows
|
|
|
|
{
|
|
|
|
return window_list;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSWindow *)windowWithWindowNumber:(int)windowNum
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
NSWindow *w;
|
|
|
|
|
|
|
|
j = [window_list count];
|
|
|
|
for (i = 0;i < j; ++i)
|
|
|
|
{
|
|
|
|
w = [window_list objectAtIndex:i];
|
|
|
|
if ([w windowNumber] == windowNum) return w;
|
|
|
|
}
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Showing Standard Panels
|
|
|
|
//
|
|
|
|
- (void)orderFrontColorPanel:sender
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)orderFrontDataLinkPanel:sender
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)orderFrontHelpPanel:sender
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)runPageLayout:sender
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Getting the main menu
|
|
|
|
//
|
|
|
|
- (NSMenu *)mainMenu
|
|
|
|
{
|
|
|
|
return main_menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setMainMenu:(NSMenu *)aMenu
|
|
|
|
{
|
|
|
|
int i, j;
|
1997-07-07 16:56:52 +00:00
|
|
|
NSMenuItem *mc;
|
1996-05-30 20:03:15 +00:00
|
|
|
NSArray *mi;
|
|
|
|
|
|
|
|
// Release old and retain new
|
1997-07-07 16:56:52 +00:00
|
|
|
[aMenu retain];
|
1996-05-30 20:03:15 +00:00
|
|
|
[main_menu release];
|
|
|
|
main_menu = aMenu;
|
|
|
|
|
|
|
|
// Search for a menucell with the name Windows
|
|
|
|
// This is the default windows menu
|
|
|
|
mi = [main_menu itemArray];
|
|
|
|
j = [mi count];
|
|
|
|
windows_menu = nil;
|
|
|
|
for (i = 0;i < j; ++i)
|
|
|
|
{
|
|
|
|
mc = [mi objectAtIndex:i];
|
|
|
|
if ([[mc stringValue] compare:@"Windows"] == NSOrderedSame)
|
|
|
|
{
|
|
|
|
// Found it!
|
|
|
|
windows_menu = mc;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Managing the Windows menu
|
|
|
|
//
|
|
|
|
- (void)addWindowsItem:aWindow
|
|
|
|
title:(NSString *)aString
|
|
|
|
filename:(BOOL)isFilename
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
// Not a subclass of window --forget it
|
|
|
|
if (![aWindow isKindOfClass:[NSWindow class]])
|
|
|
|
return;
|
|
|
|
|
1996-06-06 13:55:06 +00:00
|
|
|
// Add to our window list, the array retains it
|
1996-05-30 20:03:15 +00:00
|
|
|
i = [window_list count];
|
|
|
|
[window_list addObject:aWindow];
|
|
|
|
|
|
|
|
// set its window number
|
|
|
|
[aWindow setWindowNumber:window_count];
|
|
|
|
++window_count;
|
|
|
|
|
|
|
|
// If this was the first window then
|
|
|
|
// make it the main and key window
|
|
|
|
if (i == 0)
|
|
|
|
{
|
|
|
|
[aWindow becomeMainWindow];
|
|
|
|
[aWindow becomeKeyWindow];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)arrangeInFront:sender
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)changeWindowsItem:aWindow
|
|
|
|
title:(NSString *)aString
|
|
|
|
filename:(BOOL)isFilename
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)removeWindowsItem:aWindow
|
|
|
|
{
|
1996-06-06 13:55:06 +00:00
|
|
|
// +++ This should be different
|
1996-05-30 20:03:15 +00:00
|
|
|
if (aWindow == key_window)
|
|
|
|
key_window = nil;
|
|
|
|
if (aWindow == main_window)
|
|
|
|
main_window = nil;
|
|
|
|
|
1996-06-06 13:55:06 +00:00
|
|
|
// If we are within our dealloc then don't remove the window
|
|
|
|
// Most likely dealloc is removing windows from our window list
|
|
|
|
// and subsequently NSWindow is caling us to remove itself.
|
|
|
|
if (gnustep_gui_app_is_in_dealloc)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Remove it from the window list
|
|
|
|
[window_list removeObject: aWindow];
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setWindowsMenu:aMenu
|
|
|
|
{
|
1997-07-07 16:56:52 +00:00
|
|
|
// if (windows_menu)
|
|
|
|
// [windows_menu setSubmenu:aMenu];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)updateWindowsItem:aWindow
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSMenu *)windowsMenu
|
|
|
|
{
|
1997-07-07 16:56:52 +00:00
|
|
|
// return [windows_menu submenu];
|
|
|
|
return nil;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Managing the Service menu
|
|
|
|
//
|
|
|
|
- (void)registerServicesMenuSendTypes:(NSArray *)sendTypes
|
|
|
|
returnTypes:(NSArray *)returnTypes
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSMenu *)servicesMenu
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setServicesMenu:(NSMenu *)aMenu
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- validRequestorForSendType:(NSString *)sendType
|
|
|
|
returnType:(NSString *)returnType
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Getting the display postscript context
|
1996-06-06 13:55:06 +00:00
|
|
|
- (NSDPSContext *)context
|
|
|
|
{
|
|
|
|
return [NSDPSContext currentContext];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
// Reporting an exception
|
1996-08-22 18:51:08 +00:00
|
|
|
- (void)reportException:(NSException *)anException
|
|
|
|
{}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Terminating the application
|
|
|
|
//
|
|
|
|
- (void)terminate:sender
|
|
|
|
{
|
|
|
|
if ([self applicationShouldTerminate:sender])
|
|
|
|
app_should_quit = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assigning a delegate
|
|
|
|
- delegate
|
|
|
|
{
|
|
|
|
return delegate;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setDelegate:anObject
|
|
|
|
{
|
1997-10-28 20:44:38 +00:00
|
|
|
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
delegate = anObject;
|
1997-10-22 01:47:30 +00:00
|
|
|
|
1997-10-28 20:44:38 +00:00
|
|
|
#define SET_DELEGATE_NOTIFICATION(notif_name) \
|
|
|
|
if ([delegate respondsToSelector:@selector(application##notif_name:)]) \
|
|
|
|
[nc addObserver:delegate \
|
|
|
|
selector:@selector(application##notif_name:) \
|
|
|
|
name:NSApplication##notif_name##Notification object:self]
|
|
|
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidBecomeActive);
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidFinishLaunching);
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidHide);
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidResignActive);
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidUnhide);
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidUpdate);
|
|
|
|
SET_DELEGATE_NOTIFICATION(WillBecomeActive);
|
|
|
|
SET_DELEGATE_NOTIFICATION(WillFinishLaunching);
|
|
|
|
SET_DELEGATE_NOTIFICATION(WillHide);
|
|
|
|
SET_DELEGATE_NOTIFICATION(WillResignActive);
|
|
|
|
SET_DELEGATE_NOTIFICATION(WillUnhide);
|
|
|
|
SET_DELEGATE_NOTIFICATION(WillUpdate);
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Implemented by the delegate
|
|
|
|
//
|
|
|
|
- (BOOL)application:sender openFileWithoutUI:(NSString *)filename
|
|
|
|
{
|
|
|
|
BOOL result = NO;
|
|
|
|
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(application:openFileWithoutUI:)])
|
1996-05-30 20:03:15 +00:00
|
|
|
result = [delegate application:sender openFileWithoutUI:filename];
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)application:(NSApplication *)app openFile:(NSString *)filename
|
|
|
|
{
|
|
|
|
BOOL result = NO;
|
|
|
|
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(application:openFile:)])
|
1996-05-30 20:03:15 +00:00
|
|
|
result = [delegate application:app openFile:filename];
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)application:(NSApplication *)app openTempFile:(NSString *)filename
|
|
|
|
{
|
|
|
|
BOOL result = NO;
|
|
|
|
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(application:openTempFile:)])
|
1996-05-30 20:03:15 +00:00
|
|
|
result = [delegate application:app openTempFile:filename];
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)applicationDidBecomeActive:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(applicationDidBecomeActive:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
[delegate applicationDidBecomeActive:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(applicationDidFinishLaunching:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
[delegate applicationDidFinishLaunching:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)applicationDidHide:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(applicationDidHide:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
[delegate applicationDidHide:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)applicationDidResignActive:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(applicationDidResignActive:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
[delegate applicationDidResignActive:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)applicationDidUnhide:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(applicationDidUnhide:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
[delegate applicationDidUnhide:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)applicationDidUpdate:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(applicationDidUpdate:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
[delegate applicationDidUpdate:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)applicationOpenUntitledFile:(NSApplication *)app
|
|
|
|
{
|
|
|
|
BOOL result = NO;
|
|
|
|
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(applicationOpenUntitledFile:)])
|
1996-05-30 20:03:15 +00:00
|
|
|
result = [delegate applicationOpenUntitledFile:app];
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)applicationShouldTerminate:sender
|
|
|
|
{
|
|
|
|
BOOL result = YES;
|
|
|
|
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(applicationShouldTerminate:)])
|
1996-05-30 20:03:15 +00:00
|
|
|
result = [delegate applicationShouldTerminate:sender];
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)applicationWillBecomeActive:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(applicationWillBecomeActive:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
[delegate applicationWillBecomeActive:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(applicationWillFinishLaunching:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
[delegate applicationWillFinishLaunching:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)applicationWillHide:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(applicationWillHide:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
[delegate applicationWillHide:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)applicationWillResignActive:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(applicationWillResignActive:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
[delegate applicationWillResignActive:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)applicationWillUnhide:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(applicationWillUnhide:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
[delegate applicationWillUnhide:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1996-09-12 19:24:32 +00:00
|
|
|
- (void)applicationWillUpdate:(NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-02-18 00:29:25 +00:00
|
|
|
if ([delegate respondsToSelector:@selector(applicationWillUpdate:)])
|
1996-09-12 19:24:32 +00:00
|
|
|
[delegate applicationWillUpdate:aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// NSCoding protocol
|
|
|
|
//
|
|
|
|
- (void)encodeWithCoder:aCoder
|
|
|
|
{
|
|
|
|
[super encodeWithCoder:aCoder];
|
|
|
|
|
|
|
|
[aCoder encodeObject: window_list];
|
1997-02-18 00:29:25 +00:00
|
|
|
[aCoder encodeConditionalObject:key_window];
|
|
|
|
[aCoder encodeConditionalObject:main_window];
|
|
|
|
[aCoder encodeConditionalObject:delegate];
|
|
|
|
[aCoder encodeObject:main_menu];
|
|
|
|
[aCoder encodeConditionalObject:windows_menu];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- initWithCoder:aDecoder
|
|
|
|
{
|
|
|
|
[super initWithCoder:aDecoder];
|
|
|
|
|
|
|
|
window_list = [aDecoder decodeObject];
|
1997-02-18 00:29:25 +00:00
|
|
|
key_window = [aDecoder decodeObject];
|
|
|
|
main_window = [aDecoder decodeObject];
|
|
|
|
delegate = [aDecoder decodeObject];
|
|
|
|
main_menu = [aDecoder decodeObject];
|
|
|
|
windows_menu = [aDecoder decodeObject];
|
1996-05-30 20:03:15 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
1997-08-16 23:47:24 +00:00
|
|
|
+ (void)setNullEvent:(NSEvent *)e
|
|
|
|
{
|
1997-10-09 22:55:31 +00:00
|
|
|
ASSIGN(gnustep_gui_null_event, e);
|
1997-08-16 23:47:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+ (NSEvent *)getNullEvent;
|
|
|
|
{
|
|
|
|
return gnustep_gui_null_event;
|
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
// Get next event
|
1997-11-14 21:32:31 +00:00
|
|
|
- (void)getNextEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-10-09 22:55:31 +00:00
|
|
|
[event_queue addObject:gnustep_gui_null_event];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1997-03-27 17:47:03 +00:00
|
|
|
- (NSEvent *)peekNextEvent
|
|
|
|
{
|
1997-03-29 20:03:45 +00:00
|
|
|
return gnustep_gui_null_event;
|
1997-03-27 17:47:03 +00:00
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
// handle a non-translated event
|
|
|
|
- (void)handleNullEvent
|
|
|
|
{}
|
|
|
|
|
1997-10-09 22:55:31 +00:00
|
|
|
- (void)_flushCommunicationChannels
|
|
|
|
{}
|
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
- (void)setupRunLoopInputSourcesForMode:(NSString*)mode
|
|
|
|
{}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
@end
|
1998-01-09 22:28:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Some utilities */
|
|
|
|
NSString *NSOpenStepRootDirectory(void)
|
|
|
|
{
|
|
|
|
NSString* root = [[[NSProcessInfo processInfo] environment]
|
|
|
|
objectForKey:@"GNUSTEP_SYSTEM_ROOT"];
|
|
|
|
|
|
|
|
if (!root)
|
|
|
|
root = @"/";
|
|
|
|
|
|
|
|
return root;
|
|
|
|
}
|