* GSContext.m/.h second rewrite and polish of API.

* NSView.m displayrect add flushWindow at end.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@3339 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
far 1998-11-27 12:17:37 +00:00
parent 57f27ed12d
commit 9af04949cd
4 changed files with 44 additions and 26 deletions

View file

@ -1,3 +1,8 @@
Fri Nov 27 1998 Felipe A. Rodriguez <far@ix.netcom.com>
* GSContext.m/.h second rewrite and polish of API.
* NSView.m displayrect add flushWindow at end.
Thu Nov 26 1998 Felipe A. Rodriguez <far@ix.netcom.com> Thu Nov 26 1998 Felipe A. Rodriguez <far@ix.netcom.com>
* NSApplication.m add updateServicesMenu invocation accidently deleted * NSApplication.m add updateServicesMenu invocation accidently deleted

View file

@ -84,9 +84,6 @@ typedef enum _NSWindowOrderingMode {
{ {
NSDictionary *context_info; NSDictionary *context_info;
NSMutableData *context_data; NSMutableData *context_data;
// Reserverd for back-end use
void *be_context_reserved;
} }
// //
@ -118,6 +115,7 @@ typedef enum _NSWindowOrderingMode {
// Destroy the Context // Destroy the Context
// //
+ (void) destroyContext:(GSContext *) context; + (void) destroyContext:(GSContext *) context;
+ (void) _destroyContext:(GSContext *) context; // private use only
- (void) destroy; - (void) destroy;
@end @end

View file

@ -46,9 +46,8 @@ NSZone *_globalGSZone = NULL; // The memory zone where all
// //
// Class variables // Class variables
// //
static Class contextConcreteClass; // actual class of GSContext's static Class _concreteClass; // actual class of GSContext
static NSMutableArray *contextList; // list of drawing destinations static NSMutableArray *contextList; // list of drawing destinations
static GSContext *_currentGSContext = nil; // the current context
@ -59,7 +58,7 @@ static GSContext *_currentGSContext = nil; // the current context
// //
+ (void)initialize + (void)initialize
{ {
if (self == (contextConcreteClass = [GSContext class])) if (self == (_concreteClass = [GSContext class]))
{ {
contextList = [[NSMutableArray arrayWithCapacity:2] retain]; contextList = [[NSMutableArray arrayWithCapacity:2] retain];
NSDebugLog(@"Initialize GSContext class\n"); NSDebugLog(@"Initialize GSContext class\n");
@ -67,37 +66,50 @@ static GSContext *_currentGSContext = nil; // the current context
} }
} }
+ (void) setConcreteClass: (Class)c { contextConcreteClass = c; } + (void) setConcreteClass: (Class)c { _concreteClass = c; }
+ (Class) concreteClass { return contextConcreteClass; } + (Class) concreteClass { return _concreteClass; }
+ allocWithZone: (NSZone*)z + allocWithZone: (NSZone*)z
{ {
return NSAllocateObject(contextConcreteClass, 0, z); return NSAllocateObject(_concreteClass, 0, z);
} }
+ contextWithInfo: (NSDictionary *)info; + contextWithInfo: (NSDictionary *)info;
{ {
GSContext *context; GSContext *context;
NSAssert(contextConcreteClass, @"Error: No default GSContext is set\n"); NSAssert(_concreteClass, @"Error: No concrete GSContext is set\n");
context = [[contextConcreteClass allocWithZone: _globalGSZone] context = [[_concreteClass allocWithZone: _globalGSZone]
initWithContextInfo: info]; initWithContextInfo: info];
[context autorelease]; [context autorelease];
return context; return context;
} }
+ (GSContext *) currentContext { return _currentGSContext; } + (GSContext *) currentContext { return nil;}
+ (void) setCurrentContext: (GSContext *)context + (void) setCurrentContext: (GSContext *)context
{ {
_currentGSContext = context; [self subclassResponsibility:_cmd];
} }
+ (void) destroyContext:(GSContext *) context // remove context from the + (void) destroyContext:(GSContext *) context
{ // if concrete class is not
if(_concreteClass != [GSContext class]) // a GSContext invoke it's
[_concreteClass destroyContext: context]; // equivalent method first
else
[self _destroyContext: context];
}
// private method which
+ (void) _destroyContext:(GSContext *) context // removes context from the
{ // list so that it gets { // list so that it gets
[contextList removeObject: context]; // deallocated with the int top; // deallocated with the
} // next autorelease pool // next autorelease pool
[contextList removeObject: context];
// if not last context set
if((top = [contextList count]) > 0) // next in list as current
[_concreteClass setCurrentContext:[contextList objectAtIndex:top - 1]];
}
// //
// Instance methods // Instance methods
@ -110,8 +122,9 @@ GSContext *context;
- initWithContextInfo: (NSDictionary *)info - initWithContextInfo: (NSDictionary *)info
{ // designated initializer { // designated initializer
[super init]; // for GSContext class [super init]; // for GSContext class
[contextList addObject: self]; [contextList addObject: self];
[GSContext setCurrentContext: self]; [_concreteClass setCurrentContext: self];
if(info) if(info)
context_info = [info retain]; context_info = [info retain];
@ -131,7 +144,7 @@ GSContext *context;
- (void) destroy // remove self from context - (void) destroy // remove self from context
{ // list so that self gets { // list so that self gets
[GSContext destroyContext: self]; // deallocated with the [_concreteClass destroyContext: self]; // deallocated with the
} // next autorelease pool } // next autorelease pool
- (void) dealloc - (void) dealloc

View file

@ -801,6 +801,8 @@ int i, count;
[subview displayRect:intersection]; [subview displayRect:intersection];
} }
} }
[window flushWindow];
} }
- (void)displayRectIgnoringOpacity:(NSRect)aRect - (void)displayRectIgnoringOpacity:(NSRect)aRect