1996-05-30 20:03:15 +00:00
|
|
|
/*
|
|
|
|
NSView.m
|
|
|
|
|
|
|
|
The view class which encapsulates all drawing functionality
|
|
|
|
|
|
|
|
Copyright (C) 1996 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Author: Scott Christley <scottc@net-community.com>
|
1997-10-09 22:55:31 +00:00
|
|
|
Date: 1996
|
|
|
|
Heavily changed and extended by Ovidiu Predescu <ovidiu@net-community.com>.
|
|
|
|
Date: 1997
|
1998-08-19 09:00:26 +00:00
|
|
|
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
|
|
|
Date: August 1998
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
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.
|
1996-05-30 20:03:15 +00:00
|
|
|
*/
|
|
|
|
|
1997-09-23 22:43:24 +00:00
|
|
|
#include <gnustep/gui/config.h>
|
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/NSDictionary.h>
|
|
|
|
#include <Foundation/NSThread.h>
|
|
|
|
#include <Foundation/NSLock.h>
|
|
|
|
#include <Foundation/NSArray.h>
|
1997-08-05 21:50:10 +00:00
|
|
|
#include <Foundation/NSNotification.h>
|
1997-10-09 22:55:31 +00:00
|
|
|
#include <Foundation/NSValue.h>
|
1997-08-05 21:50:10 +00:00
|
|
|
|
1997-02-18 00:29:25 +00:00
|
|
|
#include <AppKit/NSView.h>
|
|
|
|
#include <AppKit/NSWindow.h>
|
1997-08-18 17:10:23 +00:00
|
|
|
#include <AppKit/TrackingRectangle.h>
|
|
|
|
#include <AppKit/PSMatrix.h>
|
1996-06-03 15:03:43 +00:00
|
|
|
|
1997-10-09 22:55:31 +00:00
|
|
|
@implementation NSView
|
|
|
|
|
|
|
|
/* Class variables */
|
1998-10-27 15:06:07 +00:00
|
|
|
static NSString *nsview_thread_key = @"NSViewThreadKey";
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
+ (void)initialize
|
|
|
|
{
|
|
|
|
if (self == [NSView class])
|
|
|
|
{
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"Initialize NSView class\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
// Initial version
|
|
|
|
[self setVersion:1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-10-27 15:24:42 +00:00
|
|
|
+ (void) pushFocusView:(NSView *)focusView
|
1996-06-03 15:03:43 +00:00
|
|
|
{
|
1998-10-27 15:24:42 +00:00
|
|
|
if (focusView)
|
1996-06-03 15:03:43 +00:00
|
|
|
{
|
1998-10-27 15:24:42 +00:00
|
|
|
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
|
|
|
NSMutableArray *stack = [dict objectForKey: nsview_thread_key];
|
|
|
|
|
|
|
|
if (stack == nil)
|
|
|
|
{
|
1998-10-27 16:01:33 +00:00
|
|
|
stack = [[NSMutableArray alloc] initWithCapacity: 4];
|
1998-10-27 15:24:42 +00:00
|
|
|
[dict setObject: stack forKey: nsview_thread_key];
|
|
|
|
[stack release];
|
|
|
|
}
|
|
|
|
[stack addObject: focusView];
|
1996-06-03 15:03:43 +00:00
|
|
|
}
|
1998-10-27 16:01:33 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
[NSException raise: NSInternalInconsistencyException
|
|
|
|
format: @"Attempt to push a 'nil' focus view on to stack."];
|
|
|
|
}
|
1996-06-03 15:03:43 +00:00
|
|
|
}
|
|
|
|
|
1998-10-27 16:01:33 +00:00
|
|
|
/*
|
|
|
|
* Remove the top focusView for the current thread from the stack
|
|
|
|
* and return the new focusView (or nil if the stack is now empty).
|
|
|
|
*/
|
1996-06-03 15:03:43 +00:00
|
|
|
+ (NSView *)popFocusView
|
1996-09-21 16:31:19 +00:00
|
|
|
{
|
1998-10-27 15:06:07 +00:00
|
|
|
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
1998-10-27 15:24:42 +00:00
|
|
|
NSMutableArray *stack = [dict objectForKey: nsview_thread_key];
|
|
|
|
NSView *v = nil;
|
1996-09-21 16:31:19 +00:00
|
|
|
|
1998-10-27 15:24:42 +00:00
|
|
|
if (stack)
|
|
|
|
{
|
|
|
|
unsigned count = [stack count];
|
1996-09-21 16:31:19 +00:00
|
|
|
|
1998-10-27 16:01:33 +00:00
|
|
|
if (count > 0)
|
|
|
|
{
|
|
|
|
[stack removeObjectAtIndex: --count];
|
|
|
|
}
|
1998-10-27 15:24:42 +00:00
|
|
|
if (count > 0)
|
|
|
|
{
|
|
|
|
v = [stack objectAtIndex: --count];
|
|
|
|
}
|
|
|
|
}
|
1997-03-21 01:06:15 +00:00
|
|
|
return v;
|
1996-09-21 16:31:19 +00:00
|
|
|
}
|
1996-06-03 15:03:43 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
+ (NSView *)focusView
|
|
|
|
{
|
1998-10-27 15:06:07 +00:00
|
|
|
NSMutableDictionary *dict = [[NSThread currentThread] threadDictionary];
|
1998-10-27 15:24:42 +00:00
|
|
|
NSMutableArray *stack = [dict objectForKey: nsview_thread_key];
|
1996-06-03 15:03:43 +00:00
|
|
|
NSView *current_view = nil;
|
|
|
|
|
1998-10-27 15:24:42 +00:00
|
|
|
if (stack)
|
|
|
|
{
|
|
|
|
unsigned count = [stack count];
|
1996-06-03 15:03:43 +00:00
|
|
|
|
1998-10-27 15:24:42 +00:00
|
|
|
if (count > 0)
|
|
|
|
{
|
|
|
|
current_view = [stack objectAtIndex: --count];
|
|
|
|
}
|
|
|
|
}
|
1996-06-03 15:03:43 +00:00
|
|
|
return current_view;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- init
|
|
|
|
{
|
|
|
|
return [self initWithFrame:NSZeroRect];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id)initWithFrame:(NSRect)frameRect
|
|
|
|
{
|
|
|
|
// Our super is NSResponder
|
|
|
|
[super init];
|
|
|
|
|
|
|
|
// Set frame rectangle
|
|
|
|
frame = frameRect;
|
|
|
|
|
|
|
|
// Set bounds rectangle
|
|
|
|
bounds.origin = NSZeroPoint;
|
|
|
|
bounds.size = frame.size;
|
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
frameMatrix = [PSMatrix new];
|
|
|
|
boundsMatrix = [PSMatrix new];
|
|
|
|
[frameMatrix setFrameOrigin:frame.origin];
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
// Initialize subview list
|
1997-07-07 16:56:52 +00:00
|
|
|
sub_views = [NSMutableArray new];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
// Initialize tracking rectangle list
|
1997-07-07 16:56:52 +00:00
|
|
|
tracking_rects = [NSMutableArray new];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-03-05 01:11:17 +00:00
|
|
|
// Initialize cursor rect list
|
1997-07-07 16:56:52 +00:00
|
|
|
cursor_rects = [NSMutableArray new];
|
1997-03-05 01:11:17 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
super_view = nil;
|
|
|
|
window = nil;
|
|
|
|
is_rotated_from_base = NO;
|
|
|
|
is_rotated_or_scaled_from_base = NO;
|
|
|
|
disable_autodisplay = NO;
|
|
|
|
needs_display = YES;
|
|
|
|
post_frame_changes = NO;
|
1996-06-21 15:08:08 +00:00
|
|
|
autoresize_subviews = YES;
|
1998-08-19 09:00:26 +00:00
|
|
|
autoresizingMask = NSViewNotSizable;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dealloc
|
|
|
|
{
|
1997-10-09 22:55:31 +00:00
|
|
|
[frameMatrix release];
|
|
|
|
[boundsMatrix release];
|
1997-07-07 16:56:52 +00:00
|
|
|
[sub_views release];
|
|
|
|
[tracking_rects release];
|
|
|
|
[cursor_rects release];
|
1997-03-05 01:11:17 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)addSubview:(NSView *)aView
|
|
|
|
{
|
1997-08-18 17:10:23 +00:00
|
|
|
// make sure we aren't making ourself a subview of ourself or we're not
|
|
|
|
// creating a cycle in the views hierarchy
|
|
|
|
if ([self isDescendantOf:aView])
|
1997-03-05 01:11:17 +00:00
|
|
|
{
|
1997-08-18 17:10:23 +00:00
|
|
|
NSLog(@"Operation addSubview: will create a cycle in the views tree!\n");
|
1997-03-05 01:11:17 +00:00
|
|
|
return;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
// Add to our subview list
|
1997-10-28 20:44:38 +00:00
|
|
|
[aView viewWillMoveToWindow:window];
|
1996-05-30 20:03:15 +00:00
|
|
|
[aView setSuperview:self];
|
|
|
|
[aView setNextResponder:self];
|
1997-10-28 20:44:38 +00:00
|
|
|
[sub_views addObject:(id)aView];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1997-10-28 20:44:38 +00:00
|
|
|
/* This method needs to be worked out!!! */
|
1996-05-30 20:03:15 +00:00
|
|
|
- (void)addSubview:(NSView *)aView
|
|
|
|
positioned:(NSWindowOrderingMode)place
|
1996-06-03 15:03:43 +00:00
|
|
|
relativeTo:(NSView *)otherView
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-08-18 17:10:23 +00:00
|
|
|
// make sure we aren't making ourself a subview of ourself or we're not
|
|
|
|
// creating a cycle in the views hierarchy
|
|
|
|
if ([self isDescendantOf:aView])
|
|
|
|
{
|
|
|
|
NSLog(@"Operation addSubview:positioned:relativeTo: will create a cycle "
|
|
|
|
@"in the views tree!\n");
|
|
|
|
return;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
// Add to our subview list
|
|
|
|
[sub_views addObject:(id)aView];
|
|
|
|
[aView setSuperview:self];
|
|
|
|
|
|
|
|
// Make ourselves the next responder of the view
|
|
|
|
[aView setNextResponder:self];
|
|
|
|
|
|
|
|
// Tell the view what window it has moved to
|
|
|
|
[aView viewWillMoveToWindow:window];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSView *)ancestorSharedWithView:(NSView *)aView
|
|
|
|
{
|
1997-03-20 19:23:21 +00:00
|
|
|
// Are they the same?
|
|
|
|
if (self == aView)
|
|
|
|
return self;
|
|
|
|
|
|
|
|
// Is self a descendant of view?
|
|
|
|
if ([self isDescendantOf: aView])
|
|
|
|
return aView;
|
|
|
|
|
|
|
|
// Is view a descendant of self?
|
|
|
|
if ([aView isDescendantOf: self])
|
|
|
|
return self;
|
|
|
|
|
|
|
|
// If neither are descendants of each other
|
|
|
|
// and either does not have a superview
|
|
|
|
// then they cannot have a common ancestor
|
|
|
|
if (![self superview])
|
|
|
|
return nil;
|
|
|
|
if (![aView superview])
|
|
|
|
return nil;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-03-20 19:23:21 +00:00
|
|
|
// Find the common ancestor of superviews
|
|
|
|
return [[self superview] ancestorSharedWithView: [aView superview]];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isDescendantOf:(NSView *)aView
|
|
|
|
{
|
|
|
|
// Quick check
|
|
|
|
if (aView == self) return YES;
|
|
|
|
|
|
|
|
// No superview then this is end of the line
|
|
|
|
if (!super_view) return NO;
|
|
|
|
|
|
|
|
if (super_view == aView) return YES;
|
|
|
|
|
|
|
|
return [super_view isDescendantOf:aView];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSView *)opaqueAncestor
|
|
|
|
{
|
1997-10-29 21:56:04 +00:00
|
|
|
if ([self isOpaque] || !super_view)
|
|
|
|
return self;
|
|
|
|
else
|
|
|
|
return [super_view opaqueAncestor];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)removeFromSuperview
|
|
|
|
{
|
1997-07-07 16:56:52 +00:00
|
|
|
NSMutableArray *views;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
// No superview then just return
|
|
|
|
if (!super_view) return;
|
|
|
|
|
1997-10-28 20:44:38 +00:00
|
|
|
[self viewWillMoveToWindow:nil];
|
|
|
|
|
1997-10-29 22:17:51 +00:00
|
|
|
/* Remove the view from the linked list of views maintained by the super view
|
|
|
|
so that the view will not receive an unneeded display message. */
|
|
|
|
[super_view _removeSubviewFromViewsThatNeedDisplay:self];
|
|
|
|
|
1997-07-07 16:56:52 +00:00
|
|
|
views = [super_view subviews];
|
|
|
|
[views removeObjectIdenticalTo:self];
|
1997-10-29 22:17:51 +00:00
|
|
|
super_view = nil;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)replaceSubview:(NSView *)oldView
|
|
|
|
with:(NSView *)newView
|
|
|
|
{
|
1997-10-28 20:44:38 +00:00
|
|
|
if (!newView)
|
|
|
|
return;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-10-28 20:44:38 +00:00
|
|
|
if (!oldView)
|
|
|
|
[self addSubview:newView];
|
|
|
|
else {
|
|
|
|
int index = [sub_views indexOfObjectIdenticalTo:oldView];
|
|
|
|
|
|
|
|
if (index != NSNotFound) {
|
|
|
|
[oldView viewWillMoveToWindow:nil];
|
|
|
|
[oldView setSuperview:nil];
|
|
|
|
[newView setNextResponder:nil];
|
|
|
|
|
1997-10-29 22:17:51 +00:00
|
|
|
/* Remove the view from the linked list of views so that the old view
|
|
|
|
will not receive an unneeded display message. */
|
|
|
|
[self _removeSubviewFromViewsThatNeedDisplay:oldView];
|
|
|
|
|
1997-10-28 20:44:38 +00:00
|
|
|
[sub_views replaceObjectAtIndex:index withObject:newView];
|
|
|
|
|
|
|
|
[newView viewWillMoveToWindow:window];
|
|
|
|
[newView setSuperview:self];
|
|
|
|
[newView setNextResponder:self];
|
|
|
|
}
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)sortSubviewsUsingFunction:(int (*)(id ,id ,void *))compare
|
|
|
|
context:(void *)context
|
|
|
|
{
|
1997-10-09 22:55:31 +00:00
|
|
|
[sub_views sortUsingFunction:compare context:context];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSWindow *)window
|
|
|
|
{
|
|
|
|
// If we don't know our window then ask our super_view
|
|
|
|
if (!window)
|
|
|
|
window = [super_view window];
|
|
|
|
|
|
|
|
return window;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewWillMoveToWindow:(NSWindow *)newWindow
|
|
|
|
{
|
1997-07-07 16:56:52 +00:00
|
|
|
int i, count;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
window = newWindow;
|
|
|
|
|
|
|
|
// Pass new window down to subviews
|
1997-07-07 16:56:52 +00:00
|
|
|
count = [sub_views count];
|
|
|
|
for (i = 0; i < count; ++i)
|
1996-05-30 20:03:15 +00:00
|
|
|
[[sub_views objectAtIndex:i] viewWillMoveToWindow:newWindow];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)rotateByAngle:(float)angle
|
1997-08-05 21:50:10 +00:00
|
|
|
{
|
1997-08-18 17:10:23 +00:00
|
|
|
[boundsMatrix rotateByAngle:angle];
|
1997-10-09 22:55:31 +00:00
|
|
|
is_rotated_from_base = is_rotated_or_scaled_from_base = YES;
|
1997-08-18 17:10:23 +00:00
|
|
|
|
1997-08-05 21:50:10 +00:00
|
|
|
if (post_bounds_changes)
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
postNotificationName:NSViewBoundsDidChangeNotification object:self];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)setFrame:(NSRect)frameRect
|
|
|
|
{
|
1996-06-21 15:08:08 +00:00
|
|
|
NSSize old_size = bounds.size;
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
frame = frameRect;
|
|
|
|
bounds.size = frame.size;
|
1997-08-18 17:10:23 +00:00
|
|
|
[frameMatrix setFrameOrigin:frame.origin];
|
1996-06-21 15:08:08 +00:00
|
|
|
|
|
|
|
// Resize subviews
|
|
|
|
[self resizeSubviewsWithOldSize: old_size];
|
1997-08-05 21:50:10 +00:00
|
|
|
if (post_frame_changes)
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
postNotificationName:NSViewFrameDidChangeNotification object:self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setFrameOrigin:(NSPoint)newOrigin
|
|
|
|
{
|
|
|
|
frame.origin = newOrigin;
|
1997-08-18 17:10:23 +00:00
|
|
|
[frameMatrix setFrameOrigin:frame.origin];
|
|
|
|
|
1997-08-05 21:50:10 +00:00
|
|
|
if (post_frame_changes)
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
postNotificationName:NSViewFrameDidChangeNotification object:self];
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
- (void)setFrameSize:(NSSize)newSize
|
1997-08-05 21:50:10 +00:00
|
|
|
{
|
1997-08-18 17:10:23 +00:00
|
|
|
NSSize old_size = bounds.size;
|
|
|
|
|
|
|
|
frame.size = bounds.size = newSize;
|
|
|
|
|
|
|
|
// Resize subviews
|
|
|
|
[self resizeSubviewsWithOldSize: old_size];
|
1997-08-05 21:50:10 +00:00
|
|
|
if (post_frame_changes)
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
postNotificationName:NSViewFrameDidChangeNotification object:self];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
- (void)setFrameRotation:(float)angle
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-08-18 17:10:23 +00:00
|
|
|
[frameMatrix setFrameRotation:angle];
|
1997-10-09 22:55:31 +00:00
|
|
|
is_rotated_from_base = is_rotated_or_scaled_from_base = YES;
|
1996-06-21 15:08:08 +00:00
|
|
|
|
1997-08-05 21:50:10 +00:00
|
|
|
if (post_frame_changes)
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
postNotificationName:NSViewFrameDidChangeNotification object:self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isRotatedFromBase
|
|
|
|
{
|
1997-10-09 22:55:31 +00:00
|
|
|
if (is_rotated_from_base)
|
|
|
|
return is_rotated_from_base;
|
|
|
|
else if (super_view)
|
|
|
|
return [super_view isRotatedFromBase];
|
|
|
|
else
|
|
|
|
return NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isRotatedOrScaledFromBase
|
|
|
|
{
|
1997-10-09 22:55:31 +00:00
|
|
|
if (is_rotated_or_scaled_from_base)
|
|
|
|
return is_rotated_or_scaled_from_base;
|
|
|
|
else if (super_view)
|
|
|
|
return [super_view isRotatedOrScaledFromBase];
|
|
|
|
else
|
|
|
|
return NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)scaleUnitSquareToSize:(NSSize)newSize
|
1997-08-05 21:50:10 +00:00
|
|
|
{
|
1997-08-18 17:10:23 +00:00
|
|
|
if (!newSize.width)
|
|
|
|
newSize.width = 1;
|
|
|
|
if (!newSize.height)
|
|
|
|
newSize.height = 1;
|
|
|
|
|
|
|
|
bounds.size.width = frame.size.width / newSize.width;
|
|
|
|
bounds.size.height = frame.size.height / newSize.height;
|
|
|
|
|
1997-10-09 22:55:31 +00:00
|
|
|
is_rotated_or_scaled_from_base = YES;
|
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
[boundsMatrix scaleBy:frame.size.width / bounds.size.width
|
|
|
|
:frame.size.height / bounds.size.height];
|
|
|
|
|
1997-08-05 21:50:10 +00:00
|
|
|
if (post_bounds_changes)
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
postNotificationName:NSViewBoundsDidChangeNotification object:self];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)setBounds:(NSRect)aRect
|
|
|
|
{
|
1997-10-09 22:55:31 +00:00
|
|
|
float sx, sy;
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
bounds = aRect;
|
1997-10-09 22:55:31 +00:00
|
|
|
[boundsMatrix setFrameOrigin:
|
|
|
|
NSMakePoint(-bounds.origin.x, -bounds.origin.y)];
|
|
|
|
sx = frame.size.width / bounds.size.width;
|
|
|
|
sy = frame.size.height / bounds.size.height;
|
|
|
|
[boundsMatrix scaleTo:sx :sy];
|
|
|
|
|
|
|
|
if (sx != 1 || sy != 1)
|
|
|
|
is_rotated_or_scaled_from_base = YES;
|
1997-08-18 17:10:23 +00:00
|
|
|
|
1997-08-05 21:50:10 +00:00
|
|
|
if (post_bounds_changes)
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
postNotificationName:NSViewBoundsDidChangeNotification object:self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setBoundsOrigin:(NSPoint)newOrigin
|
|
|
|
{
|
|
|
|
bounds.origin = newOrigin;
|
1997-10-09 22:55:31 +00:00
|
|
|
/* We have to translate the origin of the bounds in the oposite direction
|
|
|
|
so that the newOrigin becomes the origin when viewed. */
|
|
|
|
[boundsMatrix setFrameOrigin:NSMakePoint(-newOrigin.x, -newOrigin.y)];
|
1997-08-18 17:10:23 +00:00
|
|
|
|
1997-08-05 21:50:10 +00:00
|
|
|
if (post_bounds_changes)
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
postNotificationName:NSViewBoundsDidChangeNotification object:self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
- (void)setBoundsSize:(NSSize)newSize
|
1997-08-05 21:50:10 +00:00
|
|
|
{
|
1997-10-09 22:55:31 +00:00
|
|
|
float sx, sy;
|
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
bounds.size = newSize;
|
1997-10-09 22:55:31 +00:00
|
|
|
sx = frame.size.width / bounds.size.width;
|
|
|
|
sy = frame.size.height / bounds.size.height;
|
|
|
|
[boundsMatrix scaleTo:sx :sy];
|
|
|
|
|
|
|
|
if (sx != 1 || sy != 1)
|
|
|
|
is_rotated_or_scaled_from_base = YES;
|
1997-08-18 17:10:23 +00:00
|
|
|
|
1997-08-05 21:50:10 +00:00
|
|
|
if (post_bounds_changes)
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
postNotificationName:NSViewBoundsDidChangeNotification object:self];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
- (void)setBoundsRotation:(float)angle
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-08-18 17:10:23 +00:00
|
|
|
[boundsMatrix setFrameRotation:angle];
|
1997-10-09 22:55:31 +00:00
|
|
|
is_rotated_from_base = is_rotated_or_scaled_from_base = YES;
|
1997-08-18 17:10:23 +00:00
|
|
|
|
1997-08-05 21:50:10 +00:00
|
|
|
if (post_bounds_changes)
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
postNotificationName:NSViewBoundsDidChangeNotification object:self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)translateOriginToPoint:(NSPoint)point
|
1997-08-05 21:50:10 +00:00
|
|
|
{
|
1997-08-18 17:10:23 +00:00
|
|
|
[boundsMatrix translateToPoint:point];
|
|
|
|
|
1997-08-05 21:50:10 +00:00
|
|
|
if (post_bounds_changes)
|
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
postNotificationName:NSViewBoundsDidChangeNotification object:self];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
- (NSRect)centerScanRect:(NSRect)aRect
|
1996-06-21 15:27:13 +00:00
|
|
|
{
|
1997-08-18 17:10:23 +00:00
|
|
|
return NSZeroRect;
|
1996-06-21 15:27:13 +00:00
|
|
|
}
|
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
- (PSMatrix*)_concatenateMatricesInReverseOrderFromPath:(NSArray*)viewsPath
|
1997-08-05 21:50:10 +00:00
|
|
|
{
|
1997-08-18 17:10:23 +00:00
|
|
|
int i, count = [viewsPath count];
|
|
|
|
PSMatrix* matrix = [[PSMatrix new] autorelease];
|
1997-08-05 21:50:10 +00:00
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
for (i = count - 1; i >= 0; i--) {
|
|
|
|
NSView* view = [viewsPath objectAtIndex:i];
|
1997-08-05 21:50:10 +00:00
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
[matrix concatenateWith:view->frameMatrix];
|
|
|
|
[matrix concatenateWith:view->boundsMatrix];
|
|
|
|
}
|
1997-08-05 21:50:10 +00:00
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
return matrix;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
- (NSArray*)_pathBetweenSubview:(NSView*)subview
|
|
|
|
toSuperview:(NSView*)_superview
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-08-18 17:10:23 +00:00
|
|
|
NSMutableArray* array = [NSMutableArray array];
|
|
|
|
NSView* view = subview;
|
1996-06-21 15:27:13 +00:00
|
|
|
|
1998-07-12 15:15:36 +00:00
|
|
|
while (view && view != _superview) {
|
1997-08-18 17:10:23 +00:00
|
|
|
[array addObject:view];
|
|
|
|
view = view->super_view;
|
|
|
|
}
|
1996-06-21 15:27:13 +00:00
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
return array;
|
|
|
|
}
|
1996-06-21 15:27:13 +00:00
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
- (NSPoint)convertPoint:(NSPoint)aPoint
|
|
|
|
fromView:(NSView*)aView
|
|
|
|
{
|
|
|
|
NSPoint new;
|
|
|
|
PSMatrix* matrix;
|
1996-06-21 15:27:13 +00:00
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
if (!aView)
|
1998-10-15 12:04:53 +00:00
|
|
|
aView = [window contentView];
|
1996-06-21 15:27:13 +00:00
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
if ([self isDescendantOf:aView]) {
|
|
|
|
NSArray* path = [self _pathBetweenSubview:self toSuperview:aView];
|
1996-06-21 15:27:13 +00:00
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
matrix = [self _concatenateMatricesInReverseOrderFromPath:path];
|
|
|
|
[matrix inverse];
|
|
|
|
new = [matrix pointInMatrixSpace:aPoint];
|
|
|
|
}
|
|
|
|
else if ([aView isDescendantOf:self]) {
|
|
|
|
NSArray* path = [self _pathBetweenSubview:aView toSuperview:self];
|
1996-06-21 15:27:13 +00:00
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
matrix = [self _concatenateMatricesInReverseOrderFromPath:path];
|
|
|
|
new = [matrix pointInMatrixSpace:aPoint];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* The views are not on the same hierarchy of views. Convert the point to
|
|
|
|
window from the other's view coordinates and then to our view
|
|
|
|
coordinates. */
|
|
|
|
new = [aView convertPoint:aPoint toView:nil];
|
|
|
|
new = [self convertPoint:new fromView:nil];
|
|
|
|
}
|
|
|
|
return new;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSPoint)convertPoint:(NSPoint)aPoint
|
|
|
|
toView:(NSView *)aView
|
|
|
|
{
|
1997-08-18 17:10:23 +00:00
|
|
|
if (!aView)
|
1998-10-15 12:04:53 +00:00
|
|
|
aView = [window contentView];
|
1996-06-21 15:27:13 +00:00
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
return [aView convertPoint:aPoint fromView:self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSRect)convertRect:(NSRect)aRect
|
|
|
|
fromView:(NSView *)aView
|
|
|
|
{
|
|
|
|
NSRect r;
|
|
|
|
|
|
|
|
// Must belong to the same window
|
1997-08-18 17:10:23 +00:00
|
|
|
if (aView && [self window] != [aView window])
|
1996-05-30 20:03:15 +00:00
|
|
|
return NSZeroRect;
|
|
|
|
|
|
|
|
r = aRect;
|
|
|
|
r.origin = [self convertPoint:r.origin fromView:aView];
|
|
|
|
r.size = [self convertSize:r.size fromView:aView];
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSRect)convertRect:(NSRect)aRect
|
|
|
|
toView:(NSView *)aView
|
|
|
|
{
|
|
|
|
NSRect r;
|
|
|
|
|
|
|
|
// Must belong to the same window
|
1997-08-18 17:10:23 +00:00
|
|
|
if (aView && [self window] != [aView window])
|
1996-05-30 20:03:15 +00:00
|
|
|
return NSZeroRect;
|
|
|
|
|
|
|
|
r = aRect;
|
|
|
|
r.origin = [self convertPoint:r.origin toView:aView];
|
|
|
|
r.size = [self convertSize:r.size toView:aView];
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
- (PSMatrix*)_concatenateBoundsMatricesInReverseOrderFromPath:(NSArray*)viewsPath
|
|
|
|
{
|
|
|
|
int i, count = [viewsPath count];
|
|
|
|
PSMatrix* matrix = [[PSMatrix new] autorelease];
|
|
|
|
|
|
|
|
for (i = count - 1; i >= 0; i--) {
|
|
|
|
NSView* view = [viewsPath objectAtIndex:i];
|
|
|
|
|
|
|
|
[matrix concatenateWith:view->boundsMatrix];
|
|
|
|
}
|
|
|
|
|
|
|
|
return matrix;
|
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
- (NSSize)convertSize:(NSSize)aSize
|
|
|
|
fromView:(NSView *)aView
|
|
|
|
{
|
1997-08-18 17:10:23 +00:00
|
|
|
NSSize new;
|
|
|
|
PSMatrix* matrix;
|
|
|
|
|
|
|
|
if (!aView)
|
|
|
|
aView = [[self window] contentView];
|
|
|
|
|
|
|
|
if ([self isDescendantOf:aView]) {
|
|
|
|
NSArray* path = [self _pathBetweenSubview:self toSuperview:aView];
|
|
|
|
|
|
|
|
matrix = [self _concatenateBoundsMatricesInReverseOrderFromPath:path];
|
|
|
|
[matrix inverse];
|
|
|
|
new = [matrix sizeInMatrixSpace:aSize];
|
|
|
|
}
|
|
|
|
else if ([aView isDescendantOf:self]) {
|
|
|
|
NSArray* path = [self _pathBetweenSubview:aView toSuperview:self];
|
|
|
|
|
|
|
|
matrix = [self _concatenateBoundsMatricesInReverseOrderFromPath:path];
|
|
|
|
new = [matrix sizeInMatrixSpace:aSize];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* The views are not on the same hierarchy of views. Convert the point to
|
|
|
|
window from the other's view coordinates and then to our view
|
|
|
|
coordinates. */
|
|
|
|
new = [aView convertSize:aSize toView:nil];
|
|
|
|
new = [self convertSize:new fromView:nil];
|
|
|
|
}
|
|
|
|
return new;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSSize)convertSize:(NSSize)aSize
|
|
|
|
toView:(NSView *)aView
|
|
|
|
{
|
1997-08-18 17:10:23 +00:00
|
|
|
if (!aView)
|
|
|
|
aView = [[self window] contentView];
|
|
|
|
|
|
|
|
return [aView convertSize:aSize fromView:self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setPostsFrameChangedNotifications:(BOOL)flag
|
|
|
|
{
|
|
|
|
post_frame_changes = flag;
|
|
|
|
}
|
|
|
|
|
1997-08-05 21:50:10 +00:00
|
|
|
- (void)setPostsBoundsChangedNotifications:(BOOL)flag
|
|
|
|
{
|
|
|
|
post_bounds_changes = flag;
|
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
- (void)resizeSubviewsWithOldSize:(NSSize)oldSize
|
1996-06-21 15:08:08 +00:00
|
|
|
{
|
|
|
|
id e, o;
|
|
|
|
|
|
|
|
// Are we suppose to resize our subviews?
|
|
|
|
if (![self autoresizesSubviews])
|
|
|
|
return;
|
|
|
|
|
|
|
|
e = [sub_views objectEnumerator];
|
|
|
|
o = [e nextObject];
|
|
|
|
while (o)
|
|
|
|
{
|
|
|
|
NSRect b = [o bounds];
|
|
|
|
NSSize old_size = b.size;
|
|
|
|
|
|
|
|
// Resize the subview
|
|
|
|
// Then tell it to resize its subviews
|
|
|
|
[o resizeWithOldSuperviewSize: oldSize];
|
|
|
|
[o resizeSubviewsWithOldSize: old_size];
|
|
|
|
o = [e nextObject];
|
|
|
|
}
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)setAutoresizesSubviews:(BOOL)flag
|
|
|
|
{
|
|
|
|
autoresize_subviews = flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setAutoresizingMask:(unsigned int)mask
|
|
|
|
{
|
1997-10-09 22:55:31 +00:00
|
|
|
autoresizingMask = mask;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)resizeWithOldSuperviewSize:(NSSize)oldSize
|
1998-08-19 09:00:26 +00:00
|
|
|
{ // preliminary implementation FIX ME
|
|
|
|
if(autoresizingMask == NSViewNotSizable) // view is not resizable
|
|
|
|
return;
|
1998-08-30 16:06:47 +00:00
|
|
|
|
1998-08-19 09:00:26 +00:00
|
|
|
if(autoresizingMask & NSViewWidthSizable) // width resizable?
|
|
|
|
{
|
|
|
|
frame.size.width = [super_view frame].size.width;
|
|
|
|
}
|
|
|
|
else // width is not resizable, so check
|
|
|
|
{ // if left margin can be stretched
|
|
|
|
if(autoresizingMask & NSViewMinXMargin)
|
|
|
|
frame.origin.x += [super_view frame].size.width - oldSize.width;
|
|
|
|
}
|
1998-08-30 16:06:47 +00:00
|
|
|
|
1998-08-19 09:00:26 +00:00
|
|
|
if(autoresizingMask & NSViewHeightSizable) // height resizable?
|
|
|
|
{
|
|
|
|
frame.size.height = [super_view frame].size.height;
|
|
|
|
}
|
|
|
|
else // height is not resizable so check
|
1998-10-15 12:04:53 +00:00
|
|
|
{ // if bottom margin can be stretchd
|
1998-08-19 09:00:26 +00:00
|
|
|
if(autoresizingMask & NSViewMinYMargin)
|
1998-10-15 12:04:53 +00:00
|
|
|
frame.origin.y += [super_view frame].size.height - oldSize.height;
|
|
|
|
// if(autoresizingMask & NSViewMaxYMargin)
|
|
|
|
// frame.origin.y = [super_view frame].origin.y;
|
1998-08-19 09:00:26 +00:00
|
|
|
}
|
1998-10-15 12:04:53 +00:00
|
|
|
|
|
|
|
fprintf (stderr, "NSView resizeWithOldSuperviewSize: \n");
|
|
|
|
fprintf (stderr,
|
|
|
|
"NSView: frame origin (%1.2f, %1.2f), size (%1.2f, %1.2f)\n",
|
|
|
|
frame.origin.x, frame.origin.y,
|
|
|
|
frame.size.width, frame.size.height);
|
|
|
|
fprintf (stderr, "NSView: old size (%1.2f, %1.2f)\n",
|
|
|
|
oldSize.width, oldSize.height);
|
1998-08-19 09:00:26 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)allocateGState
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)releaseGState
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (int)gState
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)renewGState
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)setUpGState
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)lockFocus
|
|
|
|
{
|
1997-03-20 19:23:21 +00:00
|
|
|
NSView *s = [self superview];
|
|
|
|
|
|
|
|
// lock our superview
|
|
|
|
if (s)
|
|
|
|
[s lockFocus];
|
|
|
|
|
|
|
|
// push ourselves
|
1996-06-03 15:03:43 +00:00
|
|
|
[[self class] pushFocusView: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)unlockFocus
|
|
|
|
{
|
1997-03-20 19:23:21 +00:00
|
|
|
NSView *s = [self superview];
|
|
|
|
|
|
|
|
// unlock our superview
|
|
|
|
if (s)
|
|
|
|
[s unlockFocus];
|
|
|
|
|
|
|
|
// pop ourselves
|
1996-06-03 15:03:43 +00:00
|
|
|
[[self class] popFocusView];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)canDraw
|
|
|
|
{
|
1997-10-09 22:55:31 +00:00
|
|
|
// TODO
|
1996-05-30 20:03:15 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
1997-10-09 22:55:31 +00:00
|
|
|
- (void)_setNeedsFlush
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-10-09 22:55:31 +00:00
|
|
|
[window _setNeedsFlush];
|
|
|
|
}
|
1997-03-17 18:43:27 +00:00
|
|
|
|
1997-10-09 22:55:31 +00:00
|
|
|
- (void)display
|
|
|
|
{
|
1998-10-15 12:04:53 +00:00
|
|
|
if(!window) // do nothing if not in
|
|
|
|
return; // a window
|
|
|
|
|
|
|
|
invalidatedRectangle = NSZeroRect; // Reset invalid rect
|
|
|
|
[self displayRect:[self visibleRect]]; // display visible rect
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)displayIfNeeded
|
|
|
|
{
|
1997-10-09 22:55:31 +00:00
|
|
|
if (needs_display) {
|
|
|
|
NSRect rect = invalidatedRectangle;
|
|
|
|
|
|
|
|
invalidatedRectangle = NSZeroRect;
|
|
|
|
[self displayRect:rect];
|
1997-03-17 18:43:27 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)displayIfNeededIgnoringOpacity
|
|
|
|
{
|
1997-03-17 18:43:27 +00:00
|
|
|
if (needs_display) {
|
1997-10-09 22:55:31 +00:00
|
|
|
NSRect rect = invalidatedRectangle;
|
|
|
|
|
|
|
|
invalidatedRectangle = NSZeroRect;
|
|
|
|
[self displayRect:rect];
|
1997-03-17 18:43:27 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1997-10-09 22:55:31 +00:00
|
|
|
- (void)displayRect:(NSRect)rect
|
|
|
|
{
|
1998-08-30 16:06:47 +00:00
|
|
|
int i, count;
|
1997-10-09 22:55:31 +00:00
|
|
|
|
1998-08-30 16:06:47 +00:00
|
|
|
if (!boundsMatrix || !frameMatrix)
|
|
|
|
NSLog (@"warning: %@ %p has not have the PS matrices setup!",
|
|
|
|
NSStringFromClass(isa), self);
|
1997-10-09 22:55:31 +00:00
|
|
|
|
1998-08-30 16:06:47 +00:00
|
|
|
needs_display = NO;
|
1997-10-09 22:55:31 +00:00
|
|
|
|
1998-08-30 16:06:47 +00:00
|
|
|
[self lockFocus];
|
|
|
|
[self drawRect:rect];
|
|
|
|
[window _setNeedsFlush];
|
|
|
|
[self unlockFocus];
|
|
|
|
// Tell subviews to display
|
|
|
|
for (i = 0, count = [sub_views count]; i < count; ++i)
|
|
|
|
{
|
|
|
|
NSView* subview = [sub_views objectAtIndex:i];
|
|
|
|
NSRect subviewFrame = subview->frame;
|
|
|
|
NSRect intersection;
|
1998-11-02 17:42:23 +00:00
|
|
|
// If the subview is rotated compute
|
|
|
|
// its bounding rectangle and use this
|
|
|
|
// one instead of the subview's frame.
|
1998-08-30 16:06:47 +00:00
|
|
|
if ([subview->frameMatrix isRotated])
|
|
|
|
[subview->frameMatrix boundingRectFor:subviewFrame
|
|
|
|
result:&subviewFrame];
|
|
|
|
|
1998-11-02 17:42:23 +00:00
|
|
|
// Determine if the subview's frame
|
|
|
|
// intersects "rect" so that we can
|
|
|
|
// display the subview.
|
1998-08-30 16:06:47 +00:00
|
|
|
intersection = NSIntersectionRect (rect, subviewFrame);
|
|
|
|
if (intersection.origin.x || intersection.origin.y ||
|
|
|
|
intersection.size.width || intersection.size.height)
|
1998-11-02 17:42:23 +00:00
|
|
|
{ // Convert the intersection rectangle
|
|
|
|
// to the subview's coordinates
|
1998-08-30 16:06:47 +00:00
|
|
|
intersection = [subview convertRect:intersection fromView:self];
|
|
|
|
[subview displayRect:intersection];
|
|
|
|
}
|
|
|
|
}
|
1997-10-09 22:55:31 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)displayRectIgnoringOpacity:(NSRect)aRect
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)drawRect:(NSRect)rect
|
1997-08-18 17:10:23 +00:00
|
|
|
{}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (NSRect)visibleRect
|
1998-10-15 12:04:53 +00:00
|
|
|
{ // if no super view
|
|
|
|
if (!super_view) // bounds is visible
|
|
|
|
return bounds;
|
|
|
|
else // return intersection
|
|
|
|
{ // between bounds and
|
|
|
|
NSRect superviewsVisibleRect; // super view's visible
|
|
|
|
// rect
|
|
|
|
superviewsVisibleRect = [self convertRect:[super_view visibleRect]
|
|
|
|
fromView:super_view];
|
|
|
|
|
|
|
|
return NSIntersectionRect(superviewsVisibleRect, bounds);
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1997-10-09 22:55:31 +00:00
|
|
|
- (void)_addSubviewForNeedingDisplay:(NSView*)view
|
1998-10-15 12:04:53 +00:00
|
|
|
{ // Add view to the list
|
|
|
|
NSView* currentView; // of sibling subviews
|
|
|
|
// that need display.
|
1998-08-30 16:06:47 +00:00
|
|
|
currentView = _subviewsThatNeedDisplay;
|
1998-10-15 12:04:53 +00:00
|
|
|
while (currentView) // do nothing if the
|
|
|
|
{ // view is already in
|
|
|
|
if (currentView == view) // self's list.
|
1998-08-30 16:06:47 +00:00
|
|
|
return;
|
|
|
|
currentView = currentView->_nextSiblingSubviewThatNeedsDisplay;
|
|
|
|
}
|
|
|
|
// view is not in the list of subviews that need display.
|
|
|
|
// Concatenate self's list of subviews that need display to
|
|
|
|
// the view's list of siblings subviews that need display.
|
1997-10-09 22:55:31 +00:00
|
|
|
|
1998-08-30 16:06:47 +00:00
|
|
|
// find the last element in the view's
|
|
|
|
currentView = view; // list of siblings that need display
|
|
|
|
while (currentView->_nextSiblingSubviewThatNeedsDisplay)
|
|
|
|
currentView = currentView->_nextSiblingSubviewThatNeedsDisplay;
|
1997-10-09 22:55:31 +00:00
|
|
|
|
1998-08-30 16:06:47 +00:00
|
|
|
// link the lists by assigning to view's
|
|
|
|
// _nextSiblingSubviewThatNeedsDisplay ivar
|
|
|
|
// self's _subviewsThatNeedDisplay ivar.
|
|
|
|
currentView->_nextSiblingSubviewThatNeedsDisplay =_subviewsThatNeedDisplay;
|
|
|
|
_subviewsThatNeedDisplay = view;
|
1997-10-09 22:55:31 +00:00
|
|
|
|
1998-08-30 16:06:47 +00:00
|
|
|
// Add recursively using the same algorithm with
|
|
|
|
needs_display = YES; // self. This way we'll create a subtree of views
|
|
|
|
if (super_view) // that need display inside the views hierarchy.
|
|
|
|
[super_view _addSubviewForNeedingDisplay:self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1997-10-29 22:17:51 +00:00
|
|
|
- (void)_removeSubviewFromViewsThatNeedDisplay:(NSView*)view
|
|
|
|
{
|
1997-10-31 01:24:08 +00:00
|
|
|
// If no subviews need to be displayed then
|
|
|
|
// then view must not be among them
|
|
|
|
if (!_subviewsThatNeedDisplay)
|
|
|
|
return;
|
|
|
|
|
1997-10-29 22:17:51 +00:00
|
|
|
/* Remove view from the list of subviews that need display */
|
|
|
|
if (_subviewsThatNeedDisplay == view)
|
1997-10-31 01:24:08 +00:00
|
|
|
{
|
|
|
|
_subviewsThatNeedDisplay = view->_nextSiblingSubviewThatNeedsDisplay;
|
|
|
|
[view _recursivelyResetNeedsDisplayInAllViews];
|
|
|
|
}
|
1997-10-29 22:17:51 +00:00
|
|
|
else {
|
|
|
|
NSView* currentView;
|
|
|
|
|
|
|
|
for (currentView = _subviewsThatNeedDisplay;
|
1997-10-31 01:24:08 +00:00
|
|
|
currentView && currentView->_nextSiblingSubviewThatNeedsDisplay;
|
1997-10-29 22:17:51 +00:00
|
|
|
currentView = currentView->_nextSiblingSubviewThatNeedsDisplay)
|
|
|
|
if (currentView->_nextSiblingSubviewThatNeedsDisplay == view)
|
1997-10-31 01:24:08 +00:00
|
|
|
{
|
|
|
|
currentView->_nextSiblingSubviewThatNeedsDisplay
|
1997-10-29 22:17:51 +00:00
|
|
|
= view->_nextSiblingSubviewThatNeedsDisplay;
|
1997-10-31 01:24:08 +00:00
|
|
|
[view _recursivelyResetNeedsDisplayInAllViews];
|
|
|
|
break;
|
|
|
|
}
|
1997-10-29 22:17:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
- (void)setNeedsDisplay:(BOOL)flag
|
|
|
|
{
|
|
|
|
needs_display = flag;
|
1997-10-09 22:55:31 +00:00
|
|
|
if (needs_display) {
|
1998-08-30 16:06:47 +00:00
|
|
|
|
1997-10-09 22:55:31 +00:00
|
|
|
invalidatedRectangle = bounds;
|
|
|
|
[window _setNeedsDisplay];
|
|
|
|
|
|
|
|
if (super_view)
|
|
|
|
[super_view _addSubviewForNeedingDisplay:self];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1997-10-09 22:55:31 +00:00
|
|
|
- (void)setNeedsDisplayInRect:(NSRect)rect
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
needs_display = YES;
|
1997-10-09 22:55:31 +00:00
|
|
|
invalidatedRectangle = NSUnionRect (invalidatedRectangle, rect);
|
|
|
|
[window _setNeedsDisplay];
|
|
|
|
|
|
|
|
if (super_view)
|
|
|
|
[super_view _addSubviewForNeedingDisplay:self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1997-10-09 22:55:31 +00:00
|
|
|
- (void)_recursivelyResetNeedsDisplayInAllViews
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-10-09 22:55:31 +00:00
|
|
|
NSView* currentView = _subviewsThatNeedDisplay;
|
|
|
|
NSView* nextView;
|
|
|
|
|
|
|
|
while (currentView) {
|
|
|
|
nextView = currentView->_nextSiblingSubviewThatNeedsDisplay;
|
|
|
|
[currentView _recursivelyResetNeedsDisplayInAllViews];
|
|
|
|
currentView->_nextSiblingSubviewThatNeedsDisplay = NULL;
|
|
|
|
currentView = nextView;
|
|
|
|
}
|
|
|
|
_subviewsThatNeedDisplay = NULL;
|
1997-10-31 01:24:08 +00:00
|
|
|
_nextSiblingSubviewThatNeedsDisplay = NULL;
|
1997-10-09 22:55:31 +00:00
|
|
|
}
|
|
|
|
|
1997-12-04 01:58:57 +00:00
|
|
|
- (void)_unconditionallyResetNeedsDisplayInAllViews
|
|
|
|
{
|
|
|
|
int i, count;
|
|
|
|
|
|
|
|
_subviewsThatNeedDisplay = NULL;
|
|
|
|
_nextSiblingSubviewThatNeedsDisplay = NULL;
|
|
|
|
|
|
|
|
if (!sub_views || !(count = [sub_views count]))
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
[[sub_views objectAtIndex:i] _unconditionallyResetNeedsDisplayInAllViews];
|
|
|
|
}
|
|
|
|
|
1997-10-09 22:55:31 +00:00
|
|
|
- (void)_displayNeededViews
|
|
|
|
{
|
|
|
|
NSView* subview;
|
|
|
|
|
|
|
|
if (needs_display)
|
|
|
|
[self displayIfNeeded];
|
|
|
|
|
|
|
|
subview = _subviewsThatNeedDisplay;
|
|
|
|
while (subview) {
|
|
|
|
[subview _displayNeededViews];
|
|
|
|
subview = subview->_nextSiblingSubviewThatNeedsDisplay;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)_collectInvalidatedRectanglesInArray:(NSMutableArray*)array
|
|
|
|
originMatrix:(PSMatrix*)originMatrix
|
|
|
|
sizeMatrix:(PSMatrix*)sizeMatrix
|
|
|
|
{
|
|
|
|
PSMatrix* copyOfOriginMatrix;
|
|
|
|
PSMatrix* copyOfSizeMatrix;
|
|
|
|
NSView* subview = _subviewsThatNeedDisplay;
|
|
|
|
|
1997-10-22 00:27:59 +00:00
|
|
|
copyOfOriginMatrix = [originMatrix copy];
|
|
|
|
copyOfSizeMatrix = [sizeMatrix copy];
|
|
|
|
[copyOfOriginMatrix concatenateWith:frameMatrix];
|
|
|
|
[copyOfOriginMatrix concatenateWith:boundsMatrix];
|
|
|
|
[copyOfSizeMatrix concatenateWith:boundsMatrix];
|
|
|
|
|
1997-10-09 22:55:31 +00:00
|
|
|
// NSLog (@"_collectInvalidatedRectanglesInArray");
|
|
|
|
|
|
|
|
while (subview) {
|
|
|
|
NSRect subviewFrame;
|
|
|
|
NSRect intersection;
|
|
|
|
|
|
|
|
if (subview->needs_display) {
|
|
|
|
subviewFrame = subview->invalidatedRectangle;
|
|
|
|
|
1997-10-22 00:27:59 +00:00
|
|
|
/* Compute the origin of the invalidated rectangle into receiver's
|
|
|
|
coordinates. */
|
|
|
|
subviewFrame = [self convertRect:subviewFrame fromView:subview];
|
|
|
|
|
1997-10-09 22:55:31 +00:00
|
|
|
/* If the subview is rotated compute its bounding rectangle and use this
|
|
|
|
one instead of the invalidated rectangle. */
|
|
|
|
if ([subview->frameMatrix isRotated])
|
|
|
|
[subview->frameMatrix boundingRectFor:subviewFrame
|
|
|
|
result:&subviewFrame];
|
|
|
|
|
|
|
|
/* Determine if the subview's invalidated frame rectangle intersects
|
|
|
|
our bounds to find out if the subview gets displayed. */
|
|
|
|
intersection = NSIntersectionRect (bounds, subviewFrame);
|
|
|
|
if (intersection.origin.x || intersection.origin.y
|
|
|
|
|| intersection.size.width || intersection.size.height) {
|
1997-10-22 00:27:59 +00:00
|
|
|
NSDebugLog (@"intersection (%@) = ((%6.2f, %6.2f), (%6.2f, %6.2f))",
|
|
|
|
NSStringFromClass(isa),
|
|
|
|
intersection.origin.x, intersection.origin.y,
|
|
|
|
intersection.size.width, intersection.size.height);
|
1997-10-09 22:55:31 +00:00
|
|
|
/* Convert the intersection rectangle to the window coordinates */
|
|
|
|
intersection.origin
|
|
|
|
= [copyOfOriginMatrix pointInMatrixSpace:intersection.origin];
|
|
|
|
intersection.size
|
|
|
|
= [copyOfSizeMatrix sizeInMatrixSpace:intersection.size];
|
|
|
|
|
|
|
|
[array addObject:[NSValue valueWithRect:intersection]];
|
1997-10-22 00:27:59 +00:00
|
|
|
NSDebugLog (@"intersection in window coords = ((%6.2f, %6.2f), (%6.2f, %6.2f))",
|
|
|
|
intersection.origin.x, intersection.origin.y,
|
|
|
|
intersection.size.width, intersection.size.height);
|
1997-10-09 22:55:31 +00:00
|
|
|
}
|
|
|
|
}
|
1997-10-22 00:27:59 +00:00
|
|
|
else {
|
1997-10-09 22:55:31 +00:00
|
|
|
[subview _collectInvalidatedRectanglesInArray:array
|
|
|
|
originMatrix:copyOfOriginMatrix
|
|
|
|
sizeMatrix:copyOfSizeMatrix];
|
1997-10-22 00:27:59 +00:00
|
|
|
}
|
1997-10-09 22:55:31 +00:00
|
|
|
|
|
|
|
subview = subview->_nextSiblingSubviewThatNeedsDisplay;
|
|
|
|
}
|
1997-10-22 00:27:59 +00:00
|
|
|
|
|
|
|
[copyOfOriginMatrix release];
|
|
|
|
[copyOfSizeMatrix release];
|
1997-10-09 22:55:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSRect)_boundingRectFor:(NSRect)rect
|
|
|
|
{
|
|
|
|
NSRect new;
|
|
|
|
|
|
|
|
[frameMatrix boundingRectFor:rect result:&new];
|
|
|
|
return new;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Scrolling
|
|
|
|
//
|
|
|
|
- (NSRect)adjustScroll:(NSRect)newVisible
|
|
|
|
{
|
|
|
|
return NSZeroRect;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)autoscroll:(NSEvent *)theEvent
|
|
|
|
{
|
1997-08-05 21:50:10 +00:00
|
|
|
if (super_view)
|
|
|
|
return [super_view autoscroll:theEvent];
|
1996-05-30 20:03:15 +00:00
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)reflectScrolledClipView:(NSClipView *)aClipView
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)scrollClipView:(NSClipView *)aClipView
|
|
|
|
toPoint:(NSPoint)aPoint
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)scrollPoint:(NSPoint)aPoint
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)scrollRect:(NSRect)aRect
|
|
|
|
by:(NSSize)delta
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (BOOL)scrollRectToVisible:(NSRect)aRect
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Managing the Cursor
|
|
|
|
//
|
1997-03-05 01:11:17 +00:00
|
|
|
// We utilize the tracking rectangle class
|
|
|
|
// to also maintain the cursor rects
|
|
|
|
//
|
1996-05-30 20:03:15 +00:00
|
|
|
- (void)addCursorRect:(NSRect)aRect
|
|
|
|
cursor:(NSCursor *)anObject
|
1997-03-05 01:11:17 +00:00
|
|
|
{
|
|
|
|
TrackingRectangle *m;
|
|
|
|
|
1997-07-07 16:56:52 +00:00
|
|
|
m = [[[TrackingRectangle alloc] initWithRect: aRect tag: 0 owner: anObject
|
|
|
|
userData: NULL inside: YES]
|
|
|
|
autorelease];
|
1997-03-05 01:11:17 +00:00
|
|
|
[cursor_rects addObject:m];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)discardCursorRects
|
1997-03-05 01:11:17 +00:00
|
|
|
{
|
|
|
|
[cursor_rects removeAllObjects];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)removeCursorRect:(NSRect)aRect
|
|
|
|
cursor:(NSCursor *)anObject
|
1997-03-05 01:11:17 +00:00
|
|
|
{
|
|
|
|
id e = [cursor_rects objectEnumerator];
|
|
|
|
TrackingRectangle *o;
|
|
|
|
NSCursor *c;
|
|
|
|
|
|
|
|
// Base remove test upon cursor object
|
|
|
|
o = [e nextObject];
|
1997-07-07 16:56:52 +00:00
|
|
|
while (o) {
|
|
|
|
c = [o owner];
|
|
|
|
if (c == anObject) {
|
|
|
|
[cursor_rects removeObject: o];
|
|
|
|
break;
|
1997-03-05 01:11:17 +00:00
|
|
|
}
|
1997-07-07 16:56:52 +00:00
|
|
|
else
|
|
|
|
o = [e nextObject];
|
|
|
|
}
|
1997-03-05 01:11:17 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
- (void)resetCursorRects
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (id)viewWithTag:(int)aTag
|
|
|
|
{
|
1997-07-07 16:56:52 +00:00
|
|
|
int i, count;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-07-07 16:56:52 +00:00
|
|
|
count = [sub_views count];
|
|
|
|
for (i = 0; i < count; ++i)
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1997-07-07 16:56:52 +00:00
|
|
|
id view = [sub_views objectAtIndex:i];
|
|
|
|
|
|
|
|
if ([view tag] == aTag)
|
|
|
|
return view;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Aiding Event Handling
|
|
|
|
//
|
|
|
|
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSView *)hitTest:(NSPoint)aPoint
|
|
|
|
{
|
|
|
|
NSPoint p;
|
1997-08-18 17:10:23 +00:00
|
|
|
int i, count;
|
1996-05-30 20:03:15 +00:00
|
|
|
NSView *v = nil, *w;
|
|
|
|
|
1997-08-22 18:38:38 +00:00
|
|
|
// If not within our frame then immediately return
|
|
|
|
if (![self mouse:aPoint inRect:frame])
|
|
|
|
return nil;
|
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
p = [self convertPoint:aPoint fromView:super_view];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
// Check our sub_views
|
1997-08-18 17:10:23 +00:00
|
|
|
count = [sub_views count];
|
1997-10-09 22:55:31 +00:00
|
|
|
for (i = count - 1; i >= 0; i--)
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
w = [sub_views objectAtIndex:i];
|
|
|
|
v = [w hitTest:p];
|
|
|
|
if (v) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// It is either the subview or ourself
|
|
|
|
if (v)
|
|
|
|
{
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)mouse:(NSPoint)aPoint
|
|
|
|
inRect:(NSRect)aRect
|
|
|
|
{
|
|
|
|
if (aPoint.x < aRect.origin.x)
|
|
|
|
return NO;
|
|
|
|
if (aPoint.y < aRect.origin.y)
|
|
|
|
return NO;
|
|
|
|
if (aPoint.x > (aRect.origin.x + aRect.size.width))
|
|
|
|
return NO;
|
|
|
|
if (aPoint.y > (aRect.origin.y + aRect.size.height))
|
|
|
|
return NO;
|
|
|
|
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)removeTrackingRect:(NSTrackingRectTag)tag
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
TrackingRectangle *m;
|
|
|
|
|
|
|
|
j = [tracking_rects count];
|
|
|
|
for (i = 0;i < j; ++i)
|
|
|
|
{
|
|
|
|
m = (TrackingRectangle *)[tracking_rects objectAtIndex:i];
|
|
|
|
if ([m tag] == tag)
|
|
|
|
{
|
|
|
|
[tracking_rects removeObjectAtIndex:i];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent *)anEvent
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSTrackingRectTag)addTrackingRect:(NSRect)aRect
|
|
|
|
owner:(id)anObject
|
1996-09-12 19:24:32 +00:00
|
|
|
userData:(void *)data
|
|
|
|
assumeInside:(BOOL)flag
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
NSTrackingRectTag t;
|
|
|
|
int i, j;
|
|
|
|
TrackingRectangle *m;
|
|
|
|
|
|
|
|
t = 0;
|
|
|
|
j = [tracking_rects count];
|
|
|
|
for (i = 0;i < j; ++i)
|
|
|
|
{
|
|
|
|
m = (TrackingRectangle *)[tracking_rects objectAtIndex:i];
|
|
|
|
if ([m tag] > t)
|
|
|
|
t = [m tag];
|
|
|
|
}
|
|
|
|
++t;
|
|
|
|
|
1997-07-07 16:56:52 +00:00
|
|
|
m = [[[TrackingRectangle alloc] initWithRect:aRect tag:t owner:anObject
|
|
|
|
userData:data inside:flag]
|
|
|
|
autorelease];
|
1996-05-30 20:03:15 +00:00
|
|
|
[tracking_rects addObject:m];
|
|
|
|
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *)trackingRectangles
|
|
|
|
{
|
|
|
|
return tracking_rects;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Dragging
|
|
|
|
//
|
|
|
|
- (BOOL)dragFile:(NSString *)filename
|
|
|
|
fromRect:(NSRect)rect
|
1996-09-12 19:24:32 +00:00
|
|
|
slideBack:(BOOL)slideFlag
|
|
|
|
event:(NSEvent *)event
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dragImage:(NSImage *)anImage
|
|
|
|
at:(NSPoint)viewLocation
|
1996-09-12 19:24:32 +00:00
|
|
|
offset:(NSSize)initialOffset
|
|
|
|
event:(NSEvent *)event
|
|
|
|
pasteboard:(NSPasteboard *)pboard
|
|
|
|
source:(id)sourceObject
|
|
|
|
slideBack:(BOOL)slideFlag
|
1996-05-30 20:03:15 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)registerForDraggedTypes:(NSArray *)newTypes
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)unregisterDraggedTypes
|
|
|
|
{}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Printing
|
|
|
|
//
|
|
|
|
- (NSData *)dataWithEPSInsideRect:(NSRect)aRect
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)fax:(id)sender
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)print:(id)sender
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)writeEPSInsideRect:(NSRect)rect
|
|
|
|
toPasteboard:(NSPasteboard *)pasteboard
|
|
|
|
{}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Pagination
|
|
|
|
//
|
|
|
|
- (void)adjustPageHeightNew:(float *)newBottom
|
|
|
|
top:(float)oldTop
|
1996-09-12 19:24:32 +00:00
|
|
|
bottom:(float)oldBottom
|
|
|
|
limit:(float)bottomLimit
|
1996-05-30 20:03:15 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)adjustPageWidthNew:(float *)newRight
|
|
|
|
left:(float)oldLeft
|
1996-09-12 19:24:32 +00:00
|
|
|
right:(float)oldRight
|
|
|
|
limit:(float)rightLimit
|
1996-05-30 20:03:15 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
- (float)heightAdjustLimit
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)knowsPagesFirst:(int *)firstPageNum
|
|
|
|
last:(int *)lastPageNum
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSPoint)locationOfPrintRect:(NSRect)aRect
|
|
|
|
{
|
|
|
|
return NSZeroPoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSRect)rectForPage:(int)page
|
|
|
|
{
|
|
|
|
return NSZeroRect;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (float)widthAdjustLimit
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Writing Conforming PostScript
|
|
|
|
//
|
|
|
|
- (void)addToPageSetup
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)beginPage:(int)ordinalNum
|
|
|
|
label:(NSString *)aString
|
1996-09-12 19:24:32 +00:00
|
|
|
bBox:(NSRect)pageRect
|
1996-05-30 20:03:15 +00:00
|
|
|
fonts:(NSString *)fontNames
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)beginPageSetupRect:(NSRect)aRect
|
|
|
|
placement:(NSPoint)location
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)beginPrologueBBox:(NSRect)boundingBox
|
|
|
|
creationDate:(NSString *)dateCreated
|
1996-09-12 19:24:32 +00:00
|
|
|
createdBy:(NSString *)anApplication
|
|
|
|
fonts:(NSString *)fontNames
|
|
|
|
forWhom:(NSString *)user
|
|
|
|
pages:(int)numPages
|
|
|
|
title:(NSString *)aTitle
|
1996-05-30 20:03:15 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)beginSetup
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)beginTrailer
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)drawPageBorderWithSize:(NSSize)borderSize
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)drawSheetBorderWithSize:(NSSize)borderSize
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)endHeaderComments
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)endPrologue
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)endSetup
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)endPageSetup
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)endPage
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)endTrailer
|
|
|
|
{}
|
|
|
|
|
|
|
|
//
|
|
|
|
// NSCoding protocol
|
|
|
|
//
|
|
|
|
- (void)encodeWithCoder:aCoder
|
|
|
|
{
|
|
|
|
[super encodeWithCoder:aCoder];
|
|
|
|
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"NSView: start encoding\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
[aCoder encodeRect: frame];
|
|
|
|
[aCoder encodeRect: bounds];
|
1997-02-18 00:29:25 +00:00
|
|
|
[aCoder encodeConditionalObject:super_view];
|
1996-05-30 20:03:15 +00:00
|
|
|
[aCoder encodeObject: sub_views];
|
1997-02-18 00:29:25 +00:00
|
|
|
[aCoder encodeConditionalObject:window];
|
1996-05-30 20:03:15 +00:00
|
|
|
[aCoder encodeObject: tracking_rects];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &is_rotated_from_base];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(BOOL)
|
|
|
|
at: &is_rotated_or_scaled_from_base];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &needs_display];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &disable_autodisplay];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &post_frame_changes];
|
|
|
|
[aCoder encodeValueOfObjCType:@encode(BOOL) at: &autoresize_subviews];
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"NSView: finish encoding\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- initWithCoder:aDecoder
|
|
|
|
{
|
|
|
|
[super initWithCoder:aDecoder];
|
|
|
|
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"NSView: start decoding\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
frame = [aDecoder decodeRect];
|
|
|
|
bounds = [aDecoder decodeRect];
|
1997-02-18 00:29:25 +00:00
|
|
|
super_view = [aDecoder decodeObject];
|
1996-05-30 20:03:15 +00:00
|
|
|
sub_views = [aDecoder decodeObject];
|
1997-02-18 00:29:25 +00:00
|
|
|
window = [aDecoder decodeObject];
|
1996-05-30 20:03:15 +00:00
|
|
|
tracking_rects = [aDecoder decodeObject];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &is_rotated_from_base];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(BOOL)
|
|
|
|
at: &is_rotated_or_scaled_from_base];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &needs_display];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &disable_autodisplay];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &post_frame_changes];
|
|
|
|
[aDecoder decodeValueOfObjCType:@encode(BOOL) at: &autoresize_subviews];
|
1996-07-11 00:59:30 +00:00
|
|
|
NSDebugLog(@"NSView: finish decoding\n");
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
1997-10-09 22:55:31 +00:00
|
|
|
/* Accessor methods */
|
|
|
|
- (NSMutableArray *)subviews { return sub_views; }
|
|
|
|
- (NSView *)superview { return super_view; }
|
|
|
|
- (void)setSuperview:(NSView *)superview { super_view = superview; }
|
|
|
|
- (NSRect)frame { return frame; }
|
|
|
|
- (float)frameRotation { return [frameMatrix rotationAngle]; }
|
|
|
|
- (BOOL)shouldDrawColor { return YES; }
|
|
|
|
- (BOOL)isOpaque { return NO; }
|
|
|
|
- (BOOL)needsDisplay { return needs_display; }
|
|
|
|
- (BOOL)autoresizesSubviews { return autoresize_subviews; }
|
|
|
|
- (unsigned int)autoresizingMask { return autoresizingMask; }
|
|
|
|
- (int)tag { return -1; }
|
|
|
|
- (NSArray *)cursorRectangles { return cursor_rects; }
|
|
|
|
- (float)boundsRotation { return [boundsMatrix rotationAngle]; }
|
|
|
|
- (NSRect)bounds { return bounds; }
|
|
|
|
- (BOOL)isFlipped { return NO; }
|
|
|
|
- (BOOL)postsFrameChangedNotifications { return post_frame_changes; }
|
|
|
|
- (BOOL)postsBoundsChangedNotifications { return post_bounds_changes; }
|
|
|
|
- (PSMatrix*)_frameMatrix { return frameMatrix; }
|
|
|
|
- (PSMatrix*)_boundsMatrix { return boundsMatrix; }
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
@end
|