mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:20:48 +00:00
Various updates to get keyboard equivalents for buttons working (especially
for panels). git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3461 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
958d1bf294
commit
bf5137b858
7 changed files with 357 additions and 233 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
Tue Dec 15 16:30:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
|
* NSApplication.m: Terminate modal loop if the window goes away.
|
||||||
|
* NSButton.m: Handle key equivalents.
|
||||||
|
* NSButtonCell.m: Handle key equivalents.
|
||||||
|
* NSCell.m: implement ([-performClick:]) method.
|
||||||
|
* NSPanel.m: Close closable panels when user hits escape key.
|
||||||
|
handle keyboard shortcut for default option.
|
||||||
|
* NSWindow.m: Fix bug causing app to terminate when it shouldn't.
|
||||||
|
|
||||||
Mon Dec 14 16:15:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
Mon Dec 14 16:15:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
* GSServicesMnager.m: Added alert panels to display error messages
|
* GSServicesMnager.m: Added alert panels to display error messages
|
||||||
|
|
|
@ -345,80 +345,92 @@ static int code;
|
||||||
|
|
||||||
- (int) runModalSession: (NSModalSession)theSession
|
- (int) runModalSession: (NSModalSession)theSession
|
||||||
{
|
{
|
||||||
BOOL found = NO;
|
BOOL found = NO;
|
||||||
NSEvent *event;
|
NSEvent *event;
|
||||||
unsigned count;
|
unsigned count;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
if (theSession != session)
|
if (theSession != session)
|
||||||
[NSException raise: NSInvalidArgumentException
|
[NSException raise: NSInvalidArgumentException
|
||||||
format: @"runModalSession: with wrong session"];
|
format: @"runModalSession: with wrong session"];
|
||||||
|
|
||||||
theSession->runState = NSRunContinuesResponse;
|
theSession->runState = NSRunContinuesResponse;
|
||||||
[theSession->window display];
|
[theSession->window display];
|
||||||
[theSession->window makeKeyAndOrderFront: self];
|
[theSession->window makeKeyAndOrderFront: self];
|
||||||
|
|
||||||
do { // First we make sure
|
// First we make sure
|
||||||
count = [event_queue count]; // that there is an
|
// that there is an
|
||||||
for (i = 0; i < count; i++) // event.
|
// event.
|
||||||
{
|
do
|
||||||
event = [event_queue objectAtIndex: 0];
|
{
|
||||||
if ([event window] == theSession->window)
|
count = [event_queue count];
|
||||||
{
|
for (i = 0; i < count; i++)
|
||||||
found = YES;
|
{
|
||||||
break;
|
event = [event_queue objectAtIndex: 0];
|
||||||
}
|
if ([event window] == theSession->window)
|
||||||
else // dump events not for
|
{
|
||||||
[event_queue removeObjectAtIndex:0]; // the modal window
|
found = YES;
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// dump events not for
|
||||||
|
// the modal window
|
||||||
|
[event_queue removeObjectAtIndex: 0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (found == NO)
|
if (found == NO)
|
||||||
{
|
{
|
||||||
NSDate *limitDate = [NSDate distantFuture];
|
NSDate *limitDate = [NSDate distantFuture];
|
||||||
|
|
||||||
[[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode
|
[[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode
|
||||||
beforeDate: limitDate];
|
beforeDate: limitDate];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (found == NO && theSession->runState == NSRunContinuesResponse);
|
while (found == NO && theSession->runState == NSRunContinuesResponse);
|
||||||
|
|
||||||
// Deal with the events
|
// Deal with the events
|
||||||
// in the queue.
|
// in the queue.
|
||||||
while (found == YES && theSession->runState == NSRunContinuesResponse)
|
while (found == YES && theSession->runState == NSRunContinuesResponse)
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||||
|
|
||||||
found = NO;
|
found = NO;
|
||||||
count = [event_queue count];
|
count = [event_queue count];
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
event = [event_queue objectAtIndex: i];
|
event = [event_queue objectAtIndex: i];
|
||||||
if ([event window] == theSession->window)
|
if ([event window] == theSession->window)
|
||||||
{
|
{
|
||||||
ASSIGN(current_event, event);
|
ASSIGN(current_event, event);
|
||||||
[event_queue removeObjectAtIndex: i];
|
[event_queue removeObjectAtIndex: i];
|
||||||
found = YES;
|
found = YES;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found == YES)
|
if (found == YES)
|
||||||
{
|
{
|
||||||
[self sendEvent: current_event];
|
[self sendEvent: current_event];
|
||||||
|
|
||||||
if (windows_need_update)
|
/*
|
||||||
[self updateWindows];
|
* Check to see if the window has gone away - if so, end session.
|
||||||
/* xxx should we update the services menu? */
|
*/
|
||||||
[listener updateServicesMenu];
|
if ([window_list indexOfObjectIdenticalTo: session->window] ==
|
||||||
}
|
NSNotFound || [session->window isVisible] == NO)
|
||||||
|
[self stopModal];
|
||||||
|
if (windows_need_update)
|
||||||
|
[self updateWindows];
|
||||||
|
}
|
||||||
|
|
||||||
[pool release];
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSAssert(session == theSession, @"Session was changed while running");
|
NSAssert(session == theSession, @"Session was changed while running");
|
||||||
|
|
||||||
return theSession->runState;
|
return theSession->runState;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) stop: (id)sender
|
- (void) stop: (id)sender
|
||||||
|
@ -1093,22 +1105,22 @@ int i;
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)removeWindowsItem:aWindow
|
- (void) removeWindowsItem: (NSWindow*)aWindow
|
||||||
{
|
{
|
||||||
if (aWindow == key_window) // This should be different
|
if (aWindow == key_window) // This should be different
|
||||||
key_window = nil;
|
key_window = nil;
|
||||||
if (aWindow == main_window)
|
if (aWindow == main_window)
|
||||||
main_window = nil;
|
main_window = nil;
|
||||||
|
|
||||||
// If we are within our dealloc then don't remove the window
|
// If we are within our dealloc then don't remove the window
|
||||||
// Most likely dealloc is removing windows from our window list
|
// Most likely dealloc is removing windows from our window list
|
||||||
// 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;
|
|
||||||
// Remove window from the
|
|
||||||
[window_list removeObject: aWindow]; // window list
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
// Remove window from the
|
||||||
|
[window_list removeObject: aWindow]; // window list
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setWindowsMenu:aMenu
|
- (void)setWindowsMenu:aMenu
|
||||||
|
|
|
@ -263,32 +263,62 @@ id gnustep_gui_nsbutton_class = nil;
|
||||||
//
|
//
|
||||||
// Setting the Key Equivalent
|
// Setting the Key Equivalent
|
||||||
//
|
//
|
||||||
- (NSString *)keyEquivalent
|
- (NSString*) keyEquivalent
|
||||||
{
|
{
|
||||||
return nil;
|
return [cell keyEquivalent];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (unsigned int)keyEquivalentModifierMask
|
- (unsigned int) keyEquivalentModifierMask
|
||||||
{
|
{
|
||||||
return 0;
|
return [cell keyEquivalentModifierMask];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setKeyEquivalent:(NSString *)aKeyEquivalent
|
- (void) setKeyEquivalent: (NSString*)aKeyEquivalent
|
||||||
{}
|
{
|
||||||
|
[cell setKeyEquivalent: aKeyEquivalent];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)setKeyEquivalentModifierMask:(unsigned int)mask
|
- (void) setKeyEquivalentModifierMask: (unsigned int)mask
|
||||||
{}
|
{
|
||||||
|
[cell setKeyEquivalentModifierMask: mask];
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Handling Events and Action Messages
|
// Handling Events and Action Messages
|
||||||
//
|
//
|
||||||
- (void)performClick:(id)sender
|
- (BOOL)acceptsFirstResponder
|
||||||
{
|
{
|
||||||
[cell performClick:sender];
|
return [self keyEquivalent] != nil;;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)performKeyEquivalent:(NSEvent *)anEvent
|
- (void) keyDown: (NSEvent*)theEvent
|
||||||
{
|
{
|
||||||
|
if ([self performKeyEquivalent: theEvent] == NO)
|
||||||
|
[super keyDown: theEvent];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) performClick: (id)sender
|
||||||
|
{
|
||||||
|
[cell performClick: sender];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) performKeyEquivalent: (NSEvent *)anEvent
|
||||||
|
{
|
||||||
|
if ([self isEnabled])
|
||||||
|
{
|
||||||
|
NSString *key = [self keyEquivalent];
|
||||||
|
|
||||||
|
if (key != nil && [key isEqual: [anEvent charactersIgnoringModifiers]])
|
||||||
|
{
|
||||||
|
unsigned int mask = [self keyEquivalentModifierMask];
|
||||||
|
|
||||||
|
if (([anEvent modifierFlags] & mask) == mask)
|
||||||
|
{
|
||||||
|
[self performClick: self];
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <Foundation/NSLock.h>
|
#include <Foundation/NSLock.h>
|
||||||
#include <Foundation/NSArray.h>
|
#include <Foundation/NSArray.h>
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/NSString.h>
|
||||||
|
#include <Foundation/NSException.h>
|
||||||
|
|
||||||
#include <AppKit/NSButtonCell.h>
|
#include <AppKit/NSButtonCell.h>
|
||||||
#include <AppKit/NSButton.h>
|
#include <AppKit/NSButton.h>
|
||||||
|
@ -154,35 +155,67 @@ NSString* _string = [aString copy];
|
||||||
[self setContinuous:YES];
|
[self setContinuous:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) performClick: (id)sender
|
||||||
|
{
|
||||||
|
NSView *cv = [self controlView];
|
||||||
|
|
||||||
|
[self highlight: YES withFrame: [cv frame] inView: cv];
|
||||||
|
if (action && target)
|
||||||
|
{
|
||||||
|
NS_DURING
|
||||||
|
{
|
||||||
|
[(NSControl*)cv sendAction: action to: target];
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
[self highlight: NO withFrame: [cv frame] inView: cv];
|
||||||
|
[localException raise];
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER
|
||||||
|
}
|
||||||
|
[self highlight: NO withFrame: [cv frame] inView: cv];
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Setting the Key Equivalent
|
// Setting the Key Equivalent
|
||||||
//
|
//
|
||||||
- (NSString *)keyEquivalent { return keyEquivalent; }
|
- (NSString*) keyEquivalent
|
||||||
- (NSFont *)keyEquivalentFont { return keyEquivalentFont; }
|
{
|
||||||
|
return keyEquivalent;
|
||||||
|
}
|
||||||
|
|
||||||
- (unsigned int)keyEquivalentModifierMask
|
- (NSFont*) keyEquivalentFont
|
||||||
|
{
|
||||||
|
return keyEquivalentFont;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (unsigned int) keyEquivalentModifierMask
|
||||||
{
|
{
|
||||||
return keyEquivalentModifierMask;
|
return keyEquivalentModifierMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setKeyEquivalent:(NSString *)key
|
- (void) setKeyEquivalent: (NSString*)key
|
||||||
{
|
{
|
||||||
ASSIGN(keyEquivalent, [key copy]);
|
if (keyEquivalent != key)
|
||||||
|
{
|
||||||
|
[keyEquivalent release];
|
||||||
|
keyEquivalent = [key copy];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setKeyEquivalentModifierMask:(unsigned int)mask
|
- (void) setKeyEquivalentModifierMask: (unsigned int)mask
|
||||||
{
|
{
|
||||||
keyEquivalentModifierMask = mask;
|
keyEquivalentModifierMask = mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setKeyEquivalentFont:(NSFont *)fontObj
|
- (void) setKeyEquivalentFont: (NSFont*)fontObj
|
||||||
{
|
{
|
||||||
ASSIGN(keyEquivalentFont, fontObj);
|
ASSIGN(keyEquivalentFont, fontObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setKeyEquivalentFont:(NSString *)fontName size:(float)fontSize
|
- (void) setKeyEquivalentFont: (NSString*)fontName size: (float)fontSize
|
||||||
{
|
{
|
||||||
ASSIGN(keyEquivalentFont, [NSFont fontWithName:fontName size:fontSize]);
|
ASSIGN(keyEquivalentFont, [NSFont fontWithName: fontName size: fontSize]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -272,13 +305,6 @@ NSString* _string = [aString copy];
|
||||||
control_view = controlView; // Save last view cell was drawn to
|
control_view = controlView; // Save last view cell was drawn to
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Simulating a Click
|
|
||||||
//
|
|
||||||
- (void)performClick:(id)sender
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id)copyWithZone:(NSZone*)zone
|
- (id)copyWithZone:(NSZone*)zone
|
||||||
{
|
{
|
||||||
NSButtonCell* c = [super copyWithZone:zone];
|
NSButtonCell* c = [super copyWithZone:zone];
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include <gnustep/gui/config.h>
|
#include <gnustep/gui/config.h>
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/NSString.h>
|
||||||
|
#include <Foundation/NSException.h>
|
||||||
#include <Foundation/NSValue.h>
|
#include <Foundation/NSValue.h>
|
||||||
|
|
||||||
#include <AppKit/NSApplication.h>
|
#include <AppKit/NSApplication.h>
|
||||||
|
@ -525,8 +526,25 @@ unsigned int previousMask = action_mask;
|
||||||
- (void)setTarget:(id)anObject {}
|
- (void)setTarget:(id)anObject {}
|
||||||
- (id)target { return nil; }
|
- (id)target { return nil; }
|
||||||
|
|
||||||
- (void)performClick:(id)sender
|
- (void) performClick: (id)sender
|
||||||
{
|
{
|
||||||
|
NSView *cv = [self controlView];
|
||||||
|
|
||||||
|
[self highlight: YES withFrame: [cv frame] inView: cv];
|
||||||
|
if ([self action] && [self target])
|
||||||
|
{
|
||||||
|
NS_DURING
|
||||||
|
{
|
||||||
|
[(NSControl*)cv sendAction: [self action] to: [self target]];
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
[self highlight: NO withFrame: [cv frame] inView: cv];
|
||||||
|
[localException raise];
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER
|
||||||
|
}
|
||||||
|
[self highlight: NO withFrame: [cv frame] inView: cv];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -83,6 +83,18 @@
|
||||||
defer: NO];
|
defer: NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// If we receive an escape, close.
|
||||||
|
//
|
||||||
|
- (void) keyDown: (NSEvent*)theEvent
|
||||||
|
{
|
||||||
|
if ([@"\e" isEqual: [theEvent charactersIgnoringModifiers]] &&
|
||||||
|
([self styleMask] & NSClosableWindowMask) == NSClosableWindowMask)
|
||||||
|
[self close];
|
||||||
|
else
|
||||||
|
[super keyDown: theEvent];
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Determining the Panel's Behavior
|
// Determining the Panel's Behavior
|
||||||
//
|
//
|
||||||
|
@ -409,60 +421,61 @@ static GSAlertPanel *gmodelAlertPanel = nil;
|
||||||
{
|
{
|
||||||
[defButton setTitle: defaultButton];
|
[defButton setTitle: defaultButton];
|
||||||
if ([defButton superview] == nil)
|
if ([defButton superview] == nil)
|
||||||
[content addSubview: defButton];
|
[content addSubview: defButton];
|
||||||
|
[self makeFirstResponder: defButton];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ([defButton superview] != nil)
|
if ([defButton superview] != nil)
|
||||||
[defButton removeFromSuperview];
|
[defButton removeFromSuperview];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alternateButton)
|
if (alternateButton)
|
||||||
{
|
{
|
||||||
[altButton setTitle: alternateButton];
|
[altButton setTitle: alternateButton];
|
||||||
if ([altButton superview] == nil)
|
if ([altButton superview] == nil)
|
||||||
[content addSubview: altButton];
|
[content addSubview: altButton];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ([altButton superview] != nil)
|
if ([altButton superview] != nil)
|
||||||
[altButton removeFromSuperview];
|
[altButton removeFromSuperview];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (otherButton)
|
if (otherButton)
|
||||||
{
|
{
|
||||||
[othButton setTitle: otherButton];
|
[othButton setTitle: otherButton];
|
||||||
if ([othButton superview] == nil)
|
if ([othButton superview] == nil)
|
||||||
[content addSubview: othButton];
|
[content addSubview: othButton];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ([othButton superview] != nil)
|
if ([othButton superview] != nil)
|
||||||
[othButton removeFromSuperview];
|
[othButton removeFromSuperview];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message)
|
if (message)
|
||||||
{
|
{
|
||||||
[messageField setStringValue: message];
|
[messageField setStringValue: message];
|
||||||
if ([messageField superview] == nil)
|
if ([messageField superview] == nil)
|
||||||
[content addSubview: messageField];
|
[content addSubview: messageField];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ([messageField superview] != nil)
|
if ([messageField superview] != nil)
|
||||||
[messageField removeFromSuperview];
|
[messageField removeFromSuperview];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (title)
|
if (title)
|
||||||
{
|
{
|
||||||
[titleField setStringValue: title];
|
[titleField setStringValue: title];
|
||||||
if ([titleField superview] == nil)
|
if ([titleField superview] == nil)
|
||||||
[content addSubview: titleField];
|
[content addSubview: titleField];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ([titleField superview] != nil)
|
if ([titleField superview] != nil)
|
||||||
[titleField removeFromSuperview];
|
[titleField removeFromSuperview];
|
||||||
}
|
}
|
||||||
|
|
||||||
result = NSAlertErrorReturn; /* If no button was pressed */
|
result = NSAlertErrorReturn; /* If no button was pressed */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
NSWindow.m
|
NSWindow.m
|
||||||
|
|
||||||
The window class
|
The window class
|
||||||
|
@ -10,14 +10,14 @@
|
||||||
Date: 1996
|
Date: 1996
|
||||||
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
||||||
Date: June 1998
|
Date: June 1998
|
||||||
|
|
||||||
This file is part of the GNUstep GUI Library.
|
This file is part of the GNUstep GUI Library.
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Library General Public
|
modify it under the terms of the GNU Library General Public
|
||||||
License as published by the Free Software Foundation; either
|
License as published by the Free Software Foundation; either
|
||||||
version 2 of the License, or (at your option) any later version.
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
This library is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
License along with this library; see the file COPYING.LIB.
|
License along with this library; see the file COPYING.LIB.
|
||||||
If not, write to the Free Software Foundation,
|
If not, write to the Free Software Foundation,
|
||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gnustep/gui/config.h>
|
#include <gnustep/gui/config.h>
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
|
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
//
|
//
|
||||||
// NSWindow
|
// NSWindow
|
||||||
//
|
//
|
||||||
//*****************************************************************************
|
//*****************************************************************************
|
||||||
|
|
||||||
|
@ -68,22 +68,22 @@
|
||||||
if (self == [NSWindow class])
|
if (self == [NSWindow class])
|
||||||
{
|
{
|
||||||
NSDebugLog(@"Initialize NSWindow class\n");
|
NSDebugLog(@"Initialize NSWindow class\n");
|
||||||
[self setVersion:2];
|
[self setVersion:2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSView *)_windowViewWithFrame:(NSRect)frameRect // create the view at
|
+ (NSView *)_windowViewWithFrame:(NSRect)frameRect // create the view at
|
||||||
{ // the root of window's
|
{ // the root of window's
|
||||||
return nil; // view heirarchy.
|
return nil; // view heirarchy.
|
||||||
} // (backend)
|
} // (backend)
|
||||||
|
|
||||||
+ (void)removeFrameUsingName:(NSString *)name
|
+ (void)removeFrameUsingName:(NSString *)name
|
||||||
{ // Saving and restoring
|
{ // Saving and restoring
|
||||||
} // the window's frame
|
} // the window's frame
|
||||||
|
|
||||||
+ (NSRect)contentRectForFrameRect:(NSRect)aRect
|
+ (NSRect)contentRectForFrameRect:(NSRect)aRect
|
||||||
styleMask:(unsigned int)aStyle
|
styleMask:(unsigned int)aStyle
|
||||||
{ // Computing frame and
|
{ // Computing frame and
|
||||||
return aRect; // content rectangles
|
return aRect; // content rectangles
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,24 +113,24 @@ int style;
|
||||||
|
|
||||||
NSDebugLog(@"NSWindow -init\n");
|
NSDebugLog(@"NSWindow -init\n");
|
||||||
// default window
|
// default window
|
||||||
style = NSTitledWindowMask | NSClosableWindowMask // style mask
|
style = NSTitledWindowMask | NSClosableWindowMask // style mask
|
||||||
| NSMiniaturizableWindowMask | NSResizableWindowMask;
|
| NSMiniaturizableWindowMask | NSResizableWindowMask;
|
||||||
|
|
||||||
return [self initWithContentRect:NSZeroRect
|
return [self initWithContentRect:NSZeroRect
|
||||||
styleMask:style
|
styleMask:style
|
||||||
backing:NSBackingStoreBuffered
|
backing:NSBackingStoreBuffered
|
||||||
defer:NO];
|
defer:NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
if (content_view)
|
if (content_view)
|
||||||
{
|
{
|
||||||
[[content_view superview] release]; // Release the window view
|
[[content_view superview] release]; // Release the window view
|
||||||
[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];
|
||||||
|
@ -138,7 +138,7 @@ int style;
|
||||||
[miniaturized_image release];
|
[miniaturized_image release];
|
||||||
[window_title release];
|
[window_title release];
|
||||||
[_flushRectangles release];
|
[_flushRectangles release];
|
||||||
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,10 +152,10 @@ int style;
|
||||||
{
|
{
|
||||||
NSDebugLog(@"NSWindow -initWithContentRect:\n");
|
NSDebugLog(@"NSWindow -initWithContentRect:\n");
|
||||||
|
|
||||||
return [self initWithContentRect:contentRect
|
return [self initWithContentRect:contentRect
|
||||||
styleMask:aStyle
|
styleMask:aStyle
|
||||||
backing:bufferingType
|
backing:bufferingType
|
||||||
defer:flag
|
defer:flag
|
||||||
screen:nil];
|
screen:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ NSRect cframe;
|
||||||
NSLog(@"No application!\n");
|
NSLog(@"No application!\n");
|
||||||
|
|
||||||
NSDebugLog(@"NSWindow start of init\n");
|
NSDebugLog(@"NSWindow start of init\n");
|
||||||
// Initialize attributes
|
// Initialize attributes
|
||||||
[self cleanInit]; // and flags
|
[self cleanInit]; // and flags
|
||||||
|
|
||||||
backing_type = bufferingType;
|
backing_type = bufferingType;
|
||||||
|
@ -192,7 +192,7 @@ 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
|
// Register ourselves with
|
||||||
// the Application object
|
// the Application object
|
||||||
[theApp addWindowsItem:self title:window_title filename:NO];
|
[theApp addWindowsItem:self title:window_title filename:NO];
|
||||||
|
|
||||||
|
@ -214,9 +214,9 @@ NSView *wv;
|
||||||
|
|
||||||
if (!aView) // contentview can't be nil
|
if (!aView) // contentview can't be nil
|
||||||
aView = [[[NSView alloc] initWithFrame: frame] autorelease];
|
aView = [[[NSView alloc] initWithFrame: frame] autorelease];
|
||||||
// If window view has not
|
// If window view has not
|
||||||
// been created, create it
|
// been created, create it
|
||||||
if ((!content_view) || ([content_view superview] == nil))
|
if ((!content_view) || ([content_view superview] == nil))
|
||||||
{
|
{
|
||||||
wv = [NSWindow _windowViewWithFrame: frame];
|
wv = [NSWindow _windowViewWithFrame: frame];
|
||||||
[wv viewWillMoveToWindow: self];
|
[wv viewWillMoveToWindow: self];
|
||||||
|
@ -271,9 +271,9 @@ NSView *wv;
|
||||||
- (int)gState { return 0; }
|
- (int)gState { return 0; }
|
||||||
- (BOOL)isOneShot { return is_one_shot; }
|
- (BOOL)isOneShot { return is_one_shot; }
|
||||||
|
|
||||||
- (void)setBackingType:(NSBackingStoreType)type
|
- (void)setBackingType:(NSBackingStoreType)type
|
||||||
{
|
{
|
||||||
backing_type = type;
|
backing_type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setOneShot:(BOOL)flag { is_one_shot = flag; }
|
- (void)setOneShot:(BOOL)flag { is_one_shot = flag; }
|
||||||
|
@ -309,13 +309,13 @@ NSView *wv;
|
||||||
@selector(windowWillReturnFieldEditor:toObject:)])
|
@selector(windowWillReturnFieldEditor:toObject:)])
|
||||||
return [delegate windowWillReturnFieldEditor:self toObject:anObject];
|
return [delegate windowWillReturnFieldEditor:self toObject:anObject];
|
||||||
|
|
||||||
if(!_fieldEditor && createFlag) // each window has a global
|
if (!_fieldEditor && createFlag) // each window has a global
|
||||||
{ // text field editor
|
{ // text field editor
|
||||||
_fieldEditor = [[NSText new] retain];
|
_fieldEditor = [[NSText new] retain];
|
||||||
[_fieldEditor setFieldEditor:YES];
|
[_fieldEditor setFieldEditor:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
return _fieldEditor;
|
return _fieldEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -326,7 +326,7 @@ NSView *wv;
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
is_key = YES; // We are the key window
|
is_key = YES; // We are the key window
|
||||||
|
|
||||||
[self resetCursorRects]; // Reset the cursor rects
|
[self resetCursorRects]; // Reset the cursor rects
|
||||||
// Post notification
|
// Post notification
|
||||||
[nc postNotificationName: NSWindowDidBecomeKeyNotification object: self];
|
[nc postNotificationName: NSWindowDidBecomeKeyNotification object: self];
|
||||||
|
@ -335,7 +335,7 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
- (void)becomeMainWindow
|
- (void)becomeMainWindow
|
||||||
{
|
{
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
is_main = YES; // We are the main window
|
is_main = YES; // We are the main window
|
||||||
// Post notification
|
// Post notification
|
||||||
[nc postNotificationName: NSWindowDidBecomeMainNotification object: self];
|
[nc postNotificationName: NSWindowDidBecomeMainNotification object: self];
|
||||||
|
@ -351,7 +351,7 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
- (int)level { return window_level; }
|
- (int)level { return window_level; }
|
||||||
|
|
||||||
- (void)makeKeyAndOrderFront:sender
|
- (void)makeKeyAndOrderFront:sender
|
||||||
{
|
{
|
||||||
[self makeKeyWindow]; // Make self the key window
|
[self makeKeyWindow]; // Make self the key window
|
||||||
[self orderFront:sender]; // order self to the front
|
[self orderFront:sender]; // order self to the front
|
||||||
}
|
}
|
||||||
|
@ -361,24 +361,24 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
NSApplication *theApp = [NSApplication sharedApplication];
|
NSApplication *theApp = [NSApplication sharedApplication];
|
||||||
// Can we become the key
|
// Can we become the key
|
||||||
if (![self canBecomeKeyWindow]) // window?
|
if (![self canBecomeKeyWindow]) // window?
|
||||||
return;
|
return;
|
||||||
// ask the current key
|
// ask the current key
|
||||||
[[theApp keyWindow] resignKeyWindow]; // window to resign status
|
[[theApp keyWindow] resignKeyWindow]; // window to resign status
|
||||||
|
|
||||||
[self becomeKeyWindow]; // become the key window
|
[self becomeKeyWindow]; // become the key window
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)makeMainWindow
|
- (void)makeMainWindow
|
||||||
{
|
{
|
||||||
NSApplication *theApp = [NSApplication sharedApplication];
|
NSApplication *theApp = [NSApplication sharedApplication];
|
||||||
// Can we become the main
|
// Can we become the main
|
||||||
if (![self canBecomeMainWindow]) // window?
|
if (![self canBecomeMainWindow]) // window?
|
||||||
return;
|
return;
|
||||||
// ask the current main
|
// ask the current main
|
||||||
[[theApp mainWindow] resignMainWindow]; // window to resign status
|
[[theApp mainWindow] resignMainWindow]; // window to resign status
|
||||||
|
|
||||||
[self becomeMainWindow]; // become the main window
|
[self becomeMainWindow]; // become the main window
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)orderBack:sender {} // implemented in back end
|
- (void)orderBack:sender {} // implemented in back end
|
||||||
- (void)orderFront:sender {}
|
- (void)orderFront:sender {}
|
||||||
|
@ -443,13 +443,13 @@ NSPoint origin = frame.origin; // center the window
|
||||||
- (void)setFrame:(NSRect)frameRect display:(BOOL)flag
|
- (void)setFrame:(NSRect)frameRect display:(BOOL)flag
|
||||||
{
|
{
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
frame = frameRect;
|
frame = frameRect;
|
||||||
// post notification
|
// post notification
|
||||||
[nc postNotificationName: NSWindowDidResizeNotification object: self];
|
[nc postNotificationName: NSWindowDidResizeNotification object: self];
|
||||||
|
|
||||||
if (flag) // display if requested
|
if (flag) // display if requested
|
||||||
[self display];
|
[self display];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setFrameTopLeftPoint:(NSPoint)aPoint
|
- (void)setFrameTopLeftPoint:(NSPoint)aPoint
|
||||||
|
@ -491,20 +491,20 @@ NSPoint basePoint;
|
||||||
- (void)display
|
- (void)display
|
||||||
{
|
{
|
||||||
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
|
||||||
[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
|
||||||
|
|
||||||
[[content_view superview] display]; // Draw the window view
|
[[content_view superview] display]; // Draw the window view
|
||||||
|
|
||||||
[self enableFlushWindow]; // Reenable displaying and
|
[self enableFlushWindow]; // Reenable displaying and
|
||||||
} // flush the window
|
} // flush the window
|
||||||
|
|
||||||
- (void)displayIfNeeded
|
- (void)displayIfNeeded
|
||||||
{
|
{
|
||||||
if (needs_display)
|
if (needs_display)
|
||||||
{
|
{
|
||||||
[[content_view superview] displayIfNeeded];
|
[[content_view superview] displayIfNeeded];
|
||||||
needs_display = NO;
|
needs_display = NO;
|
||||||
|
@ -515,7 +515,7 @@ NSPoint basePoint;
|
||||||
{
|
{
|
||||||
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];
|
||||||
|
@ -526,14 +526,14 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
- (void)flushWindowIfNeeded
|
- (void)flushWindowIfNeeded
|
||||||
{
|
{
|
||||||
if (!disable_flush_window && needs_flush)
|
if (!disable_flush_window && needs_flush)
|
||||||
{
|
{
|
||||||
needs_flush = NO;
|
needs_flush = NO;
|
||||||
[self flushWindow];
|
[self flushWindow];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)flushWindow {} // implemented in back end
|
- (void)flushWindow {} // implemented in back end
|
||||||
- (void)enableFlushWindow { disable_flush_window = NO; }
|
- (void)enableFlushWindow { disable_flush_window = NO; }
|
||||||
- (BOOL)isAutodisplay { return is_autodisplay; }
|
- (BOOL)isAutodisplay { return is_autodisplay; }
|
||||||
- (BOOL)isFlushWindowDisabled { return disable_flush_window; }
|
- (BOOL)isFlushWindowDisabled { return disable_flush_window; }
|
||||||
|
@ -544,7 +544,7 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
|
||||||
- (BOOL)canStoreColor
|
- (BOOL)canStoreColor
|
||||||
{
|
{
|
||||||
if (depth_limit > 1) // If the depth is greater
|
if (depth_limit > 1) // If the depth is greater
|
||||||
return YES; // than a single bit
|
return YES; // than a single bit
|
||||||
else
|
else
|
||||||
return NO;
|
return NO;
|
||||||
|
@ -571,7 +571,7 @@ NSView *v;
|
||||||
// Discard cursor rects
|
// Discard cursor rects
|
||||||
[theView discardCursorRects]; // for the view
|
[theView discardCursorRects]; // for the view
|
||||||
|
|
||||||
s = [theView subviews]; // Discard cursor rects
|
s = [theView subviews]; // Discard cursor rects
|
||||||
e = [s objectEnumerator]; // for view's subviews
|
e = [s objectEnumerator]; // for view's subviews
|
||||||
while ((v = [e nextObject]))
|
while ((v = [e nextObject]))
|
||||||
[self discardCursorRectsForView: v];
|
[self discardCursorRectsForView: v];
|
||||||
|
@ -594,10 +594,10 @@ NSView *v;
|
||||||
NSArray *s;
|
NSArray *s;
|
||||||
id e;
|
id e;
|
||||||
NSView *v;
|
NSView *v;
|
||||||
|
|
||||||
[theView resetCursorRects]; // Reset cursor rects for view
|
|
||||||
|
|
||||||
s = [theView subviews]; // Reset cursor rects for the
|
[theView resetCursorRects]; // Reset cursor rects for view
|
||||||
|
|
||||||
|
s = [theView subviews]; // Reset cursor rects for the
|
||||||
e = [s objectEnumerator]; // view's subviews
|
e = [s objectEnumerator]; // view's subviews
|
||||||
while ((v = [e nextObject]))
|
while ((v = [e nextObject]))
|
||||||
[self resetCursorRectsForView: v];
|
[self resetCursorRectsForView: v];
|
||||||
|
@ -612,27 +612,22 @@ NSView *v;
|
||||||
//
|
//
|
||||||
// Handling user actions and events
|
// Handling user actions and events
|
||||||
//
|
//
|
||||||
- (void)close
|
- (void) close
|
||||||
{
|
{
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
// Notify delegate
|
// Notify delegate
|
||||||
[nc postNotificationName: NSWindowWillCloseNotification object: self];
|
[nc postNotificationName: NSWindowWillCloseNotification object: self];
|
||||||
[self orderOut:self];
|
[self orderOut: self];
|
||||||
visible = NO;
|
visible = NO;
|
||||||
// if app has no
|
|
||||||
if(![[NSApplication sharedApplication] mainMenu]) // menu terminate
|
if (is_released_when_closed)
|
||||||
[[NSApplication sharedApplication] terminate:self];
|
[self autorelease];
|
||||||
else
|
}
|
||||||
{ // else if should
|
|
||||||
if (is_released_when_closed) // release do so
|
|
||||||
[self autorelease]; // default is YES
|
|
||||||
} // for windows and
|
|
||||||
} // NO for panels
|
|
||||||
|
|
||||||
- (void)deminiaturize:sender
|
- (void)deminiaturize:sender
|
||||||
{
|
{
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
// Set ivar flag to say we
|
// Set ivar flag to say we
|
||||||
is_miniaturized = NO; // are not miniaturized
|
is_miniaturized = NO; // are not miniaturized
|
||||||
visible = YES;
|
visible = YES;
|
||||||
|
|
||||||
|
@ -655,33 +650,33 @@ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
[nc postNotificationName: NSWindowDidMiniaturizeNotification object: self];
|
[nc postNotificationName: NSWindowDidMiniaturizeNotification object: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (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
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
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;
|
||||||
} } }
|
} } }
|
||||||
|
|
||||||
[self close]; // it's ok to close self
|
[self close]; // it's ok to close self
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)performMiniaturize:sender { is_miniaturized = YES; } - (int)resizeFlags { return 0; }
|
- (void)performMiniaturize:sender { is_miniaturized = YES; } - (int)resizeFlags { return 0; }
|
||||||
|
@ -708,12 +703,32 @@ NSApplication *theApp = [NSApplication sharedApplication];
|
||||||
|
|
||||||
- (NSResponder *)firstResponder { return first_responder; }
|
- (NSResponder *)firstResponder { return first_responder; }
|
||||||
|
|
||||||
- (void)keyDown:(NSEvent *)theEvent // save the first responder
|
- (void) keyDown: (NSEvent*)theEvent
|
||||||
{ // so that the key up goes
|
{
|
||||||
original_responder = first_responder; // to it and not a possible
|
static NSEvent *inProgress = nil;
|
||||||
// new first responder
|
|
||||||
[first_responder keyDown:theEvent]; // Send the first responder
|
if (theEvent == inProgress)
|
||||||
} // the key down
|
{
|
||||||
|
/*
|
||||||
|
* There was a loop in the responser chain - nothin handled the event
|
||||||
|
* so we make a warning beep.
|
||||||
|
*/
|
||||||
|
inProgress = nil;
|
||||||
|
NSBeep();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Save the first responder so that the key up goes to it and not a
|
||||||
|
* possible new first responder.
|
||||||
|
* Save the event so we can detect a loop in the responder chain.
|
||||||
|
*/
|
||||||
|
original_responder = first_responder;
|
||||||
|
inProgress = theEvent;
|
||||||
|
[first_responder keyDown: theEvent];
|
||||||
|
inProgress = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL)makeFirstResponder:(NSResponder *)aResponder
|
- (BOOL)makeFirstResponder:(NSResponder *)aResponder
|
||||||
{
|
{
|
||||||
|
@ -725,8 +740,8 @@ NSApplication *theApp = [NSApplication sharedApplication];
|
||||||
|
|
||||||
if (![aResponder acceptsFirstResponder]) // does not accept status
|
if (![aResponder acceptsFirstResponder]) // does not accept status
|
||||||
return NO; // of first responder ret N
|
return NO; // of first responder ret N
|
||||||
// If there is a first responder tell it to
|
// If there is a first responder tell it to
|
||||||
// resign. Make change only if it replies Y
|
// resign. Make change only if it replies Y
|
||||||
if ((first_responder) && (![first_responder resignFirstResponder]))
|
if ((first_responder) && (![first_responder resignFirstResponder]))
|
||||||
return NO;
|
return NO;
|
||||||
// Make responder the first
|
// Make responder the first
|
||||||
|
@ -738,15 +753,15 @@ NSApplication *theApp = [NSApplication sharedApplication];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSPoint)mouseLocationOutsideOfEventStream // Return mouse location
|
- (NSPoint)mouseLocationOutsideOfEventStream // Return mouse location
|
||||||
{ // in reciever's base coord
|
{ // in reciever's base coord
|
||||||
return NSZeroPoint; // system, ignores event
|
return NSZeroPoint; // system, ignores event
|
||||||
} // loop status (backend)
|
} // loop status (backend)
|
||||||
|
|
||||||
- (NSEvent *)nextEventMatchingMask:(unsigned int)mask
|
- (NSEvent *)nextEventMatchingMask:(unsigned int)mask
|
||||||
{
|
{
|
||||||
return [[NSApplication sharedApplication] nextEventMatchingMask:mask
|
return [[NSApplication sharedApplication] nextEventMatchingMask:mask
|
||||||
untilDate:nil
|
untilDate:nil
|
||||||
inMode:NSEventTrackingRunLoopMode
|
inMode:NSEventTrackingRunLoopMode
|
||||||
dequeue:YES];
|
dequeue:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -755,9 +770,9 @@ NSApplication *theApp = [NSApplication sharedApplication];
|
||||||
inMode:(NSString *)mode
|
inMode:(NSString *)mode
|
||||||
dequeue:(BOOL)deqFlag
|
dequeue:(BOOL)deqFlag
|
||||||
{
|
{
|
||||||
return [[NSApplication sharedApplication] nextEventMatchingMask:mask
|
return [[NSApplication sharedApplication] nextEventMatchingMask:mask
|
||||||
untilDate:expiration
|
untilDate:expiration
|
||||||
inMode:mode
|
inMode:mode
|
||||||
dequeue:deqFlag];
|
dequeue:deqFlag];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -793,12 +808,12 @@ NSEvent *e;
|
||||||
{
|
{
|
||||||
id owner = [r owner];
|
id owner = [r owner];
|
||||||
e = [NSEvent enterExitEventWithType:NSMouseEntered
|
e = [NSEvent enterExitEventWithType:NSMouseEntered
|
||||||
location:[theEvent locationInWindow]
|
location:[theEvent locationInWindow]
|
||||||
modifierFlags:[theEvent modifierFlags]
|
modifierFlags:[theEvent modifierFlags]
|
||||||
timestamp:0
|
timestamp:0
|
||||||
windowNumber:[theEvent windowNumber]
|
windowNumber:[theEvent windowNumber]
|
||||||
context:NULL eventNumber:0
|
context:NULL eventNumber:0
|
||||||
trackingNumber:[r tag]
|
trackingNumber:[r tag]
|
||||||
userData:[r userData]];
|
userData:[r userData]];
|
||||||
// Send the event to the owner
|
// Send the event to the owner
|
||||||
if ([owner respondsToSelector:@selector(mouseEntered:)])
|
if ([owner respondsToSelector:@selector(mouseEntered:)])
|
||||||
|
@ -809,21 +824,21 @@ NSEvent *e;
|
||||||
{
|
{
|
||||||
id owner = [r owner];
|
id owner = [r owner];
|
||||||
e = [NSEvent enterExitEventWithType:NSMouseExited
|
e = [NSEvent enterExitEventWithType:NSMouseExited
|
||||||
location:[theEvent locationInWindow]
|
location:[theEvent locationInWindow]
|
||||||
modifierFlags:[theEvent modifierFlags]
|
modifierFlags:[theEvent modifierFlags]
|
||||||
timestamp:0
|
timestamp:0
|
||||||
windowNumber:[theEvent windowNumber]
|
windowNumber:[theEvent windowNumber]
|
||||||
context:NULL
|
context:NULL
|
||||||
eventNumber:0
|
eventNumber:0
|
||||||
trackingNumber:[r tag]
|
trackingNumber:[r tag]
|
||||||
userData:[r userData]];
|
userData:[r userData]];
|
||||||
// Send the event to the owner
|
// Send the event to the owner
|
||||||
if ([owner respondsToSelector:@selector(mouseExited:)])
|
if ([owner respondsToSelector:@selector(mouseExited:)])
|
||||||
[owner mouseExited:e];
|
[owner mouseExited:e];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
j = [sb count]; // Check tracking rectangles
|
j = [sb count]; // Check tracking rectangles
|
||||||
for (i = 0;i < j; ++i) // for the subviews
|
for (i = 0;i < j; ++i) // for the subviews
|
||||||
[self checkTrackingRectangles:[sb objectAtIndex:i] forEvent:theEvent];
|
[self checkTrackingRectangles:[sb objectAtIndex:i] forEvent:theEvent];
|
||||||
}
|
}
|
||||||
|
@ -848,12 +863,12 @@ NSRect rect;
|
||||||
|
|
||||||
lastPointConverted = [theView convertPoint:last_point fromView:nil];
|
lastPointConverted = [theView convertPoint:last_point fromView:nil];
|
||||||
locationConverted = [theView convertPoint:loc fromView:nil];
|
locationConverted = [theView convertPoint:loc fromView:nil];
|
||||||
|
|
||||||
rect = [r rectangle]; // Check mouse's last point
|
rect = [r rectangle]; // Check mouse's last point
|
||||||
last = [theView mouse:lastPointConverted inRect:rect];
|
last = [theView mouse:lastPointConverted inRect:rect];
|
||||||
now = [theView mouse:locationConverted inRect:rect];
|
now = [theView mouse:locationConverted inRect:rect];
|
||||||
// Mouse entered
|
// Mouse entered
|
||||||
if ((!last) && (now))
|
if ((!last) && (now))
|
||||||
{ // Post cursor update event
|
{ // Post cursor update event
|
||||||
e = [NSEvent enterExitEventWithType: NSCursorUpdate
|
e = [NSEvent enterExitEventWithType: NSCursorUpdate
|
||||||
location: loc
|
location: loc
|
||||||
|
@ -881,7 +896,7 @@ NSRect rect;
|
||||||
[self postEvent: e atStart: YES];
|
[self postEvent: e atStart: YES];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check cursor rectangles
|
// Check cursor rectangles
|
||||||
j = [sb count]; // for the subviews
|
j = [sb count]; // for the subviews
|
||||||
for (i = 0;i < j; ++i)
|
for (i = 0;i < j; ++i)
|
||||||
[self checkCursorRectangles:[sb objectAtIndex:i] forEvent:theEvent];
|
[self checkCursorRectangles:[sb objectAtIndex:i] forEvent:theEvent];
|
||||||
|
@ -898,12 +913,12 @@ NSView *v;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ([theEvent type])
|
switch ([theEvent type])
|
||||||
{
|
{
|
||||||
case NSLeftMouseDown: // Left mouse down
|
case NSLeftMouseDown: // Left mouse down
|
||||||
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];
|
||||||
|
@ -955,7 +970,7 @@ NSView *v;
|
||||||
case NSMouseEntered: // Mouse entered
|
case NSMouseEntered: // Mouse entered
|
||||||
case NSMouseExited: // Mouse exited
|
case NSMouseExited: // Mouse exited
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSKeyDown: // Key down
|
case NSKeyDown: // Key down
|
||||||
[self keyDown:theEvent];
|
[self keyDown:theEvent];
|
||||||
break;
|
break;
|
||||||
|
@ -1065,14 +1080,14 @@ id result = nil;
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)setFrameUsingName:(NSString *)name
|
- (BOOL)setFrameUsingName:(NSString *)name
|
||||||
{
|
{
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *)stringWithSavedFrame
|
- (NSString *)stringWithSavedFrame
|
||||||
{
|
{
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1275,7 +1290,7 @@ id result = nil;
|
||||||
minimum_size = [aDecoder decodeSize];
|
minimum_size = [aDecoder decodeSize];
|
||||||
maximum_size = [aDecoder decodeSize];
|
maximum_size = [aDecoder decodeSize];
|
||||||
miniaturized_image = [aDecoder decodeObject];
|
miniaturized_image = [aDecoder decodeObject];
|
||||||
[aDecoder decodeValueOfObjCType:@encode(NSBackingStoreType)
|
[aDecoder decodeValueOfObjCType:@encode(NSBackingStoreType)
|
||||||
at: &backing_type];
|
at: &backing_type];
|
||||||
[aDecoder decodeValueOfObjCType:@encode(int) at: &window_level];
|
[aDecoder decodeValueOfObjCType:@encode(int) at: &window_level];
|
||||||
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &is_one_shot];
|
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &is_one_shot];
|
||||||
|
@ -1319,7 +1334,7 @@ id result = nil;
|
||||||
- (void)performDeminiaturize:sender {}
|
- (void)performDeminiaturize:sender {}
|
||||||
- (void)performHide:sender {}
|
- (void)performHide:sender {}
|
||||||
- (void)performUnhide:sender {}
|
- (void)performUnhide:sender {}
|
||||||
|
|
||||||
- (void)initDefaults // Allow subclasses to init
|
- (void)initDefaults // Allow subclasses to init
|
||||||
{ // without the backend
|
{ // without the backend
|
||||||
first_responder = nil; // class attempting to
|
first_responder = nil; // class attempting to
|
||||||
|
@ -1357,7 +1372,7 @@ id result = nil;
|
||||||
- cleanInit
|
- cleanInit
|
||||||
{
|
{
|
||||||
[super init];
|
[super init];
|
||||||
|
|
||||||
[self initDefaults];
|
[self initDefaults];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue