Take over the Eggplant code for XIB document decoding,

with slight cleanups to get it working with gcc.
This commit is contained in:
fredkiefer 2019-12-08 23:47:53 +01:00
parent e1594a3105
commit 378c1c4077
14 changed files with 4104 additions and 149 deletions

3
.gitignore vendored
View file

@ -14,6 +14,7 @@ Headers/Additions/GNUstepGUI/GSVersion.h
Source/config.h
Source/Info-gnustep.plist
Tests/gui/*/GNUmakefile
*~
# Created by https://www.gitignore.io/api/xcode
# Edit at https://www.gitignore.io/?templates=xcode
@ -53,4 +54,4 @@ DerivedData/
### Xcode Patch ###
**/xcshareddata/WorkspaceSettings.xcsettings
# End of https://www.gitignore.io/api/xcode
# End of https://www.gitignore.io/api/xcode

View file

@ -77,9 +77,15 @@ typedef struct _GSWindowTemplateFlags
unsigned int autoPositionMask:6;
unsigned int savePosition:1;
unsigned int style:2;
unsigned int _unused:16; // currently not used, contains Cocoa specific info
unsigned int _unused2:3;
unsigned int isNotShadowed:1;
unsigned int autorecalculatesKeyViewLoop:1;
unsigned int _unused:11; // currently not used, contains Cocoa specific info
#else
unsigned int _unused:16; // currently not used, contains Cocoa specific info
unsigned int _unused:11; // currently not used, contains Cocoa specific info
unsigned int autorecalculatesKeyViewLoop:1;
unsigned int isNotShadowed:1;
unsigned int _unused2:3;
unsigned int style:2;
unsigned int savePosition:1;
unsigned int autoPositionMask:6;
@ -213,6 +219,7 @@ typedef struct _GSWindowTemplateFlags
- (NSString *)className;
- (void) setExtension: (NSString *)ext;
- (NSString *)extension;
- (void) setRealObject: (id)obj;
@end
@interface NSCustomView : NSView <GSNibLoading>

View file

