PageRenderTime 24ms CodeModel.GetById 13ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/Frameworks/AppKit/rhino.platform/CPButton.j

http://github.com/jfahrenkrug/MapKit-HelloWorld
Unknown | 445 lines | 445 code | 0 blank | 0 comment | 0 complexity | 8d5add472bd31241f580db7d110b2b29 MD5 | raw file
  1i;21;_CPImageAndTextView.ji;12;CGGeometry.ji;11;CPControl.jc;15898;
  2CPScaleProportionally=0;
  3CPScaleToFit=1;
  4CPScaleNone=2;
  5CPNoImage=0;
  6CPImageOnly=1;
  7CPImageLeft=2;
  8CPImageRight=3;
  9CPImageBelow=4;
 10CPImageAbove=5;
 11CPImageOverlaps=6;
 12CPOnState=1;
 13CPOffState=0;
 14CPMixedState=-1;
 15CPRoundedBezelStyle=1;
 16CPRegularSquareBezelStyle=2;
 17CPThickSquareBezelStyle=3;
 18CPThickerSquareBezelStyle=4;
 19CPDisclosureBezelStyle=5;
 20CPShadowlessSquareBezelStyle=6;
 21CPCircularBezelStyle=7;
 22CPTexturedSquareBezelStyle=8;
 23CPHelpButtonBezelStyle=9;
 24CPSmallSquareBezelStyle=10;
 25CPTexturedRoundedBezelStyle=11;
 26CPRoundRectBezelStyle=12;
 27CPRecessedBezelStyle=13;
 28CPRoundedDisclosureBezelStyle=14;
 29CPHUDBezelStyle=-1;
 30CPMomentaryLightButton=0;
 31CPPushOnPushOffButton=1;
 32CPToggleButton=2;
 33CPSwitchButton=3;
 34CPRadioButton=4;
 35CPMomentaryChangeButton=5;
 36CPOnOffButton=6;
 37CPMomentaryPushInButton=7;
 38CPMomentaryPushButton=0;
 39CPMomentaryLight=7;
 40CPNoButtonMask=0;
 41CPContentsButtonMask=1;
 42CPPushInButtonMask=2;
 43CPGrayButtonMask=4;
 44CPBackgroundButtonMask=8;
 45CPNoCellMask=CPNoButtonMask;
 46CPContentsCellMask=CPContentsButtonMask;
 47CPPushInCellMask=CPPushInButtonMask;
 48CPChangeGrayCellMask=CPGrayButtonMask;
 49CPChangeBackgroundCellMask=CPBackgroundButtonMask;
 50CPButtonStateMixed=CPThemeState("mixed");
 51var _1=objj_allocateClassPair(CPControl,"CPButton"),_2=_1.isa;
 52class_addIvars(_1,[new objj_ivar("_allowsMixedState"),new objj_ivar("_title"),new objj_ivar("_alternateTitle"),new objj_ivar("_image"),new objj_ivar("_alternateImage"),new objj_ivar("_showsStateBy"),new objj_ivar("_highlightsBy"),new objj_ivar("_imageDimsWhenDisabled"),new objj_ivar("_bezelStyle"),new objj_ivar("_controlSize")]);
 53objj_registerClassPair(_1);
 54objj_addClassForBundle(_1,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
 55class_addMethods(_1,[new objj_method(sel_getUid("initWithFrame:"),function(_3,_4,_5){
 56with(_3){
 57_3=objj_msgSendSuper({receiver:_3,super_class:objj_getClass("CPControl")},"initWithFrame:",_5);
 58if(_3){
 59objj_msgSend(_3,"setValue:forThemeAttribute:",CPCenterTextAlignment,"alignment");
 60objj_msgSend(_3,"setValue:forThemeAttribute:",CPCenterVerticalTextAlignment,"vertical-alignment");
 61objj_msgSend(_3,"setValue:forThemeAttribute:",CPImageLeft,"image-position");
 62objj_msgSend(_3,"setValue:forThemeAttribute:",CPScaleNone,"image-scaling");
 63_controlSize=CPRegularControlSize;
 64objj_msgSend(_3,"setBordered:",YES);
 65}
 66return _3;
 67}
 68}),new objj_method(sel_getUid("allowsMixedState"),function(_6,_7){
 69with(_6){
 70return _allowsMixedState;
 71}
 72}),new objj_method(sel_getUid("setAllowsMixedState:"),function(_8,_9,_a){
 73with(_8){
 74_a=!!_a;
 75if(_allowsMixedState===_a){
 76return;
 77}
 78_allowsMixedState=_a;
 79if(!_allowsMixedState){
 80objj_msgSend(_8,"unsetThemeState:",CPButtonStateMixed);
 81}
 82}
 83}),new objj_method(sel_getUid("setObjectValue:"),function(_b,_c,_d){
 84with(_b){
 85if(!_d||_d===""||(objj_msgSend(_d,"intValue")===0)){
 86_d=CPOffState;
 87}else{
 88if(!objj_msgSend(_d,"isKindOfClass:",objj_msgSend(CPNumber,"class"))){
 89_d=CPOnState;
 90}else{
 91if(_d>CPOnState){
 92_d=CPOnState;
 93}else{
 94if(_d<CPOffState){
 95if(objj_msgSend(_b,"allowsMixedState")){
 96_d=CPMixedState;
 97}else{
 98_d=CPOnState;
 99}
100}
101}
102}
103}
104objj_msgSendSuper({receiver:_b,super_class:objj_getClass("CPControl")},"setObjectValue:",_d);
105switch(objj_msgSend(_b,"objectValue")){
106case CPMixedState:
107objj_msgSend(_b,"unsetThemeState:",CPThemeStateSelected);
108objj_msgSend(_b,"setThemeState:",CPButtonStateMixed);
109break;
110case CPOnState:
111objj_msgSend(_b,"unsetThemeState:",CPButtonStateMixed);
112objj_msgSend(_b,"setThemeState:",CPThemeStateSelected);
113break;
114case CPOffState:
115objj_msgSend(_b,"unsetThemeState:",CPThemeStateSelected|CPButtonStateMixed);
116}
117}
118}),new objj_method(sel_getUid("nextState"),function(_e,_f){
119with(_e){
120if(objj_msgSend(_e,"allowsMixedState")){
121var _10=objj_msgSend(_e,"state");
122return _10-((_10===-1)?-2:1);
123}
124return 1-objj_msgSend(_e,"state");
125}
126}),new objj_method(sel_getUid("setNextState"),function(_11,_12){
127with(_11){
128objj_msgSend(_11,"setState:",objj_msgSend(_11,"nextState"));
129}
130}),new objj_method(sel_getUid("setState:"),function(_13,_14,_15){
131with(_13){
132objj_msgSend(_13,"setIntValue:",_15);
133}
134}),new objj_method(sel_getUid("state"),function(_16,_17){
135with(_16){
136return objj_msgSend(_16,"intValue");
137}
138}),new objj_method(sel_getUid("setTitle:"),function(_18,_19,_1a){
139with(_18){
140if(_title===_1a){
141return;
142}
143_title=_1a;
144objj_msgSend(_18,"setNeedsLayout");
145objj_msgSend(_18,"setNeedsDisplay:",YES);
146}
147}),new objj_method(sel_getUid("title"),function(_1b,_1c){
148with(_1b){
149return _title;
150}
151}),new objj_method(sel_getUid("setAlternateTitle:"),function(_1d,_1e,_1f){
152with(_1d){
153if(_alternateTitle===_1f){
154return;
155}
156_alternateTitle=_1f;
157objj_msgSend(_1d,"setNeedsLayout");
158objj_msgSend(_1d,"setNeedsDisplay:",YES);
159}
160}),new objj_method(sel_getUid("alternateTitle"),function(_20,_21){
161with(_20){
162return _alternateTitle;
163}
164}),new objj_method(sel_getUid("setImage:"),function(_22,_23,_24){
165with(_22){
166if(_image===_24){
167return;
168}
169_image=_24;
170objj_msgSend(_22,"setNeedsLayout");
171objj_msgSend(_22,"setNeedsDisplay:",YES);
172}
173}),new objj_method(sel_getUid("image"),function(_25,_26){
174with(_25){
175return _image;
176}
177}),new objj_method(sel_getUid("setAlternateImage:"),function(_27,_28,_29){
178with(_27){
179if(_alternateImage===_29){
180return;
181}
182_alternateImage=_29;
183objj_msgSend(_27,"setNeedsLayout");
184objj_msgSend(_27,"setNeedsDisplay:",YES);
185}
186}),new objj_method(sel_getUid("alternateImage"),function(_2a,_2b){
187with(_2a){
188return _alternateImage;
189}
190}),new objj_method(sel_getUid("setShowsStateBy:"),function(_2c,_2d,_2e){
191with(_2c){
192if(_showsStateBy===_2e){
193return;
194}
195_showsStateBy=_2e;
196objj_msgSend(_2c,"setNeedsDisplay:",YES);
197objj_msgSend(_2c,"setNeedsLayout");
198}
199}),new objj_method(sel_getUid("showsStateBy"),function(_2f,_30){
200with(_2f){
201return _showsStateBy;
202}
203}),new objj_method(sel_getUid("setHighlightsBy:"),function(_31,_32,_33){
204with(_31){
205if(_highlightsBy===_33){
206return;
207}
208_highlightsBy=_33;
209if(objj_msgSend(_31,"hasThemeState:",CPThemeStateHighlighted)){
210objj_msgSend(_31,"setNeedsDisplay:",YES);
211objj_msgSend(_31,"setNeedsLayout");
212}
213}
214}),new objj_method(sel_getUid("setButtonType:"),function(_34,_35,_36){
215with(_34){
216switch(buttonType){
217case CPMomentaryLightButton:
218objj_msgSend(_34,"setHighlightsBy:",CPChangeBackgroundCellMask);
219objj_msgSend(_34,"setShowsStateBy:",CPNoCellMask);
220break;
221case CPMomentaryPushInButton:
222objj_msgSend(_34,"setHighlightsBy:",CPPushInCellMask|CPChangeGrayCellMask);
223objj_msgSend(_34,"setShowsStateBy:",CPNoCellMask);
224break;
225case CPMomentaryChangeButton:
226objj_msgSend(_34,"setHighlightsBy:",CPContentsCellMask);
227objj_msgSend(_34,"setShowsStateBy:",CPNoCellMask);
228break;
229case CPPushOnPushOffButton:
230objj_msgSend(_34,"setHighlightsBy:",CPPushInCellMask|CPChangeGrayCellMask);
231objj_msgSend(_34,"setShowsStateBy:",CPChangeBackgroundCellMask);
232break;
233case CPOnOffButton:
234objj_msgSend(_34,"setHighlightsBy:",CPChangeBackgroundCellMask);
235objj_msgSend(_34,"setShowsStateBy:",CPChangeBackgroundCellMask);
236break;
237case CPToggleButton:
238objj_msgSend(_34,"setHighlightsBy:",CPPushInCellMask|NSContentsCellMask);
239objj_msgSend(_34,"setShowsStateBy:",CPContentsCellMask);
240break;
241case CPSwitchButton:
242objj_msgSend(CPException,"raise:reason:",CPInvalidArgumentException,"The CPSwitchButton type is not supported in Cappuccino, use the CPCheckBox class instead.");
243case CPRadioButton:
244objj_msgSend(CPException,"raise:reason:",CPInvalidArgumentException,"The CPRadioButton type is not supported in Cappuccino, use the CPRadio class instead.");
245default:
246objj_msgSend(CPException,"raise:reason:",CPInvalidArgumentException,"Unknown button type.");
247}
248objj_msgSend(_34,"setImageDimsWhenDisabled:",YES);
249}
250}),new objj_method(sel_getUid("setImageDimsWhenDisabled:"),function(_37,_38,_39){
251with(_37){
252_39=!!_39;
253if(_imageDimsWhenDisabled===_39){
254return;
255}
256_imageDimsWhenDisabled=_39;
257if(_imageDimsWhenDisabled){
258objj_msgSend(_37,"setNeedsDisplay:",YES);
259objj_msgSend(_37,"setNeedsLayout");
260}
261}
262}),new objj_method(sel_getUid("imageDimsWhenDisabled"),function(_3a,_3b){
263with(_3a){
264return _imageDimsWhenDisabled;
265}
266}),new objj_method(sel_getUid("startTrackingAt:"),function(_3c,_3d,_3e){
267with(_3c){
268objj_msgSend(_3c,"highlight:",YES);
269return objj_msgSendSuper({receiver:_3c,super_class:objj_getClass("CPControl")},"startTrackingAt:",_3e);
270}
271}),new objj_method(sel_getUid("stopTracking:at:mouseIsUp:"),function(_3f,_40,_41,_42,_43){
272with(_3f){
273objj_msgSend(_3f,"highlight:",NO);
274objj_msgSendSuper({receiver:_3f,super_class:objj_getClass("CPControl")},"stopTracking:at:mouseIsUp:",_41,_42,_43);
275if(_43&&CGRectContainsPoint(objj_msgSend(_3f,"bounds"),_42)){
276objj_msgSend(_3f,"setNextState");
277}
278}
279}),new objj_method(sel_getUid("contentRectForBounds:"),function(_44,_45,_46){
280with(_44){
281var _47=objj_msgSend(_44,"currentValueForThemeAttribute:","content-inset");
282if(((_47).top===0&&(_47).right===0&&(_47).bottom===0&&(_47).left===0)){
283return _46;
284}
285_46.origin.x+=_47.left;
286_46.origin.y+=_47.top;
287_46.size.width-=_47.left+_47.right;
288_46.size.height-=_47.top+_47.bottom;
289return _46;
290}
291}),new objj_method(sel_getUid("bezelRectForBounds:"),function(_48,_49,_4a){
292with(_48){
293if(!objj_msgSend(_48,"isBordered")){
294return {origin:{x:0,y:0},size:{width:0,height:0}};
295}
296var _4b=objj_msgSend(_48,"currentValueForThemeAttribute:","bezel-inset");
297if(((_4b).top===0&&(_4b).right===0&&(_4b).bottom===0&&(_4b).left===0)){
298return _4a;
299}
300_4a.origin.x+=_4b.left;
301_4a.origin.y+=_4b.top;
302_4a.size.width-=_4b.left+_4b.right;
303_4a.size.height-=_4b.top+_4b.bottom;
304return _4a;
305}
306}),new objj_method(sel_getUid("sizeToFit"),function(_4c,_4d){
307with(_4c){
308var _4e=objj_msgSend((objj_msgSend(_4c,"title")||" "),"sizeWithFont:",objj_msgSend(_4c,"currentValueForThemeAttribute:","font")),_4f=objj_msgSend(_4c,"currentValueForThemeAttribute:","content-inset"),_50=objj_msgSend(_4c,"currentValueForThemeAttribute:","min-size"),_51=objj_msgSend(_4c,"currentValueForThemeAttribute:","max-size");
309_4e.width=MAX(_4e.width+_4f.left+_4f.right,_50.width);
310_4e.height=MAX(_4e.height+_4f.top+_4f.bottom,_50.height);
311if(_51.width>=0){
312_4e.width=MIN(_4e.width,_51.width);
313}
314if(_51.height>=0){
315_4e.height=MIN(_4e.height,_51.height);
316}
317objj_msgSend(_4c,"setFrameSize:",_4e);
318}
319}),new objj_method(sel_getUid("rectForEphemeralSubviewNamed:"),function(_52,_53,_54){
320with(_52){
321if(_54==="bezel-view"){
322return objj_msgSend(_52,"bezelRectForBounds:",objj_msgSend(_52,"bounds"));
323}else{
324if(_54==="content-view"){
325return objj_msgSend(_52,"contentRectForBounds:",objj_msgSend(_52,"bounds"));
326}
327}
328return objj_msgSendSuper({receiver:_52,super_class:objj_getClass("CPControl")},"rectForEphemeralSubviewNamed:",_54);
329}
330}),new objj_method(sel_getUid("createEphemeralSubviewNamed:"),function(_55,_56,_57){
331with(_55){
332if(_57==="bezel-view"){
333var _58=objj_msgSend(objj_msgSend(CPView,"alloc"),"initWithFrame:",{origin:{x:0,y:0},size:{width:0,height:0}});
334objj_msgSend(_58,"setHitTests:",NO);
335return _58;
336}else{
337return objj_msgSend(objj_msgSend(_CPImageAndTextView,"alloc"),"initWithFrame:",{origin:{x:0,y:0},size:{width:0,height:0}});
338}
339return objj_msgSendSuper({receiver:_55,super_class:objj_getClass("CPControl")},"createEphemeralSubviewNamed:",_57);
340}
341}),new objj_method(sel_getUid("layoutSubviews"),function(_59,_5a){
342with(_59){
343var _5b=objj_msgSend(_59,"layoutEphemeralSubviewNamed:positioned:relativeToEphemeralSubviewNamed:","bezel-view",CPWindowBelow,"content-view");
344if(_5b){
345objj_msgSend(_5b,"setBackgroundColor:",objj_msgSend(_59,"currentValueForThemeAttribute:","bezel-color"));
346}
347var _5c=objj_msgSend(_59,"layoutEphemeralSubviewNamed:positioned:relativeToEphemeralSubviewNamed:","content-view",CPWindowAbove,"bezel-view");
348if(_5c){
349objj_msgSend(_5c,"setText:",(objj_msgSend(_59,"hasThemeState:",CPThemeStateHighlighted)&&_alternateTitle)?_alternateTitle:_title);
350objj_msgSend(_5c,"setImage:",(objj_msgSend(_59,"hasThemeState:",CPThemeStateHighlighted)&&_alternateImage)?_alternateImage:_image);
351objj_msgSend(_5c,"setFont:",objj_msgSend(_59,"currentValueForThemeAttribute:","font"));
352objj_msgSend(_5c,"setTextColor:",objj_msgSend(_59,"currentValueForThemeAttribute:","text-color"));
353objj_msgSend(_5c,"setAlignment:",objj_msgSend(_59,"currentValueForThemeAttribute:","alignment"));
354objj_msgSend(_5c,"setVerticalAlignment:",objj_msgSend(_59,"currentValueForThemeAttribute:","vertical-alignment"));
355objj_msgSend(_5c,"setLineBreakMode:",objj_msgSend(_59,"currentValueForThemeAttribute:","line-break-mode"));
356objj_msgSend(_5c,"setTextShadowColor:",objj_msgSend(_59,"currentValueForThemeAttribute:","text-shadow-color"));
357objj_msgSend(_5c,"setTextShadowOffset:",objj_msgSend(_59,"currentValueForThemeAttribute:","text-shadow-offset"));
358objj_msgSend(_5c,"setImagePosition:",objj_msgSend(_59,"currentValueForThemeAttribute:","image-position"));
359objj_msgSend(_5c,"setImageScaling:",objj_msgSend(_59,"currentValueForThemeAttribute:","image-scaling"));
360}
361}
362}),new objj_method(sel_getUid("setDefaultButton:"),function(_5d,_5e,_5f){
363with(_5d){
364if(_5f){
365objj_msgSend(_5d,"setThemeState:",CPThemeStateDefault);
366}else{
367objj_msgSend(_5d,"unsetThemeState:",CPThemeStateDefault);
368}
369}
370}),new objj_method(sel_getUid("setBordered:"),function(_60,_61,_62){
371with(_60){
372if(_62){
373objj_msgSend(_60,"setThemeState:",CPThemeStateBordered);
374}else{
375objj_msgSend(_60,"unsetThemeState:",CPThemeStateBordered);
376}
377}
378}),new objj_method(sel_getUid("isBordered"),function(_63,_64){
379with(_63){
380return objj_msgSend(_63,"hasThemeState:",CPThemeStateBordered);
381}
382})]);
383class_addMethods(_2,[new objj_method(sel_getUid("buttonWithTitle:"),function(_65,_66,_67){
384with(_65){
385return objj_msgSend(_65,"buttonWithTitle:theme:",_67,objj_msgSend(CPTheme,"defaultTheme"));
386}
387}),new objj_method(sel_getUid("buttonWithTitle:theme:"),function(_68,_69,_6a,_6b){
388with(_68){
389var _6c=objj_msgSend(objj_msgSend(_68,"alloc"),"init");
390objj_msgSend(_6c,"setTheme:",_6b);
391objj_msgSend(_6c,"setTitle:",_6a);
392objj_msgSend(_6c,"sizeToFit");
393return _6c;
394}
395}),new objj_method(sel_getUid("themeClass"),function(_6d,_6e){
396with(_6d){
397return "button";
398}
399}),new objj_method(sel_getUid("themeAttributes"),function(_6f,_70){
400with(_6f){
401return objj_msgSend(CPDictionary,"dictionaryWithObjects:forKeys:",[{top:(0),right:(0),bottom:(0),left:(0)},{top:(0),right:(0),bottom:(0),left:(0)},nil],["bezel-inset","content-inset","bezel-color"]);
402}
403})]);
404var _1=objj_getClass("CPButton");
405if(!_1){
406objj_exception_throw(new objj_exception(OBJJClassNotFoundException,"*** Could not find definition for class \"CPButton\""));
407}
408var _2=_1.isa;
409class_addMethods(_1,[new objj_method(sel_getUid("setBezelStyle:"),function(_71,_72,_73){
410with(_71){
411}
412}),new objj_method(sel_getUid("bezelStyle"),function(_74,_75){
413with(_74){
414}
415})]);
416var _76="CPButtonImageKey",_77="CPButtonAlternateImageKey",_78="CPButtonTitleKey",_79="CPButtonAlternateTitleKey",_7a="CPButtonIsBorderedKey";
417var _1=objj_getClass("CPButton");
418if(!_1){
419objj_exception_throw(new objj_exception(OBJJClassNotFoundException,"*** Could not find definition for class \"CPButton\""));
420}
421var _2=_1.isa;
422class_addMethods(_1,[new objj_method(sel_getUid("initWithCoder:"),function(_7b,_7c,_7d){
423with(_7b){
424_7b=objj_msgSendSuper({receiver:_7b,super_class:objj_getClass("CPControl")},"initWithCoder:",_7d);
425if(_7b){
426_controlSize=CPRegularControlSize;
427objj_msgSend(_7b,"setImage:",objj_msgSend(_7d,"decodeObjectForKey:",_76));
428objj_msgSend(_7b,"setAlternateImage:",objj_msgSend(_7d,"decodeObjectForKey:",_77));
429objj_msgSend(_7b,"setTitle:",objj_msgSend(_7d,"decodeObjectForKey:",_78));
430objj_msgSend(_7b,"setAlternateTitle:",objj_msgSend(_7d,"decodeObjectForKey:",_79));
431objj_msgSend(_7b,"setNeedsLayout");
432objj_msgSend(_7b,"setNeedsDisplay:",YES);
433}
434return _7b;
435}
436}),new objj_method(sel_getUid("encodeWithCoder:"),function(_7e,_7f,_80){
437with(_7e){
438objj_msgSendSuper({receiver:_7e,super_class:objj_getClass("CPControl")},"encodeWithCoder:",_80);
439objj_msgSend(_80,"encodeObject:forKey:",_image,_76);
440objj_msgSend(_80,"encodeObject:forKey:",_alternateImage,_77);
441objj_msgSend(_80,"encodeObject:forKey:",_title,_78);
442objj_msgSend(_80,"encodeObject:forKey:",_alternateTitle,_79);
443}
444})]);
445i;12;CPCheckBox.ji;9;CPRadio.j