PageRenderTime 26ms CodeModel.GetById 17ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/Frameworks/Debug/AppKit/rhino.platform/CPShadowView.j

http://github.com/jfahrenkrug/MapKit-HelloWorld
Unknown | 127 lines | 126 code | 1 blank | 0 comment | 0 complexity | 17f52723a43f1b26c2228a55e43a12af MD5 | raw file
  1I;21;Foundation/CPBundle.ji;12;CGGeometry.ji;9;CPImage.ji;13;CPImageView.ji;8;CPView.jc;7793;
  2CPLightShadow = 0;
  3CPHeavyShadow = 1;
  4var CPShadowViewLightBackgroundColor = nil,
  5    CPShadowViewHeavyBackgroundColor = nil;
  6var LIGHT_LEFT_INSET = 3.0,
  7    LIGHT_RIGHT_INSET = 3.0,
  8    LIGHT_TOP_INSET = 3.0,
  9    LIGHT_BOTTOM_INSET = 5.0,
 10    HEAVY_LEFT_INSET = 7.0,
 11    HEAVY_RIGHT_INSET = 7.0,
 12    HEAVY_TOP_INSET = 5.0,
 13    HEAVY_BOTTOM_INSET = 5.0;
 14{var the_class = objj_allocateClassPair(CPView, "CPShadowView"),
 15meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_weight")]);
 16objj_registerClassPair(the_class);
 17objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
 18class_addMethods(the_class, [new objj_method(sel_getUid("initWithFrame:"), function $CPShadowView__initWithFrame_(self, _cmd, aFrame)
 19{ with(self)
 20{
 21    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "initWithFrame:", aFrame);
 22    if (self)
 23    {
 24        _weight = CPLightShadow;
 25        objj_msgSend(self, "setBackgroundColor:", CPShadowViewLightBackgroundColor);
 26        objj_msgSend(self, "setHitTests:", NO);
 27    }
 28    return self;
 29}
 30}), new objj_method(sel_getUid("setWeight:"), function $CPShadowView__setWeight_(self, _cmd, aWeight)
 31{ with(self)
 32{
 33    if (_weight == aWeight)
 34        return;
 35    _weight = aWeight;
 36    if (_weight == CPLightShadow)
 37        objj_msgSend(self, "setBackgroundColor:", CPShadowViewLightBackgroundColor);
 38    else
 39        objj_msgSend(self, "setBackgroundColor:", CPShadowViewHeavyBackgroundColor);
 40}
 41}), new objj_method(sel_getUid("leftInset"), function $CPShadowView__leftInset(self, _cmd)
 42{ with(self)
 43{
 44    return _weight == CPLightShadow ? LIGHT_LEFT_INSET : HEAVY_LEFT_INSET;
 45}
 46}), new objj_method(sel_getUid("rightInset"), function $CPShadowView__rightInset(self, _cmd)
 47{ with(self)
 48{
 49    return _weight == CPLightShadow ? LIGHT_RIGHT_INSET : HEAVY_RIGHT_INSET;
 50}
 51}), new objj_method(sel_getUid("topInset"), function $CPShadowView__topInset(self, _cmd)
 52{ with(self)
 53{
 54    return _weight == CPLightShadow ? LIGHT_TOP_INSET : HEAVY_TOP_INSET;
 55}
 56}), new objj_method(sel_getUid("bottomInset"), function $CPShadowView__bottomInset(self, _cmd)
 57{ with(self)
 58{
 59    return _weight == CPLightShadow ? LIGHT_BOTTOM_INSET : HEAVY_BOTTOM_INSET;
 60}
 61}), new objj_method(sel_getUid("horizontalInset"), function $CPShadowView__horizontalInset(self, _cmd)
 62{ with(self)
 63{
 64    if (_weight == CPLightShadow)
 65        return LIGHT_LEFT_INSET + LIGHT_RIGHT_INSET;
 66    return HEAVY_LEFT_INSET + HEAVY_RIGHT_INSET;
 67}
 68}), new objj_method(sel_getUid("verticalInset"), function $CPShadowView__verticalInset(self, _cmd)
 69{ with(self)
 70{
 71    if (_weight == CPLightShadow)
 72        return LIGHT_TOP_INSET + LIGHT_BOTTOM_INSET;
 73    return HEAVY_TOP_INSET + HEAVY_BOTTOM_INSET;
 74}
 75}), new objj_method(sel_getUid("frameForContentFrame:"), function $CPShadowView__frameForContentFrame_(self, _cmd, aFrame)
 76{ with(self)
 77{
 78    return objj_msgSend(objj_msgSend(self, "class"), "frameForContentFrame:withWeight:", aFrame, _weight);
 79}
 80}), new objj_method(sel_getUid("setFrameForContentFrame:"), function $CPShadowView__setFrameForContentFrame_(self, _cmd, aFrame)
 81{ with(self)
 82{
 83    objj_msgSend(self, "setFrame:", objj_msgSend(self, "frameForContentFrame:", aFrame));
 84}
 85})]);
 86class_addMethods(meta_class, [new objj_method(sel_getUid("initialize"), function $CPShadowView__initialize(self, _cmd)
 87{ with(self)
 88{
 89    if (self != objj_msgSend(CPShadowView, "class"))
 90        return;
 91    var bundle = objj_msgSend(CPBundle, "bundleForClass:", objj_msgSend(self, "class"));
 92    CPShadowViewLightBackgroundColor = objj_msgSend(CPColor, "colorWithPatternImage:", objj_msgSend(objj_msgSend(CPNinePartImage, "alloc"), "initWithImageSlices:", 
 93        [
 94            objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewLightTopLeft.png"), CGSizeMake(9.0, 9.0)),
 95            objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewLightTop.png"), CGSizeMake(1.0, 9.0)),
 96            objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewLightTopRight.png"), CGSizeMake(9.0, 9.0)),
 97            objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewLightLeft.png"), CGSizeMake(9.0, 1.0)),
 98            nil,
 99            objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewLightRight.png"), CGSizeMake(9.0, 1.0)),
100            objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewLightBottomLeft.png"), CGSizeMake(9.0, 9.0)),
101            objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewLightBottom.png"), CGSizeMake(1.0, 9.0)),
102            objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewLightBottomRight.png"), CGSizeMake(9.0, 9.0))
103        ]));
104    CPShadowViewHeavyBackgroundColor = objj_msgSend(CPColor, "colorWithPatternImage:", objj_msgSend(objj_msgSend(CPNinePartImage, "alloc"), "initWithImageSlices:", 
105        [
106            objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewHeavyTopLeft.png"), CGSizeMake(17.0, 17.0)),
107            objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewHeavyTop.png"), CGSizeMake(1.0, 17.0)),
108            objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewHeavyTopRight.png"), CGSizeMake(17.0, 17.0)),
109            objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewHeavyLeft.png"), CGSizeMake(17.0, 1.0)),
110            nil,
111            objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewHeavyRight.png"), CGSizeMake(17.0, 1.0)),
112            objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewHeavyBottomLeft.png"), CGSizeMake(17.0, 17.0)),
113            objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewHeavyBottom.png"), CGSizeMake(1.0, 17.0)),
114            objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewHeavyBottomRight.png"), CGSizeMake(17.0, 17.0))
115        ]));
116}
117}), new objj_method(sel_getUid("frameForContentFrame:withWeight:"), function $CPShadowView__frameForContentFrame_withWeight_(self, _cmd, aFrame, aWeight)
118{ with(self)
119{
120    if (aWeight == CPLightShadow)
121        return CGRectMake((aFrame.origin.x) - LIGHT_LEFT_INSET, (aFrame.origin.y) - LIGHT_TOP_INSET, (aFrame.size.width) + LIGHT_LEFT_INSET + LIGHT_RIGHT_INSET, (aFrame.size.height) + LIGHT_TOP_INSET + LIGHT_BOTTOM_INSET);
122    else
123        return CGRectMake((aFrame.origin.x) - HEAVY_LEFT_INSET, (aFrame.origin.y) - HEAVY_TOP_INSET, (aFrame.size.width) + HEAVY_LEFT_INSET + HEAVY_RIGHT_INSET, (aFrame.size.height) + HEAVY_TOP_INSET + HEAVY_BOTTOM_INSET);
124}
125})]);
126}
127