Added keyed decoding.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@18510 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2004-01-30 19:49:00 +00:00
parent 1066f6326d
commit df3b584a19
14 changed files with 816 additions and 458 deletions

View file

@ -1,3 +1,20 @@
2004-01-30 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSBrowser.m
* Source/NSBrowserCell.m
* Source/NSButtonCell.m
* Source/NSCell.m
* Source/NSClipView.m
* Source/NSColor.m
* Source/NSControl.m
* Source/NSCursor.m
* Source/NSFont.m
* Source/NSProgressIndicator.m
* Source/NSScroller.m
* Source/NSScrollView.m
* Source/NSView.m
Added keyed decoding.
2004-01-26 Adam Fedor <fedor@gnu.org>
* /Headers/Additions/GNUstepGUI/GSHbox.h: Fix doc markup.

View file

@ -2397,77 +2397,119 @@ static NSTextFieldCell *titleCell;
- (id) initWithCoder: (NSCoder*)aDecoder
{
int colCount;
id dummy;
self = [super initWithCoder: aDecoder];
[super initWithCoder: aDecoder];
// Here to keep compatibility with old version
dummy = [aDecoder decodeObject];
_browserCellPrototype = RETAIN([aDecoder decodeObject]);
_browserMatrixClass = NSClassFromString ((NSString *)[aDecoder decodeObject]);
if ([aDecoder allowsKeyedCoding])
{
NSCell *proto = [aDecoder decodeObjectForKey: @"NSCellPrototype"];
NSString *title = [aDecoder decodeObjectForKey: @"NSFirstColumnTitle"];
NSString *sep = [aDecoder decodeObjectForKey: @"NSPathSeparator"];
int flags;
self = [super initWithCoder: aDecoder];
[self setCellPrototype: proto];
[self setPathSeparator: sep];
[self setTitle: title ofColumn: 0];
[self setPathSeparator: [aDecoder decodeObject]];
if ([aDecoder containsValueForKey: @"NSBrFlags"])
{
flags = [aDecoder decodeIntForKey: @"NSBrFlags"];
// FIXME
}
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_allowsBranchSelection];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_allowsEmptySelection];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_allowsMultipleSelection];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_maxVisibleColumns];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_minColumnWidth];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_reusesColumns];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_separatesColumns];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_takesTitleFromPreviousColumn];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isTitled];
if ([aDecoder containsValueForKey: @"NSNumberOfVisibleColumns"])
{
[self setMaxVisibleColumns: [aDecoder decodeIntForKey:
@"NSNumberOfVisibleColumns"]];
}
//NSBox *_horizontalScrollerBox;
_horizontalScroller = RETAIN([aDecoder decodeObject]);
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_hasHorizontalScroller];
_scrollerRect = [aDecoder decodeRect];
_columnSize = [aDecoder decodeSize];
if ([aDecoder containsValueForKey: @"NSMinColumnWidth"])
{
[self setMinColumnWidth: [aDecoder decodeIntForKey: @"NSMinColumnWidth"]];
}
_skipUpdateScroller = NO;
/*
_horizontalScroller = [[NSScroller alloc] initWithFrame: _scrollerRect];
[_horizontalScroller setTarget: self];
[_horizontalScroller setAction: @selector(scrollViaScroller:)];
*/
[self setHasHorizontalScroller: _hasHorizontalScroller];
if ([aDecoder containsValueForKey: @"NSColumnResizingType"])
{
//[self setColumnResizingType: [aDecoder decodeIntForKey: @"NSColumnResizingType"]];
}
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_acceptsArrowKeys];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_sendsActionOnArrowKeys];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_acceptsAlphaNumericalKeys];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_sendsActionOnAlphaNumericalKeys];
_lastKeyPressed = 0;
_charBuffer = nil;
// Skip: int _alphaNumericalLastColumn;
_browserDelegate = [aDecoder decodeObject];
if (_browserDelegate != nil)
[self setDelegate:_browserDelegate];
if ([aDecoder containsValueForKey: @"NSPreferedColumnWidth"])
{
//int prefWidth = [aDecoder decodeIntForKey: @"NSPreferedColumnWidth"];
}
}
else
_passiveDelegate = YES;
{
int colCount;
id dummy;
// Here to keep compatibility with old version
dummy = [aDecoder decodeObject];
_browserCellPrototype = RETAIN([aDecoder decodeObject]);
_browserMatrixClass = NSClassFromString ((NSString *)[aDecoder decodeObject]);
[self setPathSeparator: [aDecoder decodeObject]];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isLoaded];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_allowsBranchSelection];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_allowsEmptySelection];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_allowsMultipleSelection];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_maxVisibleColumns];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_minColumnWidth];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_reusesColumns];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_separatesColumns];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_takesTitleFromPreviousColumn];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isTitled];
//NSBox *_horizontalScrollerBox;
_horizontalScroller = RETAIN([aDecoder decodeObject]);
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_hasHorizontalScroller];
_scrollerRect = [aDecoder decodeRect];
_columnSize = [aDecoder decodeSize];
_skipUpdateScroller = NO;
/*
_horizontalScroller = [[NSScroller alloc] initWithFrame: _scrollerRect];
[_horizontalScroller setTarget: self];
[_horizontalScroller setAction: @selector(scrollViaScroller:)];
*/
[self setHasHorizontalScroller: _hasHorizontalScroller];
[aDecoder decodeValueOfObjCType: @encode(SEL) at: &_doubleAction];
_target = [aDecoder decodeObject];
[aDecoder decodeValueOfObjCType: @encode(SEL) at: &_action];
// Do the minimal thing to initiate the browser...
/*
_lastColumnLoaded = -1;
_firstVisibleColumn = 0;
_lastVisibleColumn = 0;
[self _createColumn];
*/
_browserColumns = RETAIN([aDecoder decodeObject]);
// ..and rebuild any existing browser columns
[aDecoder decodeValueOfObjCType: @encode(int) at: &colCount];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_firstVisibleColumn];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_acceptsArrowKeys];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_sendsActionOnArrowKeys];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_acceptsAlphaNumericalKeys];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_sendsActionOnAlphaNumericalKeys];
_lastKeyPressed = 0;
_charBuffer = nil;
// Skip: int _alphaNumericalLastColumn;
_browserDelegate = [aDecoder decodeObject];
if (_browserDelegate != nil)
[self setDelegate:_browserDelegate];
else
_passiveDelegate = YES;
[aDecoder decodeValueOfObjCType: @encode(SEL) at: &_doubleAction];
_target = [aDecoder decodeObject];
[aDecoder decodeValueOfObjCType: @encode(SEL) at: &_action];
// Do the minimal thing to initiate the browser...
/*
_lastColumnLoaded = -1;
_firstVisibleColumn = 0;
_lastVisibleColumn = 0;
[self _createColumn];
*/
_browserColumns = RETAIN([aDecoder decodeObject]);
// ..and rebuild any existing browser columns
[aDecoder decodeValueOfObjCType: @encode(int) at: &colCount];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_firstVisibleColumn];
}
// Display even if there isn't any column
_isLoaded = NO;
[self tile];
return self;
}

