PageRenderTime 25ms CodeModel.GetById 14ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/Frameworks/AppKit/browser.platform/CPScrollView.j

http://github.com/jfahrenkrug/MapKit-HelloWorld
Unknown | 377 lines | 377 code | 0 blank | 0 comment | 0 complexity | 44ca593d9ebc6785215c76784f9768bd MD5 | raw file
  1i;8;CPView.ji;12;CPClipView.ji;12;CPScroller.jc;14690;
  2var _1=objj_allocateClassPair(CPView,"CPScrollView"),_2=_1.isa;
  3class_addIvars(_1,[new objj_ivar("_contentView"),new objj_ivar("_hasVerticalScroller"),new objj_ivar("_hasHorizontalScroller"),new objj_ivar("_autohidesScrollers"),new objj_ivar("_verticalScroller"),new objj_ivar("_horizontalScroller"),new objj_ivar("_recursionCount"),new objj_ivar("_verticalLineScroll"),new objj_ivar("_verticalPageScroll"),new objj_ivar("_horizontalLineScroll"),new objj_ivar("_horizontalPageScroll")]);
  4objj_registerClassPair(_1);
  5objj_addClassForBundle(_1,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  6class_addMethods(_1,[new objj_method(sel_getUid("initWithFrame:"),function(_3,_4,_5){
  7with(_3){
  8_3=objj_msgSendSuper({receiver:_3,super_class:objj_getClass("CPView")},"initWithFrame:",_5);
  9if(_3){
 10_verticalLineScroll=10;
 11_verticalPageScroll=10;
 12_horizontalLineScroll=10;
 13_horizontalPageScroll=10;
 14_contentView=objj_msgSend(objj_msgSend(CPClipView,"alloc"),"initWithFrame:",objj_msgSend(_3,"bounds"));
 15objj_msgSend(_3,"addSubview:",_contentView);
 16objj_msgSend(_3,"setHasVerticalScroller:",YES);
 17objj_msgSend(_3,"setHasHorizontalScroller:",YES);
 18}
 19return _3;
 20}
 21}),new objj_method(sel_getUid("contentSize"),function(_6,_7){
 22with(_6){
 23return objj_msgSend(_contentView,"frame").size;
 24}
 25}),new objj_method(sel_getUid("documentView"),function(_8,_9){
 26with(_8){
 27return objj_msgSend(_contentView,"documentView");
 28}
 29}),new objj_method(sel_getUid("setContentView:"),function(_a,_b,_c){
 30with(_a){
 31if(!_c){
 32return;
 33}
 34var _d=objj_msgSend(_c,"documentView");
 35if(_d){
 36objj_msgSend(_d,"removeFromSuperview");
 37}
 38objj_msgSend(_contentView,"removeFromSuperview");
 39var _e=objj_msgSend(_a,"contentSize");
 40_contentView=_c;
 41objj_msgSend(_contentView,"setFrame:",CGRectMake(0,0,_e.width,_e.height));
 42objj_msgSend(_contentView,"setDocumentView:",_d);
 43objj_msgSend(_a,"addSubview:",_contentView);
 44}
 45}),new objj_method(sel_getUid("contentView"),function(_f,_10){
 46with(_f){
 47return _contentView;
 48}
 49}),new objj_method(sel_getUid("setDocumentView:"),function(_11,_12,_13){
 50with(_11){
 51objj_msgSend(_contentView,"setDocumentView:",_13);
 52objj_msgSend(_11,"reflectScrolledClipView:",_contentView);
 53}
 54}),new objj_method(sel_getUid("reflectScrolledClipView:"),function(_14,_15,_16){
 55with(_14){
 56if(_contentView!==_16){
 57return;
 58}
 59if(_recursionCount>5){
 60return;
 61}
 62++_recursionCount;
 63var _17=objj_msgSend(_14,"documentView");
 64if(!_17){
 65if(_autohidesScrollers){
 66objj_msgSend(_verticalScroller,"setHidden:",YES);
 67objj_msgSend(_horizontalScroller,"setHidden:",YES);
 68}else{
 69}
 70objj_msgSend(_contentView,"setFrame:",objj_msgSend(_14,"bounds"));
 71--_recursionCount;
 72return;
 73}
 74var _18=objj_msgSend(_17,"frame"),_19=objj_msgSend(_14,"bounds"),_1a=objj_msgSend(_contentView,"bounds").origin,_1b={width:CPRectGetWidth(_18)-CPRectGetWidth(_19),height:CPRectGetHeight(_18)-CPRectGetHeight(_19)},_1c=(!_autohidesScrollers||_1b.height>0)&&_hasVerticalScroller,_1d=(!_autohidesScrollers||_1b.width>0)&&_hasHorizontalScroller,_1e=!objj_msgSend(_verticalScroller,"isHidden"),_1f=!objj_msgSend(_horizontalScroller,"isHidden"),_20=(objj_msgSend(_verticalScroller,"frame").size.width);
 75horizontalScrollerHeight=(objj_msgSend(_horizontalScroller,"frame").size.height);
 76if(_autohidesScrollers){
 77if(_1c){
 78_1d=(!_autohidesScrollers||_1b.width>-_20)&&_hasHorizontalScroller;
 79}
 80if(_1d){
 81_1c=(!_autohidesScrollers||_1b.height>-horizontalScrollerHeight)&&_hasVerticalScroller;
 82}
 83}
 84objj_msgSend(_verticalScroller,"setHidden:",!_1c);
 85objj_msgSend(_verticalScroller,"setEnabled:",_1b.height>0);
 86objj_msgSend(_horizontalScroller,"setHidden:",!_1d);
 87objj_msgSend(_horizontalScroller,"setEnabled:",_1b.width>0);
 88if(_1c){
 89var _21=CPRectGetHeight(_19);
 90if(_1d){
 91_21-=horizontalScrollerHeight;
 92}
 93_1b.width+=_20;
 94_19.size.width-=_20;
 95objj_msgSend(_verticalScroller,"setFloatValue:knobProportion:",(_1b.height<=0)?0:_1a.y/_1b.height,CPRectGetHeight(_19)/CPRectGetHeight(_18));
 96objj_msgSend(_verticalScroller,"setFrame:",CPRectMake(CPRectGetMaxX(_19),0,_20,_21));
 97}else{
 98if(_1e){
 99objj_msgSend(_verticalScroller,"setFloatValue:knobProportion:",0,1);
100}
101}
102if(_1d){
103_1b.height+=horizontalScrollerHeight;
104_19.size.height-=horizontalScrollerHeight;
105objj_msgSend(_horizontalScroller,"setFloatValue:knobProportion:",(_1b.width<=0)?0:_1a.x/_1b.width,CPRectGetWidth(_19)/CPRectGetWidth(_18));
106objj_msgSend(_horizontalScroller,"setFrame:",CPRectMake(0,CPRectGetMaxY(_19),CPRectGetWidth(_19),horizontalScrollerHeight));
107}else{
108if(_1f){
109objj_msgSend(_horizontalScroller,"setFloatValue:knobProportion:",0,1);
110}
111}
112objj_msgSend(_contentView,"setFrame:",_19);
113--_recursionCount;
114}
115}),new objj_method(sel_getUid("setHorizontalScroller:"),function(_22,_23,_24){
116with(_22){
117if(_horizontalScroller===_24){
118return;
119}
120objj_msgSend(_horizontalScroller,"removeFromSuperview");
121objj_msgSend(_horizontalScroller,"setTarget:",nil);
122objj_msgSend(_horizontalScroller,"setAction:",nil);
123_horizontalScroller=_24;
124objj_msgSend(_horizontalScroller,"setTarget:",_22);
125objj_msgSend(_horizontalScroller,"setAction:",sel_getUid("_horizontalScrollerDidScroll:"));
126objj_msgSend(_22,"addSubview:",_horizontalScroller);
127objj_msgSend(_22,"reflectScrolledClipView:",_contentView);
128}
129}),new objj_method(sel_getUid("horizontalScroller"),function(_25,_26){
130with(_25){
131return _horizontalScroller;
132}
133}),new objj_method(sel_getUid("setHasHorizontalScroller:"),function(_27,_28,_29){
134with(_27){
135if(_hasHorizontalScroller===_29){
136return;
137}
138_hasHorizontalScroller=_29;
139if(_hasHorizontalScroller&&!_horizontalScroller){
140objj_msgSend(_27,"setHorizontalScroller:",objj_msgSend(objj_msgSend(CPScroller,"alloc"),"initWithFrame:",CGRectMake(0,0,CPRectGetWidth(objj_msgSend(_27,"bounds")),objj_msgSend(CPScroller,"scrollerWidth"))));
141}else{
142if(!_hasHorizontalScroller&&_horizontalScroller){
143objj_msgSend(_horizontalScroller,"setHidden:",YES);
144objj_msgSend(_27,"reflectScrolledClipView:",_contentView);
145}
146}
147}
148}),new objj_method(sel_getUid("hasHorizontalScroller"),function(_2a,_2b){
149with(_2a){
150return _hasHorizontalScroller;
151}
152}),new objj_method(sel_getUid("setVerticalScroller:"),function(_2c,_2d,_2e){
153with(_2c){
154if(_verticalScroller===_2e){
155return;
156}
157objj_msgSend(_verticalScroller,"removeFromSuperview");
158objj_msgSend(_verticalScroller,"setTarget:",nil);
159objj_msgSend(_verticalScroller,"setAction:",nil);
160_verticalScroller=_2e;
161objj_msgSend(_verticalScroller,"setTarget:",_2c);
162objj_msgSend(_verticalScroller,"setAction:",sel_getUid("_verticalScrollerDidScroll:"));
163objj_msgSend(_2c,"addSubview:",_verticalScroller);
164objj_msgSend(_2c,"reflectScrolledClipView:",_contentView);
165}
166}),new objj_method(sel_getUid("verticalScroller"),function(_2f,_30){
167with(_2f){
168return _verticalScroller;
169}
170}),new objj_method(sel_getUid("setHasVerticalScroller:"),function(_31,_32,_33){
171with(_31){
172if(_hasVerticalScroller===_33){
173return;
174}
175_hasVerticalScroller=_33;
176if(_hasVerticalScroller&&!_verticalScroller){
177objj_msgSend(_31,"setVerticalScroller:",objj_msgSend(objj_msgSend(CPScroller,"alloc"),"initWithFrame:",CPRectMake(0,0,objj_msgSend(CPScroller,"scrollerWidth"),CPRectGetHeight(objj_msgSend(_31,"bounds")))));
178}else{
179if(!_hasVerticalScroller&&_verticalScroller){
180objj_msgSend(_verticalScroller,"setHidden:",YES);
181objj_msgSend(_31,"reflectScrolledClipView:",_contentView);
182}
183}
184}
185}),new objj_method(sel_getUid("hasVerticalScroller"),function(_34,_35){
186with(_34){
187return _hasVerticalScroller;
188}
189}),new objj_method(sel_getUid("setAutohidesScrollers:"),function(_36,_37,_38){
190with(_36){
191if(_autohidesScrollers==_38){
192return;
193}
194_autohidesScrollers=_38;
195objj_msgSend(_36,"reflectScrolledClipView:",_contentView);
196}
197}),new objj_method(sel_getUid("autohidesScrollers"),function(_39,_3a){
198with(_39){
199return _autohidesScrollers;
200}
201}),new objj_method(sel_getUid("_verticalScrollerDidScroll:"),function(_3b,_3c,_3d){
202with(_3b){
203var _3e=objj_msgSend(_3d,"floatValue"),_3f=objj_msgSend(objj_msgSend(_contentView,"documentView"),"frame");
204contentBounds=objj_msgSend(_contentView,"bounds");
205switch(objj_msgSend(_verticalScroller,"hitPart")){
206case CPScrollerDecrementLine:
207contentBounds.origin.y-=_verticalLineScroll;
208break;
209case CPScrollerIncrementLine:
210contentBounds.origin.y+=_verticalLineScroll;
211break;
212case CPScrollerDecrementPage:
213contentBounds.origin.y-=(contentBounds.size.height)-_verticalPageScroll;
214break;
215case CPScrollerIncrementPage:
216contentBounds.origin.y+=(contentBounds.size.height)-_verticalPageScroll;
217break;
218case CPScrollerKnobSlot:
219case CPScrollerKnob:
220default:
221contentBounds.origin.y=_3e*((_3f.size.height)-(contentBounds.size.height));
222}
223objj_msgSend(_contentView,"scrollToPoint:",contentBounds.origin);
224}
225}),new objj_method(sel_getUid("_horizontalScrollerDidScroll:"),function(_40,_41,_42){
226with(_40){
227var _43=objj_msgSend(_42,"floatValue"),_44=objj_msgSend(objj_msgSend(_40,"documentView"),"frame"),_45=objj_msgSend(_contentView,"bounds");
228switch(objj_msgSend(_horizontalScroller,"hitPart")){
229case CPScrollerDecrementLine:
230_45.origin.x-=_horizontalLineScroll;
231break;
232case CPScrollerIncrementLine:
233_45.origin.x+=_horizontalLineScroll;
234break;
235case CPScrollerDecrementPage:
236_45.origin.x-=(_45.size.width)-_horizontalPageScroll;
237break;
238case CPScrollerIncrementPage:
239_45.origin.x+=(_45.size.width)-_horizontalPageScroll;
240break;
241case CPScrollerKnobSlot:
242case CPScrollerKnob:
243default:
244_45.origin.x=_43*((_44.size.width)-(_45.size.width));
245}
246objj_msgSend(_contentView,"scrollToPoint:",_45.origin);
247}
248}),new objj_method(sel_getUid("tile"),function(_46,_47){
249with(_46){
250}
251}),new objj_method(sel_getUid("resizeSubviewsWithOldSize:"),function(_48,_49,_4a){
252with(_48){
253objj_msgSend(_48,"reflectScrolledClipView:",_contentView);
254}
255}),new objj_method(sel_getUid("setLineScroll:"),function(_4b,_4c,_4d){
256with(_4b){
257objj_msgSend(_4b,"setHorizonalLineScroll:",_4d);
258objj_msgSend(_4b,"setVerticalLineScroll:",_4d);
259}
260}),new objj_method(sel_getUid("lineScroll"),function(_4e,_4f){
261with(_4e){
262return objj_msgSend(_4e,"horizontalLineScroll");
263}
264}),new objj_method(sel_getUid("setHorizontalLineScroll:"),function(_50,_51,_52){
265with(_50){
266_horizontalLineScroll=_52;
267}
268}),new objj_method(sel_getUid("horizontalLineScroll"),function(_53,_54){
269with(_53){
270return _horizontalLineScroll;
271}
272}),new objj_method(sel_getUid("setVerticalLineScroll:"),function(_55,_56,_57){
273with(_55){
274_verticalLineScroll=_57;
275}
276}),new objj_method(sel_getUid("verticalLineScroll"),function(_58,_59){
277with(_58){
278return _verticalLineScroll;
279}
280}),new objj_method(sel_getUid("setPageScroll:"),function(_5a,_5b,_5c){
281with(_5a){
282objj_msgSend(_5a,"setHorizontalPageScroll:",_5c);
283objj_msgSend(_5a,"setVerticalPageScroll:",_5c);
284}
285}),new objj_method(sel_getUid("pageScroll"),function(_5d,_5e){
286with(_5d){
287return objj_msgSend(_5d,"horizontalPageScroll");
288}
289}),new objj_method(sel_getUid("setHorizontalPageScroll:"),function(_5f,_60,_61){
290with(_5f){
291_horizontalPageScroll=_61;
292}
293}),new objj_method(sel_getUid("horizontalPageScroll"),function(_62,_63){
294with(_62){
295return _horizontalPageScroll;
296}
297}),new objj_method(sel_getUid("setVerticalPageScroll:"),function(_64,_65,_66){
298with(_64){
299_verticalPageScroll=_66;
300}
301}),new objj_method(sel_getUid("verticalPageScroll"),function(_67,_68){
302with(_67){
303return _verticalPageScroll;
304}
305}),new objj_method(sel_getUid("scrollWheel:"),function(_69,_6a,_6b){
306with(_69){
307var _6c=objj_msgSend(_verticalScroller,"floatValue"),_6d=objj_msgSend(objj_msgSend(_69,"documentView"),"frame"),_6e=objj_msgSend(_contentView,"bounds");
308_6e.origin.x+=objj_msgSend(_6b,"deltaX")*_horizontalLineScroll;
309_6e.origin.y+=objj_msgSend(_6b,"deltaY")*_verticalLineScroll;
310objj_msgSend(_contentView,"scrollToPoint:",_6e.origin);
311}
312}),new objj_method(sel_getUid("keyDown:"),function(_6f,_70,_71){
313with(_6f){
314var _72=objj_msgSend(_71,"keyCode"),_73=objj_msgSend(_verticalScroller,"floatValue"),_74=objj_msgSend(objj_msgSend(_6f,"documentView"),"frame"),_75=objj_msgSend(_contentView,"bounds");
315switch(_72){
316case 33:
317_75.origin.y-=(_75.size.height)-_verticalPageScroll;
318break;
319case 34:
320_75.origin.y+=(_75.size.height)-_verticalPageScroll;
321break;
322case 38:
323_75.origin.y-=_verticalLineScroll;
324break;
325case 40:
326_75.origin.y+=_verticalLineScroll;
327break;
328case 37:
329_75.origin.x-=_horizontalLineScroll;
330break;
331case 49:
332_75.origin.x+=_horizontalLineScroll;
333break;
334default:
335return objj_msgSendSuper({receiver:_6f,super_class:objj_getClass("CPView")},"keyDown:",_71);
336}
337objj_msgSend(_contentView,"scrollToPoint:",_75.origin);
338}
339})]);
340var _76="CPScrollViewContentView",_77="CPScrollViewVLineScroll",_78="CPScrollViewHLineScroll",_79="CPScrollViewVPageScroll",_7a="CPScrollViewHPageScroll",_7b="CPScrollViewHasVScroller",_7c="CPScrollViewHasHScroller",_7d="CPScrollViewVScroller",_7e="CPScrollViewHScroller",_7f="CPScrollViewAutohidesScroller";
341var _1=objj_getClass("CPScrollView");
342if(!_1){
343objj_exception_throw(new objj_exception(OBJJClassNotFoundException,"*** Could not find definition for class \"CPScrollView\""));
344}
345var _2=_1.isa;
346class_addMethods(_1,[new objj_method(sel_getUid("initWithCoder:"),function(_80,_81,_82){
347with(_80){
348if(_80=objj_msgSendSuper({receiver:_80,super_class:objj_getClass("CPView")},"initWithCoder:",_82)){
349_verticalLineScroll=objj_msgSend(_82,"decodeFloatForKey:",_77);
350_verticalPageScroll=objj_msgSend(_82,"decodeFloatForKey:",_79);
351_horizontalLineScroll=objj_msgSend(_82,"decodeFloatForKey:",_78);
352_horizontalPageScroll=objj_msgSend(_82,"decodeFloatForKey:",_7a);
353_contentView=objj_msgSend(_82,"decodeObjectForKey:",_76);
354_verticalScroller=objj_msgSend(_82,"decodeObjectForKey:",_7d);
355_horizontalScroller=objj_msgSend(_82,"decodeObjectForKey:",_7e);
356_hasVerticalScroller=objj_msgSend(_82,"decodeBoolForKey:",_7b);
357_hasHorizontalScroller=objj_msgSend(_82,"decodeBoolForKey:",_7c);
358_autohidesScrollers=objj_msgSend(_82,"decodeBoolForKey:",_7f);
359objj_msgSend(objj_msgSend(CPRunLoop,"currentRunLoop"),"performSelector:target:argument:order:modes:",sel_getUid("reflectScrolledClipView:"),_80,_contentView,0,[CPDefaultRunLoopMode]);
360}
361return _80;
362}
363}),new objj_method(sel_getUid("encodeWithCoder:"),function(_83,_84,_85){
364with(_83){
365objj_msgSendSuper({receiver:_83,super_class:objj_getClass("CPView")},"encodeWithCoder:",_85);
366objj_msgSend(_85,"encodeObject:forKey:",_contentView,_76);
367objj_msgSend(_85,"encodeObject:forKey:",_verticalScroller,_7d);
368objj_msgSend(_85,"encodeObject:forKey:",_horizontalScroller,_7e);
369objj_msgSend(_85,"encodeFloat:forKey:",_verticalLineScroll,_77);
370objj_msgSend(_85,"encodeFloat:forKey:",_verticalPageScroll,_79);
371objj_msgSend(_85,"encodeFloat:forKey:",_horizontalLineScroll,_78);
372objj_msgSend(_85,"encodeFloat:forKey:",_horizontalPageScroll,_7a);
373objj_msgSend(_85,"encodeBool:forKey:",_hasVerticalScroller,_7b);
374objj_msgSend(_85,"encodeBool:forKey:",_hasHorizontalScroller,_7c);
375objj_msgSend(_85,"encodeBool:forKey:",_autohidesScrollers,_7f);
376}
377})]);