PageRenderTime 23ms CodeModel.GetById 16ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://github.com/jfahrenkrug/MapKit-HelloWorld
Unknown | 77 lines | 76 code | 1 blank | 0 comment | 0 complexity | 64dc8fa32f5f0bb5a70b3823791a562b MD5 | raw file
 1i;8;CPView.jc;3751;
 2{var the_class = objj_allocateClassPair(CPView, "_CPCibCustomView"),
 3meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_className")]);
 4objj_registerClassPair(the_class);
 5objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
 6class_addMethods(the_class, [new objj_method(sel_getUid("customClassName"), function $_CPCibCustomView__customClassName(self, _cmd)
 7{ with(self)
 8{
 9    return _className;
10}
11})]);
12}
13var _CPCibCustomViewClassNameKey = "_CPCibCustomViewClassNameKey";
14{
15var the_class = objj_getClass("_CPCibCustomView")
16if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"_CPCibCustomView\""));
17var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_getUid("initWithCoder:"), function $_CPCibCustomView__initWithCoder_(self, _cmd, aCoder)
18{ with(self)
19{
20    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "initWithCoder:", aCoder);
21    if (self)
22        _className = objj_msgSend(aCoder, "decodeObjectForKey:", _CPCibCustomViewClassNameKey);
23    return self;
24}
25}), new objj_method(sel_getUid("encodeWithCoder:"), function $_CPCibCustomView__encodeWithCoder_(self, _cmd, aCoder)
26{ with(self)
27{
28    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "encodeWithCoder:", aCoder);
29    objj_msgSend(aCoder, "encodeObject:forKey:", _className, _CPCibCustomViewClassNameKey);
30}
31}), new objj_method(sel_getUid("drawRect:"), function $_CPCibCustomView__drawRect_(self, _cmd, aRect)
32{ with(self)
33{
34    var bounds = objj_msgSend(self, "bounds"),
35        context = objj_msgSend(objj_msgSend(CPGraphicsContext, "currentContext"), "graphicsPort");
36    CGContextSetLineWidth(context, 1.0);
37    CGContextSetStrokeColor(context, objj_msgSend(CPColor, "colorWithCalibratedRed:green:blue:alpha:", 169.0 / 255.0, 173.0 / 255.0, 178.0 / 255.0, 1.0));
38    CGContextStrokeRect(context, CGRectInset(CGRectIntegral(bounds), 0.5, 0.5));
39    CGContextSetFillColor(context, objj_msgSend(CPColor, "colorWithCalibratedRed:green:blue:alpha:", 224.0 / 255.0, 236.0 / 255.0, 250.0 / 255.0, 1.0));
40    CGContextFillRect(context, CGRectInset(bounds, 2.0, 2.0));
41}
42}), new objj_method(sel_getUid("_cibInstantiate"), function $_CPCibCustomView___cibInstantiate(self, _cmd)
43{ with(self)
44{
45    var theClass = CPClassFromString(_className);
46    if (!theClass)
47    {
48        CPLog("Unknown class \"" + _className + "\" in cib file, using CPView instead.");
49        theClass = objj_msgSend(CPView, "class");
50    }
51    if (theClass === objj_msgSend(self, "class"))
52    {
53        _className = "CPView";
54        return self;
55    }
56    var view = objj_msgSend(objj_msgSend(theClass, "alloc"), "initWithFrame:", objj_msgSend(self, "frame"));
57    if (view)
58    {
59        objj_msgSend(view, "setBounds:", objj_msgSend(self, "bounds"));
60        var subviews = objj_msgSend(objj_msgSend(self, "subviews"), "copy"),
61            index = 0,
62            count = subviews.length;
63        for (; index < count; ++index)
64            objj_msgSend(view, "addSubview:", subviews[index]);
65        objj_msgSend(view, "setAutoresizingMask:", objj_msgSend(self, "autoresizingMask"));
66        objj_msgSend(view, "setAutoresizesSubviews:", objj_msgSend(self, "autoresizesSubviews"));
67        objj_msgSend(view, "setHitTests:", objj_msgSend(self, "hitTests"));
68        objj_msgSend(view, "setHidden:", objj_msgSend(self, "isHidden"));
69        objj_msgSend(view, "setAlphaValue:", objj_msgSend(self, "alphaValue"));
70        objj_msgSend(_superview, "replaceSubview:with:", self, view);
71        objj_msgSend(view, "setBackgroundColor:", objj_msgSend(self, "backgroundColor"));
72    }
73    return view;
74}
75})]);
76}
77