New Apple methods on NSGraphicsContext and rework of window device

setting. Requires corresponding change in back!


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25980 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2008-01-19 13:11:16 +00:00
parent af5036aeee
commit 99e9f5a69e
6 changed files with 117 additions and 38 deletions

View file

@ -1,3 +1,17 @@
2008-01-19 Fred Kiefer <FredKiefer@gmx.de>
* Headers/Additions/GNUstepGUI/GSDisplayServer.h
(-setWindowdevice:forContext:),
* Source/GSDisplayServer.m (-setWindowdevice:forContext:): New
method replacing windowdevice:.
* Headers/AppKit/NSGraphicsContext.h,
* Source/NSGraphicsContext.m: Add new MacOSX methods and ivars.
* Source/NSWindow.m (-_processResizeEvent): Simplified with new
GSDisplayServer method.
* Source/NSWindow.m (-_initBackendWindow, -initWithWindowRef:):
Moved device interaction into backend. Requires corresponding
change in backend!
2008-01-18 14:39-EST Gregory John Casamento <greg_casamento@yahoo.com>
* Headers/Additions/GNUstepGUI/GSTheme.h

View file

@ -45,6 +45,7 @@
@class NSMutableArray;
@class NSMutableData;
@class GSDisplayServer;
@class NSGraphicsContext;
#ifndef NO_GNUSTEP
APPKIT_EXPORT GSDisplayServer * GSServerForWindow(NSWindow *window);
@ -128,7 +129,9 @@ APPKIT_EXPORT NSString * GSScreenNumber;
- (void) titlewindow: (NSString *)window_title : (int)win;
- (void) miniwindow: (int)win;
- (BOOL) appOwnsMiniwindow;
- (void) windowdevice: (int)win;
- (void) setWindowdevice: (int)win forContext: (NSGraphicsContext *)ctxt;
// Deprecated
- (void) windowdevice: (int) winNum;
- (void) orderwindow: (int)op : (int)otherWin : (int)win;
- (void) movewindow: (NSPoint)loc : (int)win;
- (void) placewindow: (NSRect)frame : (int)win;

View file

@ -47,6 +47,7 @@
@class NSWindow;
@class NSFont;
@class NSSet;
@class NSBitmapImageRep;
/*
* Backing Store Types
@ -158,6 +159,10 @@ typedef enum _GSColorSpace
NSMutableSet *usedFonts;
NSImageInterpolation _interp;
BOOL _antialias;
NSPoint _patternPhase;
void *_graphicsPort;
BOOL _isFlipped;
NSCompositingOperation _compositingOperation;
}
+ (BOOL) currentContextDrawingToScreen;
@ -169,6 +174,11 @@ typedef enum _GSColorSpace
+ (void) setGraphicsState: (int)graphicsState;
+ (void) setCurrentContext: (NSGraphicsContext*)context;
+ (NSGraphicsContext*) currentContext;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
+ (NSGraphicsContext *) graphicsContextWithBitmapImageRep: (NSBitmapImageRep *)bitmap;
+ (NSGraphicsContext *) graphicsContextWithGraphicsPort: (void *)port
flipped: (BOOL)flag;
#endif
- (NSDictionary *) attributes;
- (void *) graphicsPort;
@ -186,6 +196,18 @@ typedef enum _GSColorSpace
- (void) setShouldAntialias: (BOOL)antialias;
- (BOOL) shouldAntialias;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
- (NSPoint) patternPhase;
- (void) setPatternPhase: (NSPoint)phase;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (NSCompositingOperation) compositingOperation;
- (void) setCompositingOperation:(NSCompositingOperation) operation;
- (BOOL) isFlipped;
#endif
@end
APPKIT_EXPORT NSGraphicsContext *GSCurrentContext(void);

View file

@ -607,6 +607,15 @@ GSCurrentServer(void)
although depending on the concrete implmentation, more information
than this may need to be exchanged. */
- (void) windowdevice: (int) win
{
[self setWindowdevice: win forContext: GSCurrentContext()];
}
/** Sets the window device information for the NSGraphicsContext,
typically by calling [NSGraphicsContext-GSSetDevice:::],
although depending on the concrete implmentation, more information
than this may need to be exchanged. */
- (void) setWindowdevice: (int)win forContext: (NSGraphicsContext *)ctxt
{
[self subclassResponsibility: _cmd];
}

View file

