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>
|
1997-07-07 16:56:52 +00:00
|
|
|
|
1997-02-18 00:29:25 +00:00
|
|
|
#include <AppKit/NSWindow.h>
|
|
|
|
#include <AppKit/NSApplication.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>
|
1998-11-25 17:16:48 +00:00
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (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-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-03-23 22:35:21 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
+ (void) removeFrameUsingName: (NSString *)name
|
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
|
|
|
{
|
|
|
|
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
|
|
|
{
|
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) minFrameWidthWithTitle: (NSString *)aTitle
|
1999-06-11 04:46:12 +00:00
|
|
|
styleMask: (unsigned int)aStyle
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
return NSZeroRect;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
/* default Screen and window depth */
|
|
|
|
+ (NSWindowDepth) defaultDepthLimit
|
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
return 8;
|
1997-10-09 22:55:31 +00:00
|
|
|
}
|
|
|
|
|
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-03-23 22:35:21 +00:00
|
|
|
if (content_view)
|
|
|
|
{
|
1999-06-01 17:05:57 +00:00
|
|
|
RELEASE([content_view superview]); /* Release the window view */
|
|
|
|
RELEASE(content_view);
|
1999-03-23 22:35:21 +00:00
|
|
|
}
|
1998-12-17 13:06:17 +00:00
|
|
|
|
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-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.
|
|
|
|
*/
|
|
|
|
[GSCurrentContext() _removeDragTypes: nil fromWindow: [self windowNumber]];
|
1997-07-07 16:56:52 +00:00
|
|
|
|
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-03-23 22:35:21 +00:00
|
|
|
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-06-11 04:46:12 +00:00
|
|
|
|
|
|
|
/* Initialize attributes and flags */
|
|
|
|
[self cleanInit];
|
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];
|
|
|
|
minimum_size = NSZeroSize;
|
|
|
|
maximum_size = r.size;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
[self setNextResponder: NSApp];
|
|
|
|
|
|
|
|
cursor_rects_enabled = YES;
|
1999-03-23 22:35:21 +00:00
|
|
|
cursor_rects_valid = NO;
|
1996-10-03 18:45:41 +00:00
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
/* Create the content view */
|
|
|
|
cframe.origin = NSZeroPoint;
|
1999-03-23 22:35:21 +00:00
|
|
|
cframe.size = frame.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.
|
|
|
|
It is set by NSGraphicContext during a lockFocus to tell NSWindow what
|
|
|
|
part a view is drawing in, so NSWindow only has to flush that portion */
|
1999-06-01 17:05:57 +00:00
|
|
|
rectsBeingDrawn = RETAIN([NSMutableArray arrayWithCapacity: 10]);
|
1999-03-23 22:35:21 +00:00
|
|
|
NSDebugLog(@"NSWindow end of init\n");
|
1998-12-16 15:21:55 +00:00
|
|
|
|
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
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) setContentView: (NSView *)aView
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-01-09 21:43:09 +00:00
|
|
|
NSView *wv;
|
1997-11-14 21:32:31 +00:00
|
|
|
|
1999-04-08 20:42:46 +00:00
|
|
|
if (!aView)
|
1999-06-01 17:05:57 +00:00
|
|
|
aView = AUTORELEASE([[NSView alloc] initWithFrame: frame]);
|
1999-04-08 20:42:46 +00:00
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
/* If window view has not been created, create it */
|
1999-01-09 21:43:09 +00:00
|
|
|
if ((!content_view) || ([content_view superview] == nil))
|
|
|
|
{
|
1999-04-08 20:42:46 +00:00
|
|
|
wv = [[GSWindowView allocWithZone: [self zone]] initWithFrame: frame];
|
1999-01-09 21:43:09 +00:00
|
|
|
[wv viewWillMoveToWindow: self];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
wv = [content_view superview];
|
|
|
|
|
|
|
|
if (content_view)
|
|
|
|
[content_view removeFromSuperview];
|
|
|
|
|
|
|
|
ASSIGN(content_view, aView);
|
|
|
|
|
|
|
|
[content_view setFrame: [wv frame]]; // Resize to fill window.
|
1999-03-23 22:35:21 +00:00
|
|
|
[content_view setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
|
1999-06-11 04:46:12 +00:00
|
|
|
[wv addSubview: content_view]; // Add to our window view
|
|
|
|
NSAssert1 ([[wv subviews] count] == 1, @"window's view has %d subviews!",
|
|
|
|
[[wv subviews] count]);
|
|
|
|
|
|
|
|
[content_view setNextResponder: self];
|
1999-01-09 21:43:09 +00:00
|
|
|
[content_view setNeedsDisplay: YES]; // Make sure we redraw.
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
/*
|
|
|
|
* Window graphics
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
- (NSColor *) backgroundColor
|
|
|
|
{
|
|
|
|
return background_color;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) representedFilename
|
|
|
|
{
|
|
|
|
return represented_filename;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-03-23 22:35:21 +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
|
|
|
{
|
1999-01-06 18:01:05 +00:00
|
|
|
id old = represented_filename;
|
|
|
|
|
1998-12-17 13:06:17 +00:00
|
|
|
ASSIGN(represented_filename, aString);
|
1999-01-06 18:01:05 +00:00
|
|
|
if (menu_exclude == NO
|
|
|
|
&& ((represented_filename != nil && old == nil)
|
|
|
|
|| (represented_filename == nil && old != nil)))
|
|
|
|
{
|
1999-06-09 08:54:08 +00:00
|
|
|
[NSApp updateWindowsItem: self];
|
1999-01-06 18:01:05 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1998-12-17 13:06:17 +00:00
|
|
|
- (void) setTitle: (NSString*)aString
|
|
|
|
{
|
|
|
|
ASSIGN(window_title, aString);
|
|
|
|
[self setMiniwindowTitle: aString];
|
|
|
|
}
|
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];
|
|
|
|
[self setTitle: aString];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (unsigned int) styleMask
|
|
|
|
{
|
|
|
|
return style_mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) title
|
|
|
|
{
|
|
|
|
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
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (NSDictionary *) deviceDescription
|
1998-12-17 13:06:17 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
return nil;
|
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
|
|
|
|
{
|
|
|
|
return is_one_shot;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setBackingType: (NSBackingStoreType)type
|
|
|
|
{
|
|
|
|
backing_type = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setOneShot: (BOOL)flag
|
|
|
|
{
|
|
|
|
is_one_shot = flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) windowNumber
|
|
|
|
{
|
|
|
|
return window_num;
|
|
|
|
}
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
/*
|
|
|
|
* The miniwindow
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
- (NSImage *) miniwindowImage
|
|
|
|
{
|
|
|
|
return miniaturized_image;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) miniwindowTitle
|
|
|
|
{
|
|
|
|
return miniaturized_title;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-03-23 22:35:21 +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);
|
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
|
|
|
BOOL isDoc = NO;
|
1998-12-16 22:33:40 +00:00
|
|
|
|
1998-12-17 13:06:17 +00:00
|
|
|
ASSIGN(miniaturized_title, title);
|
|
|
|
if (is_miniaturized == NO)
|
|
|
|
title = window_title;
|
|
|
|
if ([title isEqual: represented_filename])
|
|
|
|
isDoc = YES;
|
1998-12-22 12:34:03 +00:00
|
|
|
if (menu_exclude == NO)
|
1999-06-09 08:54:08 +00:00
|
|
|
[NSApp changeWindowsItem: self
|
|
|
|
title: title
|
|
|
|
filename: isDoc];
|
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
|
|
|
{
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (NSText *) fieldEditor: (BOOL)createFlag forObject: (id)anObject
|
1999-06-01 17:05:57 +00:00
|
|
|
{
|
|
|
|
/* ask delegate if it can provide a field editor */
|
|
|
|
if ([delegate respondsToSelector:
|
1999-06-11 04:46:12 +00:00
|
|
|
@selector(windowWillReturnFieldEditor:toObject:)])
|
1999-03-23 22:35:21 +00:00
|
|
|
return [delegate windowWillReturnFieldEditor: self toObject: anObject];
|
* 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-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-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-03-23 22:35:21 +00:00
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
1997-03-05 01:11:17 +00:00
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
is_key = YES;
|
|
|
|
[self resetCursorRects];
|
|
|
|
[nc postNotificationName: NSWindowDidBecomeKeyNotification object: self];
|
|
|
|
}
|
1998-12-17 13:06:17 +00:00
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) becomeMainWindow
|
|
|
|
{
|
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
|
|
|
|
|
|
|
is_main = YES;
|
|
|
|
[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
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
return YES;
|
|
|
|
}
|
1998-12-17 13:06:17 +00:00
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (BOOL) canBecomeMainWindow
|
|
|
|
{
|
|
|
|
return YES;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (BOOL) hidesOnDeactivate
|
|
|
|
{
|
|
|
|
return hides_on_deactivate;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (BOOL) isKeyWindow
|
|
|
|
{
|
|
|
|
return is_key;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) isMainWindow
|
|
|
|
{
|
|
|
|
return is_main;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) isMiniaturized
|
|
|
|
{
|
|
|
|
return is_miniaturized;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) isVisible
|
|
|
|
{
|
|
|
|
return visible;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) level
|
|
|
|
{
|
|
|
|
return window_level;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) makeKeyAndOrderFront: (id)sender
|
1998-12-17 13:06:17 +00:00
|
|
|
{
|
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];
|
1999-06-11 04:46:12 +00:00
|
|
|
[self orderFront: sender];
|
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-06-11 04:46:12 +00:00
|
|
|
{} // implemented in back end
|
1999-03-23 22:35:21 +00:00
|
|
|
|
|
|
|
- (void) orderFront: (id)sender
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void) orderFrontRegardless
|
|
|
|
{}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) orderOut: (id)sender
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void) orderWindow: (NSWindowOrderingMode)place relativeTo: (int)otherWin
|
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-03-23 22:35:21 +00:00
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
1997-03-05 01:11:17 +00:00
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
is_key = NO;
|
|
|
|
[self discardCursorRects];
|
|
|
|
[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-03-23 22:35:21 +00:00
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
is_main = NO;
|
|
|
|
[nc postNotificationName: NSWindowDidResignMainNotification object: self];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setHidesOnDeactivate: (BOOL)flag
|
|
|
|
{
|
|
|
|
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
|
|
|
|
{
|
|
|
|
window_level = newLevel;
|
|
|
|
}
|
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
|
|
|
{
|
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;
|
|
|
|
|
|
|
|
// center the window within it's screen
|
1999-03-23 22:35:21 +00:00
|
|
|
origin.x = (screenSize.width - frame.size.width) / 2;
|
|
|
|
origin.y = (screenSize.height - frame.size.height) / 2;
|
|
|
|
[self setFrameOrigin: origin];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSRect) constrainFrameRect: (NSRect)frameRect toScreen: screen
|
|
|
|
{
|
|
|
|
return NSZeroRect;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (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
|
|
|
|
{}
|
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-03-23 22:35:21 +00:00
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
1998-12-15 16:20:22 +00:00
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
frame = frameRect;
|
|
|
|
[nc postNotificationName: NSWindowDidResizeNotification object: self];
|
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) setFrameTopLeftPoint: (NSPoint)aPoint
|
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
|
|
|
|
{
|
|
|
|
frame.origin = aPoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setMinSize: (NSSize)aSize
|
|
|
|
{
|
|
|
|
minimum_size = aSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setMaxSize: (NSSize)aSize
|
|
|
|
{
|
|
|
|
maximum_size = aSize;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
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
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
NSPoint screenPoint;
|
1998-11-12 10:49:00 +00:00
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
screenPoint.x = frame.origin.x + basePoint.x;
|
|
|
|
screenPoint.y = frame.origin.y + basePoint.y;
|
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
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
NSPoint basePoint;
|
1998-11-12 10:49:00 +00:00
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
basePoint.x = screenPoint.x - frame.origin.x;
|
|
|
|
basePoint.y = screenPoint.y - frame.origin.y;
|
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
|
|
|
|
{
|
|
|
|
disable_flush_window = YES;
|
|
|
|
}
|
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-06-11 04:46:12 +00:00
|
|
|
needs_display = NO;
|
|
|
|
/*
|
|
|
|
* 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];
|
|
|
|
[[content_view superview] display];
|
|
|
|
[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-02-12 17:00:59 +00:00
|
|
|
if (needs_display)
|
|
|
|
{
|
|
|
|
[[content_view superview] displayIfNeeded];
|
|
|
|
needs_display = NO;
|
|
|
|
}
|
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
|
|
|
|
*/
|
|
|
|
if (is_autodisplay && needs_display)
|
|
|
|
{
|
|
|
|
[self disableFlushWindow];
|
|
|
|
[self displayIfNeeded];
|
|
|
|
[self enableFlushWindow];
|
1998-12-22 12:34:03 +00:00
|
|
|
[self flushWindowIfNeeded];
|
|
|
|
}
|
|
|
|
[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-02-12 17:00:59 +00:00
|
|
|
if (!disable_flush_window && needs_flush)
|
|
|
|
{
|
|
|
|
needs_flush = NO;
|
|
|
|
[self flushWindow];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) flushWindow
|
|
|
|
{
|
|
|
|
// implemented in back end
|
1997-10-09 22:55:31 +00:00
|
|
|
}
|
|
|
|
|
1999-02-12 17:00:59 +00:00
|
|
|
- (void) enableFlushWindow
|
|
|
|
{
|
|
|
|
disable_flush_window = NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) isAutodisplay
|
|
|
|
{
|
|
|
|
return is_autodisplay;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) isFlushWindowDisabled
|
|
|
|
{
|
|
|
|
return disable_flush_window;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setAutodisplay: (BOOL)flag
|
|
|
|
{
|
|
|
|
is_autodisplay = flag;
|
|
|
|
}
|
1999-02-03 21:53:29 +00:00
|
|
|
|
|
|
|
- (void) setViewsNeedDisplay: (BOOL)flag
|
|
|
|
{
|
|
|
|
needs_display = flag;
|
1999-06-09 08:54:08 +00:00
|
|
|
[NSApp setWindowsNeedUpdate: YES];
|
1999-02-03 21:53:29 +00:00
|
|
|
}
|
|
|
|
|
1999-02-12 17:00:59 +00:00
|
|
|
- (BOOL) viewsNeedDisplay
|
|
|
|
{
|
|
|
|
return needs_display;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) useOptimizedDrawing: (BOOL)flag
|
|
|
|
{
|
|
|
|
optimize_drawing = flag;
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (NSScreen *) deepestScreen
|
|
|
|
{
|
|
|
|
return [NSScreen deepestScreen];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSWindowDepth) depthLimit
|
|
|
|
{
|
|
|
|
return depth_limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) hasDynamicDepthLimit
|
|
|
|
{
|
|
|
|
return dynamic_depth_limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSScreen *) screen
|
|
|
|
{
|
|
|
|
return [NSScreen mainScreen];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setDepthLimit: (NSWindowDepth)limit
|
|
|
|
{
|
|
|
|
depth_limit = limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setDynamicDepthLimit: (BOOL)flag
|
|
|
|
{
|
|
|
|
dynamic_depth_limit = flag;
|
|
|
|
}
|
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
|
|
|
|
{
|
|
|
|
return cursor_rects_enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) disableCursorRects
|
|
|
|
{
|
|
|
|
cursor_rects_enabled = NO;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) discardCursorRectsForView: (NSView *)theView
|
1997-03-05 01:11:17 +00:00
|
|
|
{
|
1999-05-07 20:08:51 +00:00
|
|
|
if (((NSViewPtr)theView)->_rFlags.has_currects)
|
|
|
|
[theView discardCursorRects];
|
1999-03-23 22:35:21 +00:00
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
if (((NSViewPtr)theView)->_rFlags.has_subviews)
|
|
|
|
{
|
|
|
|
NSArray *s = ((NSViewPtr)theView)->sub_views;
|
|
|
|
unsigned count = [s count];
|
1997-03-05 01:11:17 +00:00
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
if (count)
|
|
|
|
{
|
|
|
|
NSView *subs[count];
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
[s getObjects: subs];
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
[self discardCursorRectsForView: subs[i]];
|
|
|
|
}
|
|
|
|
}
|
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-03-23 22:35:21 +00:00
|
|
|
[self discardCursorRectsForView: [content_view superview]];
|
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
|
|
|
|
{
|
|
|
|
cursor_rects_enabled = YES;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) invalidateCursorRectsForView: (NSView *)aView
|
1997-03-05 01:11:17 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
cursor_rects_valid = NO;
|
1997-03-05 01:11:17 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) resetCursorRectsForView: (NSView *)theView
|
1997-03-05 01:11:17 +00:00
|
|
|
{
|
1999-05-07 20:08:51 +00:00
|
|
|
if (((NSViewPtr)theView)->_rFlags.has_currects)
|
|
|
|
[theView resetCursorRects];
|
|
|
|
|
|
|
|
if (((NSViewPtr)theView)->_rFlags.has_subviews)
|
|
|
|
{
|
|
|
|
NSArray *s = ((NSViewPtr)theView)->sub_views;
|
|
|
|
unsigned count = [s count];
|
1997-03-05 01:11:17 +00:00
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
if (count)
|
|
|
|
{
|
|
|
|
NSView *subs[count];
|
|
|
|
unsigned i;
|
1998-12-17 13:06:17 +00:00
|
|
|
|
1999-05-07 20:08:51 +00:00
|
|
|
[s getObjects: subs];
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
[self resetCursorRectsForView: subs[i]];
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
{
|
|
|
|
[self resetCursorRectsForView: [content_view superview]];
|
|
|
|
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];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If 'is_released_when_closed' then the window will be removed from the
|
1998-12-20 06:19:06 +00:00
|
|
|
* global list of windows (causing it to be released) - so we must
|
|
|
|
* bracket any work we do in a retain/release sequence in case that
|
|
|
|
* removal takes place when we post the notification.
|
1998-12-17 13:06:17 +00:00
|
|
|
*/
|
|
|
|
if (is_released_when_closed)
|
1999-06-01 17:05:57 +00:00
|
|
|
RETAIN(self);
|
1998-12-17 13:06:17 +00:00
|
|
|
|
|
|
|
[nc postNotificationName: NSWindowWillCloseNotification object: self];
|
1999-06-09 08:54:08 +00:00
|
|
|
[NSApp removeWindowsItem: self];
|
1998-12-17 13:06:17 +00:00
|
|
|
[self orderOut: self];
|
|
|
|
|
|
|
|
if (is_released_when_closed)
|
1999-06-01 17:05:57 +00:00
|
|
|
RELEASE(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
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
is_miniaturized = NO;
|
|
|
|
|
|
|
|
[self performDeminiaturize: self];
|
|
|
|
[nc postNotificationName: NSWindowDidDeminiaturizeNotification object: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-05-04 13:17:26 +00:00
|
|
|
- (BOOL) isDocumentEdited
|
|
|
|
{
|
|
|
|
return is_edited;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) isReleasedWhenClosed
|
|
|
|
{
|
|
|
|
return is_released_when_closed;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) miniaturize: sender
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
1998-12-17 13:06:17 +00:00
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
[nc postNotificationName: NSWindowWillMiniaturizeNotification object: self];
|
|
|
|
|
|
|
|
[self performMiniaturize: self];
|
|
|
|
[nc postNotificationName: NSWindowDidMiniaturizeNotification object: self];
|
1998-12-17 13:06:17 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) performClose: 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 */
|
1999-03-23 22:35:21 +00:00
|
|
|
if (!([self styleMask] & 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-03-23 22:35:21 +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
|
|
|
|
*/
|
|
|
|
if (![delegate windowShouldClose: self])
|
|
|
|
{
|
|
|
|
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
|
|
|
|
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
|
|
|
|
{
|
|
|
|
is_miniaturized = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) resizeFlags
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
1999-01-06 18:01:05 +00:00
|
|
|
|
|
|
|
- (void) setDocumentEdited: (BOOL)flag
|
|
|
|
{
|
|
|
|
if (is_edited != flag)
|
|
|
|
{
|
|
|
|
is_edited = flag;
|
|
|
|
if (menu_exclude == NO)
|
1999-06-11 04:46:12 +00:00
|
|
|
{
|
|
|
|
[NSApp updateWindowsItem: self];
|
|
|
|
}
|
1999-01-06 18:01:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) setReleasedWhenClosed: (BOOL)flag
|
|
|
|
{
|
|
|
|
is_released_when_closed = flag;
|
|
|
|
}
|
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
|
|
|
|
{
|
|
|
|
return accepts_mouse_moved;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-03-23 22:35:21 +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
|
1999-06-11 04:46:12 +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;
|
|
|
|
[first_responder becomeFirstResponder];
|
|
|
|
return YES;
|
1996-05-30 20:03:15 +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
|
|
|
|
{
|
1999-06-11 04:46:12 +00:00
|
|
|
float x;
|
|
|
|
float y;
|
1999-06-09 08:54:08 +00:00
|
|
|
|
|
|
|
DPSmouselocation(GSCurrentContext(), &x, &y);
|
|
|
|
x -= frame.origin.x;
|
|
|
|
y -= frame.origin.y;
|
|
|
|
return NSMakePoint(x, y);
|
1999-03-23 22:35:21 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-03-23 22:35:21 +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
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (NSEvent *) nextEventMatchingMask: (unsigned int)mask
|
1999-06-11 04:46:12 +00:00
|
|
|
untilDate: (NSDate *)expiration
|
1999-03-23 22:35:21 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +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-03-23 22:35:21 +00:00
|
|
|
accepts_mouse_moved = flag;
|
1996-10-03 18:45:41 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-05-07 11:06:37 +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
|
|
|
{
|
1999-05-07 20:08:51 +00:00
|
|
|
NSArray *tr = ((NSViewPtr)theView)->tracking_rects;
|
|
|
|
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];
|
|
|
|
BOOL flipped = ((NSViewPtr)theView)->_rFlags.flipped_view;
|
|
|
|
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 */
|
|
|
|
last = NSMouseInRect(last_point, r->rectangle, flipped);
|
|
|
|
/* Check mouse at current point */
|
|
|
|
now = NSMouseInRect(loc, r->rectangle, flipped);
|
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-05-07 20:08:51 +00:00
|
|
|
if (r->ownerRespondsToMouseEntered)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
{
|
|
|
|
if (r->ownerRespondsToMouseExited)
|
|
|
|
{
|
|
|
|
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
|
|
|
{
|
1999-05-07 20:08:51 +00:00
|
|
|
NSArray *sb = ((NSViewPtr)theView)->sub_views;
|
|
|
|
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
|
|
|
}
|
|
|
|
|
1999-05-07 11:06:37 +00:00
|
|
|
- (void) _checkCursorRectangles: (NSView *)theView forEvent: (NSEvent *)theEvent
|
1999-03-23 22:35:21 +00:00
|
|
|
{
|
1999-05-07 20:08:51 +00:00
|
|
|
if (((NSViewPtr)theView)->_rFlags.has_currects)
|
1999-03-23 22:35:21 +00:00
|
|
|
{
|
1999-05-07 20:08:51 +00:00
|
|
|
NSArray *tr = ((NSViewPtr)theView)->cursor_rects;
|
|
|
|
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];
|
|
|
|
NSPoint lastConv;
|
|
|
|
NSPoint locConv;
|
|
|
|
BOOL flipped = ((NSViewPtr)theView)->_rFlags.flipped_view;
|
|
|
|
unsigned i;
|
1999-05-07 11:06:37 +00:00
|
|
|
|
|
|
|
/*
|
1999-05-07 20:08:51 +00:00
|
|
|
* Convert points from window to view coordinates.
|
1999-05-07 11:06:37 +00:00
|
|
|
*/
|
1999-05-07 20:08:51 +00:00
|
|
|
lastConv = [theView convertPoint: last_point fromView: nil];
|
|
|
|
locConv = [theView convertPoint: loc fromView: nil];
|
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];
|
|
|
|
BOOL last;
|
|
|
|
BOOL now;
|
|
|
|
|
|
|
|
if ([r isValid] == NO)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for presence of point in rectangle.
|
|
|
|
*/
|
|
|
|
last = NSMouseInRect(lastConv, r->rectangle, flipped);
|
|
|
|
now = NSMouseInRect(locConv, r->rectangle, flipped);
|
|
|
|
|
|
|
|
// 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
|
|
|
|
userData: (void *)r];
|
|
|
|
[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
|
|
|
|
userData: (void *)r];
|
|
|
|
[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
|
|
|
{
|
1999-05-07 20:08:51 +00:00
|
|
|
NSArray *sb = ((NSViewPtr)theView)->sub_views;
|
|
|
|
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-03-23 22:35:21 +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-06-11 04:46:12 +00:00
|
|
|
if (!cursor_rects_valid)
|
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
[self discardCursorRects];
|
|
|
|
[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
|
1999-03-23 22:35:21 +00:00
|
|
|
v = [content_view hitTest: [theEvent locationInWindow]];
|
1999-03-24 11:31:06 +00:00
|
|
|
if (first_responder != v)
|
|
|
|
{
|
|
|
|
[self makeFirstResponder: v];
|
|
|
|
if ([v acceptsFirstMouse: theEvent] == YES)
|
|
|
|
[v mouseDown: theEvent];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
[v mouseDown: theEvent];
|
1999-03-23 22:35:21 +00:00
|
|
|
last_point = [theEvent locationInWindow];
|
|
|
|
break;
|
|
|
|
|
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:
|
|
|
|
if (accepts_mouse_moved)
|
|
|
|
{
|
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-03-24 11:31:06 +00:00
|
|
|
if (is_key)
|
|
|
|
{
|
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;
|
|
|
|
|
|
|
|
case NSKeyDown:
|
|
|
|
/*
|
|
|
|
* 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
|
|
|
{
|
|
|
|
GSTrackingRect *r =(GSTrackingRect *)[theEvent userData];
|
|
|
|
NSCursor *c = (NSCursor *)[r owner];
|
|
|
|
|
1999-03-25 21:23:32 +00:00
|
|
|
c = (NSCursor *)[r owner];
|
1999-06-11 04:46:12 +00:00
|
|
|
if ([theEvent trackingNumber]) // It's a mouse entered
|
1999-03-23 22:35:21 +00:00
|
|
|
{
|
|
|
|
if (c && [c isSetOnMouseEntered])
|
|
|
|
[c set];
|
|
|
|
}
|
1999-06-11 04:46:12 +00:00
|
|
|
else // it is a mouse exited
|
1999-03-23 22:35:21 +00:00
|
|
|
{
|
|
|
|
if (c && [c isSetOnMouseExited])
|
|
|
|
[c set];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NSPeriodic:
|
1999-06-11 04:46:12 +00:00
|
|
|
case NSAppKitDefined:
|
|
|
|
case NSSystemDefined:
|
|
|
|
case NSApplicationDefined:
|
1999-03-23 22:35:21 +00:00
|
|
|
break;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (BOOL) tryToPerform: (SEL)anAction with: anObject
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
/*
|
|
|
|
* Dragging
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) dragImage: (NSImage *)anImage
|
1999-06-11 04:46:12 +00:00
|
|
|
at: (NSPoint)baseLocation
|
|
|
|
offset: (NSSize)initialOffset
|
|
|
|
event: (NSEvent *)event
|
|
|
|
pasteboard: (NSPasteboard *)pboard
|
|
|
|
source: sourceObject
|
|
|
|
slideBack: (BOOL)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-06-15 09:23:39 +00:00
|
|
|
/*
|
|
|
|
* Ensure we have a content view and it's associated window view.
|
|
|
|
*/
|
|
|
|
if (content_view == nil)
|
|
|
|
[self setContentView: nil];
|
|
|
|
[[content_view superView] 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-06-15 09:23:39 +00:00
|
|
|
[[content_view superView] 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-03-23 22:35:21 +00:00
|
|
|
return 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-03-23 22:35:21 +00:00
|
|
|
menu_exclude = flag;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- validRequestorForSendType: (NSString *)sendType
|
1999-06-11 04:46:12 +00:00
|
|
|
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
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
if (delegate && [delegate respondsToSelector: _cmd])
|
|
|
|
result = [delegate validRequestorForSendType: sendType
|
|
|
|
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
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
- (NSString *) frameAutosaveName
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
return nil;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) saveFrameUsingName: (NSString *)name
|
1998-11-12 10:49:00 +00:00
|
|
|
{
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (BOOL) setFrameAutosaveName: (NSString *)name
|
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
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) setFrameFromString: (NSString *)string
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (BOOL) setFrameUsingName: (NSString *)name
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
return NO;
|
1998-11-12 10:49:00 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (NSString *) stringWithSavedFrame
|
1998-12-17 13:06:17 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
return nil;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
/*
|
|
|
|
* Printing and postscript
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
- (NSData *) dataWithEPSInsideRect: (NSRect)rect
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) fax: (id)sender
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void) print: (id)sender
|
|
|
|
{}
|
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
|
|
|
|
{
|
|
|
|
return delegate;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setDelegate: (id)anObject
|
|
|
|
{
|
|
|
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
|
|
|
|
|
|
|
if (delegate)
|
|
|
|
[nc removeObserver: delegate name: nil object: self];
|
|
|
|
delegate = anObject;
|
|
|
|
|
|
|
|
#define SET_DELEGATE_NOTIFICATION(notif_name) \
|
1999-03-23 22:35:21 +00:00
|
|
|
if ([delegate respondsToSelector: @selector(window##notif_name:)]) \
|
|
|
|
[nc addObserver: delegate \
|
|
|
|
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
|
|
|
/*
|
|
|
|
* Implemented by the delegate
|
|
|
|
*/
|
1999-03-23 22:35:21 +00:00
|
|
|
- (BOOL) windowShouldClose: (id)sender
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
if ([delegate respondsToSelector: @selector(windowShouldClose:)])
|
|
|
|
return [delegate windowShouldClose: sender];
|
|
|
|
else
|
|
|
|
return YES;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (NSSize) windowWillResize: (NSWindow *)sender toSize: (NSSize)frameSize
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
if ([delegate respondsToSelector: @selector(windowWillResize:toSize:)])
|
|
|
|
return [delegate windowWillResize: sender toSize: frameSize];
|
|
|
|
else
|
|
|
|
return frameSize;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (id) windowWillReturnFieldEditor: (NSWindow *)sender toObject: client
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
return nil;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) windowDidBecomeKey: (NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
if ([delegate respondsToSelector: @selector(windowDidBecomeKey:)])
|
|
|
|
return [delegate windowDidBecomeKey: aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) windowDidBecomeMain: (NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
if ([delegate respondsToSelector: @selector(windowDidBecomeMain:)])
|
|
|
|
return [delegate windowDidBecomeMain: aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) windowDidChangeScreen: (NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
if ([delegate respondsToSelector: @selector(windowDidChangeScreen:)])
|
|
|
|
return [delegate windowDidChangeScreen: aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) windowDidDeminiaturize: (NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
if ([delegate respondsToSelector: @selector(windowDidDeminiaturize:)])
|
|
|
|
return [delegate windowDidDeminiaturize: aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) windowDidExpose: (NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
if ([delegate respondsToSelector: @selector(windowDidExpose:)])
|
|
|
|
return [delegate windowDidExpose: aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) windowDidMiniaturize: (NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
if ([delegate respondsToSelector: @selector(windowDidMiniaturize:)])
|
|
|
|
return [delegate windowDidMiniaturize: aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) windowDidMove: (NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
if ([delegate respondsToSelector: @selector(windowDidMove:)])
|
|
|
|
return [delegate windowDidMove: aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) windowDidResignKey: (NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
if ([delegate respondsToSelector: @selector(windowDidResignKey:)])
|
|
|
|
return [delegate windowDidResignKey: aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) windowDidResignMain: (NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
if ([delegate respondsToSelector: @selector(windowDidResignMain:)])
|
|
|
|
return [delegate windowDidResignMain: aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) windowDidResize: (NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
if ([delegate respondsToSelector: @selector(windowDidResize:)])
|
|
|
|
return [delegate windowDidResize: aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) windowDidUpdate: (NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
if ([delegate respondsToSelector: @selector(windowDidUpdate:)])
|
|
|
|
return [delegate windowDidUpdate: aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) windowWillClose: (NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
if ([delegate respondsToSelector: @selector(windowWillClose:)])
|
|
|
|
return [delegate windowWillClose: aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) windowWillMiniaturize: (NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
if ([delegate respondsToSelector: @selector(windowWillMiniaturize:)])
|
|
|
|
return [delegate windowWillMiniaturize: aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (void) windowWillMove: (NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
if ([delegate respondsToSelector: @selector(windowWillMove:)])
|
|
|
|
return [delegate windowWillMove: aNotification];
|
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
|
|
|
{
|
|
|
|
[self setNextResponder: nil];
|
|
|
|
|
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-03-02 08:58:30 +00:00
|
|
|
[aCoder encodeRect: frame];
|
|
|
|
[aCoder encodeObject: content_view];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(int) at: &window_num];
|
|
|
|
[aCoder encodeObject: background_color];
|
|
|
|
[aCoder encodeObject: represented_filename];
|
|
|
|
[aCoder encodeObject: miniaturized_title];
|
|
|
|
[aCoder encodeObject: window_title];
|
|
|
|
[aCoder encodePoint: last_point];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &visible];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &is_key];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &is_main];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &is_edited];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &is_miniaturized];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(unsigned) at: &style_mask];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &menu_exclude];
|
1996-12-05 13:07:59 +00:00
|
|
|
|
|
|
|
// Version 2
|
1999-03-02 08:58:30 +00:00
|
|
|
[aCoder encodeSize: minimum_size];
|
|
|
|
[aCoder encodeSize: maximum_size];
|
|
|
|
[aCoder encodeObject: miniaturized_image];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(NSBackingStoreType) at: &backing_type];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(int) at: &window_level];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &is_one_shot];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &is_autodisplay];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &optimize_drawing];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(NSWindowDepth) at: &depth_limit];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &dynamic_depth_limit];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &cursor_rects_enabled];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &is_released_when_closed];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &disable_flush_window];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &hides_on_deactivate];
|
|
|
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &accepts_mouse_moved];
|
1996-12-05 13:07:59 +00:00
|
|
|
|
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-03-02 08:58:30 +00:00
|
|
|
[super initWithCoder: aDecoder];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"NSWindow: start decoding\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
frame = [aDecoder decodeRect];
|
|
|
|
content_view = [aDecoder decodeObject];
|
1999-03-02 08:58:30 +00:00
|
|
|
[aDecoder decodeValueOfObjCType: @encode(int) at: &window_num];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &background_color];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &represented_filename];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &miniaturized_title];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &window_title];
|
1996-05-30 20:03:15 +00:00
|
|
|
last_point = [aDecoder decodePoint];
|
1999-03-02 08:58:30 +00:00
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &visible];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &is_key];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &is_main];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &is_edited];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &is_miniaturized];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(unsigned) at: &style_mask];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &menu_exclude];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1996-12-05 13:07:59 +00:00
|
|
|
// Version 2
|
|
|
|
minimum_size = [aDecoder decodeSize];
|
|
|
|
maximum_size = [aDecoder decodeSize];
|
1999-03-02 08:58:30 +00:00
|
|
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &miniaturized_image];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(NSBackingStoreType)
|
1999-06-11 04:46:12 +00:00
|
|
|
at: &backing_type];
|
1999-03-02 08:58:30 +00:00
|
|
|
[aDecoder decodeValueOfObjCType: @encode(int) at: &window_level];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &is_one_shot];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &is_autodisplay];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &optimize_drawing];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(NSWindowDepth) at: &depth_limit];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &dynamic_depth_limit];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &cursor_rects_enabled];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &is_released_when_closed];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &disable_flush_window];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &hides_on_deactivate];
|
|
|
|
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &accepts_mouse_moved];
|
1996-12-05 13:07:59 +00:00
|
|
|
|
1996-07-11 00:59:30 +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;
|
|
|
|
}
|
|
|
|
|
1996-10-03 18:45:41 +00:00
|
|
|
@end
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
/*
|
|
|
|
* GNUstep backend methods
|
|
|
|
*/
|
1996-10-03 18:45:41 +00:00
|
|
|
@implementation NSWindow (GNUstepBackend)
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
+ (NSWindow*) _windowWithTag: (int)windowNumber
|
1997-07-07 16:56:52 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
return nil;
|
1997-07-07 16:56:52 +00:00
|
|
|
}
|
|
|
|
|
1999-05-04 13:17:26 +00:00
|
|
|
- (void) setWindowNumber: (int)windowNum
|
|
|
|
{
|
|
|
|
window_num = windowNum;
|
|
|
|
}
|
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
/*
|
|
|
|
* Mouse capture/release
|
|
|
|
*/
|
|
|
|
- (void) _captureMouse: sender {} // Do nothing, should be
|
|
|
|
- (void) _releaseMouse: sender {} // implemented by back-end
|
1999-03-23 22:35:21 +00:00
|
|
|
|
1999-06-11 04:46:12 +00:00
|
|
|
- (void) performDeminiaturize: sender {}
|
|
|
|
- (void) performHide: sender {}
|
|
|
|
- (void) performUnhide: sender {}
|
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
|
|
|
|
*/
|
|
|
|
- (void) initDefaults
|
|
|
|
{
|
|
|
|
first_responder = nil;
|
|
|
|
original_responder = nil;
|
|
|
|
delegate = nil;
|
|
|
|
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;
|
|
|
|
|
|
|
|
is_one_shot = NO;
|
|
|
|
needs_display = NO;
|
|
|
|
is_autodisplay = YES;
|
|
|
|
optimize_drawing = YES;
|
|
|
|
views_need_display = NO;
|
|
|
|
depth_limit = 8;
|
|
|
|
dynamic_depth_limit = YES;
|
|
|
|
cursor_rects_enabled = NO;
|
|
|
|
visible = NO;
|
|
|
|
is_key = NO;
|
|
|
|
is_main = NO;
|
|
|
|
is_edited = NO;
|
|
|
|
is_released_when_closed = YES;
|
|
|
|
is_miniaturized = NO;
|
|
|
|
disable_flush_window = NO;
|
|
|
|
menu_exclude = NO;
|
|
|
|
hides_on_deactivate = NO;
|
|
|
|
accepts_mouse_moved = NO;
|
1996-10-03 18:45:41 +00:00
|
|
|
}
|
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
- (id) cleanInit
|
1996-09-12 19:24:32 +00:00
|
|
|
{
|
1999-03-23 22:35:21 +00:00
|
|
|
[super init];
|
1998-12-17 13:06:17 +00:00
|
|
|
|
1999-03-23 22:35:21 +00:00
|
|
|
[self initDefaults];
|
|
|
|
return self;
|
1997-08-16 23:47:24 +00:00
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
@end
|