mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 23:31:02 +00:00
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:
parent
fb70f31618
commit
6123e28d45
3 changed files with 94 additions and 17 deletions
12
ChangeLog
12
ChangeLog
|
@ -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:
|
||||
|
|
|
@ -85,6 +85,7 @@
|
|||
{
|
||||
NSString *theClass;
|
||||
NSRect theFrame;
|
||||
unsigned int autoresizingMask;
|
||||
}
|
||||
@end
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Reference in a new issue