Tiny bit more support for toolbars in nib2cib.

Reviewed by me.
This commit is contained in:
Francisco Ryan Tolmasky I
2010-01-06 21:08:01 -08:00
parent af03085d5f
commit 7f85b8b33f
3 changed files with 162 additions and 0 deletions
+77
View File
@@ -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
+1
View File
@@ -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"
+84
View File
@@ -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 <AppKit/CPToolbarItem.j>
@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