mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Correction for GSNibCompatibility. Added coding to classes for keyed archiving.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23225 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
dc4a427c47
commit
84d0296b74
11 changed files with 227 additions and 91 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2006-08-08 21:33-EDT Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Headers/Additions/GNUstepGUI/GSNibCompatibility.h
|
||||
* Source/GSNibCompatibility.m: Fix for window size issue caused
|
||||
by previous change.
|
||||
* Source/NSBitmapImageRep.m
|
||||
* Source/NSBox.m
|
||||
* Source/NSButtonCell.m
|
||||
* Source/NSCachedImageRep.m
|
||||
* Source/NSImage.m
|
||||
* Source/NSTabViewItem.m
|
||||
* Source/NSTabView.m
|
||||
* Source/NSTextFieldCell.m: Added encoding in encodeWithCoder:
|
||||
|
||||
2006-08-09 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Headers/AppKit/NSStepper.h
|
||||
|
|
|
@ -82,6 +82,17 @@ typedef struct _GSWindowTemplateFlags
|
|||
@interface NSIBHelpConnector : NSNibConnector
|
||||
@end
|
||||
|
||||
/**
|
||||
* Button image source class.
|
||||
*/
|
||||
@interface NSButtonImageSource : NSObject <NSCoding>
|
||||
{
|
||||
NSString *imageName;
|
||||
}
|
||||
- (id) initWithImageNamed: (NSString *)name;
|
||||
- (NSString *)imageName;
|
||||
@end
|
||||
|
||||
/**
|
||||
* This class acts as a placeholder for the window. It doesn't derive from
|
||||
* NSWindow for two reasons. First, it shouldn't instantiate a window immediately
|
||||
|
|
|
@ -186,7 +186,7 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
}
|
||||
if ([coder containsValueForKey: @"NSWindowRect"])
|
||||
{
|
||||
_windowRect = [coder decodeRectForKey: @"NSWindowRect"];
|
||||
_windowRect = [coder decodeRectForKey: @"NSWindowRect"];
|
||||
}
|
||||
if ([coder containsValueForKey: @"NSFrameAutosaveName"])
|
||||
{
|
||||
|
@ -214,7 +214,8 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
unsigned long flags = 0;
|
||||
|
||||
NSRect rect = [NSWindow contentRectForFrameRect: _windowRect
|
||||
styleMask: _windowStyle];
|
||||
memcpy((void *)&flags,(void *)&_flags,sizeof(unsigned long));
|
||||
|
||||
[aCoder encodeObject: _viewClass forKey: @"NSViewClass"];
|
||||
|
@ -225,7 +226,7 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
[aCoder encodeInt: flags forKey: @"NSWTFlags"];
|
||||
[aCoder encodeSize: _minSize forKey: @"NSMinSize"];
|
||||
[aCoder encodeSize: _maxSize forKey: @"NSMaxSize"];
|
||||
[aCoder encodeRect: _windowRect forKey: @"NSWindowRect"];
|
||||
[aCoder encodeRect: rect forKey: @"NSWindowRect"];
|
||||
[aCoder encodeObject: _title forKey: @"NSWindowTitle"];
|
||||
[aCoder encodeObject: _autosaveName forKey: @"NSFrameAutosaveName"];
|
||||
}
|
||||
|
@ -283,9 +284,10 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
[_view _fixSubviews];
|
||||
|
||||
// resize the window...
|
||||
[_realObject setFrame: [self windowRect]
|
||||
[_realObject setFrame: [NSWindow frameRectForContentRect: [self windowRect]
|
||||
styleMask: [self windowStyle]]
|
||||
display: NO];
|
||||
|
||||
|
||||
// swap out any views which need to be swapped...
|
||||
en = [[[_realObject contentView] subviews] objectEnumerator];
|
||||
while((v = [en nextObject]) != nil)
|
||||
|
@ -1386,13 +1388,6 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
}
|
||||
@end
|
||||
|
||||
@interface NSButtonImageSource : NSObject <NSCoding>
|
||||
{
|
||||
NSString *imageName;
|
||||
}
|
||||
- (NSString *)imageName;
|
||||
@end
|
||||
|
||||
@implementation NSButtonImageSource
|
||||
- (id) initWithCoder: (NSCoder *)coder
|
||||
{
|
||||
|
@ -1425,6 +1420,15 @@ static BOOL _isInInterfaceBuilder = NO;
|
|||
}
|
||||
}
|
||||
|
||||
- (id) initWithImageNamed: (NSString *)name
|
||||
{
|
||||
if((self = [super init]) != nil)
|
||||
{
|
||||
ASSIGN(imageName,name);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)imageName
|
||||
{
|
||||
return imageName;
|
||||
|
|
|
@ -948,7 +948,14 @@ static BOOL supports_lzw_compression = NO;
|
|||
NSData *data = [self TIFFRepresentation];
|
||||
|
||||
[super encodeWithCoder: aCoder];
|
||||
[aCoder encodeObject: data];
|
||||
if([aCoder allowsKeyedCoding])
|
||||
{
|
||||
[aCoder encodeObject: data forKey: @"NSTIFFRepresentation"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[aCoder encodeObject: data];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||
|
|
|
@ -479,12 +479,24 @@
|
|||
{
|
||||
[super encodeWithCoder: aCoder];
|
||||
|
||||
[aCoder encodeObject: _cell];
|
||||
[aCoder encodeSize: _offsets];
|
||||
[aCoder encodeValueOfObjCType: @encode(NSBorderType) at: &_border_type];
|
||||
[aCoder encodeValueOfObjCType: @encode(NSTitlePosition) at: &_title_position];
|
||||
// NB: the content view is our (only) subview, so it is already
|
||||
// encoded by NSView.
|
||||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
[aCoder encodeObject: [self contentView] forKey: @"NSContentView"];
|
||||
[aCoder encodeObject: _cell forKey: @"NSTitleCell"];
|
||||
[aCoder encodeInt: [self borderType] forKey: @"NSBorderType"];
|
||||
[aCoder encodeInt: [self titlePosition] forKey: @"NSTitlePosition"];
|
||||
[aCoder encodeBool: NO forKey: @"NSTransparent"];
|
||||
[aCoder encodeSize: [self contentViewMargins] forKey: @"NSOffsets"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[aCoder encodeObject: _cell];
|
||||
[aCoder encodeSize: _offsets];
|
||||
[aCoder encodeValueOfObjCType: @encode(NSBorderType) at: &_border_type];
|
||||
[aCoder encodeValueOfObjCType: @encode(NSTitlePosition) at: &_title_position];
|
||||
// NB: the content view is our (only) subview, so it is already
|
||||
// encoded by NSView.
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "AppKit/NSSound.h"
|
||||
#include "AppKit/NSWindow.h"
|
||||
#include "GNUstepGUI/GSDrawFunctions.h"
|
||||
#include "GNUstepGUI/GSNibCompatibility.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
@ -1449,6 +1450,8 @@ typedef struct _GSButtonCellFlags
|
|||
GSButtonCellFlags buttonCellFlags;
|
||||
unsigned int bFlags = 0;
|
||||
unsigned int bFlags2 = 0;
|
||||
NSImage *image = nil;
|
||||
NSButtonImageSource *bi = nil;
|
||||
|
||||
[aCoder encodeObject: [self keyEquivalent] forKey: @"NSKeyEquivalent"];
|
||||
[aCoder encodeObject: [self image] forKey: @"NSNormalImage"];
|
||||
|
@ -1469,6 +1472,25 @@ typedef struct _GSButtonCellFlags
|
|||
bFlags2 != [self showsBorderOnlyWhileMouseInside] ? 0x8 : 0;
|
||||
bFlags2 |= [self bezelStyle];
|
||||
[aCoder encodeInt: bFlags2 forKey: @"NSButtonFlags2"];
|
||||
|
||||
// alternate image encoding...
|
||||
image = [self image];
|
||||
if ([image isKindOfClass: [NSImage class]])
|
||||
{
|
||||
if([NSImage imageNamed: @"NSSwitch"] == image)
|
||||
{
|
||||
bi = [[NSButtonImageSource alloc] initWithImageNamed: @"NSHighlightedSwitch"];
|
||||
}
|
||||
else if([NSImage imageNamed: @"NSRadioButton"] == image)
|
||||
{
|
||||
bi = [[NSButtonImageSource alloc] initWithImageNamed: @"NSHighlightedRadioButton"];
|
||||
}
|
||||
}
|
||||
[aCoder encodeObject: bi forKey: @"NSAlternateImage"];
|
||||
|
||||
// repeat and delay
|
||||
[aCoder encodeFloat: _delayInterval forKey: @"NSPeriodicDelay"];
|
||||
[aCoder encodeFloat: _repeatInterval forKey: @"NSPeriodicInterval"];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -167,16 +167,21 @@
|
|||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[super encodeWithCoder: aCoder];
|
||||
[aCoder encodeObject: _window];
|
||||
[aCoder encodeRect: _rect];
|
||||
if([aCoder allowsKeyedCoding] == NO)
|
||||
{
|
||||
[aCoder encodeObject: _window];
|
||||
[aCoder encodeRect: _rect];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||
{
|
||||
self = [super initWithCoder: aDecoder];
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_window];
|
||||
_rect = [aDecoder decodeRect];
|
||||
|
||||
if([aDecoder allowsKeyedCoding] == NO)
|
||||
{
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_window];
|
||||
_rect = [aDecoder decodeRect];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
126
Source/NSImage.m
126
Source/NSImage.m
|
@ -1479,63 +1479,93 @@ repd_for_rep(NSArray *_reps, NSImageRep *rep)
|
|||
{
|
||||
BOOL flag;
|
||||
|
||||
flag = _flags.archiveByName;
|
||||
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
if (flag == YES)
|
||||
if([coder allowsKeyedCoding])
|
||||
{
|
||||
/*
|
||||
* System image - just encode the name.
|
||||
*/
|
||||
[coder encodeValueOfObjCType: @encode(id) at: &_name];
|
||||
// FIXME: Not sure this is the way it goes...
|
||||
if(_flags.archiveByName == NO)
|
||||
{
|
||||
NSMutableArray *container = [NSMutableArray array];
|
||||
NSMutableArray *reps = [NSMutableArray array];
|
||||
NSEnumerator *en = [_reps objectEnumerator];
|
||||
GSRepData *rd = nil;
|
||||
|
||||
// add the reps to the container...
|
||||
[container addObject: reps];
|
||||
while((rd = [en nextObject]) != nil)
|
||||
{
|
||||
[reps addObject: rd->rep];
|
||||
}
|
||||
[coder encodeObject: container forKey: @"NSReps"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[coder encodeObject: _name forKey: @"NSImageName"];
|
||||
}
|
||||
|
||||
// encode the rest...
|
||||
[coder encodeObject: _color forKey: @"NSColor"];
|
||||
[coder encodeInt: 0 forKey: @"NSImageFlags"]; // zero...
|
||||
[coder encodeSize: _size forKey: @"NSSize"];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSMutableArray *a;
|
||||
NSEnumerator *e;
|
||||
NSImageRep *r;
|
||||
|
||||
/*
|
||||
* Normal image - encode the ivars
|
||||
*/
|
||||
[coder encodeValueOfObjCType: @encode(NSSize) at: &_size];
|
||||
[coder encodeValueOfObjCType: @encode(id) at: &_color];
|
||||
flag = _flags.scalable;
|
||||
flag = _flags.archiveByName;
|
||||
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
flag = _flags.dataRetained;
|
||||
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
flag = _flags.flipDraw;
|
||||
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
flag = _flags.sizeWasExplicitlySet;
|
||||
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
flag = _flags.useEPSOnResolutionMismatch;
|
||||
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
flag = _flags.colorMatchPreferred;
|
||||
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
flag = _flags.multipleResolutionMatching;
|
||||
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
flag = _flags.cacheSeparately;
|
||||
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
flag = _flags.unboundedCacheDepth;
|
||||
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
|
||||
// FIXME: The documentation says to archive only the file name,
|
||||
// if not data retained!
|
||||
/*
|
||||
* Now encode an array of all the image reps (excluding cache)
|
||||
*/
|
||||
a = [NSMutableArray arrayWithCapacity: 2];
|
||||
e = [[self representations] objectEnumerator];
|
||||
while ((r = [e nextObject]) != nil)
|
||||
if (flag == YES)
|
||||
{
|
||||
if ([r isKindOfClass: cachedClass] == NO)
|
||||
{
|
||||
[a addObject: r];
|
||||
}
|
||||
/*
|
||||
* System image - just encode the name.
|
||||
*/
|
||||
[coder encodeValueOfObjCType: @encode(id) at: &_name];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSMutableArray *a;
|
||||
NSEnumerator *e;
|
||||
NSImageRep *r;
|
||||
|
||||
/*
|
||||
* Normal image - encode the ivars
|
||||
*/
|
||||
[coder encodeValueOfObjCType: @encode(NSSize) at: &_size];
|
||||
[coder encodeValueOfObjCType: @encode(id) at: &_color];
|
||||
flag = _flags.scalable;
|
||||
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
flag = _flags.dataRetained;
|
||||
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
flag = _flags.flipDraw;
|
||||
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
flag = _flags.sizeWasExplicitlySet;
|
||||
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
flag = _flags.useEPSOnResolutionMismatch;
|
||||
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
flag = _flags.colorMatchPreferred;
|
||||
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
flag = _flags.multipleResolutionMatching;
|
||||
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
flag = _flags.cacheSeparately;
|
||||
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
flag = _flags.unboundedCacheDepth;
|
||||
[coder encodeValueOfObjCType: @encode(BOOL) at: &flag];
|
||||
|
||||
// FIXME: The documentation says to archive only the file name,
|
||||
// if not data retained!
|
||||
/*
|
||||
* Now encode an array of all the image reps (excluding cache)
|
||||
*/
|
||||
a = [NSMutableArray arrayWithCapacity: 2];
|
||||
e = [[self representations] objectEnumerator];
|
||||
while ((r = [e nextObject]) != nil)
|
||||
{
|
||||
if ([r isKindOfClass: cachedClass] == NO)
|
||||
{
|
||||
[a addObject: r];
|
||||
}
|
||||
}
|
||||
[coder encodeValueOfObjCType: @encode(id) at: &a];
|
||||
}
|
||||
[coder encodeValueOfObjCType: @encode(id) at: &a];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)coder
|
||||
{
|
||||
BOOL flag;
|
||||
|
|
|
@ -766,14 +766,25 @@
|
|||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[super encodeWithCoder: aCoder];
|
||||
|
||||
[aCoder encodeObject: _items];
|
||||
[aCoder encodeObject: _font];
|
||||
[aCoder encodeValueOfObjCType: @encode(NSTabViewType) at: &_type];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_draws_background];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_truncated_label];
|
||||
[aCoder encodeConditionalObject: _delegate];
|
||||
[aCoder encodeValueOfObjCType: "i" at: &_selected_item];
|
||||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
[aCoder encodeBool: [self allowsTruncatedLabels] forKey: @"NSAllowTruncatedLabels"];
|
||||
[aCoder encodeBool: [self drawsBackground] forKey: @"NSDrawsBackground"];
|
||||
[aCoder encodeObject: [self font] forKey: @"NSFont"];
|
||||
[aCoder encodeObject: _items forKey: @"NSTabViewItems"];
|
||||
[aCoder encodeObject: [self selectedTabViewItem] forKey: @"NSSelectedTabViewItem"];
|
||||
[aCoder encodeInt: 0 forKey: @"NSTvFlags"]; // no flags set...
|
||||
}
|
||||
else
|
||||
{
|
||||
[aCoder encodeObject: _items];
|
||||
[aCoder encodeObject: _font];
|
||||
[aCoder encodeValueOfObjCType: @encode(NSTabViewType) at: &_type];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_draws_background];
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_truncated_label];
|
||||
[aCoder encodeConditionalObject: _delegate];
|
||||
[aCoder encodeValueOfObjCType: "i" at: &_selected_item];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||
|
|
|
@ -208,13 +208,24 @@
|
|||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[aCoder encodeObject:_ident];
|
||||
[aCoder encodeObject:_label];
|
||||
[aCoder encodeObject:_view];
|
||||
[aCoder encodeObject:_color];
|
||||
[aCoder encodeValueOfObjCType: @encode(NSTabState) at: &_state];
|
||||
[aCoder encodeObject:_first_responder];
|
||||
[aCoder encodeObject:_tabview];
|
||||
if ([aCoder allowsKeyedCoding])
|
||||
{
|
||||
[aCoder encodeObject: _ident forKey: @"NSIdentifier"];
|
||||
[aCoder encodeObject: _label forKey: @"NSLabel"];
|
||||
[aCoder encodeObject: _view forKey: @"NSView"];
|
||||
[aCoder encodeObject: _color forKey: @"NSColor"];
|
||||
[aCoder encodeObject: _tabview forKey: @"NSTabView"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[aCoder encodeObject:_ident];
|
||||
[aCoder encodeObject:_label];
|
||||
[aCoder encodeObject:_view];
|
||||
[aCoder encodeObject:_color];
|
||||
[aCoder encodeValueOfObjCType: @encode(NSTabState) at: &_state];
|
||||
[aCoder encodeObject:_first_responder];
|
||||
[aCoder encodeObject:_tabview];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||
|
|
|
@ -208,10 +208,19 @@ static NSColor *txtCol;
|
|||
BOOL tmp;
|
||||
[super encodeWithCoder: aCoder];
|
||||
|
||||
[aCoder encodeValueOfObjCType: @encode(id) at: &_background_color];
|
||||
[aCoder encodeValueOfObjCType: @encode(id) at: &_text_color];
|
||||
tmp = _textfieldcell_draws_background;
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp];
|
||||
if([aCoder allowsKeyedCoding])
|
||||
{
|
||||
[aCoder encodeObject: [self backgroundColor] forKey: @"NSBackgroundColor"];
|
||||
[aCoder encodeObject: [self textColor] forKey: @"NSTextColor"];
|
||||
[aCoder encodeBool: [self drawsBackground] forKey: @"NSDrawsBackground"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[aCoder encodeValueOfObjCType: @encode(id) at: &_background_color];
|
||||
[aCoder encodeValueOfObjCType: @encode(id) at: &_text_color];
|
||||
tmp = _textfieldcell_draws_background;
|
||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &tmp];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||
|
|
Loading…
Reference in a new issue