PageRenderTime 13ms CodeModel.GetById 8ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/Tools/nib2cib/NSSearchField.j

http://github.com/cacaodev/cappuccino
Unknown | 97 lines | 77 code | 20 blank | 0 comment | 0 complexity | 17b72958be1b5c6e657c104b3f2b2c56 MD5 | raw file
 1/*
 2 * NSSearchField.j
 3 * nib2cib
 4 *
 5 * Created by Francisco Tolmasky.
 6 * Copyright 2010, 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/CPSearchField.j>
24
25@import "NSTextField.j"
26
27@class Nib2Cib
28
29
30@implementation CPSearchField (NSCoding)
31
32- (id)NS_initWithCoder:(CPCoder)aCoder
33{
34    return [super NS_initWithCoder:aCoder];
35}
36
37- (void)NS_initWithCell:(NSCell)cell
38{
39    [super NS_initWithCell:cell];
40
41    [self setRecentsAutosaveName:[cell recentsAutosaveName]];
42    [self setMaximumRecents:[cell maximumRecents]];
43    [self setSendsWholeSearchString:[cell sendsWholeSearchString]];
44    [self setSendsSearchStringImmediately:[cell sendsSearchStringImmediately]];
45}
46
47@end
48
49@implementation NSSearchField : CPSearchField
50{
51}
52
53- (id)initWithCoder:(CPCoder)aCoder
54{
55    self = [self NS_initWithCoder:aCoder];
56
57    if (self)
58    {
59        var cell = [aCoder decodeObjectForKey:@"NSCell"];
60        [self NS_initWithCell:cell];
61        [self _adjustNib2CibSize];
62    }
63
64    return self;
65}
66
67- (Class)classForKeyedArchiver
68{
69    return [CPSearchField class];
70}
71
72@end
73
74@implementation NSSearchFieldCell : NSTextFieldCell
75{
76    CPString    _recentsAutosaveName @accessors(property=recentsAutosaveName);
77    int         _maximumRecents @accessors(property=maximumRecents);
78    BOOL        _sendsWholeSearchString @accessors(property=sendsWholeSearchString);
79    BOOL        _sendsSearchStringImmediately @accessors(property=sendsSearchStringImmediately);
80}
81
82- (id)initWithCoder:(CPCoder)aCoder
83{
84    if (self = [super initWithCoder:aCoder])
85    {
86        _recentsAutosaveName = [aCoder decodeObjectForKey:@"NSRecentsAutosaveName"];
87        _maximumRecents = [aCoder decodeIntForKey:@"NSMaximumRecents"];
88        _sendsWholeSearchString = [aCoder decodeBoolForKey:@"NSSendsWholeSearchString"];
89
90        // These bytes don't seem to be used for anything else but the send immediately flag
91        _sendsSearchStringImmediately = [aCoder decodeBytesForKey:@"NSSearchFieldFlags"] ? YES : NO;
92    }
93
94    return self;
95}
96
97@end