/Frameworks/AppKit/rhino.platform/CPClipView.j

http://github.com/jfahrenkrug/MapKit-HelloWorld · Unknown · 110 lines · 110 code · 0 blank · 0 comment · 0 complexity · d37ca63a79f47d92e6ba030a48ea5675 MD5 · raw file

  1. i;8;CPView.jc;4242;
  2. var _1=objj_allocateClassPair(CPView,"CPClipView"),_2=_1.isa;
  3. class_addIvars(_1,[new objj_ivar("_documentView")]);
  4. objj_registerClassPair(_1);
  5. objj_addClassForBundle(_1,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  6. class_addMethods(_1,[new objj_method(sel_getUid("setDocumentView:"),function(_3,_4,_5){
  7. with(_3){
  8. if(_documentView==_5){
  9. return;
  10. }
  11. var _6=objj_msgSend(CPNotificationCenter,"defaultCenter");
  12. if(_documentView){
  13. objj_msgSend(_6,"removeObserver:name:object:",_3,CPViewFrameDidChangeNotification,_documentView);
  14. objj_msgSend(_6,"removeObserver:name:object:",_3,CPViewBoundsDidChangeNotification,_documentView);
  15. objj_msgSend(_documentView,"removeFromSuperview");
  16. }
  17. _documentView=_5;
  18. if(_documentView){
  19. objj_msgSend(_3,"addSubview:",_documentView);
  20. objj_msgSend(_documentView,"setPostsFrameChangedNotifications:",YES);
  21. objj_msgSend(_documentView,"setPostsBoundsChangedNotifications:",YES);
  22. objj_msgSend(_6,"addObserver:selector:name:object:",_3,sel_getUid("viewFrameChanged:"),CPViewFrameDidChangeNotification,_documentView);
  23. objj_msgSend(_6,"addObserver:selector:name:object:",_3,sel_getUid("viewBoundsChanged:"),CPViewBoundsDidChangeNotification,_documentView);
  24. }
  25. }
  26. }),new objj_method(sel_getUid("documentView"),function(_7,_8){
  27. with(_7){
  28. return _documentView;
  29. }
  30. }),new objj_method(sel_getUid("constrainScrollPoint:"),function(_9,_a,_b){
  31. with(_9){
  32. if(!_documentView){
  33. return {x:0,y:0};
  34. }
  35. var _c=objj_msgSend(_documentView,"frame");
  36. _b.x=MAX(0,MIN(_b.x,MAX((_c.size.width)-(_bounds.size.width),0)));
  37. _b.y=MAX(0,MIN(_b.y,MAX((_c.size.height)-(_bounds.size.height),0)));
  38. return _b;
  39. }
  40. }),new objj_method(sel_getUid("setBoundsOrigin:"),function(_d,_e,_f){
  41. with(_d){
  42. if((_bounds.origin.x==_f.x&&_bounds.origin.y==_f.y)){
  43. return;
  44. }
  45. objj_msgSendSuper({receiver:_d,super_class:objj_getClass("CPView")},"setBoundsOrigin:",_f);
  46. var _10=objj_msgSend(_d,"superview");
  47. if(objj_msgSend(_10,"isKindOfClass:",objj_msgSend(CPScrollView,"class"))){
  48. objj_msgSend(_10,"reflectScrolledClipView:",_d);
  49. }
  50. }
  51. }),new objj_method(sel_getUid("scrollToPoint:"),function(_11,_12,_13){
  52. with(_11){
  53. objj_msgSend(_11,"setBoundsOrigin:",objj_msgSend(_11,"constrainScrollPoint:",_13));
  54. }
  55. }),new objj_method(sel_getUid("viewBoundsChanged:"),function(_14,_15,_16){
  56. with(_14){
  57. objj_msgSend(_14,"_constrainScrollPoint");
  58. }
  59. }),new objj_method(sel_getUid("viewFrameChanged:"),function(_17,_18,_19){
  60. with(_17){
  61. objj_msgSend(_17,"_constrainScrollPoint");
  62. }
  63. }),new objj_method(sel_getUid("resizeSubviewsWithOldSize:"),function(_1a,_1b,_1c){
  64. with(_1a){
  65. objj_msgSendSuper({receiver:_1a,super_class:objj_getClass("CPView")},"resizeSubviewsWithOldSize:",_1c);
  66. objj_msgSend(_1a,"_constrainScrollPoint");
  67. }
  68. }),new objj_method(sel_getUid("_constrainScrollPoint"),function(_1d,_1e){
  69. with(_1d){
  70. var _1f=objj_msgSend(_1d,"bounds").origin;
  71. objj_msgSend(_1d,"scrollToPoint:",_1f);
  72. if(!CGPointEqualToPoint(_1f,objj_msgSend(_1d,"bounds").origin)){
  73. return;
  74. }
  75. var _20=objj_msgSend(_1d,"superview");
  76. if(objj_msgSend(_20,"isKindOfClass:",objj_msgSend(CPScrollView,"class"))){
  77. objj_msgSend(_20,"reflectScrolledClipView:",_1d);
  78. }
  79. }
  80. }),new objj_method(sel_getUid("autoscroll:"),function(_21,_22,_23){
  81. with(_21){
  82. var _24=objj_msgSend(_21,"bounds"),_25=objj_msgSend(_21,"convertPoint:fromView:",objj_msgSend(_23,"locationInWindow"),nil);
  83. if(CPRectContainsPoint(_24,_25)){
  84. return NO;
  85. }
  86. var _26=CGRectMakeZero();
  87. _26.origin=_25;
  88. _26.size=CPSizeMake(10,10);
  89. return objj_msgSend(_documentView,"scrollRectToVisible:",_26);
  90. }
  91. })]);
  92. var _27="CPScrollViewDocumentView";
  93. var _1=objj_getClass("CPClipView");
  94. if(!_1){
  95. objj_exception_throw(new objj_exception(OBJJClassNotFoundException,"*** Could not find definition for class \"CPClipView\""));
  96. }
  97. var _2=_1.isa;
  98. class_addMethods(_1,[new objj_method(sel_getUid("initWithCoder:"),function(_28,_29,_2a){
  99. with(_28){
  100. if(_28=objj_msgSendSuper({receiver:_28,super_class:objj_getClass("CPView")},"initWithCoder:",_2a)){
  101. objj_msgSend(_28,"setDocumentView:",objj_msgSend(_2a,"decodeObjectForKey:",_27));
  102. }
  103. return _28;
  104. }
  105. }),new objj_method(sel_getUid("encodeWithCoder:"),function(_2b,_2c,_2d){
  106. with(_2b){
  107. objj_msgSendSuper({receiver:_2b,super_class:objj_getClass("CPView")},"encodeWithCoder:",_2d);
  108. objj_msgSend(_2d,"encodeObject:forKey:",_documentView,_27);
  109. }
  110. })]);