View file

@ -329,15 +329,23 @@ static NSFont *_leafFont;
- (id) initWithCoder: (NSCoder*)aDecoder
{
BOOL tmp;
[super initWithCoder: aDecoder];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &tmp];
[self setLeaf: tmp];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &tmp];
[self setLoaded: tmp];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_alternateImage];
if ([aDecoder allowsKeyedCoding])
{
// Nothing special
}
else
{
BOOL tmp;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &tmp];
[self setLeaf: tmp];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &tmp];
[self setLoaded: tmp];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_alternateImage];
}
return self;
}

View file

@ -1128,23 +1128,62 @@
- (id) initWithCoder: (NSCoder*)aDecoder
{
// FIXME: Add new ivars
BOOL tmp;
[super initWithCoder: aDecoder];
self = [super initWithCoder: aDecoder];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_keyEquivalent];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_keyEquivalentFont];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_altContents];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_altImage];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &tmp];
_buttoncell_is_transparent = tmp;
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
at: &_keyEquivalentModifierMask];
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
at: &_highlightsByMask];
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
at: &_showAltStateMask];
if ([aDecoder allowsKeyedCoding])
{
NSString *alternateContents = [aDecoder decodeObjectForKey: @"NSAlternateContents"];
NSImage *alternateImage = [aDecoder decodeObjectForKey: @"NSAlternateImage"];
//NSControl *control = [aDecoder decodeObjectForKey: @"NSControlView"];
NSString *key = [aDecoder decodeObjectForKey: @"NSKeyEquivalent"];
int bFlags;
int bFlags2;
int delay = 0;
int interval = 0;
[self setAlternateImage: alternateImage];
[self setAlternateTitle: alternateContents];
[self setKeyEquivalent: key];
if ([aDecoder containsValueForKey: @"NSButtonFlags"])
{
bFlags = [aDecoder decodeIntForKey: @"NSButtonFlags"];
// FIXME
}
if ([aDecoder containsValueForKey: @"NSButtonFlags2"])
{
bFlags2 = [aDecoder decodeIntForKey: @"NSButtonFlags2"];
// FIXME
}
if ([aDecoder containsValueForKey: @"NSPeriodicDelay"])
{
delay = [aDecoder decodeIntForKey: @"NSPeriodicDelay"];
}
if ([aDecoder containsValueForKey: @"NSPeriodicInterval"])
{
interval = [aDecoder decodeIntForKey: @"NSPeriodicInterval"];
}
[self setPeriodicDelay: delay interval: interval];
}
else
{
// FIXME: Add new ivars
BOOL tmp;
[aDecoder decodeValueOfObjCType: @encode(id) at: &_keyEquivalent];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_keyEquivalentFont];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_altContents];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_altImage];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &tmp];
_buttoncell_is_transparent = tmp;
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
at: &_keyEquivalentModifierMask];
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
at: &_highlightsByMask];
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
at: &_showAltStateMask];
}
return self;
}

View file

