mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-03 20:50:43 +00:00
gui changes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3164 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
00bc3151f2
commit
65a0194e32
7 changed files with 556 additions and 660 deletions
|
@ -63,6 +63,7 @@ extern NSString *NSEventTrackingRunLoopMode;
|
||||||
// Attributes
|
// Attributes
|
||||||
NSMutableArray *window_list;
|
NSMutableArray *window_list;
|
||||||
NSMutableArray *event_queue;
|
NSMutableArray *event_queue;
|
||||||
|
NSMutableArray *recycled_event_queue;
|
||||||
NSEvent *current_event;
|
NSEvent *current_event;
|
||||||
id key_window;
|
id key_window;
|
||||||
id main_window;
|
id main_window;
|
||||||
|
@ -78,6 +79,8 @@ extern NSString *NSEventTrackingRunLoopMode;
|
||||||
BOOL windows_need_update;
|
BOOL windows_need_update;
|
||||||
NSImage *app_icon;
|
NSImage *app_icon;
|
||||||
|
|
||||||
|
BOOL inTrackingLoop;
|
||||||
|
|
||||||
// Reserved for back-end use
|
// Reserved for back-end use
|
||||||
void *be_app_reserved;
|
void *be_app_reserved;
|
||||||
}
|
}
|
||||||
|
@ -132,12 +135,6 @@ extern NSString *NSEventTrackingRunLoopMode;
|
||||||
dequeue:(BOOL)flag;
|
dequeue:(BOOL)flag;
|
||||||
- (void)postEvent:(NSEvent *)event atStart:(BOOL)flag;
|
- (void)postEvent:(NSEvent *)event atStart:(BOOL)flag;
|
||||||
|
|
||||||
// xxx Not part of OpenStep, should be removed someday
|
|
||||||
- (NSEvent *)peekEventMatchingMask:(unsigned int)mask
|
|
||||||
untilDate:(NSDate *)expiration
|
|
||||||
inMode:(NSString *)mode
|
|
||||||
dequeue:(BOOL)flag;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Sending action messages
|
// Sending action messages
|
||||||
//
|
//
|
||||||
|
@ -271,15 +268,10 @@ extern NSString *NSEventTrackingRunLoopMode;
|
||||||
+ (void)setNullEvent:(NSEvent *)e;
|
+ (void)setNullEvent:(NSEvent *)e;
|
||||||
+ (NSEvent *)getNullEvent;
|
+ (NSEvent *)getNullEvent;
|
||||||
|
|
||||||
// Get next event
|
|
||||||
- (void)getNextEvent;
|
|
||||||
- (NSEvent *)peekNextEvent;
|
|
||||||
|
|
||||||
// handle a non-translated event
|
|
||||||
- (void)handleNullEvent;
|
|
||||||
|
|
||||||
/* Private methods */
|
/* Private methods */
|
||||||
- (void)_flushCommunicationChannels;
|
|
||||||
|
// Get next event
|
||||||
|
- (void)_nextEvent;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -77,27 +77,22 @@ static id NSApp;
|
||||||
if (self == [NSApplication class])
|
if (self == [NSApplication class])
|
||||||
{
|
{
|
||||||
NSDebugLog(@"Initialize NSApplication class\n");
|
NSDebugLog(@"Initialize NSApplication class\n");
|
||||||
|
|
||||||
// Initial version
|
// Initial version
|
||||||
[self setVersion:1];
|
[self setVersion:1];
|
||||||
|
// So the application knows
|
||||||
// So the application knows its within dealloc
|
gnustep_gui_app_is_in_dealloc = NO; // its within dealloc and
|
||||||
// and can prevent -release loops.
|
} // can prevent -release
|
||||||
gnustep_gui_app_is_in_dealloc = NO;
|
} // loops.
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (NSApplication *)sharedApplication
|
+ (NSApplication *)sharedApplication
|
||||||
{
|
{ // If the global application does
|
||||||
// If the global application does not exist yet then create it
|
if (!NSApp) // not exist yet then create it
|
||||||
if (!NSApp) {
|
{
|
||||||
/* Don't combine the following two statements into one to avoid problems
|
NSApp = [self alloc]; // Don't combine the following two
|
||||||
with some classes initialization code that tries to get the shared
|
[NSApp init]; // statements into one to avoid
|
||||||
application. */
|
} // problems with some classes'
|
||||||
NSApp = [self alloc];
|
// initialization code that tries
|
||||||
[NSApp init];
|
return NSApp; // to get the shared application.
|
||||||
}
|
|
||||||
return NSApp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -113,28 +108,23 @@ static id NSApp;
|
||||||
|
|
||||||
NSDebugLog(@"Begin of NSApplication -init\n");
|
NSDebugLog(@"Begin of NSApplication -init\n");
|
||||||
|
|
||||||
// allocate the window list
|
window_list = [NSMutableArray new]; // allocate window list
|
||||||
window_list = [NSMutableArray new];
|
|
||||||
window_count = 1;
|
window_count = 1;
|
||||||
|
|
||||||
main_menu = nil;
|
main_menu = nil;
|
||||||
windows_need_update = YES;
|
windows_need_update = YES;
|
||||||
//
|
|
||||||
// Event handling setup
|
|
||||||
//
|
|
||||||
// allocate the event queue
|
|
||||||
event_queue = [NSMutableArray new];
|
|
||||||
// No current event
|
|
||||||
current_event = nil;
|
|
||||||
// The NULL event
|
|
||||||
gnustep_gui_null_event = [NSEvent new];
|
|
||||||
|
|
||||||
//
|
event_queue = [NSMutableArray new]; // allocate event queue
|
||||||
// We are the end of the responder chain
|
recycled_event_queue = [NSMutableArray new]; // alloc recycle queue
|
||||||
//
|
current_event = [NSEvent new]; // no current event
|
||||||
[self setNextResponder:NULL];
|
gnustep_gui_null_event = [NSEvent new]; // create a NULL event
|
||||||
|
|
||||||
/* Set up the run loop object for the current thread */
|
[self setNextResponder:NULL]; // We are the end of
|
||||||
|
// the responder chain
|
||||||
|
|
||||||
|
// Set up the run loop
|
||||||
|
// object for the
|
||||||
|
// current thread
|
||||||
[self setupRunLoopInputSourcesForMode:NSDefaultRunLoopMode];
|
[self setupRunLoopInputSourcesForMode:NSDefaultRunLoopMode];
|
||||||
[self setupRunLoopInputSourcesForMode:NSConnectionReplyMode];
|
[self setupRunLoopInputSourcesForMode:NSConnectionReplyMode];
|
||||||
[self setupRunLoopInputSourcesForMode:NSModalPanelRunLoopMode];
|
[self setupRunLoopInputSourcesForMode:NSModalPanelRunLoopMode];
|
||||||
|
@ -145,28 +135,30 @@ static id NSApp;
|
||||||
|
|
||||||
- (void)finishLaunching
|
- (void)finishLaunching
|
||||||
{
|
{
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
NSBundle* mainBundle = [NSBundle mainBundle];
|
NSBundle* mainBundle = [NSBundle mainBundle];
|
||||||
NSString* resourcePath = [mainBundle resourcePath];
|
NSString* resourcePath = [mainBundle resourcePath];
|
||||||
NSString* infoFilePath
|
NSString* infoFilePath = [resourcePath
|
||||||
= [resourcePath stringByAppendingPathComponent:@"Info-gnustep.plist"];
|
stringByAppendingPathComponent:@"Info-gnustep.plist"];
|
||||||
NSDictionary* infoDict = [[NSString stringWithContentsOfFile:infoFilePath]
|
NSDictionary* infoDict;
|
||||||
propertyList];
|
NSString* mainModelFile;
|
||||||
NSString* mainModelFile = [infoDict objectForKey:@"NSMainNibFile"];
|
|
||||||
|
|
||||||
if (mainModelFile && ![mainModelFile isEqual:@""]) {
|
infoDict = [[NSString stringWithContentsOfFile:infoFilePath] propertyList];
|
||||||
|
mainModelFile = [infoDict objectForKey:@"NSMainNibFile"];
|
||||||
|
|
||||||
|
if (mainModelFile && ![mainModelFile isEqual:@""])
|
||||||
|
{
|
||||||
if (![GMModel loadIMFile:mainModelFile
|
if (![GMModel loadIMFile:mainModelFile
|
||||||
owner:[NSApplication sharedApplication]])
|
owner:[NSApplication sharedApplication]])
|
||||||
NSLog (@"Cannot load the main model file '%@", mainModelFile);
|
NSLog (@"Cannot load the main model file '%@", mainModelFile);
|
||||||
}
|
}
|
||||||
|
// post notification that
|
||||||
// notify that we will finish the launching
|
// launch will finish
|
||||||
[nc postNotificationName: NSApplicationWillFinishLaunchingNotification
|
[nc postNotificationName: NSApplicationWillFinishLaunchingNotification
|
||||||
object: self];
|
object: self];
|
||||||
|
|
||||||
// finish the launching
|
// finish the launching
|
||||||
|
// post notification that
|
||||||
// notify that the launching has finished
|
// launching has finished
|
||||||
[nc postNotificationName: NSApplicationDidFinishLaunchingNotification
|
[nc postNotificationName: NSApplicationDidFinishLaunchingNotification
|
||||||
object: self];
|
object: self];
|
||||||
}
|
}
|
||||||
|
@ -174,12 +166,12 @@ static id NSApp;
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
NSDebugLog(@"Freeing NSApplication\n");
|
NSDebugLog(@"Freeing NSApplication\n");
|
||||||
|
// Let ourselves know we
|
||||||
// Let ourselves know we are within dealloc
|
gnustep_gui_app_is_in_dealloc = YES; // are within dealloc
|
||||||
gnustep_gui_app_is_in_dealloc = YES;
|
|
||||||
|
|
||||||
[window_list release];
|
[window_list release];
|
||||||
[event_queue release];
|
[event_queue release];
|
||||||
|
[recycled_event_queue release];
|
||||||
[current_event release];
|
[current_event release];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
@ -244,8 +236,6 @@ NSAutoreleasePool* pool;
|
||||||
dequeue:YES];
|
dequeue:YES];
|
||||||
if (e)
|
if (e)
|
||||||
[self sendEvent: e];
|
[self sendEvent: e];
|
||||||
else // if Null event call back
|
|
||||||
[self handleNullEvent]; // end method to handle it
|
|
||||||
|
|
||||||
if(windows_need_update) // send an update message
|
if(windows_need_update) // send an update message
|
||||||
[self updateWindows]; // to all visible windows
|
[self updateWindows]; // to all visible windows
|
||||||
|
@ -261,6 +251,7 @@ NSAutoreleasePool* pool;
|
||||||
{
|
{
|
||||||
[theWindow display];
|
[theWindow display];
|
||||||
[theWindow makeKeyAndOrderFront: self];
|
[theWindow makeKeyAndOrderFront: self];
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,22 +262,16 @@ NSAutoreleasePool* pool;
|
||||||
|
|
||||||
- (void)sendEvent:(NSEvent *)theEvent
|
- (void)sendEvent:(NSEvent *)theEvent
|
||||||
{
|
{
|
||||||
// Don't send the null event
|
if (theEvent == gnustep_gui_null_event) // Don't send null event
|
||||||
if (theEvent == gnustep_gui_null_event)
|
|
||||||
{
|
{
|
||||||
NSDebugLog(@"Not sending the Null Event\n");
|
NSDebugLog(@"Not sending the Null Event\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// What is the event type
|
switch ([theEvent type]) // determine the event type
|
||||||
switch ([theEvent type])
|
|
||||||
{
|
{
|
||||||
|
case NSPeriodic: // NSApplication traps the
|
||||||
//
|
break; // periodic events
|
||||||
// NSApplication traps the periodic events
|
|
||||||
//
|
|
||||||
case NSPeriodic:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSKeyDown:
|
case NSKeyDown:
|
||||||
{
|
{
|
||||||
|
@ -294,20 +279,20 @@ NSAutoreleasePool* pool;
|
||||||
[[theEvent window] sendEvent:theEvent];
|
[[theEvent window] sendEvent:theEvent];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case NSKeyUp:
|
case NSKeyUp:
|
||||||
{
|
{
|
||||||
NSDebugLog(@"send key up event\n");
|
NSDebugLog(@"send key up event\n");
|
||||||
[[theEvent window] sendEvent:theEvent];
|
[[theEvent window] sendEvent:theEvent];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// All others get passed to the window
|
default: // pass all other events to
|
||||||
//
|
{ // the event's window
|
||||||
default:
|
|
||||||
{
|
|
||||||
NSWindow* window = [theEvent window];
|
NSWindow* window = [theEvent window];
|
||||||
|
|
||||||
if (!theEvent) NSDebugLog(@"NSEvent is nil!\n");
|
if (!theEvent)
|
||||||
|
NSDebugLog(@"NSEvent is nil!\n");
|
||||||
NSDebugLog(@"NSEvent type: %d", [theEvent type]);
|
NSDebugLog(@"NSEvent type: %d", [theEvent type]);
|
||||||
NSDebugLog(@"send event to window");
|
NSDebugLog(@"send event to window");
|
||||||
NSDebugLog([window description]);
|
NSDebugLog([window description]);
|
||||||
|
@ -334,95 +319,6 @@ NSAutoreleasePool* pool;
|
||||||
//
|
//
|
||||||
// Getting, removing, and posting events
|
// Getting, removing, and posting events
|
||||||
//
|
//
|
||||||
- (BOOL)event:(NSEvent *)theEvent matchMask:(unsigned int)mask
|
|
||||||
{
|
|
||||||
if (mask == NSAnyEventMask) // If mask is for any event
|
|
||||||
return YES; // then return success
|
|
||||||
|
|
||||||
if (!theEvent)
|
|
||||||
return NO;
|
|
||||||
|
|
||||||
if (theEvent == gnustep_gui_null_event) // Don't check a null event
|
|
||||||
return NO;
|
|
||||||
|
|
||||||
switch([theEvent type])
|
|
||||||
{
|
|
||||||
case NSLeftMouseDown:
|
|
||||||
if (mask & NSLeftMouseDownMask)
|
|
||||||
return YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSLeftMouseUp:
|
|
||||||
if (mask & NSLeftMouseUpMask)
|
|
||||||
return YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSRightMouseDown:
|
|
||||||
if (mask & NSRightMouseDownMask)
|
|
||||||
return YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSRightMouseUp:
|
|
||||||
if (mask & NSRightMouseUpMask)
|
|
||||||
return YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSMouseMoved:
|
|
||||||
if (mask & NSMouseMovedMask)
|
|
||||||
return YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSMouseEntered:
|
|
||||||
if (mask & NSMouseEnteredMask)
|
|
||||||
return YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSMouseExited:
|
|
||||||
if (mask & NSMouseExitedMask)
|
|
||||||
return YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSLeftMouseDragged:
|
|
||||||
if (mask & NSLeftMouseDraggedMask)
|
|
||||||
return YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSRightMouseDragged:
|
|
||||||
if (mask & NSRightMouseDraggedMask)
|
|
||||||
return YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSKeyDown:
|
|
||||||
if (mask & NSKeyDownMask)
|
|
||||||
return YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSKeyUp:
|
|
||||||
if (mask & NSKeyUpMask)
|
|
||||||
return YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSFlagsChanged:
|
|
||||||
if (mask & NSFlagsChangedMask)
|
|
||||||
return YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSPeriodic:
|
|
||||||
if (mask & NSPeriodicMask)
|
|
||||||
return YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NSCursorUpdate:
|
|
||||||
if (mask & NSCursorUpdateMask)
|
|
||||||
return YES;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSEvent *)currentEvent;
|
- (NSEvent *)currentEvent;
|
||||||
{
|
{
|
||||||
|
@ -434,61 +330,152 @@ NSAutoreleasePool* pool;
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSEvent*)_eventMatchingMask:(unsigned int)mask
|
- (NSEvent*)_eventMatchingMask:(unsigned int)mask // return the next
|
||||||
{
|
{ // event in the queue
|
||||||
NSEvent* event;
|
NSEvent* event; // which matches mask
|
||||||
int i, count;
|
int i, count;
|
||||||
|
BOOL match = NO;
|
||||||
|
|
||||||
[self getNextEvent];
|
[self _nextEvent];
|
||||||
|
|
||||||
if ((count = [event_queue count])) // Get an event from
|
if ((count = [event_queue count])) // Get an event from
|
||||||
{ // the events queue
|
{ // the events queue
|
||||||
//fprintf(stderr,"NSAppliation _eventMatchingMask: count %d\n", count);
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
event = [event_queue objectAtIndex:i];
|
event = [event_queue objectAtIndex:i];
|
||||||
if ([self event:event matchMask:mask])
|
|
||||||
|
if (mask == NSAnyEventMask) // any event is a match
|
||||||
|
match = YES;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (event == gnustep_gui_null_event) // do nothing if null
|
||||||
|
match = NO; // event
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
[event retain];
|
[event retain];
|
||||||
[event_queue removeObjectAtIndex:i];
|
[event_queue removeObjectAtIndex:i];
|
||||||
ASSIGN(current_event, event);
|
ASSIGN(current_event, event);
|
||||||
|
|
||||||
return [event autorelease];
|
return [event autorelease]; // return an event from
|
||||||
}
|
} // the queue which
|
||||||
}
|
} // matches the mask
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil;
|
return nil; // no event in the
|
||||||
}
|
} // queue matches mask
|
||||||
|
|
||||||
- (NSEvent *)nextEventMatchingMask:(unsigned int)mask
|
- (NSEvent *)nextEventMatchingMask:(unsigned int)mask
|
||||||
untilDate:(NSDate *)expiration
|
untilDate:(NSDate *)expiration
|
||||||
inMode:(NSString *)mode
|
inMode:(NSString *)mode
|
||||||
dequeue:(BOOL)flag
|
dequeue:(BOOL)flag
|
||||||
{
|
{
|
||||||
NSRunLoop* currentLoop = [NSRunLoop currentRunLoop];
|
|
||||||
NSEventType type;
|
NSEventType type;
|
||||||
NSEvent *event;
|
NSEvent *event;
|
||||||
BOOL done = NO;
|
BOOL done = NO;
|
||||||
|
|
||||||
event = [self _eventMatchingMask:mask];
|
if(mode == NSEventTrackingRunLoopMode) // temporary hack to
|
||||||
if (event)
|
inTrackingLoop = YES; // regulate translation
|
||||||
|
else // of X motion events
|
||||||
|
inTrackingLoop = NO; // while not in a
|
||||||
|
// tracking loop
|
||||||
|
if (event = [self _eventMatchingMask:mask])
|
||||||
done = YES;
|
done = YES;
|
||||||
else if (!expiration)
|
else
|
||||||
|
if (!expiration)
|
||||||
expiration = [NSDate distantFuture];
|
expiration = [NSDate distantFuture];
|
||||||
|
|
||||||
while (!done) // Not in queue so wait
|
while (!done) // Not in queue so wait
|
||||||
{ // for next event
|
{ // for next event
|
||||||
NSDate *limitDate, *originalLimitDate;
|
NSDate *limitDate, *originalLimitDate;
|
||||||
// Retain the limitDate so it doesn't get
|
NSRunLoop* currentLoop = [NSRunLoop currentRunLoop];
|
||||||
// released accidentally by runMode:beforeDate:
|
// Retain the limitDate so that it doesn't get released
|
||||||
// if a timer which has this date as fire date
|
// accidentally by runMode:beforeDate: if a timer which
|
||||||
// gets released.
|
// has this date as fire date gets released.
|
||||||
limitDate = [[currentLoop limitDateForMode:mode] retain];
|
limitDate = [[currentLoop limitDateForMode:mode] retain];
|
||||||
originalLimitDate = limitDate;
|
originalLimitDate = limitDate;
|
||||||
|
|
||||||
event = [self _eventMatchingMask:mask];
|
if (event = [self _eventMatchingMask:mask])
|
||||||
if (event)
|
|
||||||
{
|
{
|
||||||
[limitDate release];
|
[limitDate release];
|
||||||
break;
|
break;
|
||||||
|
@ -502,12 +489,12 @@ BOOL done = NO;
|
||||||
[currentLoop runMode:mode beforeDate:limitDate];
|
[currentLoop runMode:mode beforeDate:limitDate];
|
||||||
[originalLimitDate release];
|
[originalLimitDate release];
|
||||||
|
|
||||||
event = [self _eventMatchingMask:mask];
|
if (event = [self _eventMatchingMask:mask])
|
||||||
if (event)
|
|
||||||
break;
|
break;
|
||||||
}
|
} // no need to unhide cursor
|
||||||
// Unhide the cursor if necessary
|
// while in a tracking loop
|
||||||
if (event != gnustep_gui_null_event) // and event is not a null event
|
if (event != gnustep_gui_null_event && // or if event is the null
|
||||||
|
(!inTrackingLoop)) // event
|
||||||
{
|
{
|
||||||
if ([NSCursor isHiddenUntilMouseMoves]) // do so only if we should
|
if ([NSCursor isHiddenUntilMouseMoves]) // do so only if we should
|
||||||
{ // unhide when mouse moves
|
{ // unhide when mouse moves
|
||||||
|
@ -515,45 +502,10 @@ BOOL done = NO;
|
||||||
if ((type == NSLeftMouseDown) || (type == NSLeftMouseUp)
|
if ((type == NSLeftMouseDown) || (type == NSLeftMouseUp)
|
||||||
|| (type == NSRightMouseDown) || (type == NSRightMouseUp)
|
|| (type == NSRightMouseDown) || (type == NSRightMouseUp)
|
||||||
|| (type == NSMouseMoved))
|
|| (type == NSMouseMoved))
|
||||||
|
{
|
||||||
[NSCursor unhide];
|
[NSCursor unhide];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return event;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSEvent *)peekEventMatchingMask:(unsigned int)mask
|
|
||||||
untilDate:(NSDate *)expiration
|
|
||||||
inMode:(NSString *)mode
|
|
||||||
dequeue:(BOOL)flag
|
|
||||||
{
|
|
||||||
NSEvent *event = nil;
|
|
||||||
|
|
||||||
event = [self _eventMatchingMask:mask];
|
|
||||||
|
|
||||||
if (!event)
|
|
||||||
{
|
|
||||||
// Not in queue so peek for event
|
|
||||||
event = [self peekNextEvent];
|
|
||||||
|
|
||||||
event = [self _eventMatchingMask:mask];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unhide the cursor if necessary
|
|
||||||
if (event && (event != gnustep_gui_null_event))
|
|
||||||
{
|
|
||||||
NSEventType type;
|
|
||||||
|
|
||||||
// Only if we should unhide when mouse moves
|
|
||||||
if ([NSCursor isHiddenUntilMouseMoves])
|
|
||||||
{
|
|
||||||
// Make sure the event is a mouse event before unhiding
|
|
||||||
type = [event type];
|
|
||||||
if ((type == NSLeftMouseDown) || (type == NSLeftMouseUp)
|
|
||||||
|| (type == NSRightMouseDown) || (type == NSRightMouseUp)
|
|
||||||
|| (type == NSMouseMoved))
|
|
||||||
[NSCursor unhide];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
|
@ -570,45 +522,32 @@ BOOL done = NO;
|
||||||
//
|
//
|
||||||
// Sending action messages
|
// Sending action messages
|
||||||
//
|
//
|
||||||
- (BOOL)sendAction:(SEL)aSelector
|
- (BOOL)sendAction:(SEL)aSelector to:aTarget from:sender
|
||||||
to:aTarget
|
{ // If target responds
|
||||||
from:sender
|
if ([aTarget respondsToSelector:aSelector]) // to the selector then
|
||||||
{
|
{ // have it perform it
|
||||||
//
|
|
||||||
// If the target responds to the selector
|
|
||||||
// then have it perform it
|
|
||||||
//
|
|
||||||
if ([aTarget respondsToSelector:aSelector])
|
|
||||||
{
|
|
||||||
[aTarget performSelector:aSelector withObject:sender];
|
[aTarget performSelector:aSelector withObject:sender];
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
return NO; // Otherwise traverse
|
||||||
// Otherwise traverse the responder chain
|
} // the responder chain
|
||||||
//
|
|
||||||
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
- targetForAction:(SEL)aSelector
|
- targetForAction:(SEL)aSelector
|
||||||
{
|
{
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)tryToPerform:(SEL)aSelector
|
- (BOOL)tryToPerform:(SEL)aSelector with:anObject
|
||||||
with:anObject
|
|
||||||
{
|
{
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setting the application's icon
|
|
||||||
- (void)setApplicationIconImage:(NSImage *)anImage
|
- (void)setApplicationIconImage:(NSImage *)anImage
|
||||||
{
|
{ // Set the app's icon
|
||||||
if (app_icon != nil)
|
if (app_icon != nil)
|
||||||
{
|
|
||||||
[app_icon release];
|
[app_icon release];
|
||||||
}
|
|
||||||
|
|
||||||
app_icon = [anImage retain];
|
app_icon = [anImage retain];
|
||||||
}
|
}
|
||||||
|
@ -623,13 +562,12 @@ BOOL done = NO;
|
||||||
//
|
//
|
||||||
- (void)hide:sender
|
- (void)hide:sender
|
||||||
{
|
{
|
||||||
int i, count;
|
int i, count;
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
// notify that we will hide
|
// notify that we will hide
|
||||||
[nc postNotificationName: NSApplicationWillHideNotification
|
[nc postNotificationName: NSApplicationWillHideNotification
|
||||||
object: self];
|
object: self];
|
||||||
|
|
||||||
// TODO: hide the menu
|
// TODO: hide the menu
|
||||||
|
|
||||||
// Tell the windows to hide
|
// Tell the windows to hide
|
||||||
|
@ -637,7 +575,6 @@ BOOL done = NO;
|
||||||
[[window_list objectAtIndex:i] performHide:sender];
|
[[window_list objectAtIndex:i] performHide:sender];
|
||||||
|
|
||||||
app_is_hidden = YES;
|
app_is_hidden = YES;
|
||||||
|
|
||||||
// notify that we did hide
|
// notify that we did hide
|
||||||
[nc postNotificationName: NSApplicationDidHideNotification
|
[nc postNotificationName: NSApplicationDidHideNotification
|
||||||
object: self];
|
object: self];
|
||||||
|
@ -650,31 +587,27 @@ BOOL done = NO;
|
||||||
|
|
||||||
- (void)unhide:sender
|
- (void)unhide:sender
|
||||||
{
|
{
|
||||||
int i, count;
|
int i, count;
|
||||||
|
// Tell windows to unhide
|
||||||
// Tell the windows to unhide
|
|
||||||
for (i = 0, count = [window_list count]; i < count; i++)
|
for (i = 0, count = [window_list count]; i < count; i++)
|
||||||
[[window_list objectAtIndex:i] performUnhide:sender];
|
[[window_list objectAtIndex:i] performUnhide:sender];
|
||||||
|
|
||||||
// TODO: unhide the menu
|
// TODO: unhide the menu
|
||||||
|
|
||||||
app_is_hidden = NO;
|
app_is_hidden = NO;
|
||||||
|
// Bring the key window to
|
||||||
// Bring the key window to the front
|
[[self keyWindow] makeKeyAndOrderFront:self]; // the front
|
||||||
[[self keyWindow] makeKeyAndOrderFront:self];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)unhideWithoutActivation
|
- (void)unhideWithoutActivation
|
||||||
{
|
{
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
// notify we will unhide
|
||||||
// notify that we will unhide
|
|
||||||
[nc postNotificationName: NSApplicationWillUnhideNotification
|
[nc postNotificationName: NSApplicationWillUnhideNotification
|
||||||
object: self];
|
object: self];
|
||||||
|
|
||||||
[self unhide: self];
|
[self unhide: self];
|
||||||
|
// notify we did unhide
|
||||||
// notify that we did unhide
|
|
||||||
[nc postNotificationName: NSApplicationDidUnhideNotification
|
[nc postNotificationName: NSApplicationDidUnhideNotification
|
||||||
object: self];
|
object: self];
|
||||||
}
|
}
|
||||||
|
@ -684,41 +617,44 @@ BOOL done = NO;
|
||||||
//
|
//
|
||||||
- (NSWindow *)keyWindow
|
- (NSWindow *)keyWindow
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
id w;
|
id w;
|
||||||
|
|
||||||
j = [window_list count];
|
j = [window_list count];
|
||||||
for (i = 0;i < j; ++i)
|
for (i = 0;i < j; ++i)
|
||||||
{
|
{
|
||||||
w = [window_list objectAtIndex:i];
|
w = [window_list objectAtIndex:i];
|
||||||
if ([w isKeyWindow]) return w;
|
if ([w isKeyWindow])
|
||||||
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSWindow *)mainWindow
|
- (NSWindow *)mainWindow
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
id w;
|
id w;
|
||||||
|
|
||||||
j = [window_list count];
|
j = [window_list count];
|
||||||
for (i = 0;i < j; ++i)
|
for (i = 0;i < j; ++i)
|
||||||
{
|
{
|
||||||
w = [window_list objectAtIndex:i];
|
w = [window_list objectAtIndex:i];
|
||||||
if ([w isMainWindow]) return w;
|
if ([w isMainWindow])
|
||||||
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSWindow *)makeWindowsPerform:(SEL)aSelector
|
- (NSWindow *)makeWindowsPerform:(SEL)aSelector inOrder:(BOOL)flag
|
||||||
inOrder:(BOOL)flag
|
|
||||||
{
|
{
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)miniaturizeAll:sender
|
- (void)miniaturizeAll:sender
|
||||||
{
|
{
|
||||||
int i, count;
|
int i, count;
|
||||||
|
|
||||||
for (i = 0, count = [window_list count]; i < count; i++)
|
for (i = 0, count = [window_list count]; i < count; i++)
|
||||||
[[window_list objectAtIndex:i] miniaturize:sender];
|
[[window_list objectAtIndex:i] miniaturize:sender];
|
||||||
|
@ -733,21 +669,21 @@ BOOL done = NO;
|
||||||
windows_need_update = flag;
|
windows_need_update = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateWindows // send an update message to
|
- (void)updateWindows // send an update message
|
||||||
{ // all visible windows
|
{ // to all visible windows
|
||||||
int i, count;
|
int i, count;
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
// notify that an update is
|
||||||
// notify that we will update
|
// imminent
|
||||||
[nc postNotificationName:NSApplicationWillUpdateNotification object:self];
|
[nc postNotificationName:NSApplicationWillUpdateNotification object:self];
|
||||||
|
|
||||||
for (i = 0, count = [window_list count]; i < count; i++)
|
for (i = 0, count = [window_list count]; i < count; i++)
|
||||||
{
|
{
|
||||||
NSWindow *win = [window_list objectAtIndex:i];
|
NSWindow *win = [window_list objectAtIndex:i];
|
||||||
if([win isVisible]) // send update only if
|
if([win isVisible]) // send update only if the
|
||||||
[win update]; // window is visible
|
[win update]; // window is visible
|
||||||
}
|
}
|
||||||
// notify that we did update
|
// notify update did occur
|
||||||
[nc postNotificationName:NSApplicationDidUpdateNotification object:self];
|
[nc postNotificationName:NSApplicationDidUpdateNotification object:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -758,15 +694,17 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
- (NSWindow *)windowWithWindowNumber:(int)windowNum
|
- (NSWindow *)windowWithWindowNumber:(int)windowNum
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
NSWindow *w;
|
NSWindow *w;
|
||||||
|
|
||||||
j = [window_list count];
|
j = [window_list count];
|
||||||
for (i = 0;i < j; ++i)
|
for (i = 0;i < j; ++i)
|
||||||
{
|
{
|
||||||
w = [window_list objectAtIndex:i];
|
w = [window_list objectAtIndex:i];
|
||||||
if ([w windowNumber] == windowNum) return w;
|
if ([w windowNumber] == windowNum)
|
||||||
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -799,28 +737,24 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
- (void)setMainMenu:(NSMenu *)aMenu
|
- (void)setMainMenu:(NSMenu *)aMenu
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
NSMenuItem *mc;
|
NSMenuItem *mc;
|
||||||
NSArray *mi;
|
NSArray *mi;
|
||||||
|
|
||||||
// Release old and retain new
|
[aMenu retain]; // Release old menu and
|
||||||
[aMenu retain];
|
if(main_menu) // retain new
|
||||||
if(main_menu)
|
|
||||||
[main_menu release];
|
[main_menu release];
|
||||||
main_menu = aMenu;
|
main_menu = aMenu;
|
||||||
|
|
||||||
// Search for a menucell with the name Windows
|
mi = [main_menu itemArray]; // find a menucell with
|
||||||
// This is the default windows menu
|
j = [mi count]; // the title Windows
|
||||||
mi = [main_menu itemArray];
|
windows_menu = nil; // this is the default
|
||||||
j = [mi count];
|
for (i = 0;i < j; ++i) // windows menu
|
||||||
windows_menu = nil;
|
|
||||||
for (i = 0;i < j; ++i)
|
|
||||||
{
|
{
|
||||||
mc = [mi objectAtIndex:i];
|
mc = [mi objectAtIndex:i];
|
||||||
if ([[mc stringValue] compare:@"Windows"] == NSOrderedSame)
|
if ([[mc stringValue] compare:@"Windows"] == NSOrderedSame)
|
||||||
{
|
{
|
||||||
// Found it!
|
windows_menu = mc; // Found it!
|
||||||
windows_menu = mc;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -833,25 +767,20 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
title:(NSString *)aString
|
title:(NSString *)aString
|
||||||
filename:(BOOL)isFilename
|
filename:(BOOL)isFilename
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// Not a subclass of window --forget it
|
if (![aWindow isKindOfClass:[NSWindow class]]) // proceed only if subclass
|
||||||
if (![aWindow isKindOfClass:[NSWindow class]])
|
return; // of window
|
||||||
return;
|
|
||||||
|
|
||||||
// Add to our window list, the array retains it
|
i = [window_list count]; // Add to our window list,
|
||||||
i = [window_list count];
|
[window_list addObject:aWindow]; // the array retains it
|
||||||
[window_list addObject:aWindow];
|
|
||||||
|
|
||||||
// set its window number
|
[aWindow setWindowNumber:window_count]; // set its window number
|
||||||
[aWindow setWindowNumber:window_count];
|
|
||||||
++window_count;
|
++window_count;
|
||||||
|
|
||||||
// If this was the first window then
|
if (i == 0) // If this was the first
|
||||||
// make it the main and key window
|
{ // window then make it the
|
||||||
if (i == 0)
|
[aWindow becomeMainWindow]; // main and key window
|
||||||
{
|
|
||||||
[aWindow becomeMainWindow];
|
|
||||||
[aWindow becomeKeyWindow];
|
[aWindow becomeKeyWindow];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -868,8 +797,7 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
- (void)removeWindowsItem:aWindow
|
- (void)removeWindowsItem:aWindow
|
||||||
{
|
{
|
||||||
// +++ This should be different
|
if (aWindow == key_window) // This should be different
|
||||||
if (aWindow == key_window)
|
|
||||||
key_window = nil;
|
key_window = nil;
|
||||||
if (aWindow == main_window)
|
if (aWindow == main_window)
|
||||||
main_window = nil;
|
main_window = nil;
|
||||||
|
@ -879,9 +807,8 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
// and subsequently NSWindow is caling us to remove itself.
|
// and subsequently NSWindow is caling us to remove itself.
|
||||||
if (gnustep_gui_app_is_in_dealloc)
|
if (gnustep_gui_app_is_in_dealloc)
|
||||||
return;
|
return;
|
||||||
|
// Remove window from the
|
||||||
// Remove it from the window list
|
[window_list removeObject: aWindow]; // window list
|
||||||
[window_list removeObject: aWindow];
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -925,15 +852,14 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getting the display postscript context
|
- (NSDPSContext *)context // return the DPS context
|
||||||
- (NSDPSContext *)context
|
|
||||||
{
|
{
|
||||||
return [NSDPSContext currentContext];
|
return [NSDPSContext currentContext];
|
||||||
}
|
}
|
||||||
|
// Reporting an exception
|
||||||
// Reporting an exception
|
|
||||||
- (void)reportException:(NSException *)anException
|
- (void)reportException:(NSException *)anException
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Terminating the application
|
// Terminating the application
|
||||||
|
@ -944,15 +870,14 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
app_should_quit = YES;
|
app_should_quit = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assigning a delegate
|
- delegate // Assigning a delegate
|
||||||
- delegate
|
|
||||||
{
|
{
|
||||||
return delegate;
|
return delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setDelegate:anObject
|
- (void)setDelegate:anObject
|
||||||
{
|
{
|
||||||
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter* nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
delegate = anObject;
|
delegate = anObject;
|
||||||
|
|
||||||
|
@ -981,7 +906,7 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
//
|
//
|
||||||
- (BOOL)application:sender openFileWithoutUI:(NSString *)filename
|
- (BOOL)application:sender openFileWithoutUI:(NSString *)filename
|
||||||
{
|
{
|
||||||
BOOL result = NO;
|
BOOL result = NO;
|
||||||
|
|
||||||
if ([delegate respondsToSelector:@selector(application:openFileWithoutUI:)])
|
if ([delegate respondsToSelector:@selector(application:openFileWithoutUI:)])
|
||||||
result = [delegate application:sender openFileWithoutUI:filename];
|
result = [delegate application:sender openFileWithoutUI:filename];
|
||||||
|
@ -991,7 +916,7 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
- (BOOL)application:(NSApplication *)app openFile:(NSString *)filename
|
- (BOOL)application:(NSApplication *)app openFile:(NSString *)filename
|
||||||
{
|
{
|
||||||
BOOL result = NO;
|
BOOL result = NO;
|
||||||
|
|
||||||
if ([delegate respondsToSelector:@selector(application:openFile:)])
|
if ([delegate respondsToSelector:@selector(application:openFile:)])
|
||||||
result = [delegate application:app openFile:filename];
|
result = [delegate application:app openFile:filename];
|
||||||
|
@ -1001,7 +926,7 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
- (BOOL)application:(NSApplication *)app openTempFile:(NSString *)filename
|
- (BOOL)application:(NSApplication *)app openTempFile:(NSString *)filename
|
||||||
{
|
{
|
||||||
BOOL result = NO;
|
BOOL result = NO;
|
||||||
|
|
||||||
if ([delegate respondsToSelector:@selector(application:openTempFile:)])
|
if ([delegate respondsToSelector:@selector(application:openTempFile:)])
|
||||||
result = [delegate application:app openTempFile:filename];
|
result = [delegate application:app openTempFile:filename];
|
||||||
|
@ -1047,7 +972,7 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
- (BOOL)applicationOpenUntitledFile:(NSApplication *)app
|
- (BOOL)applicationOpenUntitledFile:(NSApplication *)app
|
||||||
{
|
{
|
||||||
BOOL result = NO;
|
BOOL result = NO;
|
||||||
|
|
||||||
if ([delegate respondsToSelector:@selector(applicationOpenUntitledFile:)])
|
if ([delegate respondsToSelector:@selector(applicationOpenUntitledFile:)])
|
||||||
result = [delegate applicationOpenUntitledFile:app];
|
result = [delegate applicationOpenUntitledFile:app];
|
||||||
|
@ -1057,7 +982,7 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
- (BOOL)applicationShouldTerminate:sender
|
- (BOOL)applicationShouldTerminate:sender
|
||||||
{
|
{
|
||||||
BOOL result = YES;
|
BOOL result = YES;
|
||||||
|
|
||||||
if ([delegate respondsToSelector:@selector(applicationShouldTerminate:)])
|
if ([delegate respondsToSelector:@selector(applicationShouldTerminate:)])
|
||||||
result = [delegate applicationShouldTerminate:sender];
|
result = [delegate applicationShouldTerminate:sender];
|
||||||
|
@ -1135,30 +1060,17 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSEvent *)getNullEvent;
|
+ (NSEvent *)getNullEvent;
|
||||||
{
|
{ // return the class
|
||||||
return gnustep_gui_null_event;
|
return gnustep_gui_null_event; // dummy event
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get next event
|
- (void)_nextEvent // get next event
|
||||||
- (void)getNextEvent
|
{ // implemented in
|
||||||
{
|
} // backend
|
||||||
[event_queue addObject:gnustep_gui_null_event];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSEvent *)peekNextEvent
|
|
||||||
{
|
|
||||||
return gnustep_gui_null_event;
|
|
||||||
}
|
|
||||||
|
|
||||||
// handle a non-translated event
|
|
||||||
- (void)handleNullEvent
|
|
||||||
{}
|
|
||||||
|
|
||||||
- (void)_flushCommunicationChannels
|
|
||||||
{}
|
|
||||||
|
|
||||||
- (void)setupRunLoopInputSourcesForMode:(NSString*)mode
|
- (void)setupRunLoopInputSourcesForMode:(NSString*)mode
|
||||||
{}
|
{ // implemented in
|
||||||
|
} // backend
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -1166,7 +1078,7 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
/* Some utilities */
|
/* Some utilities */
|
||||||
NSString *NSOpenStepRootDirectory(void)
|
NSString *NSOpenStepRootDirectory(void)
|
||||||
{
|
{
|
||||||
NSString* root = [[[NSProcessInfo processInfo] environment]
|
NSString* root = [[[NSProcessInfo processInfo] environment]
|
||||||
objectForKey:@"GNUSTEP_SYSTEM_ROOT"];
|
objectForKey:@"GNUSTEP_SYSTEM_ROOT"];
|
||||||
|
|
||||||
if (!root)
|
if (!root)
|
||||||
|
|
|
@ -45,12 +45,12 @@ float tabSize;
|
||||||
while(*str != '\0') // calc the additional size
|
while(*str != '\0') // calc the additional size
|
||||||
{ // to be added for tabs.
|
{ // to be added for tabs.
|
||||||
if(*str++ == '\t')
|
if(*str++ == '\t')
|
||||||
{
|
{ // j is initialized to the
|
||||||
i += j; // j is the max number of spaces
|
i += j; // max number of spaces
|
||||||
j = TABWIDTH; // needed per tab. this number
|
j = TABWIDTH; // needed per tab. it then
|
||||||
} // varies in order to align tabs
|
} // varies in order to align
|
||||||
else // at even multiples of TABWIDTH+1.
|
else // tabs to even multiples
|
||||||
j = j-- > 0 ? j : TABWIDTH;
|
j = j-- > 0 ? j : TABWIDTH; // of TABWIDTH + 1.
|
||||||
};
|
};
|
||||||
// if font is not
|
// if font is not
|
||||||
if(!(font = [attrs objectForKey:NSFontAttributeName])) // specified, use
|
if(!(font = [attrs objectForKey:NSFontAttributeName])) // specified, use
|
||||||
|
|
|
@ -56,9 +56,7 @@ static NSString *timerKey = @"NSEventTimersKey";
|
||||||
if (self == [NSEvent class])
|
if (self == [NSEvent class])
|
||||||
{
|
{
|
||||||
NSDebugLog(@"Initialize NSEvent class\n");
|
NSDebugLog(@"Initialize NSEvent class\n");
|
||||||
|
[self setVersion:1]; // Initial version
|
||||||
// Initial version
|
|
||||||
[self setVersion:1];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,8 +189,8 @@ NSEvent *e = [[[NSEvent alloc] init] autorelease];
|
||||||
+ (void)startPeriodicEventsAfterDelay:(NSTimeInterval)delaySeconds
|
+ (void)startPeriodicEventsAfterDelay:(NSTimeInterval)delaySeconds
|
||||||
withPeriod:(NSTimeInterval)periodSeconds
|
withPeriod:(NSTimeInterval)periodSeconds
|
||||||
{
|
{
|
||||||
NSTimer* timer;
|
NSTimer* timer;
|
||||||
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
||||||
|
|
||||||
NSDebugLog (@"startPeriodicEventsAfterDelay:withPeriod:");
|
NSDebugLog (@"startPeriodicEventsAfterDelay:withPeriod:");
|
||||||
// Check this thread
|
// Check this thread
|
||||||
|
@ -239,11 +237,10 @@ NSEvent* periodicEvent = [self otherEventWithType:NSPeriodic
|
||||||
[theApp postEvent:periodicEvent atStart:NO]; // place a periodic
|
[theApp postEvent:periodicEvent atStart:NO]; // place a periodic
|
||||||
} // event in the queue
|
} // event in the queue
|
||||||
|
|
||||||
+ (void)_registerRealTimer:(NSTimer*)timer
|
+ (void)_registerRealTimer:(NSTimer*)timer // this method provides a
|
||||||
{ // this method provides a
|
{ // means of delaying the
|
||||||
NSTimer* realTimer; // means of delaying the
|
NSTimer* realTimer; // start of periodic events
|
||||||
// start of periodic events
|
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
||||||
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
|
||||||
|
|
||||||
NSDebugLog (@"_registerRealTimer:");
|
NSDebugLog (@"_registerRealTimer:");
|
||||||
|
|
||||||
|
@ -253,7 +250,6 @@ NSEvent* periodicEvent = [self otherEventWithType:NSPeriodic
|
||||||
userInfo:nil
|
userInfo:nil
|
||||||
repeats:YES]; // Add the real timer to the timers
|
repeats:YES]; // Add the real timer to the timers
|
||||||
// dictionary and to the run loop
|
// dictionary and to the run loop
|
||||||
/* xxx what if there is already a timer - are we sure there isn't? */
|
|
||||||
[dict setObject: realTimer forKey: timerKey];
|
[dict setObject: realTimer forKey: timerKey];
|
||||||
[[NSRunLoop currentRunLoop] addTimer: realTimer
|
[[NSRunLoop currentRunLoop] addTimer: realTimer
|
||||||
forMode: NSEventTrackingRunLoopMode];
|
forMode: NSEventTrackingRunLoopMode];
|
||||||
|
@ -261,13 +257,12 @@ NSEvent* periodicEvent = [self otherEventWithType:NSPeriodic
|
||||||
|
|
||||||
+ (void)stopPeriodicEvents
|
+ (void)stopPeriodicEvents
|
||||||
{
|
{
|
||||||
NSTimer* timer;
|
NSTimer* timer;
|
||||||
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
||||||
|
|
||||||
NSDebugLog (@"stopPeriodicEvents");
|
NSDebugLog (@"stopPeriodicEvents");
|
||||||
|
// Remove any existing
|
||||||
/* Remove any existing timer for this thread */
|
timer = [dict objectForKey: timerKey]; // timer for this thread
|
||||||
timer = [dict objectForKey: timerKey];
|
|
||||||
[timer invalidate];
|
[timer invalidate];
|
||||||
[dict removeObjectForKey: timerKey];
|
[dict removeObjectForKey: timerKey];
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,7 +223,6 @@ NSPoint point;
|
||||||
_knobMoved = YES;
|
_knobMoved = YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!_knobMoved) // button scrolling
|
if (!_knobMoved) // button scrolling
|
||||||
{
|
{
|
||||||
if (scroller == _horizScroller)
|
if (scroller == _horizScroller)
|
||||||
|
@ -233,17 +232,12 @@ NSPoint point;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (scroller == _vertScroller) // For the vertical
|
if (scroller == _vertScroller)
|
||||||
{ // scroller the amount
|
{
|
||||||
point.x = clipViewBounds.origin.x; // should be reversed
|
point.x = clipViewBounds.origin.x;
|
||||||
amount = -amount;
|
// If view is flipped
|
||||||
|
if ([_contentView isFlipped]) // reverse the scroll
|
||||||
// If the view is flipped we also have to
|
amount = -amount; // direction
|
||||||
// reverse the meanings of increasing or
|
|
||||||
// decreasing of the y coordinate
|
|
||||||
// if (![_contentView isFlipped])
|
|
||||||
// amount = -amount;
|
|
||||||
|
|
||||||
NSDebugLog (@"increment/decrement: amount = %f, flipped = %d",
|
NSDebugLog (@"increment/decrement: amount = %f, flipped = %d",
|
||||||
amount, [_contentView isFlipped]);
|
amount, [_contentView isFlipped]);
|
||||||
point.y = clipViewBounds.origin.y + amount;
|
point.y = clipViewBounds.origin.y + amount;
|
||||||
|
@ -253,8 +247,8 @@ NSPoint point;
|
||||||
return; // do nothing
|
return; // do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else // knob scolling
|
||||||
{ // knob scolling
|
{
|
||||||
if (scroller == _horizScroller)
|
if (scroller == _horizScroller)
|
||||||
{
|
{
|
||||||
point.x = floatValue * (documentRect.size.width
|
point.x = floatValue * (documentRect.size.width
|
||||||
|
|
|
@ -444,13 +444,13 @@ static NSButtonCell* knobCell = nil;
|
||||||
|
|
||||||
- (void)trackScrollButtons:(NSEvent*)theEvent
|
- (void)trackScrollButtons:(NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
NSApplication *theApp = [NSApplication sharedApplication];
|
NSApplication *theApp = [NSApplication sharedApplication];
|
||||||
unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask |
|
unsigned int eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask |
|
||||||
NSLeftMouseDraggedMask | NSMouseMovedMask;
|
NSLeftMouseDraggedMask | NSMouseMovedMask;
|
||||||
NSPoint location;
|
NSPoint location;
|
||||||
BOOL shouldReturn = NO;
|
BOOL shouldReturn = NO;
|
||||||
id theCell = nil;
|
id theCell = nil;
|
||||||
NSRect rect;
|
NSRect rect;
|
||||||
|
|
||||||
NSDebugLog (@"trackScrollButtons");
|
NSDebugLog (@"trackScrollButtons");
|
||||||
do {
|
do {
|
||||||
|
@ -458,9 +458,8 @@ static NSButtonCell* knobCell = nil;
|
||||||
_hitPart = [self testPart:location];
|
_hitPart = [self testPart:location];
|
||||||
rect = [self rectForPart:_hitPart];
|
rect = [self rectForPart:_hitPart];
|
||||||
|
|
||||||
switch (_hitPart) {
|
switch (_hitPart) // determine which
|
||||||
// determine which cell was hit
|
{ // cell was hit
|
||||||
|
|
||||||
case NSScrollerIncrementLine:
|
case NSScrollerIncrementLine:
|
||||||
case NSScrollerIncrementPage:
|
case NSScrollerIncrementPage:
|
||||||
theCell = (_isHorizontal ? rightCell : upCell);
|
theCell = (_isHorizontal ? rightCell : upCell);
|
||||||
|
@ -476,15 +475,17 @@ static NSButtonCell* knobCell = nil;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theCell) {
|
if (theCell)
|
||||||
|
{
|
||||||
[theCell highlight:YES withFrame:rect inView:self];
|
[theCell highlight:YES withFrame:rect inView:self];
|
||||||
// [self setNeedsDisplayInRect:rect]; // not needed by XRAW
|
// [self setNeedsDisplayInRect:rect]; // not needed by XRAW
|
||||||
[window flushWindow];
|
[window flushWindow];
|
||||||
|
|
||||||
NSLog (@"tracking cell %x", theCell);
|
NSLog (@"tracking cell %x", theCell);
|
||||||
// Track the mouse until mouse goes up
|
|
||||||
shouldReturn = [theCell trackMouse:theEvent
|
shouldReturn = [theCell trackMouse:theEvent // Track the mouse
|
||||||
inRect:rect
|
inRect:rect // until left mouse
|
||||||
ofView:self
|
ofView:self // goes up
|
||||||
untilMouseUp:YES];
|
untilMouseUp:YES];
|
||||||
|
|
||||||
if([_target isKindOf:[NSScrollView class]]) // a hack for XRAW
|
if([_target isKindOf:[NSScrollView class]]) // a hack for XRAW
|
||||||
|
@ -492,6 +493,7 @@ static NSButtonCell* knobCell = nil;
|
||||||
if([[_target contentView] respondsTo:@selector(_freeMatrix)])
|
if([[_target contentView] respondsTo:@selector(_freeMatrix)])
|
||||||
[[_target contentView] _freeMatrix];
|
[[_target contentView] _freeMatrix];
|
||||||
}
|
}
|
||||||
|
|
||||||
[theCell highlight:NO withFrame:rect inView:self];
|
[theCell highlight:NO withFrame:rect inView:self];
|
||||||
// [self setNeedsDisplayInRect:rect]; // not needed by XRAW
|
// [self setNeedsDisplayInRect:rect]; // not needed by XRAW
|
||||||
[window flushWindow];
|
[window flushWindow];
|
||||||
|
@ -504,7 +506,8 @@ static NSButtonCell* knobCell = nil;
|
||||||
untilDate:[NSDate distantFuture]
|
untilDate:[NSDate distantFuture]
|
||||||
inMode:NSEventTrackingRunLoopMode
|
inMode:NSEventTrackingRunLoopMode
|
||||||
dequeue:YES];
|
dequeue:YES];
|
||||||
} while ([theEvent type] != NSLeftMouseUp);
|
}
|
||||||
|
while ([theEvent type] != NSLeftMouseUp);
|
||||||
|
|
||||||
NSDebugLog (@"return from trackScrollButtons");
|
NSDebugLog (@"return from trackScrollButtons");
|
||||||
}
|
}
|
||||||
|
|
|
@ -851,21 +851,21 @@ int i, count;
|
||||||
NSView* subview = [sub_views objectAtIndex:i];
|
NSView* subview = [sub_views objectAtIndex:i];
|
||||||
NSRect subviewFrame = subview->frame;
|
NSRect subviewFrame = subview->frame;
|
||||||
NSRect intersection;
|
NSRect intersection;
|
||||||
// If the subview is rotated compute its
|
// If the subview is rotated compute
|
||||||
// bounding rectangle and use this one
|
// its bounding rectangle and use this
|
||||||
// instead of the subview's frame.
|
// one instead of the subview's frame.
|
||||||
if ([subview->frameMatrix isRotated])
|
if ([subview->frameMatrix isRotated])
|
||||||
[subview->frameMatrix boundingRectFor:subviewFrame
|
[subview->frameMatrix boundingRectFor:subviewFrame
|
||||||
result:&subviewFrame];
|
result:&subviewFrame];
|
||||||
|
|
||||||
// Determine if the subview's frame
|
// Determine if the subview's frame
|
||||||
// intersects "rect" so that we can display
|
// intersects "rect" so that we can
|
||||||
// the subview.
|
// display the subview.
|
||||||
intersection = NSIntersectionRect (rect, subviewFrame);
|
intersection = NSIntersectionRect (rect, subviewFrame);
|
||||||
if (intersection.origin.x || intersection.origin.y ||
|
if (intersection.origin.x || intersection.origin.y ||
|
||||||
intersection.size.width || intersection.size.height)
|
intersection.size.width || intersection.size.height)
|
||||||
{ // Convert the intersection rectangle to
|
{ // Convert the intersection rectangle
|
||||||
// the subview's coordinates
|
// to the subview's coordinates
|
||||||
intersection = [subview convertRect:intersection fromView:self];
|
intersection = [subview convertRect:intersection fromView:self];
|
||||||
[subview displayRect:intersection];
|
[subview displayRect:intersection];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue