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
|
1998-08-30 16:06:47 +00:00
|
|
|
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
|
|
|
Date: August 1998
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
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-11-24 15:25:22 +00:00
|
|
|
#include <Foundation/NSSet.h>
|
1998-01-09 22:28:14 +00:00
|
|
|
#include <Foundation/NSDictionary.h>
|
1998-12-03 06:54:56 +00:00
|
|
|
#include <Foundation/NSException.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>
|
1998-11-24 15:25:22 +00:00
|
|
|
#include <Foundation/NSUserDefaults.h>
|
1997-08-27 21:20:19 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
#ifndef LIB_FOUNDATION_LIBRARY
|
|
|
|
# include <Foundation/NSConnection.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <AppKit/GSContext.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
#include <AppKit/NSApplication.h>
|
|
|
|
#include <AppKit/NSPopUpButton.h>
|
1998-11-24 15:25:22 +00:00
|
|
|
#include <AppKit/NSPasteboard.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
#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>
|
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
#define CONVEY(a, b) [b retain]; \
|
|
|
|
[a release]; \
|
|
|
|
a = b;
|
|
|
|
|
1998-12-03 06:54:56 +00:00
|
|
|
#include <AppKit/GNUServicesManager.h>
|
1998-11-25 17:16:48 +00:00
|
|
|
|
|
|
|
//*****************************************************************************
|
|
|
|
//
|
|
|
|
// NSApplication
|
|
|
|
//
|
|
|
|
//*****************************************************************************
|
1998-11-24 15:25:22 +00:00
|
|
|
|
1998-12-03 06:54:56 +00:00
|
|
|
//
|
|
|
|
// Types
|
|
|
|
//
|
|
|
|
struct _NSModalSession {
|
|
|
|
int runState;
|
|
|
|
NSWindow *window;
|
|
|
|
NSModalSession parent;
|
|
|
|
};
|
|
|
|
|
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;
|
1998-11-24 15:25:22 +00:00
|
|
|
static NSEvent *null_event;
|
1997-08-16 23:47:24 +00:00
|
|
|
static id NSApp;
|
1998-12-03 06:54:56 +00:00
|
|
|
static NSString *NSAbortModalException = @"NSAbortModalException";
|
1997-08-16 23:47:24 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
@implementation NSApplication
|
|
|
|
|
|
|
|
//
|
|
|
|
// Class methods
|
|
|
|
//
|
|
|
|
+ (void)initialize
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
if (self == [NSApplication class])
|
|
|
|
{
|
|
|
|
NSDebugLog(@"Initialize NSApplication class\n");
|
|
|
|
// Initial version
|
|
|
|
[self setVersion:1];
|
|
|
|
// So the application knows
|
|
|
|
gnustep_gui_app_is_in_dealloc = NO; // its within dealloc and
|
|
|
|
} // can prevent -release
|
|
|
|
} // loops.
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
+ (NSApplication *)sharedApplication
|
1998-11-25 17:16:48 +00:00
|
|
|
{ // If the global application does
|
|
|
|
if (!NSApp) // not exist yet then create it
|
|
|
|
{
|
|
|
|
NSApp = [self alloc]; // Don't combine the following two
|
|
|
|
[NSApp init]; // statements into one to avoid
|
|
|
|
} // problems with some classes'
|
|
|
|
// initialization code that tries
|
|
|
|
return NSApp; // to get the shared application.
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Instance methods
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// Creating and initializing the NSApplication
|
|
|
|
//
|
|
|
|
- init
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
[super init];
|
1997-04-22 18:23:58 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
NSDebugLog(@"Begin of NSApplication -init\n");
|
1998-11-02 17:42:23 +00:00
|
|
|
|
1998-12-01 20:54:23 +00:00
|
|
|
listener = [GNUServicesManager newWithApplication: self];
|
1998-11-25 17:16:48 +00:00
|
|
|
window_list = [NSMutableArray new]; // allocate window list
|
|
|
|
window_count = 1;
|
1998-11-02 17:42:23 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
main_menu = nil;
|
|
|
|
windows_need_update = YES;
|
1998-11-02 17:42:23 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
event_queue = [NSMutableArray new]; // allocate event queue
|
|
|
|
current_event = [NSEvent new]; // no current event
|
|
|
|
null_event = [NSEvent new]; // create dummy event
|
1998-11-02 17:42:23 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
[self setNextResponder:NULL]; // We are the end of
|
|
|
|
// the responder chain
|
1998-11-02 17:42:23 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
// Set up the run loop
|
|
|
|
// object for the
|
|
|
|
// current thread
|
|
|
|
[self setupRunLoopInputSourcesForMode:NSDefaultRunLoopMode];
|
|
|
|
[self setupRunLoopInputSourcesForMode:NSConnectionReplyMode];
|
|
|
|
[self setupRunLoopInputSourcesForMode:NSModalPanelRunLoopMode];
|
|
|
|
[self setupRunLoopInputSourcesForMode:NSEventTrackingRunLoopMode];
|
1998-11-02 17:42:23 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
return self;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)finishLaunching
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
|
|
|
NSBundle* mainBundle = [NSBundle mainBundle];
|
|
|
|
NSString* resourcePath = [mainBundle resourcePath];
|
|
|
|
NSString* infoFilePath = [resourcePath
|
|
|
|
stringByAppendingPathComponent:@"Info-gnustep.plist"];
|
|
|
|
NSDictionary* infoDict;
|
|
|
|
NSString* mainModelFile;
|
|
|
|
|
|
|
|
infoDict = [[NSString stringWithContentsOfFile:infoFilePath] propertyList];
|
|
|
|
mainModelFile = [infoDict objectForKey:@"NSMainNibFile"];
|
|
|
|
|
|
|
|
if (mainModelFile && ![mainModelFile isEqual:@""])
|
|
|
|
{
|
|
|
|
if (![GMModel loadIMFile:mainModelFile
|
|
|
|
owner:[NSApplication sharedApplication]])
|
|
|
|
NSLog (@"Cannot load the main model file '%@", mainModelFile);
|
|
|
|
}
|
|
|
|
// post notification that
|
|
|
|
// launch will finish
|
|
|
|
[nc postNotificationName: NSApplicationWillFinishLaunchingNotification
|
|
|
|
object: self];
|
|
|
|
// Register our listener to
|
|
|
|
// handle incoming services
|
|
|
|
[listener registerAsServiceProvider]; // requests etc.
|
|
|
|
|
|
|
|
// finish the launching
|
|
|
|
// post notification that
|
|
|
|
// launching has finished
|
|
|
|
[nc postNotificationName: NSApplicationDidFinishLaunchingNotification
|
|
|
|
object: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dealloc
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
NSDebugLog(@"Freeing NSApplication\n");
|
|
|
|
// Let ourselves know we
|
|
|
|
gnustep_gui_app_is_in_dealloc = YES; // are within dealloc
|
|
|
|
|
|
|
|
[listener release];
|
|
|
|
[window_list release];
|
|
|
|
[event_queue release];
|
|
|
|
[current_event release];
|
|
|
|
[super dealloc];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Changing the active application
|
|
|
|
//
|
|
|
|
- (void)activateIgnoringOtherApps:(BOOL)flag
|
|
|
|
{
|
1998-11-24 15:25:22 +00:00
|
|
|
app_is_active = YES;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)deactivate
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
app_is_active = NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isActive
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
return app_is_active;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Running the event loop
|
|
|
|
//
|
1998-12-03 06:54:56 +00:00
|
|
|
- (void) abortModal
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-12-03 06:54:56 +00:00
|
|
|
if (session == 0)
|
|
|
|
[NSException raise: NSAbortModalException
|
|
|
|
format: @"abortModal when not in a modal session"];
|
|
|
|
|
|
|
|
[NSException raise: NSAbortModalException
|
|
|
|
format: @"abortModal"];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1998-12-03 06:54:56 +00:00
|
|
|
- (NSModalSession) beginModalSessionForWindow: (NSWindow*)theWindow
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-12-03 06:54:56 +00:00
|
|
|
NSModalSession theSession;
|
|
|
|
|
|
|
|
theSession = (NSModalSession)NSZoneMalloc(NSDefaultMallocZone(),
|
|
|
|
sizeof(struct _NSModalSession));
|
|
|
|
theSession->parent = 0;
|
|
|
|
theSession->runState = NSRunContinuesResponse;
|
|
|
|
theSession->window = theWindow;
|
|
|
|
return theSession;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1998-12-03 06:54:56 +00:00
|
|
|
- (void) endModalSession: (NSModalSession)theSession
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-12-03 06:54:56 +00:00
|
|
|
if (theSession == 0)
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
format: @"null pointer passed to endModalSession:"];
|
|
|
|
/*
|
|
|
|
* Remove this session from the linked list of sessions.
|
|
|
|
*/
|
|
|
|
if (session == theSession)
|
|
|
|
session = session->parent;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSModalSession tmp = session;
|
|
|
|
|
|
|
|
while (tmp != 0 && tmp->parent != theSession)
|
|
|
|
tmp = tmp->parent;
|
|
|
|
if (tmp)
|
|
|
|
tmp->parent = tmp->parent->parent;
|
|
|
|
}
|
|
|
|
NSZoneFree(NSDefaultMallocZone(), session);
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
- (BOOL)isRunning
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
return app_is_running;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
- (void)run
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
NSEvent *e;
|
|
|
|
NSAutoreleasePool* pool;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
NSDebugLog(@"NSApplication -run\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
[self finishLaunching];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
app_should_quit = NO;
|
|
|
|
app_is_running = YES;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
do {
|
|
|
|
pool = [NSAutoreleasePool new];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
e = [self nextEventMatchingMask:NSAnyEventMask
|
|
|
|
untilDate:[NSDate distantFuture]
|
|
|
|
inMode:NSDefaultRunLoopMode
|
|
|
|
dequeue:YES];
|
|
|
|
if (e)
|
|
|
|
[self sendEvent: e];
|
1998-08-30 16:06:47 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
if(windows_need_update) // send an update message
|
|
|
|
[self updateWindows]; // to all visible windows
|
|
|
|
|
1998-11-26 16:22:17 +00:00
|
|
|
[listener updateServicesMenu]; // update (en/disable) the
|
|
|
|
// services menu's items
|
1998-11-25 17:16:48 +00:00
|
|
|
[pool release];
|
|
|
|
}
|
|
|
|
while (!app_should_quit);
|
1998-08-30 16:06:47 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
NSDebugLog(@"NSApplication end of run loop\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1998-12-03 06:54:56 +00:00
|
|
|
- (int) runModalForWindow: (NSWindow*)theWindow
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-12-03 06:54:56 +00:00
|
|
|
NSModalSession theSession;
|
|
|
|
int code = NSRunContinuesResponse;
|
|
|
|
|
|
|
|
NS_DURING
|
|
|
|
{
|
|
|
|
theSession = [self beginModalSessionForWindow:theWindow];
|
|
|
|
while (code == NSRunContinuesResponse)
|
|
|
|
{
|
|
|
|
code = [self runModalSession: theSession];
|
|
|
|
}
|
|
|
|
[self endModalSession: theSession];
|
|
|
|
}
|
|
|
|
NS_HANDLER
|
|
|
|
{
|
|
|
|
if (theSession)
|
|
|
|
{
|
|
|
|
theSession->runState = NSRunAbortedResponse;
|
|
|
|
[self endModalSession: theSession];
|
|
|
|
}
|
|
|
|
if ([[localException name] isEqual: NSAbortModalException] == NO)
|
|
|
|
[localException raise];
|
|
|
|
code = NSRunAbortedResponse;
|
|
|
|
}
|
|
|
|
NS_ENDHANDLER
|
|
|
|
return code;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1998-12-03 06:54:56 +00:00
|
|
|
- (int) runModalSession: (NSModalSession)theSession
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-12-03 06:54:56 +00:00
|
|
|
BOOL found;
|
|
|
|
NSEvent *event;
|
|
|
|
unsigned count;
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
theSession->parent = session;
|
|
|
|
session = theSession;
|
|
|
|
session->runState = NSRunContinuesResponse;
|
|
|
|
[session->window display];
|
|
|
|
[session->window makeKeyAndOrderFront: self];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* First we make sure that there is an event.
|
|
|
|
*/
|
|
|
|
do
|
|
|
|
{
|
|
|
|
count = [event_queue count];
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
event = [event_queue objectAtIndex: i];
|
|
|
|
if ([event window] == session->window)
|
|
|
|
{
|
|
|
|
found = YES;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (found == NO)
|
|
|
|
{
|
|
|
|
NSDate *limitDate = [NSDate distantFuture];
|
|
|
|
|
|
|
|
[[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode
|
|
|
|
beforeDate: limitDate];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (found == NO && session->runState == NSRunContinuesResponse);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now we deal with all the events in the queue.
|
|
|
|
*/
|
|
|
|
while (found == YES && session->runState == NSRunContinuesResponse)
|
|
|
|
{
|
|
|
|
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
|
|
|
|
|
|
|
count = [event_queue count];
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
event = [event_queue objectAtIndex: i];
|
|
|
|
if ([event window] == session->window)
|
|
|
|
{
|
|
|
|
ASSIGN(current_event, event);
|
|
|
|
[event_queue removeObjectAtIndex: i];
|
|
|
|
found = YES;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (found == YES)
|
|
|
|
{
|
|
|
|
[self sendEvent: current_event];
|
|
|
|
|
|
|
|
if (windows_need_update)
|
|
|
|
[self updateWindows];
|
|
|
|
|
|
|
|
/* xxx should we update the services menu? */
|
|
|
|
[listener updateServicesMenu];
|
|
|
|
}
|
|
|
|
[pool release];
|
|
|
|
}
|
|
|
|
|
|
|
|
NSAssert(session == theSession, @"Session was ended while running");
|
|
|
|
session = session->parent;
|
|
|
|
return theSession->runState;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)sendEvent:(NSEvent *)theEvent
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
if (theEvent == null_event) // Don't send null event
|
|
|
|
{
|
|
|
|
NSDebugLog(@"Not sending the Null Event\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ([theEvent type]) // determine the event type
|
|
|
|
{
|
|
|
|
case NSPeriodic: // NSApplication traps the
|
|
|
|
break; // periodic events
|
|
|
|
|
|
|
|
case NSKeyDown:
|
|
|
|
{
|
|
|
|
NSDebugLog(@"send key down event\n");
|
|
|
|
[[theEvent window] sendEvent:theEvent];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NSKeyUp:
|
|
|
|
{
|
|
|
|
NSDebugLog(@"send key up event\n");
|
|
|
|
[[theEvent window] sendEvent:theEvent];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NSRightMouseDown: // Right mouse down
|
|
|
|
if(main_menu)
|
|
|
|
{
|
|
|
|
static NSMenu *copyOfMainMenu = nil;
|
|
|
|
NSWindow *copyMenuWindow;
|
|
|
|
|
|
|
|
if(!copyOfMainMenu) // display the menu
|
|
|
|
copyOfMainMenu = [main_menu copy]; // under the mouse
|
|
|
|
copyMenuWindow = [copyOfMainMenu menuWindow];
|
|
|
|
[copyOfMainMenu _rightMouseDisplay];
|
|
|
|
[copyMenuWindow captureMouse:self];
|
|
|
|
[[copyOfMainMenu menuCells] mouseDown:theEvent];
|
|
|
|
[copyMenuWindow releaseMouse:self];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: // pass all other events to
|
|
|
|
{ // the event's window
|
|
|
|
NSWindow* window = [theEvent window];
|
|
|
|
|
|
|
|
if (!theEvent)
|
|
|
|
NSDebugLog(@"NSEvent is nil!\n");
|
|
|
|
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
|
|
|
}
|
|
|
|
|
1998-12-03 06:54:56 +00:00
|
|
|
- (void) stop: (id)sender
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-12-03 06:54:56 +00:00
|
|
|
if (session)
|
|
|
|
[self stopModal];
|
|
|
|
else
|
|
|
|
app_is_running = NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1998-12-03 06:54:56 +00:00
|
|
|
- (void) stopModal
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-12-03 06:54:56 +00:00
|
|
|
[self stopModalWithCode: NSRunStoppedResponse];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1998-12-03 06:54:56 +00:00
|
|
|
- (void) stopModalWithCode: (int)returnCode
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-12-03 06:54:56 +00:00
|
|
|
if (session == 0)
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
format: @"stopModalWithCode: when not in a modal session"];
|
|
|
|
else if (returnCode == NSRunContinuesResponse)
|
|
|
|
[NSException raise: NSInvalidArgumentException
|
|
|
|
format: @"stopModalWithCode: with NSRunContinuesResponse"];
|
|
|
|
|
|
|
|
session->runState = returnCode;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Getting, removing, and posting events
|
|
|
|
//
|
|
|
|
|
|
|
|
- (NSEvent *)currentEvent;
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
return current_event;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)discardEventsMatchingMask:(unsigned int)mask
|
1998-11-25 17:16:48 +00:00
|
|
|
beforeEvent:(NSEvent *)lastEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-11-12 10:49:00 +00:00
|
|
|
int i = 0, count;
|
|
|
|
NSEvent* event = nil;
|
1998-11-25 17:16:48 +00:00
|
|
|
BOOL match = NO;
|
|
|
|
|
|
|
|
count = [event_queue count];
|
|
|
|
event = [event_queue objectAtIndex:i];
|
|
|
|
while((event != lastEvent) && (i < count))
|
|
|
|
{
|
|
|
|
if (mask == NSAnyEventMask) // any event is a match
|
|
|
|
match = YES;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (event == null_event)
|
|
|
|
match = YES; // dump all null events
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch([event type])
|
|
|
|
{
|
|
|
|
case NSLeftMouseDown:
|
|
|
|
if (mask & NSLeftMouseDownMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSLeftMouseUp:
|
|
|
|
if (mask & NSLeftMouseUpMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSRightMouseDown:
|
|
|
|
if (mask & NSRightMouseDownMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSRightMouseUp:
|
|
|
|
if (mask & NSRightMouseUpMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSMouseMoved:
|
|
|
|
if (mask & NSMouseMovedMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSMouseEntered:
|
|
|
|
if (mask & NSMouseEnteredMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSMouseExited:
|
|
|
|
if (mask & NSMouseExitedMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSLeftMouseDragged:
|
|
|
|
if (mask & NSLeftMouseDraggedMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSRightMouseDragged:
|
|
|
|
if (mask & NSRightMouseDraggedMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSKeyDown:
|
|
|
|
if (mask & NSKeyDownMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSKeyUp:
|
|
|
|
if (mask & NSKeyUpMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSFlagsChanged:
|
|
|
|
if (mask & NSFlagsChangedMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSPeriodic:
|
|
|
|
if (mask & NSPeriodicMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSCursorUpdate:
|
|
|
|
if (mask & NSCursorUpdateMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
match = NO;
|
|
|
|
break;
|
|
|
|
} } } // remove event from
|
|
|
|
// the queue if it
|
|
|
|
if (match) // matched the mask
|
|
|
|
[event_queue removeObjectAtIndex:i];
|
|
|
|
event = [event_queue objectAtIndex:++i]; // get the next event
|
|
|
|
}; // in the queue
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSEvent*)_eventMatchingMask:(unsigned int)mask dequeue:(BOOL)flag
|
|
|
|
{
|
|
|
|
NSEvent* event; // return the next
|
|
|
|
int i, count; // event in the queue
|
|
|
|
BOOL match = NO; // which matches mask
|
|
|
|
|
|
|
|
[self _nextEvent];
|
|
|
|
|
|
|
|
if ((count = [event_queue count])) // if queue contains
|
|
|
|
{ // events check them
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{ // Get next event from
|
|
|
|
event = [event_queue objectAtIndex:i]; // the events queue
|
|
|
|
|
|
|
|
if (mask == NSAnyEventMask) // the any event mask
|
|
|
|
match = YES; // matches all events
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (event == null_event) // do not send the null
|
|
|
|
{ // event
|
|
|
|
match = NO;
|
|
|
|
if(flag) // dequeue null event
|
|
|
|
{ // if flag is set
|
|
|
|
[event retain];
|
|
|
|
[event_queue removeObjectAtIndex:i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch([event type])
|
|
|
|
{
|
|
|
|
case NSLeftMouseDown:
|
|
|
|
if (mask & NSLeftMouseDownMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSLeftMouseUp:
|
|
|
|
if (mask & NSLeftMouseUpMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSRightMouseDown:
|
|
|
|
if (mask & NSRightMouseDownMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSRightMouseUp:
|
|
|
|
if (mask & NSRightMouseUpMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSMouseMoved:
|
|
|
|
if (mask & NSMouseMovedMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSMouseEntered:
|
|
|
|
if (mask & NSMouseEnteredMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSMouseExited:
|
|
|
|
if (mask & NSMouseExitedMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSLeftMouseDragged:
|
|
|
|
if (mask & NSLeftMouseDraggedMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSRightMouseDragged:
|
|
|
|
if (mask & NSRightMouseDraggedMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSKeyDown:
|
|
|
|
if (mask & NSKeyDownMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSKeyUp:
|
|
|
|
if (mask & NSKeyUpMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSFlagsChanged:
|
|
|
|
if (mask & NSFlagsChangedMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSPeriodic:
|
|
|
|
if (mask & NSPeriodicMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSCursorUpdate:
|
|
|
|
if (mask & NSCursorUpdateMask)
|
|
|
|
match = YES;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
match = NO;
|
|
|
|
break;
|
|
|
|
} } }
|
|
|
|
|
|
|
|
if (match)
|
|
|
|
{
|
|
|
|
if(flag) // dequeue the event if
|
|
|
|
{ // flag is set
|
|
|
|
[event retain];
|
|
|
|
[event_queue removeObjectAtIndex:i];
|
|
|
|
}
|
|
|
|
CONVEY(current_event, event);
|
|
|
|
|
|
|
|
return event; // return an event from
|
|
|
|
} // the queue which
|
|
|
|
} // matches the mask
|
|
|
|
}
|
|
|
|
// no event in the
|
|
|
|
return nil; // queue matches mask
|
1998-11-24 15:25:22 +00:00
|
|
|
}
|
|
|
|
|
1998-11-26 16:22:17 +00:00
|
|
|
- (NSEvent*) nextEventMatchingMask:(unsigned int)mask
|
|
|
|
untilDate:(NSDate *)expiration
|
|
|
|
inMode:(NSString *)mode
|
|
|
|
dequeue:(BOOL)flag
|
1998-11-24 15:25:22 +00:00
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
NSEvent *event;
|
|
|
|
BOOL done = NO;
|
|
|
|
|
|
|
|
if(mode == NSEventTrackingRunLoopMode) // temporary hack to
|
|
|
|
inTrackingLoop = YES; // regulate translation
|
|
|
|
else // of X motion events
|
|
|
|
inTrackingLoop = NO; // while not in a
|
|
|
|
// tracking loop
|
|
|
|
if ((event = [self _eventMatchingMask:mask dequeue:flag]))
|
|
|
|
done = YES;
|
|
|
|
else
|
|
|
|
if (!expiration)
|
|
|
|
expiration = [NSDate distantFuture];
|
|
|
|
|
|
|
|
while (!done) // Not in queue so wait
|
|
|
|
{ // for next event
|
|
|
|
NSDate *limitDate, *originalLimitDate;
|
|
|
|
NSRunLoop* currentLoop = [NSRunLoop currentRunLoop];
|
|
|
|
// Retain the limitDate so that it doesn't get released
|
|
|
|
// accidentally by runMode:beforeDate: if a timer which
|
|
|
|
// has this date as fire date gets released.
|
|
|
|
limitDate = [[currentLoop limitDateForMode:mode] retain];
|
|
|
|
originalLimitDate = limitDate;
|
|
|
|
|
|
|
|
if ((event = [self _eventMatchingMask:mask dequeue:flag]))
|
|
|
|
{
|
|
|
|
[limitDate release];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (limitDate)
|
|
|
|
limitDate = [expiration earlierDate:limitDate];
|
|
|
|
else
|
|
|
|
limitDate = expiration;
|
|
|
|
|
|
|
|
[currentLoop runMode:mode beforeDate:limitDate];
|
|
|
|
[originalLimitDate release];
|
|
|
|
|
|
|
|
if ((event = [self _eventMatchingMask:mask dequeue:flag]))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// no need to unhide cursor
|
|
|
|
if (!inTrackingLoop) // while in a tracking loop
|
|
|
|
{
|
|
|
|
if ([NSCursor isHiddenUntilMouseMoves]) // do so only if we should
|
|
|
|
{ // unhide when mouse moves
|
|
|
|
NSEventType type = [event type]; // and event is mouse event
|
|
|
|
if ((type == NSLeftMouseDown) || (type == NSLeftMouseUp)
|
|
|
|
|| (type == NSRightMouseDown) || (type == NSRightMouseUp)
|
|
|
|
|| (type == NSMouseMoved))
|
|
|
|
{
|
|
|
|
[NSCursor unhide];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return event;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)postEvent:(NSEvent *)event atStart:(BOOL)flag
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
if (!flag)
|
|
|
|
[event_queue addObject: event];
|
|
|
|
else
|
|
|
|
[event_queue insertObject: event atIndex: 0];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Sending action messages
|
|
|
|
//
|
1998-11-02 17:42:23 +00:00
|
|
|
- (BOOL)sendAction:(SEL)aSelector to:aTarget from:sender
|
1998-11-25 17:16:48 +00:00
|
|
|
{ // If target responds
|
|
|
|
if ([aTarget respondsToSelector:aSelector]) // to the selector then
|
|
|
|
{ // have it perform it
|
|
|
|
[aTarget performSelector:aSelector withObject:sender];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
return YES;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
return NO; // Otherwise traverse
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- targetForAction:(SEL)aSelector
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
return self;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1998-11-02 17:42:23 +00:00
|
|
|
- (BOOL)tryToPerform:(SEL)aSelector with:anObject
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
return NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setApplicationIconImage:(NSImage *)anImage
|
1998-11-25 17:16:48 +00:00
|
|
|
{ // Set the app's icon
|
|
|
|
if (app_icon != nil)
|
|
|
|
[app_icon release];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
app_icon = [anImage retain];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSImage *)applicationIconImage
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
return app_icon;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Hiding all windows
|
|
|
|
//
|
|
|
|
- (void)hide:sender
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
int i, count;
|
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
1997-08-16 23:47:24 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
// notify that we will hide
|
|
|
|
[nc postNotificationName: NSApplicationWillHideNotification
|
|
|
|
object: self];
|
|
|
|
// TODO: hide the menu
|
1997-08-16 23:47:24 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
// Tell the windows to hide
|
|
|
|
for (i = 0, count = [window_list count]; i < count; i++)
|
|
|
|
[[window_list objectAtIndex:i] performHide:sender];
|
1997-10-28 20:44:38 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
app_is_hidden = YES;
|
|
|
|
// notify that we did hide
|
|
|
|
[nc postNotificationName: NSApplicationDidHideNotification
|
|
|
|
object: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isHidden
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
return app_is_hidden;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)unhide:sender
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
int i, count;
|
|
|
|
// Tell windows to unhide
|
|
|
|
for (i = 0, count = [window_list count]; i < count; i++)
|
|
|
|
[[window_list objectAtIndex:i] performUnhide:sender];
|
1997-08-16 23:47:24 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
// TODO: unhide the menu
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
app_is_hidden = NO;
|
|
|
|
// Bring the key window to
|
|
|
|
[[self keyWindow] makeKeyAndOrderFront:self]; // the front
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)unhideWithoutActivation
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
|
|
|
// notify we will unhide
|
1997-10-28 20:44:38 +00:00
|
|
|
[nc postNotificationName: NSApplicationWillUnhideNotification
|
1998-11-25 17:16:48 +00:00
|
|
|
object: self];
|
1997-10-28 20:44:38 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
[self unhide: self];
|
1998-11-25 17:16:48 +00:00
|
|
|
// notify we did unhide
|
1997-10-28 20:44:38 +00:00
|
|
|
[nc postNotificationName: NSApplicationDidUnhideNotification
|
1998-11-25 17:16:48 +00:00
|
|
|
object: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Managing windows
|
|
|
|
//
|
|
|
|
- (NSWindow *)keyWindow
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
int i, j;
|
|
|
|
id w;
|
1998-11-02 17:42:23 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
j = [window_list count];
|
|
|
|
for (i = 0;i < j; ++i)
|
|
|
|
{
|
|
|
|
w = [window_list objectAtIndex:i];
|
|
|
|
if ([w isKeyWindow])
|
|
|
|
return w;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
return nil;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSWindow *)mainWindow
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
int i, j;
|
|
|
|
id w;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
j = [window_list count];
|
|
|
|
for (i = 0;i < j; ++i)
|
|
|
|
{
|
|
|
|
w = [window_list objectAtIndex:i];
|
|
|
|
if ([w isMainWindow])
|
|
|
|
return w;
|
|
|
|
}
|
1998-11-02 17:42:23 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
return nil;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1998-11-02 17:42:23 +00:00
|
|
|
- (NSWindow *)makeWindowsPerform:(SEL)aSelector inOrder:(BOOL)flag
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
return nil;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)miniaturizeAll:sender
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
int i, count;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1998-11-25 17:16:48 +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
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
windows_need_update = flag;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
- (void)updateWindows // send an update message
|
|
|
|
{ // to all visible windows
|
|
|
|
int i, count;
|
1998-08-30 16:06:47 +00:00
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
1998-11-25 17:16:48 +00:00
|
|
|
// notify that an update is
|
|
|
|
// imminent
|
|
|
|
[nc postNotificationName:NSApplicationWillUpdateNotification object:self];
|
1997-10-28 20:44:38 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
for (i = 0, count = [window_list count]; i < count; i++)
|
|
|
|
{
|
|
|
|
NSWindow *win = [window_list objectAtIndex:i];
|
|
|
|
if([win isVisible]) // send update only if the
|
|
|
|
[win update]; // window is visible
|
|
|
|
}
|
|
|
|
// notify update did occur
|
|
|
|
[nc postNotificationName:NSApplicationDidUpdateNotification object:self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *)windows
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
return window_list;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSWindow *)windowWithWindowNumber:(int)windowNum
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
int i, j;
|
|
|
|
NSWindow *w;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
j = [window_list count];
|
|
|
|
for (i = 0;i < j; ++i)
|
|
|
|
{
|
|
|
|
w = [window_list objectAtIndex:i];
|
|
|
|
if ([w windowNumber] == windowNum)
|
|
|
|
return w;
|
|
|
|
}
|
1998-11-02 17:42:23 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
return nil;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Showing Standard Panels
|
|
|
|
//
|
|
|
|
- (void)orderFrontColorPanel:sender
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)orderFrontDataLinkPanel:sender
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)orderFrontHelpPanel:sender
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)runPageLayout:sender
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Getting the main menu
|
|
|
|
//
|
|
|
|
- (NSMenu *)mainMenu
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
return main_menu;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setMainMenu:(NSMenu *)aMenu
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
int i, j;
|
|
|
|
NSMenuItem *mc;
|
|
|
|
NSArray *mi;
|
|
|
|
|
|
|
|
[aMenu retain]; // Release old menu and
|
|
|
|
if(main_menu) // retain new
|
|
|
|
[main_menu release];
|
|
|
|
main_menu = aMenu;
|
|
|
|
|
|
|
|
mi = [main_menu itemArray]; // find a menucell with
|
|
|
|
j = [mi count]; // the title Windows
|
|
|
|
windows_menu = nil; // this is the default
|
|
|
|
for (i = 0;i < j; ++i) // windows menu
|
|
|
|
{
|
|
|
|
mc = [mi objectAtIndex:i];
|
|
|
|
if ([[mc stringValue] compare:@"Windows"] == NSOrderedSame)
|
|
|
|
{
|
|
|
|
windows_menu = mc; // Found it!
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Managing the Windows menu
|
|
|
|
//
|
|
|
|
- (void)addWindowsItem:aWindow
|
1998-11-25 17:16:48 +00:00
|
|
|
title:(NSString *)aString
|
|
|
|
filename:(BOOL)isFilename
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-11-02 17:42:23 +00:00
|
|
|
int i;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
if (![aWindow isKindOfClass:[NSWindow class]]) // proceed only if subclass
|
|
|
|
return; // of window
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
i = [window_list count]; // Add to our window list,
|
|
|
|
[window_list addObject:aWindow]; // the array retains it
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
[aWindow setWindowNumber:window_count]; // set its window number
|
|
|
|
++window_count;
|
|
|
|
|
|
|
|
if (i == 0) // If this was the first
|
|
|
|
{ // window then make it the
|
|
|
|
[aWindow becomeMainWindow]; // main and key window
|
|
|
|
[aWindow becomeKeyWindow];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)arrangeInFront:sender
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1998-11-02 17:42:23 +00:00
|
|
|
- (void)changeWindowsItem:aWindow
|
1998-11-25 17:16:48 +00:00
|
|
|
title:(NSString *)aString
|
|
|
|
filename:(BOOL)isFilename
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)removeWindowsItem:aWindow
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
if (aWindow == key_window) // This should be different
|
|
|
|
key_window = nil;
|
|
|
|
if (aWindow == main_window)
|
|
|
|
main_window = nil;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1998-11-25 17:16:48 +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 window from the
|
|
|
|
[window_list removeObject: aWindow]; // window list
|
1996-06-06 13:55:06 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
return;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setWindowsMenu:aMenu
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
if (windows_menu)
|
|
|
|
[windows_menu setSubmenu:aMenu];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)updateWindowsItem:aWindow
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSMenu *)windowsMenu
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
if(windows_menu)
|
|
|
|
return [windows_menu submenu];
|
|
|
|
else
|
|
|
|
return nil;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Managing the Service menu
|
|
|
|
//
|
1998-11-24 15:25:22 +00:00
|
|
|
- (void) registerServicesMenuSendTypes: (NSArray *)sendTypes
|
|
|
|
returnTypes: (NSArray *)returnTypes
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
[listener registerSendTypes: sendTypes
|
1998-12-01 20:54:23 +00:00
|
|
|
returnTypes: returnTypes];
|
1998-11-24 15:25:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSMenu *) servicesMenu
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
return [listener servicesMenu];
|
1998-11-24 15:25:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (id) servicesProvider
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
return [listener servicesProvider];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1998-11-24 15:25:22 +00:00
|
|
|
- (void) setServicesMenu: (NSMenu *)aMenu
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
[listener setServicesMenu: aMenu];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1998-11-24 15:25:22 +00:00
|
|
|
- (void) setServicesProvider: (id)anObject
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
[listener setServicesProvider: anObject];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1998-11-24 15:25:22 +00:00
|
|
|
- (id) validRequestorForSendType: (NSString *)sendType
|
|
|
|
returnType: (NSString *)returnType
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
return nil;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
- (GSContext *)context // return the current draw
|
|
|
|
{ // context (drawing dest)
|
|
|
|
return [GSContext currentContext];
|
1996-06-06 13:55:06 +00:00
|
|
|
}
|
1998-11-25 17:16:48 +00:00
|
|
|
|
1998-11-24 15:25:22 +00:00
|
|
|
- (void) reportException: (NSException *)anException
|
1998-11-25 17:16:48 +00:00
|
|
|
{ // Reporting an exception
|
|
|
|
if (anException)
|
|
|
|
NSLog(@"reported exception - %@", anException);
|
1998-11-02 17:42:23 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Terminating the application
|
|
|
|
//
|
|
|
|
- (void)terminate:sender
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
if ([self applicationShouldTerminate:self])
|
|
|
|
{ // app should end run loop
|
|
|
|
app_should_quit = YES;
|
|
|
|
[event_queue addObject: null_event]; // add dummy event to queue
|
|
|
|
} // to assure loop cycles
|
|
|
|
} // at least one more time
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
- delegate // Assigning a delegate
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
return delegate;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setDelegate:anObject
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
|
1997-10-28 20:44:38 +00:00
|
|
|
|
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 \
|
1998-11-25 17:16:48 +00:00
|
|
|
selector:@selector(application##notif_name:) \
|
|
|
|
name:NSApplication##notif_name##Notification object:self]
|
1997-10-28 20:44:38 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
{
|
1998-11-02 17:42:23 +00:00
|
|
|
BOOL result = NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
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;
|
|
|
|
}
|
1998-11-24 15:25:22 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
- (BOOL)application:(NSApplication *)app openFile:(NSString *)filename
|
|
|
|
{
|
1998-11-02 17:42:23 +00:00
|
|
|
BOOL result = NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
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
|
|
|
|
{
|
1998-11-02 17:42:23 +00:00
|
|
|
BOOL result = NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
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
|
|
|
}
|
1998-11-24 15:25:22 +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
|
|
|
|
{
|
1998-11-02 17:42:23 +00:00
|
|
|
BOOL result = NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
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
|
|
|
|
{
|
1998-11-02 17:42:23 +00:00
|
|
|
BOOL result = YES;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
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
|
|
|
|
{
|
1998-11-25 17:16:48 +00:00
|
|
|
ASSIGN(null_event, e);
|
1997-08-16 23:47:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+ (NSEvent *)getNullEvent;
|
1998-11-25 17:16:48 +00:00
|
|
|
{ // return the class
|
|
|
|
return null_event; // dummy event
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
- (void)_nextEvent // get next event
|
|
|
|
{ // implemented in
|
|
|
|
} // backend
|
1997-10-09 22:55:31 +00:00
|
|
|
|
1997-04-22 18:23:58 +00:00
|
|
|
- (void)setupRunLoopInputSourcesForMode:(NSString*)mode
|
1998-11-25 17:16:48 +00:00
|
|
|
{ // implemented in
|
|
|
|
} // backend
|
1997-04-22 18:23:58 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
@end /* NSApplication */
|
1998-01-09 22:28:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Some utilities */
|
|
|
|
NSString *NSOpenStepRootDirectory(void)
|
|
|
|
{
|
1998-11-02 17:42:23 +00:00
|
|
|
NSString* root = [[[NSProcessInfo processInfo] environment]
|
1998-11-24 15:25:22 +00:00
|
|
|
objectForKey:@"GNUSTEP_SYSTEM_ROOT"];
|
1998-01-09 22:28:14 +00:00
|
|
|
|
1998-11-24 15:25:22 +00:00
|
|
|
if (!root)
|
|
|
|
root = @"/";
|
1998-01-09 22:28:14 +00:00
|
|
|
|
1998-11-24 15:25:22 +00:00
|
|
|
return root;
|
1998-01-09 22:28:14 +00:00
|
|
|
}
|