@ -1980,78 +1980,101 @@ static NSColor *shadowCol;
- (id) initWithCoder: (NSCoder*)aDecoder
{
BOOL flag;
unsigned int tmp_int;
[aDecoder decodeValueOfObjCType: @encode(id) at: &_contents];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_cell_image];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_font];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_objectValue];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.contents_is_attributed_string = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.is_highlighted = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.is_disabled = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.is_editable = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.is_rich_text = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.imports_graphics = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.shows_first_responder = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.refuses_first_responder = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.sends_action_on_end_editing = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.is_bordered = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.is_bezeled = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.is_scrollable = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.is_selectable = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
// This used to be is_continuous, which has been replaced.
//_cell.is_continuous = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.allows_mixed_state = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.wraps = flag;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
_cell.text_align = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
_cell.type = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
_cell.image_position = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
_cell.entry_type = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
_cell.state = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
at: &_mnemonic_location];
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
at: &_mouse_down_flags];
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &_action_mask];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_formatter];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_menu];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_represented_object];
if (_formatter != nil)
if ([aDecoder allowsKeyedCoding])
{
NSString *contents;
NSString *contents = [aDecoder decodeObjectForKey: @"NSContents"];
NSFont *support = [aDecoder decodeObjectForKey: @"NSSupport"];
int cFlags;
int cFlags2;
contents = [_formatter stringForObjectValue: _objectValue];
if (contents != nil)
{
_cell.has_valid_object_value = YES;
ASSIGN (_contents, contents);
_cell.contents_is_attributed_string = NO;
if ([aDecoder containsValueForKey: @"NSCellFlags"])
{
cFlags = [aDecoder decodeIntForKey: @"NSCellFlags"];
// FIXME
}
if ([aDecoder containsValueForKey: @"NSCellFlags2"])
{
cFlags2 = [aDecoder decodeIntForKey: @"NSCellFlags2"];
// FIXME
}
self = [self initTextCell: contents];
[self setFont: support];
}
else
{
BOOL flag;
unsigned int tmp_int;
[aDecoder decodeValueOfObjCType: @encode(id) at: &_contents];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_cell_image];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_font];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_objectValue];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.contents_is_attributed_string = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.is_highlighted = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.is_disabled = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.is_editable = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.is_rich_text = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.imports_graphics = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.shows_first_responder = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.refuses_first_responder = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.sends_action_on_end_editing = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.is_bordered = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.is_bezeled = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.is_scrollable = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.is_selectable = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
// This used to be is_continuous, which has been replaced.
//_cell.is_continuous = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.allows_mixed_state = flag;
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &flag];
_cell.wraps = flag;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
_cell.text_align = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
_cell.type = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
_cell.image_position = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
_cell.entry_type = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &tmp_int];
_cell.state = tmp_int;
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
at: &_mnemonic_location];
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
at: &_mouse_down_flags];
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &_action_mask];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_formatter];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_menu];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_represented_object];
if (_formatter != nil)
{
NSString *contents;
contents = [_formatter stringForObjectValue: _objectValue];
if (contents != nil)
{
_cell.has_valid_object_value = YES;
ASSIGN (_contents, contents);
_cell.contents_is_attributed_string = NO;
}
}
}
return self;
}
@end

View file

@ -718,25 +718,42 @@ static inline NSRect integralRect (NSRect rect, NSView *view)
- (id) initWithCoder: (NSCoder*)aDecoder
{
NSView *document;
BOOL temp;
self = [super initWithCoder: aDecoder];
[self setAutoresizesSubviews: YES];
[self setBackgroundColor: [aDecoder decodeObject]];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_copiesOnScroll];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &temp];
[self setDrawsBackground: temp];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_cursor];
if ([[self subviews] count] > 0)
if ([aDecoder allowsKeyedCoding])
{
document = AUTORELEASE(RETAIN([[self subviews] objectAtIndex: 0]));
[self removeSubview: document];
[self setDocumentView: document];
}
int flags;
[self setBackgroundColor: [aDecoder decodeObjectForKey: @"NSBGColor"]];
[self setDocumentCursor: [aDecoder decodeObjectForKey: @"NSCursor"]];
[self setDocumentView: [aDecoder decodeObjectForKey: @"NSDocView"]];
if ([aDecoder containsValueForKey: @"NScvFlags"])
{
flags = [aDecoder decodeIntForKey: @"NScvFlags"];
// FIXME setCopiesOnScroll: setDrawsBackground:
}
}
else
{
NSView *document;
BOOL temp;
[self setAutoresizesSubviews: YES];
[self setBackgroundColor: [aDecoder decodeObject]];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_copiesOnScroll];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &temp];
[self setDrawsBackground: temp];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_cursor];
if ([[self subviews] count] > 0)
{
document = AUTORELEASE(RETAIN([[self subviews] objectAtIndex: 0]));
[self removeSubview: document];
[self setDocumentView: document];
}
}
return self;
}
@end

View file

