mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 18:50:48 +00:00
Improvements in keyed coding and correction for NSCell formatter unarchiving issue.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20235 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
31eeedc9c5
commit
c0dc199651
7 changed files with 160 additions and 51 deletions
17
ChangeLog
17
ChangeLog
|
@ -1,4 +1,21 @@
|
||||||
|
2004-10-17 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
|
* Source/NSCell.m: Added code to [NSCell initWithCoder:] which
|
||||||
|
properly retains the formatter and menu.
|
||||||
|
* Source/GSNibCompatibility.m: Changed comment.
|
||||||
|
* Source/NSResponder.m: Added keyed archiving implementation in
|
||||||
|
initWithCoder:
|
||||||
|
* Source/NSTextView.m: Improved implementation of keyed coding
|
||||||
|
for NSTextView. Also preparing to add details discovered about
|
||||||
|
the flag settings.
|
||||||
|
* Source/NSView.m: Improved NSView keyed decoding. Also made
|
||||||
|
sure that [super initWithCoder:] is called in that method for both
|
||||||
|
the keyed and non-keyed archiving (as it should be).
|
||||||
|
* Source/NSWindow.m: Added implementation of undo: and redo: to
|
||||||
|
NSWindow.m.
|
||||||
|
|
||||||
2004-10-17 Adrian Robert <arobert@cogsci.ucsd.edu>
|
2004-10-17 Adrian Robert <arobert@cogsci.ucsd.edu>
|
||||||
|
|
||||||
* Source/Functions.m (NSBestDepth): Check outarg exactMatch is
|
* Source/Functions.m (NSBestDepth): Check outarg exactMatch is
|
||||||
non-null before setting.
|
non-null before setting.
|
||||||
* Source/NSFont.m (getNSFont): Use defaultSize for 'fontSize'
|
* Source/NSFont.m (getNSFont): Use defaultSize for 'fontSize'
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
They will be removed from the GUI library in the next few versions as
|
They will be removed from the GUI library in the next few versions as
|
||||||
they need to be phased out gradually.
|
they need to be phased out gradually.
|
||||||
<p/>
|
<p/>
|
||||||
If you have any .gorm files which were created using custom classes, you
|
If you have any older .gorm files which were created using custom classes,
|
||||||
should load them into Gorm and save them so that they will use the new
|
you should load them into Gorm and save them so that they will use the new
|
||||||
system. Updating the .gorm files should be as easy as that. These
|
system. Updating the .gorm files should be as easy as that. These
|
||||||
classes are included ONLY for backwards compatibility.
|
classes are included ONLY for backwards compatibility.
|
||||||
</abstract>
|
</abstract>
|
||||||
|
|
|
@ -2079,7 +2079,8 @@ static NSColor *shadowCol;
|
||||||
{
|
{
|
||||||
BOOL flag;
|
BOOL flag;
|
||||||
unsigned int tmp_int;
|
unsigned int tmp_int;
|
||||||
|
id formatter, menu;
|
||||||
|
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_contents];
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_contents];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_cell_image];
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_cell_image];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_font];
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_font];
|
||||||
|
@ -2132,10 +2133,12 @@ static NSColor *shadowCol;
|
||||||
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
|
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
|
||||||
at: &_mouse_down_flags];
|
at: &_mouse_down_flags];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &_action_mask];
|
[aDecoder decodeValueOfObjCType: @encode(unsigned int) at: &_action_mask];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_formatter];
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &formatter];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_menu];
|
[self setFormatter: formatter];
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &menu];
|
||||||
|
[self setMenu: menu];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_represented_object];
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_represented_object];
|
||||||
|
|
||||||
if (_formatter != nil)
|
if (_formatter != nil)
|
||||||
{
|
{
|
||||||
NSString *contents;
|
NSString *contents;
|
||||||
|
|
|
@ -338,18 +338,51 @@
|
||||||
*/
|
*/
|
||||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||||
{
|
{
|
||||||
[aCoder encodeValueOfObjCType: @encode(NSInterfaceStyle)
|
if([aCoder allowsKeyedCoding])
|
||||||
at: &_interface_style];
|
{
|
||||||
[aCoder encodeObject: _menu];
|
if(_interface_style != NSNoInterfaceStyle)
|
||||||
|
{
|
||||||
|
[aCoder encodeInt: _interface_style
|
||||||
|
forKey: @"NSInterfaceStyle"];
|
||||||
|
}
|
||||||
|
|
||||||
|
if([self menu] != nil)
|
||||||
|
{
|
||||||
|
[aCoder encodeObject: [self menu]
|
||||||
|
forKey: @"NSMenu"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(NSInterfaceStyle)
|
||||||
|
at: &_interface_style];
|
||||||
|
[aCoder encodeObject: _menu];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||||
{
|
{
|
||||||
id obj;
|
id obj;
|
||||||
|
|
||||||
[aDecoder decodeValueOfObjCType: @encode(NSInterfaceStyle)
|
if([aDecoder allowsKeyedCoding])
|
||||||
at: &_interface_style];
|
{
|
||||||
obj = [aDecoder decodeObject];
|
if([aDecoder containsValueForKey: @"NSInterfaceStyle"])
|
||||||
|
{
|
||||||
|
_interface_style = [aDecoder decodeIntForKey: @"NSInterfaceStyle"];
|
||||||
|
}
|
||||||
|
|
||||||
|
if([aDecoder containsValueForKey: @"NSMenu"])
|
||||||
|
{
|
||||||
|
obj = [aDecoder decodeObjectForKey: @"NSMenu"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[aDecoder decodeValueOfObjCType: @encode(NSInterfaceStyle)
|
||||||
|
at: &_interface_style];
|
||||||
|
obj = [aDecoder decodeObject];
|
||||||
|
}
|
||||||
|
|
||||||
[self setMenu: obj];
|
[self setMenu: obj];
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
|
|
@ -133,6 +133,7 @@ Interface for a bunch of internal methods that need to be cleaned up.
|
||||||
NSArray *linkAttr;
|
NSArray *linkAttr;
|
||||||
NSArray *markAttr;
|
NSArray *markAttr;
|
||||||
NSArray *selectedAttr;
|
NSArray *selectedAttr;
|
||||||
|
NSTextView *textView;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -656,20 +657,24 @@ that makes decoding and encoding compatible with the old code.
|
||||||
{
|
{
|
||||||
[self setMaxSize: [aDecoder decodeSizeForKey: @"NSMaxSize"]];
|
[self setMaxSize: [aDecoder decodeSizeForKey: @"NSMaxSize"]];
|
||||||
}
|
}
|
||||||
// Is this a mistype from Apple?
|
|
||||||
if ([aDecoder containsValueForKey: @"NSMinize"])
|
if ([aDecoder containsValueForKey: @"NSMinize"])
|
||||||
{
|
{
|
||||||
|
// it's NSMinize in pre-10.3 formats.
|
||||||
[self setMinSize: [aDecoder decodeSizeForKey: @"NSMinize"]];
|
[self setMinSize: [aDecoder decodeSizeForKey: @"NSMinize"]];
|
||||||
}
|
}
|
||||||
|
if ([aDecoder containsValueForKey: @"NSMinSize"])
|
||||||
|
{
|
||||||
|
// However, if NSMinSize is present we want to use it.
|
||||||
|
[self setMinSize: [aDecoder decodeSizeForKey: @"NSMinSize"]];
|
||||||
|
}
|
||||||
if ([aDecoder containsValueForKey: @"NSTextContainer"])
|
if ([aDecoder containsValueForKey: @"NSTextContainer"])
|
||||||
{
|
{
|
||||||
[self setTextContainer: [aDecoder decodeObjectForKey: @"NSTextContainer"]];
|
[self setTextContainer: [aDecoder decodeObjectForKey: @"NSTextContainer"]];
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME set the flags, shared data, storage
|
|
||||||
if ([aDecoder containsValueForKey: @"NSTVFlags"])
|
if ([aDecoder containsValueForKey: @"NSTVFlags"])
|
||||||
{
|
{
|
||||||
//int vFlags = [aDecoder decodeIntForKey: @"NSTVFlags"];
|
int vFlags = [aDecoder decodeIntForKey: @"NSTVFlags"];
|
||||||
// FIXME set the flags
|
// FIXME set the flags
|
||||||
}
|
}
|
||||||
if ([aDecoder containsValueForKey: @"NSSharedData"])
|
if ([aDecoder containsValueForKey: @"NSSharedData"])
|
||||||
|
|
113
Source/NSView.m
113
Source/NSView.m
|
@ -3736,41 +3736,84 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
||||||
*/
|
*/
|
||||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||||
{
|
{
|
||||||
[super encodeWithCoder: aCoder];
|
if([aCoder allowsKeyedCoding])
|
||||||
|
{
|
||||||
|
int vFlags = 0;
|
||||||
|
|
||||||
NSDebugLLog(@"NSView", @"NSView: start encoding\n");
|
// encoding
|
||||||
[aCoder encodeRect: _frame];
|
[aCoder encodeConditionalObject: [self nextKeyView]
|
||||||
[aCoder encodeRect: _bounds];
|
forKey: @"NSNextKeyView"];
|
||||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_is_rotated_from_base];
|
[aCoder encodeConditionalObject: [self previousKeyView]
|
||||||
[aCoder encodeValueOfObjCType: @encode(BOOL)
|
forKey: @"NSPreviousKeyView"];
|
||||||
at: &_is_rotated_or_scaled_from_base];
|
[aCoder encodeObject: _sub_views
|
||||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_post_frame_changes];
|
forKey: @"NSSubviews"];
|
||||||
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_autoresizes_subviews];
|
[aCoder encodeRect: _frame
|
||||||
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_autoresizingMask];
|
forKey: @"NSFrame"];
|
||||||
[aCoder encodeConditionalObject: [self nextKeyView]];
|
|
||||||
[aCoder encodeConditionalObject: [self previousKeyView]];
|
// autosizing masks.
|
||||||
[aCoder encodeObject: _sub_views];
|
vFlags = _autoresizingMask;
|
||||||
NSDebugLLog(@"NSView", @"NSView: finish encoding\n");
|
|
||||||
|
// add the autoresize flag.
|
||||||
|
if(_autoresizes_subviews)
|
||||||
|
{
|
||||||
|
vFlags |= 0x100;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the hidden flag
|
||||||
|
if(_is_hidden)
|
||||||
|
{
|
||||||
|
vFlags |= 0x80000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
[aCoder encodeInt: vFlags
|
||||||
|
forKey: @"NSvFlags"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSDebugLLog(@"NSView", @"NSView: start encoding\n");
|
||||||
|
[super encodeWithCoder: aCoder];
|
||||||
|
|
||||||
|
[aCoder encodeRect: _frame];
|
||||||
|
[aCoder encodeRect: _bounds];
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_is_rotated_from_base];
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(BOOL)
|
||||||
|
at: &_is_rotated_or_scaled_from_base];
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_post_frame_changes];
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_autoresizes_subviews];
|
||||||
|
[aCoder encodeValueOfObjCType: @encode(unsigned int) at: &_autoresizingMask];
|
||||||
|
[aCoder encodeConditionalObject: [self nextKeyView]];
|
||||||
|
[aCoder encodeConditionalObject: [self previousKeyView]];
|
||||||
|
[aCoder encodeObject: _sub_views];
|
||||||
|
NSDebugLLog(@"NSView", @"NSView: finish encoding\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder*)aDecoder
|
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||||
{
|
{
|
||||||
|
// decode the superclass...
|
||||||
|
[super initWithCoder: aDecoder];
|
||||||
|
|
||||||
|
// initialize these here, since they're needed in either case.
|
||||||
|
_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
|
||||||
|
|
||||||
if ([aDecoder allowsKeyedCoding])
|
if ([aDecoder allowsKeyedCoding])
|
||||||
{
|
{
|
||||||
NSRect frame = NSZeroRect;
|
NSView *prevKeyView = [aDecoder decodeObjectForKey: @"NSPreviousKeyView"];
|
||||||
//id next = [aDecoder decodeObjectForKey: @"NSNextResponder"];
|
|
||||||
//NSView *superView = [aDecoder decodeObjectForKey: @"NSSuperview"];
|
|
||||||
NSView *nextKeyView = [aDecoder decodeObjectForKey: @"NSNextKeyView"];
|
NSView *nextKeyView = [aDecoder decodeObjectForKey: @"NSNextKeyView"];
|
||||||
NSArray *subViews = [aDecoder decodeObjectForKey: @"NSSubviews"];
|
NSArray *subViews = [aDecoder decodeObjectForKey: @"NSSubviews"];
|
||||||
|
|
||||||
if ([aDecoder containsValueForKey: @"NSFrame"])
|
if ([aDecoder containsValueForKey: @"NSFrame"])
|
||||||
{
|
{
|
||||||
frame = [aDecoder decodeRectForKey: @"NSFrame"];
|
_frame = [aDecoder decodeRectForKey: @"NSFrame"];
|
||||||
|
[_frameMatrix setFrameOrigin: _frame.origin];
|
||||||
}
|
}
|
||||||
self = [self initWithFrame: frame];
|
self = [self initWithFrame: _frame];
|
||||||
|
|
||||||
if (subViews != nil)
|
if (subViews != nil)
|
||||||
{
|
{
|
||||||
NSEnumerator *enumerator = [subViews objectEnumerator];
|
NSEnumerator *enumerator = [subViews objectEnumerator];
|
||||||
NSView *sub;
|
NSView *sub;
|
||||||
|
|
||||||
|
@ -3780,13 +3823,17 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nextKeyView != nil)
|
if (nextKeyView != nil)
|
||||||
{
|
{
|
||||||
[self setNextKeyView: nextKeyView];
|
[self setNextKeyView: nextKeyView];
|
||||||
}
|
}
|
||||||
|
if (prevKeyView != nil)
|
||||||
|
{
|
||||||
|
[self setPreviousKeyView: prevKeyView];
|
||||||
|
}
|
||||||
if ([aDecoder containsValueForKey: @"NSvFlags"])
|
if ([aDecoder containsValueForKey: @"NSvFlags"])
|
||||||
{
|
{
|
||||||
int vFlags = [aDecoder decodeIntForKey: @"NSvFlags"];
|
int vFlags = [aDecoder decodeIntForKey: @"NSvFlags"];
|
||||||
|
|
||||||
// We are lucky here, Apple use the same constants
|
// We are lucky here, Apple use the same constants
|
||||||
// in the lower bits of the flags
|
// in the lower bits of the flags
|
||||||
[self setAutoresizingMask: vFlags & 0x3F];
|
[self setAutoresizingMask: vFlags & 0x3F];
|
||||||
|
@ -3797,27 +3844,21 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSRect rect;
|
NSRect rect;
|
||||||
NSEnumerator *e;
|
NSEnumerator *e;
|
||||||
NSView *sub;
|
NSView *sub;
|
||||||
NSArray *subs;
|
NSArray *subs;
|
||||||
|
|
||||||
self = [super initWithCoder: aDecoder];
|
|
||||||
|
|
||||||
NSDebugLLog(@"NSView", @"NSView: start decoding\n");
|
NSDebugLLog(@"NSView", @"NSView: start decoding\n");
|
||||||
|
|
||||||
_frame = [aDecoder decodeRect];
|
_frame = [aDecoder decodeRect];
|
||||||
|
|
||||||
_bounds.origin = NSZeroPoint;
|
_bounds.origin = NSZeroPoint;
|
||||||
_bounds.size = _frame.size;
|
_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];
|
[_frameMatrix setFrameOrigin: _frame.origin];
|
||||||
|
|
||||||
rect = [aDecoder decodeRect];
|
rect = [aDecoder decodeRect];
|
||||||
[self setBounds: rect];
|
[self setBounds: rect];
|
||||||
|
|
||||||
_sub_views = [NSMutableArray new];
|
_sub_views = [NSMutableArray new];
|
||||||
_tracking_rects = [NSMutableArray new];
|
_tracking_rects = [NSMutableArray new];
|
||||||
_cursor_rects = [NSMutableArray new];
|
_cursor_rects = [NSMutableArray new];
|
||||||
|
@ -3842,7 +3883,7 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &subs];
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &subs];
|
||||||
e = [subs objectEnumerator];
|
e = [subs objectEnumerator];
|
||||||
while ((sub = [e nextObject]) != nil)
|
while ((sub = [e nextObject]) != nil)
|
||||||
{
|
{
|
||||||
NSAssert(sub->_window == nil, NSInternalInconsistencyException);
|
NSAssert(sub->_window == nil, NSInternalInconsistencyException);
|
||||||
NSAssert(sub->_super_view == nil, NSInternalInconsistencyException);
|
NSAssert(sub->_super_view == nil, NSInternalInconsistencyException);
|
||||||
[sub viewWillMoveToWindow: _window];
|
[sub viewWillMoveToWindow: _window];
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
#include "AppKit/NSColor.h"
|
#include "AppKit/NSColor.h"
|
||||||
#include "AppKit/NSColorList.h"
|
#include "AppKit/NSColorList.h"
|
||||||
#include "AppKit/NSCursor.h"
|
#include "AppKit/NSCursor.h"
|
||||||
|
#include "AppKit/NSDocumentController.h"
|
||||||
#include "AppKit/NSDocument.h"
|
#include "AppKit/NSDocument.h"
|
||||||
#include "AppKit/NSDragging.h"
|
#include "AppKit/NSDragging.h"
|
||||||
#include "AppKit/NSFont.h"
|
#include "AppKit/NSFont.h"
|
||||||
|
@ -4147,6 +4148,15 @@ resetCursorRectsForView(NSView *theView)
|
||||||
return (void *)_windowNum;
|
return (void *)_windowNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) undo: (id)sender
|
||||||
|
{
|
||||||
|
[[[[NSDocumentController sharedDocumentController] currentDocument] undoManager] undo];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) redo: (id)sender
|
||||||
|
{
|
||||||
|
[[[[NSDocumentController sharedDocumentController] currentDocument] undoManager] redo];
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue