/Frameworks/AppKit/rhino.platform/_CPImageAndTextView.j
http://github.com/jfahrenkrug/MapKit-HelloWorld · Unknown · 249 lines · 249 code · 0 blank · 0 comment · 0 complexity · b6a44a28958481d72901a5cb75366519 MD5 · raw file
- I;21;Foundation/CPString.ji;9;CPColor.ji;8;CPFont.ji;9;CPImage.ji;13;CPTextField.ji;8;CPView.jc;7026;
- CPTopVerticalTextAlignment=1,CPCenterVerticalTextAlignment=2,CPBottomVerticalTextAlignment=3;
- var _1=1<<0,_2=1<<1,_3=1<<2,_4=1<<3,_5=1<<4,_6=1<<5,_7=1<<6,_8=1<<7,_9=1<<8,_a=1<<9,_b=1<<10;
- var _c=3,_d=5;
- var _e=objj_allocateClassPair(CPView,"_CPImageAndTextView"),_f=_e.isa;
- class_addIvars(_e,[new objj_ivar("_alignment"),new objj_ivar("_verticalAlignment"),new objj_ivar("_lineBreakMode"),new objj_ivar("_textColor"),new objj_ivar("_font"),new objj_ivar("_textShadowColor"),new objj_ivar("_textShadowOffset"),new objj_ivar("_imagePosition"),new objj_ivar("_imageScaling"),new objj_ivar("_image"),new objj_ivar("_text"),new objj_ivar("_textSize"),new objj_ivar("_flags")]);
- objj_registerClassPair(_e);
- objj_addClassForBundle(_e,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
- class_addMethods(_e,[new objj_method(sel_getUid("initWithFrame:control:"),function(_10,_11,_12,_13){
- with(_10){
- _10=objj_msgSendSuper({receiver:_10,super_class:objj_getClass("CPView")},"initWithFrame:",_12);
- if(_10){
- _textShadowOffset={width:0,height:0};
- objj_msgSend(_10,"setVerticalAlignment:",CPTopVerticalTextAlignment);
- if(_13){
- objj_msgSend(_10,"setLineBreakMode:",objj_msgSend(_13,"lineBreakMode"));
- objj_msgSend(_10,"setTextColor:",objj_msgSend(_13,"textColor"));
- objj_msgSend(_10,"setAlignment:",objj_msgSend(_13,"alignment"));
- objj_msgSend(_10,"setVerticalAlignment:",objj_msgSend(_13,"verticalAlignment"));
- objj_msgSend(_10,"setFont:",objj_msgSend(_13,"font"));
- objj_msgSend(_10,"setImagePosition:",objj_msgSend(_13,"imagePosition"));
- objj_msgSend(_10,"setImageScaling:",objj_msgSend(_13,"imageScaling"));
- }else{
- objj_msgSend(_10,"setLineBreakMode:",CPLineBreakByClipping);
- objj_msgSend(_10,"setAlignment:",CPCenterTextAlignment);
- objj_msgSend(_10,"setFont:",objj_msgSend(CPFont,"systemFontOfSize:",12));
- objj_msgSend(_10,"setImagePosition:",CPNoImage);
- objj_msgSend(_10,"setImageScaling:",CPScaleNone);
- }
- _textSize=NULL;
- }
- return _10;
- }
- }),new objj_method(sel_getUid("initWithFrame:"),function(_14,_15,_16){
- with(_14){
- return objj_msgSend(_14,"initWithFrame:control:",_16,nil);
- }
- }),new objj_method(sel_getUid("setAlignment:"),function(_17,_18,_19){
- with(_17){
- if(_alignment===_19){
- return;
- }
- _alignment=_19;
- }
- }),new objj_method(sel_getUid("alignment"),function(_1a,_1b){
- with(_1a){
- return _alignment;
- }
- }),new objj_method(sel_getUid("setVerticalAlignment:"),function(_1c,_1d,_1e){
- with(_1c){
- if(_verticalAlignment===_1e){
- return;
- }
- _verticalAlignment=_1e;
- _flags|=_5;
- objj_msgSend(_1c,"setNeedsLayout");
- }
- }),new objj_method(sel_getUid("verticalAlignment"),function(_1f,_20){
- with(_1f){
- return _verticalAlignment;
- }
- }),new objj_method(sel_getUid("setLineBreakMode:"),function(_21,_22,_23){
- with(_21){
- if(_lineBreakMode===_23){
- return;
- }
- _lineBreakMode=_23;
- _flags|=_6;
- objj_msgSend(_21,"setNeedsLayout");
- }
- }),new objj_method(sel_getUid("lineBreakMode"),function(_24,_25){
- with(_24){
- return _lineBreakMode;
- }
- }),new objj_method(sel_getUid("setImagePosition:"),function(_26,_27,_28){
- with(_26){
- if(_imagePosition==_28){
- return;
- }
- _imagePosition=_28;
- _flags|=_a;
- objj_msgSend(_26,"setNeedsLayout");
- }
- }),new objj_method(sel_getUid("imagePosition"),function(_29,_2a){
- with(_29){
- return _imagePosition;
- }
- }),new objj_method(sel_getUid("setImageScaling:"),function(_2b,_2c,_2d){
- with(_2b){
- if(_imageScaling==_2d){
- return;
- }
- _imageScaling=_2d;
- _flags|=_b;
- objj_msgSend(_2b,"setNeedsLayout");
- }
- }),new objj_method(sel_getUid("imageScaling"),function(_2e,_2f){
- with(_2e){
- return _imageScaling;
- }
- }),new objj_method(sel_getUid("setTextColor:"),function(_30,_31,_32){
- with(_30){
- if(_textColor===_32){
- return;
- }
- _textColor=_32;
- }
- }),new objj_method(sel_getUid("textColor"),function(_33,_34){
- with(_33){
- return _textColor;
- }
- }),new objj_method(sel_getUid("setFont:"),function(_35,_36,_37){
- with(_35){
- if(_font===_37){
- return;
- }
- _font=_37;
- _flags|=_8;
- _textSize=NULL;
- objj_msgSend(_35,"setNeedsLayout");
- }
- }),new objj_method(sel_getUid("font"),function(_38,_39){
- with(_38){
- return _font;
- }
- }),new objj_method(sel_getUid("setTextShadowColor:"),function(_3a,_3b,_3c){
- with(_3a){
- if(_textShadowColor===_3c){
- return;
- }
- _textShadowColor=_3c;
- _flags|=_9;
- objj_msgSend(_3a,"setNeedsLayout");
- }
- }),new objj_method(sel_getUid("textShadowColor"),function(_3d,_3e){
- with(_3d){
- return _textShadowColor;
- }
- }),new objj_method(sel_getUid("setTextShadowOffset:"),function(_3f,_40,_41){
- with(_3f){
- if((_textShadowOffset.width==_41.width&&_textShadowOffset.height==_41.height)){
- return;
- }
- _textShadowOffset={width:_41.width,height:_41.height};
- objj_msgSend(_3f,"setNeedsLayout");
- }
- }),new objj_method(sel_getUid("textShadowOffset"),function(_42,_43){
- with(_42){
- return _textShadowOffset;
- }
- }),new objj_method(sel_getUid("setImage:"),function(_44,_45,_46){
- with(_44){
- if(_image==_46){
- return;
- }
- _image=_46;
- _flags|=_2;
- objj_msgSend(_44,"setNeedsLayout");
- }
- }),new objj_method(sel_getUid("image"),function(_47,_48){
- with(_47){
- return _image;
- }
- }),new objj_method(sel_getUid("setText:"),function(_49,_4a,_4b){
- with(_49){
- if(_text===_4b){
- return;
- }
- _text=_4b;
- _flags|=_3;
- _textSize=NULL;
- objj_msgSend(_49,"setNeedsLayout");
- }
- }),new objj_method(sel_getUid("text"),function(_4c,_4d){
- with(_4c){
- return _text;
- }
- }),new objj_method(sel_getUid("layoutSubviews"),function(_4e,_4f){
- with(_4e){
- var _50=objj_msgSend(_4e,"bounds").size,_51={origin:{x:0,y:0},size:{width:_50.width,height:_50.height}};
- if(hasDOMImageElement){
- if(!_52){
- var _52=_DOMImageElement.style;
- }
- if(_flags&_2){
- _DOMImageElement.src=objj_msgSend(_image,"filename");
- }
- var _53=_50.width/2,_54=_50.height/2,_55=objj_msgSend(_image,"size"),_56=_55.width,_57=_55.height;
- if(_imageScaling===CPScaleToFit){
- _56=_50.width;
- _57=_50.height;
- }else{
- if(_imageScaling===CPScaleProportionally){
- var _58=MIN(MIN(_50.width,_56)/_56,MIN(_50.height,_57)/_57);
- _56*=_58;
- _57*=_58;
- }
- }
- if(_imagePosition===CPImageBelow){
- _51.size.height=_50.height-_57-_d;
- }else{
- if(_imagePosition===CPImageAbove){
- _51.origin.y+=_57+_d;
- _51.size.height=_50.height-_57-_d;
- }else{
- if(_imagePosition===CPImageLeft){
- _51.origin.x=_56+_c;
- _51.size.width-=_56+_c;
- }else{
- if(_imagePosition===CPImageRight){
- _51.size.width-=_56+_c;
- }else{
- if(_imagePosition===CPImageOnly){
- }
- }
- }
- }
- }
- }
- _flags=0;
- }
- }),new objj_method(sel_getUid("sizeToFit"),function(_59,_5a){
- with(_59){
- var _5b=CGSizeMakeZero();
- if((_imagePosition!==CPNoImage)&&_image){
- var _5c=objj_msgSend(_image,"size");
- _5b.width+=_5c.width;
- _5b.height+=_5c.height;
- }
- if((_imagePosition!==CPImageOnly)&&objj_msgSend(_text,"length")>0){
- if(!_textSize){
- _textSize=objj_msgSend(_text,"sizeWithFont:",_font?_font:objj_msgSend(CPFont,"systemFontOfSize:",12));
- }
- if(_imagePosition===CPImageLeft||_imagePosition===CPImageRight){
- _5b.width+=_textSize.width+_c;
- _5b.height=MAX(_5b.height,_textSize.height);
- }else{
- if(_imagePosition===CPImageAbove||_imagePosition===CPImageBelow){
- _5b.width=MAX(_5b.width,_textSize.width);
- _5b.height+=_textSize.height+_d;
- }else{
- _5b.width=MAX(_5b.width,_textSize.width);
- _5b.height=MAX(_5b.height,_textSize.height);
- }
- }
- }
- objj_msgSend(_59,"setFrameSize:",_5b);
- }
- })]);