/Frameworks/Debug/AppKit/browser.platform/CPRadio.j

http://github.com/jfahrenkrug/MapKit-HelloWorld · Unknown · 170 lines · 169 code · 1 blank · 0 comment · 0 complexity · 188cae2e63e1d620b786d4c93cda1e9d MD5 · raw file

  1. I;21;Foundation/CPObject.jI;18;Foundation/CPSet.ji;10;CPButton.jc;6807;
  2. {var the_class = objj_allocateClassPair(CPButton, "CPRadio"),
  3. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_radioGroup")]);
  4. objj_registerClassPair(the_class);
  5. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  6. class_addMethods(the_class, [new objj_method(sel_getUid("initWithFrame:radioGroup:"), function $CPRadio__initWithFrame_radioGroup_(self, _cmd, aFrame, aRadioGroup)
  7. { with(self)
  8. {
  9. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPButton") }, "initWithFrame:", aFrame);
  10. if (self)
  11. {
  12. objj_msgSend(self, "setRadioGroup:", aRadioGroup || objj_msgSend(CPRadioGroup, "new"));
  13. objj_msgSend(self, "setHighlightsBy:", CPContentsCellMask);
  14. objj_msgSend(self, "setShowsStateBy:", CPContentsCellMask);
  15. objj_msgSend(self, "setImagePosition:", CPImageLeft);
  16. objj_msgSend(self, "setAlignment:", CPLeftTextAlignment);
  17. objj_msgSend(self, "setBordered:", YES);
  18. }
  19. return self;
  20. }
  21. }), new objj_method(sel_getUid("initWithFrame:"), function $CPRadio__initWithFrame_(self, _cmd, aFrame)
  22. { with(self)
  23. {
  24. return objj_msgSend(self, "initWithFrame:radioGroup:", aFrame, nil);
  25. }
  26. }), new objj_method(sel_getUid("nextState"), function $CPRadio__nextState(self, _cmd)
  27. { with(self)
  28. {
  29. return CPOnState;
  30. }
  31. }), new objj_method(sel_getUid("setRadioGroup:"), function $CPRadio__setRadioGroup_(self, _cmd, aRadioGroup)
  32. { with(self)
  33. {
  34. if (_radioGroup === aRadioGroup)
  35. return;
  36. objj_msgSend(_radioGroup, "_removeRadio:", self);
  37. _radioGroup = aRadioGroup;
  38. objj_msgSend(_radioGroup, "_addRadio:", self);
  39. }
  40. }), new objj_method(sel_getUid("radioGroup"), function $CPRadio__radioGroup(self, _cmd)
  41. { with(self)
  42. {
  43. return _radioGroup;
  44. }
  45. }), new objj_method(sel_getUid("setObjectValue:"), function $CPRadio__setObjectValue_(self, _cmd, aValue)
  46. { with(self)
  47. {
  48. objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPButton") }, "setObjectValue:", aValue);
  49. if (objj_msgSend(self, "state") === CPOnState)
  50. objj_msgSend(_radioGroup, "_setSelectedRadio:", self);
  51. }
  52. })]);
  53. class_addMethods(meta_class, [new objj_method(sel_getUid("radioWithTitle:theme:"), function $CPRadio__radioWithTitle_theme_(self, _cmd, aTitle, aTheme)
  54. { with(self)
  55. {
  56. return objj_msgSend(self, "buttonWithTitle:theme:", aTitle, aTheme);
  57. }
  58. }), new objj_method(sel_getUid("radioWithTitle:"), function $CPRadio__radioWithTitle_(self, _cmd, aTitle)
  59. { with(self)
  60. {
  61. return objj_msgSend(self, "buttonWithTitle:", aTitle);
  62. }
  63. }), new objj_method(sel_getUid("standardButtonWithTitle:"), function $CPRadio__standardButtonWithTitle_(self, _cmd, aTitle)
  64. { with(self)
  65. {
  66. var button = objj_msgSend(objj_msgSend(CPRadio, "alloc"), "init");
  67. objj_msgSend(button, "setTitle:", aTitle);
  68. return button;
  69. }
  70. }), new objj_method(sel_getUid("themeClass"), function $CPRadio__themeClass(self, _cmd)
  71. { with(self)
  72. {
  73. return "radio";
  74. }
  75. })]);
  76. }
  77. var CPRadioRadioGroupKey = "CPRadioRadioGroupKey";
  78. {
  79. var the_class = objj_getClass("CPRadio")
  80. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPRadio\""));
  81. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("initWithCoder:"), function $CPRadio__initWithCoder_(self, _cmd, aCoder)
  82. { with(self)
  83. {
  84. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPButton") }, "initWithCoder:", aCoder);
  85. if (self)
  86. _radioGroup = objj_msgSend(aCoder, "decodeObjectForKey:", CPRadioRadioGroupKey);
  87. return self;
  88. }
  89. }), new objj_method(sel_getUid("encodeWithCoder:"), function $CPRadio__encodeWithCoder_(self, _cmd, aCoder)
  90. { with(self)
  91. {
  92. objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPButton") }, "encodeWithCoder:", aCoder);
  93. objj_msgSend(aCoder, "encodeObject:forKey:", _radioGroup, CPRadioRadioGroupKey);
  94. }
  95. })]);
  96. }
  97. {var the_class = objj_allocateClassPair(CPObject, "CPRadioGroup"),
  98. meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_radios"), new objj_ivar("_selectedRadio")]);
  99. objj_registerClassPair(the_class);
  100. objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  101. class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $CPRadioGroup__init(self, _cmd)
  102. { with(self)
  103. {
  104. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  105. if (self)
  106. {
  107. _radios = objj_msgSend(CPSet, "set");
  108. _selectedRadio = nil;
  109. }
  110. return self;
  111. }
  112. }), new objj_method(sel_getUid("_addRadio:"), function $CPRadioGroup___addRadio_(self, _cmd, aRadio)
  113. { with(self)
  114. {
  115. objj_msgSend(_radios, "addObject:", aRadio);
  116. if (objj_msgSend(aRadio, "state") === CPOnState)
  117. objj_msgSend(self, "_setSelectedRadio:", aRadio);
  118. }
  119. }), new objj_method(sel_getUid("_removeRadio:"), function $CPRadioGroup___removeRadio_(self, _cmd, aRadio)
  120. { with(self)
  121. {
  122. if (_selectedRadio === aRadio)
  123. _selectedRadio = nil;
  124. objj_msgSend(_radios, "removeObject:", aRadio);
  125. }
  126. }), new objj_method(sel_getUid("_setSelectedRadio:"), function $CPRadioGroup___setSelectedRadio_(self, _cmd, aRadio)
  127. { with(self)
  128. {
  129. if (_selectedRadio === aRadio)
  130. return;
  131. objj_msgSend(_selectedRadio, "setState:", CPOffState);
  132. _selectedRadio = aRadio;
  133. }
  134. }), new objj_method(sel_getUid("selectedRadio"), function $CPRadioGroup__selectedRadio(self, _cmd)
  135. { with(self)
  136. {
  137. return _selectedRadio;
  138. }
  139. }), new objj_method(sel_getUid("radios"), function $CPRadioGroup__radios(self, _cmd)
  140. { with(self)
  141. {
  142. return objj_msgSend(_radios, "allObjects");
  143. }
  144. })]);
  145. }
  146. var CPRadioGroupRadiosKey = "CPRadioGroupRadiosKey",
  147. CPRadioGroupSelectedRadioKey = "CPRadioGroupSelectedRadioKey";
  148. {
  149. var the_class = objj_getClass("CPRadioGroup")
  150. if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPRadioGroup\""));
  151. var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("initWithCoder:"), function $CPRadioGroup__initWithCoder_(self, _cmd, aCoder)
  152. { with(self)
  153. {
  154. self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
  155. if (self)
  156. {
  157. _radios = objj_msgSend(aCoder, "decodeObjectForKey:", CPRadioGroupRadiosKey);
  158. _selectedRadio = objj_msgSend(aCoder, "decodeObjectForKey:", CPRadioGroupSelectedRadioKey);
  159. }
  160. return self;
  161. }
  162. }), new objj_method(sel_getUid("encodeWithCoder:"), function $CPRadioGroup__encodeWithCoder_(self, _cmd, aCoder)
  163. { with(self)
  164. {
  165. objj_msgSend(aCoder, "encodeObject:forKey:", _radios, CPRadioGroupRadiosKey);
  166. objj_msgSend(aCoder, "encodeObject:forKey:", _selectedRadio, CPRadioGroupSelectedRadioKey);
  167. }
  168. })]);
  169. }