1998-12-17 13:06:17 +00:00
|
|
|
|
/*
|
1996-05-30 20:03:15 +00:00
|
|
|
|
The window class
|
|
|
|
|
|
|
|
|
|
Copyright (C) 1996 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
|
|
Author: Scott Christley <scottc@net-community.com>
|
1999-06-11 04:46:12 +00:00
|
|
|
|
Venkat Ajjanagadde <venkat@ocbi.com>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
Date: 1996
|
1998-07-10 18:44:18 +00:00
|
|
|
|
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
|
|
|
|
Date: June 1998
|
1999-02-19 20:31:07 +00:00
|
|
|
|
Author: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
|
|
|
|
Date: December 1998
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
1999-06-11 04:46:12 +00:00
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
1996-05-30 20:03:15 +00:00
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
1996-10-18 17:14:13 +00:00
|
|
|
|
License along with this library; see the file COPYING.LIB.
|
|
|
|
|
If not, write to the Free Software Foundation,
|
|
|
|
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1998-12-17 13:06:17 +00:00
|
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1997-09-23 22:43:24 +00:00
|
|
|
|
#include <gnustep/gui/config.h>
|
1998-11-12 10:49:00 +00:00
|
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
|
#include <Foundation/NSString.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
|
#include <Foundation/NSCoder.h>
|
|
|
|
|
#include <Foundation/NSArray.h>
|
1999-05-07 11:06:37 +00:00
|
|
|
|
#include <Foundation/NSGeometry.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
|
#include <Foundation/NSNotification.h>
|
1997-10-09 22:55:31 +00:00
|
|
|
|
#include <Foundation/NSValue.h>
|
1997-12-04 01:58:57 +00:00
|
|
|
|
#include <Foundation/NSException.h>
|
1999-07-06 05:37:15 +00:00
|
|
|
|
#include <Foundation/NSSet.h>
|
|
|
|
|
#include <Foundation/NSLock.h>
|
|
|
|
|
#include <Foundation/NSUserDefaults.h>
|
1997-07-07 16:56:52 +00:00
|
|
|
|
|
1999-09-11 00:52:04 +00:00
|
|
|
|
#include <AppKit/NSDocument.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
|
#include <AppKit/NSWindow.h>
|
1999-09-11 00:52:04 +00:00
|
|
|
|
#include <AppKit/NSWindowController.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
|
#include <AppKit/NSApplication.h>
|
1999-11-29 06:12:34 +00:00
|
|
|
|
#include <AppKit/NSMenu.h>
|
1997-07-07 16:56:52 +00:00
|
|
|
|
#include <AppKit/NSImage.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
|
#include <AppKit/NSTextFieldCell.h>
|
|
|
|
|
#include <AppKit/NSTextField.h>
|
|
|
|
|
#include <AppKit/NSColor.h>
|
1998-12-09 01:26:37 +00:00
|
|
|
|
#include <AppKit/GSTrackingRect.h>
|
1997-02-18 00:29:25 +00:00
|
|
|
|
#include <AppKit/NSSliderCell.h>
|
|
|
|
|
#include <AppKit/NSScreen.h>
|
1999-05-07 20:08:51 +00:00
|
|
|
|
#include <AppKit/NSView.h>
|
1997-03-05 01:11:17 +00:00
|
|
|
|
#include <AppKit/NSCursor.h>
|
1999-06-09 08:54:08 +00:00
|
|
|
|
#include <AppKit/PSOperators.h>
|
1999-07-29 20:58:04 +00:00
|
|
|
|
#include <AppKit/NSDragging.h>
|
|
|
|
|
#include <AppKit/NSPasteboard.h>
|
1999-09-10 23:12:48 +00:00
|
|
|
|
#include <AppKit/NSHelpManager.h>
|
1999-10-21 18:08:50 +00:00
|
|
|
|
#include <AppKit/NSGraphicsContext.h>
|
2000-03-06 11:39:22 +00:00
|
|
|
|
#include <AppKit/NSGraphics.h>
|
1999-10-21 18:08:50 +00:00
|
|
|
|
#include <AppKit/GSWraps.h>
|
1998-11-25 17:16:48 +00:00
|
|
|
|
|
2000-03-10 21:48:52 +00:00
|
|
|
|
static float GSTitleBarHeight = 24.0;
|
|
|
|
|
static float GSResizeBarHeight = 11.0;
|
|
|
|
|
/*
|
|
|
|
|
PJB: This should be the same as in GSMenuBarHeight in NSMenuView
|
|
|
|
|
and the actual title bar height currently drawn by WindowMaker.
|
|
|
|
|
(We should do this ourselves).
|
|
|
|
|
I don't know how it's been computed for NSMenu, but I find the
|
|
|
|
|
title bar heigh to be 24 pixels.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
1999-07-29 20:58:04 +00:00
|
|
|
|
BOOL GSViewAcceptsDrag(NSView *v, id<NSDraggingInfo> dragInfo);
|
1998-11-25 17:16:48 +00:00
|
|
|
|
|
2000-03-06 11:39:22 +00:00
|
|
|
|
/*
|
|
|
|
|
* Catagory for internal methods (for use only within the
|
|
|
|
|
* NSWindow class itsself)
|
|
|
|
|
*/
|
|
|
|
|
@interface NSWindow (GNUstepPrivate)
|
|
|
|
|
- (void) _handleWindowNeedsDisplay: (id)bogus;
|
2000-03-08 21:26:11 +00:00
|
|
|
|
- (void) _lossOfKeyOrMainWindow;
|
2000-03-06 11:39:22 +00:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation NSWindow (GNUstepPrivate)
|
|
|
|
|
- (void) _handleWindowNeedsDisplay: (id)bogus
|
|
|
|
|
{
|
|
|
|
|
[self displayIfNeeded];
|
|
|
|
|
}
|
2000-03-08 21:26:11 +00:00
|
|
|
|
- (void) _lossOfKeyOrMainWindow
|
|
|
|
|
{
|
|
|
|
|
NSArray *windowList = GSAllWindows();
|
|
|
|
|
unsigned pos = [windowList indexOfObjectIdenticalTo: self];
|
|
|
|
|
unsigned c = [windowList count];
|
|
|
|
|
unsigned i;
|
|
|
|
|
NSWindow *w;
|
|
|
|
|
|
|
|
|
|
if ([self isKeyWindow])
|
|
|
|
|
{
|
|
|
|
|
[self resignKeyWindow];
|
|
|
|
|
i = pos + 1;
|
|
|
|
|
if (i == c)
|
|
|
|
|
{
|
|
|
|
|
i = 0;
|
|
|
|
|
}
|
|
|
|
|
while (i != pos)
|
|
|
|
|
{
|
|
|
|
|
w = [windowList objectAtIndex: i];
|
|
|
|
|
if ([w isVisible] && [w canBecomeKeyWindow])
|
|
|
|
|
{
|
|
|
|
|
[w makeKeyWindow];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
if (i == c)
|
|
|
|
|
{
|
|
|
|
|
i = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* if we didn't find a possible key window - use the app icon or,
|
|
|
|
|
* failing that, use the menu window.
|
|
|
|
|
*/
|
|
|
|
|
if (i == pos)
|
|
|
|
|
{
|
|
|
|
|
w = [NSApp iconWindow];
|
|
|
|
|
if (w == nil || [w isVisible] == NO)
|
|
|
|
|
{
|
|
|
|
|
w = [[NSApp mainMenu] window];
|
|
|
|
|
}
|
|
|
|
|
if (w != nil && [w isVisible] == YES)
|
|
|
|
|
{
|
|
|
|
|
[GSCurrentContext() DPSsetinputfocus: [w windowNumber]];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ([self isMainWindow])
|
|
|
|
|
{
|
|
|
|
|
NSWindow *w = [NSApp keyWindow];
|
|
|
|
|
|
|
|
|
|
[self resignMainWindow];
|
|
|
|
|
if (w != nil && [w canBecomeMainWindow])
|
|
|
|
|
{
|
|
|
|
|
[w makeMainWindow];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
i = pos + 1;
|
|
|
|
|
if (i == c)
|
|
|
|
|
{
|
|
|
|
|
i = 0;
|
|
|
|
|
}
|
|
|
|
|
while (i != pos)
|
|
|
|
|
{
|
|
|
|
|
w = [windowList objectAtIndex: i];
|
|
|
|
|
if ([w isVisible] && [w canBecomeMainWindow])
|
|
|
|
|
{
|
|
|
|
|
[w makeMainWindow];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
if (i == c)
|
|
|
|
|
{
|
|
|
|
|
i = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-03-06 11:39:22 +00:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-03-01 17:21:08 +00:00
|
|
|
|
@interface NSMiniWindow : NSWindow
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation NSMiniWindow
|
|
|
|
|
|
|
|
|
|
- (BOOL) canBecomeMainWindow
|
|
|
|
|
{
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) canBecomeKeyWindow
|
|
|
|
|
{
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-06 11:39:22 +00:00
|
|
|
|
- (void) _initDefaults
|
2000-03-01 17:21:08 +00:00
|
|
|
|
{
|
2000-03-06 11:39:22 +00:00
|
|
|
|
[super _initDefaults];
|
2000-03-01 17:21:08 +00:00
|
|
|
|
[self setExcludedFromWindowsMenu: YES];
|
|
|
|
|
[self setReleasedWhenClosed: NO];
|
|
|
|
|
window_level = NSDockWindowLevel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@interface NSMiniWindowView : NSView
|
|
|
|
|
{
|
|
|
|
|
NSCell *imageCell;
|
|
|
|
|
NSCell *titleCell;
|
|
|
|
|
}
|
|
|
|
|
- (void) setImage: (NSImage*)anImage;
|
|
|
|
|
- (void) setTitle: (NSString*)aString;
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
static NSCell* tileCell = nil;
|
|
|
|
|
|
|
|
|
|
@implementation NSMiniWindowView
|
|
|
|
|
|
|
|
|
|
+ (void) initialize
|
|
|
|
|
{
|
|
|
|
|
NSImage *tileImage = [NSImage imageNamed: @"common_Tile"];
|
|
|
|
|
|
|
|
|
|
tileCell = [[NSCell alloc] initImageCell: tileImage];
|
|
|
|
|
[tileCell setBordered: NO];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) acceptsFirstMouse: (NSEvent*)theEvent
|
|
|
|
|
{
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
|
{
|
|
|
|
|
TEST_RELEASE(imageCell);
|
|
|
|
|
TEST_RELEASE(titleCell);
|
|
|
|
|
[super dealloc];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) drawRect: (NSRect)rect
|
|
|
|
|
{
|
|
|
|
|
[tileCell drawWithFrame: NSMakeRect(0,0,64,64) inView: self];
|
|
|
|
|
[imageCell drawWithFrame: NSMakeRect(8,8,48,48) inView: self];
|
|
|
|
|
[titleCell drawWithFrame: NSMakeRect(0,56,64,8) inView: self];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) mouseDown: (NSEvent*)theEvent
|
|
|
|
|
{
|
|
|
|
|
if ([theEvent clickCount] >= 2)
|
|
|
|
|
{
|
|
|
|
|
NSWindow *w = [_window counterpart];
|
|
|
|
|
|
|
|
|
|
[_window orderOut: self];
|
|
|
|
|
[w orderFront: self];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NSPoint lastLocation;
|
|
|
|
|
NSPoint location;
|
|
|
|
|
unsigned eventMask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
|
|
|
|
| NSPeriodicMask | NSRightMouseUpMask;
|
|
|
|
|
NSDate *theDistantFuture = [NSDate distantFuture];
|
|
|
|
|
BOOL done = NO;
|
|
|
|
|
|
|
|
|
|
lastLocation = [theEvent locationInWindow];
|
|
|
|
|
[NSEvent startPeriodicEventsAfterDelay: 0.02 withPeriod: 0.02];
|
|
|
|
|
|
|
|
|
|
while (!done)
|
|
|
|
|
{
|
|
|
|
|
theEvent = [NSApp nextEventMatchingMask: eventMask
|
|
|
|
|
untilDate: theDistantFuture
|
|
|
|
|
inMode: NSEventTrackingRunLoopMode
|
|
|
|
|
dequeue: YES];
|
|
|
|
|
|
|
|
|
|
switch ([theEvent type])
|
|
|
|
|
{
|
|
|
|
|
case NSRightMouseUp:
|
|
|
|
|
case NSLeftMouseUp:
|
|
|
|
|
/* right mouse up or left mouse up means we're done */
|
|
|
|
|
done = YES;
|
|
|
|
|
break;
|
|
|
|
|
case NSPeriodic:
|
|
|
|
|
location = [_window mouseLocationOutsideOfEventStream];
|
|
|
|
|
if (NSEqualPoints(location, lastLocation) == NO)
|
|
|
|
|
{
|
|
|
|
|
NSPoint origin = [_window frame].origin;
|
|
|
|
|
|
|
|
|
|
origin.x += (location.x - lastLocation.x);
|
|
|
|
|
origin.y += (location.y - lastLocation.y);
|
|
|
|
|
[_window setFrameOrigin: origin];
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
[NSEvent stopPeriodicEvents];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setImage: (NSImage*)anImage
|
|
|
|
|
{
|
|
|
|
|
if (imageCell == nil)
|
|
|
|
|
{
|
|
|
|
|
imageCell = [[NSCell alloc] initImageCell: anImage];
|
|
|
|
|
[imageCell setBordered: NO];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[imageCell setImage: anImage];
|
|
|
|
|
}
|
|
|
|
|
if (_window != nil)
|
|
|
|
|
{
|
|
|
|
|
[self lockFocus];
|
|
|
|
|
[self drawRect: [self bounds]];
|
|
|
|
|
[self unlockFocus];
|
|
|
|
|
[_window flushWindow];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setTitle: (NSString*)aString
|
|
|
|
|
{
|
|
|
|
|
if (titleCell == nil)
|
|
|
|
|
{
|
|
|
|
|
titleCell = [[NSCell alloc] initTextCell: aString];
|
|
|
|
|
[titleCell setBordered: NO];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[titleCell setStringValue: aString];
|
|
|
|
|
}
|
|
|
|
|
if (_window != nil)
|
|
|
|
|
{
|
|
|
|
|
[self lockFocus];
|
|
|
|
|
[self drawRect: [self bounds]];
|
|
|
|
|
[self unlockFocus];
|
|
|
|
|
[_window flushWindow];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
|
@interface GSWindowView : NSView
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation GSWindowView
|
|
|
|
|
|
|
|
|
|
- (BOOL) isOpaque
|
|
|
|
|
{
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) drawRect: (NSRect)rect
|
|
|
|
|
{
|
|
|
|
|
NSColor *c = [[self window] backgroundColor];
|
|
|
|
|
|
|
|
|
|
[c set];
|
|
|
|
|
NSRectFill(rect);
|
|
|
|
|
}
|
|
|
|
|
|
1999-07-18 15:22:53 +00:00
|
|
|
|
/*
|
1999-10-23 22:24:43 +00:00
|
|
|
|
* Special setFrame: implementation - a minimal autoresize mechanism
|
1999-07-18 15:22:53 +00:00
|
|
|
|
*/
|
|
|
|
|
- (void) setFrame: (NSRect)frameRect
|
|
|
|
|
{
|
2000-01-10 02:09:33 +00:00
|
|
|
|
NSSize oldSize = _frame.size;
|
|
|
|
|
NSView *cv = [_window contentView];
|
1999-10-23 22:24:43 +00:00
|
|
|
|
|
2000-01-10 02:09:33 +00:00
|
|
|
|
_autoresizes_subviews = NO;
|
1999-07-18 15:22:53 +00:00
|
|
|
|
[super setFrame: frameRect];
|
1999-10-23 22:24:43 +00:00
|
|
|
|
// Safety Check.
|
|
|
|
|
[cv setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable)];
|
|
|
|
|
[cv resizeWithOldSuperviewSize: oldSize];
|
1999-07-18 15:22:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
|
- (Class) classForCoder: (NSCoder*)aCoder
|
|
|
|
|
{
|
|
|
|
|
if ([self class] == [GSWindowView class])
|
|
|
|
|
return [super class];
|
|
|
|
|
return [self class];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*****************************************************************************
|
|
|
|
|
*
|
|
|
|
|
* NSWindow
|
|
|
|
|
*
|
|
|
|
|
*****************************************************************************/
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1998-11-12 10:49:00 +00:00
|
|
|
|
@implementation NSWindow
|
1997-10-09 22:55:31 +00:00
|
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
|
typedef struct NSView_struct
|
|
|
|
|
{
|
|
|
|
|
@defs(NSView)
|
|
|
|
|
} *NSViewPtr;
|
|
|
|
|
|
|
|
|
|
|
1999-05-07 11:06:37 +00:00
|
|
|
|
/*
|
|
|
|
|
* Class variables
|
|
|
|
|
*/
|
1999-05-07 11:09:07 +00:00
|
|
|
|
static SEL ccSel = @selector(_checkCursorRectangles:forEvent:);
|
1999-05-07 11:06:37 +00:00
|
|
|
|
static SEL ctSel = @selector(_checkTrackingRectangles:forEvent:);
|
|
|
|
|
static IMP ccImp;
|
|
|
|
|
static IMP ctImp;
|
1999-05-14 14:50:05 +00:00
|
|
|
|
static Class responderClass;
|
1999-10-04 06:18:17 +00:00
|
|
|
|
static Class viewClass;
|
1999-07-06 05:37:15 +00:00
|
|
|
|
static NSMutableSet *autosaveNames;
|
|
|
|
|
static NSRecursiveLock *windowsLock;
|
1999-10-21 18:08:50 +00:00
|
|
|
|
static NSMapTable* windowmaps = NULL;
|
1999-05-07 11:06:37 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Class methods
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
+ (void) initialize
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
|
if (self == [NSWindow class])
|
|
|
|
|
{
|
|
|
|
|
NSDebugLog(@"Initialize NSWindow class\n");
|
|
|
|
|
[self setVersion: 2];
|
1999-05-07 11:06:37 +00:00
|
|
|
|
ccImp = [self instanceMethodForSelector: ccSel];
|
|
|
|
|
ctImp = [self instanceMethodForSelector: ctSel];
|
1999-05-14 14:50:05 +00:00
|
|
|
|
responderClass = [NSResponder class];
|
1999-10-04 06:18:17 +00:00
|
|
|
|
viewClass = [NSView class];
|
1999-07-06 05:37:15 +00:00
|
|
|
|
autosaveNames = [NSMutableSet new];
|
|
|
|
|
windowsLock = [NSRecursiveLock new];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-07-06 05:37:15 +00:00
|
|
|
|
+ (void) removeFrameUsingName: (NSString*)name
|
1999-06-11 04:46:12 +00:00
|
|
|
|
{
|
1999-07-06 05:37:15 +00:00
|
|
|
|
if (name != nil)
|
|
|
|
|
{
|
|
|
|
|
NSString *key;
|
|
|
|
|
|
1999-11-16 09:48:54 +00:00
|
|
|
|
key = [NSString stringWithFormat: @"NSWindow Frame %@", name];
|
1999-07-06 05:37:15 +00:00
|
|
|
|
[windowsLock lock];
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] removeObjectForKey: key];
|
|
|
|
|
[windowsLock unlock];
|
|
|
|
|
}
|
1999-06-11 04:46:12 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
+ (NSRect) contentRectForFrameRect: (NSRect)aRect
|
1999-06-11 04:46:12 +00:00
|
|
|
|
styleMask: (unsigned int)aStyle
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2000-03-07 12:00:00 +00:00
|
|
|
|
NSGraphicsContext *context = GSCurrentContext();
|
|
|
|
|
float t, b, l, r;
|
|
|
|
|
|
|
|
|
|
DPSstyleoffsets(context, &l, &r, &t, &b, aStyle);
|
|
|
|
|
aRect.size.width -= (l + r);
|
|
|
|
|
aRect.size.height -= (t + b);
|
|
|
|
|
aRect.origin.x += l;
|
|
|
|
|
aRect.origin.y += b;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return aRect;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
+ (NSRect) frameRectForContentRect: (NSRect)aRect
|
1999-06-11 04:46:12 +00:00
|
|
|
|
styleMask: (unsigned int)aStyle
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2000-03-07 12:00:00 +00:00
|
|
|
|
NSGraphicsContext *context = GSCurrentContext();
|
|
|
|
|
float t, b, l, r;
|
|
|
|
|
|
|
|
|
|
DPSstyleoffsets(context, &l, &r, &t, &b, aStyle);
|
|
|
|
|
aRect.size.width += (l + r);
|
|
|
|
|
aRect.size.height += (t + b);
|
|
|
|
|
aRect.origin.x -= l;
|
|
|
|
|
aRect.origin.y -= b;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return aRect;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
+ (NSRect) minFrameWidthWithTitle: (NSString*)aTitle
|
1999-06-11 04:46:12 +00:00
|
|
|
|
styleMask: (unsigned int)aStyle
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2000-03-07 12:00:00 +00:00
|
|
|
|
NSGraphicsContext *context = GSCurrentContext();
|
|
|
|
|
float t, b, l, r;
|
|
|
|
|
NSRect f = NSZeroRect;
|
|
|
|
|
|
|
|
|
|
DPSstyleoffsets(context, &l, &r, &t, &b, aStyle);
|
|
|
|
|
f.size.width = l + r;
|
|
|
|
|
f.size.height = t + b;
|
|
|
|
|
/*
|
|
|
|
|
* Assume that the width of the area needed for a button is equal to
|
|
|
|
|
* the height of the title bar.
|
|
|
|
|
*/
|
|
|
|
|
if (aStyle & NSClosableWindowMask)
|
|
|
|
|
f.size.width += t;
|
|
|
|
|
if (aStyle & NSMiniaturizableWindowMask)
|
|
|
|
|
f.size.width += t;
|
|
|
|
|
/*
|
|
|
|
|
* FIXME - title width has to be better determined than this.
|
|
|
|
|
* need to get correct values from font.
|
|
|
|
|
*/
|
|
|
|
|
f.size.width += [aTitle length] * 10;
|
|
|
|
|
return f;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/* default Screen and window depth */
|
|
|
|
|
+ (NSWindowDepth) defaultDepthLimit
|
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
// FIXME: This should come from the server
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return 8;
|
1997-10-09 22:55:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
+ (void)menuChanged: (NSMenu*)aMenu
|
2000-03-04 07:55:42 +00:00
|
|
|
|
{
|
|
|
|
|
// FIXME: This method is for MS Windows only, does nothing
|
|
|
|
|
// on other window systems
|
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Instance methods
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (id) init
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
|
int style;
|
|
|
|
|
|
|
|
|
|
NSDebugLog(@"NSWindow -init\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
style = NSTitledWindowMask | NSClosableWindowMask
|
|
|
|
|
| NSMiniaturizableWindowMask | NSResizableWindowMask;
|
1998-11-03 21:04:55 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return [self initWithContentRect: NSZeroRect
|
|
|
|
|
styleMask: style
|
|
|
|
|
backing: NSBackingStoreBuffered
|
|
|
|
|
defer: NO];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) dealloc
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-11-22 07:31:01 +00:00
|
|
|
|
NSGraphicsContext *context = GSCurrentContext();
|
|
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
2000-02-21 15:33:30 +00:00
|
|
|
|
[[NSRunLoop currentRunLoop]
|
|
|
|
|
cancelPerformSelector: @selector(_handleWindowNeedsDisplay:)
|
|
|
|
|
target: self
|
|
|
|
|
argument: nil];
|
2000-02-25 17:43:32 +00:00
|
|
|
|
[NSApp removeWindowsItem: self];
|
1999-11-22 07:31:01 +00:00
|
|
|
|
|
1999-07-06 16:19:03 +00:00
|
|
|
|
[self setFrameAutosaveName: nil];
|
2000-03-01 17:21:08 +00:00
|
|
|
|
if (_counterpart != 0 && (style_mask & NSMiniWindowMask) == 0)
|
|
|
|
|
{
|
|
|
|
|
NSWindow *mini = [NSApp windowWithWindowNumber: _counterpart];
|
|
|
|
|
|
|
|
|
|
_counterpart = 0;
|
|
|
|
|
RELEASE(mini);
|
|
|
|
|
}
|
1999-12-08 15:01:52 +00:00
|
|
|
|
TEST_RELEASE(_wv);
|
1999-06-01 17:05:57 +00:00
|
|
|
|
TEST_RELEASE(_fieldEditor);
|
|
|
|
|
TEST_RELEASE(background_color);
|
|
|
|
|
TEST_RELEASE(represented_filename);
|
|
|
|
|
TEST_RELEASE(miniaturized_title);
|
|
|
|
|
TEST_RELEASE(miniaturized_image);
|
|
|
|
|
TEST_RELEASE(window_title);
|
|
|
|
|
TEST_RELEASE(rectsBeingDrawn);
|
1999-10-04 06:18:17 +00:00
|
|
|
|
TEST_RELEASE(_initial_first_responder);
|
|
|
|
|
|
1999-06-15 09:23:39 +00:00
|
|
|
|
/*
|
|
|
|
|
* FIXME This should not be necessary - the views should have removed
|
|
|
|
|
* their drag types, so we should already have been removed.
|
|
|
|
|
*/
|
2000-01-10 02:09:33 +00:00
|
|
|
|
[context _removeDragTypes: nil fromWindow: window_num];
|
1997-07-07 16:56:52 +00:00
|
|
|
|
|
1999-10-27 03:22:11 +00:00
|
|
|
|
if (gstate)
|
|
|
|
|
DPSundefineuserobject(context, gstate);
|
|
|
|
|
DPStermwindow(context, window_num);
|
1999-10-21 18:08:50 +00:00
|
|
|
|
NSMapRemove(windowmaps, (void*)window_num);
|
1999-03-23 22:35:21 +00:00
|
|
|
|
[super dealloc];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Initializing and getting a new NSWindow object
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (id) initWithContentRect: (NSRect)contentRect
|
|
|
|
|
styleMask: (unsigned int)aStyle
|
|
|
|
|
backing: (NSBackingStoreType)bufferingType
|
|
|
|
|
defer: (BOOL)flag
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
|
NSDebugLog(@"NSWindow -initWithContentRect: \n");
|
1998-11-03 21:04:55 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return [self initWithContentRect: contentRect
|
|
|
|
|
styleMask: aStyle
|
|
|
|
|
backing: bufferingType
|
|
|
|
|
defer: flag
|
|
|
|
|
screen: nil];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (id) initWithContentRect: (NSRect)contentRect
|
|
|
|
|
styleMask: (unsigned int)aStyle
|
|
|
|
|
backing: (NSBackingStoreType)bufferingType
|
|
|
|
|
defer: (BOOL)flag
|
1999-06-11 04:46:12 +00:00
|
|
|
|
screen: (NSScreen*)aScreen
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-11-22 07:31:01 +00:00
|
|
|
|
NSGraphicsContext *context = GSCurrentContext();
|
|
|
|
|
NSRect r = [[NSScreen mainScreen] frame];
|
|
|
|
|
NSRect cframe;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
NSDebugLog(@"NSWindow default initializer\n");
|
1999-06-09 08:54:08 +00:00
|
|
|
|
if (!NSApp)
|
1999-03-23 22:35:21 +00:00
|
|
|
|
NSLog(@"No application!\n");
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
NSDebugLog(@"NSWindow start of init\n");
|
1999-10-21 18:08:50 +00:00
|
|
|
|
if (!windowmaps)
|
|
|
|
|
windowmaps = NSCreateMapTable(NSIntMapKeyCallBacks,
|
|
|
|
|
NSNonRetainedObjectMapValueCallBacks, 20);
|
1999-06-11 04:46:12 +00:00
|
|
|
|
|
|
|
|
|
/* Initialize attributes and flags */
|
2000-03-06 21:10:08 +00:00
|
|
|
|
[super init];
|
|
|
|
|
[self _initDefaults];
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
backing_type = bufferingType;
|
|
|
|
|
style_mask = aStyle;
|
1999-06-11 04:46:12 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
frame = [NSWindow frameRectForContentRect: contentRect styleMask: aStyle];
|
2000-03-07 12:00:00 +00:00
|
|
|
|
minimum_size = NSMakeSize(frame.size.width - contentRect.size.width + 1,
|
|
|
|
|
frame.size.height - contentRect.size.height + 1);
|
1999-03-23 22:35:21 +00:00
|
|
|
|
maximum_size = r.size;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
[self setNextResponder: NSApp];
|
|
|
|
|
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.cursor_rects_enabled = YES;
|
|
|
|
|
_f.cursor_rects_valid = NO;
|
1996-10-03 18:45:41 +00:00
|
|
|
|
|
1999-12-08 15:01:52 +00:00
|
|
|
|
/* Create the window view */
|
|
|
|
|
cframe.origin = NSZeroPoint;
|
2000-03-07 12:00:00 +00:00
|
|
|
|
cframe.size = contentRect.size;
|
1999-12-08 15:01:52 +00:00
|
|
|
|
_wv = [[GSWindowView allocWithZone: [self zone]] initWithFrame: cframe];
|
|
|
|
|
[_wv viewWillMoveToWindow: self];
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/* Create the content view */
|
|
|
|
|
cframe.origin = NSZeroPoint;
|
2000-03-07 12:00:00 +00:00
|
|
|
|
cframe.size = contentRect.size;
|
1999-06-01 17:05:57 +00:00
|
|
|
|
[self setContentView: AUTORELEASE([[NSView alloc] initWithFrame: cframe])];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-05-02 01:34:06 +00:00
|
|
|
|
/* rectBeingDrawn is variable used to optimize flushing the backing store.
|
1999-10-21 18:08:50 +00:00
|
|
|
|
It is set by NSGraphicsContext during a lockFocus to tell NSWindow what
|
1999-05-02 01:34:06 +00:00
|
|
|
|
part a view is drawing in, so NSWindow only has to flush that portion */
|
1999-12-16 04:53:50 +00:00
|
|
|
|
rectsBeingDrawn = RETAIN([NSMutableArray arrayWithCapacity: 10]);
|
1998-12-16 15:21:55 +00:00
|
|
|
|
|
2000-03-04 07:55:42 +00:00
|
|
|
|
// FIXME: If flag is YES, the creation of the window should be defered
|
1999-10-21 18:08:50 +00:00
|
|
|
|
DPSwindow(context, NSMinX(contentRect), NSMinY(contentRect),
|
1999-12-16 04:53:50 +00:00
|
|
|
|
NSWidth(contentRect), NSHeight(contentRect),
|
1999-10-21 18:08:50 +00:00
|
|
|
|
bufferingType, &window_num);
|
|
|
|
|
DPSstylewindow(context, aStyle, window_num);
|
|
|
|
|
DPSsetwindowlevel(context, [self level], window_num);
|
|
|
|
|
|
|
|
|
|
// Set window in new gstate
|
|
|
|
|
DPSgsave(context);
|
|
|
|
|
DPSwindowdevice(context, window_num);
|
|
|
|
|
DPSgstate(context);
|
|
|
|
|
gstate = GSWDefineAsUserObj(context);
|
|
|
|
|
DPSgrestore(context);
|
|
|
|
|
|
|
|
|
|
NSMapInsert (windowmaps, (void*)window_num, self);
|
1999-10-23 02:48:20 +00:00
|
|
|
|
|
1999-10-21 18:08:50 +00:00
|
|
|
|
NSDebugLog(@"NSWindow end of init\n");
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return self;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Accessing the content view
|
|
|
|
|
*/
|
1999-05-04 13:17:26 +00:00
|
|
|
|
- (id) contentView
|
|
|
|
|
{
|
|
|
|
|
return content_view;
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) setContentView: (NSView*)aView
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-12-08 15:01:52 +00:00
|
|
|
|
if (aView == nil)
|
1999-01-09 21:43:09 +00:00
|
|
|
|
{
|
1999-12-08 15:01:52 +00:00
|
|
|
|
aView = AUTORELEASE([[NSView alloc] initWithFrame: frame]);
|
1999-01-09 21:43:09 +00:00
|
|
|
|
}
|
1999-12-08 15:01:52 +00:00
|
|
|
|
if (content_view != nil)
|
|
|
|
|
{
|
|
|
|
|
[content_view removeFromSuperview];
|
|
|
|
|
}
|
|
|
|
|
content_view = aView;
|
2000-02-19 00:40:47 +00:00
|
|
|
|
[content_view setAutoresizingMask: (NSViewWidthSizable
|
|
|
|
|
| NSViewHeightSizable)];
|
|
|
|
|
[_wv addSubview: content_view];
|
|
|
|
|
[content_view resizeWithOldSuperviewSize: [content_view frame].size];
|
|
|
|
|
[content_view setFrameOrigin: [_wv bounds].origin];
|
|
|
|
|
|
1999-12-08 15:01:52 +00:00
|
|
|
|
NSAssert1 ([[_wv subviews] count] == 1,
|
|
|
|
|
@"window's view has %d subviews!", [[_wv subviews] count]);
|
1999-06-11 04:46:12 +00:00
|
|
|
|
|
|
|
|
|
[content_view setNextResponder: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Window graphics
|
|
|
|
|
*/
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSColor*) backgroundColor
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
|
|
|
|
return background_color;
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSString*) representedFilename
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
|
|
|
|
return represented_filename;
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) setBackgroundColor: (NSColor*)color
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
|
ASSIGN(background_color, color);
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-12-17 13:06:17 +00:00
|
|
|
|
- (void) setRepresentedFilename: (NSString*)aString
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1998-12-17 13:06:17 +00:00
|
|
|
|
ASSIGN(represented_filename, aString);
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-12-17 13:06:17 +00:00
|
|
|
|
- (void) setTitle: (NSString*)aString
|
|
|
|
|
{
|
1999-12-03 11:32:39 +00:00
|
|
|
|
if ([window_title isEqual: aString] == NO)
|
|
|
|
|
{
|
|
|
|
|
ASSIGN(window_title, aString);
|
|
|
|
|
[self setMiniwindowTitle: aString];
|
|
|
|
|
DPStitlewindow(GSCurrentContext(), [aString cString], window_num);
|
1999-12-08 15:01:52 +00:00
|
|
|
|
if (_f.menu_exclude == NO && _f.has_opened == YES)
|
1999-12-03 11:32:39 +00:00
|
|
|
|
{
|
|
|
|
|
[NSApp changeWindowsItem: self
|
|
|
|
|
title: aString
|
|
|
|
|
filename: NO];
|
|
|
|
|
}
|
|
|
|
|
}
|
1998-12-17 13:06:17 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1998-12-17 13:06:17 +00:00
|
|
|
|
- (void) setTitleWithRepresentedFilename: (NSString*)aString
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1998-12-17 13:06:17 +00:00
|
|
|
|
[self setRepresentedFilename: aString];
|
1999-12-03 11:32:39 +00:00
|
|
|
|
aString = [NSString stringWithFormat:
|
|
|
|
|
@"%@ -- %@", [aString lastPathComponent],
|
|
|
|
|
[aString stringByDeletingLastPathComponent]];
|
|
|
|
|
if ([window_title isEqual: aString] == NO)
|
|
|
|
|
{
|
|
|
|
|
ASSIGN(window_title, aString);
|
|
|
|
|
[self setMiniwindowTitle: aString];
|
|
|
|
|
DPStitlewindow(GSCurrentContext(), [aString cString], window_num);
|
1999-12-08 15:01:52 +00:00
|
|
|
|
if (_f.menu_exclude == NO && _f.has_opened == YES)
|
1999-12-03 11:32:39 +00:00
|
|
|
|
{
|
|
|
|
|
[NSApp changeWindowsItem: self
|
|
|
|
|
title: aString
|
|
|
|
|
filename: YES];
|
|
|
|
|
}
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (unsigned int) styleMask
|
|
|
|
|
{
|
|
|
|
|
return style_mask;
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSString*) title
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
|
|
|
|
return window_title;
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Window device attributes
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (NSBackingStoreType) backingType
|
|
|
|
|
{
|
|
|
|
|
return backing_type;
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSDictionary*) deviceDescription
|
1998-12-17 13:06:17 +00:00
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
return [[self screen] deviceDescription];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (int) gState
|
|
|
|
|
{
|
1999-05-04 13:17:26 +00:00
|
|
|
|
return gstate;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) isOneShot
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
return _f.is_one_shot;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setBackingType: (NSBackingStoreType)type
|
|
|
|
|
{
|
|
|
|
|
backing_type = type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setOneShot: (BOOL)flag
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.is_one_shot = flag;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (int) windowNumber
|
|
|
|
|
{
|
|
|
|
|
return window_num;
|
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* The miniwindow
|
|
|
|
|
*/
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSImage*) miniwindowImage
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
|
|
|
|
return miniaturized_image;
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSString*) miniwindowTitle
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
|
|
|
|
return miniaturized_title;
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) setMiniwindowImage: (NSImage*)image
|
1996-10-03 18:45:41 +00:00
|
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
|
ASSIGN(miniaturized_image, image);
|
2000-03-01 17:21:08 +00:00
|
|
|
|
if (_counterpart != 0 && (style_mask & NSMiniWindowMask) == 0)
|
|
|
|
|
{
|
|
|
|
|
NSMiniWindow *mini = [NSApp windowWithWindowNumber: _counterpart];
|
|
|
|
|
id v = [mini contentView];
|
|
|
|
|
|
|
|
|
|
if ([v respondsToSelector: @selector(setImage:)])
|
|
|
|
|
{
|
|
|
|
|
[v setImage: [self miniwindowImage]];
|
|
|
|
|
}
|
|
|
|
|
}
|
1996-10-03 18:45:41 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1998-12-17 13:06:17 +00:00
|
|
|
|
- (void) setMiniwindowTitle: (NSString*)title
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1998-12-17 13:06:17 +00:00
|
|
|
|
ASSIGN(miniaturized_title, title);
|
2000-03-01 17:21:08 +00:00
|
|
|
|
if (_counterpart != 0 && (style_mask & NSMiniWindowMask) == 0)
|
|
|
|
|
{
|
|
|
|
|
NSMiniWindow *mini = [NSApp windowWithWindowNumber: _counterpart];
|
|
|
|
|
id v = [mini contentView];
|
|
|
|
|
|
|
|
|
|
if ([v respondsToSelector: @selector(setTitle:)])
|
|
|
|
|
{
|
|
|
|
|
[v setTitle: [self miniwindowTitle]];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSWindow*) counterpart
|
|
|
|
|
{
|
|
|
|
|
if (_counterpart == 0)
|
|
|
|
|
return nil;
|
|
|
|
|
return [NSApp windowWithWindowNumber: _counterpart];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* The field editor
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) endEditingFor: (id)anObject
|
1998-11-12 10:49:00 +00:00
|
|
|
|
{
|
1999-12-16 04:53:50 +00:00
|
|
|
|
NSText *t = [self fieldEditor: NO
|
1999-11-14 03:16:39 +00:00
|
|
|
|
forObject: anObject];
|
|
|
|
|
|
|
|
|
|
if (t && (first_responder == t))
|
|
|
|
|
{
|
1999-12-16 04:53:50 +00:00
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
|
postNotificationName: NSTextDidEndEditingNotification
|
1999-11-14 03:16:39 +00:00
|
|
|
|
object: t];
|
|
|
|
|
[t setText: @""];
|
|
|
|
|
[t setDelegate: nil];
|
|
|
|
|
[t removeFromSuperview];
|
|
|
|
|
first_responder = self;
|
|
|
|
|
[first_responder becomeFirstResponder];
|
|
|
|
|
}
|
1998-11-12 10:49:00 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSText*) fieldEditor: (BOOL)createFlag forObject: (id)anObject
|
1999-06-01 17:05:57 +00:00
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
NSText *edit;
|
1999-06-01 17:05:57 +00:00
|
|
|
|
/* ask delegate if it can provide a field editor */
|
2000-03-04 07:55:42 +00:00
|
|
|
|
if ((_delegate != anObject) &&
|
|
|
|
|
[_delegate respondsToSelector:
|
|
|
|
|
@selector(windowWillReturnFieldEditor:toObject:)] &&
|
|
|
|
|
(edit = [_delegate windowWillReturnFieldEditor: self toObject: anObject]) != nil)
|
|
|
|
|
return edit;
|
|
|
|
|
|
1999-06-01 17:05:57 +00:00
|
|
|
|
/*
|
|
|
|
|
* Each window has a global text field editor, if it doesn't exist create it
|
|
|
|
|
* if create flag is set
|
|
|
|
|
*/
|
|
|
|
|
if (!_fieldEditor && createFlag)
|
|
|
|
|
{
|
|
|
|
|
_fieldEditor = [NSText new];
|
|
|
|
|
[_fieldEditor setFieldEditor: YES];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
* NSWindow.m renmae captureMouse: to _captureMouse: (designate as non OS),
various methods add fieldEditor support.
* GSContext.m/GSContext.h revert to previous code as solution discussed
with Adam Fedor regarding backends had problems I had not forseen.
* NSBrowserCell.h/.m specify text subcell as an NSCell, eliminate image
cell, copyWithZone: optimize and eliminate use of ASSIGN (fixes serious
dealloc bug), highlight: eliminate method (fixes dup display bug).
* NSButtonCell.m copyWithZone: optimize and eliminate use of ASSIGN
* NSStringDrawing.h/.m remove unimplemented draw methods from Category
(these are backend specific, can't be defined twice and are already
implemented in xraw).
* NSApplication.h redefine initialize_gnustep_backend () per Adam's
redefinition in the backend.
* Functions.m/.h remove initialize_gnustep_backend()
* NSCell.m preliminary implementation of fieldEditor mechanism,
copyWithZone: optimize and eliminate use of ASSIGN
* NSControl.m rename cell class global to _NSCONTROL_CELL_CLASS
* NSMatrix.m implement NSControl's updateCell: to prevent unecessary
matrix drawing if possible.
* NSView.m -resizeWithOldSuperviewSize reverted code to my own once more
(fewer lines and no if/else logic), changed code to use view frame instead
of bounds per 3.3/4.2 docs, optimize to avoid floating point math and scale
adjustment unless view has been scaled.
* NSScrollView.m define as externs various PS* functions for use in
drawing, polish drawing, move all backend code to front.
* Tools/dummy.m define dummy PS* functions employed in gui.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3454 72102866-910b-0410-8b05-ffd578937521
1998-12-14 09:54:38 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return _fieldEditor;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-09-11 00:52:04 +00:00
|
|
|
|
/*
|
|
|
|
|
* Window controller
|
|
|
|
|
*/
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) setWindowController: (NSWindowController*)windowController
|
1999-09-11 00:52:04 +00:00
|
|
|
|
{
|
|
|
|
|
ASSIGN(_windowController, windowController);
|
|
|
|
|
}
|
1999-12-16 04:53:50 +00:00
|
|
|
|
|
1999-11-22 12:58:14 +00:00
|
|
|
|
- (id) windowController
|
1999-12-16 04:53:50 +00:00
|
|
|
|
{
|
1999-09-11 00:52:04 +00:00
|
|
|
|
return _windowController;
|
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Window status and ordering
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) becomeKeyWindow
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-11-22 15:03:41 +00:00
|
|
|
|
if (_f.is_key == NO)
|
|
|
|
|
{
|
|
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
1997-03-05 01:11:17 +00:00
|
|
|
|
|
2000-03-04 07:55:42 +00:00
|
|
|
|
[first_responder becomeFirstResponder];
|
2000-03-08 21:26:11 +00:00
|
|
|
|
if ((first_responder != self)
|
|
|
|
|
&& [first_responder respondsToSelector: @selector(becomeKeyWindow)])
|
2000-03-04 07:55:42 +00:00
|
|
|
|
[first_responder becomeKeyWindow];
|
|
|
|
|
|
1999-11-22 15:03:41 +00:00
|
|
|
|
_f.is_key = YES;
|
2000-03-06 21:10:08 +00:00
|
|
|
|
DPSsetinputstate(GSCurrentContext(), window_num, GSTitleBarKey);
|
2000-03-08 16:31:32 +00:00
|
|
|
|
DPSsetinputfocus(GSCurrentContext(), window_num);
|
1999-11-22 15:03:41 +00:00
|
|
|
|
[self resetCursorRects];
|
|
|
|
|
[nc postNotificationName: NSWindowDidBecomeKeyNotification object: self];
|
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) becomeMainWindow
|
|
|
|
|
{
|
1999-11-22 15:03:41 +00:00
|
|
|
|
if (_f.is_main == NO)
|
|
|
|
|
{
|
|
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
1999-11-22 15:03:41 +00:00
|
|
|
|
_f.is_main = YES;
|
2000-03-06 21:10:08 +00:00
|
|
|
|
if (_f.is_key == NO)
|
|
|
|
|
{
|
|
|
|
|
DPSsetinputstate(GSCurrentContext(), window_num, GSTitleBarMain);
|
|
|
|
|
}
|
1999-11-22 15:03:41 +00:00
|
|
|
|
[nc postNotificationName: NSWindowDidBecomeMainNotification object: self];
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (BOOL) canBecomeKeyWindow
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2000-03-08 21:26:11 +00:00
|
|
|
|
if (!_f.visible)
|
|
|
|
|
return NO;
|
|
|
|
|
if (_f.is_miniaturized)
|
|
|
|
|
return NO;
|
2000-03-04 07:55:42 +00:00
|
|
|
|
if ((NSResizableWindowMask | NSTitledWindowMask) & style_mask)
|
|
|
|
|
return YES;
|
|
|
|
|
else
|
|
|
|
|
return NO;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (BOOL) canBecomeMainWindow
|
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
if (!_f.visible)
|
|
|
|
|
return NO;
|
2000-03-08 21:26:11 +00:00
|
|
|
|
if (_f.is_miniaturized)
|
|
|
|
|
return NO;
|
2000-03-04 07:55:42 +00:00
|
|
|
|
if ((NSResizableWindowMask | NSTitledWindowMask) & style_mask)
|
|
|
|
|
return YES;
|
|
|
|
|
else
|
|
|
|
|
return NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (BOOL) hidesOnDeactivate
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
return _f.hides_on_deactivate;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (BOOL) isKeyWindow
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
return _f.is_key;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) isMainWindow
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
return _f.is_main;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) isMiniaturized
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
return _f.is_miniaturized;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) isVisible
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
return _f.visible;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (int) level
|
|
|
|
|
{
|
|
|
|
|
return window_level;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) makeKeyAndOrderFront: (id)sender
|
1998-12-17 13:06:17 +00:00
|
|
|
|
{
|
1999-12-14 16:53:23 +00:00
|
|
|
|
[self orderFront: sender];
|
1999-06-11 04:46:12 +00:00
|
|
|
|
[self makeKeyWindow];
|
1998-12-22 12:34:03 +00:00
|
|
|
|
/*
|
|
|
|
|
* OPENSTEP makes a window the main window when it makes it the key window.
|
|
|
|
|
* So we do the same (though the documentation doesn't mention it).
|
|
|
|
|
*/
|
|
|
|
|
[self makeMainWindow];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-12-22 12:34:03 +00:00
|
|
|
|
- (void) makeKeyWindow
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
|
if (![self canBecomeKeyWindow])
|
1998-12-22 12:34:03 +00:00
|
|
|
|
return;
|
1999-06-09 08:54:08 +00:00
|
|
|
|
[[NSApp keyWindow] resignKeyWindow];
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
[self becomeKeyWindow];
|
1998-12-17 13:06:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) makeMainWindow
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
|
if (![self canBecomeMainWindow])
|
|
|
|
|
return;
|
1999-06-09 08:54:08 +00:00
|
|
|
|
[[NSApp mainWindow] resignMainWindow];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
[self becomeMainWindow];
|
1998-12-17 13:06:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) orderBack: (id)sender
|
1999-07-06 18:22:58 +00:00
|
|
|
|
{
|
|
|
|
|
[self orderWindow: NSWindowBelow relativeTo: 0];
|
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
|
|
|
|
- (void) orderFront: (id)sender
|
1999-07-06 18:22:58 +00:00
|
|
|
|
{
|
|
|
|
|
if ([NSApp isActive] == YES)
|
|
|
|
|
{
|
|
|
|
|
[self orderWindow: NSWindowAbove relativeTo: 0];
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
|
|
|
|
- (void) orderFrontRegardless
|
1999-07-06 18:22:58 +00:00
|
|
|
|
{
|
|
|
|
|
[self orderWindow: NSWindowAbove relativeTo: 0];
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) orderOut: (id)sender
|
1999-07-06 18:22:58 +00:00
|
|
|
|
{
|
|
|
|
|
[self orderWindow: NSWindowOut relativeTo: 0];
|
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
|
|
|
|
- (void) orderWindow: (NSWindowOrderingMode)place relativeTo: (int)otherWin
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-11-29 06:12:34 +00:00
|
|
|
|
if (place == NSWindowOut)
|
|
|
|
|
{
|
2000-01-02 20:24:56 +00:00
|
|
|
|
_f.visible = NO;
|
1999-12-01 12:02:09 +00:00
|
|
|
|
if (_rFlags.needs_display == YES)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* Don't keep trying to update the window while it is ordered out
|
|
|
|
|
*/
|
|
|
|
|
[[NSRunLoop currentRunLoop]
|
|
|
|
|
cancelPerformSelector: @selector(_handleWindowNeedsDisplay:)
|
|
|
|
|
target: self
|
|
|
|
|
argument: nil];
|
|
|
|
|
}
|
2000-03-08 21:26:11 +00:00
|
|
|
|
[self _lossOfKeyOrMainWindow];
|
1999-11-29 06:12:34 +00:00
|
|
|
|
}
|
2000-01-10 02:09:33 +00:00
|
|
|
|
DPSorderwindow(GSCurrentContext(), place, otherWin, window_num);
|
1999-12-14 16:53:23 +00:00
|
|
|
|
if (place != NSWindowOut)
|
1999-12-01 12:02:09 +00:00
|
|
|
|
{
|
|
|
|
|
if (_rFlags.needs_display == NO)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* Once we are ordered back in, we will want to update the window
|
|
|
|
|
* whenever there is anything to do.
|
|
|
|
|
*/
|
|
|
|
|
[[NSRunLoop currentRunLoop]
|
|
|
|
|
performSelector: @selector(_handleWindowNeedsDisplay:)
|
|
|
|
|
target: self
|
|
|
|
|
argument: nil
|
1999-12-16 04:53:50 +00:00
|
|
|
|
order: 600000
|
1999-12-01 12:02:09 +00:00
|
|
|
|
modes: [NSArray arrayWithObjects:
|
|
|
|
|
NSDefaultRunLoopMode,
|
|
|
|
|
NSModalPanelRunLoopMode,
|
|
|
|
|
NSEventTrackingRunLoopMode, nil]];
|
|
|
|
|
}
|
2000-02-25 17:43:32 +00:00
|
|
|
|
if (_f.has_closed == YES)
|
|
|
|
|
{
|
|
|
|
|
_f.has_closed = NO; /* A closed window has re-opened */
|
|
|
|
|
}
|
1999-12-08 15:01:52 +00:00
|
|
|
|
if (_f.has_opened == NO)
|
|
|
|
|
{
|
|
|
|
|
_f.has_opened = YES;
|
|
|
|
|
if (_f.menu_exclude == NO)
|
|
|
|
|
{
|
|
|
|
|
BOOL isFileName;
|
|
|
|
|
|
|
|
|
|
isFileName = [window_title isEqual: represented_filename];
|
|
|
|
|
|
|
|
|
|
[NSApp addWindowsItem: self
|
|
|
|
|
title: window_title
|
|
|
|
|
filename: isFileName];
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-12-14 16:53:23 +00:00
|
|
|
|
if ([self isKeyWindow] == YES)
|
|
|
|
|
{
|
2000-03-08 16:31:32 +00:00
|
|
|
|
DPSsetinputstate(GSCurrentContext(), window_num, GSTitleBarKey);
|
2000-01-10 02:09:33 +00:00
|
|
|
|
DPSsetinputfocus(GSCurrentContext(), window_num);
|
1999-12-14 16:53:23 +00:00
|
|
|
|
}
|
1999-12-01 12:02:09 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) resignKeyWindow
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-11-22 15:03:41 +00:00
|
|
|
|
if (_f.is_key == YES)
|
|
|
|
|
{
|
|
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
1997-03-05 01:11:17 +00:00
|
|
|
|
|
2000-03-08 21:26:11 +00:00
|
|
|
|
if ((first_responder != self)
|
|
|
|
|
&& [first_responder respondsToSelector: @selector(resignKeyWindow)])
|
|
|
|
|
[first_responder resignKeyWindow];
|
2000-03-04 07:55:42 +00:00
|
|
|
|
|
1999-11-22 15:03:41 +00:00
|
|
|
|
_f.is_key = NO;
|
2000-03-06 21:10:08 +00:00
|
|
|
|
|
|
|
|
|
if (_f.is_main == YES)
|
|
|
|
|
{
|
|
|
|
|
DPSsetinputstate(GSCurrentContext(), window_num, GSTitleBarMain);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DPSsetinputstate(GSCurrentContext(), window_num, GSTitleBarNormal);
|
|
|
|
|
}
|
1999-11-22 15:03:41 +00:00
|
|
|
|
[self discardCursorRects];
|
2000-03-04 07:55:42 +00:00
|
|
|
|
|
1999-11-22 15:03:41 +00:00
|
|
|
|
[nc postNotificationName: NSWindowDidResignKeyNotification object: self];
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) resignMainWindow
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-11-22 15:03:41 +00:00
|
|
|
|
if (_f.is_main == YES)
|
|
|
|
|
{
|
|
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-11-22 15:03:41 +00:00
|
|
|
|
_f.is_main = NO;
|
2000-03-06 21:10:08 +00:00
|
|
|
|
if (_f.is_key == YES)
|
|
|
|
|
{
|
|
|
|
|
DPSsetinputstate(GSCurrentContext(), window_num, GSTitleBarKey);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DPSsetinputstate(GSCurrentContext(), window_num, GSTitleBarNormal);
|
|
|
|
|
}
|
1999-11-22 15:03:41 +00:00
|
|
|
|
[nc postNotificationName: NSWindowDidResignMainNotification object: self];
|
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setHidesOnDeactivate: (BOOL)flag
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
if (flag != _f.hides_on_deactivate)
|
|
|
|
|
{
|
|
|
|
|
_f.hides_on_deactivate = flag;
|
|
|
|
|
}
|
1996-10-03 18:45:41 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) setLevel: (int)newLevel
|
|
|
|
|
{
|
2000-03-08 21:26:11 +00:00
|
|
|
|
if (window_level != newLevel)
|
|
|
|
|
{
|
|
|
|
|
NSGraphicsContext *context = GSCurrentContext();
|
2000-03-08 18:08:26 +00:00
|
|
|
|
|
2000-03-08 21:26:11 +00:00
|
|
|
|
window_level = newLevel;
|
|
|
|
|
DPSsetwindowlevel(context, window_level, window_num);
|
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Moving and resizing the window
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (NSPoint) cascadeTopLeftFromPoint: (NSPoint)topLeftPoint
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
// FIXME: The implementation of this method is missing
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return NSZeroPoint;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) center
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
|
NSSize screenSize = [[NSScreen mainScreen] frame].size;
|
1999-04-01 20:21:05 +00:00
|
|
|
|
NSPoint origin = frame.origin;
|
2000-03-10 21:48:52 +00:00
|
|
|
|
float offset=0.0;
|
|
|
|
|
|
|
|
|
|
// center the window within it's screen,
|
|
|
|
|
// taking into account the title bar and the resize bar heights <PJB>.
|
|
|
|
|
if((style_mask&NSTitledWindowMask)!=0){
|
|
|
|
|
offset+=GSTitleBarHeight;
|
|
|
|
|
}
|
|
|
|
|
if((style_mask&NSResizableWindowMask)!=0){
|
|
|
|
|
offset+=GSResizeBarHeight;
|
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
origin.x = (screenSize.width - frame.size.width) / 2;
|
2000-03-10 21:48:52 +00:00
|
|
|
|
origin.y = (screenSize.height - offset - frame.size.height) / 2;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
[self setFrameOrigin: origin];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSRect) constrainFrameRect: (NSRect)frameRect toScreen: screen
|
|
|
|
|
{
|
2000-03-07 12:00:00 +00:00
|
|
|
|
NSRect r = [screen frame];
|
|
|
|
|
|
|
|
|
|
r = NSIntersectionRect(r, frameRect);
|
|
|
|
|
return r;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSRect) frame
|
|
|
|
|
{
|
|
|
|
|
return frame;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSSize) minSize
|
|
|
|
|
{
|
|
|
|
|
return minimum_size;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (NSSize) maxSize
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return maximum_size;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) setContentSize: (NSSize)aSize
|
1999-07-06 05:37:15 +00:00
|
|
|
|
{
|
|
|
|
|
NSRect r = frame;
|
|
|
|
|
|
|
|
|
|
r.size = aSize;
|
2000-03-07 12:00:00 +00:00
|
|
|
|
r = [NSWindow frameRectForContentRect: r styleMask: style_mask];
|
|
|
|
|
r.origin = frame.origin;
|
1999-07-06 05:37:15 +00:00
|
|
|
|
[self setFrame: r display: YES];
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) setFrame: (NSRect)frameRect display: (BOOL)flag
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-07-06 05:37:15 +00:00
|
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
1998-12-15 16:20:22 +00:00
|
|
|
|
|
1999-07-06 05:37:15 +00:00
|
|
|
|
if (maximum_size.width > 0 && frameRect.size.width > maximum_size.width)
|
|
|
|
|
{
|
|
|
|
|
frameRect.size.width = maximum_size.width;
|
|
|
|
|
}
|
|
|
|
|
if (maximum_size.height > 0 && frameRect.size.height > maximum_size.height)
|
|
|
|
|
{
|
|
|
|
|
frameRect.size.height = maximum_size.height;
|
|
|
|
|
}
|
1999-07-25 11:54:26 +00:00
|
|
|
|
if (frameRect.size.width < minimum_size.width)
|
1999-07-06 05:37:15 +00:00
|
|
|
|
{
|
|
|
|
|
frameRect.size.width = minimum_size.width;
|
|
|
|
|
}
|
1999-07-25 11:54:26 +00:00
|
|
|
|
if (frameRect.size.height < minimum_size.height)
|
1999-07-06 05:37:15 +00:00
|
|
|
|
{
|
|
|
|
|
frameRect.size.height = minimum_size.height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (NSEqualSizes(frameRect.size, frame.size) == NO)
|
|
|
|
|
{
|
1999-12-07 05:53:26 +00:00
|
|
|
|
if ([_delegate respondsToSelector: @selector(windowWillResize:toSize:)])
|
1999-07-06 05:37:15 +00:00
|
|
|
|
{
|
1999-12-07 05:53:26 +00:00
|
|
|
|
frameRect.size = [_delegate windowWillResize: self
|
1999-07-06 05:37:15 +00:00
|
|
|
|
toSize: frameRect.size];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (NSEqualPoints(frame.origin, frameRect.origin) == NO)
|
|
|
|
|
[nc postNotificationName: NSWindowWillMoveNotification object: self];
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Now we can tell the graphics context to do the actual resizing.
|
1999-11-16 07:00:43 +00:00
|
|
|
|
* We will recieve an event to tell us when the resize is done.
|
1999-07-06 05:37:15 +00:00
|
|
|
|
*/
|
1999-11-18 11:06:22 +00:00
|
|
|
|
DPSplacewindow(GSCurrentContext(), frameRect.origin.x, frameRect.origin.y,
|
2000-01-10 02:09:33 +00:00
|
|
|
|
frameRect.size.width, frameRect.size.height, window_num);
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
if (flag)
|
|
|
|
|
[self display];
|
1996-10-03 18:45:41 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) setFrameOrigin: (NSPoint)aPoint
|
|
|
|
|
{
|
1999-07-06 05:37:15 +00:00
|
|
|
|
NSRect r = frame;
|
|
|
|
|
|
|
|
|
|
r.origin = aPoint;
|
|
|
|
|
[self setFrame: r display: YES];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setFrameTopLeftPoint: (NSPoint)aPoint
|
|
|
|
|
{
|
|
|
|
|
NSRect r = frame;
|
|
|
|
|
|
1999-08-26 13:51:56 +00:00
|
|
|
|
r.origin = aPoint;
|
|
|
|
|
r.origin.y -= frame.size.height;
|
1999-07-06 05:37:15 +00:00
|
|
|
|
[self setFrame: r display: YES];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setMinSize: (NSSize)aSize
|
|
|
|
|
{
|
1999-07-25 11:54:26 +00:00
|
|
|
|
if (aSize.width < 1)
|
|
|
|
|
aSize.width = 1;
|
|
|
|
|
if (aSize.height < 1)
|
|
|
|
|
aSize.height = 1;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
minimum_size = aSize;
|
1999-10-21 18:08:50 +00:00
|
|
|
|
DPSsetminsize(GSCurrentContext(), aSize.width, aSize.height, window_num);
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setMaxSize: (NSSize)aSize
|
|
|
|
|
{
|
1999-09-09 02:56:20 +00:00
|
|
|
|
/*
|
|
|
|
|
* Documented maximum size for macOS-X - do we need this restriction?
|
|
|
|
|
*/
|
|
|
|
|
if (aSize.width > 10000)
|
|
|
|
|
aSize.width = 10000;
|
|
|
|
|
if (aSize.height > 10000)
|
|
|
|
|
aSize.height = 10000;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
maximum_size = aSize;
|
1999-10-21 18:08:50 +00:00
|
|
|
|
DPSsetmaxsize(GSCurrentContext(), aSize.width, aSize.height, window_num);
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-05-04 13:17:26 +00:00
|
|
|
|
- (NSSize) resizeIncrements
|
|
|
|
|
{
|
|
|
|
|
return increments;
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) setResizeIncrements: (NSSize)aSize
|
|
|
|
|
{
|
|
|
|
|
increments = aSize;
|
1999-12-16 04:53:50 +00:00
|
|
|
|
DPSsetresizeincrements(GSCurrentContext(), aSize.width, aSize.height,
|
1999-10-21 18:08:50 +00:00
|
|
|
|
window_num);
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-03-04 07:55:42 +00:00
|
|
|
|
- (NSSize) aspectRatio
|
|
|
|
|
{
|
|
|
|
|
// FIXME: This method is missing
|
|
|
|
|
return NSMakeSize(1, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setAspectRatio: (NSSize)ratio
|
|
|
|
|
{
|
|
|
|
|
// FIXME: This method is missing
|
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Converting coordinates
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (NSPoint) convertBaseToScreen: (NSPoint)basePoint
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2000-03-07 12:00:00 +00:00
|
|
|
|
NSGraphicsContext *context = GSCurrentContext();
|
|
|
|
|
NSPoint screenPoint;
|
|
|
|
|
float t, b, l, r;
|
1998-11-12 10:49:00 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
DPSstyleoffsets(context, &l, &r, &t, &b, style_mask);
|
|
|
|
|
screenPoint.x = frame.origin.x + basePoint.x + l;
|
|
|
|
|
screenPoint.y = frame.origin.y + basePoint.y + b;
|
1998-11-12 10:49:00 +00:00
|
|
|
|
|
1999-06-10 03:05:11 +00:00
|
|
|
|
return screenPoint;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (NSPoint) convertScreenToBase: (NSPoint)screenPoint
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2000-03-07 12:00:00 +00:00
|
|
|
|
NSGraphicsContext *context = GSCurrentContext();
|
|
|
|
|
NSPoint basePoint;
|
|
|
|
|
float t, b, l, r;
|
1998-11-12 10:49:00 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
DPSstyleoffsets(context, &l, &r, &t, &b, style_mask);
|
|
|
|
|
basePoint.x = screenPoint.x - frame.origin.x - l;
|
|
|
|
|
basePoint.y = screenPoint.y - frame.origin.y - b;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return basePoint;
|
1998-11-12 10:49:00 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Managing the display
|
|
|
|
|
*/
|
1999-02-12 17:00:59 +00:00
|
|
|
|
- (void) disableFlushWindow
|
|
|
|
|
{
|
1999-09-06 05:18:16 +00:00
|
|
|
|
disable_flush_window++;
|
1999-02-12 17:00:59 +00:00
|
|
|
|
}
|
1997-10-09 22:55:31 +00:00
|
|
|
|
|
1999-02-12 17:00:59 +00:00
|
|
|
|
- (void) display
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_rFlags.needs_display = NO;
|
2000-03-04 07:55:42 +00:00
|
|
|
|
// FIXME: Is the first responder processing needed here?
|
1999-10-13 00:51:46 +00:00
|
|
|
|
if ((!first_responder) || (first_responder == self))
|
|
|
|
|
if (_initial_first_responder)
|
|
|
|
|
[self makeFirstResponder: _initial_first_responder];
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* inform first responder of it's status so it can set the focus to itself
|
|
|
|
|
*/
|
|
|
|
|
[first_responder becomeFirstResponder];
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
[self disableFlushWindow];
|
1999-12-17 12:06:35 +00:00
|
|
|
|
[_wv display];
|
1999-06-11 04:46:12 +00:00
|
|
|
|
[self enableFlushWindow];
|
|
|
|
|
[self flushWindowIfNeeded];
|
1999-02-12 17:00:59 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-02-12 17:00:59 +00:00
|
|
|
|
- (void) displayIfNeeded
|
1996-10-03 18:45:41 +00:00
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
if (_rFlags.needs_display)
|
1999-02-12 17:00:59 +00:00
|
|
|
|
{
|
1999-12-17 12:06:35 +00:00
|
|
|
|
[_wv displayIfNeeded];
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_rFlags.needs_display = NO;
|
1999-02-12 17:00:59 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1998-12-22 12:34:03 +00:00
|
|
|
|
- (void) update
|
1998-11-20 02:14:22 +00:00
|
|
|
|
{
|
1998-12-22 12:34:03 +00:00
|
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
1998-11-20 02:14:22 +00:00
|
|
|
|
|
1999-02-12 17:00:59 +00:00
|
|
|
|
/*
|
|
|
|
|
* if autodisplay is enabled and window display
|
|
|
|
|
*/
|
1999-11-15 21:45:56 +00:00
|
|
|
|
if (_f.is_autodisplay && _rFlags.needs_display)
|
1999-02-12 17:00:59 +00:00
|
|
|
|
{
|
|
|
|
|
[self disableFlushWindow];
|
|
|
|
|
[self displayIfNeeded];
|
|
|
|
|
[self enableFlushWindow];
|
1998-12-22 12:34:03 +00:00
|
|
|
|
[self flushWindowIfNeeded];
|
|
|
|
|
}
|
1999-10-21 18:08:50 +00:00
|
|
|
|
[GSCurrentContext() flush];
|
1998-12-22 12:34:03 +00:00
|
|
|
|
[nc postNotificationName: NSWindowDidUpdateNotification object: self];
|
1998-11-20 02:14:22 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-02-12 17:00:59 +00:00
|
|
|
|
- (void) flushWindowIfNeeded
|
1996-10-03 18:45:41 +00:00
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
if (disable_flush_window == 0 && _f.needs_flush == YES)
|
1999-02-12 17:00:59 +00:00
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.needs_flush = NO;
|
1999-02-12 17:00:59 +00:00
|
|
|
|
[self flushWindow];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) flushWindow
|
|
|
|
|
{
|
1999-10-21 18:08:50 +00:00
|
|
|
|
int i;
|
|
|
|
|
NSGraphicsContext* context = GSCurrentContext();
|
|
|
|
|
|
|
|
|
|
// do nothing if backing is not buffered
|
|
|
|
|
if (backing_type == NSBackingStoreNonretained)
|
|
|
|
|
{
|
|
|
|
|
[context flush];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (disable_flush_window) // if flushWindow is called
|
|
|
|
|
{ // while flush is disabled
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.needs_flush = YES; // mark self as needing a
|
1999-10-21 18:08:50 +00:00
|
|
|
|
return; // flush, then return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Check for special case of flushing while we are lock focused.
|
|
|
|
|
For instance, when we are highlighting a button. */
|
|
|
|
|
if (NSIsEmptyRect(rectNeedingFlush))
|
|
|
|
|
{
|
|
|
|
|
if ([rectsBeingDrawn count] == 0)
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.needs_flush = NO;
|
1999-10-21 18:08:50 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Accumulate the rectangles from all nested focus locks.
|
|
|
|
|
*/
|
|
|
|
|
i = [rectsBeingDrawn count];
|
|
|
|
|
while (i-- > 0)
|
|
|
|
|
{
|
1999-12-16 04:53:50 +00:00
|
|
|
|
rectNeedingFlush = NSUnionRect(rectNeedingFlush,
|
1999-10-21 18:08:50 +00:00
|
|
|
|
[[rectsBeingDrawn objectAtIndex: i] rectValue]);
|
|
|
|
|
}
|
1999-12-16 04:53:50 +00:00
|
|
|
|
|
|
|
|
|
DPSflushwindowrect(context,
|
1999-10-21 18:08:50 +00:00
|
|
|
|
NSMinX(rectNeedingFlush), NSMinY(rectNeedingFlush),
|
|
|
|
|
NSWidth(rectNeedingFlush), NSHeight(rectNeedingFlush),
|
|
|
|
|
window_num);
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.needs_flush = NO;
|
1999-10-21 18:08:50 +00:00
|
|
|
|
rectNeedingFlush = NSZeroRect;
|
1997-10-09 22:55:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-02-12 17:00:59 +00:00
|
|
|
|
- (void) enableFlushWindow
|
|
|
|
|
{
|
1999-09-06 05:18:16 +00:00
|
|
|
|
if (disable_flush_window > 0)
|
|
|
|
|
{
|
|
|
|
|
disable_flush_window--;
|
|
|
|
|
}
|
1999-02-12 17:00:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) isAutodisplay
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
return _f.is_autodisplay;
|
1999-02-12 17:00:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) isFlushWindowDisabled
|
|
|
|
|
{
|
1999-09-06 05:18:16 +00:00
|
|
|
|
return disable_flush_window == 0 ? NO : YES;
|
1999-02-12 17:00:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setAutodisplay: (BOOL)flag
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.is_autodisplay = flag;
|
1999-02-12 17:00:59 +00:00
|
|
|
|
}
|
1999-02-03 21:53:29 +00:00
|
|
|
|
|
|
|
|
|
- (void) setViewsNeedDisplay: (BOOL)flag
|
|
|
|
|
{
|
1999-12-08 15:01:52 +00:00
|
|
|
|
if (_rFlags.needs_display != flag)
|
1999-09-09 02:56:20 +00:00
|
|
|
|
{
|
1999-12-08 15:01:52 +00:00
|
|
|
|
_rFlags.needs_display = flag;
|
|
|
|
|
if (flag)
|
|
|
|
|
{
|
|
|
|
|
[NSApp setWindowsNeedUpdate: YES];
|
|
|
|
|
if (_f.visible && _f.has_opened)
|
|
|
|
|
{
|
|
|
|
|
[[NSRunLoop currentRunLoop]
|
|
|
|
|
performSelector: @selector(_handleWindowNeedsDisplay:)
|
|
|
|
|
target: self
|
|
|
|
|
argument: nil
|
|
|
|
|
order: 600000 /*NSDisplayWindowRunLoopOrdering OS*/
|
|
|
|
|
modes: [NSArray arrayWithObjects:
|
|
|
|
|
NSDefaultRunLoopMode,
|
|
|
|
|
NSModalPanelRunLoopMode,
|
|
|
|
|
NSEventTrackingRunLoopMode, nil]];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[[NSRunLoop currentRunLoop]
|
|
|
|
|
cancelPerformSelector: @selector(_handleWindowNeedsDisplay:)
|
|
|
|
|
target: self
|
|
|
|
|
argument: nil];
|
|
|
|
|
}
|
1999-09-09 02:56:20 +00:00
|
|
|
|
}
|
1999-02-03 21:53:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-02-12 17:00:59 +00:00
|
|
|
|
- (BOOL) viewsNeedDisplay
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
return _rFlags.needs_display;
|
1999-02-12 17:00:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) cacheImageInRect: (NSRect)aRect
|
2000-03-04 07:55:42 +00:00
|
|
|
|
{
|
|
|
|
|
// FIXME: This Method is missing
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) discardCachedImage
|
2000-03-04 07:55:42 +00:00
|
|
|
|
{
|
|
|
|
|
// FIXME: This Method is missing
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) restoreCachedImage
|
2000-03-04 07:55:42 +00:00
|
|
|
|
{
|
|
|
|
|
// FIXME: This Method is missing
|
|
|
|
|
}
|
|
|
|
|
|
1999-02-12 17:00:59 +00:00
|
|
|
|
- (void) useOptimizedDrawing: (BOOL)flag
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.optimize_drawing = flag;
|
1999-02-12 17:00:59 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-02-12 17:00:59 +00:00
|
|
|
|
- (BOOL) canStoreColor
|
1996-08-22 18:51:08 +00:00
|
|
|
|
{
|
1999-06-11 04:46:12 +00:00
|
|
|
|
if (depth_limit > 1)
|
|
|
|
|
return YES;
|
1999-02-12 17:00:59 +00:00
|
|
|
|
else
|
|
|
|
|
return NO;
|
1996-08-22 18:51:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSScreen*) deepestScreen
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
// FIXME: We must check the screens the window is on
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return [NSScreen deepestScreen];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSWindowDepth) depthLimit
|
|
|
|
|
{
|
|
|
|
|
return depth_limit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) hasDynamicDepthLimit
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
return _f.dynamic_depth_limit;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSScreen*) screen
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
// FIXME: Works only if there is only one screen
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return [NSScreen mainScreen];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setDepthLimit: (NSWindowDepth)limit
|
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
if (limit == 0)
|
|
|
|
|
limit = [[self class] defaultDepthLimit];
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
depth_limit = limit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setDynamicDepthLimit: (BOOL)flag
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.dynamic_depth_limit = flag;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Cursor management
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (BOOL) areCursorRectsEnabled
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
return _f.cursor_rects_enabled;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) disableCursorRects
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.cursor_rects_enabled = NO;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-11-15 16:00:47 +00:00
|
|
|
|
static void
|
|
|
|
|
discardCursorRectsForView(NSView *theView)
|
1997-03-05 01:11:17 +00:00
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
if (theView != nil)
|
1999-05-07 20:08:51 +00:00
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
if (((NSViewPtr)theView)->_rFlags.has_currects)
|
|
|
|
|
{
|
|
|
|
|
[theView discardCursorRects];
|
|
|
|
|
}
|
1997-03-05 01:11:17 +00:00
|
|
|
|
|
1999-11-15 16:00:47 +00:00
|
|
|
|
if (((NSViewPtr)theView)->_rFlags.has_subviews)
|
1999-05-07 20:08:51 +00:00
|
|
|
|
{
|
2000-01-10 02:09:33 +00:00
|
|
|
|
NSArray *s = ((NSViewPtr)theView)->_sub_views;
|
1999-11-15 16:00:47 +00:00
|
|
|
|
unsigned count = [s count];
|
|
|
|
|
|
|
|
|
|
if (count)
|
|
|
|
|
{
|
|
|
|
|
NSView *subs[count];
|
|
|
|
|
unsigned i;
|
1999-05-07 20:08:51 +00:00
|
|
|
|
|
1999-11-15 16:00:47 +00:00
|
|
|
|
[s getObjects: subs];
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
discardCursorRectsForView(subs[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-07 20:08:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1997-03-05 01:11:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) discardCursorRects
|
1997-03-05 01:11:17 +00:00
|
|
|
|
{
|
1999-12-17 12:06:35 +00:00
|
|
|
|
discardCursorRectsForView(_wv);
|
1997-03-05 01:11:17 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) enableCursorRects
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.cursor_rects_enabled = YES;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) invalidateCursorRectsForView: (NSView*)aView
|
1997-03-05 01:11:17 +00:00
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
if (((NSViewPtr)aView)->_rFlags.valid_rects)
|
|
|
|
|
{
|
2000-01-10 02:09:33 +00:00
|
|
|
|
[((NSViewPtr)aView)->_cursor_rects
|
1999-11-15 16:00:47 +00:00
|
|
|
|
makeObjectsPerformSelector: @selector(invalidate)];
|
|
|
|
|
((NSViewPtr)aView)->_rFlags.valid_rects = 0;
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.cursor_rects_valid = NO;
|
1999-11-15 16:00:47 +00:00
|
|
|
|
}
|
1997-03-05 01:11:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-15 16:00:47 +00:00
|
|
|
|
static void
|
|
|
|
|
resetCursorRectsForView(NSView *theView)
|
1997-03-05 01:11:17 +00:00
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
if (theView != nil)
|
1999-05-07 20:08:51 +00:00
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
[theView resetCursorRects];
|
1997-03-05 01:11:17 +00:00
|
|
|
|
|
1999-11-15 16:00:47 +00:00
|
|
|
|
if (((NSViewPtr)theView)->_rFlags.has_subviews)
|
1999-05-07 20:08:51 +00:00
|
|
|
|
{
|
2000-01-10 02:09:33 +00:00
|
|
|
|
NSArray *s = ((NSViewPtr)theView)->_sub_views;
|
1999-11-15 16:00:47 +00:00
|
|
|
|
unsigned count = [s count];
|
|
|
|
|
|
|
|
|
|
if (count)
|
|
|
|
|
{
|
|
|
|
|
NSView *subs[count];
|
|
|
|
|
unsigned i;
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1999-11-15 16:00:47 +00:00
|
|
|
|
[s getObjects: subs];
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
|
{
|
|
|
|
|
resetCursorRectsForView(subs[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-07 20:08:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1997-03-05 01:11:17 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) resetCursorRects
|
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
[self discardCursorRects];
|
1999-12-17 12:06:35 +00:00
|
|
|
|
resetCursorRectsForView(_wv);
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.cursor_rects_valid = YES;
|
1997-03-05 01:11:17 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Handling user actions and events
|
|
|
|
|
*/
|
1998-12-17 13:06:17 +00:00
|
|
|
|
- (void) close
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1998-12-17 13:06:17 +00:00
|
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
2000-02-21 16:25:29 +00:00
|
|
|
|
CREATE_AUTORELEASE_POOL(pool);
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
|
|
|
|
[nc postNotificationName: NSWindowWillCloseNotification object: self];
|
1999-12-08 15:01:52 +00:00
|
|
|
|
_f.has_opened = NO;
|
|
|
|
|
[[NSRunLoop currentRunLoop]
|
2000-02-25 17:43:32 +00:00
|
|
|
|
cancelPerformSelector: @selector(_handleWindowNeedsDisplay:)
|
|
|
|
|
target: self
|
|
|
|
|
argument: nil];
|
1999-06-09 08:54:08 +00:00
|
|
|
|
[NSApp removeWindowsItem: self];
|
1998-12-17 13:06:17 +00:00
|
|
|
|
[self orderOut: self];
|
2000-02-21 16:25:29 +00:00
|
|
|
|
RELEASE(pool);
|
2000-02-25 17:43:32 +00:00
|
|
|
|
if (_f.has_closed == NO)
|
|
|
|
|
{
|
|
|
|
|
_f.has_closed = YES;
|
|
|
|
|
if (_f.is_released_when_closed)
|
|
|
|
|
{
|
|
|
|
|
RELEASE(self);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NSWarnMLog(@"closing window (%@) that's already closed.", self);
|
|
|
|
|
}
|
1998-12-17 13:06:17 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) deminiaturize: sender
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-03-08 21:26:11 +00:00
|
|
|
|
if (_counterpart != 0)
|
|
|
|
|
{
|
|
|
|
|
NSWindow *mini = GSWindowWithNumber(_counterpart);
|
|
|
|
|
|
|
|
|
|
[mini orderOut: self];
|
|
|
|
|
}
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.is_miniaturized = NO;
|
2000-03-08 21:26:11 +00:00
|
|
|
|
[self makeKeyAndOrderFront: self];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
|
|
|
|
[nc postNotificationName: NSWindowDidDeminiaturizeNotification object: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-05-04 13:17:26 +00:00
|
|
|
|
- (BOOL) isDocumentEdited
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
return _f.is_edited;
|
1999-05-04 13:17:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) isReleasedWhenClosed
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
return _f.is_released_when_closed;
|
1999-05-04 13:17:26 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-03-08 21:26:11 +00:00
|
|
|
|
- (void) miniaturize: (id)sender
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
|
|
|
|
|
|
|
|
|
[nc postNotificationName: NSWindowWillMiniaturizeNotification
|
2000-03-08 21:26:11 +00:00
|
|
|
|
object: self];
|
2000-03-04 07:55:42 +00:00
|
|
|
|
|
2000-03-08 21:26:11 +00:00
|
|
|
|
_f.is_miniaturized = YES;
|
2000-03-04 07:55:42 +00:00
|
|
|
|
/*
|
|
|
|
|
* Ensure that we have a miniwindow counterpart.
|
|
|
|
|
*/
|
|
|
|
|
if (_counterpart == 0)
|
2000-03-01 17:21:08 +00:00
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
NSWindow *mini;
|
|
|
|
|
NSMiniWindowView *v;
|
|
|
|
|
|
2000-03-08 21:26:11 +00:00
|
|
|
|
mini = [[NSMiniWindow alloc] initWithContentRect: NSMakeRect(0,0,64,64)
|
|
|
|
|
styleMask: NSMiniWindowMask
|
|
|
|
|
backing: NSBackingStoreBuffered
|
|
|
|
|
defer: NO];
|
2000-03-04 07:55:42 +00:00
|
|
|
|
mini->_counterpart = [self windowNumber];
|
|
|
|
|
_counterpart = [mini windowNumber];
|
|
|
|
|
v = [[NSMiniWindowView alloc] initWithFrame: NSMakeRect(0,0,64,64)];
|
|
|
|
|
[v setImage: [self miniwindowImage]];
|
|
|
|
|
[v setTitle: [self miniwindowTitle]];
|
|
|
|
|
[mini setContentView: v];
|
|
|
|
|
RELEASE(v);
|
|
|
|
|
}
|
2000-03-08 21:26:11 +00:00
|
|
|
|
[self _lossOfKeyOrMainWindow];
|
2000-03-04 07:55:42 +00:00
|
|
|
|
DPSminiwindow(GSCurrentContext(), window_num);
|
|
|
|
|
|
|
|
|
|
[nc postNotificationName: NSWindowDidMiniaturizeNotification
|
2000-03-08 21:26:11 +00:00
|
|
|
|
object: self];
|
1998-12-17 13:06:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-08 21:26:11 +00:00
|
|
|
|
- (void) performClose: (id)sender
|
1998-12-17 13:06:17 +00:00
|
|
|
|
{
|
1999-05-04 13:17:26 +00:00
|
|
|
|
/* self must have a close button in order to be closed */
|
2000-03-01 17:21:08 +00:00
|
|
|
|
if (!(style_mask & NSClosableWindowMask))
|
1999-05-04 13:17:26 +00:00
|
|
|
|
{
|
|
|
|
|
NSBeep();
|
|
|
|
|
return;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1999-12-07 05:53:26 +00:00
|
|
|
|
if ([_delegate respondsToSelector: @selector(windowShouldClose:)])
|
1999-05-04 13:17:26 +00:00
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* if delegate responds to windowShouldClose query it to see if
|
|
|
|
|
* it's ok to close the window
|
|
|
|
|
*/
|
1999-12-07 05:53:26 +00:00
|
|
|
|
if (![_delegate windowShouldClose: self])
|
1999-05-04 13:17:26 +00:00
|
|
|
|
{
|
|
|
|
|
NSBeep();
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
1999-05-04 13:17:26 +00:00
|
|
|
|
/*
|
|
|
|
|
* else if self responds to windowShouldClose query
|
|
|
|
|
* self to see if it's ok to close self
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
if ([self respondsToSelector: @selector(windowShouldClose:)])
|
1999-05-04 13:17:26 +00:00
|
|
|
|
{
|
|
|
|
|
if (![self windowShouldClose: self])
|
|
|
|
|
{
|
|
|
|
|
NSBeep();
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
2000-03-04 07:55:42 +00:00
|
|
|
|
// FIXME: The button should be highlighted
|
1999-05-04 13:17:26 +00:00
|
|
|
|
[self close];
|
1998-12-17 13:06:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-06-02 19:43:09 +00:00
|
|
|
|
- (BOOL) performKeyEquivalent: (NSEvent*)theEvent
|
|
|
|
|
{
|
|
|
|
|
if (content_view)
|
|
|
|
|
return [content_view performKeyEquivalent: theEvent];
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) performMiniaturize: (id)sender
|
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
if (!(style_mask & (NSIconWindowMask | NSMiniWindowMask)))
|
2000-03-01 17:21:08 +00:00
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
// FIXME: The button should be highlighted
|
|
|
|
|
[self miniaturize: sender];
|
2000-03-01 17:21:08 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
NSBeep();
|
2000-03-01 17:21:08 +00:00
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (int) resizeFlags
|
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
// FIXME: The implementation is missing
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
1999-01-06 18:01:05 +00:00
|
|
|
|
|
|
|
|
|
- (void) setDocumentEdited: (BOOL)flag
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
if (_f.is_edited != flag)
|
1999-01-06 18:01:05 +00:00
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.is_edited = flag;
|
1999-12-08 15:01:52 +00:00
|
|
|
|
if (_f.menu_exclude == NO && _f.has_opened == YES)
|
1999-06-11 04:46:12 +00:00
|
|
|
|
{
|
|
|
|
|
[NSApp updateWindowsItem: self];
|
|
|
|
|
}
|
1999-12-06 13:32:01 +00:00
|
|
|
|
DPSdocedited(GSCurrentContext(), flag, window_num);
|
1999-01-06 18:01:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) setReleasedWhenClosed: (BOOL)flag
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.is_released_when_closed = flag;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Aiding event handling
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (BOOL) acceptsMouseMovedEvents
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
return _f.accepts_mouse_moved;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSEvent*) currentEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-06-09 08:54:08 +00:00
|
|
|
|
return [NSApp currentEvent];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) discardEventsMatchingMask: (unsigned int)mask
|
2000-03-07 12:00:00 +00:00
|
|
|
|
beforeEvent: (NSEvent*)lastEvent
|
1996-10-03 18:45:41 +00:00
|
|
|
|
{
|
1999-06-09 08:54:08 +00:00
|
|
|
|
[NSApp discardEventsMatchingMask: mask beforeEvent: lastEvent];
|
1996-10-03 18:45:41 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1998-12-17 13:06:17 +00:00
|
|
|
|
- (NSResponder*) firstResponder
|
|
|
|
|
{
|
|
|
|
|
return first_responder;
|
|
|
|
|
}
|
1998-12-16 22:33:40 +00:00
|
|
|
|
|
1998-12-17 13:06:17 +00:00
|
|
|
|
- (BOOL) acceptsFirstResponder
|
|
|
|
|
{
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1998-12-17 13:06:17 +00:00
|
|
|
|
- (BOOL) makeFirstResponder: (NSResponder*)aResponder
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
|
if (first_responder == aResponder)
|
|
|
|
|
return YES;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-05-14 14:50:05 +00:00
|
|
|
|
if (![aResponder isKindOfClass: responderClass])
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return NO;
|
|
|
|
|
|
|
|
|
|
if (![aResponder acceptsFirstResponder])
|
|
|
|
|
return NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* If there is a first responder tell it to resign.
|
|
|
|
|
* Change only if it replies Y
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
if ((first_responder) && (![first_responder resignFirstResponder]))
|
|
|
|
|
return NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
first_responder = aResponder;
|
2000-03-04 07:55:42 +00:00
|
|
|
|
if (![first_responder becomeFirstResponder])
|
|
|
|
|
{
|
|
|
|
|
first_responder = self;
|
|
|
|
|
[first_responder becomeFirstResponder];
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return YES;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) setInitialFirstResponder: (NSView*)aView
|
1999-12-16 04:53:50 +00:00
|
|
|
|
{
|
1999-10-04 06:18:17 +00:00
|
|
|
|
if ([aView isKindOfClass: viewClass])
|
|
|
|
|
{
|
2000-02-21 15:33:30 +00:00
|
|
|
|
ASSIGN(_initial_first_responder, aView);
|
1999-10-04 06:18:17 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSView*) initialFirstResponder
|
1999-12-16 04:53:50 +00:00
|
|
|
|
{
|
1999-10-04 06:18:17 +00:00
|
|
|
|
return _initial_first_responder;
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) keyDown: (NSEvent*)theEvent
|
1999-12-16 04:53:50 +00:00
|
|
|
|
{
|
1999-10-12 15:05:37 +00:00
|
|
|
|
unsigned int key_code = [theEvent keyCode];
|
|
|
|
|
|
|
|
|
|
// If this is a TAB or TAB+SHIFT event, move to the next key view
|
1999-12-16 04:53:50 +00:00
|
|
|
|
if (key_code == 0x09)
|
1999-10-12 15:05:37 +00:00
|
|
|
|
{
|
|
|
|
|
if ([theEvent modifierFlags] & NSShiftKeyMask)
|
|
|
|
|
[self selectPreviousKeyView: self];
|
|
|
|
|
else
|
|
|
|
|
[self selectNextKeyView: self];
|
|
|
|
|
return;
|
1999-12-16 04:53:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If this is an ESC event, abort modal loop
|
1999-10-12 15:05:37 +00:00
|
|
|
|
if (key_code == 0x1b)
|
|
|
|
|
{
|
|
|
|
|
NSApplication *app = [NSApplication sharedApplication];
|
1999-10-18 22:49:29 +00:00
|
|
|
|
if ([app modalWindow] == self)
|
1999-10-12 15:05:37 +00:00
|
|
|
|
{
|
|
|
|
|
// NB: The following *never* returns.
|
|
|
|
|
[app abortModal];
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
2000-03-04 07:55:42 +00:00
|
|
|
|
// FIXME: The return key should trigger the default botton
|
1999-10-13 00:51:46 +00:00
|
|
|
|
|
1999-12-16 04:53:50 +00:00
|
|
|
|
// Try to process the event as a key equivalent
|
1999-10-14 00:39:46 +00:00
|
|
|
|
// without Command having being pressed
|
1999-10-13 00:51:46 +00:00
|
|
|
|
{
|
1999-12-16 04:53:50 +00:00
|
|
|
|
NSEvent *new_event
|
|
|
|
|
= [NSEvent keyEventWithType: [theEvent type]
|
|
|
|
|
location: NSZeroPoint
|
1999-10-14 00:39:46 +00:00
|
|
|
|
modifierFlags: ([theEvent modifierFlags] | NSCommandKeyMask)
|
1999-12-16 04:53:50 +00:00
|
|
|
|
timestamp: [theEvent timestamp]
|
1999-10-13 00:51:46 +00:00
|
|
|
|
windowNumber: [theEvent windowNumber]
|
1999-12-16 04:53:50 +00:00
|
|
|
|
context: [theEvent context]
|
1999-10-13 00:51:46 +00:00
|
|
|
|
characters: [theEvent characters]
|
1999-12-16 04:53:50 +00:00
|
|
|
|
charactersIgnoringModifiers: [theEvent
|
1999-10-13 00:51:46 +00:00
|
|
|
|
charactersIgnoringModifiers]
|
|
|
|
|
isARepeat: [theEvent isARepeat]
|
|
|
|
|
keyCode: key_code];
|
|
|
|
|
if ([self performKeyEquivalent: new_event])
|
|
|
|
|
return;
|
|
|
|
|
}
|
1999-12-16 04:53:50 +00:00
|
|
|
|
|
1999-10-12 15:05:37 +00:00
|
|
|
|
// Otherwise, pass the event up
|
|
|
|
|
[super keyDown: theEvent];
|
|
|
|
|
}
|
1999-10-04 06:18:17 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
/* Return mouse location in reciever's base coord system, ignores event
|
1999-06-09 08:54:08 +00:00
|
|
|
|
* loop status */
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (NSPoint) mouseLocationOutsideOfEventStream
|
|
|
|
|
{
|
2000-03-07 12:00:00 +00:00
|
|
|
|
NSPoint p;
|
1999-06-09 08:54:08 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
DPSmouselocation(GSCurrentContext(), &p.x, &p.y);
|
|
|
|
|
p = [self convertScreenToBase: p];
|
|
|
|
|
return p;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSEvent*) nextEventMatchingMask: (unsigned int)mask
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-06-09 08:54:08 +00:00
|
|
|
|
return [NSApp nextEventMatchingMask: mask
|
|
|
|
|
untilDate: nil
|
|
|
|
|
inMode: NSEventTrackingRunLoopMode
|
|
|
|
|
dequeue: YES];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSEvent*) nextEventMatchingMask: (unsigned int)mask
|
|
|
|
|
untilDate: (NSDate*)expiration
|
|
|
|
|
inMode: (NSString*)mode
|
|
|
|
|
dequeue: (BOOL)deqFlag
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-06-09 08:54:08 +00:00
|
|
|
|
return [NSApp nextEventMatchingMask: mask
|
|
|
|
|
untilDate: expiration
|
|
|
|
|
inMode: mode
|
|
|
|
|
dequeue: deqFlag];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) postEvent: (NSEvent*)event atStart: (BOOL)flag
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-06-09 08:54:08 +00:00
|
|
|
|
[NSApp postEvent: event atStart: flag];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) setAcceptsMouseMovedEvents: (BOOL)flag
|
1996-10-03 18:45:41 +00:00
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.accepts_mouse_moved = flag;
|
1996-10-03 18:45:41 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) _checkTrackingRectangles: (NSView*)theView
|
|
|
|
|
forEvent: (NSEvent*)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-05-07 20:08:51 +00:00
|
|
|
|
if (((NSViewPtr)theView)->_rFlags.has_trkrects)
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2000-01-10 02:09:33 +00:00
|
|
|
|
NSArray *tr = ((NSViewPtr)theView)->_tracking_rects;
|
1999-05-07 20:08:51 +00:00
|
|
|
|
unsigned count = [tr count];
|
1999-05-07 11:06:37 +00:00
|
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
|
/*
|
|
|
|
|
* Loop through the tracking rectangles
|
|
|
|
|
*/
|
|
|
|
|
if (count > 0)
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
1999-05-07 20:08:51 +00:00
|
|
|
|
GSTrackingRect *rects[count];
|
|
|
|
|
NSPoint loc = [theEvent locationInWindow];
|
|
|
|
|
unsigned i;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
|
[tr getObjects: rects];
|
1999-05-07 11:06:37 +00:00
|
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
|
for (i = 0; i < count; ++i)
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
1999-05-07 20:08:51 +00:00
|
|
|
|
BOOL last;
|
|
|
|
|
BOOL now;
|
|
|
|
|
GSTrackingRect *r = rects[i];
|
1999-05-07 11:06:37 +00:00
|
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
|
/* Check mouse at last point */
|
1999-07-15 17:04:25 +00:00
|
|
|
|
last = NSMouseInRect(last_point, r->rectangle, NO);
|
1999-05-07 20:08:51 +00:00
|
|
|
|
/* Check mouse at current point */
|
1999-07-15 17:04:25 +00:00
|
|
|
|
now = NSMouseInRect(loc, r->rectangle, NO);
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
|
if ((!last) && (now)) // Mouse entered event
|
1999-05-07 11:06:37 +00:00
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
if (r->flags.checked == NO)
|
|
|
|
|
{
|
|
|
|
|
if ([r->owner respondsToSelector:
|
|
|
|
|
@selector(mouseEntered:)])
|
|
|
|
|
r->flags.ownerRespondsToMouseEntered = YES;
|
|
|
|
|
if ([r->owner respondsToSelector:
|
|
|
|
|
@selector(mouseExited:)])
|
|
|
|
|
r->flags.ownerRespondsToMouseExited = YES;
|
|
|
|
|
r->flags.checked = YES;
|
|
|
|
|
}
|
|
|
|
|
if (r->flags.ownerRespondsToMouseEntered)
|
1999-05-07 20:08:51 +00:00
|
|
|
|
{
|
|
|
|
|
NSEvent *e;
|
|
|
|
|
|
|
|
|
|
e = [NSEvent enterExitEventWithType: NSMouseEntered
|
|
|
|
|
location: loc
|
|
|
|
|
modifierFlags: [theEvent modifierFlags]
|
|
|
|
|
timestamp: 0
|
|
|
|
|
windowNumber: [theEvent windowNumber]
|
|
|
|
|
context: NULL
|
|
|
|
|
eventNumber: 0
|
|
|
|
|
trackingNumber: r->tag
|
|
|
|
|
userData: r->user_data];
|
|
|
|
|
[r->owner mouseEntered: e];
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-05-07 11:06:37 +00:00
|
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
|
if ((last) && (!now)) // Mouse exited event
|
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
if (r->flags.checked == NO)
|
|
|
|
|
{
|
|
|
|
|
if ([r->owner respondsToSelector:
|
|
|
|
|
@selector(mouseEntered:)])
|
|
|
|
|
r->flags.ownerRespondsToMouseEntered = YES;
|
|
|
|
|
if ([r->owner respondsToSelector:
|
|
|
|
|
@selector(mouseExited:)])
|
|
|
|
|
r->flags.ownerRespondsToMouseExited = YES;
|
|
|
|
|
r->flags.checked = YES;
|
|
|
|
|
}
|
|
|
|
|
if (r->flags.ownerRespondsToMouseExited)
|
1999-05-07 20:08:51 +00:00
|
|
|
|
{
|
|
|
|
|
NSEvent *e;
|
|
|
|
|
|
|
|
|
|
e = [NSEvent enterExitEventWithType: NSMouseExited
|
|
|
|
|
location: loc
|
|
|
|
|
modifierFlags: [theEvent modifierFlags]
|
|
|
|
|
timestamp: 0
|
|
|
|
|
windowNumber: [theEvent windowNumber]
|
|
|
|
|
context: NULL
|
|
|
|
|
eventNumber: 0
|
|
|
|
|
trackingNumber: r->tag
|
|
|
|
|
userData: r->user_data];
|
|
|
|
|
[r->owner mouseExited: e];
|
|
|
|
|
}
|
1999-05-07 11:06:37 +00:00
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1999-05-07 11:06:37 +00:00
|
|
|
|
/*
|
|
|
|
|
* Check tracking rectangles for the subviews
|
|
|
|
|
*/
|
1999-05-07 20:08:51 +00:00
|
|
|
|
if (((NSViewPtr)theView)->_rFlags.has_subviews)
|
1999-05-07 11:06:37 +00:00
|
|
|
|
{
|
2000-01-10 02:09:33 +00:00
|
|
|
|
NSArray *sb = ((NSViewPtr)theView)->_sub_views;
|
1999-05-07 20:08:51 +00:00
|
|
|
|
unsigned count = [sb count];
|
1999-05-07 11:06:37 +00:00
|
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
|
if (count > 0)
|
|
|
|
|
{
|
|
|
|
|
NSView *subs[count];
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
|
|
[sb getObjects: subs];
|
|
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
|
(*ctImp)(self, ctSel, subs[i], theEvent);
|
|
|
|
|
}
|
1999-05-07 11:06:37 +00:00
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) _checkCursorRectangles: (NSView*)theView forEvent: (NSEvent*)theEvent
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
if (((NSViewPtr)theView)->_rFlags.valid_rects)
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2000-01-10 02:09:33 +00:00
|
|
|
|
NSArray *tr = ((NSViewPtr)theView)->_cursor_rects;
|
1999-05-07 20:08:51 +00:00
|
|
|
|
unsigned count = [tr count];
|
1999-05-07 11:06:37 +00:00
|
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
|
// Loop through cursor rectangles
|
|
|
|
|
if (count > 0)
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
1999-05-07 20:08:51 +00:00
|
|
|
|
GSTrackingRect *rects[count];
|
|
|
|
|
NSPoint loc = [theEvent locationInWindow];
|
|
|
|
|
unsigned i;
|
1999-05-07 11:06:37 +00:00
|
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
|
[tr getObjects: rects];
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < count; ++i)
|
1999-05-07 11:06:37 +00:00
|
|
|
|
{
|
1999-05-07 20:08:51 +00:00
|
|
|
|
GSTrackingRect *r = rects[i];
|
1999-07-15 17:04:25 +00:00
|
|
|
|
BOOL last;
|
|
|
|
|
BOOL now;
|
1999-05-07 20:08:51 +00:00
|
|
|
|
|
|
|
|
|
if ([r isValid] == NO)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check for presence of point in rectangle.
|
|
|
|
|
*/
|
1999-11-15 16:00:47 +00:00
|
|
|
|
last = NSMouseInRect(last_point, r->rectangle, NO);
|
|
|
|
|
now = NSMouseInRect(loc, r->rectangle, NO);
|
1999-05-07 20:08:51 +00:00
|
|
|
|
|
|
|
|
|
// Mouse entered
|
|
|
|
|
if ((!last) && (now))
|
|
|
|
|
{
|
|
|
|
|
NSEvent *e;
|
|
|
|
|
|
|
|
|
|
e = [NSEvent enterExitEventWithType: NSCursorUpdate
|
|
|
|
|
location: loc
|
|
|
|
|
modifierFlags: [theEvent modifierFlags]
|
|
|
|
|
timestamp: 0
|
|
|
|
|
windowNumber: [theEvent windowNumber]
|
|
|
|
|
context: [theEvent context]
|
|
|
|
|
eventNumber: 0
|
|
|
|
|
trackingNumber: (int)YES
|
2000-03-07 12:00:00 +00:00
|
|
|
|
userData: (void*)r];
|
1999-05-07 20:08:51 +00:00
|
|
|
|
[self postEvent: e atStart: YES];
|
|
|
|
|
}
|
|
|
|
|
// Mouse exited
|
|
|
|
|
if ((last) && (!now))
|
|
|
|
|
{
|
|
|
|
|
NSEvent *e;
|
|
|
|
|
|
|
|
|
|
e = [NSEvent enterExitEventWithType: NSCursorUpdate
|
|
|
|
|
location: loc
|
|
|
|
|
modifierFlags: [theEvent modifierFlags]
|
|
|
|
|
timestamp: 0
|
|
|
|
|
windowNumber: [theEvent windowNumber]
|
|
|
|
|
context: [theEvent context]
|
|
|
|
|
eventNumber: 0
|
|
|
|
|
trackingNumber: (int)NO
|
2000-03-07 12:00:00 +00:00
|
|
|
|
userData: (void*)r];
|
1999-05-07 20:08:51 +00:00
|
|
|
|
[self postEvent: e atStart: YES];
|
|
|
|
|
}
|
1999-05-07 11:06:37 +00:00
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-07 11:06:37 +00:00
|
|
|
|
/*
|
|
|
|
|
* Check cursor rectangles for the subviews
|
|
|
|
|
*/
|
1999-05-07 20:08:51 +00:00
|
|
|
|
if (((NSViewPtr)theView)->_rFlags.has_subviews)
|
1999-05-07 11:06:37 +00:00
|
|
|
|
{
|
2000-01-10 02:09:33 +00:00
|
|
|
|
NSArray *sb = ((NSViewPtr)theView)->_sub_views;
|
1999-05-07 20:08:51 +00:00
|
|
|
|
unsigned count = [sb count];
|
1999-05-07 11:06:37 +00:00
|
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
|
if (count > 0)
|
|
|
|
|
{
|
|
|
|
|
NSView *subs[count];
|
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
|
|
[sb getObjects: subs];
|
|
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
|
(*ccImp)(self, ccSel, subs[i], theEvent);
|
|
|
|
|
}
|
1999-05-07 11:06:37 +00:00
|
|
|
|
}
|
1997-03-05 01:11:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-10-21 18:08:50 +00:00
|
|
|
|
- (void) _processResizeEvent
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (gstate)
|
|
|
|
|
{
|
2000-03-07 12:00:00 +00:00
|
|
|
|
NSGraphicsContext *context = GSCurrentContext();
|
1999-10-21 18:08:50 +00:00
|
|
|
|
DPSgsave(context);
|
|
|
|
|
DPSsetgstate(context, gstate);
|
1999-12-13 22:14:54 +00:00
|
|
|
|
DPSupdatewindow(context, window_num);
|
|
|
|
|
DPScurrentgstate(context, gstate);
|
|
|
|
|
DPSpop(context);
|
|
|
|
|
DPSgrestore(context);
|
1999-10-21 18:08:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[self update];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) sendEvent: (NSEvent*)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-03-24 11:31:06 +00:00
|
|
|
|
NSView *v;
|
|
|
|
|
NSEventType type;
|
1998-11-12 10:49:00 +00:00
|
|
|
|
|
1999-11-15 21:45:56 +00:00
|
|
|
|
if (!_f.cursor_rects_valid)
|
1999-06-11 04:46:12 +00:00
|
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
|
[self resetCursorRects];
|
|
|
|
|
}
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1999-03-24 11:31:06 +00:00
|
|
|
|
type = [theEvent type];
|
|
|
|
|
switch (type)
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
1999-06-11 04:46:12 +00:00
|
|
|
|
case NSLeftMouseDown: // Left mouse down
|
2000-01-02 20:24:56 +00:00
|
|
|
|
{
|
|
|
|
|
BOOL wasKey = _f.is_key;
|
|
|
|
|
|
|
|
|
|
if ([NSApp isActive] == NO && self != [NSApp iconWindow])
|
|
|
|
|
{
|
|
|
|
|
[NSApp activateIgnoringOtherApps: YES];
|
|
|
|
|
}
|
|
|
|
|
if (_f.is_key == NO)
|
|
|
|
|
{
|
|
|
|
|
[self makeKeyAndOrderFront: self];
|
|
|
|
|
}
|
|
|
|
|
v = [content_view hitTest: [theEvent locationInWindow]];
|
|
|
|
|
if (first_responder != v)
|
|
|
|
|
{
|
|
|
|
|
[self makeFirstResponder: v];
|
|
|
|
|
}
|
|
|
|
|
if (wasKey == YES || [v acceptsFirstMouse: theEvent] == YES)
|
|
|
|
|
{
|
|
|
|
|
if ([NSHelpManager isContextHelpModeActive])
|
|
|
|
|
{
|
|
|
|
|
[v helpRequested: theEvent];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[v mouseDown: theEvent];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
last_point = [theEvent locationInWindow];
|
|
|
|
|
break;
|
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
case NSLeftMouseUp: // Left mouse up
|
1999-06-04 15:06:00 +00:00
|
|
|
|
v = first_responder; /* Send to the view that got the mouse down. */
|
1999-03-23 22:35:21 +00:00
|
|
|
|
[v mouseUp: theEvent];
|
|
|
|
|
last_point = [theEvent locationInWindow];
|
|
|
|
|
break;
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
case NSRightMouseDown: // Right mouse down
|
1999-03-23 22:35:21 +00:00
|
|
|
|
v = [content_view hitTest: [theEvent locationInWindow]];
|
|
|
|
|
[v rightMouseDown: theEvent];
|
|
|
|
|
last_point = [theEvent locationInWindow];
|
|
|
|
|
break;
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
case NSRightMouseUp: // Right mouse up
|
1999-03-23 22:35:21 +00:00
|
|
|
|
v = [content_view hitTest: [theEvent locationInWindow]];
|
|
|
|
|
[v rightMouseUp: theEvent];
|
|
|
|
|
last_point = [theEvent locationInWindow];
|
|
|
|
|
break;
|
|
|
|
|
|
1999-03-24 11:31:06 +00:00
|
|
|
|
case NSLeftMouseDragged: // Left mouse dragged
|
|
|
|
|
case NSRightMouseDragged: // Right mouse dragged
|
|
|
|
|
case NSMouseMoved: // Mouse moved
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case NSLeftMouseDragged:
|
|
|
|
|
v = [content_view hitTest: [theEvent locationInWindow]];
|
|
|
|
|
[v mouseDragged: theEvent];
|
|
|
|
|
break;
|
|
|
|
|
case NSRightMouseDragged:
|
|
|
|
|
v = [content_view hitTest: [theEvent locationInWindow]];
|
|
|
|
|
[v rightMouseDragged: theEvent];
|
|
|
|
|
break;
|
|
|
|
|
default:
|
1999-11-15 21:45:56 +00:00
|
|
|
|
if (_f.accepts_mouse_moved)
|
1999-03-24 11:31:06 +00:00
|
|
|
|
{
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* If the window is set to accept mouse movements, we need to
|
|
|
|
|
* forward the mouse movement to the correct view.
|
|
|
|
|
*/
|
1999-03-24 11:31:06 +00:00
|
|
|
|
v = [content_view hitTest: [theEvent locationInWindow]];
|
|
|
|
|
[v mouseMoved: theEvent];
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* We need to go through all of the views, and if there is any with
|
|
|
|
|
* a tracking rectangle then we need to determine if we should send
|
|
|
|
|
* a NSMouseEntered or NSMouseExited event.
|
|
|
|
|
*/
|
1999-05-07 11:06:37 +00:00
|
|
|
|
(*ctImp)(self, ctSel, content_view, theEvent);
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
1999-11-15 21:45:56 +00:00
|
|
|
|
if (_f.is_key)
|
1999-03-24 11:31:06 +00:00
|
|
|
|
{
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* We need to go through all of the views, and if there is any with
|
|
|
|
|
* a cursor rectangle then we need to determine if we should send a
|
|
|
|
|
* cursor update event.
|
|
|
|
|
*/
|
1999-05-07 11:06:37 +00:00
|
|
|
|
(*ccImp)(self, ccSel, content_view, theEvent);
|
1999-03-24 11:31:06 +00:00
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
|
|
|
|
last_point = [theEvent locationInWindow];
|
|
|
|
|
break;
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
case NSMouseEntered: // Mouse entered
|
|
|
|
|
case NSMouseExited: // Mouse exited
|
1999-03-23 22:35:21 +00:00
|
|
|
|
break;
|
|
|
|
|
|
1999-12-16 04:53:50 +00:00
|
|
|
|
case NSKeyDown:
|
1999-03-23 22:35:21 +00:00
|
|
|
|
/*
|
|
|
|
|
* 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;
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
case NSKeyUp: // Key up
|
|
|
|
|
/*
|
|
|
|
|
* send message to the object that got the key down
|
|
|
|
|
*/
|
|
|
|
|
if (original_responder)
|
|
|
|
|
[original_responder keyUp: theEvent];
|
|
|
|
|
break;
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
case NSFlagsChanged: // Flags changed
|
1999-01-12 12:29:05 +00:00
|
|
|
|
break;
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
case NSCursorUpdate: // Cursor update
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2000-03-07 12:00:00 +00:00
|
|
|
|
GSTrackingRect *r =(GSTrackingRect*)[theEvent userData];
|
|
|
|
|
NSCursor *c = (NSCursor*)[r owner];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
if ([theEvent trackingNumber]) // It's a mouse entered
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
[c mouseEntered: theEvent];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
1999-06-11 04:46:12 +00:00
|
|
|
|
else // it is a mouse exited
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
1999-11-15 16:00:47 +00:00
|
|
|
|
[c mouseExited: theEvent];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
case NSAppKitDefined:
|
1999-07-06 11:56:22 +00:00
|
|
|
|
{
|
1999-07-29 20:58:04 +00:00
|
|
|
|
id dragInfo;
|
|
|
|
|
int action;
|
|
|
|
|
NSEvent *e;
|
1999-07-06 11:56:22 +00:00
|
|
|
|
GSAppKitSubtype sub = [theEvent subtype];
|
|
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
|
|
|
|
|
|
|
|
|
switch (sub)
|
|
|
|
|
{
|
|
|
|
|
case GSAppKitWindowMoved:
|
|
|
|
|
frame.origin.x = (float)[theEvent data1];
|
|
|
|
|
frame.origin.y = (float)[theEvent data2];
|
2000-03-08 14:15:17 +00:00
|
|
|
|
NSDebugLLog(@"Moving", @"Move event: %d %@",
|
|
|
|
|
window_num, NSStringFromPoint(frame.origin));
|
1999-07-06 11:56:22 +00:00
|
|
|
|
if (autosave_name != nil)
|
|
|
|
|
{
|
|
|
|
|
[self saveFrameUsingName: autosave_name];
|
|
|
|
|
}
|
|
|
|
|
[nc postNotificationName: NSWindowDidMoveNotification
|
|
|
|
|
object: self];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GSAppKitWindowResized:
|
|
|
|
|
frame.size.width = (float)[theEvent data1];
|
|
|
|
|
frame.size.height = (float)[theEvent data2];
|
1999-11-16 07:00:43 +00:00
|
|
|
|
if (autosave_name != nil)
|
|
|
|
|
{
|
|
|
|
|
[self saveFrameUsingName: autosave_name];
|
|
|
|
|
}
|
1999-12-08 15:01:52 +00:00
|
|
|
|
{
|
|
|
|
|
NSRect rect = frame;
|
1999-07-06 11:56:22 +00:00
|
|
|
|
|
2000-03-08 14:15:17 +00:00
|
|
|
|
rect = [NSWindow contentRectForFrameRect: rect
|
|
|
|
|
styleMask: style_mask];
|
1999-12-08 15:01:52 +00:00
|
|
|
|
rect.origin = NSZeroPoint;
|
|
|
|
|
[_wv setFrame: rect];
|
|
|
|
|
[_wv setNeedsDisplay: YES];
|
|
|
|
|
}
|
1999-10-21 18:08:50 +00:00
|
|
|
|
[self _processResizeEvent];
|
1999-07-06 11:56:22 +00:00
|
|
|
|
[nc postNotificationName: NSWindowDidResizeNotification
|
|
|
|
|
object: self];
|
|
|
|
|
break;
|
2000-03-08 14:15:17 +00:00
|
|
|
|
|
1999-10-21 18:08:50 +00:00
|
|
|
|
case GSAppKitWindowClose:
|
|
|
|
|
[self performClose: NSApp];
|
|
|
|
|
break;
|
1999-07-06 11:56:22 +00:00
|
|
|
|
|
1999-07-29 20:58:04 +00:00
|
|
|
|
#define GSPerformDragSelector(view, sel, info, action) \
|
1999-12-07 05:53:26 +00:00
|
|
|
|
if (view == content_view && _delegate) \
|
|
|
|
|
action = (int)[_delegate performSelector: sel withObject: \
|
1999-07-29 20:58:04 +00:00
|
|
|
|
info]; \
|
|
|
|
|
else \
|
|
|
|
|
action = (int)[view performSelector: sel withObject: info]
|
|
|
|
|
#define GSPerformVoidDragSelector(view, sel, info) \
|
1999-12-07 05:53:26 +00:00
|
|
|
|
if (view == content_view && _delegate) \
|
|
|
|
|
[_delegate performSelector: sel withObject: info]; \
|
1999-07-29 20:58:04 +00:00
|
|
|
|
else \
|
|
|
|
|
[view performSelector: sel withObject: info]
|
|
|
|
|
|
|
|
|
|
case GSAppKitDraggingEnter:
|
|
|
|
|
case GSAppKitDraggingUpdate:
|
|
|
|
|
v = [content_view hitTest: [theEvent locationInWindow]];
|
|
|
|
|
if (!v)
|
|
|
|
|
v = content_view;
|
|
|
|
|
dragInfo = [GSCurrentContext() _dragInfo];
|
1999-11-15 21:45:56 +00:00
|
|
|
|
if (_lastDragView && _lastDragView != v && _f.accepts_drag)
|
1999-10-21 18:08:50 +00:00
|
|
|
|
{
|
1999-12-16 04:53:50 +00:00
|
|
|
|
GSPerformVoidDragSelector(_lastDragView,
|
1999-07-29 20:58:04 +00:00
|
|
|
|
@selector(draggingExited:), dragInfo);
|
1999-10-21 18:08:50 +00:00
|
|
|
|
}
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.accepts_drag = GSViewAcceptsDrag(v, dragInfo);
|
|
|
|
|
if (_lastDragView != v && _f.accepts_drag)
|
1999-10-21 18:08:50 +00:00
|
|
|
|
{
|
1999-12-16 04:53:50 +00:00
|
|
|
|
GSPerformDragSelector(v, @selector(draggingEntered:),
|
1999-07-29 20:58:04 +00:00
|
|
|
|
dragInfo, action);
|
1999-10-21 18:08:50 +00:00
|
|
|
|
}
|
1999-07-29 20:58:04 +00:00
|
|
|
|
else
|
1999-10-21 18:08:50 +00:00
|
|
|
|
{
|
1999-12-16 04:53:50 +00:00
|
|
|
|
GSPerformDragSelector(v, @selector(draggingUpdated:),
|
1999-07-29 20:58:04 +00:00
|
|
|
|
dragInfo, action);
|
1999-10-21 18:08:50 +00:00
|
|
|
|
}
|
1999-07-29 20:58:04 +00:00
|
|
|
|
e = [NSEvent otherEventWithType: NSAppKitDefined
|
|
|
|
|
location: [theEvent locationInWindow]
|
|
|
|
|
modifierFlags: 0
|
|
|
|
|
timestamp: 0
|
2000-01-10 02:09:33 +00:00
|
|
|
|
windowNumber: window_num
|
1999-07-29 20:58:04 +00:00
|
|
|
|
context: GSCurrentContext()
|
|
|
|
|
subtype: GSAppKitDraggingStatus
|
|
|
|
|
data1: [theEvent data1]
|
|
|
|
|
data2: action];
|
|
|
|
|
[GSCurrentContext() _postExternalEvent: e];
|
|
|
|
|
_lastDragView = v;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GSAppKitDraggingStatus:
|
2000-01-16 09:52:49 +00:00
|
|
|
|
NSDebugLLog(@"NSDragging",
|
|
|
|
|
@"Internal: dropped GSAppKitDraggingStatus event");
|
1999-07-29 20:58:04 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GSAppKitDraggingExit:
|
1999-09-09 02:56:20 +00:00
|
|
|
|
dragInfo = [GSCurrentContext() _dragInfo];
|
1999-11-15 21:45:56 +00:00
|
|
|
|
if (_lastDragView && _f.accepts_drag)
|
1999-10-21 18:08:50 +00:00
|
|
|
|
{
|
1999-12-16 04:53:50 +00:00
|
|
|
|
GSPerformDragSelector(_lastDragView,
|
1999-07-29 20:58:04 +00:00
|
|
|
|
@selector(draggingExited:), dragInfo,
|
|
|
|
|
action);
|
1999-10-21 18:08:50 +00:00
|
|
|
|
}
|
1999-12-22 10:12:48 +00:00
|
|
|
|
_lastDragView = nil;
|
1999-07-29 20:58:04 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GSAppKitDraggingDrop:
|
1999-11-15 21:45:56 +00:00
|
|
|
|
if (_lastDragView && _f.accepts_drag)
|
1999-07-29 20:58:04 +00:00
|
|
|
|
{
|
1999-09-09 02:56:20 +00:00
|
|
|
|
dragInfo = [GSCurrentContext() _dragInfo];
|
1999-12-16 04:53:50 +00:00
|
|
|
|
GSPerformDragSelector(_lastDragView,
|
|
|
|
|
@selector(prepareForDragOperation:),
|
1999-07-29 20:58:04 +00:00
|
|
|
|
dragInfo, action);
|
|
|
|
|
if (action)
|
1999-10-21 18:08:50 +00:00
|
|
|
|
{
|
1999-12-16 04:53:50 +00:00
|
|
|
|
GSPerformDragSelector(_lastDragView,
|
|
|
|
|
@selector(performDragOperation:),
|
1999-07-29 20:58:04 +00:00
|
|
|
|
dragInfo, action);
|
1999-10-21 18:08:50 +00:00
|
|
|
|
}
|
1999-07-29 20:58:04 +00:00
|
|
|
|
if (action)
|
1999-10-21 18:08:50 +00:00
|
|
|
|
{
|
1999-12-16 04:53:50 +00:00
|
|
|
|
GSPerformVoidDragSelector(_lastDragView,
|
|
|
|
|
@selector(concludeDragOperation:),
|
1999-07-29 20:58:04 +00:00
|
|
|
|
dragInfo);
|
1999-10-21 18:08:50 +00:00
|
|
|
|
}
|
1999-07-29 20:58:04 +00:00
|
|
|
|
}
|
1999-12-22 10:12:48 +00:00
|
|
|
|
_lastDragView = nil;
|
1999-07-29 20:58:04 +00:00
|
|
|
|
e = [NSEvent otherEventWithType: NSAppKitDefined
|
|
|
|
|
location: [theEvent locationInWindow]
|
|
|
|
|
modifierFlags: 0
|
|
|
|
|
timestamp: 0
|
2000-01-10 02:09:33 +00:00
|
|
|
|
windowNumber: window_num
|
1999-07-29 20:58:04 +00:00
|
|
|
|
context: GSCurrentContext()
|
|
|
|
|
subtype: GSAppKitDraggingFinished
|
|
|
|
|
data1: [theEvent data1]
|
|
|
|
|
data2: 0];
|
|
|
|
|
[GSCurrentContext() _postExternalEvent: e];
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GSAppKitDraggingFinished:
|
1999-12-22 10:12:48 +00:00
|
|
|
|
_lastDragView = nil;
|
2000-01-16 09:52:49 +00:00
|
|
|
|
NSDebugLLog(@"NSDragging",
|
|
|
|
|
@"Internal: dropped GSAppKitDraggingFinished event");
|
1999-07-29 20:58:04 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
1999-07-06 11:56:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
1999-12-16 04:53:50 +00:00
|
|
|
|
case NSPeriodic:
|
1999-06-11 04:46:12 +00:00
|
|
|
|
case NSSystemDefined:
|
|
|
|
|
case NSApplicationDefined:
|
1999-03-23 22:35:21 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (BOOL) tryToPerform: (SEL)anAction with: (id)anObject
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
// FIXME: On NO we should hand it on to the delegate
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return ([super tryToPerform: anAction with: anObject]);
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (BOOL) worksWhenModal
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) selectKeyViewFollowingView: (NSView*)aView
|
1999-10-08 07:17:19 +00:00
|
|
|
|
{
|
|
|
|
|
NSView *theView = nil;
|
1999-12-16 04:53:50 +00:00
|
|
|
|
|
1999-10-08 07:17:19 +00:00
|
|
|
|
if ([aView isKindOfClass: viewClass])
|
|
|
|
|
theView = [aView nextValidKeyView];
|
|
|
|
|
if (theView)
|
1999-11-14 21:16:04 +00:00
|
|
|
|
{
|
|
|
|
|
[self makeFirstResponder: theView];
|
1999-11-18 01:00:58 +00:00
|
|
|
|
if ([theView respondsToSelector:@selector(selectText:)])
|
|
|
|
|
{
|
|
|
|
|
_selection_direction = NSSelectingNext;
|
|
|
|
|
[(id)theView selectText: self];
|
|
|
|
|
_selection_direction = NSDirectSelection;
|
|
|
|
|
}
|
1999-11-14 21:16:04 +00:00
|
|
|
|
}
|
1999-10-08 07:17:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) selectKeyViewPrecedingView: (NSView*)aView
|
1999-10-08 07:17:19 +00:00
|
|
|
|
{
|
|
|
|
|
NSView *theView = nil;
|
|
|
|
|
|
|
|
|
|
if ([aView isKindOfClass: viewClass])
|
|
|
|
|
theView = [aView previousValidKeyView];
|
|
|
|
|
if (theView)
|
1999-11-14 21:16:04 +00:00
|
|
|
|
{
|
|
|
|
|
[self makeFirstResponder: theView];
|
1999-11-18 01:00:58 +00:00
|
|
|
|
if ([theView respondsToSelector:@selector(selectText:)])
|
|
|
|
|
{
|
|
|
|
|
_selection_direction = NSSelectingPrevious;
|
|
|
|
|
[(id)theView selectText: self];
|
|
|
|
|
_selection_direction = NSDirectSelection;
|
|
|
|
|
}
|
1999-11-14 21:16:04 +00:00
|
|
|
|
}
|
1999-10-08 07:17:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) selectNextKeyView: (id)sender
|
|
|
|
|
{
|
|
|
|
|
NSView *theView = nil;
|
1999-12-16 04:53:50 +00:00
|
|
|
|
|
|
|
|
|
if ([first_responder isKindOfClass: viewClass])
|
1999-10-08 07:17:19 +00:00
|
|
|
|
theView = [first_responder nextValidKeyView];
|
1999-12-16 04:53:50 +00:00
|
|
|
|
|
1999-11-18 01:00:58 +00:00
|
|
|
|
if ((theView == nil) && (_initial_first_responder))
|
1999-10-08 07:17:19 +00:00
|
|
|
|
{
|
|
|
|
|
if ([_initial_first_responder acceptsFirstResponder])
|
|
|
|
|
theView = _initial_first_responder;
|
1999-12-16 04:53:50 +00:00
|
|
|
|
else
|
1999-10-08 07:17:19 +00:00
|
|
|
|
theView = [_initial_first_responder nextValidKeyView];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (theView)
|
1999-11-14 21:16:04 +00:00
|
|
|
|
{
|
|
|
|
|
[self makeFirstResponder: theView];
|
1999-11-18 01:00:58 +00:00
|
|
|
|
if ([theView respondsToSelector:@selector(selectText:)])
|
|
|
|
|
{
|
|
|
|
|
_selection_direction = NSSelectingNext;
|
|
|
|
|
[(id)theView selectText: self];
|
|
|
|
|
_selection_direction = NSDirectSelection;
|
|
|
|
|
}
|
1999-11-14 21:16:04 +00:00
|
|
|
|
}
|
1999-10-08 07:17:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) selectPreviousKeyView: (id)sender
|
|
|
|
|
{
|
|
|
|
|
NSView *theView = nil;
|
1999-12-16 04:53:50 +00:00
|
|
|
|
|
|
|
|
|
if ([first_responder isKindOfClass: viewClass])
|
1999-10-08 07:17:19 +00:00
|
|
|
|
theView = [first_responder previousValidKeyView];
|
1999-12-16 04:53:50 +00:00
|
|
|
|
|
1999-11-18 01:00:58 +00:00
|
|
|
|
if ((theView == nil) && (_initial_first_responder))
|
1999-10-08 07:17:19 +00:00
|
|
|
|
{
|
|
|
|
|
if ([_initial_first_responder acceptsFirstResponder])
|
|
|
|
|
theView = _initial_first_responder;
|
1999-12-16 04:53:50 +00:00
|
|
|
|
else
|
1999-10-08 07:17:19 +00:00
|
|
|
|
theView = [_initial_first_responder previousValidKeyView];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (theView)
|
1999-11-14 21:16:04 +00:00
|
|
|
|
{
|
|
|
|
|
[self makeFirstResponder: theView];
|
1999-11-18 01:00:58 +00:00
|
|
|
|
if ([theView respondsToSelector:@selector(selectText:)])
|
|
|
|
|
{
|
|
|
|
|
_selection_direction = NSSelectingPrevious;
|
|
|
|
|
[(id)theView selectText: self];
|
|
|
|
|
_selection_direction = NSDirectSelection;
|
|
|
|
|
}
|
1999-11-14 21:16:04 +00:00
|
|
|
|
}
|
1999-10-08 07:17:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-11-18 01:00:58 +00:00
|
|
|
|
// This is invoked by selectText: of some views (eg matrixes),
|
|
|
|
|
// to know whether they have received it from the window, and
|
1999-12-16 04:53:50 +00:00
|
|
|
|
// if so, in which direction is the selection moving (so that they know
|
1999-11-18 01:00:58 +00:00
|
|
|
|
// if they should select the last or the first editable cell).
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSSelectionDirection) keyViewSelectionDirection
|
1999-12-16 04:53:50 +00:00
|
|
|
|
{
|
1999-11-18 01:00:58 +00:00
|
|
|
|
return _selection_direction;
|
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Dragging
|
|
|
|
|
*/
|
1999-07-04 18:13:15 +00:00
|
|
|
|
- (void) dragImage: (NSImage*)anImage
|
|
|
|
|
at: (NSPoint)baseLocation
|
|
|
|
|
offset: (NSSize)initialOffset
|
|
|
|
|
event: (NSEvent*)event
|
|
|
|
|
pasteboard: (NSPasteboard*)pboard
|
|
|
|
|
source: (id)sourceObject
|
|
|
|
|
slideBack: (BOOL)slideFlag
|
1998-11-12 10:49:00 +00:00
|
|
|
|
{
|
1999-12-17 12:06:35 +00:00
|
|
|
|
[_wv dragImage: anImage
|
|
|
|
|
at: baseLocation
|
|
|
|
|
offset: initialOffset
|
|
|
|
|
event: event
|
|
|
|
|
pasteboard: pboard
|
|
|
|
|
source: sourceObject
|
|
|
|
|
slideBack: slideFlag];
|
1998-11-12 10:49:00 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-06-01 17:05:57 +00:00
|
|
|
|
- (void) registerForDraggedTypes: (NSArray*)newTypes
|
1998-11-12 10:49:00 +00:00
|
|
|
|
{
|
1999-12-17 12:06:35 +00:00
|
|
|
|
[_wv registerForDraggedTypes: newTypes];
|
1998-11-12 10:49:00 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) unregisterDraggedTypes
|
1998-11-12 10:49:00 +00:00
|
|
|
|
{
|
1999-12-17 12:06:35 +00:00
|
|
|
|
[_wv unregisterDraggedTypes];
|
1998-11-12 10:49:00 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Services and windows menu support
|
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (BOOL) isExcludedFromWindowsMenu
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
return _f.menu_exclude;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
- (void) setExcludedFromWindowsMenu: (BOOL)flag
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-11-30 20:26:33 +00:00
|
|
|
|
if (_f.menu_exclude != flag)
|
|
|
|
|
{
|
|
|
|
|
_f.menu_exclude = flag;
|
1999-12-08 15:01:52 +00:00
|
|
|
|
if (_f.has_opened == YES)
|
1999-11-30 20:26:33 +00:00
|
|
|
|
{
|
1999-12-08 15:01:52 +00:00
|
|
|
|
if (_f.menu_exclude == NO)
|
|
|
|
|
{
|
|
|
|
|
BOOL isFileName;
|
|
|
|
|
|
|
|
|
|
isFileName = [window_title isEqual: represented_filename];
|
|
|
|
|
|
|
|
|
|
[NSApp addWindowsItem: self
|
|
|
|
|
title: window_title
|
|
|
|
|
filename: isFileName];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
[NSApp removeWindowsItem: self];
|
|
|
|
|
}
|
1999-11-30 20:26:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (id) validRequestorForSendType: (NSString*)sendType
|
|
|
|
|
returnType: (NSString*)returnType
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
|
id result = nil;
|
1998-11-24 15:25:22 +00:00
|
|
|
|
|
2000-03-04 07:55:42 +00:00
|
|
|
|
// FIXME: We should not forward this method if the delegate is a NSResponder
|
1999-12-07 05:53:26 +00:00
|
|
|
|
if (_delegate && [_delegate respondsToSelector: _cmd])
|
|
|
|
|
result = [_delegate validRequestorForSendType: sendType
|
1999-03-23 22:35:21 +00:00
|
|
|
|
returnType: returnType];
|
1998-11-24 15:25:22 +00:00
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
|
if (result == nil)
|
1999-06-09 08:54:08 +00:00
|
|
|
|
result = [NSApp validRequestorForSendType: sendType
|
|
|
|
|
returnType: returnType];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return result;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Saving and restoring the frame
|
|
|
|
|
*/
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSString*) frameAutosaveName
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-07-06 05:37:15 +00:00
|
|
|
|
return autosave_name;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) saveFrameUsingName: (NSString*)name
|
1998-11-12 10:49:00 +00:00
|
|
|
|
{
|
1999-11-16 09:40:14 +00:00
|
|
|
|
NSUserDefaults *defs;
|
|
|
|
|
NSString *key;
|
|
|
|
|
id obj;
|
1999-07-06 05:37:15 +00:00
|
|
|
|
|
|
|
|
|
[windowsLock lock];
|
1999-11-16 09:40:14 +00:00
|
|
|
|
defs = [NSUserDefaults standardUserDefaults];
|
|
|
|
|
obj = [self stringWithSavedFrame];
|
2000-01-07 16:46:35 +00:00
|
|
|
|
key = [NSString stringWithFormat: @"NSWindow Frame %@", name];
|
1999-11-16 09:40:14 +00:00
|
|
|
|
[defs setObject: obj forKey: key];
|
1999-07-06 05:37:15 +00:00
|
|
|
|
[windowsLock unlock];
|
1998-11-12 10:49:00 +00:00
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (BOOL) setFrameAutosaveName: (NSString*)name
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-12-15 15:28:18 +00:00
|
|
|
|
NSString *nameToRemove = nil;
|
|
|
|
|
|
1999-07-06 05:37:15 +00:00
|
|
|
|
if ([name isEqual: autosave_name])
|
|
|
|
|
{
|
|
|
|
|
return YES; /* That's our name already. */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[windowsLock lock];
|
|
|
|
|
if ([autosaveNames member: name] != nil)
|
|
|
|
|
{
|
|
|
|
|
[windowsLock unlock];
|
|
|
|
|
return NO; /* Name in use elsewhere. */
|
|
|
|
|
}
|
|
|
|
|
if (autosave_name != nil)
|
|
|
|
|
{
|
1999-12-15 15:28:18 +00:00
|
|
|
|
if (name == nil || [name isEqual: @""] == YES)
|
|
|
|
|
{
|
|
|
|
|
nameToRemove = RETAIN(autosave_name);
|
|
|
|
|
}
|
1999-07-06 05:37:15 +00:00
|
|
|
|
[autosaveNames removeObject: autosave_name];
|
|
|
|
|
autosave_name = nil;
|
|
|
|
|
}
|
|
|
|
|
if (name != nil && [name isEqual: @""] == NO)
|
|
|
|
|
{
|
|
|
|
|
name = [name copy];
|
|
|
|
|
[autosaveNames addObject: name];
|
|
|
|
|
autosave_name = name;
|
2000-02-21 15:33:30 +00:00
|
|
|
|
RELEASE(name);
|
1999-07-06 05:37:15 +00:00
|
|
|
|
}
|
1999-12-15 15:28:18 +00:00
|
|
|
|
else if (nameToRemove != nil)
|
1999-12-01 08:26:33 +00:00
|
|
|
|
{
|
|
|
|
|
NSUserDefaults *defs;
|
|
|
|
|
NSString *key;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Autosave name cleared - remove from defaults database.
|
|
|
|
|
*/
|
|
|
|
|
defs = [NSUserDefaults standardUserDefaults];
|
2000-01-07 16:46:35 +00:00
|
|
|
|
key = [NSString stringWithFormat: @"NSWindow Frame %@", nameToRemove];
|
|
|
|
|
[defs removeObjectForKey: key];
|
1999-12-15 15:28:18 +00:00
|
|
|
|
RELEASE(nameToRemove);
|
1999-12-01 08:26:33 +00:00
|
|
|
|
}
|
1999-07-06 05:37:15 +00:00
|
|
|
|
[windowsLock unlock];
|
|
|
|
|
return YES;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) setFrameFromString: (NSString*)string
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-11-16 07:00:43 +00:00
|
|
|
|
NSScanner *scanner = [NSScanner scannerWithString: string];
|
|
|
|
|
NSRect nRect;
|
|
|
|
|
NSRect sRect;
|
|
|
|
|
NSRect fRect;
|
|
|
|
|
int value;
|
1999-07-06 05:37:15 +00:00
|
|
|
|
|
1999-11-16 07:00:43 +00:00
|
|
|
|
/*
|
|
|
|
|
* Scan in the window frame (flipped coordinate system).
|
|
|
|
|
*/
|
|
|
|
|
if ([scanner scanInt: &value] == NO)
|
1999-09-09 02:56:20 +00:00
|
|
|
|
{
|
1999-11-16 07:00:43 +00:00
|
|
|
|
NSLog(@"Bad window frame format - x-coord missing");
|
|
|
|
|
return;
|
1999-09-09 02:56:20 +00:00
|
|
|
|
}
|
1999-11-16 07:00:43 +00:00
|
|
|
|
fRect.origin.x = value;
|
|
|
|
|
|
|
|
|
|
if ([scanner scanInt: &value] == NO)
|
1999-09-09 02:56:20 +00:00
|
|
|
|
{
|
1999-11-16 07:00:43 +00:00
|
|
|
|
NSLog(@"Bad window frame format - y-coord missing");
|
|
|
|
|
return;
|
1999-09-09 02:56:20 +00:00
|
|
|
|
}
|
1999-11-16 07:00:43 +00:00
|
|
|
|
fRect.origin.y = value;
|
|
|
|
|
|
|
|
|
|
if ([scanner scanInt: &value] == NO)
|
1999-09-09 02:56:20 +00:00
|
|
|
|
{
|
1999-11-16 07:00:43 +00:00
|
|
|
|
NSLog(@"Bad window frame format - width missing");
|
|
|
|
|
return;
|
1999-09-09 02:56:20 +00:00
|
|
|
|
}
|
1999-11-16 07:00:43 +00:00
|
|
|
|
fRect.size.width = value;
|
|
|
|
|
|
|
|
|
|
if ([scanner scanInt: &value] == NO)
|
1999-09-09 02:56:20 +00:00
|
|
|
|
{
|
1999-11-16 07:00:43 +00:00
|
|
|
|
NSLog(@"Bad window frame format - height missing");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
fRect.size.height = value;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Scan in the frame for the area the window was placed in in screen.
|
|
|
|
|
*/
|
|
|
|
|
if ([scanner scanInt: &value] == NO)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Bad screen frame format - x-coord missing");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
sRect.origin.x = value;
|
|
|
|
|
|
|
|
|
|
if ([scanner scanInt: &value] == NO)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Bad screen frame format - y-coord missing");
|
|
|
|
|
return;
|
1999-09-09 02:56:20 +00:00
|
|
|
|
}
|
1999-11-16 07:00:43 +00:00
|
|
|
|
sRect.origin.y = value;
|
|
|
|
|
|
|
|
|
|
if ([scanner scanInt: &value] == NO)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Bad screen frame format - width missing");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
sRect.size.width = value;
|
|
|
|
|
|
|
|
|
|
if ([scanner scanInt: &value] == NO)
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Bad screen frame format - height missing");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
sRect.size.height = value;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* FIXME - the screen rectangle should give the area of the screen in which
|
|
|
|
|
* the window could be placed (ie a rectangle excluding the dock), but
|
|
|
|
|
* there is no API for that yet - so we just use the screen at present.
|
|
|
|
|
*/
|
|
|
|
|
nRect = [[NSScreen mainScreen] frame];
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* FIXME - if the stored screen area is not the same as that currently
|
|
|
|
|
* available, we should probably adjust the window frame (position) in
|
|
|
|
|
* some way to try to amke layout sensible.
|
|
|
|
|
*/
|
|
|
|
|
if (NSEqualRects(nRect, sRect) == NO)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Convert frame from flipped to normal coordinates.
|
|
|
|
|
*/
|
|
|
|
|
fRect.origin.y -= fRect.size.height;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check and set frame.
|
|
|
|
|
*/
|
|
|
|
|
if (maximum_size.width > 0 && fRect.size.width > maximum_size.width)
|
|
|
|
|
{
|
|
|
|
|
fRect.size.width = maximum_size.width;
|
|
|
|
|
}
|
|
|
|
|
if (maximum_size.height > 0 && fRect.size.height > maximum_size.height)
|
|
|
|
|
{
|
|
|
|
|
fRect.size.height = maximum_size.height;
|
|
|
|
|
}
|
|
|
|
|
if (fRect.size.width < minimum_size.width)
|
|
|
|
|
{
|
|
|
|
|
fRect.size.width = minimum_size.width;
|
|
|
|
|
}
|
|
|
|
|
if (fRect.size.height < minimum_size.height)
|
|
|
|
|
{
|
|
|
|
|
fRect.size.height = minimum_size.height;
|
|
|
|
|
}
|
|
|
|
|
[self setFrame: fRect display: YES];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (BOOL) setFrameUsingName: (NSString*)name
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-11-16 09:40:14 +00:00
|
|
|
|
NSUserDefaults *defs;
|
|
|
|
|
id obj;
|
2000-01-07 16:46:35 +00:00
|
|
|
|
NSString *key;
|
1999-07-06 05:37:15 +00:00
|
|
|
|
|
|
|
|
|
[windowsLock lock];
|
1999-11-16 09:40:14 +00:00
|
|
|
|
defs = [NSUserDefaults standardUserDefaults];
|
2000-01-07 16:46:35 +00:00
|
|
|
|
key = [NSString stringWithFormat: @"NSWindow Frame %@", name];
|
|
|
|
|
obj = [defs objectForKey: key];
|
1999-07-06 05:37:15 +00:00
|
|
|
|
[windowsLock unlock];
|
|
|
|
|
if (obj == nil)
|
|
|
|
|
return NO;
|
|
|
|
|
[self setFrameFromString: obj];
|
|
|
|
|
return YES;
|
1998-11-12 10:49:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-01-07 16:46:35 +00:00
|
|
|
|
- (NSString*) stringWithSavedFrame
|
1998-12-17 13:06:17 +00:00
|
|
|
|
{
|
1999-11-16 07:00:43 +00:00
|
|
|
|
NSRect fRect;
|
|
|
|
|
NSRect sRect;
|
|
|
|
|
|
|
|
|
|
fRect = frame;
|
|
|
|
|
fRect.origin.y += fRect.size.height; /* Make flipped */
|
|
|
|
|
/*
|
|
|
|
|
* FIXME - the screen rectangle should give the area of the screen in which
|
|
|
|
|
* the window could be placed (ie a rectangle excluding the dock), but
|
|
|
|
|
* there is no API for that yet - so we just use the screen at present.
|
|
|
|
|
*/
|
|
|
|
|
sRect = [[NSScreen mainScreen] frame];
|
|
|
|
|
|
1999-11-16 09:40:14 +00:00
|
|
|
|
return [NSString stringWithFormat: @"%d %d %d %d %d %d % d %d ",
|
1999-11-16 07:00:43 +00:00
|
|
|
|
(int)fRect.origin.x, (int)fRect.origin.y,
|
|
|
|
|
(int)fRect.size.width, (int)fRect.size.height,
|
|
|
|
|
(int)sRect.origin.x, (int)sRect.origin.y,
|
|
|
|
|
(int)sRect.size.width, (int)sRect.size.height];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-03-04 07:55:42 +00:00
|
|
|
|
/*
|
|
|
|
|
* Printing and postscript
|
|
|
|
|
*/
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSData*) dataWithEPSInsideRect: (NSRect)rect
|
2000-03-04 07:55:42 +00:00
|
|
|
|
{
|
|
|
|
|
// FIXME: The implementation of this method is missing
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) fax: (id)sender
|
|
|
|
|
{
|
|
|
|
|
// FIXME: This method is missing
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) print: (id)sender
|
|
|
|
|
{
|
|
|
|
|
// FIXME: This method is missing
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Zooming
|
|
|
|
|
*/
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (BOOL) isZoomed
|
2000-03-04 07:55:42 +00:00
|
|
|
|
{
|
|
|
|
|
// FIXME: Method is missing
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-03 02:22:11 +00:00
|
|
|
|
- (void) performZoom: (id)sender
|
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
// FIXME: We should check for the style and highlight the button
|
|
|
|
|
[self zoom: sender];
|
2000-03-03 02:22:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) zoom: (id)sender
|
|
|
|
|
{
|
|
|
|
|
NSLog (@"[NSWindow zoom:] not implemented yet");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
2000-03-04 07:55:42 +00:00
|
|
|
|
* Default botton
|
1999-06-11 04:46:12 +00:00
|
|
|
|
*/
|
2000-03-04 07:55:42 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (NSButtonCell*) defaultButtonCell
|
1999-03-23 22:35:21 +00:00
|
|
|
|
{
|
2000-03-04 07:55:42 +00:00
|
|
|
|
// FIXME: Method is missing
|
1999-03-23 22:35:21 +00:00
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) setDefaultButtonCell: (NSButtonCell*)aButtonCell
|
2000-03-04 07:55:42 +00:00
|
|
|
|
{
|
|
|
|
|
// FIXME: Method is missing
|
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) disableKeyEquivalentForDefaultButtonCell
|
2000-03-04 07:55:42 +00:00
|
|
|
|
{
|
|
|
|
|
// FIXME: Method is missing
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void) enableKeyEquivalentForDefaultButtonCell
|
2000-03-04 07:55:42 +00:00
|
|
|
|
{
|
|
|
|
|
// FIXME: Method is missing
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Assigning a delegate
|
|
|
|
|
*/
|
1999-02-17 04:52:58 +00:00
|
|
|
|
- (id) delegate
|
|
|
|
|
{
|
1999-12-07 05:53:26 +00:00
|
|
|
|
return _delegate;
|
1999-02-17 04:52:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setDelegate: (id)anObject
|
|
|
|
|
{
|
|
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
|
|
|
|
|
1999-12-07 05:53:26 +00:00
|
|
|
|
if (_delegate)
|
|
|
|
|
[nc removeObserver: _delegate name: nil object: self];
|
|
|
|
|
_delegate = anObject;
|
1999-02-17 04:52:58 +00:00
|
|
|
|
|
|
|
|
|
#define SET_DELEGATE_NOTIFICATION(notif_name) \
|
1999-12-07 05:53:26 +00:00
|
|
|
|
if ([_delegate respondsToSelector: @selector(window##notif_name:)]) \
|
|
|
|
|
[nc addObserver: _delegate \
|
1999-03-23 22:35:21 +00:00
|
|
|
|
selector: @selector(window##notif_name:) \
|
|
|
|
|
name: NSWindow##notif_name##Notification object: self]
|
1999-02-17 04:52:58 +00:00
|
|
|
|
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidBecomeKey);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidBecomeMain);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidChangeScreen);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidDeminiaturize);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidExpose);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidMiniaturize);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidMove);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidResignKey);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidResignMain);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidResize);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(DidUpdate);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(WillClose);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(WillMiniaturize);
|
|
|
|
|
SET_DELEGATE_NOTIFICATION(WillMove);
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* NSCoding protocol
|
|
|
|
|
*/
|
1999-03-02 08:58:30 +00:00
|
|
|
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-12-03 14:51:56 +00:00
|
|
|
|
BOOL flag;
|
1999-11-15 21:45:56 +00:00
|
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
|
[super encodeWithCoder: aCoder];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1996-07-11 00:59:30 +00:00
|
|
|
|
NSDebugLog(@"NSWindow: start encoding\n");
|
1999-12-03 14:51:56 +00:00
|
|
|
|
|
1999-11-30 19:44:53 +00:00
|
|
|
|
[aCoder encodeRect: [[self contentView] frame]];
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &style_mask];
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(NSBackingStoreType) at: &backing_type];
|
|
|
|
|
|
1999-12-03 14:51:56 +00:00
|
|
|
|
[aCoder encodePoint: NSMakePoint(NSMinX([self frame]), NSMaxY([self frame]))];
|
1999-03-02 08:58:30 +00:00
|
|
|
|
[aCoder encodeObject: content_view];
|
|
|
|
|
[aCoder encodeObject: background_color];
|
|
|
|
|
[aCoder encodeObject: represented_filename];
|
|
|
|
|
[aCoder encodeObject: miniaturized_title];
|
|
|
|
|
[aCoder encodeObject: window_title];
|
1999-11-30 19:44:53 +00:00
|
|
|
|
|
|
|
|
|
[aCoder encodeSize: minimum_size];
|
|
|
|
|
[aCoder encodeSize: maximum_size];
|
|
|
|
|
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(int) at: &window_level];
|
|
|
|
|
|
|
|
|
|
flag = _f.menu_exclude;
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
1999-11-15 21:45:56 +00:00
|
|
|
|
flag = _f.is_one_shot;
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
flag = _f.is_autodisplay;
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
flag = _f.optimize_drawing;
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
flag = _f.dynamic_depth_limit;
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
flag = _f.cursor_rects_enabled;
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
flag = _f.is_released_when_closed;
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
flag = _f.hides_on_deactivate;
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
flag = _f.accepts_mouse_moved;
|
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
1996-12-05 13:07:59 +00:00
|
|
|
|
|
1999-11-30 19:44:53 +00:00
|
|
|
|
[aCoder encodeObject: miniaturized_image];
|
|
|
|
|
[aCoder encodeConditionalObject: _initial_first_responder];
|
|
|
|
|
|
1996-07-11 00:59:30 +00:00
|
|
|
|
NSDebugLog(@"NSWindow: finish encoding\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
|
- (id) initWithCoder: (NSCoder*)aDecoder
|
1996-05-30 20:03:15 +00:00
|
|
|
|
{
|
1999-11-30 19:44:53 +00:00
|
|
|
|
id oldself = self;
|
1999-11-15 21:45:56 +00:00
|
|
|
|
BOOL flag;
|
|
|
|
|
|
1999-11-30 19:44:53 +00:00
|
|
|
|
if ((self = [super initWithCoder: aDecoder]) == oldself)
|
|
|
|
|
{
|
|
|
|
|
NSSize aSize;
|
|
|
|
|
NSRect aRect;
|
1999-12-03 14:51:56 +00:00
|
|
|
|
NSPoint p;
|
1999-11-30 19:44:53 +00:00
|
|
|
|
unsigned aStyle;
|
|
|
|
|
NSBackingStoreType aBacking;
|
|
|
|
|
int anInt;
|
|
|
|
|
id obj;
|
|
|
|
|
|
|
|
|
|
NSDebugLog(@"NSWindow: start decoding\n");
|
|
|
|
|
aRect = [aDecoder decodeRect];
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(unsigned)
|
|
|
|
|
at: &aStyle];
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(NSBackingStoreType)
|
|
|
|
|
at: &aBacking];
|
|
|
|
|
|
|
|
|
|
self = [self initWithContentRect: aRect
|
|
|
|
|
styleMask: aStyle
|
|
|
|
|
backing: aBacking
|
|
|
|
|
defer: NO
|
|
|
|
|
screen: nil];
|
|
|
|
|
|
1999-12-03 14:51:56 +00:00
|
|
|
|
p = [aDecoder decodePoint];
|
1999-11-30 19:44:53 +00:00
|
|
|
|
obj = [aDecoder decodeObject];
|
|
|
|
|
[self setContentView: obj];
|
|
|
|
|
obj = [aDecoder decodeObject];
|
|
|
|
|
[self setBackgroundColor: obj];
|
|
|
|
|
obj = [aDecoder decodeObject];
|
|
|
|
|
[self setRepresentedFilename: obj];
|
|
|
|
|
obj = [aDecoder decodeObject];
|
|
|
|
|
[self setMiniwindowTitle: obj];
|
|
|
|
|
obj = [aDecoder decodeObject];
|
|
|
|
|
[self setTitle: obj];
|
|
|
|
|
|
|
|
|
|
aSize = [aDecoder decodeSize];
|
|
|
|
|
[self setMinSize: aSize];
|
|
|
|
|
aSize = [aDecoder decodeSize];
|
|
|
|
|
[self setMaxSize: aSize];
|
|
|
|
|
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(int)
|
|
|
|
|
at: &anInt];
|
2000-03-08 21:26:11 +00:00
|
|
|
|
[self setLevel: anInt];
|
1999-11-30 19:44:53 +00:00
|
|
|
|
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
[self setExcludedFromWindowsMenu: flag];
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
[self setOneShot: flag];
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
[self setAutodisplay: flag];
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
[self useOptimizedDrawing: flag];
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
[self setDynamicDepthLimit: flag];
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
if (flag)
|
|
|
|
|
[self enableCursorRects];
|
|
|
|
|
else
|
|
|
|
|
[self disableCursorRects];
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
[self setReleasedWhenClosed: flag];
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
[self setHidesOnDeactivate: flag];
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
|
|
|
|
|
[self setAcceptsMouseMovedEvents: flag];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
1999-11-30 19:44:53 +00:00
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(id)
|
|
|
|
|
at: &miniaturized_image];
|
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(id)
|
|
|
|
|
at: &_initial_first_responder];
|
1996-12-05 13:07:59 +00:00
|
|
|
|
|
1999-12-03 14:51:56 +00:00
|
|
|
|
[self setFrameTopLeftPoint: p];
|
1999-11-30 19:44:53 +00:00
|
|
|
|
NSDebugLog(@"NSWindow: finish decoding\n");
|
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-04 13:17:26 +00:00
|
|
|
|
- (NSInterfaceStyle) interfaceStyle
|
|
|
|
|
{
|
|
|
|
|
return interface_style;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setInterfaceStyle: (NSInterfaceStyle)aStyle
|
|
|
|
|
{
|
|
|
|
|
interface_style = aStyle;
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-07 12:00:00 +00:00
|
|
|
|
- (void*) windowHandle
|
2000-03-04 07:55:42 +00:00
|
|
|
|
{
|
|
|
|
|
// FIXME: Should only be defined on MS Windows
|
2000-03-07 12:00:00 +00:00
|
|
|
|
return (void*) 0;
|
2000-03-04 07:55:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-10-03 18:45:41 +00:00
|
|
|
|
@end
|
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* GNUstep backend methods
|
|
|
|
|
*/
|
2000-03-06 11:39:22 +00:00
|
|
|
|
@implementation NSWindow (GNUstepBackend)
|
1999-10-29 18:43:48 +00:00
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
|
/*
|
|
|
|
|
* Mouse capture/release
|
|
|
|
|
*/
|
1999-10-21 18:08:50 +00:00
|
|
|
|
- (void) _captureMouse: sender
|
|
|
|
|
{
|
|
|
|
|
DPScapturemouse(GSCurrentContext(), window_num);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) _releaseMouse: sender
|
|
|
|
|
{
|
|
|
|
|
DPSreleasemouse(GSCurrentContext());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setContentViewSize: (NSSize)aSize
|
|
|
|
|
{
|
|
|
|
|
NSRect r;
|
|
|
|
|
|
|
|
|
|
r.origin = NSZeroPoint;
|
|
|
|
|
r.size = aSize;
|
|
|
|
|
if (content_view)
|
|
|
|
|
[content_view setFrame: r];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) _setVisible: (BOOL)flag
|
|
|
|
|
{
|
1999-11-15 21:45:56 +00:00
|
|
|
|
_f.visible = flag;
|
1999-10-21 18:08:50 +00:00
|
|
|
|
}
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
2000-03-04 07:55:42 +00:00
|
|
|
|
- (void) performDeminiaturize: sender
|
|
|
|
|
{
|
|
|
|
|
[self deminiaturize: sender];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) performHide: sender
|
|
|
|
|
{
|
|
|
|
|
// FIXME: Implementation is missing
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) performUnhide: sender
|
|
|
|
|
{
|
|
|
|
|
// FIXME: Implementation is missing
|
|
|
|
|
}
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
1999-05-04 13:17:26 +00:00
|
|
|
|
/*
|
|
|
|
|
* Allow subclasses to init without the backend
|
|
|
|
|
* class attempting to create an actual window
|
|
|
|
|
*/
|
2000-03-06 11:39:22 +00:00
|
|
|
|
- (void) _initDefaults
|
1999-05-04 13:17:26 +00:00
|
|
|
|
{
|
1999-10-13 00:51:46 +00:00
|
|
|
|
first_responder = self;
|
1999-05-04 13:17:26 +00:00
|
|
|
|
original_responder = nil;
|
1999-10-04 06:18:17 +00:00
|
|
|
|
_initial_first_responder = nil;
|
1999-11-18 01:00:58 +00:00
|
|
|
|
_selection_direction = NSDirectSelection;
|
1999-12-07 05:53:26 +00:00
|
|
|
|
_delegate = nil;
|
1999-05-04 13:17:26 +00:00
|
|
|
|
window_num = 0;
|
1999-05-18 16:49:13 +00:00
|
|
|
|
gstate = 0;
|
1999-06-01 17:05:57 +00:00
|
|
|
|
background_color = RETAIN([NSColor controlColor]);
|
1999-05-04 13:17:26 +00:00
|
|
|
|
represented_filename = @"Window";
|
|
|
|
|
miniaturized_title = @"Window";
|
|
|
|
|
miniaturized_image = nil;
|
|
|
|
|
window_title = @"Window";
|
|
|
|
|
last_point = NSZeroPoint;
|
|
|
|
|
window_level = NSNormalWindowLevel;
|
|
|
|
|
|
|
|
|
|
depth_limit = 8;
|
1999-09-06 05:18:16 +00:00
|
|
|
|
disable_flush_window = 0;
|
1999-11-15 21:45:56 +00:00
|
|
|
|
|
|
|
|
|
_f.is_one_shot = NO;
|
|
|
|
|
_f.is_autodisplay = YES;
|
|
|
|
|
_f.optimize_drawing = YES;
|
|
|
|
|
_f.dynamic_depth_limit = YES;
|
|
|
|
|
_f.cursor_rects_enabled = NO;
|
|
|
|
|
_f.visible = NO;
|
|
|
|
|
_f.is_key = NO;
|
|
|
|
|
_f.is_main = NO;
|
|
|
|
|
_f.is_edited = NO;
|
|
|
|
|
_f.is_released_when_closed = YES;
|
|
|
|
|
_f.is_miniaturized = NO;
|
|
|
|
|
_f.menu_exclude = NO;
|
|
|
|
|
_f.hides_on_deactivate = NO;
|
|
|
|
|
_f.accepts_mouse_moved = NO;
|
1999-12-08 15:01:52 +00:00
|
|
|
|
_f.has_opened = NO;
|
2000-02-25 17:43:32 +00:00
|
|
|
|
_f.has_closed = NO;
|
1996-10-03 18:45:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
|
@end
|
1999-07-29 20:58:04 +00:00
|
|
|
|
|
|
|
|
|
BOOL GSViewAcceptsDrag(NSView *v, id<NSDraggingInfo> dragInfo)
|
|
|
|
|
{
|
1999-09-09 02:56:20 +00:00
|
|
|
|
NSPasteboard *pb = [dragInfo draggingPasteboard];
|
1999-07-29 20:58:04 +00:00
|
|
|
|
if ([pb availableTypeFromArray: GSGetDragTypes(v)])
|
|
|
|
|
return YES;
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-06 11:39:22 +00:00
|
|
|
|
void NSCountWindows(int *count)
|
|
|
|
|
{
|
|
|
|
|
*count = (int)NSCountMapTable(windowmaps);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void NSWindowList(int size, int list[])
|
|
|
|
|
{
|
|
|
|
|
NSMapEnumerator me = NSEnumerateMapTable(windowmaps);
|
|
|
|
|
int num;
|
|
|
|
|
id win;
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
|
|
while (i < size && NSNextMapEnumeratorPair(&me, (void*)&num, (void*)&win))
|
|
|
|
|
{
|
|
|
|
|
list[i++] = num;
|
|
|
|
|
}
|
|
|
|
|
/* FIXME - the list produced should be in window stacking order */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NSArray* GSAllWindows()
|
|
|
|
|
{
|
|
|
|
|
return NSAllMapTableValues(windowmaps);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NSWindow* GSWindowWithNumber(int num)
|
|
|
|
|
{
|
|
|
|
|
return (NSWindow*)NSMapGet(windowmaps, (void*)num);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|