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

/Frameworks/AppKit/browser.platform/CPSegmentedControl.j

http://github.com/jfahrenkrug/MapKit-HelloWorld
Unknown | 522 lines | 522 code | 0 blank | 0 comment | 0 complexity | 06cdee77051c9bf977befd173fbe6820 MD5 | raw file
  1I;20;Foundation/CPArray.ji;11;CPControl.jc;20227;
  2CPSegmentSwitchTrackingSelectOne=0;
  3CPSegmentSwitchTrackingSelectAny=1;
  4CPSegmentSwitchTrackingMomentary=2;
  5var _1=objj_allocateClassPair(CPControl,"CPSegmentedControl"),_2=_1.isa;
  6class_addIvars(_1,[new objj_ivar("_segments"),new objj_ivar("_themeStates"),new objj_ivar("_selectedSegment"),new objj_ivar("_segmentStyle"),new objj_ivar("_trackingMode"),new objj_ivar("_trackingSegment"),new objj_ivar("_trackingHighlighted")]);
  7objj_registerClassPair(_1);
  8objj_addClassForBundle(_1,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
  9class_addMethods(_1,[new objj_method(sel_getUid("initWithFrame:"),function(_3,_4,_5){
 10with(_3){
 11_segments=[];
 12_themeStates=[];
 13_3=objj_msgSendSuper({receiver:_3,super_class:objj_getClass("CPControl")},"initWithFrame:",_5);
 14if(_3){
 15_selectedSegment=-1;
 16_trackingMode=CPSegmentSwitchTrackingSelectOne;
 17}
 18return _3;
 19}
 20}),new objj_method(sel_getUid("selectedTag"),function(_6,_7){
 21with(_6){
 22return _segments[_selectedSegment].tag;
 23}
 24}),new objj_method(sel_getUid("setSegmentCount:"),function(_8,_9,_a){
 25with(_8){
 26if(_segments.length==_a){
 27return;
 28}
 29var _b=CGRectGetHeight(objj_msgSend(_8,"bounds"));
 30if(_segments.length<_a){
 31for(var _c=_segments.length;_c<_a;++_c){
 32_segments[_c]=objj_msgSend(objj_msgSend(_CPSegmentItem,"alloc"),"init");
 33_themeStates[_c]=CPThemeStateNormal;
 34}
 35}else{
 36if(_a<_segments.length){
 37for(var _c=_a;_c<_segments.length;++_c){
 38_segments[_c]=nil;
 39}
 40}
 41}
 42if(_selectedSegment<_segments.length){
 43_selectedSegment=-1;
 44}
 45objj_msgSend(_8,"tileWithChangedSegment:",0);
 46}
 47}),new objj_method(sel_getUid("segmentCount"),function(_d,_e){
 48with(_d){
 49return _segments.length;
 50}
 51}),new objj_method(sel_getUid("setSelectedSegment:"),function(_f,_10,_11){
 52with(_f){
 53objj_msgSend(_f,"setSelected:forSegment:",YES,_11);
 54}
 55}),new objj_method(sel_getUid("selectedSegment"),function(_12,_13){
 56with(_12){
 57return _selectedSegment;
 58}
 59}),new objj_method(sel_getUid("selectSegmentWithTag:"),function(_14,_15,_16){
 60with(_14){
 61var _17=0;
 62for(;_17<_segments.length;++_17){
 63if(_segments[_17].tag==_16){
 64objj_msgSend(_14,"setSelectedSegment:",_17);
 65return YES;
 66}
 67}
 68return NO;
 69}
 70}),new objj_method(sel_getUid("isTracking"),function(_18,_19){
 71with(_18){
 72}
 73}),new objj_method(sel_getUid("setTrackingMode:"),function(_1a,_1b,_1c){
 74with(_1a){
 75if(_trackingMode==_1c){
 76return;
 77}
 78_trackingMode=_1c;
 79if(_trackingMode==CPSegmentSwitchTrackingSelectOne){
 80var _1d=0,_1e=NO;
 81for(;_1d<_segments.length;++_1d){
 82if(_segments[_1d].selected){
 83if(_1e){
 84objj_msgSend(_1a,"setSelected:forSegment:",NO,_1d);
 85}else{
 86_1e=YES;
 87}
 88}
 89}
 90}else{
 91if(_trackingMode==CPSegmentSwitchTrackingMomentary){
 92var _1d=0;
 93for(;_1d<_segments.length;++_1d){
 94if(_segments[_1d].selected){
 95objj_msgSend(_1a,"setSelected:forSegment:",NO,_1d);
 96}
 97}
 98}
 99}
100}
101}),new objj_method(sel_getUid("trackingMode"),function(_1f,_20){
102with(_1f){
103return _trackingMode;
104}
105}),new objj_method(sel_getUid("setWidth:forSegment:"),function(_21,_22,_23,_24){
106with(_21){
107_segments[_24].width=_23;
108objj_msgSend(_21,"tileWithChangedSegment:",_24);
109}
110}),new objj_method(sel_getUid("widthForSegment:"),function(_25,_26,_27){
111with(_25){
112return _segments[_27].width;
113}
114}),new objj_method(sel_getUid("setImage:forSegment:"),function(_28,_29,_2a,_2b){
115with(_28){
116var _2c=_segments[_2b];
117_2c.image=_2a;
118objj_msgSend(_28,"tileWithChangedSegment:",_2b);
119}
120}),new objj_method(sel_getUid("imageForSegment:"),function(_2d,_2e,_2f){
121with(_2d){
122return _segments[_2f].image;
123}
124}),new objj_method(sel_getUid("setLabel:forSegment:"),function(_30,_31,_32,_33){
125with(_30){
126var _34=_segments[_33];
127_segments[_33].label=_32;
128objj_msgSend(_30,"tileWithChangedSegment:",_33);
129}
130}),new objj_method(sel_getUid("labelForSegment:"),function(_35,_36,_37){
131with(_35){
132return _segments[_37].label;
133}
134}),new objj_method(sel_getUid("setMenu:forSegment:"),function(_38,_39,_3a,_3b){
135with(_38){
136_segments[_3b].menu=_3a;
137}
138}),new objj_method(sel_getUid("menuForSegment:"),function(_3c,_3d,_3e){
139with(_3c){
140return _segments[_3e].menu;
141}
142}),new objj_method(sel_getUid("setSelected:forSegment:"),function(_3f,_40,_41,_42){
143with(_3f){
144var _43=_segments[_42];
145if(_43.selected==_41){
146return;
147}
148_43.selected=_41;
149_themeStates[_42]=_41?CPThemeStateSelected:CPThemeStateNormal;
150if(_41){
151var _44=_selectedSegment;
152_selectedSegment=_42;
153if(_trackingMode==CPSegmentSwitchTrackingSelectOne&&_44!=_42&&_44!=-1){
154_segments[_44].selected=NO;
155_themeStates[_44]=CPThemeStateNormal;
156objj_msgSend(_3f,"drawSegmentBezel:highlight:",_44,NO);
157}
158}
159if(_trackingMode!=CPSegmentSwitchTrackingMomentary){
160objj_msgSend(_3f,"drawSegmentBezel:highlight:",_42,NO);
161}
162objj_msgSend(_3f,"setNeedsLayout");
163objj_msgSend(_3f,"setNeedsDisplay:",YES);
164}
165}),new objj_method(sel_getUid("isSelectedForSegment:"),function(_45,_46,_47){
166with(_45){
167return _segments[_47].selected;
168}
169}),new objj_method(sel_getUid("setEnabled:forSegment:"),function(_48,_49,_4a,_4b){
170with(_48){
171_segments[_4b].enabled=_4a;
172objj_msgSend(_48,"setNeedsLayout");
173objj_msgSend(_48,"setNeedsDisplay:",YES);
174}
175}),new objj_method(sel_getUid("isEnabledForSegment:"),function(_4c,_4d,_4e){
176with(_4c){
177return _segments[_4e].enabled;
178}
179}),new objj_method(sel_getUid("setTag:forSegment:"),function(_4f,_50,_51,_52){
180with(_4f){
181_segments[_52].tag=_51;
182}
183}),new objj_method(sel_getUid("tagForSegment:"),function(_53,_54,_55){
184with(_53){
185return _segments[_55].tag;
186}
187}),new objj_method(sel_getUid("drawSegmentBezel:highlight:"),function(_56,_57,_58,_59){
188with(_56){
189if(_59){
190_themeStates[_58]|=CPThemeStateHighlighted;
191}else{
192_themeStates[_58]&=~CPThemeStateHighlighted;
193}
194objj_msgSend(_56,"setNeedsLayout");
195objj_msgSend(_56,"setNeedsDisplay:",YES);
196}
197}),new objj_method(sel_getUid("_leftOffsetForSegment:"),function(_5a,_5b,_5c){
198with(_5a){
199var _5d=objj_msgSend(_5a,"currentValueForThemeAttribute:","bezel-inset");
200if(_5c==0){
201return _5d.left;
202}
203var _5e=objj_msgSend(_5a,"currentValueForThemeAttribute:","divider-thickness");
204return objj_msgSend(_5a,"_leftOffsetForSegment:",_5c-1)+objj_msgSend(_5a,"widthForSegment:",_5c-1)+_5e;
205}
206}),new objj_method(sel_getUid("rectForEphemeralSubviewNamed:"),function(_5f,_60,_61){
207with(_5f){
208var _62=objj_msgSend(_5f,"currentValueForThemeAttribute:","default-height"),_63=objj_msgSend(_5f,"currentValueForThemeAttribute:","content-inset"),_64=objj_msgSend(_5f,"currentValueForThemeAttribute:","bezel-inset"),_65=objj_msgSend(_5f,"bounds");
209if(_61==="left-segment-bezel"){
210return CGRectMake(_64.left,_64.top,_63.left,_62);
211}else{
212if(_61==="right-segment-bezel"){
213return CGRectMake(CGRectGetMaxX(_65)-_63.right-_64.right,_64.top,_63.right,_62);
214}else{
215if(_61.substring(0,"segment-bezel".length)=="segment-bezel"){
216var _66=parseInt(_61.substring("segment-bezel-".length),10),_67=CGRectCreateCopy(_segments[_66].frame);
217if(_66==0){
218_67.origin.x+=_63.left;
219_67.size.width-=_63.left;
220}
221if(_66==_segments.length-1){
222_67.size.width-=_63.right;
223}
224return _67;
225}else{
226if(_61.substring(0,"divider-bezel".length)=="divider-bezel"){
227var _66=parseInt(_61.substring("divider-bezel-".length),10),_68=objj_msgSend(_5f,"widthForSegment:",_66),_69=objj_msgSend(_5f,"_leftOffsetForSegment:",_66),_6a=objj_msgSend(_5f,"currentValueForThemeAttribute:","divider-thickness");
228return CGRectMake(_69+_68,_64.top,_6a,_62);
229}else{
230if(_61.substring(0,"segment-content".length)=="segment-content"){
231var _66=parseInt(_61.substring("segment-content-".length),10);
232return objj_msgSend(_5f,"contentFrameForSegment:",_66);
233}
234}
235}
236}
237}
238return objj_msgSendSuper({receiver:_5f,super_class:objj_getClass("CPControl")},"rectForEphemeralSubviewNamed:",_61);
239}
240}),new objj_method(sel_getUid("createEphemeralSubviewNamed:"),function(_6b,_6c,_6d){
241with(_6b){
242if(_6d.substring(0,"segment-content".length)=="segment-content"){
243return objj_msgSend(objj_msgSend(_CPImageAndTextView,"alloc"),"initWithFrame:",{origin:{x:0,y:0},size:{width:0,height:0}});
244}
245return objj_msgSend(objj_msgSend(CPView,"alloc"),"initWithFrame:",{origin:{x:0,y:0},size:{width:0,height:0}});
246}
247}),new objj_method(sel_getUid("layoutSubviews"),function(_6e,_6f){
248with(_6e){
249var _70=objj_msgSend(_6e,"valueForThemeAttribute:inState:","left-segment-bezel-color",_themeStates[0]);
250var _71=objj_msgSend(_6e,"layoutEphemeralSubviewNamed:positioned:relativeToEphemeralSubviewNamed:","left-segment-bezel",CPWindowBelow,nil);
251objj_msgSend(_71,"setBackgroundColor:",_70);
252var _72=objj_msgSend(_6e,"valueForThemeAttribute:inState:","right-segment-bezel-color",_themeStates[_themeStates.length-1]);
253var _73=objj_msgSend(_6e,"layoutEphemeralSubviewNamed:positioned:relativeToEphemeralSubviewNamed:","right-segment-bezel",CPWindowBelow,nil);
254objj_msgSend(_73,"setBackgroundColor:",_72);
255for(var i=0,_75=_themeStates.length;i<_75;i++){
256var _76=_themeStates[i];
257_76|=_themeState&CPThemeStateDisabled;
258var _77=objj_msgSend(_6e,"valueForThemeAttribute:inState:","center-segment-bezel-color",_76);
259var _78=objj_msgSend(_6e,"layoutEphemeralSubviewNamed:positioned:relativeToEphemeralSubviewNamed:","segment-bezel-"+i,CPWindowBelow,nil);
260objj_msgSend(_78,"setBackgroundColor:",_77);
261var _79=_segments[i];
262var _7a=objj_msgSend(_6e,"layoutEphemeralSubviewNamed:positioned:relativeToEphemeralSubviewNamed:","segment-content-"+i,CPWindowAbove,"segment-bezel-"+i);
263objj_msgSend(_7a,"setText:",_79.label);
264objj_msgSend(_7a,"setImage:",_79.image);
265objj_msgSend(_7a,"setFont:",objj_msgSend(_6e,"valueForThemeAttribute:inState:","font",_76));
266objj_msgSend(_7a,"setTextColor:",objj_msgSend(_6e,"valueForThemeAttribute:inState:","text-color",_76));
267objj_msgSend(_7a,"setAlignment:",objj_msgSend(_6e,"valueForThemeAttribute:inState:","alignment",_76));
268objj_msgSend(_7a,"setVerticalAlignment:",objj_msgSend(_6e,"valueForThemeAttribute:inState:","vertical-alignment",_76));
269objj_msgSend(_7a,"setLineBreakMode:",objj_msgSend(_6e,"valueForThemeAttribute:inState:","line-break-mode",_76));
270objj_msgSend(_7a,"setTextShadowColor:",objj_msgSend(_6e,"valueForThemeAttribute:inState:","text-shadow-color",_76));
271objj_msgSend(_7a,"setTextShadowOffset:",objj_msgSend(_6e,"valueForThemeAttribute:inState:","text-shadow-offset",_76));
272objj_msgSend(_7a,"setImageScaling:",objj_msgSend(_6e,"valueForThemeAttribute:inState:","image-scaling",_76));
273if(_79.image&&_79.label){
274objj_msgSend(_7a,"setImagePosition:",objj_msgSend(_6e,"valueForThemeAttribute:inState:","image-position",_76));
275}else{
276if(_79.image){
277objj_msgSend(_7a,"setImagePosition:",CPImageOnly);
278}
279}
280if(i==_75-1){
281continue;
282}
283var _7b=_themeStates[i]|_themeStates[i+1];
284_7b=(_7b&CPThemeStateSelected&~CPThemeStateHighlighted)?CPThemeStateSelected:CPThemeStateNormal;
285_7b|=_themeState&CPThemeStateDisabled;
286var _7c=objj_msgSend(_6e,"valueForThemeAttribute:inState:","divider-bezel-color",_7b);
287var _7d=objj_msgSend(_6e,"layoutEphemeralSubviewNamed:positioned:relativeToEphemeralSubviewNamed:","divider-bezel-"+i,CPWindowBelow,nil);
288objj_msgSend(_7d,"setBackgroundColor:",_7c);
289}
290}
291}),new objj_method(sel_getUid("drawSegment:highlight:"),function(_7e,_7f,_80,_81){
292with(_7e){
293}
294}),new objj_method(sel_getUid("tileWithChangedSegment:"),function(_82,_83,_84){
295with(_82){
296if(_84>=_segments.length){
297return;
298}
299var _85=_segments[_84],_86=_85.width,_87=_themeStates[_84]|(_themeState&CPThemeStateDisabled),_88=objj_msgSend(_82,"valueForThemeAttribute:inState:","content-inset",_87),_89=objj_msgSend(_82,"valueForThemeAttribute:inState:","font",_87);
300if(!_86){
301if(_85.image&&_85.label){
302_86=objj_msgSend(_85.label,"sizeWithFont:",_89).width+objj_msgSend(_85.image,"size").width+_88.left+_88.right;
303}else{
304if(_85.image){
305_86=objj_msgSend(_85.image,"size").width+_88.left+_88.right;
306}else{
307if(_85.label){
308_86=objj_msgSend(_85.label,"sizeWithFont:",_89).width+_88.left+_88.right;
309}else{
310_86=0;
311}
312}
313}
314}
315var _8a=_86-CGRectGetWidth(_85.frame);
316if(!_8a){
317return;
318}
319var _8b=objj_msgSend(_82,"frame");
320objj_msgSend(_82,"setFrameSize:",CGSizeMake(CGRectGetWidth(_8b)+_8a,CGRectGetHeight(_8b)));
321_85.width=_86;
322_85.frame=objj_msgSend(_82,"frameForSegment:",_84);
323var _8c=_84+1;
324for(;_8c<_segments.length;++_8c){
325_segments[_8c].frame.origin.x+=_8a;
326objj_msgSend(_82,"drawSegmentBezel:highlight:",_8c,NO);
327objj_msgSend(_82,"drawSegment:highlight:",_8c,NO);
328}
329objj_msgSend(_82,"drawSegmentBezel:highlight:",_84,NO);
330objj_msgSend(_82,"drawSegment:highlight:",_84,NO);
331objj_msgSend(_82,"setNeedsLayout");
332objj_msgSend(_82,"setNeedsDisplay:",YES);
333}
334}),new objj_method(sel_getUid("frameForSegment:"),function(_8d,_8e,_8f){
335with(_8d){
336return objj_msgSend(_8d,"bezelFrameForSegment:",_8f);
337}
338}),new objj_method(sel_getUid("bezelFrameForSegment:"),function(_90,_91,_92){
339with(_90){
340var _93=objj_msgSend(_90,"currentValueForThemeAttribute:","default-height"),_94=objj_msgSend(_90,"currentValueForThemeAttribute:","bezel-inset"),_95=objj_msgSend(_90,"widthForSegment:",_92),_96=objj_msgSend(_90,"_leftOffsetForSegment:",_92);
341return CGRectMake(_96,_94.top,_95,_93);
342}
343}),new objj_method(sel_getUid("contentFrameForSegment:"),function(_97,_98,_99){
344with(_97){
345var _9a=objj_msgSend(_97,"currentValueForThemeAttribute:","default-height"),_9b=objj_msgSend(_97,"currentValueForThemeAttribute:","content-inset"),_9c=objj_msgSend(_97,"widthForSegment:",_99),_9d=objj_msgSend(_97,"_leftOffsetForSegment:",_99);
346return CGRectMake(_9d+_9b.left,_9b.top,_9c-_9b.left-_9b.right,_9a-_9b.top-_9b.bottom);
347}
348}),new objj_method(sel_getUid("testSegment:"),function(_9e,_9f,_a0){
349with(_9e){
350var _a1=objj_msgSend(_9e,"convertPoint:fromView:",_a0,nil),_a2=_segments.length;
351while(_a2--){
352if(CGRectContainsPoint(_segments[_a2].frame,_a0)){
353return _a2;
354}
355}
356return -1;
357}
358}),new objj_method(sel_getUid("mouseDown:"),function(_a3,_a4,_a5){
359with(_a3){
360if(!objj_msgSend(_a3,"isEnabled")){
361return;
362}
363objj_msgSend(_a3,"trackSegment:",_a5);
364}
365}),new objj_method(sel_getUid("mouseUp:"),function(_a6,_a7,_a8){
366with(_a6){
367}
368}),new objj_method(sel_getUid("trackSegment:"),function(_a9,_aa,_ab){
369with(_a9){
370var _ac=objj_msgSend(_ab,"type"),_ad=objj_msgSend(_a9,"convertPoint:fromView:",objj_msgSend(_ab,"locationInWindow"),nil);
371if(_ac==CPLeftMouseUp){
372if(_trackingSegment==-1){
373return;
374}
375if(CGRectContainsPoint(_segments[_trackingSegment].frame,_ad)){
376if(_trackingMode==CPSegmentSwitchTrackingSelectAny){
377objj_msgSend(_a9,"setSelected:forSegment:",!objj_msgSend(_a9,"isSelectedForSegment:",_trackingSegment),_trackingSegment);
378_selectedSegment=_trackingSegment;
379}else{
380objj_msgSend(_a9,"setSelected:forSegment:",YES,_trackingSegment);
381}
382objj_msgSend(_a9,"sendAction:to:",objj_msgSend(_a9,"action"),objj_msgSend(_a9,"target"));
383if(_trackingMode==CPSegmentSwitchTrackingMomentary){
384objj_msgSend(_a9,"setSelected:forSegment:",NO,_trackingSegment);
385_selectedSegment=-1;
386}
387}
388objj_msgSend(_a9,"drawSegmentBezel:highlight:",_trackingSegment,NO);
389_trackingSegment=-1;
390return;
391}
392if(_ac==CPLeftMouseDown){
393_trackingHighlighted=YES;
394_trackingSegment=objj_msgSend(_a9,"testSegment:",_ad);
395objj_msgSend(_a9,"drawSegmentBezel:highlight:",_trackingSegment,YES);
396}else{
397if(_ac==CPLeftMouseDragged){
398if(_trackingSegment==-1){
399return;
400}
401var _ae=CGRectContainsPoint(_segments[_trackingSegment].frame,_ad);
402if(_ae!=_trackingHighlighted){
403_trackingHighlighted=_ae;
404objj_msgSend(_a9,"drawSegmentBezel:highlight:",_trackingSegment,_trackingHighlighted);
405}
406}
407}
408objj_msgSend(CPApp,"setTarget:selector:forNextEventMatchingMask:untilDate:inMode:dequeue:",_a9,sel_getUid("trackSegment:"),CPLeftMouseDraggedMask|CPLeftMouseUpMask,nil,nil,YES);
409}
410}),new objj_method(sel_getUid("setFont:"),function(_af,_b0,_b1){
411with(_af){
412objj_msgSendSuper({receiver:_af,super_class:objj_getClass("CPControl")},"setFont:",_b1);
413objj_msgSend(_af,"tileWithChangedSegment:",0);
414}
415})]);
416class_addMethods(_2,[new objj_method(sel_getUid("themeClass"),function(_b2,_b3){
417with(_b2){
418return "segmented-control";
419}
420}),new objj_method(sel_getUid("themeAttributes"),function(_b4,_b5){
421with(_b4){
422return objj_msgSend(CPDictionary,"dictionaryWithObjects:forKeys:",[CPCenterTextAlignment,CPCenterVerticalTextAlignment,CPImageLeft,CPScaleNone,{top:(0),right:(0),bottom:(0),left:(0)},{top:(0),right:(0),bottom:(0),left:(0)},nil,nil,nil,nil,1,24],["alignment","vertical-alignment","image-position","image-scaling","bezel-inset","content-inset","left-segment-bezel-color","right-segment-bezel-color","center-segment-bezel-color","divider-bezel-color","divider-thickness","default-height"]);
423}
424})]);
425var _b6="CPSegmentedControlSegmentsKey",_b7="CPSegmentedControlSelectedKey",_b8="CPSegmentedControlSegmentStyleKey",_b9="CPSegmentedControlTrackingModeKey";
426var _1=objj_getClass("CPSegmentedControl");
427if(!_1){
428objj_exception_throw(new objj_exception(OBJJClassNotFoundException,"*** Could not find definition for class \"CPSegmentedControl\""));
429}
430var _2=_1.isa;
431class_addMethods(_1,[new objj_method(sel_getUid("initWithCoder:"),function(_ba,_bb,_bc){
432with(_ba){
433_ba=objj_msgSendSuper({receiver:_ba,super_class:objj_getClass("CPControl")},"initWithCoder:",_bc);
434if(_ba){
435var _bd=objj_msgSend(_ba,"frame"),_be=_bd.size.width;
436_bd.size.width=0;
437objj_msgSend(_ba,"setFrame:",_bd);
438_segments=objj_msgSend(_bc,"decodeObjectForKey:",_b6);
439_segmentStyle=objj_msgSend(_bc,"decodeIntForKey:",_b8);
440_themeStates=[];
441if(objj_msgSend(_bc,"containsValueForKey:",_b7)){
442_selectedSegment=objj_msgSend(_bc,"decodeIntForKey:",_b7);
443}else{
444_selectedSegment=-1;
445}
446if(objj_msgSend(_bc,"containsValueForKey:",_b9)){
447_trackingMode=objj_msgSend(_bc,"decodeIntForKey:",_b9);
448}else{
449_trackingMode=CPSegmentSwitchTrackingSelectOne;
450}
451for(var i=0;i<_segments.length;i++){
452_themeStates[i]=_segments[i].selected?CPThemeStateSelected:CPThemeStateNormal;
453objj_msgSend(_ba,"tileWithChangedSegment:",i);
454}
455var _c0=MAX(_be-objj_msgSend(_ba,"frame").size.width,0),_c1=FLOOR(_c0/_segments.length);
456for(var i=0;i<_segments.length;i++){
457objj_msgSend(_ba,"setWidth:forSegment:",_segments[i].width+_c1,i);
458}
459objj_msgSend(_ba,"tileWithChangedSegment:",0);
460}
461return _ba;
462}
463}),new objj_method(sel_getUid("encodeWithCoder:"),function(_c2,_c3,_c4){
464with(_c2){
465objj_msgSendSuper({receiver:_c2,super_class:objj_getClass("CPControl")},"encodeWithCoder:",_c4);
466objj_msgSend(_c4,"encodeObject:forKey:",_segments,_b6);
467objj_msgSend(_c4,"encodeInt:forKey:",_selectedSegment,_b7);
468objj_msgSend(_c4,"encodeInt:forKey:",_segmentStyle,_b8);
469objj_msgSend(_c4,"encodeInt:forKey:",_trackingMode,_b9);
470}
471})]);
472var _1=objj_allocateClassPair(CPObject,"_CPSegmentItem"),_2=_1.isa;
473class_addIvars(_1,[new objj_ivar("image"),new objj_ivar("label"),new objj_ivar("menu"),new objj_ivar("selected"),new objj_ivar("enabled"),new objj_ivar("tag"),new objj_ivar("width"),new objj_ivar("frame")]);
474objj_registerClassPair(_1);
475objj_addClassForBundle(_1,objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
476class_addMethods(_1,[new objj_method(sel_getUid("init"),function(_c5,_c6){
477with(_c5){
478if(_c5=objj_msgSendSuper({receiver:_c5,super_class:objj_getClass("CPObject")},"init")){
479image=nil;
480label="";
481menu=nil;
482selected=NO;
483enabled=NO;
484tag=0;
485width=0;
486frame=CGRectMakeZero();
487}
488return _c5;
489}
490})]);
491var _c7="CPSegmentItemImageKey",_c8="CPSegmentItemLabelKey",_c9="CPSegmentItemMenuKey",_ca="CPSegmentItemSelectedKey",_cb="CPSegmentItemEnabledKey",_cc="CPSegmentItemTagKey",_cd="CPSegmentItemWidthKey";
492var _1=objj_getClass("_CPSegmentItem");
493if(!_1){
494objj_exception_throw(new objj_exception(OBJJClassNotFoundException,"*** Could not find definition for class \"_CPSegmentItem\""));
495}
496var _2=_1.isa;
497class_addMethods(_1,[new objj_method(sel_getUid("initWithCoder:"),function(_ce,_cf,_d0){
498with(_ce){
499_ce=objj_msgSendSuper({receiver:_ce,super_class:objj_getClass("CPObject")},"init");
500if(_ce){
501image=objj_msgSend(_d0,"decodeObjectForKey:",_c7);
502label=objj_msgSend(_d0,"decodeObjectForKey:",_c8);
503menu=objj_msgSend(_d0,"decodeObjectForKey:",_c9);
504selected=objj_msgSend(_d0,"decodeBoolForKey:",_ca);
505enabled=objj_msgSend(_d0,"decodeBoolForKey:",_cb);
506tag=objj_msgSend(_d0,"decodeIntForKey:",_cc);
507width=objj_msgSend(_d0,"decodeFloatForKey:",_cd);
508frame=CGRectMakeZero();
509}
510return _ce;
511}
512}),new objj_method(sel_getUid("encodeWithCoder:"),function(_d1,_d2,_d3){
513with(_d1){
514objj_msgSend(_d3,"encodeObject:forKey:",image,_c7);
515objj_msgSend(_d3,"encodeObject:forKey:",label,_c8);
516objj_msgSend(_d3,"encodeObject:forKey:",menu,_c9);
517objj_msgSend(_d3,"encodeBool:forKey:",selected,_ca);
518objj_msgSend(_d3,"encodeBool:forKey:",enabled,_cb);
519objj_msgSend(_d3,"encodeInt:forKey:",tag,_cc);
520objj_msgSend(_d3,"encodeFloat:forKey:",width,_cd);
521}
522})]);