diff --git a/AppKit/CPClipView.j b/AppKit/CPClipView.j index 2a8e029ed..3ee0dd8a2 100644 --- a/AppKit/CPClipView.j +++ b/AppKit/CPClipView.j @@ -167,3 +167,47 @@ } @end + + +var CPClipViewDocumentViewKey = @"CPScrollViewDocumentView"; + +@implementation CPClipView (CPCoding) + +- (id)initWithCoder:(CPCoder)aCoder +{ + if (self = [super initWithCoder:aCoder]) + { + _documentView = [aCoder decodeObjectForKey:CPClipViewDocumentViewKey]; + + if (_documentView) + { + [_documentView setPostsFrameChangedNotifications:YES]; + [_documentView setPostsBoundsChangedNotifications:YES]; + + var defaultCenter = [CPNotificationCenter defaultCenter]; + + [defaultCenter + addObserver:self + selector:@selector(viewFrameChanged:) + name:CPViewFrameDidChangeNotification + object:_documentView]; + + [defaultCenter + addObserver:self + selector:@selector(viewBoundsChanged:) + name:CPViewBoundsDidChangeNotification + object:_documentView]; + } + } + + return self; +} + +- (void)encodeWithCoder:(CPCoder)aCoder +{ + [super encodeWithCoder:aCoder]; + + [aCoder encodeObject:_documentView forKey:CPClipViewDocumentViewKey]; +} + +@end diff --git a/AppKit/CPScrollView.j b/AppKit/CPScrollView.j index 22560e8e8..5d3cbfe39 100644 --- a/AppKit/CPScrollView.j +++ b/AppKit/CPScrollView.j @@ -626,3 +626,62 @@ } @end + +var CPScrollViewContentViewKey = "CPScrollViewContentView", + CPScrollViewVLineScrollKey = "CPScrollViewVLineScroll", + CPScrollViewHLineScrollKey = "CPScrollViewHLineScroll", + CPScrollViewVPageScrollKey = "CPScrollViewVPageScroll", + CPScrollViewHPageScrollKey = "CPScrollViewHPageScroll", + CPScrollViewHasVScrollerKey = "CPScrollViewHasVScroller", + CPScrollViewHasHScrollerKey = "CPScrollViewHasHScroller", + CPScrollViewVScrollerKey = "CPScrollViewVScroller", + CPScrollViewHScrollerKey = "CPScrollViewHScroller", + CPScrollViewAutohidesScrollerKey = "CPScrollViewAutohidesScroller"; + +@implementation CPScrollView (CPCoding) + +- (id)initWithCoder:(CPCoder)aCoder +{ + if (self = [super initWithCoder:aCoder]) + { + _verticalLineScroll = [aCoder decodeFloatForKey:CPScrollViewVLineScrollKey]; + _verticalPageScroll = [aCoder decodeFloatForKey:CPScrollViewVPageScrollKey]; + + _horizontalLineScroll = [aCoder decodeFloatForKey:CPScrollViewHLineScrollKey]; + _horizontalPageScroll = [aCoder decodeFloatForKey:CPScrollViewHPageScrollKey]; + + _contentView = [aCoder decodeObjectForKey:CPScrollViewContentViewKey]; + + _verticalScroller = [aCoder decodeObjectForKey:CPScrollViewVScrollerKey]; + _horizontalScroller = [aCoder decodeObjectForKey:CPScrollViewHScrollerKey]; + + _hasVerticalScroller = [aCoder decodeBoolForKey:CPScrollViewHasVScrollerKey]; + _hasHorizontalScroller = [aCoder decodeBoolForKey:CPScrollViewHasHScrollerKey]; + _autohidesScrollers = [aCoder decodeBoolForKey:CPScrollViewAutohidesScrollerKey]; + + [[CPRunLoop currentRunLoop] performSelector:@selector(reflectScrolledClipView:) target:self argument:_contentView order:0 modes:[CPDefaultRunLoopMode]]; + } + + return self; +} + +- (void)encodeWithCoder:(CPCoder)aCoder +{ + [super encodeWithCoder:aCoder]; + + [aCoder encodeObject:_contentView forKey:CPScrollViewContentViewKey]; + + [aCoder encodeObject:_verticalScroller forKey:CPScrollViewVScrollerKey]; + [aCoder encodeObject:_horizontalScroller forKey:CPScrollViewHScrollerKey]; + + [aCoder encodeFloat:_verticalLineScroll forKey:CPScrollViewVLineScrollKey]; + [aCoder encodeFloat:_verticalPageScroll forKey:CPScrollViewVPageScrollKey]; + [aCoder encodeFloat:_horizontalLineScroll forKey:CPScrollViewHLineScrollKey]; + [aCoder encodeFloat:_horizontalPageScroll forKey:CPScrollViewHPageScrollKey]; + + [aCoder encodeBool:_hasVerticalScroller forKey:CPScrollViewHasVScrollerKey]; + [aCoder encodeBool:_hasHorizontalScroller forKey:CPScrollViewHasHScrollerKey]; + [aCoder encodeBool:_autohidesScrollers forKey:CPScrollViewAutohidesScrollerKey]; +} + +@end diff --git a/AppKit/CPScroller.j b/AppKit/CPScroller.j index 33cb9f8db..b7a3794b0 100644 --- a/AppKit/CPScroller.j +++ b/AppKit/CPScroller.j @@ -694,3 +694,45 @@ var _CPScrollerClassName = nil, } @end + +var CPScrollerControlSizeKey = "CPScrollerControlSize", + CPScrollerKnobProportionKey = "CPScrollerKnobProportion"; + +@implementation CPScroller (CPCoding) + +- (id)initWithCoder:(CPCoder)aCoder +{ + if (self = [super initWithCoder:aCoder]) + { + _controlSize = CPRegularControlSize; + if ([aCoder containsValueForKey:CPScrollerControlSizeKey]) + _controlSize = [aCoder decodeIntForKey:CPScrollerControlSizeKey]; + + _knobProportion = 1.0; + if ([aCoder containsValueForKey:CPScrollerKnobProportionKey]) + _knobProportion = [aCoder decodeFloatForKey:CPScrollerKnobProportionKey]; + + _partRects = []; + + _isHorizontal = CPRectGetWidth([self frame]) > CPRectGetHeight([self frame]); + + _hitPart = CPScrollerNoPart; + + [self checkSpaceForParts]; + [self drawParts]; + + [self layoutSubviews]; + } + + return self; +} + +- (void)encodeWithCoder:(CPCoder)aCoder +{ + [super encodeWithCoder:aCoder]; + + [aCoder encodeInt:_controlSize forKey:CPScrollerControlSizeKey]; + [aCoder encodeFloat:_knobProportion forKey:CPScrollerKnobProportionKey]; +} + +@end diff --git a/Tools/nib2cib/NSAppKit.j b/Tools/nib2cib/NSAppKit.j index d35bcc452..e10183182 100644 --- a/Tools/nib2cib/NSAppKit.j +++ b/Tools/nib2cib/NSAppKit.j @@ -22,6 +22,7 @@ @import "NSButton.j" @import "NSCell.j" +@import "NSClipView.j" @import "NSColor.j" @import "NSColorWell.j" @import "NSControl.j" @@ -34,6 +35,8 @@ @import "NSNibConnector.j" @import "NSPopUpButton.j" @import "NSResponder.j" +@import "NSScrollView.j" +@import "NSScroller.j" @import "NSSegmentedControl.j" @import "NSSlider.j" @import "NSSplitView.j" diff --git a/Tools/nib2cib/NSClipView.j b/Tools/nib2cib/NSClipView.j new file mode 100644 index 000000000..7ed55cfa5 --- /dev/null +++ b/Tools/nib2cib/NSClipView.j @@ -0,0 +1,59 @@ +/* + * NSClipView.j + * nib2cib + * + * Created by Thomas Robinson. + * Copyright 2008, 280 North, Inc. + * + * 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.1 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; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +@import + + +@implementation CPClipView (CPCoding) + +- (id)NS_initWithCoder:(CPCoder)aCoder +{ + if (self = [super NS_initWithCoder:aCoder]) + { + _documentView = [aCoder decodeObjectForKey:"NSDocView"]; + + if ([aCoder containsValueForKey:"NSBGColor"]) + [self setBackgroundColor:[aCoder decodeObjectForKey:"NSBGColor"]]; + + //var flags = [aCoder decodeIntForKey:"NScvFlags"]; + } + + return self; +} + +@end + +@implementation NSClipView : CPClipView +{ +} + +- (id)initWithCoder:(CPCoder)aCoder +{ + return [self NS_initWithCoder:aCoder]; +} + +- (Class)classForKeyedArchiver +{ + return [CPClipView class]; +} + +@end diff --git a/Tools/nib2cib/NSScrollView.j b/Tools/nib2cib/NSScrollView.j new file mode 100644 index 000000000..4dded33d6 --- /dev/null +++ b/Tools/nib2cib/NSScrollView.j @@ -0,0 +1,68 @@ +/* + * NSScrollView.j + * nib2cib + * + * Created by Thomas Robinson. + * Copyright 2008, 280 North, Inc. + * + * 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.1 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; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +@import + + +@implementation CPScrollView (CPCoding) + +- (id)NS_initWithCoder:(CPCoder)aCoder +{ + if (self = [super NS_initWithCoder:aCoder]) + { + var flags = [aCoder decodeIntForKey:"NSsFlags"]; + + _hasVerticalScroller = Boolean(flags & (1 << 4)); + _hasHorizontalScroller = Boolean(flags & (1 << 5)); + _autohidesScrollers = Boolean(flags & (1 << 9)); + + _verticalScroller = [aCoder decodeObjectForKey:"NSVScroller"]; + _horizontalScroller = [aCoder decodeObjectForKey:"NSHScroller"]; + _contentView = [aCoder decodeObjectForKey:"NSContentView"]; + + //[aCoder decodeBytesForKey:"NSScrollAmts"]; + _verticalLineScroll = 10.0; + _verticalPageScroll = 10.0; + _horizontalLineScroll = 10.0; + _horizontalPageScroll = 10.0; + } + + return self; +} + +@end + +@implementation NSScrollView : CPScrollView +{ +} + +- (id)initWithCoder:(CPCoder)aCoder +{ + return [self NS_initWithCoder:aCoder]; +} + +- (Class)classForKeyedArchiver +{ + return [CPScrollView class]; +} + +@end diff --git a/Tools/nib2cib/NSScroller.j b/Tools/nib2cib/NSScroller.j new file mode 100644 index 000000000..30bd2be12 --- /dev/null +++ b/Tools/nib2cib/NSScroller.j @@ -0,0 +1,68 @@ +/* + * NSScroller.j + * nib2cib + * + * Created by Thomas Robinson. + * Copyright 2008, 280 North, Inc. + * + * 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.1 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; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +@import + + +@implementation CPScroller (CPCoding) + +- (id)NS_initWithCoder:(CPCoder)aCoder +{ + if (self = [super NS_initWithCoder:aCoder]) + { + //"NSsFlags" + //"NSArrowsLoc" + + _controlSize = CPRegularControlSize; + //if ([aCoder containsValueForKey:CPScrollerControlSizeKey]) + // _controlSize = [aCoder decodeIntForKey:CPScrollerControlSizeKey]; + + _knobProportion = 1.0; + if ([aCoder containsValueForKey:"NSPercent"]) + _knobProportion = [aCoder decodeFloatForKey:"NSPercent"]; + + _value = 0.0; + // Cocoa uses NSCurValue instead of NSControl's NSContents + if ([aCoder containsValueForKey:"NSCurValue"]) + _value = [aCoder decodeFloatForKey:"NSCurValue"]; + } + + return self; +} + +@end + +@implementation NSScroller : CPScroller +{ +} + +- (id)initWithCoder:(CPCoder)aCoder +{ + return [self NS_initWithCoder:aCoder]; +} + +- (Class)classForKeyedArchiver +{ + return [CPScroller class]; +} + +@end