/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. @import <AppKit/CPSearchField.j>
  23. @import "NSTextField.j"
  24. @class Nib2Cib
  25. @implementation CPSearchField (NSCoding)
  26. - (id)NS_initWithCoder:(CPCoder)aCoder
  27. {
  28. return [super NS_initWithCoder:aCoder];
  29. }
  30. - (void)NS_initWithCell:(NSCell)cell
  31. {
  32. [super NS_initWithCell:cell];
  33. [self setRecentsAutosaveName:[cell recentsAutosaveName]];
  34. [self setMaximumRecents:[cell maximumRecents]];
  35. [self setSendsWholeSearchString:[cell sendsWholeSearchString]];
  36. [self setSendsSearchStringImmediately:[cell sendsSearchStringImmediately]];
  37. }
  38. @end
  39. @implementation NSSearchField : CPSearchField
  40. {
  41. }
  42. - (id)initWithCoder:(CPCoder)aCoder
  43. {
  44. self = [self NS_initWithCoder:aCoder];
  45. if (self)
  46. {
  47. var cell = [aCoder decodeObjectForKey:@"NSCell"];
  48. [self NS_initWithCell:cell];
  49. [self _adjustNib2CibSize];
  50. }
  51. return self;
  52. }
  53. - (Class)classForKeyedArchiver
  54. {
  55. return [CPSearchField class];
  56. }
  57. @end
  58. @implementation NSSearchFieldCell : NSTextFieldCell
  59. {
  60. CPString _recentsAutosaveName @accessors(property=recentsAutosaveName);
  61. int _maximumRecents @accessors(property=maximumRecents);
  62. BOOL _sendsWholeSearchString @accessors(property=sendsWholeSearchString);
  63. BOOL _sendsSearchStringImmediately @accessors(property=sendsSearchStringImmediately);
  64. }
  65. - (id)initWithCoder:(CPCoder)aCoder
  66. {
  67. if (self = [super initWithCoder:aCoder])
  68. {
  69. _recentsAutosaveName = [aCoder decodeObjectForKey:@"NSRecentsAutosaveName"];
  70. _maximumRecents = [aCoder decodeIntForKey:@"NSMaximumRecents"];
  71. _sendsWholeSearchString = [aCoder decodeBoolForKey:@"NSSendsWholeSearchString"];
  72. // These bytes don't seem to be used for anything else but the send immediately flag
  73. _sendsSearchStringImmediately = [aCoder decodeBytesForKey:@"NSSearchFieldFlags"] ? YES : NO;
  74. }
  75. return self;
  76. }
  77. @end