PageRenderTime 14ms CodeModel.GetById 9ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Frameworks/Debug/AppKit/browser.platform/CPToolbarItem.j

http://github.com/jfahrenkrug/MapKit-HelloWorld
Unknown | 303 lines | 302 code | 1 blank | 0 comment | 0 complexity | 864f734f528bf603a741440bc5e1b20c MD5 | raw file
  1I;21;Foundation/CPObject.jI;21;Foundation/CPString.jI;16;AppKit/CPImage.jI;15;AppKit/CPView.jc;13108;
  2CPToolbarItemVisibilityPriorityStandard = 0;
  3CPToolbarItemVisibilityPriorityLow = -1000;
  4CPToolbarItemVisibilityPriorityHigh = 1000;
  5CPToolbarItemVisibilityPriorityUser = 2000;
  6CPToolbarSeparatorItemIdentifier = "CPToolbarSeparatorItemIdentifier";
  7CPToolbarSpaceItemIdentifier = "CPToolbarSpaceItemIdentifier";
  8CPToolbarFlexibleSpaceItemIdentifier = "CPToolbarFlexibleSpaceItemIdentifier";
  9CPToolbarShowColorsItemIdentifier = "CPToolbarShowColorsItemIdentifier";
 10CPToolbarShowFontsItemIdentifier = "CPToolbarShowFontsItemIdentifier";
 11CPToolbarCustomizeToolbarItemIdentifier = "CPToolbarCustomizeToolbarItemIdentifier";
 12CPToolbarPrintItemIdentifier = "CPToolbarPrintItemIdentifier";
 13{var the_class = objj_allocateClassPair(CPObject, "CPToolbarItem"),
 14meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_itemIdentifier"), new objj_ivar("_toolbar"), new objj_ivar("_label"), new objj_ivar("_paletteLabel"), new objj_ivar("_toolTip"), new objj_ivar("_tag"), new objj_ivar("_target"), new objj_ivar("_action"), new objj_ivar("_isEnabled"), new objj_ivar("_image"), new objj_ivar("_alternateImage"), new objj_ivar("_view"), new objj_ivar("_minSize"), new objj_ivar("_maxSize"), new objj_ivar("_visibilityPriority")]);
 15objj_registerClassPair(the_class);
 16objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
 17class_addMethods(the_class, [new objj_method(sel_getUid("initWithItemIdentifier:"), function $CPToolbarItem__initWithItemIdentifier_(self, _cmd, anItemIdentifier)
 18{ with(self)
 19{
 20    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
 21    if (self)
 22    {
 23        _itemIdentifier = anItemIdentifier;
 24        _tag = 0;
 25        _isEnabled = YES;
 26        _minSize = CGSizeMakeZero();
 27        _maxSize = CGSizeMakeZero();
 28        _visibilityPriority = CPToolbarItemVisibilityPriorityStandard;
 29    }
 30    return self;
 31}
 32}), new objj_method(sel_getUid("itemIdentifier"), function $CPToolbarItem__itemIdentifier(self, _cmd)
 33{ with(self)
 34{
 35    return _itemIdentifier;
 36}
 37}), new objj_method(sel_getUid("toolbar"), function $CPToolbarItem__toolbar(self, _cmd)
 38{ with(self)
 39{
 40    return _toolbar;
 41}
 42}), new objj_method(sel_getUid("label"), function $CPToolbarItem__label(self, _cmd)
 43{ with(self)
 44{
 45    return _label;
 46}
 47}), new objj_method(sel_getUid("setLabel:"), function $CPToolbarItem__setLabel_(self, _cmd, aLabel)
 48{ with(self)
 49{
 50    _label = aLabel;
 51}
 52}), new objj_method(sel_getUid("paletteLabel"), function $CPToolbarItem__paletteLabel(self, _cmd)
 53{ with(self)
 54{
 55    return _paletteLabel;
 56}
 57}), new objj_method(sel_getUid("setPaletteLabel:"), function $CPToolbarItem__setPaletteLabel_(self, _cmd, aPaletteLabel)
 58{ with(self)
 59{
 60    _paletteLabel = aPaletteLabel;
 61}
 62}), new objj_method(sel_getUid("toolTip"), function $CPToolbarItem__toolTip(self, _cmd)
 63{ with(self)
 64{
 65    if (objj_msgSend(_view, "respondsToSelector:", sel_getUid("toolTip")))
 66        return objj_msgSend(_view, "toolTip");
 67    return _toolTip;
 68}
 69}), new objj_method(sel_getUid("setToolTip:"), function $CPToolbarItem__setToolTip_(self, _cmd, aToolTip)
 70{ with(self)
 71{
 72    if (objj_msgSend(_view, "respondsToSelector:", sel_getUid("setToolTip:")))
 73        objj_msgSend(view, "setToolTip:", aToolTip);
 74    _toolTip = aToolTip;
 75}
 76}), new objj_method(sel_getUid("tag"), function $CPToolbarItem__tag(self, _cmd)
 77{ with(self)
 78{
 79    if (objj_msgSend(_view, "respondsToSelector:", sel_getUid("tag")))
 80        return objj_msgSend(_view, "tag");
 81    return _tag;
 82}
 83}), new objj_method(sel_getUid("setTag:"), function $CPToolbarItem__setTag_(self, _cmd, aTag)
 84{ with(self)
 85{
 86    if (objj_msgSend(_view, "respondsToSelector:", sel_getUid("setTag:")))
 87        objj_msgSend(_view, "setTag:", aTag);
 88    _tag = aTag;
 89}
 90}), new objj_method(sel_getUid("target"), function $CPToolbarItem__target(self, _cmd)
 91{ with(self)
 92{
 93    if (_view)
 94        return objj_msgSend(_view, "respondsToSelector:", sel_getUid("target")) ? objj_msgSend(_view, "target") : nil;
 95    return _target;
 96}
 97}), new objj_method(sel_getUid("setTarget:"), function $CPToolbarItem__setTarget_(self, _cmd, aTarget)
 98{ with(self)
 99{
100    if (!_view)
101        _target = aTarget;
102    else if (objj_msgSend(_view, "respondsToSelector:", sel_getUid("setTarget:")))
103        objj_msgSend(_view, "setTarget:", aTarget);
104}
105}), new objj_method(sel_getUid("action"), function $CPToolbarItem__action(self, _cmd)
106{ with(self)
107{
108    if (_view)
109        return objj_msgSend(_view, "respondsToSelector:", sel_getUid("action")) ? objj_msgSend(_view, "action") : nil;
110    return _action;
111}
112}), new objj_method(sel_getUid("setAction:"), function $CPToolbarItem__setAction_(self, _cmd, anAction)
113{ with(self)
114{
115    if (!_view)
116        _action = anAction;
117    else if (objj_msgSend(_view, "respondsToSelector:", sel_getUid("setAction:")))
118        objj_msgSend(_view, "setAction:", anAction);
119}
120}), new objj_method(sel_getUid("isEnabled"), function $CPToolbarItem__isEnabled(self, _cmd)
121{ with(self)
122{
123    if (objj_msgSend(_view, "respondsToSelector:", sel_getUid("isEnabled")))
124        return objj_msgSend(_view, "isEnabled");
125    return _isEnabled;
126}
127}), new objj_method(sel_getUid("setEnabled:"), function $CPToolbarItem__setEnabled_(self, _cmd, shouldBeEnabled)
128{ with(self)
129{
130    if (objj_msgSend(_view, "respondsToSelector:", sel_getUid("setEnabled:")))
131        objj_msgSend(_view, "setEnabled:", shouldBeEnabled);
132    _isEnabled = shouldBeEnabled;
133}
134}), new objj_method(sel_getUid("image"), function $CPToolbarItem__image(self, _cmd)
135{ with(self)
136{
137    if (objj_msgSend(_view, "respondsToSelector:", sel_getUid("image")))
138        return objj_msgSend(_view, "image");
139    return _image;
140}
141}), new objj_method(sel_getUid("setImage:"), function $CPToolbarItem__setImage_(self, _cmd, anImage)
142{ with(self)
143{
144    if (objj_msgSend(_view, "respondsToSelector:", sel_getUid("setImage:")))
145        objj_msgSend(_view, "setImage:", anImage);
146    _image = anImage;
147    if (!_image)
148        return;
149    if (_minSize.width == 0 && _minSize.height == 0 &&
150        _maxSize.width == 0 && _maxSize.height == 0)
151    {
152        var imageSize = objj_msgSend(_image, "size");
153        if (imageSize.width > 0 || imageSize.height > 0)
154        {
155            objj_msgSend(self, "setMinSize:", imageSize);
156            objj_msgSend(self, "setMaxSize:", imageSize);
157        }
158    }
159}
160}), new objj_method(sel_getUid("setAlternateImage:"), function $CPToolbarItem__setAlternateImage_(self, _cmd, anImage)
161{ with(self)
162{
163    if (objj_msgSend(_view, "respondsToSelector:", sel_getUid("setAlternateImage:")))
164        objj_msgSend(_view, "setAlternateImage:", anImage);
165    _alternateImage = anImage;
166}
167}), new objj_method(sel_getUid("alternateImage"), function $CPToolbarItem__alternateImage(self, _cmd)
168{ with(self)
169{
170    if (objj_msgSend(_view, "respondsToSelector:", sel_getUid("alternateIamge")))
171        return objj_msgSend(_view, "alternateImage");
172    return _alternateImage;
173}
174}), new objj_method(sel_getUid("view"), function $CPToolbarItem__view(self, _cmd)
175{ with(self)
176{
177    return _view;
178}
179}), new objj_method(sel_getUid("setView:"), function $CPToolbarItem__setView_(self, _cmd, aView)
180{ with(self)
181{
182    if (_view == aView)
183        return;
184    _view = aView;
185    if (_view)
186    {
187        if (_tag !== 0 && objj_msgSend(_view, "respondsToSelector:", sel_getUid("setTag:")))
188            objj_msgSend(_view, "setTag:", _tag);
189        _target = nil;
190        _action = nil;
191    }
192}
193}), new objj_method(sel_getUid("minSize"), function $CPToolbarItem__minSize(self, _cmd)
194{ with(self)
195{
196    return _minSize;
197}
198}), new objj_method(sel_getUid("setMinSize:"), function $CPToolbarItem__setMinSize_(self, _cmd, aMinSize)
199{ with(self)
200{
201    _minSize = CGSizeMakeCopy(aMinSize);
202    _maxSize = CGSizeMake(MAX(_minSize.width, _maxSize.width), MAX(_minSize.height, _maxSize.height));
203}
204}), new objj_method(sel_getUid("maxSize"), function $CPToolbarItem__maxSize(self, _cmd)
205{ with(self)
206{
207    return _maxSize;
208}
209}), new objj_method(sel_getUid("setMaxSize:"), function $CPToolbarItem__setMaxSize_(self, _cmd, aMaxSize)
210{ with(self)
211{
212    _maxSize = CGSizeMakeCopy(aMaxSize);
213    _minSize = CGSizeMake(MIN(_minSize.width, _maxSize.width), MIN(_minSize.height, _maxSize.height));
214}
215}), new objj_method(sel_getUid("visibilityPriority"), function $CPToolbarItem__visibilityPriority(self, _cmd)
216{ with(self)
217{
218    return _visibilityPriority;
219}
220}), new objj_method(sel_getUid("setVisibilityPriority:"), function $CPToolbarItem__setVisibilityPriority_(self, _cmd, aVisibilityPriority)
221{ with(self)
222{
223    _visibilityPriority = aVisibilityPriority;
224}
225})]);
226}
227{
228var the_class = objj_getClass("CPToolbarItem")
229if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPToolbarItem\""));
230var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("copy"), function $CPToolbarItem__copy(self, _cmd)
231{ with(self)
232{
233    var copy = objj_msgSend(objj_msgSend(objj_msgSend(self, "class"), "alloc"), "initWithItemIdentifier:", _itemIdentifier);
234    if (_view)
235        objj_msgSend(copy, "setView:", objj_msgSend(CPKeyedUnarchiver, "unarchiveObjectWithData:", objj_msgSend(CPKeyedArchiver, "archivedDataWithRootObject:", _view)));
236    objj_msgSend(copy, "setLabel:", _label);
237    objj_msgSend(copy, "setPaletteLabel:", _paletteLabel);
238    objj_msgSend(copy, "setToolTip:", objj_msgSend(self, "toolTip"));
239    objj_msgSend(copy, "setTag:", objj_msgSend(self, "tag"));
240    objj_msgSend(copy, "setTarget:", objj_msgSend(self, "target"));
241    objj_msgSend(copy, "setAction:", objj_msgSend(self, "action"));
242    objj_msgSend(copy, "setEnabled:", objj_msgSend(self, "isEnabled"));
243    objj_msgSend(copy, "setImage:", _image);
244    objj_msgSend(copy, "setAlternateImage:", _alternateImage);
245    objj_msgSend(copy, "setMinSize:", _minSize);
246    objj_msgSend(copy, "setMaxSize:", _maxSize);
247    objj_msgSend(copy, "setVisibilityPriority:", _visibilityPriority);
248    return copy;
249}
250})]);
251}
252var _CPToolbarSeparatorItemView = nil,
253    _CPToolbarSpaceItemView = nil;
254{
255var the_class = objj_getClass("CPToolbarItem")
256if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPToolbarItem\""));
257var meta_class = the_class.isa;class_addMethods(meta_class, [new objj_method(sel_getUid("_separatorItemView"), function $CPToolbarItem___separatorItemView(self, _cmd)
258{ with(self)
259{
260    if (!_CPToolbarSeparatorItemView)
261    {
262        _CPToolbarSeparatorItemView = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", CGRectMake(0.0, 0.0, 2.0, 32.0));
263        sizes = {};
264        sizes["CPToolbarItemSeparator"] = [CGSizeMake(2.0, 26.0), CGSizeMake(2.0, 1.0), CGSizeMake(2.0, 26.0)];
265        objj_msgSend(_CPToolbarSeparatorItemView, "setBackgroundColor:", _CPControlThreePartImagePattern(YES, sizes, "CPToolbarItem", "Separator"));
266    }
267    return _CPToolbarSeparatorItemView;
268}
269}), new objj_method(sel_getUid("_spaceItemView"), function $CPToolbarItem___spaceItemView(self, _cmd)
270{ with(self)
271{
272    if (!_CPToolbarSpaceItemView)
273        _CPToolbarSpaceItemView = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", CGRectMakeZero());
274    return _CPToolbarSpaceItemView;
275}
276}), new objj_method(sel_getUid("_standardItemWithItemIdentifier:"), function $CPToolbarItem___standardItemWithItemIdentifier_(self, _cmd, anItemIdentifier)
277{ with(self)
278{
279    var item = objj_msgSend(objj_msgSend(CPToolbarItem, "alloc"), "initWithItemIdentifier:", anItemIdentifier);
280    switch (anItemIdentifier)
281    {
282        case CPToolbarSeparatorItemIdentifier: objj_msgSend(item, "setView:", objj_msgSend(self, "_separatorItemView"));
283                                                        objj_msgSend(item, "setMinSize:", CGSizeMake(2.0, 0.0));
284                                                        objj_msgSend(item, "setMaxSize:", CGSizeMake(2.0, 100000.0));
285                                                        return item;
286        case CPToolbarSpaceItemIdentifier: objj_msgSend(item, "setView:", objj_msgSend(self, "_spaceItemView"));
287                                                        objj_msgSend(item, "setMinSize:", CGSizeMake(32.0, 32.0));
288                                                        objj_msgSend(item, "setMaxSize:", CGSizeMake(32.0, 32.0));
289                                                        return item;
290        case CPToolbarFlexibleSpaceItemIdentifier: objj_msgSend(item, "setView:", objj_msgSend(self, "_spaceItemView"));
291                                                        objj_msgSend(item, "setMinSize:", CGSizeMake(32.0, 32.0));
292                                                        objj_msgSend(item, "setMaxSize:", CGSizeMake(10000.0, 32.0));
293                                                        return item;
294        case CPToolbarShowColorsItemIdentifier: return nil;
295        case CPToolbarShowFontsItemIdentifier: return nil;
296        case CPToolbarCustomizeToolbarItemIdentifier: return nil;
297        case CPToolbarPrintItemIdentifier: return nil;
298    }
299    return nil;
300}
301})]);
302}
303