@ -1044,7 +1044,72 @@ systemColorWithName(NSString *name)
- (id) initWithCoder: (NSCoder*)aDecoder
{
if ([aDecoder versionForClassName: @"NSColor"] < 3)
if ([aDecoder allowsKeyedCoding])
{
int colorSpace = [aDecoder decodeIntForKey: @"NSColorSpace"];
DESTROY(self);
if (colorSpace == 1)
{
unsigned length;
const uint8_t *data;
float red = 0.0;
float green = 0.0;
float blue = 0.0;
float alpha = 0.0;
NSString *str;
NSScanner *scanner;
if ([aDecoder containsValueForKey: @"NSRGB"])
{
data = [aDecoder decodeBytesForKey: @"NSRGB"
returnedLength: &length];
str = [[NSString alloc] initWithCString: data length: length];
scanner = [[NSScanner alloc] initWithString: str];
[scanner scanFloat: &red];
[scanner scanFloat: &green];
[scanner scanFloat: &blue];
}
self = [NSColor colorWithCalibratedRed: red
green: green
blue: blue
alpha: alpha];
}
else if (colorSpace == 3)
{
unsigned length;
const uint8_t *data;
float white = 0.0;
float alpha = 0.0;
NSString *str;
NSScanner *scanner;
if ([aDecoder containsValueForKey: @"NSWhite"])
{
data = [aDecoder decodeBytesForKey: @"NSWhite"
returnedLength: &length];
str = [[NSString alloc] initWithCString: data length: length];
scanner = [[NSScanner alloc] initWithString: str];
[scanner scanFloat: &white];
}
self = [NSColor colorWithDeviceWhite: white
alpha: alpha];
}
else if (colorSpace == 6)
{
NSString *catalog = [aDecoder decodeObjectForKey: @"NSCatalogName"];
NSString *name = [aDecoder decodeObjectForKey: @"NSColorName"];
//NSColor *color = [aDecoder decodeObjectForKey: @"NSColor"];
self = [NSColor colorWithCatalogName: catalog
colorName: name];
}
return self;
}
else if ([aDecoder versionForClassName: @"NSColor"] < 3)
{
float red;
float green;

View file

@ -643,9 +643,25 @@ static Class actionCellClass;
{
[super initWithCoder: aDecoder];
[aDecoder decodeValueOfObjCType: @encode(int) at: &_tag];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_cell];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_ignoresMultiClick];
if ([aDecoder allowsKeyedCoding])
{
NSCell *cell = [aDecoder decodeObjectForKey: @"NSCell"];
if (cell != nil)
{
[self setCell: cell];
}
if ([aDecoder containsValueForKey: @"NSEnabled"])
{
[self setEnabled: [aDecoder decodeBoolForKey: @"NSEnabled"]];
}
}
else
{
[aDecoder decodeValueOfObjCType: @encode(int) at: &_tag];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_cell];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_ignoresMultiClick];
}
return self;
}

View file

@ -29,6 +29,7 @@
#include <Foundation/NSArray.h>
#include <Foundation/NSDebug.h>
#include <Foundation/NSKeyedArchiver.h>
#include "AppKit/NSColor.h"
#include "AppKit/NSCursor.h"
@ -371,12 +372,40 @@ backgroundColorHint:(NSColor *)bg
- (id) initWithCoder: (NSCoder*)aDecoder
{
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_is_set_on_mouse_entered];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_is_set_on_mouse_exited];
_cursor_image = [aDecoder decodeObject];
_hot_spot = [aDecoder decodePoint];
[self _computeCid];
if ([aDecoder allowsKeyedCoding])
{
int type = 0;
NSPoint hotSpot;
if ([aDecoder containsValueForKey: @"NSCursorType"])
{
type = [aDecoder decodeIntForKey: @"NSCursorType"];
}
DESTROY(self);
// FIXME
if (type == 0)
{
self = [NSCursor arrowCursor];
}
else if (type == 1)
{
self = [NSCursor IBeamCursor];
}
if ([aDecoder containsValueForKey: @"NSHotSpot"])
{
hotSpot = [aDecoder decodePointForKey: @"NSHotSpot"];
}
}
else
{
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_is_set_on_mouse_entered];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_is_set_on_mouse_exited];
_cursor_image = [aDecoder decodeObject];
_hot_spot = [aDecoder decodePoint];
[self _computeCid];
}
return self;
}

View file

