mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:30:48 +00:00
Set up print context and view coords for priting
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@11006 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
217fa10eae
commit
8f75f002cd
2 changed files with 73 additions and 19 deletions
|
@ -318,6 +318,7 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
|
||||||
|
|
||||||
- (void)destroyContext
|
- (void)destroyContext
|
||||||
{
|
{
|
||||||
|
[_context destroyContext];
|
||||||
DESTROY(_context);
|
DESTROY(_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,7 +466,7 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
|
||||||
- (void) _print
|
- (void) _print
|
||||||
{
|
{
|
||||||
// This is the actual printing
|
// This is the actual printing
|
||||||
[_view displayRect: _rect];
|
[_view displayRectIgnoringOpacity: _rect];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -554,14 +555,24 @@ static NSString *NSPrintOperationThreadKey = @"NSPrintOperationThreadKey";
|
||||||
|
|
||||||
- (NSGraphicsContext*)createContext
|
- (NSGraphicsContext*)createContext
|
||||||
{
|
{
|
||||||
// FIXME
|
NSMutableDictionary *info = [_printInfo dictionary];
|
||||||
return nil;
|
NSGraphicsContext *psContext;
|
||||||
|
|
||||||
|
[info setObject: _path forKey: @"NSOutputFile"];
|
||||||
|
psContext = [NSGraphicsContext postscriptContextWithInfo: info];
|
||||||
|
|
||||||
|
return psContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)deliverResult
|
- (BOOL)deliverResult
|
||||||
{
|
{
|
||||||
if (_data != nil && _path != nil && [_data length])
|
if (_data != nil && _path != nil)
|
||||||
return [_data writeToFile: _path atomically: NO];
|
{
|
||||||
|
NSString *eps;
|
||||||
|
|
||||||
|
eps = [NSString stringWithContentsOfFile: _path];
|
||||||
|
[_data setData: [eps dataUsingEncoding:NSASCIIStringEncoding]];
|
||||||
|
}
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,11 @@
|
||||||
#include <AppKit/NSPrintInfo.h>
|
#include <AppKit/NSPrintInfo.h>
|
||||||
#include <AppKit/NSPrintOperation.h>
|
#include <AppKit/NSPrintOperation.h>
|
||||||
|
|
||||||
|
/* Variable tells this view and subviews that we're printing. Not really
|
||||||
|
a class variable because we want it visible to subviews also
|
||||||
|
*/
|
||||||
|
NSView *viewIsPrinting = nil;
|
||||||
|
|
||||||
struct NSWindow_struct
|
struct NSWindow_struct
|
||||||
{
|
{
|
||||||
@defs(NSWindow)
|
@defs(NSWindow)
|
||||||
|
@ -1333,12 +1338,33 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
||||||
NSDebugLLog(@"NSView", @"Displaying rect \n\t%@\n\t window %p, flip %d",
|
NSDebugLLog(@"NSView", @"Displaying rect \n\t%@\n\t window %p, flip %d",
|
||||||
NSStringFromRect(wrect), _window, _rFlags.flipped_view);
|
NSStringFromRect(wrect), _window, _rFlags.flipped_view);
|
||||||
window_t = (struct NSWindow_struct *)_window;
|
window_t = (struct NSWindow_struct *)_window;
|
||||||
[window_t->_rectsBeingDrawn addObject: [NSValue valueWithRect: wrect]];
|
if (viewIsPrinting == nil)
|
||||||
|
[window_t->_rectsBeingDrawn addObject: [NSValue valueWithRect: wrect]];
|
||||||
|
|
||||||
/* Make sure we don't modify superview's gstate */
|
/* Make sure we don't modify superview's gstate */
|
||||||
DPSgsave(ctxt);
|
DPSgsave(ctxt);
|
||||||
|
|
||||||
if (_gstate)
|
if (viewIsPrinting != nil)
|
||||||
|
{
|
||||||
|
if (viewIsPrinting == self)
|
||||||
|
{
|
||||||
|
/* Make sure coordinates are valid, then fake that we don't have
|
||||||
|
a superview so we get printed correctly */
|
||||||
|
[self _matrixToWindow];
|
||||||
|
[_matrixToWindow makeIdentityMatrix];
|
||||||
|
_visibleRect = _bounds;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[[self _matrixToWindow] concat];
|
||||||
|
}
|
||||||
|
DPSrectclip(ctxt, NSMinX(rect), NSMinY(rect),
|
||||||
|
NSWidth(rect), NSHeight(rect));
|
||||||
|
|
||||||
|
/* Allow subclases to make other modifications */
|
||||||
|
[self setUpGState];
|
||||||
|
}
|
||||||
|
else if (_gstate)
|
||||||
{
|
{
|
||||||
DPSsetgstate(ctxt, _gstate);
|
DPSsetgstate(ctxt, _gstate);
|
||||||
if (_renew_gstate)
|
if (_renew_gstate)
|
||||||
|
@ -1385,8 +1411,6 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
||||||
|
|
||||||
- (void) unlockFocusNeedsFlush: (BOOL)flush
|
- (void) unlockFocusNeedsFlush: (BOOL)flush
|
||||||
{
|
{
|
||||||
NSRect rect;
|
|
||||||
struct NSWindow_struct *window_t;
|
|
||||||
NSGraphicsContext *ctxt = GSCurrentContext();
|
NSGraphicsContext *ctxt = GSCurrentContext();
|
||||||
|
|
||||||
NSAssert(_window != nil, NSInternalInconsistencyException);
|
NSAssert(_window != nil, NSInternalInconsistencyException);
|
||||||
|
@ -1394,22 +1418,34 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
||||||
if ([_window gState] == 0)
|
if ([_window gState] == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Restore our original gstate */
|
if (viewIsPrinting != nil)
|
||||||
DPSgrestore(ctxt);
|
{
|
||||||
|
_coordinates_valid = NO;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Restore our original gstate */
|
||||||
|
DPSgrestore(ctxt);
|
||||||
|
}
|
||||||
/* Restore state of nesting lockFocus */
|
/* Restore state of nesting lockFocus */
|
||||||
DPSgrestore(ctxt);
|
DPSgrestore(ctxt);
|
||||||
if (!_allocate_gstate)
|
if (!_allocate_gstate)
|
||||||
_gstate = 0;
|
_gstate = 0;
|
||||||
|
|
||||||
window_t = (struct NSWindow_struct *)_window;
|
if (viewIsPrinting == nil)
|
||||||
if (flush)
|
|
||||||
{
|
{
|
||||||
rect = [[window_t->_rectsBeingDrawn lastObject] rectValue];
|
NSRect rect;
|
||||||
window_t->_rectNeedingFlush =
|
struct NSWindow_struct *window_t;
|
||||||
NSUnionRect(window_t->_rectNeedingFlush, rect);
|
window_t = (struct NSWindow_struct *)_window;
|
||||||
window_t->_f.needs_flush = YES;
|
if (flush)
|
||||||
|
{
|
||||||
|
rect = [[window_t->_rectsBeingDrawn lastObject] rectValue];
|
||||||
|
window_t->_rectNeedingFlush =
|
||||||
|
NSUnionRect(window_t->_rectNeedingFlush, rect);
|
||||||
|
window_t->_f.needs_flush = YES;
|
||||||
|
}
|
||||||
|
[window_t->_rectsBeingDrawn removeLastObject];
|
||||||
}
|
}
|
||||||
[window_t->_rectsBeingDrawn removeLastObject];
|
|
||||||
[ctxt unlockFocusView: self needsFlush: YES ];
|
[ctxt unlockFocusView: self needsFlush: YES ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2409,10 +2445,17 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
||||||
- (NSData*) dataWithEPSInsideRect: (NSRect)aRect
|
- (NSData*) dataWithEPSInsideRect: (NSRect)aRect
|
||||||
{
|
{
|
||||||
NSMutableData *data = [NSMutableData data];
|
NSMutableData *data = [NSMutableData data];
|
||||||
|
|
||||||
|
/* Inform ourselves and subviews that we're printing so we adjust
|
||||||
|
the PostScript accordingly. Perhaps this could be in the thread
|
||||||
|
dictionary, but that's probably overkill and slow */
|
||||||
|
viewIsPrinting = self;
|
||||||
|
|
||||||
[[NSPrintOperation EPSOperationWithView: self
|
[[NSPrintOperation EPSOperationWithView: self
|
||||||
insideRect: aRect
|
insideRect: aRect
|
||||||
toData: data] runOperation];
|
toData: data] runOperation];
|
||||||
|
|
||||||
|
viewIsPrinting = nil;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue