mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 18:11:06 +00:00
Add class NSIBUserDefinedRuntimeAttributesConnector to handle
newer NIB files. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@39836 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a0bb18fbcc
commit
78a695bc8e
4 changed files with 173 additions and 5 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,12 @@
|
|||
2016-06-02 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSBitmapImageRep+PNG.m:
|
||||
Convert image before storing it.
|
||||
* Headers/Additions/GNUstepGUI/GSNibLoading.h,
|
||||
* Source/GSNibLoading.m:
|
||||
Add class NSIBUserDefinedRuntimeAttributesConnector to handle
|
||||
newer NIB files.
|
||||
|
||||
2016-05-31 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/Additions/GNUstepGUI/GSTheme.h:
|
||||
|
@ -64,7 +73,7 @@
|
|||
* Source/NSWorkspace.m
|
||||
* Images/GNUMakefile
|
||||
Add Application folder (patch by Bertrand Dekoninck)
|
||||
|
||||
|
||||
2016-03-22 Riccardo Mottola <rm@gnu.org>
|
||||
|
||||
* Headers/AppKit/NSWorkspace.h
|
||||
|
|
|
@ -341,4 +341,31 @@ typedef struct _GSWindowTemplateFlags
|
|||
- (void) setKeyPath: (NSString *)keyPath;
|
||||
- (void) setOptions: (NSDictionary *)options;
|
||||
@end
|
||||
|
||||
@interface NSIBUserDefinedRuntimeAttributesConnector : NSObject <NSCoding>
|
||||
{
|
||||
id _object;
|
||||
NSArray *_keyPaths;
|
||||
NSArray *_values;
|
||||
}
|
||||
|
||||
- (void) instantiateWithObjectInstantiator: (id)instantiator;
|
||||
- (void) establishConnection;
|
||||
/*
|
||||
- (void) replaceObject: (id)anObject withObject: (id)anotherObject;
|
||||
- (void) setLabel: (id)label;
|
||||
- (id) label;
|
||||
- (void) setDestination: (id)destination;
|
||||
- (id) destination;
|
||||
- (void) setSource: (id)source;
|
||||
- (id) source;
|
||||
*/
|
||||
- (void) setObject: (id)object;
|
||||
- (id) object;
|
||||
- (void) setValues: (id)values;
|
||||
- (id) values;
|
||||
- (void) setKeyPaths: (id)keyPaths;
|
||||
- (id) keyPaths;
|
||||
@end
|
||||
|
||||
#endif /* _GNUstep_H_GSNibCompatibility */
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#import <Foundation/NSEnumerator.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSKeyedArchiver.h>
|
||||
#import <Foundation/NSKeyValueCoding.h>
|
||||
#import <Foundation/NSObjCRuntime.h>
|
||||
#import <Foundation/NSSet.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
@ -1955,6 +1956,14 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
[obj instantiateWithInstantiator: self];
|
||||
[obj establishConnection];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([obj respondsToSelector: @selector(instantiateWithObjectInstantiator:)])
|
||||
{
|
||||
[obj instantiateWithObjectInstantiator: self];
|
||||
[obj establishConnection];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// awaken all objects except proxy objects.
|
||||
|
@ -2256,7 +2265,7 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
}
|
||||
if (_marker != nil)
|
||||
{
|
||||
[coder encodeObject: _file forKey: @"NSMarker"];
|
||||
[coder encodeObject: _marker forKey: @"NSMarker"];
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2368,3 +2377,117 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
return self;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSIBUserDefinedRuntimeAttributesConnector
|
||||
- (void) setObject: (id)object
|
||||
{
|
||||
ASSIGN(_object, object);
|
||||
}
|
||||
|
||||
- (id) object
|
||||
{
|
||||
return _object;
|
||||
}
|
||||
|
||||
- (void) setValues: (id)values
|
||||
{
|
||||
ASSIGN(_values, values);
|
||||
}
|
||||
|
||||
- (id) values
|
||||
{
|
||||
return _values;
|
||||
}
|
||||
|
||||
- (void) setKeyPaths: (id)keyPaths
|
||||
{
|
||||
ASSIGN(_keyPaths, keyPaths);
|
||||
}
|
||||
|
||||
- (id) keyPaths
|
||||
{
|
||||
return _keyPaths;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_object);
|
||||
RELEASE(_keyPaths);
|
||||
RELEASE(_values);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder *)coder
|
||||
{
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
if (_object != nil)
|
||||
{
|
||||
[coder encodeObject: _object forKey: @"NSObject"];
|
||||
}
|
||||
if (_keyPaths != nil)
|
||||
{
|
||||
[coder encodeObject: _keyPaths forKey: @"NSKeyPaths"];
|
||||
}
|
||||
if (_values != nil)
|
||||
{
|
||||
[coder encodeObject: _values forKey: @"NSValues"];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[coder encodeObject: _object];
|
||||
[coder encodeObject: _keyPaths];
|
||||
[coder encodeObject: _values];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
if ([coder allowsKeyedCoding])
|
||||
{
|
||||
if ([coder containsValueForKey: @"NSObject"])
|
||||
{
|
||||
ASSIGN(_object, [coder decodeObjectForKey: @"NSObject"]);
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSKeyPaths"])
|
||||
{
|
||||
ASSIGN(_keyPaths, [coder decodeObjectForKey: @"NSKeyPaths"]);
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSValues"])
|
||||
{
|
||||
ASSIGN(_values, [coder decodeObjectForKey: @"NSValues"]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSIGN(_object, [coder decodeObject]);
|
||||
ASSIGN(_keyPaths, [coder decodeObject]);
|
||||
ASSIGN(_values, [coder decodeObject]);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) establishConnection
|
||||
{
|
||||
// Loop over key paths and values and use KVC on object
|
||||
NSEnumerator *keyEn = [_keyPaths objectEnumerator];
|
||||
NSEnumerator *valEn = [_values objectEnumerator];
|
||||
id key;
|
||||
|
||||
while ((key = [keyEn nextObject]) != nil)
|
||||
{
|
||||
id val = [valEn nextObject];
|
||||
|
||||
[_object setValue: val forKeyPath: key];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) instantiateWithObjectInstantiator: (id)instantiator
|
||||
{
|
||||
[self setObject: [(id<GSInstantiator>)instantiator instantiateObject: _object]];
|
||||
// FIXME Should handle values too
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -320,10 +320,19 @@ static void writer_func(png_structp png_struct, png_bytep data,
|
|||
NSNumber * gammaNumber = nil;
|
||||
double gamma = 0.0;
|
||||
|
||||
// FIXME: Need to convert to non-pre-multiplied format
|
||||
if ([self isPlanar]) // don't handle planar yet
|
||||
// Need to convert to non-pre-multiplied format
|
||||
if ([self isPlanar] || !(_format & NSAlphaNonpremultipliedBitmapFormat))
|
||||
{
|
||||
return nil;
|
||||
NSBitmapImageRep *converted = [self _convertToFormatBitsPerSample: _bitsPerSample
|
||||
samplesPerPixel: _numColors
|
||||
hasAlpha: _hasAlpha
|
||||
isPlanar: NO
|
||||
colorSpaceName: _colorSpace
|
||||
bitmapFormat: _format | NSAlphaNonpremultipliedBitmapFormat
|
||||
bytesPerRow: _bytesPerRow
|
||||
bitsPerPixel: _bitsPerPixel];
|
||||
|
||||
return [converted _PNGRepresentationWithProperties: properties];
|
||||
}
|
||||
// get the image parameters
|
||||
width = [self pixelsWide];
|
||||
|
|
Loading…
Reference in a new issue