@ -978,121 +978,139 @@ static BOOL flip_hack;
- (id) initWithCoder: (NSCoder*)aDecoder
{
int version = [aDecoder versionForClassName: @"NSFont"];
id name;
float fontMatrix[6];
BOOL fix;
int the_role;
if (version == 3)
if ([aDecoder allowsKeyedCoding])
{
[aDecoder decodeValueOfObjCType: @encode(int)
at: &the_role];
}
else
{
the_role = RoleExplicit;
}
if (the_role == RoleExplicit)
{
/* The easy case: an explicit font, or a font encoded with
version <= 2. */
name = [aDecoder decodeObject];
[aDecoder decodeArrayOfObjCType: @encode(float)
count: 6
at: fontMatrix];
if (version >= 2)
{
[aDecoder decodeValueOfObjCType: @encode(BOOL)
at: &fix];
}
else
{
if (fontMatrix[0] == fontMatrix[3]
&& fontMatrix[1] == 0.0 && fontMatrix[2] == 0.0)
fix = NO;
else
fix = YES;
}
self = [self initWithName: name
matrix: fontMatrix
fix: fix
screenFont: NO
role: RoleExplicit];
if (self)
return self;
self = [NSFont userFontOfSize: fontMatrix[0]];
NSAssert(self != nil, @"Couldn't find a valid font when decoding.");
return RETAIN(self);
}
else
{
/* A non-explicit font. */
float size;
NSFont *new;
if (the_role & 1)
{
[aDecoder decodeValueOfObjCType: @encode(float)
at: &size];
}
else
{
size = 0.0;
}
switch (the_role >> 1)
{
case RoleBoldSystemFont:
new = [NSFont boldSystemFontOfSize: size];
break;
case RoleSystemFont:
new = [NSFont systemFontOfSize: size];
break;
case RoleUserFixedPitchFont:
new = [NSFont userFixedPitchFontOfSize: size];
break;
case RoleTitleBarFont:
new = [NSFont titleBarFontOfSize: size];
break;
case RoleMenuFont:
new = [NSFont menuFontOfSize: size];
break;
case RoleMessageFont:
new = [NSFont messageFontOfSize: size];
break;
case RolePaletteFont:
new = [NSFont paletteFontOfSize: size];
break;
case RoleToolTipsFont:
new = [NSFont toolTipsFontOfSize: size];
break;
case RoleControlContentFont:
new = [NSFont controlContentFontOfSize: size];
break;
case RoleLabelFont:
new = [NSFont labelFontOfSize: size];
break;
default:
NSDebugLLog(@"NSFont", @"unknown role %i", the_role);
/* fall through */
case RoleUserFont:
new = [NSFont userFontOfSize: size];
break;
}
NSString *name = [aDecoder decodeObjectForKey: @"NSName"];
int size = [aDecoder decodeIntForKey: @"NSSize"];
RELEASE(self);
if (new)
return RETAIN(new);
if ([aDecoder containsValueForKey: @"NSfFlags"])
{
//int flags = [aDecoder decodeIntForKey: @"NSfFlags"];
// FIXME
}
new = [NSFont userFontOfSize: size];
NSAssert(new != nil, @"Couldn't find a valid font when decoding.");
return RETAIN(new);
self = [NSFont fontWithName: name size: size];
return self;
}
else
{
int version = [aDecoder versionForClassName: @"NSFont"];
id name;
float fontMatrix[6];
BOOL fix;
int the_role;
if (version == 3)
{
[aDecoder decodeValueOfObjCType: @encode(int)
at: &the_role];
}
else
{
the_role = RoleExplicit;
}
if (the_role == RoleExplicit)
{
/* The easy case: an explicit font, or a font encoded with
version <= 2. */
name = [aDecoder decodeObject];
[aDecoder decodeArrayOfObjCType: @encode(float)
count: 6
at: fontMatrix];
if (version >= 2)
{
[aDecoder decodeValueOfObjCType: @encode(BOOL)
at: &fix];
}
else
{
if (fontMatrix[0] == fontMatrix[3]
&& fontMatrix[1] == 0.0 && fontMatrix[2] == 0.0)
fix = NO;
else
fix = YES;
}
self = [self initWithName: name
matrix: fontMatrix
fix: fix
screenFont: NO
role: RoleExplicit];
if (self)
return self;
self = [NSFont userFontOfSize: fontMatrix[0]];
NSAssert(self != nil, @"Couldn't find a valid font when decoding.");
return RETAIN(self);
}
else
{
/* A non-explicit font. */
float size;
NSFont *new;
if (the_role & 1)
{
[aDecoder decodeValueOfObjCType: @encode(float)
at: &size];
}
else
{
size = 0.0;
}
switch (the_role >> 1)
{
case RoleBoldSystemFont:
new = [NSFont boldSystemFontOfSize: size];
break;
case RoleSystemFont:
new = [NSFont systemFontOfSize: size];
break;
case RoleUserFixedPitchFont:
new = [NSFont userFixedPitchFontOfSize: size];
break;
case RoleTitleBarFont:
new = [NSFont titleBarFontOfSize: size];
break;
case RoleMenuFont:
new = [NSFont menuFontOfSize: size];
break;
case RoleMessageFont:
new = [NSFont messageFontOfSize: size];
break;
case RolePaletteFont:
new = [NSFont paletteFontOfSize: size];
break;
case RoleToolTipsFont:
new = [NSFont toolTipsFontOfSize: size];
break;
case RoleControlContentFont:
new = [NSFont controlContentFontOfSize: size];
break;
case RoleLabelFont:
new = [NSFont labelFontOfSize: size];
break;
default:
NSDebugLLog(@"NSFont", @"unknown role %i", the_role);
/* fall through */
case RoleUserFont:
new = [NSFont userFontOfSize: size];
break;
}
RELEASE(self);
if (new)
return RETAIN(new);
new = [NSFont userFontOfSize: size];
NSAssert(new != nil, @"Couldn't find a valid font when decoding.");
return RETAIN(new);
}
}
}

View file

