Fixes for NSScrollView

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4842 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-09-07 05:31:44 +00:00
parent 63e43e1956
commit 44dc7234b5
3 changed files with 101 additions and 15 deletions

View file

@ -1,3 +1,10 @@
Tue Sep 7 6:50:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSScrollView.m: ([-setContentView:]) prohibit illegal settings.
([-encodeWithCoder:]) and ([-initWithCoder:]) implemented.
* Model/GMAppKit.m: Fix NSScrollView initialisation to create the
content-view (NSClipView) as it should.
1999-09-06 Nicola Pero <n.pero@mi.flashnet.it>
* Source/NSMatrix: Added missing method ([-sizeToFit]).

View file

@ -425,28 +425,40 @@ void __dummy_GMAppKit_functionForLinking() {}
return [NSArray array];
}
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
- (void) encodeWithModelArchiver: (GMArchiver*)archiver
{
[super encodeWithModelArchiver:archiver];
[super encodeWithModelArchiver: archiver];
[archiver encodeObject:[self backgroundColor] withName:@"backgroundColor"];
[archiver encodeInt:[self borderType] withName:@"borderType"];
[archiver encodeBOOL:[self hasHorizontalScroller] withName:@"hasHorizontalScroller"];
[archiver encodeBOOL:[self hasVerticalScroller] withName:@"hasVerticalScroller"];
[archiver encodeObject:[self documentView] withName:@"documentView"];
[archiver encodeObject: [self backgroundColor]
withName: @"backgroundColor"];
[archiver encodeInt: [self borderType]
withName: @"borderType"];
[archiver encodeBOOL: [self hasHorizontalScroller]
withName: @"hasHorizontalScroller"];
[archiver encodeBOOL: [self hasVerticalScroller]
withName: @"hasVerticalScroller"];
[archiver encodeObject: [self documentView]
withName: @"documentView"];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
- (id) initWithModelUnarchiver: (GMUnarchiver*)unarchiver
{
self = [super initWithModelUnarchiver:unarchiver];
self = [super initWithModelUnarchiver: unarchiver];
[self setBackgroundColor:[unarchiver decodeObjectWithName:@"backgroundColor"]];
[self setBorderType:[unarchiver decodeIntWithName:@"borderType"]];
[self setHasHorizontalScroller:[unarchiver decodeBOOLWithName:@"hasHorizontalScroller"]];
[self setHasVerticalScroller:[unarchiver decodeBOOLWithName:@"hasVerticalScroller"]];
[self setDocumentView:[unarchiver decodeObjectWithName:@"documentView"]];
[self setContentView: AUTORELEASE([NSClipView new])];
return self;
[self setBackgroundColor:
[unarchiver decodeObjectWithName: @"backgroundColor"]];
[self setBorderType:
[unarchiver decodeIntWithName: @"borderType"]];
[self setHasHorizontalScroller:
[unarchiver decodeBOOLWithName: @"hasHorizontalScroller"]];
[self setHasVerticalScroller:
[unarchiver decodeBOOLWithName: @"hasVerticalScroller"]];
[self setDocumentView:
[unarchiver decodeObjectWithName: @"documentView"]];
return self;
}
@end /* NSScrollView (GMArchiverMethods) */

View file

@ -195,6 +195,12 @@ static Class rulerViewClass = nil;
- (void) setContentView: (NSClipView*)aView
{
if (aView == nil)
[NSException raise: NSInvalidArgumentException
format: @"Attempt to set nil content view"];
if ([aView isKindOfClass: [NSView class]] == NO)
[NSException raise: NSInvalidArgumentException
format: @"Attempt to set non-view object as content view"];
ASSIGN((id)_contentView, (id)aView);
[self addSubview: _contentView];
[_contentView setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
@ -777,4 +783,65 @@ static Class rulerViewClass = nil;
return _vertScroller;
}
/*
* NSCoding protocol
*/
- (void) encodeWithCoder: (NSCoder*)aCoder
{
[super encodeWithCoder: aCoder];
NSDebugLLog(@"NSScrollView", @"NSScrollView: start encoding\n");
[aCoder encodeObject: _contentView];
[aCoder encodeValueOfObjCType: @encode(NSBorderType) at: &_borderType];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_scrollsDynamically];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_rulersVisible];
[aCoder encodeValueOfObjCType: @encode(float) at: &_hLineScroll];
[aCoder encodeValueOfObjCType: @encode(float) at: &_hPageScroll];
[aCoder encodeValueOfObjCType: @encode(float) at: &_vLineScroll];
[aCoder encodeValueOfObjCType: @encode(float) at: &_vPageScroll];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_hasHorizScroller];
if (_hasHorizScroller)
[aCoder encodeObject: _horizScroller];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_hasVertScroller];
if (_hasVertScroller)
[aCoder encodeObject: _vertScroller];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_hasHorizRuler];
if (_hasHorizRuler)
[aCoder encodeObject: _horizRuler];
[aCoder encodeValueOfObjCType: @encode(BOOL) at: &_hasVertRuler];
if (_hasVertRuler)
[aCoder encodeObject: _vertRuler];
NSDebugLLog(@"NSScrollView", @"NSScrollView: finish encoding\n");
}
- (id) initWithCoder: (NSCoder*)aDecoder
{
[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: &_horizScroller];
if (_horizScroller)
[aDecoder decodeValueOfObjCType: @encode(id) at: &_horizScroller];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_vertScroller];
if (_vertScroller)
[aDecoder decodeValueOfObjCType: @encode(id) at: &_vertScroller];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_horizRuler];
if (_horizRuler)
[aDecoder decodeValueOfObjCType: @encode(id) at: &_horizRuler];
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_vertRuler];
if (_vertRuler)
[aDecoder decodeValueOfObjCType: @encode(id) at: &_vertRuler];
NSDebugLLog(@"NSScrollView", @"NSScrollView: finish decoding\n");
return self;
}
@end