Use save/restore in lockFocus/unlockFocus

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@10835 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fedor 2001-09-03 04:10:36 +00:00
parent 97bfbf5304
commit 9eabdb49cf
7 changed files with 117 additions and 25 deletions

View file

@ -1317,6 +1317,7 @@ GSSetDragTypes(NSView* obj, NSArray *types)
- (void) lockFocusInRect: (NSRect)rect
{
NSGraphicsContext *ctxt = GSCurrentContext();
NSAffineTransform *matrix;
struct NSWindow_struct *window_t;
NSRect wrect;
int window_gstate;
@ -1330,12 +1331,26 @@ GSSetDragTypes(NSView* obj, NSArray *types)
[ctxt lockFocusView: self inRect: rect];
wrect = [self convertRect: rect toView: nil];
NSDebugLLog(@"NSView", @"Displaying rect \n\t%@\n\t window %p",
NSStringFromRect(wrect), _window);
NSDebugLLog(@"NSView", @"Displaying rect \n\t%@\n\t window %p, flip %d",
NSStringFromRect(wrect), _window, _rFlags.flipped_view);
window_t = (struct NSWindow_struct *)_window;
[window_t->_rectsBeingDrawn addObject: [NSValue valueWithRect: wrect]];
DPSgsave(ctxt);
/*
* Clipping - set viewclip to the visible rectangle - which will never be
* greater than the bounds of the view. This prevents drawing outside
* our bounds (FIXME: Perhaps IntersectRect with bounds, just to make sure?)
*/
DPSsave(ctxt);
DPSmark(ctxt); /* Rather than keep the save object, just mark it to make
sure we can find it when we unlock. We really should
keep an ivar for it, though... */
matrix = [self _matrixToWindow];
if ([matrix isRotated])
{
[matrix boundingRectFor: rect result: &rect];
}
if (_gstate)
{
DPSsetgstate(ctxt, _gstate);
@ -1345,32 +1360,16 @@ GSSetDragTypes(NSView* obj, NSArray *types)
}
_renew_gstate = 0;
DPSgsave(ctxt);
DPSrectviewclip(ctxt, NSMinX(rect), NSMinY(rect),
NSWidth(rect), NSHeight(rect));
}
else
{
NSAffineTransform *matrix;
float x, y, w, h;
DPSsetgstate(ctxt, window_gstate);
DPSgsave(ctxt);
matrix = [self _matrixToWindow];
[matrix concat];
/*
* Clipping - set viewclip to the visible rectangle - which will never be
* greater than the bounds of the view.
* Set the standard clippath to an empty path.
*/
if ([matrix isRotated])
{
[matrix boundingRectFor: rect result: &rect];
}
x = NSMinX(rect);
y = NSMinY(rect);
w = NSWidth(rect);
h = NSHeight(rect);
DPSrectviewclip(ctxt, x, y, w, h);
DPSrectviewclip(ctxt, NSMinX(rect), NSMinY(rect),
NSWidth(rect), NSHeight(rect));
/* Allow subclases to make other modifications */
[self setUpGState];
@ -1401,8 +1400,9 @@ GSSetDragTypes(NSView* obj, NSArray *types)
/* Restore our original gstate */
DPSgrestore(ctxt);
/* Restore gstate of nesting lockFocus (if any) */
DPSgrestore(ctxt);
/* Restore state (including viewclip) of nesting lockFocus */
DPScleartomark(ctxt);
DPSrestore(ctxt);
if (!_allocate_gstate)
_gstate = 0;