@ -302,16 +302,35 @@ static NSImage *images[maxCount];
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at:&_isIndeterminate];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at:&_isBezeled];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at:&_usesThreadedAnimation];
[aDecoder decodeValueOfObjCType: @encode(NSTimeInterval)
at:&_animationDelay];
[aDecoder decodeValueOfObjCType: @encode(double) at:&_doubleValue];
[aDecoder decodeValueOfObjCType: @encode(double) at:&_minValue];
[aDecoder decodeValueOfObjCType: @encode(double) at:&_maxValue];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at:&_isVertical];
self = [super initWithCoder:aDecoder];
if ([aDecoder allowsKeyedCoding])
{
//id *matrix = [aDecoder decodeObjectForKey: @"NSDrawMatrix"];
if ([aDecoder containsValueForKey: @"NSMaxValue"])
{
int max = [aDecoder decodeIntForKey: @"NSMaxValue"];
[self setMaxValue: max];
}
if ([aDecoder containsValueForKey: @"NSpiFlags"])
{
//int flags = [aDecoder decodeIntForKey: @"NSpiFlags"];
// FIXME
}
}
else
{
[aDecoder decodeValueOfObjCType: @encode(BOOL) at:&_isIndeterminate];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at:&_isBezeled];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at:&_usesThreadedAnimation];
[aDecoder decodeValueOfObjCType: @encode(NSTimeInterval)
at:&_animationDelay];
[aDecoder decodeValueOfObjCType: @encode(double) at:&_doubleValue];
[aDecoder decodeValueOfObjCType: @encode(double) at:&_minValue];
[aDecoder decodeValueOfObjCType: @encode(double) at:&_maxValue];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at:&_isVertical];
}
return self;
}

View file

@ -1237,93 +1237,86 @@ static float scrollerWidth;
- (id) initWithCoder: (NSCoder*)aDecoder
{
int version = [aDecoder versionForClassName:
@"NSScrollView"];
if (version == 2)
{
[super initWithCoder: aDecoder];
NSDebugLLog(@"NSScrollView", @"NSScrollView: start decoding\n");
[aDecoder decodeValueOfObjCType: @encode(id) at: &_contentView];
[aDecoder decodeValueOfObjCType: @encode(NSBorderType) at: &_borderType];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_scrollsDynamically];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_rulersVisible];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_hLineScroll];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_hPageScroll];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_vLineScroll];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_vPageScroll];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_hasHorizScroller];
if (_hasHorizScroller)
[aDecoder decodeValueOfObjCType: @encode(id) at: &_horizScroller];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_hasVertScroller];
if (_hasVertScroller)
[aDecoder decodeValueOfObjCType: @encode(id) at: &_vertScroller];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_hasHorizRuler];
if (_hasHorizRuler)
[aDecoder decodeValueOfObjCType: @encode(id) at: &_horizRuler];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_hasVertRuler];
if (_hasVertRuler)
[aDecoder decodeValueOfObjCType: @encode(id) at: &_vertRuler];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_hasHeaderView];
if (_hasHeaderView)
[aDecoder decodeValueOfObjCType: @encode(id) at: &_headerClipView];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_hasCornerView];
self = [super initWithCoder: aDecoder];
[self tile];
NSDebugLLog(@"NSScrollView", @"NSScrollView: finish decoding\n");
return self;
}
else if (version == 1)
if ([aDecoder allowsKeyedCoding])
{
[super initWithCoder: aDecoder];
NSClipView *content = [aDecoder decodeObjectForKey: @"NSContentView"];
NSScroller *hScroller = [aDecoder decodeObjectForKey: @"NSHScroller"];
NSScroller *vScroller = [aDecoder decodeObjectForKey: @"NSVScroller"];
NSDebugLLog(@"NSScrollView", @"NSScrollView: start decoding\n");
[aDecoder decodeValueOfObjCType: @encode(id) at: &_contentView];
[aDecoder decodeValueOfObjCType: @encode(NSBorderType) at: &_borderType];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_scrollsDynamically];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_rulersVisible];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_hLineScroll];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_hPageScroll];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_vLineScroll];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_vPageScroll];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_hasHorizScroller];
if (_hasHorizScroller)
[aDecoder decodeValueOfObjCType: @encode(id) at: &_horizScroller];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_hasVertScroller];
if (_hasVertScroller)
[aDecoder decodeValueOfObjCType: @encode(id) at: &_vertScroller];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_hasHorizRuler];
if (_hasHorizRuler)
[aDecoder decodeValueOfObjCType: @encode(id) at: &_horizRuler];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_hasVertRuler];
if (_hasVertRuler)
[aDecoder decodeValueOfObjCType: @encode(id) at: &_vertRuler];
/* This recreates all the info about headerView, cornerView, etc */
[self setDocumentView: [_contentView documentView]];
[self tile];
NSDebugLLog(@"NSScrollView", @"NSScrollView: finish decoding\n");
return self;
if (content != nil)
{
[self setContentView: content];
}
if (hScroller != nil)
{
[self setHorizontalScroller: hScroller];
}
if (vScroller != nil)
{
[self setVerticalScroller: vScroller];
}
if ([aDecoder containsValueForKey: @"NSsFlags"])
{
//int flags = [aDecoder decodeIntForKey: @"NSsFlags"];
// FIXME
}
}
else
{
NSLog(@"unknown NSScrollView version (%d)", version);
return nil;
int version = [aDecoder versionForClassName:
@"NSScrollView"];
NSDebugLLog(@"NSScrollView", @"NSScrollView: start decoding\n");
[aDecoder decodeValueOfObjCType: @encode(id) at: &_contentView];
[aDecoder decodeValueOfObjCType: @encode(NSBorderType) at: &_borderType];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_scrollsDynamically];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_rulersVisible];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_hLineScroll];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_hPageScroll];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_vLineScroll];
[aDecoder decodeValueOfObjCType: @encode(float) at: &_vPageScroll];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_hasHorizScroller];
if (_hasHorizScroller)
[aDecoder decodeValueOfObjCType: @encode(id) at: &_horizScroller];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_hasVertScroller];
if (_hasVertScroller)
[aDecoder decodeValueOfObjCType: @encode(id) at: &_vertScroller];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_hasHorizRuler];
if (_hasHorizRuler)
[aDecoder decodeValueOfObjCType: @encode(id) at: &_horizRuler];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_hasVertRuler];
if (_hasVertRuler)
[aDecoder decodeValueOfObjCType: @encode(id) at: &_vertRuler];
if (version == 2)
{
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_hasHeaderView];
if (_hasHeaderView)
[aDecoder decodeValueOfObjCType: @encode(id) at: &_headerClipView];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_hasCornerView];
}
else if (version == 1)
{
/* This recreates all the info about headerView, cornerView, etc */
[self setDocumentView: [_contentView documentView]];
}
else
{
NSLog(@"unknown NSScrollView version (%d)", version);
DESTROY(self);
}
[self tile];
NSDebugLLog(@"NSScrollView", @"NSScrollView: finish decoding\n");
}
return self;
}
@end

