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-08-18 17:10:23 +00:00
|
|
|
Ovidiu Predescu <ovidiu@net-community.com>
|
|
|
|
Date: 1996, 1997
|
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-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
|
|
|
|
|
|
|
//
|
|
|
|
// Class variables
|
|
|
|
//
|
1997-02-18 00:29:25 +00:00
|
|
|
static NSMutableDictionary *gnustep_gui_nsview_thread_dict = nil;
|
|
|
|
static NSRecursiveLock *gnustep_gui_nsview_lock = nil;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
@implementation NSView
|
|
|
|
|
|
|
|
//
|
|
|
|
// Class methods
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Initialization
|
|
|
|
//
|
|
|
|
+ (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];
|
1996-06-03 15:03:43 +00:00
|
|
|
|
|
|
|
// Allocate dictionary for maintaining
|
|
|
|
// mapping of threads to focused views
|
|
|
|
gnustep_gui_nsview_thread_dict = [NSMutableDictionary dictionary];
|
|
|
|
// Create lock for serializing access to dictionary
|
|
|
|
gnustep_gui_nsview_lock = [[NSRecursiveLock alloc] init];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Focusing
|
|
|
|
//
|
1996-06-03 15:03:43 +00:00
|
|
|
// +++ Really each thread should have a stack!
|
|
|
|
//
|
|
|
|
+ (void)pushFocusView:(NSView *)focusView
|
|
|
|
{
|
|
|
|
NSThread *current_thread = [NSThread currentThread];
|
|
|
|
|
1996-06-06 13:55:06 +00:00
|
|
|
// Obtain lock so we can edit the dictionary
|
1996-06-03 15:03:43 +00:00
|
|
|
[gnustep_gui_nsview_lock lock];
|
|
|
|
|
|
|
|
// If no context then remove from dictionary
|
|
|
|
if (!focusView)
|
|
|
|
{
|
|
|
|
[gnustep_gui_nsview_thread_dict removeObjectForKey: current_thread];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[gnustep_gui_nsview_thread_dict setObject: focusView
|
|
|
|
forKey: current_thread];
|
|
|
|
}
|
|
|
|
|
|
|
|
[gnustep_gui_nsview_lock unlock];
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (NSView *)popFocusView
|
1996-09-21 16:31:19 +00:00
|
|
|
{
|
|
|
|
NSThread *current_thread = [NSThread currentThread];
|
1997-03-21 01:06:15 +00:00
|
|
|
id v;
|
1996-09-21 16:31:19 +00:00
|
|
|
|
|
|
|
// Obtain lock so we can edit the dictionary
|
|
|
|
[gnustep_gui_nsview_lock lock];
|
|
|
|
|
|
|
|
// Remove from dictionary
|
1997-03-21 01:06:15 +00:00
|
|
|
v = [gnustep_gui_nsview_thread_dict objectForKey: current_thread];
|
1996-09-21 16:31:19 +00:00
|
|
|
[gnustep_gui_nsview_thread_dict removeObjectForKey: current_thread];
|
|
|
|
|
|
|
|
[gnustep_gui_nsview_lock unlock];
|
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
|
|
|
|
{
|
1996-06-03 15:03:43 +00:00
|
|
|
NSThread *current_thread = [NSThread currentThread];
|
|
|
|
NSView *current_view = nil;
|
|
|
|
|
|
|
|
// Get focused view for current thread
|
|
|
|
[gnustep_gui_nsview_lock lock];
|
|
|
|
|
1996-06-06 13:55:06 +00:00
|
|
|
// current_view is nil if no focused view
|
|
|
|
current_view = [gnustep_gui_nsview_thread_dict objectForKey: current_thread];
|
1996-06-03 15:03:43 +00:00
|
|
|
|
|
|
|
[gnustep_gui_nsview_lock unlock];
|
|
|
|
|
|
|
|
return current_view;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Instance methods
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Initializing NSView Objects
|
|
|
|
//
|
|
|
|
- init
|
|
|
|
{
|
|
|
|
return [self initWithFrame:NSZeroRect];
|
|
|
|
}
|
|
|
|
|
|
|
|
// The default initializer
|
|
|
|
- (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;
|
1997-03-17 18:43:27 +00:00
|
|
|
opaque = YES;
|
1996-05-30 20:03:15 +00:00
|
|
|
disable_autodisplay = NO;
|
|
|
|
needs_display = YES;
|
|
|
|
post_frame_changes = NO;
|
1996-06-21 15:08:08 +00:00
|
|
|
autoresize_subviews = YES;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dealloc
|
|
|
|
{
|
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];
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Managing the NSView Hierarchy
|
|
|
|
//
|
|
|
|
- (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
|
|
|
|
[sub_views addObject:(id)aView];
|
|
|
|
[aView setSuperview:self];
|
|
|
|
[aView setNextResponder:self];
|
|
|
|
[aView viewWillMoveToWindow:window];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (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
|
|
|
|
{
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (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-07-07 16:56:52 +00:00
|
|
|
views = [super_view subviews];
|
|
|
|
[views removeObjectIdenticalTo:self];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)replaceSubview:(NSView *)oldView
|
|
|
|
with:(NSView *)newView
|
|
|
|
{
|
1997-07-07 16:56:52 +00:00
|
|
|
int index = [sub_views indexOfObjectIdenticalTo:oldView];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-07-07 16:56:52 +00:00
|
|
|
if (index != NSNotFound)
|
|
|
|
[sub_views replaceObjectAtIndex:index withObject:newView];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)sortSubviewsUsingFunction:(int (*)(id ,id ,void *))compare
|
|
|
|
context:(void *)context
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (NSMutableArray *)subviews
|
|
|
|
{
|
|
|
|
return sub_views;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSView *)superview
|
|
|
|
{
|
|
|
|
return super_view;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setSuperview:(NSView *)superview
|
|
|
|
{
|
|
|
|
super_view = superview;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (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];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Modifying the Frame Rectangle
|
|
|
|
//
|
1997-08-18 17:10:23 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
- (float)frameRotation
|
|
|
|
{
|
1997-08-18 17:10:23 +00:00
|
|
|
return [frameMatrix rotationAngle];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSRect)frame
|
|
|
|
{
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)rotateByAngle:(float)angle
|
1997-08-05 21:50:10 +00:00
|
|
|
{
|
1997-08-18 17:10:23 +00:00
|
|
|
[boundsMatrix rotateByAngle:angle];
|
|
|
|
|
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];
|
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
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Modifying the Coordinate System
|
|
|
|
//
|
|
|
|
|
|
|
|
- (float)boundsRotation
|
|
|
|
{
|
1997-08-18 17:10:23 +00:00
|
|
|
return [boundsMatrix rotationAngle];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSRect)bounds
|
|
|
|
{
|
|
|
|
return bounds;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isFlipped
|
|
|
|
{
|
1997-08-05 21:50:10 +00:00
|
|
|
return NO;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isRotatedFromBase
|
|
|
|
{
|
1997-08-18 17:10:23 +00:00
|
|
|
// TODO
|
1996-05-30 20:03:15 +00:00
|
|
|
return is_rotated_from_base;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isRotatedOrScaledFromBase
|
|
|
|
{
|
1997-08-18 17:10:23 +00:00
|
|
|
// TODO
|
1996-05-30 20:03:15 +00:00
|
|
|
return is_rotated_or_scaled_from_base;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (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;
|
|
|
|
|
|
|
|
[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
|
|
|
|
{
|
|
|
|
bounds = aRect;
|
1997-08-18 17:10:23 +00:00
|
|
|
[boundsMatrix setFrameOrigin:bounds.origin];
|
1997-08-22 18:38:38 +00:00
|
|
|
[boundsMatrix scaleTo:frame.size.width / bounds.size.width
|
1997-08-18 17:10:23 +00:00
|
|
|
: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)setBoundsOrigin:(NSPoint)newOrigin
|
|
|
|
{
|
|
|
|
bounds.origin = newOrigin;
|
1997-08-18 17:10:23 +00:00
|
|
|
[boundsMatrix setFrameOrigin:newOrigin];
|
|
|
|
|
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-08-18 17:10:23 +00:00
|
|
|
bounds.size = newSize;
|
1997-08-22 18:38:38 +00:00
|
|
|
[boundsMatrix scaleTo:frame.size.width / bounds.size.width
|
1997-08-18 17:10:23 +00:00
|
|
|
: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
|
|
|
|
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-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
|
|
|
|
|
|
|
//
|
|
|
|
// Converting Coordinates
|
|
|
|
//
|
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
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
while (view != _superview) {
|
|
|
|
[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)
|
|
|
|
aView = [[self 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)
|
|
|
|
aView = [[self 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
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Notifying Ancestor Views
|
|
|
|
//
|
|
|
|
- (BOOL)postsFrameChangedNotifications
|
|
|
|
{
|
|
|
|
return post_frame_changes;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setPostsFrameChangedNotifications:(BOOL)flag
|
|
|
|
{
|
|
|
|
post_frame_changes = flag;
|
|
|
|
}
|
|
|
|
|
1997-08-05 21:50:10 +00:00
|
|
|
- (void)setPostsBoundsChangedNotifications:(BOOL)flag
|
|
|
|
{
|
|
|
|
post_bounds_changes = flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)postsBoundsChangedNotifications
|
|
|
|
{
|
|
|
|
return post_bounds_changes;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Resizing Subviews
|
|
|
|
//
|
|
|
|
- (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;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)autoresizesSubviews
|
|
|
|
{
|
|
|
|
return autoresize_subviews;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setAutoresizingMask:(unsigned int)mask
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (unsigned int)autoresizingMask
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)resizeWithOldSuperviewSize:(NSSize)oldSize
|
|
|
|
{}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Graphics State Objects
|
|
|
|
//
|
|
|
|
- (void)allocateGState
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)releaseGState
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (int)gState
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)renewGState
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (void)setUpGState
|
|
|
|
{}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Focusing
|
|
|
|
//
|
|
|
|
- (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
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Displaying
|
|
|
|
//
|
|
|
|
- (BOOL)canDraw
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)display
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
if (!boundsMatrix || !frameMatrix)
|
|
|
|
NSLog (@"warning: %@ %p has not setup the PS matrices",
|
|
|
|
NSStringFromClass(isa), self);
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
[self lockFocus];
|
|
|
|
[self drawRect:bounds];
|
1997-03-21 01:06:15 +00:00
|
|
|
[self unlockFocus];
|
1997-03-17 18:43:27 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
// Tell subviews to display
|
|
|
|
j = [sub_views count];
|
|
|
|
for (i = 0;i < j; ++i)
|
|
|
|
[(NSView *)[sub_views objectAtIndex:i] display];
|
1997-03-17 18:43:27 +00:00
|
|
|
[[self window] flushWindow];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)displayIfNeeded
|
|
|
|
{
|
1997-03-17 18:43:27 +00:00
|
|
|
if ((needs_display) && (opaque)) {
|
1996-05-30 20:03:15 +00:00
|
|
|
[self display];
|
1997-03-17 18:43:27 +00:00
|
|
|
[self setNeedsDisplay:NO];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)displayIfNeededIgnoringOpacity
|
|
|
|
{
|
1997-03-17 18:43:27 +00:00
|
|
|
if (needs_display) {
|
1996-05-30 20:03:15 +00:00
|
|
|
[self display];
|
1997-03-17 18:43:27 +00:00
|
|
|
[self setNeedsDisplay:NO];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)displayRect:(NSRect)aRect
|
|
|
|
{}
|
|
|
|
|
|
|
|
- (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
|
|
|
|
{
|
|
|
|
return bounds;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isOpaque
|
|
|
|
{
|
|
|
|
return opaque;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)needsDisplay
|
|
|
|
{
|
|
|
|
return needs_display;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setNeedsDisplay:(BOOL)flag
|
|
|
|
{
|
|
|
|
needs_display = flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setNeedsDisplayInRect:(NSRect)invalidRect
|
|
|
|
{
|
|
|
|
needs_display = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)shouldDrawColor
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
{}
|
|
|
|
|
1997-03-05 01:11:17 +00:00
|
|
|
- (NSArray *)cursorRectangles
|
|
|
|
{
|
|
|
|
return cursor_rects;
|
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
|
|
|
// Assigning a Tag
|
|
|
|
//
|
|
|
|
- (int)tag
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (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];
|
|
|
|
for (i = 0; i < count; ++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)
|
|
|
|
{
|
|
|
|
[m release];
|
|
|
|
[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
|
|
|
#if 0
|
1996-05-30 20:03:15 +00:00
|
|
|
[aCoder encodeObjectReference: super_view withName: @"Superview"];
|
1997-02-18 00:29:25 +00:00
|
|
|
#else
|
|
|
|
[aCoder encodeConditionalObject:super_view];
|
|
|
|
#endif
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
[aCoder encodeObject: sub_views];
|
1997-02-18 00:29:25 +00:00
|
|
|
|
|
|
|
#if 0
|
1996-05-30 20:03:15 +00:00
|
|
|
[aCoder encodeObjectReference: window withName: @"Window"];
|
1997-02-18 00:29:25 +00:00
|
|
|
#else
|
|
|
|
[aCoder encodeConditionalObject:window];
|
|
|
|
#endif
|
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: &opaque];
|
|
|
|
[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
|
|
|
#if 0
|
1996-05-30 20:03:15 +00:00
|
|
|
[aDecoder decodeObjectAt: &super_view withName: NULL];
|
1997-02-18 00:29:25 +00:00
|
|
|
#else
|
|
|
|
super_view = [aDecoder decodeObject];
|
|
|
|
#endif
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
sub_views = [aDecoder decodeObject];
|
1997-02-18 00:29:25 +00:00
|
|
|
|
|
|
|
#if 0
|
1996-05-30 20:03:15 +00:00
|
|
|
[aDecoder decodeObjectAt: &window withName: NULL];
|
1997-02-18 00:29:25 +00:00
|
|
|
#else
|
|
|
|
window = [aDecoder decodeObject];
|
|
|
|
#endif
|
|
|
|
|
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: &opaque];
|
|
|
|
[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;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|