@ -38,7 +38,7 @@
@interface GSXibElement: NSObject
{
NSString *type;
NSDictionary *attributes;
NSMutableDictionary *attributes;
NSString *value;
NSMutableDictionary *elements;
NSMutableArray *values;
@ -54,6 +54,7 @@
- (void) setElement: (GSXibElement*)element forKey: (NSString*)key;
- (void) setValue: (NSString*)text;
- (NSString*) attributeForKey: (NSString*)key;
- (void) setAttribute: (NSString*)attribute forKey: (NSString*)key;
- (GSXibElement*) elementForKey: (NSString*)key;
- (NSDictionary *) attributes;
@end

View file

@ -156,6 +156,24 @@ enum {
};
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
enum {
NSBackgroundStyleLight = 0,
NSBackgroundStyleDark = 1,
NSBackgroundStyleRaised = 2,
NSBackgroundStyleLowered = 3
};
typedef NSInteger NSBackgroundStyle;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_12, GS_API_LATEST)
enum __NSControlSize {
NSControlSizeRegular,
NSControlSizeSmall,
NSControlSizeMini
};
#endif
@interface NSCell : NSObject <NSCopying, NSCoding>
{
// Attributes
@ -188,7 +206,7 @@ enum {
unsigned allows_undo: 1;
unsigned line_break_mode: 3; // 6 values
// total 20 bits. 4 bits extension, 8 bits left.
// total 23 bits. 4 bits extension, 5 bits left.
int state: 2; // 3 values but one negative
unsigned mnemonic_location: 8;
unsigned control_tint: 3;
@ -204,6 +222,7 @@ enum {
unsigned in_editing: 1;
// Set if cell uses single line mode.
unsigned uses_single_line_mode:1;
unsigned background_style: 2; // 3 values
} _cell;
NSUInteger _mouse_down_flags;
NSUInteger _action_mask;
@ -455,6 +474,8 @@ enum {
ofView:(NSView *)controlView
untilMouseUp:(BOOL)flag;
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
- (NSBackgroundStyle)backgroundStyle;
- (void)setBackgroundStyle:(NSBackgroundStyle)backgroundStyle;
- (NSUInteger)hitTestForEvent:(NSEvent *)event
inRect:(NSRect)cellFrame
ofView:(NSView *)controlView;

View file

@ -96,22 +96,37 @@ enum {
enum {
NSBorderlessWindowMask = 0,
NSWindowStyleMaskBorderless = NSBorderlessWindowMask,
NSTitledWindowMask = 1,
NSClosableWindowMask = 2,
NSMiniaturizableWindowMask = 4,
NSResizableWindowMask = 8,
NSWindowStyleMaskTitled = NSTitledWindowMask,
NSClosableWindowMask = 1 << 1,
NSWindowStyleMaskClosable = NSClosableWindowMask,
NSMiniaturizableWindowMask = 1 << 2,
NSWindowStyleMaskMiniaturizable = NSMiniaturizableWindowMask,
NSResizableWindowMask = 1 << 3,
NSWindowStyleMaskResizable = NSResizableWindowMask,
NSWindowStyleMaskUtilityWindow = 1 << 4,
NSWindowStyleMaskDocModalWindow = 1 << 6,
NSWindowStyleMaskNonactivatingPanel = 1 << 7, // Specifies that a panel that does not activate the owning application
#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
NSTexturedBackgroundWindowMask = 256,
NSTexturedBackgroundWindowMask = 1 << 8,
NSWindowStyleMaskTexturedBackground = NSTexturedBackgroundWindowMask,
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
NSUnscaledWindowMask = 2048,
NSUnifiedTitleAndToolbarWindowMask = 4096,
NSUnscaledWindowMask = 1 << 11,
NSUnifiedTitleAndToolbarWindowMask = 1 << 12,
NSWindowStyleMaskUnifiedTitleAndToolbar = NSUnifiedTitleAndToolbarWindowMask,
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
NSWindowStyleMaskHUDWindow = 1 << 13,
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST)
NSFullScreenWindowMask = 16384,
NSFullScreenWindowMask = 1 << 14,
NSWindowStyleMaskFullScreen = NSFullScreenWindowMask,
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_10, GS_API_LATEST)
NSFullSizeContentViewWindowMask = 1 << 15,
NSWindowStyleMaskFullSizeContentView = NSFullSizeContentViewWindowMask,
#endif
NSIconWindowMask = 64, /* GNUstep extension - app icon window */
NSMiniWindowMask = 128 /* GNUstep extension - miniwindows */

View file

@ -308,6 +308,7 @@ GSXibElement.m \
GSXibLoader.m \
GSXibLoading.m \
GSXibKeyedUnarchiver.m \
GSXib5KeyedUnarchiver.m \
GSXibObjectContainer.m \
GSXibParser.m \
GSHelpAttachment.m

385
Source/GSCodingFlags.h Normal file
View file

@ -0,0 +1,385 @@
/*
GSCodingFlags.h
Define flags used in keyed coding. Extracted from existing files.
Copyright (C) 2019 Free Software Foundation, Inc.
Author: Fred Kiefer <fredkiefer@gmx.de>
Date: 12.2019
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _GNUstep_H_GSCodingFlags
#define _GNUstep_H_GSCodingFlags
#import "GNUstepGUI/GSNibLoading.h"
typedef struct _GSCellFlags {
#if GS_WORDS_BIGENDIAN == 1
unsigned int state:1;
unsigned int highlighted:1;
unsigned int disabled:1;
unsigned int editable:1;
NSCellType type:2;
unsigned int vCentered:1;
unsigned int hCentered:1;
unsigned int bordered:1;
unsigned int bezeled:1;
unsigned int selectable:1;
unsigned int scrollable:1;
unsigned int continuous:1;
unsigned int actOnMouseDown:1;
unsigned int isLeaf:1;
unsigned int invalidObjectValue:1;
unsigned int invalidFont:1;
NSLineBreakMode lineBreakMode:3;
unsigned int weakTargetHelperFlag:1;
unsigned int allowsAppearanceEffects:1;
unsigned int singleLineMode:1;
unsigned int actOnMouseDragged:1;
unsigned int isLoaded:1;
unsigned int truncateLastLine:1;
unsigned int dontActOnMouseUp:1;
unsigned int isWhite:1;
unsigned int useUserKeyEquivalent:1;
unsigned int showsFirstResponder:1;
unsigned int focusRingType:2;
#else
unsigned int focusRingType:2;
unsigned int showsFirstResponder:1;
unsigned int useUserKeyEquivalent:1;
unsigned int isWhite:1;
unsigned int dontActOnMouseUp:1;
unsigned int truncateLastLine:1;
unsigned int isLoaded:1;
unsigned int actOnMouseDragged:1;
unsigned int singleLineMode:1;
unsigned int allowsAppearanceEffects:1;
unsigned int weakTargetHelperFlag:1;
NSLineBreakMode lineBreakMode:3;
unsigned int invalidFont:1;
unsigned int invalidObjectValue:1;
unsigned int isLeaf:1;
unsigned int actOnMouseDown:1;
unsigned int continuous:1;
unsigned int scrollable:1;
unsigned int selectable:1;
unsigned int bezeled:1;
unsigned int bordered:1;
unsigned int hCentered:1;
unsigned int vCentered:1;
NSCellType type:2;
unsigned int editable:1;
unsigned int disabled:1;
unsigned int highlighted:1;
unsigned int state:1;
#endif
} GSCellFlags;
typedef union _GSCellFlagsUnion
{
GSCellFlags flags;
uint32_t value;
} GSCellFlagsUnion;
typedef struct _GSCellflags2
{
#if GS_WORDS_BIGENDIAN == 1
unsigned int unused1:1;
unsigned int allowsEditingTextAttributes:1;
unsigned int importsGraphics:1;
unsigned int alignment:3;
unsigned int refusesFirstResponder:1;
unsigned int allowsMixedState:1;
unsigned int unused2:1;
unsigned int sendsActionOnEndEditing:1;
unsigned int unused3:2;
unsigned int controlSize:3;
unsigned int unused4:4;
unsigned int doesNotAllowUndo:1;
unsigned int lineBreakMode:3;
unsigned int unused5:1;
unsigned int controlTint:3;
unsigned int unused6:5;
#else
unsigned int unused6:5;
unsigned int controlTint:3;
unsigned int unused5:1;
unsigned int lineBreakMode:3;
unsigned int doesNotAllowUndo:1;
unsigned int unused4:4;
unsigned int controlSize:3;
unsigned int unused3:2;
unsigned int sendsActionOnEndEditing:1;
unsigned int unused2:1;
unsigned int allowsMixedState:1;
unsigned int refusesFirstResponder:1;
unsigned int alignment:3;
unsigned int importsGraphics:1;
unsigned int allowsEditingTextAttributes:1;
unsigned int unused1:1;
#endif
} GSCellFlags2;
typedef union _GSCellFlags2Union
{
GSCellFlags2 flags;
uint32_t value;
} GSCellFlags2Union;
typedef struct _GSButtonCellFlags
{
#if GS_WORDS_BIGENDIAN == 1
unsigned int isPushin:1;
unsigned int changeContents:1;
unsigned int changeBackground:1;
unsigned int changeGray:1;
unsigned int highlightByContents:1;
unsigned int highlightByBackground:1;
unsigned int highlightByGray:1;
unsigned int drawing:1;
unsigned int isBordered:1;
unsigned int imageDoesOverlap:1;
unsigned int isHorizontal:1;
unsigned int isBottomOrLeft:1;
unsigned int isImageAndText:1;
unsigned int isImageSizeDiff:1;
unsigned int hasKeyEquiv:1;
unsigned int lastState:1;
unsigned int isTransparent:1;
unsigned int inset:2; // inset:2
unsigned int doesNotDimImage:1; //doesn't dim:1
unsigned int gradient:3; // gradient:3
unsigned int useButtonImageSource:1;
unsigned int unused2:8; // alt mnemonic loc.
#else
unsigned int unused2:8; // alt mnemonic loc.
unsigned int useButtonImageSource:1;
unsigned int gradient:3; // gradient:3
unsigned int doesNotDimImage:1; // doesn't dim:1
unsigned int inset:2; // inset:2
unsigned int isTransparent:1;
unsigned int lastState:1;
unsigned int hasKeyEquiv:1;
unsigned int isImageSizeDiff:1;
unsigned int isImageAndText:1;
unsigned int isBottomOrLeft:1;
unsigned int isHorizontal:1;
unsigned int imageDoesOverlap:1;
unsigned int isBordered:1;
unsigned int drawing:1;
unsigned int highlightByGray:1;
unsigned int highlightByBackground:1;
unsigned int highlightByContents:1;
unsigned int changeGray:1;
unsigned int changeBackground:1;
unsigned int changeContents:1;
unsigned int isPushin:1;
#endif
} GSButtonCellFlags;
typedef union _GSButtonCellFlagsUnion
{
GSButtonCellFlags flags;
uint32_t value;
} GSButtonCellFlagsUnion;
typedef struct _GSButtonCellFlags2 {
#if GS_WORDS_BIGENDIAN == 1
unsigned int keyEquivalentModifierMask:24;
unsigned int imageScaling:2;
unsigned int bezelStyle2:1;
unsigned int mouseInside:1;
unsigned int showsBorderOnlyWhileMouseInside:1;
unsigned int bezelStyle:3;
#else
unsigned int bezelStyle:3;
unsigned int showsBorderOnlyWhileMouseInside:1;
unsigned int mouseInside:1;
unsigned int bezelStyle2:1;
unsigned int imageScaling:2;
unsigned int keyEquivalentModifierMask:24;
#endif
} GSButtonCellFlags2;
typedef union _GSButtonCellFlags2Union
{
GSButtonCellFlags2 flags;
uint32_t value;
} GSButtonCellFlags2Union;
typedef struct _GSvFlags
{
#if GS_WORDS_BIGENDIAN == 1
unsigned int isHidden:1;
unsigned int unused1:3;
unsigned int unused2:4;
unsigned int unused3:4;
unsigned int unused4:4;
unsigned int unused5:4;
unsigned int unused6:3;
unsigned int autoresizesSubviews:1;
unsigned int unused7:2;
unsigned int autoresizingMask:6;
#else
unsigned int autoresizingMask:6;
unsigned int unused7:2;
unsigned int autoresizesSubviews:1;
unsigned int unused6:3;
unsigned int unused5:4;
unsigned int unused4:4;
unsigned int unused3:4;
unsigned int unused2:4;
unsigned int unused1:3;
unsigned int isHidden:1;
#endif
} GSvFlags;
typedef union _GSvFlagsUnion
{
GSvFlags flags;
uint32_t value;
} GSvFlagsUnion;
typedef struct _GSTabViewTypeFlags
{
#if GS_WORDS_BIGENDIAN == 1
unsigned int reserved1:1;
unsigned int controlTint:3;
unsigned int controlSize:2;
unsigned int reserved2:18;
unsigned int tabPosition:5;
unsigned int tabViewBorderType:3;
#else
unsigned int tabViewBorderType:3;
unsigned int tabPosition:5;
unsigned int reserved2:18;
unsigned int controlSize:2;
unsigned int controlTint:3;
unsigned int reserved1:1;
#endif
} GSTabViewTypeFlags;
typedef union _GSTabViewTypeFlagsUnion
{
GSTabViewTypeFlags flags;
unsigned int value;
} GSTabViewTypeFlagsUnion;
/*
* Nib compatibility struct. This structure is used to
* pull the attributes out of the nib that we need to fill
* in the flags.
*/
typedef struct _tableViewFlags
{
#if GS_WORDS_BIGENDIAN == 1
unsigned int columnOrdering:1;
unsigned int columnResizing:1;
unsigned int drawsGrid:1;
unsigned int emptySelection:1;
unsigned int multipleSelection:1;
unsigned int columnSelection:1;
unsigned int unknown1:1;
unsigned int columnAutosave:1;
unsigned int alternatingRowBackgroundColors:1;
unsigned int unknown2:3;
unsigned int _unused:20;
#else
unsigned int _unused:20;
unsigned int unknown2:3;
unsigned int alternatingRowBackgroundColors:1;
unsigned int columnAutosave:1;
unsigned int unknown1:1;
unsigned int columnSelection:1;
unsigned int multipleSelection:1;
unsigned int emptySelection:1;
unsigned int drawsGrid:1;
unsigned int columnResizing:1;
unsigned int columnOrdering:1;
#endif
} GSTableViewFlags;
typedef union _GSTableViewFlagsUnion
{
GSTableViewFlags flags;
uint32_t value;
} GSTableViewFlagsUnion;
typedef union _GSWindowTemplateFlagsUnion
{
GSWindowTemplateFlags flags;
uint32_t value;
} GSWindowTemplateFlagsUnion;
typedef struct _GSMatrixFlags {
#if GS_WORDS_BIGENDIAN == 1
unsigned int isHighlight:1;
unsigned int isRadio:1;
unsigned int isList:1;
unsigned int allowsEmptySelection:1;
unsigned int autoScroll:1;
unsigned int selectionByRect:1;
unsigned int drawCellBackground:1;
unsigned int drawBackground:1;
unsigned int autosizesCells:1;
unsigned int drawingAncestor:1;
unsigned int tabKeyTraversesCells:1;
unsigned int tabKeyTraversesCellsExplicitly:1;
unsigned int canSearchIncrementally:1;
unsigned int unused:19;
#else
unsigned int unused:19;
unsigned int canSearchIncrementally:1;
unsigned int tabKeyTraversesCellsExplicitly:1;
unsigned int tabKeyTraversesCells:1;
unsigned int drawingAncestor:1;
unsigned int autosizesCells:1;
unsigned int drawBackground:1;
unsigned int drawCellBackground:1;
unsigned int selectionByRect:1;
unsigned int autoScroll:1;
unsigned int allowsEmptySelection:1;
unsigned int isList:1;
unsigned int isRadio:1;
unsigned int isHighlight:1;
#endif
} GSMatrixFlags;
typedef union _GSMatrixFlagsUnion
{
GSMatrixFlags flags;
unsigned int value;
} GSMatrixFlagsUnion;
#endif // _GNUstep_H_GSCodingFlags

View file

@ -0,0 +1,46 @@
/** <title>GSXibParserDelegate.h</title>
<abstract>The XIB 5 keyed unarchiver</abstract>
Copyright (C) 2016,2017 Free Software Foundation, Inc.
Author: Marcian Lytwyn <gnustep@advcsi.com>
Date: 12/28/16
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#import <Foundation/Foundation.h>
#import "GNUstepGUI/GSXibKeyedUnarchiver.h"
@class GSXibElement;
@interface GSXib5KeyedUnarchiver : GSXibKeyedUnarchiver
{
GSXibElement *_IBObjectContainer;
GSXibElement *_connectionRecords;
GSXibElement *_objectRecords;
GSXibElement *_orderedObjects;
GSXibElement *_flattenedProperties;
GSXibElement *_runtimeAttributes;
NSMutableDictionary *_orderedObjectsDict;
}
- (NSRange) decodeRangeForKey: (NSString*)key;
@end

File diff suppressed because it is too large Load diff

View file

@ -38,7 +38,7 @@
andAttributes: (NSDictionary*)attribs
{
ASSIGN(type, typeName);
ASSIGN(attributes, attribs);
attributes = [attribs mutableCopy];
elements = [[NSMutableDictionary alloc] init];
values = [[NSMutableArray alloc] init];
@ -95,6 +95,11 @@
return [attributes objectForKey: key];
}
- (void) setAttribute: (NSString*)attribute forKey: (NSString*)key
{
[attributes setObject: attribute forKey: key];
}
- (GSXibElement*) elementForKey: (NSString*)key
{
return [elements objectForKey: key];

View file

@ -49,6 +49,7 @@
#import "GNUstepGUI/GSXibObjectContainer.h"
#import "GNUstepGUI/GSXibElement.h"
#import "GNUstepGUI/GSXibKeyedUnarchiver.h"
#import "GSXib5KeyedUnarchiver.h"
@interface NSApplication (NibCompatibility)
- (void) _setMainMenu: (NSMenu*)aMenu;
@ -105,7 +106,7 @@
}
else
{
[NSException raise: NSInvalidArgumentException
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
@ -150,7 +151,7 @@
}
else
{
[NSException raise: NSInvalidArgumentException
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
@ -182,7 +183,7 @@
}
else
{
[NSException raise: NSInvalidArgumentException
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
@ -218,7 +219,7 @@
}
else
{
[NSException raise: NSInvalidArgumentException
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
@ -272,10 +273,19 @@
[result setDestination: [self destination]];
[result setSource: [self source]];
[result setLabel: [self label]];
return result;
}
- (NSString*) description
{
NSMutableString *description = [[super description] mutableCopy];
[description appendFormat: @" - label: %@: ", label];
[description appendFormat: @" source: %@: ", NSStringFromClass([source class])];
[description appendFormat: @" destination: %@: ", NSStringFromClass([destination class])];
return AUTORELEASE(description);
}
- (id) nibInstantiate
{
if ([source respondsToSelector: @selector(nibInstantiate)])
@ -301,7 +311,7 @@
- (void) establishConnection
{
SEL sel = NSSelectorFromString(label);
[destination setTarget: source];
[destination setAction: sel];
}
@ -317,33 +327,39 @@
if (source != nil)
{
NSString *selName;
SEL sel;
selName = [NSString stringWithFormat: @"set%@%@:",
[[label substringToIndex: 1] uppercaseString],
[label substringFromIndex: 1]];
sel = NSSelectorFromString(selName);
if (sel && [source respondsToSelector: sel])
{
[source performSelector: sel withObject: destination];
}
else
{
SEL sel;
selName = [NSString stringWithFormat: @"set%@%@:",
[[label substringToIndex: 1] uppercaseString],
[label substringFromIndex: 1]];
sel = NSSelectorFromString(selName);
if (sel && [source respondsToSelector: sel])
{
[source performSelector: sel withObject: destination];
}
else
{
/*
* We cannot use the KVC mechanism here, as this would always retain _dst
* and it could also affect _setXXX methods and _XXX ivars that aren't
* affected by the Cocoa code.
*/
*/
const char *name = [label cString];
Class class = object_getClass(source);
Ivar ivar = class_getInstanceVariable(class, name);
if (ivar != 0)
{
object_setIvar(source, ivar, destination);
}
}
#if defined(DEBUG)
else
{
NSWarnMLog(@"class '%@' has no instance var named: %@", NSStringFromClass(class), label);
}
#endif
}
}
}
NS_HANDLER
@ -411,7 +427,7 @@
[NSException raise: NSInvalidArgumentException
format: @"%@", format];
}
// Load the connection ID....
if ([coder containsValueForKey: @"connectionID"])
{
@ -446,7 +462,7 @@
}
else
{
[NSException raise: NSInvalidArgumentException
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
@ -503,7 +519,7 @@
}
else
{
[NSException raise: NSInvalidArgumentException
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
@ -541,7 +557,7 @@
}
else
{
[NSException raise: NSInvalidArgumentException
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
@ -583,7 +599,7 @@
[NSException raise: NSInvalidArgumentException
format: @"%@", format];
}
if ([coder containsValueForKey: @"object"])
{
ASSIGN(object, [coder decodeObjectForKey: @"object"]);
@ -599,7 +615,7 @@
}
else
{
[NSException raise: NSInvalidArgumentException
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
@ -652,7 +668,7 @@
}
else
{
[NSException raise: NSInvalidArgumentException
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
@ -718,7 +734,7 @@
}
else
{
[NSException raise: NSInvalidArgumentException
[NSException raise: NSInvalidArgumentException
format: @"Can't decode %@ with %@.",NSStringFromClass([self class]),
NSStringFromClass([coder class])];
}
@ -742,6 +758,17 @@
[super dealloc];
}
- (NSString*) description
{
NSMutableString *description = [[super description] mutableCopy];
[description appendFormat: @" - sourceID: %@: ", sourceID];
[description appendFormat: @" maxID: %@: ", maxID];
[description appendFormat: @" objectRecords: %@: ", objectRecords];
[description appendFormat: @" flattenedProperties: %@: ", flattenedProperties];
[description appendFormat: @" connectionRecords: %@: ", connectionRecords];
return AUTORELEASE(description);
}
- (NSEnumerator*) connectionRecordEnumerator
{
return [connectionRecords objectEnumerator];
@ -833,7 +860,7 @@
}
properties = [self propertiesForObjectID: [obj objectID]];
NSDebugLLog(@"XIB", @"object %ld props %@", (long)[obj objectID], properties);
NSDebugLLog(@"XIB", @"object %@ props %@", [obj objectID], properties);
//value = [properties objectForKey: @"windowTemplate.maxSize"];
//value = [properties objectForKey: @"CustomClassName"];
@ -857,7 +884,7 @@
if (value != nil)
{
NSDictionary *infodict = (NSDictionary*)value;
// Process tooltips...
IBToolTipAttribute *tooltip = [infodict objectForKey: @"ToolTip"];
@ -865,7 +892,7 @@
{
[realObj setToolTip: [tooltip toolTip]];
}
// Process XIB runtime attributes...
if ([infodict objectForKey:@"IBUserDefinedRuntimeAttributesPlaceholderName"])
{
@ -874,7 +901,7 @@
NSArray *attributes = [placeholder runtimeAttributes];
NSEnumerator *objectIter = [attributes objectEnumerator];
IBUserDefinedRuntimeAttribute *attribute;
while ((attribute = [objectIter nextObject]) != nil)
{
[realObj setValue: [attribute value] forKeyPath: [attribute keyPath]];
@ -910,8 +937,7 @@
return 4.0;
}
- (void) awake: (NSArray *)rootObjects
inContainer: (id)objects
- (void) awake: (NSArray *)rootObjects
withContext: (NSDictionary *)context
{
NSEnumerator *en;
@ -923,6 +949,12 @@
NSCustomObject *object;
NSString *className;
if ([rootObjects count] == 0)
{
NSWarnMLog(@"no root objects!!!");
return;
}
// Get the file's owner and NSApplication object references...
object = (NSCustomObject*)[rootObjects objectAtIndex: 1];
if ([[object className] isEqualToString: @"FirstResponder"])
@ -974,9 +1006,16 @@
[NSApp _setMainMenu: obj];
}
}
}
- (void) awake: (NSArray *)rootObjects
inContainer: (id)objects
withContext: (NSDictionary *)context
{
[self awake: rootObjects withContext: context];
// Load connections and awaken objects
if ([objects respondsToSelector:@selector(nibInstantiate)])
if ([objects respondsToSelector: @selector(nibInstantiate)])
{
[objects nibInstantiate];
}
@ -993,7 +1032,15 @@
{
if (data != nil)
{
unarchiver = [[GSXibKeyedUnarchiver alloc] initForReadingWithData: data];
// We now default to checking XIB 5 versions first...
unarchiver = [[GSXib5KeyedUnarchiver alloc] initForReadingWithData: data];
// If that doesn't work try the XIB 5 loader...
if (unarchiver == nil)
{
unarchiver = [[GSXibKeyedUnarchiver alloc] initForReadingWithData: data];
}
if (unarchiver != nil)
{
NSArray *rootObjects;
@ -1004,28 +1051,15 @@
rootObjects = [unarchiver decodeObjectForKey: @"IBDocument.RootObjects"];
objects = [unarchiver decodeObjectForKey: @"IBDocument.Objects"];
NSDebugLLog(@"XIB", @"rootObjects %@", rootObjects);
[self awake: rootObjects
inContainer: objects
[self awake: rootObjects
inContainer: objects
withContext: context];
loaded = YES;
RELEASE(unarchiver);
}
else
{
GSXibParser *parser = [[GSXibParser alloc] initWithData: data];
NSDictionary *result = [parser parse];
if (result != nil)
{
NSArray *rootObjects = [result objectForKey: @"IBDocument.RootObjects"];
GSXibObjectContainer *objects = [result objectForKey: @"IBDocument.Objects"];
[self awake: rootObjects
inContainer: objects
withContext: context];
}
else
{
NSLog(@"Could not instantiate Xib unarchiver/Unable to parse Xib.");
}
NSLog(@"Could not instantiate Xib unarchiver/Unable to parse Xib.");
}
}
else

View file

@ -56,56 +56,10 @@
#import "GNUstepGUI/GSTheme.h"
#import "GNUstepGUI/GSNibLoading.h"
#import "GSGuiPrivate.h"
#import "GSCodingFlags.h"
#include <math.h>
typedef struct _GSButtonCellFlags
{
#if GS_WORDS_BIGENDIAN == 1
unsigned int isPushin:1;
unsigned int changeContents:1;
unsigned int changeBackground:1;
unsigned int changeGray:1;
unsigned int highlightByContents:1;
unsigned int highlightByBackground:1;
unsigned int highlightByGray:1;
unsigned int drawing:1;
unsigned int isBordered:1;
unsigned int imageDoesOverlap:1;
unsigned int isHorizontal:1;
unsigned int isBottomOrLeft:1;
unsigned int isImageAndText:1;
unsigned int isImageSizeDiff:1;
unsigned int hasKeyEquiv:1;
unsigned int lastState:1;
unsigned int isTransparent:1;
unsigned int unused1:6; // inset:2 doesn't dim:1 gradient:3
unsigned int useButtonImageSource:1;
unsigned int unused2:8; // alt mnemonic loc.
#else
unsigned int unused2:8; // alt mnemonic loc.
unsigned int useButtonImageSource:1;
unsigned int unused1:6; // inset:2 doesn't dim:1 gradient:3
unsigned int isTransparent:1;
unsigned int lastState:1;
unsigned int hasKeyEquiv:1;
unsigned int isImageSizeDiff:1;
unsigned int isImageAndText:1;
unsigned int isBottomOrLeft:1;
unsigned int isHorizontal:1;
unsigned int imageDoesOverlap:1;
unsigned int isBordered:1;
unsigned int drawing:1;
unsigned int highlightByGray:1;
unsigned int highlightByBackground:1;
unsigned int highlightByContents:1;
unsigned int changeGray:1;
unsigned int changeBackground:1;
unsigned int changeContents:1;
unsigned int isPushin:1;
#endif
} GSButtonCellFlags;
@interface NSCell (Private)
- (NSSize) _scaleImageWithSize: (NSSize)imageSize
toFitInSize: (NSSize)canvasSize
@ -1674,7 +1628,9 @@ typedef struct _GSButtonCellFlags
buttonCellFlags.changeGray = [self cellAttribute: NSChangeGrayCell];
// set these to zero...
buttonCellFlags.unused1 = 0; // 32;
buttonCellFlags.inset = 0; // 32;
buttonCellFlags.doesNotDimImage = 0; // 32;
buttonCellFlags.gradient = 0; // 32;
buttonCellFlags.unused2 = 0; // 255;
buttonCellFlags.lastState = 0;
buttonCellFlags.isImageSizeDiff = 0;

View file

@ -1577,6 +1577,16 @@ static NSColor *dtxtCol;
ASSIGN (_represented_object, anObject);
}
- (NSBackgroundStyle)backgroundStyle
{
return(_cell.background_style);
}
- (void)setBackgroundStyle:(NSBackgroundStyle)backgroundStyle
{
_cell.background_style = backgroundStyle;
}
/**<p>Returns the mouse flags. This flags are usally sets in
the -trackMouse:inRect:ofView:untilMouseUp: method</p>
*/
@ -2480,6 +2490,7 @@ static NSColor *dtxtCol;
// flags part 2
cFlags2 |= ([self usesSingleLineMode] ? 0x40 : 0);
cFlags2 |= (([self allowsUndo] == NO) ? 0x1000 : 0);
cFlags2 |= ([self controlTint] << 5);
cFlags2 |= ([self lineBreakMode] << 9);
cFlags2 |= ([self controlSize] << 17);

View file

@ -76,6 +76,7 @@
#import "AppKit/NSKeyValueBinding.h"
#import "AppKit/NSMatrix.h"
#import "AppKit/NSWindow.h"
#import "GSCodingFlags.h"
#include <math.h>
@ -129,40 +130,6 @@ typedef struct {
NSInteger height;
} MRect;
typedef struct _GSMatrixFlags {
#if GS_WORDS_BIGENDIAN == 1
unsigned int isHighlight:1;
unsigned int isRadio:1;
unsigned int isList:1;
unsigned int allowsEmptySelection:1;
unsigned int autoScroll:1;
unsigned int selectionByRect:1;
unsigned int drawCellBackground:1;
unsigned int drawBackground:1;
unsigned int autosizesCells:1;
unsigned int drawingAncestor:1;
unsigned int tabKeyTraversesCells:1;
unsigned int tabKeyTraversesCellsExplicitly:1;
unsigned int canSearchIncrementally:1;
unsigned int unused:19;
#else
unsigned int unused:19;
unsigned int canSearchIncrementally:1;
unsigned int tabKeyTraversesCellsExplicitly:1;
unsigned int tabKeyTraversesCells:1;
unsigned int drawingAncestor:1;
unsigned int autosizesCells:1;
unsigned int drawBackground:1;
unsigned int drawCellBackground:1;
unsigned int selectionByRect:1;
unsigned int autoScroll:1;
unsigned int allowsEmptySelection:1;
unsigned int isList:1;
unsigned int isRadio:1;
unsigned int isHighlight:1;
#endif
} GSMatrixFlags;
static inline MPoint MakePoint (NSInteger x, NSInteger y)
{
MPoint point = { x, y };