From 7f85b8b33f427e1dd52d8dee04bca9882d036d50 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Wed, 6 Jan 2010 21:08:01 -0800 Subject: [PATCH] Tiny bit more support for toolbars in nib2cib. Reviewed by me. --- AppKit/CPToolbarItem.j | 77 ++++++++++++++++++++++++++++++++ Tools/nib2cib/NSAppKit.j | 1 + Tools/nib2cib/NSToolbarItem.j | 84 +++++++++++++++++++++++++++++++++++ 3 files changed, 162 insertions(+) create mode 100644 Tools/nib2cib/NSToolbarItem.j diff --git a/AppKit/CPToolbarItem.j b/AppKit/CPToolbarItem.j index 29df422c4..2cdd5528c 100644 --- a/AppKit/CPToolbarItem.j +++ b/AppKit/CPToolbarItem.j @@ -495,6 +495,83 @@ CPToolbarItemVisibilityPriorityUser @end +var CPToolbarItemIdentifierKey = @"CPToolbarItemIdentifierKey", + CPToolbarItemLabelKey = @"CPToolbarItemLabelKey", + CPToolbarItemPaletteLabelKey = @"CPToolbarItemPaletteLabelKey", + CPToolbarItemToolTipKey = @"CPToolbarItemToolTipKey", + CPToolbarItemTagKey = @"CPToolbarItemTagKey", + CPToolbarItemTargetKey = @"CPToolbarItemTargetKey", + CPToolbarItemActionKey = @"CPToolbarItemActionKey", + CPToolbarItemEnabledKey = @"CPToolbarItemEnabledKey", + CPToolbarItemImageKey = @"CPToolbarItemImageKey", + CPToolbarItemAlternateImageKey = @"CPToolbarItemAlternateImageKey", + CPToolbarItemViewKey = @"CPToolbarItemViewKey", + CPToolbarItemMinSizeKey = @"CPToolbarItemMinSizeKey", + CPToolbarItemMaxSizeKey = @"CPToolbarItemMaxSizeKey", + CPToolbarItemVisibilityPriorityKey = @"CPToolbarItemVisibilityPriorityKey"; + +@implementation CPToolbarItem (CPCoding) + +- (id)initWithCoder:(CPCoder)aCoder +{ + self = [super init]; + + if (self) + { + _itemIdentifier = [aCoder decodeObjectForKey:CPToolbarItemIdentifierKey]; + + [self setLabel:[aCoder decodeObjectForKey:CPToolbarItemLabelKey]]; + [self setPaletteLabel:[aCoder decodeObjectForKey:CPToolbarItemPaletteLabelKey]]; + [self setToolTip:[aCoder decodeObjectForKey:CPToolbarItemToolTipKey]]; + + [self setTag:[aCoder decodeObjectForKey:CPToolbarItemTagKey]]; + [self setTarget:[aCoder decodeObjectForKey:CPToolbarItemTargetKey]]; + [self setAction:[aCoder decodeObjectForKey:CPToolbarItemActionKey]]; + + [self setEnabled:[aCoder decodeBoolForKey:CPToolbarItemEnabledKey]]; + + [self setImage:[aCoder decodeBoolForKey:CPToolbarItemImageKey]]; + [self setAlternateImage:[aCoder decodeBoolForKey:CPToolbarItemAlternateImageKey]]; + + [self setView:[aCoder decodeObjectForKey:CPToolbarItemViewKey]]; + + [self setMinSize:[aCoder decodeSizeForKey:CPToolbarItemMinSizeKey]]; + [self setMaxSize:[aCoder decodeSizeForKey:CPToolbarItemMaxSizeKey]]; + + [self setVisibilityPriority:[aCoder decodeIntForKey:CPToolbarItemVisibilityPriorityKey]]; + } + + return self; +} + +- (void)encodeWithCoder:(CPCoder)aCoder +{ + [aCoder encodeObject:_itemIdentifier forKey:CPToolbarItemItemIdentifierKey]; + + [aCoder encodeObject:[self label] forKey:CPToolbarItemLabelKey]; + [aCoder encodeObject:[self paletteLabel] forKey:CPToolbarItemPaletteLabelKey]; + + [aCoder encodeObject:[self toolTip] forKey:CPToolbarItemToolTipKey]; + + [aCoder encodeObject:[self tag] forKey:CPToolbarItemTagKey]; + [aCoder encodeObject:[self target] forKey:CPToolbarItemTargetKey]; + [aCoder encodeObject:[self action] forKey:CPToolbarItemActionKey]; + + [aCoder encodeObject:[self isEnabled] forKey:CPToolbarItemEnabledKey]; + + [aCoder encodeObject:[self image] forKey:CPToolbarItemImageKey]; + [aCoder encodeObject:[self alternateImage] forKey:CPToolbarItemAlternateImageKey]; + + [aCoder encodeObject:[self view] forKey:CPToolbarItemViewKey]; + + [aCoder encodeSize:[self minSize] forKey:CPToolbarItemMinSizeKey]; + [aCoder encodeSize:[self maxSize] forKey:CPToolbarItemMaxSizeKey]; + + [aCoder encodeObject:[self visibilityPriority] forKey:CPToolbarItemVisibilityPriorityKey]; +} + +@end + @implementation CPToolbarItem (CPCopying) - (id)copy diff --git a/Tools/nib2cib/NSAppKit.j b/Tools/nib2cib/NSAppKit.j index 1852ebf55..b6c4cda04 100644 --- a/Tools/nib2cib/NSAppKit.j +++ b/Tools/nib2cib/NSAppKit.j @@ -55,6 +55,7 @@ @import "NSTabViewItem.j" @import "NSTextField.j" @import "NSToolbar.j" +@import "NSToolbarItem.j" @import "NSView.j" @import "NSViewController.j" @import "NSWindowTemplate.j" diff --git a/Tools/nib2cib/NSToolbarItem.j b/Tools/nib2cib/NSToolbarItem.j new file mode 100644 index 000000000..1fc82af08 --- /dev/null +++ b/Tools/nib2cib/NSToolbarItem.j @@ -0,0 +1,84 @@ +/* + * NSToolbarItem.j + * nib2cib + * + * Created by Francisco Tolmasky. + * Copyright 2010, 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 CPToolbarItem (NSCoding) + +- (id)NS_initWithCoder:(CPCoder)aCoder +{ + self = [super init]; + + if (self) + { + _itemIdentifier = [aCoder decodeObjectForKey:@"NSToolbarItemIdentifier"]; + + [self setLabel:[aCoder decodeObjectForKey:@"NSToolbarItemLabel"]]; + [self setPaletteLabel:[aCoder decodeObjectForKey:@"NSToolbarItemPaletteLabel"]]; + [self setToolTip:[aCoder decodeObjectForKey:@"NSToolbarItemToolTip"]]; + + [self setTag:[aCoder decodeObjectForKey:@"NSToolbarItemTag"]]; + [self setTarget:[aCoder decodeObjectForKey:@"NSToolbarItemTarget"]]; + [self setAction:CPSelectorFromString([aCoder decodeObjectForKey:@"NSToolbarItemAction"])]; + + [self setEnabled:[aCoder decodeBoolForKey:@"NSToolbarItemEnabled"]]; + + [self setImage:[aCoder decodeBoolForKey:@"NSToolbarItemImage"]]; + + [self setView:[aCoder decodeObjectForKey:@"NSToolbarItemView"]]; + + _minSize = [aCoder decodeSizeForKey:@"NSToolbarItemMinSize"]; + _maxSize = [aCoder decodeSizeForKey:@"NSToolbarItemMaxSize"]; + + [self setVisibilityPriority:[aCoder decodeIntForKey:@"NSToolbarItemVisibilityPriority"]]; + } + + return self; +} + +@end + +@implementation NSToolbarItem : CPToolbarItem +{ +} + +- (id)initWithCoder:(CPCoder)aCoder +{ + return [self NS_initWithCoder:aCoder]; +} + +- (Class)classForKeyedArchiver +{ + return [CPToolbarItem class]; +} + +@end + +@implementation NSToolbarSpaceItem : NSToolbarItem +@end + +@implementation NSToolbarFlexibleSpaceItem : NSToolbarItem +@end + +@implementation NSToolbarSeparatorItem : NSToolbarItem +@end