PageRenderTime 18ms CodeModel.GetById 11ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/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
  1I;21;Foundation/CPString.ji;9;CPColor.ji;8;CPFont.ji;9;CPImage.ji;13;CPTextField.ji;8;CPView.jc;7026;
  2CPTopVerticalTextAlignment=1,CPCenterVerticalTextAlignment=2,CPBottomVerticalTextAlignment=3;
  3var _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;
  4var _c=3,_d=5;
  5var _e=objj_allocateClassPair(CPView,"_CPImageAndTextView"),_f=_e.isa;
  6class_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")]);
  7objj_registerClassPair(_e);
  8objj_addClassForBundle(_e,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  9class_addMethods(_e,[new objj_method(sel_getUid("initWithFrame:control:"),function(_10,_11,_12,_13){
 10with(_10){
 11_10=objj_msgSendSuper({receiver:_10,super_class:objj_getClass("CPView")},"initWithFrame:",_12);
 12if(_10){
 13_textShadowOffset={width:0,height:0};
 14objj_msgSend(_10,"setVerticalAlignment:",CPTopVerticalTextAlignment);
 15if(_13){
 16objj_msgSend(_10,"setLineBreakMode:",objj_msgSend(_13,"lineBreakMode"));
 17objj_msgSend(_10,"setTextColor:",objj_msgSend(_13,"textColor"));
 18objj_msgSend(_10,"setAlignment:",objj_msgSend(_13,"alignment"));
 19objj_msgSend(_10,"setVerticalAlignment:",objj_msgSend(_13,"verticalAlignment"));
 20objj_msgSend(_10,"setFont:",objj_msgSend(_13,"font"));
 21objj_msgSend(_10,"setImagePosition:",objj_msgSend(_13,"imagePosition"));
 22objj_msgSend(_10,"setImageScaling:",objj_msgSend(_13,"imageScaling"));
 23}else{
 24objj_msgSend(_10,"setLineBreakMode:",CPLineBreakByClipping);
 25objj_msgSend(_10,"setAlignment:",CPCenterTextAlignment);
 26objj_msgSend(_10,"setFont:",objj_msgSend(CPFont,"systemFontOfSize:",12));
 27objj_msgSend(_10,"setImagePosition:",CPNoImage);
 28objj_msgSend(_10,"setImageScaling:",CPScaleNone);
 29}
 30_textSize=NULL;
 31}
 32return _10;
 33}
 34}),new objj_method(sel_getUid("initWithFrame:"),function(_14,_15,_16){
 35with(_14){
 36return objj_msgSend(_14,"initWithFrame:control:",_16,nil);
 37}
 38}),new objj_method(sel_getUid("setAlignment:"),function(_17,_18,_19){
 39with(_17){
 40if(_alignment===_19){
 41return;
 42}
 43_alignment=_19;
 44}
 45}),new objj_method(sel_getUid("alignment"),function(_1a,_1b){
 46with(_1a){
 47return _alignment;
 48}
 49}),new objj_method(sel_getUid("setVerticalAlignment:"),function(_1c,_1d,_1e){
 50with(_1c){
 51if(_verticalAlignment===_1e){
 52return;
 53}
 54_verticalAlignment=_1e;
 55_flags|=_5;
 56objj_msgSend(_1c,"setNeedsLayout");
 57}
 58}),new objj_method(sel_getUid("verticalAlignment"),function(_1f,_20){
 59with(_1f){
 60return _verticalAlignment;
 61}
 62}),new objj_method(sel_getUid("setLineBreakMode:"),function(_21,_22,_23){
 63with(_21){
 64if(_lineBreakMode===_23){
 65return;
 66}
 67_lineBreakMode=_23;
 68_flags|=_6;
 69objj_msgSend(_21,"setNeedsLayout");
 70}
 71}),new objj_method(sel_getUid("lineBreakMode"),function(_24,_25){
 72with(_24){
 73return _lineBreakMode;
 74}
 75}),new objj_method(sel_getUid("setImagePosition:"),function(_26,_27,_28){
 76with(_26){
 77if(_imagePosition==_28){
 78return;
 79}
 80_imagePosition=_28;
 81_flags|=_a;
 82objj_msgSend(_26,"setNeedsLayout");
 83}
 84}),new objj_method(sel_getUid("imagePosition"),function(_29,_2a){
 85with(_29){
 86return _imagePosition;
 87}
 88}),new objj_method(sel_getUid("setImageScaling:"),function(_2b,_2c,_2d){
 89with(_2b){
 90if(_imageScaling==_2d){
 91return;
 92}
 93_imageScaling=_2d;
 94_flags|=_b;
 95objj_msgSend(_2b,"setNeedsLayout");
 96}
 97}),new objj_method(sel_getUid("imageScaling"),function(_2e,_2f){
 98with(_2e){
 99return _imageScaling;
100}
101}),new objj_method(sel_getUid("setTextColor:"),function(_30,_31,_32){
102with(_30){
103if(_textColor===_32){
104return;
105}
106_textColor=_32;
107}
108}),new objj_method(sel_getUid("textColor"),function(_33,_34){
109with(_33){
110return _textColor;
111}
112}),new objj_method(sel_getUid("setFont:"),function(_35,_36,_37){
113with(_35){
114if(_font===_37){
115return;
116}
117_font=_37;
118_flags|=_8;
119_textSize=NULL;
120objj_msgSend(_35,"setNeedsLayout");
121}
122}),new objj_method(sel_getUid("font"),function(_38,_39){
123with(_38){
124return _font;
125}
126}),new objj_method(sel_getUid("setTextShadowColor:"),function(_3a,_3b,_3c){
127with(_3a){
128if(_textShadowColor===_3c){
129return;
130}
131_textShadowColor=_3c;
132_flags|=_9;
133objj_msgSend(_3a,"setNeedsLayout");
134}
135}),new objj_method(sel_getUid("textShadowColor"),function(_3d,_3e){
136with(_3d){
137return _textShadowColor;
138}
139}),new objj_method(sel_getUid("setTextShadowOffset:"),function(_3f,_40,_41){
140with(_3f){
141if((_textShadowOffset.width==_41.width&&_textShadowOffset.height==_41.height)){
142return;
143}
144_textShadowOffset={width:_41.width,height:_41.height};
145objj_msgSend(_3f,"setNeedsLayout");
146}
147}),new objj_method(sel_getUid("textShadowOffset"),function(_42,_43){
148with(_42){
149return _textShadowOffset;
150}
151}),new objj_method(sel_getUid("setImage:"),function(_44,_45,_46){
152with(_44){
153if(_image==_46){
154return;
155}
156_image=_46;
157_flags|=_2;
158objj_msgSend(_44,"setNeedsLayout");
159}
160}),new objj_method(sel_getUid("image"),function(_47,_48){
161with(_47){
162return _image;
163}
164}),new objj_method(sel_getUid("setText:"),function(_49,_4a,_4b){
165with(_49){
166if(_text===_4b){
167return;
168}
169_text=_4b;
170_flags|=_3;
171_textSize=NULL;
172objj_msgSend(_49,"setNeedsLayout");
173}
174}),new objj_method(sel_getUid("text"),function(_4c,_4d){
175with(_4c){
176return _text;
177}
178}),new objj_method(sel_getUid("layoutSubviews"),function(_4e,_4f){
179with(_4e){
180var _50=objj_msgSend(_4e,"bounds").size,_51={origin:{x:0,y:0},size:{width:_50.width,height:_50.height}};
181if(hasDOMImageElement){
182if(!_52){
183var _52=_DOMImageElement.style;
184}
185if(_flags&_2){
186_DOMImageElement.src=objj_msgSend(_image,"filename");
187}
188var _53=_50.width/2,_54=_50.height/2,_55=objj_msgSend(_image,"size"),_56=_55.width,_57=_55.height;
189if(_imageScaling===CPScaleToFit){
190_56=_50.width;
191_57=_50.height;
192}else{
193if(_imageScaling===CPScaleProportionally){
194var _58=MIN(MIN(_50.width,_56)/_56,MIN(_50.height,_57)/_57);
195_56*=_58;
196_57*=_58;
197}
198}
199if(_imagePosition===CPImageBelow){
200_51.size.height=_50.height-_57-_d;
201}else{
202if(_imagePosition===CPImageAbove){
203_51.origin.y+=_57+_d;
204_51.size.height=_50.height-_57-_d;
205}else{
206if(_imagePosition===CPImageLeft){
207_51.origin.x=_56+_c;
208_51.size.width-=_56+_c;
209}else{
210if(_imagePosition===CPImageRight){
211_51.size.width-=_56+_c;
212}else{
213if(_imagePosition===CPImageOnly){
214}
215}
216}
217}
218}
219}
220_flags=0;
221}
222}),new objj_method(sel_getUid("sizeToFit"),function(_59,_5a){
223with(_59){
224var _5b=CGSizeMakeZero();
225if((_imagePosition!==CPNoImage)&&_image){
226var _5c=objj_msgSend(_image,"size");
227_5b.width+=_5c.width;
228_5b.height+=_5c.height;
229}
230if((_imagePosition!==CPImageOnly)&&objj_msgSend(_text,"length")>0){
231if(!_textSize){
232_textSize=objj_msgSend(_text,"sizeWithFont:",_font?_font:objj_msgSend(CPFont,"systemFontOfSize:",12));
233}
234if(_imagePosition===CPImageLeft||_imagePosition===CPImageRight){
235_5b.width+=_textSize.width+_c;
236_5b.height=MAX(_5b.height,_textSize.height);
237}else{
238if(_imagePosition===CPImageAbove||_imagePosition===CPImageBelow){
239_5b.width=MAX(_5b.width,_textSize.width);
240_5b.height+=_textSize.height+_d;
241}else{
242_5b.width=MAX(_5b.width,_textSize.width);
243_5b.height=MAX(_5b.height,_textSize.height);
244}
245}
246}
247objj_msgSend(_59,"setFrameSize:",_5b);
248}
249})]);