mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:00:47 +00:00
* Headers/Additions/GNUstepGUI/GSNibLoading.h: Added new method
nibInstantiateWithCoder: to do the initialization normally done in NSView when not in IB/Gorm. * Source/GSNibLoading.m: Added implementation of new method and also re-wrote part of NSCustomView. * Source/NSView.m: Added an NSAssert to assure that no subview ever decoded is an NSCustomView. --- Moved decoding of custom view attributes here so that it can cleanly initialize everything to ensure that the view works properly. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27281 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
5dfc9be420
commit
a26e76582a
4 changed files with 149 additions and 66 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2008-12-12 02:04-EST Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
|
* Headers/Additions/GNUstepGUI/GSNibLoading.h: Added new method
|
||||||
|
nibInstantiateWithCoder: to do the initialization normally done
|
||||||
|
in NSView when not in IB/Gorm.
|
||||||
|
* Source/GSNibLoading.m: Added implementation of new method and
|
||||||
|
also re-wrote part of NSCustomView.
|
||||||
|
* Source/NSView.m: Added an NSAssert to assure that no subview
|
||||||
|
ever decoded is an NSCustomView.
|
||||||
|
|
||||||
2008-12-12 Fred Kiefer <FredKiefer@gmx.de>
|
2008-12-12 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSBitmapImageRep.m (-_convertToFormatBitsPerSample:...):
|
* Source/NSBitmapImageRep.m (-_convertToFormatBitsPerSample:...):
|
||||||
|
|
|
@ -218,6 +218,7 @@ typedef struct _GSWindowTemplateFlags
|
||||||
- (void) setExtension: (NSString *)view;
|
- (void) setExtension: (NSString *)view;
|
||||||
- (NSString *)extension;
|
- (NSString *)extension;
|
||||||
- (id)nibInstantiate;
|
- (id)nibInstantiate;
|
||||||
|
- (id)nibInstantiateWithCoder: (NSCoder *)coder;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface NSCustomResource : NSObject <NSCoding>
|
@interface NSCustomResource : NSObject <NSCoding>
|
||||||
|
|
|
@ -65,6 +65,31 @@
|
||||||
|
|
||||||
static BOOL _isInInterfaceBuilder = NO;
|
static BOOL _isInInterfaceBuilder = NO;
|
||||||
|
|
||||||
|
@interface NSKeyedUnarchiver (NSClassSwapperPrivate)
|
||||||
|
- (BOOL) replaceObject: (id)oldObj withObject: (id)newObj;
|
||||||
|
- (NSDictionary *)keyMap;
|
||||||
|
- (Class) replacementClassForClassName: (NSString *)className;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface NSApplication (NibCompatibility)
|
||||||
|
- (void) _setMainMenu: (NSMenu*)aMenu;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface NSView (NibCompatibility)
|
||||||
|
- (void) _fixSubviews;
|
||||||
|
@end
|
||||||
|
|
||||||
|
/* Correct some instances where the ":" is missing from the method name in the label */
|
||||||
|
@interface NSNibControlConnector (NibCompatibility)
|
||||||
|
- (void) instantiateWithInstantiator: (id<GSInstantiator>)instantiator;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface NSDecimalNumberPlaceholder : NSObject
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface _NSCornerView : NSView
|
||||||
|
@end
|
||||||
|
|
||||||
@interface NSMenu (NibCompatibility)
|
@interface NSMenu (NibCompatibility)
|
||||||
- (void) _setGeometry;
|
- (void) _setGeometry;
|
||||||
- (void) _setMain: (BOOL)isMain;
|
- (void) _setMain: (BOOL)isMain;
|
||||||
|
@ -147,10 +172,6 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface NSApplication (NibCompatibility)
|
|
||||||
- (void) _setMainMenu: (NSMenu*)aMenu;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation NSApplication (NibCompatibility)
|
@implementation NSApplication (NibCompatibility)
|
||||||
- (void) _setMainMenu: (NSMenu*)aMenu
|
- (void) _setMainMenu: (NSMenu*)aMenu
|
||||||
{
|
{
|
||||||
|
@ -173,10 +194,6 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface NSView (NibCompatibility)
|
|
||||||
- (void) _fixSubviews;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation NSView (NibCompatibility)
|
@implementation NSView (NibCompatibility)
|
||||||
- (void) _setWindow: (id) w
|
- (void) _setWindow: (id) w
|
||||||
{
|
{
|
||||||
|
@ -818,45 +835,87 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
|
|
||||||
- (id) nibInstantiate
|
- (id) nibInstantiate
|
||||||
{
|
{
|
||||||
if (_view == nil)
|
Class aClass;
|
||||||
|
|
||||||
|
if ([NSClassSwapper isInInterfaceBuilder])
|
||||||
{
|
{
|
||||||
Class aClass;
|
_view = self;
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
aClass = NSClassFromString(_className);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the class name is nil, assume NSView.
|
||||||
|
if(_className == nil)
|
||||||
|
{
|
||||||
|
aClass = [NSView class];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aClass == nil)
|
||||||
|
{
|
||||||
|
[NSException raise: NSInternalInconsistencyException
|
||||||
|
format: @"Unable to find class '%@'", _className];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_view = [[aClass allocWithZone: NSDefaultMallocZone()] initWithFrame: [self frame]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return _view;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) awakeAfterUsingCoder: (NSCoder *)coder
|
||||||
|
{
|
||||||
|
return _view;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (id) nibInstantiateWithCoder: (NSCoder *)coder
|
||||||
|
{
|
||||||
|
if([NSClassSwapper isInInterfaceBuilder])
|
||||||
|
{
|
||||||
|
return _view;
|
||||||
|
}
|
||||||
|
else if ([coder allowsKeyedCoding])
|
||||||
|
{
|
||||||
|
NSArray *subs = nil;
|
||||||
|
id nextKeyView = nil;
|
||||||
|
id prevKeyView = nil;
|
||||||
|
NSEnumerator *en = nil;
|
||||||
|
id v = nil;
|
||||||
|
|
||||||
|
prevKeyView = [coder decodeObjectForKey: @"NSPreviousKeyView"];
|
||||||
|
nextKeyView = [coder decodeObjectForKey: @"NSNextKeyView"];
|
||||||
|
if (nextKeyView != nil)
|
||||||
|
{
|
||||||
|
[self setNextKeyView: nextKeyView];
|
||||||
|
}
|
||||||
|
if (prevKeyView != nil)
|
||||||
|
{
|
||||||
|
[self setPreviousKeyView: prevKeyView];
|
||||||
|
}
|
||||||
|
if ([coder containsValueForKey: @"NSvFlags"])
|
||||||
|
{
|
||||||
|
int vFlags = [coder decodeIntForKey: @"NSvFlags"];
|
||||||
|
[_view setAutoresizingMask: vFlags & 0x3F];
|
||||||
|
[_view setAutoresizesSubviews: ((vFlags & 0x100) == 0x100)];
|
||||||
|
[_view setHidden: ((vFlags & 0x80000000) == 0x80000000)];
|
||||||
|
}
|
||||||
|
|
||||||
if ([NSClassSwapper isInInterfaceBuilder])
|
[_view setNextResponder: [self nextResponder]];
|
||||||
{
|
|
||||||
_view = self;
|
subs = [coder decodeObjectForKey: @"NSSubviews"];
|
||||||
return self;
|
en = [subs objectEnumerator];
|
||||||
}
|
while((v = [en nextObject]) != nil)
|
||||||
else
|
{
|
||||||
{
|
[_view addSubview: v];
|
||||||
aClass = NSClassFromString(_className);
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (aClass == nil)
|
{
|
||||||
{
|
[NSException raise: NSInternalInconsistencyException
|
||||||
[NSException raise: NSInternalInconsistencyException
|
format: @"Called NSCustomView awakeAfterUsingCoder with non-keyed archiver."];
|
||||||
format: @"Unable to find class '%@'", _className];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_view = [[aClass allocWithZone: NSDefaultMallocZone()] initWithFrame: [self frame]];
|
|
||||||
[_view setAutoresizingMask: [self autoresizingMask]];
|
|
||||||
[_view setAutoresizesSubviews: [self autoresizesSubviews]];
|
|
||||||
[_view setHidden: [self isHidden]];
|
|
||||||
[_view setNextResponder: [self nextResponder]];
|
|
||||||
// [[self superview] replaceSubview: self with: _view]; // replace the old view...
|
|
||||||
|
|
||||||
if (_rFlags.has_subviews)
|
|
||||||
{
|
|
||||||
NSEnumerator *en = [[self subviews] objectEnumerator];
|
|
||||||
id v = nil;
|
|
||||||
|
|
||||||
while((v = [en nextObject]) == nil)
|
|
||||||
{
|
|
||||||
[_view addSubview: v];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return _view;
|
return _view;
|
||||||
|
@ -864,19 +923,46 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder *)coder
|
- (id) initWithCoder: (NSCoder *)coder
|
||||||
{
|
{
|
||||||
self = [super initWithCoder: coder];
|
// if in interface builder, then initialize as normal.
|
||||||
|
if([NSClassSwapper isInInterfaceBuilder])
|
||||||
|
{
|
||||||
|
self = [super initWithCoder: coder];
|
||||||
|
}
|
||||||
|
|
||||||
if (self != nil)
|
if (self != nil)
|
||||||
{
|
{
|
||||||
if ([coder allowsKeyedCoding])
|
if ([coder allowsKeyedCoding])
|
||||||
{
|
{
|
||||||
|
// get the super stuff without calling super...
|
||||||
|
if ([coder containsValueForKey: @"NSFrame"])
|
||||||
|
{
|
||||||
|
_frame = [coder decodeRectForKey: @"NSFrame"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_frame = NSZeroRect;
|
||||||
|
if ([coder containsValueForKey: @"NSFrameSize"])
|
||||||
|
{
|
||||||
|
_frame.size = [coder decodeSizeForKey: @"NSFrameSize"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ASSIGN(_className, [coder decodeObjectForKey: @"NSClassName"]);
|
ASSIGN(_className, [coder decodeObjectForKey: @"NSClassName"]);
|
||||||
ASSIGN(_extension, [coder decodeObjectForKey: @"NSExtension"]);
|
ASSIGN(_extension, [coder decodeObjectForKey: @"NSExtension"]);
|
||||||
|
|
||||||
[self nibInstantiate];
|
if([self nibInstantiate] != nil)
|
||||||
|
{
|
||||||
|
[self nibInstantiateWithCoder: coder];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent the case where we get back an NSCustomView.
|
||||||
|
// NSAssert((([NSClassSwapper isInInterfaceBuilder] == NO) &&
|
||||||
|
// ([_view class] != [NSCustomView class])), NSInvalidArgumentException);
|
||||||
|
|
||||||
if(self != _view)
|
if(self != _view)
|
||||||
{
|
{
|
||||||
AUTORELEASE(self);
|
AUTORELEASE(self);
|
||||||
[coder replaceObject: self withObject: _view];
|
[(NSKeyedUnarchiver *)coder replaceObject: self withObject: _view];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -977,12 +1063,6 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface NSKeyedUnarchiver (NSClassSwapperPrivate)
|
|
||||||
- (BOOL) replaceObject: (id)oldObj withObject: (id)newObj;
|
|
||||||
- (NSDictionary *)keyMap;
|
|
||||||
- (Class) replacementClassForClassName: (NSString *)className;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation NSKeyedUnarchiver (NSClassSwapperPrivate)
|
@implementation NSKeyedUnarchiver (NSClassSwapperPrivate)
|
||||||
- (BOOL) replaceObject: (id)oldObj withObject: (id)newObj
|
- (BOOL) replaceObject: (id)oldObj withObject: (id)newObj
|
||||||
{
|
{
|
||||||
|
@ -1191,11 +1271,6 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/* Correct some instances where the ":" is missing from the method name in the label */
|
|
||||||
@interface NSNibControlConnector (NibCompatibility)
|
|
||||||
- (void) instantiateWithInstantiator: (id<GSInstantiator>)instantiator;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation NSNibControlConnector (NibCompatibility)
|
@implementation NSNibControlConnector (NibCompatibility)
|
||||||
- (void) instantiateWithInstantiator: (id<GSInstantiator>)instantiator
|
- (void) instantiateWithInstantiator: (id<GSInstantiator>)instantiator
|
||||||
{
|
{
|
||||||
|
@ -1729,9 +1804,6 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface NSDecimalNumberPlaceholder : NSObject
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation NSDecimalNumberPlaceholder
|
@implementation NSDecimalNumberPlaceholder
|
||||||
- (id) initWithCoder: (NSCoder *)coder
|
- (id) initWithCoder: (NSCoder *)coder
|
||||||
{
|
{
|
||||||
|
@ -1775,9 +1847,6 @@ static BOOL _isInInterfaceBuilder = NO;
|
||||||
// ...dummy/placeholder classes...
|
// ...dummy/placeholder classes...
|
||||||
// overridden in NSTableView to be GSTableCornerView,
|
// overridden in NSTableView to be GSTableCornerView,
|
||||||
// but the class needs to be present to be overridden.
|
// but the class needs to be present to be overridden.
|
||||||
@interface _NSCornerView : NSView
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation _NSCornerView
|
@implementation _NSCornerView
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,7 @@
|
||||||
#include "AppKit/PSOperators.h"
|
#include "AppKit/PSOperators.h"
|
||||||
#include "GNUstepGUI/GSDisplayServer.h"
|
#include "GNUstepGUI/GSDisplayServer.h"
|
||||||
#include "GNUstepGUI/GSTrackingRect.h"
|
#include "GNUstepGUI/GSTrackingRect.h"
|
||||||
|
#include "GNUstepGUI/GSNibLoading.h"
|
||||||
#include "GSToolTips.h"
|
#include "GSToolTips.h"
|
||||||
#include "GSBindingHelpers.h"
|
#include "GSBindingHelpers.h"
|
||||||
|
|
||||||
|
@ -4471,6 +4472,8 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
||||||
e = [subs objectEnumerator];
|
e = [subs objectEnumerator];
|
||||||
while ((sub = [e nextObject]) != nil)
|
while ((sub = [e nextObject]) != nil)
|
||||||
{
|
{
|
||||||
|
NSAssert([sub class] != [NSCustomView class],
|
||||||
|
NSInternalInconsistencyException);
|
||||||
NSAssert([sub window] == nil,
|
NSAssert([sub window] == nil,
|
||||||
NSInternalInconsistencyException);
|
NSInternalInconsistencyException);
|
||||||
NSAssert([sub superview] == nil,
|
NSAssert([sub superview] == nil,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue