Implement GSReadRect and initWithFocusedViewRect:

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@17687 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2003-09-20 02:57:45 +00:00
parent 0d81427181
commit 50ed66958a
7 changed files with 68 additions and 18 deletions

View file

@ -1,3 +1,12 @@
2003-09-19 Adam Fedor <fedor@gnu.org>
* Headers/Additions/GNUstepGUI/GSMethodTable.h: Change NSReadPixel
to GSReadRect
* Headers/AppKit/NSGraphicsContext.h, Source/NSGraphicsContext.m: Idem.
* Headers/AppKit/NSGraphics.h (NSReadPixel): Move to...
* Source/Functions.m (NSReadPixel): here.
* Source/NSBitmapImageRep.m (-initWithFocusedViewRect:): Implement.
2003-09-16 Adam Fedor <fedor@gnu.org>
* GNUmakefile (SUBPROJECTS): Don't build Documentation by default.

View file

@ -279,8 +279,8 @@ typedef struct {
/* ----------------------------------------------------------------------- */
/* NSGraphics Ops */
/* ----------------------------------------------------------------------- */
NSColor * (*NSReadPixel_)
(NSGraphicsContext*, SEL, NSPoint);
NSDictionary * (*GSReadRect_)
(NSGraphicsContext*, SEL, NSRect);
void (*NSBeep)
(NSGraphicsContext*, SEL);

View file

@ -138,13 +138,7 @@ APPKIT_EXPORT void NSDottedFrameRect(NSRect aRect);
APPKIT_EXPORT void NSFrameRect(const NSRect aRect);
APPKIT_EXPORT void NSFrameRectWithWidth(const NSRect aRect, float frameWidth);
static inline NSColor*
NSReadPixel(NSPoint location)
{
NSGraphicsContext *ctxt = GSCurrentContext();
return (ctxt->methods->NSReadPixel_)
(ctxt, @selector(NSReadPixel:), location);
}
APPKIT_EXPORT NSColor* NSReadPixel(NSPoint location);
APPKIT_EXPORT void NSCopyBitmapFromGState(int srcGstate, NSRect srcRect,
NSRect destRect);

View file

@ -373,7 +373,7 @@ APPKIT_EXPORT NSGraphicsContext *GSCurrentContext(void);
/* NSGraphics Ops */
/* ----------------------------------------------------------------------- */
@interface NSGraphicsContext (NSGraphics)
- (NSColor *) NSReadPixel: (NSPoint) location;
- (NSDictionary *) GSReadRect: (NSRect)rect;
/* Soon to be obsolete */
- (void) NSDrawBitmap: (NSRect) rect : (int) pixelsWide : (int) pixelsHigh

View file

@ -301,8 +301,15 @@ NSPlanarFromDepth(NSWindowDepth depth)
}
/* Graphic Ops */
NSColor* NSReadPixel(NSPoint location)
{
NSLog(@"NSReadPixel not implemented");
return nil;
}
void NSCopyBitmapFromGState(int srcGstate, NSRect srcRect, NSRect destRect)
{
NSLog(@"NSCopyBitmapFromGState not implemented");
}
void NSCopyBits(int srcGstate, NSRect srcRect, NSPoint destPoint)

View file

@ -35,9 +35,11 @@
#include <Foundation/NSDebug.h>
#include <Foundation/NSException.h>
#include <Foundation/NSFileManager.h>
#include <Foundation/NSValue.h>
#include "AppKit/AppKitExceptions.h"
#include "AppKit/NSBitmapImageRep.h"
#include "AppKit/NSGraphics.h"
#include "AppKit/NSGraphicsContext.h"
#include "AppKit/NSPasteboard.h"
#include "AppKit/NSView.h"
#include "GSGuiPrivate.h"
@ -224,11 +226,45 @@ static BOOL supports_lzw_compression = NO;
- (id) initWithFocusedViewRect: (NSRect)rect
{
// TODO
[self notImplemented: _cmd];
int bps, spp, alpha;
NSSize size;
NSString *space;
unsigned char *planes[4];
NSDictionary *dict;
dict = [GSCurrentContext() GSReadRect: rect];
if (dict == nil)
{
NSLog(@"NSBitmapImageRep initWithFocusedViewRect: failed");
RELEASE(self);
return nil;
}
_imageData = RETAIN([dict objectForKey: @"ImageData"]);
if (_imageData == nil)
{
NSLog(@"NSBitmapImageRep initWithFocusedViewRect: failed");
RELEASE(self);
return nil;
}
bps = [[dict objectForKey: @"ImageBPS"] intValue];
if (bps == 0)
bps = 8;
spp = [[dict objectForKey: @"ImageSPP"] intValue];
alpha = [[dict objectForKey: @"ImageAlpha"] intValue];
size = [[dict objectForKey: @"ImageSize"] sizeValue];
space = [dict objectForKey: @"ImageColorSpace"];
planes[0] = (unsigned char *)[_imageData mutableBytes];
self = [self initWithBitmapDataPlanes: planes
pixelsWide: size.width
pixelsHigh: size.height
bitsPerSample: bps
samplesPerPixel: spp
hasAlpha: (alpha) ? YES : NO
isPlanar: NO
colorSpaceName: space
bytesPerRow: 0
bitsPerPixel: 0];
return self;
}
/**

View file

@ -652,8 +652,8 @@ NSGraphicsContext *GSCurrentContext(void)
/* ----------------------------------------------------------------------- */
/* NSGraphics Ops */
/* ----------------------------------------------------------------------- */
methodTable.NSReadPixel_ =
GET_IMP(@selector(NSReadPixel:));
methodTable.GSReadRect_ =
GET_IMP(@selector(GSReadRect:));
methodTable.NSBeep =
GET_IMP(@selector(NSBeep));
@ -1454,9 +1454,13 @@ NSGraphicsContext *GSCurrentContext(void)
/* NSGraphics Ops */
/* ----------------------------------------------------------------------- */
@implementation NSGraphicsContext (NSGraphics)
/** Read the Color at a Screen Position
/** Read the data inside rect (defined in the current graphics state)
and return the information as a bitmap. The dictionary contains
the bitmap data plus various information about the size and format
of the data. The dictionary keys include ImageSize, ImageBPS,
ImageSPP, and ImageData.
*/
- (NSColor *) NSReadPixel: (NSPoint) location
- (NSDictionary *) GSReadRect: (NSRect) rect
{
[self subclassResponsibility: _cmd];
return nil;