* Source/NSButtonCell.m (-initWithCoder:):

Fix image scaling value extract from XIB.
        * Headers/Additions/GNUstepGUI/GSXibLoading.h
        * Source/GSXibLoading.m
        * Source/GSXibLoader.m
        Add IB defined runtime attribute processing for XIB
        Patch by Marcian Lytwyn <gna@advcsi.com>.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@38882 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2015-08-13 22:03:03 +00:00
parent f922f3a5a5
commit 3920ffef1c
5 changed files with 122 additions and 36 deletions

View file

@ -1,3 +1,13 @@
2015-08-13 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSButtonCell.m (-initWithCoder:):
Fix image scaling value extract from XIB.
* Headers/Additions/GNUstepGUI/GSXibLoading.h
* Source/GSXibLoading.m
* Source/GSXibLoader.m
Add IB defined runtime attribute processing for XIB
Patch by Marcian Lytwyn <gna@advcsi.com>.
2015-08-11 Fred Kiefer <FredKiefer@gmx.de> 2015-08-11 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSTextView.m: Rewrite * Source/NSTextView.m: Rewrite

View file

@ -37,6 +37,7 @@
@class NSString, NSDictionary, NSArray, NSMutableDictionary, NSMutableArray; @class NSString, NSDictionary, NSArray, NSMutableDictionary, NSMutableArray;
@class NSNibBindingConnector; @class NSNibBindingConnector;
@class GSXibElement; @class GSXibElement;
@class NSNibConnector;
// Hack: This allows the class name FirstResponder in NSCustomObject and // Hack: This allows the class name FirstResponder in NSCustomObject and
// correctly returns nil as the corresponding object. // correctly returns nil as the corresponding object.
@ -158,6 +159,39 @@
- (NSEnumerator *) objectRecordEnumerator; - (NSEnumerator *) objectRecordEnumerator;
@end @end
@interface IBUserDefinedRuntimeAttributesPlaceholder : NSObject <NSCoding>
{
NSArray *runtimeAttributes;
NSString *name;
}
- (void) setName: (NSString *)name;
- (NSString *) name;
- (void) setRuntimeAttributes: (NSArray *)attributes;
- (NSArray *) runtimeAttributes;
@end
@interface IBUserDefinedRuntimeAttribute : NSObject <NSCoding>
{
NSString *typeIdentifier;
NSString *keyPath;
id value;
}
- (void) setTypeIdentifier: (NSString *)type;
- (NSString *) typeIdentifier;
- (void) setKeyPath: (NSString *)keyPath;
- (NSString *) keyPath;
- (void) setValue: (id)value;
- (id) value;
@end
@interface GSXibKeyedUnarchiver: NSKeyedUnarchiver @interface GSXibKeyedUnarchiver: NSKeyedUnarchiver
{ {
NSMutableDictionary *objects; NSMutableDictionary *objects;

View file

@ -32,6 +32,7 @@
#import <Foundation/NSException.h> #import <Foundation/NSException.h>
#import <Foundation/NSFileManager.h> #import <Foundation/NSFileManager.h>
#import <Foundation/NSKeyedArchiver.h> #import <Foundation/NSKeyedArchiver.h>
#import <Foundation/NSKeyValueCoding.h>
#import <Foundation/NSString.h> #import <Foundation/NSString.h>
#import <Foundation/NSValue.h> #import <Foundation/NSValue.h>
#import <Foundation/NSXMLParser.h> #import <Foundation/NSXMLParser.h>
@ -857,11 +858,29 @@
value = [properties objectForKey: @"IBAttributePlaceholdersKey"]; value = [properties objectForKey: @"IBAttributePlaceholdersKey"];
if (value != nil) if (value != nil)
{ {
IBToolTipAttribute *tta = [(NSDictionary*)value objectForKey: @"ToolTip"]; NSDictionary *infodict = (NSDictionary*)value;
// Process tooltips...
IBToolTipAttribute *tooltip = [infodict objectForKey: @"ToolTip"];
if ([realObj respondsToSelector: @selector(setToolTip:)]) if (tooltip && [realObj respondsToSelector: @selector(setToolTip:)])
{ {
[realObj setToolTip: [tta toolTip]]; [realObj setToolTip: [tooltip toolTip]];
}
// Process XIB runtime attributes...
if ([infodict objectForKey:@"IBUserDefinedRuntimeAttributesPlaceholderName"])
{
IBUserDefinedRuntimeAttributesPlaceholder *placeholder =
[infodict objectForKey:@"IBUserDefinedRuntimeAttributesPlaceholderName"];
NSArray *attributes = [placeholder runtimeAttributes];
NSEnumerator *objectIter = [attributes objectEnumerator];
IBUserDefinedRuntimeAttribute *attribute;
while ((attribute = [objectIter nextObject]) != nil)
{
[realObj setValue: [attribute value] forKeyPath: [attribute keyPath]];
}
} }
} }

View file

@ -1,24 +1,7 @@
#import <Foundation/NSObject.h> #import <Foundation/NSObject.h>
#import <Foundation/NSKeyedArchiver.h> #import <Foundation/NSKeyedArchiver.h>
#import "GNUstepGUI/GSXibElement.h" #import "GNUstepGUI/GSXibElement.h"
#import "GNUstepGUI/GSXibLoading.h"
@interface IBUserDefinedRuntimeAttributesPlaceholder : NSObject <NSCoding>
{
NSString *typeIdentifier;
NSString *keyPath;
id value;
}
- (void) setTypeIdentifier: (NSString *)type;
- (NSString *) typeIdentifier;
- (void) setKeyPath: (NSString *)keyPath;
- (NSString *) keyPath;
- (void) setValue: (id)value;
- (id) value;
@end
@interface IBAccessibilityAttribute : NSObject <NSCoding> @interface IBAccessibilityAttribute : NSObject <NSCoding>
@end @end
@ -29,20 +12,17 @@
@interface IBLayoutConstant : NSObject <NSCoding> @interface IBLayoutConstant : NSObject <NSCoding>
@end @end
@implementation IBUserDefinedRuntimeAttributesPlaceholder @implementation IBUserDefinedRuntimeAttribute
- (void) encodeWithCoder: (NSCoder *)coder - (void) encodeWithCoder: (NSCoder *)coder
{ {
if([coder allowsKeyedCoding]) if([coder allowsKeyedCoding])
{ {
[coder encodeObject: typeIdentifier [coder encodeObject: typeIdentifier forKey: @"typeIdentifier"];
forKey: @"typeIdentifier"]; [coder encodeObject: keyPath forKey: @"keyPath"];
[coder encodeObject: keyPath [coder encodeObject: value forKey: @"value"];
forKey: @"keyPath"]; }
[coder encodeObject: value }
forKey: @"value"];
}
}
- (id) initWithCoder: (NSCoder *)coder - (id) initWithCoder: (NSCoder *)coder
{ {
@ -87,6 +67,49 @@
@end @end
@implementation IBUserDefinedRuntimeAttributesPlaceholder
- (void) encodeWithCoder: (NSCoder *)coder
{
if([coder allowsKeyedCoding])
{
[coder encodeObject: name forKey: @"IBUserDefinedRuntimeAttributesPlaceholderName"];
[coder encodeObject: runtimeAttributes forKey: @"userDefinedRuntimeAttributes"];
}
}
- (id) initWithCoder: (NSCoder *)coder
{
if([coder allowsKeyedCoding])
{
[self setName: [coder decodeObjectForKey: @"IBUserDefinedRuntimeAttributesPlaceholderName"]];
[self setRuntimeAttributes: [coder decodeObjectForKey: @"userDefinedRuntimeAttributes"]];
}
return self;
}
- (void) setName: (NSString *)value
{
ASSIGN(name, value);
}
- (NSString *) name
{
return name;
}
- (void) setRuntimeAttributes: (NSArray *)attrbutes
{
ASSIGN(runtimeAttributes, attrbutes);
}
- (NSArray *) runtimeAttributes
{
return runtimeAttributes;
}
@end
@implementation IBAccessibilityAttribute @implementation IBAccessibilityAttribute
- (void) encodeWithCoder: (NSCoder *)coder - (void) encodeWithCoder: (NSCoder *)coder

View file

@ -1877,7 +1877,7 @@ typedef struct _GSButtonCellFlags
[self setKeyEquivalentModifierMask: ((bFlags2 >> 8) & [self setKeyEquivalentModifierMask: ((bFlags2 >> 8) &
NSDeviceIndependentModifierFlagsMask)]; NSDeviceIndependentModifierFlagsMask)];
switch (bFlags2 & (3 << 6)) switch ((bFlags2 >> 6) & 3)
{ {
case 2: case 2:
imageScale = NSImageScaleProportionallyDown; imageScale = NSImageScaleProportionallyDown;