mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
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:
parent
09193da35a
commit
99818a7d2b
7 changed files with 117 additions and 25 deletions
26
ChangeLog
26
ChangeLog
|
@ -1,3 +1,29 @@
|
|||
2001-09-02 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Source/NSView.m (-lockFocusInRect:) Properly mark the save object.
|
||||
Do a rectviewclip in (sortof) the right place.
|
||||
|
||||
2001-08-31 Georg Fleischmann
|
||||
|
||||
* Source/NSView.m
|
||||
[NSView lockFocusInRect:]: DPSsave(ctxt) added
|
||||
[NSView unlockFocusWithFlush:]: DPSrestore(ctxt) added
|
||||
|
||||
* Headers/gnustep/gui/DPSOperators.h
|
||||
DPSrestore() and DPSsave(): new
|
||||
|
||||
* Headers/gnustep/gui/GSMethodTable.h
|
||||
DPSrestore and DPSsave added
|
||||
|
||||
* Headers/gnustep/gui/NSGraphicsContext.h
|
||||
-DPSrestore and -DPSsave added
|
||||
|
||||
* Source/NSGraphicsContext.m
|
||||
[NSGraphicContext _inittializeMethodTable]:
|
||||
DPSrestore and DPSsave added
|
||||
[NSGraphicsContext DPSrestore]: new
|
||||
[NSGraphicsContext DPSsave]: new
|
||||
|
||||
2001-09-01 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Source/NSImage.m ([NSImage -initWithCoder:]): Create _reps array
|
||||
|
|
|
@ -667,6 +667,17 @@ static inline void
|
|||
DPSviewclippath(GSCTXT *ctxt)
|
||||
__attribute__((unused));
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* System ops */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
static inline void
|
||||
DPSrestore(GSCTXT *ctxt)
|
||||
__attribute__((unused));
|
||||
|
||||
static inline void
|
||||
DPSsave(GSCTXT *ctxt)
|
||||
__attribute__((unused));
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Window system ops */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
@ -2179,6 +2190,23 @@ DPScurrentalpha(GSCTXT *ctxt, float *a)
|
|||
(ctxt, @selector(DPScurrentalpha:), a);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* System ops */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
static inline void
|
||||
DPSrestore(GSCTXT *ctxt)
|
||||
{
|
||||
(ctxt->methods->DPSrestore)
|
||||
(ctxt, @selector(DPSrestore));
|
||||
}
|
||||
|
||||
static inline void
|
||||
DPSsave(GSCTXT *ctxt)
|
||||
{
|
||||
(ctxt->methods->DPSsave)
|
||||
(ctxt, @selector(DPSsave));
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Window ops extensions */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
|
|
@ -369,6 +369,14 @@ typedef struct {
|
|||
void (*DPSviewclippath)
|
||||
(NSGraphicsContext*, SEL);
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* System ops */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
void (*DPSrestore)
|
||||
(NSGraphicsContext*, SEL);
|
||||
void (*DPSsave)
|
||||
(NSGraphicsContext*, SEL);
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Window system ops */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
void (*DPScurrentdrawingfunction_)
|
||||
|
|
|
@ -366,6 +366,13 @@ NSGraphicsContext *GSCurrentContext();
|
|||
- (void) DPSsetbbox: (float)llx : (float)lly : (float)urx : (float)ury ;
|
||||
- (void) DPSviewclip;
|
||||
- (void) DPSviewclippath;
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* System system ops */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
- (void) DPSrestore ;
|
||||
- (void) DPSsave ;
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Window system ops */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
#include <Foundation/NSObject.h>
|
||||
#include <Foundation/NSBundle.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSGeometry.h>
|
||||
|
||||
@class NSString;
|
||||
@class NSDictionary;
|
||||
|
|
|
@ -731,6 +731,13 @@ NSGraphicsContext *GSCurrentContext()
|
|||
methodTable.DPSviewclippath =
|
||||
GET_IMP(@selector(DPSviewclippath));
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* System system ops */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
methodTable.DPSrestore =
|
||||
GET_IMP(@selector(DPSrestore));
|
||||
methodTable.DPSsave =
|
||||
GET_IMP(@selector(DPSsave));
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Window system ops */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
methodTable.DPScurrentdrawingfunction_ =
|
||||
|
@ -1798,6 +1805,20 @@ NSGraphicsContext *GSCurrentContext()
|
|||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* System ops */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
||||
- (void) DPSrestore
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (void) DPSsave
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
/* Window system ops */
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue