Source/NSBundleAdditions.m

Headers/gnustep/gui/NSNibLoading.h


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@12931 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Pierre-Yves Rivaille 2002-03-01 14:41:59 +00:00
parent fb70f31618
commit 6123e28d45
3 changed files with 94 additions and 17 deletions

View file

@ -1,3 +1,15 @@
2002-03-01 Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
* Source/NSBundleAdditions.m
([GSNibItem -initWithCoder:]):
([GSNibItem -encodeWithCoder:]):
new encoding (support for autoresizingMask).
([GSNibItem +initialize]):
([GSCustomView +initialize]):
new methods, set the version number.
* Headers/gnustep/gui/NSNibLoading.h:
new autoresizingMask ivar in GSNibItem.
2002-02-28 Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
* Headers/gnustep/gui/NSEvent.h:

View file

@ -85,6 +85,7 @@
{
NSString *theClass;
NSRect theFrame;
unsigned int autoresizingMask;
}
@end

View file

@ -50,6 +50,8 @@
#include <AppKit/NSNibLoading.h>
#include <AppKit/IMLoading.h>
static const int currentVersion = 1;
@implementation NSNibConnector
- (void) dealloc
@ -590,6 +592,13 @@ Class gmodel_class(void)
@end
@implementation GSNibItem
+ (void) initialize
{
if (self == [GSNibItem class])
{
[self setVersion: currentVersion];
}
}
- (void) dealloc
{
@ -601,37 +610,92 @@ Class gmodel_class(void)
{
[aCoder encodeObject: theClass];
[aCoder encodeRect: theFrame];
[aCoder encodeValueOfObjCType: @encode(unsigned int)
at: &autoresizingMask];
}
- (id) initWithCoder: (NSCoder*)aCoder
{
id obj;
Class cls;
int version = [aCoder versionForClassName:
NSStringFromClass([self class])];
[aCoder decodeValueOfObjCType: @encode(id) at: &theClass];
theFrame = [aCoder decodeRect];
cls = NSClassFromString(theClass);
if (cls == nil)
if (version == 1)
{
[NSException raise: NSInternalInconsistencyException
format: @"Unable to find class '%@'", theClass];
id obj;
Class cls;
unsigned int mask;
[aCoder decodeValueOfObjCType: @encode(id) at: &theClass];
theFrame = [aCoder decodeRect];
[aCoder decodeValueOfObjCType: @encode(unsigned int)
at: &mask];
cls = NSClassFromString(theClass);
if (cls == nil)
{
[NSException raise: NSInternalInconsistencyException
format: @"Unable to find class '%@'", theClass];
}
obj = [cls allocWithZone: [self zone]];
if (theFrame.size.height > 0 && theFrame.size.width > 0)
obj = [obj initWithFrame: theFrame];
else
obj = [obj init];
if ([obj respondsToSelector: @selector(setAutoresizingMask:)])
{
[obj setAutoresizingMask: mask];
}
RELEASE(self);
return obj;
}
else if (version == 0)
{
id obj;
Class cls;
[aCoder decodeValueOfObjCType: @encode(id) at: &theClass];
theFrame = [aCoder decodeRect];
cls = NSClassFromString(theClass);
if (cls == nil)
{
[NSException raise: NSInternalInconsistencyException
format: @"Unable to find class '%@'", theClass];
}
obj = [cls allocWithZone: [self zone]];
if (theFrame.size.height > 0 && theFrame.size.width > 0)
obj = [obj initWithFrame: theFrame];
else
obj = [obj init];
RELEASE(self);
return obj;
}
obj = [cls allocWithZone: [self zone]];
if (theFrame.size.height > 0 && theFrame.size.width > 0)
obj = [obj initWithFrame: theFrame];
else
obj = [obj init];
RELEASE(self);
return obj;
{
NSLog(@"no initWithCoder for this version");
RELEASE(self);
return nil;
}
}
@end
@implementation GSCustomView
+ (void) initialize
{
if (self == [GSCustomView class])
{
[self setVersion: currentVersion];
}
}
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[super encodeWithCoder: aCoder];