@ -50,6 +50,7 @@
#include "AppKit/NSView.h"
#include "AppKit/DPSOperators.h"
#include "GNUstepGUI/GSVersion.h"
#include "GNUstepGUI/GSDisplayServer.h"
typedef struct { @defs(NSThread) } *TInfo;
@ -212,7 +213,29 @@ NSGraphicsContext *GSCurrentContext(void)
device description. */
+ (NSGraphicsContext *) graphicsContextWithWindow: (NSWindow *)aWindow
{
return [self graphicsContextWithAttributes: [aWindow deviceDescription]];
return [self graphicsContextWithAttributes:
[NSDictionary dictionaryWithObject: aWindow
forKey: NSGraphicsContextDestinationAttributeName]];
}
+ (NSGraphicsContext *) graphicsContextWithBitmapImageRep: (NSBitmapImageRep *)bitmap
{
return [self graphicsContextWithAttributes:
[NSDictionary dictionaryWithObject: bitmap
forKey: NSGraphicsContextDestinationAttributeName]];
}
+ (NSGraphicsContext *) graphicsContextWithGraphicsPort: (void *)port
flipped: (BOOL)flag
{
NSGraphicsContext *new;
// FIXME
new = [self graphicsContextWithAttributes: nil];
new->_graphicsPort = port;
new->_isFlipped = flag;
return new;
}
+ (void) restoreGraphicsState
@ -286,11 +309,11 @@ NSGraphicsContext *GSCurrentContext(void)
[contextLock lock];
methods = [[classMethodTable objectForKey: [self class]] pointerValue];
if (methods == 0)
{
methods = [[self class] _initializeMethodTable];
[classMethodTable setObject: [NSValue valueWithPointer: methods]
forKey: [self class]];
}
{
methods = [[self class] _initializeMethodTable];
[classMethodTable setObject: [NSValue valueWithPointer: methods]
forKey: [self class]];
}
[contextLock unlock];
}
return self;
@ -308,7 +331,7 @@ NSGraphicsContext *GSCurrentContext(void)
- (void *) graphicsPort
{
return NULL;
return _graphicsPort;
}
- (BOOL) isDrawingToScreen
@ -356,6 +379,35 @@ NSGraphicsContext *GSCurrentContext(void)
return _antialias;
}
- (NSPoint) patternPhase
{
return _patternPhase;
}
- (void) setPatternPhase: (NSPoint)phase
{
_patternPhase = phase;
}
- (BOOL) isFlipped
{
NSView *focusView = [self focusView];
if (focusView)
return [focusView isFlipped];
else
return _isFlipped;
}
- (NSCompositingOperation) compositingOperation
{
return _compositingOperation;
}
- (void) setCompositingOperation: (NSCompositingOperation)operation
{
_compositingOperation = operation;
}
- (NSView*) focusView
{
return [focus_stack lastObject];
@ -1489,8 +1541,6 @@ NSGraphicsContext *GSCurrentContext(void)
@end
#include "GNUstepGUI/GSDisplayServer.h"
/* ----------------------------------------------------------------------- */
/* NSGraphics Ops */
/* ----------------------------------------------------------------------- */

View file

@ -770,7 +770,6 @@ many times.
- (void) _initBackendWindow
{
int screenNumber;
NSCountedSet *dragTypes;
GSDisplayServer *srv = GSCurrentServer();
@ -785,25 +784,17 @@ many times.
dragTypes = [dragTypes copy];
/* Now we need to remove all the drag types for this window. */
[srv removeDragTypes: nil fromWindow: self];
[srv removeDragTypes: nil fromWindow: self];
}
screenNumber = [_screen screenNumber];
_windowNum =
[srv window: _frame
: _backingType
: _styleMask
: screenNumber];
_windowNum = [srv window: _frame
: _backingType
: _styleMask
: [_screen screenNumber]];
[srv setwindowlevel: [self level] : _windowNum];
NSMapInsert (windowmaps, (void*)(intptr_t)_windowNum, self);
NSMapInsert(windowmaps, (void*)(intptr_t)_windowNum, self);
ASSIGN(_context, [NSGraphicsContext graphicsContextWithWindow: self]);
// FIXME: This belongs into NSGraphicsContext
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext: _context];
[srv windowdevice: _windowNum];
[NSGraphicsContext restoreGraphicsState];
// Set window in new _gstate
_gstate = GSDefineGState(_context);
@ -812,6 +803,7 @@ many times.
NSRect frame = _frame;
frame.origin = NSZeroPoint;
[_wv setFrame: frame];
[_wv setWindowNumber: _windowNum];
[_wv setNeedsDisplay: YES];
}
@ -852,8 +844,6 @@ many times.
if (!NSEqualSizes(_increments, NSZeroSize))
[self setResizeIncrements: _increments];
[_wv setWindowNumber: _windowNum];
NSDebugLLog(@"NSWindow", @"Created NSWindow window frame %@",
NSStringFromRect(_frame));
}
@ -1020,11 +1010,6 @@ many times.
NSMapInsert (windowmaps, (void*)(intptr_t)_windowNum, self);
ASSIGN(_context, [NSGraphicsContext graphicsContextWithWindow: self]);
// FIXME: This belongs into NSGraphicsContext
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext: _context];
[srv windowdevice: _windowNum];
[NSGraphicsContext restoreGraphicsState];
// Set window in new _gstate
_gstate = GSDefineGState(_context);
@ -3404,13 +3389,9 @@ resetCursorRectsForView(NSView *theView)
{
if (_windowNum && _gstate)
{
// FIXME: move this into NSGraphicsContext
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext: _context];
DPSsetgstate(_context, _gstate);
[GSServerForWindow(self) windowdevice: _windowNum];
[GSServerForWindow(self) setWindowdevice: _windowNum
forContext: _context];
GSReplaceGState(_context, _gstate);
[NSGraphicsContext restoreGraphicsState];
}
[self update];