View file

@ -153,36 +153,69 @@ static NSColor *scrollBarColor = nil;
{
self = [super initWithCoder: aDecoder];
if (_frame.size.width > _frame.size.height)
if ([aDecoder allowsKeyedCoding])
{
_isHorizontal = YES;
NSString *action = [aDecoder decodeObjectForKey: @"NSAction"];
id target = [aDecoder decodeObjectForKey: @"NSTarget"];
float value = 0.0;
float percent = 0.0;
int flags;
if (action != nil)
{
[self setAction: NSSelectorFromString(action)];
}
[self setTarget: target];
if ([aDecoder containsValueForKey: @"NSCurValue"])
{
value = [aDecoder decodeFloatForKey: @"NSCurValue"];
}
if ([aDecoder containsValueForKey: @"NSPercent"])
{
percent = [aDecoder decodeFloatForKey: @"NSPercent"];
}
[self setFloatValue: value knobProportion: percent];
if ([aDecoder containsValueForKey: @"NSsFlags"])
{
flags = [aDecoder decodeIntForKey: @"NSsFlags"];
// FIXME
}
}
else
{
_isHorizontal = NO;
if (_frame.size.width > _frame.size.height)
{
_isHorizontal = YES;
}
else
{
_isHorizontal = NO;
}
if (_isHorizontal)
{
_floatValue = 0.0;
}
else
{
_floatValue = 1.0;
}
_hitPart = NSScrollerNoPart;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &_arrowsPosition];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isEnabled];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_target];
// Undo RETAIN by decoder
TEST_RELEASE(_target);
[aDecoder decodeValueOfObjCType: @encode(SEL) at: &_action];
[self drawParts];
[self checkSpaceForParts];
}
if (_isHorizontal)
{
_floatValue = 0.0;
}
else
{
_floatValue = 1.0;
}
_hitPart = NSScrollerNoPart;
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &_arrowsPosition];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_isEnabled];
[aDecoder decodeValueOfObjCType: @encode(id) at: &_target];
// Undo RETAIN by decoder
TEST_RELEASE(_target);
[aDecoder decodeValueOfObjCType: @encode(SEL) at: &_action];
[self drawParts];
[self checkSpaceForParts];
return self;
}

View file

