New MacOS 10.4 methods for NSView plus some clean up and corrections.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@24783 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2007-03-06 16:11:45 +00:00
parent 459f7f2797
commit d7f2bb2e66
5 changed files with 276 additions and 118 deletions

View file

@ -36,10 +36,11 @@
#include <AppKit/NSGraphicsContext.h> #include <AppKit/NSGraphicsContext.h>
#include <AppKit/NSResponder.h> #include <AppKit/NSResponder.h>
@class NSString;
@class NSArray; @class NSArray;
@class NSMutableArray; @class NSAttributedString;
@class NSData; @class NSData;
@class NSMutableArray;
@class NSString;
@class NSWindow; @class NSWindow;
@class NSPasteboard; @class NSPasteboard;
@ -243,6 +244,9 @@ typedef enum _NSFocusRingType {
- (BOOL) lockFocusIfCanDraw; - (BOOL) lockFocusIfCanDraw;
- (void) lockFocusInRect: (NSRect)rect; - (void) lockFocusInRect: (NSRect)rect;
#endif #endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (BOOL) lockFocusIfCanDrawInContext: (NSGraphicsContext *)context;
#endif
/* /*
* Displaying * Displaying
@ -258,7 +262,7 @@ typedef enum _NSFocusRingType {
- (void) setNeedsDisplay: (BOOL)flag; - (void) setNeedsDisplay: (BOOL)flag;
- (void) setNeedsDisplayInRect: (NSRect)invalidRect; - (void) setNeedsDisplayInRect: (NSRect)invalidRect;
- (BOOL) isOpaque; - (BOOL) isOpaque;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) #if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
+ (NSFocusRingType) defaultFocusRingType; + (NSFocusRingType) defaultFocusRingType;
- (void) setKeyboardFocusRingNeedsDisplayInRect: (NSRect)rect; - (void) setKeyboardFocusRingNeedsDisplayInRect: (NSRect)rect;
- (void) setFocusRingType: (NSFocusRingType)focusRingType; - (void) setFocusRingType: (NSFocusRingType)focusRingType;
@ -276,7 +280,7 @@ typedef enum _NSFocusRingType {
- (NSRect) visibleRect; - (NSRect) visibleRect;
- (BOOL) canDraw; - (BOOL) canDraw;
- (BOOL) shouldDrawColor; - (BOOL) shouldDrawColor;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) #if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
- (BOOL) wantsDefaultClipping; - (BOOL) wantsDefaultClipping;
- (BOOL) needsToDrawRect: (NSRect)aRect; - (BOOL) needsToDrawRect: (NSRect)aRect;
- (void) getRectsBeingDrawn: (const NSRect **)rects count: (int *)count; - (void) getRectsBeingDrawn: (const NSRect **)rects count: (int *)count;
@ -288,6 +292,12 @@ typedef enum _NSFocusRingType {
- (void) viewWillStartLiveResize; - (void) viewWillStartLiveResize;
- (void) viewDidEndLiveResize; - (void) viewDidEndLiveResize;
#endif #endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (BOOL) preservesContentDuringLiveResize;
- (void) getRectsExposedDuringLiveResize: (NSRect[4])exposedRects count: (int *)count;
- (NSRect) rectPreservedDuringLiveResize;
#endif
/* /*
* Graphics State Objects * Graphics State Objects
@ -325,7 +335,7 @@ typedef enum _NSFocusRingType {
- (void) registerForDraggedTypes: (NSArray*)newTypes; - (void) registerForDraggedTypes: (NSArray*)newTypes;
- (void) unregisterDraggedTypes; - (void) unregisterDraggedTypes;
- (BOOL) shouldDelayWindowOrderingForEvent: (NSEvent*)anEvent; - (BOOL) shouldDelayWindowOrderingForEvent: (NSEvent*)anEvent;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) #if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
- (BOOL) dragPromisedFilesOfTypes: (NSArray *)typeArray - (BOOL) dragPromisedFilesOfTypes: (NSArray *)typeArray
fromRect: (NSRect)aRect fromRect: (NSRect)aRect
source: (id)sourceObject source: (id)sourceObject
@ -441,7 +451,7 @@ typedef enum _NSFocusRingType {
- (void) setPreviousKeyView: (NSView*)aView; - (void) setPreviousKeyView: (NSView*)aView;
- (NSView*) previousKeyView; - (NSView*) previousKeyView;
- (NSView*) previousValidKeyView; - (NSView*) previousValidKeyView;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST) #if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
- (BOOL) canBecomeKeyView; - (BOOL) canBecomeKeyView;
#endif #endif
@ -514,6 +524,10 @@ typedef enum _NSFocusRingType {
atPlacement:(NSPoint)location; atPlacement:(NSPoint)location;
- (void)endDocument; - (void)endDocument;
#endif #endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (NSAttributedString *)pageFooter;
- (NSAttributedString *)pageHeader;
#endif
@end @end

View file

@ -444,6 +444,10 @@ APPKIT_EXPORT NSSize NSTokenSize;
- (void) setBackingType: (NSBackingStoreType)type; - (void) setBackingType: (NSBackingStoreType)type;
- (BOOL) isOneShot; - (BOOL) isOneShot;
- (void) setOneShot: (BOOL)flag; - (void) setOneShot: (BOOL)flag;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (NSGraphicsContext*) graphicsContext;
#endif
/* /*
* Screens and window depths * Screens and window depths

View file

@ -67,8 +67,13 @@
// //
- (id) initWithFrame: (NSRect)frameRect - (id) initWithFrame: (NSRect)frameRect
{ {
[super initWithFrame: frameRect]; NSView *cv;
self = [super initWithFrame: frameRect];
if (!self)
return self;
_cell = [[NSCell alloc] initTextCell: @"Title"]; _cell = [[NSCell alloc] initTextCell: @"Title"];
[_cell setAlignment: NSCenterTextAlignment]; [_cell setAlignment: NSCenterTextAlignment];
[_cell setBordered: NO]; [_cell setBordered: NO];
@ -80,10 +85,10 @@
_title_position = NSAtTop; _title_position = NSAtTop;
_title_rect = NSZeroRect; _title_rect = NSZeroRect;
[self setAutoresizesSubviews: NO]; [self setAutoresizesSubviews: NO];
_content_view = [NSView new];
[super addSubview: _content_view]; cv = [NSView new];
[_content_view setFrame: [self calcSizesAllowingNegative: NO]]; [self setContentView: cv];
RELEASE(_content_view); RELEASE(cv);
return self; return self;
} }

View file

@ -244,7 +244,7 @@ GSSetDragTypes(NSView* obj, NSArray *types)
} }
} }
} }
[self releaseGState]; [self renewGState];
} }
} }
@ -427,7 +427,9 @@ GSSetDragTypes(NSView* obj, NSArray *types)
- (id) initWithFrame: (NSRect)frameRect - (id) initWithFrame: (NSRect)frameRect
{ {
[super init]; self = [super init];
if (!self)
return self;
if (frameRect.size.width < 0) if (frameRect.size.width < 0)
{ {
@ -443,7 +445,7 @@ GSSetDragTypes(NSView* obj, NSArray *types)
_bounds.origin = NSZeroPoint; // Set bounds rectangle _bounds.origin = NSZeroPoint; // Set bounds rectangle
_bounds.size = _frame.size; _bounds.size = _frame.size;
_boundsMatrix = [NSAffineTransform new]; // Map fromsuperview to bounds _boundsMatrix = [NSAffineTransform new]; // Map from superview to bounds
_matrixToWindow = [NSAffineTransform new]; // Map to window coordinates _matrixToWindow = [NSAffineTransform new]; // Map to window coordinates
_matrixFromWindow = [NSAffineTransform new]; // Map from window coordinates _matrixFromWindow = [NSAffineTransform new]; // Map from window coordinates
@ -451,18 +453,20 @@ GSSetDragTypes(NSView* obj, NSArray *types)
_tracking_rects = [NSMutableArray new]; _tracking_rects = [NSMutableArray new];
_cursor_rects = [NSMutableArray new]; _cursor_rects = [NSMutableArray new];
_super_view = nil; // Some values are already set by initialisation
_window = nil; //_super_view = nil;
_is_rotated_from_base = NO; //_window = nil;
_is_rotated_or_scaled_from_base = NO; //_is_rotated_from_base = NO;
//_is_rotated_or_scaled_from_base = NO;
_rFlags.needs_display = YES; _rFlags.needs_display = YES;
_post_frame_changes = NO; //_post_frame_changes = NO;
_autoresizes_subviews = YES; _autoresizes_subviews = YES;
_autoresizingMask = NSViewNotSizable; _autoresizingMask = NSViewNotSizable;
_coordinates_valid = NO; //_coordinates_valid = NO;
_nextKeyView = 0; //_nextKeyView = 0;
_previousKeyView = 0; //_previousKeyView = 0;
// cache as optimization
_rFlags.flipped_view = [self isFlipped]; _rFlags.flipped_view = [self isFlipped];
return self; return self;
@ -507,7 +511,7 @@ GSSetDragTypes(NSView* obj, NSArray *types)
/* /*
* Now we clean up the previous view array, in case subclasses have * Now we clean up the previous view array, in case subclasses have
* overridden the default -setNextkeyView: method and broken things. * overridden the default -setNextKeyView: method and broken things.
* We also relase the memory we used. * We also relase the memory we used.
*/ */
if (pKV(self) != 0) if (pKV(self) != 0)
@ -596,34 +600,9 @@ GSSetDragTypes(NSView* obj, NSArray *types)
*/ */
- (void) addSubview: (NSView*)aView - (void) addSubview: (NSView*)aView
{ {
if (aView == nil) [self addSubview: aView
{ positioned: NSWindowAbove
[NSException raise: NSInvalidArgumentException relativeTo: nil];
format: @"Adding a nil subview"];
}
if ([self isDescendantOf: aView])
{
[NSException raise: NSInvalidArgumentException
format: @"addSubview: creates a loop in the views tree!"];
}
RETAIN(aView);
[aView removeFromSuperview];
if (aView->_coordinates_valid)
{
(*invalidateImp)(aView, invalidateSel);
}
[aView viewWillMoveToWindow: _window];
[aView viewWillMoveToSuperview: self];
[aView setNextResponder: self];
[_sub_views addObject: aView];
_rFlags.has_subviews = 1;
[aView resetCursorRects];
[aView setNeedsDisplay: YES];
[aView _viewDidMoveToWindow];
[aView viewDidMoveToSuperview];
[self didAddSubview: aView];
RELEASE(aView);
} }
- (void) addSubview: (NSView*)aView - (void) addSubview: (NSView*)aView
@ -647,7 +626,26 @@ GSSetDragTypes(NSView* obj, NSArray *types)
if (aView == otherView) if (aView == otherView)
return; return;
index = [_sub_views indexOfObjectIdenticalTo: otherView]; RETAIN(aView);
[aView removeFromSuperview];
if (aView->_coordinates_valid)
{
(*invalidateImp)(aView, invalidateSel);
}
[aView viewWillMoveToWindow: _window];
[aView viewWillMoveToSuperview: self];
[aView setNextResponder: self];
// Do this after the removeFromSuperview, as aView may already
// be a subview and the index could change.
if (otherView == nil)
{
index = NSNotFound;
}
else
{
index = [_sub_views indexOfObjectIdenticalTo: otherView];
}
if (index == NSNotFound) if (index == NSNotFound)
{ {
if (place == NSWindowBelow) if (place == NSWindowBelow)
@ -660,15 +658,6 @@ GSSetDragTypes(NSView* obj, NSArray *types)
index += 1; index += 1;
} }
RETAIN(aView);
[aView removeFromSuperview];
if (aView->_coordinates_valid)
{
(*invalidateImp)(aView, invalidateSel);
}
[aView viewWillMoveToWindow: _window];
[aView viewWillMoveToSuperview: self];
[aView setNextResponder: self];
[_sub_views insertObject: aView atIndex: index]; [_sub_views insertObject: aView atIndex: index];
_rFlags.has_subviews = 1; _rFlags.has_subviews = 1;
[aView resetCursorRects]; [aView resetCursorRects];
@ -790,7 +779,7 @@ GSSetDragTypes(NSView* obj, NSArray *types)
* which assumes the view is still in the view hierarchy * which assumes the view is still in the view hierarchy
*/ */
for (view = [_window firstResponder]; for (view = [_window firstResponder];
view != nil && [view respondsToSelector:@selector(superview)]; view != nil && [view respondsToSelector: @selector(superview)];
view = [view superview]) view = [view superview])
{ {
if (view == aView) if (view == aView)
@ -1720,21 +1709,20 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
*/ */
- (void) allocateGState - (void) allocateGState
{ {
// FIXME: This should create an actual gState
_allocate_gstate = 1; _allocate_gstate = 1;
_renew_gstate = 1; _renew_gstate = 1;
} }
/** /**
Frees the gstate object, if there is one. Note that the next time Frees the gstate object, if there is one.
the view is lockFocused, the gstate will be allocated again. */ */
- (void) releaseGState - (void) releaseGState
{ {
if (_allocate_gstate && _gstate) if (_allocate_gstate && _gstate)
GSUndefineGState(GSCurrentContext(), _gstate); GSUndefineGState(GSCurrentContext(), _gstate);
_gstate = 0; _gstate = 0;
/* Note that the next time we lock focus, we'll realloc a gstate (if _allocate_gstate = 0;
_allocate_gstate). This seems to make sense, and also allows us
to call this method each time we invalidate the coordinates */
} }
/** /**
@ -1742,7 +1730,10 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
which is used to encapsulate drawing information about the view. which is used to encapsulate drawing information about the view.
Most of the time a gstate object is created from scratch when the Most of the time a gstate object is created from scratch when the
view is focused, so if the view is not currently focused or view is focused, so if the view is not currently focused or
allocateGState has not been called, then this method will */ allocateGState has not been called, then this method will return 0.
FIXME: The above is what the OpenStep and Cocoa specification say, but
gState is 0 unless allocateGState has been called.
*/
- (int) gState - (int) gState
{ {
return _gstate; return _gstate;
@ -1754,6 +1745,9 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
- (void) renewGState - (void) renewGState
{ {
_renew_gstate = 1; _renew_gstate = 1;
/* Note that the next time we lock focus, we'll realloc a gstate (if
_allocate_gstate). This seems to make sense, and also allows us
to call this method each time we invalidate the coordinates */
} }
/* Overridden by subclasses to setup custom gstate */ /* Overridden by subclasses to setup custom gstate */
@ -1761,9 +1755,8 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
{ {
} }
- (void) lockFocusInRect: (NSRect)rect - (void) _lockFocusInContext: ctxt inRect: (NSRect)rect
{ {
NSGraphicsContext *ctxt = GSCurrentContext();
NSRect wrect; NSRect wrect;
int window_gstate = 0; int window_gstate = 0;
@ -1777,6 +1770,8 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
} }
} }
// FIXME: Set current context?
[ctxt lockFocusView: self inRect: rect]; [ctxt lockFocusView: self inRect: rect];
wrect = [self convertRect: rect toView: nil]; wrect = [self convertRect: rect toView: nil];
NSDebugLLog(@"NSView", @"-lockFocusInRect: %@\n" NSDebugLLog(@"NSView", @"-lockFocusInRect: %@\n"
@ -1807,8 +1802,6 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
{ {
[[self _matrixToWindow] concat]; [[self _matrixToWindow] concat];
} }
DPSrectclip(ctxt, NSMinX(rect), NSMinY(rect),
NSWidth(rect), NSHeight(rect));
/* Allow subclases to make other modifications */ /* Allow subclases to make other modifications */
[self setUpGState]; [self setUpGState];
@ -1848,14 +1841,20 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
} }
} }
}
if ([self wantsDefaultClipping])
{
/* Clip to the visible rectangle - which will never be greater /* Clip to the visible rectangle - which will never be greater
* than the bounds of the view. This prevents drawing outside * than the bounds of the view. This prevents drawing outside
* our bounds * our bounds
*/ */
DPSrectclip(ctxt, NSMinX(rect), NSMinY(rect), DPSrectclip(ctxt, NSMinX(rect), NSMinY(rect),
NSWidth(rect), NSHeight(rect)); NSWidth(rect), NSHeight(rect));
} }
/* This is obsolete. Backends shouldn't depend on this */
/* Tell backends that images are drawn upside down.
This is needed when a backend is able to handle full image transformation. */
GSWSetViewIsFlipped(ctxt, _rFlags.flipped_view); GSWSetViewIsFlipped(ctxt, _rFlags.flipped_view);
} }
@ -1899,6 +1898,11 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
[ctxt unlockFocusView: self needsFlush: YES ]; [ctxt unlockFocusView: self needsFlush: YES ];
} }
- (void) lockFocusInRect: (NSRect)rect
{
[self _lockFocusInContext: [_window graphicsContext] inRect: rect];
}
- (void) lockFocus - (void) lockFocus
{ {
[self lockFocusInRect: [self visibleRect]]; [self lockFocusInRect: [self visibleRect]];
@ -1910,10 +1914,15 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
} }
- (BOOL) lockFocusIfCanDraw - (BOOL) lockFocusIfCanDraw
{
return [self lockFocusIfCanDrawInContext: [_window graphicsContext]];
}
- (BOOL) lockFocusIfCanDrawInContext: (NSGraphicsContext *)context;
{ {
if ([self canDraw]) if ([self canDraw])
{ {
[self lockFocus]; [self _lockFocusInContext: context inRect: [self visibleRect]];
return YES; return YES;
} }
else else
@ -1923,7 +1932,7 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
} }
- (BOOL) canDraw - (BOOL) canDraw
{ // not implemented per OS spec FIX ME {
if (((viewIsPrinting != nil) && [self isDescendantOf: viewIsPrinting]) || if (((viewIsPrinting != nil) && [self isDescendantOf: viewIsPrinting]) ||
((_window != nil) && ([_window windowNumber] != 0) && ((_window != nil) && ([_window windowNumber] != 0) &&
![self isHiddenOrHasHiddenAncestor])) ![self isHiddenOrHasHiddenAncestor]))
@ -2200,6 +2209,7 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
*/ */
[self lockFocusInRect: aRect]; [self lockFocusInRect: aRect];
[self drawRect: aRect]; [self drawRect: aRect];
[self unlockFocusNeedsFlush: YES];
} }
if (_rFlags.has_subviews == YES) if (_rFlags.has_subviews == YES)
@ -2266,11 +2276,6 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
} }
} }
if (NSIsEmptyRect(aRect) == NO)
{
[self unlockFocusNeedsFlush: YES];
}
/* /*
* If the rect we displayed contains the _invalidRect or _visibleRect * If the rect we displayed contains the _invalidRect or _visibleRect
* then we can empty _invalidRect. If all subviews have been * then we can empty _invalidRect. If all subviews have been
@ -2326,21 +2331,36 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
- (BOOL) needsToDrawRect: (NSRect)aRect - (BOOL) needsToDrawRect: (NSRect)aRect
{ {
NSRect rect; const NSRect *rects;
struct NSWindow_struct *window_t; int i, count;
aRect = [self convertRect: aRect toView: nil]; [self getRectsBeingDrawn: &rects count: &count];
window_t = (struct NSWindow_struct *)_window; for (i = 0; i < count; i++)
rect = [[window_t->_rectsBeingDrawn lastObject] rectValue]; {
return NSIntersectsRect(rect, aRect); if (NSIntersectsRect(aRect, rects[i]))
return YES;
}
return NO;
} }
- (void) getRectsBeingDrawn: (const NSRect **)rects count: (int *)count - (void) getRectsBeingDrawn: (const NSRect **)rects count: (int *)count
{ {
// FIXME // FIXME
static NSRect rect;
struct NSWindow_struct *window_t;
window_t = (struct NSWindow_struct *)_window;
rect = [[window_t->_rectsBeingDrawn lastObject] rectValue];
rect = [self convertRect: rect fromView: nil];
if (rects != NULL)
{
*rects = &rect;
}
if (count != NULL) if (count != NULL)
{ {
*count = 0; *count = 1;
} }
} }
@ -2519,6 +2539,26 @@ in the main thread.
_in_live_resize = NO; _in_live_resize = NO;
} }
- (BOOL) preservesContentDuringLiveResize
{
return NO;
}
- (void) getRectsExposedDuringLiveResize: (NSRect[4])exposedRects count: (int *)count
{
// FIXME
if (count != NULL)
{
*count = 1;
}
exposedRects[0] = _bounds;
}
- (NSRect) rectPreservedDuringLiveResize
{
return NSZeroRect;
}
/* /*
* Scrolling * Scrolling
*/ */
@ -2546,19 +2586,42 @@ in the main thread.
} }
- (void) reflectScrolledClipView: (NSClipView*)aClipView - (void) reflectScrolledClipView: (NSClipView*)aClipView
{} {
}
- (void) scrollClipView: (NSClipView*)aClipView toPoint: (NSPoint)aPoint - (void) scrollClipView: (NSClipView*)aClipView toPoint: (NSPoint)aPoint
{} {
[aClipView scrollToPoint: aPoint];
}
- (NSClipView*) _enclosingClipView
{
static Class clipViewClass;
id aView = [self superview];
if (!clipViewClass)
{
clipViewClass = [NSClipView class];
}
while (aView != nil)
{
if ([aView isKindOfClass: clipViewClass])
{
break;
}
aView = [aView superview];
}
return aView;
}
- (void) scrollPoint: (NSPoint)aPoint - (void) scrollPoint: (NSPoint)aPoint
{ {
NSClipView *s = (NSClipView*)_super_view; NSClipView *s = [self _enclosingClipView];
while (s != nil && [s isKindOfClass: [NSClipView class]] == NO) if (s == nil)
{ return;
s = (NSClipView*)[s superview];
}
aPoint = [self convertPoint: aPoint toView: s]; aPoint = [self convertPoint: aPoint toView: s];
if (NSEqualPoints(aPoint, [s bounds].origin) == NO) if (NSEqualPoints(aPoint, [s bounds].origin) == NO)
@ -2567,8 +2630,20 @@ in the main thread.
} }
} }
/**
Copy on scroll method, should be called from [NSClipView setBoundsOrigin].
*/
- (void) scrollRect: (NSRect)aRect by: (NSSize)delta - (void) scrollRect: (NSRect)aRect by: (NSSize)delta
{} {
NSPoint destPoint = aRect.origin;
destPoint.x -= delta.width;
destPoint.y -= delta.height;
[self lockFocus];
NSCopyBits(0, aRect, destPoint);
[self unlockFocus];
}
/** /**
Scrolls the nearest enclosing clip view the minimum required distance Scrolls the nearest enclosing clip view the minimum required distance
@ -2577,12 +2652,8 @@ Returns YES iff any scrolling was done.
*/ */
- (BOOL) scrollRectToVisible: (NSRect)aRect - (BOOL) scrollRectToVisible: (NSRect)aRect
{ {
NSClipView *s = (NSClipView*)_super_view; NSClipView *s = [self _enclosingClipView];
while (s != nil && [s isKindOfClass: [NSClipView class]] == NO)
{
s = (NSClipView*)[s superview];
}
if (s != nil) if (s != nil)
{ {
NSRect vRect = [self visibleRect]; NSRect vRect = [self visibleRect];
@ -2621,11 +2692,17 @@ Returns YES iff any scrolling was done.
- (NSScrollView*) enclosingScrollView - (NSScrollView*) enclosingScrollView
{ {
static Class scrollViewClass;
id aView = [self superview]; id aView = [self superview];
if (!scrollViewClass)
{
scrollViewClass = [NSScrollView class];
}
while (aView != nil) while (aView != nil)
{ {
if ([aView isKindOfClass: [NSScrollView class]]) if ([aView isKindOfClass: scrollViewClass])
{ {
break; break;
} }
@ -2935,8 +3012,7 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
- (BOOL) mouseDownCanMoveWindow - (BOOL) mouseDownCanMoveWindow
{ {
// FIXME return ![self isOpaque];
return NO;
} }
- (void) removeTrackingRect: (NSTrackingRectTag)tag - (void) removeTrackingRect: (NSTrackingRectTag)tag
@ -3356,12 +3432,12 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
_rFlags.has_draginfo = 1; _rFlags.has_draginfo = 1;
if (_window != nil) if (_window != nil)
{ {
// Remove the old types first, that way overlapping types stay assigned.
[GSDisplayServer addDragTypes: t toWindow: _window];
if (o != nil) if (o != nil)
{ {
[GSDisplayServer removeDragTypes: o fromWindow: _window]; [GSDisplayServer removeDragTypes: o fromWindow: _window];
} }
[GSDisplayServer addDragTypes: t toWindow: _window];
} }
TEST_RELEASE(o); TEST_RELEASE(o);
} }
@ -3387,8 +3463,28 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
slideBack: (BOOL)slideBack slideBack: (BOOL)slideBack
event: (NSEvent *)theEvent event: (NSEvent *)theEvent
{ {
// FIXME // FIXME: Where to get the image from?
return NO; NSImage *anImage = nil;
NSPasteboard *pboard = [NSPasteboard pasteboardWithName: NSDragPboard];
if (anImage == nil)
return NO;
[pboard declareTypes: [NSArray arrayWithObject: NSFilesPromisePboardType]
owner: sourceObject];
// FIXME: Not sure if this is correct.
if (![pboard setPropertyList: typeArray
forType: NSFilesPromisePboardType])
return NO;
[self dragImage: anImage
at: aRect.origin
offset: NSMakeSize(0, 0)
event: theEvent
pasteboard: pboard
source: sourceObject
slideBack: slideBack];
return YES;
} }
/* /*
@ -3412,11 +3508,16 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
{ {
NSMutableData *data = [NSMutableData data]; NSMutableData *data = [NSMutableData data];
[[NSPrintOperation EPSOperationWithView: self if ([[NSPrintOperation EPSOperationWithView: self
insideRect: aRect insideRect: aRect
toData: data] runOperation]; toData: data] runOperation])
{
return data; return data;
}
else
{
return nil;
}
} }
- (void) writeEPSInsideRect: (NSRect)rect - (void) writeEPSInsideRect: (NSRect)rect
@ -3433,10 +3534,16 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
{ {
NSMutableData *data = [NSMutableData data]; NSMutableData *data = [NSMutableData data];
[[NSPrintOperation PDFOperationWithView: self if ([[NSPrintOperation PDFOperationWithView: self
insideRect: aRect insideRect: aRect
toData: data] runOperation]; toData: data] runOperation])
return data; {
return data;
}
else
{
return nil;
}
} }
- (void)writePDFInsideRect:(NSRect)aRect - (void)writePDFInsideRect:(NSRect)aRect
@ -3773,6 +3880,8 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
{ {
DPSPrintf(ctxt, "__GSpagesaveobject restore\n\n"); DPSPrintf(ctxt, "__GSpagesaveobject restore\n\n");
} }
[self unlockFocus];
} }
- (void) endTrailer - (void) endTrailer
@ -3781,6 +3890,23 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
DPSPrintf(ctxt, "%%%%EOF\n"); DPSPrintf(ctxt, "%%%%EOF\n");
} }
- (NSAttributedString *) pageFooter
{
return [[[NSAttributedString alloc]
initWithString:
[NSString stringWithFormat:@"Page %d",
[[NSPrintOperation currentOperation] currentPage]]]
autorelease];
}
- (NSAttributedString *) pageHeader
{
return [[[NSAttributedString alloc]
initWithString:
[NSString stringWithFormat:@"%@ %@", [self printJobTitle],
[[NSCalendarDate calendarDate] description]]] autorelease];
}
- (void) _loadPrinterProlog: (NSGraphicsContext *)ctxt - (void) _loadPrinterProlog: (NSGraphicsContext *)ctxt
{ {
NSString *prolog; NSString *prolog;
@ -3874,10 +4000,13 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
int nup; int nup;
float scale; float scale;
NSRect bounds; NSRect bounds;
NSGraphicsContext *ctxt = GSCurrentContext();
NSPrintOperation *printOp = [NSPrintOperation currentOperation]; NSPrintOperation *printOp = [NSPrintOperation currentOperation];
NSGraphicsContext *ctxt = [printOp context];
NSDictionary *dict = [[printOp printInfo] dictionary]; NSDictionary *dict = [[printOp printInfo] dictionary];
// FIXME: Need to place this correctly
[self lockFocusIfCanDrawInContext: ctxt];
if ([dict objectForKey: @"NSPrintPaperBounds"]) if ([dict objectForKey: @"NSPrintPaperBounds"])
bounds = [[dict objectForKey: @"NSPrintPaperBounds"] rectValue]; bounds = [[dict objectForKey: @"NSPrintPaperBounds"] rectValue];
else else

View file

@ -1171,6 +1171,12 @@ many times.
return [[self screen] deviceDescription]; return [[self screen] deviceDescription];
} }
- (NSGraphicsContext*) graphicsContext
{
// FIXME
return GSCurrentContext();
}
- (int) gState - (int) gState
{ {
if (_gstate <= 0) if (_gstate <= 0)