Implement extended graphics ops (composite, etc).

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4262 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fedor 1999-05-18 16:49:13 +00:00
parent ed2acc2520
commit 95f1109ae7
8 changed files with 266 additions and 17 deletions

View file

@ -619,6 +619,21 @@ struct NSWindow_struct
GET_IMP(@selector(DPSsetrgbactual::::));
methodTable.DPScapturegstate_ =
GET_IMP(@selector(DPScapturegstate:));
/*-------------------------------------------------------------------------*/
/* Graphics Extension Ops */
/*-------------------------------------------------------------------------*/
methodTable.DPScomposite________ =
GET_IMP(@selector(DPScomposite::::::::));
methodTable.DPScompositerect_____ =
GET_IMP(@selector(DPScompositerect:::::));
methodTable.DPSdissolve________ =
GET_IMP(@selector(DPSdissolve::::::::));
methodTable.DPSreadimage =
GET_IMP(@selector(DPSreadimage));
methodTable.DPSsetalpha_ =
GET_IMP(@selector(DPSsetalpha:));
methodTable.DPScurrentalpha_ =
GET_IMP(@selector(DPScurrentalpha:));
mptr = NSZoneMalloc(_globalGSZone, sizeof(gsMethodTable));
memcpy(mptr, &methodTable, sizeof(gsMethodTable));
@ -1476,6 +1491,40 @@ struct NSWindow_struct
[self subclassResponsibility: _cmd];
}
/*-------------------------------------------------------------------------*/
/* Graphics Extension Ops */
/*-------------------------------------------------------------------------*/
- (void) DPScomposite: (float)x : (float)y : (float)w : (float)h : (int)gstateNum : (float)dx : (float)dy : (int)op
{
[self subclassResponsibility: _cmd];
}
- (void) DPScompositerect: (float)x : (float)y : (float)w : (float)h : (int)op
{
[self subclassResponsibility: _cmd];
}
- (void) DPSdissolve: (float)x : (float)y : (float)w : (float)h : (int)gstateNum
: (float)dx : (float)dy : (float)delta
{
[self subclassResponsibility: _cmd];
}
- (void) DPSreadimage
{
[self subclassResponsibility: _cmd];
}
- (void) DPSsetalpha: (float)a
{
[self subclassResponsibility: _cmd];
}
- (void) DPScurrentalpha: (float *)alpha
{
[self subclassResponsibility: _cmd];
}
/* ----------------------------------------------------------------------- */
/* GNUstep Event and other I/O extensions */
/* ----------------------------------------------------------------------- */

View file

@ -35,13 +35,9 @@
#include <AppKit/NSBitmapImageRep.h>
#include <AppKit/NSEPSImageRep.h>
#include <AppKit/NSPasteboard.h>
/* Backend protocol - methods that must be implemented by the backend to
complete the class */
@protocol NXImageRepBackend
- (BOOL) drawAtPoint: (NSPoint)aPoint;
- (BOOL) drawInRect: (NSRect)aRect;
@end
#include <AppKit/NSGraphicsContext.h>
#include <AppKit/NSView.h>
#include <AppKit/DPSOperators.h>
static NSMutableArray* imageReps = NULL;
@ -284,23 +280,51 @@ static NSMutableArray* imageReps = NULL;
- (BOOL) drawAtPoint: (NSPoint)aPoint
{
NSRect r;
BOOL ok, reset;
NSGraphicsContext *ctxt;
if (aPoint.x == 0 && aPoint.y == 0)
return [self draw];
r.origin = aPoint;
r.size = size;
return [self drawInRect: r];
if (size.width == 0 && size.height == 0)
return NO;
NSDebugLLog(@"NSImage", @"Drawing at point %f %f\n", aPoint.x, aPoint.y);
reset = 0;
ctxt = GSCurrentContext();
if (aPoint.x != 0 || aPoint.y != 0)
{
if ([[ctxt focusView] isFlipped])
aPoint.y -= size.height;
DPSmatrix(ctxt); DPScurrentmatrix(ctxt);
DPStranslate(ctxt, aPoint.x, aPoint.y);
reset = 1;
}
ok = [self draw];
if (reset)
DPSsetmatrix(ctxt);
return ok;
}
- (BOOL) drawInRect: (NSRect)aRect
{
float x, y;
NSSize scale;
BOOL ok;
NSGraphicsContext *ctxt;
if (size.height == 0 || size.width == 0)
NSDebugLLog(@"NSImage", @"Drawing in rect (%f %f %f %f)\n",
NSMinX(aRect), NSMinY(aRect), NSWidth(aRect), NSHeight(aRect));
if (size.width == 0 && size.height == 0)
return NO;
/* FIXME - should scale and move as necessary. */
return NO;
ctxt = GSCurrentContext();
scale = NSMakeSize(NSWidth(aRect) / size.width,
NSHeight(aRect) / size.height);
if ([[ctxt focusView] isFlipped])
aRect.origin.y -= NSHeight(aRect);
DPSmatrix(ctxt); DPScurrentmatrix(ctxt);
DPStranslate(ctxt, NSMinX(aRect), NSMinY(aRect));
DPSscale(ctxt, scale.width, scale.height);
ok = [self draw];
DPSsetmatrix(ctxt);
return ok;
}
// Managing NSImageRep Subclasses

View file

@ -1800,6 +1800,7 @@ static Class responderClass;
original_responder = nil;
delegate = nil;
window_num = 0;
gstate = 0;
background_color = [[NSColor controlColor] retain];
represented_filename = @"Window";
miniaturized_title = @"Window";