/Frameworks/AppKit/browser.platform/_CPWindowView.j

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

  1. i;8;CPView.ji;13;CPImageView.jc;9039;
  2. var _1=nil;
  3. var _2=objj_allocateClassPair(CPView,"_CPWindowView"),_3=_2.isa;
  4. class_addIvars(_2,[new objj_ivar("_styleMask"),new objj_ivar("_resizeIndicator"),new objj_ivar("_resizeIndicatorOffset"),new objj_ivar("_toolbarView"),new objj_ivar("_resizeFrame"),new objj_ivar("_mouseDraggedPoint"),new objj_ivar("_cachedScreenFrame")]);
  5. objj_registerClassPair(_2);
  6. objj_addClassForBundle(_2,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  7. class_addMethods(_2,[new objj_method(sel_getUid("contentRectForFrameRect:"),function(_4,_5,_6){
  8. with(_4){
  9. return objj_msgSend(objj_msgSend(_4,"class"),"contentRectForFrameRect:",_6);
  10. }
  11. }),new objj_method(sel_getUid("frameRectForContentRect:"),function(_7,_8,_9){
  12. with(_7){
  13. return objj_msgSend(objj_msgSend(_7,"class"),"frameRectForContentRect:",_9);
  14. }
  15. }),new objj_method(sel_getUid("initWithFrame:styleMask:"),function(_a,_b,_c,_d){
  16. with(_a){
  17. _a=objj_msgSendSuper({receiver:_a,super_class:objj_getClass("CPView")},"initWithFrame:",_c);
  18. if(_a){
  19. _styleMask=_d;
  20. _resizeIndicatorOffset=CGSizeMake(0,0);
  21. _toolbarOffset=CGSizeMake(0,0);
  22. objj_msgSend(_a,"setShowsResizeIndicator:",!(_styleMask&CPBorderlessBridgeWindowMask)&&(_styleMask&CPResizableWindowMask));
  23. }
  24. return _a;
  25. }
  26. }),new objj_method(sel_getUid("setTitle:"),function(_e,_f,_10){
  27. with(_e){
  28. }
  29. }),new objj_method(sel_getUid("acceptsFirstMouse:"),function(_11,_12,_13){
  30. with(_11){
  31. return YES;
  32. }
  33. }),new objj_method(sel_getUid("mouseDown:"),function(_14,_15,_16){
  34. with(_14){
  35. var _17=objj_msgSend(_14,"window");
  36. if((_styleMask&CPResizableWindowMask)&&_resizeIndicator){
  37. var _18=objj_msgSend(_resizeIndicator,"frame");
  38. if(CGRectContainsPoint(_18,objj_msgSend(_14,"convertPoint:fromView:",objj_msgSend(_16,"locationInWindow"),nil))){
  39. return objj_msgSend(_14,"trackResizeWithEvent:",_16);
  40. }
  41. }
  42. if(objj_msgSend(_17,"isMovableByWindowBackground")){
  43. objj_msgSend(_14,"trackMoveWithEvent:",_16);
  44. }else{
  45. objj_msgSendSuper({receiver:_14,super_class:objj_getClass("CPView")},"mouseDown:",_16);
  46. }
  47. }
  48. }),new objj_method(sel_getUid("trackResizeWithEvent:"),function(_19,_1a,_1b){
  49. with(_19){
  50. var _1c=objj_msgSend(_1b,"locationInWindow"),_1d=objj_msgSend(_1b,"type");
  51. if(_1d===CPLeftMouseUp){
  52. return;
  53. }
  54. var _1e=objj_msgSend(_19,"window");
  55. if(_1d===CPLeftMouseDown){
  56. var _1f=objj_msgSend(_1e,"frame");
  57. _resizeFrame=CGRectMake(_1c.x,_1c.y,CGRectGetWidth(_1f),CGRectGetHeight(_1f));
  58. }else{
  59. if(_1d===CPLeftMouseDragged){
  60. objj_msgSend(_1e,"setFrameSize:",CGSizeMake(CGRectGetWidth(_resizeFrame)+_1c.x-CGRectGetMinX(_resizeFrame),CGRectGetHeight(_resizeFrame)+_1c.y-CGRectGetMinY(_resizeFrame)));
  61. }
  62. }
  63. objj_msgSend(CPApp,"setTarget:selector:forNextEventMatchingMask:untilDate:inMode:dequeue:",_19,sel_getUid("trackResizeWithEvent:"),CPLeftMouseDraggedMask|CPLeftMouseUpMask,nil,nil,YES);
  64. }
  65. }),new objj_method(sel_getUid("_pointWithinScreenFrame:"),function(_20,_21,_22){
  66. with(_20){
  67. var _23=_cachedScreenFrame;
  68. if(!_23){
  69. _23=objj_msgSend(objj_msgSend(CPDOMWindowBridge,"sharedDOMWindowBridge"),"visibleFrame");
  70. }
  71. var _24=CGPointMake(0,0);
  72. _24.x=MIN(MAX(_22.x,-_frame.size.width+4),CGRectGetMaxX(_23)-4);
  73. _24.y=MIN(MAX(_22.y,0),CGRectGetMaxY(_23)-8);
  74. return _24;
  75. }
  76. }),new objj_method(sel_getUid("trackMoveWithEvent:"),function(_25,_26,_27){
  77. with(_25){
  78. var _28=objj_msgSend(_27,"type");
  79. if(_28===CPLeftMouseUp){
  80. _cachedScreenFrame=nil;
  81. return;
  82. }else{
  83. if(_28===CPLeftMouseDown){
  84. _mouseDraggedPoint=objj_msgSend(objj_msgSend(_25,"window"),"convertBaseToBridge:",objj_msgSend(_27,"locationInWindow"));
  85. _cachedScreenFrame=objj_msgSend(objj_msgSend(CPDOMWindowBridge,"sharedDOMWindowBridge"),"visibleFrame");
  86. }else{
  87. if(_28===CPLeftMouseDragged){
  88. var _29=objj_msgSend(_25,"window"),_2a=objj_msgSend(_29,"frame"),_2b=objj_msgSend(_29,"convertBaseToBridge:",objj_msgSend(_27,"locationInWindow")),_2c=objj_msgSend(_25,"_pointWithinScreenFrame:",CGPointMake((_2a.origin.x)+(_2b.x-_mouseDraggedPoint.x),(_2a.origin.y)+(_2b.y-_mouseDraggedPoint.y)));
  89. objj_msgSend(_29,"setFrameOrigin:",_2c);
  90. _mouseDraggedPoint=objj_msgSend(_25,"_pointWithinScreenFrame:",_2b);
  91. }
  92. }
  93. }
  94. objj_msgSend(CPApp,"setTarget:selector:forNextEventMatchingMask:untilDate:inMode:dequeue:",_25,sel_getUid("trackMoveWithEvent:"),CPLeftMouseDraggedMask|CPLeftMouseUpMask,nil,nil,YES);
  95. }
  96. }),new objj_method(sel_getUid("setShowsResizeIndicator:"),function(_2d,_2e,_2f){
  97. with(_2d){
  98. if(_2f){
  99. var _30=objj_msgSend(_1,"size"),_31=objj_msgSend(_2d,"frame").size;
  100. _resizeIndicator=objj_msgSend(objj_msgSend(CPImageView,"alloc"),"initWithFrame:",CGRectMake(_31.width-_30.width-_resizeIndicatorOffset.width,_31.height-_30.height-_resizeIndicatorOffset.height,_30.width,_30.height));
  101. objj_msgSend(_resizeIndicator,"setImage:",_1);
  102. objj_msgSend(_resizeIndicator,"setAutoresizingMask:",CPViewMinXMargin|CPViewMinYMargin);
  103. objj_msgSend(_2d,"addSubview:",_resizeIndicator);
  104. }else{
  105. objj_msgSend(_resizeIndicator,"removeFromSuperview");
  106. _resizeIndicator=nil;
  107. }
  108. }
  109. }),new objj_method(sel_getUid("showsResizeIndicator"),function(_32,_33){
  110. with(_32){
  111. return _resizeIndicator!==nil;
  112. }
  113. }),new objj_method(sel_getUid("setResizeIndicatorOffset:"),function(_34,_35,_36){
  114. with(_34){
  115. if(CGSizeEqualToSize(_resizeIndicatorOffset,_36)){
  116. return;
  117. }
  118. _resizeIndicatorOffset=_36;
  119. if(!_resizeIndicator){
  120. return;
  121. }
  122. var _37=objj_msgSend(_resizeIndicator,"frame").size,_38=objj_msgSend(_34,"frame").size;
  123. objj_msgSend(_resizeIndicator,"setFrameOrigin:",CGPointMake(_38.width-_37.width-_36.width,_38.height-_37.height-_36.height));
  124. }
  125. }),new objj_method(sel_getUid("resizeIndicatorOffset"),function(_39,_3a){
  126. with(_39){
  127. return _resizeIndicatorOffset;
  128. }
  129. }),new objj_method(sel_getUid("windowDidChangeDocumentEdited"),function(_3b,_3c){
  130. with(_3b){
  131. }
  132. }),new objj_method(sel_getUid("windowDidChangeDocumentSaving"),function(_3d,_3e){
  133. with(_3d){
  134. }
  135. }),new objj_method(sel_getUid("showsToolbar"),function(_3f,_40){
  136. with(_3f){
  137. return YES;
  138. }
  139. }),new objj_method(sel_getUid("toolbarOffset"),function(_41,_42){
  140. with(_41){
  141. return CGSizeMakeZero();
  142. }
  143. }),new objj_method(sel_getUid("toolbarLabelColor"),function(_43,_44){
  144. with(_43){
  145. return objj_msgSend(CPColor,"blackColor");
  146. }
  147. }),new objj_method(sel_getUid("toolbarMaxY"),function(_45,_46){
  148. with(_45){
  149. if(!_toolbarView||objj_msgSend(_toolbarView,"isHidden")){
  150. return objj_msgSend(_45,"toolbarOffset").height;
  151. }
  152. return CGRectGetMaxY(objj_msgSend(_toolbarView,"frame"));
  153. }
  154. }),new objj_method(sel_getUid("toolbarView"),function(_47,_48){
  155. with(_47){
  156. return _toolbarView;
  157. }
  158. }),new objj_method(sel_getUid("tile"),function(_49,_4a){
  159. with(_49){
  160. var _4b=objj_msgSend(_49,"window"),_4c=objj_msgSend(_49,"bounds"),_4d=CGRectGetWidth(_4c);
  161. if(objj_msgSend(objj_msgSend(_4b,"toolbar"),"isVisible")){
  162. var _4e=objj_msgSend(_49,"toolbarView"),_4f=objj_msgSend(_49,"toolbarOffset");
  163. objj_msgSend(_4e,"setFrame:",CGRectMake(_4f.width,_4f.height,_4d,CGRectGetHeight(objj_msgSend(_4e,"frame"))));
  164. }
  165. if(objj_msgSend(_49,"showsResizeIndicator")){
  166. var _50=objj_msgSend(_resizeIndicator,"frame").size,_51=objj_msgSend(_49,"bounds").size;
  167. objj_msgSend(_resizeIndicator,"setFrameOrigin:",CGPointMake(_51.width-_50.width-_resizeIndicatorOffset.width,_51.height-_50.height-_resizeIndicatorOffset.height));
  168. }
  169. }
  170. }),new objj_method(sel_getUid("noteToolbarChanged"),function(_52,_53){
  171. with(_52){
  172. var _54=objj_msgSend(_52,"window"),_55=objj_msgSend(_54,"toolbar"),_56=objj_msgSend(_55,"_toolbarView");
  173. if(_toolbarView!==_56){
  174. objj_msgSend(_toolbarView,"removeFromSuperview");
  175. if(_56){
  176. objj_msgSend(_56,"removeFromSuperview");
  177. objj_msgSend(_56,"setLabelColor:",objj_msgSend(_52,"toolbarLabelColor"));
  178. if(objj_msgSend(_52,"respondsToSelector:",sel_getUid("toolbarLabelShadowColor"))){
  179. objj_msgSend(_56,"setLabelShadowColor:",objj_msgSend(_52,"toolbarLabelShadowColor"));
  180. }
  181. objj_msgSend(_52,"addSubview:",_56);
  182. }
  183. _toolbarView=_56;
  184. }
  185. objj_msgSend(_56,"setHidden:",!objj_msgSend(_52,"showsToolbar")||!objj_msgSend(_55,"isVisible"));
  186. if(_54){
  187. var _57=objj_msgSend(_52,"convertRect:toView:",objj_msgSend(objj_msgSend(_54,"contentView"),"frame"),nil);
  188. _57.origin=objj_msgSend(_54,"convertBaseToBridge:",_57.origin);
  189. objj_msgSend(_52,"setAutoresizesSubviews:",NO);
  190. objj_msgSend(_54,"setFrame:",objj_msgSend(_54,"frameRectForContentRect:",_57));
  191. objj_msgSend(_52,"setAutoresizesSubviews:",YES);
  192. }
  193. objj_msgSend(_52,"tile");
  194. }
  195. }),new objj_method(sel_getUid("didAddSubview:"),function(_58,_59,_5a){
  196. with(_58){
  197. if(!_resizeIndicator||_5a===_resizeIndicator){
  198. return;
  199. }
  200. objj_msgSend(_58,"addSubview:",_resizeIndicator);
  201. }
  202. })]);
  203. class_addMethods(_3,[new objj_method(sel_getUid("initialize"),function(_5b,_5c){
  204. with(_5b){
  205. if(_5b!=objj_msgSend(_CPWindowView,"class")){
  206. return;
  207. }
  208. _1=objj_msgSend(objj_msgSend(CPImage,"alloc"),"initWithContentsOfFile:size:",objj_msgSend(objj_msgSend(CPBundle,"bundleForClass:",objj_msgSend(CPWindow,"class")),"pathForResource:","_CPWindowView/_CPWindowViewResizeIndicator.png"),CGSizeMake(12,12));
  209. }
  210. }),new objj_method(sel_getUid("contentRectForFrameRect:"),function(_5d,_5e,_5f){
  211. with(_5d){
  212. return CGRectMakeCopy(_5f);
  213. }
  214. }),new objj_method(sel_getUid("frameRectForContentRect:"),function(_60,_61,_62){
  215. with(_60){
  216. return CGRectMakeCopy(_62);
  217. }
  218. })]);