PageRenderTime 22ms CodeModel.GetById 18ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/Tools/nib2cib/NSPopUpButton.j

http://github.com/cacaodev/cappuccino
Unknown | 103 lines | 81 code | 22 blank | 0 comment | 0 complexity | eef6f579c41604c4207cbe39190e7c63 MD5 | raw file
  1/*
  2 * NSPopUpButton.j
  3 * nib2cib
  4 *
  5 * Created by Thomas Robinson.
  6 * Copyright 2008, 280 North, Inc.
  7 *
  8 * This library is free software; you can redistribute it and/or
  9 * modify it under the terms of the GNU Lesser General Public
 10 * License as published by the Free Software Foundation; either
 11 * version 2.1 of the License, or (at your option) any later version.
 12 *
 13 * This library is distributed in the hope that it will be useful,
 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 16 * Lesser General Public License for more details.
 17 *
 18 * You should have received a copy of the GNU Lesser General Public
 19 * License along with this library; if not, write to the Free Software
 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 21 */
 22
 23@import <AppKit/CPPopUpButton.j>
 24
 25@import "NSMenu.j"
 26@import "NSMenuItem.j"
 27
 28
 29@implementation CPPopUpButton (CPCoding)
 30
 31- (id)NS_initWithCoder:(CPCoder)aCoder
 32{
 33    return [super NS_initWithCoder:aCoder];
 34}
 35
 36- (void)NS_initWithCell:(NSCell)cell
 37{
 38    [super NS_initWithCell:cell];
 39
 40    _menu = [cell menu];
 41    [self setPullsDown:[cell pullsDown]];
 42    _preferredEdge  = [cell preferredEdge];
 43}
 44
 45@end
 46
 47@implementation NSPopUpButton : CPPopUpButton
 48{
 49}
 50
 51- (id)initWithCoder:(CPCoder)aCoder
 52{
 53    self = [self NS_initWithCoder:aCoder];
 54
 55    if (self)
 56    {
 57        var cell = [aCoder decodeObjectForKey:@"NSCell"];
 58        [self NS_initWithCell:cell];
 59        [self _adjustNib2CibSize];
 60    }
 61
 62    return self;
 63}
 64
 65- (Class)classForKeyedArchiver
 66{
 67    return [CPPopUpButton class];
 68}
 69
 70@end
 71
 72
 73@implementation NSPopUpButtonCell : NSMenuItemCell
 74{
 75    BOOL    pullsDown      @accessors(readonly);
 76    int     selectedIndex  @accessors(readonly);
 77    int     preferredEdge  @accessors(readonly);
 78    CPMenu  menu           @accessors(readonly);
 79}
 80
 81- (id)initWithCoder:(CPCoder)aCoder
 82{
 83    self = [super initWithCoder:aCoder];
 84
 85    if (self)
 86    {
 87        pullsDown      = [aCoder decodeBoolForKey:@"NSPullDown"];
 88        selectedIndex  = [aCoder decodeIntForKey:@"NSSelectedIndex"];
 89        preferredEdge  = [aCoder decodeIntForKey:@"NSPreferredEdge"];
 90        menu           = [aCoder decodeObjectForKey:@"NSMenu"];
 91    }
 92
 93    return self;
 94}
 95
 96
 97// - [NSPopUpButton objectValue] is overridden to return the selected index.
 98- (CPUInteger)objectValue
 99{
100    return selectedIndex;
101}
102
103@end