Reinstate changes to NSWindow.m to keep it working.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3480 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1998-12-17 13:06:17 +00:00
parent ed8cb51bc9
commit 582f5f44ad
2 changed files with 671 additions and 658 deletions

View file

@ -1,3 +1,8 @@
Thu Dec 17 13:20:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* NSWindow.m: Reinstated changes lost in last update (to fix
recursion problem on menu creation) and added acceptsFirstResponder.
Wed Dec 16 1998 Felipe A. Rodriguez <far@ix.netcom.com> Wed Dec 16 1998 Felipe A. Rodriguez <far@ix.netcom.com>
* NSWindow.m acceptsFirstResponder implement. * NSWindow.m acceptsFirstResponder implement.

View file

@ -130,7 +130,7 @@ int style;
[content_view release]; // Release the content view [content_view release]; // Release the content view
} }
if(_fieldEditor) if (_fieldEditor)
[_fieldEditor release]; [_fieldEditor release];
[background_color release]; [background_color release];
[represented_filename release]; [represented_filename release];
@ -192,9 +192,9 @@ NSRect cframe;
cframe.origin = NSZeroPoint; // Create the content view cframe.origin = NSZeroPoint; // Create the content view
cframe.size = frame.size; cframe.size = frame.size;
[self setContentView:[[[NSView alloc] initWithFrame:cframe] autorelease]]; [self setContentView:[[[NSView alloc] initWithFrame:cframe] autorelease]];
// Register ourselves with
// the Application object
[theApp addWindowsItem:self title:window_title filename:NO]; [theApp addWindowsItem: self title: nil filename: NO];
_flushRectangles = [[NSMutableArray alloc] initWithCapacity:10]; _flushRectangles = [[NSMutableArray alloc] initWithCapacity:10];
@ -247,17 +247,21 @@ NSView *wv;
ASSIGN(background_color, color); ASSIGN(background_color, color);
} }
- (void)setRepresentedFilename:(NSString *)aString - (void) setRepresentedFilename: (NSString*)aString
{ {
ASSIGN(represented_filename, aString); ASSIGN(represented_filename, aString);
} }
- (void)setTitle:(NSString *)aString { ASSIGN(window_title,aString); } - (void) setTitle: (NSString*)aString
- (void)setTitleWithRepresentedFilename:(NSString *)aString
{ {
[self setRepresentedFilename:aString]; ASSIGN(window_title, aString);
[self setTitle:aString]; [self setMiniwindowTitle: aString];
}
- (void) setTitleWithRepresentedFilename: (NSString*)aString
{
[self setRepresentedFilename: aString];
[self setTitle: aString];
} }
- (unsigned int)styleMask { return style_mask; } - (unsigned int)styleMask { return style_mask; }
@ -291,16 +295,15 @@ NSView *wv;
ASSIGN(miniaturized_image, image); ASSIGN(miniaturized_image, image);
} }
- (void)setMiniwindowTitle:(NSString *)title; - (void) setMiniwindowTitle: (NSString*)title
{ {
BOOL isDoc = NO; BOOL isDoc = NO;
ASSIGN(miniaturized_title, title); ASSIGN(miniaturized_title, title);
if (is_miniaturized == NO) if (is_miniaturized == NO)
title = window_title; title = window_title;
if ([title isEqual: represented_filename]) if ([title isEqual: represented_filename])
isDoc = YES; isDoc = YES;
[[NSApplication sharedApplication] changeWindowsItem: self [[NSApplication sharedApplication] changeWindowsItem: self
title: title title: title
filename: isDoc]; filename: isDoc];
@ -503,7 +506,6 @@ NSPoint basePoint;
visible = YES; visible = YES;
needs_display = NO; // inform first responder needs_display = NO; // inform first responder
// of it's status so it can // of it's status so it can
if(first_responder)
[first_responder becomeFirstResponder]; // set the focus to itself [first_responder becomeFirstResponder]; // set the focus to itself
[self disableFlushWindow]; // tmp disable display [self disableFlushWindow]; // tmp disable display
@ -526,7 +528,7 @@ if(first_responder)
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
if(is_autodisplay && needs_display) // if autodisplay is if (is_autodisplay && needs_display) // if autodisplay is
{ // enabled and window { // enabled and window
[self displayIfNeeded]; // display [self displayIfNeeded]; // display
[self flushWindowIfNeeded]; [self flushWindowIfNeeded];
@ -623,25 +625,26 @@ NSView *v;
// //
// Handling user actions and events // Handling user actions and events
// //
- (void)close - (void) close
{ {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSApplication *theApp = [NSApplication sharedApplication]; NSApplication *theApp = [NSApplication sharedApplication];
// Notify delegate
/*
* If 'is_released_when_closed' then the window will be removed from the
* applications list of windows (causing it to be released) - so we must
* bracket any work we do in a retain/release sequence.
*/
if (is_released_when_closed)
[self retain];
[nc postNotificationName: NSWindowWillCloseNotification object: self]; [nc postNotificationName: NSWindowWillCloseNotification object: self];
[self orderOut:self]; [theApp removeWindowsItem: self];
[self orderOut: self];
visible = NO; visible = NO;
// if app has no
if(![theApp mainMenu]) // menu terminate if (is_released_when_closed)
[theApp terminate:self]; [self release];
else
{ // else if should
if (is_released_when_closed) // release do so
{ // default is YES
[theApp removeWindowsItem: self]; // for windows and
[self autorelease]; // NO for panels
}
}
} }
- (void)deminiaturize:sender - (void)deminiaturize:sender
@ -672,7 +675,7 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
- (void)performClose:sender - (void)performClose:sender
{ {
if(!([self styleMask] & NSClosableWindowMask)) if (!([self styleMask] & NSClosableWindowMask))
{ // self must have a close { // self must have a close
NSBeep(); // button in order to be NSBeep(); // button in order to be
return; // closed return; // closed
@ -680,7 +683,7 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
if ([delegate respondsToSelector:@selector(windowShouldClose:)]) if ([delegate respondsToSelector:@selector(windowShouldClose:)])
{ // if delegate responds to { // if delegate responds to
if(![delegate windowShouldClose:self]) // windowShouldClose query if (![delegate windowShouldClose:self]) // windowShouldClose query
{ // it to see if it's ok to { // it to see if it's ok to
NSBeep(); // close the window NSBeep(); // close the window
return; return;
@ -690,7 +693,7 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
{ {
if ([self respondsToSelector:@selector(windowShouldClose:)]) if ([self respondsToSelector:@selector(windowShouldClose:)])
{ // else if self responds to { // else if self responds to
if(![self windowShouldClose:self]) // windowShouldClose query if (![self windowShouldClose:self]) // windowShouldClose query
{ // self to see if it's ok { // self to see if it's ok
NSBeep(); // to close self NSBeep(); // to close self
return; return;
@ -721,17 +724,17 @@ NSApplication *theApp = [NSApplication sharedApplication];
[theApp discardEventsMatchingMask:mask beforeEvent:lastEvent]; [theApp discardEventsMatchingMask:mask beforeEvent:lastEvent];
} }
- (NSResponder *)firstResponder { return first_responder; } - (NSResponder*) firstResponder
- (BOOL)acceptsFirstResponder { return YES; } {
return first_responder;
}
- (void)keyDown:(NSEvent *)theEvent // save the first responder - (BOOL) acceptsFirstResponder
{ // so that the key up goes {
original_responder = first_responder; // to it and not a possible return YES;
// new first responder }
[first_responder keyDown:theEvent]; // Send the first responder
} // the key down
- (BOOL)makeFirstResponder:(NSResponder *)aResponder - (BOOL) makeFirstResponder: (NSResponder*)aResponder
{ {
if (first_responder == aResponder) // if responder is already if (first_responder == aResponder) // if responder is already
return YES; // first responder return Y return YES; // first responder return Y
@ -919,7 +922,7 @@ NSView *v;
v = [content_view hitTest:[theEvent locationInWindow]]; v = [content_view hitTest:[theEvent locationInWindow]];
NSDebugLog([v description]); NSDebugLog([v description]);
NSDebugLog(@"\n"); NSDebugLog(@"\n");
if(first_responder != v) // if hit view is not first if (first_responder != v) // if hit view is not first
[self makeFirstResponder:v]; // responder ask it to be [self makeFirstResponder:v]; // responder ask it to be
[v mouseDown:theEvent]; [v mouseDown:theEvent];
last_point = [theEvent locationInWindow]; last_point = [theEvent locationInWindow];
@ -972,8 +975,13 @@ NSView *v;
case NSMouseExited: // Mouse exited case NSMouseExited: // Mouse exited
break; break;
case NSKeyDown: // Key down case NSKeyDown:
[self keyDown:theEvent]; /*
* Save the first responder so that the key up goes to it and not a
* possible new first responder.
*/
original_responder = first_responder;
[first_responder keyDown: theEvent];
break; break;
case NSKeyUp: // Key up case NSKeyUp: // Key up
@ -1309,7 +1317,7 @@ id result = nil;
// +++ we shouldn't do this because coding may not be done? // +++ we shouldn't do this because coding may not be done?
// better to do it in the awakeFromCoder method // better to do it in the awakeFromCoder method
theApp = [NSApplication sharedApplication]; theApp = [NSApplication sharedApplication];
[theApp addWindowsItem:self title:nil filename:NO]; [theApp addWindowsItem: self title: nil filename: NO];
NSDebugLog(@"NSWindow: finish decoding\n"); NSDebugLog(@"NSWindow: finish decoding\n");
return self; return self;
@ -1362,7 +1370,7 @@ id result = nil;
is_key = NO; is_key = NO;
is_main = NO; is_main = NO;
is_edited = NO; is_edited = NO;
is_released_when_closed = NO; is_released_when_closed = YES;
is_miniaturized = NO; is_miniaturized = NO;
disable_flush_window = NO; disable_flush_window = NO;
menu_exclude = NO; menu_exclude = NO;