/Tools/nib2cib/NSMenuItem.j

http://github.com/cacaodev/cappuccino · Unknown · 112 lines · 83 code · 29 blank · 0 comment · 0 complexity · f84d427130429e99a607d304d3af325c MD5 · raw file

  1. /*
  2. * NSMenuItem.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. @import <AppKit/CPMenuItem.j>
  23. @import "NSButton.j"
  24. @import "NSEvent.j"
  25. @import "NSMenu.j"
  26. @implementation CPMenuItem (NSCoding)
  27. - (id)NS_initWithCoder:(CPCoder)aCoder
  28. {
  29. self = [super init];
  30. if (self)
  31. {
  32. _isSeparator = [aCoder decodeBoolForKey:@"NSIsSeparator"];
  33. _title = [aCoder decodeObjectForKey:"NSTitle"];
  34. // _font = [aCoder decodeObjectForKey:"NSTitle"];
  35. _target = [aCoder decodeObjectForKey:"NSTarget"];
  36. _action = [aCoder decodeObjectForKey:"NSAction"];
  37. _isEnabled = ![aCoder decodeBoolForKey:"NSIsDisabled"];
  38. _isHidden = [aCoder decodeBoolForKey:"NSIsHidden"];
  39. _tag = [aCoder decodeIntForKey:"NSTag"];
  40. _state = [aCoder decodeIntForKey:"NSState"];
  41. _image = [aCoder decodeObjectForKey:"NSImage"];
  42. // _alternateImage = [aCoder decodeObjectForKey:""];
  43. // _onStateImage = [aCoder decodeObjectForKey:"NSOnImage"];
  44. // _offStateImage = [aCoder decodeObjectForKey:"NSOffImage"];
  45. // _mixedStateImage = [aCoder decodeObjectForKey:"NSMixedImage"];
  46. _submenu = [aCoder decodeObjectForKey:"NSSubmenu"];
  47. _menu = [aCoder decodeObjectForKey:"NSMenu"];
  48. _keyEquivalent = [aCoder decodeObjectForKey:"NSKeyEquiv"];
  49. _keyEquivalentModifierMask = CP_NSMapKeyMask([aCoder decodeObjectForKey:"NSKeyEquivModMask"]);
  50. // _mnemonicLocation = [aCoder decodeObjectForKey:"NSMnemonicLoc"];
  51. // _isAlternate = [aCoder decodeBoolForKey:"NSIsAlternate"];
  52. _indentationLevel = [aCoder decodeIntForKey:"NSIndent"];
  53. // _toolTip;
  54. _representedObject = [aCoder decodeObjectForKey:"NSRepObject"];
  55. }
  56. return self;
  57. }
  58. - (void)swapCellsForParents:(JSObject)parentsForCellUIDs
  59. {
  60. var target = [self target];
  61. if (!target)
  62. return;
  63. var parent = parentsForCellUIDs[[[self target] UID]];
  64. if (parent)
  65. [self setTarget:parent];
  66. }
  67. @end
  68. @implementation NSMenuItem : CPMenuItem
  69. {
  70. }
  71. - (id)initWithCoder:(CPCoder)aCoder
  72. {
  73. return [self NS_initWithCoder:aCoder];
  74. }
  75. - (Class)classForKeyedArchiver
  76. {
  77. return [CPMenuItem class];
  78. }
  79. @end
  80. @implementation NSMenuItemCell : NSButtonCell
  81. {
  82. }
  83. @end