PageRenderTime 20ms CodeModel.GetById 16ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

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