@ -38,6 +38,7 @@
#include <Foundation/NSString.h>
#include <Foundation/NSCalendarDate.h>
#include <Foundation/NSCoder.h>
#include <Foundation/NSKeyedArchiver.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSThread.h>
#include <Foundation/NSLock.h>
@ -3619,71 +3620,109 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
- (id) initWithCoder: (NSCoder*)aDecoder
{
NSRect rect;
NSEnumerator *e;
NSView *sub;
NSArray *subs;
self = [super initWithCoder: aDecoder];
NSDebugLLog(@"NSView", @"NSView: start decoding\n");
_frame = [aDecoder decodeRect];
_bounds.origin = NSZeroPoint;
_bounds.size = _frame.size;
_frameMatrix = [NSAffineTransform new]; // Map fromsuperview to frame
_boundsMatrix = [NSAffineTransform new]; // Map fromsuperview to bounds
_matrixToWindow = [NSAffineTransform new]; // Map to window coordinates
_matrixFromWindow = [NSAffineTransform new]; // Map from window coordinates
[_frameMatrix setFrameOrigin: _frame.origin];
rect = [aDecoder decodeRect];
[self setBounds: rect];
_sub_views = [NSMutableArray new];
_tracking_rects = [NSMutableArray new];
_cursor_rects = [NSMutableArray new];
_super_view = nil;
_window = nil;
_rFlags.needs_display = YES;
_coordinates_valid = NO;
_rFlags.flipped_view = [self isFlipped];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_is_rotated_from_base];
[aDecoder decodeValueOfObjCType: @encode(BOOL)
at: &_is_rotated_or_scaled_from_base];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_post_frame_changes];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_autoresizes_subviews];
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
at: &_autoresizingMask];
[self setNextKeyView: [aDecoder decodeObject]];
[[aDecoder decodeObject] setNextKeyView: self];
[aDecoder decodeValueOfObjCType: @encode(id) at: &subs];
e = [subs objectEnumerator];
while ((sub = [e nextObject]) != nil)
if ([aDecoder allowsKeyedCoding])
{
NSAssert(sub->_window == nil, NSInternalInconsistencyException);
NSAssert(sub->_super_view == nil, NSInternalInconsistencyException);
[sub viewWillMoveToWindow: _window];
[sub viewWillMoveToSuperview: self];
[sub setNextResponder: self];
[_sub_views addObject: sub];
_rFlags.has_subviews = 1;
[sub resetCursorRects];
[sub setNeedsDisplay: YES];
[sub viewDidMoveToWindow];
[sub viewDidMoveToSuperview];
[self didAddSubview: sub];
NSRect frame = NSZeroRect;
id next = [aDecoder decodeObjectForKey: @"NSNextResponder"];
//NSView *superView = [aDecoder decodeObjectForKey: @"NSSuperview"];
NSView *nextKeyView = [aDecoder decodeObjectForKey: @"NSNextKeyView"];
NSArray *subViews = [aDecoder decodeObjectForKey: @"NSSubviews"];
if ([aDecoder containsValueForKey: @"NSFrame"])
{
frame = [aDecoder decodeRectForKey: @"NSFrame"];
}
self = [self initWithFrame: frame];
if (next != nil)
{
[self setNextResponder: next];
}
if (subViews != nil)
{
NSEnumerator *enumerator = [subViews objectEnumerator];
NSView *sub;
while ((sub = [enumerator nextObject]) != nil)
{
[self addSubview: sub];
}
}
if (nextKeyView != nil)
{
[self setNextKeyView: nextKeyView];
}
if ([aDecoder containsValueForKey: @"NSvFlags"])
{
//int vFlags = [aDecoder decodeIntForKey: @"NSvFlags"];
// FIXME set the flags
}
}
RELEASE(subs);
else
{
NSRect rect;
NSEnumerator *e;
NSView *sub;
NSArray *subs;
self = [super initWithCoder: aDecoder];
NSDebugLLog(@"NSView", @"NSView: finish decoding\n");
NSDebugLLog(@"NSView", @"NSView: start decoding\n");
_frame = [aDecoder decodeRect];
_bounds.origin = NSZeroPoint;
_bounds.size = _frame.size;
_frameMatrix = [NSAffineTransform new]; // Map fromsuperview to frame
_boundsMatrix = [NSAffineTransform new]; // Map fromsuperview to bounds
_matrixToWindow = [NSAffineTransform new]; // Map to window coordinates
_matrixFromWindow = [NSAffineTransform new];// Map from window coordinates
[_frameMatrix setFrameOrigin: _frame.origin];
rect = [aDecoder decodeRect];
[self setBounds: rect];
_sub_views = [NSMutableArray new];
_tracking_rects = [NSMutableArray new];
_cursor_rects = [NSMutableArray new];
_super_view = nil;
_window = nil;
_rFlags.needs_display = YES;
_coordinates_valid = NO;
_rFlags.flipped_view = [self isFlipped];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_is_rotated_from_base];
[aDecoder decodeValueOfObjCType: @encode(BOOL)
at: &_is_rotated_or_scaled_from_base];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_post_frame_changes];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_autoresizes_subviews];
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
at: &_autoresizingMask];
[self setNextKeyView: [aDecoder decodeObject]];
[[aDecoder decodeObject] setNextKeyView: self];
[aDecoder decodeValueOfObjCType: @encode(id) at: &subs];
e = [subs objectEnumerator];
while ((sub = [e nextObject]) != nil)
{
NSAssert(sub->_window == nil, NSInternalInconsistencyException);
NSAssert(sub->_super_view == nil, NSInternalInconsistencyException);
[sub viewWillMoveToWindow: _window];
[sub viewWillMoveToSuperview: self];
[sub setNextResponder: self];
[_sub_views addObject: sub];
_rFlags.has_subviews = 1;
[sub resetCursorRects];
[sub setNeedsDisplay: YES];
[sub viewDidMoveToWindow];
[sub viewDidMoveToSuperview];
[self didAddSubview: sub];
}
RELEASE(subs);
NSDebugLLog(@"NSView", @"NSView: finish decoding\n");
}
return self;
}