@STATIC1.0;p;8;AppKit.ji;12;CPGeometry.ji;13;CPResponder.ji;9;CPImage.ji;9;CPColor.ji;11;CPControl.ji;13;CPTextField.ji;10;CPButton.ji;10;CPBorder.ji;8;CPView.ji;13;CPImageView.ji;10;CPSlider.ji;14;CPScrollView.ji;13;CPTableView.ji;15;CPOutlineView.ji;10;CPWindow.ji;12;CPDocument.ji;22;CPDocumentController.ji;15;CPApplication.ji;17;CPCompatibility.ji;14;CPPasteboard.jp;13;CAAnimation.jI;21;Foundation/CPObject.jI;21;Foundation/CPString.ji;23;CAMediaTimingFunction.jc;5566;


{var the_class = objj_allocateClassPair(CPObject, "CAAnimation"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_isRemovedOnCompletion"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("animation"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(objj_msgSend(self, "alloc"), "init");
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("init"), function(self, _cmd)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
        _isRemovedOnCompletion = YES;

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("shouldArchiveValueForKey:"), function(self, _cmd, aKey)
{ with(self)
{
    return YES;
}
});
class_methods[1] = new objj_method(sel_registerName("defaultValueForKey:"), function(self, _cmd, aKey)
{ with(self)
{
    return nil;
}
});
instance_methods[2] = new objj_method(sel_registerName("setRemovedOnCompletion:"), function(self, _cmd, isRemovedOnCompletion)
{ with(self)
{
    _isRemovedOnCompletion = isRemovedOnCompletion;
}
});
instance_methods[3] = new objj_method(sel_registerName("removedOnCompletion"), function(self, _cmd)
{ with(self)
{
    return _isRemovedOnCompletion;
}
});
instance_methods[4] = new objj_method(sel_registerName("isRemovedOnCompletion"), function(self, _cmd)
{ with(self)
{
    return _isRemovedOnCompletion;
}
});
instance_methods[5] = new objj_method(sel_registerName("timingFunction"), function(self, _cmd)
{ with(self)
{

    return nil;
}
});
instance_methods[6] = new objj_method(sel_registerName("setDelegate:"), function(self, _cmd, aDelegate)
{ with(self)
{
    _delegate = aDelegate;
}
});
instance_methods[7] = new objj_method(sel_registerName("delegate"), function(self, _cmd)
{ with(self)
{
    return _delegate;
}
});
instance_methods[8] = new objj_method(sel_registerName("runActionForKey:object:arguments:"), function(self, _cmd, aKey, anObject, arguments)
{ with(self)
{
    objj_msgSend(anObject, "addAnimation:forKey:", self, aKey);
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

{var the_class = objj_allocateClassPair(CAAnimation, "CAPropertyAnimation"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_keyPath"), new objj_ivar("_isCumulative"), new objj_ivar("_isAdditive"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("animationWithKeyPath:"), function(self, _cmd, aKeyPath)
{ with(self)
{
    var animation = objj_msgSend(self, "animation");

    objj_msgSend(animation, "setKeypath:", aKeyPath);

    return animation;
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("setKeyPath:"), function(self, _cmd, aKeyPath)
{ with(self)
{
    _keyPath = aKeyPath;
}
});
instance_methods[1] = new objj_method(sel_registerName("keyPath"), function(self, _cmd)
{ with(self)
{
    return _keyPath;
}
});
instance_methods[2] = new objj_method(sel_registerName("setCumulative:"), function(self, _cmd, isCumulative)
{ with(self)
{
    _isCumulative = isCumulative;
}
});
instance_methods[3] = new objj_method(sel_registerName("cumulative"), function(self, _cmd)
{ with(self)
{
    return _isCumulative;
}
});
instance_methods[4] = new objj_method(sel_registerName("isCumulative"), function(self, _cmd)
{ with(self)
{
    return _isCumulative;
}
});
instance_methods[5] = new objj_method(sel_registerName("setAdditive:"), function(self, _cmd, isAdditive)
{ with(self)
{
    _isAdditive = isAdditive;
}
});
instance_methods[6] = new objj_method(sel_registerName("additive"), function(self, _cmd)
{ with(self)
{
    return _isAdditive;
}
});
instance_methods[7] = new objj_method(sel_registerName("isAdditive"), function(self, _cmd)
{ with(self)
{
    return _isAdditive;
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

{var the_class = objj_allocateClassPair(CAPropertyAnimation, "CABasicAnimation"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_fromValue"), new objj_ivar("_toValue"), new objj_ivar("_byValue"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("setFromValue:"), function(self, _cmd, aValue)
{ with(self)
{
    _fromValue = aValue;
}
});
instance_methods[1] = new objj_method(sel_registerName("fromValue"), function(self, _cmd)
{ with(self)
{
    return _fromValue;
}
});
instance_methods[2] = new objj_method(sel_registerName("setToValue:"), function(self, _cmd, aValue)
{ with(self)
{
    _toValue = aValue;
}
});
instance_methods[3] = new objj_method(sel_registerName("toValue"), function(self, _cmd)
{ with(self)
{
    return _toValue;
}
});
instance_methods[4] = new objj_method(sel_registerName("setByValue:"), function(self, _cmd, aValue)
{ with(self)
{
    _byValue = aValue;
}
});
instance_methods[5] = new objj_method(sel_registerName("byValue"), function(self, _cmd)
{ with(self)
{
    return _byValue;
}
});
class_addMethods(the_class, instance_methods);
}

p;16;CABackingStore.ji;12;CGGeometry.jc;856;



CABackingStoreGetContext= function(aBackingStore)
{
    return aBackingStore.context;
}

if (CPFeatureIsCompatible(CPHTMLCanvasFeature))
{

CABackingStoreCreate = function()
{
    var DOMElement = document.createElement("canvas");

    DOMElement.style.position = "absolute";


    return { context:DOMElement.getContext("2d"), buffer:DOMElement, _image:DOMElement };
}

CABackingStoreSetSize = function(aBackingStore, aSize)
{
    var buffer = aBackingStore.buffer;

    buffer.width = aSize.width;
    buffer.height = aSize.height;
    buffer.style.width = aSize.width + "px";;
    buffer.style.height = aSize.height + "px";;
}
}
else
{

CABackingStoreCreate = function()
{
    var context = CGBitmapGraphicsContextCreate();

    context.buffer = "";

    return { context:context };
}

CABackingStoreSetSize = function(aBackingStore, aSize)
{
}

}

p;14;CAFlashLayer.ji;9;CALayer.ji;14;CPFlashMovie.jc;1189;


{var the_class = objj_allocateClassPair(CALayer, "CAFlashLayer"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_flashMovie"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("setFlashMovie:"), function(self, _cmd, aFlashMovie)
{ with(self)
{
    if (_flashMovie == aFlashMovie)
        return;

    _flashMovie = aFlashMovie;

    _DOMElement.innerHTML = "<object width = \"100%\" height = \"100%\"><param name = \"movie\" value = \"" +
                            aFlashMovie._fileName +
                            "\"></param><param name = \"wmode\" value = \"transparent\"></param><embed src = \"" +
                            aFlashMovie._fileName + "\" type = \"application/x-shockwave-flash\" wmode = \"transparent\" width = \"100%\" height = \"100%\"></embed></object>";
}
});
instance_methods[1] = new objj_method(sel_registerName("flashMovie"), function(self, _cmd)
{ with(self)
{
    return _flashMovie;
}
});
class_addMethods(the_class, instance_methods);
}

p;9;CALayer.jI;21;Foundation/CPObject.jI;23;AppKit/CABackingStore.jI;18;AppKit/CGContext.jI;19;AppKit/CGGeometry.ji;12;CGGeometry.jc;36705;
CGAffineTransformMake= function(a, b, c, d, tx, ty) { return { a:a, b:b, c:c, d:d, tx:tx, ty:ty }; }
CGAffineTransformMakeIdentity= function() { return { a:1.0, b:0.0, c:0.0, d:1.0, tx:0.0, ty:0.0 }; }
CGAffineTransformMakeCopy= function(anAffineTransform) { return { a:anAffineTransform.a, b:anAffineTransform.b, c:anAffineTransform.c, d:anAffineTransform.d, tx:anAffineTransform.tx, ty:anAffineTransform.ty }; }

CGAffineTransformMakeScale= function(sx, sy) { return { a:sx, b:0.0, c:0.0, d:sy, tx:0.0, ty:0.0 }; }
CGAffineTransformMakeTranslation= function(tx, ty) { return { a:1.0, b:0.0, c:0.0, d:1.0, tx:tx, ty:ty }; }
CGAffineTransformTranslate= function(aTransform, tx, ty) { return { a:aTransform.a, b:aTransform.b, c:aTransform.c, d:aTransform.d, tx:aTransform.tx + aTransform.a * tx + aTransform.c * ty, ty:aTransform.ty + aTransform.b * tx + aTransform.d * ty }; }
CGAffineTransformScale= function(aTransform, sx, sy) { return { a:aTransform.a * sx, b:aTransform.b * sx, c:aTransform.c * sy, d:aTransform.d * sy, tx:aTransform.tx, ty:aTransform.ty }; }

CGAffineTransformConcat= function(lhs, rhs) { return { a:lhs.a * rhs.a + lhs.b * rhs.c, b:lhs.a * rhs.b + lhs.b * rhs.d, c:lhs.c * rhs.a + lhs.d * rhs.c, d:lhs.c * rhs.b + lhs.d * rhs.d, tx:lhs.tx * rhs.a + lhs.ty * rhs.c + rhs.tx, ty:lhs.tx * rhs.b + lhs.ty * rhs.d + rhs.ty }; }
CGPointApplyAffineTransform= function(aPoint, aTransform) { return { x:aPoint.x * aTransform.a + aPoint.y * aTransform.c + aTransform.tx, y:aPoint.x * aTransform.b + aPoint.y * aTransform.d + aTransform.ty }; }
CGSizeApplyAffineTransform= function(aSize, aTransform) { return { width:aSize.width * aTransform.a + aSize.height * aTransform.c, height:aSize.width * aTransform.b + aSize.height * aTransform.d }; }

CGAffineTransformIsIdentity= function(aTransform) { return (aTransform.a == 1 && aTransform.b == 0 && aTransform.c == 0 && aTransform.d == 1 && aTransform.tx == 0 && aTransform.ty == 0); }
CGAffineTransformEqualToTransform= function(lhs, rhs) { return (lhs.a == rhs.a && lhs.b == rhs.b && lhs.c == rhs.c && lhs.d == rhs.d && lhs.tx == rhs.tx && lhs.ty == rhs.ty); }

CGStringCreateWithCGAffineTransform= function(aTransform) { return (" [[ " + aTransform.a + ", " + aTransform.b + ", 0 ], [ " + aTransform.c + ", " + aTransform.d + ", 0 ], [ " + aTransform.tx + ", " + aTransform.ty + ", 1]]"); }


CGAffineTransformCreateCopy= function(aTransform)
{
    return { a:aTransform.a, b:aTransform.b, c:aTransform.c, d:aTransform.d, tx:aTransform.tx, ty:aTransform.ty };
}

CGAffineTransformMakeRotation= function(anAngle)
{
    var sin = SIN(anAngle),
        cos = COS(anAngle);

    return { a:cos, b:sin, c:-sin, d:cos, tx:0.0, ty:0.0 };
}

CGAffineTransformRotate= function(aTransform, anAngle)
{
    var sin = SIN(anAngle),
        cos = COS(anAngle);

    return {
            a:aTransform.a * cos + aTransform.c * sin,
            b:aTransform.b * cos + aTransform.d * sin,
            c:aTransform.c * cos - aTransform.a * sin,
            d:aTransform.d * cos - aTransform.b * sin,
            tx:aTransform.tx,
            ty:aTransform.ty
        };
}

CGAffineTransformInvert= function(aTransform)
{
    var determinant = 1 / (aTransform.a * aTransform.d - aTransform.b * aTransform.c);

    return {
        a:determinant * aTransform.d,
        b:-determinant * aTransform.b,
        c:-determinant * aTransform.c,
        d:determinant * aTransform.a,
        tx:determinant * (aTransform.c * aTransform.ty - aTransform.d * aTransform.tx),
        ty:determinant * (aTransform.b * aTransform.tx - aTransform.a * aTransform.ty)
    };
}

CGRectApplyAffineTransform= function(aRect, anAffineTransform)
{
    var top = (aRect.origin.y),
        left = (aRect.origin.x),
        right = (aRect.origin.x + aRect.size.width),
        bottom = (aRect.origin.y + aRect.size.height),
        topLeft = CGPointApplyAffineTransform({ x:left, y:top }, anAffineTransform),
        topRight = CGPointApplyAffineTransform({ x:right, y:top }, anAffineTransform),
        bottomLeft = CGPointApplyAffineTransform({ x:left, y:bottom }, anAffineTransform),
        bottomRight = CGPointApplyAffineTransform({ x:right, y:bottom }, anAffineTransform),
        minX = MIN(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x),
        maxX = MAX(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x),
        minY = MIN(topLeft.y, topRight.y, bottomLeft.y, bottomRight.y),
        maxY = MAX(topLeft.y, topRight.y, bottomLeft.y, bottomRight.y);

    return { origin: { x:minX, y:minY }, size: { width:(maxX - minX), height:(maxY - minY) } };
}

CPStringFromCGAffineTransform= function(anAffineTransform)
{
    return '{' + anAffineTransform.a + ", " + anAffineTransform.b + ", " + anAffineTransform.c + ", " + anAffineTransform.d + ", " + anAffineTransform.tx + ", " + anAffineTransform.ty + '}';
}
var CALayerGeometryBoundsMask = 1,
    CALayerGeometryPositionMask = 2,
    CALayerGeometryAnchorPointMask = 4,
    CALayerGeometryAffineTransformMask = 8,
    CALayerGeometryParentSublayerTransformMask = 16;
var USE_BUFFER = NO;
var CALayerFrameOriginUpdateMask = 1,
    CALayerFrameSizeUpdateMask = 2,
    CALayerZPositionUpdateMask = 4,
    CALayerDisplayUpdateMask = 8,
    CALayerCompositeUpdateMask = 16,
    CALayerDOMUpdateMask = CALayerZPositionUpdateMask | CALayerFrameOriginUpdateMask | CALayerFrameSizeUpdateMask;
var CALayerRegisteredRunLoopUpdates = nil;
{var the_class = objj_allocateClassPair(CPObject, "CALayer"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_frame"), new objj_ivar("_bounds"), new objj_ivar("_position"), new objj_ivar("_zPosition"), new objj_ivar("_anchorPoint"), new objj_ivar("_affineTransform"), new objj_ivar("_sublayerTransform"), new objj_ivar("_sublayerTransformForSublayers"), new objj_ivar("_backingStoreFrame"), new objj_ivar("_standardBackingStoreFrame"), new objj_ivar("_hasSublayerTransform"), new objj_ivar("_hasCustomBackingStoreFrame"), new objj_ivar("_opacity"), new objj_ivar("_isHidden"), new objj_ivar("_backgroundColor"), new objj_ivar("_superlayer"), new objj_ivar("_sublayers"), new objj_ivar("_runLoopUpdateMask"), new objj_ivar("_needsDisplayOnBoundsChange"), new objj_ivar("_delegate"), new objj_ivar("_delegateRespondsToDisplayLayerSelector"), new objj_ivar("_delegateRespondsToDrawLayerInContextSelector"), new objj_ivar("_DOMElement"), new objj_ivar("_DOMContentsElement"), new objj_ivar("_contents"), new objj_ivar("_context"), new objj_ivar("_owningView"), new objj_ivar("_transformToLayer"), new objj_ivar("_transformFromLayer"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("layer"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(objj_msgSend(objj_msgSend(self, "class"), "alloc"), "init");
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("init"), function(self, _cmd)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");
    if (self)
    {
        _frame = CGRectMakeZero();
        _backingStoreFrame = CGRectMakeZero();
        _standardBackingStoreFrame = CGRectMakeZero();
        _bounds = CGRectMakeZero();
        _position = CGPointMakeZero();
        _zPosition = 0.0;
        _anchorPoint = CGPointMake(0.5, 0.5);
        _affineTransform = CGAffineTransformMakeIdentity();
        _sublayerTransform = CGAffineTransformMakeIdentity();
        _transformToLayer = CGAffineTransformMakeIdentity();
        _transformFromLayer = CGAffineTransformMakeIdentity();
        _opacity = 1.0;
        _isHidden = NO;
        _masksToBounds = NO;
        _sublayers = [];
        _DOMElement = document.createElement("div");
        _DOMElement.style.overflow = "visible";
        _DOMElement.style.position = "absolute";
        _DOMElement.style.visibility = "visible";
        _DOMElement.style.top = "0px";
        _DOMElement.style.left = "0px";
        _DOMElement.style.zIndex = 0;
        _DOMElement.style.width = "0px";
        _DOMElement.style.height = "0px";
    }
    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setBounds:"), function(self, _cmd, aBounds)
{ with(self)
{
    if (CGRectEqualToRect(_bounds, aBounds))
        return;
    var oldOrigin = _bounds.origin;
    _bounds = { origin: { x:aBounds.origin.x, y:aBounds.origin.y }, size: { width:aBounds.size.width, height:aBounds.size.height } };
    if (_hasSublayerTransform)
        _CALayerUpdateSublayerTransformForSublayers(self);
    _CALayerRecalculateGeometry(self, CALayerGeometryBoundsMask);
}
});
instance_methods[2] = new objj_method(sel_registerName("bounds"), function(self, _cmd)
{ with(self)
{
    return _bounds;
}
});
instance_methods[3] = new objj_method(sel_registerName("setPosition:"), function(self, _cmd, aPosition)
{ with(self)
{
    if (CGPointEqualToPoint(_position, aPosition))
        return;
    _position = { x:aPosition.x, y:aPosition.y };
    _CALayerRecalculateGeometry(self, CALayerGeometryPositionMask);
}
});
instance_methods[4] = new objj_method(sel_registerName("position"), function(self, _cmd)
{ with(self)
{
    return _position;
}
});
instance_methods[5] = new objj_method(sel_registerName("setZPosition:"), function(self, _cmd, aZPosition)
{ with(self)
{
    if (_zPosition == aZPosition)
        return;
    _zPosition = aZPosition;
    objj_msgSend(self, "registerRunLoopUpdateWithMask:", CALayerZPositionUpdateMask);
}
});
instance_methods[6] = new objj_method(sel_registerName("setAnchorPoint:"), function(self, _cmd, anAnchorPoint)
{ with(self)
{
    anAnchorPoint = { x:anAnchorPoint.x, y:anAnchorPoint.y };
    anAnchorPoint.x = MIN(1.0, MAX(0.0, anAnchorPoint.x));
    anAnchorPoint.y = MIN(1.0, MAX(0.0, anAnchorPoint.y));
    if (CGPointEqualToPoint(_anchorPoint, anAnchorPoint))
        return;
    _anchorPoint = anAnchorPoint;
    if (_hasSublayerTransform)
        _CALayerUpdateSublayerTransformForSublayers(self);
    if (_owningView)
        _position = CGPointMake((_bounds.size.width) * _anchorPoint.x, (_bounds.size.height) * _anchorPoint.y);
    _CALayerRecalculateGeometry(self, CALayerGeometryAnchorPointMask);
}
});
instance_methods[7] = new objj_method(sel_registerName("anchorPoint"), function(self, _cmd)
{ with(self)
{
    return _anchorPoint;
}
});
instance_methods[8] = new objj_method(sel_registerName("setAffineTransform:"), function(self, _cmd, anAffineTransform)
{ with(self)
{
    if (CGAffineTransformEqualToTransform(_affineTransform, anAffineTransform))
        return;
    _affineTransform = { a:anAffineTransform.a, b:anAffineTransform.b, c:anAffineTransform.c, d:anAffineTransform.d, tx:anAffineTransform.tx, ty:anAffineTransform.ty };
    _CALayerRecalculateGeometry(self, CALayerGeometryAffineTransformMask);
}
});
instance_methods[9] = new objj_method(sel_registerName("affineTransform"), function(self, _cmd)
{ with(self)
{
    return _affineTransform;
}
});
instance_methods[10] = new objj_method(sel_registerName("setSublayerTransform:"), function(self, _cmd, anAffineTransform)
{ with(self)
{
    if (CGAffineTransformEqualToTransform(_sublayerTransform, anAffineTransform))
        return;
    var hadSublayerTransform = _hasSublayerTransform;
    _sublayerTransform = { a:anAffineTransform.a, b:anAffineTransform.b, c:anAffineTransform.c, d:anAffineTransform.d, tx:anAffineTransform.tx, ty:anAffineTransform.ty };
    _hasSublayerTransform = !(_sublayerTransform.a == 1 && _sublayerTransform.b == 0 && _sublayerTransform.c == 0 && _sublayerTransform.d == 1 && _sublayerTransform.tx == 0 && _sublayerTransform.ty == 0);
    if (_hasSublayerTransform)
    {
        _CALayerUpdateSublayerTransformForSublayers(self);
        var index = _sublayers.length;


        while (index--)
            _CALayerRecalculateGeometry(_sublayers[index], CALayerGeometryParentSublayerTransformMask);
    }
}
});
instance_methods[11] = new objj_method(sel_registerName("sublayerTransform"), function(self, _cmd)
{ with(self)
{
    return _sublayerTransform;
}
});
instance_methods[12] = new objj_method(sel_registerName("transformToLayer"), function(self, _cmd)
{ with(self)
{
    return _transformToLayer;
}
});
instance_methods[13] = new objj_method(sel_registerName("setFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    alert("FIXME IMPLEMENT");
}
});
instance_methods[14] = new objj_method(sel_registerName("frame"), function(self, _cmd)
{ with(self)
{
    if (!_frame)
        _frame = objj_msgSend(self, "convertRect:toLayer:", _bounds, _superlayer);

    return _frame;
}
});
instance_methods[15] = new objj_method(sel_registerName("backingStoreFrame"), function(self, _cmd)
{ with(self)
{
    return _backingStoreFrame;
}
});
instance_methods[16] = new objj_method(sel_registerName("setBackingStoreFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    _hasCustomBackingStoreFrame = (aFrame != nil);

    if (aFrame == nil)
        aFrame = CGRectMakeCopy(_standardBackingStoreFrame);
    else
    {
        if (_superlayer)
        {
            aFrame = objj_msgSend(_superlayer, "convertRect:toLayer:", aFrame, nil);

            var bounds = objj_msgSend(_superlayer, "bounds"),
                frame = objj_msgSend(_superlayer, "convertRect:toLayer:", bounds, nil);

            aFrame.origin.x -= (frame.origin.x);
            aFrame.origin.y -= (frame.origin.y);
        }
        else
            aFrame = CGRectMakeCopy(aFrame);
    }

    if (!CGPointEqualToPoint(_backingStoreFrame.origin, aFrame.origin))
        objj_msgSend(self, "registerRunLoopUpdateWithMask:", CALayerFrameOriginUpdateMask);

    if (!CGSizeEqualToSize(_backingStoreFrame.size, aFrame.size))
        objj_msgSend(self, "registerRunLoopUpdateWithMask:", CALayerFrameSizeUpdateMask);

    _backingStoreFrame = aFrame;
}
});
instance_methods[17] = new objj_method(sel_registerName("contents"), function(self, _cmd)
{ with(self)
{
    return _contents;
}
});
instance_methods[18] = new objj_method(sel_registerName("setContents:"), function(self, _cmd, contents)
{ with(self)
{
    if (_contents == contents)
        return;

    _contents = contents;

    objj_msgSend(self, "composite");
}
});
instance_methods[19] = new objj_method(sel_registerName("composite"), function(self, _cmd)
{ with(self)
{
    if (USE_BUFFER && !_contents || !_context)
        return;

    CGContextClearRect(_context, { origin: { x:0.0, y:0.0 }, size: { width:(_backingStoreFrame.size.width), height:(_backingStoreFrame.size.height) } });


    var transform = _transformFromLayer;

    if (_superlayer)
    {
        var superlayerTransform = _CALayerGetTransform(_superlayer, nil),
            superlayerOrigin = CGPointApplyAffineTransform(_superlayer._bounds.origin, superlayerTransform);

        transform = CGAffineTransformConcat(transform, superlayerTransform);

        transform.tx -= superlayerOrigin.x;
        transform.ty -= superlayerOrigin.y;
    }

    transform.tx -= (_backingStoreFrame.origin.x);
    transform.ty -= (_backingStoreFrame.origin.y);

    CGContextSaveGState(_context);
    CGContextConcatCTM(_context, transform);
    if (USE_BUFFER)
    {

        _context.drawImage(_contents.buffer, (_bounds.origin.x), (_bounds.origin.y));
    }
    else
        objj_msgSend(self, "drawInContext:", _context);
    CGContextRestoreGState(_context);
}
});
instance_methods[20] = new objj_method(sel_registerName("display"), function(self, _cmd)
{ with(self)
{
    if (!_context)
    {
        _context = CGBitmapGraphicsContextCreate();

        _DOMContentsElement = _context.DOMElement;

        _DOMContentsElement.style.zIndex = -100;

        _DOMContentsElement.style.overflow = "hidden";
        _DOMContentsElement.style.position = "absolute";
        _DOMContentsElement.style.visibility = "visible";

        _DOMContentsElement.width = ROUND((_backingStoreFrame.size.width));
        _DOMContentsElement.height = ROUND((_backingStoreFrame.size.height));

        _DOMContentsElement.style.top = "0px";
        _DOMContentsElement.style.left = "0px";
        _DOMContentsElement.style.width = ROUND((_backingStoreFrame.size.width)) + "px";
        _DOMContentsElement.style.height = ROUND((_backingStoreFrame.size.height)) + "px";

        _DOMElement.appendChild(_DOMContentsElement);
    }

    if (USE_BUFFER)
    {
        if (_delegateRespondsToDisplayLayerSelector)
            return objj_msgSend(self, "displayInLayer:", self);

        if ((_backingStoreFrame.size.width) == 0.0 || (_backingStoreFrame.size.height) == 0.0)
            return;

        if (!_contents)
            _contents = CABackingStoreCreate();

        CABackingStoreSetSize(_contents, _bounds.size);

        objj_msgSend(self, "drawInContext:", CABackingStoreGetContext(_contents));
    }

    objj_msgSend(self, "composite");
}
});
instance_methods[21] = new objj_method(sel_registerName("drawInContext:"), function(self, _cmd, aContext)
{ with(self)
{ if (!window.loop || window.nodisplay) {objj_debug_print_backtrace(); alert("BAD!" + objj_msgSend(self, "description"));}
    if (_backgroundColor)
    {
        CGContextSetFillColor(aContext, _backgroundColor);
        CGContextFillRect(aContext, _bounds);
    }

    if (_delegateRespondsToDrawLayerInContextSelector)
        objj_msgSend(_delegate, "drawLayer:inContext:", self, aContext);
}
});
instance_methods[22] = new objj_method(sel_registerName("opacity"), function(self, _cmd)
{ with(self)
{
    return _opacity;
}
});
instance_methods[23] = new objj_method(sel_registerName("setOpacity:"), function(self, _cmd, anOpacity)
{ with(self)
{
    if (_opacity == anOpacity)
        return;

    _opacity = anOpacity;

    _DOMElement.style.opacity = anOpacity;
    _DOMElement.style.filter = "alpha(opacity=" + anOpacity * 100 + ")";
}
});
instance_methods[24] = new objj_method(sel_registerName("setHidden:"), function(self, _cmd, isHidden)
{ with(self)
{
    _isHidden = isHidden;
    _DOMElement.style.display = isHidden ? "none" : "block";
}
});
instance_methods[25] = new objj_method(sel_registerName("hidden"), function(self, _cmd)
{ with(self)
{
    return _isHidden;
}
});
instance_methods[26] = new objj_method(sel_registerName("isHidden"), function(self, _cmd)
{ with(self)
{
    return _isHidden;
}
});
instance_methods[27] = new objj_method(sel_registerName("setMasksToBounds:"), function(self, _cmd, masksToBounds)
{ with(self)
{
    if (_masksToBounds == masksToBounds)
        return;

    _masksToBounds = masksToBounds;
    _DOMElement.style.overflow = _masksToBounds ? "hidden" : "visible";
}
});
instance_methods[28] = new objj_method(sel_registerName("setBackgroundColor:"), function(self, _cmd, aColor)
{ with(self)
{
    _backgroundColor = aColor;

    objj_msgSend(self, "setNeedsDisplay");
}
});
instance_methods[29] = new objj_method(sel_registerName("backgroundColor"), function(self, _cmd)
{ with(self)
{
    return _backgroundColor;
}
});
instance_methods[30] = new objj_method(sel_registerName("sublayers"), function(self, _cmd)
{ with(self)
{
    return _sublayers;
}
});
instance_methods[31] = new objj_method(sel_registerName("superlayer"), function(self, _cmd)
{ with(self)
{
    return _superlayer;
}
});
instance_methods[32] = new objj_method(sel_registerName("addSublayer:"), function(self, _cmd, aLayer)
{ with(self)
{
    objj_msgSend(self, "insertSublayer:atIndex:", aLayer, _sublayers.length);
    return;
    if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex) _DOMContentsElement.style.zIndex -= 100.0;;

    objj_msgSend(_sublayers, "addObject:", aLayer);
    _DOMElement.appendChild(aLayer._DOMElement);
}
});
instance_methods[33] = new objj_method(sel_registerName("removeFromSuperlayer"), function(self, _cmd)
{ with(self)
{
    if (_owningView)
        objj_msgSend(_owningView, "setLayer:", nil);

    if (!_superlayer)
        return;

    _superlayer._DOMElement.removeChild(_DOMElement);
    objj_msgSend(_superlayer._sublayers, "removeObject:", self);

    _superlayer = nil;
}
});
instance_methods[34] = new objj_method(sel_registerName("insertSublayer:atIndex:"), function(self, _cmd, aLayer, anIndex)
{ with(self)
{
    if (!aLayer)
        return;

    var superlayer = objj_msgSend(aLayer, "superlayer");

    if (superlayer == self)
    {
        var index = objj_msgSend(_sublayers, "indexOfObjectIdenticalTo:", aLayer);

        if (index == anIndex)
            return;

        objj_msgSend(_sublayers, "removeObjectAtIndex:", index);

        if (index < anIndex)
            --anIndex;
    }
    else if (superlayer != nil)
        objj_msgSend(aLayer, "removeFromSuperlayer");

    if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex) _DOMContentsElement.style.zIndex -= 100.0;;

    objj_msgSend(_sublayers, "insertObject:atIndex:", aLayer, anIndex);

    if (anIndex >= _sublayers.length - 1)
        _DOMElement.appendChild(aLayer._DOMElement);
    else
        _DOMElement.insertBefore(aLayer._DOMElement, _sublayers[anIndex+1]._DOMElement);

    aLayer._superlayer = self;

    if (self != superlayer)
        _CALayerRecalculateGeometry(aLayer, 0xFFFFFFF);
}
});
instance_methods[35] = new objj_method(sel_registerName("insertSublayer:below:"), function(self, _cmd, aLayer, aSublayer)
{ with(self)
{
    var index = aSublayer ? objj_msgSend(_sublayers, "indexOfObjectIdenticalTo:", aSublayer) : 0;

    objj_msgSend(self, "insertSublayer:atIndex:", aLayer, index==CPNotFound?_sublayers.length:index);
}
});
instance_methods[36] = new objj_method(sel_registerName("insertSublayer:after:"), function(self, _cmd, aLayer, aSublayer)
{ with(self)
{
    var index = aSublayer ? objj_msgSend(_sublayers, "indexOfObjectIdenticalTo:", aSublayer) : _sublayers.length;

    objj_msgSend(_sublayers, "insertObject:atIndex:", aLayer, index==CPNotFound?_sublayers.length:index+1);
}
});
instance_methods[37] = new objj_method(sel_registerName("replaceSublayer:with:"), function(self, _cmd, aSublayer, aLayer)
{ with(self)
{
    if (aSublayer == aLayer)
        return;


    if (aSublayer._superlayer != self)
    {
        alert("EXCEPTION");
        return;
    }

    if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex) _DOMContentsElement.style.zIndex -= 100.0;;

    objj_msgSend(_sublayers, "replaceObjectAtIndex:withObject:", objj_msgSend(_sublayers, "indexOfObjectIdenticalTo:", aSublayer), aLayer);
    _DOMElement.replaceChild(aSublayer._DOMElement, aLayer._DOMElement);
}
});
class_methods[1] = new objj_method(sel_registerName("runLoopUpdateLayers"), function(self, _cmd)
{ with(self)
{if (window.oops) {alert(window.latest); objj_debug_print_backtrace();}
    window.loop = true;
    for (hash in CALayerRegisteredRunLoopUpdates)
    {
        var layer = CALayerRegisteredRunLoopUpdates[hash],
            mask = layer._runLoopUpdateMask;

        if (mask & CALayerDOMUpdateMask)
            _CALayerUpdateDOM(layer, mask);

        if (mask & CALayerDisplayUpdateMask)
            objj_msgSend(layer, "display");

        else if (mask & CALayerFrameSizeUpdateMask || mask & CALayerCompositeUpdateMask)
            objj_msgSend(layer, "composite");

        layer._runLoopUpdateMask = 0;
    }
    window.loop= false;
    CALayerRegisteredRunLoopUpdates = nil;
}
});
instance_methods[38] = new objj_method(sel_registerName("registerRunLoopUpdateWithMask:"), function(self, _cmd, anUpdateMask)
{ with(self)
{
    if (CALayerRegisteredRunLoopUpdates == nil)
    {
        CALayerRegisteredRunLoopUpdates = {};

        objj_msgSend(objj_msgSend(CPRunLoop, "currentRunLoop"), "performSelector:target:argument:order:modes:", sel_registerName("runLoopUpdateLayers"), CALayer, nil, 0, [CPDefaultRunLoopMode]);
    }

    _runLoopUpdateMask |= anUpdateMask;
    CALayerRegisteredRunLoopUpdates[objj_msgSend(self, "hash")] = self;
}
});
instance_methods[39] = new objj_method(sel_registerName("setNeedsComposite"), function(self, _cmd)
{ with(self)
{
    objj_msgSend(self, "registerRunLoopUpdateWithMask:", CALayerCompositeUpdateMask);
}
});
instance_methods[40] = new objj_method(sel_registerName("setNeedsDisplay"), function(self, _cmd)
{ with(self)
{
    objj_msgSend(self, "registerRunLoopUpdateWithMask:", CALayerDisplayUpdateMask);
}
});
instance_methods[41] = new objj_method(sel_registerName("setNeedsDisplayOnBoundsChange:"), function(self, _cmd, needsDisplayOnBoundsChange)
{ with(self)
{
    _needsDisplayOnBoundsChange = needsDisplayOnBoundsChange;
}
});
instance_methods[42] = new objj_method(sel_registerName("needsDisplayOnBoundsChange"), function(self, _cmd)
{ with(self)
{
    return _needsDisplayOnBoundsChange;
}
});
instance_methods[43] = new objj_method(sel_registerName("setNeedsDisplayInRect:"), function(self, _cmd, aRect)
{ with(self)
{
    _dirtyRect = aRect;
    objj_msgSend(self, "display");
}
});
instance_methods[44] = new objj_method(sel_registerName("convertPoint:fromLayer:"), function(self, _cmd, aPoint, aLayer)
{ with(self)
{
    return CGPointApplyAffineTransform(aPoint, _CALayerGetTransform(aLayer, self));
}
});
instance_methods[45] = new objj_method(sel_registerName("convertPoint:toLayer:"), function(self, _cmd, aPoint, aLayer)
{ with(self)
{
    return CGPointApplyAffineTransform(aPoint, _CALayerGetTransform(self, aLayer));
}
});
instance_methods[46] = new objj_method(sel_registerName("convertRect:fromLayer:"), function(self, _cmd, aRect, aLayer)
{ with(self)
{
    return CGRectApplyAffineTransform(aRect, _CALayerGetTransform(aLayer, self));
}
});
instance_methods[47] = new objj_method(sel_registerName("convertRect:toLayer:"), function(self, _cmd, aRect, aLayer)
{ with(self)
{
    return CGRectApplyAffineTransform(aRect, _CALayerGetTransform(self, aLayer));
}
});
instance_methods[48] = new objj_method(sel_registerName("containsPoint:"), function(self, _cmd, aPoint)
{ with(self)
{
    return (aPoint.x >= (_bounds.origin.x) && aPoint.y >= (_bounds.origin.y) && aPoint.x < (_bounds.origin.x + _bounds.size.width) && aPoint.y < (_bounds.origin.y + _bounds.size.height));
}
});
instance_methods[49] = new objj_method(sel_registerName("hitTest:"), function(self, _cmd, aPoint)
{ with(self)
{
    if (_isHidden)
        return nil;

    var point = CGPointApplyAffineTransform(aPoint, _transformToLayer);


    if (!(point.x >= (_bounds.origin.x) && point.y >= (_bounds.origin.y) && point.x < (_bounds.origin.x + _bounds.size.width) && point.y < (_bounds.origin.y + _bounds.size.height)))
        return nil;

    var layer = nil,
        index = _sublayers.length;


    while (index--)
        if (layer = objj_msgSend(_sublayers[index], "hitTest:", point))
            return layer;

    return self;
}
});
instance_methods[50] = new objj_method(sel_registerName("setDelegate:"), function(self, _cmd, aDelegate)
{ with(self)
{
    if (_delegate == aDelegate)
        return;

    _delegate = aDelegate;

    _delegateRespondsToDisplayLayerSelector = objj_msgSend(_delegate, "respondsToSelector:", sel_registerName("displayLayer:"));
    _delegateRespondsToDrawLayerInContextSelector = objj_msgSend(_delegate, "respondsToSelector:", sel_registerName("drawLayer:inContext:"));

    if (_delegateRespondsToDisplayLayerSelector || _delegateRespondsToDrawLayerInContextSelector)
        objj_msgSend(self, "setNeedsDisplay");
}
});
instance_methods[51] = new objj_method(sel_registerName("delegate"), function(self, _cmd)
{ with(self)
{
    return _delegate;
}
});
instance_methods[52] = new objj_method(sel_registerName("_setOwningView:"), function(self, _cmd, anOwningView)
{ with(self)
{
    _owningView = anOwningView;

    if (_owningView)
    {
        _owningView = anOwningView;

        _bounds.size = CGSizeMakeCopy(objj_msgSend(_owningView, "bounds").size);
        _position = CGPointMake((_bounds.size.width) * _anchorPoint.x, (_bounds.size.height) * _anchorPoint.y);
    }

    _CALayerRecalculateGeometry(self, CALayerGeometryPositionMask | CALayerGeometryBoundsMask);
}
});
instance_methods[53] = new objj_method(sel_registerName("_owningViewBoundsChanged"), function(self, _cmd)
{ with(self)
{
    _bounds.size = CGSizeMakeCopy(objj_msgSend(_owningView, "bounds").size);
    _position = CGPointMake((_bounds.size.width) * _anchorPoint.x, (_bounds.size.height) * _anchorPoint.y);

    _CALayerRecalculateGeometry(self, CALayerGeometryPositionMask | CALayerGeometryBoundsMask);
}
});
instance_methods[54] = new objj_method(sel_registerName("_update"), function(self, _cmd)
{ with(self)
{
    window.loop = true;

    var mask = _runLoopUpdateMask;

    if (mask & CALayerDOMUpdateMask)
        _CALayerUpdateDOM(self, mask);

    if (mask & CALayerDisplayUpdateMask)
        objj_msgSend(self, "display");

    else if (mask & CALayerFrameSizeUpdateMask || mask & CALayerCompositeUpdateMask)
        objj_msgSend(self, "composite");

    _runLoopUpdateMask = 0;

    window.loop = false;
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

_CALayerUpdateSublayerTransformForSublayers= function(aLayer)
{
    var bounds = aLayer._bounds,
        anchorPoint = aLayer._anchorPoint,
        translateX = (bounds.size.width) * anchorPoint.x,
        translateY = (bounds.size.height) * anchorPoint.y;

    aLayer._sublayerTransformForSublayers = CGAffineTransformConcat(
        CGAffineTransformMakeTranslation(-translateX, -translateY),
        CGAffineTransformConcat(aLayer._sublayerTransform,
        CGAffineTransformMakeTranslation(translateX, translateY)));
}

_CALayerUpdateDOM= function(aLayer, aMask)
{
    var DOMElementStyle = aLayer._DOMElement.style;

    if (aMask & CALayerZPositionUpdateMask)
        DOMElementStyle.zIndex = aLayer._zPosition;

    var frame = aLayer._backingStoreFrame;

    if (aMask & CALayerFrameOriginUpdateMask)
    {
        DOMElementStyle.top = ROUND((frame.origin.y)) + "px";
        DOMElementStyle.left = ROUND((frame.origin.x)) + "px";
    }

    if (aMask & CALayerFrameSizeUpdateMask)
    {
        var width = MAX(0.0, ROUND((frame.size.width))),
            height = MAX(0.0, ROUND((frame.size.height))),
            DOMContentsElement = aLayer._DOMContentsElement;

        DOMElementStyle.width = width + "px";
        DOMElementStyle.height = height + "px";

        if (DOMContentsElement)
        {
            DOMContentsElement.width = width;
            DOMContentsElement.height = height;
            DOMContentsElement.style.width = width + "px";
            DOMContentsElement.style.height = height + "px";
        }
    }
}

_CALayerRecalculateGeometry= function(aLayer, aGeometryChange)
{
    var bounds = aLayer._bounds,
        superlayer = aLayer._superlayer,
        width = (bounds.size.width),
        height = (bounds.size.height),
        position = aLayer._position,
        anchorPoint = aLayer._anchorPoint,
        affineTransform = aLayer._affineTransform,
        backingStoreFrameSize = { width:aLayer._backingStoreFrame.width, height:aLayer._backingStoreFrame.height },
        hasCustomBackingStoreFrame = aLayer._hasCustomBackingStoreFrame;


    aLayer._transformFromLayer = CGAffineTransformConcat(
        CGAffineTransformMakeTranslation(-width * anchorPoint.x - (aLayer._bounds.origin.x), -height * anchorPoint.y - (aLayer._bounds.origin.y)),
        CGAffineTransformConcat(affineTransform,
        CGAffineTransformMakeTranslation(position.x, position.y)));

    if (superlayer && superlayer._hasSublayerTransform)
    {

        var tx = aLayer._transformFromLayer.tx * superlayer._sublayerTransformForSublayers.a + aLayer._transformFromLayer.ty * superlayer._sublayerTransformForSublayers.c + superlayer._sublayerTransformForSublayers.tx;aLayer._transformFromLayer.ty = aLayer._transformFromLayer.tx * superlayer._sublayerTransformForSublayers.b + aLayer._transformFromLayer.ty * superlayer._sublayerTransformForSublayers.d + superlayer._sublayerTransformForSublayers.ty;aLayer._transformFromLayer.tx = tx;var a = aLayer._transformFromLayer.a * superlayer._sublayerTransformForSublayers.a + aLayer._transformFromLayer.b * superlayer._sublayerTransformForSublayers.c, b = aLayer._transformFromLayer.a * superlayer._sublayerTransformForSublayers.b + aLayer._transformFromLayer.b * superlayer._sublayerTransformForSublayers.d, c = aLayer._transformFromLayer.c * superlayer._sublayerTransformForSublayers.a + aLayer._transformFromLayer.d * superlayer._sublayerTransformForSublayers.c;aLayer._transformFromLayer.d = aLayer._transformFromLayer.c * superlayer._sublayerTransformForSublayers.b + aLayer._transformFromLayer.d * superlayer._sublayerTransformForSublayers.d;aLayer._transformFromLayer.a = a;aLayer._transformFromLayer.b = b;aLayer._transformFromLayer.c = c;;
    }

    aLayer._transformToLayer = CGAffineTransformInvert(aLayer._transformFromLayer);




    aLayer._frame = nil;
    aLayer._standardBackingStoreFrame = objj_msgSend(aLayer, "convertRect:toLayer:", bounds, nil);

    if (superlayer)
    {
        var bounds = objj_msgSend(superlayer, "bounds"),
            frame = objj_msgSend(superlayer, "convertRect:toLayer:", bounds, nil);

        aLayer._standardBackingStoreFrame.origin.x -= (frame.origin.x);
        aLayer._standardBackingStoreFrame.origin.y -= (frame.origin.y);
    }

    aLayer._standardBackingStoreFrame = CGRectIntegral(aLayer._standardBackingStoreFrame);


    if (!hasCustomBackingStoreFrame)
    {
        var backingStoreFrame = CGRectMakeCopy(aLayer._standardBackingStoreFrame);



        if (ROUND((backingStoreFrame.origin.x)) != ROUND((aLayer._backingStoreFrame.origin.x)) ||
            ROUND((backingStoreFrame.origin.y)) != ROUND((aLayer._backingStoreFrame.origin.y)))
            objj_msgSend(aLayer, "registerRunLoopUpdateWithMask:", CALayerFrameOriginUpdateMask);


        if (aGeometryChange != CALayerGeometryPositionMask &&
            (ROUND((backingStoreFrame.size.width)) != ROUND((aLayer._backingStoreFrame.size.width)) ||
            ROUND((backingStoreFrame.size.height)) != ROUND((aLayer._backingStoreFrame.size.height))))
            objj_msgSend(aLayer, "registerRunLoopUpdateWithMask:", CALayerFrameSizeUpdateMask);

        aLayer._backingStoreFrame = backingStoreFrame;
    }

    if (aGeometryChange & CALayerGeometryBoundsMask && aLayer._needsDisplayOnBoundsChange)
        objj_msgSend(aLayer, "setNeedsDisplay");




    else if (hasCustomBackingStoreFrame || (aGeometryChange & ~(CALayerGeometryPositionMask | CALayerGeometryAnchorPointMask)))
        objj_msgSend(aLayer, "setNeedsComposite");

    var sublayers = aLayer._sublayers,
        index = 0,
        count = sublayers.length;

    for (; index < count; ++index)
        _CALayerRecalculateGeometry(sublayers[index], aGeometryChange);
}

_CALayerGetTransform= function(fromLayer, toLayer)
{
    var transform = CGAffineTransformMakeIdentity();

    if (fromLayer)
    {
        var layer = fromLayer;



        while (layer && layer != toLayer)
        {
            var transformFromLayer = layer._transformFromLayer;


            var tx = transform.tx * transformFromLayer.a + transform.ty * transformFromLayer.c + transformFromLayer.tx;transform.ty = transform.tx * transformFromLayer.b + transform.ty * transformFromLayer.d + transformFromLayer.ty;transform.tx = tx;var a = transform.a * transformFromLayer.a + transform.b * transformFromLayer.c, b = transform.a * transformFromLayer.b + transform.b * transformFromLayer.d, c = transform.c * transformFromLayer.a + transform.d * transformFromLayer.c;transform.d = transform.c * transformFromLayer.b + transform.d * transformFromLayer.d;transform.a = a;transform.b = b;transform.c = c;;

            layer = layer._superlayer;
        }


        if (layer == toLayer)
            return transform;
    }

    var layers = [],
        layer = toLayer;

    while (layer)
    {
        layers.push(layer);
        layer = layer._superlayer;
    }

    var index = layers.length;

    while (index--)
    {
        var transformToLayer = layers[index]._transformToLayer;

        var tx = transform.tx * transformToLayer.a + transform.ty * transformToLayer.c + transformToLayer.tx;transform.ty = transform.tx * transformToLayer.b + transform.ty * transformToLayer.d + transformToLayer.ty;transform.tx = tx;var a = transform.a * transformToLayer.a + transform.b * transformToLayer.c, b = transform.a * transformToLayer.b + transform.b * transformToLayer.d, c = transform.c * transformToLayer.a + transform.d * transformToLayer.c;transform.d = transform.c * transformToLayer.b + transform.d * transformToLayer.d;transform.a = a;transform.b = b;transform.c = c;;
    }

    return transform;
}

p;23;CAMediaTimingFunction.jI;21;Foundation/CPObject.jI;25;Foundation/CPDictionary.jI;21;Foundation/CPString.jc;3077;


kCAMediaTimingFunctionLinear = "kCAMediaTimingFunctionLinear";
kCAMediaTimingFunctionEaseIn = "kCAMediaTimingFunctionEaseIn";
kCAMediaTimingFunctionEaseOut = "kCAMediaTimingFunctionEaseOut";
kCAMediaTimingFunctionEaseInEaseOut = "kCAMediaTimingFunctionEaseInEaseOut";

var CAMediaNamedTimingFunctions = nil;

{var the_class = objj_allocateClassPair(CPObject, "CAMediaTimingFunction"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_c1x"), new objj_ivar("_c1y"), new objj_ivar("_c2x"), new objj_ivar("_c2y"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("functionWithName:"), function(self, _cmd, aName)
{ with(self)
{
    if (!CAMediaNamedTimingFunctions)
    {
        CAMediaNamedTimingFunctions = objj_msgSend(CPDictionary, "dictionary");

        objj_msgSend(CAMediaNamedTimingFunctions, "setObject:forKey:", objj_msgSend(CAMediaTimingFunction, "functionWithControlPoints::::", 0.0, 0.0, 1.0, 1.0), kCAMediaTimingFunctionLinear);
        objj_msgSend(CAMediaNamedTimingFunctions, "setObject:forKey:", objj_msgSend(CAMediaTimingFunction, "functionWithControlPoints::::", 0.42, 0.0, 1.0, 1.0), kCAMediaTimingFunctionEaseIn);
        objj_msgSend(CAMediaNamedTimingFunctions, "setObject:forKey:", objj_msgSend(CAMediaTimingFunction, "functionWithControlPoints::::", 0.0, 0.0, 0.58, 1.0), kCAMediaTimingFunctionEaseOut);
        objj_msgSend(CAMediaNamedTimingFunctions, "setObject:forKey:", objj_msgSend(CAMediaTimingFunction, "functionWithControlPoints::::", 0.42, 0.0, 0.58, 1.0), kCAMediaTimingFunctionEaseInEaseOut);
    }

    return objj_msgSend(CAMediaNamedTimingFunctions, "objectForKey:", aName);
}
});
class_methods[1] = new objj_method(sel_registerName("functionWithControlPoints::::"), function(self, _cmd, c1x, c1y, c2x, c2y)
{ with(self)
{
    return objj_msgSend(objj_msgSend(self, "alloc"), "initWithControlPoints::::", c1x, c1y, c2x, c2y);
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithControlPoints::::"), function(self, _cmd, c1x, c1y, c2x, c2y)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
    {
        _c1x = c1x;
        _c1y = c1y;
        _c2x = c2x;
        _c2y = c2y;
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("getControlPointAtIndex:values:"), function(self, _cmd, anIndex, reference)
{ with(self)
{
    if (anIndex == 0)
    {
        reference[0] = 0;
        reference[1] = 0;
    }
    else if (anIndex == 1)
    {
        reference[0] = _c1x;
        reference[1] = _c1y;
    }
    else if (anIndex == 2)
    {
        reference[0] = _c2x;
        reference[1] = _c2y;
    }
    else
    {
        reference[0] = 1.0;
        reference[0] = 1.0;
    }
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

p;19;CGAffineTransform.ji;12;CGGeometry.jc;4830;
CGAffineTransformMake= function(a, b, c, d, tx, ty) { return { a:a, b:b, c:c, d:d, tx:tx, ty:ty }; }
CGAffineTransformMakeIdentity= function() { return { a:1.0, b:0.0, c:0.0, d:1.0, tx:0.0, ty:0.0 }; }
CGAffineTransformMakeCopy= function(anAffineTransform) { return { a:anAffineTransform.a, b:anAffineTransform.b, c:anAffineTransform.c, d:anAffineTransform.d, tx:anAffineTransform.tx, ty:anAffineTransform.ty }; }
CGAffineTransformMakeScale= function(sx, sy) { return { a:sx, b:0.0, c:0.0, d:sy, tx:0.0, ty:0.0 }; }
CGAffineTransformMakeTranslation= function(tx, ty) { return { a:1.0, b:0.0, c:0.0, d:1.0, tx:tx, ty:ty }; }
CGAffineTransformTranslate= function(aTransform, tx, ty) { return { a:aTransform.a, b:aTransform.b, c:aTransform.c, d:aTransform.d, tx:aTransform.tx + aTransform.a * tx + aTransform.c * ty, ty:aTransform.ty + aTransform.b * tx + aTransform.d * ty }; }
CGAffineTransformScale= function(aTransform, sx, sy) { return { a:aTransform.a * sx, b:aTransform.b * sx, c:aTransform.c * sy, d:aTransform.d * sy, tx:aTransform.tx, ty:aTransform.ty }; }
CGAffineTransformConcat= function(lhs, rhs) { return { a:lhs.a * rhs.a + lhs.b * rhs.c, b:lhs.a * rhs.b + lhs.b * rhs.d, c:lhs.c * rhs.a + lhs.d * rhs.c, d:lhs.c * rhs.b + lhs.d * rhs.d, tx:lhs.tx * rhs.a + lhs.ty * rhs.c + rhs.tx, ty:lhs.tx * rhs.b + lhs.ty * rhs.d + rhs.ty }; }
CGPointApplyAffineTransform= function(aPoint, aTransform) { return { x:aPoint.x * aTransform.a + aPoint.y * aTransform.c + aTransform.tx, y:aPoint.x * aTransform.b + aPoint.y * aTransform.d + aTransform.ty }; }
CGSizeApplyAffineTransform= function(aSize, aTransform) { return { width:aSize.width * aTransform.a + aSize.height * aTransform.c, height:aSize.width * aTransform.b + aSize.height * aTransform.d }; }
CGAffineTransformIsIdentity= function(aTransform) { return (aTransform.a == 1 && aTransform.b == 0 && aTransform.c == 0 && aTransform.d == 1 && aTransform.tx == 0 && aTransform.ty == 0); }
CGAffineTransformEqualToTransform= function(lhs, rhs) { return (lhs.a == rhs.a && lhs.b == rhs.b && lhs.c == rhs.c && lhs.d == rhs.d && lhs.tx == rhs.tx && lhs.ty == rhs.ty); }
CGStringCreateWithCGAffineTransform= function(aTransform) { return (" [[ " + aTransform.a + ", " + aTransform.b + ", 0 ], [ " + aTransform.c + ", " + aTransform.d + ", 0 ], [ " + aTransform.tx + ", " + aTransform.ty + ", 1]]"); }
CGAffineTransformCreateCopy= function(aTransform)
{
    return { a:aTransform.a, b:aTransform.b, c:aTransform.c, d:aTransform.d, tx:aTransform.tx, ty:aTransform.ty };
}
CGAffineTransformMakeRotation= function(anAngle)
{
    var sin = SIN(anAngle),
        cos = COS(anAngle);
    return { a:cos, b:sin, c:-sin, d:cos, tx:0.0, ty:0.0 };
}
CGAffineTransformRotate= function(aTransform, anAngle)
{
    var sin = SIN(anAngle),
        cos = COS(anAngle);
    return {
            a:aTransform.a * cos + aTransform.c * sin,
            b:aTransform.b * cos + aTransform.d * sin,
            c:aTransform.c * cos - aTransform.a * sin,
            d:aTransform.d * cos - aTransform.b * sin,
            tx:aTransform.tx,
            ty:aTransform.ty
        };
}
CGAffineTransformInvert= function(aTransform)
{
    var determinant = 1 / (aTransform.a * aTransform.d - aTransform.b * aTransform.c);
    return {
        a:determinant * aTransform.d,
        b:-determinant * aTransform.b,
        c:-determinant * aTransform.c,
        d:determinant * aTransform.a,
        tx:determinant * (aTransform.c * aTransform.ty - aTransform.d * aTransform.tx),
        ty:determinant * (aTransform.b * aTransform.tx - aTransform.a * aTransform.ty)
    };
}
CGRectApplyAffineTransform= function(aRect, anAffineTransform)
{
    var top = (aRect.origin.y),
        left = (aRect.origin.x),
        right = (aRect.origin.x + aRect.size.width),
        bottom = (aRect.origin.y + aRect.size.height),
        topLeft = CGPointApplyAffineTransform({ x:left, y:top }, anAffineTransform),
        topRight = CGPointApplyAffineTransform({ x:right, y:top }, anAffineTransform),
        bottomLeft = CGPointApplyAffineTransform({ x:left, y:bottom }, anAffineTransform),
        bottomRight = CGPointApplyAffineTransform({ x:right, y:bottom }, anAffineTransform),
        minX = MIN(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x),
        maxX = MAX(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x),
        minY = MIN(topLeft.y, topRight.y, bottomLeft.y, bottomRight.y),
        maxY = MAX(topLeft.y, topRight.y, bottomLeft.y, bottomRight.y);
    return { origin: { x:minX, y:minY }, size: { width:(maxX - minX), height:(maxY - minY) } };
}
CPStringFromCGAffineTransform= function(anAffineTransform)
{
    return '{' + anAffineTransform.a + ", " + anAffineTransform.b + ", " + anAffineTransform.c + ", " + anAffineTransform.d + ", " + anAffineTransform.tx + ", " + anAffineTransform.ty + '}';
}

p;9;CGColor.ji;14;CGColorSpace.jc;3055;


var CFTypeGlobalCount = 0;

CFHashCode= function(aCFObject)
{
    if (!aCFObject.hash)
        aCFObject.hash = ++CFTypeGlobalCount;

    return aCFObject;
}

kCGColorWhite = "kCGColorWhite";
kCGColorBlack = "kCGColorBlack";
kCGColorClear = "kCGColorClear";

var _CGColorMap = { };

CGColorGetConstantColor= function(aColorName)
{
    alert("FIX ME");
}

CGColorRetain= function(aColor)
{
    return aColor;
}

CGColorRelease= function()
{
}

CGColorCreate= function(aColorSpace, components)
{
    if (!aColorSpace || !components)
        return NULL;

    var components = components.slice();

    CGColorSpaceStandardizeComponents(aColorSpace, components);

    var UID = CFHashCode(aColorSpace) + components.join("");

    if (_CGColorMap[UID])
        return _CGColorMap[UID];

    return _CGColorMap[UID] = { colorspace:aColorSpace, pattern:NULL, components:components };
}

CGColorCreateCopy= function(aColor)
{

    return aColor;
}

CGColorCreateGenericGray= function(gray, alpha)
{
    return CGColorCreate(0, [gray,alpha]);
}

CGColorCreateGenericRGB= function(red, green, blue, alpha)
{
    return CGColorCreate(0, [red,green,blue,alpha]);
}

CGColorCreateGenericCMYK= function(cyan, magenta, yellow, black, alpha)
{
    return CGColorCreate(0, [cyan,magenta,yellow,black,alpha]);
}

CGColorCreateCopyWithAlpha= function(aColor, anAlpha)
{
    var components = aColor.components;

    if (!aColor || anAlpha == components[components.length-1])
     return aColor;

    if (aColor.pattern)
        var copy = CGColorCreateWithPattern(aColor.colorspace, aColor.pattern, components);
    else
        var copy = CGColorCreate(aColor.colorspace, components);

    copy.components[components.length-1] = anAlpha;

    return copy;
}

CGColorCreateWithPattern= function(aColorSpace, aPattern, components)
{
    if (!aColorSpace || !aPattern || !components)
        return NULL;

    return { colorspace:aColorSpace, pattern:aPattern, components:components.slice() };
}

CGColorEqualToColor= function(lhs, rhs)
{
    if (lhs == rhs)
        return true;

    if (!lhs || !rhs)
        return false;

    var lhsComponents = lhs.components,
        rhsComponents = rhs.components,
        lhsComponentCount = lhsComponents.length;

    if (lhsComponentCount != rhsComponents.length)
        return false;

    while (lhsComponentCount--)
        if (lhsComponents[lhsComponentCount] != rhsComponents[lhsComponentCount])
            return false;

    if (lhs.pattern != rhs.pattern)
        return false;

    if (CGColorSpaceEqualToColorSpace(lhs.colorspace, rhs.colorspace))
        return false;

    return true;
}

CGColorGetAlpha= function(aColor)
{
    var components = aColor.components;

    return components[components.length-1];
}

CGColorGetColorSpace= function(aColor)
{
    return aColor.colorspace;
}

CGColorGetComponents= function(aColor)
{
    return aColor.components;
}

CGColorGetNumberOfComponents= function(aColor)
{
    return aColor.components.length;
}

CGColorGetPattern= function(aColor)
{
    return aColor.pattern;
}

p;14;CGColorSpace.jc;4713;



kCGColorSpaceModelUnknown = -1;
kCGColorSpaceModelMonochrome = 0;
kCGColorSpaceModelRGB = 1;
kCGColorSpaceModelCMYK = 2;
kCGColorSpaceModelLab = 3;
kCGColorSpaceModelDeviceN = 4;
kCGColorSpaceModelIndexed = 5;
kCGColorSpaceModelPattern = 6;

kCGColorSpaceGenericGray = "CGColorSpaceGenericGray";
kCGColorSpaceGenericRGB = "CGColorSpaceGenericRGB";
kCGColorSpaceGenericCMYK = "CGColorSpaceGenericCMYK";
kCGColorSpaceGenericRGBLinear = "CGColorSpaceGenericRGBLinear";
kCGColorSpaceGenericRGBHDR = "CGColorSpaceGenericRGBHDR";
kCGColorSpaceAdobeRGB1998 = "CGColorSpaceAdobeRGB1998";
kCGColorSpaceSRGB = "CGColorSpaceSRGB";

var _CGNamedColorSpaces = {};




CGColorSpaceCreateCalibratedGray= function(aWhitePoint, aBlackPoint, gamma)
{
    return { model:kCGColorSpaceModelMonochrome, count:1, base:NULL };
}

CGColorSpaceCreateCalibratedRGB= function(aWhitePoint, aBlackPoint, gamma)
{
    return { model:kCGColorSpaceModelRGB, count:1, base:NULL };
}

CGColorSpaceCreateICCBased= function(aComponentCount, range, profile, alternate)
{

    return NULL;
}

CGColorSpaceCreateLab= function(aWhitePoint, aBlackPoint, aRange)
{

    return NULL;
}

CGColorSpaceCreateDeviceCMYK= function()
{
    return CGColorSpaceCreateWithName(kCGColorSpaceGenericCMYK);
}

CGColorSpaceCreateDeviceGray= function()
{
    return CGColorSpaceCreateWithName(kCGColorSpaceGenericGray);
}

CGColorSpaceCreateDeviceRGB= function()
{
    return CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
}

CGColorSpaceCreateWithPlatformColorSpace= function()
{

    return NULL;
}

CGColorSpaceCreateIndexed= function(aBaseColorSpace, lastIndex, colorTable)
{

    return NULL;
}

CGColorSpaceCreatePattern= function(aBaseColorSpace)
{
    if (aBaseColorSpace)
        return { model:kCGColorSpaceModelPattern, count:aBaseColorSpace.count, base:aBaseColorSpace };

    return { model:kCGColorSpaceModelPattern, count:0, base:NULL };
}

CGColorSpaceCreateWithName= function(aName)
{
    var colorSpace = _CGNamedColorSpaces[aName];

    if (colorSpace)
        return colorSpace;

    switch (aName)
    {
        case kCGColorSpaceGenericGray: return _CGNamedColorSpaces[aName] = { model:kCGColorSpaceModelMonochrome, count:1, base:NULL };
        case kCGColorSpaceGenericRGB: return _CGNamedColorSpaces[aName] = { model:kCGColorSpaceModelRGB, count:3, base:NULL };
        case kCGColorSpaceGenericCMYK: return _CGNamedColorSpaces[aName] = { model:kCGColorSpaceModelCMYK, count:4, base:NULL };
        case kCGColorSpaceGenericRGBLinear: return _CGNamedColorSpaces[aName] = { model:kCGColorSpaceModelRGB, count:3, base:NULL };
        case kCGColorSpaceGenericRGBHDR: return _CGNamedColorSpaces[aName] = { model:kCGColorSpaceModelRGB, count:3, base:NULL };
        case kCGColorSpaceAdobeRGB1998: return _CGNamedColorSpaces[aName] = { model:kCGColorSpaceModelRGB, count:3, base:NULL };
        case kCGColorSpaceSRGB: return _CGNamedColorSpaces[aName] = { model:kCGColorSpaceModelRGB, count:3, base:NULL };
    }

    return NULL;
}



CGColorSpaceCopyICCProfile= function(aColorSpace)
{
    return NULL;
}

CGColorSpaceGetNumberOfComponents= function(aColorSpace)
{
    return aColorSpace.count;
}

CGColorSpaceGetTypeID= function(aColorSpace)
{
}

CGColorSpaceGetModel= function(aColorSpace)
{
    return aColorSpace.model;
}

CGColorSpaceGetBaseColorSpace= function(aColorSpace)
{
}

CGColorSpaceGetColorTableCount= function(aColorSpace)
{
}

CGColorSpaceGetColorTable= function(aColorSpace)
{
}



CGColorSpaceRelease= function(aColorSpace)
{
}

CGColorSpaceRetain= function(aColorSpace)
{
    return aColorSpace;
}
CGColorSpaceStandardizeComponents= function(aColorSpace, components)
{
    var count = aColorSpace.count;
    { if (count > components.length) { components[count] = 1; return; } var component = components[count]; if (component < 0) components[count] = 0; else if (component > 1) components[count] = 1; else components[count] = ROUND(component * 1000) / 1000; };
    if (aColorSpace.base)
        aColorSpace = aColorSpace.base;
    switch (aColorSpace.model)
    {
        case kCGColorSpaceModelMonochrome:
        case kCGColorSpaceModelRGB:
        case kCGColorSpaceModelCMYK:
        case kCGColorSpaceModelDeviceN: while (count--)
                                                { if (count > components.length) { components[count] = 1; return; } var component = components[count]; if (component < 0) components[count] = 0; else if (component > 1) components[count] = 1; else components[count] = ROUND(component * 255) / 255; };
                                            break;
        case kCGColorSpaceModelIndexed:
        case kCGColorSpaceModelLab:
        case kCGColorSpaceModelPattern: break;
    }
}

p;11;CGContext.ji;12;CGGeometry.ji;19;CGAffineTransform.ji;8;CGPath.jc;30758;

kCGLineCapButt = 0;
kCGLineCapRound = 1;
kCGLineCapSquare = 2;

kCGLineJoinMiter = 0;
kCGLineJoinRound = 1;
kCGLineJoinBevel = 2;

kCGPathFill = 0;
kCGPathEOFill = 1;
kCGPathStroke = 2;
kCGPathFillStroke = 3;
kCGPathEOFillStroke = 4;

kCGBlendModeNormal = 0;
kCGBlendModeMultiply = 1;
kCGBlendModeScreen = 2;
kCGBlendModeOverlay = 3;
kCGBlendModeDarken = 4;
kCGBlendModeLighten = 5;
kCGBlendModeColorDodge = 6;
kCGBlendModeColorBurn = 7;
kCGBlendModeSoftLight = 8;
kCGBlendModeHardLight = 9;
kCGBlendModeDifference = 10;
kCGBlendModeExclusion = 11;
kCGBlendModeHue = 12;
kCGBlendModeSaturation = 13;
kCGBlendModeColor = 14;
kCGBlendModeLuminosity = 15;
kCGBlendModeClear = 16;
kCGBlendModeCopy = 17;
kCGBlendModeSourceIn = 18;
kCGBlendModeSourceOut = 19;
kCGBlendModeSourceAtop = 20;
kCGBlendModeDestinationOver = 21;
kCGBlendModeDestinationIn = 22;
kCGBlendModeDestinationOut = 23;
kCGBlendModeDestinationAtop = 24;
kCGBlendModeXOR = 25;
kCGBlendModePlusDarker = 26;
kCGBlendModePlusLighter = 27;

CGContextRelease= function()
{
}

CGContextRetain= function(aContext)
{
    return aContext;
}

if (!CPFeatureIsCompatible(CPHTMLCanvasFeature))
{

CGGStateCreate= function()
{
    return { strokeStyle:"#000", fillStyle:"#ccc", lineWidth:1.0, lineJoin:kCGLineJoinMiter, lineCap:kCGLineCapButt, miterLimit:10.0, globalAlpha:1.0,
        blendMode:kCGBlendModeNormal,
        shadowOffset:{ width:0.0, height:0.0 }, shadowBlur:0.0, shadowColor:NULL, CTM:{ a:1.0, b:0.0, c:0.0, d:1.0, tx:0.0, ty:0.0 } };
}

CGGStateCreateCopy= function(aGState)
{
    return { strokeStyle:aGState.strokeStyle, fillStyle:aGState.fillStyle, lineWidth:aGState.lineWidth,
        lineJoin:aGState.lineJoin, lineCap:aGState.lineCap, miterLimit:aGState.miterLimit, globalAlpha:aGState.globalAlpha,
        blendMode:aGState.blendMode,
        shadowOffset:aGState.shadowOffset, shadowBlur:aGState.shadowBlur, shadowColor:aGState.shadowColor, CTM:{ a:aGState.CTM.a, b:aGState.CTM.b, c:aGState.CTM.c, d:aGState.CTM.d, tx:aGState.CTM.tx, ty:aGState.CTM.ty } };
}

CGBitmapGraphicsContextCreate= function()
{
    return { DOMElement:document.createElement("div"), path:NULL, gState:CGGStateCreate(), gStateStack:[] };
}

CGContextSaveGState= function(aContext)
{
    aContext.gStateStack.push(CGGStateCreateCopy(aContext.gState));
}

CGContextRestoreGState= function(aContext)
{
    aContext.gState = aContext.gStateStack.pop();
}

CGContextSetLineCap= function(aContext, aLineCap)
{
    aContext.gState.lineCap = aLineCap;
}

CGContextSetLineJoin= function(aContext, aLineJoin)
{
    aContext.gState.lineJoin = aLineJoin;
}

CGContextSetLineWidth= function(aContext, aLineWidth)
{
    aContext.gState.lineWidth = aLineWidth;
}

CGContextSetMiterLimit= function(aContext, aMiterLimit)
{
    aContext.gState.miterLimit = aMiterLimit;
}

CGContextSetBlendMode= function(aContext, aBlendMode)
{
    aContext.gState.blendMode = aBlendMode;
}

CGContextAddArc= function(aContext, x, y, radius, startAngle, endAngle, clockwise)
{
    CGPathAddArc(aContext.path, aContext.gState.CTM, x, y, radius, startAngle, endAngle, clockwise);
}

CGContextAddArcToPoint= function(aContext, x1, y1, x2, y2, radius)
{
    CGPathAddArcToPoint(aContext.path, aContext.gState.CTM, x1, y1, x2, y2, radius);
}

CGContextAddCurveToPoint= function(aContext, cp1x, cp1y, cp2x, cp2y, x, y)
{
    CGPathAddCurveToPoint(aContext.path, cp1x, cp1y, cp2x, cp2y, x, y);
}

CGContextAddLines= function(aContext, points, count)
{
    CGPathAddLines(aContext.path, aContext.gState.CTM, points, count);
}

CGContextAddLineToPoint= function(aContext, x, y)
{
    CGPathAddLineToPoint(aContext.path, aContext.gState.CTM, x, y);
}

CGContextAddPath= function(aContext, aPath)
{
    if (!aContext || CGPathIsEmpty(aPath))
        return;

    if (!aContext.path)
        aContext.path = CGPathCreateMutable();

    CGPathAddPath(aContext.path, aContext.gState.CTM, aPath);
}

CGContextAddQuadCurveToPoint= function(aContext, cpx, cpy, x, y)
{
    CGPathAddQuadCurveToPoint(aContext.path, aContext.gState.CTM, cpx, cpy, x, y);
}

CGContextAddRect= function(aContext, aRect)
{
    CGPathAddRect(aContext.path, aContext.gState.CTM, aRect);
}

CGContextAddRects= function(aContext, rects, count)
{
    CGPathAddRects(aContext.path, aContext.gState.CTM, rects, count);
}

CGContextBeginPath= function(aContext)
{

    aContext.path = CGPathCreateMutable();
}

CGContextClosePath= function(aContext)
{
    CGPathCloseSubpath(aContext.path);
}

CGContextMoveToPoint= function(aContext, x, y)
{
    if (!aContext.path)
        aContext.path = CGPathCreateMutable();

    CGPathMoveToPoint(aContext.path, aContext.gState.CTM, x, y);
}

CGContextFillRect= function(aContext, aRect)
{
    CGContextFillRects(aContext, [aRect], 1);
}

CGContextFillRects= function(aContext, rects, count)
{
    if (arguments["count"] == NULL)
        var count = rects.length;

    CGContextBeginPath(aContext);
    CGContextAddRects(aContext, rects, count);
    CGContextClosePath(aContext);

    CGContextDrawPath(aContext, kCGPathFill);
}

CGContextStrokeRect= function(aContext, aRect)
{
    CGContextBeginPath(aContext);
    CGContextAddRect(aContext, aRect);
    CGContextClosePath(aContext);

    CGContextDrawPath(aContext, kCGPathStroke);
}

CGContextStrokeRectWithWidth= function(aContext, aRect, aWidth)
{
    CGContextSaveGState(aContext);

    CGContextSetLineWidth(aContext, aWidth);
    CGContextStrokeRect(aContext, aRect);

    CGContextRestoreGState(aContext);
}

CGContextConcatCTM= function(aContext, aTransform)
{
    var CTM = aContext.gState.CTM;

    var tx = CTM.tx * aTransform.a + CTM.ty * aTransform.c + aTransform.tx;CTM.ty = CTM.tx * aTransform.b + CTM.ty * aTransform.d + aTransform.ty;CTM.tx = tx;var a = CTM.a * aTransform.a + CTM.b * aTransform.c, b = CTM.a * aTransform.b + CTM.b * aTransform.d, c = CTM.c * aTransform.a + CTM.d * aTransform.c;CTM.d = CTM.c * aTransform.b + CTM.d * aTransform.d;CTM.a = a;CTM.b = b;CTM.c = c;;
}

CGContextGetCTM= function(aContext)
{
    return aContext.gState.CTM;
}

CGContextRotateCTM= function(aContext, anAngle)
{
    var gState = aContext.gState;

    gState.CTM = CGAffineTransformRotate(gState.CTM, anAngle);
}

CGContextScaleCTM= function(aContext, sx, sy)
{
    var gState = aContext.gState;

    gState.CTM = { a:gState.CTM.a * sx, b:gState.CTM.b * sx, c:gState.CTM.c * sy, d:gState.CTM.d * sy, tx:gState.CTM.tx, ty:gState.CTM.ty };
}

CGContextTranslateCTM= function(aContext, tx, ty)
{
    var gState = aContext.gState;

    gState.CTM = { a:gState.CTM.a, b:gState.CTM.b, c:gState.CTM.c, d:gState.CTM.d, tx:gState.CTM.tx + gState.CTM.a * tx + gState.CTM.c * ty, ty:gState.CTM.ty + gState.CTM.b * tx + gState.CTM.d * ty };
}

CGContextSetShadow= function(aContext, aSize, aBlur)
{
    var gState = aContext.gState;

    gState.shadowOffset = { width:aSize.width, height:aSize.height };
    gState.shadowBlur = aBlur;
    gState.shadowColor = objj_msgSend(CPColor, "shadowColor");
}

CGContextSetShadowWithColor= function(aContext, aSize, aBlur, aColor)
{
    var gState = aContext.gState;

    gState.shadowOffset = { width:aSize.width, height:aSize.height };
    gState.shadowBlur = aBlur;
    gState.shadowColor = aColor;
}

}



CGContextEOFillPath= function(aContext, aMode)
{
    CGContextDrawPath(aContext, kCGPathEOFill);
}

CGContextFillPath= function(aContext)
{
    CGContextDrawPath(aContext, kCGPathFill);
}

var KAPPA = 4.0 * ((SQRT2 - 1.0) / 3.0);

CGContextAddEllipseInRect= function(aContext, aRect)
{
 CGContextBeginPath(aContext);

 if ((aRect.size.width) == (aRect.size.height))
     CGContextAddArc(aContext, (aRect.origin.x + (aRect.size.width) / 2.0), (aRect.origin.y + (aRect.size.height) / 2.0), (aRect.size.width) / 2.0, 0.0, 2 * PI, YES);
 else
 {
     var axis = { width:(aRect.size.width) / 2.0, height:(aRect.size.height) / 2.0 },
         center = { x:(aRect.origin.x) + axis.width, y:(aRect.origin.y) + axis.height };

     CGContextMoveToPoint(aContext, center.x, center.y - axis.height);

     CGContextAddCurveToPoint(aContext, center.x + (KAPPA * axis.width), center.y - axis.height, center.x + axis.width, center.y - (KAPPA * axis.height), center.x + axis.width, center.y);
     CGContextAddCurveToPoint(aContext, center.x + axis.width, center.y + (KAPPA * axis.height), center.x + (KAPPA * axis.width), center.y + axis.height, center.x, center.y + axis.height);
     CGContextAddCurveToPoint(aContext, center.x - (KAPPA * axis.width), center.y + axis.height, center.x - axis.width, center.y + (KAPPA * axis.height), center.x - axis.width, center.y);
     CGContextAddCurveToPoint(aContext, center.x - axis.width, center.y - (KAPPA * axis.height), center.x - (KAPPA * axis.width), center.y - axis.height, center.x, center.y - axis.height);
 }

 CGContextClosePath(aContext);
}


CGContextFillEllipseInRect= function(aContext, aRect)
{
    CGContextAddEllipseInRect(aContext, aRect);
    CGContextFillPath(aContext);
}

CGContextStrokeEllipseInRect= function(aContext, aRect)
{
    CGContextAddEllipseInRect(aContext, aRect);
    CGContextStrokePath(aContext);
}

CGContextStrokePath= function(aContext)
{
    CGContextDrawPath(aContext, kCGPathStroke);
}

CGContextStrokeLineSegments= function(aContext, points, count)
{
    var i = 0;

    if (arguments["count"] == NULL)
        var count = points.length;

    CGContextBeginPath(aContext);

    for (; i < count; i += 2)
    {
        CGContextMoveToPoint(aContext, points[i].x, points[i].y);
        CGContextAddLineToPoint(aContext, points[i+1].x, points[i+1].y);
    }

    CGContextStrokePath(aContext);
}



CGContextSetFillColor= function(aContext, aColor)
{
    if (aColor)
        aContext.gState.fillStyle = objj_msgSend(aColor, "cssString");
}

CGContextSetStrokeColor= function(aContext, aColor)
{
    if (aColor)
        aContext.gState.strokeStyle = objj_msgSend(aColor, "cssString");
}

CGContextFillRoundedRectangleInRect= function(aContext, aRect, aRadius, ne, se, sw, nw)
{
    var xMin = (aRect.origin.x),
        xMax = (aRect.origin.x + aRect.size.width),
        yMin = (aRect.origin.y),
        yMax = (aRect.origin.y + aRect.size.height);

    CGContextBeginPath(aContext);
    CGContextMoveToPoint(aContext, xMin + aRadius, yMin);

 if (ne)
 {
  CGContextAddLineToPoint(aContext, xMax - aRadius, yMin);
  CGContextAddCurveToPoint(aContext, xMax - aRadius, yMin, xMax, yMin, xMax, yMin + aRadius);
 }
 else
  CGContextAddLineToPoint(aContext, xMax, yMin);

 if (se)
 {
  CGContextAddLineToPoint(aContext, xMax, yMax - aRadius);
  CGContextAddCurveToPoint(aContext, xMax, yMax - aRadius, xMax, yMax, xMax - aRadius, yMax);
 }
 else
  CGContextAddLineToPoint(aContext, xMax, yMax);

 if (sw)
 {
  CGContextAddLineToPoint(aContext, xMin + aRadius, yMax);
  CGContextAddCurveToPoint(aContext, xMin + aRadius, yMax, xMin, yMax, xMin, yMax - aRadius);
 }
 else
  CGContextAddLineToPoint(aContext, xMin, yMax);

 if (nw)
 {
  CGContextAddLineToPoint(aContext, xMin, yMin + aRadius);
  CGContextAddCurveToPoint(aContext, xMin, yMin + aRadius, xMin, yMin, xMin + aRadius, yMin);
 } else
  CGContextAddLineToPoint(aContext, xMin, yMin);

 CGContextClosePath(aContext);

    CGContextFillPath(aContext);
}

if (CPFeatureIsCompatible(CPHTMLCanvasFeature))
{
var CANVAS_LINECAP_TABLE = ["butt","round","square"],
    CANVAS_LINEJOIN_TABLE = ["miter","round","bevel"],
    CANVAS_COMPOSITE_TABLE = ["source-over","source-over","source-over","source-over","darker","lighter","source-over","source-over","source-over","source-over","source-over","source-over","source-over","source-over","source-over","source-over","source-over","copy","source-in","source-out","source-atop","destination-over","destination-in","destination-out","destination-atop","xor","source-over","source-over"];
CGContextSaveGState= function(aContext)
{
    aContext.save();
}
CGContextRestoreGState= function(aContext)
{
    aContext.restore();
}
CGContextSetLineCap= function(aContext, aLineCap)
{
    aContext.lineCap = CANVAS_LINECAP_TABLE[aLineCap];
}
CGContextSetLineJoin= function(aContext, aLineJoin)
{
    aContext.lineJoin = CANVAS_LINEJOIN_TABLE[aLineJoin];
}
CGContextSetLineWidth= function(aContext, aLineWidth)
{
    aContext.lineWidth = aLineWidth;
}
CGContextSetMiterLimit= function(aContext, aMiterLimit)
{
    aContext.miterLimit = aMiterLimit;
}
CGContextSetBlendMode= function(aContext, aBlendMode)
{
    aContext.globalCompositeOperation = CANVAS_COMPOSITE_TABLE[aBlendMode];
}
CGContextAddArc= function(aContext, x, y, radius, startAngle, endAngle, clockwise)
{
    aContext.arc(x, y, radius, startAngle, endAngle, !clockwise);
}
CGContextAddArcToPoint= function(aContext, x1, y1, x2, y2, radius)
{
    aContext.arcTo(x1, y1, x2, y2, radius);
}
CGContextAddCurveToPoint= function(aContext, cp1x, cp1y, cp2x, cp2y, x, y)
{
    aContext.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
}
CGContextAddLineToPoint= function(aContext, x, y)
{
    aContext.lineTo(x, y);
}
CGContextAddPath= function(aContext, aPath)
{
    if (!aContext || CGPathIsEmpty(aPath))
        return;
    var elements = aPath.elements,
        i = 0,
        count = aPath.count;
    for (; i < count; ++i)
    {
        var element = elements[i],
            type = element.type;
        switch (type)
        {
            case kCGPathElementMoveToPoint: aContext.moveTo(element.x, element.y);
                                                    break;
            case kCGPathElementAddLineToPoint: _CGContextLineToPoint(aContext, element.x, element.y);
                                                    break;
            case kCGPathElementAddQuadCurveToPoint: _CGContextAddQuadCurveToPoint(aContext, element.cpx, element.cpy, element.x, element.y);
                                                    break;
            case kCGPathElementAddCurveToPoint: aContext.bezierCurveTo(element.cp1x, element.cp1y, element.cp2x, element.cp2y, element.x, element.y);
                                                    break;
            case kCGPathElementCloseSubpath: aContext.closePath();
                                                    break;
            case kCGPathElementAddArc: aContext.arc(element.x, element.y, element.radius, element.startAngle, element.endAngle, element.clockwise);
                                                    break;
            case kCGPathElementAddArcTo:
                                                    break;
        }
    }
}
CGContextAddRect= function(aContext, aRect)
{
    aContext.rect((aRect.origin.x), (aRect.origin.y), (aRect.size.width), (aRect.size.height));
}
CGContextAddRects= function(aContext, rects, count)
{
    var i = 0;
    if (arguments["count"] == NULL)
        var count = rects.length;
    for (; i < count; ++i)
    {
        var rect = rects[i];
        aContext.rect((rect.origin.x), (rect.origin.y), (rect.size.width), (rect.size.height));
    }
}
CGContextBeginPath= function(aContext)
{
    aContext.beginPath();
}
CGContextClosePath= function(aContext)
{
    aContext.closePath();
}
CGContextMoveToPoint= function(aContext, x, y)
{
    aContext.moveTo(x, y);
}
CGContextClearRect= function(aContext, aRect)
{
    aContext.clearRect((aRect.origin.x), (aRect.origin.y), (aRect.size.width), (aRect.size.height));
}
CGContextDrawPath= function(aContext, aMode)
{
    if (aMode == kCGPathFill || aMode == kCGPathFillStroke)
        aContext.fill();
    else if (aMode == kCGPathEOFill || aMode == kCGPathEOFillStroke)
        alert("not implemented!!!");
    if (aMode == kCGPathStroke || aMode == kCGPathFillStroke || aMode == kCGPathEOFillStroke)
        aContext.stroke();
}
CGContextFillRect= function(aContext, aRect)
{
    aContext.fillRect((aRect.origin.x), (aRect.origin.y), (aRect.size.width), (aRect.size.height));
}
CGContextFillRects= function(aContext, rects, count)
{
    var i = 0;
    if (arguments["count"] == NULL)
        var count = rects.length;
    for (; i < count; ++i)
    {
        var rect = rects[i];
        aContext.fillRect((rect.origin.x), (rect.origin.y), (rect.size.width), (rect.size.height));
    }
}
CGContextStrokeRect= function(aContext, aRect)
{
    aContext.strokeRect((aRect.origin.x), (aRect.origin.y), (aRect.size.width), (aRect.size.height));
}
CGContextClip= function(aContext)
{
    aContext.clip();
}
CGContextClipToRect= function(aContext, aRect)
{
    aContext.beginPath();
    aContext.rect((aRect.origin.x), (aRect.origin.y), (aRect.size.width), (aRect.size.height));
    aContext.closePath();
    aContext.clip();
}
CGContextClipToRects= function(aContext, rects, count)
{
    if (arguments["count"] == NULL)
        var count = rects.length;
    aContext.beginPath();
    CGContextAddRects(aContext, rects, count);
    aContext.clip();
}
CGContextSetAlpha= function(aContext, anAlpha)
{
    aContext.globalAlpha = anAlpha;
}
CGContextSetFillColor= function(aContext, aColor)
{
    aContext.fillStyle = objj_msgSend(aColor, "cssString");
}
CGContextSetStrokeColor= function(aContext, aColor)
{
    aContext.strokeStyle = objj_msgSend(aColor, "cssString");
}
CGContextSetShadow= function(aContext, aSize, aBlur)
{
    aContext.shadowOffsetX = aSize.width;
    aContext.shadowOffsetY = aSize.height;
    aContext.shadowBlur = aBlur;
}
CGContextSetShadowWithColor= function(aContext, aSize, aBlur, aColor)
{
    aContext.shadowOffsetX = aSize.width;
    aContext.shadowOffsetY = aSize.height;
    aContext.shadowBlur = aBlur;
    aContext.shadowColor = objj_msgSend(aColor, "cssString");
}
CGContextRotateCTM= function(aContext, anAngle)
{
    aContext.rotate(anAngle);
}
CGContextScaleCTM= function(aContext, sx, sy)
{
    aContext.scale(sx, sy);
}
CGContextTranslateCTM= function(aContext, tx, ty)
{
    aContext.translate(tx, ty);
}
eigen= function(anAffineTransform)
{
    alert("IMPLEMENT ME!");
}
CGContextConcatCTM= function(aContext, anAffineTransform)
{
    var a = anAffineTransform.a,
        b = anAffineTransform.b,
        c = anAffineTransform.c,
        d = anAffineTransform.d,
        tx = anAffineTransform.tx,
        ty = anAffineTransform.ty,
        sx = 1.0,
        sy = 1.0,
        a1 = 0.0,
        a2 = 0.0;
    if (b == 0.0 && c == 0.0)
    {
        sx = a;
        sy = d;
    }
    else if (a * b == -c * d)
    {
        var sign = (a * d < 0.0 || b * c > 0.0) ? -1.0 : 1.0, a2 = (ATAN2(b, d) + ATAN2(-sign * c, sign * a)) / 2.0, cos = COS(a2), sin = SIN(a2); if (cos == 0) { sx = -c / sin; sy = b / sin; } else if (sin == 0) { sx = a / cos; sy = d / cos; } else { abs_cos = ABS(cos); abs_sin = ABS(sin); sx = (abs_cos * a / cos + abs_sin * -c / sin) / (abs_cos + abs_sin); sy = (abs_cos * d / cos + abs_sin * b / sin) / (abs_cos + abs_sin); }
    }
    else if (a * c == -b * d)
    {
        var sign = (a * d < 0.0 || b * c > 0.0) ? -1.0 : 1.0; a1 = (Math.atan2(sign * b, sign * a) + Math.atan2(-c, d)) / 2.0, cos = COS(a1), sin = SIN(a1); if (cos == 0) { sx = b / sin; sy = -c / sin; } else if (sin == 0) { sx = a / cos; sy = d / cos; } else { abs_cos = ABS(cos); abs_sin = ABS(sin); sx = (abs_cos * a / cos + abs_sin * b / sin) / (abs_cos + abs_sin); sy = (abs_cos * d / cos + abs_sin * -c / sin) / (abs_cos + abs_sin); }
    }
    else
    {
        var transpose = CGAffineTransformMake(a, c, b, d, 0.0, 0.0),
            u = eigen(CGAffineTransformConcat(anAffineTransform, transpose)),
            v = eigen(CGAffineTransformConcat(transpose, anAffineTransform)),
            U = CGAffineTransformMake(u.vector_1.x, u.vector_2.x, u.vector_1.y, u.vector_2.y, 0.0, 0.0),
            VT = CGAffineTransformMake(v.vector_1.x, v.vector_1.y, v.vector_2.x, v.vector_2.y, 0.0, 0.0),
            S = CGAffineTransformConcat(CGAffineTransformConcat(CGAffineTransformInvert(U), anAffineTransform), CGAffineTransformInvert(VT));
        a = VT.a;
        b = VT.b;
        c = VT.c;
        d = VT.d;
        var sign = (a * d < 0.0 || b * c > 0.0) ? -1.0 : 1.0, a2 = (ATAN2(b, d) + ATAN2(-sign * c, sign * a)) / 2.0, cos = COS(a2), sin = SIN(a2); if (cos == 0) { sx = -c / sin; sy = b / sin; } else if (sin == 0) { sx = a / cos; sy = d / cos; } else { abs_cos = ABS(cos); abs_sin = ABS(sin); sx = (abs_cos * a / cos + abs_sin * -c / sin) / (abs_cos + abs_sin); sy = (abs_cos * d / cos + abs_sin * b / sin) / (abs_cos + abs_sin); }
        S.a *= sx;
        S.d *= sy;
        a = U.a;
        b = U.b;
        c = U.c;
        d = U.d;
        var sign = (a * d < 0.0 || b * c > 0.0) ? -1.0 : 1.0; a1 = (Math.atan2(sign * b, sign * a) + Math.atan2(-c, d)) / 2.0, cos = COS(a1), sin = SIN(a1); if (cos == 0) { sx = b / sin; sy = -c / sin; } else if (sin == 0) { sx = a / cos; sy = d / cos; } else { abs_cos = ABS(cos); abs_sin = ABS(sin); sx = (abs_cos * a / cos + abs_sin * b / sin) / (abs_cos + abs_sin); sy = (abs_cos * d / cos + abs_sin * -c / sin) / (abs_cos + abs_sin); }
        sx = S.a * sx;
        sy = S.d * sy;
    }
    if (tx != 0 || ty != 0)
        CGContextTranslateCTM(aContext, tx, ty);
    if (a1 != 0.0)
        CGContextRotateCTM(aContext, a1);
    if (sx != 1.0 || sy != 1.0)
        CGContextScaleCTM(aContext, sx, sy);
    if (a2 != 0.0)
        CGContextRotateCTM(aContext, a2);
}
CGContextDrawImage= function(aContext, aRect, anImage)
{
    aContext.drawImage(anImage._image, (aRect.origin.x), (aRect.origin.y), (aRect.size.width), (aRect.size.height));
}
to_string= function(aColor)
{
    return "rgba(" + ROUND(aColor.components[0] * 255) + ", " + ROUND(aColor.components[1] * 255) + ", " + ROUND(255 * aColor.components[2]) + ", " + aColor.components[3] + ")";
}
CGContextDrawLinearGradient= function(aContext, aGradient, aStartPoint, anEndPoint, options)
{
    var colors = aGradient.colors,
        count = colors.length,
        linearGradient = aContext.createLinearGradient(aStartPoint.x, aStartPoint.y, anEndPoint.x, anEndPoint.y);
    while (count--)
        linearGradient.addColorStop(aGradient.locations[count], to_string(colors[count]));
    aContext.fillStyle = linearGradient;
    aContext.fill();
}
CGBitmapGraphicsContextCreate= function()
{
    var DOMElement = document.createElement("canvas"),
        context = DOMElement.getContext("2d");
    context.DOMElement = DOMElement;
    return context;
}
}
else if (CPFeatureIsCompatible(CPVMLFeature))
{
var VML_TRUTH_TABLE = ["f","t"],
    VML_LINECAP_TABLE = ["flat","round","square"],
    VML_LINEJOIN_TABLE = ["miter","round","bevel"],
    VML_ELEMENT_TABLE = [" m "," l ","qb"," c "," x ",[" at "," wa "]];
var _CGBitmapGraphicsContextCreate = CGBitmapGraphicsContextCreate;
CGBitmapGraphicsContextCreate= function()
{
    document.namespaces.add("cg_vml_", "urn:schemas-microsoft-com:vml");
    document.createStyleSheet().cssText = "cg_vml_\\:*{behavior:url(#default#VML)}";
    CGBitmapGraphicsContextCreate = _CGBitmapGraphicsContextCreate;
    return _CGBitmapGraphicsContextCreate();
}
CGContextClearRect= function(aContext, aRect)
{
    if (aContext.buffer != nil)
        aContext.buffer = "";
    else
        aContext.DOMElement.innerHTML = "";
    aContext.path = NULL;
}
var W = 10.0,
    H = 10.0,
    Z = 10.0,
    Z_2 = Z / 2.0;
CGContextDrawImage= function(aContext, aRect, anImage)
{
    var string = "";
    if (anImage.buffer != nil)
        string = anImage.buffer;
    else
    {
        var ctm = aContext.gState.CTM,
            origin = CGPointApplyAffineTransform(aRect.origin, ctm),
            similarity = ctm.a == ctm.d && ctm.b == -ctm.c,
            vml = ["<cg_vml_:group coordsize=\"1,1\" coordorigin=\"0,0\" style=\"width:1;height:1;position:absolute"];
        {
            var transformedRect = CGRectApplyAffineTransform(aRect, ctm);
            vml.push( ";padding:0 ", ROUND((transformedRect.origin.x + transformedRect.size.width)), "px ", ROUND((transformedRect.origin.y + transformedRect.size.height)),
                        "px 0;filter:progid:DXImageTransform.Microsoft.Matrix(",
                        "M11='", ctm.a, "',M12='", ctm.c, "',M21='", ctm.b, "',M22='", ctm.d, "',",
                        "Dx='", ROUND(origin.x), "', Dy='", ROUND(origin.y), "', sizingmethod='clip');");
        }
        vml.push( "\"><cg_vml_:image src=\"", anImage._image.src,
                    "\" style=\"width:", (aRect.size.width), "px;height:", (aRect.size.height),
                    "px;\"/></g_vml_:group>");
        string = vml.join("");
    }
    if (aContext.buffer != nil)
        aContext.buffer += string;
    else
        aContext.DOMElement.insertAdjacentHTML("BeforeEnd", string);
}
CGContextDrawPath= function(aContext, aMode)
{
    if (!aContext || CGPathIsEmpty(aContext.path))
        return;
var opacity = 1.0;
    var elements = aContext.path.elements,
        i = 0,
        count = aContext.path.count,
        gState = aContext.gState,
        fill = (aMode == kCGPathFill || aMode == kCGPathFillStroke) ? 1 : 0,
        stroke = (aMode == kCGPathStroke || aMode == kCGPathFillStroke) ? 1 : 0,
        vml = ["<cg_vml_:shape"," fillcolor=\"",gState.fillStyle,"\" filled=\"",VML_TRUTH_TABLE[fill],"\" style=\"position:absolute;width:",W,";height:",H,";\" coordorigin=\"0 0\" coordsize=\"",Z*W," ",Z*H,"\" stroked=\"",VML_TRUTH_TABLE[stroke],"\" strokeweight=\"",gState.lineWidth,"\" strokecolor=\"",gState.strokeStyle,"\" path=\""];
    for (; i < count; ++i)
    {
        var element = elements[i],
            type = element.type;
        switch(type)
        {
            case kCGPathElementMoveToPoint:
            case kCGPathElementAddLineToPoint: vml.push(VML_ELEMENT_TABLE[type], (ROUND(Z * (element.x) - Z_2)), ',', (ROUND(Z * (element.y) - Z_2)));
                                                    break;
            case kCGPathElementAddQuadCurveToPoint: vml.push(VML_ELEMENT_TABLE[type],
                                                        (ROUND(Z * (element.cpx) - Z_2)), ',', (ROUND(Z * (element.cpy) - Z_2)), ',',
                                                        (ROUND(Z * (element.x) - Z_2)), ',', (ROUND(Z * (element.y) - Z_2)));
                                                    break;
            case kCGPathElementAddCurveToPoint: vml.push(VML_ELEMENT_TABLE[type],
                                                        (ROUND(Z * (element.cp1x) - Z_2)), ',', (ROUND(Z * (element.cp1y) - Z_2)), ',',
                                                        (ROUND(Z * (element.cp2x) - Z_2)), ',', (ROUND(Z * (element.cp2y) - Z_2)), ',',
                                                        (ROUND(Z * (element.x) - Z_2)), ',', (ROUND(Z * (element.y) - Z_2)));
                                                    break;
            case kCGPathElementCloseSubpath: vml.push(VML_ELEMENT_TABLE[type]);
                                                    break;
            case kCGPathElementAddArc: var x = element.x,
                                                        y = element.y,
                                                        radius = element.radius,
                                                        clockwise = element.clockwise ? 1 : 0,
                                                        endAngle = element.endAngle,
                                                        startAngle = element.startAngle,
                                                        start = { x:x + radius * COS(startAngle), y:y + radius * SIN(startAngle) };
                                                    if (startAngle == endAngle && !clockwise)
                                                    {
                                                        vml.push(VML_ELEMENT_TABLE[kCGPathElementMoveToPoint], (ROUND(Z * (start.x) - Z_2)), ',', (ROUND(Z * (start.y) - Z_2)));
                                                        continue;
                                                    }
                                                    var end = { x:x + radius * COS(endAngle), y:y + radius * SIN(endAngle) };
                                                    if (clockwise && startAngle != endAngle && (start.x == end.x && start.y == end.y))
                                                        if (start.x >= x)
                                                        {
                                                            if (start.y < y)
                                                                start.x += 0.125;
                                                            else
                                                                start.y += 0.125;
                                                        }
                                                        else
                                                        {
                                                            if (end.y <= y)
                                                                end.x += 0.125;
                                                            else
                                                                end.y += 0.125;
                                                        }
                                                    vml.push(VML_ELEMENT_TABLE[type][clockwise],
                                                        (ROUND(Z * (x - radius) - Z_2)), ',', (ROUND(Z * (y - radius) - Z_2)), " ",
                                                        (ROUND(Z * (x + radius) - Z_2)), ',', (ROUND(Z * (y + radius) - Z_2)), " ",
                                                        (ROUND(Z * (start.x) - Z_2)), ',', (ROUND(Z * (start.y) - Z_2)), " ",
                                                        (ROUND(Z * (end.x) - Z_2)), ',', (ROUND(Z * (end.y) - Z_2)));
                                                    break;
            case kCGPathElementAddArcTo: break;
        }
    }
    vml.push("\">");
    if (fill)
        vml.push("<cg_vml_:fill color=\"", gState.fillStyle, "\" opacity=\"", opacity, "\" />");
    if (stroke)
        vml.push( "<cg_vml_:stroke opacity=\"", opacity,
                    "\" joinstyle=\"", VML_LINEJOIN_TABLE[gState.lineJoin],
                    "\" miterlimit=\"", gState.miterLimit,
                    "\" endcap=\"", VML_LINECAP_TABLE[gState.lineCap],
                    "\" weight=\"", gState.lineWidth, "",
                    "px\" color=\"", gState.strokeStyle,"\" />");
    var shadowColor = gState.shadowColor;
    if (shadowColor)
    {
        var shadowOffset = gState.shadowOffset;
        vml.push("<cg_vml_:shadow on=\"t\" offset=\"",
            shadowOffset.width, "pt ", shadowOffset.height, "pt\" opacity=\"", objj_msgSend(shadowColor, "alphaComponent"), "\" color=black />");
    }
    vml.push("</cg_vml_:shape>");
    aContext.path = NULL;
    if (aContext.buffer != nil)
        aContext.buffer += vml.join("");
    else
        aContext.DOMElement.insertAdjacentHTML("BeforeEnd", vml.join(""));
}
}

p;12;CGGeometry.jc;6535;





CGPointMake= function(x, y) { return { x:x, y:y }; }
CGPointMakeZero= function() { return { x:0.0, y:0.0 }; }
CGPointMakeCopy= function(aPoint) { return { x:aPoint.x, y:aPoint.y }; }
CGPointCreateCopy= function(aPoint) { return { x:aPoint.x, y:aPoint.y }; }

CGPointEqualToPoint= function(lhsPoint, rhsPoint) { return (lhsPoint.x == rhsPoint.x && lhsPoint.y == rhsPoint.y); }
CGStringFromPoint= function(aPoint) { return ("{" + aPoint.x + ", " + aPoint.y + "}"); }

CGSizeMake= function(width, height) { return { width:width, height:height }; }
CGSizeMakeZero= function() { return { width:0.0, height:0.0 }; }
CGSizeMakeCopy= function(aSize) { return { width:aSize.width, height:aSize.height }; }
CGSizeCreateCopy= function(aSize) { return { width:aSize.width, height:aSize.height }; }

CGSizeEqualToSize= function(lhsSize, rhsSize) { return (lhsSize.width == rhsSize.width && lhsSize.height == rhsSize.height); }
CGStringFromSize= function(aSize) { return ("{" + aSize.width + ", " + aSize.height + "}"); }

CGRectMake= function(x, y, width, height) { return { origin: { x:x, y:y }, size: { width:width, height:height } }; }
CGRectMakeZero= function() { return { origin: { x:0.0, y:0.0 }, size: { width:0.0, height:0.0 } }; }
CGRectMakeCopy= function(aRect) { return { origin: { x:aRect.origin.x, y:aRect.origin.y }, size: { width:aRect.size.width, height:aRect.size.height } }; }
CGRectCreateCopy= function(aRect) { return { origin: { x:aRect.origin.x, y:aRect.origin.y }, size: { width:aRect.size.width, height:aRect.size.height } }; }

CGRectEqualToRect= function(lhsRect, rhsRect) { return ((lhsRect.origin.x == rhsRect.origin.x && lhsRect.origin.y == rhsRect.origin.y) && (lhsRect.size.width == rhsRect.size.width && lhsRect.size.height == rhsRect.size.height)); }
CGStringFromRect= function(aRect) { return ("{" + ("{" + aRect.origin.x + ", " + aRect.origin.y + "}") + ", " + ("{" + aRect.size.width + ", " + aRect.size.height + "}") + "}"); }

CGRectOffset= function(aRect, dX, dY) { return { origin: { x:aRect.origin.x + dX, y:aRect.origin.y + dY }, size: { width:aRect.size.width, height:aRect.size.height } }; }
CGRectInset= function(aRect, dX, dY) { return { origin: { x:aRect.origin.x + dX, y:aRect.origin.y + dY }, size: { width:aRect.size.width - 2 * dX, height:aRect.size.height - 2 * dY } }; }

CGRectGetHeight= function(aRect) { return (aRect.size.height); }
CGRectGetMaxX= function(aRect) { return (aRect.origin.x + aRect.size.width); }
CGRectGetMaxY= function(aRect) { return (aRect.origin.y + aRect.size.height); }
CGRectGetMidX= function(aRect) { return (aRect.origin.x + (aRect.size.width) / 2.0); }
CGRectGetMidY= function(aRect) { return (aRect.origin.y + (aRect.size.height) / 2.0); }
CGRectGetMinX= function(aRect) { return (aRect.origin.x); }
CGRectGetMinY= function(aRect) { return (aRect.origin.y); }
CGRectGetWidth= function(aRect) { return (aRect.size.width); }

CGRectIsEmpty= function(aRect) { return (aRect.size.width <= 0.0 || aRect.size.height <= 0.0); }
CGRectIsNull= function(aRect) { return (aRect.size.width <= 0.0 || aRect.size.height <= 0.0); }

CGRectContainsPoint= function(aRect, aPoint) { return (aPoint.x >= (aRect.origin.x) && aPoint.y >= (aRect.origin.y) && aPoint.x < (aRect.origin.x + aRect.size.width) && aPoint.y < (aRect.origin.y + aRect.size.height)); }

CGRectContainsRect= function(lhsRect, rhsRect)
{
    var union = CGRectUnion(lhsRect, rhsRect);

    return ((union.origin.x == lhsRect.origin.x && union.origin.y == lhsRect.origin.y) && (union.size.width == lhsRect.size.width && union.size.height == lhsRect.size.height));
}

CGRectIntersectsRect= function(lhsRect, rhsRect)
{
    var intersection = CGRectIntersection(lhsRect, rhsRect);

    return !(intersection.size.width <= 0.0 || intersection.size.height <= 0.0);
}

CGRectIntegral= function(aRect)
{
    aRect = CGRectStandardize(aRect);


    var x = FLOOR((aRect.origin.x)),
        y = FLOOR((aRect.origin.y));

    aRect.size.width = CEIL((aRect.origin.x + aRect.size.width)) - x;
    aRect.size.height = CEIL((aRect.origin.y + aRect.size.height)) - y;

    aRect.origin.x = x;
    aRect.origin.y = y;

    return aRect;
}

CGRectIntersection= function(lhsRect, rhsRect)
{
    var intersection = { origin: { x:MAX((lhsRect.origin.x), (rhsRect.origin.x)), y:MAX((lhsRect.origin.y), (rhsRect.origin.y)) }, size: { width:0, height:0 } };




    intersection.size.width = MIN((lhsRect.origin.x + lhsRect.size.width), (rhsRect.origin.x + rhsRect.size.width)) - (intersection.origin.x);
    intersection.size.height = MIN((lhsRect.origin.y + lhsRect.size.height), (rhsRect.origin.y + rhsRect.size.height)) - (intersection.origin.y);

    return (intersection.size.width <= 0.0 || intersection.size.height <= 0.0) ? { origin: { x:0.0, y:0.0 }, size: { width:0.0, height:0.0 } } : intersection;
}

CGRectStandardize= function(aRect)
{
    var width = (aRect.size.width),
        height = (aRect.size.height),
        standardized = { origin: { x:aRect.origin.x, y:aRect.origin.y }, size: { width:aRect.size.width, height:aRect.size.height } };

    if (width < 0.0)
    {
        standardized.origin.x += width;
        standardized.size.width = -width;
    }

    if (height < 0.0)
    {
        standardized.origin.y += height;
        standardized.size.height = -height;
    }

    return standardized;
}

CGRectUnion= function(lhsRect, rhsRect)
{
    var minX = MIN((lhsRect.origin.x), (rhsRect.origin.x)),
        minY = MIN((lhsRect.origin.y), (rhsRect.origin.y)),
        maxX = MAX((lhsRect.origin.x + lhsRect.size.width), (rhsRect.origin.x + rhsRect.size.width)),
        maxY = MAX((lhsRect.origin.y + lhsRect.size.height), (rhsRect.origin.y + rhsRect.size.height));

    return { origin: { x:minX, y:minY }, size: { width:maxX - minX, height:maxY - minY } };
}

CGPointFromString= function(aString)
{
    var comma = aString.indexOf(',');

    return { x:parseInt(aString.substr(1, comma - 1)), y:parseInt(aString.substring(comma + 1, aString.length)) };
}

CGSizeFromString= function(aString)
{
    var comma = aString.indexOf(',');

    return { width:parseInt(aString.substr(1, comma - 1)), height:parseInt(aString.substring(comma + 1, aString.length)) };
}

CGRectFromString= function(aString)
{
    var comma = aString.indexOf(',', aString.indexOf(',') + 1);

    return { origin:CGPointFromString(aString.substr(1, comma - 1)), size:CGSizeFromString(aString.substring(comma + 2, aString.length)) };
}

CGPointFromEvent= function(anEvent)
{
    return { x:anEvent.clientX, y:anEvent.clientY };
}

p;12;CGGradient.ji;9;CGColor.ji;14;CGColorSpace.jc;758;

kCGGradientDrawsBeforeStartLocation = 1 << 0;
kCGGradientDrawsAfterEndLocation = 1 << 1;

CGGradientCreateWithColorComponents= function(aColorSpace, components, locations, count)
{
    if (arguments["count"] == NULL)
        var count = locations.length;

    var colors = [];

    while (count--)
    {
        var offset = count * 4;
        colors[count] = CGColorCreate(aColorSpace, components.slice(offset, offset + 4));
    }

    return CGGradientCreateWithColors(aColorSpace, colors, locations);
}

CGGradientCreateWithColors= function(aColorSpace, colors, locations)
{
    return { colorspace:aColorSpace, colors:colors, locations:locations };
}

CGGradientRelease= function()
{
}

CGGradientRetain= function(aGradient)
{
    return aGradient;
}

p;8;CGPath.ji;12;CGGeometry.ji;19;CGAffineTransform.jc;8149;

kCGPathElementMoveToPoint = 0;
kCGPathElementAddLineToPoint = 1;
kCGPathElementAddQuadCurveToPoint = 2;
kCGPathElementAddCurveToPoint = 3;
kCGPathElementCloseSubpath = 4;

kCGPathElementAddArc = 5;
kCGPathElementAddArcToPoint = 6;

CGPathCreateMutable= function()
{
    return { count:0, start:NULL, current:NULL, elements:[] };
}

CGPathCreateMutableCopy= function(aPath)
{
    var path = CGPathCreateMutable();

    CGPathAddPath(path, aPath);

    return path;
}

CGPathCreateCopy= function(aPath)
{
    return CGPathCreateMutableCopy(aPath);
}

CGPathRelease= function(aPath)
{
}

CGPathRetain= function(aPath)
{
    return aPath;
}

CGPathAddArc= function(aPath, aTransform, x, y, aRadius, aStartAngle, anEndAngle, isClockwise)
{
    if (aTransform && !(aTransform.a == 1 && aTransform.b == 0 && aTransform.c == 0 && aTransform.d == 1 && aTransform.tx == 0 && aTransform.ty == 0))
    {
        var center = { x:x, y:y },
            end = { x:COS(anEndAngle), y:SIN(anEndAngle) },
            start = { x:COS(aStartAngle), y:SIN(aStartAngle) };

        end = { x:end.x * aTransform.a + end.y * aTransform.c + aTransform.tx, y:end.x * aTransform.b + end.y * aTransform.d + aTransform.ty };
        start = { x:start.x * aTransform.a + start.y * aTransform.c + aTransform.tx, y:start.x * aTransform.b + start.y * aTransform.d + aTransform.ty };
        center = { x:center.x * aTransform.a + center.y * aTransform.c + aTransform.tx, y:center.x * aTransform.b + center.y * aTransform.d + aTransform.ty };

        x = center.x;
        y = center.y;

        var oldEndAngle = anEndAngle,
            oldStartAngle = aStartAngle;

        anEndAngle = ATAN2(end.y - aTransform.ty, end.x - aTransform.tx);
        aStartAngle = ATAN2(start.y - aTransform.ty, start.x - aTransform.tx);




        if (anEndAngle == aStartAngle && oldEndAngle != oldStartAngle)
            if (oldStartAngle > oldEndAngle)
                anEndAngle = anEndAngle - PI2;
            else
                aStartAngle = aStartAngle - PI2;

        aRadius = { width:aRadius, height:0 };
        aRadius = { width:aRadius.width * aTransform.a + aRadius.height * aTransform.c, height:aRadius.width * aTransform.b + aRadius.height * aTransform.d };
        aRadius = SQRT(aRadius.width * aRadius.width + aRadius.height * aRadius.height);
    }

    aPath.current = { x:x + aRadius * COS(anEndAngle), y:y + aRadius * SIN(anEndAngle) };
    aPath.elements[aPath.count++] = { type:kCGPathElementAddArc, x:x, y:y, radius:aRadius, startAngle:aStartAngle, endAngle:anEndAngle };
}

CGPathAddArcToPoint= function(aPath, aTransform, x1, y1, x2, y2, aRadius)
{

}

CGPathAddCurveToPoint= function(aPath, aTransform, cp1x, cp1y, cp2x, cp2y, x, y)
{
    var cp1 = { x:cp1x, y:cp1y },
        cp2 = { x:cp2x, y:cp2y },
        end = { x:x, y:y };

    if (aTransform)
    {
        cp1 = { x:cp1.x * aTransform.a + cp1.y * aTransform.c + aTransform.tx, y:cp1.x * aTransform.b + cp1.y * aTransform.d + aTransform.ty };
        cp2 = { x:cp2.x * aTransform.a + cp2.y * aTransform.c + aTransform.tx, y:cp2.x * aTransform.b + cp2.y * aTransform.d + aTransform.ty };
        end = { x:end.x * aTransform.a + end.y * aTransform.c + aTransform.tx, y:end.x * aTransform.b + end.y * aTransform.d + aTransform.ty };
    }

   aPath.current = end;
   aPath.elements[aPath.count++] = { type:kCGPathElementAddCurveToPoint, cp1x:cp1.x, cp1y:cp1.y, cp2x:cp2.x, cp2y:cp2.y, x:end.x, y:end.y };
}

CGPathAddLines= function(aPath, aTransform, points, count)
{
    var i = 1;

    if (arguments["count"] == NULL)
        var count = points.length;

    if (!aPath || count < 2)
        return;

    CGPathMoveToPoint(aPath, aTransform, points[0].x, points[0].y);

    for (; i < count; ++i)
        CGPathAddLineToPoint(aPath, aTransform, points[i].x, points[i].y);
}

CGPathAddLineToPoint= function(aPath, aTransform, x, y)
{
    var point = { x:x, y:y };

    if (aTransform != NULL)
        point = { x:point.x * aTransform.a + point.y * aTransform.c + aTransform.tx, y:point.x * aTransform.b + point.y * aTransform.d + aTransform.ty };

    aPath.elements[aPath.count++] = { type: kCGPathElementAddLineToPoint, x:point.x, y:point.y };
    aPath.current = point;
}

CGPathAddPath= function(aPath, aTransform, anotherPath)
{
    var i = 0,
        count = anotherPath.count;

    for (; i < count; ++i)
    {
        var element = anotherPath[i];

        aPath.elements[aPath.count++] = { type:element.type, points:element.point.slice() };

        if (element.type == kCGPathElementAddArc || element.type == kCGPathElementAddArcToPoint)
            aPath.elements[aPath.count-1].radius = element.radius;
    }

    aPath.current = anotherPath.current;
}

CGPathAddQuadCurveToPoint= function(aPath, aTransform, cpx, cpy, x, y)
{
    var cp = { x:cpx, y:cpy },
        end = { x:x, y:y };

    if (aTransform)
    {
        cp = { x:control.x * aTransform.a + control.y * aTransform.c + aTransform.tx, y:control.x * aTransform.b + control.y * aTransform.d + aTransform.ty };
        end = { x:end.x * aTransform.a + end.y * aTransform.c + aTransform.tx, y:end.x * aTransform.b + end.y * aTransform.d + aTransform.ty };
    }

    aPath.elements[aPath.count++] = { type:kCGPathElementAddQuadCurveToPoint, cpx:cp.x, cpy:cp.y, x:end.x, y:end.y }
    aPath.current = end;
}

CGPathAddRect= function(aPath, aTransform, aRect)
{
    CGPathAddRects(aPath, aTransform, [aRect], 1);
}

CGPathAddRects= function(aPath, aTransform, rects, count)
{
    var i = 0;

    if (arguments["count"] == NULL)
        var count = rects.length;

    for (; i < count; ++i)
    {
        var rect = rects[i];

        CGPathMoveToPoint(aPath, aTransform, (rect.origin.x), (rect.origin.y));
        CGPathAddLineToPoint(aPath, aTransform, (rect.origin.x + rect.size.width), (rect.origin.y));
        CGPathAddLineToPoint(aPath, aTransform, (rect.origin.x + rect.size.width), (rect.origin.y + rect.size.height));
        CGPathAddLineToPoint(aPath, aTransform, (rect.origin.x), (rect.origin.y + rect.size.height));

        CGPathCloseSubpath(aPath);
    }
}

CGPathMoveToPoint= function(aPath, aTransform, x, y)
{
    var point = { x:x, y:y },
        count = aPath.count;

    if (aTransform != NULL)
        point = { x:point.x * aTransform.a + point.y * aTransform.c + aTransform.tx, y:point.x * aTransform.b + point.y * aTransform.d + aTransform.ty };

    aPath.start = point;
    aPath.current = point;

    var previous = aPath.elements[count-1];

    if (count != 0 && previous.type == kCGPathElementMoveToPoint)
    {
        previous.x = point.x;
        previous.y = point.y;
    }
    else
        aPath.elements[aPath.count++] = { type:kCGPathElementMoveToPoint, x:point.x, y:point.y };
}

CGPathCloseSubpath= function(aPath)
{
    var count = aPath.count;


    if (count == 0 || aPath.elements[count-1].type == kCGPathElementCloseSubpath)
        return;

    aPath.elements[aPath.count++] = { type:kCGPathElementCloseSubpath, points:[aPath.start] };
}

CGPathEqualToPath= function(aPath, anotherPath)
{
    if (aPath == anotherPath)
        return YES;

    if (aPath.count != anotherPath.count || !(aPath.start.x == anotherPath.start.x && aPath.start.y == anotherPath.start.y) || !(aPath.current.x == anotherPath.current.x && aPath.current.y == anotherPath.current.y))
        return NO;

    var i = 0,
        count = aPath.count;

    for (; i < count; ++i)
    {
        var element = aPath[i],
            anotherElement = anotherPath[i];

        if (element.type != anotherElement.type)
            return NO;

        if ((element.type == kCGPathElementAddArc || element.type == kCGPathElementAddArcToPoint) &&
            element.radius != anotherElement.radius)
            return NO;

        var j = element.points.length;

        while (j--)
            if (!(element.points[j].x == anotherElement.points[j].x && element.points[j].y == anotherElement.points[j].y))
                return NO;
    }

    return YES;
}

CGPathGetCurrentPoint= function(aPath)
{
    return { x:aPath.current.x, y:aPath.current.y };
}

CGPathIsEmpty= function(aPath)
{
    return !aPath || aPath.count == 0;
}

p;13;CPAnimation.jI;21;Foundation/CPObject.ji;23;CAMediaTimingFunction.jc;5122;


CPAnimationEaseInOut = 0,
CPAnimationEaseIn = 1,
CPAnimationEaseOut = 2,
CPAnimationLinear = 3;

ACTUAL_FRAME_RATE = 0;

{var the_class = objj_allocateClassPair(CPObject, "CPAnimation"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_startTime"), new objj_ivar("_duration"), new objj_ivar("_animationCurve"), new objj_ivar("_timingFunction"), new objj_ivar("_frameRate"), new objj_ivar("_progress"), new objj_ivar("_delegate"), new objj_ivar("_timer"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithDuration:animationCurve:"), function(self, _cmd, aDuration, anAnimationCurve)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
    {
        _duration = aDuration;
        _animationCurve = anAnimationCurve;
        _frameRate = 60.0;
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setAnimationCurve:"), function(self, _cmd, anAnimationCurve)
{ with(self)
{
    _animationCurve = anAnimationCurve;

    var timingFunctionName = kCAMediaTimingFunctionLinear;

    switch (_animationCurve)
    {
        case CPAnimationEaseInOut: timingFunctionName = kCAMediaTimingFunctionEaseInEaseOut;
                                    break;

        case CPAnimationEaseIn: timingFunctionName = kCAMediaTimingFunctionEaseIn;
                                    break;

        case CPAnimationEaseOut: timingFunctionName = kCAMediaTimingFunctionEaseOut;
                                    break;
    }

    _timingFunction = objj_msgSend(CAMediaTimingFunction, "functionWithName:", timingFunctionName);
}
});
instance_methods[2] = new objj_method(sel_registerName("animationCurve"), function(self, _cmd)
{ with(self)
{
    return _animationCurve;
}
});
instance_methods[3] = new objj_method(sel_registerName("setDuration:"), function(self, _cmd, aDuration)
{ with(self)
{
    _duration = aDuration;
}
});
instance_methods[4] = new objj_method(sel_registerName("duration"), function(self, _cmd)
{ with(self)
{
    return _duration;
}
});
instance_methods[5] = new objj_method(sel_registerName("setFramesPerSecond:"), function(self, _cmd, framesPerSecond)
{ with(self)
{
    _frameRate = framesPerSecond;
}
});
instance_methods[6] = new objj_method(sel_registerName("frameRate"), function(self, _cmd)
{ with(self)
{
    return _frameRate;
}
});
instance_methods[7] = new objj_method(sel_registerName("delegate"), function(self, _cmd)
{ with(self)
{
    return _delegate;
}
});
instance_methods[8] = new objj_method(sel_registerName("setDelegate:"), function(self, _cmd, aDelegate)
{ with(self)
{
    _delegate = aDelegate;
}
});
instance_methods[9] = new objj_method(sel_registerName("startAnimation"), function(self, _cmd)
{ with(self)
{

    if (_timer || _delegate && !objj_msgSend(_delegate, "animationShouldStart:", self))
        return;

    _progress = 0.0;
    ACTUAL_FRAME_RATE = 0;
    _startTime = new Date();

    _timer = window.setInterval(function() {
        objj_msgSend(self, "animationTimerDidFire:", _timer);
        objj_msgSend(objj_msgSend(CPRunLoop, "currentRunLoop"), "performSelectors");
    }, 1);
}
});
instance_methods[10] = new objj_method(sel_registerName("animationTimerDidFire:"), function(self, _cmd, aTimer)
{ with(self)
{
    var elapsed = new Date() - _startTime,
        progress = MIN(1.0, 1.0 - (_duration - elapsed / 1000.0) / _duration);
++ACTUAL_FRAME_RATE;
    objj_msgSend(self, "setCurrentProgress:", progress);

    if (progress == 1.0)
    {
        window.clearTimeout(_timer);
        _timer = nil;

        if (objj_msgSend(_delegate, "respondsToSelector:", sel_registerName("animationDidEnd:")))
            objj_msgSend(_delegate, "animationDidEnd:", self);
    }

}
});
instance_methods[11] = new objj_method(sel_registerName("stopAnimation"), function(self, _cmd)
{ with(self)
{
    if (!_timer)
        return;

    window.clearTimeout(_timer);
    _timer = nil;

    objj_msgSend(_delegate, "animationDidStop:", self);
}
});
instance_methods[12] = new objj_method(sel_registerName("isAnimating"), function(self, _cmd)
{ with(self)
{
    return _timer;
}
});
instance_methods[13] = new objj_method(sel_registerName("setCurrentProgress:"), function(self, _cmd, aProgress)
{ with(self)
{
    _progress = aProgress;
}
});
instance_methods[14] = new objj_method(sel_registerName("currentProgress"), function(self, _cmd)
{ with(self)
{
    return _progress;
}
});
instance_methods[15] = new objj_method(sel_registerName("currentValue"), function(self, _cmd)
{ with(self)
{
    if (objj_msgSend(_delegate, "respondsToSelector:", sel_registerName("animation:valueForProgress:")))
        return objj_msgSend(_delegate, "animation:valueForProgress:", self, _progress);

    if (_animationCurve == CPAnimationLinear)
        return _progress;

    alert("IMPLEMENT ANIMATION CURVES!!!");
}
});
class_addMethods(the_class, instance_methods);
}

p;15;CPApplication.jI;21;Foundation/CPBundle.ji;17;CPCompatibility.ji;9;CPEvent.ji;8;CPMenu.ji;13;CPResponder.ji;22;CPDocumentController.jc;15086;

CPApp = nil;

CPApplicationWillFinishLaunchingNotification = "CPApplicationWillFinishLaunchingNotification";
CPApplicationDidFinishLaunchingNotification = "CPApplicationDidFinishLaunchingNotification";

CPRunStoppedResponse = -1000;
CPRunAbortedResponse = -1001;
CPRunContinuesResponse = -1002;

{var the_class = objj_allocateClassPair(CPResponder, "CPApplication"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_eventListeners"), new objj_ivar("_currentEvent"), new objj_ivar("_windows"), new objj_ivar("_keyWindow"), new objj_ivar("_mainWindow"), new objj_ivar("_mainMenu"), new objj_ivar("_currentSession"), new objj_ivar("_delegate"), new objj_ivar("_namedArgs"), new objj_ivar("_args"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("sharedApplication"), function(self, _cmd)
{ with(self)
{
    if (!CPApp)
        CPApp = objj_msgSend(objj_msgSend(CPApplication, "alloc"), "init");

    return CPApp;
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("init"), function(self, _cmd)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPResponder") }, "init");

    if (self)
    {
        _eventListeners = [];

        _windows = [];

        objj_msgSend(_windows, "addObject:", nil);


        _mainMenu = objj_msgSend(objj_msgSend(CPMenu, "alloc"), "initWithTitle:", "MainMenu");

        var undoMenuItem = objj_msgSend(objj_msgSend(CPMenuItem, "alloc"), "initWithTitle:action:keyEquivalent:", "Undo", sel_registerName("undo:"), CPUndoKeyEquivalent),
            redoMenuItem = objj_msgSend(objj_msgSend(CPMenuItem, "alloc"), "initWithTitle:action:keyEquivalent:", "Redo", sel_registerName("redo:"), CPRedoKeyEquivalent);

        objj_msgSend(undoMenuItem, "setKeyEquivalentModifierMask:", CPUndoKeyEquivalentModifierMask);
        objj_msgSend(redoMenuItem, "setKeyEquivalentModifierMask:", CPRedoKeyEquivalentModifierMask);

        objj_msgSend(_mainMenu, "addItem:", undoMenuItem);
        objj_msgSend(_mainMenu, "addItem:", redoMenuItem);

        objj_msgSend(_mainMenu, "addItem:", objj_msgSend(CPMenuItem, "separatorItem"));

        objj_msgSend(_mainMenu, "addItem:", objj_msgSend(objj_msgSend(CPMenuItem, "alloc"), "initWithTitle:action:keyEquivalent:", "New", sel_registerName("newDocument:"), "N")),
        objj_msgSend(_mainMenu, "addItem:", objj_msgSend(objj_msgSend(CPMenuItem, "alloc"), "initWithTitle:action:keyEquivalent:", "Open", sel_registerName("openDocument:"), "O")),
        objj_msgSend(_mainMenu, "addItem:", objj_msgSend(objj_msgSend(CPMenuItem, "alloc"), "initWithTitle:action:keyEquivalent:", "Save", sel_registerName("saveDocument:"), "S"));

        objj_msgSend(_mainMenu, "addItem:", objj_msgSend(objj_msgSend(CPMenuItem, "alloc"), "initWithTitle:action:keyEquivalent:", "Cut", sel_registerName("cut:"), "X")),
        objj_msgSend(_mainMenu, "addItem:", objj_msgSend(objj_msgSend(CPMenuItem, "alloc"), "initWithTitle:action:keyEquivalent:", "Copy", sel_registerName("copy:"), "C")),
        objj_msgSend(_mainMenu, "addItem:", objj_msgSend(objj_msgSend(CPMenuItem, "alloc"), "initWithTitle:action:keyEquivalent:", "Paste", sel_registerName("paste:"), "V"));
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setDelegate:"), function(self, _cmd, aDelegate)
{ with(self)
{
    if (_delegate == aDelegate)
        return;

    var defaultCenter = objj_msgSend(CPNotificationCenter, "defaultCenter");

    if (_delegate)
    {
        objj_msgSend(defaultCenter, "removeObesrver:name:object:", _delegate, CPApplicationWillFinishLaunchingNotification, self);

        objj_msgSend(defaultCenter, "removeObesrver:name:object:", _delegate, CPApplicationDidFinishLaunchingNotification, self);
    }

    _delegate = aDelegate;

    if (objj_msgSend(_delegate, "respondsToSelector:", sel_registerName("applicationWillFinishLaunching:")))
        objj_msgSend(defaultCenter, "addObserver:selector:name:object:", _delegate, sel_registerName("applicationWillFinishLaunching:"), CPApplicationWillFinishLaunchingNotification, self);

    if (objj_msgSend(_delegate, "respondsToSelector:", sel_registerName("applicationDidFinishLaunching:")))
        objj_msgSend(defaultCenter, "addObserver:selector:name:object:", _delegate, sel_registerName("applicationDidFinishLaunching:"), CPApplicationDidFinishLaunchingNotification, self);
}
});
instance_methods[2] = new objj_method(sel_registerName("delegate"), function(self, _cmd)
{ with(self)
{
    return _delegate;
}
});
instance_methods[3] = new objj_method(sel_registerName("finishLaunching"), function(self, _cmd)
{ with(self)
{
    var defaultCenter = objj_msgSend(CPNotificationCenter, "defaultCenter");

    objj_msgSend(defaultCenter, "postNotificationName:object:", CPApplicationWillFinishLaunchingNotification, self);


    if (YES)
    {
        objj_msgSend(self, "setDelegate:", objj_msgSend(CPDocumentController, "sharedDocumentController"));

        objj_msgSend(_delegate, "newDocument:", self);
    }

    objj_msgSend(defaultCenter, "postNotificationName:object:", CPApplicationDidFinishLaunchingNotification, self);

    objj_msgSend(objj_msgSend(CPRunLoop, "currentRunLoop"), "performSelectors");
}
});
instance_methods[4] = new objj_method(sel_registerName("run"), function(self, _cmd)
{ with(self)
{
    objj_msgSend(self, "finishLaunching");
}
});
instance_methods[5] = new objj_method(sel_registerName("runModalForWindow:"), function(self, _cmd, aWindow)
{ with(self)
{
    objj_msgSend(self, "runModalSession:", objj_msgSend(self, "beginModalSessionForWindow:", aWindow));
}
});
instance_methods[6] = new objj_method(sel_registerName("stopModalWithCode:"), function(self, _cmd, aCode)
{ with(self)
{
    if (!_currentSession)
    {
        return;

    }

    _currentSession._state = aCode;
    _currentSession = _currentSession._previous;

    if (aCode == CPRunAbortedResponse)
        objj_msgSend(self, "_removeRunModalLoop");
}
});
instance_methods[7] = new objj_method(sel_registerName("_removeRunModalLoop"), function(self, _cmd)
{ with(self)
{
    var count = _eventListeners.length;

    while (count--)
        if (_eventListeners[count]._callback == _CPRunModalLoop)
        {
            _eventListeners.splice(count, 1);

            return;
        }
}
});
instance_methods[8] = new objj_method(sel_registerName("stopModal"), function(self, _cmd)
{ with(self)
{
    objj_msgSend(self, "stopModalWithCode:", CPRunStoppedResponse)
}
});
instance_methods[9] = new objj_method(sel_registerName("abortModal"), function(self, _cmd)
{ with(self)
{
    objj_msgSend(self, "stopModalWithCode:", CPRunAbortedResponse);
}
});
instance_methods[10] = new objj_method(sel_registerName("beginModalSessionForWindow:"), function(self, _cmd, aWindow)
{ with(self)
{
    return _CPModalSessionMake(aWindow, 0);
}
});
instance_methods[11] = new objj_method(sel_registerName("runModalSession:"), function(self, _cmd, aModalSession)
{ with(self)
{
    aModalSession._previous = _currentSession;
    _currentSession = aModalSession;

    var theWindow = aModalSession._window;

    objj_msgSend(theWindow, "center");
    objj_msgSend(theWindow, "makeKeyAndOrderFront:", self);



    objj_msgSend(CPApp, "setCallback:forNextEventMatchingMask:untilDate:inMode:dequeue:", _CPRunModalLoop, CPAnyEventMask, nil, 0, NO);
}
});
instance_methods[12] = new objj_method(sel_registerName("modalWindow"), function(self, _cmd)
{ with(self)
{
    if (!_currentSession)
        return nil;

    return _currentSession._window;
}
});
instance_methods[13] = new objj_method(sel_registerName("_handleKeyEquivalent:"), function(self, _cmd, anEvent)
{ with(self)
{
    if (objj_msgSend(_mainMenu, "performKeyEquivalent:", anEvent))
        return YES;

    return NO;
}
});
instance_methods[14] = new objj_method(sel_registerName("sendEvent:"), function(self, _cmd, anEvent)
{ with(self)
{

    if (objj_msgSend(anEvent, "type") == CPKeyDown &&
        objj_msgSend(anEvent, "modifierFlags") & (CPCommandKeyMask | CPControlKeyMask) &&
        objj_msgSend(objj_msgSend(anEvent, "characters"), "length") > 0 &&
        objj_msgSend(self, "_handleKeyEquivalent:", anEvent))
        return;

    if (_eventListeners.length)
    {
        if (_eventListeners[_eventListeners.length-1]._mask & (1 << objj_msgSend(anEvent, "type")))
            _eventListeners.pop()._callback(anEvent);

        return;
    }

    objj_msgSend(objj_msgSend(anEvent, "window"), "sendEvent:", anEvent);
}
});
instance_methods[15] = new objj_method(sel_registerName("doCommandBySelector:"), function(self, _cmd, aSelector)
{ with(self)
{
    if (objj_msgSend(_delegate, "respondsToSelector:", aSelector))
        objj_msgSend(_delegate, "performSelector:", aSelector);
    else
        objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPResponder") }, "doCommandBySelector:", aSelector);
}
});
instance_methods[16] = new objj_method(sel_registerName("keyWindow"), function(self, _cmd)
{ with(self)
{
    return _keyWindow;
}
});
instance_methods[17] = new objj_method(sel_registerName("mainWindow"), function(self, _cmd)
{ with(self)
{
    return _mainWindow;
}
});
instance_methods[18] = new objj_method(sel_registerName("windowWithWindowNumber:"), function(self, _cmd, aWindowNumber)
{ with(self)
{
    return _windows[aWindowNumber];
}
});
instance_methods[19] = new objj_method(sel_registerName("windows"), function(self, _cmd)
{ with(self)
{
    return _windows;
}
});
instance_methods[20] = new objj_method(sel_registerName("mainMenu"), function(self, _cmd)
{ with(self)
{
    return _mainMenu;
}
});
instance_methods[21] = new objj_method(sel_registerName("setMainMenu:"), function(self, _cmd, aMenu)
{ with(self)
{
    _mainMenu = aMenu;
}
});
instance_methods[22] = new objj_method(sel_registerName("tryToPerform:with:"), function(self, _cmd, anAction, anObject)
{ with(self)
{
    if (!anAction)
        return NO;

    if (objj_msgSend(self, "tryToPerform:with:", anAction, anObject))
        return YES;

    if(objj_msgSend(_delegate, "respondsToSelector:", aSelector))
    {
        objj_msgSend(_delegate, "performSelector:withObject:", aSelector, anObject);

        return YES;
    }

    return NO;
}
});
instance_methods[23] = new objj_method(sel_registerName("sendAction:to:from:"), function(self, _cmd, anAction, aTarget, aSender)
{ with(self)
{
    var target = objj_msgSend(self, "targetForAction:to:from:", anAction, aTarget, aSender);

    if (!target)
        return NO;

    objj_msgSend(target, "performSelector:withObject:", anAction, aSender);

    return YES;
}
});
instance_methods[24] = new objj_method(sel_registerName("targetForAction:to:from:"), function(self, _cmd, anAction, aTarget, aSender)
{ with(self)
{
    if (!anAction)
        return nil;

    if (aTarget)
        return aTarget;

    return objj_msgSend(self, "targetForAction:", anAction);
}
});
instance_methods[25] = new objj_method(sel_registerName("targetForAction:"), function(self, _cmd, anAction)
{ with(self)
{
    if (!anAction)
        return nil;

    var theWindow = objj_msgSend(self, "keyWindow"),
        responder = objj_msgSend(theWindow, "firstResponder");

    while (responder)
    {
        if (objj_msgSend(responder, "respondsToSelector:", anAction))
            return responder;

        responder = objj_msgSend(responder, "nextResponder");
    }

    var delegate = objj_msgSend(theWindow, "delegate");

    if (objj_msgSend(delegate, "respondsToSelector:", anAction))
        return delegate;

    theWindow = objj_msgSend(self, "mainWindow");

    if (theWindow != objj_msgSend(self, "keyWindow"))
    {
        responder = objj_msgSend(theWindow, "firstResponder");

        while (responder)
        {
            if (objj_msgSend(responder, "respondsToSelector:", anAction))
                return responder;

            responder = objj_msgSend(responder, "nextResponder");
        }

        delegate = objj_msgSend(theWindow, "delegate");

        if (objj_msgSend(delegate, "respondsToSelector:", anAction))
            return delegate;
    }

    if (objj_msgSend(self, "respondsToSelector:", anAction))
        return self;

    if (objj_msgSend(_delegate, "respondsToSelector:", anAction))
        return _delegate;

    return nil;
}
});
instance_methods[26] = new objj_method(sel_registerName("setCallback:forNextEventMatchingMask:untilDate:inMode:dequeue:"), function(self, _cmd, aCallback, aMask, anExpiration, aMode, shouldDequeue)
{ with(self)
{
    _eventListeners.push(_CPEventListenerMake(aMask, aCallback));

    if (_eventListeners.length == 3) objj_debug_print_backtrace();
}
});
instance_methods[27] = new objj_method(sel_registerName("setTarget:selector:forNextEventMatchingMask:untilDate:inMode:dequeue:"), function(self, _cmd, aTarget, aSelector, aMask, anExpiration, aMode, shouldDequeue)
{ with(self)
{
    _eventListeners.push(_CPEventListenerMake(aMask, function (anEvent) { objj_msgSend(aTarget, aSelector, anEvent); }));
}
});
instance_methods[28] = new objj_method(sel_registerName("beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:"), function(self, _cmd, aSheet, aWindow, aModalDelegate, aDidEndSelector, aContextInfo)
{ with(self)
{
    objj_msgSend(aWindow, "_attachSheet:modalDelegate:didEndSelector:contextInfo:", aSheet, aModalDelegate, aDidEndSelector, aContextInfo);
}
});
instance_methods[29] = new objj_method(sel_registerName("arguments"), function(self, _cmd)
{ with(self)
{
    return _args;
}
});
instance_methods[30] = new objj_method(sel_registerName("namedArguments"), function(self, _cmd)
{ with(self)
{
    return _namedArgs;
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

var _CPModalSessionMake = function(aWindow, aStopCode)
{
    return { _window:aWindow, _state:CPRunContinuesResponse , _previous:nil };
}

var _CPEventListenerMake = function(anEventMask, aCallback)
{
    return { _mask:anEventMask, _callback:aCallback };
}

var _CPRunModalLoop = function(anEvent)
{
    objj_msgSend(CPApp, "setCallback:forNextEventMatchingMask:untilDate:inMode:dequeue:", _CPRunModalLoop, CPAnyEventMask, nil, 0, NO);


    var theWindow = objj_msgSend(anEvent, "window"),
        modalSession = CPApp._currentSession;

    if (theWindow == modalSession._window)
        objj_msgSend(theWindow, "sendEvent:", anEvent);



    if (modalSession._state != CPRunContinuesResponse)
        objj_msgSend(CPApp, "_removeRunModalLoop");
}

CPApplicationMain= function(args, namedArgs)
{
    var mainBundle = objj_msgSend(CPBundle, "mainBundle"),
        principalClass = objj_msgSend(mainBundle, "principalClass");

    if (!principalClass)
        principalClass = objj_msgSend(CPApplication, "class");

    objj_msgSend(principalClass, "sharedApplication");




    CPApp._args = args;
    CPApp._namedArgs = namedArgs;

    objj_msgSend(CPApp, "run");
}

p;10;CPBorder.jc;3513;


CPBorderNoneStyle = 0;
CPBorderSolidStyle = 1;
CPBorderDashedStyle = 2;

var CPBorderStyleMap = nil;

{var the_class = objj_allocateClassPair(CPObject, "CPBorder"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_color"), new objj_ivar("_thickness"), new objj_ivar("_style"), new objj_ivar("_cssString"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("initialize"), function(self, _cmd)
{ with(self)
{
    if (self == objj_msgSend(CPBorder, "class"))
    {
        CPBorderStyleMap = objj_msgSend(CPArray, "array");

        CPBorderStyleMap[CPBorderNoneStyle] = "none";
        CPBorderStyleMap[CPBorderSolidStyle] = "solid";
        CPBorderStyleMap[CPBorderDashedStyle] = "dashed";
    }
}
});
class_methods[1] = new objj_method(sel_registerName("emptyBorder"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(self, "borderWithColor:thickness:style:", nil, 0.0, CPBorderNoneStyle);
}
});
class_methods[2] = new objj_method(sel_registerName("borderWithColor:thickness:style:"), function(self, _cmd, aColor, aThickness, aStyle)
{ with(self)
{
    return objj_msgSend(objj_msgSend(self, "alloc"), "initWithColor:thickness:style:", aColor, aThickness, aStyle);
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithColor:thickness:style:"), function(self, _cmd, aColor, aThickness, aStyle)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
    {
        _color = aColor;
        _thickness = aThickness;
        _style = aStyle;

        if (_style == CPBorderNoneStyle)
            _cssString = "none";
        else
            _cssString = _thickness + "px " + CPBorderStyleMap[_style] + " " + objj_msgSend(_color, "cssString");
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("color"), function(self, _cmd)
{ with(self)
{
    return _color;
}
});
instance_methods[2] = new objj_method(sel_registerName("thickness"), function(self, _cmd)
{ with(self)
{
    return _thickness;
}
});
instance_methods[3] = new objj_method(sel_registerName("cssString"), function(self, _cmd)
{ with(self)
{
    return _cssString;
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

{
var the_class = objj_getClass("CPBorder")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPBorder\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
    {
        _color = objj_msgSend(aCoder, "decodeObject");
        _thickness = objj_msgSend(aCoder, "decodeNumber");
        _style = objj_msgSend(aCoder, "decodeNumber");
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("encodeWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    objj_msgSend(aCoder, "encodeObject:", _color);
    objj_msgSend(aCoder, "encodeNumber:", _thickness);
    objj_msgSend(aCoder, "encodeNumber:", _style);
}
});
class_addMethods(the_class, instance_methods);
}

p;10;CPButton.ji;12;CGGeometry.ji;11;CPControl.ji;13;CPImageView.ji;13;CPTextField.jc;21694;




CPScaleProportionally = 0;
CPScaleToFit = 1;
CPScaleNone = 2;

CPNoImage = 0;
CPImageOnly = 1;
CPImageLeft = 2;
CPImageRight = 3;
CPImageBelow = 4;
CPImageAbove = 5;
CPImageOverlaps = 6;

CPOnState = 1;
CPOffState = 0;
CPMixedState = -1;

CPRoundedBezelStyle = 1;
CPRegularSquareBezelStyle = 2;
CPThickSquareBezelStyle = 3;
CPThickerSquareBezelStyle = 4;
CPDisclosureBezelStyle = 5;
CPShadowlessSquareBezelStyle = 6;
CPCircularBezelStyle = 7;
CPTexturedSquareBezelStyle = 8;
CPHelpButtonBezelStyle = 9;
CPSmallSquareBezelStyle = 10;
CPTexturedRoundedBezelStyle = 11;
CPRoundRectBezelStyle = 12;
CPRecessedBezelStyle = 13;
CPRoundedDisclosureBezelStyle = 14;
CPHUDBezelStyle = -1;

CPMomentaryLightButton = 0;
CPPushOnPushOffButton = 1;
CPToggleButton = 2;
CPSwitchButton = 3;
CPRadioButton = 4;
CPMomentaryChangeButton = 5;
CPOnOffButton = 6;
CPMomentaryPushInButton = 7;
CPMomentaryPushButton = 0;
CPMomentaryLight = 7;


var CPHUDBezelStyleTextColor = nil;

var _CPButtonClassName = nil,
    _CPButtonBezelStyleSizes = {},
    _CPButtonBezelStyleIdentifiers = {},
    _CPButtonBezelStyleHighlightedIdentifier = "Highlighted";

{var the_class = objj_allocateClassPair(CPControl, "CPButton"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_isDisplayingHighlight"), new objj_ivar("_tag"), new objj_ivar("_state"), new objj_ivar("_allowsMixedState"), new objj_ivar("_image"), new objj_ivar("_alternateImage"), new objj_ivar("_currentImage"), new objj_ivar("_imagePosition"), new objj_ivar("_imageScalng"), new objj_ivar("_title"), new objj_ivar("_alternateTitle"), new objj_ivar("_titleField"), new objj_ivar("_bezelStyle"), new objj_ivar("_isBordered"), new objj_ivar("_controlSize"), new objj_ivar("_bezelBorderNeedsUpdate"), new objj_ivar("_bezelBorderView"), new objj_ivar("_DOMImageElement"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("initialize"), function(self, _cmd)
{ with(self)
{
    if (self != objj_msgSend(CPButton, "class"))
        return;

    _CPButtonClassName = objj_msgSend(CPButton, "className");

    _CPButtonBezelStyleIdentifiers[CPRoundedBezelStyle] = "Rounded";
    _CPButtonBezelStyleIdentifiers[CPRegularSquareBezelStyle] = "RegularSquare";
    _CPButtonBezelStyleIdentifiers[CPThickSquareBezelStyle] = "ThickSquare";
    _CPButtonBezelStyleIdentifiers[CPThickerSquareBezelStyle] = "ThickerSquare";
    _CPButtonBezelStyleIdentifiers[CPDisclosureBezelStyle] = "Disclosure";
    _CPButtonBezelStyleIdentifiers[CPShadowlessSquareBezelStyle] = "ShadowlessSquare";
    _CPButtonBezelStyleIdentifiers[CPCircularBezelStyle] = "Circular";
    _CPButtonBezelStyleIdentifiers[CPTexturedSquareBezelStyle] = "TexturedSquare";
    _CPButtonBezelStyleIdentifiers[CPHelpButtonBezelStyle] = "HelpButton";
    _CPButtonBezelStyleIdentifiers[CPSmallSquareBezelStyle] = "SmallSquare";
    _CPButtonBezelStyleIdentifiers[CPTexturedRoundedBezelStyle] = "TexturedRounded";
    _CPButtonBezelStyleIdentifiers[CPRoundRectBezelStyle] = "RoundRect";
    _CPButtonBezelStyleIdentifiers[CPRecessedBezelStyle] = "Recessed";
    _CPButtonBezelStyleIdentifiers[CPRoundedDisclosureBezelStyle] = "RoundedDisclosure";
    _CPButtonBezelStyleIdentifiers[CPHUDBezelStyle] = "HUD";

    var regularIdentifier = _CPControlIdentifierForControlSize(CPRegularControlSize),
        smallIdentifier = _CPControlIdentifierForControlSize(CPSmallControlSize),
        miniIdentifier = _CPControlIdentifierForControlSize(CPMiniControlSize);


    var prefix = _CPButtonClassName + _CPButtonBezelStyleIdentifiers[CPRoundRectBezelStyle];

    _CPButtonBezelStyleSizes[prefix+regularIdentifier] = [{width:10.0,height:18.0},{width:1.0,height:18.0},{width:10.0,height:18.0}];
    _CPButtonBezelStyleSizes[prefix+regularIdentifier+_CPButtonBezelStyleHighlightedIdentifier] = [{width:10.0,height:18.0},{width:1.0,height:18.0},{width:10.0,height:18.0}];


    var prefix = _CPButtonClassName + _CPButtonBezelStyleIdentifiers[CPHUDBezelStyle];

    _CPButtonBezelStyleSizes[prefix+regularIdentifier] = [{width:13.0,height:20.0},{width:1.0,height:20.0},{width:13.0,height:20.0}];
    _CPButtonBezelStyleSizes[prefix+regularIdentifier+_CPButtonBezelStyleHighlightedIdentifier] = [{width:13.0,height:20.0},{width:1.0,height:20.0},{width:13.0,height:20.0}];

    CPHUDBezelStyleTextColor = objj_msgSend(CPColor, "whiteColor");


    var prefix = _CPButtonClassName + _CPButtonBezelStyleIdentifiers[CPTexturedRoundedBezelStyle];

    _CPButtonBezelStyleSizes[prefix+regularIdentifier] = [{width:7.0,height:20.0},{width:1.0,height:20.0},{width:7.0,height:20.0}];
    _CPButtonBezelStyleSizes[prefix+regularIdentifier+_CPButtonBezelStyleHighlightedIdentifier] = [{width:7.0,height:20.0},{width:1.0,height:20.0},{width:7.0,height:20.0}];

}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("setButtonType:"), function(self, _cmd, aButtonType)
{ with(self)
{
    if (aButtonType == CPSwitchButton)
    {
        objj_msgSend(self, "setBordered:", NO);
        objj_msgSend(self, "setImage:", nil);
        objj_msgSend(self, "setAlternateImage:", nil);
        objj_msgSend(self, "setAlignment:", CPLeftTextAlignment);
    }
}
});
instance_methods[1] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "initWithFrame:", aFrame);

    if (self)
        objj_msgSend(self, "setup");

    return self;
}
});
instance_methods[2] = new objj_method(sel_registerName("setup"), function(self, _cmd)
{ with(self)
{
    objj_msgSend(self, "_titleField");

    objj_msgSend(self, "setAlignment:", CPCenterTextAlignment);

    _DOMImageElement = document.createElement("img");
    _DOMImageElement.style.top = "0px";
    _DOMImageElement.style.left = "0px";
    _DOMImageElement.style.position = "absolute";
    _DOMImageElement.style.display = "none";
    _DOMImageElement.style.zIndex = 100;

    _DOMElement.appendChild(_DOMImageElement);

    _imagePosition = CPImageAbove;
    _imageScaling = CPScaleNone;

    _controlSize = CPRegularControlSize;

}
});
instance_methods[3] = new objj_method(sel_registerName("_titleField"), function(self, _cmd)
{ with(self)
{
    if (!_titleField)
    {
        _titleField = objj_msgSend(objj_msgSend(CPTextField, "alloc"), "initWithFrame:", CPRectMakeZero());

        objj_msgSend(_titleField, "setEditable:", NO);
        objj_msgSend(_titleField, "setFont:", objj_msgSend(self, "font"));
        objj_msgSend(_titleField, "setTextColor:", objj_msgSend(self, "textColor"));

        objj_msgSend(self, "addSubview:", _titleField);
    }

    return _titleField;
}
});
instance_methods[4] = new objj_method(sel_registerName("setImagePosition:"), function(self, _cmd, anImagePosition)
{ with(self)
{
    if (_imagePosition == anImagePosition)
        return;

    _imagePosition = anImagePosition;

    if (_imagePosition == CPNoImage)
        objj_msgSend(_titleField, "setHidden:", NO);
    else
        objj_msgSend(_titleField, "setHidden:", YES);

    objj_msgSend(self, "tile");
}
});
instance_methods[5] = new objj_method(sel_registerName("imagePosition"), function(self, _cmd)
{ with(self)
{
    return _imagePosition;
}
});
instance_methods[6] = new objj_method(sel_registerName("setTextColor:"), function(self, _cmd, aColor)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "setTextColor:", aColor);
    objj_msgSend(_titleField, "setTextColor:", aColor);
}
});
instance_methods[7] = new objj_method(sel_registerName("setFont:"), function(self, _cmd, aFont)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "setFont:", aFont);

    objj_msgSend(_titleField, "setFont:", aFont);

    objj_msgSend(self, "tile");
}
});
instance_methods[8] = new objj_method(sel_registerName("allowsMixedState"), function(self, _cmd)
{ with(self)
{
    return _allowsMixedState;
}
});
instance_methods[9] = new objj_method(sel_registerName("setAllowsMixedState:"), function(self, _cmd, aFlag)
{ with(self)
{
    _allowsMixedState = aFlag;
}
});
instance_methods[10] = new objj_method(sel_registerName("setNextState"), function(self, _cmd)
{ with(self)
{
    if (_state == CPOffState)
        _state = CPOnState;
    else
        _state = (_state >= CPOnState && _allowsMixedState) ? CPMixedState : CPOffState;
}
});
instance_methods[11] = new objj_method(sel_registerName("setState:"), function(self, _cmd, aState)
{ with(self)
{
    _state = aState;
}
});
instance_methods[12] = new objj_method(sel_registerName("state"), function(self, _cmd)
{ with(self)
{
    return _state;
}
});
instance_methods[13] = new objj_method(sel_registerName("setAlignment:"), function(self, _cmd, anAlignment)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "setAlignment:", anAlignment);

    objj_msgSend(_titleField, "setAlignment:", anAlignment);
}
});
instance_methods[14] = new objj_method(sel_registerName("setImagePosition:"), function(self, _cmd, anImagePosition)
{ with(self)
{
    _imagePosition = anImagePosition;
}
});
instance_methods[15] = new objj_method(sel_registerName("imagePosition"), function(self, _cmd)
{ with(self)
{
    return _imagePosition;
}
});
instance_methods[16] = new objj_method(sel_registerName("setImage:"), function(self, _cmd, anImage)
{ with(self)
{
    if (_image == anImage)
        return;

    _image = anImage;

    if (anImage)
    {
        var size = objj_msgSend(_image, "size");

        _DOMImageElement.style.display = "block";

        _DOMImageElement.src = objj_msgSend(_image, "filename");
        _DOMImageElement.width = size.width;
        _DOMImageElement.height = size.height;
        _DOMImageElement.style.width = size.width + "px";
        _DOMImageElement.style.height = size.height + "px";
    }
    else
        _DOMImageElement.style.display = "none";

    objj_msgSend(self, "tile");
}
});
instance_methods[17] = new objj_method(sel_registerName("image"), function(self, _cmd)
{ with(self)
{
    return _image;
}
});
instance_methods[18] = new objj_method(sel_registerName("setAlternateImage:"), function(self, _cmd, anImage)
{ with(self)
{
    _alternateImage = anImage;
}
});
instance_methods[19] = new objj_method(sel_registerName("alternateImage"), function(self, _cmd)
{ with(self)
{
    return _alternateImage;
}
});
instance_methods[20] = new objj_method(sel_registerName("setTitle:"), function(self, _cmd, aTitle)
{ with(self)
{
    var titleField = objj_msgSend(self, "_titleField");

    objj_msgSend(titleField, "setStringValue:", _title=aTitle);

    objj_msgSend(self, "tile");
}
});
instance_methods[21] = new objj_method(sel_registerName("title"), function(self, _cmd)
{ with(self)
{
    return _title;
}
});
instance_methods[22] = new objj_method(sel_registerName("tile"), function(self, _cmd)
{ with(self)
{
    if (_imagePosition != CPImageOnly)
        objj_msgSend(_titleField, "sizeToFit");

    var size = objj_msgSend(self, "bounds").size,
        centerX = size.width / 2.0,
        centerY = size.height / 2.0,
        titleHeight = _titleField ? CGRectGetHeight(objj_msgSend(_titleField, "frame")) : 0.0,
        titleRect = CGRectMake(0.0, centerY - titleHeight / 2.0, size.width, titleHeight);

    if (_imagePosition != CPNoImage && _image)
    {
        var imageSize = objj_msgSend(_image, "size"),
            imageWidth = imageSize.width,
            imageHeight = imageSize.height;

        if (_imageScaling == CPScaleToFit)
        {
            imageWidth = size.width;
            imageHeight = size.height;
        }
        else if (_imageScaling == CPScaleProportionally)
        {
            var scale = MIN(MIN(size.width, imageWidth) / imageWidth, MIN(size.height, imageHeight) / imageHeight);

            imageWidth *= scale;
            imageHeight *= scale;
        }

        _DOMImageElement.width = imageWidth;
        _DOMImageElement.height = imageHeight;
        _DOMImageElement.style.width = imageWidth + "px";
        _DOMImageElement.style.height = imageHeight + "px";

        if (_imagePosition == CPImageBelow)
        {
            _DOMImageElement.style.left = FLOOR(centerX - imageWidth / 2.0) + "px";
            _DOMImageElement.style.top = FLOOR(size.height - imageHeight) + "px";

            titleRect.origin.y = (size.height - imageHeight - titleHeight) / 2.0;
        }
        else if (_imagePosition == CPImageAbove)
        {
            _DOMImageElement.style.top = "0px";
            _DOMImageElement.style.left = FLOOR(centerX - imageWidth / 2.0) + "px";

            titleRect.origin.y = imageHeight + (size.height - imageHeight - titleHeight) / 2.0;
        }
        else if (_imagePosition == CPImageLeft)
        {
            _DOMImageElement.style.top = FLOOR(centerY - imageHeight / 2.0) + "px";
            _DOMImageElement.style.left = "0px";

            titleRect.origin.x += imageWidth;
            titleRect.size.width -= imageWidth;
        }
        else if (_imagePosition == CPImageRight)
        {
            _DOMImageElement.style.top = FLOOR(centerY - imageHeight / 2.0) + "px";
            _DOMImageElement.style.left = FLOOR(size.width - imageWidth) + "px";

            titleRect.size.width -= imageWidth;
        }
        else if(_imagePosition == CPImageOnly)
        {
            _DOMImageElement.style.top = FLOOR(centerY - imageHeight / 2.0) + "px";
            _DOMImageElement.style.left = FLOOR(centerX - imageWidth / 2.0) + "px";
        }
    }

    if (_bezelStyle == CPHUDBezelStyle)
        titleRect.origin.y -= 2.0;
    else if (_bezelStyle == CPRoundRectBezelStyle)
        titleRect.origin.y -= 1.0;
    else if (_bezelStyle == CPTexturedRoundedBezelStyle)
        titleRect.origin.y -= 2.0;

    objj_msgSend(_titleField, "setFrame:", titleRect);
}
});
instance_methods[23] = new objj_method(sel_registerName("sizeToFit"), function(self, _cmd)
{ with(self)
{
    var size = CGSizeMakeZero();

    if (_imagePosition != CPNoImage && _image)
    {
        var imageSize = objj_msgSend(_image, "size");

        size.width += imageSize.width;
        size.height += imageSize.height;
    }

    if (_imagePosition != CPImageOnly && objj_msgSend(_title, "length"))
    {
        objj_msgSend(_titleField, "sizeToFit");

        var titleFieldSize = objj_msgSend(_titleField, "frame").size;

        if (_imagePosition == CPImageLeft || _imagePosition == CPImageRight)
        {
            size.width += titleFieldSize.width
            size.height = MAX(size.height, titleFieldSize.height);
        }
        else if (_imagePosition == CPImageAbove || _imagePosition == CPImageBelow)
        {
            size.width = MAX(size.widht, titleFieldSize.width);
            size.height += titleFieldSize.height;
        }
        else
        {
            size.width = MAX(size.width, titleFieldSize.width);
            size.height = MAX(size.height, titleFieldSize.height);
        }
    }

    objj_msgSend(self, "setFrameSize:", size);
}
});
instance_methods[24] = new objj_method(sel_registerName("setFrameSize:"), function(self, _cmd, aSize)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "setFrameSize:", aSize);

    objj_msgSend(self, "tile");
}
});
instance_methods[25] = new objj_method(sel_registerName("highlight:"), function(self, _cmd, aFlag)
{ with(self)
{
    objj_msgSend(self, "drawBezelWithHighlight:", aFlag);

    if (aFlag)
        _DOMImageElement.src = objj_msgSend(_alternateImage, "filename");
    else
        _DOMImageElement.src = objj_msgSend(_image, "filename");
}
});
instance_methods[26] = new objj_method(sel_registerName("setTag:"), function(self, _cmd, aTag)
{ with(self)
{
    _tag = aTag;
}
});
instance_methods[27] = new objj_method(sel_registerName("tag"), function(self, _cmd)
{ with(self)
{
    return _tag;
}
});
instance_methods[28] = new objj_method(sel_registerName("mouseDown:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(self, "highlight:", YES);
}
});
instance_methods[29] = new objj_method(sel_registerName("mouseDragged:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(self, "highlight:", CPRectContainsPoint(objj_msgSend(self, "bounds"),objj_msgSend(self, "convertPoint:fromView:", objj_msgSend(anEvent, "locationInWindow"), nil)));
}
});
instance_methods[30] = new objj_method(sel_registerName("mouseUp:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(self, "highlight:", NO);

    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "mouseUp:", anEvent);
}
});
instance_methods[31] = new objj_method(sel_registerName("setControlSize:"), function(self, _cmd, aControlSize)
{ with(self)
{
    if (_controlSize == aControlSize)
        return;

    _controlSize = aControlSize;

    objj_msgSend(self, "drawBezelWithHighlight:", NO);
    objj_msgSend(self, "_updateTextAttributes");
}
});
instance_methods[32] = new objj_method(sel_registerName("controlSize"), function(self, _cmd)
{ with(self)
{
    return _controlSize;
}
});
instance_methods[33] = new objj_method(sel_registerName("setBordered:"), function(self, _cmd, isBordered)
{ with(self)
{
    if (_isBordered == isBordered)
        return;

    _isBordered = isBordered;

    objj_msgSend(self, "drawBezelWithHighlight:", NO);
}
});
instance_methods[34] = new objj_method(sel_registerName("isBordered"), function(self, _cmd)
{ with(self)
{
    return _isBordered;
}
});
instance_methods[35] = new objj_method(sel_registerName("setBezelStyle:"), function(self, _cmd, aBezelStyle)
{ with(self)
{
    if (_bezelStyle == aBezelStyle)
        return;

    _bezelStyle = aBezelStyle;

    objj_msgSend(self, "drawBezelWithHighlight:", NO);
    objj_msgSend(self, "_updateTextAttributes");
}
});
instance_methods[36] = new objj_method(sel_registerName("bezelStyle"), function(self, _cmd)
{ with(self)
{
    return _bezelStyle;
}
});
instance_methods[37] = new objj_method(sel_registerName("drawBezelWithHighlight:"), function(self, _cmd, shouldHighlight)
{ with(self)
{
    _bezelBorderNeedsUpdate = !objj_msgSend(self, "window");

    if (_bezelBorderNeedsUpdate)
        return;

    if (!_isBordered)
    {
        objj_msgSend(_bezelBorderView, "removeFromSuperview");

        _bezelBorderView = nil;

        return;
    }

    if (!_bezelBorderView)
    {
        _bezelBorderView = objj_msgSend(objj_msgSend(CPThreePartImageView, "alloc"), "initWithFrame:", CGRectMakeCopy(objj_msgSend(self, "bounds")));

        objj_msgSend(_bezelBorderView, "setAutoresizingMask:", CPViewWidthSizable);

        objj_msgSend(self, "insertSubview:atIndex:", _bezelBorderView, 0);
    }
    try {
    objj_msgSend(_bezelBorderView, "setImages:", _CPControlThreePartImages(_CPButtonBezelStyleSizes,_CPButtonClassName,_CPButtonBezelStyleIdentifiers[_bezelStyle],_CPControlIdentifierForControlSize(_controlSize),shouldHighlight?_CPButtonBezelStyleHighlightedIdentifier:""));}catch(e) { alert(_CPButtonBezelStyleSizes + _CPButtonClassName + _CPButtonBezelStyleIdentifiers[_bezelStyle] + _CPControlIdentifierForControlSize(_controlSize)) }
}
});
instance_methods[38] = new objj_method(sel_registerName("viewDidMoveToWindow"), function(self, _cmd)
{ with(self)
{
    if (_bezelBorderNeedsUpdate)
        objj_msgSend(self, "drawBezelWithHighlight:", NO);
}
});
instance_methods[39] = new objj_method(sel_registerName("_updateTextAttributes"), function(self, _cmd)
{ with(self)
{
    if (_bezelStyle == CPHUDBezelStyle)
        objj_msgSend(self, "setTextColor:", CPHUDBezelStyleTextColor);

    if (_controlSize == CPRegularControlSize)
        objj_msgSend(self, "setFont:", objj_msgSend(CPFont, "systemFontOfSize:", 11.0));

    objj_msgSend(self, "tile");
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}


var CPButtonImageKey = "CPButtonImageKey",
    CPButtonAlternateImageKey = "CPButtonAlteranteImageKey",
    CPButtonImagePositionKey = "CPButtonImagePositionKey";

{
var the_class = objj_getClass("CPButton")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPButton\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "initWithCoder:", aCoder);

    if (self)
    {
        objj_msgSend(self, "setup");

        objj_msgSend(self, "setImage:", objj_msgSend(aCoder, "decodeObjectForKey:", CPButtonImageKey));
        objj_msgSend(self, "setAlternateImage:", objj_msgSend(aCoder, "decodeObjectForKey:", CPButtonAlternateImageKey));
        objj_msgSend(self, "setImagePosition:", objj_msgSend(aCoder, "decodeIntForKey:", CPButtonImagePositionKey));
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("encodeWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "encodeWithCoder:", aCoder);

    objj_msgSend(aCoder, "encodeObject:forKey:", _image, CPButtonImageKey);
    objj_msgSend(aCoder, "encodeObject:forKey:", _alternateImage, CPButtonAlternateImageKey);
    objj_msgSend(aCoder, "encodeInt:forKey:", _imagePosition, CPButtonImagePositionKey);
}
});
class_addMethods(the_class, instance_methods);
}

p;12;CPClipView.ji;8;CPView.jc;1724;

{var the_class = objj_allocateClassPair(CPView, "CPClipView"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_documentView"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("setDocumentView:"), function(self, _cmd, aView)
{ with(self)
{
    if (_documentView == aView)
        return;



    objj_msgSend(_documentView, "removeFromSuperview");

    objj_msgSend(_documentView=aView, "setFrameOrigin:", CPPointMake(0.0,0.0));
    objj_msgSend(self, "addSubview:", _documentView);
}
});
instance_methods[1] = new objj_method(sel_registerName("documentView"), function(self, _cmd)
{ with(self)
{
    return _documentView;
}
});
instance_methods[2] = new objj_method(sel_registerName("constrainScrollPoint:"), function(self, _cmd, aPoint)
{ with(self)
{
    var bounds = objj_msgSend(self, "bounds"),
        documentFrame = objj_msgSend(_documentView, "frame"),
        difference = CGSizeMake(MIN(0.0, CGRectGetWidth(bounds) - CGRectGetWidth(documentFrame)), MIN(0.0, CGRectGetHeight(bounds) - CGRectGetHeight(documentFrame)));

    aPoint.x = MIN(0.0, MAX(difference.width, aPoint.x));
    aPoint.y = MIN(0.0, MAX(difference.height, aPoint.y));

    return aPoint;
}
});
instance_methods[3] = new objj_method(sel_registerName("scrollToPoint:"), function(self, _cmd, aPoint)
{ with(self)
{
    objj_msgSend(_documentView, "setFrameOrigin:", objj_msgSend(self, "constrainScrollPoint:", aPoint));

    var superview = objj_msgSend(self, "superview");





}
});
class_addMethods(the_class, instance_methods);
}

p;18;CPCollectionView.jI;20;Foundation/CPArray.jI;19;Foundation/CPData.jI;23;Foundation/CPIndexSet.jI;28;Foundation/CPKeyedArchiver.jI;30;Foundation/CPKeyedUnarchiver.jI;15;AppKit/CPView.jc;16969;


{var the_class = objj_allocateClassPair(CPView, "CPCollectionView"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_content"), new objj_ivar("_items"), new objj_ivar("_itemData"), new objj_ivar("_itemPrototype"), new objj_ivar("_itemForDragging"), new objj_ivar("_cachedItems"), new objj_ivar("_maxNumberOfRows"), new objj_ivar("_maxNumberOfColumns"), new objj_ivar("_minItemSize"), new objj_ivar("_maxItemSize"), new objj_ivar("_tileWidth"), new objj_ivar("_isSelectable"), new objj_ivar("_allowsMultipleSelection"), new objj_ivar("_selectionIndexes"), new objj_ivar("_itemSize"), new objj_ivar("_horizontalMargin"), new objj_ivar("_verticalMargin"), new objj_ivar("_numberOfRows"), new objj_ivar("_numberOfColumns"), new objj_ivar("_delegate"), new objj_ivar("_scrollView"), new objj_ivar("_contentView"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "initWithFrame:", aFrame);

    if (self)
    {
        _items = [];
        _content = [];

        _cachedItems = [];

        _itemSize = CGSizeMakeZero();
        _minItemSize = CGSizeMakeZero();
        _maxItemSize = CGSizeMakeZero();

        _verticalMargin = 5.0;
        _tileWidth = -1.0;

        _selectionIndexes = objj_msgSend(CPIndexSet, "indexSet");
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setItemPrototype:"), function(self, _cmd, anItem)
{ with(self)
{
    _itemData = objj_msgSend(CPKeyedArchiver, "archivedDataWithRootObject:", anItem);
    _itemForDragging = anItem

    objj_msgSend(self, "reloadContent");
}
});
instance_methods[2] = new objj_method(sel_registerName("itemPrototype"), function(self, _cmd)
{ with(self)
{
    return _itemPrototype;
}
});
instance_methods[3] = new objj_method(sel_registerName("newItemForRepresentedObject:"), function(self, _cmd, anObject)
{ with(self)
{
    var item = nil;

    if (_cachedItems.length)
        item = _cachedItems.pop();
    else
        item = objj_msgSend(CPKeyedUnarchiver, "unarchiveObjectWithData:", _itemData);

    objj_msgSend(item, "setRepresentedObject:", anObject);
    objj_msgSend(objj_msgSend(item, "view"), "setFrameSize:", _itemSize);

    return item;
}
});
instance_methods[4] = new objj_method(sel_registerName("acceptsFirstResponder"), function(self, _cmd)
{ with(self)
{
    return YES;
}
});
instance_methods[5] = new objj_method(sel_registerName("isFirstResponder"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(objj_msgSend(self, "window"), "firstResponder") == self;
}
});
instance_methods[6] = new objj_method(sel_registerName("setContent:"), function(self, _cmd, anArray)
{ with(self)
{
    if (_content == anArray)
        return;

    _content = anArray;

    objj_msgSend(self, "reloadContent");
}
});
instance_methods[7] = new objj_method(sel_registerName("content"), function(self, _cmd)
{ with(self)
{
    return _content;
}
});
instance_methods[8] = new objj_method(sel_registerName("setSelectable:"), function(self, _cmd, isSelectable)
{ with(self)
{
    if (_isSelectable == isSelectable)
        return;

    _isSelectable = isSelectable;

    if (!_isSelectable)
    {
        var index = CPNotFound;

        while ((index = objj_msgSend(_selectionIndexes, "indexGreaterThanIndex:", index)) != CPNotFound)
            objj_msgSend(_items[index], "setSelected:", NO);
    }
}
});
instance_methods[9] = new objj_method(sel_registerName("isSelected"), function(self, _cmd)
{ with(self)
{
    return _isSelected;
}
});
instance_methods[10] = new objj_method(sel_registerName("setAllowsMultipleSelection:"), function(self, _cmd, shouldAllowMultipleSelection)
{ with(self)
{
    _allowsMultipleSelection = shouldAllowsMultipleSelection;
}
});
instance_methods[11] = new objj_method(sel_registerName("allowsMultipleSelection"), function(self, _cmd)
{ with(self)
{
    return _allowsMultipleSelection;
}
});
instance_methods[12] = new objj_method(sel_registerName("setSelectionIndexes:"), function(self, _cmd, anIndexSet)
{ with(self)
{
    if (_selectionIndexes == anIndexSet)
        return;

    var index = CPNotFound;

    while ((index = objj_msgSend(_selectionIndexes, "indexGreaterThanIndex:", index)) != CPNotFound)
        objj_msgSend(_items[index], "setSelected:", NO);

    _selectionIndexes = anIndexSet;

    var index = CPNotFound;

    while ((index = objj_msgSend(_selectionIndexes, "indexGreaterThanIndex:", index)) != CPNotFound)
        objj_msgSend(_items[index], "setSelected:", YES);

    if (objj_msgSend(_delegate, "respondsToSelector:", sel_registerName("collectionViewDidChangeSelection:")))
        objj_msgSend(_delegate, "collectionViewDidChangeSelection:", self)
}
});
instance_methods[13] = new objj_method(sel_registerName("selectionIndexes"), function(self, _cmd)
{ with(self)
{
    return _selectionIndexes;
}
});
instance_methods[14] = new objj_method(sel_registerName("reloadContent"), function(self, _cmd)
{ with(self)
{

    var count = _items.length;

    while (count--)
    {
        objj_msgSend(objj_msgSend(_items[count], "view"), "removeFromSuperview");
        _cachedItems.push(_items[count]);
    }

    _items = [];

    if (!_itemData || !_content)
        return;

    var index = 0;

    count = _content.length;

    for (; index < count; ++index)
    {
        _items.push(objj_msgSend(self, "newItemForRepresentedObject:", _content[index]));

        objj_msgSend(self, "addSubview:", objj_msgSend(_items[index], "view"));
    }

    objj_msgSend(self, "tile");
}
});
instance_methods[15] = new objj_method(sel_registerName("tile"), function(self, _cmd)
{ with(self)
{
    var width = CGRectGetWidth(objj_msgSend(self, "bounds"));

    if (!objj_msgSend(_content, "count") || width == _tileWidth)
        return;




    var itemSize = CGSizeMakeCopy(_minItemSize);

    _numberOfColumns = MAX(1.0, FLOOR(width / itemSize.width));

    if (_maxNumberOfColumns > 0)
        _numberOfColumns = MIN(_maxNumberOfColumns, _numberOfColumns);

    _numberOfRows = CEIL(count / _numberOfColumns);

    var remaining = width - _numberOfColumns * itemSize.width,
        itemsNeedSizeUpdate = NO;

    if (remaining > 0 && itemSize.width < _maxItemSize.width)
        itemSize.width = MIN(_maxItemSize.width, itemSize.width + FLOOR(remaining / _numberOfColumns));

    if (!CGSizeEqualToSize(_itemSize, itemSize))
    {
        _itemSize = itemSize;
        itemsNeedSizeUpdate = YES;
    }

    var index = 0,
        count = _items.length;

    if (_maxNumberOfColumns > 0 && _maxNumberOfRows > 0)
        count = MIN(count, _maxNumberOfColumns * _maxNumberOfRows);

    _horizontalMargin = FLOOR((width - _numberOfColumns * itemSize.width) / (_numberOfColumns + 1));

    var x = _horizontalMargin,
        y = -itemSize.height;

    for (; index < count; ++index)
    {
        if (index % _numberOfColumns == 0)
        {
            x = _horizontalMargin;
            y += _verticalMargin + itemSize.height;
        }

        var view = objj_msgSend(_items[index], "view");

        objj_msgSend(view, "setFrameOrigin:", CGPointMake(x,y));

        if (itemsNeedSizeUpdate)
            objj_msgSend(view, "setFrameSize:", _itemSize);

        x += itemSize.width + _horizontalMargin;
    }

    _tileWidth = width;
    objj_msgSend(self, "setFrameSize:", CGSizeMake(width,y+itemSize.height+_verticalMargin));
    _tileWidth = -1.0;
}
});
instance_methods[16] = new objj_method(sel_registerName("resizeSubviewsWithOldSize:"), function(self, _cmd, aSize)
{ with(self)
{
    objj_msgSend(self, "tile");
}
});
instance_methods[17] = new objj_method(sel_registerName("setMaxNumberOfRows:"), function(self, _cmd, aMaxNumberOfRows)
{ with(self)
{
    if (_maxNumberOfRows == aMaxNumberOfRows)
        return;

    _maxNumberOfRows = aMaxNumberOfRows;

    objj_msgSend(self, "tile");
}
});
instance_methods[18] = new objj_method(sel_registerName("maxNumberOfRows"), function(self, _cmd)
{ with(self)
{
    return _maxNumberOfRows;
}
});
instance_methods[19] = new objj_method(sel_registerName("setMaxNumberOfColumns:"), function(self, _cmd, aMaxNumberOfColumns)
{ with(self)
{
    if (_maxNumberOfColumns == aMaxNumberOfColumns)
        return;

    _maxNumberOfColumns = aMaxNumberOfColumns;

    objj_msgSend(self, "tile");
}
});
instance_methods[20] = new objj_method(sel_registerName("maxNumberOfColumns"), function(self, _cmd)
{ with(self)
{
    return _maxNumberOfColumns;
}
});
instance_methods[21] = new objj_method(sel_registerName("setMinItemSize:"), function(self, _cmd, aSize)
{ with(self)
{
    if (CGSizeEqualToSize(_minItemSize, aSize))
        return;

    _minItemSize = CGSizeMakeCopy(aSize);

    objj_msgSend(self, "tile");
}
});
instance_methods[22] = new objj_method(sel_registerName("minItemSize"), function(self, _cmd)
{ with(self)
{
    return _minItemSize;
}
});
instance_methods[23] = new objj_method(sel_registerName("setMaxItemSize:"), function(self, _cmd, aSize)
{ with(self)
{
    if (CGSizeEqualToSize(_maxItemSize, aSize))
        return;

    _maxItemSize = CGSizeMakeCopy(aSize);

    objj_msgSend(self, "tile");
}
});
instance_methods[24] = new objj_method(sel_registerName("maxItemSize"), function(self, _cmd)
{ with(self)
{
    return _maxItemSize;
}
});
instance_methods[25] = new objj_method(sel_registerName("mouseUp:"), function(self, _cmd, anEvent)
{ with(self)
{
    if (objj_msgSend(_selectionIndexes, "count") && objj_msgSend(anEvent, "clickCount") == 2 && objj_msgSend(_delegate, "respondsToSelector:", sel_registerName("collectionView:didDoubleClickOnItemAtIndex:")))
        objj_msgSend(_delegate, "collectionView:didDoubleClickOnItemAtIndex:", self, objj_msgSend(_selectionIndexes, "firstIndex"));
}
});
instance_methods[26] = new objj_method(sel_registerName("mouseDown:"), function(self, _cmd, anEvent)
{ with(self)
{
    var location = objj_msgSend(self, "convertPoint:fromView:", objj_msgSend(anEvent, "locationInWindow"), nil),
        row = FLOOR(location.y / (_itemSize.height + _verticalMargin)),
        column = FLOOR(location.x / (_itemSize.width + _horizontalMargin)),
        index = row * _numberOfColumns + column;

    if (index >= 0 && index < _items.length)
        objj_msgSend(self, "setSelectionIndexes:", objj_msgSend(CPIndexSet, "indexSetWithIndex:", index));
}
});
instance_methods[27] = new objj_method(sel_registerName("mouseDragged:"), function(self, _cmd, anEvent)
{ with(self)
{
    if (!objj_msgSend(_delegate, "respondsToSelector:", sel_registerName("collectionView:dragTypesForItemsAtIndexes:")))
        return;


    if (!objj_msgSend(_selectionIndexes, "count"))
        return;


    var dragTypes = objj_msgSend(_delegate, "collectionView:dragTypesForItemsAtIndexes:", self, _selectionIndexes);

    objj_msgSend(objj_msgSend(CPPasteboard, "pasteboardWithName:", CPDragPboard), "declareTypes:owner:", dragTypes, self);

    var point = objj_msgSend(self, "convertPoint:fromView:", objj_msgSend(anEvent, "locationInWindow"), nil);

    objj_msgSend(_itemForDragging, "setRepresentedObject:", _content[objj_msgSend(_selectionIndexes, "firstIndex")]);

    var view = objj_msgSend(_itemForDragging, "view"),
        frame = objj_msgSend(view, "frame");

    objj_msgSend(view, "setFrameSize:", _itemSize);

    objj_msgSend(self, "dragView:at:offset:event:pasteboard:source:slideBack:", view, objj_msgSend(objj_msgSend(_items[objj_msgSend(_selectionIndexes, "firstIndex")], "view"), "frame").origin, CGPointMakeZero(), anEvent, nil, self, YES);
}
});
instance_methods[28] = new objj_method(sel_registerName("pasteboard:provideDataForType:"), function(self, _cmd, aPasteboard, aType)
{ with(self)
{
    objj_msgSend(aPasteboard, "setData:forType:", objj_msgSend(_delegate, "collectionView:dataForItemsAtIndexes:forType:", self, _selectionIndexes, aType), aType);
}
});
instance_methods[29] = new objj_method(sel_registerName("setVerticalMargin:"), function(self, _cmd, aVerticalMargin)
{ with(self)
{
    if (_verticalMargin == aVerticalMargin)
        return;

    _verticalMargin = aVerticalMargin;

    objj_msgSend(self, "tile");
}
});
instance_methods[30] = new objj_method(sel_registerName("setDelegate:"), function(self, _cmd, aDelegate)
{ with(self)
{
    _delegate = aDelegate;
}
});
instance_methods[31] = new objj_method(sel_registerName("delegate"), function(self, _cmd)
{ with(self)
{
    return _delegate;
}
});
class_addMethods(the_class, instance_methods);
}

{
var the_class = objj_getClass("CPCollectionView")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPCollectionView\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("viewDidMoveToSuperview"), function(self, _cmd)
{ with(self)
{
    var enclosingScrollView = objj_msgSend(self, "enclosingScrollView");

    if (enclosingScrollView != objj_msgSend(objj_msgSend(self, "superview"), "superview"))
    {
        _scrollView = nil;
        _contentView = nil;

        return;
    }

    _scrollView = enclosingScrollView;
    _contentView = objj_msgSend(_scrollView, "contentView");
}
});
instance_methods[1] = new objj_method(sel_registerName("setFrameSize:"), function(self, _cmd, aSize)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "setFrameSize:", aSize);


    objj_msgSend(_scrollView, "reflectScrolledClipView:", _contentView);
}
});
class_addMethods(the_class, instance_methods);
}

{var the_class = objj_allocateClassPair(CPObject, "CPCollectionViewItem"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_representedObject"), new objj_ivar("_view"), new objj_ivar("_isSelected"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("setRepresentedObject:"), function(self, _cmd, anObject)
{ with(self)
{
    if (_representedObject == anObject)
        return;

    _representedObject = anObject;


    objj_msgSend(_view, "setRepresentedObject:", anObject);
}
});
instance_methods[1] = new objj_method(sel_registerName("representedObject"), function(self, _cmd)
{ with(self)
{
    return _representedObject;
}
});
instance_methods[2] = new objj_method(sel_registerName("setView:"), function(self, _cmd, aView)
{ with(self)
{
    _view = aView;
}
});
instance_methods[3] = new objj_method(sel_registerName("view"), function(self, _cmd)
{ with(self)
{
    return _view;
}
});
instance_methods[4] = new objj_method(sel_registerName("setSelected:"), function(self, _cmd, shouldBeSelected)
{ with(self)
{
    if (_isSelected == shouldBeSelected)
        return;

    _isSelected = shouldBeSelected;


    objj_msgSend(_view, "setSelected:", _isSelected);
}
});
instance_methods[5] = new objj_method(sel_registerName("isSelected"), function(self, _cmd)
{ with(self)
{
    return _isSelected;
}
});
instance_methods[6] = new objj_method(sel_registerName("collectionView"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(_view, "superview");
}
});
class_addMethods(the_class, instance_methods);
}

var CPCollectionViewItemViewKey = "CPCollectionViewItemViewKey";

{
var the_class = objj_getClass("CPCollectionViewItem")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPCollectionViewItem\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("copy"), function(self, _cmd)
{ with(self)
{}
});
class_addMethods(the_class, instance_methods);
}

var CPCollectionViewItemViewKey = "CPCollectionViewItemViewKey";

{
var the_class = objj_getClass("CPCollectionViewItem")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPCollectionViewItem\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
        _view = objj_msgSend(aCoder, "decodeObjectForKey:", CPCollectionViewItemViewKey);

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("encodeWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    objj_msgSend(aCoder, "encodeObject:forKey:", _view, CPCollectionViewItemViewKey);
}
});
class_addMethods(the_class, instance_methods);
}

p;9;CPColor.jI;21;Foundation/CPObject.ji;9;CGColor.ji;17;CPCompatibility.ji;9;CPImage.jc;16057;

var _redComponent = 0,
    _greenComponent = 1,
    _blueComponent = 2,
    _alphaCompnent = 3;

var _hueComponent = 0,
    _saturationComponent = 1,
    _brightnessComponent = 2;

{var the_class = objj_allocateClassPair(CPObject, "CPColor"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_components"), new objj_ivar("_patternImage"), new objj_ivar("_cssString"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("colorWithCalibratedRed:green:blue:alpha:"), function(self, _cmd, red, green, blue, alpha)
{ with(self)
{
    return objj_msgSend(objj_msgSend(CPColor, "alloc"), "_initWithRGBA:", [red,green,blue,alpha]);
}
});
class_methods[1] = new objj_method(sel_registerName("colorWithCalibratedWhite:alpha:"), function(self, _cmd, white, alpha)
{ with(self)
{
    return objj_msgSend(objj_msgSend(CPColor, "alloc"), "_initWithRGBA:", [white,white,white,alpha]);
}
});
class_methods[2] = new objj_method(sel_registerName("colorWithHue:saturation:brightness:"), function(self, _cmd, hue, saturation, brightness)
{ with(self)
{
    if(saturation == 0.0)
        return objj_msgSend(CPColor, "colorWithCalibratedWhite:alpha:", brightness/100.0, 1.0);

    var f = hue % 60,
        p = (brightness * (100 - saturation)) / 10000,
        q = (brightness * (6000 - saturation * f)) / 600000,
        t = (brightness * (6000 - saturation * (60 -f))) / 600000,
        b = brightness / 100.0;

    switch(FLOOR(hue / 60))
    {
        case 0: return objj_msgSend(CPColor, "colorWithCalibratedRed:green:blue:alpha:", b, t, p, 1.0);
        case 1: return objj_msgSend(CPColor, "colorWithCalibratedRed:green:blue:alpha:", q, b, p, 1.0);
        case 2: return objj_msgSend(CPColor, "colorWithCalibratedRed:green:blue:alpha:", p, b, t, 1.0);
        case 3: return objj_msgSend(CPColor, "colorWithCalibratedRed:green:blue:alpha:", p, q, b, 1.0);
        case 4: return objj_msgSend(CPColor, "colorWithCalibratedRed:green:blue:alpha:", t, p, b, 1.0);
        case 5: return objj_msgSend(CPColor, "colorWithCalibratedRed:green:blue:alpha:", b, p, q, 1.0);
    }
}
});
class_methods[3] = new objj_method(sel_registerName("colorWithHexString:"), function(self, _cmd, hex)
{ with(self)
{
    return objj_msgSend(objj_msgSend(CPColor, "alloc"), "_initWithRGBA:", hexToRGB(hex));
}
});
class_methods[4] = new objj_method(sel_registerName("blackColor"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(objj_msgSend(CPColor, "alloc"), "_initWithRGBA:", [0.0,0.0,0.0,1.0]);
}
});
class_methods[5] = new objj_method(sel_registerName("blueColor"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(objj_msgSend(CPColor, "alloc"), "_initWithRGBA:", [0.0,0.0,1.0,1.0]);
}
});
class_methods[6] = new objj_method(sel_registerName("darkGrayColor"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(CPColor, "colorWithCalibratedWhite:alpha:", 1.0/3.0, 1.0);
}
});
class_methods[7] = new objj_method(sel_registerName("grayColor"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(CPColor, "colorWithCalibratedWhite:alpha:", 0.5, 1.0);
}
});
class_methods[8] = new objj_method(sel_registerName("greenColor"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(objj_msgSend(CPColor, "alloc"), "_initWithRGBA:", [0.0,1.0,0.0,1.0]);
}
});
class_methods[9] = new objj_method(sel_registerName("lightGrayColor"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(CPColor, "colorWithCalibratedWhite:alpha:", 2.0/3.0, 1.0);
}
});
class_methods[10] = new objj_method(sel_registerName("redColor"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(objj_msgSend(CPColor, "alloc"), "_initWithRGBA:", [1.0,0.0,0.0,1.0]);
}
});
class_methods[11] = new objj_method(sel_registerName("whiteColor"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(objj_msgSend(CPColor, "alloc"), "_initWithRGBA:", [1.0,1.0,1.0,1.0]);
}
});
class_methods[12] = new objj_method(sel_registerName("yellowColor"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(objj_msgSend(CPColor, "alloc"), "_initWithRGBA:", [1.0,1.0,0.0,1.0]);
}
});
class_methods[13] = new objj_method(sel_registerName("shadowColor"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(objj_msgSend(CPColor, "alloc"), "_initWithRGBA:", [0.0,0.0,0.0,1.0/3.0]);
}
});
class_methods[14] = new objj_method(sel_registerName("colorWithPatternImage:"), function(self, _cmd, anImage)
{ with(self)
{
    return objj_msgSend(objj_msgSend(CPColor, "alloc"), "_initWithPatternImage:", anImage);
}
});
class_methods[15] = new objj_method(sel_registerName("colorWithCSSString:"), function(self, _cmd, aString)
{ with(self)
{
    return objj_msgSend(objj_msgSend(CPColor, "alloc"), "_initWithCSSString:", aString);
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("_initWithCSSString:"), function(self, _cmd, aString)
{ with(self)
{
    if(aString.indexOf("rgb") == CPNotFound)
        return nil;

    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    var startingIndex = aString.indexOf("(");
    var parts = aString.substring(startingIndex+1).split(',');

    _components = [parseInt(parts[0],10)/255.0,parseInt(parts[1],10)/255.0,parseInt(parts[2],10)/255.0,parts[3]?parseInt(parts[3],10)/255.0:1.0]

    _cssString = aString;

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("_initWithRGBA:"), function(self, _cmd, components)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
    {
        _components = components;

  if (!CPFeatureIsCompatible(CPCSSRGBAFeature) && _components[3] != 1.0 && window.Base64 && window.CRC32)
  {
   var bytes = [0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1,0x8,0x3,0x0,0x0,0x0,0x28,0xcb,0x34,0xbb,0x0,0x0,0x3,0x0,0x50,0x4c,0x54,0x45,0xff,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x17,0x89,0x99,0x55,0x0,0x0,0x0,0x1,0x74,0x52,0x4e,0x53,0x0,0x40,0xe6,0xd8,0x66,0x0,0x0,0x0,0x10,0x49,0x44,0x41,0x54,0x78,0xda,0x62,0x60,0x0,0x0,0x0,0x0,0xff,0xff,0x3,0x0,0x0,0x2,0x0,0x1,0x24,0x7f,0x24,0xf1,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82,0xff];
   var r_off = 41;
   var g_off = 42;
   var b_off = 43;
   var a_off = 821;
   var plte_crc_off = 809;
   var trns_crc_off = 822;
   var plte_type_off = 37;
   var trns_type_off = 817;

   bytes[r_off] = Math.round(_components[0]*255);
   bytes[g_off] = Math.round(_components[1]*255);
   bytes[b_off] = Math.round(_components[2]*255);
   bytes[a_off] = Math.round(_components[3]*255);


   var new_plte_crc = integerToBytes(CRC32.getCRC(bytes, plte_type_off, 4+768), 4);
   var new_trns_crc = integerToBytes(CRC32.getCRC(bytes, trns_type_off, 4+1), 4);


   for (var i = 0; i < 4; i++)
   {
    bytes[plte_crc_off+i] = new_plte_crc[i];
    bytes[trns_crc_off+i] = new_trns_crc[i];
   }


   var base64image = Base64.encode(bytes);

   _cssString = "url(\"data:image/png;base64," + base64image + "\")";
  }
  else
  {
         var hasAlpha = CPFeatureIsCompatible(CPCSSRGBAFeature) && _components[3] != 1.0;

         _cssString = (hasAlpha ? "rgba(" : "rgb(") +
             parseInt(_components[0] * 255.0) + ", " +
             parseInt(_components[1] * 255.0) + ", " +
             parseInt(_components[2] * 255.0) +
             (hasAlpha ? (", " + _components[3]) : "") + ")";
  }
    }
    return self;
}
});
instance_methods[2] = new objj_method(sel_registerName("_initWithPatternImage:"), function(self, _cmd, anImage)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
    {
        _patternImage = anImage;
        _cssString = "url(\"" + _patternImage._filename + "\")";
    }

    return self;
}
});
instance_methods[3] = new objj_method(sel_registerName("patternImage"), function(self, _cmd)
{ with(self)
{
    return _patternImage;
}
});
instance_methods[4] = new objj_method(sel_registerName("alphaComponent"), function(self, _cmd)
{ with(self)
{
    return _components[3];
}
});
instance_methods[5] = new objj_method(sel_registerName("blueComponent"), function(self, _cmd)
{ with(self)
{
    return _components[2];
}
});
instance_methods[6] = new objj_method(sel_registerName("greenComponent"), function(self, _cmd)
{ with(self)
{
    return _components[1];
}
});
instance_methods[7] = new objj_method(sel_registerName("redComponent"), function(self, _cmd)
{ with(self)
{
    return _components[0];
}
});
instance_methods[8] = new objj_method(sel_registerName("components"), function(self, _cmd)
{ with(self)
{
    return _components;
}
});
instance_methods[9] = new objj_method(sel_registerName("colorWithAlphaComponent:"), function(self, _cmd, anAlphaComponent)
{ with(self)
{
    var components = _components.slice();

    components[components.length-1] = anAlphaComponent;

    return objj_msgSend(objj_msgSend(objj_msgSend(self, "class"), "alloc"), "_initWithRGBA:", components);
}
});
instance_methods[10] = new objj_method(sel_registerName("hsbComponents"), function(self, _cmd)
{ with(self)
{
    var red = ROUND(_components[_redComponent] * 255.0),
        green = ROUND(_components[_greenComponent] * 255.0),
        blue = ROUND(_components[_blueComponent] * 255.0);

    var max = MAX(red, green, blue),
        min = MIN(red, green, blue),
        delta = max - min;

    var brightness = max / 255.0,
        saturation = (max != 0) ? delta / max : 0;

    var hue;
    if(saturation == 0)
        hue = 0;
    else
    {
        var rr = (max - red) / delta;
        var gr = (max - green) / delta;
        var br = (max - blue) / delta;

        if (red == max)
            hue = br - gr;
        else if (green == max)
            hue = 2 + rr - br;
        else
            hue = 4 + gr - rr;

        hue /= 6;
        if (hue < 0)
            hue++;
    }

    return [ROUND(hue*360.0),ROUND(saturation*100.0),ROUND(brightness*100.0)];
}
});
instance_methods[11] = new objj_method(sel_registerName("cssString"), function(self, _cmd)
{ with(self)
{
    return _cssString;
}
});
instance_methods[12] = new objj_method(sel_registerName("hexString"), function(self, _cmd)
{ with(self)
{
    return rgbToHex(objj_msgSend(self, "redComponent"), objj_msgSend(self, "greenComponent"), objj_msgSend(self, "blueComponent"))
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

var CPColorComponentsKey = "CPColorComponentsKey",
    CPColorPatternImageKey = "CPColorPatternImageKey";

{
var the_class = objj_getClass("CPColor")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPColor\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    if (objj_msgSend(aCoder, "containsValueForKey:", CPColorPatternImageKey))
        return objj_msgSend(self, "_initWithPatternImage:", objj_msgSend(aCoder, "decodeObjectForKey:", CPColorPatternImageKey));

    return objj_msgSend(self, "_initWithRGBA:", objj_msgSend(aCoder, "decodeObjectForKey:", CPColorComponentsKey));
}
});
instance_methods[1] = new objj_method(sel_registerName("encodeWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    if (_patternImage)
        objj_msgSend(aCoder, "encodeObject:forKey:", _patternImage, CPColorPatternImageKey);
    else
        objj_msgSend(aCoder, "encodeObject:forKey:", _components, CPColorComponentsKey);
}
});
class_addMethods(the_class, instance_methods);
}

var hexCharacters = "0123456789ABCDEF";

hexToRGB= function(hex)
{
    if(hex.length != 6)
        return null;

    for(var i=0; i<hex.length; i++)
        if(hexCharacters.indexOf(hex.charAt(i)) == -1)
            return null;

    var red = (hexCharacters.indexOf(hex.charAt(0)) * 16 + hexCharacters.indexOf(hex.charAt(1))) / 255.0;
    var green = (hexCharacters.indexOf(hex.charAt(2)) * 16 + hexCharacters.indexOf(hex.charAt(3))) / 255.0;
    var blue = (hexCharacters.indexOf(hex.charAt(4)) * 16 + hexCharacters.indexOf(hex.charAt(5))) / 255.0;

    return [red,green,blue,1.0];
}

integerToBytes= function(integer, length) {
 if (!length)
  length = (integer == 0) ? 1 : Math.round((Math.log(integer)/Math.log(2))/8+0.5);

 var bytes = new Array(length);
 for (var i = length-1; i >= 0; i--) {
  bytes[i] = integer & 255;
  integer = integer >> 8
 }
 return bytes;
}

rgbToHex= function(r,g,b) {
    return byteToHex(r) + byteToHex(g) + byteToHex(b);
}

byteToHex= function(n) {
    if (!n || isNaN(n)) return "00";
    n = ROUND(MIN(255,MAX(0,256*n)));
    return hexCharacters.charAt((n - n % 16) / 16) +
            hexCharacters.charAt(n % 16);
}

p;14;CPColorPanel.jI;23;Foundation/Foundation.jI;21;Foundation/CPCookie.jI;17;AppKit/CPButton.jI;22;AppKit/CPColorPicker.jI;27;AppKit/CPKulerColorPicker.jI;16;AppKit/CPPanel.jI;28;AppKit/CPSliderColorPicker.jI;15;AppKit/CPView.jc;22824;


CPColorPanelColorDidChangeNotification = "CPColorPanelColorDidChangeNotification";

var PREVIEW_HEIGHT = 20.0,
    TOOLBAR_HEIGHT = 32.0,
    SWATCH_HEIGHT = 14.0;

var SharedColorPanel = nil;

CPWheelColorPickerMode = 1,
CPKulerColorPickerMode = 2,
CPSliderColorPickerMode = 3;

CPColorPickerViewWidth = 265,
CPColorPickerViewHeight = 370;

{var the_class = objj_allocateClassPair(CPPanel, "CPColorPanel"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_toolbar"), new objj_ivar("_swatchView"), new objj_ivar("_previewView"), new objj_ivar("_previewLabel"), new objj_ivar("_swatchLabel"), new objj_ivar("_activeView"), new objj_ivar("_activePicker"), new objj_ivar("_wheelPicker"), new objj_ivar("_kulerPicker"), new objj_ivar("_sliderPicker"), new objj_ivar("_color"), new objj_ivar("_target"), new objj_ivar("_action"), new objj_ivar("_mode"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("sharedColorPanel"), function(self, _cmd)
{ with(self)
{
    if (!SharedColorPanel)
        SharedColorPanel = objj_msgSend(objj_msgSend(CPColorPanel, "alloc"), "init");

    return SharedColorPanel;
}
});
class_methods[1] = new objj_method(sel_registerName("setPickerMode:"), function(self, _cmd, mode)
{ with(self)
{
    var panel = objj_msgSend(CPColorPanel, "sharedColorPanel");
    objj_msgSend(panel, "setMode:", mode);
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("init"), function(self, _cmd)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPPanel") }, "initWithContentRect:styleMask:", CGRectMake(500.0,50.0,218.0,360.0), (CPHUDBackgroundWindowMask|CPTitledWindowMask|CPClosableWindowMask|CPResizableWindowMask));

    if (self)
    {
        objj_msgSend(self, "setTitle:", "Color Panel");
        objj_msgSend(self, "setLevel:", CPFloatingWindowLevel);

        objj_msgSend(self, "setBecomesKeyOnlyIfNeeded:", YES);

        objj_msgSend(self, "setMinSize:", CGSizeMake(218.0,360.0));
        objj_msgSend(self, "setMaxSize:", CGSizeMake(327.0,540.0));
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setColor:"), function(self, _cmd, aColor)
{ with(self)
{
    _color = aColor;
    objj_msgSend(_previewView, "setBackgroundColor:", _color);

    objj_msgSend(CPApp, "sendAction:to:from:", sel_registerName("changeColor:"), nil, self);

    if (_target && _action)
        objj_msgSend(_target, _action, self);

    objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:", CPColorPanelColorDidChangeNotification, self);
}
});
instance_methods[2] = new objj_method(sel_registerName("setColor:updatePicker:"), function(self, _cmd, aColor, bool)
{ with(self)
{
    objj_msgSend(self, "setColor:", aColor);

    if(bool)
        objj_msgSend(_activePicker, "setColor:", _color);
 }
});
instance_methods[3] = new objj_method(sel_registerName("color"), function(self, _cmd)
{ with(self)
{
    return _color;
}
});
instance_methods[4] = new objj_method(sel_registerName("setTarget:"), function(self, _cmd, aTarget)
{ with(self)
{
    _target = aTarget;
}
});
instance_methods[5] = new objj_method(sel_registerName("target"), function(self, _cmd)
{ with(self)
{
    return _target;
}
});
instance_methods[6] = new objj_method(sel_registerName("setAction:"), function(self, _cmd, anAction)
{ with(self)
{
    _action = anAction;
}
});
instance_methods[7] = new objj_method(sel_registerName("action"), function(self, _cmd)
{ with(self)
{
    return _action;
}
});
instance_methods[8] = new objj_method(sel_registerName("setMode:"), function(self, _cmd, mode)
{ with(self)
{
    if(mode == _mode)
        return;

    var frame = CPRectCreateCopy(objj_msgSend(_currentView, "frame"));
    objj_msgSend(_currentView, "removeFromSuperview");

    switch(mode)
    {
        case CPWheelColorPickerMode: _activePicker = _wheelPicker; break;
        case CPKulerColorPickerMode: _activePicker = _kulerPicker; break;
        case CPSliderColorPickerMode: _activePicker = _sliderPicker; break;
    }

    _currentView = objj_msgSend(_activePicker, "provideNewView:", NO);
    objj_msgSend(_activePicker, "setColor:", _color);

    _mode = mode;

    objj_msgSend(_currentView, "setFrame:", frame);
    objj_msgSend(_currentView, "setAutoresizingMask:", (CPViewWidthSizable|CPViewHeightSizable));
    objj_msgSend(objj_msgSend(self, "contentView"), "addSubview:", _currentView);
}
});
instance_methods[9] = new objj_method(sel_registerName("mode"), function(self, _cmd)
{ with(self)
{
    return _mode;
}
});
instance_methods[10] = new objj_method(sel_registerName("orderFront:"), function(self, _cmd, aSender)
{ with(self)
{
    objj_msgSend(self, "_loadContentsIfNecessary");

    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPPanel") }, "orderFront:", aSender);
}
});
instance_methods[11] = new objj_method(sel_registerName("_loadContentsIfNecessary"), function(self, _cmd)
{ with(self)
{
    if (_toolbar)
        return;

    var contentView = objj_msgSend(self, "contentView"),
        bounds = objj_msgSend(contentView, "bounds");

    _toolbar = objj_msgSend(objj_msgSend(_CPColorPanelToolbar, "alloc"), "initWithFrame:", CPRectMake(0,0,CGRectGetWidth(bounds),TOOLBAR_HEIGHT));
    objj_msgSend(_toolbar, "setAutoresizingMask:", CPViewWidthSizable);

    _previewView = objj_msgSend(objj_msgSend(_CPColorPanelPreview, "alloc"), "initWithFrame:", CPRectMake(76,TOOLBAR_HEIGHT+10,CGRectGetWidth(bounds)-86,PREVIEW_HEIGHT));

    objj_msgSend(_previewView, "setColorPanel:", self);
    objj_msgSend(_previewView, "setBorder:", objj_msgSend(CPBorder, "borderWithColor:thickness:style:", objj_msgSend(CPColor, "grayColor"), 2.0, CPBorderSolidStyle));
    objj_msgSend(_previewView, "setAutoresizingMask:", CPViewWidthSizable);

    _previewLabel = objj_msgSend(objj_msgSend(CPTextField, "alloc"), "initWithFrame:", CPRectMake(10,TOOLBAR_HEIGHT+14,60,15));
    objj_msgSend(_previewLabel, "setStringValue:", "Preview:");
    objj_msgSend(_previewLabel, "setTextColor:", objj_msgSend(CPColor, "whiteColor"));
    objj_msgSend(_previewLabel, "setAlignment:", CPRightTextAlignment);

    _swatchView = objj_msgSend(objj_msgSend(_CPColorPanelSwatches, "alloc"), "initWithFrame:", CPRectMake(76,TOOLBAR_HEIGHT+10+PREVIEW_HEIGHT+5,CGRectGetWidth(bounds)-86,SWATCH_HEIGHT));

    objj_msgSend(_swatchView, "setColorPanel:", self);
    objj_msgSend(_swatchView, "setAutoresizingMask:", CPViewWidthSizable);
    objj_msgSend(_swatchView, "setBorder:", objj_msgSend(CPBorder, "borderWithColor:thickness:style:", objj_msgSend(CPColor, "grayColor"), 1.0, CPBorderSolidStyle));

    _swatchLabel = objj_msgSend(objj_msgSend(CPTextField, "alloc"), "initWithFrame:", CPRectMake(10,TOOLBAR_HEIGHT+8+PREVIEW_HEIGHT+5,60,15));
    objj_msgSend(_swatchLabel, "setStringValue:", "Swatches:");
    objj_msgSend(_swatchLabel, "setTextColor:", objj_msgSend(CPColor, "whiteColor"));
    objj_msgSend(_swatchLabel, "setAlignment:", CPRightTextAlignment);

    _wheelPicker = objj_msgSend(objj_msgSend(CPColorWheelColorPicker, "alloc"), "initWithPickerMask:colorPanel:", 1|2|3, self);
    _currentView = objj_msgSend(_wheelPicker, "provideNewView:", YES);

    var height = (TOOLBAR_HEIGHT+10+PREVIEW_HEIGHT+5+SWATCH_HEIGHT+10);
    objj_msgSend(_currentView, "setFrameSize:", CPSizeMake(bounds.size.width-10,bounds.size.height-height));
    objj_msgSend(_currentView, "setFrameOrigin:", CPPointMake(5,TOOLBAR_HEIGHT+10+PREVIEW_HEIGHT+5+SWATCH_HEIGHT+10));
    objj_msgSend(_currentView, "setAutoresizingMask:", (CPViewWidthSizable|CPViewHeightSizable));

    _kulerPicker = objj_msgSend(objj_msgSend(CPKulerColorPicker, "alloc"), "initWithPickerMask:colorPanel:", 1|2|3, self);
    objj_msgSend(_kulerPicker, "provideNewView:", YES);

    _sliderPicker = objj_msgSend(objj_msgSend(CPSliderColorPicker, "alloc"), "initWithPickerMask:colorPanel:", 1|2|3, self);
    objj_msgSend(_sliderPicker, "provideNewView:", YES);

    objj_msgSend(contentView, "addSubview:", _toolbar);
    objj_msgSend(contentView, "addSubview:", _previewView);
    objj_msgSend(contentView, "addSubview:", _previewLabel);
    objj_msgSend(contentView, "addSubview:", _swatchView);
    objj_msgSend(contentView, "addSubview:", _swatchLabel);
    objj_msgSend(contentView, "addSubview:", _currentView);

    _target = nil;
    _action = nil;

    _activePicker = _wheelPicker;

    objj_msgSend(self, "setColor:", objj_msgSend(CPColor, "whiteColor"));
    objj_msgSend(_activePicker, "setColor:", objj_msgSend(CPColor, "whiteColor"));
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

var iconSize = 32,
    totalIcons = 3;

{var the_class = objj_allocateClassPair(CPView, "_CPColorPanelToolbar"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_wheelImage"), new objj_ivar("_wheelAlternateImage"), new objj_ivar("_wheelButton"), new objj_ivar("_sliderImage"), new objj_ivar("_sliderAlternateImage"), new objj_ivar("_sliderButton"), new objj_ivar("_kulerImage"), new objj_ivar("_kulerAlternateImage"), new objj_ivar("_kulerButton"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "initWithFrame:", aFrame);

    var width = aFrame.size.width;
    var center = width / 2.0;
    var start = center - ((totalIcons * iconSize) + (totalIcons - 1) * 8.0) / 2.0;

    _wheelButton = objj_msgSend(objj_msgSend(CPButton, "alloc"), "initWithFrame:", CPRectMake(start,0,iconSize,iconSize));
    start += iconSize + 8;

    var path = objj_msgSend(objj_msgSend(CPBundle, "bundleForClass:", _CPColorPanelToolbar), "pathForResource:", "wheel_button.png");
    _wheelImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", path, CPSizeMake(iconSize,iconSize));

    path = objj_msgSend(objj_msgSend(CPBundle, "bundleForClass:", _CPColorPanelToolbar), "pathForResource:", "wheel_button_h.png");
    _wheelAlternateImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", path, CPSizeMake(iconSize,iconSize));

    objj_msgSend(_wheelButton, "setImage:", _wheelImage);
    objj_msgSend(_wheelButton, "setAlternateImage:", _wheelAlternateImage);
    objj_msgSend(_wheelButton, "setTarget:", self);
    objj_msgSend(_wheelButton, "setAction:", sel_registerName("setMode:"));
    objj_msgSend(_wheelButton, "setAutoresizingMask:", CPViewMinXMargin|CPViewMaxXMargin);

    objj_msgSend(self, "addSubview:", _wheelButton);

    _sliderButton = objj_msgSend(objj_msgSend(CPButton, "alloc"), "initWithFrame:", CPRectMake(start,0,iconSize,iconSize));
    start += iconSize + 8;

    path = objj_msgSend(objj_msgSend(CPBundle, "bundleForClass:", _CPColorPanelToolbar), "pathForResource:", "slider_button.png");
    _sliderImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", path, CPSizeMake(iconSize,iconSize));

    path = objj_msgSend(objj_msgSend(CPBundle, "bundleForClass:", _CPColorPanelToolbar), "pathForResource:", "slider_button_h.png");
    _sliderAlternateImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", path, CPSizeMake(iconSize,iconSize));

    objj_msgSend(_sliderButton, "setImage:", _sliderImage);
    objj_msgSend(_sliderButton, "setAlternateImage:", _sliderAlternateImage);
    objj_msgSend(_sliderButton, "setTarget:", self);
    objj_msgSend(_sliderButton, "setAction:", sel_registerName("setMode:"));
    objj_msgSend(_sliderButton, "setAutoresizingMask:", CPViewMinXMargin|CPViewMaxXMargin);

    objj_msgSend(self, "addSubview:", _sliderButton);

    _kulerButton = objj_msgSend(objj_msgSend(CPButton, "alloc"), "initWithFrame:", CPRectMake(start,0,iconSize,iconSize));
    start += iconSize + 8;

    path = objj_msgSend(objj_msgSend(CPBundle, "bundleForClass:", _CPColorPanelToolbar), "pathForResource:", "kuler_button.png");
    _kulerImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", path, CPSizeMake(iconSize,iconSize));

    path = objj_msgSend(objj_msgSend(CPBundle, "bundleForClass:", _CPColorPanelToolbar), "pathForResource:", "kuler_button_h.png");
    _kulerAlternateImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", path, CPSizeMake(iconSize,iconSize));

    objj_msgSend(_kulerButton, "setImage:", _kulerImage);
    objj_msgSend(_kulerButton, "setAlternateImage:", _kulerAlternateImage);
    objj_msgSend(_kulerButton, "setTarget:", self);
    objj_msgSend(_kulerButton, "setAction:", sel_registerName("setMode:"));
    objj_msgSend(_kulerButton, "setAutoresizingMask:", CPViewMinXMargin|CPViewMaxXMargin);

    objj_msgSend(self, "addSubview:", _kulerButton);

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setMode:"), function(self, _cmd, sender)
{ with(self)
{
    if(sender == _kulerButton)
        objj_msgSend(objj_msgSend(CPColorPanel, "sharedColorPanel"), "setMode:", CPKulerColorPickerMode);
    else if(sender == _wheelButton)
        objj_msgSend(objj_msgSend(CPColorPanel, "sharedColorPanel"), "setMode:", CPWheelColorPickerMode);
    else
        objj_msgSend(objj_msgSend(CPColorPanel, "sharedColorPanel"), "setMode:", CPSliderColorPickerMode);
}
});
class_addMethods(the_class, instance_methods);
}

CPColorDragType = "CPColorDragType";
var CPColorPanelSwatchesCookie = "CPColorPanelSwatchesCookie";

{var the_class = objj_allocateClassPair(CPView, "_CPColorPanelSwatches"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("["), new objj_ivar("_swatches"), new objj_ivar("_dragColor"), new objj_ivar("_colorPanel"), new objj_ivar("_swatchCookie"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "initWithFrame:", aFrame);

    objj_msgSend(self, "setBackgroundColor:", objj_msgSend(CPColor, "grayColor"));

    objj_msgSend(self, "registerForDraggedTypes:", objj_msgSend(CPArray, "arrayWithObjects:", CPColorDragType));

    var whiteColor = objj_msgSend(CPColor, "whiteColor");

    _swatchCookie = objj_msgSend(objj_msgSend(CPCookie, "alloc"), "initWithName:", CPColorPanelSwatchesCookie);
    var colorList = objj_msgSend(self, "startingColorList");

    _swatches = [];
    for(var i=0; i < 50; i++)
    {
        var view = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", CPRectMake(13*i+1,1,12,12));
        objj_msgSend(view, "setBackgroundColor:", (i<colorList.length)?colorList[i]:whiteColor);
        objj_msgSend(view, "setBorder:", objj_msgSend(CPBorder, "borderWithColor:thickness:style:", whiteColor, 1.0, CPBorderSolidStyle));
        objj_msgSend(self, "addSubview:", view);
        _swatches.push(view);
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("startingColorList"), function(self, _cmd)
{ with(self)
{
    var cookieValue = objj_msgSend(_swatchCookie, "value");
    if(cookieValue == "")
    {
        return [objj_msgSend(CPColor, "blackColor"),objj_msgSend(CPColor, "darkGrayColor"),objj_msgSend(CPColor, "grayColor"),objj_msgSend(CPColor, "lightGrayColor"),objj_msgSend(CPColor, "whiteColor"),objj_msgSend(CPColor, "redColor"),objj_msgSend(CPColor, "greenColor"),objj_msgSend(CPColor, "blueColor"),objj_msgSend(CPColor, "yellowColor")];
    }

    var cookieValue = eval(cookieValue);
    var result = [];

    for(var i=0; i<cookieValue.length; i++)
        result.push(objj_msgSend(CPColor, "colorWithHexString:", cookieValue[i]));

    return result;
}
});
instance_methods[2] = new objj_method(sel_registerName("saveColorList"), function(self, _cmd)
{ with(self)
{
    var result = [];
    for(var i=0; i<_swatches.length; i++)
        result.push(objj_msgSend(objj_msgSend(_swatches[i], "backgroundColor"), "hexString"));

    var future = new Date();
    future.setYear(2019);

    objj_msgSend(_swatchCookie, "setValue:expires:domain:", CPJSObjectCreateJSON(result), future, nil);
}
});
instance_methods[3] = new objj_method(sel_registerName("setColorPanel:"), function(self, _cmd, panel)
{ with(self)
{
    _colorPanel = panel;
}
});
instance_methods[4] = new objj_method(sel_registerName("colorPanel"), function(self, _cmd)
{ with(self)
{
    return _colorPanel;
}
});
instance_methods[5] = new objj_method(sel_registerName("colorAtIndex:"), function(self, _cmd, index)
{ with(self)
{
    return objj_msgSend(_swatches[index], "backgroundColor");
}
});
instance_methods[6] = new objj_method(sel_registerName("setColor:atIndex:"), function(self, _cmd, aColor, index)
{ with(self)
{
    objj_msgSend(_swatches[index], "setBackgroundColor:", aColor);
    objj_msgSend(self, "saveColorList");
}
});
instance_methods[7] = new objj_method(sel_registerName("mouseUp:"), function(self, _cmd, anEvent)
{ with(self)
{
    var point = objj_msgSend(self, "convertPoint:fromView:", objj_msgSend(anEvent, "locationInWindow"), nil);

    if(point.x > objj_msgSend(self, "bounds").size.width - 1 || point.x < 1)
        return NO;

    objj_msgSend(_colorPanel, "setColor:updatePicker:", objj_msgSend(self, "colorAtIndex:", FLOOR(point.x/13)), YES);
}
});
instance_methods[8] = new objj_method(sel_registerName("mouseDragged:"), function(self, _cmd, anEvent)
{ with(self)
{
    var point = objj_msgSend(self, "convertPoint:fromView:", objj_msgSend(anEvent, "locationInWindow"), nil);

     if(point.x > objj_msgSend(self, "bounds").size.width - 1 || point.x < 1)
        return NO;

    objj_msgSend(objj_msgSend(CPPasteboard, "pasteboardWithName:", CPDragPboard), "declareTypes:owner:", objj_msgSend(CPArray, "arrayWithObject:", CPColorDragType), self);

    var swatch = _swatches[FLOOR(point.x/13)];

    _dragColor = objj_msgSend(swatch, "backgroundColor");

    var bounds = CPRectCreateCopy(objj_msgSend(swatch, "bounds"));

    var dragView = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", bounds);
    objj_msgSend(dragView, "setBackgroundColor:", _dragColor);
    objj_msgSend(dragView, "setBorder:", objj_msgSend(CPBorder, "borderWithColor:thickness:style:", objj_msgSend(CPColor, "blackColor"), 1.0, CPBorderSolidStyle));

    objj_msgSend(self, "dragView:at:offset:event:pasteboard:source:slideBack:", dragView, CPPointMake(point.x-bounds.size.width/2.0,point.y-bounds.size.height/2.0), CPPointMake(0.0,0.0), anEvent, nil, self, YES);
}
});
instance_methods[9] = new objj_method(sel_registerName("pasteboard:provideDataForType:"), function(self, _cmd, aPasteboard, aType)
{ with(self)
{
    if(aType == CPColorDragType)
        objj_msgSend(aPasteboard, "setData:forType:", _dragColor, aType);
}
});
instance_methods[10] = new objj_method(sel_registerName("performDragOperation:"), function(self, _cmd, aSender)
{ with(self)
{
    var location = objj_msgSend(self, "convertPoint:fromView:", objj_msgSend(aSender, "draggingLocation"), nil),
        pasteboard = objj_msgSend(aSender, "draggingPasteboard"),
        swatch = nil;

    if(!objj_msgSend(pasteboard, "availableTypeFromArray:", [CPColorDragType]) || location.x > objj_msgSend(self, "bounds").size.width - 1 || location.x < 1)
        return NO;

    objj_msgSend(self, "setColor:atIndex:", objj_msgSend(pasteboard, "dataForType:", CPColorDragType), FLOOR(location.x/13));
}
});
class_addMethods(the_class, instance_methods);
}

{var the_class = objj_allocateClassPair(CPView, "_CPColorPanelPreview"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_colorPanel"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "initWithFrame:", aFrame);

    objj_msgSend(self, "registerForDraggedTypes:", objj_msgSend(CPArray, "arrayWithObjects:", CPColorDragType));

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setColorPanel:"), function(self, _cmd, aPanel)
{ with(self)
{
    _colorPanel = aPanel;
}
});
instance_methods[2] = new objj_method(sel_registerName("colorPanel"), function(self, _cmd)
{ with(self)
{
    return _colorPanel;
}
});
instance_methods[3] = new objj_method(sel_registerName("performDragOperation:"), function(self, _cmd, aSender)
{ with(self)
{
    var pasteboard = objj_msgSend(aSender, "draggingPasteboard");

    if(!objj_msgSend(pasteboard, "availableTypeFromArray:", [CPColorDragType]))
        return NO;

    var color = objj_msgSend(pasteboard, "dataForType:", CPColorDragType);
    objj_msgSend(_colorPanel, "setColor:updatePicker:", color, YES);
}
});
instance_methods[4] = new objj_method(sel_registerName("mouseDragged:"), function(self, _cmd, anEvent)
{ with(self)
{
    var point = objj_msgSend(self, "convertPoint:fromView:", objj_msgSend(anEvent, "locationInWindow"), nil);

    objj_msgSend(objj_msgSend(CPPasteboard, "pasteboardWithName:", CPDragPboard), "declareTypes:owner:", objj_msgSend(CPArray, "arrayWithObject:", CPColorDragType), self);

    var bounds = CPRectMake(0, 0, 15, 15);

    var dragView = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", bounds);
    objj_msgSend(dragView, "setBackgroundColor:", objj_msgSend(self, "backgroundColor"));
    objj_msgSend(dragView, "setBorder:", objj_msgSend(CPBorder, "borderWithColor:thickness:style:", objj_msgSend(CPColor, "blackColor"), 1.0, CPBorderSolidStyle));

    objj_msgSend(self, "dragView:at:offset:event:pasteboard:source:slideBack:", dragView, CPPointMake(point.x-bounds.size.width/2.0,point.y-bounds.size.height/2.0), CPPointMake(0.0,0.0), anEvent, nil, self, YES);
}
});
instance_methods[5] = new objj_method(sel_registerName("pasteboard:provideDataForType:"), function(self, _cmd, aPasteboard, aType)
{ with(self)
{
    if(aType == CPColorDragType)
        objj_msgSend(aPasteboard, "setData:forType:", objj_msgSend(self, "backgroundColor"), aType);
}
});
class_addMethods(the_class, instance_methods);
}

p;15;CPColorPicker.jI;23;Foundation/Foundation.jI;15;AppKit/CPView.jI;16;AppKit/CPImage.jI;20;AppKit/CPImageView.jc;12496;


{var the_class = objj_allocateClassPair(CPObject, "CPColorPicker"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_panel"), new objj_ivar("_mask"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithPickerMask:colorPanel:"), function(self, _cmd, aMask, aPanel)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    _panel = aPanel;
    _mask = aMask;

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("colorPanel"), function(self, _cmd)
{ with(self)
{
    return _panel;
}
});
instance_methods[2] = new objj_method(sel_registerName("provideNewButtonImage"), function(self, _cmd)
{ with(self)
{
    return nil;
}
});
instance_methods[3] = new objj_method(sel_registerName("setMode:"), function(self, _cmd, mode)
{ with(self)
{
    return;
}
});
instance_methods[4] = new objj_method(sel_registerName("setColor:"), function(self, _cmd, aColor)
{ with(self)
{
    return;
}
});
class_addMethods(the_class, instance_methods);
}

{var the_class = objj_allocateClassPair(CPColorPicker, "CPColorWheelColorPicker"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_pickerView"), new objj_ivar("_brightnessSlider"), new objj_ivar("_brightnessBarImage"), new objj_ivar("_hueSaturationView"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithPickerMask:colorPanel:"), function(self, _cmd, mask, owningColorPanel)
{ with(self)
{
    return objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPColorPicker") }, "initWithPickerMask:colorPanel:", mask, owningColorPanel);
}
});
instance_methods[1] = new objj_method(sel_registerName("initView"), function(self, _cmd)
{ with(self)
{
    aFrame = CPRectMake(0, 0, CPColorPickerViewWidth, CPColorPickerViewHeight);
    _pickerView = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", aFrame);

    var path = objj_msgSend(objj_msgSend(CPBundle, "bundleForClass:", CPColorPicker), "pathForResource:", "brightness_bar.png");

    _brightnessBarImage = new Image();
    _brightnessBarImage.src = path;
    _brightnessBarImage.style.width = "100%";
    _brightnessBarImage.style.height = "100%";
    _brightnessBarImage.style.position = "absolute";
    _brightnessBarImage.style.top = "0px";
    _brightnessBarImage.style.left = "0px";

    var brightnessBarView = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", CPRectMake(0,(aFrame.size.height-34),aFrame.size.width,15));
    objj_msgSend(brightnessBarView, "setAutoresizingMask:", (CPViewWidthSizable|CPViewMinYMargin));
    brightnessBarView._DOMElement.appendChild(_brightnessBarImage);

    _brightnessSlider = objj_msgSend(objj_msgSend(CPSlider, "alloc"), "initWithFrame:", CPRectMake(0,aFrame.size.height-22,aFrame.size.width,12));
    objj_msgSend(_brightnessSlider, "setMaxValue:", 100.0);
    objj_msgSend(_brightnessSlider, "setMinValue:", 0.0);
    objj_msgSend(_brightnessSlider, "setValue:", 100.0);

    objj_msgSend(_brightnessSlider, "setTarget:", self);
    objj_msgSend(_brightnessSlider, "setAction:", sel_registerName("brightnessSliderDidChange:"));
    objj_msgSend(_brightnessSlider, "setAutoresizingMask:", (CPViewWidthSizable|CPViewMinYMargin));

    _hueSaturationView = objj_msgSend(objj_msgSend(__CPColorWheel, "alloc"), "initWithFrame:", CPRectMake(0,0,aFrame.size.width,aFrame.size.height-38));
    objj_msgSend(_hueSaturationView, "setDelegate:", self);
    objj_msgSend(_hueSaturationView, "setAutoresizingMask:", (CPViewWidthSizable|CPViewHeightSizable));

    objj_msgSend(_pickerView, "addSubview:", brightnessBarView);
    objj_msgSend(_pickerView, "addSubview:", _hueSaturationView);
    objj_msgSend(_pickerView, "addSubview:", _brightnessSlider);
}
});
instance_methods[2] = new objj_method(sel_registerName("brightnessSliderDidChange:"), function(self, _cmd, sender)
{ with(self)
{
    objj_msgSend(self, "updateColor");
}
});
instance_methods[3] = new objj_method(sel_registerName("colorWheelDidChange:"), function(self, _cmd, sender)
{ with(self)
{
    objj_msgSend(self, "updateColor");
}
});
instance_methods[4] = new objj_method(sel_registerName("updateColor"), function(self, _cmd)
{ with(self)
{
    var hue = objj_msgSend(_hueSaturationView, "angle"),
        saturation = objj_msgSend(_hueSaturationView, "distance"),
        brightness = objj_msgSend(_brightnessSlider, "value");

    objj_msgSend(_hueSaturationView, "setWheelBrightness:", brightness/100.0);
    _brightnessBarImage.style.backgroundColor = "#"+objj_msgSend(objj_msgSend(CPColor, "colorWithHue:saturation:brightness:", hue, saturation, 100), "hexString");

    objj_msgSend(objj_msgSend(self, "colorPanel"), "setColor:", objj_msgSend(CPColor, "colorWithHue:saturation:brightness:", hue, saturation, brightness));
}
});
instance_methods[5] = new objj_method(sel_registerName("supportsMode:"), function(self, _cmd, mode)
{ with(self)
{
    return (mode == CPWheelColorPickerMode) ? YES : NO;
}
});
instance_methods[6] = new objj_method(sel_registerName("currentMode"), function(self, _cmd)
{ with(self)
{
    return CPWheelColorPickerMode;
}
});
instance_methods[7] = new objj_method(sel_registerName("provideNewView:"), function(self, _cmd, initialRequest)
{ with(self)
{
    if (initialRequest)
        objj_msgSend(self, "initView");

    return _pickerView;
}
});
instance_methods[8] = new objj_method(sel_registerName("setColor:"), function(self, _cmd, newColor)
{ with(self)
{
    var hsb = objj_msgSend(newColor, "hsbComponents");

    objj_msgSend(_hueSaturationView, "setPositionToColor:", newColor);
    objj_msgSend(_brightnessSlider, "setValue:", hsb[2]);
    objj_msgSend(_hueSaturationView, "setWheelBrightness:", hsb[2]/100.0);

    _brightnessBarImage.style.backgroundColor = "#"+objj_msgSend(objj_msgSend(CPColor, "colorWithHue:saturation:brightness:", hsb[0], hsb[1], 100), "hexString");
}
});
class_addMethods(the_class, instance_methods);
}

{var the_class = objj_allocateClassPair(CPView, "__CPColorWheel"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_wheelImage"), new objj_ivar("_blackWheelImage"), new objj_ivar("_crosshair"), new objj_ivar("_delegate"), new objj_ivar("_angle"), new objj_ivar("_distance"), new objj_ivar("_radius"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "initWithFrame:", aFrame);

    var path = objj_msgSend(objj_msgSend(CPBundle, "bundleForClass:", CPColorPicker), "pathForResource:", "wheel.png");

    _wheelImage = new Image();
    _wheelImage.src = path;
    _wheelImage.style.position = "absolute";

    path = objj_msgSend(objj_msgSend(CPBundle, "bundleForClass:", CPColorPicker), "pathForResource:", "wheel_black.png");

    _blackWheelImage = new Image();
    _blackWheelImage.src = path;
    _blackWheelImage.style.opacity = "0";
    _blackWheelImage.style.filter = "alpha(opacity=0)"
    _blackWheelImage.style.position = "absolute";

    _DOMElement.appendChild(_wheelImage);
    _DOMElement.appendChild(_blackWheelImage);

    objj_msgSend(self, "setWheelSize:", aFrame.size);

    _crosshair = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", CPRectMake(_radius-2,_radius-2,4,4));
    objj_msgSend(_crosshair, "setBackgroundColor:", objj_msgSend(CPColor, "whiteColor"));
    objj_msgSend(_crosshair, "setBorder:", objj_msgSend(CPBorder, "borderWithColor:thickness:style:", objj_msgSend(CPColor, "blackColor"), 1.0, CPBorderSolidStyle));
    objj_msgSend(self, "addSubview:", _crosshair);

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setWheelBrightness:"), function(self, _cmd, brightness)
{ with(self)
{
    _blackWheelImage.style.opacity = 1.0 - brightness;
    _blackWheelImage.style.filter = "alpha(opacity=" + (1.0 - brightness)*100 + ")"
}
});
instance_methods[2] = new objj_method(sel_registerName("setFrameSize:"), function(self, _cmd, aSize)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "setFrameSize:", aSize);
    objj_msgSend(self, "setWheelSize:", aSize);
}
});
instance_methods[3] = new objj_method(sel_registerName("setWheelSize:"), function(self, _cmd, aSize)
{ with(self)
{
    var min = MIN(aSize.width, aSize.height);

    _blackWheelImage.style.width = min;
    _blackWheelImage.style.height = min;
    _blackWheelImage.width = min;
    _blackWheelImage.height = min;
    _blackWheelImage.style.top = (aSize.height - min) / 2.0 + "px";
    _blackWheelImage.style.left = (aSize.width - min) / 2.0 + "px";

    _wheelImage.style.width = min;
    _wheelImage.style.height = min;
    _wheelImage.width = min;
    _wheelImage.height = min;
    _wheelImage.style.top = (aSize.height - min) / 2.0 + "px";
    _wheelImage.style.left = (aSize.width - min) / 2.0 + "px";

    _radius = min / 2.0;

    objj_msgSend(self, "setAngle:distance:", objj_msgSend(self, "degreesToRadians:", _angle), (_distance/100.0)*_radius);
}
});
instance_methods[4] = new objj_method(sel_registerName("setDelegate:"), function(self, _cmd, aDelegate)
{ with(self)
{
    _delegate = aDelegate;
}
});
instance_methods[5] = new objj_method(sel_registerName("delegate"), function(self, _cmd)
{ with(self)
{
    return _delegate;
}
});
instance_methods[6] = new objj_method(sel_registerName("angle"), function(self, _cmd)
{ with(self)
{
    return _angle;
}
});
instance_methods[7] = new objj_method(sel_registerName("distance"), function(self, _cmd)
{ with(self)
{
    return _distance;
}
});
instance_methods[8] = new objj_method(sel_registerName("mouseDown:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(self, "reposition:", anEvent);
}
});
instance_methods[9] = new objj_method(sel_registerName("mouseDragged:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(self, "reposition:", anEvent);
}
});
instance_methods[10] = new objj_method(sel_registerName("reposition:"), function(self, _cmd, anEvent)
{ with(self)
{
    var bounds = objj_msgSend(self, "bounds"),
        location = objj_msgSend(self, "convertPoint:fromView:", objj_msgSend(anEvent, "locationInWindow"), nil);

    var midX = CGRectGetMidX(bounds);
    var midY = CGRectGetMidY(bounds);

    var distance = MIN(SQRT((location.x - midX)*(location.x - midX) + (location.y - midY)*(location.y - midY)), _radius);
    var angle = ATAN2(location.y - midY, location.x - midX);

    objj_msgSend(self, "setAngle:distance:", angle, distance);

    if(_delegate)
        objj_msgSend(_delegate, "colorWheelDidChange:", self);
}
});
instance_methods[11] = new objj_method(sel_registerName("setAngle:distance:"), function(self, _cmd, angle, distance)
{ with(self)
{
    var bounds = objj_msgSend(self, "bounds");
    var midX = CGRectGetMidX(bounds);
    var midY = CGRectGetMidY(bounds);

    _angle = objj_msgSend(self, "radiansToDegrees:", angle);
    _distance = (distance / _radius) * 100.0;

    objj_msgSend(_crosshair, "setFrameOrigin:", CPPointMake(COS(angle)*distance+midX-2.0,SIN(angle)*distance+midY-2.0));
}
});
instance_methods[12] = new objj_method(sel_registerName("setPositionToColor:"), function(self, _cmd, aColor)
{ with(self)
{
    var hsb = objj_msgSend(aColor, "hsbComponents"),
        bounds = objj_msgSend(self, "bounds");

    var angle = objj_msgSend(self, "degreesToRadians:", hsb[0]),
        distance = (hsb[1] / 100.0) * _radius;

    objj_msgSend(self, "setAngle:distance:", angle, distance);
}
});
instance_methods[13] = new objj_method(sel_registerName("radiansToDegrees:"), function(self, _cmd, radians)
{ with(self)
{
    return ((-radians / PI) * 180 + 360) % 360;
}
});
instance_methods[14] = new objj_method(sel_registerName("degreesToRadians:"), function(self, _cmd, degrees)
{ with(self)
{
    return -(((degrees - 360) / 180) * PI);
}
});
class_addMethods(the_class, instance_methods);
}

p;13;CPColorWell.jI;21;Foundation/CPString.ji;8;CPView.ji;9;CPColor.ji;14;CPColorPanel.jc;5642;


var _CPColorWellDidBecomeExclusiveNotification = "_CPColorWellDidBecomeExclusiveNotification";

{var the_class = objj_allocateClassPair(CPControl, "CPColorWell"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_active"), new objj_ivar("_color"), new objj_ivar("_wellView"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "initWithFrame:", aFrame);

    if (self)
    {
        _active = NO;

        _color = objj_msgSend(CPColor, "whiteColor");

        objj_msgSend(self, "drawBezelWithHighlight:", NO);
        objj_msgSend(self, "drawWellInside:", CGRectInset(objj_msgSend(self, "bounds"),3.0,3.0));

        var defaultCenter = objj_msgSend(CPNotificationCenter, "defaultCenter");

        objj_msgSend(defaultCenter, "addObserver:selector:name:object:", self, sel_registerName("colorWellDidBecomeExclusive:"), _CPColorWellDidBecomeExclusiveNotification, nil);

        objj_msgSend(defaultCenter, "addObserver:selector:name:object:", self, sel_registerName("colorPanelWillClose:"), CPWindowWillCloseNotification, objj_msgSend(CPColorPanel, "sharedColorPanel"));
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("color"), function(self, _cmd)
{ with(self)
{
    return _color;
}
});
instance_methods[2] = new objj_method(sel_registerName("setColor:"), function(self, _cmd, aColor)
{ with(self)
{
    if (_color == aColor)
        return;

    _color = aColor;

    objj_msgSend(self, "drawWellInside:", CGRectInset(objj_msgSend(self, "bounds"),3.0,3.0));
}
});
instance_methods[3] = new objj_method(sel_registerName("takeColorFrom:"), function(self, _cmd, aSender)
{ with(self)
{
    objj_msgSend(self, "setColor:", objj_msgSend(aSender, "color"));
}
});
instance_methods[4] = new objj_method(sel_registerName("activate:"), function(self, _cmd, shouldBeExclusive)
{ with(self)
{
    if (shouldBeExclusive)

        objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:", _CPColorWellDidBecomeExclusiveNotification, self);


    if (objj_msgSend(self, "isActive"))
        return;

    _active = YES;

    objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "addObserver:selector:name:object:", self, sel_registerName("colorPanelDidChangeColor:"), CPColorPanelColorDidChangeNotification, objj_msgSend(CPColorPanel, "sharedColorPanel"));
}
});
instance_methods[5] = new objj_method(sel_registerName("deactivate"), function(self, _cmd)
{ with(self)
{
    if (!objj_msgSend(self, "isActive"))
        return;

    _active = NO;

    objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "removeObserver:name:object:", self, CPColorPanelColorDidChangeNotification, objj_msgSend(CPColorPanel, "sharedColorPanel"));
}
});
instance_methods[6] = new objj_method(sel_registerName("isActive"), function(self, _cmd)
{ with(self)
{
    return _active;
}
});
instance_methods[7] = new objj_method(sel_registerName("drawBezelWithHighlight:"), function(self, _cmd, shouldHighlight)
{ with(self)
{}
});
instance_methods[8] = new objj_method(sel_registerName("drawWellInside:"), function(self, _cmd, aRect)
{ with(self)
{
    if (!_wellView)
    {
        _wellView = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", aRect);

        objj_msgSend(self, "addSubview:", _wellView);
    }
    else
        objj_msgSend(_wellView, "setFrame:", aRect);

    objj_msgSend(_wellView, "setBackgroundColor:", _color);
}
});
instance_methods[9] = new objj_method(sel_registerName("colorPanelDidChangeColor:"), function(self, _cmd, aNotification)
{ with(self)
{
    objj_msgSend(self, "takeColorFrom:", objj_msgSend(aNotification, "object"));

    objj_msgSend(self, "sendAction:to:", objj_msgSend(self, "action"), objj_msgSend(self, "target"));
}
});
instance_methods[10] = new objj_method(sel_registerName("colorWellDidBecomeExclusive:"), function(self, _cmd, aNotification)
{ with(self)
{
    if (self != objj_msgSend(aNotification, "object"))
        objj_msgSend(self, "deactivate");
}
});
instance_methods[11] = new objj_method(sel_registerName("colorPanelWillClose:"), function(self, _cmd, aNotification)
{ with(self)
{
    objj_msgSend(self, "deactivate");
}
});
instance_methods[12] = new objj_method(sel_registerName("mouseDown:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(self, "drawBezelWithHighlight:", YES);
}
});
instance_methods[13] = new objj_method(sel_registerName("mouseDragged:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(self, "drawBezelWithHighlight:", CGRectContainsPoint(objj_msgSend(self, "bounds"),objj_msgSend(self, "convertPoint:fromView:", objj_msgSend(anEvent, "locationInWindow"), nil)));
}
});
instance_methods[14] = new objj_method(sel_registerName("mouseUp:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(self, "drawBezelWithHighlight:", NO);

    if (!CGRectContainsPoint(objj_msgSend(self, "bounds"), objj_msgSend(self, "convertPoint:fromView:", objj_msgSend(anEvent, "locationInWindow"), nil)))
        return;

    objj_msgSend(self, "activate:", YES);

    var colorPanel = objj_msgSend(CPColorPanel, "sharedColorPanel");

    objj_msgSend(colorPanel, "setColor:", _color);

    objj_msgSend(colorPanel, "orderFront:", self);
}
});
class_addMethods(the_class, instance_methods);
}

p;17;CPCompatibility.ji;9;CPEvent.jc;3242;


CPUnknownBrowserEngine = 0;
CPGeckoBrowserEngine = 1;
CPInternetExplorerBrowserEngine = 2;
CPKHTMLBrowserEngine = 3;
CPOperaBrowserEngine = 4;
CPWebKitBrowserEngine = 5;


CPCSSRGBAFeature = 1 << 5;

CPHTMLCanvasFeature = 1 << 6;
CPHTMLContentEditableFeature = 1 << 7;

CPJavascriptInnerTextFeature = 1 << 8;
CPJavascriptTextContentFeature = 1 << 9;
CPJavascriptClipboardEventsFeature = 1 << 10;
CPJavascriptClipboardAccessFeature = 1 << 11;
CPJavaScriptCanvasDrawFeature = 1 << 12;

CPVMLFeature = 1 << 14;

CPJavascriptRemedialKeySupport = 1 << 15;
CPJavaScriptShadowFeature = 1 << 20;

CPJavaScriptNegativeMouseWheelValues = 1 << 22;

var USER_AGENT = "";

    PLATFORM_ENGINE = CPUnknownBrowserEngine,
    PLATFORM_FEATURES = 0;

if (typeof window != "undfined" && typeof window.navigator != "undefined")
    USER_AGENT = window.navigator.userAgent;


if (window.opera)
{
    PLATFORM_ENGINE = CPOperaBrowserEngine;

    PLATFORM_FEATURES |= CPJavaScriptCanvasDrawFeature;
}


else if (window.attachEvent)
{
    PLATFORM_ENGINE = CPInternetExplorerBrowserEngine;


    PLATFORM_FEATURES |= CPVMLFeature;
    PLATFORM_FEATURES |= CPJavascriptRemedialKeySupport;
    PLATFORM_FEATURES |= CPJavaScriptShadowFeature;
}


else if (USER_AGENT.indexOf("AppleWebKit/") != -1)
{
    PLATFORM_ENGINE = CPWebKitBrowserEngine;


    PLATFORM_FEATURES |= CPCSSRGBAFeature;
    PLATFORM_FEATURES |= CPHTMLContentEditableFeature;
    PLATFORM_FEATURES |= CPJavascriptClipboardEventsFeature;
    PLATFORM_FEATURES |= CPJavascriptClipboardAccessFeature;
    PLATFORM_FEATURES |= CPJavaScriptShadowFeature;

    if(USER_AGENT.indexOf("Version/") != -1)
    {
        var versionStart = USER_AGENT.indexOf("Version/") + "Version/".length,
            versionEnd = USER_AGENT.indexOf(" ", versionStart),
            version = parseFloat(USER_AGENT.substring(versionStart, versionEnd), 10);

        if(version >= 3.1)
            PLATFORM_FEATURES |= CPJavascriptRemedialKeySupport;
    }
}


else if (USER_AGENT.indexOf('KHTML') != -1)
{
    PLATFORM_ENGINE = CPKHTMLBrowserEngine;
}


else if (USER_AGENT.indexOf('Gecko') != -1)
{
    PLATFORM_ENGINE = CPGeckoBrowserEngine;

    PLATFORM_FEATURES |= CPJavaScriptCanvasDrawFeature;
}


if (typeof document != "undefined")
{

    if (document.createElement("canvas").getContext)
        PLATFORM_FEATURES |= CPHTMLCanvasFeature;

    var DOMElement = document.createElement("div");


    if (DOMElement.innerText != undefined)
        PLATFORM_FEATURES |= CPJavascriptInnerTextFeature;
    else if (DOMElement.textContent != undefined)
        PLATFORM_FEATURES |= CPJavascriptTextContentFeature;
}

CPFeatureIsCompatible= function(aFeature)
{
    return PLATFORM_FEATURES & aFeature;
}

if (USER_AGENT.indexOf("Mac") != -1)
{
    CPPlatformActionKeyMask = CPCommandKeyMask;

    CPUndoKeyEquivalent = "Z";
    CPRedoKeyEquivalent = "Z";

    CPUndoKeyEquivalentModifierMask = CPCommandKeyMask;
    CPRedoKeyEquivalentModifierMask = CPCommandKeyMask | CPShiftKeyMask;
}
else
{
    CPPlatformActionKeyMask = CPControlKeyMask;

    CPUndoKeyEquivalent = "Z";
    CPRedoKeyEquivalent = "Y";

    CPUndoKeyEquivalentModifierMask = CPControlKeyMask;
    CPRedoKeyEquivalentModifierMask = CPControlKeyMask;
}

p;11;CPControl.ji;8;CPFont.ji;10;CPShadow.ji;8;CPView.jc;9317;

CPLeftTextAlignment = 0;
CPRightTextAlignment = 1;
CPCenterTextAlignment = 2;
CPJustifiedTextAlignment = 3;
CPNaturalTextAlignment = 4;

CPRegularControlSize = 0;
CPSmallControlSize = 1;
CPMiniControlSize = 2;


var CPControlBlackColor = objj_msgSend(CPColor, "blackColor");

{var the_class = objj_allocateClassPair(CPView, "CPControl"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_value"), new objj_ivar("_isEditable"), new objj_ivar("_isEnabled"), new objj_ivar("_alignment"), new objj_ivar("_font"), new objj_ivar("_textColor"), new objj_ivar("_textShadow"), new objj_ivar("_target"), new objj_ivar("_action"), new objj_ivar("_sendActionOn"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "initWithFrame:", aFrame);

    if (self)
    {
        _sendActionOn = CPLeftMouseUpMask;
        _isEnabled = YES;

        objj_msgSend(self, "setFont:", objj_msgSend(CPFont, "systemFontOfSize:", 12.0));
        objj_msgSend(self, "setTextColor:", CPControlBlackColor);
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setEnabled:"), function(self, _cmd, isEnabled)
{ with(self)
{
    objj_msgSend(self, "setAlphaValue:", (_isEnabled=isEnabled)?1.0:0.3);
}
});
instance_methods[2] = new objj_method(sel_registerName("isEnabled"), function(self, _cmd)
{ with(self)
{
    return _isEnabled;
}
});
instance_methods[3] = new objj_method(sel_registerName("setEditable:"), function(self, _cmd, aFlag)
{ with(self)
{
    _isEditable = aFlag;
}
});
instance_methods[4] = new objj_method(sel_registerName("isEditable"), function(self, _cmd)
{ with(self)
{
    return _isEditable;
}
});
instance_methods[5] = new objj_method(sel_registerName("setTextColor:"), function(self, _cmd, aColor)
{ with(self)
{
    _DOMElement.style.color = objj_msgSend(_textColor=aColor, "cssString");
}
});
instance_methods[6] = new objj_method(sel_registerName("textColor"), function(self, _cmd)
{ with(self)
{
    return _textColor;
}
});
instance_methods[7] = new objj_method(sel_registerName("alignment"), function(self, _cmd)
{ with(self)
{
    return _alignment;
}
});
instance_methods[8] = new objj_method(sel_registerName("setAlignment:"), function(self, _cmd, anAlignment)
{ with(self)
{
    _alignment = anAlignment;
}
});
instance_methods[9] = new objj_method(sel_registerName("setFont:"), function(self, _cmd, aFont)
{ with(self)
{
    if (_font == aFont)
        return;

    _DOMElement.style.font = objj_msgSend(_font=aFont, "cssString");
}
});
instance_methods[10] = new objj_method(sel_registerName("font"), function(self, _cmd)
{ with(self)
{
    return _font;
}
});
instance_methods[11] = new objj_method(sel_registerName("setTextShadow:"), function(self, _cmd, aTextShadow)
{ with(self)
{
    _DOMElement.style.textShadow = objj_msgSend(_textShadow=aTextShadow, "cssString");
}
});
instance_methods[12] = new objj_method(sel_registerName("textShadow"), function(self, _cmd)
{ with(self)
{
    return _textShadow;
}
});
instance_methods[13] = new objj_method(sel_registerName("action"), function(self, _cmd)
{ with(self)
{
    return _action;
}
});
instance_methods[14] = new objj_method(sel_registerName("setAction:"), function(self, _cmd, anAction)
{ with(self)
{
    _action = anAction;
}
});
instance_methods[15] = new objj_method(sel_registerName("target"), function(self, _cmd)
{ with(self)
{
    return _target;
}
});
instance_methods[16] = new objj_method(sel_registerName("setTarget:"), function(self, _cmd, aTarget)
{ with(self)
{
    _target = aTarget;
}
});
instance_methods[17] = new objj_method(sel_registerName("mouseUp:"), function(self, _cmd, anEvent)
{ with(self)
{
    if (_sendActionOn & CPLeftMouseUpMask && CPRectContainsPoint(objj_msgSend(self, "bounds"), objj_msgSend(self, "convertPoint:fromView:", objj_msgSend(anEvent, "locationInWindow"), nil)))
        objj_msgSend(self, "sendAction:to:", _action, _target);

    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "mouseUp:", anEvent);
}
});
instance_methods[18] = new objj_method(sel_registerName("sendAction:to:"), function(self, _cmd, anAction, anObject)
{ with(self)
{
    objj_msgSend(CPApp, "sendAction:to:from:", anAction, anObject, self);
}
});
instance_methods[19] = new objj_method(sel_registerName("floatValue"), function(self, _cmd)
{ with(self)
{
    return _value ? parseFloat(_value) : 0.0;
}
});
instance_methods[20] = new objj_method(sel_registerName("setFloatValue:"), function(self, _cmd, aValue)
{ with(self)
{
    _value = aValue;
}
});
class_addMethods(the_class, instance_methods);
}
var CPControlAlignmentKey = "CPControlAlignmentKey",
    CPControlFontKey = "CPControlFontKey",
    CPControlTextColorKey = "CPControlTextColorKey",
    CPControlTargetKey = "CPControlTargetKey",
    CPControlActionKey = "CPControlActionKey",
    CPControlSendActionOnKey = "CPControlSendActionOnKey";
{
var the_class = objj_getClass("CPControl")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPControl\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "initWithCoder:", aCoder);
    if (self)
    {
        objj_msgSend(self, "setAlignment:", objj_msgSend(aCoder, "decodeIntForKey:", CPControlAlignmentKey));
        objj_msgSend(self, "setFont:", objj_msgSend(aCoder, "decodeObjectForKey:", CPControlFontKey));
        objj_msgSend(self, "setTextColor:", objj_msgSend(aCoder, "decodeObjectForKey:", CPControlTextColorKey));
        objj_msgSend(self, "setTarget:", objj_msgSend(aCoder, "decodeObjectForKey:", CPControlTargetKey));
        objj_msgSend(self, "setAction:", objj_msgSend(aCoder, "decodeObjectForKey:", CPControlActionKey));
        _sendActionOn = objj_msgSend(aCoder, "decodeIntForKey:", CPControlSendActionOnKey);
    }
    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("encodeWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "encodeWithCoder:", aCoder);
    objj_msgSend(aCoder, "encodeInt:forKey:", _alignment, CPControlAlignmentKey);
    objj_msgSend(aCoder, "encodeObject:forKey:", _font, CPControlFontKey);
    objj_msgSend(aCoder, "encodeObject:forKey:", _textColor, CPControlTextColorKey);
    objj_msgSend(aCoder, "encodeConditionalObject:forKey:", _target, CPControlTargetKey);
    objj_msgSend(aCoder, "encodeObject:forKey:", _action, CPControlActionKey);
    objj_msgSend(aCoder, "encodeInt:forKey:", _sendActionOn, CPControlSendActionOnKey);
}
});
class_addMethods(the_class, instance_methods);
}
var _CPControlSizeIdentifiers = [],
    _CPControlCachedThreePartImages = {},
    _CPControlCachedColorWithPatternImages = {};
_CPControlSizeIdentifiers[CPRegularControlSize] = "Regular";
_CPControlSizeIdentifiers[CPSmallControlSize] = "Small";
_CPControlSizeIdentifiers[CPMiniControlSize] = "Mini";
_CPControlIdentifierForControlSize= function(aControlSize)
{
    return _CPControlSizeIdentifiers[aControlSize];
}
_CPControlColorWithPatternImage= function(sizes, aClassName)
{
    var index = 1,
        count = arguments.length,
        identifier = "";
    for (; index < count; ++index)
        identifier += arguments[index];
    var color = _CPControlCachedColorWithPatternImages[identifier];
    if (!color)
    {
        var bundle = objj_msgSend(CPBundle, "bundleForClass:", objj_msgSend(CPControl, "class"));
        color = objj_msgSend(CPColor, "colorWithPatternImage:", objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", aClassName+"/"+identifier+".png"), sizes[identifier]));
        _CPControlCachedColorWithPatternImages[identifier] = color;
    }
    return color;
}
_CPControlThreePartImages= function(sizes, aClassName)
{
    var index = 1,
        count = arguments.length,
        identifier = "";
    for (; index < count; ++index)
        identifier += arguments[index];
    var images = _CPControlCachedThreePartImages[identifier];
    if (!images)
    {
        var bundle = objj_msgSend(CPBundle, "bundleForClass:", objj_msgSend(CPControl, "class")),
            path = aClassName + "/" + identifier;
        sizes = sizes[identifier];
        images = [objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", path+"0.png"), sizes[0]),objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", path+"1.png"), sizes[1]),objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", path+"2.png"), sizes[2])];
        _CPControlCachedThreePartImages[identifier] = images;
    }
    return images;
}

p;19;CPCoreDragManager.jI;15;AppKit/CPView.jI;16;AppKit/CPEvent.jI;21;AppKit/CPPasteboard.jI;20;AppKit/CPImageView.jc;11170;

var CPSharedCoreDragManager = nil;

var CPCoreDragView = nil,
    CPCoreDragSource = nil,
    CPCoreDragWindow = nil,
    CPCoreDragOffset = nil,
    CPCoreDragLocation = nil,
    CPCoreDragPasteboard = nil,
    CPCoreDragDestination = nil,
    CPCoreDragDraggingInfo = nil;

var CPCoreDragIsDraggingImage = NO,

    CPCoreDragShouldSendDraggedViewMovedTo = NO,
    CPCoreDragShouldSendDraggedImageMovedTo = NO,

    CPCoreDragShouldSendDraggedViewEndedAtOperation = NO,
    CPCoreDragShouldSendDraggedImageEndedAtOperation = NO;

var CPCoreDragStartDragging = function(anEvent)
{
    CPCoreDragUpdateDragging(anEvent);
}

var CPCoreDragUpdateDragging = function(anEvent)
{

    if(objj_msgSend(anEvent, "type") == CPLeftMouseUp)
    {
        CPCoreDragLocation = objj_msgSend(objj_msgSend(CPCoreDragDestination, "window"), "convertBridgeToBase:", objj_msgSend(objj_msgSend(anEvent, "window"), "convertBaseToBridge:", objj_msgSend(anEvent, "locationInWindow")));

        objj_msgSend(CPCoreDragView, "removeFromSuperview");
        objj_msgSend(CPSharedCoreDragManager._dragWindow, "orderOut:", nil);

        if (CPCoreDragDestination &&
            (!objj_msgSend(CPCoreDragDestination, "respondsToSelector:", sel_registerName("prepareForDragOperation:")) || objj_msgSend(CPCoreDragDestination, "prepareForDragOperation:", CPCoreDragDraggingInfo)) &&
            (!objj_msgSend(CPCoreDragDestination, "respondsToSelector:", sel_registerName("performDragOperation:")) || objj_msgSend(CPCoreDragDestination, "performDragOperation:", CPCoreDragDraggingInfo)) &&
            objj_msgSend(CPCoreDragDestination, "respondsToSelector:", sel_registerName("concludeDragOperation:")))
            objj_msgSend(CPCoreDragDestination, "concludeDragOperation:", CPCoreDragDraggingInfo);

        if (CPCoreDragShouldSendDraggedImageEndedAtOperation)
            objj_msgSend(CPCoreDragSource, "draggedImage:endedAt:operation:", objj_msgSend(CPCoreDragView, "image"), CPCoreDragLocation, NO);
        else if (CPCoreDragShouldSendDraggedViewEndedAtOperation)
            objj_msgSend(CPCoreDragSource, "draggedView:endedAt:operation:", CPCoreDragView, CPCoreDragLocation, NO);

        CPCoreDragIsDraggingImage = NO;
        CPCoreDragDestination = nil;

        return;
    }


    objj_msgSend(CPApp, "setCallback:forNextEventMatchingMask:untilDate:inMode:dequeue:", CPCoreDragUpdateDragging, CPMouseMovedMask|CPLeftMouseDraggedMask|CPLeftMouseUpMask, nil, 0, NO);

    var location = objj_msgSend(anEvent, "locationInWindow"),
        operation =
        bridgeLocation = objj_msgSend(objj_msgSend(anEvent, "window"), "convertBaseToBridge:", location);


    var draggingDestination = objj_msgSend(objj_msgSend(CPDOMWindowBridge, "sharedDOMWindowBridge"), "_dragHitTest:pasteboard:", bridgeLocation, CPCoreDragPasteboard);

    CPCoreDragLocation = objj_msgSend(objj_msgSend(CPCoreDragDestination, "window"), "convertBridgeToBase:", bridgeLocation);

    if(draggingDestination != CPCoreDragDestination)
    {
        if (CPCoreDragDestination && objj_msgSend(CPCoreDragDestination, "respondsToSelector:", sel_registerName("draggingExited:")))
            objj_msgSend(CPCoreDragDestination, "draggingExited:", CPCoreDragDraggingInfo);

        CPCoreDragDestination = draggingDestination;

        if (CPCoreDragDestination && objj_msgSend(CPCoreDragDestination, "respondsToSelector:", sel_registerName("draggingEntered:")))
            objj_msgSend(CPCoreDragDestination, "draggingEntered:", CPCoreDragDraggingInfo);
    }
    else if (CPCoreDragDestination && objj_msgSend(CPCoreDragDestination, "respondsToSelector:", sel_registerName("draggingUpdated:")))
        objj_msgSend(CPCoreDragDestination, "draggingUpdated:", CPCoreDragDraggingInfo);

    location.x -= CPCoreDragOffset.x;
    location.y -= CPCoreDragOffset.y;

    objj_msgSend(CPCoreDragView, "setFrameOrigin:", location);

    if (CPCoreDragShouldSendDraggedImageMovedTo)
        objj_msgSend(CPCoreDragSource, "draggedImage:movedTo:", objj_msgSend(CPCoreDragView, "image"), location);
    else if (CPCoreDragShouldSendDraggedViewMovedTo)
        objj_msgSend(CPCoreDragSource, "draggedView:movedTo:", CPCoreDragView, location);
}

{var the_class = objj_allocateClassPair(CPObject, "CPDraggingInfo"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_window"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithWindow:"), function(self, _cmd, aWindow)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
        _window = aWindow;

    return this;
}
});
instance_methods[1] = new objj_method(sel_registerName("draggingSource"), function(self, _cmd)
{ with(self)
{
    return CPCoreDragSource;
}
});
instance_methods[2] = new objj_method(sel_registerName("draggingLocation"), function(self, _cmd)
{ with(self)
{
    return CPCoreDragLocation;
}
});
instance_methods[3] = new objj_method(sel_registerName("draggingPasteboard"), function(self, _cmd)
{ with(self)
{
    return CPCoreDragPasteboard;
}
});
class_addMethods(the_class, instance_methods);
}

{var the_class = objj_allocateClassPair(CPObject, "CPCoreDragManager"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_dragWindow"), new objj_ivar("_imageView"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("initialize"), function(self, _cmd)
{ with(self)
{
    if (self != objj_msgSend(CPCoreDragManager, "class"))
        return;

    CPCoreDragDraggingInfo = objj_msgSend(objj_msgSend(CPDraggingInfo, "alloc"), "init");
}
});
class_methods[1] = new objj_method(sel_registerName("sharedCoreDragManager"), function(self, _cmd)
{ with(self)
{
    if (!CPSharedCoreDragManager)
        CPSharedCoreDragManager = objj_msgSend(objj_msgSend(CPCoreDragManager, "alloc"), "init");

    return CPSharedCoreDragManager;
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("init"), function(self, _cmd)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
    {
        _dragWindow = objj_msgSend(objj_msgSend(CPWindow, "alloc"), "initWithContentRect:styleMask:", CPRectMakeZero(), CPBorderlessWindowMask);
        objj_msgSend(_dragWindow, "setLevel:", CPDraggingWindowLevel);
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("dragView:fromWindow:at:offset:event:pasteboard:source:slideBack:"), function(self, _cmd, aView, aWindow, viewLocation, mouseOffset, anEvent, aPasteboard, aSourceObject, slideBack)
{ with(self)
{
    var eventLocation = objj_msgSend(anEvent, "locationInWindow");

    CPCoreDragView = aView;
    CPCoreDragSource = aSourceObject;
    CPCoreDragWindow = aWindow;
    CPCoreDragOffset = CPPointMake(eventLocation.x - viewLocation.x, eventLocation.y - viewLocation.y);
    CPCoreDragPasteboard = objj_msgSend(CPPasteboard, "pasteboardWithName:", CPDragPboard);

    objj_msgSend(_dragWindow, "setFrameSize:", CGSizeMakeCopy(objj_msgSend(objj_msgSend(CPDOMWindowBridge, "sharedDOMWindowBridge"), "frame").size));
    objj_msgSend(_dragWindow, "orderFront:", self);

    objj_msgSend(aView, "setFrameOrigin:", viewLocation);
    objj_msgSend(objj_msgSend(_dragWindow, "contentView"), "addSubview:", aView);

    if (CPCoreDragIsDraggingImage)
    {
        if (objj_msgSend(CPCoreDragSource, "respondsToSelector:", sel_registerName("draggedImage:beganAt:")))
            objj_msgSend(CPCoreDragSource, "draggedImage:beganAt:", objj_msgSend(aView, "image"), viewLocation);

        CPCoreDragShouldSendDraggedImageMovedTo = objj_msgSend(CPCoreDragSource, "respondsToSelector:", sel_registerName("draggedImage:movedTo:"));
        CPCoreDragShouldSendDraggedImageEndedAtOperation = objj_msgSend(CPCoreDragSource, "respondsToSelector:", sel_registerName("draggedImage:endAt:operation:"));

        CPCoreDragShouldSendDraggedViewMovedTo = NO;
        CPCoreDragShouldSendDraggedViewEndedAtOperation = NO;
    }
    else
    {
        if (objj_msgSend(CPCoreDragSource, "respondsToSelector:", sel_registerName("draggedView:beganAt:")))
            objj_msgSend(CPCoreDragSource, "draggedView:beganAt:", aView, viewLocation);

        CPCoreDragShouldSendDraggedViewMovedTo = objj_msgSend(CPCoreDragSource, "respondsToSelector:", sel_registerName("draggedView:movedTo:"));
        CPCoreDragShouldSendDraggedViewEndedAtOperation = objj_msgSend(CPCoreDragSource, "respondsToSelector:", sel_registerName("draggedView:endedAt:operation:"));


        CPCoreDragShouldSendDraggedImageMovedTo = NO;
        CPCoreDragShouldSendDraggedImageEndedAtOperation = NO;
    }

    objj_msgSend(self, "_dragUntilMouseUp:accepted:event:", YES, NO, anEvent);
}
});
instance_methods[2] = new objj_method(sel_registerName("dragImage:fromWindow:at:offset:event:pasteboard:source:slideBack:"), function(self, _cmd, anImage, aWindow, imageLocation, mouseOffset, anEvent, aPasteboard, aSourceObject, slideBack)
{ with(self)
{
    CPCoreDragIsDraggingImage = YES;

    if (!_imageView)
        _imageView = objj_msgSend(objj_msgSend(CPImageView, "alloc"), "initWithFrame:", CPRectMakeZero());

    objj_msgSend(_imageView, "setImage:", anImage);
    objj_msgSend(_imageView, "setFrameSize:", CGSizeMakeCopy(objj_msgSend(anImage, "size")));

    objj_msgSend(self, "dragView:fromWindow:at:offset:event:pasteboard:source:slideBack:", _imageView, aWindow, imageLocation, mouseOffset, anEvent, aPasteboard, aSourceObject, slideBack);
}
});
instance_methods[3] = new objj_method(sel_registerName("_dragUntilMouseUp:accepted:event:"), function(self, _cmd, mouseUpFlag, acceptedFlag, anEvent)
{ with(self)
{
    CPCoreDragStartDragging(anEvent);
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

{
var the_class = objj_getClass("CPView")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPView\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("_dragHitTest:pasteboard:"), function(self, _cmd, aPoint, aPasteboard)
{ with(self)
{
    if(!CPRectContainsPoint(_frame, aPoint) || self == CPCoreDragView)
        return nil;

    var view = nil,
        i = objj_msgSend(_subviews, "count"),
        adjustedPoint = CPPointMake(aPoint.x - CPRectGetMinX(_frame), aPoint.y - CPRectGetMinY(_frame));

    while (i--)
        if (view = objj_msgSend(_subviews[i], "_dragHitTest:pasteboard:", adjustedPoint, aPasteboard))
            return view;

    if (objj_msgSend(aPasteboard, "availableTypeFromArray:", _registeredDraggedTypes))
        return self;

    return nil;
}
});
class_addMethods(the_class, instance_methods);
}

p;19;CPDOMWindowBridge.jI;21;Foundation/CPObject.jI;22;Foundation/CPRunLoop.ji;9;CPEvent.ji;17;CPCompatibility.ji;18;CPDOMWindowLayer.jc;27227;

CPSharedDOMWindowBridge = nil;

{var the_class = objj_allocateClassPair(CPObject, "CPDOMWindowBridge"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_orderedWindows"), new objj_ivar("_mouseDownWindow"), new objj_ivar("_DOMWindow"), new objj_ivar("_DOMBodyElement"), new objj_ivar("_DOMFocusElement"), new objj_ivar("_windowLevels"), new objj_ivar("_windowLayers"), new objj_ivar("_frame"), new objj_ivar("_contentBounds"), new objj_ivar("_mouseIsDown"), new objj_ivar("_lastMouseUp"), new objj_ivar("_lastMouseDown"), new objj_ivar("_currentMousePosition"), new objj_ivar("_charCodes"), new objj_ivar("_keyCode"), new objj_ivar("_DOMPasteboardElement"), new objj_ivar("_pasteboardKeyDownEvent"), new objj_ivar("_overriddenEventType"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("sharedDOMWindowBridge"), function(self, _cmd)
{ with(self)
{
    if (!CPSharedDOMWindowBridge)
        CPSharedDOMWindowBridge = objj_msgSend(objj_msgSend(CPDOMWindowBridge, "alloc"), "_initWithDOMWindow:", window);

    return CPSharedDOMWindowBridge;
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    alert("unimplemented");
}
});
instance_methods[1] = new objj_method(sel_registerName("_initWithDOMWindow:"), function(self, _cmd, aDOMWindow)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
    {
        _DOMWindow = aDOMWindow;

        _windowLevels = [];
        _windowLayers = objj_msgSend(CPDictionary, "dictionary");

        _frame = CPDOMWindowGetFrame(_DOMWindow);
        _contentBounds = CGRectMake(0.0, 0.0, CPRectGetWidth(_frame), CPRectGetHeight(_frame));

        _DOMBodyElement = document.getElementsByTagName("body")[0];
        _DOMBodyElement.innerHTML = "";
        _DOMBodyElement.style.overflow = "hidden";

        _DOMFocusElement = document.createElement("input");
        _DOMFocusElement.style.position = "absolute";
        _DOMFocusElement.style.zIndex = "-1000";
        _DOMFocusElement.style.opacity = "0";
        _DOMFocusElement.style.filter = "alpha(opacity=0)";
        _DOMBodyElement.appendChild(_DOMFocusElement);
        _DOMFocusElement.focus();
        _DOMFocusElement.blur();


        _DOMPasteboardElement = document.createElement("input");
        _DOMPasteboardElement.style.position = "absolute";
        _DOMPasteboardElement.style.top = "-10000px";
        _DOMPasteboardElement.style.zIndex = "99";

        _DOMBodyElement.appendChild(_DOMPasteboardElement);


        _DOMPasteboardElement.blur();

        _charCodes = {};


        var theClass = objj_msgSend(self, "class"),

            keyEventSelector = sel_registerName("_bridgeKeyEvent:"),
            keyEventImplementation = _class_lookupMethodAndLoadCache(theClass, keyEventSelector),
            keyEventCallback = function (anEvent) { keyEventImplementation(self, nil, anEvent); },

            mouseEventSelector = sel_registerName("_bridgeMouseEvent:"),
            mouseEventImplementation = _class_lookupMethodAndLoadCache(theClass, mouseEventSelector),
            mouseEventCallback = function (anEvent) { mouseEventImplementation(self, nil, anEvent); },

            scrollEventSelector = sel_registerName("_bridgeScrollEvent:"),
            scrollEventImplementation = _class_lookupMethodAndLoadCache(theClass, scrollEventSelector),
            scrollEventCallback = function (anEvent) { scrollEventImplementation(self, nil, anEvent); },

            resizeEventSelector = sel_registerName("_bridgeResizeEvent:"),
            resizeEventImplementation = _class_lookupMethodAndLoadCache(theClass, resizeEventSelector),
            resizeEventCallback = function (anEvent) { resizeEventImplementation(self, nil, anEvent); },

            theDocument = _DOMWindow.document;

        if (document.addEventListener)
        {
            _DOMWindow.addEventListener("resize", resizeEventCallback, NO);

            theDocument.addEventListener(CPDOMEventMouseUp, mouseEventCallback, NO);
            theDocument.addEventListener(CPDOMEventMouseDown, mouseEventCallback, NO);
            theDocument.addEventListener(CPDOMEventMouseMoved, mouseEventCallback, NO);

            theDocument.addEventListener(CPDOMEventKeyUp, keyEventCallback, NO);
            theDocument.addEventListener(CPDOMEventKeyDown, keyEventCallback, NO);
            theDocument.addEventListener(CPDOMEventKeyPress, keyEventCallback, NO);


            _DOMWindow.addEventListener("DOMMouseScroll", scrollEventCallback, NO);
            _DOMWindow.addEventListener(CPDOMEventScrollWheel, scrollEventCallback, NO);
        }
        else if(document.attachEvent)
        {
            _DOMWindow.attachEvent("onresize", resizeEventCallback);

            theDocument.attachEvent("on" + CPDOMEventMouseUp, mouseEventCallback);
            theDocument.attachEvent("on" + CPDOMEventMouseDown, mouseEventCallback);
            theDocument.attachEvent("on" + CPDOMEventMouseMoved, mouseEventCallback);
            theDocument.attachEvent("on" + CPDOMEventDoubleClick, mouseEventCallback);

            theDocument.attachEvent("on" + CPDOMEventKeyUp, keyEventCallback);
            theDocument.attachEvent("on" + CPDOMEventKeyDown, keyEventCallback);
            theDocument.attachEvent("on" + CPDOMEventKeyPress, keyEventCallback);

            _DOMWindow.onmousewheel = scrollEventCallback;
            theDocument.onmousewheel = scrollEventCallback;

            theDocument.body.ondrag = function () { return NO; };
            theDocument.body.onselectstart = function () { return window.event.srcElement == _DOMPasteboardElement; };
        }
    }

    return self;
}
});
instance_methods[2] = new objj_method(sel_registerName("frame"), function(self, _cmd)
{ with(self)
{
    return _frame;
}
});
instance_methods[3] = new objj_method(sel_registerName("contentBounds"), function(self, _cmd)
{ with(self)
{
    return CPRectCreateCopy(_contentBounds);
}
});
instance_methods[4] = new objj_method(sel_registerName("layerAtLevel:create:"), function(self, _cmd, aLevel, aFlag)
{ with(self)
{
    var layer = objj_msgSend(_windowLayers, "objectForKey:", aLevel);



    if (!layer && aFlag)
    {
        layer = objj_msgSend(objj_msgSend(CPDOMWindowLayer, "alloc"), "initWithLevel:", aLevel);

        objj_msgSend(_windowLayers, "setObject:forKey:", layer, aLevel);



        var low = 0,
            high = _windowLevels.length - 1,
            middle;

        while (low <= high)
        {
            middle = FLOOR((low + high) / 2);

            if (_windowLevels[middle] > aLevel)
                high = middle - 1;
            else
                low = middle + 1;
        }

        objj_msgSend(_windowLevels, "insertObject:atIndex:", aLevel, _windowLevels[middle]>aLevel?middle:middle+1);
        layer._DOMElement.style.zIndex = aLevel;
        _DOMBodyElement.appendChild(layer._DOMElement);
    }

    return layer;
}
});
instance_methods[5] = new objj_method(sel_registerName("order:window:relativeTo:"), function(self, _cmd, aPlace, aWindow, otherWindow)
{ with(self)
{


    var layer = objj_msgSend(self, "layerAtLevel:create:", objj_msgSend(aWindow, "level"), aPlace!=CPWindowOut);



    if (aPlace == CPWindowOut)
        return objj_msgSend(layer, "removeWindow:", aWindow);


    objj_msgSend(layer, "insertWindow:atIndex:", aWindow, (otherWindow?(aPlace==CPWindowAbove?otherWindow._index+1:otherWindow._index):CPNotFound));
}
});
instance_methods[6] = new objj_method(sel_registerName("_dragHitTest:pasteboard:"), function(self, _cmd, aPoint, aPasteboard)
{ with(self)
{
    var view = nil,
        levels = _windowLevels,
        layers = _windowLayers,
        levelCount = levels.length;

    while (levelCount-- && !view)
    {

        if (levels[levelCount] >= CPDraggingWindowLevel)
            continue;

        var windows = objj_msgSend(layers, "objectForKey:", levels[levelCount])._windows,
            windowCount = windows.length;

        while (windowCount--)
        {
            var theWindow = windows[windowCount],
                frame = theWindow._frame;

            if (CPRectContainsPoint(frame, aPoint))
                if (view = objj_msgSend(theWindow._themeFrame, "_dragHitTest:pasteboard:", CGPointMake(aPoint.x-frame.origin.x,aPoint.y-frame.origin.y), aPasteboard))
                    return view;
                else
                    return nil;
        }
    }

    return view;
}
});
instance_methods[7] = new objj_method(sel_registerName("_propagateCurrentDOMEvent:"), function(self, _cmd, aFlag)
{ with(self)
{
    StopDOMEventPropagation = !aFlag;
}
});
instance_methods[8] = new objj_method(sel_registerName("hitTest:"), function(self, _cmd, location)
{ with(self)
{
    var levels = _windowLevels,
        layers = _windowLayers,
        levelCount = levels.length,
        theWindow = nil;

    while (levelCount-- && !theWindow)
    {
        var windows = objj_msgSend(layers, "objectForKey:", levels[levelCount])._windows,
            windowCount = windows.length;

        while (windowCount-- && !theWindow)
            if (CPRectContainsPoint(windows[windowCount]._frame, location))
                theWindow = windows[windowCount];
    }

    return theWindow;
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

var CPDOMWindowGetFrame = function(_DOMWindow)
{
    var frame = nil;


    if (_DOMWindow.outerWidth)
        frame = CGRectMake(0, 0, _DOMWindow.outerWidth, _DOMWindow.outerHeight);

    else
        frame = CGRectMake(0, 0, -1, -1);

    if (window.screenTop)
        frame.origin = CGPointMake(_DOMWindow.screenLeft, _DOMWindow.screenTop, 0);

    else if (window.screenX)
        frame.origin = CGPointMake(_DOMWindow.screenX, _DOMWindow.screenY, 0);


    if (_DOMWindow.innerWidth)
        frame.size = CGSizeMake(_DOMWindow.innerWidth, _DOMWindow.innerHeight);


    else if (document.documentElement && document.documentElement.clientWidth)
        frame.size = CGSizeMake(_DOMWindow.document.documentElement.clientWidth, _DOMWindow.document.documentElement.clientHeight);


    else
        frame.size = CGSizeMake(_DOMWindow.document.body.clientWidth, _DOMWindow.document.body.clientHeight);

    return frame;
}




var KeyCodesToPropagate = { '113':1, '119':1, '114':1, '116':1 };
var KeyCodesWithoutKeyPressEvents = { '8':1, '9':1, '37':1, '38':1, '39':1, '40':1 };

var CTRL_KEY_CODE = 17;

{
var the_class = objj_getClass("CPDOMWindowBridge")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPDOMWindowBridge\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("_bridgeMouseEvent:"), function(self, _cmd, aDOMEvent)
{ with(self)
{
    var theType = _overriddenEventType || aDOMEvent.type;


    if (theType == CPDOMEventDoubleClick)
    {
        _overriddenEventType = CPDOMEventMouseDown;
        objj_msgSend(self, "_bridgeMouseEvent:", aDOMEvent);

        _overriddenEventType = CPDOMEventMouseUp;
        objj_msgSend(self, "_bridgeMouseEvent:", aDOMEvent);

        _overriddenEventType = nil;

        return;
    }

    try
    {

        if ( (aDOMEvent.target || aDOMEvent.srcElement) != _DOMFocusElement &&
            ((aDOMEvent.target || aDOMEvent.srcElement).tagName == "INPUT" ||
             (aDOMEvent.target || aDOMEvent.srcElement).tagName == "SELECT" ||
             (aDOMEvent.target || aDOMEvent.srcElement).tagName == "TEXTAREA" ||
             (aDOMEvent.target || aDOMEvent.srcElement).tagName == "OPTION" ))
            return;

        var event,
            location = CGPointMake(aDOMEvent.clientX, aDOMEvent.clientY),
            timestamp = aDOMEvent.timeStamp ? aDOMEvent.timeStamp : new Date(),
            windowNumber = 0,
            modifierFlags = (aDOMEvent.shiftKey ? CPShiftKeyMask : 0) |
                            (aDOMEvent.ctrlKey ? CPControlKeyMask : 0) |
                            (aDOMEvent.altKey ? CPAlternateKeyMask : 0) |
                            (aDOMEvent.metaKey ? CPCommandKeyMask : 0);

        StopDOMEventPropagation = YES;

        if (_mouseDownWindow)
            windowNumber = objj_msgSend(_mouseDownWindow, "windowNumber");
        else
        {
            var theWindow = objj_msgSend(self, "hitTest:", location);

            if (aDOMEvent.type == CPDOMEventMouseDown && window)
                _mouseDownWindow = theWindow;

            windowNumber = objj_msgSend(theWindow, "windowNumber");
        }

        if (windowNumber)
        {
            var windowFrame = CPApp._windows[windowNumber]._frame;

            location.x -= CGRectGetMinX(windowFrame);
            location.y -= CGRectGetMinY(windowFrame);
        }

        switch (theType)
        {
            case CPDOMEventMouseUp: if(_mouseIsDown)
                                        {
                                            event = objj_msgSend(CPEvent, "mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:", CPLeftMouseUp, location, modifierFlags, timestamp, windowNumber, nil, -1, CPDOMEventGetClickCount(_lastMouseUp,timestamp,location), 0);

                                            _mouseIsDown = NO;
                                            _lastMouseUp = event;
                                            _mouseDownWindow = nil;
                                        }

                                        break;

            case CPDOMEventMouseDown: event = objj_msgSend(CPEvent, "mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:", CPLeftMouseDown, location, modifierFlags, timestamp, windowNumber, nil, -1, CPDOMEventGetClickCount(_lastMouseDown,timestamp,location), 0);

                                        _mouseIsDown = YES;
                                        _lastMouseDown = event;

                                        break;

            case CPDOMEventMouseMoved: event = objj_msgSend(CPEvent, "mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:", _mouseIsDown?CPLeftMouseDragged:CPMouseMoved, location, modifierFlags, timestamp, windowNumber, nil, -1, 1, 0);

                                        _currentMousePosition = CGPointMake(aDOMEvent.clientX, aDOMEvent.clientY);

                                        break;
        }

        if (event)
        {
            event._DOMEvent = aDOMEvent;

            objj_msgSend(CPApp, "sendEvent:", event);
        }

        if (StopDOMEventPropagation)
            CPDOMEventStop(aDOMEvent);

        objj_msgSend(objj_msgSend(CPRunLoop, "currentRunLoop"), "performSelectors");
    }
    catch (anException)
    {
        objj_exception_report(anException, {path:"CPDOMWindowBridge.j"});
    }
}
});
instance_methods[1] = new objj_method(sel_registerName("_bridgeKeyEvent:"), function(self, _cmd, aDOMEvent)
{ with(self)
{
    try
    {

        if ( (aDOMEvent.target || aDOMEvent.srcElement) != _DOMFocusElement &&
            (aDOMEvent.target || aDOMEvent.srcElement) != _DOMPasteboardElement &&
            ((aDOMEvent.target || aDOMEvent.srcElement).tagName == "INPUT" ||
             (aDOMEvent.target || aDOMEvent.srcElement).tagName == "SELECT" ||
             (aDOMEvent.target || aDOMEvent.srcElement).tagName == "TEXTAREA" ||
             (aDOMEvent.target || aDOMEvent.srcElement).tagName == "OPTION" ))
            return;

        var event,
            timestamp = aDOMEvent.timeStamp ? aDOMEvent.timeStamp : new Date(),
            windowNumber = objj_msgSend(objj_msgSend(CPApp, "keyWindow"), "windowNumber"),
            modifierFlags = (aDOMEvent.shiftKey ? CPShiftKeyMask : 0) |
                            (aDOMEvent.ctrlKey ? CPControlKeyMask : 0) |
                            (aDOMEvent.altKey ? CPAlternateKeyMask : 0) |
                            (aDOMEvent.metaKey ? CPCommandKeyMask : 0);

        StopDOMEventPropagation = YES;

        if(KeyCodesToPropagate[aDOMEvent.keyCode])
            StopDOMEventPropagation = !(modifierFlags & (CPControlKeyMask | CPCommandKeyMask));






        var isNativePasteEvent = NO,
            isNativeCopyOrCutEvent = NO;

        switch (aDOMEvent.type)
        {
            case CPDOMEventKeyDown:
                                        _keyCode = aDOMEvent.keyCode;

                                        var characters = String.fromCharCode(_keyCode).toLowerCase();



                                        if (characters == "v" && (modifierFlags & CPPlatformActionKeyMask))
                                        {
                                            _DOMPasteboardElement.select();
                                            _DOMPasteboardElement.value = "";

                                            isNativePasteEvent = YES;
                                        }






                                        else if ((characters == "c" || characters == "x") && (modifierFlags & CPPlatformActionKeyMask))
                                            isNativeCopyOrCutEvent = YES;



                                        else if (!CPFeatureIsCompatible(CPJavascriptRemedialKeySupport))
                                            return;


                                        else if (!KeyCodesWithoutKeyPressEvents[_keyCode] && (_keyCode == CTRL_KEY_CODE || !(modifierFlags & CPControlKeyMask)))
                                            return;


            case CPDOMEventKeyPress:


                                        if ((aDOMEvent.target || aDOMEvent.srcElement) == _DOMPasteboardElement)
                                            return;

                                        var keyCode = _keyCode,
                                            charCode = aDOMEvent.keyCode || aDOMEvent.charCode,
                                            isARepeat = (_charCodes[keyCode] != nil);

                                        _charCodes[keyCode] = charCode;

                                        var characters = String.fromCharCode(charCode),
                                            charactersIgnoringModifiers = characters.toLowerCase();

                                        if (!(modifierFlags & CPShiftKeyMask))
                                            characters = charactersIgnoringModifiers;

                                        event = objj_msgSend(CPEvent, "keyEventWithType:location:modifierFlags:timestamp:windowNumber:context:characters:charactersIgnoringModifiers:isARepeat:keyCode:", CPKeyDown, location, modifierFlags, timestamp, windowNumber, nil, characters, charactersIgnoringModifiers, isARepeat, keyCode);

                                        if (isNativePasteEvent)
                                        {
                                            _pasteboardKeyDownEvent = event;

                                            window.setTimeout(function () { objj_msgSend(self, "_checkPasteboardElement") }, 0);

                                            return;
                                        }

                                        break;

            case CPDOMEventKeyUp: var keyCode = aDOMEvent.keyCode,
                                            charCode = _charCodes[keyCode];

                                        _charCodes[keyCode] = nil;

                                        var characters = String.fromCharCode(charCode),
                                            charactersIgnoringModifiers = characters.toLowerCase();

                                        if (!(modifierFlags & CPShiftKeyMask))
                                            characters = charactersIgnoringModifiers;

                                        event = objj_msgSend(CPEvent, "keyEventWithType:location:modifierFlags:timestamp:windowNumber:context:characters:charactersIgnoringModifiers:isARepeat:keyCode:", CPKeyUp, location, modifierFlags, timestamp, windowNumber, nil, characters, charactersIgnoringModifiers, NO, keyCode);
                                        break;
        }

        if (event)
        {
            event._DOMEvent = aDOMEvent;

            objj_msgSend(CPApp, "sendEvent:", event);

            if (isNativeCopyOrCutEvent)
            {
                var pasteboard = objj_msgSend(CPPasteboard, "generalPasteboard"),
                    types = objj_msgSend(pasteboard, "types");


                if (types.length)
                {
                    if (objj_msgSend(types, "indexOfObjectIdenticalTo:", CPStringPboardType) != CPNotFound)
                        _DOMPasteboardElement.value = objj_msgSend(pasteboard, "stringForType:", CPStringPboardType);
                    else
                        _DOMPasteboardElement.value = objj_msgSend(pasteboard, "_generateStateUID");

                    _DOMPasteboardElement.select();

                    window.setTimeout(function() { objj_msgSend(self, "_clearPasteboardElement"); }, 0);
                }

                return;
            }
        }

        if (StopDOMEventPropagation)
            CPDOMEventStop(aDOMEvent);

        objj_msgSend(objj_msgSend(CPRunLoop, "currentRunLoop"), "performSelectors");
    }
    catch (anException)
    {
        objj_exception_report(anException, {path:"CPDOMWindowBridge.j"});
    }
}
});
instance_methods[2] = new objj_method(sel_registerName("_bridgeScrollEvent:"), function(self, _cmd, aDOMEvent)
{ with(self)
{
    if(!aDOMEvent)
        aDOMEvent = window.event;

    try
    {
        var deltaX = 0.0,
            deltaY = 0.0,
            windowNumber = 0,
            location = CGPointMake(_currentMousePosition.x, _currentMousePosition.y),
            timestamp = aDOMEvent.timeStamp ? aDOMEvent.timeStamp : new Date(),
            modifierFlags = (aDOMEvent.shiftKey ? CPShiftKeyMask : 0) |
                            (aDOMEvent.ctrlKey ? CPControlKeyMask : 0) |
                            (aDOMEvent.altKey ? CPAlternateKeyMask : 0) |
                            (aDOMEvent.metaKey ? CPCommandKeyMask : 0);

        StopDOMEventPropagation = YES;

        windowNumber = objj_msgSend(objj_msgSend(self, "hitTest:", location), "windowNumber");

        if (!windowNumber)
            return;

        var windowFrame = CPApp._windows[windowNumber]._frame;

        location.x -= CGRectGetMinX(windowFrame);
        location.y -= CGRectGetMinY(windowFrame);

        if(typeof aDOMEvent.wheelDeltaX != "undefined")
        {
            deltaX = aDOMEvent.wheelDeltaX / 120.0;
            deltaY = aDOMEvent.wheelDeltaY / 120.0;
        }

        else if (aDOMEvent.wheelDelta)
            deltaY = aDOMEvent.wheelDelta / 120.0;

        else if (aDOMEvent.detail)
            deltaY = -aDOMEvent.detail / 3.0;

        else
            return;

        if(!CPFeatureIsCompatible(CPJavaScriptNegativeMouseWheelValues))
        {
            deltaX = -deltaX;
            deltaY = -deltaY;
        }

        var event = objj_msgSend(CPEvent, "mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:", CPScrollWheel, location, modifierFlags, timestamp, windowNumber, nil, -1, 1, 0);

        event._DOMEvent = aDOMEvent;
        event._deltaX = ROUND(deltaX * 1.5);
        event._deltaY = ROUND(deltaY * 1.5);

        objj_msgSend(CPApp, "sendEvent:", event);

        if (StopDOMEventPropagation)
            CPDOMEventStop(aDOMEvent);

        objj_msgSend(objj_msgSend(CPRunLoop, "currentRunLoop"), "performSelectors");
    }
    catch (anException)
    {
        objj_exception_report(anException, {path:"CPDOMWindowBridge.j"});
    }

}
});
instance_methods[3] = new objj_method(sel_registerName("_bridgeResizeEvent:"), function(self, _cmd, aDOMEvent)
{ with(self)
{
    try
    {




        var oldSize = _frame.size;


        _frame = CPDOMWindowGetFrame(_DOMWindow);
        _contentBounds.size = CGSizeCreateCopy(_frame.size);

        var levels = _windowLevels,
            layers = _windowLayers,
            levelCount = levels.length;

        while (levelCount--)
        {
            var windows = objj_msgSend(layers, "objectForKey:", levels[levelCount])._windows,
                windowCount = windows.length;

            while (windowCount--)
                objj_msgSend(windows[windowCount], "resizeWithOldBridgeSize:", oldSize);
        }



        objj_msgSend(objj_msgSend(CPRunLoop, "currentRunLoop"), "performSelectors");

    }
    catch (anException)
    {
        objj_exception_report(anException, {path:"CPDOMWindowBridge.j"});
    }
}
});
instance_methods[4] = new objj_method(sel_registerName("_checkPasteboardElement"), function(self, _cmd)
{ with(self)
{
    try
    {
        var value = _DOMPasteboardElement.value;

        if (objj_msgSend(value, "length"))
        {
            var pasteboard = objj_msgSend(CPPasteboard, "generalPasteboard");

            if (objj_msgSend(pasteboard, "_stateUID") != value)
            {
                objj_msgSend(pasteboard, "declareTypes:owner:", [CPStringPboardType], self);

                objj_msgSend(pasteboard, "setString:forType:", value, CPStringPboardType);
            }
        }

        objj_msgSend(self, "_clearPasteboardElement");

        objj_msgSend(CPApp, "sendEvent:", _pasteboardKeyDownEvent);

        _pasteboardKeyDownEvent = nil;

        objj_msgSend(objj_msgSend(CPRunLoop, "currentRunLoop"), "performSelectors");
    }
    catch (anException)
    {
        objj_exception_report(anException, {path:"CPDOMWindowBridge.j"});
    }
}
});
instance_methods[5] = new objj_method(sel_registerName("_clearPasteboardElement"), function(self, _cmd)
{ with(self)
{
    _DOMPasteboardElement.value = "";
    _DOMPasteboardElement.blur();
}
});
class_addMethods(the_class, instance_methods);
}

var CLICK_SPACE_DELTA = 5.0,
    CLICK_TIME_DELTA = document.addEventListener ? 350.0 : 1000.0;

var CPDOMEventGetClickCount = function(aComparisonEvent, aTimestamp, aLocation)
{
    if (!aComparisonEvent)
        return 1;

    var comparisonLocation = objj_msgSend(aComparisonEvent, "locationInWindow");

    return (aTimestamp - objj_msgSend(aComparisonEvent, "timestamp") < CLICK_TIME_DELTA &&
        ABS(comparisonLocation.x - aLocation.x) < CLICK_SPACE_DELTA &&
        ABS(comparisonLocation.y - aLocation.y) < CLICK_SPACE_DELTA) ? objj_msgSend(aComparisonEvent, "clickCount") + 1 : 1;
}

var CPDOMEventStop = function(aDOMEvent)
{

    aDOMEvent.cancelBubble = true;
    aDOMEvent.returnValue = false;


    if (aDOMEvent.preventDefault)
        aDOMEvent.preventDefault();

    if (aDOMEvent.stopPropagation)
        aDOMEvent.stopPropagation();

    if (aDOMEvent.type == CPDOMEventMouseDown)
    {
        CPSharedDOMWindowBridge._DOMFocusElement.focus();
        CPSharedDOMWindowBridge._DOMFocusElement.blur();
    }
}

p;18;CPDOMWindowLayer.jI;20;Foundation/CPArray.jI;21;Foundation/CPObject.jc;2745;


{var the_class = objj_allocateClassPair(CPObject, "CPDOMWindowLayer"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_level"), new objj_ivar("_windows"), new objj_ivar("_DOMElement"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithLevel:"), function(self, _cmd, aLevel)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
    {
        _level = aLevel;

        _windows = [];

        _DOMElement = document.createElement("div");
        _DOMElement.style.position = "absolute";
        _DOMElement.style.top = "0px";
        _DOMElement.style.left = "0px";
        _DOMElement.style.width = "1px";
        _DOMElement.style.height = "1px";
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("level"), function(self, _cmd)
{ with(self)
{
    return _level;
}
});
instance_methods[2] = new objj_method(sel_registerName("removeWindow:"), function(self, _cmd, aWindow)
{ with(self)
{
    var index = aWindow._index,
        count = _windows.length - 1;

    _DOMElement.removeChild(aWindow._DOMElement);
    objj_msgSend(_windows, "removeObjectAtIndex:", aWindow._index);

    for (; index < count; ++index)
    {
        _windows[index]._index = index;
        _windows[index]._DOMElement.style.zIndex = index;
    }

    aWindow._isVisible = NO;
}
});
instance_methods[3] = new objj_method(sel_registerName("insertWindow:atIndex:"), function(self, _cmd, aWindow, anIndex)
{ with(self)
{

    var count = objj_msgSend(_windows, "count"),
        zIndex = (anIndex == CPNotFound ? count : anIndex),
        isVisible = aWindow._isVisible;


    if (isVisible)
    {
        zIndex = MIN(zIndex, aWindow._index);
        objj_msgSend(_windows, "removeObjectAtIndex:", aWindow._index);
    }
    else
        ++count;

    if (anIndex == CPNotFound || anIndex >= count)
        objj_msgSend(_windows, "addObject:", aWindow);
    else
        objj_msgSend(_windows, "insertObject:atIndex:", aWindow, anIndex);


    for (; zIndex < count; ++zIndex)
    {
        _windows[zIndex]._index = zIndex;
        _windows[zIndex]._DOMElement.style.zIndex = zIndex;
    }

    if (!isVisible)
    {
        _DOMElement.appendChild(aWindow._DOMElement);
        aWindow._isVisible = YES;

        if (objj_msgSend(aWindow, "styleMask") & CPBorderlessBridgeWindowMask)
            objj_msgSend(aWindow, "setFrame:", objj_msgSend(aWindow._bridge, "contentBounds"));
    }
}
});
class_addMethods(the_class, instance_methods);
}

p;12;CPDocument.jI;21;Foundation/CPString.jI;20;Foundation/CPArray.ji;13;CPResponder.ji;20;CPWindowController.jc;14136;


CPSaveOperation = 0;
CPSaveAsOperation = 1;
CPSaveToOperation = 2;
CPAutosaveOperation = 3;

CPChangeDone = 0;
CPChangeUndone = 1;
CPChangeCleared = 2;
CPChangeReadOtherContents = 3;
CPChangeAutosaved = 4;

CPDocumentWillSaveNotification = "CPDocumentWillSaveNotification";
CPDocumentDidSaveNotification = "CPDocumentDidSaveNotification";
CPDocumentDidFailToSaveNotification = "CPDocumentDidFailToSaveNotification";

var CPDocumentUntitledCount = 0;

{var the_class = objj_allocateClassPair(CPResponder, "CPDocument"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_fileURL"), new objj_ivar("_fileType"), new objj_ivar("_windowControllers"), new objj_ivar("_untitledDocumentIndex"), new objj_ivar("_hasUndoManager"), new objj_ivar("_undoManager"), new objj_ivar("_changeCount"), new objj_ivar("_readConnection"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("init"), function(self, _cmd)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPResponder") }, "init");

    if (self)
    {
        _windowControllers = [];

        _hasUndoManager = YES;
        _changeCount = 0;

        objj_msgSend(self, "setNextResponder:", CPApp);
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("initWithType:error:"), function(self, _cmd, aType, anError)
{ with(self)
{
    self = objj_msgSend(self, "init");

    if (self)
        objj_msgSend(self, "setFileType:", aType);

    return self;
}
});
instance_methods[2] = new objj_method(sel_registerName("initWithContentsOfURL:ofType:delegate:didReadSelector:contextInfo:"), function(self, _cmd, anAbsoluteURL, aType, aDelegate, aDidReadSelector, aContextInfo)
{ with(self)
{
    self = objj_msgSend(self, "init");

    if (self)
    {
        objj_msgSend(self, "readFromURL:ofType:delegate:didReadSelector:contextInfo:", anAbsoluteURL, aType, aDelegate, aDidReadSelector, aContextInfo);

        objj_msgSend(self, "setFileURL:", anAbsoluteURL);
        objj_msgSend(self, "setFileType:", aType);
    }

    return self;
}
});
instance_methods[3] = new objj_method(sel_registerName("dataOfType:error:"), function(self, _cmd, aType, anError)
{ with(self)
{

    return nil;
}
});
instance_methods[4] = new objj_method(sel_registerName("readFromData:ofType:error:"), function(self, _cmd, aData, aType, anError)
{ with(self)
{}
});
instance_methods[5] = new objj_method(sel_registerName("makeWindowControllers"), function(self, _cmd)
{ with(self)
{
    var controller = objj_msgSend(objj_msgSend(CPWindowController, "alloc"), "initWithWindowCibName:", nil);

    objj_msgSend(self, "addWindowController:", controller);
}
});
instance_methods[6] = new objj_method(sel_registerName("windowControllers"), function(self, _cmd)
{ with(self)
{
    return _windowControllers;
}
});
instance_methods[7] = new objj_method(sel_registerName("addWindowController:"), function(self, _cmd, aWindowController)
{ with(self)
{
    objj_msgSend(_windowControllers, "addObject:", aWindowController);

    if (objj_msgSend(aWindowController, "document") != self)
    {
        objj_msgSend(aWindowController, "setNextResponder:", self);
        objj_msgSend(aWindowController, "setDocument:", self);
    }
}
});
instance_methods[8] = new objj_method(sel_registerName("showWindows"), function(self, _cmd)
{ with(self)
{
    objj_msgSend(_windowControllers, "makeObjectsPerformSelector:withObject:", sel_registerName("showWindow:"), self);
}
});
instance_methods[9] = new objj_method(sel_registerName("displayName"), function(self, _cmd)
{ with(self)
{

    if (!_untitledDocumentIndex)
        _untitledDocumentIndex = ++CPDocumentUntitledCount;

 if (_untitledDocumentIndex == 1)
    return "Untitled";

 return "Untitled " + _untitledDocumentIndex;
}
});
instance_methods[10] = new objj_method(sel_registerName("windowCibName"), function(self, _cmd)
{ with(self)
{
    return nil;
}
});
instance_methods[11] = new objj_method(sel_registerName("windowControllerDidLoadNib:"), function(self, _cmd, aWindowController)
{ with(self)
{}
});
instance_methods[12] = new objj_method(sel_registerName("windowControllerWillLoadNib:"), function(self, _cmd, aWindowController)
{ with(self)
{}
});
instance_methods[13] = new objj_method(sel_registerName("readFromURL:ofType:delegate:didReadSelector:contextInfo:"), function(self, _cmd, anAbsoluteURL, aType, aDelegate, aDidReadSelector, aContextInfo)
{ with(self)
{
    objj_msgSend(_readConnection, "cancel");


    _readConnection = objj_msgSend(AuthorizedConnection, "connectionWithRequest:delegate:", objj_msgSend(CPURLRequest, "requestWithURL:", anAbsoluteURL), self);

    _readConnection.session = _CPReadSessionMake(aType, aDelegate, aDidReadSelector, aContextInfo);
}
});
instance_methods[14] = new objj_method(sel_registerName("fileURL"), function(self, _cmd)
{ with(self)
{
    return _fileURL;
}
});
instance_methods[15] = new objj_method(sel_registerName("setFileURL:"), function(self, _cmd, aFileURL)
{ with(self)
{
    if (_fileURL == aFileURL)
        return;

    _fileURL = aFileURL;

    objj_msgSend(_windowControllers, "makeObjectsPerformSelector:", sel_registerName("synchronizeWindowTitleWithDocumentName"));
}
});
instance_methods[16] = new objj_method(sel_registerName("saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo:"), function(self, _cmd, anAbsoluteURL, aTypeName, aSaveOperation, aDelegate, aDidSaveSelector, aContextInfo)
{ with(self)
{
    var request = objj_msgSend(CPURLRequest, "requestWithURL:", anAbsoluteURL),
        data = objj_msgSend(self, "dataOfType:error:", objj_msgSend(self, "fileType"), nil);

    objj_msgSend(request, "setHTTPMethod:", "POST");
    objj_msgSend(request, "setHTTPBody:", objj_msgSend(data, "string"));

    objj_msgSend(request, "setValue:forHTTPHeaderField:", "close", "Connection");


    var connection = objj_msgSend(AuthorizedConnection, "connectionWithRequest:delegate:", request, self);

    if (aSaveOperation != CPSaveToOperation)
        objj_msgSend(self, "updateChangeCount:", CPChangeCleared);

    connection.session = _CPSaveSessionMake(anAbsoluteURL, aSaveOperation, _changeCount, aDelegate, aDidSaveSelector, aContextInfo, connection);
}
});
instance_methods[17] = new objj_method(sel_registerName("connection:didReceiveData:"), function(self, _cmd, aConnection, aData)
{ with(self)
{
    var session = aConnection.session;


    if (aConnection == _readConnection)
    {
        objj_msgSend(self, "readFromData:ofType:error:", objj_msgSend(CPData, "dataWithString:", aData), session.fileType, nil);

        objj_msgSend(session.delegate, session.didReadSelector, self, YES, session.contextInfo);
    }
    else
    {
        if (session.saveOperation != CPSaveToOperation)
            objj_msgSend(self, "setFileURL:", session.absoluteURL);

        objj_msgSend(session.delegate, session.didSaveSelector, self, YES, session.contextInfo);
    }
}
});
instance_methods[18] = new objj_method(sel_registerName("connection:didFailWithError:"), function(self, _cmd, aConnection, anError)
{ with(self)
{
    var session = aConnection.session;

    if (_readConnection == aConnection)
        objj_msgSend(session.delegate, session.didReadSelector, self, NO, session.contextInfo);

    else
    {
        _changeCount += session.changeCount;
        objj_msgSend(_windowControllers, "makeObjectsPerformSelector:withObject:", sel_registerName("setDocumentEdited:"), objj_msgSend(self, "isDocumentEdited"));

        objj_msgSend(session.delegate, session.didSaveSelector, self, NO, session.contextInfo);
    }
}
});
instance_methods[19] = new objj_method(sel_registerName("connectionDidFinishLoading:"), function(self, _cmd, aConnection)
{ with(self)
{
    if (_readConnection == aConnection)
        _readConnection = nil;
}
});
instance_methods[20] = new objj_method(sel_registerName("isDocumentEdited"), function(self, _cmd)
{ with(self)
{
    return _changeCount != 0;
}
});
instance_methods[21] = new objj_method(sel_registerName("updateChangeCount:"), function(self, _cmd, aChangeType)
{ with(self)
{
    if (aChangeType == CPChangeDone)
        ++_changeCount;
    else if (aChangeType == CPChangeUndone)
        --_changeCount;
    else if (aChangeType == CPChangeCleared)
        _changeCount = 0;




    objj_msgSend(_windowControllers, "makeObjectsPerformSelector:withObject:", sel_registerName("setDocumentEdited:"), objj_msgSend(self, "isDocumentEdited"));
}
});
instance_methods[22] = new objj_method(sel_registerName("setFileType:"), function(self, _cmd, aType)
{ with(self)
{
    _fileType = aType;
}
});
instance_methods[23] = new objj_method(sel_registerName("fileType"), function(self, _cmd)
{ with(self)
{
    return _fileType;
}
});
instance_methods[24] = new objj_method(sel_registerName("hasUndoManager"), function(self, _cmd)
{ with(self)
{
    return _hasUndoManager;
}
});
instance_methods[25] = new objj_method(sel_registerName("setHashUndoManager:"), function(self, _cmd, aFlag)
{ with(self)
{
    if (_hasUndoManager == aFlag)
        return;

    _hasUndoManager = aFlag;

    if (!_hasUndoManager)
        objj_msgSend(self, "setUndoManager:", nil);
}
});
instance_methods[26] = new objj_method(sel_registerName("_undoManagerWillCloseGroup:"), function(self, _cmd, aNotification)
{ with(self)
{
    var undoManager = objj_msgSend(aNotification, "object");

    if (objj_msgSend(undoManager, "isUndoing") || objj_msgSend(undoManager, "isRedoing"))
        return;

    objj_msgSend(self, "updateChangeCount:", CPChangeDone);
}
});
instance_methods[27] = new objj_method(sel_registerName("_undoManagerDidUndoChange:"), function(self, _cmd, aNotification)
{ with(self)
{
    objj_msgSend(self, "updateChangeCount:", CPChangeUndone);
}
});
instance_methods[28] = new objj_method(sel_registerName("_undoManagerDidRedoChange:"), function(self, _cmd, aNotification)
{ with(self)
{
    objj_msgSend(self, "updateChangeCount:", CPChangeDone);
}
});
instance_methods[29] = new objj_method(sel_registerName("setUndoManager:"), function(self, _cmd, anUndoManager)
{ with(self)
{
    var defaultCenter = objj_msgSend(CPNotificationCenter, "defaultCenter");

    if (_undoManager)
    {
        objj_msgSend(defaultCenter, "removeObserver:name:object:", self, CPUndoManagerDidUndoChangeNotification, _undoManager);

        objj_msgSend(defaultCenter, "removeObserver:name:object:", self, CPUndoManagerDidRedoChangeNotification, _undoManager);

        objj_msgSend(defaultCenter, "removeObserver:name:object:", self, CPUndoManagerWillCloseUndoGroupNotification, _undoManager);
    }

    _undoManager = anUndoManager;

    if (_undoManager)
    {

        objj_msgSend(defaultCenter, "addObserver:selector:name:object:", self, sel_registerName("_undoManagerDidUndoChange:"), CPUndoManagerDidUndoChangeNotification, _undoManager);

        objj_msgSend(defaultCenter, "addObserver:selector:name:object:", self, sel_registerName("_undoManagerDidRedoChange:"), CPUndoManagerDidRedoChangeNotification, _undoManager);

        objj_msgSend(defaultCenter, "addObserver:selector:name:object:", self, sel_registerName("_undoManagerWillCloseGroup:"), CPUndoManagerWillCloseUndoGroupNotification, _undoManager);
    }
}
});
instance_methods[30] = new objj_method(sel_registerName("undoManager"), function(self, _cmd)
{ with(self)
{
    if (_hasUndoManager && !_undoManager)
        objj_msgSend(self, "setUndoManager:", objj_msgSend(objj_msgSend(CPUndoManager, "alloc"), "init"));

    return _undoManager;
}
});
instance_methods[31] = new objj_method(sel_registerName("windowWillReturnUndoManager:"), function(self, _cmd, aWindow)
{ with(self)
{
    return objj_msgSend(self, "undoManager");
}
});
instance_methods[32] = new objj_method(sel_registerName("saveDocument:"), function(self, _cmd, aSender)
{ with(self)
{
    if (_fileURL)
    {
        objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:", CPDocumentWillSaveNotification, self);

        objj_msgSend(self, "saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo:", _fileURL, objj_msgSend(self, "fileType"), CPSaveOperation, self, sel_registerName("document:didSave:contextInfo:"), NULL);
    }
    else
        objj_msgSend(self, "saveDocumentAs:", self);
}
});
instance_methods[33] = new objj_method(sel_registerName("saveDocumentAs:"), function(self, _cmd, aSender)
{ with(self)
{
    _documentName = window.prompt("Document Name:");

    if (!_documentName)
        return;

    objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:", CPDocumentWillSaveNotification, self);

    objj_msgSend(self, "saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo:", objj_msgSend(self, "proposedFileURL"), objj_msgSend(self, "fileType"), CPSaveOperation, self, sel_registerName("document:didSave:contextInfo:"), NULL);
}
});
instance_methods[34] = new objj_method(sel_registerName("document:didSave:contextInfo:"), function(self, _cmd, aDocument, didSave, aContextInfo)
{ with(self)
{
    if (didSave)
        objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:", CPDocumentDidSaveNotification, self);
    else
        objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:", CPDocumentDidFailToSaveNotification, self);
}
});
class_addMethods(the_class, instance_methods);
}

var _CPReadSessionMake = function(aType, aDelegate, aDidReadSelector, aContextInfo)
{
    return { fileType:aType, delegate:aDelegate, didReadSelector:aDidReadSelector, contextInfo:aContextInfo };
}

var _CPSaveSessionMake = function(anAbsoluteURL, aSaveOperation, aChangeCount, aDelegate, aDidSaveSelector, aContextInfo, aConnection)
{
    return { absoluteURL:anAbsoluteURL, saveOperation:aSaveOperation, changeCount:aChangeCount, delegate:aDelegate, didSaveSelector:aDidSaveSelector, contextInfo:aContextInfo, connection:aConnection };
}

p;22;CPDocumentController.jI;21;Foundation/CPObject.jI;21;Foundation/CPBundle.ji;12;CPDocument.jc;5479;

var CPSharedDocumentController = nil;

{var the_class = objj_allocateClassPair(CPObject, "CPDocumentController"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_documents"), new objj_ivar("_documentTypes"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("sharedDocumentController"), function(self, _cmd)
{ with(self)
{
    if (!CPSharedDocumentController)
        objj_msgSend(objj_msgSend(self, "alloc"), "init");

    return CPSharedDocumentController;
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("init"), function(self, _cmd)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
    {
        _documents = objj_msgSend(objj_msgSend(CPArray, "alloc"), "init");

        if (!CPSharedDocumentController)
            CPSharedDocumentController = self;

        _documentTypes = objj_msgSend(objj_msgSend(objj_msgSend(CPBundle, "mainBundle"), "infoDictionary"), "objectForKey:", "CPBundleDocumentTypes");
    }
    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("documentForURL:"), function(self, _cmd, aURL)
{ with(self)
{
    var index = 0,
        count = objj_msgSend(_documents, "count");

 for (; index < count; ++index)
    {
        var theDocument = _documents[index];

  if (objj_msgSend(objj_msgSend(theDocument, "fileURL"), "isEqual:", aURL))
   return theDocument;
    }

 return nil;
}
});
instance_methods[2] = new objj_method(sel_registerName("openUntitledDocumentOfType:display:"), function(self, _cmd, aType, shouldDisplay)
{ with(self)
{
    var document = objj_msgSend(self, "makeUntitledDocumentOfType:error:", aType, nil);

    if (document)
        objj_msgSend(self, "addDocument:", document);

    if (shouldDisplay)
    {
        objj_msgSend(document, "makeWindowControllers");
        objj_msgSend(document, "showWindows");
    }

    return document;
}
});
instance_methods[3] = new objj_method(sel_registerName("makeUntitledDocumentOfType:error:"), function(self, _cmd, aType, anError)
{ with(self)
{
    return objj_msgSend(objj_msgSend(objj_msgSend(self, "documentClassForType:", aType), "alloc"), "initWithType:error:", aType, anError);
}
});
instance_methods[4] = new objj_method(sel_registerName("openDocumentWithContentsOfURL:display:error:"), function(self, _cmd, anAbsoluteURL, shouldDisplay, anError)
{ with(self)
{
    var result = objj_msgSend(self, "documentForURL:", anAbsoluteURL);

    if (!result)

        result = objj_msgSend(self, "makeDocumentWithContentsOfURL:ofType:delegate:didReadSelector:contextInfo:", anAbsoluteURL, objj_msgSend(objj_msgSend(_documentTypes, "objectAtIndex:", 0), "objectForKey:", "CPBundleTypeName"), self, sel_registerName("document:didRead:contextInfo:"), nil);

    else if (shouldDisplay)
        objj_msgSend(result, "showWindows");

    return result;
}
});
instance_methods[5] = new objj_method(sel_registerName("makeDocumentWithContentsOfURL:ofType:delegate:didReadSelector:contextInfo:"), function(self, _cmd, anAbsoluteURL, aType, aDelegate, aSelector, aContextInfo)
{ with(self)
{
    return objj_msgSend(objj_msgSend(objj_msgSend(self, "documentClassForType:", aType), "alloc"), "initWithContentsOfURL:ofType:delegate:didReadSelector:contextInfo:", anAbsoluteURL, aType, aDelegate, aSelector, aContextInfo);
}
});
instance_methods[6] = new objj_method(sel_registerName("document:didRead:contextInfo:"), function(self, _cmd, aDocument, didRead, aContextInfo)
{ with(self)
{
    if (!didRead)
        return;

    objj_msgSend(self, "addDocument:", aDocument);
    objj_msgSend(aDocument, "makeWindowControllers");
}
});
instance_methods[7] = new objj_method(sel_registerName("newDocument:"), function(self, _cmd, aSender)
{ with(self)
{
    objj_msgSend(self, "openUntitledDocumentOfType:display:", objj_msgSend(objj_msgSend(_documentTypes, "objectAtIndex:", 0), "objectForKey:", "CPBundleTypeName"), YES);
}
});
instance_methods[8] = new objj_method(sel_registerName("documents"), function(self, _cmd)
{ with(self)
{
    return _documents;
}
});
instance_methods[9] = new objj_method(sel_registerName("addDocument:"), function(self, _cmd, aDocument)
{ with(self)
{
    objj_msgSend(_documents, "addObject:", aDocument);
}
});
instance_methods[10] = new objj_method(sel_registerName("removeDocument:"), function(self, _cmd, aDocument)
{ with(self)
{
    objj_msgSend(_documents, "removeObjectIdenticalTo:", aDocument);
}
});
instance_methods[11] = new objj_method(sel_registerName("_infoForType:"), function(self, _cmd, aType)
{ with(self)
{
    var i = 0,
        count = objj_msgSend(_documentTypes, "count");

    for (;i < count; ++i)
    {
        var documentType = _documentTypes[i];

        if (objj_msgSend(documentType, "objectForKey:", "CPBundleTypeName") == aType)
            return documentType;
    }

    return nil;
}
});
instance_methods[12] = new objj_method(sel_registerName("documentClassForType:"), function(self, _cmd, aType)
{ with(self)
{
    var className = objj_msgSend(objj_msgSend(self, "_infoForType:", aType), "objectForKey:", "CPDocumentClass");

    return className ? CPClassFromString(className) : Nil;
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

p;9;CPEvent.jI;21;Foundation/CPObject.jc;10335;




CPLeftMouseDown = 1;
CPLeftMouseUp = 2;
CPRightMouseDown = 3;
CPRightMouseUp = 4;
CPMouseMoved = 5;
CPLeftMouseDragged = 6;
CPRightMouseDragged = 7;
CPMouseEntered = 8;
CPMouseExited = 9;
CPKeyDown = 10;
CPKeyUp = 11;
CPFlagsChanged = 12;
CPAppKitDefined = 13;
CPSystemDefined = 14;
CPApplicationDefined = 15;
CPPeriodic = 16;
CPCursorUpdate = 17;
CPScrollWheel = 22;
CPOtherMouseDown = 25;
CPOtherMouseUp = 26;
CPOtherMouseDragged = 27;

CPAlphaShiftKeyMask = 1 << 16;
CPShiftKeyMask = 1 << 17;
CPControlKeyMask = 1 << 18;
CPAlternateKeyMask = 1 << 19;
CPCommandKeyMask = 1 << 20;
CPNumericPadKeyMask = 1 << 21;
CPHelpKeyMask = 1 << 22;
CPFunctionKeyMask = 1 << 23;
CPDeviceIndependentModifierFlagsMask = 0xffff0000;

CPLeftMouseDownMask = 1 << CPLeftMouseDown;
CPLeftMouseUpMask = 1 << CPLeftMouseUp;
CPRightMouseDownMask = 1 << CPRightMouseDown;
CPRightMouseUpMask = 1 << CPRightMouseUp;
CPOtherMouseDownMask = 1 << CPOtherMouseDown;
CPOtherMouseUpMask = 1 << CPOtherMouseUp;
CPMouseMovedMask = 1 << CPMouseMoved;
CPLeftMouseDraggedMask = 1 << CPLeftMouseDragged;
CPRightMouseDraggedMask = 1 << CPRightMouseDragged;
CPOtherMouseDragged = 1 << CPOtherMouseDragged;
CPMouseEnteredMask = 1 << CPMouseEntered;
CPMouseExitedMask = 1 << CPMouseExited;
CPCursorUpdateMask = 1 << CPCursorUpdate;
CPKeyDownMask = 1 << CPKeyDown;
CPKeyUpMask = 1 << CPKeyUp;
CPFlagsChangedMask = 1 << CPFlagsChanged;
CPAppKitDefinedMask = 1 << CPAppKitDefined;
CPSystemDefinedMask = 1 << CPSystemDefined;
CPApplicationDefinedMask = 1 << CPApplicationDefined;
CPPeriodicMask = 1 << CPPeriodic;
CPScrollWheelMask = 1 << CPScrollWheel;
CPAnyEventMask = 0xffffffff;

CPDOMEventDoubleClick = "dblclick",
CPDOMEventMouseDown = "mousedown",
CPDOMEventMouseUp = "mouseup",
CPDOMEventMouseMoved = "mousemove",
CPDOMEventMouseDragged = "mousedrag",
CPDOMEventKeyUp = "keyup",
CPDOMEventKeyDown = "keydown",
CPDOMEventKeyPress = "keypress";
CPDOMEventCopy = "copy";
CPDOMEventPaste = "paste";
CPDOMEventScrollWheel = "mousewheel";

var _CPEventPeriodicEventPeriod = 0,
    _CPEventPeriodicEventTimer = nil;

{var the_class = objj_allocateClassPair(CPObject, "CPEvent"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_type"), new objj_ivar("_location"), new objj_ivar("_modifierFlags"), new objj_ivar("_timestamp"), new objj_ivar("_context"), new objj_ivar("_eventNumber"), new objj_ivar("_clickCount"), new objj_ivar("_pressure"), new objj_ivar("_window"), new objj_ivar("_characters"), new objj_ivar("_charactersIgnoringModifiers"), new objj_ivar("_isARepeat"), new objj_ivar("_keyCode"), new objj_ivar("_DOMEvent"), new objj_ivar("_deltaX"), new objj_ivar("_deltaY"), new objj_ivar("_deltaZ"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("keyEventWithType:location:modifierFlags:timestamp:windowNumber:context:characters:charactersIgnoringModifiers:isARepeat:keyCode:"), function(self, _cmd, anEventType, aPoint, modifierFlags, aTimestamp, aWindowNumber, aGraphicsContext, characters, unmodCharacters, repeatKey, code)
{ with(self)
{
    return objj_msgSend(objj_msgSend(self, "alloc"), "_initKeyEventWithType:location:modifierFlags:timestamp:windowNumber:context:characters:charactersIgnoringModifiers:isARepeat:keyCode:", anEventType, aPoint, modifierFlags, aTimestamp, aWindowNumber, aGraphicsContext, characters, unmodCharacters, repeatKey, code);
}
});
class_methods[1] = new objj_method(sel_registerName("mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:"), function(self, _cmd, anEventType, aPoint, modifierFlags, aTimestamp, aWindowNumber, aGraphicsContext, anEventNumber, aClickCount, aPressure)
{ with(self)
{
    return objj_msgSend(objj_msgSend(self, "alloc"), "_initMouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:", anEventType, aPoint, modifierFlags, aTimestamp, aWindowNumber, aGraphicsContext, anEventNumber, aClickCount, aPressure);
}
});
class_methods[2] = new objj_method(sel_registerName("otherEventWithType:location:modifierFlags:timestamp:windowNumber:context:subtype:data1:data2:"), function(self, _cmd, anEventType, aLocation, modifierFlags, aTimestamp, aWindowNumber, aGraphicsContext, aSubtype, aData1, aData2)
{ with(self)
{
    return objj_msgSend(objj_msgSend(self, "alloc"), "_initOtherEventWithType:location:modifierFlags:timestamp:windowNumber:context:subtype:data1:data2:", anEventType, aLocation, modifierFlags, aTimestamp, aWindowNumber, aGraphicsContext, aSubtype, aData1, aData2);
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("_initMouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:"), function(self, _cmd, anEventType, aPoint, modifierFlags, aTimestamp, aWindowNumber, aGraphicsContext, anEventNumber, aClickCount, aPressure)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
    {
        _type = anEventType;
        _location = CPPointCreateCopy(aPoint);
        _modifierFlags = modifierFlags;
        _timestamp = aTimestamp;
        _context = aGraphicsContext;
        _eventNumber = anEventNumber;
        _clickCount = aClickCount;
        _pressure = aPressure;
        _window = objj_msgSend(CPApp, "windowWithWindowNumber:", aWindowNumber);
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("_initKeyEventWithType:location:modifierFlags:timestamp:windowNumber:context:characters:charactersIgnoringModifiers:isARepeat:keyCode:"), function(self, _cmd, anEventType, aPoint, modifierFlags, aTimestamp, aWindowNumber, aGraphicsContext, characters, unmodCharacters, isARepeat, code)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
    {
        _type = anEventType;
        _location = CPPointCreateCopy(aPoint);
        _modifierFlags = modifierFlags;
        _timestamp = aTimestamp;
        _context = aGraphicsContext;
        _characters = characters;
        _charactersIgnoringModifiers = unmodCharacters;
        _isARepeat = isARepeat;
        _keyCode = code;
        _window = objj_msgSend(CPApp, "windowWithWindowNumber:", aWindowNumber);
    }

    return self;
}
});
instance_methods[2] = new objj_method(sel_registerName("_initOtherEventWithType:location:modifierFlags:timestamp:windowNumber:context:subtype:data1:data2:"), function(self, _cmd, anEventType, aPoint, modifierFlags, aTimestamp, aWindowNumber, aGraphicsContext, aSubtype, aData1, aData2)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
    {
        _type = anEventType;
        _location = CPPointCreateCopy(aPoint);
        _modifierFlags = modifierFlags;
        _timestamp = aTimestamp;
        _context = aGraphicsContext;
        _subtype = aSubtype;
        _data1 = aData1;
        _data2 = aData2;
    }

    return self;
}
});
instance_methods[3] = new objj_method(sel_registerName("locationInWindow"), function(self, _cmd)
{ with(self)
{
    return _location;
}
});
instance_methods[4] = new objj_method(sel_registerName("modifierFlags"), function(self, _cmd)
{ with(self)
{
    return _modifierFlags;
}
});
instance_methods[5] = new objj_method(sel_registerName("timestamp"), function(self, _cmd)
{ with(self)
{
    return _timestamp;
}
});
instance_methods[6] = new objj_method(sel_registerName("type"), function(self, _cmd)
{ with(self)
{
    return _type;
}
});
instance_methods[7] = new objj_method(sel_registerName("window"), function(self, _cmd)
{ with(self)
{
    return _window;
}
});
instance_methods[8] = new objj_method(sel_registerName("windowNumber"), function(self, _cmd)
{ with(self)
{
    return _windowNumber;
}
});
instance_methods[9] = new objj_method(sel_registerName("buttonNumber"), function(self, _cmd)
{ with(self)
{
    return _buttonNumber;
}
});
instance_methods[10] = new objj_method(sel_registerName("clickCount"), function(self, _cmd)
{ with(self)
{
    return _clickCount;
}
});
instance_methods[11] = new objj_method(sel_registerName("characters"), function(self, _cmd)
{ with(self)
{
    return _characters;
}
});
instance_methods[12] = new objj_method(sel_registerName("charactersIgnoringModifiers"), function(self, _cmd)
{ with(self)
{
    return _charactersIgnoringModifiers;
}
});
instance_methods[13] = new objj_method(sel_registerName("isARepeat"), function(self, _cmd)
{ with(self)
{
    return _isARepeat;
}
});
instance_methods[14] = new objj_method(sel_registerName("keyCode"), function(self, _cmd)
{ with(self)
{
    return _keyCode;
}
});
instance_methods[15] = new objj_method(sel_registerName("_DOMEvent"), function(self, _cmd)
{ with(self)
{
    return _DOMEvent;
}
});
instance_methods[16] = new objj_method(sel_registerName("deltaX"), function(self, _cmd)
{ with(self)
{
    return _deltaX;
}
});
instance_methods[17] = new objj_method(sel_registerName("deltaY"), function(self, _cmd)
{ with(self)
{
    return _deltaY;
}
});
instance_methods[18] = new objj_method(sel_registerName("deltaZ"), function(self, _cmd)
{ with(self)
{
    return _deltaZ;
}
});
class_methods[3] = new objj_method(sel_registerName("startPeriodicEventsAfterDelay:withPeriod:"), function(self, _cmd, aDelay, aPeriod)
{ with(self)
{
    _CPEventPeriodicEventPeriod = aPeriod;


    _CPEventPeriodicEventTimer = window.setTimeout(function() { _CPEventPeriodicEventTimer = window.setInterval(_CPEventFirePeriodEvent, aPeriod * 1000.0); }, aDelay * 1000.0);
}
});
class_methods[4] = new objj_method(sel_registerName("stopPeriodicEvents"), function(self, _cmd)
{ with(self)
{
    window.clearTimeout(_CPEventPeriodicEventTimer);

    _CPEventPeriodicEventTimer = nil;
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

_CPEventFirePeriodEvent= function()
{
    objj_msgSend(CPApp, "sendEvent:", objj_msgSend(CPEvent, "otherEventWithType:location:modifierFlags:timestamp:windowNumber:context:subtype:data1:data2:", CPPeriodic, {x:0.0,y:0.0}, 0, 0, 0, nil, 0, 0, 0));
}

p;14;CPFlashMovie.jI;21;Foundation/CPObject.jc;951;


{var the_class = objj_allocateClassPair(CPObject, "CPFlashMovie"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_fileName"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("flashMovieWithFile:"), function(self, _cmd, aFileName)
{ with(self)
{
    return objj_msgSend(objj_msgSend(self, "alloc"), "initWithFile:", aFileName);
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFile:"), function(self, _cmd, aFileName)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
        _fileName = aFileName;

    return self;
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

p;13;CPFlashView.ji;19;CPDOMWindowBridge.ji;14;CPFlashMovie.ji;8;CPView.jc;2882;


{var the_class = objj_allocateClassPair(CPView, "CPFlashView"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_flashMovie"), new objj_ivar("_DOMEmbedElement"), new objj_ivar("_DOMMParamElement"), new objj_ivar("_DOMObjectElement"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "initWithFrame:", aFrame);

    if (self)
    {
        _DOMObjectElement = document.createElement("object");
        _DOMObjectElement.width = "100%";
        _DOMObjectElement.height = "100%";
        _DOMObjectElement.style.top = "0px";
        _DOMObjectElement.style.left = "0px";

        _DOMParamElement = document.createElement("param");
        _DOMParamElement.name = "movie";

        _DOMObjectElement.appendChild(_DOMParamElement);

        var param = document.createElement("param");

        param.name = "wmode";
        param.value = "transparent";

        _DOMObjectElement.appendChild(param);

        _DOMEmbedElement = document.createElement("embed");

        _DOMEmbedElement.type = "application/x-shockwave-flash";
        _DOMEmbedElement.wmode = "transparent";
        _DOMEmbedElement.width = "100%";
        _DOMEmbedElement.height = "100%";


        _DOMElement.appendChild(_DOMEmbedElement);

        _DOMElement.appendChild(_DOMObjectElement);
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setFlashMovie:"), function(self, _cmd, aFlashMovie)
{ with(self)
{
    if (_flashMovie == aFlashMovie)
        return;

    _flashMovie = aFlashMovie;

    _DOMParamElement.value = aFlashMovie._fileName;

    if (_DOMEmbedElement)
       _DOMEmbedElement.src = aFlashMovie._fileName;
}
});
instance_methods[2] = new objj_method(sel_registerName("flashMovie"), function(self, _cmd)
{ with(self)
{
    return _flashMovie;
}
});
instance_methods[3] = new objj_method(sel_registerName("mouseDragged:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(objj_msgSend(CPDOMWindowBridge, "sharedDOMWindowBridge"), "_propagateCurrentDOMEvent:", YES);
}
});
instance_methods[4] = new objj_method(sel_registerName("mouseDown:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(objj_msgSend(CPDOMWindowBridge, "sharedDOMWindowBridge"), "_propagateCurrentDOMEvent:", YES);
}
});
instance_methods[5] = new objj_method(sel_registerName("mouseUp:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(objj_msgSend(CPDOMWindowBridge, "sharedDOMWindowBridge"), "_propagateCurrentDOMEvent:", YES);
}
});
class_addMethods(the_class, instance_methods);
}

p;8;CPFont.jc;3805;


var _CPFonts = {};
    _CPFontSystemFontFace = "Arial";



{var the_class = objj_allocateClassPair(CPObject, "CPFont"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_name"), new objj_ivar("_size"), new objj_ivar("_isBold"), new objj_ivar("_cssString"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("fontWithName:size:"), function(self, _cmd, aName, aSize)
{ with(self)
{
    return _CPFonts[(NO?"bold ":"")+ROUND(aSize)+"px '"+aName+"'"] || objj_msgSend(objj_msgSend(CPFont, "alloc"), "_initWithName:size:bold:", aName, aSize, NO);
}
});
class_methods[1] = new objj_method(sel_registerName("boldFontWithName:size:"), function(self, _cmd, aName, aSize)
{ with(self)
{
    return _CPFonts[(YES?"bold ":"")+ROUND(aSize)+"px '"+aName+"'"] || objj_msgSend(objj_msgSend(CPFont, "alloc"), "_initWithName:size:bold:", aName, aSize, YES);
}
});
class_methods[2] = new objj_method(sel_registerName("systemFontOfSize:"), function(self, _cmd, aSize)
{ with(self)
{
    return _CPFonts[(NO?"bold ":"")+ROUND(aSize)+"px '"+_CPFontSystemFontFace+"'"] || objj_msgSend(objj_msgSend(CPFont, "alloc"), "_initWithName:size:bold:", _CPFontSystemFontFace, aSize, NO);
}
});
class_methods[3] = new objj_method(sel_registerName("boldSystemFontOfSize:"), function(self, _cmd, aSize)
{ with(self)
{
    return _CPFonts[(YES?"bold ":"")+ROUND(aSize)+"px '"+_CPFontSystemFontFace+"'"] || objj_msgSend(objj_msgSend(CPFont, "alloc"), "_initWithName:size:bold:", _CPFontSystemFontFace, aSize, YES);
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("_initWithName:size:bold:"), function(self, _cmd, aName, aSize, isBold)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
    {
        _name = aName;
        _size = aSize;
        _isBold = isBold;

        _cssString = (_isBold ? "bold " : "") + ROUND(aSize) + "px '" + aName + "'";

        _CPFonts[_cssString] = self;
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("size"), function(self, _cmd)
{ with(self)
{
    return _size;
}
});
instance_methods[2] = new objj_method(sel_registerName("cssString"), function(self, _cmd)
{ with(self)
{
    return _cssString;
}
});
instance_methods[3] = new objj_method(sel_registerName("familyName"), function(self, _cmd)
{ with(self)
{
    return _name;
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

var CPFontNameKey = "CPFontNameKey",
    CPFontSizeKey = "CPFontSizeKey",
    CPFontIsBoldKey = "CPFontIsBoldKey";

{
var the_class = objj_getClass("CPFont")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPFont\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    return objj_msgSend(self, "_initWithName:size:bold:", objj_msgSend(aCoder, "decodeObjectForKey:", CPFontNameKey), objj_msgSend(aCoder, "decodeFloatForKey:", CPFontSizeKey), objj_msgSend(aCoder, "decodeBoolForKey:", CPFontIsBoldKey));
}
});
instance_methods[1] = new objj_method(sel_registerName("encodeWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    objj_msgSend(aCoder, "encodeObject:forKey:", _name, CPFontNameKey);
    objj_msgSend(aCoder, "encodeFloat:forKey:", _size, CPFontSizeKey);
    objj_msgSend(aCoder, "encodeBool:forKey:", _isBold, CPFontIsBoldKey);
}
});
class_addMethods(the_class, instance_methods);
}

p;15;CPFontManager.jI;21;Foundation/CPObject.jI;15;AppKit/CPFont.jc;4755;


var CPSharedFontManager = nil,
    CPFontManagerFactory = Nil;

{var the_class = objj_allocateClassPair(CPObject, "CPFontManager"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_availableFonts"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("sharedFontManager"), function(self, _cmd)
{ with(self)
{
    if (!CPSharedFontManager)
        CPSharedFontManager = objj_msgSend(objj_msgSend(CPFontManagerFactory, "alloc"), "init");

    return CPSharedFontManager;
}
});
class_methods[1] = new objj_method(sel_registerName("setFontManagerFactory:"), function(self, _cmd, aClass)
{ with(self)
{
    CPFontManagerFactory = aClass;
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("availableFonts"), function(self, _cmd)
{ with(self)
{
    if (!_availableFonts)
    {
        _CPFontDetectSpan = document.createElement("span");
        _CPFontDetectSpan.fontSize = "24px";
        _CPFontDetectSpan.appendChild(document.createTextNode("mmmmmmmmmml"));
        var div = document.createElement("div");
        div.style.position = "absolute";
        div.style.top = "-1000px";
        div.appendChild(_CPFontDetectSpan);
        document.getElementsByTagName("body")[0].appendChild(div);

    _CPFontDetectReferenceFonts = _CPFontDetectPickTwoDifferentFonts(["monospace","serif","sans-serif","cursive"]);

        _availableFonts = [];
        for (var i = 0; i < _CPFontDetectAllFonts.length; i++) {
            var available = _CPFontDetectFontAvailable(_CPFontDetectAllFonts[i]);
      if (available)
                _availableFonts.push(_CPFontDetectAllFonts[i]);
        }
    }
    return _availableFonts;
}
});
instance_methods[1] = new objj_method(sel_registerName("fontWithNameIsAvailable:"), function(self, _cmd, aFontName)
{ with(self)
{
    return _CPFontDetectFontAvailable(aFontName);
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

var _CPFontDetectSpan,
    _CPFontDetectReferenceFonts,
    _CPFontDetectAllFonts = ["American Typewriter","Apple Chancery","Arial","Arial Black","Arial Narrow","Arial Rounded MT Bold","Arial Unicode MS","Big Caslon","Bitstream Vera Sans","Bitstream Vera Sans Mono","Bitstream Vera Serif","Brush Script MT","Cambria","Caslon","Castellar","Cataneo BT","Centaur","Century Gothic","Century Schoolbook","Century Schoolbook L","Comic Sans","Comic Sans MS","Consolas","Constantia","Cooper Black","Copperplate","Copperplate Gothic Bold","Copperplate Gothic Light","Corbel","Courier","Courier New","Futura","Geneva","Georgia","Georgia Ref","Gigi","Gill Sans","Gill Sans MT","Gill Sans MT Condensed","Gill Sans MT Ext Condensed Bold","Gill Sans Ultra Bold","Gill Sans Ultra Bold Condensed","Helvetica","Helvetica Narrow","Helvetica Neue","Herculanum","High Tower Text","Highlight LET","Hoefler Text","Impact","Imprint MT Shadow","Lucida","Lucida Bright","Lucida Calligraphy","Lucida Console","Lucida Fax","Lucida Grande","Lucida Handwriting","Lucida Sans","Lucida Sans Typewriter","Lucida Sans Unicode","Marker Felt","Microsoft Sans Serif","Milano LET","Minion Web","MisterEarl BT","Mistral","Monaco","Monotype Corsiva","Monotype.com","New Century Schoolbook","New York","News Gothic MT","Papyrus","Tahoma","Techno","Tempus Sans ITC","Terminal","Textile","Times","Times New Roman","Tiranti Solid LET","Trebuchet MS","Verdana","Verdana Ref","Zapfino"];


var _CPFontDetectFontAvailable = function(font) {
 for (var i = 0; i < _CPFontDetectReferenceFonts.length; i++)
  if (_CPFontDetectCompareFonts(_CPFontDetectReferenceFonts[i], font))
   return true;
 return false;
}

var _CPFontDetectCache = {};


var _CPFontDetectCompareFonts = function(fontA, fontB) {
    var a;
    if (_CPFontDetectCache[fontA]) {
        a = _CPFontDetectCache[fontA];
    } else {
     _CPFontDetectSpan.style.fontFamily = '"' + fontA + '"';
        _CPFontDetectCache[fontA] = a = { w: _CPFontDetectSpan.offsetWidth, h: _CPFontDetectSpan.offsetHeight };
    }

 _CPFontDetectSpan.style.fontFamily= '"' + fontB + '", "' + fontA + '"';
 var bWidth = _CPFontDetectSpan.offsetWidth;
 var bHeight = _CPFontDetectSpan.offsetHeight;

 return (a.w != bWidth || a.h != bHeight);
}


var _CPFontDetectPickTwoDifferentFonts = function(candidates) {
 for (var i = 0; i < candidates.length; i++)
  for (var j = 0; j < i; j++)
   if (_CPFontDetectCompareFonts(candidates[i], candidates[j]))
    return [candidates[i],candidates[j]];
 return [candidates[0]];
}

objj_msgSend(CPFontManager, "setFontManagerFactory:", objj_msgSend(CPFontManager, "class"));

p;12;CPGeometry.jc;5328;


CPPointCreateCopy= function(aPoint)
{
    return { x: aPoint.x, y: aPoint.y };
}

CPPointMake= function(x, y)
{
    return { x: x, y: y };
}

CPRectInset= function(aRect, dX, dY)
{
    return CPRectMake( aRect.origin.x + dX, aRect.origin.y + dY,
                        aRect.size.width - 2 * dX, aRect.size.height - 2*dY);
}

CPRectIntegral= function(aRect)
{

    alert("CPRectIntegral unimplemented");
}

CPRectIntersection= function(lhsRect, rhsRect)
{
    var intersection = CPRectMake(
        Math.max(CPRectGetMinX(lhsRect), CPRectGetMinX(rhsRect)),
        Math.max(CPRectGetMinY(lhsRect), CPRectGetMinY(rhsRect)),
        0, 0);

    intersection.size.width = Math.min(CPRectGetMaxX(lhsRect), CPRectGetMaxX(rhsRect)) - CPRectGetMinX(intersection);
    intersection.size.height = Math.min(CPRectGetMaxY(lhsRect), CPRectGetMaxY(rhsRect)) - CPRectGetMinY(intersection);

    return CPRectIsEmpty(intersection) ? CPRectMakeZero() : intersection;
}

CPRectCreateCopy= function(aRect)
{
    return { origin: CPPointCreateCopy(aRect.origin), size: CPSizeCreateCopy(aRect.size) };
}

CPRectMake= function(x, y, width, height)
{
    return { origin: CPPointMake(x, y), size: CPSizeMake(width, height) };
}

CPRectOffset= function(aRect, dX, dY)
{
    return CPRectMake(aRect.origin.x + dX, aRect.origin.y + dY, aRect.size.width, aRect.size.height);
}

CPRectStandardize= function(aRect)
{
    var width = CPRectGetWidth(aRect),
        height = CPRectGetHeight(aRect),
        standardized = CPRectCreateCopy(aRect);

    if (width < 0.0)
    {
        standardized.origin.x += width;
        standardized.size.width = -width;
    }

    if (height < 0.0)
    {
        standardized.origin.y += height;
        standardized.size.height = -height;
    }

    return standardized;
}

CPRectUnion= function(lhsRect, rhsRect)
{
    var minX = Math.min(CPRectGetMinX(lhsRect), CPRectGetMinX(rhsRect)),
        minY = Math.min(CPRectGetMinY(lhsRect), CPRectGetMinY(rhsRect)),
        maxX = Math.max(CPRectGetMaxX(lhsRect), CPRectGetMaxX(rhsRect)),
        maxY = Math.max(CPRectGetMaxY(lhsRect), CPRectGetMaxY(rhsRect));

    return CPRectMake(minX, minY, maxX - minX, maxY - minY);
}

CPSizeCreateCopy= function(aSize)
{
    return { width: aSize.width, height: aSize.height };
}

CPSizeMake= function(width, height)
{
    return { width: width, height: height };
}

CPRectContainsPoint= function(aRect, aPoint)
{
    return aPoint.x >= CPRectGetMinX(aRect) &&
            aPoint.y >= CPRectGetMinY(aRect) &&
      aPoint.x < CPRectGetMaxX(aRect) &&
      aPoint.y < CPRectGetMaxY(aRect);
}

CPRectContainsRect= function(lhsRect, rhsRect)
{
    return CPRectEqualToRect(CPUnionRect(lhsRect, rhsRect), rhsRect);
}

CPPointEqualToPoint= function(lhsPoint, rhsPoint)
{
    return lhsPoint.x == rhsPoint.x && lhsPoint.y == rhsPoint.y;
}

CPRectEqualToRect= function(lhsRect, rhsRect)
{
    return CPPointEqualToPoint(lhsRect.origin, rhsRect.origin) &&
            CPSizeEqualToSize(lhsRect.size, rhsRect.size);
}

CPRectGetHeight= function(aRect)
{
    return aRect.size.height;
}

CPRectGetMaxX= function(aRect)
{
    return aRect.origin.x + aRect.size.width;
}

CPRectGetMaxY= function(aRect)
{
    return aRect.origin.y + aRect.size.height;
}

CPRectGetMidX= function(aRect)
{
    return aRect.origin.x + (aRect.size.width) / 2.0;
}

CPRectGetMidY= function(aRect)
{
    return aRect.origin.y + (aRect.size.height) / 2.0;
}

CPRectGetMinX= function(aRect)
{
    return aRect.origin.x;
}

CPRectGetMinY= function(aRect)
{
    return aRect.origin.y;
}

CPRectGetWidth= function(aRect)
{
    return aRect.size.width;
}

CPRectIntersectsRect= function(lhsRect, rhsRect)
{
    return !CPRectIsEmpty(CPRectIntersection(lhsRect, rhsRect));
}

CPRectIsEmpty= function(aRect)
{
    return aRect.size.width <= 0.0 || aRect.size.height <= 0.0;
}

CPRectIsNull= function(aRect)
{
    return aRect.size.width <= 0.0 || aRect.size.height <= 0.0;
}

CPSizeEqualToSize= function(lhsSize, rhsSize)
{
    return lhsSize.width == rhsSize.width && lhsSize.height == rhsSize.height;
}

CPStringFromPoint= function(aPoint)
{
    return "{" + aPoint.x + ", " + aPoint.y + "}";
}

CPStringFromSize= function(aSize)
{
    return "{" + aSize.width + ", " + aSize.height + "}";
}

CPStringFromRect= function(aRect)
{
    return "{" + CPStringFromPoint(aRect.origin) + ", " + CPStringFromSize(aRect.size) + "}";
}

CPPointFromString= function(aString)
{
    var comma = aString.indexOf(',');

    return { x:parseInt(aString.substr(1, comma - 1)), y:parseInt(aString.substring(comma + 1, aString.length)) };
}

CPSizeFromString= function(aString)
{
    var comma = aString.indexOf(',');

    return { width:parseInt(aString.substr(1, comma - 1)), height:parseInt(aString.substring(comma + 1, aString.length)) };
}

CPRectFromString= function(aString)
{
    var comma = aString.indexOf(',', aString.indexOf(',') + 1);

    return { origin:CPPointFromString(aString.substr(1, comma - 1)), size:CPSizeFromString(aString.substring(comma + 2, aString.length)) };
}

CPPointFromEvent= function(anEvent)
{
    return CPPointMake(anEvent.clientX, anEvent.clientY, 0);
}

CPSizeMakeZero= function()
{
    return CPSizeMake(0, 0);
}

CPRectMakeZero= function()
{
    return CPRectMake(0, 0, 0, 0);
}

CPPointMakeZero= function()
{
    return CPPointMake(0, 0, 0);
}

p;19;CPGraphicsContext.jc;1525;


var CPGraphicsContextCurrent = nil;

{var the_class = objj_allocateClassPair(CPObject, "CPGraphicsContext"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_graphicsPort"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("currentContext"), function(self, _cmd)
{ with(self)
{
    return CPGraphicsContextCurrent;
}
});
class_methods[1] = new objj_method(sel_registerName("setCurrentContext:"), function(self, _cmd, aGraphicsContext)
{ with(self)
{
    CPGraphicsContextCurrent = aGraphicsContext;
}
});
class_methods[2] = new objj_method(sel_registerName("graphicsContextWithGraphicsPort:flipped:"), function(self, _cmd, aContext, aFlag)
{ with(self)
{
    return objj_msgSend(objj_msgSend(self, "alloc"), "initWithGraphicsPort:", aContext);
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithGraphicsPort:"), function(self, _cmd, aGraphicsPort)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
        _graphicsPort = aGraphicsPort;

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("graphicsPort"), function(self, _cmd)
{ with(self)
{
    return _graphicsPort;
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

p;9;CPImage.jI;21;Foundation/CPObject.jI;21;Foundation/CPString.jI;21;Foundation/CPBundle.jI;22;Foundation/CPRunLoop.ji;12;CPGeometry.jc;5759;

CPImageLoadStatusInitialized = 0;
CPImageLoadStatusCompleted = 1;
CPImageLoadStatusCancelled = 2;
CPImageLoadStatusInvalidData = 3;
CPImageLoadStatusUnexpectedEOF = 4;
CPImageLoadStatusReadError = 5;

{
var the_class = objj_getClass("CPBundle")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPBundle\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("pathForResource:"), function(self, _cmd, aFilename)
{ with(self)
{
    return objj_msgSend(self, "bundlePath") + "Resources/" + aFilename;
}
});
class_addMethods(the_class, instance_methods);
}

{var the_class = objj_allocateClassPair(CPObject, "CPImage"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_size"), new objj_ivar("_filename"), new objj_ivar("_delegate"), new objj_ivar("_loadStatus"), new objj_ivar("_image"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initByReferencingFile:size:"), function(self, _cmd, aFilename, aSize)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
    {
        _size = CPSizeCreateCopy(aSize);
        _filename = aFilename;
        _loadStatus = CPImageLoadStatusInitialized;
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("initWithContentsOfFile:size:"), function(self, _cmd, aFilename, aSize)
{ with(self)
{
    self = objj_msgSend(self, "initByReferencingFile:size:", aFilename, aSize);

    if (self)
        objj_msgSend(self, "load");

    return self;
}
});
instance_methods[2] = new objj_method(sel_registerName("initWithContentsOfFile:"), function(self, _cmd, aFilename)
{ with(self)
{
    self = objj_msgSend(self, "initByReferencingFile:size:", aFilename, CPSizeMakeZero());

    if (self)
        objj_msgSend(self, "load");

    return self;
}
});
instance_methods[3] = new objj_method(sel_registerName("filename"), function(self, _cmd)
{ with(self)
{
    return _filename;
}
});
instance_methods[4] = new objj_method(sel_registerName("setSize:"), function(self, _cmd, aSize)
{ with(self)
{
    _size = CGSizeMakeCopy(aSize);
}
});
instance_methods[5] = new objj_method(sel_registerName("size"), function(self, _cmd)
{ with(self)
{
    return _size;
}
});
instance_methods[6] = new objj_method(sel_registerName("setDelegate:"), function(self, _cmd, aDelegate)
{ with(self)
{
    _delegate = aDelegate;
}
});
instance_methods[7] = new objj_method(sel_registerName("delegate"), function(self, _cmd)
{ with(self)
{
    return _delegate;
}
});
instance_methods[8] = new objj_method(sel_registerName("loadStatus"), function(self, _cmd)
{ with(self)
{
    return _loadStatus;
}
});
instance_methods[9] = new objj_method(sel_registerName("load"), function(self, _cmd)
{ with(self)
{
    if (_loadStatus == CPImageLoadStatusCompleted)
        return;

    _image = new Image();


    _image.onload = function () { objj_msgSend(self, "_imageDidLoad"); }
    _image.onerror = function () { objj_msgSend(self, "_imageDidError"); }
    _image.onabort = function () { objj_msgSend(self, "_imageDidAbort"); }

    _image.src = _filename;


    if (_image.width && navigator && navigator.userAgent && navigator.userAgent.indexOf("MSIE") >= 0)
        _loadStatus = CPImageLoadStatusCompleted;
}
});
instance_methods[10] = new objj_method(sel_registerName("_imageDidLoad"), function(self, _cmd)
{ with(self)
{

    if (!_size)
        _size = CGSizeMake(_image.width, _image.height);

    _loadStatus = CPImageLoadStatusCompleted;

    if (objj_msgSend(_delegate, "respondsToSelector:", sel_registerName("imageDidLoad:")))
        objj_msgSend(_delegate, "imageDidLoad:", self);

    objj_msgSend(objj_msgSend(CPRunLoop, "currentRunLoop"), "performSelectors");
}
});
instance_methods[11] = new objj_method(sel_registerName("_imageDidError"), function(self, _cmd)
{ with(self)
{
    _loadStatus = CPImageLoadStatusReadError;

    if (objj_msgSend(_delegate, "respondsToSelector:", sel_registerName("imageDidError:")))
        objj_msgSend(_delegate, "imageDidError:", self);

    objj_msgSend(objj_msgSend(CPRunLoop, "currentRunLoop"), "performSelectors");
}
});
instance_methods[12] = new objj_method(sel_registerName("_imageDidAbort"), function(self, _cmd)
{ with(self)
{
    _loadStatus = CPImageLoadStatusCancelled;

    if (objj_msgSend(_delegate, "respondsToSelector:", sel_registerName("imageDidAbort:")))
        objj_msgSend(_delegate, "imageDidAbort:", self);

    objj_msgSend(objj_msgSend(CPRunLoop, "currentRunLoop"), "performSelectors");
}
});
class_addMethods(the_class, instance_methods);
}

{
var the_class = objj_getClass("CPImage")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPImage\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    return objj_msgSend(self, "initWithContentsOfFile:size:", objj_msgSend(aCoder, "decodeObjectForKey:", "CPFilename"), objj_msgSend(aCoder, "decodeSizeForKey:", "CPSize"));
}
});
instance_methods[1] = new objj_method(sel_registerName("encodeWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    objj_msgSend(aCoder, "encodeObject:forKey:", _filename, "CPFilename");
    objj_msgSend(aCoder, "encodeSize:forKey:", _size, "CPSize");
}
});
class_addMethods(the_class, instance_methods);
}

p;13;CPImageView.ji;9;CPImage.ji;11;CPControl.jc;28543;




CPScaleProportionally = 0;
CPScaleToFit = 1;
CPScaleNone = 2;


var CPImageViewTopShadowImage,
    CPImageViewTopLeftShadowImage,
    CPImageViewTopRightShadowImage,
    CPImageViewLeftShadowImage,
    CPImageViewRightShadowImage,
    CPImageViewBottomImage,
    CPImageViewBottomLeftImage,
    CPImageViewBottomRightImage;

var LEFT_SHADOW_INSET = 3.0,
    RIGHT_SHADOW_INSET = 3.0,
    TOP_SHADOW_INSET = 3.0,
    BOTTOM_SHADOW_INSET = 5.0,
    VERTICAL_SHADOW_INSET = TOP_SHADOW_INSET + BOTTOM_SHADOW_INSET,
    HORIZONTAL_SHADOW_INSET = LEFT_SHADOW_INSET + RIGHT_SHADOW_INSET;

{var the_class = objj_allocateClassPair(CPControl, "CPImageView"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_image"), new objj_ivar("_DOMImageElement"), new objj_ivar("_imageScaling"), new objj_ivar("_hasShadow"), new objj_ivar("_shadowView"), new objj_ivar("_imageRect"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "initWithFrame:", aFrame);

    if (self)
    {
        _DOMImageElement = document.createElement("img");
        _DOMImageElement.style.position = "absolute";
        _DOMImageElement.style.left = "0px";
        _DOMImageElement.style.top = "0px";

        _DOMElement.appendChild(_DOMImageElement);

        _DOMImageElement.style.visibility = "hidden";
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("image"), function(self, _cmd)
{ with(self)
{
    return _image;
}
});
instance_methods[2] = new objj_method(sel_registerName("setImage:"), function(self, _cmd, anImage)
{ with(self)
{
    if (_image == anImage)
        return;

    _image = anImage;

    _DOMImageElement.src = objj_msgSend(anImage, "filename");

    if (_imageScaling == CPScaleNone && _image)
    {
        var size = objj_msgSend(_image, "size");

        _DOMImageElement.width = ROUND(size.width);
        _DOMImageElement.height = ROUND(size.height);
    }

    objj_msgSend(self, "hideOrDisplayContents");

    objj_msgSend(self, "tile");
}
});
instance_methods[3] = new objj_method(sel_registerName("setHasShadow:"), function(self, _cmd, shouldHaveShadow)
{ with(self)
{
    if (_hasShadow == shouldHaveShadow)
        return;

    _hasShadow = shouldHaveShadow;

    if (_hasShadow)
    {
        _shadowView = objj_msgSend(objj_msgSend(CPNinePartImageView, "alloc"), "initWithFrame:", CGRectMakeCopy(objj_msgSend(self, "bounds")));

        if (!CPImageViewTopShadowImage)
        {
            var bundle = objj_msgSend(CPBundle, "bundleForClass:", objj_msgSend(self, "class"));

            CPImageViewTopShadowImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPImageView/CPImageViewTopShadow.png"), CGSizeMake(1.0,4.0));
            CPImageViewTopLeftShadowImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPImageView/CPImageViewTopLeftShadow.png"), CGSizeMake(9.0,9.0));
            CPImageViewTopRightShadowImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPImageView/CPImageViewTopRightShadow.png"), CGSizeMake(9.0,9.0));
            CPImageViewLeftShadowImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPImageView/CPImageViewLeftShadow.png"), CGSizeMake(3.0,1.0));
            CPImageViewRightShadowImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPImageView/CPImageViewRightShadow.png"), CGSizeMake(9.0,1.0));
            CPImageViewBottomImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPImageView/CPImageViewBottomShadow.png"), CGSizeMake(1.0,9.0));
            CPImageViewBottomLeftImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPImageView/CPImageViewBottomLeftShadow.png"), CGSizeMake(9.0,9.0));
            CPImageViewBottomRightImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPImageView/CPImageViewBottomRightShadow.png"), CGSizeMake(9.0,9.0));
        }

        objj_msgSend(_shadowView, "setTopImage:", CPImageViewTopShadowImage);
        objj_msgSend(_shadowView, "setTopLeftImage:", CPImageViewTopLeftShadowImage);
        objj_msgSend(_shadowView, "setTopRightImage:", CPImageViewTopRightShadowImage);
        objj_msgSend(_shadowView, "setLeftImage:", CPImageViewLeftShadowImage);
        objj_msgSend(_shadowView, "setRightImage:", CPImageViewRightShadowImage);
        objj_msgSend(_shadowView, "setBottomImage:", CPImageViewBottomImage);
        objj_msgSend(_shadowView, "setBottomLeftImage:", CPImageViewBottomLeftImage);
        objj_msgSend(_shadowView, "setBottomRightImage:", CPImageViewBottomRightImage);

        objj_msgSend(self, "addSubview:", _shadowView);

        objj_msgSend(self, "tile");
    }
    else
    {
        objj_msgSend(_shadowView, "removeFromSuperview");

        _shadowView = nil;
    }

    objj_msgSend(self, "hideOrDisplayContents");
}
});
instance_methods[4] = new objj_method(sel_registerName("setImageScaling:"), function(self, _cmd, anImageScaling)
{ with(self)
{
    if (_imageScaling == anImageScaling)
        return;

    _imageScaling = anImageScaling;

    var style = _DOMImageElement.style;

    if (_imageScaling == CPScaleToFit)
    {
        style.top = "0px";
        style.left = "0px";
    }
    else if (_imageScaling == CPScaleNone && _image)
    {
        var size = objj_msgSend(_image, "size");

        _DOMImageElement.width = ROUND(size.width);
        _DOMImageElement.height = ROUND(size.height);
    }

    objj_msgSend(self, "tile");
}
});
instance_methods[5] = new objj_method(sel_registerName("imageScaling"), function(self, _cmd)
{ with(self)
{
    return _imageScaling;
}
});
instance_methods[6] = new objj_method(sel_registerName("setFrameSize:"), function(self, _cmd, aSize)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "setFrameSize:", aSize);

    objj_msgSend(self, "tile");
}
});
instance_methods[7] = new objj_method(sel_registerName("hideOrDisplayContents"), function(self, _cmd)
{ with(self)
{
    if (!_image)
    {
        _DOMImageElement.style.visibility = "hidden";
        objj_msgSend(_shadowView, "setHidden:", YES);
    }
    else
    {
        _DOMImageElement.style.visibility = "visible";
        objj_msgSend(_shadowView, "setHidden:", NO);
    }
}
});
instance_methods[8] = new objj_method(sel_registerName("imageRect"), function(self, _cmd)
{ with(self)
{
    return _imageRect;
}
});
instance_methods[9] = new objj_method(sel_registerName("tile"), function(self, _cmd)
{ with(self)
{
    if (!_image)
        return;

    var style = _DOMImageElement.style,
        bounds = objj_msgSend(self, "bounds"),
        x = 0.0,
        y = 0.0,
        insetWidth = (_hasShadow ? HORIZONTAL_SHADOW_INSET : 0.0),
        insetHeight = (_hasShadow ? VERTICAL_SHADOW_INSET : 0.0),
        width = CGRectGetWidth(bounds) - insetWidth,
        height = CGRectGetHeight(bounds) - insetHeight;

    if (_imageScaling == CPScaleToFit)
    {
        _DOMImageElement.width = ROUND(width);
        _DOMImageElement.height = ROUND(height);
    }
    else
    {
        var size = objj_msgSend(_image, "size");

        if (_imageScaling == CPScaleProportionally)
        {


            if (width >= size.width && height >= size.height)
            {
                width = size.width;
                height = size.height;
            }
            else
            {
                var imageRatio = size.width / size.height,
                    viewRatio = width / height;

                if (viewRatio > imageRatio)
                    width = height * imageRatio;
                else
                    height = width / imageRatio;
            }

            _DOMImageElement.width = ROUND(width);
            _DOMImageElement.height = ROUND(height);
        }
        else
        {
            width = size.width;
            height = size.height;
        }

        x = ROUND((CGRectGetWidth(bounds) - width) / 2.0);
        y = ROUND((CGRectGetHeight(bounds) - height) / 2.0);

        style.top = y + "px";
        style.left = x + "px";
    }

    _imageRect = CGRectMake(x, y, width, height);

    if (_hasShadow)
        objj_msgSend(_shadowView, "setFrame:", CGRectMake(x-LEFT_SHADOW_INSET,y-TOP_SHADOW_INSET,width+insetWidth,height+insetHeight));
}
});
class_addMethods(the_class, instance_methods);
}

var CPImageViewImageKey = "CPImageViewImageKey",
    CPImageViewImageScalingKey = "CPImageViewImageScalingKey",
    CPImageViewHasShadowKey = "CPImageViewHasShadowKey";

{
var the_class = objj_getClass("CPImageView")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPImageView\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "initWithCoder:", aCoder);

    if (self)
    {
        _DOMImageElement = document.createElement("img");
        _DOMImageElement.style.position = "absolute";
        _DOMImageElement.style.left = "0px";
        _DOMImageElement.style.top = "0px";

        _DOMElement.appendChild(_DOMImageElement);
        _DOMImageElement.style.visibility = "hidden";

        objj_msgSend(self, "setImage:", objj_msgSend(aCoder, "decodeObjectForKey:", CPImageViewImageKey));

        objj_msgSend(self, "setImageScaling:", objj_msgSend(aCoder, "decodeIntForKey:", CPImageViewImageScalingKey));
        objj_msgSend(self, "setHasShadow:", objj_msgSend(aCoder, "decodeBoolForKey:", CPImageViewHasShadowKey));objj_msgSend(self, "tile");
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("encodeWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "encodeWithCoder:", aCoder);

    objj_msgSend(aCoder, "encodeObject:forKey:", _image, CPImageViewImageKey);

    objj_msgSend(aCoder, "encodeInt:forKey:", _imageScaling, CPImageViewImageScalingKey);
    objj_msgSend(aCoder, "encodeBool:forKey:", _hasShadow, CPImageViewHasShadowKey);
}
});
class_addMethods(the_class, instance_methods);
}

var _DOMImagePartCreate = function()
{
    var part = document.createElement("div"),
        style = part.style;

    style.overflow = "hidden";
    style.position = "absolute";
    style.visibility = "visible";
    style.left = "0px";
    style.top = "0px";
    style.zIndex = 0;

    return part;
}

var _DOMImagePartSetImage = function(aPart, anImage)
{
    aPart.style.background = "url(\"" + objj_msgSend(anImage, "filename") + "\")";

    var size = objj_msgSend(anImage, "size"),
        style = aPart.style;

    style.width = ROUND(size.width) + "px";
    style.height = ROUND(size.height) + "px";
}

var CPThreePartImageViewTop = 0,
    CPThreePartImageViewLeft = 0,
    CPThreePartImageViewRight = 1,
    CPThreePartImageViewBottom = 1,
    CPThreePartImageViewCenter = 2;

{var the_class = objj_allocateClassPair(CPView, "CPThreePartImageView"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_isVertical"), new objj_ivar("_images"), new objj_ivar("_DOMImageParts"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "initWithFrame:", aFrame);

    if (self)
    {
        _images = [];
        _DOMImageParts = [];

        _DOMImageParts[0] = _DOMImagePartCreate();
        _DOMImageParts[1] = _DOMImagePartCreate();
        _DOMImageParts[2] = _DOMImagePartCreate();

        _DOMElement.appendChild(_DOMImageParts[0]);
        _DOMElement.appendChild(_DOMImageParts[1]);
        _DOMElement.appendChild(_DOMImageParts[2]);

        objj_msgSend(self, "setAutoresizesSubviews:", NO);
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setVertical:"), function(self, _cmd, isVertical)
{ with(self)
{
    _isVertical = isVertical;

    objj_msgSend(self, "tile");
}
});
instance_methods[2] = new objj_method(sel_registerName("isVertical"), function(self, _cmd)
{ with(self)
{
    return _isVertical;
}
});
instance_methods[3] = new objj_method(sel_registerName("topImage"), function(self, _cmd)
{ with(self)
{
    return _images[CPThreePartImageViewTop];
}
});
instance_methods[4] = new objj_method(sel_registerName("setTopImage:"), function(self, _cmd, anImage)
{ with(self)
{
    _images[CPThreePartImageViewTop] = anImage;

    _DOMImagePartSetImage(_DOMImageParts[CPThreePartImageViewTop], anImage);
    _DOMImageParts[CPThreePartImageViewCenter].style.top = ROUND(objj_msgSend(anImage, "size").height) + "px";

    objj_msgSend(self, "tile");
}
});
instance_methods[5] = new objj_method(sel_registerName("bottomImage"), function(self, _cmd)
{ with(self)
{
    return _images[CPThreePartImageViewBottom];
}
});
instance_methods[6] = new objj_method(sel_registerName("setBottomImage:"), function(self, _cmd, anImage)
{ with(self)
{
    _images[CPThreePartImageViewBottom] = anImage;

    _DOMImagePartSetImage(_DOMImageParts[CPThreePartImageViewBottom], anImage);

    objj_msgSend(self, "tile");
}
});
instance_methods[7] = new objj_method(sel_registerName("leftImage"), function(self, _cmd)
{ with(self)
{
    return _images[CPThreePartImageViewLeft];
}
});
instance_methods[8] = new objj_method(sel_registerName("setLeftImage:"), function(self, _cmd, anImage)
{ with(self)
{
    _images[CPThreePartImageViewLeft] = anImage;

    _DOMImagePartSetImage(_DOMImageParts[CPThreePartImageViewLeft], anImage);
    _DOMImageParts[CPThreePartImageViewCenter].style.left = ROUND(objj_msgSend(anImage, "size").width) + "px";

    objj_msgSend(self, "tile");
}
});
instance_methods[9] = new objj_method(sel_registerName("rightImage"), function(self, _cmd)
{ with(self)
{
    return _images[CPThreePartImageViewRight];
}
});
instance_methods[10] = new objj_method(sel_registerName("setRightImage:"), function(self, _cmd, anImage)
{ with(self)
{
    _images[CPThreePartImageViewRight] = anImage;

    if (anImage)
        _DOMImagePartSetImage(_DOMImageParts[CPThreePartImageViewRight], anImage);

    objj_msgSend(self, "tile");
}
});
instance_methods[11] = new objj_method(sel_registerName("centerImage"), function(self, _cmd)
{ with(self)
{
    return _images[CPThreePartImageViewCenter];
}
});
instance_methods[12] = new objj_method(sel_registerName("setCenterImage:"), function(self, _cmd, anImage)
{ with(self)
{
    _images[CPThreePartImageViewCenter] = anImage;

    _DOMImagePartSetImage(_DOMImageParts[CPThreePartImageViewCenter], anImage);

    objj_msgSend(self, "tile");
}
});
instance_methods[13] = new objj_method(sel_registerName("setImages:"), function(self, _cmd, images)
{ with(self)
{
    if (_isVertical)
    {
        objj_msgSend(self, "setTopImage:", images[0]);
        objj_msgSend(self, "setBottomImage:", images[2]);
    }
    else
    {
        objj_msgSend(self, "setLeftImage:", images[0]);
        objj_msgSend(self, "setRightImage:", images[2]);
    }

    objj_msgSend(self, "setCenterImage:", images[1]);
}
});
instance_methods[14] = new objj_method(sel_registerName("setFrameSize:"), function(self, _cmd, aSize)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "setFrameSize:", aSize);

    objj_msgSend(self, "tile");
}
});
instance_methods[15] = new objj_method(sel_registerName("tile"), function(self, _cmd)
{ with(self)
{
    if (_isVertical)
    {
        var top = ROUND((objj_msgSend(self, "bounds").size.height) - (_images[CPThreePartImageViewBottom] ? objj_msgSend(_images[CPThreePartImageViewBottom], "size").height : 0.0));

        _DOMImageParts[CPThreePartImageViewBottom].style.top = top + "px";
        _DOMImageParts[CPThreePartImageViewCenter].style.height = MAX(0.0, ROUND(top - (_images[CPThreePartImageViewTop] ? objj_msgSend(_images[CPThreePartImageViewTop], "size").height : 0.0))) + "px";
    }
    else
    {
        var left = ROUND((objj_msgSend(self, "bounds").size.width) - (_images[CPThreePartImageViewRight] ? objj_msgSend(_images[CPThreePartImageViewRight], "size").width : 0.0));

        _DOMImageParts[CPThreePartImageViewRight].style.left = left + "px";
        _DOMImageParts[CPThreePartImageViewCenter].style.width = MAX(0.0, ROUND(left - (_images[CPThreePartImageViewLeft] ? objj_msgSend(_images[CPThreePartImageViewLeft], "size").width : 0.0))) + "px";
    }
}
});
class_addMethods(the_class, instance_methods);
}

var CPNinePartImageViewTop = 0,
    CPNinePartImageViewLeft = 1,
    CPNinePartImageViewRight = 2,
    CPNinePartImageViewBottom = 3,
    CPNinePartImageViewCenter = 4,
    CPNinePartImageViewTopLeft = 5,
    CPNinePartImageViewTopRight = 6,
    CPNinePartImageViewBottomLeft = 7,
    CPNinePartImageViewBottomRight = 8;

{var the_class = objj_allocateClassPair(CPView, "CPNinePartImageView"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_images"), new objj_ivar("_DOMImageParts"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "initWithFrame:", aFrame);

    if (self)
    {
        _images = [];
        _DOMImageParts = [_DOMImagePartCreate(),_DOMImagePartCreate(),_DOMImagePartCreate(),_DOMImagePartCreate(),_DOMImagePartCreate(),_DOMImagePartCreate(),_DOMImagePartCreate(),_DOMImagePartCreate(),_DOMImagePartCreate(),];

        _DOMElement.appendChild(_DOMImageParts[0]);
        _DOMElement.appendChild(_DOMImageParts[1]);
        _DOMElement.appendChild(_DOMImageParts[2]);
        _DOMElement.appendChild(_DOMImageParts[3]);
        _DOMElement.appendChild(_DOMImageParts[4]);
        _DOMElement.appendChild(_DOMImageParts[5]);
        _DOMElement.appendChild(_DOMImageParts[6]);
        _DOMElement.appendChild(_DOMImageParts[7]);
        _DOMElement.appendChild(_DOMImageParts[8]);

        objj_msgSend(self, "setAutoresizesSubviews:", NO);
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("topLeftImage"), function(self, _cmd)
{ with(self)
{
    return _images[CPNinePartImageViewTopLeft];
}
});
instance_methods[2] = new objj_method(sel_registerName("setTopLeftImage:"), function(self, _cmd, anImage)
{ with(self)
{
    _images[CPNinePartImageViewTopLeft] = anImage;

    _DOMImagePartSetImage(_DOMImageParts[CPNinePartImageViewTopLeft], anImage);

    var size = objj_msgSend(anImage, "size");

    _DOMImageParts[CPNinePartImageViewLeft].style.top = ROUND(size.height) + "px";
    _DOMImageParts[CPNinePartImageViewRight].style.top = _DOMImageParts[CPNinePartImageViewLeft].style.top;
    _DOMImageParts[CPNinePartImageViewCenter].style.top = _DOMImageParts[CPNinePartImageViewLeft].style.top;

    _DOMImageParts[CPNinePartImageViewTop].style.left = ROUND(size.width) + "px";
    _DOMImageParts[CPNinePartImageViewCenter].style.left = _DOMImageParts[CPNinePartImageViewTop].style.left;
    _DOMImageParts[CPNinePartImageViewBottom].style.left = _DOMImageParts[CPNinePartImageViewTop].style.left;

    objj_msgSend(self, "tile");
}
});
instance_methods[3] = new objj_method(sel_registerName("topRightImage"), function(self, _cmd)
{ with(self)
{
    return _images[CPNinePartImageViewTopRight];
}
});
instance_methods[4] = new objj_method(sel_registerName("setTopRightImage:"), function(self, _cmd, anImage)
{ with(self)
{
    _images[CPNinePartImageViewTopRight] = anImage;

    _DOMImagePartSetImage(_DOMImageParts[CPNinePartImageViewTopRight], anImage);

    objj_msgSend(self, "tile");
}
});
instance_methods[5] = new objj_method(sel_registerName("bottomLeftImage"), function(self, _cmd)
{ with(self)
{
    return _images[CPNinePartImageViewBottomLeft];
}
});
instance_methods[6] = new objj_method(sel_registerName("setBottomLeftImage:"), function(self, _cmd, anImage)
{ with(self)
{
    _images[CPNinePartImageViewBottomLeft] = anImage;

    _DOMImagePartSetImage(_DOMImageParts[CPNinePartImageViewBottomLeft], anImage);

    objj_msgSend(self, "tile");
}
});
instance_methods[7] = new objj_method(sel_registerName("bottomRightImage"), function(self, _cmd)
{ with(self)
{
    return _images[CPNinePartImageViewBottomRight];
}
});
instance_methods[8] = new objj_method(sel_registerName("setBottomRightImage:"), function(self, _cmd, anImage)
{ with(self)
{
    _images[CPNinePartImageViewBottomRight] = anImage;

    _DOMImagePartSetImage(_DOMImageParts[CPNinePartImageViewBottomRight], anImage);

    objj_msgSend(self, "tile");
}
});
instance_methods[9] = new objj_method(sel_registerName("topImage"), function(self, _cmd)
{ with(self)
{
    return _images[CPNinePartImageViewTop];
}
});
instance_methods[10] = new objj_method(sel_registerName("setTopImage:"), function(self, _cmd, anImage)
{ with(self)
{
    _images[CPNinePartImageViewTop] = anImage;

    _DOMImagePartSetImage(_DOMImageParts[CPNinePartImageViewTop], anImage);

    objj_msgSend(self, "tile");
}
});
instance_methods[11] = new objj_method(sel_registerName("leftImage"), function(self, _cmd)
{ with(self)
{
    return _images[CPNinePartImageViewLeft];
}
});
instance_methods[12] = new objj_method(sel_registerName("setLeftImage:"), function(self, _cmd, anImage)
{ with(self)
{
    _images[CPNinePartImageViewLeft] = anImage;

    _DOMImagePartSetImage(_DOMImageParts[CPNinePartImageViewLeft], anImage);

    if (!_images[CPNinePartImageViewTopLeft])
    {
        var width = ROUND(objj_msgSend(anImage, "size").width);

        _DOMImageParts[CPNinePartImageViewTopLeft].style.width = width + "px";
        _DOMImageParts[CPNinePartImageViewTop].style.left = _DOMImageParts[CPNinePartImageViewTopLeft].style.width;
        _DOMImageParts[CPNinePartImageViewCenter].style.left = _DOMImageParts[CPNinePartImageViewTopLeft].style.width
        _DOMImageParts[CPNinePartImageViewBottom].style.left = _DOMImageParts[CPNinePartImageViewTopLeft].style.width
    }

    objj_msgSend(self, "tile");
}
});
instance_methods[13] = new objj_method(sel_registerName("rightImage"), function(self, _cmd)
{ with(self)
{
    return _images[CPNinePartImageViewRight];
}
});
instance_methods[14] = new objj_method(sel_registerName("setRightImage:"), function(self, _cmd, anImage)
{ with(self)
{
    _images[CPNinePartImageViewRight] = anImage;

    _DOMImagePartSetImage(_DOMImageParts[CPNinePartImageViewRight], anImage);

    if (!_images[CPNinePartImageViewTopRight])
        _DOMImageParts[CPNinePartImageViewTopRight].style.width = ROUND(objj_msgSend(anImage, "size").width) + "px";

    objj_msgSend(self, "tile");
}
});
instance_methods[15] = new objj_method(sel_registerName("bottomImage"), function(self, _cmd)
{ with(self)
{
    return _images[CPNinePartImageViewBottom];
}
});
instance_methods[16] = new objj_method(sel_registerName("setBottomImage:"), function(self, _cmd, anImage)
{ with(self)
{
    _images[CPNinePartImageViewBottom] = anImage;

    _DOMImagePartSetImage(_DOMImageParts[CPNinePartImageViewBottom], anImage);

    objj_msgSend(self, "tile");
}
});
instance_methods[17] = new objj_method(sel_registerName("centerImage"), function(self, _cmd)
{ with(self)
{
    return _images[CPNinePartImageViewCenter];
}
});
instance_methods[18] = new objj_method(sel_registerName("setCenterImage:"), function(self, _cmd, anImage)
{ with(self)
{
    _images[CPNinePartImageViewCenter] = anImage;

    _DOMImagePartSetImage(_DOMImageParts[CPNinePartImageViewCenter], anImage);

    if (!_images[CPNinePartImageViewTop])
        objj_msgSend(self, "setTopImage:", anImage);
    if (!_images[CPNinePartImageViewLeft])
        objj_msgSend(self, "setLeftImage:", anImage);
    if (!_images[CPNinePartImageViewRight])
        objj_msgSend(self, "setRightImage:", anImage);
    if (!_images[CPNinePartImageViewBottom])
        objj_msgSend(self, "setBottomImage:", anImage);

    objj_msgSend(self, "tile");
}
});
instance_methods[19] = new objj_method(sel_registerName("setImages:"), function(self, _cmd, images)
{ with(self)
{
    objj_msgSend(self, "setTopLeftImage:", images[0]);
    objj_msgSend(self, "setTopImage:", images[1]);
    objj_msgSend(self, "setTopRightImage:", images[2]);

    objj_msgSend(self, "setLeftImage:", images[3]);
    objj_msgSend(self, "setCenterImage:", images[4]);
    objj_msgSend(self, "setRightImage:", images[5]);

    objj_msgSend(self, "setBottomLeftImage:", images[6]);
    objj_msgSend(self, "setBottomImage:", images[7]);
    objj_msgSend(self, "setBottomRightImage:", images[8]);
}
});
instance_methods[20] = new objj_method(sel_registerName("centerColor"), function(self, _cmd)
{ with(self)
{
    return nil;
}
});
instance_methods[21] = new objj_method(sel_registerName("setCenterColor:"), function(self, _cmd, aColor)
{ with(self)
{
    _DOMImageParts[CPNinePartImageViewCenter].style.background = objj_msgSend(aColor, "cssString");
}
});
instance_methods[22] = new objj_method(sel_registerName("setFrameSize:"), function(self, _cmd, aSize)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "setFrameSize:", aSize);

    objj_msgSend(self, "tile");
}
});
instance_methods[23] = new objj_method(sel_registerName("tile"), function(self, _cmd)
{ with(self)
{
    var bounds = objj_msgSend(self, "bounds"),
        right = _images[CPNinePartImageViewTopRight] || _images[CPNinePartImageViewRight],

        zeroSize = CGSizeMakeZero(),
        topLeftSize = (_images[CPNinePartImageViewTopLeft] ? objj_msgSend(_images[CPNinePartImageViewTopLeft], "size") :
                        (_images[CPNinePartImageViewLeft] ? CGSizeMake(objj_msgSend(_images[CPNinePartImageViewLeft], "size").width, 0.0) : zeroSize)),
        topRightSize = (right ? objj_msgSend(right, "size") : zeroSize),
        bottomRightSize = (_images[CPNinePartImageViewBottomRight] ? objj_msgSend(_images[CPNinePartImageViewBottomRight], "size") : zeroSize),

        width = MAX(0.0, ROUND(CGRectGetWidth(bounds) - topLeftSize.width - topRightSize.width)),
        height = MAX(0.0, ROUND(CGRectGetHeight(bounds) - topLeftSize.height - bottomRightSize.height));

    _DOMImageParts[CPNinePartImageViewTopRight].style.left = ROUND(topLeftSize.width + width) + "px";
    _DOMImageParts[CPNinePartImageViewBottomLeft].style.top = ROUND(topLeftSize.height + height) + "px";

    _DOMImageParts[CPNinePartImageViewBottomRight].style.left = _DOMImageParts[CPNinePartImageViewTopRight].style.left;
    _DOMImageParts[CPNinePartImageViewBottomRight].style.top = _DOMImageParts[CPNinePartImageViewBottomLeft].style.top;


    _DOMImageParts[CPNinePartImageViewTop].style.width = width + "px";
    _DOMImageParts[CPNinePartImageViewLeft].style.height = height + "px";

    _DOMImageParts[CPNinePartImageViewRight].style.left = _DOMImageParts[CPNinePartImageViewTopRight].style.left;
    _DOMImageParts[CPNinePartImageViewRight].style.height = height + "px";

    _DOMImageParts[CPNinePartImageViewBottom].style.top = _DOMImageParts[CPNinePartImageViewBottomLeft].style.top;
    _DOMImageParts[CPNinePartImageViewBottom].style.width = width + "px";

    _DOMImageParts[CPNinePartImageViewCenter].style.width = width + "px";
    _DOMImageParts[CPNinePartImageViewCenter].style.height = height + "px";
}
});
class_addMethods(the_class, instance_methods);
}

p;20;CPKulerColorPicker.jI;23;Foundation/Foundation.jI;15;AppKit/CPView.jI;17;AppKit/CPButton.jI;16;AppKit/CPImage.jI;20;AppKit/CPImageView.jI;22;AppKit/CPColorPicker.jI;21;AppKit/CPColorPanel.jI;18;AppKit/CPTabView.jI;22;AppKit/CPTabViewItem.jc;14252;

{var the_class = objj_allocateClassPair(CPColorPicker, "CPKulerColorPicker"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_contentView"), new objj_ivar("_tabView"), new objj_ivar("_searchView"), new objj_ivar("_popularView"), new objj_ivar("_searchView"), new objj_ivar("_FIXME_searchField"), new objj_ivar("_searchConnection"), new objj_ivar("_popularConnection"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithPickerMask:colorPanel:"), function(self, _cmd, mask, owningColorPanel)
{ with(self)
{
    return objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPColorPicker") }, "initWithPickerMask:colorPanel:", mask, owningColorPanel);
}
});
instance_methods[1] = new objj_method(sel_registerName("initView"), function(self, _cmd)
{ with(self)
{
    aFrame = CPRectMake(0, 0, CPColorPickerViewWidth, CPColorPickerViewHeight);
    _contentView = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", aFrame);

    _tabView = objj_msgSend(objj_msgSend(CPTabView, "alloc"), "initWithFrame:", CGRectMake(0.0,0.0,CGRectGetWidth(aFrame),CGRectGetHeight(aFrame)-20));
    objj_msgSend(_tabView, "setAutoresizingMask:", CPViewWidthSizable|CPViewHeightSizable);
    objj_msgSend(_tabView, "setDelegate:", self);
    objj_msgSend(_contentView, "addSubview:", _tabView);

    var label = objj_msgSend(objj_msgSend(CPButton, "alloc"), "initWithFrame:", CPRectMake((CPColorPickerViewWidth-150)/2,CPColorPickerViewHeight-20,150,20));
    objj_msgSend(label, "setAutoresizingMask:", CPViewMinXMargin|CPViewMaxXMargin|CPViewMinYMargin);
    objj_msgSend(label, "setFont:", objj_msgSend(CPFont, "boldSystemFontOfSize:", 10.0));
    objj_msgSend(label, "setTextColor:", objj_msgSend(CPColor, "whiteColor"));
    objj_msgSend(label, "setTitle:", "Powered by Adobe Kuler");
    objj_msgSend(label, "setTarget:", self);
    objj_msgSend(label, "setAction:", sel_registerName("openKulerLink:"));
    objj_msgSend(label, "setBordered:", NO);
    objj_msgSend(_contentView, "addSubview:", label);

    var searchThemeView = objj_msgSend(objj_msgSend(_CPKulerThemeView, "alloc"), "initWithFrame:", CPRectMake(0,0,aFrame.size.width,0));
    objj_msgSend(searchThemeView, "setDelegate:", self);
    objj_msgSend(searchThemeView, "setAutoresizingMask:", CPViewWidthSizable);

    _searchView = objj_msgSend(objj_msgSend(CPScrollView, "alloc"), "initWithFrame:", CPRectMake(0,0,aFrame.size.width,CPColorPickerViewHeight-10));
    objj_msgSend(_searchView, "setDocumentView:", searchThemeView);
    objj_msgSend(_searchView, "setHasHorizontalScroller:", NO);
    objj_msgSend(_searchView, "setAutoresizingMask:", (CPViewWidthSizable|CPViewHeightSizable));
    objj_msgSend(objj_msgSend(_searchView, "verticalScroller"), "setControlSize:", CPSmallControlSize);
    objj_msgSend(_searchView, "setAutohidesScrollers:", YES);

    var auxiliarySearchView = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", CGRectMake(0.0,0.0,CPColorPickerViewWidth,26.0));
    objj_msgSend(auxiliarySearchView, "setAutoresizingMask:", (CPViewMinYMargin|CPViewWidthSizable));

    _FIXME_searchField = document.createElement("input");

    if(!window.addEventListener)
        _FIXME_searchField.type = "text";
    else
        _FIXME_searchField.type = "search";

    _FIXME_searchField.style.position = "absolute";
    _FIXME_searchField.style.width = "96%";
    _FIXME_searchField.style.left = "2%";
    _FIXME_searchField.style.top = "2px";
    _FIXME_searchField.onkeypress = function(aDOMEvent)
    {
        aDOMEvent = aDOMEvent || window.event;
        if (aDOMEvent.keyCode == 13)
        {
            objj_msgSend(self, "search");

            if(aDOMEvent.preventDefault)
                aDOMEvent.preventDefault();
            else if(aDOMEvent.stopPropagation)
                aDOMEvent.stopPropagation();

            _FIXME_searchField.blur();
        }
    };

    auxiliarySearchView._DOMElement.appendChild(_FIXME_searchField);

    var popularThemeView = objj_msgSend(objj_msgSend(_CPKulerThemeView, "alloc"), "initWithFrame:", CPRectMake(0,0,aFrame.size.width,0));
    objj_msgSend(popularThemeView, "setDelegate:", self);
    objj_msgSend(popularThemeView, "setAutoresizingMask:", CPViewWidthSizable);

    _popularView = objj_msgSend(objj_msgSend(CPScrollView, "alloc"), "initWithFrame:", CPRectMake(0,0,aFrame.size.width,CPColorPickerViewHeight));
    objj_msgSend(_popularView, "setDocumentView:", popularThemeView);
    objj_msgSend(_popularView, "setHasHorizontalScroller:", NO);
    objj_msgSend(_popularView, "setAutoresizingMask:", (CPViewWidthSizable|CPViewHeightSizable));
    objj_msgSend(objj_msgSend(_popularView, "verticalScroller"), "setControlSize:", CPSmallControlSize);
    objj_msgSend(_popularView, "setAutohidesScrollers:", YES);

    var mostPopularItem = objj_msgSend(objj_msgSend(CPTabViewItem, "alloc"), "initWithIdentifier:", "Popular");
    var searchItem = objj_msgSend(objj_msgSend(CPTabViewItem, "alloc"), "initWithIdentifier:", "Search");

    objj_msgSend(searchItem, "setLabel:", "Search");
    objj_msgSend(searchItem, "setView:", _searchView);
    objj_msgSend(searchItem, "setAuxiliaryView:", auxiliarySearchView);

    objj_msgSend(mostPopularItem, "setLabel:", "Popular");
    objj_msgSend(mostPopularItem, "setView:", _popularView);

    objj_msgSend(_tabView, "addTabViewItem:", mostPopularItem);
    objj_msgSend(_tabView, "addTabViewItem:", searchItem);

    objj_msgSend(self, "popularThemes");
}
});
instance_methods[2] = new objj_method(sel_registerName("openKulerLink:"), function(self, _cmd, sender)
{ with(self)
{
    window.open("http://kuler.adobe.com");
}
});
instance_methods[3] = new objj_method(sel_registerName("provideNewView:"), function(self, _cmd, initialRequest)
{ with(self)
{
    if (initialRequest)
        objj_msgSend(self, "initView");

    return _contentView;
}
});
instance_methods[4] = new objj_method(sel_registerName("currentMode"), function(self, _cmd)
{ with(self)
{
    return CPKulerColorPickerMode;
}
});
instance_methods[5] = new objj_method(sel_registerName("supportsMode:"), function(self, _cmd, mode)
{ with(self)
{
    return (mode == CPKulerColorPickerMode) ? YES : NO;
}
});
instance_methods[6] = new objj_method(sel_registerName("search"), function(self, _cmd)
{ with(self)
{
    var query = escape(_FIXME_searchField.value);

    if(query.replace("%20", "") == "")
        return;

    objj_msgSend(_searchConnection, "cancel");

    _searchConnection = nil;
    _searchConnection = objj_msgSend(CPURLConnection, "connectionWithRequest:delegate:", objj_msgSend(CPURLRequest, "requestWithURL:", BASE_URL+"kuler.php?mode=search&query="+query), self);
}
});
instance_methods[7] = new objj_method(sel_registerName("popularThemes"), function(self, _cmd)
{ with(self)
{
    objj_msgSend(_popularConnection, "cancel");
    _popularConnection = nil;
    _popularConnection = objj_msgSend(CPURLConnection, "connectionWithRequest:delegate:", objj_msgSend(CPURLRequest, "requestWithURL:", BASE_URL+"kuler.php?mode=popular"), self);
}
});
instance_methods[8] = new objj_method(sel_registerName("connection:didReceiveData:"), function(self, _cmd, aConnection, data)
{ with(self)
{
    var themes = CPJSObjectCreateWithJSON(data).result;
    if(!themes)
        return;
    if(aConnection == _popularConnection)
    {
        objj_msgSend(objj_msgSend(_popularView, "documentView"), "setThemes:", themes);
        objj_msgSend(_popularView, "reflectScrolledClipView:", objj_msgSend(_popularView, "contentView"));
    }
    if(aConnection == _searchConnection)
    {
        objj_msgSend(objj_msgSend(_searchView, "documentView"), "setThemes:", themes);
        objj_msgSend(_searchView, "reflectScrolledClipView:", objj_msgSend(_searchView, "contentView"));
    }
}
});
instance_methods[9] = new objj_method(sel_registerName("connection:didFailWithError:"), function(self, _cmd, aConnection, anError)
{ with(self)
{
    objj_msgSend(self, "connectionDidFinishLoading:", aConnection);
}
});
instance_methods[10] = new objj_method(sel_registerName("connectionDidFinishLoading:"), function(self, _cmd, aConnection)
{ with(self)
{}
});
instance_methods[11] = new objj_method(sel_registerName("chooseColor:"), function(self, _cmd, aColor)
{ with(self)
{
    objj_msgSend(objj_msgSend(self, "colorPanel"), "setColor:", aColor);
}
});
class_addMethods(the_class, instance_methods);
}
{var the_class = objj_allocateClassPair(CPView, "_CPKulerThemeView"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_themes"), new objj_ivar("_delegate"), new objj_ivar("_alternateBGColor"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "initWithFrame:", aFrame);
    _alternateBGColor = objj_msgSend(CPColor, "colorWithCalibratedRed:green:blue:alpha:", 241.0/255.0, 245.0/255.0, 250.0/255.0, 1.0);
    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("delegate"), function(self, _cmd)
{ with(self)
{
    return _delegate;
}
});
instance_methods[2] = new objj_method(sel_registerName("setDelegate:"), function(self, _cmd, delegate)
{ with(self)
{
    _delegate = delegate;
}
});
instance_methods[3] = new objj_method(sel_registerName("themes"), function(self, _cmd)
{ with(self)
{
    return _themes;
}
});
instance_methods[4] = new objj_method(sel_registerName("setThemes:"), function(self, _cmd, themes)
{ with(self)
{
    _themes = themes;
    objj_msgSend(self, "updateDisplay");
}
});
instance_methods[5] = new objj_method(sel_registerName("updateDisplay"), function(self, _cmd)
{ with(self)
{
    var width = objj_msgSend(self, "frame").size.width;
    var subviews = objj_msgSend(self, "subviews");
    for(var i = objj_msgSend(subviews, "count")-1; i >= 0; --i)
        objj_msgSend(subviews[i], "removeFromSuperview");
    for(var i=0, count = objj_msgSend(_themes, "count"); i<count; i++)
    {
        var swatches = _themes[i].swatches;
        var containerView = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", CPRectMake(0,1+20*i,width,20));
        objj_msgSend(containerView, "setAutoresizingMask:", CPViewWidthSizable);
        for(var j=0; j<swatches.length; j++)
        {
            var view = objj_msgSend(objj_msgSend(_CPColorView, "alloc"), "initWithFrame:", CPRectMake(2+20*j,1,18,18));
            objj_msgSend(view, "setTarget:", self);
            objj_msgSend(view, "setAction:", sel_registerName("selectedColor:"));
            objj_msgSend(view, "setBackgroundColor:", objj_msgSend(CPColor, "colorWithHexString:", swatches[j].hexColor));
            objj_msgSend(view, "setBorder:", objj_msgSend(CPBorder, "borderWithColor:thickness:style:", objj_msgSend(CPColor, "blackColor"), 1.0, CPBorderSolidStyle));
            objj_msgSend(containerView, "addSubview:", view);
        }
        var label = objj_msgSend(objj_msgSend(CPTextField, "alloc"), "initWithFrame:", CPRectMake(102,0,width-102,20));
        objj_msgSend(label, "setStringValue:", _themes[i].title);
        objj_msgSend(label, "setFont:", objj_msgSend(CPFont, "systemFontOfSize:", 11.0));
        objj_msgSend(label, "setLineBreakMode:", CPLineBreakByTruncatingTail);
        objj_msgSend(label, "setAutoresizingMask:", CPViewWidthSizable);
        objj_msgSend(containerView, "addSubview:", label);
        if(i%2 == 1)
            objj_msgSend(containerView, "setBackgroundColor:", _alternateBGColor);
        objj_msgSend(self, "addSubview:", containerView);
    }
    objj_msgSend(self, "setFrameSize:", CPSizeMake(width,(count)*20+2));
}
});
instance_methods[6] = new objj_method(sel_registerName("selectedColor:"), function(self, _cmd, sender)
{ with(self)
{
    objj_msgSend(_delegate, "chooseColor:", objj_msgSend(sender, "backgroundColor"));
}
});
class_addMethods(the_class, instance_methods);
}
{var the_class = objj_allocateClassPair(CPControl, "_CPColorView"),
meta_class = _class_getMeta(the_class);objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "initWithFrame:", aFrame);
    objj_msgSend(self, "registerForDraggedTypes:", objj_msgSend(CPArray, "arrayWithObjects:", CPColorDragType));
    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("mouseDragged:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(objj_msgSend(CPPasteboard, "pasteboardWithName:", CPDragPboard), "declareTypes:owner:", objj_msgSend(CPArray, "arrayWithObject:", CPColorDragType), self);
    var bounds = CPRectMake(0, 0, 15, 15),
        point = objj_msgSend(self, "convertPoint:fromView:", objj_msgSend(anEvent, "locationInWindow"), nil);
    var dragView = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", bounds);
    objj_msgSend(dragView, "setBackgroundColor:", objj_msgSend(self, "backgroundColor"));
    objj_msgSend(dragView, "setBorder:", objj_msgSend(CPBorder, "borderWithColor:thickness:style:", objj_msgSend(CPColor, "blackColor"), 1.0, CPBorderSolidStyle));
    objj_msgSend(self, "dragView:at:offset:event:pasteboard:source:slideBack:", dragView, CPPointMake(point.x-bounds.size.width/2.0,point.y-bounds.size.height/2.0), CPPointMake(0.0,0.0), anEvent, nil, self, YES);
}
});
instance_methods[2] = new objj_method(sel_registerName("pasteboard:provideDataForType:"), function(self, _cmd, aPasteboard, aType)
{ with(self)
{
    if(aType == CPColorDragType)
        objj_msgSend(aPasteboard, "setData:forType:", objj_msgSend(self, "backgroundColor"), aType);
}
});
class_addMethods(the_class, instance_methods);
}

p;8;CPMenu.jI;20;Foundation/CPArray.jI;25;Foundation/CPDictionary.jI;33;Foundation/CPNotificationCenter.jI;21;Foundation/CPString.jI;22;AppKit/CPApplication.ji;12;CPMenuItem.jc;9755;


CPMenuDidChangeItemNotification = "CPMenuDidChangeItemNotification";
CPMenuItemIndex = "CPMenuItemIndex";

{var the_class = objj_allocateClassPair(CPObject, "CPMenu"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_title"), new objj_ivar("_items"), new objj_ivar("_attachedMenu"), new objj_ivar("_autoenablesItems"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithTitle:"), function(self, _cmd, aTitle)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
    {
        _title = aTitle;
        _items = [];

        _autoenablesItems = YES;
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("insertItem:atIndex:"), function(self, _cmd, aMenuItem, anIndex)
{ with(self)
{
    objj_msgSend(aMenuItem, "setMenu:", self);
    objj_msgSend(_items, "insertObject:atIndex:", aMenuItem, anIndex);
}
});
instance_methods[2] = new objj_method(sel_registerName("insertItemWithTitle:action:keyEquivalent:atIndex:"), function(self, _cmd, aTitle, anAction, aKeyEquivalent, anIndex)
{ with(self)
{
    var item = objj_msgSend(objj_msgSend(CPMenuItem, "alloc"), "initWithTitle:action:keyEquivalent:", aTitle, anAction, aKeyEquivalent);

    objj_msgSend(self, "insertItem:atIndex:", item, anIndex);

    return item;
}
});
instance_methods[3] = new objj_method(sel_registerName("addItem:"), function(self, _cmd, aMenuItem)
{ with(self)
{
    objj_msgSend(aMenuItem, "setMenu:", self);
    objj_msgSend(_items, "addObject:", aMenuItem);
}
});
instance_methods[4] = new objj_method(sel_registerName("addItemWithTitle:action:keyEquivalent:atIndex:"), function(self, _cmd, aTitle, anAction, aKeyEquivalent, anIndex)
{ with(self)
{
    var item = objj_msgSend(objj_msgSend(CPMenuItem, "alloc"), "initWithTitle:action:keyEquivalent:", aTitle, anAction, aKeyEquivalent);

    objj_msgSend(self, "addItem:atIndex:", item, anIndex);

    return item;
}
});
instance_methods[5] = new objj_method(sel_registerName("removeItem:"), function(self, _cmd, aMenuItem)
{ with(self)
{
    var count = _items.length;

    objj_msgSend(_items, "removeObjectIdenticalTo:", aMenuItem);

    if (_items.length < count)
        objj_msgSend(aMenuItem, "setMenu:", nil);
}
});
instance_methods[6] = new objj_method(sel_registerName("removeItemAtIndex:"), function(self, _cmd, anIndex)
{ with(self)
{
    objj_msgSend(_items[anIndex], "setMenu:", nil);
    objj_msgSend(_items, "removeObjectAtIndex:", aMenuItem);
}
});
instance_methods[7] = new objj_method(sel_registerName("itemChanged:"), function(self, _cmd, aMenuItem)
{ with(self)
{
    if (objj_msgSend(aMenuItem, "menu") != self)
        return;

    objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:userInfo:", CPMenuDidChangeItemNotification, self, objj_msgSend(CPDictionary, "dictionaryWithObject:forKey:", objj_msgSend(_items, "indexOfObjectIdenticalTo:", aMenuItem), CPMenuItemIndex));
}
});
instance_methods[8] = new objj_method(sel_registerName("menuWithTag:"), function(self, _cmd, aTag)
{ with(self)
{
    var index = objj_msgSend(self, "indexOfItemWithTag:", aTag);

    if (index == CPNotFound)
        return nil;

    return _items[index];
}
});
instance_methods[9] = new objj_method(sel_registerName("menuWithTitle:"), function(self, _cmd, aTitle)
{ with(self)
{
    var index = objj_msgSend(self, "indexOfItemWithTitle:", aTitle);

    if (index == CPNotFound)
        return nil;

    return _items[index];
}
});
instance_methods[10] = new objj_method(sel_registerName("itemAtIndex:"), function(self, _cmd, anIndex)
{ with(self)
{
    return objj_msgSend(_items, "objectAtIndex:", anIndex);
}
});
instance_methods[11] = new objj_method(sel_registerName("numberOfItems"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(_items, "count");
}
});
instance_methods[12] = new objj_method(sel_registerName("itemArray"), function(self, _cmd)
{ with(self)
{
    return _items;
}
});
instance_methods[13] = new objj_method(sel_registerName("indexOfItem:"), function(self, _cmd, aMenuItem)
{ with(self)
{
    if (objj_msgSend(aMenuItem, "menu") != self)
        return CPNotFound;

    return objj_msgSend(_items, "indexOfObjectIdenticalTo:", aMenuItem);
}
});
instance_methods[14] = new objj_method(sel_registerName("indexOfItemWithTitle:"), function(self, _cmd, aTitle)
{ with(self)
{
    var index = 0,
        count = _items.length;

    for (; index < count; ++index)
        if (objj_msgSend(_items[index], "title") == aTitle)
            return index;

    return CPNotFound;
}
});
instance_methods[15] = new objj_method(sel_registerName("indexOfItemWithTag:"), function(self, _cmd, aTag)
{ with(self)
{
    var index = 0,
        count = _items.length;

    for (; index < count; ++index)
        if (objj_msgSend(_items[index], "tag") == aTag)
            return index;

    return CPNotFound;
}
});
instance_methods[16] = new objj_method(sel_registerName("indexOfItemWithTarget:andAction:"), function(self, _cmd, aTarget, anAction)
{ with(self)
{
    var index = 0,
        count = _items.length;

    for (; index < count; ++index)
    {
        var item = _items[index];

        if (objj_msgSend(item, "target") == aTarget && (!anAction || objj_msgSend(item, "action") == anAction))
            return index;
    }

    return CPNotFound;
}
});
instance_methods[17] = new objj_method(sel_registerName("indexOfItemWithRepresentedObject:"), function(self, _cmd, anObject)
{ with(self)
{
    var index = 0,
        count = _items.length;

    for (; index < count; ++index)
        if (objj_msgSend(objj_msgSend(_items[index], "representedObject"), "isEqual:", anObject))
            return index;

    return CPNotFound;
}
});
instance_methods[18] = new objj_method(sel_registerName("indexOfItemWithSubmenu:"), function(self, _cmd, aMenu)
{ with(self)
{
    var index = 0,
        count = _items.length;

    for (; index < count; ++index)
        if (objj_msgSend(_items[index], "submenu") == aMenu)
            return index;

    return CPNotFound;
}
});
instance_methods[19] = new objj_method(sel_registerName("setSubmenu:forItem:"), function(self, _cmd, aMenu, aMenuItem)
{ with(self)
{
    objj_msgSend(aMenuItem, "setTarget:", aMenuItem);
    objj_msgSend(aMenuItem, "setAction:", sel_registerName("submenuAction:"));

    objj_msgSend(aMenuItem, "setSubmenu:", aMenu);
}
});
instance_methods[20] = new objj_method(sel_registerName("submenuAction:"), function(self, _cmd, aSender)
{ with(self)
{}
});
instance_methods[21] = new objj_method(sel_registerName("attachedMenu"), function(self, _cmd)
{ with(self)
{
    return _attachedMenu;
}
});
instance_methods[22] = new objj_method(sel_registerName("isAttached"), function(self, _cmd)
{ with(self)
{
    return _isAttached;
}
});
instance_methods[23] = new objj_method(sel_registerName("locationOfSubmenu:"), function(self, _cmd, aMenu)
{ with(self)
{}
});
instance_methods[24] = new objj_method(sel_registerName("supermenu"), function(self, _cmd)
{ with(self)
{
    return _supermenu;
}
});
instance_methods[25] = new objj_method(sel_registerName("setSupermenu:"), function(self, _cmd, aMenu)
{ with(self)
{
    _supermenu = aMenu;
}
});
instance_methods[26] = new objj_method(sel_registerName("isTornOff"), function(self, _cmd)
{ with(self)
{
    return !_supermenu || self == objj_msgSend(CPApp, "mainMenu");
}
});
instance_methods[27] = new objj_method(sel_registerName("setAutoenablesItems:"), function(self, _cmd, aFlag)
{ with(self)
{
    _autoenablesItems = aFlag;
}
});
instance_methods[28] = new objj_method(sel_registerName("autoenablesItems"), function(self, _cmd)
{ with(self)
{
    return _autoenablesItems;
}
});
instance_methods[29] = new objj_method(sel_registerName("update"), function(self, _cmd)
{ with(self)
{}
});
instance_methods[30] = new objj_method(sel_registerName("setTitle:"), function(self, _cmd, aTitle)
{ with(self)
{
    _title = aTitle;
}
});
instance_methods[31] = new objj_method(sel_registerName("title"), function(self, _cmd)
{ with(self)
{
    return _title;
}
});
instance_methods[32] = new objj_method(sel_registerName("performKeyEquivalent:"), function(self, _cmd, anEvent)
{ with(self)
{
    if (_autoenablesItems)
        objj_msgSend(self, "update");

    var index = 0,
        count = _items.length,
        characters = objj_msgSend(anEvent, "charactersIgnoringModifiers"),
        modifierFlags = objj_msgSend(anEvent, "modifierFlags");

    for(; index < count; ++index)
    {
        var item = _items[index],
            modifierMask = objj_msgSend(item, "keyEquivalentModifierMask");

        if ((modifierFlags & (CPShiftKeyMask | CPAlternateKeyMask | CPCommandKeyMask | CPControlKeyMask)) == modifierMask &&
            objj_msgSend(characters, "caseInsensitiveCompare:", objj_msgSend(item, "keyEquivalent")) == CPOrderedSame)
        {
            if (objj_msgSend(item, "isEnabled"))
                objj_msgSend(self, "performActionForItemAtIndex:", index);
            else
            {

            }

            return YES;
        }

        if (objj_msgSend(objj_msgSend(item, "submenu"), "performKeyEquivalent:", anEvent))
            return YES;
   }

   return NO;
}
});
instance_methods[33] = new objj_method(sel_registerName("performActionForItemAtIndex:"), function(self, _cmd, anIndex)
{ with(self)
{
    var item = _items[anIndex];

    objj_msgSend(CPApp, "sendAction:to:from:", objj_msgSend(item, "action"), objj_msgSend(item, "target"), item);
}
});
class_addMethods(the_class, instance_methods);
}

p;12;CPMenuItem.jI;20;Foundation/CPCoder.jI;21;Foundation/CPObject.jI;21;Foundation/CPString.jI;16;AppKit/CPImage.jI;15;AppKit/CPMenu.jI;15;AppKit/CPView.jc;11139;


{var the_class = objj_allocateClassPair(CPObject, "CPMenuItem"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_title"), new objj_ivar("_target"), new objj_ivar("_action"), new objj_ivar("_isEnabled"), new objj_ivar("_isHidden"), new objj_ivar("_tag"), new objj_ivar("_state"), new objj_ivar("_image"), new objj_ivar("_onStateImage"), new objj_ivar("_offStateImage"), new objj_ivar("_mixedStateImage"), new objj_ivar("_submenu"), new objj_ivar("_menu"), new objj_ivar("_keyEquivalent"), new objj_ivar("_keyEquivalentModifierMask"), new objj_ivar("_mnemonicLocation"), new objj_ivar("_isAlternate"), new objj_ivar("_indentationLevel"), new objj_ivar("_toolTip"), new objj_ivar("_representedObject"), new objj_ivar("_view"), new objj_ivar("_isHighlighted"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithTitle:action:keyEquivalent:"), function(self, _cmd, aTitle, anAction, aKeyEquivalent)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
    {
        _title = aTitle;
        _action = anAction;

        _isEnabled = YES;

        _keyEquivalent = aKeyEquivalent;
        _keyEquivalentModifierMask = CPPlatformActionKeyMask;

        _mnemonicLocation = CPNotFound;
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setEnabled:"), function(self, _cmd, isEnabled)
{ with(self)
{
    if (objj_msgSend(_menu, "autoenablesItems"))
        return;

    _isEnabled = isEnabled;
}
});
instance_methods[2] = new objj_method(sel_registerName("isEnabled"), function(self, _cmd)
{ with(self)
{
    return _isEnabled;
}
});
instance_methods[3] = new objj_method(sel_registerName("setHidden:"), function(self, _cmd, isHidden)
{ with(self)
{
    _isHidden = isHidden;
}
});
instance_methods[4] = new objj_method(sel_registerName("isHidden"), function(self, _cmd)
{ with(self)
{
    return _isHidden;
}
});
instance_methods[5] = new objj_method(sel_registerName("isHiddenOrHasHiddenAncestor"), function(self, _cmd)
{ with(self)
{
    if (_isHidden)
        return YES;

    if (objj_msgSend(objj_msgSend(objj_msgSend(_menu, "supermenu"), "indexOfItemWithSubmenu:", self), "isHiddenOrHasHiddenAncestor"))
        return YES;

    return NO;
}
});
instance_methods[6] = new objj_method(sel_registerName("setTarget:"), function(self, _cmd, aTarget)
{ with(self)
{
    _target = aTarget;
}
});
instance_methods[7] = new objj_method(sel_registerName("target"), function(self, _cmd)
{ with(self)
{
    return _target;
}
});
instance_methods[8] = new objj_method(sel_registerName("setAction:"), function(self, _cmd, anAction)
{ with(self)
{
    _action = anAction;
}
});
instance_methods[9] = new objj_method(sel_registerName("action"), function(self, _cmd)
{ with(self)
{
    return _action;
}
});
instance_methods[10] = new objj_method(sel_registerName("setTitle:"), function(self, _cmd, aTitle)
{ with(self)
{
    _mnemonicLocation = CPNotFound;

    if (_title == aTitle)
        return;

    _title = aTitle;
    objj_msgSend(_menu, "itemChanged:", self);
}
});
instance_methods[11] = new objj_method(sel_registerName("title"), function(self, _cmd)
{ with(self)
{
    return _title;
}
});
instance_methods[12] = new objj_method(sel_registerName("setTag:"), function(self, _cmd, aTag)
{ with(self)
{
    _tag = aTag;
}
});
instance_methods[13] = new objj_method(sel_registerName("tag"), function(self, _cmd)
{ with(self)
{
    return _tag;
}
});
instance_methods[14] = new objj_method(sel_registerName("setState:"), function(self, _cmd, aState)
{ with(self)
{
    if (_state == aState)
        return;
    _state = aState;
    objj_msgSend(_menu, "itemChanged:", self);
}
});
instance_methods[15] = new objj_method(sel_registerName("state"), function(self, _cmd)
{ with(self)
{
    return _state;
}
});
instance_methods[16] = new objj_method(sel_registerName("setImage:"), function(self, _cmd, anImage)
{ with(self)
{
    if (_image == anImage)
        return;
    _image = anImage;
    objj_msgSend(_menu, "itemChanged:", self);
}
});
instance_methods[17] = new objj_method(sel_registerName("image"), function(self, _cmd)
{ with(self)
{
    return _image;
}
});
instance_methods[18] = new objj_method(sel_registerName("setOnStateImage:"), function(self, _cmd, anImage)
{ with(self)
{
    if (_onStateImage == anImage)
        return;
    _onStateImage = anImage;
    objj_msgSend(_menu, "itemChanged:", self);
}
});
instance_methods[19] = new objj_method(sel_registerName("onStateImage"), function(self, _cmd)
{ with(self)
{
    return _onStateImage;
}
});
instance_methods[20] = new objj_method(sel_registerName("setOffStateImage:"), function(self, _cmd, anImage)
{ with(self)
{
    if (_offStateImage == anImage)
        return;
    _offStateImage = anImage;
    objj_msgSend(_menu, "itemChanged:", self);
}
});
instance_methods[21] = new objj_method(sel_registerName("offStateImage"), function(self, _cmd)
{ with(self)
{
    return _offStateImage;
}
});
instance_methods[22] = new objj_method(sel_registerName("setMixedStateImage:"), function(self, _cmd, anImage)
{ with(self)
{
    if (_mixedStateImage == anImage)
        return;
    _mixedStateImage = anImage;
    objj_msgSend(_menu, "itemChanged:", self);
}
});
instance_methods[23] = new objj_method(sel_registerName("mixedStateImage"), function(self, _cmd)
{ with(self)
{
    return _mixedStateImage;
}
});
instance_methods[24] = new objj_method(sel_registerName("setSubmenu:"), function(self, _cmd, aMenu)
{ with(self)
{
    var supermenu = objj_msgSend(_submenu, "supermenu");
    if (supermenu == self)
        return;
    if (supermenu)
        return alert("bad");
    objj_msgSend(_submenu, "setSupermenu:", _menu);
    _submenu = aMenu;
}
});
instance_methods[25] = new objj_method(sel_registerName("submenu"), function(self, _cmd)
{ with(self)
{
    return _submenu;
}
});
instance_methods[26] = new objj_method(sel_registerName("hasSubmenu"), function(self, _cmd)
{ with(self)
{
    return _submenu ? YES : NO;
}
});
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("separatorItem"), function(self, _cmd)
{ with(self)
{
    var item = objj_msgSend(objj_msgSend(self, "alloc"), "initWithTitle:action:keyEquivalent:", " ", NULL, "");
    objj_msgSend(item, "setEnabled:", NO);
    return item;
}
});
instance_methods[27] = new objj_method(sel_registerName("isSeparatorItem"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(item, "title") == "";
}
});
instance_methods[28] = new objj_method(sel_registerName("setMenu:"), function(self, _cmd, aMenu)
{ with(self)
{
    _menu = aMenu;
}
});
instance_methods[29] = new objj_method(sel_registerName("menu"), function(self, _cmd)
{ with(self)
{
    return _menu;
}
});
instance_methods[30] = new objj_method(sel_registerName("setKeyEquivalent:"), function(self, _cmd, aString)
{ with(self)
{
    _keyEquivalent = aString;
}
});
instance_methods[31] = new objj_method(sel_registerName("keyEquivalent"), function(self, _cmd)
{ with(self)
{
    return _keyEquivalent;
}
});
instance_methods[32] = new objj_method(sel_registerName("setKeyEquivalentModifierMask:"), function(self, _cmd, aMask)
{ with(self)
{
    _keyEquivalentModifierMask = aMask;
}
});
instance_methods[33] = new objj_method(sel_registerName("keyEquivalentModifierMask"), function(self, _cmd)
{ with(self)
{
    return _keyEquivalentModifierMask;
}
});
instance_methods[34] = new objj_method(sel_registerName("setMnemonicLocation:"), function(self, _cmd, aLocation)
{ with(self)
{
    _mnemonicLocation = aLocation;
}
});
instance_methods[35] = new objj_method(sel_registerName("mnemonicLocation"), function(self, _cmd)
{ with(self)
{
    return _mnemonicLocation;
}
});
instance_methods[36] = new objj_method(sel_registerName("setTitleWithMnemonicLocation:"), function(self, _cmd, aTitle)
{ with(self)
{
    var location = objj_msgSend(aTitle, "rangeOfString:", "&").location;
    if (location == CPNotFound)
        objj_msgSend(self, "setTitle:", aTitle);
    else
    {
        objj_msgSend(self, "setTitle:", objj_msgSend(aTitle, "substringToIndex:", location)+objj_msgSend(aTitle, "substringFromIndex:", location+1));
        objj_msgSend(self, "setMnemonicLocation:", location);
    }
}
});
instance_methods[37] = new objj_method(sel_registerName("mnemonic"), function(self, _cmd)
{ with(self)
{
    return _mnemonicLocation == CPNotFound ? "" : objj_msgSend(_title, "characterAtIndex:", _mnemonicLocation);
}
});
instance_methods[38] = new objj_method(sel_registerName("setAlternate:"), function(self, _cmd, isAlternate)
{ with(self)
{
    _isAlternate = isAlternate;
}
});
instance_methods[39] = new objj_method(sel_registerName("isAlternate"), function(self, _cmd)
{ with(self)
{
    return _isAlternate;
}
});
instance_methods[40] = new objj_method(sel_registerName("setIndentationLevel:"), function(self, _cmd, aLevel)
{ with(self)
{
    if (aLevel < 0)
        alert("bad");
    _indentationLevel = MIN(15, aLevel);
}
});
instance_methods[41] = new objj_method(sel_registerName("indentationLevel"), function(self, _cmd)
{ with(self)
{
    return _indentationLevel;
}
});
instance_methods[42] = new objj_method(sel_registerName("setToolTip:"), function(self, _cmd, aToolTip)
{ with(self)
{
    _toolTip = aToolTip;
}
});
instance_methods[43] = new objj_method(sel_registerName("toolTip"), function(self, _cmd)
{ with(self)
{
    return _toolTip;
}
});
instance_methods[44] = new objj_method(sel_registerName("setRepresentedObject:"), function(self, _cmd, anObject)
{ with(self)
{
    _representedObject = anObject;
}
});
instance_methods[45] = new objj_method(sel_registerName("representedObject"), function(self, _cmd)
{ with(self)
{
    return _representedObject;
}
});
instance_methods[46] = new objj_method(sel_registerName("setView:"), function(self, _cmd, aView)
{ with(self)
{
    _view = aView;
    objj_msgSend(_menu, "itemChanged:", self);
}
});
instance_methods[47] = new objj_method(sel_registerName("view"), function(self, _cmd)
{ with(self)
{
    return _view;
}
});
instance_methods[48] = new objj_method(sel_registerName("isHighlighted"), function(self, _cmd)
{ with(self)
{
    return _isHighlighted;
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}
{
var the_class = objj_getClass("CPMenuItem")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPMenuItem\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    alert("implement initWithCoder for CPMenuItem.");
}
});
instance_methods[1] = new objj_method(sel_registerName("encodeWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    alert("implement encodeWithCoder for CPMenuItem.");
}
});
class_addMethods(the_class, instance_methods);
}

p;15;CPOutlineView.ji;13;CPTableView.jc;2420;

{var the_class = objj_allocateClassPair(CPTableView, "CPOutlineView"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_outlineDataSource"), new objj_ivar("_itemsByRow"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPTableView") }, "initWithFrame:", aFrame);

    if (self)
    {
        objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPTableView") }, "setDataSource:", self);
        _itemsByRow = objj_msgSend(objj_msgSend(CPArray, "alloc"), "init");
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setDataSource:"), function(self, _cmd, aDataSource)
{ with(self)
{
    _outlineDataSource = aDataSource;

    objj_msgSend(self, "reloadData");
}
});
instance_methods[2] = new objj_method(sel_registerName("reloadData"), function(self, _cmd)
{ with(self)
{
    _numberOfVisibleItems = objj_msgSend(_outlineDataSource, "outlineView:numberOfChildrenOfItem:", self, nil);
    _numberOfRows = _numberOfVisibleItems;

    var i = 0;

    for (; i < _numberOfVisibleItems; ++i)
        _itemsByRow[i] = objj_msgSend(_outlineDataSource, "outlineView:child:ofItem:", self, i, nil);

    objj_msgSend(self, "loadTableCellsInRect:", objj_msgSend(self, "bounds"));
}
});
class_addMethods(the_class, instance_methods);
}

{
var the_class = objj_getClass("CPOutlineView")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPOutlineView\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("numberOfRowsInTableView:"), function(self, _cmd, aTableView)
{ with(self)
{
    return _numberOfVisibleItems;
}
});
instance_methods[1] = new objj_method(sel_registerName("tableView:objectValueForTableColumn:row:"), function(self, _cmd, aTableView, aTableColumn, aRowIndex)
{ with(self)
{
    return objj_msgSend(_outlineDataSource, "outlineView:objectValueForTableColumn:byItem:", self, aTableColumn, _itemsByRow[aRowIndex]);
}
});
class_addMethods(the_class, instance_methods);
}

p;9;CPPanel.jI;17;AppKit/CPWindow.jc;1304;


CPOKButton = 1;
CPCancelButton = 0;

{var the_class = objj_allocateClassPair(CPWindow, "CPPanel"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_becomesKeyOnlyIfNeeded"), new objj_ivar("_worksWhenModal"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("becomesKeyOnlyIfNeeded"), function(self, _cmd)
{ with(self)
{
    return _becomesKeyOnlyIfNeeded;
}
});
instance_methods[1] = new objj_method(sel_registerName("setBecomesKeyOnlyIfNeeded:"), function(self, _cmd, shouldBecomeKeyOnlyIfNeeded)
{ with(self)
{
    _becomesKeyOnlyIfNeeded = shouldBecomeKeyOnlyIfNeeded
}
});
instance_methods[2] = new objj_method(sel_registerName("worksWhenModal"), function(self, _cmd)
{ with(self)
{
    return _worksWhenModal;
}
});
instance_methods[3] = new objj_method(sel_registerName("setWorksWhenModal:"), function(self, _cmd, shouldWorkWhenModal)
{ with(self)
{
    _worksWhenModal = shouldWorkWhenModal;
}
});
instance_methods[4] = new objj_method(sel_registerName("canBecomeMainWindow"), function(self, _cmd)
{ with(self)
{
    return NO;
}
});
class_addMethods(the_class, instance_methods);
}

p;14;CPPasteboard.jI;21;Foundation/CPObject.jI;20;Foundation/CPArray.jI;25;Foundation/CPDictionary.jI;40;Foundation/CPPropertyListSerialization.jc;6118;


CPGeneralPboard = "CPGeneralPboard";
CPFontPboard = "CPFontPboard";
CPRulerPboard = "CPRulerPboard";
CPFindPboard = "CPFindPboard";
CPDragPboard = "CPDragPboard";

CPColorPboardType = "CPColorPboardType";
CPFilenamesPboardType = "CPFilenamesPboardType";
CPFontPboardType = "CPFontPboardType";
CPHTMLPboardType = "CPHTMLPboardType";
CPStringPboardType = "CPStringPboardType";
CPURLPboardType = "CPURLPboardType";
CPImagePboardType = "CPImagePboardType";

var CPPasteboards = nil;

{var the_class = objj_allocateClassPair(CPObject, "CPPasteboard"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_types"), new objj_ivar("_owners"), new objj_ivar("_provided"), new objj_ivar("_changeCount"), new objj_ivar("_stateUID"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("initialize"), function(self, _cmd)
{ with(self)
{
    if (self != objj_msgSend(CPPasteboard, "class"))
        return;

    objj_msgSend(self, "setVersion:", 1.0);

    CPPasteboards = objj_msgSend(CPDictionary, "dictionary");
}
});
class_methods[1] = new objj_method(sel_registerName("generalPasteboard"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(CPPasteboard, "pasteboardWithName:", CPGeneralPboard);
}
});
class_methods[2] = new objj_method(sel_registerName("pasteboardWithName:"), function(self, _cmd, aName)
{ with(self)
{
    var pasteboard = objj_msgSend(CPPasteboards, "objectForKey:", aName);

    if (pasteboard)
        return pasteboard;

    pasteboard = objj_msgSend(objj_msgSend(CPPasteboard, "alloc"), "_initWithName:", aName);
    objj_msgSend(CPPasteboards, "setObject:forKey:", pasteboard, aName);

    return pasteboard;
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("_initWithName:"), function(self, _cmd, aName)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
    {
        _name = aName;
        _types = [];

        _owners = objj_msgSend(CPDictionary, "dictionary");
        _provided = objj_msgSend(CPDictionary, "dictionary");

        _changeCount = 0;
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("addTypes:owner:"), function(self, _cmd, types, anOwner)
{ with(self)
{
    var i = 0,
        count = types.length;

    for (; i < count; ++i)
    {
        var type = types[i];

        if(!objj_msgSend(_owners, "objectForKey:", type))
        {
            objj_msgSend(_types, "addObject:", type);
            objj_msgSend(_provided, "removeObjectForKey:", type);
        }

        objj_msgSend(_owners, "setObject:forKey:", anOwner, type);
    }

    return ++_changeCount;
}
});
instance_methods[2] = new objj_method(sel_registerName("declareTypes:owner:"), function(self, _cmd, types, anOwner)
{ with(self)
{
    objj_msgSend(_types, "setArray:", types);

    _owners = objj_msgSend(CPDictionary, "dictionary");
    _provided = objj_msgSend(CPDictionary, "dictionary");

    var count = _types.length;

    while (count--)
        objj_msgSend(_owners, "setObject:forKey:", anOwner, _types[count]);

    return ++_changeCount;
}
});
instance_methods[3] = new objj_method(sel_registerName("setData:forType:"), function(self, _cmd, aData, aType)
{ with(self)
{
    objj_msgSend(_provided, "setObject:forKey:", aData, aType);

    return YES;
}
});
instance_methods[4] = new objj_method(sel_registerName("setPropertyList:forType:"), function(self, _cmd, aPropertyList, aType)
{ with(self)
{
    return objj_msgSend(self, "setData:forType:", objj_msgSend(CPPropertyListSerialization, "dataFromPropertyList:format:errorDescription:", aPropertyList, CPPropertyListXMLFormat_v1_0, nil), aType);
}
});
instance_methods[5] = new objj_method(sel_registerName("setString:forType:"), function(self, _cmd, aString, aType)
{ with(self)
{
    return objj_msgSend(self, "setPropertyList:forType:", aString, aType);
}
});
instance_methods[6] = new objj_method(sel_registerName("availableTypeFromArray:"), function(self, _cmd, anArray)
{ with(self)
{
    return objj_msgSend(_types, "firstObjectCommonWithArray:", anArray);
}
});
instance_methods[7] = new objj_method(sel_registerName("types"), function(self, _cmd)
{ with(self)
{
    return _types;
}
});
instance_methods[8] = new objj_method(sel_registerName("changeCount"), function(self, _cmd)
{ with(self)
{
    return _changeCount;
}
});
instance_methods[9] = new objj_method(sel_registerName("dataForType:"), function(self, _cmd, aType)
{ with(self)
{
    var data = objj_msgSend(_provided, "objectForKey:", aType);

    if (data)
        return data;

    var owner = objj_msgSend(_owners, "objectForKey:", aType);

    if (owner)
    {
        objj_msgSend(owner, "pasteboard:provideDataForType:", self, aType);

        ++_changeCount;

        return objj_msgSend(_provided, "objectForKey:", aType);
    }

    return nil;
}
});
instance_methods[10] = new objj_method(sel_registerName("propertyListForType:"), function(self, _cmd, aType)
{ with(self)
{
    var data = objj_msgSend(self, "dataForType:", aType);

    if (data)
        return objj_msgSend(CPPropertyListSerialization, "propertyListFromData:format:errorDescription:", data, CPPropertyListXMLFormat_v1_0, nil);

    return nil;
}
});
instance_methods[11] = new objj_method(sel_registerName("stringForType:"), function(self, _cmd, aType)
{ with(self)
{
    return objj_msgSend(self, "propertyListForType:", aType);
}
});
instance_methods[12] = new objj_method(sel_registerName("_generateStateUID"), function(self, _cmd)
{ with(self)
{
    var bits = 32;

    _stateUID = "";

    while (bits--)
        _stateUID += FLOOR(RAND() * 16.0).toString(16).toUpperCase();

    return _stateUID;
}
});
instance_methods[13] = new objj_method(sel_registerName("_stateUID"), function(self, _cmd)
{ with(self)
{
    return _stateUID;
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

p;15;CPPopupButton.jI;21;Foundation/CPObject.jI;21;Foundation/CPString.jI;20;Foundation/CPArray.jI;22;Foundation/CPRunLoop.ji;11;CPControl.jc;2;;
i;13;CPTextField.ji;8;CPView.jc;7191;


{var the_class = objj_allocateClassPair(CPControl, "CPPopupButton"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_FIXME_popup"), new objj_ivar("_displayString"), new objj_ivar("_options"), new objj_ivar("_selectedItem"), new objj_ivar("_target"), new objj_ivar("_action"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "initWithFrame:", aFrame);

    _FIXME_popup = document.createElement("select");

    _FIXME_popup.style.position = "absolute";
    _FIXME_popup.style.top = "0px";
    _FIXME_popup.style.left = "0px";
    _FIXME_popup.style.opacity = "0";
    _FIXME_popup.style.filter = "alpha(opacity=0)";
    _FIXME_popup.style.zIndex = 1000;
    _FIXME_popup.style.height = CGRectGetHeight(aFrame) + "px";

    var eventBridge = function(anEvent)
    {
        _FIXME_popup.blur();
        objj_msgSend(self, "selectItemAtIndex:", _FIXME_popup.selectedIndex);

    objj_msgSend(CPApp, "sendAction:to:from:", _action, _target, self);
        objj_msgSend(objj_msgSend(CPRunLoop, "currentRunLoop"), "performSelectors");
    }

    _selectedItem = null;

    _displayString = objj_msgSend(objj_msgSend(CPTextField, "alloc"), "initWithFrame:", CGRectMake(2,-2,0.0,0.0));

    objj_msgSend(_displayString, "setFont:", objj_msgSend(CPFont, "systemFontOfSize:", 10.0));
    objj_msgSend(_displayString, "setStringValue:", "Font");
    objj_msgSend(_displayString, "sizeToFit");
    objj_msgSend(_displayString, "setFrameSize:", CGSizeMake(CGRectGetWidth(objj_msgSend(self, "bounds"))-12.0,CGRectGetHeight(objj_msgSend(_displayString, "frame"))));
    objj_msgSend(_displayString, "setLineBreakMode:", CPLineBreakByTruncatingTail);

    objj_msgSend(self, "addSubview:", _displayString);

    if(document.addEventListener)
        _FIXME_popup.addEventListener("change", eventBridge, NO);
    else
        _FIXME_popup.attachEvent("onchange", eventBridge);

    _DOMElement.appendChild(_FIXME_popup);

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setTarget:"), function(self, _cmd, anObject)
{ with(self)
{
    _target = anObject;
}
});
instance_methods[2] = new objj_method(sel_registerName("setAction:"), function(self, _cmd, anObject)
{ with(self)
{
    _action = anObject;
}
});
instance_methods[3] = new objj_method(sel_registerName("action"), function(self, _cmd)
{ with(self)
{
    return _action;
}
});
instance_methods[4] = new objj_method(sel_registerName("selectionDidChange"), function(self, _cmd)
{ with(self)
{
    var selectedIndex = _FIXME_popup.selectedIndex;

    _selectedItem = _options[selectedIndex];
    objj_msgSend(_displayString, "setStringValue:", objj_msgSend(_selectedItem, "name"));
}
});
instance_methods[5] = new objj_method(sel_registerName("setSelectedItem:"), function(self, _cmd, item)
{ with(self)
{
    _FIXME_popup.selectedIndex = objj_msgSend(_options, "indexOfObject:", item);
    objj_msgSend(self, "selectionDidChange");
}
});
instance_methods[6] = new objj_method(sel_registerName("indexOfItemWithTitle:"), function(self, _cmd, aTitle)
{ with(self)
{
    var index = 0,
        count = _options.length;

    for (; index < count; ++index)
        if (objj_msgSend(_options[index], "name") == aTitle)
            return index;

    return CPNotFound;
}
});
instance_methods[7] = new objj_method(sel_registerName("indexOfItemWithRepresentedObject:"), function(self, _cmd, anObject)
{ with(self)
{
    var index = 0,
        count = _options.length;

    for (; index < count; ++index)
        if (objj_msgSend(_options[index], "value") == anObject)
            return index;

    return CPNotFound;
}
});
instance_methods[8] = new objj_method(sel_registerName("removeItemAtIndex:"), function(self, _cmd, anIndex)
{ with(self)
{
    _FIXME_popup.options[anIndex] = NULL;

    objj_msgSend(_options, "removeObjectAtIndex:", anIndex);
}
});
instance_methods[9] = new objj_method(sel_registerName("insertItemWithTitle:atIndex:"), function(self, _cmd, aTitle, anIndex)
{ with(self)
{
    var item = objj_msgSend(objj_msgSend(CPPopupButtonItem, "alloc"), "initWithName:value:", aTitle, nil);

    if(_FIXME_popup.options.add)
        _FIXME_popup.options.add(objj_msgSend(item, "htmlObject"), anIndex);
    else if(_FIXME_popup.add)
        _FIXME_popup.add(objj_msgSend(item, "htmlObject"), anIndex);

    objj_msgSend(_options, "insertObject:atIndex:", objj_msgSend(objj_msgSend(CPPopupButtonItem, "alloc"), "initWithName:value:", aTitle, nil), anIndex);
}
});
instance_methods[10] = new objj_method(sel_registerName("selectedItem"), function(self, _cmd)
{ with(self)
{
    return _selectedItem;
}
});
instance_methods[11] = new objj_method(sel_registerName("titleOfItemAtIndex:"), function(self, _cmd, anIndex)
{ with(self)
{
    return objj_msgSend(_options[anIndex], "name");
}
});
instance_methods[12] = new objj_method(sel_registerName("selectItemAtIndex:"), function(self, _cmd, anIndex)
{ with(self)
{
    _FIXME_popup.selectedIndex = anIndex;
    objj_msgSend(self, "selectionDidChange");
}
});
instance_methods[13] = new objj_method(sel_registerName("setOptions:"), function(self, _cmd, options)
{ with(self)
{
    for(var i=0; i<options.length; i++)
    {
        if(_FIXME_popup.options.add)
            _FIXME_popup.options.add(objj_msgSend(options[i], "htmlObject"));
        else if(_FIXME_popup.add)
            _FIXME_popup.add(objj_msgSend(options[i], "htmlObject"));
    }

    _selectedItem = options[0];
    _FIXME_popup.selectedIndex = 0;

    _options = options;
}
});
instance_methods[14] = new objj_method(sel_registerName("options"), function(self, _cmd)
{ with(self)
{
    return _options;
}
});
class_addMethods(the_class, instance_methods);
}

{var the_class = objj_allocateClassPair(CPObject, "CPPopupButtonItem"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_name"), new objj_ivar("_value"), new objj_ivar("_option"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithName:value:"), function(self, _cmd, name, value)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    _name = name;
    _value = value;

    _option = document.createElement("option");
    _option.text = name;


    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("name"), function(self, _cmd)
{ with(self)
{
    return _name;
}
});
instance_methods[2] = new objj_method(sel_registerName("value"), function(self, _cmd)
{ with(self)
{
    return _value;
}
});
instance_methods[3] = new objj_method(sel_registerName("htmlObject"), function(self, _cmd)
{ with(self)
{
    return _option;
}
});
class_addMethods(the_class, instance_methods);
}

p;21;CPProgressIndicator.jI;19;AppKit/CGGeometry.jI;20;AppKit/CPImageView.jI;15;AppKit/CPView.jc;15620;




CPProgressIndicatorBarStyle = 0;
CPProgressIndicatorSpinningStyle = 1;
CPProgressIndicatorHUDBarStyle = 2;

var CPProgressIndicatorSpinningStyleImages = nil,
    CPProgressIndicatorBezelBorderViewPool = nil;

{var the_class = objj_allocateClassPair(CPView, "CPProgressIndicator"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_minValue"), new objj_ivar("_maxValue"), new objj_ivar("_doubleValue"), new objj_ivar("_controlSize"), new objj_ivar("_isIndeterminate"), new objj_ivar("_style"), new objj_ivar("_isAnimating"), new objj_ivar("_isDisplayedWhenStoppedSet"), new objj_ivar("_isDisplayedWhenStopped"), new objj_ivar("_bezelBorderNeedsUpdate"), new objj_ivar("_bezelBorderView"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("initialize"), function(self, _cmd)
{ with(self)
{
    if (self != objj_msgSend(CPProgressIndicator, "class"))
        return;

    var bundle = objj_msgSend(CPBundle, "bundleForClass:", self);

    CPProgressIndicatorSpinningStyleImages = [];

    CPProgressIndicatorSpinningStyleImages[CPMiniControlSize] = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPProgressIndicator/CPProgressIndicatorSpinningStyleRegular.gif"), CGSizeMake(64.0,64.0));
    CPProgressIndicatorSpinningStyleImages[CPSmallControlSize] = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPProgressIndicator/CPProgressIndicatorSpinningStyleRegular.gif"), CGSizeMake(64.0,64.0));
    CPProgressIndicatorSpinningStyleImages[CPRegularControlSize] = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPProgressIndicator/CPProgressIndicatorSpinningStyleRegular.gif"), CGSizeMake(64.0,64.0));

    CPProgressIndicatorBezelBorderViewPool = [];

    var start = CPProgressIndicatorBarStyle,
        end = CPProgressIndicatorHUDBarStyle;

    for (; start <= end; ++start)
    {
        CPProgressIndicatorBezelBorderViewPool[start] = [];

        CPProgressIndicatorBezelBorderViewPool[start][CPMiniControlSize] = [];
        CPProgressIndicatorBezelBorderViewPool[start][CPSmallControlSize] = [];
        CPProgressIndicatorBezelBorderViewPool[start][CPRegularControlSize] = [];
    }
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "initWithFrame:", aFrame);

    if (self)
    {
        _minValue = 0.0;
        _maxValue = 100.0;

        _doubleValue = 0.0;

        _isDisplayedWhenStoppedSet = NO;

        _controlSize = CPRegularControlSize;

        objj_msgSend(self, "_updateBezelBorder");
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setUsesThreadedAnimation:"), function(self, _cmd, aFlag)
{ with(self)
{}
});
instance_methods[2] = new objj_method(sel_registerName("startAnimation:"), function(self, _cmd, aSender)
{ with(self)
{
    _isAnimating = YES;

    objj_msgSend(self, "_hideOrDisplay");
}
});
instance_methods[3] = new objj_method(sel_registerName("stopAnimation:"), function(self, _cmd, aSender)
{ with(self)
{
    _isAnimating = NO;

    objj_msgSend(self, "_hideOrDisplay");
}
});
instance_methods[4] = new objj_method(sel_registerName("usesThreadedAnimation"), function(self, _cmd)
{ with(self)
{
    return NO;
}
});
instance_methods[5] = new objj_method(sel_registerName("incrementBy:"), function(self, _cmd, aValue)
{ with(self)
{
    objj_msgSend(self, "setDoubleValue:", _doubleValue+aValue);
}
});
instance_methods[6] = new objj_method(sel_registerName("setDoubleValue:"), function(self, _cmd, aValue)
{ with(self)
{
    _doubleValue = MIN(MAX(aValue, _minValue), _maxValue);

    if (objj_msgSend(_bezelBorderView, "respondsToSelector:", sel_registerName("setProgress:")))
        objj_msgSend(_bezelBorderView, "setProgress:", (_doubleValue-_minValue)/(_maxValue-_minValue));
}
});
instance_methods[7] = new objj_method(sel_registerName("doubleValue"), function(self, _cmd)
{ with(self)
{
    return _doubleValue;
}
});
instance_methods[8] = new objj_method(sel_registerName("setMinValue:"), function(self, _cmd, aValue)
{ with(self)
{
    _minValue = aValue;
}
});
instance_methods[9] = new objj_method(sel_registerName("minValue"), function(self, _cmd)
{ with(self)
{
    return _minValue;
}
});
instance_methods[10] = new objj_method(sel_registerName("setMaxValue:"), function(self, _cmd, aValue)
{ with(self)
{
    _maxValue = aValue;
}
});
instance_methods[11] = new objj_method(sel_registerName("maxValue"), function(self, _cmd)
{ with(self)
{
    return _maxValue;
}
});
instance_methods[12] = new objj_method(sel_registerName("setControlSize:"), function(self, _cmd, aControlSize)
{ with(self)
{
    if (_controlSize == aControlSize)
        return;

    _controlSize = aControlSize;

    objj_msgSend(self, "_updateBezelBorder");
}
});
instance_methods[13] = new objj_method(sel_registerName("controlSize"), function(self, _cmd)
{ with(self)
{
    return _controlSize;
}
});
instance_methods[14] = new objj_method(sel_registerName("setControlTint:"), function(self, _cmd, aControlTint)
{ with(self)
{}
});
instance_methods[15] = new objj_method(sel_registerName("controlTint"), function(self, _cmd)
{ with(self)
{
    return 0;
}
});
instance_methods[16] = new objj_method(sel_registerName("setBezeled:"), function(self, _cmd, isBezeled)
{ with(self)
{}
});
instance_methods[17] = new objj_method(sel_registerName("isBezeled"), function(self, _cmd)
{ with(self)
{
    return YES;
}
});
instance_methods[18] = new objj_method(sel_registerName("setIndeterminate:"), function(self, _cmd, isIndeterminate)
{ with(self)
{
    if (_indeterminate == isIndeterminate)
        return;

    _isIndeterminate = isIndeterminate;

    objj_msgSend(self, "_updateBezelBorder");
}
});
instance_methods[19] = new objj_method(sel_registerName("isIndeterminate"), function(self, _cmd)
{ with(self)
{
    return _isIndeterminate;
}
});
instance_methods[20] = new objj_method(sel_registerName("setStyle:"), function(self, _cmd, aStyle)
{ with(self)
{
    if (_style == aStyle)
        return;

    _style = aStyle;

    objj_msgSend(self, "_updateBezelBorder");
}
});
instance_methods[21] = new objj_method(sel_registerName("sizeToFit"), function(self, _cmd)
{ with(self)
{
    if (_style == CPProgressIndicatorSpinningStyle)
        objj_msgSend(self, "setFrameSize:", CGSizeMakeCopy(objj_msgSend(CPProgressIndicatorSpinningStyleImages[_controlSize], "size")));
    else
        objj_msgSend(self, "setFrameSize:", CGSizeMake(CGRectGetWidth(objj_msgSend(self, "frame")),_CPProgressIndicatorBackgroundSizes[_style][_controlSize][1].height));
}
});
instance_methods[22] = new objj_method(sel_registerName("setDisplayedWhenStopped:"), function(self, _cmd, isDisplayedWhenStopped)
{ with(self)
{
    if (_isDisplayedWhenStoppedSet && _isDisplayedWhenStopped == isDisplayedWhenStopped)
        return;

    _isDisplayedWhenStoppedSet = YES;

    _isDisplayedWhenStopped = isDisplayedWhenStopped;

    objj_msgSend(self, "_hideOrDisplay");
}
});
instance_methods[23] = new objj_method(sel_registerName("isDisplayedWhenStopped"), function(self, _cmd)
{ with(self)
{
    if (_isDisplayedWhenStoppedSet)
        return _isDisplayedWhenStopped;

    if (_style == CPProgressIndicatorBarStyle)
        return YES;

    return NO;
}
});
instance_methods[24] = new objj_method(sel_registerName("setHidden:"), function(self, _cmd, isHidden)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "setHidden:", isHidden);

    if (isHidden)
    {
        objj_msgSend(_bezelBorderView, "removeFromSuperview");
        objj_msgSend(objj_msgSend(self, "class"), "_returnBezelBorderView:style:controlSize:", _bezelBorderView, _style, _controlSize);

        _bezelBorderView = nil;
    }
    else if (!_bezelBorderView)
        objj_msgSend(self, "_updateBezelBorder");
}
});
instance_methods[25] = new objj_method(sel_registerName("_hideOrDisplay"), function(self, _cmd)
{ with(self)
{
    objj_msgSend(self, "setHidden:", !_isAnimating||objj_msgSend(self, "isDisplayedWhenStopped"));
}
});
instance_methods[26] = new objj_method(sel_registerName("viewDidMoveToWindow"), function(self, _cmd)
{ with(self)
{
    if (_bezelBorderNeedsUpdate)
        objj_msgSend(self, "_updateBezelBorder");
}
});
instance_methods[27] = new objj_method(sel_registerName("_updateBezelBorder"), function(self, _cmd)
{ with(self)
{
    _bezelBorderNeedsUpdate = !objj_msgSend(self, "window") || objj_msgSend(self, "isHidden");

    if (_bezelBorderNeedsUpdate)
        return;

    objj_msgSend(_bezelBorderView, "removeFromSuperview");

    _bezelBorderView = objj_msgSend(objj_msgSend(self, "class"), "bezelBorderViewForStyle:controlSize:", _style, _controlSize);
    objj_msgSend(_bezelBorderView, "setFrameSize:", CGSizeMakeCopy(objj_msgSend(self, "bounds").size));
    objj_msgSend(_bezelBorderView, "setAutoresizingMask:", CPViewWidthSizable|CPViewMinYMargin);

    objj_msgSend(self, "insertSubview:atIndex:", _bezelBorderView, 0);
}
});
class_methods[1] = new objj_method(sel_registerName("bezelBorderViewForStyle:controlSize:"), function(self, _cmd, aStyle, aControlSize)
{ with(self)
{
    var bezelBorderView = CPProgressIndicatorBezelBorderViewPool[aStyle][aControlSize].pop();

    if (!bezelBorderView)
    {
        if (aStyle == CPProgressIndicatorSpinningStyle)
        {
            bezelBorderView = objj_msgSend(objj_msgSend(CPImageView, "alloc"), "initWithFrame:", CGRectMakeZero());

            objj_msgSend(bezelBorderView, "setImage:", CPProgressIndicatorSpinningStyleImages[aControlSize]);
        }
        else
            bezelBorderView = objj_msgSend(objj_msgSend(_CPProgressIndicatorBezelBorder, "alloc"), "initWithStyle:controlSize:isIndeterminate:", aStyle, aControlSize, NO);
    }

    return bezelBorderView;
}
});
class_methods[2] = new objj_method(sel_registerName("_returnBezelBorderView:style:controlSize:"), function(self, _cmd, aView, aStyle, aControlSize)
{ with(self)
{
    if (!aView)
        return;

    CPProgressIndicatorBezelBorderViewPool[aStyle][aControlSize].push(aView);
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

var _CPProgressIndicatorStyleNames = [],
    _CPProgressIndicatorSizeNames = [],
    _CPProgressIndicatorBackgroundSizes = [],
    _CPProgressIndicatorBarSizes = [];

CPProgressIndicatorBarStyle = 0;
CPProgressIndicatorSpinningStyle = 1;
CPProgressIndicatorHUDBarStyle = 2;

_CPProgressIndicatorStyleNames[CPProgressIndicatorBarStyle] = "Bar";
_CPProgressIndicatorStyleNames[CPProgressIndicatorHUDBarStyle] = "HUDBar";

_CPProgressIndicatorSizeNames[CPRegularControlSize] = "Regular";
_CPProgressIndicatorSizeNames[CPSmallControlSize] = "Small";
_CPProgressIndicatorSizeNames[CPMiniControlSize] = "Mini";


_CPProgressIndicatorBackgroundSizes[CPProgressIndicatorHUDBarStyle] = [];
_CPProgressIndicatorBackgroundSizes[CPProgressIndicatorHUDBarStyle][CPSmallControlSize] = [{width:3.0,height:15.0},{width:1.0,height:15.0},{width:3.0,height:15.0}];

_CPProgressIndicatorBarSizes[CPProgressIndicatorHUDBarStyle] = [];
_CPProgressIndicatorBarSizes[CPProgressIndicatorHUDBarStyle][CPSmallControlSize] = [{width:0.0,height:9.0},{width:1.0,height:9.0},{width:0.0,height:9.0}];

var _CPProgressIndicatorBackgroundImages = [],
    _CPProgressIndicatorBarImages = [];

var _CPProgressIndicatorImageMatrix = function(aStyle, aControlSize, isBackground)
{
    var imageMatrix = isBackground ? _CPProgressIndicatorBackgroundImages : _CPProgressIndicatorBarImages;

    if (!imageMatrix[aStyle])
        imageMatrix[aStyle] = [];

    imageMatrix = imageMatrix[aStyle];

    if (!imageMatrix[aControlSize])
        imageMatrix[aControlSize] = [];

    imageMatrix = imageMatrix[aControlSize];

    if (!imageMatrix[0])
    {
        var bundle = objj_msgSend(CPBundle, "bundleForClass:", objj_msgSend(CPProgressIndicator, "class")),
            pathPrefix = "CPProgressIndicator/_CPProgressIndicatorBezelBorder" + _CPProgressIndicatorStyleNames[aStyle] + _CPProgressIndicatorSizeNames[aControlSize] + (isBackground ? "" : "Bar"),
            sizes = isBackground ? _CPProgressIndicatorBackgroundSizes[aStyle][aControlSize] : _CPProgressIndicatorBarSizes[aStyle][aControlSize];

        if (!sizes)
            return [nil,nil,nil];

        imageMatrix[0] = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", pathPrefix+"Left.png"), sizes[0]);
        imageMatrix[1] = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", pathPrefix+"Center.png"), sizes[1]);
        imageMatrix[2] = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", pathPrefix+"Right.png"), sizes[2]);
    }

    return imageMatrix;
}


{var the_class = objj_allocateClassPair(CPView, "_CPProgressIndicatorBezelBorder"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_backgroundView"), new objj_ivar("_barView"), new objj_ivar("_progress"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithStyle:controlSize:isIndeterminate:"), function(self, _cmd, aStyle, aControlSize, isIndeterminate)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "initWithFrame:", CGRectMakeZero());

    if (self)
    {
        _backgroundView = objj_msgSend(objj_msgSend(CPThreePartImageView, "alloc"), "initWithFrame:", CGRectMakeZero());

        objj_msgSend(_backgroundView, "setImages:", _CPProgressIndicatorImageMatrix(aStyle,aControlSize,YES));
        objj_msgSend(_backgroundView, "setAutoresizingMask:", CPViewWidthSizable|CPViewHeightSizable);

        objj_msgSend(self, "addSubview:", _backgroundView);

        if (!isIndeterminate)
        {
            _barView = objj_msgSend(objj_msgSend(CPThreePartImageView, "alloc"), "initWithFrame:", CGRectMakeZero());

            objj_msgSend(_barView, "setImages:", _CPProgressIndicatorImageMatrix(aStyle,aControlSize,NO));
            objj_msgSend(_barView, "setFrame:", CGRectMake(1.0,2.0,0.0,9.0));

            objj_msgSend(self, "addSubview:", _barView);
        }
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setProgress:"), function(self, _cmd, aProgress)
{ with(self)
{
    _progress = aProgress;

    objj_msgSend(_barView, "setFrameSize:", CGSizeMake(CGRectGetWidth(objj_msgSend(self, "frame"))*_progress,CGRectGetHeight(objj_msgSend(_barView, "frame"))));
}
});
instance_methods[2] = new objj_method(sel_registerName("setFrameSize:"), function(self, _cmd, aSize)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "setFrameSize:", aSize);

    objj_msgSend(_barView, "setFrameSize:", CGSizeMake((CGRectGetWidth(objj_msgSend(self, "frame"))-2.0)*_progress,CGRectGetHeight(objj_msgSend(_barView, "frame"))));
}
});
class_addMethods(the_class, instance_methods);
}

p;13;CPResponder.jI;21;Foundation/CPObject.jc;6662;

CPDeleteKeyCode = 8;
CPUpArrowKeyCode = 63232;
CPDownArrowKeyCode = 63233;
CPLeftArrowKeyCode = 63234;
CPRightArrowKeyCode = 63235;

{var the_class = objj_allocateClassPair(CPObject, "CPResponder"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_nextResponder"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("acceptsFirstResponder"), function(self, _cmd)
{ with(self)
{
    return NO;
}
});
instance_methods[1] = new objj_method(sel_registerName("becomeFirstResponder"), function(self, _cmd)
{ with(self)
{
    return YES;
}
});
instance_methods[2] = new objj_method(sel_registerName("resignFirstResponder"), function(self, _cmd)
{ with(self)
{
    return YES;
}
});
instance_methods[3] = new objj_method(sel_registerName("setNextResponder:"), function(self, _cmd, aResponder)
{ with(self)
{
    _nextResponder = aResponder;
}
});
instance_methods[4] = new objj_method(sel_registerName("nextResponder"), function(self, _cmd)
{ with(self)
{
    return _nextResponder;
}
});
instance_methods[5] = new objj_method(sel_registerName("interpretKeyEvents:"), function(self, _cmd, events)
{ with(self)
{
    var event,
        index = 0;

    while(event = events[index++])
    {
        switch(objj_msgSend(event, "keyCode"))
        {
            case CPLeftArrowKeyCode: objj_msgSend(self, "moveBackward:", self);
                                        break;
            case CPRightArrowKeyCode: objj_msgSend(self, "moveForward:", self);
                                        break;
            case CPUpArrowKeyCode: objj_msgSend(self, "moveUp:", self);
                                        break;
            case CPDownArrowKeyCode: objj_msgSend(self, "moveDown:", self);
                                        break;
            case CPDeleteKeyCode: objj_msgSend(self, "deleteBackward:", self);
                                        break;
            case 3:
            case 13: objj_msgSend(self, "insertLineBreak:", self);
                                        break;
            default: objj_msgSend(self, "insertText:", objj_msgSend(event, "characters"));
        }
    }
}
});
instance_methods[6] = new objj_method(sel_registerName("mouseDown:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(_nextResponder, "performSelector:withObject:", _cmd, anEvent);
}
});
instance_methods[7] = new objj_method(sel_registerName("mouseDragged:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(_nextResponder, "performSelector:withObject:", _cmd, anEvent);
}
});
instance_methods[8] = new objj_method(sel_registerName("mouseUp:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(_nextResponder, "performSelector:withObject:", _cmd, anEvent);
}
});
instance_methods[9] = new objj_method(sel_registerName("mouseMoved:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(_nextResponder, "performSelector:withObject:", _cmd, anEvent);
}
});
instance_methods[10] = new objj_method(sel_registerName("mouseEntered:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(_nextResponder, "performSelector:withObject:", _cmd, anEvent);
}
});
instance_methods[11] = new objj_method(sel_registerName("mouseExited:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(_nextResponder, "performSelector:withObject:", _cmd, anEvent);
}
});
instance_methods[12] = new objj_method(sel_registerName("scrollWheel:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(_nextResponder, "performSelector:withObject:", _cmd, anEvent);
}
});
instance_methods[13] = new objj_method(sel_registerName("keyDown:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(_nextResponder, "performSelector:withObject:", _cmd, anEvent);
}
});
instance_methods[14] = new objj_method(sel_registerName("keyUp:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(_nextResponder, "performSelector:withObject:", _cmd, anEvent);
}
});
instance_methods[15] = new objj_method(sel_registerName("performKeyEquivalent:"), function(self, _cmd, anEvent)
{ with(self)
{
    return NO;
}
});
instance_methods[16] = new objj_method(sel_registerName("deleteBackward:"), function(self, _cmd, aSender)
{ with(self)
{}
});
instance_methods[17] = new objj_method(sel_registerName("insertLineBreak:"), function(self, _cmd, aSender)
{ with(self)
{}
});
instance_methods[18] = new objj_method(sel_registerName("insertText:"), function(self, _cmd, aString)
{ with(self)
{}
});
instance_methods[19] = new objj_method(sel_registerName("doCommandBySelector:"), function(self, _cmd, aSelector)
{ with(self)
{
    if(objj_msgSend(self, "respondsToSelector:", aSelector))
        objj_msgSend(self, "performSelector:", aSelector);
    else
        objj_msgSend(_nextResponder, "doCommandBySelector:", aSelector);
}
});
instance_methods[20] = new objj_method(sel_registerName("tryToPerform:with:"), function(self, _cmd, aSelector, anObject)
{ with(self)
{
    if(objj_msgSend(self, "respondsToSelector:", aSelector))
    {
        objj_msgSend(self, "performSelector:withObject:", aSelector, anObject);

        return YES;
    }

    return objj_msgSend(_nextResponder, "tryToPerform:with:", aSelector, anObject);
}
});
instance_methods[21] = new objj_method(sel_registerName("undoManager"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(_nextResponder, "performSelector:", _cmd);
}
});
instance_methods[22] = new objj_method(sel_registerName("noResponderFor:"), function(self, _cmd, anEventSelector)
{ with(self)
{}
});
class_addMethods(the_class, instance_methods);
}

var CPResponderNextResponderKey = "CPResponderNextResponderKey";

{
var the_class = objj_getClass("CPResponder")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPResponder\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    self = objj_msgSend(self, "init");

    if (self)
        _nextResponder = objj_msgSend(aCoder, "decodeObjectForKey:", CPResponderNextResponderKey);

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("encodeWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    objj_msgSend(aCoder, "encodeConditionalObject:forKey:", _nextResponder, CPResponderNextResponderKey);
}
});
class_addMethods(the_class, instance_methods);
}

p;14;CPScrollView.ji;8;CPView.ji;12;CPClipView.ji;12;CPScroller.jc;17917;




{var the_class = objj_allocateClassPair(CPView, "CPScrollView"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_contentView"), new objj_ivar("_hasVerticalScroller"), new objj_ivar("_hasHorizontalScroller"), new objj_ivar("_autohidesScrollers"), new objj_ivar("_verticalScroller"), new objj_ivar("_horizontalScroller"), new objj_ivar("_recursionCount"), new objj_ivar("_verticalLineScroll"), new objj_ivar("_verticalPageScroll"), new objj_ivar("_horizontalLineScroll"), new objj_ivar("_horizontalPageScroll"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "initWithFrame:", aFrame);

    if (self)
    {
        _verticalLineScroll = 10.0;
        _verticalPageScroll = 10.0;

        _horizontalLineScroll = 10.0;
        _horizontalPageScroll = 10.0;

        _contentView = objj_msgSend(objj_msgSend(CPClipView, "alloc"), "initWithFrame:", objj_msgSend(self, "bounds"));

        objj_msgSend(self, "addSubview:", _contentView);

        objj_msgSend(self, "setHasVerticalScroller:", YES);
        objj_msgSend(self, "setHasHorizontalScroller:", YES);
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("contentSize"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(_contentView, "frame").size;
}
});
instance_methods[2] = new objj_method(sel_registerName("documentView"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(_contentView, "documentView");
}
});
instance_methods[3] = new objj_method(sel_registerName("setContentView:"), function(self, _cmd, aContentView)
{ with(self)
{
    if (!aContentView)
        return;

    var documentView = objj_msgSend(aContentView, "documentView");

    if (documentView)
        objj_msgSend(documentView, "removeFromSuperview");

    objj_msgSend(_contentView, "removeFromSuperview");

    var size = objj_msgSend(self, "contentSize");

    _contentView = aContentView;

    objj_msgSend(_contentView, "setFrame:", CGRectMake(0.0,0.0,size.width,size.height));
    objj_msgSend(_contentView, "setDocumentView:", documentView);

    objj_msgSend(self, "addSubview:", _contentView);
}
});
instance_methods[4] = new objj_method(sel_registerName("contentView"), function(self, _cmd)
{ with(self)
{
    return _contentView;
}
});
instance_methods[5] = new objj_method(sel_registerName("setDocumentView:"), function(self, _cmd, aView)
{ with(self)
{
   objj_msgSend(_contentView, "setDocumentView:", aView);
   objj_msgSend(self, "reflectScrolledClipView:", _contentView);
}
});
instance_methods[6] = new objj_method(sel_registerName("reflectScrolledClipView:"), function(self, _cmd, aClipView)
{ with(self)
{
    if(_contentView != aClipView)
        return;

    if (_recursionCount > 5)
        return;

    ++_recursionCount;

    var documentView = objj_msgSend(self, "documentView");

    if (!documentView)
    {
        if (_autohidesScrollers)
        {
            objj_msgSend(_verticalScroller, "setHidden:", YES);
            objj_msgSend(_horizontalScroller, "setHidden:", YES);
        }
        else
        {
            objj_msgSend(_verticalScroller, "setEnabled:", NO);
            objj_msgSend(_horizontalScroller, "setEnabled:", NO);
        }

        objj_msgSend(_contentView, "setFrame:", objj_msgSend(self, "bounds"));

        --_recursionCount;

        return;
    }

    var documentFrame = objj_msgSend(documentView, "frame"),
        contentViewFrame = CPRectCreateCopy(objj_msgSend(self, "bounds")),
        difference = CPSizeMake(CPRectGetWidth(documentFrame) - CPRectGetWidth(contentViewFrame), CPRectGetHeight(documentFrame) - CPRectGetHeight(contentViewFrame)),
        shouldShowVerticalScroller = (!_autohidesScrollers || difference.height > 0.0) && _hasVerticalScroller,
        shouldShowHorizontalScroller = (!_autohidesScrollers || difference.width > 0.0) && _hasHorizontalScroller,
        wasShowingVerticalScroller = !objj_msgSend(_verticalScroller, "isHidden"),
        wasShowingHorizontalScroller = !objj_msgSend(_horizontalScroller, "isHidden"),
        verticalScrollerWidth = objj_msgSend(CPScroller, "scrollerWidthForControlSize:", objj_msgSend(_verticalScroller, "controlSize")),
        horizontalScrollerHeight = objj_msgSend(CPScroller, "scrollerWidthForControlSize:", objj_msgSend(_horizontalScroller, "controlSize"));

    if (_autohidesScrollers)
    {
        if (shouldShowVerticalScroller)
            shouldShowHorizontalScroller = (!_autohidesScrollers || difference.width > -verticalScrollerWidth) && _hasHorizontalScroller;
        if (shouldShowHorizontalScroller)
            shouldShowVerticalScroller = (!_autohidesScrollers || difference.height > -horizontalScrollerHeight) && _hasVerticalScroller;
    }

    objj_msgSend(_verticalScroller, "setHidden:", !shouldShowVerticalScroller);
    objj_msgSend(_verticalScroller, "setEnabled:", !_autohidesScrollers&&difference.height<0);

    objj_msgSend(_horizontalScroller, "setHidden:", !shouldShowHorizontalScroller);
    objj_msgSend(_horizontalScroller, "setEnabled:", !_autohidesScrollers&&difference.width<0);

    if (shouldShowVerticalScroller)
    {
        var verticalScrollerHeight = CPRectGetHeight(contentViewFrame);

        if (shouldShowHorizontalScroller)
            verticalScrollerHeight -= horizontalScrollerHeight;

        difference.width += verticalScrollerWidth;
        contentViewFrame.size.width -= verticalScrollerWidth;

        objj_msgSend(_verticalScroller, "setFloatValue:knobProportion:", (difference.height<=0.0)?0.0:(CPRectGetMinY(contentViewFrame)-CPRectGetMinY(documentFrame))/difference.height, CPRectGetHeight(contentViewFrame)/CPRectGetHeight(documentFrame));
        objj_msgSend(_verticalScroller, "setFrame:", CPRectMake(CPRectGetMaxX(contentViewFrame),0.0,verticalScrollerWidth,verticalScrollerHeight));
    }
    else if (wasShowingVerticalScroller)
        objj_msgSend(_verticalScroller, "setFloatValue:knobProportion:", 0.0, 1.0);

    if (shouldShowHorizontalScroller)
    {
        difference.height += horizontalScrollerHeight;
        contentViewFrame.size.height -= horizontalScrollerHeight;

        objj_msgSend(_horizontalScroller, "setFloatValue:knobProportion:", (difference.width<=0.0)?0.0:(CPRectGetMinX(contentViewFrame)-CPRectGetMinX(documentFrame))/difference.width, CPRectGetWidth(contentViewFrame)/CPRectGetWidth(documentFrame));
        objj_msgSend(_horizontalScroller, "setFrame:", CPRectMake(0.0,CPRectGetMaxY(contentViewFrame),CPRectGetWidth(contentViewFrame),horizontalScrollerHeight));
    }
    else if (wasShowingHorizontalScroller)
        objj_msgSend(_horizontalScroller, "setFloatValue:knobProportion:", 0.0, 1.0);

    objj_msgSend(_contentView, "setFrame:", contentViewFrame);

    if (_hasVerticalScroller && (shouldShowVerticalScroller || wasShowingVerticalScroller))
        objj_msgSend(self, "_verticalScrollerDidScroll:", _verticalScroller);
    if (_hasHorizontalScroller && (shouldShowHorizontalScroller || wasShowingHorizontalScroller));
        objj_msgSend(self, "_horizontalScrollerDidScroll:", _horizontalScroller);

    --_recursionCount;
}
});
instance_methods[7] = new objj_method(sel_registerName("setHorizontalScroller:"), function(self, _cmd, aScroller)
{ with(self)
{
    if (_horizontalScroller == aScroller)
        return;

    objj_msgSend(_horizontalScroller, "removeFromSuperview");
    objj_msgSend(_horizontalScroller, "setTarget:", nil);
    objj_msgSend(_horizontalScroller, "setAction:", nil);

    _horizontalScroller = aScroller;

    objj_msgSend(_horizontalScroller, "setTarget:", self);
    objj_msgSend(_horizontalScroller, "setAction:", sel_registerName("_horizontalScrollerDidScroll:"));
    objj_msgSend(self, "addSubview:", _horizontalScroller);
}
});
instance_methods[8] = new objj_method(sel_registerName("horizontalScroller"), function(self, _cmd)
{ with(self)
{
    return _horizontalScroller;
}
});
instance_methods[9] = new objj_method(sel_registerName("setHasHorizontalScroller:"), function(self, _cmd, hasHorizontalScroller)
{ with(self)
{
    _hasHorizontalScroller = hasHorizontalScroller;

    if (_hasHorizontalScroller && !_horizontalScroller)
        objj_msgSend(self, "setHorizontalScroller:", objj_msgSend(objj_msgSend(CPScroller, "alloc"), "initWithFrame:", CPRectMake(0.0,0.0,CPRectGetWidth(objj_msgSend(self, "bounds")),objj_msgSend(CPScroller, "scrollerWidth"))));
    else if (!hasHorizontalScroller && _horizontalScroller)
        objj_msgSend(_horizontalScroller, "setHidden:", YES);
}
});
instance_methods[10] = new objj_method(sel_registerName("hasHorizontalScroller"), function(self, _cmd)
{ with(self)
{
    return _hasHorizontalScroller;
}
});
instance_methods[11] = new objj_method(sel_registerName("setVerticalScroller:"), function(self, _cmd, aScroller)
{ with(self)
{
    if (_verticalScroller == aScroller)
        return;

    objj_msgSend(_verticalScroller, "removeFromSuperview");
    objj_msgSend(_verticalScroller, "setTarget:", nil);
    objj_msgSend(_verticalScroller, "setAction:", nil);

    _verticalScroller = aScroller;

    objj_msgSend(_verticalScroller, "setTarget:", self);
    objj_msgSend(_verticalScroller, "setAction:", sel_registerName("_verticalScrollerDidScroll:"));
    objj_msgSend(self, "addSubview:", _verticalScroller);
}
});
instance_methods[12] = new objj_method(sel_registerName("verticalScroller"), function(self, _cmd)
{ with(self)
{
    return _verticalScroller;
}
});
instance_methods[13] = new objj_method(sel_registerName("setHasVerticalScroller:"), function(self, _cmd, hasVerticalScroller)
{ with(self)
{
    _hasVerticalScroller = hasVerticalScroller;

    if (_hasVerticalScroller && !_verticalScroller)
        objj_msgSend(self, "setVerticalScroller:", objj_msgSend(objj_msgSend(CPScroller, "alloc"), "initWithFrame:", CPRectMake(0.0,0.0,objj_msgSend(CPScroller, "scrollerWidth"),CPRectGetHeight(objj_msgSend(self, "bounds")))));
    else if (!hasVerticalScroller && _verticalScroller)
        objj_msgSend(_verticalScroller, "setHidden:", YES);
}
});
instance_methods[14] = new objj_method(sel_registerName("hasHorizontalScroller"), function(self, _cmd)
{ with(self)
{
    return _hasHorizontalScroller;
}
});
instance_methods[15] = new objj_method(sel_registerName("setAutohidesScrollers:"), function(self, _cmd, autohidesScrollers)
{ with(self)
{
    _autohidesScrollers = autohidesScrollers;
}
});
instance_methods[16] = new objj_method(sel_registerName("autohidesScrollers"), function(self, _cmd)
{ with(self)
{
    return _autohidesScrollers;
}
});
instance_methods[17] = new objj_method(sel_registerName("_verticalScrollerDidScroll:"), function(self, _cmd, aScroller)
{ with(self)
{
   var value = objj_msgSend(aScroller, "floatValue"),
       documentFrame = { origin: { x:objj_msgSend(objj_msgSend(self, "documentView"), "frame").origin.x, y:objj_msgSend(objj_msgSend(self, "documentView"), "frame").origin.y }, size: { width:objj_msgSend(objj_msgSend(self, "documentView"), "frame").size.width, height:objj_msgSend(objj_msgSend(self, "documentView"), "frame").size.height } },
       contentBounds = objj_msgSend(_contentView, "bounds");
    switch (objj_msgSend(_verticalScroller, "hitPart"))
    {
        case CPScrollerDecrementLine: documentFrame.origin.y += _verticalLineScroll;
                                        break;
        case CPScrollerIncrementLine: documentFrame.origin.y -= _verticalLineScroll;
                                        break;
        case CPScrollerDecrementPage: documentFrame.origin.y += (contentBounds.size.height) - _verticalPageScroll;
                                        break;
        case CPScrollerIncrementPage: documentFrame.origin.y -= (contentBounds.size.height) - _verticalPageScroll;
                                        break;
        case CPScrollerKnobSlot:
        case CPScrollerKnob:
        default: documentFrame.origin.y = -value * ((documentFrame.size.height) - (contentBounds.size.height));
    }
    objj_msgSend(_contentView, "scrollToPoint:", documentFrame.origin);
    objj_msgSend(_verticalScroller, "setFloatValue:knobProportion:", -documentFrame.origin.y/((documentFrame.size.height)-(contentBounds.size.height)), objj_msgSend(_verticalScroller, "knobProportion"));
}
});
instance_methods[18] = new objj_method(sel_registerName("_horizontalScrollerDidScroll:"), function(self, _cmd, aScroller)
{ with(self)
{
   var value = objj_msgSend(aScroller, "floatValue"),
       documentFrame = { origin: { x:objj_msgSend(objj_msgSend(self, "documentView"), "frame").origin.x, y:objj_msgSend(objj_msgSend(self, "documentView"), "frame").origin.y }, size: { width:objj_msgSend(objj_msgSend(self, "documentView"), "frame").size.width, height:objj_msgSend(objj_msgSend(self, "documentView"), "frame").size.height } },
       contentBounds = objj_msgSend(_contentView, "bounds");
    switch (objj_msgSend(_horizontalScroller, "hitPart"))
    {
        case CPScrollerDecrementLine: documentFrame.origin.x += _horizontalLineScroll;
                                        break;
        case CPScrollerIncrementLine: documentFrame.origin.x -= _horizontalLineScroll;
                                        break;
        case CPScrollerDecrementPage: documentFrame.origin.x += (contentBounds.size.width) - _horizontalPageScroll;
                                        break;
        case CPScrollerIncrementPage: documentFrame.origin.x -= (contentBounds.size.width) - _horizontalPageScroll;
                                        break;
        case CPScrollerKnobSlot:
        case CPScrollerKnob:
        default: documentFrame.origin.x = -value * ((documentFrame.size.width) - (contentBounds.size.width));
    }
    objj_msgSend(_contentView, "scrollToPoint:", documentFrame.origin);
    objj_msgSend(_horizontalScroller, "setFloatValue:knobProportion:", -documentFrame.origin.x/((documentFrame.size.width)-(contentBounds.size.width)), objj_msgSend(_horizontalScroller, "knobProportion"));
}
});
instance_methods[19] = new objj_method(sel_registerName("tile"), function(self, _cmd)
{ with(self)
{}
});
instance_methods[20] = new objj_method(sel_registerName("resizeSubviewsWithOldSize:"), function(self, _cmd, aSize)
{ with(self)
{
    objj_msgSend(self, "reflectScrolledClipView:", _contentView);
}
});
instance_methods[21] = new objj_method(sel_registerName("setLineScroll:"), function(self, _cmd, aLineScroll)
{ with(self)
{
    objj_msgSend(self, "setHorizonalLineScroll:", aLineScroll);
    objj_msgSend(self, "setVerticalLineScroll:", aLineScroll);
}
});
instance_methods[22] = new objj_method(sel_registerName("lineScroll"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(self, "horizontalLineScroll");
}
});
instance_methods[23] = new objj_method(sel_registerName("setHorizontalLineScroll:"), function(self, _cmd, aLineScroll)
{ with(self)
{
    _horizontalLineScroll = aLineScroll;
}
});
instance_methods[24] = new objj_method(sel_registerName("horizontalLineScroll"), function(self, _cmd)
{ with(self)
{
    return _horizontalLineScroll;
}
});
instance_methods[25] = new objj_method(sel_registerName("setVerticalLineScroll:"), function(self, _cmd, aLineScroll)
{ with(self)
{
    _verticalLineScroll = aLineScroll;
}
});
instance_methods[26] = new objj_method(sel_registerName("verticalLineScroll"), function(self, _cmd)
{ with(self)
{
    return _verticalLineScroll;
}
});
instance_methods[27] = new objj_method(sel_registerName("setPageScroll:"), function(self, _cmd, aPageScroll)
{ with(self)
{
    objj_msgSend(self, "setHorizontalPageScroll:", aPageScroll);
    objj_msgSend(self, "setVerticalPageScroll:", aPageScroll);
}
});
instance_methods[28] = new objj_method(sel_registerName("pageScroll"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(self, "horizontalPageScroll");
}
});
instance_methods[29] = new objj_method(sel_registerName("setHorizontalPageScroll:"), function(self, _cmd, aPageScroll)
{ with(self)
{
    _horizontalPageScroll = aPageScroll;
}
});
instance_methods[30] = new objj_method(sel_registerName("horizontalPageScroll"), function(self, _cmd)
{ with(self)
{
    return _horizontalPageScroll;
}
});
instance_methods[31] = new objj_method(sel_registerName("setVerticalPageScroll:"), function(self, _cmd, aPageScroll)
{ with(self)
{
    _verticalPageScroll = aPageScroll;
}
});
instance_methods[32] = new objj_method(sel_registerName("verticalPageScroll"), function(self, _cmd)
{ with(self)
{
    return _verticalPageScroll;
}
});
instance_methods[33] = new objj_method(sel_registerName("scrollWheel:"), function(self, _cmd, anEvent)
{ with(self)
{
   var value = objj_msgSend(_verticalScroller, "floatValue"),
       documentFrame = { origin: { x:objj_msgSend(objj_msgSend(self, "documentView"), "frame").origin.x, y:objj_msgSend(objj_msgSend(self, "documentView"), "frame").origin.y }, size: { width:objj_msgSend(objj_msgSend(self, "documentView"), "frame").size.width, height:objj_msgSend(objj_msgSend(self, "documentView"), "frame").size.height } },
       contentBounds = objj_msgSend(_contentView, "bounds");
    documentFrame.origin.x -= objj_msgSend(anEvent, "deltaX") * _horizontalLineScroll;
    documentFrame.origin.y -= objj_msgSend(anEvent, "deltaY") * _verticalLineScroll;
    objj_msgSend(_contentView, "scrollToPoint:", documentFrame.origin);
    objj_msgSend(_horizontalScroller, "setFloatValue:", -documentFrame.origin.x/((documentFrame.size.width)-(contentBounds.size.width)));
    objj_msgSend(_verticalScroller, "setFloatValue:", -documentFrame.origin.y/((documentFrame.size.height)-(contentBounds.size.height)));
}
});
class_addMethods(the_class, instance_methods);
}

p;12;CPScroller.ji;11;CPControl.jc;27422;





CPScrollerNoPart = 0;
CPScrollerDecrementPage = 1;
CPScrollerKnob = 2;
CPScrollerIncrementPage = 3;
CPScrollerDecrementLine = 4;
CPScrollerIncrementLine = 5;
CPScrollerKnobSlot = 6;

CPScrollerIncrementArrow = 0;
CPScrollerDecrementArrow = 1;

CPNoScrollerParts = 0;
CPOnlyScrollerArrows = 1;
CPAllScrollerParts = 2;

var _CPScrollerWidths = [],
    _CPScrollerKnobMinimumHeights = [],
    _CPScrollerArrowHeights = [],
    _CPScrollerArrowUsableHeights = [];

_CPScrollerWidths[CPRegularControlSize] = 14.0;
_CPScrollerWidths[CPSmallControlSize] = 11.0;
_CPScrollerWidths[CPMiniControlSize] = 11.0;

_CPScrollerKnobMinimumHeights[CPRegularControlSize] = 18.0;
_CPScrollerKnobMinimumHeights[CPSmallControlSize] = 12.0;
_CPScrollerKnobMinimumHeights[CPMiniControlSize] = 12.0;

_CPScrollerArrowHeights[CPRegularControlSize] = 21.0;
_CPScrollerArrowHeights[CPSmallControlSize] = 16.0;
_CPScrollerArrowHeights[CPMiniControlSize] = 16.0;

_CPScrollerArrowUsableHeights[CPRegularControlSize] = 16.0
_CPScrollerArrowUsableHeights[CPSmallControlSize] = 10.0;
_CPScrollerArrowUsableHeights[CPMiniControlSize] = 10.0;

var _CPScrollerKnobIdentifier = "Knob",
    _CPScrollerKnobSlotIdentifier = "KnobSlot",
    _CPScrollerDecrementArrowIdentifier = "DecrementArrow",
    _CPScrollerIncrementArrowIdentifier = "IncrementArrow",
    _CPScrollerHorizontalIdentifier = "Horizontal",
    _CPScrollerVerticalIdentifier = "Vertical",
    _CPScrollerHighlightedIdentifier = "Highlighted",
    _CPScrollerDisabledIdentifier = "Disabled";

var _CPScrollerClassName = nil,
    _CPScrollerPartSizes = {};

{var the_class = objj_allocateClassPair(CPControl, "CPScroller"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_controlSize"), new objj_ivar("_usableParts"), new objj_ivar("_partRects"), new objj_ivar("_isHorizontal"), new objj_ivar("_knobProportion"), new objj_ivar("_hitPart"), new objj_ivar("_trackingPart"), new objj_ivar("_trackingFloatValue"), new objj_ivar("_trackingStartPoint"), new objj_ivar("_knobView"), new objj_ivar("_knobSlotView"), new objj_ivar("_decrementArrowView"), new objj_ivar("_incrementArrowView"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("initialize"), function(self, _cmd)
{ with(self)
{
    if (self != objj_msgSend(CPScroller, "class"))
        return;

    _CPScrollerClassName = objj_msgSend(self, "className");

    var regularIdentifier = _CPControlIdentifierForControlSize(CPRegularControlSize),
        smallIdentifier = _CPControlIdentifierForControlSize(CPSmallControlSize),
        miniIdentifier = _CPControlIdentifierForControlSize(CPMiniControlSize);


    var prefix = _CPScrollerClassName + _CPScrollerKnobIdentifier + _CPScrollerHorizontalIdentifier;

    _CPScrollerPartSizes[prefix+regularIdentifier] = [{width:9.0,height:_CPScrollerWidths[CPRegularControlSize]},{width:1.0,height:_CPScrollerWidths[CPRegularControlSize]},{width:9.0,height:_CPScrollerWidths[CPRegularControlSize]}];
    _CPScrollerPartSizes[prefix+smallIdentifier] = [{width:6.0,height:_CPScrollerWidths[CPSmallControlSize]},{width:1.0,height:_CPScrollerWidths[CPSmallControlSize]},{width:6.0,height:_CPScrollerWidths[CPSmallControlSize]}];
    _CPScrollerPartSizes[prefix+miniIdentifier] = [{width:6.0,height:_CPScrollerWidths[CPMiniControlSize]},{width:1.0,height:_CPScrollerWidths[CPMiniControlSize]},{width:6.0,height:_CPScrollerWidths[CPMiniControlSize]}];


    var prefix = _CPScrollerClassName + _CPScrollerKnobIdentifier + _CPScrollerVerticalIdentifier;

    _CPScrollerPartSizes[prefix+regularIdentifier] = [{width:_CPScrollerWidths[CPRegularControlSize],height:9.0},{width:_CPScrollerWidths[CPRegularControlSize],height:1.0},{width:_CPScrollerWidths[CPRegularControlSize],height:9.0}];
    _CPScrollerPartSizes[prefix+smallIdentifier] = [{width:_CPScrollerWidths[CPSmallControlSize],height:6.0},{width:_CPScrollerWidths[CPSmallControlSize],height:1.0},{width:_CPScrollerWidths[CPSmallControlSize],height:6.0}];
    _CPScrollerPartSizes[prefix+miniIdentifier] = [{width:_CPScrollerWidths[CPMiniControlSize],height:6.0},{width:_CPScrollerWidths[CPMiniControlSize],height:1.0},{width:_CPScrollerWidths[CPMiniControlSize],height:6.0}];


    var prefix = _CPScrollerClassName + _CPScrollerKnobSlotIdentifier + _CPScrollerHorizontalIdentifier;

    _CPScrollerPartSizes[prefix+regularIdentifier] = { width:1.0, height:_CPScrollerWidths[CPRegularControlSize] };
    _CPScrollerPartSizes[prefix+smallIdentifier] = { width:1.0, height:_CPScrollerWidths[CPSmallControlSize] };
    _CPScrollerPartSizes[prefix+miniIdentifier] = { width:1.0, height:_CPScrollerWidths[CPMiniControlSize] };


    var prefix = _CPScrollerClassName + _CPScrollerKnobSlotIdentifier + _CPScrollerVerticalIdentifier;

    _CPScrollerPartSizes[prefix+regularIdentifier] = { width:_CPScrollerWidths[CPRegularControlSize], height:1.0 };
    _CPScrollerPartSizes[prefix+smallIdentifier] = { width:_CPScrollerWidths[CPSmallControlSize], height:1.0 };
    _CPScrollerPartSizes[prefix+miniIdentifier] = { width:_CPScrollerWidths[CPMiniControlSize], height:1.0 };


    var prefix = _CPScrollerClassName + _CPScrollerDecrementArrowIdentifier + _CPScrollerHorizontalIdentifier;

    _CPScrollerPartSizes[prefix+regularIdentifier] = { width:_CPScrollerArrowHeights[CPRegularControlSize], height:_CPScrollerWidths[CPRegularControlSize] };
    _CPScrollerPartSizes[prefix+regularIdentifier+_CPScrollerHighlightedIdentifier] = { width:_CPScrollerArrowHeights[CPRegularControlSize], height:_CPScrollerWidths[CPRegularControlSize] };
    _CPScrollerPartSizes[prefix+smallIdentifier] = { width:_CPScrollerArrowHeights[CPSmallControlSize], height:_CPScrollerWidths[CPSmallControlSize] };
    _CPScrollerPartSizes[prefix+smallIdentifier+_CPScrollerHighlightedIdentifier] = { width:_CPScrollerArrowHeights[CPSmallControlSize], height:_CPScrollerWidths[CPSmallControlSize] };
    _CPScrollerPartSizes[prefix+miniIdentifier] = { width:_CPScrollerArrowHeights[CPMiniControlSize], height:_CPScrollerWidths[CPMiniControlSize] };
    _CPScrollerPartSizes[prefix+miniIdentifier+_CPScrollerHighlightedIdentifier] = { width:_CPScrollerArrowHeights[CPMiniControlSize], height:_CPScrollerWidths[CPMiniControlSize] };


    var prefix = _CPScrollerClassName + _CPScrollerDecrementArrowIdentifier + _CPScrollerVerticalIdentifier;

    _CPScrollerPartSizes[prefix+regularIdentifier] = { width:_CPScrollerWidths[CPRegularControlSize], height:_CPScrollerArrowHeights[CPRegularControlSize] };
    _CPScrollerPartSizes[prefix+regularIdentifier+_CPScrollerHighlightedIdentifier] = { width:_CPScrollerWidths[CPRegularControlSize], height:_CPScrollerArrowHeights[CPRegularControlSize] };
    _CPScrollerPartSizes[prefix+smallIdentifier] = { width:_CPScrollerWidths[CPSmallControlSize], height:_CPScrollerArrowHeights[CPSmallControlSize] };
    _CPScrollerPartSizes[prefix+smallIdentifier+_CPScrollerHighlightedIdentifier] = { width:_CPScrollerWidths[CPSmallControlSize], height:_CPScrollerArrowHeights[CPSmallControlSize] };
    _CPScrollerPartSizes[prefix+miniIdentifier] = { width:_CPScrollerWidths[CPMiniControlSize], height:_CPScrollerArrowHeights[CPMiniControlSize] };
    _CPScrollerPartSizes[prefix+miniIdentifier+_CPScrollerHighlightedIdentifier] = { width:_CPScrollerWidths[CPMiniControlSize], height:_CPScrollerArrowHeights[CPMiniControlSize] };


    var prefix = _CPScrollerClassName + _CPScrollerIncrementArrowIdentifier + _CPScrollerHorizontalIdentifier;

    _CPScrollerPartSizes[prefix+regularIdentifier] = { width:_CPScrollerArrowHeights[CPRegularControlSize], height:_CPScrollerWidths[CPRegularControlSize] };
    _CPScrollerPartSizes[prefix+regularIdentifier+_CPScrollerHighlightedIdentifier] = { width:_CPScrollerArrowHeights[CPRegularControlSize], height:_CPScrollerWidths[CPRegularControlSize] };
    _CPScrollerPartSizes[prefix+smallIdentifier] = { width:_CPScrollerArrowHeights[CPSmallControlSize], height:_CPScrollerWidths[CPSmallControlSize] };
    _CPScrollerPartSizes[prefix+smallIdentifier+_CPScrollerHighlightedIdentifier] = { width:_CPScrollerArrowHeights[CPSmallControlSize], height:_CPScrollerWidths[CPSmallControlSize] };
    _CPScrollerPartSizes[prefix+miniIdentifier] = { width:_CPScrollerArrowHeights[CPMiniControlSize], height:_CPScrollerWidths[CPMiniControlSize] };
    _CPScrollerPartSizes[prefix+miniIdentifier+_CPScrollerHighlightedIdentifier] = { width:_CPScrollerArrowHeights[CPMiniControlSize], height:_CPScrollerWidths[CPMiniControlSize] };


    var prefix = _CPScrollerClassName + _CPScrollerIncrementArrowIdentifier + _CPScrollerVerticalIdentifier;

    _CPScrollerPartSizes[prefix+regularIdentifier] = { width:_CPScrollerWidths[CPRegularControlSize], height:_CPScrollerArrowHeights[CPRegularControlSize] };
    _CPScrollerPartSizes[prefix+regularIdentifier+_CPScrollerHighlightedIdentifier] = { width:_CPScrollerWidths[CPRegularControlSize], height:_CPScrollerArrowHeights[CPRegularControlSize] };
    _CPScrollerPartSizes[prefix+smallIdentifier] = { width:_CPScrollerWidths[CPSmallControlSize], height:_CPScrollerArrowHeights[CPSmallControlSize] };
    _CPScrollerPartSizes[prefix+smallIdentifier+_CPScrollerHighlightedIdentifier] = { width:_CPScrollerWidths[CPSmallControlSize], height:_CPScrollerArrowHeights[CPSmallControlSize] };
    _CPScrollerPartSizes[prefix+miniIdentifier] = { width:_CPScrollerWidths[CPMiniControlSize], height:_CPScrollerArrowHeights[CPMiniControlSize] };
    _CPScrollerPartSizes[prefix+miniIdentifier+_CPScrollerHighlightedIdentifier] = { width:_CPScrollerWidths[CPMiniControlSize], height:_CPScrollerArrowHeights[CPMiniControlSize] };
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "initWithFrame:", aFrame);

    if (self)
    {
        _controlSize = CPRegularControlSize;
        _partRects = [];

        objj_msgSend(self, "setFloatValue:knobProportion:", 0.0, 1.0);

        _isHorizontal = CPRectGetWidth(aFrame) > CPRectGetHeight(aFrame);

        _hitPart = CPScrollerNoPart;

        objj_msgSend(self, "checkSpaceForUsableParts");
        objj_msgSend(self, "drawParts");

        objj_msgSend(self, "layoutSubviews");
    }

    return self;
}
});
class_methods[1] = new objj_method(sel_registerName("scrollerWidth"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(self, "scrollerWidthForControlSize:", CPRegularControlSize);
}
});
class_methods[2] = new objj_method(sel_registerName("scrollerWidthForControlSize:"), function(self, _cmd, aControlSize)
{ with(self)
{
    return _CPScrollerWidths[aControlSize];
}
});
instance_methods[1] = new objj_method(sel_registerName("setControlSize:"), function(self, _cmd, aControlSize)
{ with(self)
{
    if (_controlSize == aControlSize)
        return;

    _controlSize = aControlSize;

    objj_msgSend(self, "drawKnobSlot");
    objj_msgSend(self, "drawKnob");
    objj_msgSend(self, "drawArrow:highlight:", CPScrollerDecrementArrow, NO);
    objj_msgSend(self, "drawArrow:highlight:", CPScrollerIncrementArrow, NO);

    objj_msgSend(self, "layoutSubviews");
}
});
instance_methods[2] = new objj_method(sel_registerName("controlSize"), function(self, _cmd)
{ with(self)
{
    return _controlSize;
}
});
instance_methods[3] = new objj_method(sel_registerName("setFloatValue:"), function(self, _cmd, aValue)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "setFloatValue:", MIN(1.0,MAX(0.0,aValue)));

    objj_msgSend(self, "checkSpaceForUsableParts");
    objj_msgSend(self, "layoutSubviews");
}
});
instance_methods[4] = new objj_method(sel_registerName("setFloatValue:knobProportion:"), function(self, _cmd, aValue, aProportion)
{ with(self)
{
    _knobProportion = MIN(1.0, MAX(0.0001, aProportion));

    objj_msgSend(self, "setFloatValue:", aValue);
}
});
instance_methods[5] = new objj_method(sel_registerName("knobProportion"), function(self, _cmd)
{ with(self)
{
    return _knobProportion;
}
});
instance_methods[6] = new objj_method(sel_registerName("rectForPart:"), function(self, _cmd, aPart)
{ with(self)
{
    if (aPart == CPScrollerNoPart)
        return { origin: { x:0.0, y:0.0 }, size: { width:0.0, height:0.0 } };

    return _partRects[aPart];
}
});
instance_methods[7] = new objj_method(sel_registerName("testPart:"), function(self, _cmd, aPoint)
{ with(self)
{
    aPoint = objj_msgSend(self, "convertPoint:fromView:", aPoint, nil);




    if (CGRectContainsPoint(objj_msgSend(self, "rectForPart:", CPScrollerKnob), aPoint))
        return CPScrollerKnob;

    if (CGRectContainsPoint(objj_msgSend(self, "rectForPart:", CPScrollerDecrementPage), aPoint))
        return CPScrollerDecrementPage;

    if (CGRectContainsPoint(objj_msgSend(self, "rectForPart:", CPScrollerIncrementPage), aPoint))
        return CPScrollerIncrementPage;

    if (CGRectContainsPoint(objj_msgSend(self, "rectForPart:", CPScrollerDecrementLine), aPoint))
        return CPScrollerDecrementLine;

    if (CGRectContainsPoint(objj_msgSend(self, "rectForPart:", CPScrollerIncrementLine), aPoint))
        return CPScrollerIncrementLine;

    if (CGRectContainsPoint(objj_msgSend(self, "rectForPart:", CPScrollerKnobSlot), aPoint))
        return CPScrollerKnobSlot;

    return CPScrollerNoPart;
}
});
instance_methods[8] = new objj_method(sel_registerName("checkSpaceForUsableParts"), function(self, _cmd)
{ with(self)
{
    var bounds = objj_msgSend(self, "bounds");


    if (_knobProportion == 1.0)
    {
        _usableParts = CPNoScrollerParts;

        _partRects[CPScrollerDecrementPage] = { origin: { x:0.0, y:0.0 }, size: { width:0.0, height:0.0 } };
        _partRects[CPScrollerKnob] = { origin: { x:0.0, y:0.0 }, size: { width:0.0, height:0.0 } };
        _partRects[CPScrollerIncrementPage] = { origin: { x:0.0, y:0.0 }, size: { width:0.0, height:0.0 } };
        _partRects[CPScrollerDecrementLine] = { origin: { x:0.0, y:0.0 }, size: { width:0.0, height:0.0 } };
        _partRects[CPScrollerIncrementLine] = { origin: { x:0.0, y:0.0 }, size: { width:0.0, height:0.0 } };


        _partRects[CPScrollerKnobSlot] = { origin: { x:bounds.origin.x, y:bounds.origin.y }, size: { width:bounds.size.width, height:bounds.size.height } };

        return;
    }

    var width = (bounds.size.width),
        height = (bounds.size.height),
        usableArrowHeight = _CPScrollerArrowUsableHeights[_controlSize],
        slotWidth = (_isHorizontal ? width : height) - 2.0 * usableArrowHeight,
        knobWidth = MAX(_CPScrollerKnobMinimumHeights[_controlSize], (slotWidth * _knobProportion));

    _usableParts = CPAllScrollerParts;

    var arrowHeight = _CPScrollerArrowHeights[_controlSize],
        knobLocation = usableArrowHeight + (slotWidth - knobWidth) * objj_msgSend(self, "floatValue");


    if (_isHorizontal)
    {


        _partRects[CPScrollerDecrementPage] = { origin: { x:usableArrowHeight, y:0.0 }, size: { width:knobLocation - usableArrowHeight, height:height } };
        _partRects[CPScrollerKnob] = { origin: { x:knobLocation, y:0.0 }, size: { width:knobWidth, height:_CPScrollerWidths[_controlSize] } };
        _partRects[CPScrollerIncrementPage] = { origin: { x:knobLocation + knobWidth, y:0.0 }, size: { width:width - (knobLocation + knobWidth) - usableArrowHeight, height:height } };
        _partRects[CPScrollerKnobSlot] = { origin: { x:usableArrowHeight, y:0.0 }, size: { width:slotWidth, height:height } };
        _partRects[CPScrollerDecrementLine] = { origin: { x:0.0, y:0.0 }, size: { width:arrowHeight, height:height } };
        _partRects[CPScrollerIncrementLine] = { origin: { x:width - _CPScrollerArrowHeights[_controlSize], y:0.0 }, size: { width:arrowHeight, height:height } };
    }
    else
    {


        _partRects[CPScrollerDecrementPage] = { origin: { x:0.0, y:usableArrowHeight }, size: { width:width, height:knobLocation - usableArrowHeight } };
        _partRects[CPScrollerKnob] = { origin: { x:0.0, y:knobLocation }, size: { width:_CPScrollerWidths[_controlSize], height:knobWidth } };
        _partRects[CPScrollerIncrementPage] = { origin: { x:0.0, y:knobLocation + knobWidth }, size: { width:width, height:height - (knobLocation + knobWidth) - usableArrowHeight } };
        _partRects[CPScrollerKnobSlot] = { origin: { x:0.0, y:usableArrowHeight }, size: { width:width, height:slotWidth } };
        _partRects[CPScrollerDecrementLine] = { origin: { x:0.0, y:0.0 }, size: { width:width, height:arrowHeight } };
        _partRects[CPScrollerIncrementLine] = { origin: { x:0.0, y:height - _CPScrollerArrowHeights[_controlSize] }, size: { width:width, height:arrowHeight } };
    }
}
});
instance_methods[9] = new objj_method(sel_registerName("usableParts"), function(self, _cmd)
{ with(self)
{
    return _usableParts;
}
});
instance_methods[10] = new objj_method(sel_registerName("drawArrow:highlight:"), function(self, _cmd, anArrow, shouldHighlight)
{ with(self)
{
    var identifier = (anArrow == CPScrollerDecrementArrow ? _CPScrollerDecrementArrowIdentifier : _CPScrollerIncrementArrowIdentifier),
        arrowView = (anArrow == CPScrollerDecrementArrow ? _decrementArrowView : _incrementArrowView);

    objj_msgSend(arrowView, "setBackgroundColor:", _CPControlColorWithPatternImage(_CPScrollerPartSizes,_CPScrollerClassName,identifier,_isHorizontal?_CPScrollerHorizontalIdentifier:_CPScrollerVerticalIdentifier,_CPControlIdentifierForControlSize(_controlSize),shouldHighlight?_CPScrollerHighlightedIdentifier:""));
}
});
instance_methods[11] = new objj_method(sel_registerName("drawKnob"), function(self, _cmd)
{ with(self)
{
    objj_msgSend(_knobView, "setImages:", _CPControlThreePartImages(_CPScrollerPartSizes,_CPScrollerClassName,_CPScrollerKnobIdentifier,_isHorizontal?_CPScrollerHorizontalIdentifier:_CPScrollerVerticalIdentifier,_CPControlIdentifierForControlSize(_controlSize)));
}
});
instance_methods[12] = new objj_method(sel_registerName("drawKnobSlot"), function(self, _cmd)
{ with(self)
{
    objj_msgSend(_knobSlotView, "setBackgroundColor:", _CPControlColorWithPatternImage(_CPScrollerPartSizes,_CPScrollerClassName,_CPScrollerKnobSlotIdentifier,_isHorizontal?_CPScrollerHorizontalIdentifier:_CPScrollerVerticalIdentifier,_CPControlIdentifierForControlSize(_controlSize)));
}
});
instance_methods[13] = new objj_method(sel_registerName("drawParts"), function(self, _cmd)
{ with(self)
{
    _knobSlotView = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", {origin:{x:0.0,y:0.0},size:{width:0.0,height:0.0}});

    objj_msgSend(_knobSlotView, "setHitTests:", NO);

    objj_msgSend(self, "addSubview:", _knobSlotView);

    objj_msgSend(self, "drawKnobSlot");

    _knobView = objj_msgSend(objj_msgSend(CPThreePartImageView, "alloc"), "initWithFrame:", {origin:{x:0.0,y:0.0},size:{width:0.0,height:0.0}});

    objj_msgSend(_knobView, "setHitTests:", NO);
    objj_msgSend(_knobView, "setVertical:", !_isHorizontal);

    objj_msgSend(self, "addSubview:", _knobView);

    objj_msgSend(self, "drawKnob");

    _decrementArrowView = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", {origin:{x:0.0,y:0.0},size:{width:0.0,height:0.0}});

    objj_msgSend(_decrementArrowView, "setHitTests:", NO);

    objj_msgSend(self, "addSubview:", _decrementArrowView);

    objj_msgSend(self, "drawArrow:highlight:", CPScrollerDecrementArrow, NO);

    _incrementArrowView = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", {origin:{x:0.0,y:0.0},size:{width:0.0,height:0.0}});

    objj_msgSend(_incrementArrowView, "setHitTests:", NO);

    objj_msgSend(self, "addSubview:", _incrementArrowView);

    objj_msgSend(self, "drawArrow:highlight:", CPScrollerIncrementArrow, NO);
}
});
instance_methods[14] = new objj_method(sel_registerName("highlight:"), function(self, _cmd, shouldHighlight)
{ with(self)
{
    if (_trackingPart == CPScrollerDecrementLine)
        objj_msgSend(self, "drawArrow:highlight:", CPScrollerDecrementArrow, shouldHighlight);

    else if (_trackingPart == CPScrollerIncrementLine)
        objj_msgSend(self, "drawArrow:highlight:", CPScrollerIncrementArrow, shouldHighlight);
}
});
instance_methods[15] = new objj_method(sel_registerName("hitPart"), function(self, _cmd)
{ with(self)
{
    return _hitPart;
}
});
instance_methods[16] = new objj_method(sel_registerName("trackKnob:"), function(self, _cmd, anEvent)
{ with(self)
{
    var type = objj_msgSend(anEvent, "type");

    if (type == CPLeftMouseUp)
    {
        _hitPart = CPScrollerNoPart;

        return;
    }

    if (type == CPLeftMouseDown)
    {
        _trackingFloatValue = objj_msgSend(self, "floatValue");
        _trackingStartPoint = objj_msgSend(self, "convertPoint:fromView:", objj_msgSend(anEvent, "locationInWindow"), nil);
    }

    else if (type == CPLeftMouseDragged)
    {
        var knobRect = objj_msgSend(self, "rectForPart:", CPScrollerKnob),
            knobSlotRect = objj_msgSend(self, "rectForPart:", CPScrollerKnobSlot),
            remainder = _isHorizontal ? ((knobSlotRect.size.width) - (knobRect.size.width)) : ((knobSlotRect.size.height) - (knobRect.size.height));

        if (remainder <= 0)
            objj_msgSend(self, "setFloatValue:", 0.0);
        else
        {
            var location = objj_msgSend(self, "convertPoint:fromView:", objj_msgSend(anEvent, "locationInWindow"), nil);
                delta = _isHorizontal ? location.x - _trackingStartPoint.x : location.y - _trackingStartPoint.y;

            objj_msgSend(self, "setFloatValue:", _trackingFloatValue+delta/remainder);
        }
    }

    objj_msgSend(CPApp, "setTarget:selector:forNextEventMatchingMask:untilDate:inMode:dequeue:", self, sel_registerName("trackKnob:"), CPLeftMouseDraggedMask|CPLeftMouseUpMask, nil, nil, YES);

    objj_msgSend(self, "sendAction:to:", objj_msgSend(self, "action"), objj_msgSend(self, "target"));
}
});
instance_methods[17] = new objj_method(sel_registerName("trackScrollButtons:"), function(self, _cmd, anEvent)
{ with(self)
{
    var type = objj_msgSend(anEvent, "type");

    if (type == CPLeftMouseUp)
    {
        objj_msgSend(self, "highlight:", NO);
        objj_msgSend(CPEvent, "stopPeriodicEvents");

        _hitPart = CPScrollerNoPart;

        return;
    }

    if (type == CPLeftMouseDown)
    {
        _trackingPart = objj_msgSend(self, "hitPart");

        _trackingStartPoint = objj_msgSend(self, "convertPoint:fromView:", objj_msgSend(anEvent, "locationInWindow"), nil);

        if (objj_msgSend(anEvent, "modifierFlags") & CPAlternateKeyMask)
        {
            if (_trackingPart == CPScrollerDecrementLine)
                _hitPart = CPScrollerDecrementPage;
            else if (_trackingPart == CPScrollerIncrementLine)
                _hitPart = CPScrollerIncrementPage;
            else if (_trackingPart == CPScrollerDecrementPage || _trackingPart == CPScrollerIncrementPage)
            {
                var knobRect = objj_msgSend(self, "rectForPart:", CPScrollerKnob),
                    knobWidth = _isHorizontal ? (knobRect.size.width) : (knobRect.size.height),
                    knobSlotRect = objj_msgSend(self, "rectForPart:", CPScrollerKnobSlot),
                    remainder = (_isHorizontal ? (knobSlotRect.size.width) : (knobSlotRect.size.height)) - knobWidth;

                objj_msgSend(self, "setFloatValue:", ((_isHorizontal?_trackingStartPoint.x-(knobSlotRect.origin.x):_trackingStartPoint.y-(knobSlotRect.origin.y))-knobWidth/2.0)/remainder);

                _hitPart = CPScrollerKnob;

                objj_msgSend(self, "sendAction:to:", objj_msgSend(self, "action"), objj_msgSend(self, "target"));


                return objj_msgSend(self, "trackKnob:", anEvent);
            }
        }

        objj_msgSend(self, "highlight:", YES);
        objj_msgSend(self, "sendAction:to:", objj_msgSend(self, "action"), objj_msgSend(self, "target"));

        objj_msgSend(CPEvent, "startPeriodicEventsAfterDelay:withPeriod:", 0.5, 0.04);
    }

    else if (type == CPLeftMouseDragged)
    {
        _trackingStartPoint = objj_msgSend(self, "convertPoint:fromView:", objj_msgSend(anEvent, "locationInWindow"), nil);

        if (_trackingPart == CPScrollerDecrementPage || _trackingPart == CPScrollerIncrementPage)
        {
            var hitPart = objj_msgSend(self, "testPart:", objj_msgSend(anEvent, "locationInWindow"));

            if (hitPart == CPScrollerDecrementPage || hitPart == CPScrollerIncrementPage)
            {
                _trackingPart = hitPart;
                _hitPart = hitPart;
            }
        }

        objj_msgSend(self, "highlight:", CGRectContainsPoint(objj_msgSend(self, "rectForPart:", _trackingPart),_trackingStartPoint));
    }
    else if (type == CPPeriodic && CGRectContainsPoint(objj_msgSend(self, "rectForPart:", _trackingPart), _trackingStartPoint))
        objj_msgSend(self, "sendAction:to:", objj_msgSend(self, "action"), objj_msgSend(self, "target"));

    objj_msgSend(CPApp, "setTarget:selector:forNextEventMatchingMask:untilDate:inMode:dequeue:", self, sel_registerName("trackScrollButtons:"), CPPeriodicMask|CPLeftMouseDraggedMask|CPLeftMouseUpMask, nil, nil, YES);

}
});
instance_methods[18] = new objj_method(sel_registerName("setFrameSize:"), function(self, _cmd, aSize)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "setFrameSize:", aSize);

    objj_msgSend(self, "checkSpaceForUsableParts");

    objj_msgSend(self, "layoutSubviews");
}
});
instance_methods[19] = new objj_method(sel_registerName("layoutSubviews"), function(self, _cmd)
{ with(self)
{
    objj_msgSend(_knobSlotView, "setFrame:", objj_msgSend(self, "rectForPart:", CPScrollerKnobSlot));

    var usableParts = objj_msgSend(self, "usableParts"),
        hidden = !(usableParts == CPAllScrollerParts);

    if (hidden != objj_msgSend(_knobView, "isHidden"))
    {
        objj_msgSend(_knobView, "setHidden:", hidden);
        objj_msgSend(_decrementArrowView, "setHidden:", hidden);
        objj_msgSend(_incrementArrowView, "setHidden:", hidden);
    }

    if (!hidden)
    {
        objj_msgSend(_knobView, "setFrame:", objj_msgSend(self, "rectForPart:", CPScrollerKnob));
        objj_msgSend(_decrementArrowView, "setFrame:", objj_msgSend(self, "rectForPart:", CPScrollerDecrementLine));
        objj_msgSend(_incrementArrowView, "setFrame:", objj_msgSend(self, "rectForPart:", CPScrollerIncrementLine));
    }
}
});
instance_methods[20] = new objj_method(sel_registerName("mouseDown:"), function(self, _cmd, anEvent)
{ with(self)
{
    _hitPart = objj_msgSend(self, "testPart:", objj_msgSend(anEvent, "locationInWindow"));

    switch (_hitPart)
    {
        case CPScrollerKnob: return objj_msgSend(self, "trackKnob:", anEvent);

        case CPScrollerDecrementLine:
        case CPScrollerIncrementLine:
        case CPScrollerDecrementPage:
        case CPScrollerIncrementPage: return objj_msgSend(self, "trackScrollButtons:", anEvent);
    }
}
});
instance_methods[21] = new objj_method(sel_registerName("setEnabled:"), function(self, _cmd, shouldBeEnabled)
{ with(self)
{}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

p;20;CPSegmentedControl.jI;20;Foundation/CPArray.ji;11;CPControl.jc;15349;


CPSegmentSwitchTrackingSelectOne = 0;
CPSegmentSwitchTrackingSelectAny = 1;
CPSegmentSwitchTrackingMomentary = 2;

{var the_class = objj_allocateClassPair(CPControl, "CPSegmentedControl"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_segmentCount"), new objj_ivar("_segments"), new objj_ivar("_selectedSegment"), new objj_ivar("_trackingMode"), new objj_ivar("_trackingSegment"), new objj_ivar("_trackingHighlighted"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aRect)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "initWithFrame:", aRect);

    if (self)
    {
        _segments = [];
        _selectedSegment = -1;

        _segmentCount = 0;

        _trackingMode = CPSegmentSwitchTrackingSelectOne;
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("selectedTag"), function(self, _cmd)
{ with(self)
{
    return _segments[_selectedSegment].tag;
}
});
instance_methods[2] = new objj_method(sel_registerName("setSegmentCount:"), function(self, _cmd, aCount)
{ with(self)
{
    if (_segmentCount == aCount)
        return;

    var height = CGRectGetHeight(objj_msgSend(self, "bounds"));

    if (_segmentCount < aCount)
    {
        var index = _segmentCount;

        for (; index < aCount; ++index)
        {
            _segments[index] = _CPSegmentMake();
            _segments[index].frame.size.height = height;
        }
    }
    else if (aCount < _segmentCount)
    {
        var index = aCount;

        for (; index < _segmentCount; ++index)
        {
            objj_msgSend(_segments[index].imageView, "removeFromSuperview");
            objj_msgSend(_segments[index].labelView, "removeFromSuperview");

            _segments[index] = nil;
        }
    }

    _segmentCount = aCount;

    if (_selectedSegment < _segmentCount)
        _selectedSegment = -1;

    objj_msgSend(self, "tileWithChangedSegment:", 0);
}
});
instance_methods[3] = new objj_method(sel_registerName("segmentCount"), function(self, _cmd)
{ with(self)
{
    return _segmentCount;
}
});
instance_methods[4] = new objj_method(sel_registerName("setSelectedSegment:"), function(self, _cmd, aSegment)
{ with(self)
{
    objj_msgSend(self, "setSelected:forSegment:", YES, aSegment);
}
});
instance_methods[5] = new objj_method(sel_registerName("selectedSegment"), function(self, _cmd)
{ with(self)
{
    return _selectedSegment;
}
});
instance_methods[6] = new objj_method(sel_registerName("selectSegmentWithTag:"), function(self, _cmd, aTag)
{ with(self)
{
    var index = 0;

    for (; index < _segmentCount; ++index)
        if (_segments[index].tag == aTag)
        {
            objj_msgSend(self, "setSelectedSegment:", index);

            return YES;
        }

    return NO;
}
});
instance_methods[7] = new objj_method(sel_registerName("isTracking"), function(self, _cmd)
{ with(self)
{}
});
instance_methods[8] = new objj_method(sel_registerName("setTrackingMode:"), function(self, _cmd, aTrackingMode)
{ with(self)
{
    if (_trackingMode == aTrackingMode)
        return;

    _trackingMode = aTrackingMode;

    if (_trackingMode == CPSegmentSwitchTrackingSelectOne)
    {
        var index = 0,
            selected = NO;

        for (; index < _segmentCount; ++index)
            if (_segments[index].selected)
                if (selected)
                    objj_msgSend(self, "setSelected:forSegment:", NO, index);
                else
                    selected = YES;
    }

    else if (_trackingMode == CPSegmentSwitchTrackingMomentary)
    {
        var index = 0;

        for (; index < _segmentCount; ++index)
            if (_segments[index].selected)
                objj_msgSend(self, "setSelected:forSegment:", NO, index);
    }
}
});
instance_methods[9] = new objj_method(sel_registerName("trackingMode"), function(self, _cmd)
{ with(self)
{
    return _trackingMode;
}
});
instance_methods[10] = new objj_method(sel_registerName("setWidth:forSegment:"), function(self, _cmd, aWidth, aSegment)
{ with(self)
{
    _segments[aSegment].width = aWidth;

    objj_msgSend(self, "tileWithChangedSegment:", aSegment);
}
});
instance_methods[11] = new objj_method(sel_registerName("widthForSegment:"), function(self, _cmd, aSegment)
{ with(self)
{
    return _segments[aSegment].width;
}
});
instance_methods[12] = new objj_method(sel_registerName("setImage:forSegment:"), function(self, _cmd, anImage, aSegment)
{ with(self)
{
    var segment = _segments[aSegment];

    if (!anImage)
    {
        objj_msgSend(segment.imageView, "removeFromSuperview");

        segment.imageView = nil;
    }

    else
    {
        if (!segment.imageView)
        {
            segment.imageView = objj_msgSend(objj_msgSend(CPImageView, "alloc"), "initWithFrame:", CGRectMakeZero());

            objj_msgSend(self, "addSubview:", segment.imageView);
        }

        objj_msgSend(segment.imageView, "setImage:", anImage);
        objj_msgSend(segment.imageView, "setFrameSize:", CGSizeMakeCopy(objj_msgSend(anImage, "size")));
    }

    segment.image = anImage;

    if (segment.width)
        objj_msgSend(self, "drawSegment:highlight:", aSegment, NO);
    else
        objj_msgSend(self, "tileWithChangedSegment:", aSegment);
}
});
instance_methods[13] = new objj_method(sel_registerName("imageForSegment:"), function(self, _cmd, aSegment)
{ with(self)
{
    return _segments[aSegment].image;
}
});
instance_methods[14] = new objj_method(sel_registerName("setLabel:forSegment:"), function(self, _cmd, aLabel, aSegment)
{ with(self)
{
    var segment = _segments[aSegment];

    if (!aLabel || !aLabel.length)
    {
        objj_msgSend(segment.labelView, "removeFromSuperview");

        segment.labelView = nil;
    }

    else
    {
        if (!segment.labelView)
        {
            segment.labelView = objj_msgSend(objj_msgSend(CPTextField, "alloc"), "initWithFrame:", CGRectMakeZero());

            objj_msgSend(self, "addSubview:", segment.labelView);
        }

        objj_msgSend(segment.labelView, "setStringValue:", aLabel);
        objj_msgSend(segment.labelView, "sizeToFit");
    }

    _segments[aSegment].label = aLabel;

    if (segment.width)
        objj_msgSend(self, "drawSegment:highlight:", aSegment, NO);
    else
        objj_msgSend(self, "tileWithChangedSegment:", aSegment);
}
});
instance_methods[15] = new objj_method(sel_registerName("labelForSegment:"), function(self, _cmd, aSegment)
{ with(self)
{
    return _segments[aSegment].label;
}
});
instance_methods[16] = new objj_method(sel_registerName("setMenu:forSegment:"), function(self, _cmd, aMenu, aSegment)
{ with(self)
{
    _segments[aSegment].menu = aMenu;
}
});
instance_methods[17] = new objj_method(sel_registerName("menuForSegment:"), function(self, _cmd, aSegment)
{ with(self)
{
    return _segments[aSegment].menu;
}
});
instance_methods[18] = new objj_method(sel_registerName("setSelected:forSegment:"), function(self, _cmd, isSelected, aSegment)
{ with(self)
{

    if (aSegment < 0 || aSegment >= _segments.length)
        return;

    var segment = _segments[aSegment];


    if (segment.selected == isSelected)
        return;

    segment.selected = isSelected;


    if (isSelected)
    {
        var oldSelectedSegment = _selectedSegment;

        _selectedSegment = aSegment;

        if (_trackingMode == CPSegmentSwitchTrackingSelectOne && oldSelectedSegment != aSegment && oldSelectedSegment != -1)
        {
            _segments[oldSelectedSegment].selected = NO;

            objj_msgSend(self, "drawSegmentBezel:highlight:", oldSelectedSegment, NO);
        }
    }

    if (_trackingMode != CPSegmentSwitchTrackingMomentary)
        objj_msgSend(self, "drawSegmentBezel:highlight:", aSegment, NO);
}
});
instance_methods[19] = new objj_method(sel_registerName("isSelectedForSegment:"), function(self, _cmd, aSegment)
{ with(self)
{
    return _segments[aSegment].selected;
}
});
instance_methods[20] = new objj_method(sel_registerName("setEnabled:forSegment:"), function(self, _cmd, isEnabled, aSegment)
{ with(self)
{
    _segments[aSegment].enabled = isEnabled;
}
});
instance_methods[21] = new objj_method(sel_registerName("isEnabledForSegment:"), function(self, _cmd, aSegment)
{ with(self)
{
    return _segments[aSegment].enabled;
}
});
instance_methods[22] = new objj_method(sel_registerName("setTag:forSegment:"), function(self, _cmd, aTag, aSegment)
{ with(self)
{
    _segments[aSegment].tag = aTag;
}
});
instance_methods[23] = new objj_method(sel_registerName("tagForSegment:"), function(self, _cmd, aSegment)
{ with(self)
{
    return _segments[aSegment].tag;
}
});
instance_methods[24] = new objj_method(sel_registerName("drawSegmentBezel:highlgiht:"), function(self, _cmd, aSegment, shouldHighlight)
{ with(self)
{}
});
instance_methods[25] = new objj_method(sel_registerName("drawSegment:highlight:"), function(self, _cmd, aSegment, shouldHighlight)
{ with(self)
{
    var segment = _segments[aSegment],

        imageView = segment.imageView,
        labelView = segment.labelView,

        frame = segment.frame,

        segmentX = CGRectGetMinX(frame),
        segmentWidth = CGRectGetWidth(frame),
        segmentHeight = CGRectGetHeight(frame) - 1.0;

    if (imageView && labelView)
    {
        var imageViewSize = objj_msgSend(imageView, "frame").size,
            labelViewSize = objj_msgSend(labelView, "frame").size,
            totalHeight = imageViewSize.height + labelViewSize.height,
            labelWidth = MIN(labelViewSize.width, width),
            y = (segmentHeight - totalHeight) / 2.0;

        objj_msgSend(imageView, "setFrameOrigin:", CGPointMake(segmentX+(segmentWidth-imageViewSize.width)/2.0,y));

        if (labelWidth < labelViewSize.width)
            objj_msgSend(labelView, "setFrameSize:", CGSizeMake(labelWidth,labelViewSize.height));

        objj_msgSend(labelView, "setFrameOrigin:", CGPointMake(segmentX+(segmentWidth-labelWidth)/2.0,y+imageViewSize.height));
    }
    else if (imageView)
    {
        var imageViewSize = objj_msgSend(imageView, "frame").size;

        objj_msgSend(imageView, "setFrameOrigin:", CGPointMake(segmentX+(segmentWidth-imageViewSize.width)/2.0,(segmentHeight-imageViewSize.height)/2.0));
    }
    else if (labelView)
    {
        var labelViewSize = objj_msgSend(labelView, "frame").size,
            labelWidth = MIN(labelViewSize.width, segmentWidth);

        if (labelWidth < labelViewSize.width)
            objj_msgSend(labelView, "setFrameSize:", CGSizeMake(labelWidth,labelViewSize.height));

        objj_msgSend(labelView, "setFrameOrigin:", CGPointMake(segmentX+(segmentWidth-labelWidth)/2.0,(segmentHeight-labelViewSize.height)/2.0));
    }
}
});
instance_methods[26] = new objj_method(sel_registerName("tileWithChangedSegment:"), function(self, _cmd, aSegment)
{ with(self)
{
    var segment = _segments[aSegment],
        segmentWidth = segment.width;

    if (!segmentWidth)
    {
        if (segment.labelView && segment.imageView)
            segmentWidth = MAX(CGRectGetWidth(objj_msgSend(segment.labelView, "frame")) , CGRectGetWidth(objj_msgSend(segment.imageView, "frame")));
        else if (segment.labelView)
            segmentWidth = CGRectGetWidth(objj_msgSend(segment.labelView, "frame"));
        else if (segment.imageView)
            segmentWidth = CGRectGetWidth(objj_msgSend(segment.imageView, "frame"));
    }

    var delta = segmentWidth - CGRectGetWidth(segment.frame);

    if (!delta)
        return;


    var frame = objj_msgSend(self, "frame");

    objj_msgSend(self, "setFrameSize:", CGSizeMake(CGRectGetWidth(frame)+delta,CGRectGetHeight(frame)));


    segment.frame.size.width = segmentWidth;


    var index = aSegment + 1;

    for (; index < _segmentCount; ++index)
    {
        _segments[index].frame.origin.x += delta;

        objj_msgSend(self, "drawSegmentBezel:highlight:", index, NO);
        objj_msgSend(self, "drawSegment:highlight:", index, NO);
    }

    objj_msgSend(self, "drawSegmentBezel:highlight:", aSegment, NO);
    objj_msgSend(self, "drawSegment:highlight:", aSegment, NO);
}
});
instance_methods[27] = new objj_method(sel_registerName("frameForSegment:"), function(self, _cmd, aSegment)
{ with(self)
{
    return _segments[aSegment].frame;
}
});
instance_methods[28] = new objj_method(sel_registerName("testSegment:"), function(self, _cmd, aPoint)
{ with(self)
{
    var location = objj_msgSend(self, "convertPoint:fromView:", aPoint, nil),
        count = _segments.length;

    while (count--)
        if (CGRectContainsPoint(_segments[count].frame, aPoint))
            return count;

    return -1;
}
});
instance_methods[29] = new objj_method(sel_registerName("mouseDown:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(self, "trackSegment:", anEvent);
}
});
instance_methods[30] = new objj_method(sel_registerName("trackSegment:"), function(self, _cmd, anEvent)
{ with(self)
{
    var type = objj_msgSend(anEvent, "type"),
        location = objj_msgSend(self, "convertPoint:fromView:", objj_msgSend(anEvent, "locationInWindow"), nil);

    if (type == CPLeftMouseUp)
    {
        if (CGRectContainsPoint(_segments[_trackingSegment].frame, location))
        {
            if (_trackingMode == CPSegmentSwitchTrackingSelectAny)
            {
                objj_msgSend(self, "setSelected:forSegment:", !objj_msgSend(self, "isSelectedForSegment:", _trackingSegment), _trackingSegment);


                _selectedSegment = _trackingSegment;
            }
            else
                objj_msgSend(self, "setSelected:forSegment:", YES, _trackingSegment);

            objj_msgSend(self, "sendAction:to:", objj_msgSend(self, "action"), objj_msgSend(self, "target"));

            if (_trackingMode == CPSegmentSwitchTrackingMomentary)
            {
                objj_msgSend(self, "setSelected:forSegment:", NO, _trackingSegment);

                _selectedSegment = -1;
            }
        }

        objj_msgSend(self, "drawSegmentBezel:highlight:", _trackingSegment, NO);

        _trackingSegment = -1;

        return;
    }

    if (type == CPLeftMouseDown)
    {
        _trackingHighlighted = YES;
        _trackingSegment = objj_msgSend(self, "testSegment:", location);

        objj_msgSend(self, "drawSegmentBezel:highlight:", _trackingSegment, YES);
    }

    else if (type == CPLeftMouseDragged)
    {
        var highlighted = CGRectContainsPoint(_segments[_trackingSegment].frame, location);

        if (highlighted != _trackingHighlighted)
        {
            _trackingHighlighted = highlighted;

            objj_msgSend(self, "drawSegmentBezel:highlight:", _trackingSegment, _trackingHighlighted);
        }
    }

    objj_msgSend(CPApp, "setTarget:selector:forNextEventMatchingMask:untilDate:inMode:dequeue:", self, sel_registerName("trackSegment:"), CPLeftMouseDraggedMask|CPLeftMouseUpMask, nil, nil, YES);
}
});
class_addMethods(the_class, instance_methods);
}

var _CPSegmentMake = function()
{
    return { width:0, image:nil, label:"", menu:nil, selected:NO, enabled:NO, tag:0, labelView:nil, imageView:nil, frame:CGRectMakeZero() }
}

p;10;CPShadow.jI;21;Foundation/CPObject.jc;1929;

{var the_class = objj_allocateClassPair(CPObject, "CPShadow"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_offset"), new objj_ivar("_blurRadius"), new objj_ivar("_color"), new objj_ivar("_cssString"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("shadowWithOffset:blurRadius:color:"), function(self, _cmd, anOffset, aBlurRadius, aColor)
{ with(self)
{
    return objj_msgSend(objj_msgSend(CPShadow, "alloc"), "_initWithOffset:blurRadius:color:", anOffset, aBlurRadius, aColor);
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("_initWithOffset:blurRadius:color:"), function(self, _cmd, anOffset, aBlurRadius, aColor)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
    {
        _offset = anOffset;
        _blurRadius = aBlurRadius;
        _color = aColor;

        _cssString = objj_msgSend(_color, "cssString") + " " + Math.round(anOffset.width) + "px " + Math.round(anOffset.height) + "px " + Math.round(_blurRadius) + "px";
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("shadowOffset"), function(self, _cmd)
{ with(self)
{
    return _offset;
}
});
instance_methods[2] = new objj_method(sel_registerName("shadowBlurRadius"), function(self, _cmd)
{ with(self)
{
    return _blurRadius;
}
});
instance_methods[3] = new objj_method(sel_registerName("shadowColor"), function(self, _cmd)
{ with(self)
{
    return _color;
}
});
instance_methods[4] = new objj_method(sel_registerName("cssString"), function(self, _cmd)
{ with(self)
{
    return _cssString;
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

p;14;CPShadowView.jI;21;Foundation/CPBundle.ji;12;CGGeometry.ji;9;CPImage.ji;13;CPImageView.ji;8;CPView.jc;10086;



CPLightShadow = 0;
CPHeavyShadow = 1;

var CPShadowViewLightTopImage = nil,
    CPShadowViewLightTopLeftImage = nil,
    CPShadowViewLightTopRightImage = nil,
    CPShadowViewLightLeftImage = nil,
    CPShadowViewLightRightImage = nil,
    CPShadowViewLightBottomImage = nil,
    CPShadowViewLightBottomLeftImage = nil,
    CPShadowViewLightBottomRightImage = nil,

    CPShadowViewHeavyTopImage = nil,
    CPShadowViewHeavyTopLeftImage = nil,
    CPShadowViewHeavyTopRightImage = nil,
    CPShadowViewHeavyLeftImage = nil,
    CPShadowViewHeavyRightImage = nil,
    CPShadowViewHeavyBottomImage = nil,
    CPShadowViewHeavyBottomLeftImage = nil,
    CPShadowViewHeavyBottomRightImage = nil;

var LIGHT_LEFT_INSET = 3.0,
    LIGHT_RIGHT_INSET = 3.0,
    LIGHT_TOP_INSET = 3.0,
    LIGHT_BOTTOM_INSET = 5.0,

    HEAVY_LEFT_INSET = 7.0,
    HEAVY_RIGHT_INSET = 7.0,
    HEAVY_TOP_INSET = 5.0,
    HEAVY_BOTTOM_INSET = 5.0;

{var the_class = objj_allocateClassPair(CPNinePartImageView, "CPShadowView"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_weight"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("initialize"), function(self, _cmd)
{ with(self)
{
    if (self != objj_msgSend(CPShadowView, "class"))
        return;

    var bundle = objj_msgSend(CPBundle, "bundleForClass:", objj_msgSend(self, "class"));

    CPShadowViewLightTopImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewLightTop.png"), CGSizeMake(1.0,4.0));
    CPShadowViewLightTopLeftImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewLightTopLeft.png"), CGSizeMake(9.0,9.0));
    CPShadowViewLightTopRightImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewLightTopRight.png"), CGSizeMake(9.0,9.0));
    CPShadowViewLightLeftImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewLightLeft.png"), CGSizeMake(3.0,1.0));
    CPShadowViewLightRightImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewLightRight.png"), CGSizeMake(9.0,1.0));
    CPShadowViewLightBottomImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewLightBottom.png"), CGSizeMake(1.0,9.0));
    CPShadowViewLightBottomLeftImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewLightBottomLeft.png"), CGSizeMake(9.0,9.0));
    CPShadowViewLightBottomRightImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewLightBottomRight.png"), CGSizeMake(9.0,9.0));

    CPShadowViewHeavyTopImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewHeavyTop.png"), CGSizeMake(1.0,17.0));
    CPShadowViewHeavyTopLeftImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewHeavyTopLeft.png"), CGSizeMake(17.0,17.0));
    CPShadowViewHeavyTopRightImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewHeavyTopRight.png"), CGSizeMake(17.0,17.0));
    CPShadowViewHeavyLeftImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewHeavyLeft.png"), CGSizeMake(17.0,1.0));
    CPShadowViewHeavyRightImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewHeavyRight.png"), CGSizeMake(17.0,1.0));
    CPShadowViewHeavyBottomImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewHeavyBottom.png"), CGSizeMake(1.0,17.0));
    CPShadowViewHeavyBottomLeftImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewHeavyBottomLeft.png"), CGSizeMake(17.0,17.0));
    CPShadowViewHeavyBottomRightImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPShadowView/CPShadowViewHeavyBottomRight.png"), CGSizeMake(17.0,17.0));
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPNinePartImageView") }, "initWithFrame:", aFrame);

    if (self)
    {
        _weight = CPLightShadow;

        objj_msgSend(self, "setTopImage:", CPShadowViewLightTopImage);
        objj_msgSend(self, "setTopLeftImage:", CPShadowViewLightTopLeftImage);
        objj_msgSend(self, "setTopRightImage:", CPShadowViewLightTopRightImage);
        objj_msgSend(self, "setLeftImage:", CPShadowViewLightLeftImage);
        objj_msgSend(self, "setRightImage:", CPShadowViewLightRightImage);
        objj_msgSend(self, "setBottomImage:", CPShadowViewLightBottomImage);
        objj_msgSend(self, "setBottomLeftImage:", CPShadowViewLightBottomLeftImage);
        objj_msgSend(self, "setBottomRightImage:", CPShadowViewLightBottomRightImage);

        objj_msgSend(self, "setHitTests:", NO);
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setWeight:"), function(self, _cmd, aWeight)
{ with(self)
{
    if (_weight == aWeight)
        return;

    _weight = aWeight;

    if (_weight == CPLightShadow)
    {
        objj_msgSend(self, "setTopImage:", CPShadowViewLightTopImage);
        objj_msgSend(self, "setTopLeftImage:", CPShadowViewLightTopLeftImage);
        objj_msgSend(self, "setTopRightImage:", CPShadowViewLightTopRightImage);
        objj_msgSend(self, "setLeftImage:", CPShadowViewLightLeftImage);
        objj_msgSend(self, "setRightImage:", CPShadowViewLightRightImage);
        objj_msgSend(self, "setBottomImage:", CPShadowViewLightBottomImage);
        objj_msgSend(self, "setBottomLeftImage:", CPShadowViewLightBottomLeftImage);
        objj_msgSend(self, "setBottomRightImage:", CPShadowViewLightBottomRightImage);
    }
    else
    {
        objj_msgSend(self, "setTopImage:", CPShadowViewHeavyTopImage);
        objj_msgSend(self, "setTopLeftImage:", CPShadowViewHeavyTopLeftImage);
        objj_msgSend(self, "setTopRightImage:", CPShadowViewHeavyTopRightImage);
        objj_msgSend(self, "setLeftImage:", CPShadowViewHeavyLeftImage);
        objj_msgSend(self, "setRightImage:", CPShadowViewHeavyRightImage);
        objj_msgSend(self, "setBottomImage:", CPShadowViewHeavyBottomImage);
        objj_msgSend(self, "setBottomLeftImage:", CPShadowViewHeavyBottomLeftImage);
        objj_msgSend(self, "setBottomRightImage:", CPShadowViewHeavyBottomRightImage);
    }
}
});
instance_methods[2] = new objj_method(sel_registerName("leftInset"), function(self, _cmd)
{ with(self)
{
    return _weight == CPLightShadow ? LIGHT_LEFT_INSET : HEAVY_LEFT_INSET;
}
});
instance_methods[3] = new objj_method(sel_registerName("rightInset"), function(self, _cmd)
{ with(self)
{
    return _weight == CPLightShadow ? LIGHT_RIGHT_INSET : HEAVY_RIGHT_INSET;
}
});
instance_methods[4] = new objj_method(sel_registerName("topInset"), function(self, _cmd)
{ with(self)
{
    return _weight == CPLightShadow ? LIGHT_TOP_INSET : HEAVY_TOP_INSET;
}
});
instance_methods[5] = new objj_method(sel_registerName("bottomInset"), function(self, _cmd)
{ with(self)
{
    return _weight == CPLightShadow ? LIGHT_BOTTOM_INSET : HEAVY_BOTTOM_INSET;
}
});
instance_methods[6] = new objj_method(sel_registerName("horizontalInset"), function(self, _cmd)
{ with(self)
{
    if (_weight == CPLightShadow)
        return LIGHT_LEFT_INSET + LIGHT_RIGHT_INSET;

    return HEAVY_LEFT_INSET + HEAVY_RIGHT_INSET;
}
});
instance_methods[7] = new objj_method(sel_registerName("verticalInset"), function(self, _cmd)
{ with(self)
{
    if (_weight == CPLightShadow)
        return LIGHT_TOP_INSET + LIGHT_BOTTOM_INSET;

    return HEAVY_TOP_INSET + HEAVY_BOTTOM_INSET;
}
});
class_methods[1] = new objj_method(sel_registerName("frameForContentFrame:withWeight:"), function(self, _cmd, aFrame, aWeight)
{ with(self)
{
    if (aWeight == CPLightShadow)
        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);
    else
        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);
}
});
instance_methods[8] = new objj_method(sel_registerName("frameForContentFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    return objj_msgSend(objj_msgSend(self, "class"), "frameForContentFrame:withWeight:", aFrame, _weight);
}
});
instance_methods[9] = new objj_method(sel_registerName("setFrameForContentFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    objj_msgSend(self, "setFrame:", objj_msgSend(self, "frameForContentFrame:", aFrame));
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

p;10;CPSlider.ji;11;CPControl.jc;13121;

var CPSliderHorizontalKnobImage = nil
    CPSliderHorizontalBarLeftImage = nil,
    CPSliderHorizontalBarRightImage = nil,
    CPSliderHorizontalBarCenterImage = nil;

{var the_class = objj_allocateClassPair(CPControl, "CPSlider"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_value"), new objj_ivar("_minValue"), new objj_ivar("_maxValue"), new objj_ivar("_altIncrementValue"), new objj_ivar("_bar"), new objj_ivar("_knob"), new objj_ivar("_isVertical"), new objj_ivar("_standardKnob"), new objj_ivar("_standardVerticalBar"), new objj_ivar("_standardHorizontalBar"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("initialize"), function(self, _cmd)
{ with(self)
{
    if (self != objj_msgSend(CPSlider, "class"))
        return;

    var bundle = objj_msgSend(CPBundle, "bundleForClass:", self);

    CPSliderKnobImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPSlider/CPSliderKnobRegular.png"), CPSizeMake(11.0,11.0)),
    CPSliderKnobPushedImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPSlider/CPSliderKnobRegularPushed.png"), CPSizeMake(11.0,11.0)),
    CPSliderHorizontalBarLeftImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPSlider/CPSliderTrackHorizontalLeft.png"), CPSizeMake(2.0,4.0)),
    CPSliderHorizontalBarRightImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPSlider/CPSliderTrackHorizontalRight.png"), CPSizeMake(2.0,4.0)),
    CPSliderHorizontalBarCenterImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPSlider/CPSliderTrackHorizontalCenter.png"), CPSizeMake(1.0,4.0));
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "initWithFrame:", aFrame);

    if (self)
    {
        _value = 50.0;
        _minValue = 0.0;
        _maxValue = 100.0;

        _bar = objj_msgSend(self, "bar");
        _knob = objj_msgSend(self, "knob");
        _knobSize = objj_msgSend(objj_msgSend(self, "knobImage"), "size");
        _isVertical = objj_msgSend(self, "isVertical");

        objj_msgSend(_knob, "setFrameOrigin:", objj_msgSend(self, "knobPosition"));

        objj_msgSend(self, "addSubview:", _bar);
        objj_msgSend(self, "addSubview:", _knob);
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setFrameSize:"), function(self, _cmd, aSize)
{ with(self)
{
    if(aSize.height > 21.0)
        aSize.height = 21.0;

    if (_isVertical != objj_msgSend(self, "isVertical"))
    {
        _isVertical = objj_msgSend(self, "isVertical");

        var bar = objj_msgSend(self, "bar"),
            knob = objj_msgSend(self, "knob");

        if (_bar != bar)
            objj_msgSend(self, "replaceSubview:withView:", _bar=bar, _bar);

        if (_knob != knob)
        {
            objj_msgSend(self, "replaceSubview:withView:", knob, _knob);

            _knob = knob;
            objj_msgSend(_knob, "setFrameOrigin:", objj_msgSend(self, "knobPosition"));
        }
    }

    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "setFrameSize:", aSize);

    objj_msgSend(_knob, "setFrameOrigin:", objj_msgSend(self, "knobPosition"));
}
});
instance_methods[2] = new objj_method(sel_registerName("altIncrementValue"), function(self, _cmd)
{ with(self)
{
    return _altIncrementValue;
}
});
instance_methods[3] = new objj_method(sel_registerName("knobThickness"), function(self, _cmd)
{ with(self)
{
    return CPRectGetWidth(objj_msgSend(_knob, "frame"));
}
});
instance_methods[4] = new objj_method(sel_registerName("leftTrackImage"), function(self, _cmd)
{ with(self)
{
    return CPSliderHorizontalBarLeftImage;
}
});
instance_methods[5] = new objj_method(sel_registerName("rightTrackImage"), function(self, _cmd)
{ with(self)
{
    return CPSliderHorizontalBarRightImage;
}
});
instance_methods[6] = new objj_method(sel_registerName("centerTrackImage"), function(self, _cmd)
{ with(self)
{
    return CPSliderHorizontalBarCenterImage
}
});
instance_methods[7] = new objj_method(sel_registerName("knobImage"), function(self, _cmd)
{ with(self)
{
    return CPSliderKnobImage;
}
});
instance_methods[8] = new objj_method(sel_registerName("pushedKnobImage"), function(self, _cmd)
{ with(self)
{
    return CPSliderKnobPushedImage;
}
});
instance_methods[9] = new objj_method(sel_registerName("knob"), function(self, _cmd)
{ with(self)
{
    if (!_standardKnob)
    {
        var knobImage = objj_msgSend(self, "knobImage"),
            knobSize = objj_msgSend(knobImage, "size");

        _standardKnob = objj_msgSend(objj_msgSend(CPImageView, "alloc"), "initWithFrame:", CPRectMake(0.0,0.0,knobSize.width,knobSize.height));

        objj_msgSend(_standardKnob, "setImage:", knobImage);
    }

    return _standardKnob;
}
});
instance_methods[10] = new objj_method(sel_registerName("bar"), function(self, _cmd)
{ with(self)
{

    if (objj_msgSend(self, "isVertical"))
        return nil;
    else
    {
        if (!_standardHorizontalBar)
        {
            var frame = objj_msgSend(self, "frame"),
                barFrame = CPRectMake(0.0, 0.0, CPRectGetWidth(frame), 5.0);

            _standardHorizontalBar = objj_msgSend(objj_msgSend(CPThreePartImageView, "alloc"), "initWithFrame:", barFrame);

            objj_msgSend(_standardHorizontalBar, "setLeftImage:", objj_msgSend(self, "leftTrackImage"));
            objj_msgSend(_standardHorizontalBar, "setRightImage:", objj_msgSend(self, "rightTrackImage"));
            objj_msgSend(_standardHorizontalBar, "setCenterImage:", objj_msgSend(self, "centerTrackImage"));

            objj_msgSend(_standardHorizontalBar, "setFrame:", CPRectMake(0.0,(CPRectGetHeight(frame)-CPRectGetHeight(barFrame))/2.0,CPRectGetWidth(_isVertical?barFrame:frame),CPRectGetHeight(_isVertical?frame:barFrame)));
            objj_msgSend(_standardHorizontalBar, "setAutoresizingMask:", _isVertical?CPViewHeightSizable:CPViewWidthSizable);
        }

        return _standardHorizontalBar;
    }
}
});
instance_methods[11] = new objj_method(sel_registerName("setAltIncrementValue:"), function(self, _cmd, anIncrementValue)
{ with(self)
{
    _altIncrementValue = anIncrementValue;
}
});
instance_methods[12] = new objj_method(sel_registerName("isVertical"), function(self, _cmd)
{ with(self)
{
    var frame = objj_msgSend(self, "frame");

    if (CPRectGetWidth(frame) == CPRectGetHeight(frame))
        return -1;

    return CPRectGetWidth(frame) < CPRectGetHeight(frame);
}
});
instance_methods[13] = new objj_method(sel_registerName("maxValue"), function(self, _cmd)
{ with(self)
{
    return _maxValue;
}
});
instance_methods[14] = new objj_method(sel_registerName("minValue"), function(self, _cmd)
{ with(self)
{
    return _minValue;
}
});
instance_methods[15] = new objj_method(sel_registerName("setMaxValue:"), function(self, _cmd, aMaxValue)
{ with(self)
{
    _maxValue = aMaxValue;
}
});
instance_methods[16] = new objj_method(sel_registerName("setMinValue:"), function(self, _cmd, aMinValue)
{ with(self)
{
    _minValue = aMinValue;
}
});
instance_methods[17] = new objj_method(sel_registerName("setValue:"), function(self, _cmd, aValue)
{ with(self)
{
    _value = aValue;

    objj_msgSend(_knob, "setFrameOrigin:", objj_msgSend(self, "knobPosition"));
}
});
instance_methods[18] = new objj_method(sel_registerName("value"), function(self, _cmd)
{ with(self)
{
    return _value;
}
});
instance_methods[19] = new objj_method(sel_registerName("knobPosition"), function(self, _cmd)
{ with(self)
{
    if (objj_msgSend(self, "isVertical"))
        return CPPointMake(0.0, 0.0);
    else
        return CPPointMake(
            ((_value - _minValue) / (_maxValue - _minValue)) * (CPRectGetWidth(objj_msgSend(self, "frame")) - CPRectGetWidth(objj_msgSend(_knob, "frame"))),
            (CPRectGetHeight(objj_msgSend(self, "frame")) - CPRectGetHeight(objj_msgSend(_knob, "frame"))) / 2.0);
}
});
instance_methods[20] = new objj_method(sel_registerName("valueForKnobPosition:"), function(self, _cmd, aPoint)
{ with(self)
{
    if (objj_msgSend(self, "isVertical"))
        return 0.0;
    else
        return Math.max(Math.min((aPoint.x) * (_maxValue - _minValue) / ( CPRectGetWidth(objj_msgSend(self, "frame")) - CPRectGetWidth(objj_msgSend(_knob, "frame")) ) + _minValue, _maxValue), _minValue);
}
});
instance_methods[21] = new objj_method(sel_registerName("constrainKnobPosition:"), function(self, _cmd, aPoint)
{ with(self)
{

    aPoint.x -= _knobSize.width / 2.0;
    return CPPointMake(Math.max(Math.min(CPRectGetWidth(objj_msgSend(self, "bounds")) - _knobSize.width, aPoint.x), 0.0), (CPRectGetHeight(objj_msgSend(self, "bounds")) - CPRectGetHeight(objj_msgSend(_knob, "frame"))) / 2.0);
}
});
instance_methods[22] = new objj_method(sel_registerName("mouseUp:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(objj_msgSend(self, "knob"), "setImage:", objj_msgSend(self, "knobImage"));

    if (objj_msgSend(_target, "respondsToSelector:", sel_registerName("sliderDidFinish:")))
        objj_msgSend(_target, "sliderDidFinish:", self);
}
});
instance_methods[23] = new objj_method(sel_registerName("mouseDown:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(_knob, "setFrameOrigin:", objj_msgSend(self, "constrainKnobPosition:", objj_msgSend(self, "convertPoint:fromView:", objj_msgSend(anEvent, "locationInWindow"), nil)));

    _value = objj_msgSend(self, "valueForKnobPosition:", objj_msgSend(_knob, "frame").origin);

    objj_msgSend(objj_msgSend(self, "knob"), "setImage:", objj_msgSend(self, "pushedKnobImage"));
    objj_msgSend(self, "sendAction:to:", _action, _target);
}
});
instance_methods[24] = new objj_method(sel_registerName("mouseDragged:"), function(self, _cmd, anEvent)
{ with(self)
{
    objj_msgSend(_knob, "setFrameOrigin:", objj_msgSend(self, "constrainKnobPosition:", objj_msgSend(self, "convertPoint:fromView:", objj_msgSend(anEvent, "locationInWindow"), nil)));

    _value = objj_msgSend(self, "valueForKnobPosition:", objj_msgSend(_knob, "frame").origin);

    objj_msgSend(self, "sendAction:to:", _action, _target);
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

var CPHUDSliderKnobImage = nil,
    CPHUDSliderHorizontalBarLeftImage = nil,
    CPHUDSliderHorizontalBarRightImage = nil,
    CPHUDSliderHorizontalBarCenterImage = nil;

{var the_class = objj_allocateClassPair(CPSlider, "CPHUDSlider"),
meta_class = _class_getMeta(the_class);objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("initialize"), function(self, _cmd)
{ with(self)
{
    if (self != objj_msgSend(CPHUDSlider, "class"))
        return;

    var bundle = objj_msgSend(CPBundle, "bundleForClass:", self);

    CPHUDSliderKnobImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "HUDTheme/CPSliderHorizontalKnob.png"), CPSizeMake(12.0,12.0)),
    CPHUDSliderHorizontalBarLeftImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "HUDTheme/CPSliderHorizontalBarLeft.png"), CPSizeMake(3.0,4.0)),
    CPHUDSliderHorizontalBarRightImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "HUDTheme/CPSliderHorizontalBarRight.png"), CPSizeMake(3.0,4.0)),
    CPHUDSliderHorizontalBarCenterImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "HUDTheme/CPSliderHorizontalBarCenter.png"), CPSizeMake(1.0,4.0));
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("leftTrackImage"), function(self, _cmd)
{ with(self)
{
    return CPHUDSliderHorizontalBarLeftImage;
}
});
instance_methods[1] = new objj_method(sel_registerName("rightTrackImage"), function(self, _cmd)
{ with(self)
{
    return CPHUDSliderHorizontalBarRightImage;
}
});
instance_methods[2] = new objj_method(sel_registerName("centerTrackImage"), function(self, _cmd)
{ with(self)
{
    return CPHUDSliderHorizontalBarCenterImage
}
});
instance_methods[3] = new objj_method(sel_registerName("knobImage"), function(self, _cmd)
{ with(self)
{
    return CPHUDSliderKnobImage;
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

p;21;CPSliderColorPicker.jI;23;Foundation/Foundation.jI;15;AppKit/CPView.jI;17;AppKit/CPSlider.jI;22;AppKit/CPColorPicker.jI;21;AppKit/CPColorPanel.jc;16595;

{var the_class = objj_allocateClassPair(CPColorPicker, "CPSliderColorPicker"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_contentView"), new objj_ivar("_redSlider"), new objj_ivar("_greenSlider"), new objj_ivar("_blueSlider"), new objj_ivar("_hueSlider"), new objj_ivar("_saturationSlider"), new objj_ivar("_brightnessSlider"), new objj_ivar("_rgbLabel"), new objj_ivar("_hsbLabel"), new objj_ivar("_redLabel"), new objj_ivar("_greenLabel"), new objj_ivar("_blueLabel"), new objj_ivar("_hueLabel"), new objj_ivar("_saturationLabel"), new objj_ivar("_brightnessLabel"), new objj_ivar("_hexLabel"), new objj_ivar("_redValue"), new objj_ivar("_greenValue"), new objj_ivar("_blueValue"), new objj_ivar("_hueValue"), new objj_ivar("_saturationValue"), new objj_ivar("_brightnessValue"), new objj_ivar("_hexValue"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithPickerMask:colorPanel:"), function(self, _cmd, mask, owningColorPanel)
{ with(self)
{
    return objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPColorPicker") }, "initWithPickerMask:colorPanel:", mask, owningColorPanel);
}
});
instance_methods[1] = new objj_method(sel_registerName("initView"), function(self, _cmd)
{ with(self)
{
    aFrame = CPRectMake(0, 0, CPColorPickerViewWidth, CPColorPickerViewHeight);
    _contentView = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", aFrame);

    _rgbLabel = objj_msgSend(objj_msgSend(CPTextField, "alloc"), "initWithFrame:", CPRectMake(0,10,100,20));
    objj_msgSend(_rgbLabel, "setStringValue:", "RGB");
    objj_msgSend(_rgbLabel, "setTextColor:", objj_msgSend(CPColor, "whiteColor"));

    _redLabel = objj_msgSend(objj_msgSend(CPTextField, "alloc"), "initWithFrame:", CPRectMake(0,35,15,20));
    objj_msgSend(_redLabel, "setStringValue:", "R");
    objj_msgSend(_redLabel, "setTextColor:", objj_msgSend(CPColor, "whiteColor"));

    _redSlider = objj_msgSend(objj_msgSend(CPSlider, "alloc"), "initWithFrame:", CPRectMake(15,35,aFrame.size.width-70,20));
    objj_msgSend(_redSlider, "setMaxValue:", 1.0);
    objj_msgSend(_redSlider, "setMinValue:", 0.0);
    objj_msgSend(_redSlider, "setTarget:", self);
    objj_msgSend(_redSlider, "setAction:", sel_registerName("sliderChanged:"));
    objj_msgSend(_redSlider, "setAutoresizingMask:", CPViewWidthSizable);

    var updateFunction = function(aDOMEvent)
    {
        if(isNaN(this.value))
            return;

        switch(this)
        {
            case _redValue: objj_msgSend(_redSlider, "setValue:", MAX(MIN(ROUND(this.value),255)/255.0,0));
                                   objj_msgSend(self, "sliderChanged:", _redSlider);
                                   break;

            case _greenValue: objj_msgSend(_greenSlider, "setValue:", MAX(MIN(ROUND(this.value),255)/255.0,0));
                                   objj_msgSend(self, "sliderChanged:", _greenSlider);
                                   break;

            case _blueValue: objj_msgSend(_blueSlider, "setValue:", MAX(MIN(ROUND(this.value),255)/255.0,0));
                                   objj_msgSend(self, "sliderChanged:", _blueSlider);
                                   break;

            case _hueValue: objj_msgSend(_hueSlider, "setValue:", MAX(MIN(ROUND(this.value),360),0));
                                   objj_msgSend(self, "sliderChanged:", _hueSlider);
                                   break;

            case _saturationValue: objj_msgSend(_saturationSlider, "setValue:", MAX(MIN(ROUND(this.value),100),0));
                                   objj_msgSend(self, "sliderChanged:", _saturationSlider);
                                   break;

            case _brightnessValue: objj_msgSend(_brightnessSlider, "setValue:", MAX(MIN(ROUND(this.value),100),0));
                                   objj_msgSend(self, "sliderChanged:", _brightnessSlider);
                                   break;
        }

        this.blur();
    };

    var keypressFunction = function(aDOMEvent)
    {
        aDOMEvent = aDOMEvent || window.event;
        if (aDOMEvent.keyCode == 13)
        {
            updateFunction(aDOMEvent);

            if(aDOMEvent.preventDefault)
                aDOMEvent.preventDefault();
            else if(aDOMEvent.stopPropagation)
                aDOMEvent.stopPropagation();
        }
    }


    var redValue = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", CPRectMake(aFrame.size.width-45,35,45,20));
    objj_msgSend(redValue, "setAutoresizingMask:", CPViewMinXMargin);

    _redValue = document.createElement("input");
    _redValue.style.width = "40px";
    _redValue.style.backgroundColor = "transparent";
    _redValue.style.border = "1px solid white";
    _redValue.style.color = "white";
    _redValue.style.position = "absolute";
    _redValue.style.top = "0px";
    _redValue.style.left = "0px";
    _redValue.onchange = updateFunction;

    redValue._DOMElement.appendChild(_redValue);
    objj_msgSend(_contentView, "addSubview:", redValue);

    _greenLabel = objj_msgSend(objj_msgSend(CPTextField, "alloc"), "initWithFrame:", CPRectMake(0,58,15,20));
    objj_msgSend(_greenLabel, "setStringValue:", "G");
    objj_msgSend(_greenLabel, "setTextColor:", objj_msgSend(CPColor, "whiteColor"));

    _greenSlider = objj_msgSend(objj_msgSend(CPSlider, "alloc"), "initWithFrame:", CPRectMake(15,58,aFrame.size.width-70,20));
    objj_msgSend(_greenSlider, "setMaxValue:", 1.0);
    objj_msgSend(_greenSlider, "setMinValue:", 0.0);
    objj_msgSend(_greenSlider, "setTarget:", self);
    objj_msgSend(_greenSlider, "setAction:", sel_registerName("sliderChanged:"));
    objj_msgSend(_greenSlider, "setAutoresizingMask:", CPViewWidthSizable);


    var greenValue = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", CPRectMake(aFrame.size.width-45,58,45,20));
    objj_msgSend(greenValue, "setAutoresizingMask:", CPViewMinXMargin);

    _greenValue = _redValue.cloneNode(false);
    _greenValue.onchange = updateFunction;

    greenValue._DOMElement.appendChild(_greenValue);
    objj_msgSend(_contentView, "addSubview:", greenValue);

    _blueLabel = objj_msgSend(objj_msgSend(CPTextField, "alloc"), "initWithFrame:", CPRectMake(0,81,15,20));
    objj_msgSend(_blueLabel, "setStringValue:", "B");
    objj_msgSend(_blueLabel, "setTextColor:", objj_msgSend(CPColor, "whiteColor"));

    _blueSlider = objj_msgSend(objj_msgSend(CPSlider, "alloc"), "initWithFrame:", CPRectMake(15,81,aFrame.size.width-70,20));
    objj_msgSend(_blueSlider, "setMaxValue:", 1.0);
    objj_msgSend(_blueSlider, "setMinValue:", 0.0);
    objj_msgSend(_blueSlider, "setTarget:", self);
    objj_msgSend(_blueSlider, "setAction:", sel_registerName("sliderChanged:"));
    objj_msgSend(_blueSlider, "setAutoresizingMask:", CPViewWidthSizable);


    var blueValue = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", CPRectMake(aFrame.size.width-45,81,45,20));
    objj_msgSend(blueValue, "setAutoresizingMask:", CPViewMinXMargin);

    _blueValue = _redValue.cloneNode(false);
    _blueValue.onchange = updateFunction;

    blueValue._DOMElement.appendChild(_blueValue);
    objj_msgSend(_contentView, "addSubview:", blueValue);

    _hsbLabel = objj_msgSend(objj_msgSend(CPTextField, "alloc"), "initWithFrame:", CPRectMake(0,120,100,20));
    objj_msgSend(_hsbLabel, "setStringValue:", "HSB");
    objj_msgSend(_hsbLabel, "setTextColor:", objj_msgSend(CPColor, "whiteColor"));

    _hueLabel = objj_msgSend(objj_msgSend(CPTextField, "alloc"), "initWithFrame:", CPRectMake(0,145,15,20));
    objj_msgSend(_hueLabel, "setStringValue:", "H");
    objj_msgSend(_hueLabel, "setTextColor:", objj_msgSend(CPColor, "whiteColor"));

    _hueSlider = objj_msgSend(objj_msgSend(CPSlider, "alloc"), "initWithFrame:", CPRectMake(15,145,aFrame.size.width-70,20));
    objj_msgSend(_hueSlider, "setMaxValue:", 359.0);
    objj_msgSend(_hueSlider, "setMinValue:", 0.0);
    objj_msgSend(_hueSlider, "setTarget:", self);
    objj_msgSend(_hueSlider, "setAction:", sel_registerName("sliderChanged:"));
    objj_msgSend(_hueSlider, "setAutoresizingMask:", CPViewWidthSizable);


    var hueValue = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", CPRectMake(aFrame.size.width-45,145,45,20));
    objj_msgSend(hueValue, "setAutoresizingMask:", CPViewMinXMargin);

    _hueValue = _redValue.cloneNode(false);
    _hueValue.onchange = updateFunction;

    hueValue._DOMElement.appendChild(_hueValue);
    objj_msgSend(_contentView, "addSubview:", hueValue);

    _saturationLabel = objj_msgSend(objj_msgSend(CPTextField, "alloc"), "initWithFrame:", CPRectMake(0,168,15,20));
    objj_msgSend(_saturationLabel, "setStringValue:", "S");
    objj_msgSend(_saturationLabel, "setTextColor:", objj_msgSend(CPColor, "whiteColor"));

    _saturationSlider = objj_msgSend(objj_msgSend(CPSlider, "alloc"), "initWithFrame:", CPRectMake(15,168,aFrame.size.width-70,20));
    objj_msgSend(_saturationSlider, "setMaxValue:", 100.0);
    objj_msgSend(_saturationSlider, "setMinValue:", 0.0);
    objj_msgSend(_saturationSlider, "setTarget:", self);
    objj_msgSend(_saturationSlider, "setAction:", sel_registerName("sliderChanged:"));
    objj_msgSend(_saturationSlider, "setAutoresizingMask:", CPViewWidthSizable);


    var saturationValue = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", CPRectMake(aFrame.size.width-45,168,45,20));
    objj_msgSend(saturationValue, "setAutoresizingMask:", CPViewMinXMargin);

    _saturationValue = _redValue.cloneNode(false);
    _saturationValue.onchange = updateFunction;

    saturationValue._DOMElement.appendChild(_saturationValue);
    objj_msgSend(_contentView, "addSubview:", saturationValue);

    _brightnessLabel = objj_msgSend(objj_msgSend(CPTextField, "alloc"), "initWithFrame:", CPRectMake(0,191,15,20));
    objj_msgSend(_brightnessLabel, "setStringValue:", "B");
    objj_msgSend(_brightnessLabel, "setTextColor:", objj_msgSend(CPColor, "whiteColor"));

    _brightnessSlider = objj_msgSend(objj_msgSend(CPSlider, "alloc"), "initWithFrame:", CPRectMake(15,191,aFrame.size.width-70,20));
    objj_msgSend(_brightnessSlider, "setMaxValue:", 100.0);
    objj_msgSend(_brightnessSlider, "setMinValue:", 0.0);
    objj_msgSend(_brightnessSlider, "setTarget:", self);
    objj_msgSend(_brightnessSlider, "setAction:", sel_registerName("sliderChanged:"));
    objj_msgSend(_brightnessSlider, "setAutoresizingMask:", CPViewWidthSizable);


    var brightnessValue = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", CPRectMake(aFrame.size.width-45,191,45,20));
    objj_msgSend(brightnessValue, "setAutoresizingMask:", CPViewMinXMargin);

    _brightnessValue = _redValue.cloneNode(false);
    _brightnessValue.onchange = updateFunction;

    brightnessValue._DOMElement.appendChild(_brightnessValue);
    objj_msgSend(_contentView, "addSubview:", brightnessValue);

    _hexLabel = objj_msgSend(objj_msgSend(CPTextField, "alloc"), "initWithFrame:", CPRectMake(0,230,100,20));
    objj_msgSend(_hexLabel, "setStringValue:", "Hex");
    objj_msgSend(_hexLabel, "setTextColor:", objj_msgSend(CPColor, "whiteColor"));


    _hexValue = _redValue.cloneNode(false);
    _hexValue.style.top = "255px";
    _hexValue.style.width = "80px";
    _hexValue.style.left = "0px";
    _hexValue.onkeypress = function(aDOMEvent)
    {
        aDOMEvent = aDOMEvent || window.event;
        if (aDOMEvent.keyCode == 13)
        {
            var newColor = objj_msgSend(CPColor, "colorWithHexString:", this.value);

            if(newColor)
            {
                objj_msgSend(self, "setColor:", newColor);
                objj_msgSend(objj_msgSend(self, "colorPanel"), "setColor:", newColor);
            }

            if(aDOMEvent.preventDefault)
                aDOMEvent.preventDefault();
            else if(aDOMEvent.stopPropagation)
                aDOMEvent.stopPropagation();

            this.blur();
        }
    };

    _contentView._DOMElement.appendChild(_hexValue);

    objj_msgSend(_contentView, "addSubview:", _rgbLabel);
    objj_msgSend(_contentView, "addSubview:", _redLabel);
    objj_msgSend(_contentView, "addSubview:", _greenLabel);
    objj_msgSend(_contentView, "addSubview:", _blueLabel);
    objj_msgSend(_contentView, "addSubview:", _redSlider);
    objj_msgSend(_contentView, "addSubview:", _greenSlider);
    objj_msgSend(_contentView, "addSubview:", _blueSlider);

    objj_msgSend(_contentView, "addSubview:", _hsbLabel);
    objj_msgSend(_contentView, "addSubview:", _hueLabel);
    objj_msgSend(_contentView, "addSubview:", _saturationLabel);
    objj_msgSend(_contentView, "addSubview:", _brightnessLabel);
    objj_msgSend(_contentView, "addSubview:", _hueSlider);
    objj_msgSend(_contentView, "addSubview:", _saturationSlider);
    objj_msgSend(_contentView, "addSubview:", _brightnessSlider);

    objj_msgSend(_contentView, "addSubview:", _hexLabel);
}
});
instance_methods[2] = new objj_method(sel_registerName("provideNewView:"), function(self, _cmd, initialRequest)
{ with(self)
{
    if (initialRequest)
        objj_msgSend(self, "initView");

    return _contentView;
}
});
instance_methods[3] = new objj_method(sel_registerName("currentMode"), function(self, _cmd)
{ with(self)
{
    return CPSliderColorPickerMode;
}
});
instance_methods[4] = new objj_method(sel_registerName("supportsMode:"), function(self, _cmd, mode)
{ with(self)
{
    return (mode == CPSliderColorPickerMode) ? YES : NO;
}
});
instance_methods[5] = new objj_method(sel_registerName("sliderChanged:"), function(self, _cmd, sender)
{ with(self)
{
    var newColor;

    switch(sender)
    {
        case _hueSlider:
        case _saturationSlider:
        case _brightnessSlider: newColor = objj_msgSend(CPColor, "colorWithHue:saturation:brightness:", objj_msgSend(_hueSlider, "value"), objj_msgSend(_saturationSlider, "value"), objj_msgSend(_brightnessSlider, "value"));

                                        objj_msgSend(self, "updateRGBSliders:", newColor);
                                        break;

        case _redSlider:
        case _greenSlider:
        case _blueSlider: newColor = objj_msgSend(CPColor, "colorWithCalibratedRed:green:blue:alpha:", objj_msgSend(_redSlider, "value"), objj_msgSend(_greenSlider, "value"), objj_msgSend(_blueSlider, "value"), 1.0);

                                        objj_msgSend(self, "updateHSBSliders:", newColor);
                                        break;
    }

    objj_msgSend(self, "updateLabels");
    objj_msgSend(self, "updateHex:", newColor);
    objj_msgSend(objj_msgSend(self, "colorPanel"), "setColor:", newColor);
}
});
instance_methods[6] = new objj_method(sel_registerName("setColor:"), function(self, _cmd, aColor)
{ with(self)
{
    objj_msgSend(self, "updateRGBSliders:", aColor);
    objj_msgSend(self, "updateHSBSliders:", aColor);
    objj_msgSend(self, "updateHex:", aColor);
    objj_msgSend(self, "updateLabels");
}
});
instance_methods[7] = new objj_method(sel_registerName("updateHSBSliders:"), function(self, _cmd, aColor)
{ with(self)
{
    var hsb = objj_msgSend(aColor, "hsbComponents");

    objj_msgSend(_hueSlider, "setValue:", hsb[0]);
    objj_msgSend(_saturationSlider, "setValue:", hsb[1]);
    objj_msgSend(_brightnessSlider, "setValue:", hsb[2]);
}
});
instance_methods[8] = new objj_method(sel_registerName("updateHex:"), function(self, _cmd, aColor)
{ with(self)
{
    _hexValue.value = objj_msgSend(aColor, "hexString");
}
});
instance_methods[9] = new objj_method(sel_registerName("updateRGBSliders:"), function(self, _cmd, aColor)
{ with(self)
{
    var rgb = objj_msgSend(aColor, "components");

    objj_msgSend(_redSlider, "setValue:", rgb[0]);
    objj_msgSend(_greenSlider, "setValue:", rgb[1]);
    objj_msgSend(_blueSlider, "setValue:", rgb[2]);
}
});
instance_methods[10] = new objj_method(sel_registerName("updateLabels"), function(self, _cmd)
{ with(self)
{
    _hueValue.value = ROUND(objj_msgSend(_hueSlider, "value"));
    _saturationValue.value = ROUND(objj_msgSend(_saturationSlider, "value"));
    _brightnessValue.value = ROUND(objj_msgSend(_brightnessSlider, "value"));

    _redValue.value = ROUND(objj_msgSend(_redSlider, "value") * 255);
    _greenValue.value = ROUND(objj_msgSend(_greenSlider, "value") * 255);
    _blueValue.value = ROUND(objj_msgSend(_blueSlider, "value") * 255);
}
});
class_addMethods(the_class, instance_methods);
}

p;17;CPStringDrawing.jI;21;Foundation/CPString.jc;435;

{
var the_class = objj_getClass("CPString")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPString\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("cssString"), function(self, _cmd)
{ with(self)
{
    return self;
}
});
class_addMethods(the_class, instance_methods);
}

p;11;CPTabView.ji;13;CPImageView.ji;15;CPTabViewItem.ji;8;CPView.jc;25250;


CPTopTabsBezelBorder = 0;



CPNoTabsBezelBorder = 4;
CPNoTabsLineBorder = 5;
CPNoTabsNoBorder = 6;

var CPTabViewBezelBorderLeftImage = nil,
    CPTabViewBackgroundCenterImage = nil,
    CPTabViewBezelBorderRightImage = nil,
    CPTabViewBezelBorderColor = nil;

var LEFT_INSET = 7.0,
    RIGHT_INSET = 7.0;

var CPTabViewDidSelectTabViewItemSelector = 1,
    CPTabViewShouldSelectTabViewItemSelector = 2,
    CPTabViewWillSelectTabViewItemSelector = 4,
    CPTabViewDidChangeNumberOfTabViewItemsSelector = 8;

{var the_class = objj_allocateClassPair(CPView, "CPTabView"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_labelsView"), new objj_ivar("_backgroundView"), new objj_ivar("_separatorView"), new objj_ivar("_auxiliaryView"), new objj_ivar("_contentView"), new objj_ivar("_tabViewItems"), new objj_ivar("_selectedTabViewItem"), new objj_ivar("_tabViewType"), new objj_ivar("_delegate"), new objj_ivar("_delegateSelectors"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("initialize"), function(self, _cmd)
{ with(self)
{
    if (self != CPTabView)
        return;

    var bundle = objj_msgSend(CPBundle, "bundleForClass:", self);

    CPTabViewBezelBorderLeftImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPTabView/CPTabViewBezelBorderLeft.png"), CGSizeMake(7.0,1.0));
    CPTabViewBackgroundCenterImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPTabView/CPTabViewBezelBackgroundCenter.png"), CGSizeMake(1.0,1.0));
    CPTabViewBezelBorderRightImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPTabView/CPTabViewBezelBorderRight.png"), CGSizeMake(7.0,1.0));
    CPTabViewBezerBorderImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPTabView/CPTabViewBezelBorder.png"), CGSizeMake(1.0,1.0));

    CPTabViewBezelBorderColor = objj_msgSend(CPColor, "colorWithPatternImage:", CPTabViewBezerBorderImage);
}
});
class_methods[1] = new objj_method(sel_registerName("bezelBorderColor"), function(self, _cmd)
{ with(self)
{
    return CPTabViewBezelBorderColor;
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "initWithFrame:", aFrame);

    if (self)
    {
        _tabViewType = CPTopTabsBezelBorder;
        _tabViewItems = [];
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("viewDidMoveToWindow"), function(self, _cmd)
{ with(self)
{
    if (_tabViewType != CPTopTabsBezelBorder || _labelsView)
        return;

    objj_msgSend(self, "_createBezelBorder");
    objj_msgSend(self, "layoutSubviews");
}
});
instance_methods[2] = new objj_method(sel_registerName("_createBezelBorder"), function(self, _cmd)
{ with(self)
{
    var bounds = objj_msgSend(self, "bounds");

    _labelsView = objj_msgSend(objj_msgSend(_CPTabLabelsView, "alloc"), "initWithFrame:", CGRectMake(0.0,0.0,CGRectGetWidth(bounds),0.0));

    objj_msgSend(_labelsView, "setTabView:", self);
    objj_msgSend(_labelsView, "setAutoresizingMask:", CPViewWidthSizable);

    objj_msgSend(self, "addSubview:", _labelsView);

    _backgroundView = objj_msgSend(objj_msgSend(CPNinePartImageView, "alloc"), "initWithFrame:", CGRectMakeZero());

    objj_msgSend(_backgroundView, "setLeftImage:", CPTabViewBezelBorderLeftImage);
    objj_msgSend(_backgroundView, "setCenterImage:", CPTabViewBackgroundCenterImage);
    objj_msgSend(_backgroundView, "setRightImage:", CPTabViewBezelBorderRightImage);

    objj_msgSend(_backgroundView, "setBottomLeftImage:", CPTabViewBezelBorderLeftImage);
    objj_msgSend(_backgroundView, "setBottomImage:", CPTabViewBezerBorderImage);
    objj_msgSend(_backgroundView, "setBottomRightImage:", CPTabViewBezelBorderRightImage);

    objj_msgSend(_backgroundView, "setAutoresizingMask:", CPViewWidthSizable|CPViewHeightSizable);

    objj_msgSend(self, "addSubview:", _backgroundView);

    _separatorView = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", CGRectMakeZero());

    objj_msgSend(_separatorView, "setBackgroundColor:", objj_msgSend(objj_msgSend(self, "class"), "bezelBorderColor"));
    objj_msgSend(_separatorView, "setAutoresizingMask:", CPViewWidthSizable|CPViewMaxYMargin);

    objj_msgSend(self, "addSubview:", _separatorView);
}
});
instance_methods[3] = new objj_method(sel_registerName("layoutSubviews"), function(self, _cmd)
{ with(self)
{
    if (_tabViewType == CPTopTabsBezelBorder)
    {
        var backgroundRect = CGRectMakeCopy(objj_msgSend(self, "bounds")),
            labelsViewHeight = objj_msgSend(_CPTabLabelsView, "height");

        backgroundRect.origin.y += labelsViewHeight;
        backgroundRect.size.height -= labelsViewHeight;

        objj_msgSend(_backgroundView, "setFrame:", backgroundRect);

        var auxiliaryViewHeight = 5.0;

        if (_auxiliaryView)
        {
            auxiliaryViewHeight = CGRectGetHeight(objj_msgSend(_auxiliaryView, "frame"));

            objj_msgSend(_auxiliaryView, "setFrame:", CGRectMake(LEFT_INSET,labelsViewHeight,CGRectGetWidth(backgroundRect)-LEFT_INSET-RIGHT_INSET,auxiliaryViewHeight));
        }

        objj_msgSend(_separatorView, "setFrame:", CGRectMake(LEFT_INSET,labelsViewHeight+auxiliaryViewHeight,CGRectGetWidth(backgroundRect)-LEFT_INSET-RIGHT_INSET,1.0));
    }


    objj_msgSend(_contentView, "setFrame:", objj_msgSend(self, "contentRect"));
}
});
instance_methods[4] = new objj_method(sel_registerName("addTabViewItem:"), function(self, _cmd, aTabViewItem)
{ with(self)
{
    objj_msgSend(self, "insertTabViewItem:atIndex:", aTabViewItem, objj_msgSend(_tabViewItems, "count"));
}
});
instance_methods[5] = new objj_method(sel_registerName("insertTabViewItem:atIndex:"), function(self, _cmd, aTabViewItem, anIndex)
{ with(self)
{
    objj_msgSend(_tabViewItems, "insertObject:atIndex:", aTabViewItem, anIndex);

    objj_msgSend(_labelsView, "tabView:didAddTabViewItem:", self, aTabViewItem);

    if (objj_msgSend(_tabViewItems, "count") == 1)
        objj_msgSend(self, "selectFirstTabViewItem:", self);

    if (_delegateSelectors & CPTabViewDidChangeNumberOfTabViewItemsSelector)
        objj_msgSend(_delegate, "tabViewDidChangeNumberOfTabViewItems:", self);
}
});
instance_methods[6] = new objj_method(sel_registerName("removeTabViewItem:"), function(self, _cmd, aTabViewItem)
{ with(self)
{
    objj_msgSend(_tabViewItems, "removeObjectIdenticalTo:", aTabViewItem);

    objj_msgSend(_labelsView, "tabView:didRemoveTabViewItem:", self, aTabViewItem);

    if (_delegateSelectors & CPTabViewDidChangeNumberOfTabViewItemsSelector)
        objj_msgSend(_delegate, "tabViewDidChangeNumberOfTabViewItems:", self);
}
});
instance_methods[7] = new objj_method(sel_registerName("indexOfTabViewItem:"), function(self, _cmd, aTabViewItem)
{ with(self)
{
    return objj_msgSend(_tabViewItems, "indexOfObjectIdenticalTo:", aTabViewItem);
}
});
instance_methods[8] = new objj_method(sel_registerName("indexOfTabViewItemWithIdentifier:"), function(self, _cmd, anIdentifier)
{ with(self)
{
    var index = 0,
        count = objj_msgSend(_tabViewItems, "count");

    for (; index < count; ++index)
        if (objj_msgSend(objj_msgSend(_tabViewItems[index], "identifier"), "isEqualTo:", anIdentifier))
            return index;

    return index;
}
});
instance_methods[9] = new objj_method(sel_registerName("numberOfTabViewItems"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(_tabViewItems, "count");
}
});
instance_methods[10] = new objj_method(sel_registerName("tabViewItemAtIndex:"), function(self, _cmd, anIndex)
{ with(self)
{
    return _tabViewItems[anIndex];
}
});
instance_methods[11] = new objj_method(sel_registerName("tabViewItems"), function(self, _cmd)
{ with(self)
{
    return _tabViewItems;
}
});
instance_methods[12] = new objj_method(sel_registerName("selectFirstTabViewItem:"), function(self, _cmd, aSender)
{ with(self)
{
    var count = objj_msgSend(_tabViewItems, "count");

    if (count)
        objj_msgSend(self, "selectTabViewItemAtIndex:", 0);
}
});
instance_methods[13] = new objj_method(sel_registerName("selectLastTabViewItem:"), function(self, _cmd, aSender)
{ with(self)
{
    var count = objj_msgSend(_tabViewItems, "count");

    if (count)
        objj_msgSend(self, "selectTabViewItemAtIndex:", count-1);
}
});
instance_methods[14] = new objj_method(sel_registerName("selectNextTabViewItem:"), function(self, _cmd, aSender)
{ with(self)
{
    if (!_selectedTabViewItem)
        return;

    var index = objj_msgSend(self, "indexOfTabViewItem:", _selectedTabViewItem),
        count = objj_msgSend(_tabViewItems, "count");

    objj_msgSend(self, "selectTabViewItemAtIndex:", index+1%count);
}
});
instance_methods[15] = new objj_method(sel_registerName("selectPreviousTabViewItem:"), function(self, _cmd, aSender)
{ with(self)
{
    if (!_selectedTabViewItem)
        return;

    var index = objj_msgSend(self, "indexOfTabViewItem:", _selectedTabViewItem),
        count = objj_msgSend(_tabViewItems, "count");

    objj_msgSend(self, "selectTabViewItemAtIndex:", index==0?count:index-1);
}
});
instance_methods[16] = new objj_method(sel_registerName("selectTabViewItem:"), function(self, _cmd, aTabViewItem)
{ with(self)
{
    if ((_delegateSelectors & CPTabViewShouldSelectTabViewItemSelector) && !objj_msgSend(_delegate, "tabView:shouldSelectTabViewItem:", self, aTabViewItem))
        return;

    if (_delegateSelectors & CPTabViewWillSelectTabViewItemSelector)
        objj_msgSend(_delegate, "tabView:willSelectTabViewItem:", self, aTabViewItem);

    if (_selectedTabViewItem)
    {
        _selectedTabViewItem._tabState = CPBackgroundTab;
        objj_msgSend(_labelsView, "tabView:didChangeStateOfTabViewItem:", self, _selectedTabViewItem);

        objj_msgSend(_contentView, "removeFromSuperview");
        objj_msgSend(_auxiliaryView, "removeFromSuperview");
    }
    _selectedTabViewItem = aTabViewItem;

    _selectedTabViewItem._tabState = CPSelectedTab;

    _contentView = objj_msgSend(_selectedTabViewItem, "view");
    objj_msgSend(_contentView, "setAutoresizingMask:", CPViewWidthSizable|CPViewHeightSizable);

    _auxiliaryView = objj_msgSend(_selectedTabViewItem, "auxiliaryView");
    objj_msgSend(_auxiliaryView, "setAutoresizingMask:", CPViewWidthSizable);

    objj_msgSend(self, "addSubview:", _contentView);

    if (_auxiliaryView)
        objj_msgSend(self, "addSubview:", _auxiliaryView);

    objj_msgSend(_labelsView, "tabView:didChangeStateOfTabViewItem:", self, _selectedTabViewItem);

    objj_msgSend(self, "layoutSubviews");

    if (_delegateSelectors & CPTabViewDidSelectTabViewItemSelector)
        objj_msgSend(_delegate, "tabView:didSelectTabViewItem:", self, aTabViewItem);
}
});
instance_methods[17] = new objj_method(sel_registerName("selectTabViewItemAtIndex:"), function(self, _cmd, anIndex)
{ with(self)
{
    objj_msgSend(self, "selectTabViewItem:", _tabViewItems[anIndex]);
}
});
instance_methods[18] = new objj_method(sel_registerName("selectedTabViewItem"), function(self, _cmd)
{ with(self)
{
    return _selectedTabViewItem;
}
});
instance_methods[19] = new objj_method(sel_registerName("setTabViewType:"), function(self, _cmd, aTabViewType)
{ with(self)
{
    if (_tabViewType == aTabViewType)
        return;

    _tabViewType = aTabViewType;

    if (_tabViewType == CPNoTabsBezelBorder || _tabViewType == CPNoTabsLineBorder || _tabViewType == CPNoTabsNoBorder)
        objj_msgSend(_labelsView, "removeFromSuperview");
    else if (!objj_msgSend(_labelsView, "superview"))
        objj_msgSend(self, "addSubview:", _lablesView);

    if (_tabViewType == CPNoTabsLineBorder || _tabViewType == CPNoTabsNoBorder)
        objj_msgSend(_backgroundView, "removeFromSuperview");
    else if (!objj_msgSend(_backgroundView, "superview"))
        objj_msgSend(self, "addSubview:", _backgroundView);

    objj_msgSend(self, "layoutSubviews");
}
});
instance_methods[20] = new objj_method(sel_registerName("tabViewType"), function(self, _cmd)
{ with(self)
{
    return _tabViewType;
}
});
instance_methods[21] = new objj_method(sel_registerName("contentRect"), function(self, _cmd)
{ with(self)
{
    var contentRect = CGRectMakeCopy(objj_msgSend(self, "bounds"));

    if (_tabViewType == CPTopTabsBezelBorder)
    {
        var labelsViewHeight = objj_msgSend(_CPTabLabelsView, "height"),
            auxiliaryViewHeight = _auxiliaryView ? CGRectGetHeight(objj_msgSend(_auxiliaryView, "frame")) : 5.0,
            separatorViewHeight = 1.0;

        contentRect.origin.y += labelsViewHeight + auxiliaryViewHeight + separatorViewHeight;
        contentRect.size.height -= labelsViewHeight + auxiliaryViewHeight + separatorViewHeight * 2.0;

        contentRect.origin.x += LEFT_INSET;
        contentRect.size.width -= LEFT_INSET + RIGHT_INSET;
    }

    return contentRect;
}
});
instance_methods[22] = new objj_method(sel_registerName("setDelegate:"), function(self, _cmd, aDelegate)
{ with(self)
{
    if (_delegate == aDelegate)
        return;

    _delegate = aDelegate;

    _delegateSelectors = 0;

    if (objj_msgSend(_delegate, "respondsToSelector:", sel_registerName("tabView:shouldSelectTabViewItem:")))
        _delegateSelectors |= CPTabViewShouldSelectTabViewItemSelector;

    if (objj_msgSend(_delegate, "respondsToSelector:", sel_registerName("tabView:willSelectTabViewItem:")))
        _delegateSelectors |= CPTabViewWillSelectTabViewItemSelector;

    if (objj_msgSend(_delegate, "respondsToSelector:", sel_registerName("tabView:didSelectTabViewItem:")))
        _delegateSelectors |= CPTabViewDidSelectTabViewItemSelector;

    if (objj_msgSend(_delegate, "respondsToSelector:", sel_registerName("tabViewDidChangeNumberOfTabViewItems:")))
        _delegateSelectors |= CPTabViewDidChangeNumberOfTabViewItemsSelector;
}
});
instance_methods[23] = new objj_method(sel_registerName("mouseDown:"), function(self, _cmd, anEvent)
{ with(self)
{
    var location = objj_msgSend(_labelsView, "convertPoint:fromView:", objj_msgSend(anEvent, "locationInWindow"), nil),
        tabViewItem = objj_msgSend(_labelsView, "representedTabViewItemAtPoint:", location);

    if (tabViewItem)
        objj_msgSend(self, "selectTabViewItem:", tabViewItem);
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

var _CPTabLabelsViewLeftImage = nil,
    _CPTabLabelsViewCenterImage = nil,
    _CPTabLabelsViewRightImage = nil,
    _CPTabLabelsViewInsideMargin = 10.0,
    _CPTabLabelsViewOutsideMargin = 15.0;

{var the_class = objj_allocateClassPair(CPThreePartImageView, "_CPTabLabelsView"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_tabView"), new objj_ivar("_tabLabels"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("initialize"), function(self, _cmd)
{ with(self)
{
    if (self != objj_msgSend(_CPTabLabelsView, "class"))
        return;

    var bundle = objj_msgSend(CPBundle, "bundleForClass:", self);

    _CPTabLabelsViewLeftImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPTabView/_CPTabLabelsViewLeft.png"), CGSizeMake(12.0,26.0));
    _CPTabLabelsViewCenterImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPTabView/_CPTabLabelsViewCenter.png"), CGSizeMake(1.0,26.0));
    _CPTabLabelsViewRightImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPTabView/_CPTabLabelsViewRight.png"), CGSizeMake(12.0,26.0));
}
});
class_methods[1] = new objj_method(sel_registerName("height"), function(self, _cmd)
{ with(self)
{
    return 26.0;
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPThreePartImageView") }, "initWithFrame:", aFrame);

    if (self)
    {
        _tabLabels = [];

        objj_msgSend(self, "setLeftImage:", _CPTabLabelsViewLeftImage);
        objj_msgSend(self, "setCenterImage:", _CPTabLabelsViewCenterImage);
        objj_msgSend(self, "setRightImage:", _CPTabLabelsViewRightImage);

        objj_msgSend(self, "setFrameSize:", CGSizeMake(CGRectGetWidth(aFrame),26.0));
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setTabView:"), function(self, _cmd, aTabView)
{ with(self)
{
    _tabView = aTabView;
}
});
instance_methods[2] = new objj_method(sel_registerName("tabView"), function(self, _cmd)
{ with(self)
{
    return _tabView;
}
});
instance_methods[3] = new objj_method(sel_registerName("tabView:didAddTabViewItem:"), function(self, _cmd, aTabView, aTabViewItem)
{ with(self)
{
    var label = objj_msgSend(objj_msgSend(_CPTabLabel, "alloc"), "initWithFrame:", CGRectMakeZero());

    objj_msgSend(label, "setTabViewItem:", aTabViewItem);

    _tabLabels.push(label);

    objj_msgSend(self, "addSubview:", label);

    objj_msgSend(self, "layoutSubviews");
}
});
instance_methods[4] = new objj_method(sel_registerName("tabView:didRemoveTabViewItem:"), function(self, _cmd, aTabView, aTabViewItem)
{ with(self)
{
    var index = objj_msgSend(aTabView, "indexOfTabViewItem:", aTabViewItem),
        label = _tabLabels[index];

    objj_msgSend(_tabLabels, "removeObjectAtIndex:", index);

    objj_msgSend(label, "removeFromSuperview");

    objj_msgSend(self, "layoutSubviews");
}
});
instance_methods[5] = new objj_method(sel_registerName("tabView:didChangeStateOfTabViewItem:"), function(self, _cmd, aTabView, aTabViewItem)
{ with(self)
{
    objj_msgSend(_tabLabels[objj_msgSend(aTabView, "indexOfTabViewItem:", aTabViewItem)], "setTabState:", objj_msgSend(aTabViewItem, "tabState"));
 }
});
instance_methods[6] = new objj_method(sel_registerName("representedTabViewItemAtPoint:"), function(self, _cmd, aPoint)
{ with(self)
{
    var index = 0,
        count = _tabLabels.length;

    for (; index < count; ++index)
    {
        var label = _tabLabels[index];

        if (CGRectContainsPoint(objj_msgSend(label, "frame"), aPoint))
            return objj_msgSend(label, "tabViewItem");
    }

    return nil;
}
});
instance_methods[7] = new objj_method(sel_registerName("layoutSubviews"), function(self, _cmd)
{ with(self)
{
    var index = 0,
        count = _tabLabels.length,
        width = (CGRectGetWidth(objj_msgSend(self, "frame")) - (count - 1) * _CPTabLabelsViewInsideMargin - 2 * _CPTabLabelsViewOutsideMargin) / count,
        x = _CPTabLabelsViewOutsideMargin;

    for (; index < count; ++index)
    {
        var label = _tabLabels[index];

        objj_msgSend(label, "setFrame:", CGRectMake(x,8.0,width,18.0));

        x = CGRectGetMaxX(objj_msgSend(label, "frame")) + _CPTabLabelsViewInsideMargin;
    }
}
});
instance_methods[8] = new objj_method(sel_registerName("setFrameSize:"), function(self, _cmd, aSize)
{ with(self)
{
    if (CGSizeEqualToSize(objj_msgSend(self, "frame").size, aSize))
        return;

    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPThreePartImageView") }, "setFrameSize:", aSize);

    objj_msgSend(self, "layoutSubviews");
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

{var the_class = objj_allocateClassPair(CPView, "_CPTabLabel"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_backgroundViews"), new objj_ivar("_currentBackgroundView"), new objj_ivar("_tabViewItem"), new objj_ivar("_labelField"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("initialize"), function(self, _cmd)
{ with(self)
{
    if (self != objj_msgSend(_CPTabLabel, "class"))
        return;

    var bundle = objj_msgSend(CPBundle, "bundleForClass:", self);

    _CPTabLabelSelectedLeftImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPTabView/_CPTabLabelSelectedLeft.png"), CGSizeMake(3.0,18.0));
    _CPTabLabelSelectedCenterImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPTabView/_CPTabLabelSelectedCenter.png"), CGSizeMake(1.0,18.0));
    _CPTabLabelSelectedRightImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPTabView/_CPTabLabelSelectedRight.png"), CGSizeMake(3.0,18.0));

    _CPTabLabelBackgroundLeftImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPTabView/_CPTabLabelBackgroundLeft.png"), CGSizeMake(6.0,17.0));
    _CPTabLabelBackgroundCenterImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPTabView/_CPTabLabelBackgroundCenter.png"), CGSizeMake(1.0,17.0));
    _CPTabLabelBackgroundRightImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPTabView/_CPTabLabelBackgroundRight.png"), CGSizeMake(6.0,17.0));
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "initWithFrame:", aFrame);

    if (self)
    {
        _labelField = objj_msgSend(objj_msgSend(CPTextField, "alloc"), "initWithFrame:", CGRectMakeZero());

        objj_msgSend(_labelField, "setAlignment:", CPCenterTextAlignment);
        objj_msgSend(_labelField, "setFrame:", CGRectMake(5.0,0.0,CGRectGetWidth(aFrame)-10.0,20.0));
        objj_msgSend(_labelField, "setAutoresizingMask:", CPViewWidthSizable);
        objj_msgSend(_labelField, "setFont:", objj_msgSend(CPFont, "boldSystemFontOfSize:", 11.0));

        objj_msgSend(self, "addSubview:", _labelField);

        _backgroundViews = [];


        var backgroundView = objj_msgSend(objj_msgSend(CPThreePartImageView, "alloc"), "initWithFrame:", CGRectMakeZero());

        objj_msgSend(backgroundView, "setAutoresizingMask:", CPViewWidthSizable);
        objj_msgSend(backgroundView, "setLeftImage:", _CPTabLabelSelectedLeftImage);
        objj_msgSend(backgroundView, "setRightImage:", _CPTabLabelSelectedRightImage);
        objj_msgSend(backgroundView, "setCenterImage:", _CPTabLabelSelectedCenterImage);

        _backgroundViews[CPSelectedTab] = backgroundView;

        backgroundView = objj_msgSend(objj_msgSend(CPThreePartImageView, "alloc"), "initWithFrame:", CGRectMakeZero());

        objj_msgSend(backgroundView, "setAutoresizingMask:", CPViewWidthSizable);
        objj_msgSend(backgroundView, "setLeftImage:", _CPTabLabelBackgroundLeftImage);
        objj_msgSend(backgroundView, "setRightImage:", _CPTabLabelBackgroundRightImage);
        objj_msgSend(backgroundView, "setCenterImage:", _CPTabLabelBackgroundCenterImage);

        _backgroundViews[CPBackgroundTab] = backgroundView;

        objj_msgSend(self, "setTabState:", CPBackgroundTab);






    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setTabState:"), function(self, _cmd, aTabState)
{ with(self)
{
    var backgroundView = _backgroundViews[aTabState];

    if (backgroundView == _currentBackgroundView)
        return self;

    objj_msgSend(_currentBackgroundView, "removeFromSuperview");

    _currentBackgroundView = backgroundView;
    objj_msgSend(_currentBackgroundView, "setFrameSize:", CGSizeMake(CGRectGetWidth(objj_msgSend(self, "bounds")),aTabState==CPSelectedTab?18.0:17.0));

    objj_msgSend(self, "insertSubview:atIndex:", _currentBackgroundView, 0);
}
});
instance_methods[2] = new objj_method(sel_registerName("setTabViewItem:"), function(self, _cmd, aTabViewItem)
{ with(self)
{
    _tabViewItem = aTabViewItem;

    objj_msgSend(self, "update");
}
});
instance_methods[3] = new objj_method(sel_registerName("tabViewItem"), function(self, _cmd)
{ with(self)
{
    return _tabViewItem;
}
});
instance_methods[4] = new objj_method(sel_registerName("update"), function(self, _cmd)
{ with(self)
{
    objj_msgSend(_labelField, "setStringValue:", objj_msgSend(_tabViewItem, "label"));
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

p;15;CPTabViewItem.jI;21;Foundation/CPObject.jI;15;AppKit/CPView.jc;2232;


CPSelectedTab = 0;
CPBackgroundTab = 1;
CPPressedTab = 2;

{var the_class = objj_allocateClassPair(CPObject, "CPTabViewItem"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_identifier"), new objj_ivar("_label"), new objj_ivar("_view"), new objj_ivar("_auxiliaryView"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithIdentifier:"), function(self, _cmd, anIdentifier)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
        _identifier = anIdentifier;

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setLabel:"), function(self, _cmd, aLabel)
{ with(self)
{
    _label = aLabel;
}
});
instance_methods[2] = new objj_method(sel_registerName("label"), function(self, _cmd)
{ with(self)
{
    return _label;
}
});
instance_methods[3] = new objj_method(sel_registerName("tabState"), function(self, _cmd)
{ with(self)
{
    return _tabState;
}
});
instance_methods[4] = new objj_method(sel_registerName("setIdentifier:"), function(self, _cmd, anIdentifier)
{ with(self)
{
    _identifier = anIdentifier;
}
});
instance_methods[5] = new objj_method(sel_registerName("identifier"), function(self, _cmd)
{ with(self)
{
    return _identifier;
}
});
instance_methods[6] = new objj_method(sel_registerName("setView:"), function(self, _cmd, aView)
{ with(self)
{
    _view = aView;
}
});
instance_methods[7] = new objj_method(sel_registerName("view"), function(self, _cmd)
{ with(self)
{
    return _view;
}
});
instance_methods[8] = new objj_method(sel_registerName("setAuxiliaryView:"), function(self, _cmd, anAuxiliaryView)
{ with(self)
{
    _auxiliaryView = anAuxiliaryView;
}
});
instance_methods[9] = new objj_method(sel_registerName("auxiliaryView"), function(self, _cmd)
{ with(self)
{
    return _auxiliaryView;
}
});
instance_methods[10] = new objj_method(sel_registerName("tabView"), function(self, _cmd)
{ with(self)
{
    return _tabView;
}
});
class_addMethods(the_class, instance_methods);
}

p;15;CPTableColumn.jI;23;Foundation/Foundation.jc;4292;

CPTableColumnNoResizing = 0;
CPTableColumnAutoresizingMask = 1;
CPTableColumnUserResizingMask = 2;

{var the_class = objj_allocateClassPair(CPObject, "CPTableColumn"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_identifier"), new objj_ivar("_tableView"), new objj_ivar("_width"), new objj_ivar("_minWidth"), new objj_ivar("_maxWidth"), new objj_ivar("_resizingMask"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithIdentifier:"), function(self, _cmd, anIdentifier)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
    {
        _identifier = anIdentifier;

        _width = 40.0;
        _minWidth = 8.0;
        _maxWidth = 1000.0;


        _dataCell = objj_msgSend(objj_msgSend(CPTextField, "alloc"), "initWithFrame:", CPRectMakeZero());
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setIdentifier:"), function(self, _cmd, anIdentifier)
{ with(self)
{
    _identifier = anIdentifier;
}
});
instance_methods[2] = new objj_method(sel_registerName("identifier"), function(self, _cmd)
{ with(self)
{
    return _identifier;
}
});
instance_methods[3] = new objj_method(sel_registerName("setTabelView:"), function(self, _cmd, aTableView)
{ with(self)
{
    _tableView = aTableView;
}
});
instance_methods[4] = new objj_method(sel_registerName("tableView"), function(self, _cmd)
{ with(self)
{
    return _tableView;
}
});
instance_methods[5] = new objj_method(sel_registerName("setWidth:"), function(self, _cmd, aWidth)
{ with(self)
{
    _width = aWidth;
}
});
instance_methods[6] = new objj_method(sel_registerName("width"), function(self, _cmd)
{ with(self)
{
    return _width;
}
});
instance_methods[7] = new objj_method(sel_registerName("setMinWidth:"), function(self, _cmd, aWidth)
{ with(self)
{
    if (_width < (_minWidth = aWidth))
        objj_msgSend(self, "setWidth:", _minWidth);
}
});
instance_methods[8] = new objj_method(sel_registerName("minWidth"), function(self, _cmd)
{ with(self)
{
    return _minWidth;
}
});
instance_methods[9] = new objj_method(sel_registerName("setMaxWidth:"), function(self, _cmd, aWidth)
{ with(self)
{
    if (_width > (_maxmimumWidth = aWidth))
        objj_msgSend(self, "setWidth:", _maxWidth);
}
});
instance_methods[10] = new objj_method(sel_registerName("setResizingMask:"), function(self, _cmd, aMask)
{ with(self)
{
    _resizingMask = aMask;
}
});
instance_methods[11] = new objj_method(sel_registerName("resizingMask"), function(self, _cmd)
{ with(self)
{
    return _resizingMask;
}
});
instance_methods[12] = new objj_method(sel_registerName("sizeToFit"), function(self, _cmd)
{ with(self)
{
    var width = CPRectGetWidth(objj_msgSend(_headerView, "frame"));

    if (width < _minWidth)
        objj_msgSend(self, "setMinWidth:", width);
    else if (width > _maxWidth)
        objj_msgSend(self, "setMaxWidth:", width)

    if (_width != width)
        objj_msgSend(self, "setWidth:", width);
}
});
instance_methods[13] = new objj_method(sel_registerName("setEditable:"), function(self, _cmd, aFlag)
{ with(self)
{
    _isEditable = aFlag;
}
});
instance_methods[14] = new objj_method(sel_registerName("isEditable"), function(self, _cmd)
{ with(self)
{
    return _isEditable;
}
});
instance_methods[15] = new objj_method(sel_registerName("setHeaderView:"), function(self, _cmd, aHeaderView)
{ with(self)
{
    _headerView = aHeaderView;
}
});
instance_methods[16] = new objj_method(sel_registerName("headerView"), function(self, _cmd)
{ with(self)
{
    return _headerView;
}
});
instance_methods[17] = new objj_method(sel_registerName("setDataCell:"), function(self, _cmd, aDataCell)
{ with(self)
{
    _dataCell = aDataCell;
}
});
instance_methods[18] = new objj_method(sel_registerName("dataCell"), function(self, _cmd)
{ with(self)
{
    return _dataCell;
}
});
instance_methods[19] = new objj_method(sel_registerName("dataCellForRow:"), function(self, _cmd, aRowIndex)
{ with(self)
{
    return objj_msgSend(self, "dataCell");
}
});
class_addMethods(the_class, instance_methods);
}

p;13;CPTableView.ji;11;CPControl.ji;15;CPTableColumn.jc;10498;

var CPTableViewCellPlaceholder = objj_msgSend(objj_msgSend(CPObject, "alloc"), "init");

{var the_class = objj_allocateClassPair(CPControl, "CPTableView"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_dataSource"), new objj_ivar("_scrollView"), new objj_ivar("_headerView"), new objj_ivar("_tableColumns"), new objj_ivar("_numberOfRows"), new objj_ivar("_numberOfColumns"), new objj_ivar("_tableCells"), new objj_ivar("_tableColumnViews"), new objj_ivar("_intercellSpacing"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "initWithFrame:", aFrame);
    if (self)
    {
        _rowHeight = 17.0;
        _tableCells = objj_msgSend(objj_msgSend(CPArray, "alloc"), "init");
        _tableColumns = objj_msgSend(objj_msgSend(CPArray, "alloc"), "init");
        _tableColumnViews = objj_msgSend(objj_msgSend(CPArray, "alloc"), "init");
        _intercellSpacing = CPSizeMake(3.0, 2.0);
    }
    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("columnHeight"), function(self, _cmd)
{ with(self)
{
    var bounds = objj_msgSend(self, "bounds"),
        height = _numberOfRows * (_rowHeight + _intercellSpacing.height);
    return CPRectGetHeight(bounds) > height ? CPRectGetHeight(bounds) : height;
}
});
instance_methods[2] = new objj_method(sel_registerName("loadTableCellsInRect:"), function(self, _cmd, aRect)
{ with(self)
{
   if (!_dataSource)
        return;
    var rows = CPMakeRange(MAX(Math.floor((CPRectGetMinY(aRect) + _intercellSpacing.height) / (_rowHeight + _intercellSpacing.height)), 0), 1);
    rows.length = MIN(_numberOfRows, Math.ceil(CPRectGetMaxY(aRect) / (_rowHeight + _intercellSpacing.height))) - rows.location;
    var columns = CPMakeRange(0, 1);
    while (columns.location < _numberOfColumns && !CPRectIntersectsRect(objj_msgSend(_tableColumnViews[columns.location], "frame"), aRect))
        ++columns.location;
    while (CPMaxRange(columns) < _numberOfColumns && CPRectIntersectsRect(objj_msgSend(_tableColumnViews[CPMaxRange(columns)], "frame"), aRect))
        ++columns.length;
    var row = rows.location,
        column = 0;
    for (; row < CPMaxRange(rows); ++row)
        for (column = columns.location; column < CPMaxRange(columns); ++column)
        {
            if (!_tableCells[column][row] || _tableCells[column][row] == CPTableViewCellPlaceholder)
            {
                _tableCells[column][row] = objj_msgSend(objj_msgSend(_tableColumns[column], "dataCellForRow:", row), "copy");
                objj_msgSend(_tableCells[column][row], "setFrame:", CPRectMake(0.0,row*(_rowHeight+_intercellSpacing.height),objj_msgSend(_tableColumns[column], "width"),_rowHeight));
                objj_msgSend(_tableColumnViews[column], "addSubview:", _tableCells[column][row]);
            }
            objj_msgSend(_tableCells[column][row], "setObjectValue:", objj_msgSend(_dataSource, "tableView:objectValueForTableColumn:row:", self, _tableColumns[column], row));
        }
}
});
instance_methods[3] = new objj_method(sel_registerName("setIntercellSpacing:"), function(self, _cmd, aSize)
{ with(self)
{
    if (_intercellSpacing.width != aSize.width)
    {
        var i = 1,
            delta = aSize.width - _intercellSpacing.width;
            total = delta;
        for (; i < _numberOfColumns; ++i, total += delta)
        {
            var origin = objj_msgSend(_tableColumnViews[i], "frame").origin;
            objj_msgSend(_tableColumnViews[i], "setFrameOrigin:", CPPointMake(origin.x+total,origin.y));
        }
    }
    if (_intercellSpacing.height != aSize.height)
    {
        var i = 0;
        for (; i < _numberOfColumns; ++i, total += delta)
        {
            objj_msgSend(_tableColumnViews[i], "setFrameSize:", CPSizeMake(objj_msgSend(_tableColumnViews[i], "width"),_numberOfRows*(_rowHeight+_intercellSpacing.height)));
            var j = 1,
                y = _rowHeight + _intercellSpacing.height;
            for (; j < _numberOfRows; ++i, y += _rowHeight + _intercellSpacing.height)
            {
                if (_tableCells[i][j] == CPTableViewCellPlaceholder)
                    continue;
                objj_msgSend(_tableCells[i][j], "setFrameOrigin:", CPPointMake(0.0,y));
            }
        }
    }
    _intercellSpacing = CPSizeCreateCopy(aSize);
}
});
instance_methods[4] = new objj_method(sel_registerName("intercellSpacing"), function(self, _cmd)
{ with(self)
{
    return _intercellSpacing;
}
});
instance_methods[5] = new objj_method(sel_registerName("setRowHeight:"), function(self, _cmd, aRowHeight)
{ with(self)
{
    if (_rowHeight == aRowHeight)
        return;
    _rowHeight = aRowHeight;
    var row = 0,
        column = 0;
    for (; row < _numberOfRows; ++row)
        for (column = 0; column < _numberOfColumns; ++column)
            objj_msgSend(_tableCells[column][row], "setFrameOrigin:", CPPointMake(0.0,row*(_rowHeight+_intercellSpacing.height)));
}
});
instance_methods[6] = new objj_method(sel_registerName("rowHeight"), function(self, _cmd)
{ with(self)
{
    return _rowHeight;
}
});
instance_methods[7] = new objj_method(sel_registerName("addTableColumn:"), function(self, _cmd, aTableColumn)
{ with(self)
{
    var i = 0,
        x = _numberOfColumns ? CPRectGetMaxX(objj_msgSend(self, "rectOfColumn:", _numberOfColumns-1)) + _intercellSpacing.width : 0.0,
        tableColumnView = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", CPRectMake(x,0.0,objj_msgSend(aTableColumn, "width"),objj_msgSend(self, "columnHeight"))),
        tableColumnCells = objj_msgSend(objj_msgSend(CPArray, "alloc"), "init");
    objj_msgSend(_tableColumns, "addObject:", aTableColumn);
    objj_msgSend(_tableColumnViews, "addObject:", tableColumnView);
    objj_msgSend(self, "addSubview:", tableColumnView);
    objj_msgSend(_tableCells, "addObject:", tableColumnCells);
    for (; i < _numberOfRows; ++i)
        _tableCells[_numberOfColumns][i] = CPTableViewCellPlaceholder;
    ++_numberOfColumns;
}
});
instance_methods[8] = new objj_method(sel_registerName("removeTableColumn:"), function(self, _cmd, aTableColumn)
{ with(self)
{
    var frame = objj_msgSend(self, "frame"),
        width = objj_msgSend(aTableColumn, "width") + _intercellSpacing.width,
        index = objj_msgSend(_tableColumns, "indexOfObjectIdenticalTo:", aTableColumn);
    objj_msgSend(_tableColumnViews[i], "removeFromSuperview");
    objj_msgSend(_tableCells, "removeObjectAtIndex:", index);
    objj_msgSend(_tableColumns, "removeObjectAtIndex:", index);
    objj_msgSend(_tabelColumnViews, "removeObjectAtIndex:", index);
    for (; index < _numberOfColumns; ++ index)
        objj_msgSend(_tableColumnViews[index], "setFrameOrigin:", CPPointMake(CPRectGetMinX(objj_msgSend(_tableColumnViews[index], "frame"))-width,0.0))
    objj_msgSend(self, "setFrameSize:", CPSizeMake(CPRectGetWidth(frame)-width,CPRectGetHeight(frame)));
}
});
instance_methods[9] = new objj_method(sel_registerName("moveColumn:toColumn:"), function(self, _cmd, fromIndex, toIndex)
{ with(self)
{
    if (fromIndex == toIndex)
        return;
}
});
instance_methods[10] = new objj_method(sel_registerName("tableColumns"), function(self, _cmd)
{ with(self)
{
    return _tableColumns;
}
});
instance_methods[11] = new objj_method(sel_registerName("numberOfColumns"), function(self, _cmd)
{ with(self)
{
    return _numberOfColumns;
}
});
instance_methods[12] = new objj_method(sel_registerName("numberOfRows"), function(self, _cmd)
{ with(self)
{
    return _numberOfRows;
}
});
instance_methods[13] = new objj_method(sel_registerName("tile"), function(self, _cmd)
{ with(self)
{
    var HEIGHT = 10.0;
    objj_msgSend(_headerView, "setFrame:", CPRectMake(0.0,0.0,CPRectGetWidth(objj_msgSend(self, "bounds")),HEIGHT));
    objj_msgSend(_scrollView, "setFrame:", CPRectMake(0.0,HEIGHT,CPRectGetWidth(objj_msgSend(self, "bounds")),CPRectGetHeight(objj_msgSend(self, "bounds"))-HEIGHT));
}
});
instance_methods[14] = new objj_method(sel_registerName("setDataSource:"), function(self, _cmd, aDataSource)
{ with(self)
{
    _dataSource = aDataSource;
    objj_msgSend(self, "reloadData");
}
});
instance_methods[15] = new objj_method(sel_registerName("dataSource"), function(self, _cmd)
{ with(self)
{
    return _dataSource;
}
});
instance_methods[16] = new objj_method(sel_registerName("setFrameSize:"), function(self, _cmd, aSize)
{ with(self)
{
    var oldColumnHeight = objj_msgSend(self, "columnHeight");
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "setFrameSize:", aSize);
    var columnHeight = objj_msgSend(self, "columnHeight");
    if (columnHeight != oldColumnHeight)
    {
        var i = 0;
        for (; i < _numberOfColumns; ++i)
            objj_msgSend(_tableColumnViews[i], "setFrameSize:", CPSizeMake(objj_msgSend(_tableColumns[i], "width"),columnHeight));
    }
    objj_msgSend(self, "tile");
}
});
instance_methods[17] = new objj_method(sel_registerName("noteNumberOfRowsChanged"), function(self, _cmd)
{ with(self)
{
    var numberOfRows = objj_msgSend(_dataSource, "numberOfRowsInTableView:", self);
    if (_numberOfRows != numberOfRows)
    {
        _numberOfRows = numberOfRows;
        objj_msgSend(self, "sizeToFit");
    }
}
});
instance_methods[18] = new objj_method(sel_registerName("rectOfRow:"), function(self, _cmd, aRowIndex)
{ with(self)
{
    return CPRectMake(0.0, aRowIndex * (_rowHeight + _intercellSpacing.height), CPRectGetWidth(objj_msgSend(self, "bounds")), _rowHeight);
}
});
instance_methods[19] = new objj_method(sel_registerName("rectOfColumn:"), function(self, _cmd, aColumnIndex)
{ with(self)
{
    return CPRectCreateCopy(objj_msgSend(_tableColumnViews[aColumnIndex], "frame"));
}
});
instance_methods[20] = new objj_method(sel_registerName("sizeToFit"), function(self, _cmd)
{ with(self)
{
    objj_msgSend(self, "tile");
}
});
instance_methods[21] = new objj_method(sel_registerName("reloadData"), function(self, _cmd)
{ with(self)
{
    _numberOfRows = objj_msgSend(_dataSource, "numberOfRowsInTableView:", self);
    objj_msgSend(self, "loadTableCellsInRect:", objj_msgSend(self, "bounds"));
}
});
class_addMethods(the_class, instance_methods);
}

p;13;CPTextField.ji;11;CPControl.ji;17;CPStringDrawing.jc;11008;

var CPTextFieldDOMInputElement = nil;

CPLineBreakByWordWrapping = 0,
CPLineBreakByCharWrapping = 1,
CPLineBreakByClipping = 2,
CPLineBreakByTruncatingHead = 3,
CPLineBreakByTruncatingTail = 4,
CPLineBreakByTruncatingMiddle = 5;

var TOP_PADDING = 4.0,
    BOTTOM_PADDING = 3.0;
    HORIZONTAL_PADDING = 3.0;

{
var the_class = objj_getClass("CPString")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPString\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("string"), function(self, _cmd)
{ with(self)
{
    return self;
}
});
class_addMethods(the_class, instance_methods);
}

{var the_class = objj_allocateClassPair(CPControl, "CPTextField"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_isSelectable"), new objj_ivar("_value"), new objj_ivar("_lineBreakMode"), new objj_ivar("_DOMTextElement"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("_inputElement"), function(self, _cmd)
{ with(self)
{
    if (!CPTextFieldDOMInputElement)
    {
        CPTextFieldDOMInputElement = document.createElement("input");
        CPTextFieldDOMInputElement.style.position = "absolute";
        CPTextFieldDOMInputElement.style.top = "0px";
        CPTextFieldDOMInputElement.style.left = "0px";
        CPTextFieldDOMInputElement.style.width = "100%"
        CPTextFieldDOMInputElement.style.height = "100%";
        CPTextFieldDOMInputElement.style.border = "0px";
        CPTextFieldDOMInputElement.style.padding = "0px";
        CPTextFieldDOMInputElement.style.whiteSpace = "pre";
        CPTextFieldDOMInputElement.style.background = "transparent";
        CPTextFieldDOMInputElement.style.outline = "none";
    }

    return CPTextFieldDOMInputElement;
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "initWithFrame:", aFrame);

    if (self)
    {
        _value = "";

        _DOMTextElement = document.createElement("div");
        _DOMTextElement.style.position = "absolute";
        _DOMTextElement.style.top = TOP_PADDING + "px";
        _DOMTextElement.style.left = HORIZONTAL_PADDING + "px";
        _DOMTextElement.style.width = MAX(0.0, CGRectGetWidth(aFrame) - 2.0 * HORIZONTAL_PADDING) + "px";
        _DOMTextElement.style.height = MAX(0.0, CGRectGetHeight(aFrame) - TOP_PADDING - BOTTOM_PADDING) + "px";
        _DOMTextElement.style.whiteSpace = "pre";
        _DOMTextElement.style.cursor = "default";

        objj_msgSend(self, "setAlignment:", CPLeftTextAlignment);

        _DOMElement.appendChild(_DOMTextElement);
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setFrameSize:"), function(self, _cmd, aSize)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "setFrameSize:", aSize);

    _DOMTextElement.style.width = MAX(0.0, aSize.width - 2.0 * HORIZONTAL_PADDING) + "px";
    _DOMTextElement.style.height = MAX(0.0, aSize.height - TOP_PADDING - BOTTOM_PADDING) + "px";
}
});
instance_methods[2] = new objj_method(sel_registerName("setEditable:"), function(self, _cmd, aFlag)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "setEditable:", aFlag);
}
});
instance_methods[3] = new objj_method(sel_registerName("isSelectable"), function(self, _cmd)
{ with(self)
{
    return _isSelectable;
}
});
instance_methods[4] = new objj_method(sel_registerName("setSelectable:"), function(self, _cmd, aFlag)
{ with(self)
{
    _isSelectable = aFlag;
}
});
instance_methods[5] = new objj_method(sel_registerName("setAlignment:"), function(self, _cmd, anAlignment)
{ with(self)
{
    if (objj_msgSend(self, "alignment") == anAlignment)
        return;

    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "setAlignment:", anAlignment);

    switch (objj_msgSend(self, "alignment"))
    {
        case CPLeftTextAlignment: _DOMTextElement.style.textAlign = "left";
                                        break;
        case CPRightTextAlignment: _DOMTextElement.style.textAlign = "right";
                                        break;
        case CPCenterTextAlignment: _DOMTextElement.style.textAlign = "center";
                                        break;
        case CPJustifiedTextAlignment: _DOMTextElement.style.textAlign = "justify";
                                        break;
        case CPNaturalTextAlignment: _DOMTextElement.style.textAlign = "";
                                        break;
    }
}
});
instance_methods[6] = new objj_method(sel_registerName("setLineBreakMode:"), function(self, _cmd, aLineBreakMode)
{ with(self)
{
    _lineBreakMode = aLineBreakMode;

    switch (aLineBreakMode)
    {
        case CPLineBreakByTruncatingTail: _DOMTextElement.style.textOverflow = "ellipsis";
                                            _DOMTextElement.style.whiteSpace = "nowrap";
                                            _DOMTextElement.style.overflow = "hidden";
                                            break;

        case CPLineBreakByWordWrapping: _DOMTextElement.style.whiteSpace = "normal";
                                            _DOMTextElement.style.overflow = "hidden";
                                            _DOMTextElement.style.textOverflow = "clip";
                                            break;
    }
}
});
instance_methods[7] = new objj_method(sel_registerName("stringValue"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(_value, "string");
}
});
instance_methods[8] = new objj_method(sel_registerName("setStringValue:"), function(self, _cmd, aStringValue)
{ with(self)
{
    _value = aStringValue;

    var cssString = _value ? objj_msgSend(_value, "cssString") : "";

    if (CPFeatureIsCompatible(CPJavascriptInnerTextFeature))
        _DOMTextElement.innerText = cssString;
    else if (CPFeatureIsCompatible(CPJavascriptTextContentFeature))
        _DOMTextElement.textContent = cssString;
}
});
instance_methods[9] = new objj_method(sel_registerName("sizeToFit"), function(self, _cmd)
{ with(self)
{
    var hasWindow = NO;

    if (!hasWindow)
    {
        _DOMElement.style.visibility = "hidden";
        document.getElementsByTagName("body")[0].appendChild(_DOMElement);
    }


    _DOMTextElement.style.width = "auto";
    _DOMTextElement.style.height = "auto";

    var size = CGSizeMake(_DOMTextElement.clientWidth + 6.0, _DOMTextElement.clientHeight + TOP_PADDING + BOTTOM_PADDING);

    _DOMTextElement.style.width = "100%";
    _DOMTextElement.style.height = "100%";

    if (!hasWindow)
    {
        document.getElementsByTagName("body")[0].removeChild(_DOMElement);
        _DOMElement.style.visibility = "visible";
        if (objj_msgSend(self, "superview"))
            objj_msgSend(self, "superview")._DOMElement.appendChild(_DOMElement);
    }

    objj_msgSend(self, "setFrameSize:", size);
}
});
instance_methods[10] = new objj_method(sel_registerName("mouseDown:"), function(self, _cmd, anEvent)
{ with(self)
{
    if (!objj_msgSend(self, "isEditable"))
        return objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "mouseDown:", anEvent);
}
});
instance_methods[11] = new objj_method(sel_registerName("acceptsFirstResponder"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(self, "isEditable");
}
});
instance_methods[12] = new objj_method(sel_registerName("becomeFirstResponder"), function(self, _cmd)
{ with(self)
{
    var string = objj_msgSend(self, "stringValue");

    objj_msgSend(self, "setStringValue:", "");

    var element = objj_msgSend(objj_msgSend(self, "class"), "_inputElement");

    element.value = string;
    element.style.color = _DOMElement.style.color;



    this._DOMElement.appendChild(element);
    element.focus();
    element.select();

    return YES;
}
});
instance_methods[13] = new objj_method(sel_registerName("resignFirstResponder"), function(self, _cmd)
{ with(self)
{
    var element = objj_msgSend(objj_msgSend(self, "class"), "_inputElement");

    this._DOMElement.removeChild(element);
    objj_msgSend(self, "setStringValue:", element.value);

    return YES;
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

var CPTextFieldIsSelectableKey = "CPTextFieldIsSelectableKey",
    CPTextFieldLineBreakModeKey = "CPTextFieldLineBreakModeKey",
    CPTextFieldStringValueKey = "CPTextFieldStringValueKey";

{
var the_class = objj_getClass("CPTextField")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPTextField\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    _DOMTextElement = document.createElement("div");

    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "initWithCoder:", aCoder);

    if (self)
    {
        var bounds = objj_msgSend(self, "bounds");

        _value = "";

        _DOMTextElement.style.position = "absolute";
        _DOMTextElement.style.top = TOP_PADDING + "px";
        _DOMTextElement.style.left = HORIZONTAL_PADDING + "px";
        _DOMTextElement.style.width = MAX(0.0, CGRectGetWidth(bounds) - 2.0 * HORIZONTAL_PADDING) + "px";
        _DOMTextElement.style.height = MAX(0.0, CGRectGetHeight(bounds) - TOP_PADDING - BOTTOM_PADDING) + "px";
        _DOMTextElement.style.whiteSpace = "pre";
        _DOMTextElement.style.cursor = "default";

        _DOMElement.appendChild(_DOMTextElement);

        objj_msgSend(self, "setSelectable:", objj_msgSend(aCoder, "decodeBoolForKey:", CPTextFieldIsSelectableKey));
        objj_msgSend(self, "setLineBreakMode:", objj_msgSend(aCoder, "decodeIntForKey:", CPTextFieldLineBreakModeKey));

        objj_msgSend(self, "setStringValue:", objj_msgSend(aCoder, "decodeObjectForKey:", CPTextFieldStringValueKey));
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("encodeWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPControl") }, "encodeWithCoder:", aCoder);

    objj_msgSend(aCoder, "encodeBool:forKey:", _isSelectable, CPTextFieldIsSelectableKey);
    objj_msgSend(aCoder, "encodeInt:forKey:", _lineBreakMode, CPTextFieldLineBreakModeKey);

    objj_msgSend(aCoder, "encodeObject:forKey:", _value, CPTextFieldStringValueKey);
}
});
class_addMethods(the_class, instance_methods);
}

p;14;CPThemeFrame.ji;8;CPView.ji;13;CPImageView.jc;12855;

var CPThemeFrameResizeIndicatorImage = nil;

{var the_class = objj_allocateClassPair(CPView, "CPThemeFrame"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_mouseDraggedPoint"), new objj_ivar("_styleMask"), new objj_ivar("_resizeIndicator"), new objj_ivar("_title"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("initialize"), function(self, _cmd)
{ with(self)
{
    if (self != objj_msgSend(CPThemeFrame, "class"))
        return;

    CPThemeFrameResizeIndicatorImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(objj_msgSend(CPBundle, "bundleForClass:", self), "pathForResource:", "CPThemeFrame/CPThemeFrameResizeIndicator.png"), CGSizeMake(12.0,12.0));
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:forStyleMask:"), function(self, _cmd, aFrame, aStyleMask)
{ with(self)
{
    if (aStyleMask & CPHUDBackgroundWindowMask)
        self = objj_msgSend(CPHUDFrame, "alloc");
    else if (aStyleMask & CPBorderlessBridgeWindowMask)
        self = objj_msgSend(_CPBorderlessBridgeFrame, "alloc");

    self._styleMask = aStyleMask;

    return objj_msgSend(self, "initWithFrame:", aFrame);
}
});
instance_methods[1] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "initWithFrame:", aFrame);

    if (self)
    {
        _resizeIndicator = objj_msgSend(objj_msgSend(CPImageView, "alloc"), "initWithFrame:", CGRectMakeZero());

        objj_msgSend(_resizeIndicator, "setImage:", CPThemeFrameResizeIndicatorImage);
        objj_msgSend(_resizeIndicator, "setFrameSize:", CGSizeMakeCopy(objj_msgSend(CPThemeFrameResizeIndicatorImage, "size")));

        objj_msgSend(self, "addSubview:", _resizeIndicator);

        objj_msgSend(self, "setShowsResizeIndicator:", _styleMask&CPResizableWindowMask);
    }

    return self;
}
});
instance_methods[2] = new objj_method(sel_registerName("setTitle:"), function(self, _cmd, aTitle)
{ with(self)
{}
});
instance_methods[3] = new objj_method(sel_registerName("title"), function(self, _cmd)
{ with(self)
{
    return nil;
}
});
instance_methods[4] = new objj_method(sel_registerName("acceptsFirstMouse:"), function(self, _cmd, anEvent)
{ with(self)
{
    return YES;
}
});
instance_methods[5] = new objj_method(sel_registerName("mouseUp:"), function(self, _cmd, anEvent)
{ with(self)
{
    _mouseDraggedPoint = nil;
}
});
instance_methods[6] = new objj_method(sel_registerName("mouseDown:"), function(self, _cmd, anEvent)
{ with(self)
{
    if (!(_styleMask & CPBorderlessBridgeWindowMask))
    {
        _mouseDraggedPoint = objj_msgSend(objj_msgSend(self, "window"), "convertBaseToBridge:", objj_msgSend(anEvent, "locationInWindow"));


        var frame = CGRectMakeCopy(objj_msgSend(self, "frame"));

        frame.origin.x = CGRectGetWidth(frame) - 20.0;
        frame.origin.y = CGRectGetHeight(frame) - 24.0;
        frame.size.width = 20.0 - 5.0,
        frame.size.height = 24.0 - 8.0;

        if (!objj_msgSend(_resizeIndicator, "isHidden") && CGRectContainsPoint(frame, objj_msgSend(self, "convertPoint:fromView:", objj_msgSend(anEvent, "locationInWindow"), nil)))
            objj_msgSend(objj_msgSend(self, "window"), "trackResizeWithEvent:", anEvent);
    }
}
});
instance_methods[7] = new objj_method(sel_registerName("mouseDragged:"), function(self, _cmd, anEvent)
{ with(self)
{
    if (_styleMask & CPBorderlessBridgeWindowMask || !_mouseDraggedPoint)
        return;

    var theWindow = objj_msgSend(self, "window"),
        location = objj_msgSend(theWindow, "convertBaseToBridge:", objj_msgSend(anEvent, "locationInWindow")),
        frame = objj_msgSend(theWindow, "frame"),
        dX = location.x - _mouseDraggedPoint.x,
        dY = location.y - _mouseDraggedPoint.y;

    objj_msgSend(theWindow, "setFrameOrigin:", CGPointMake(CGRectGetMinX(frame)+dX,CGRectGetMinY(frame)+dY));

    _mouseDraggedPoint = location;
}
});
instance_methods[8] = new objj_method(sel_registerName("setShowsResizeIndicator:"), function(self, _cmd, shouldShowResizeIndicator)
{ with(self)
{
    objj_msgSend(_resizeIndicator, "setHidden:", !shouldShowResizeIndicator);
}
});
instance_methods[9] = new objj_method(sel_registerName("showsResizeIndicator"), function(self, _cmd)
{ with(self)
{
    return !objj_msgSend(_resizeIndicator, "isHidden");
}
});
instance_methods[10] = new objj_method(sel_registerName("setTitle:"), function(self, _cmd, title)
{ with(self)
{
    _title = title;
}
});
instance_methods[11] = new objj_method(sel_registerName("title"), function(self, _cmd)
{ with(self)
{
    return _title;
}
});
instance_methods[12] = new objj_method(sel_registerName("windowDidChangeDocumentEdited"), function(self, _cmd)
{ with(self)
{}
});
instance_methods[13] = new objj_method(sel_registerName("windowDidChangeDocumentSaving"), function(self, _cmd)
{ with(self)
{}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

var CPHUDFrameTopImage = nil,
    CPHUDFrameTopLeftImage = nil,
    CPHUDFrameTopRightImage = nil,

    CPHUDFrameLeftImage = nil,
    CPHUDFrameRightImage = nil,
    CPHUDFrameCenterImage = nil,

    CPHUDFrameBottomImage = nil,
    CPHUDFrameBottomLeftImage = nil,
    CPHUDFrameBottomRightImage = nil,

    CPHUDCloseButtonImage = nil;

{var the_class = objj_allocateClassPair(CPThemeFrame, "CPHUDFrame"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_backgroundView"), new objj_ivar("_titleField"), new objj_ivar("_closeButton"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("initialize"), function(self, _cmd)
{ with(self)
{
    if (self != objj_msgSend(CPHUDFrame, "class"))
        return;

    var bundle = objj_msgSend(CPBundle, "bundleForClass:", self);

    CPHUDFrameTopCenterImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "HUDTheme/WindowTopCenter.png"), CPSizeMake(1.0,86.0));
    CPHUDFrameTopLeftImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "HUDTheme/WindowTopLeft.png"), CPSizeMake(15.0,86.0));
    CPHUDFrameTopRightImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "HUDTheme/WindowTopRight.png"), CPSizeMake(15.0,86.0));

    CPHUDFrameLeftImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "HUDTheme/WindowCenterLeft.png"), CPSizeMake(15.0,1.0));
    CPHUDFrameRightImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "HUDTheme/WindowCenterRight.png"), CPSizeMake(15.0,1.0));
    CPHUDFrameCenterImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "HUDTheme/WindowCenter.png"), CPSizeMake(1.0,1.0));

    CPHUDFrameBottomCenterImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "HUDTheme/WindowBottomCenter.png"), CPSizeMake(1.0,39.0));
    CPHUDFrameBottomLeftImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "HUDTheme/WindowBottomLeft.png"), CPSizeMake(15.0,39.0));
    CPHUDFrameBottomRightImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "HUDTheme/WindowBottomRight.png"), CPSizeMake(15.0,39.0));

    CPHUDFrameCloseImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "HUDTheme/WindowClose.png"), CPSizeMake(20.0,20.0));
    CPHUDFrameCloseActiveImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "HUDTheme/WindowCloseActive.png"), CPSizeMake(20.0,20.0));
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("hitTest:"), function(self, _cmd, aPoint)
{ with(self)
{
    var view = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPThemeFrame") }, "hitTest:", aPoint);

    if (view == _backgroundView || view == _titleField)
        return self;

    return view;
}
});
instance_methods[1] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPThemeFrame") }, "initWithFrame:", aFrame);

    if (self)
    {
        var bounds = objj_msgSend(self, "bounds");

        _backgroundView = objj_msgSend(objj_msgSend(CPNinePartImageView, "alloc"), "initWithFrame:", bounds);
        objj_msgSend(_backgroundView, "setAutoresizingMask:", CPViewWidthSizable|CPViewHeightSizable);

        objj_msgSend(_backgroundView, "setTopImage:", CPHUDFrameTopCenterImage);
        objj_msgSend(_backgroundView, "setTopLeftImage:", CPHUDFrameTopLeftImage);
        objj_msgSend(_backgroundView, "setTopRightImage:", CPHUDFrameTopRightImage);

        objj_msgSend(_backgroundView, "setLeftImage:", CPHUDFrameLeftImage);
        objj_msgSend(_backgroundView, "setCenterImage:", CPHUDFrameCenterImage);
        objj_msgSend(_backgroundView, "setRightImage:", CPHUDFrameRightImage);

        objj_msgSend(_backgroundView, "setBottomImage:", CPHUDFrameBottomCenterImage);
        objj_msgSend(_backgroundView, "setBottomLeftImage:", CPHUDFrameBottomLeftImage);
        objj_msgSend(_backgroundView, "setBottomRightImage:", CPHUDFrameBottomRightImage);

        objj_msgSend(self, "insertSubview:atIndex:", _backgroundView, 0);

        _titleField = objj_msgSend(objj_msgSend(CPTextField, "alloc"), "initWithFrame:", CPRectMakeZero());

        objj_msgSend(_titleField, "setFont:", objj_msgSend(CPFont, "systemFontOfSize:", 11.0));
        objj_msgSend(_titleField, "setTextColor:", objj_msgSend(CPColor, "whiteColor"));
        objj_msgSend(_titleField, "setTextShadow:", objj_msgSend(CPShadow, "shadowWithOffset:blurRadius:color:", CPSizeMake(0.0,1.0), 2.0, objj_msgSend(CPColor, "blackColor")));
        objj_msgSend(_titleField, "setAutoresizingMask:", CPViewMinXMargin|CPViewMaxXMargin);

        objj_msgSend(self, "addSubview:", _titleField);

        if (_styleMask & CPClosableWindowMask)
        {
            var closeSize = objj_msgSend(CPHUDFrameCloseImage, "size");

            _closeButton = objj_msgSend(objj_msgSend(CPButton, "alloc"), "initWithFrame:", CPRectMake(10.0,7.0,closeSize.width,closeSize.height));

            objj_msgSend(_closeButton, "setImage:", CPHUDFrameCloseImage);
            objj_msgSend(_closeButton, "setAlternateImage:", CPHUDFrameCloseActiveImage);

            objj_msgSend(_closeButton, "setTarget:", self);
            objj_msgSend(_closeButton, "setAction:", sel_registerName("close:"));

            objj_msgSend(self, "addSubview:", _closeButton);
        }

        objj_msgSend(_resizeIndicator, "setFrameOrigin:", CGPointMake(CGRectGetWidth(bounds)-20.0,CGRectGetHeight(bounds)-24.0));
        objj_msgSend(_resizeIndicator, "setAutoresizingMask:", CPViewMinXMargin|CPViewMinYMargin);
    }

    return self;
}
});
instance_methods[2] = new objj_method(sel_registerName("close:"), function(self, _cmd, aSender)
{ with(self)
{
    objj_msgSend(objj_msgSend(self, "window"), "performClose:", self);
}
});
instance_methods[3] = new objj_method(sel_registerName("setTitle:"), function(self, _cmd, aTitle)
{ with(self)
{
    objj_msgSend(_titleField, "setStringValue:", aTitle);
    objj_msgSend(_titleField, "sizeToFit");

    var size = objj_msgSend(_titleField, "frame").size;

    objj_msgSend(_titleField, "setFrameOrigin:", CPPointMake((CPRectGetWidth(objj_msgSend(self, "frame"))-size.width)/2.0,(26.0-size.height)/2.0));
}
});
instance_methods[4] = new objj_method(sel_registerName("title"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(_titleField, "stringValue");
}
});
instance_methods[5] = new objj_method(sel_registerName("setFrameSize:"), function(self, _cmd, aSize)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPThemeFrame") }, "setFrameSize:", aSize);
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

p;11;CPToolbar.jI;21;Foundation/CPObject.ji;15;CPToolbarItem.jc;15349;

CPToolbarDisplayModeDefault = 0;
CPToolbarDisplayModeIconAndLabel = 1;
CPToolbarDisplayModeIconOnly = 2;
CPToolbarDisplayModeLabelOnly = 3;

var CPToolbarsByIdentifier = nil;
var CPToolbarConfigurationsByIdentifier = nil;

var _CPToolbarItemVisibilityPriorityCompare = function(lhs, rhs)
{
    var lhsVisibilityPriority = objj_msgSend(lhs, "visibilityPriority"),
        rhsVisibilityPriority = objj_msgSend(rhs, "visibilityPriority");

    if (lhsVisibilityPriority == rhsVisibilityPriority)
        return CPOrderedSame;

    if (lhsVisibilityPriority > rhsVisibilityPriority)
        return CPOrderedAscending;

    return CPOrderedDescending;
}

{var the_class = objj_allocateClassPair(CPObject, "CPToolbar"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_identifier"), new objj_ivar("_displayMode"), new objj_ivar("_showsBaselineSeparator"), new objj_ivar("_allowsUserCustomization"), new objj_ivar("_isVisible"), new objj_ivar("_needsReloadOfItems"), new objj_ivar("_delegate"), new objj_ivar("_toolbarView"), new objj_ivar("_itemIdentifiers"), new objj_ivar("_allowedItemIdentifiers"), new objj_ivar("_items"), new objj_ivar("_labels"), new objj_ivar("_itemIndexes"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("initialize"), function(self, _cmd)
{ with(self)
{
    if (self != objj_msgSend(CPToolbar, "class"))
        return;

    CPToolbarsByIdentifier = objj_msgSend(CPDictionary, "dictionary");
    CPToolbarConfigurationsByIdentifier = objj_msgSend(CPDictionary, "dictionary");
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithIdentifier:"), function(self, _cmd, anIdentifier)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
    {
        _items = [];
        _labels = [];

        _identifier = anIdentifier;
        _isVisible = YES;

        var toolbarsSharingIdentifier = objj_msgSend(CPToolbarsByIdentifier, "objectForKey:", _identifier);

        if (!toolbarsSharingIdentifier)
        {
            toolbarsSharingIdentifier = []
            objj_msgSend(CPToolbarsByIdentifier, "setObject:forKey:", toolbarsSharingIdentifier, _identifier);
        }

        objj_msgSend(toolbarsSharingIdentifier, "addObject:", self);
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setDisplayMode:"), function(self, _cmd, aDisplayMode)
{ with(self)
{}
});
instance_methods[2] = new objj_method(sel_registerName("identifier"), function(self, _cmd)
{ with(self)
{
    return _identifier;
}
});
instance_methods[3] = new objj_method(sel_registerName("delegate"), function(self, _cmd)
{ with(self)
{
    return _delegate;
}
});
instance_methods[4] = new objj_method(sel_registerName("isVisible"), function(self, _cmd)
{ with(self)
{
    return _isVisible;
}
});
instance_methods[5] = new objj_method(sel_registerName("setVisible:"), function(self, _cmd, aFlag)
{ with(self)
{
    if (_isVisible == aFlag)
        return;

    _isVisible = aFlag;

    objj_msgSend(_window, "_setToolbarVisible:", _isVisible);
    objj_msgSend(self, "_reloadToolbarItems");
}
});
instance_methods[6] = new objj_method(sel_registerName("setDelegate:"), function(self, _cmd, aDelegate)
{ with(self)
{
    if (_delegate == aDelegate)
        return;

    _delegate = aDelegate;


    _itemIdentifiers = nil;
    _allowedItemIdentifiers = objj_msgSend(_delegate, "toolbarAllowedItemIdentifiers:", self);

    objj_msgSend(self, "_reloadToolbarItems");
}
});
instance_methods[7] = new objj_method(sel_registerName("_loadConfiguration"), function(self, _cmd)
{ with(self)
{}
});
instance_methods[8] = new objj_method(sel_registerName("_toolbarView"), function(self, _cmd)
{ with(self)
{
    if (!_toolbarView)
    {
        _toolbarView = objj_msgSend(objj_msgSend(_CPToolbarView, "alloc"), "initWithFrame:", CPRectMake(0.0,0.0,1200.0,59.0));
        objj_msgSend(_toolbarView, "setAutoresizingMask:", CPViewWidthSizable);

        objj_msgSend(_toolbarView, "setToolbar:", self);
    }

    return _toolbarView;
}
});
instance_methods[9] = new objj_method(sel_registerName("_reloadToolbarItems"), function(self, _cmd)
{ with(self)
{
    if (!objj_msgSend(_toolbarView, "superview") || !_delegate)
        return;

    var count = objj_msgSend(_itemIdentifiers, "count");

    if (!count)
    {
        _itemIdentifiers = objj_msgSend(objj_msgSend(_delegate, "toolbarDefaultItemIdentifiers:", self), "mutableCopy");

        count = objj_msgSend(_itemIdentifiers, "count");
    }

    objj_msgSend(objj_msgSend(_toolbarView, "subviews"), "makeObjectsPerformSelector:", sel_registerName("removeFromSuperview"));

    _items = [];
    _labels = [];

    var index = 0;

    for (; index < count; ++index)
    {
        var identifier = _itemIdentifiers[index],
            item = objj_msgSend(CPToolbarItem, "_standardItemWithItemIdentifier:", identifier);

        if (!item)
            item = objj_msgSend(objj_msgSend(_delegate, "toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:", self, identifier, YES), "copy");

        if (item == nil)
            objj_msgSend(CPException, "raise:format:", CPInvalidArgumentException, "_delegate %@ returned nil toolbar item returned for identifier %@",_delegate,identifier);

        objj_msgSend(_items, "addObject:", item);
    }




    _itemsSortedByVisibilityPriority = objj_msgSend(_items, "sortedArrayUsingFunction:context:", _CPToolbarItemVisibilityPriorityCompare, NULL);

    objj_msgSend(_toolbarView, "reloadToolbarItems");
}
});
instance_methods[10] = new objj_method(sel_registerName("items"), function(self, _cmd)
{ with(self)
{
    return _items;
}
});
instance_methods[11] = new objj_method(sel_registerName("visibleItems"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(_toolbarView, "visibleItems");
}
});
instance_methods[12] = new objj_method(sel_registerName("indexOfItem:"), function(self, _cmd, anItem)
{ with(self)
{
    var info = objj_msgSend(_itemIndexes, "objectForKey:", objj_msgSend(anItem, "hash"));

    if (!info)
        return CPNotFound;

    return info.index;
}
});
instance_methods[13] = new objj_method(sel_registerName("itemsSortedByVisibilityPriority"), function(self, _cmd)
{ with(self)
{
    return _itemsSortedByVisibilityPriority;
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}


var _CPToolbarViewBackgroundColor = nil;

var TOOLBAR_TOP_MARGIN = 5.0,
    TOOLBAR_ITEM_MARGIN = 10.0;

var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth)
{
    return { index:anIndex, view:aView, label:aLabel, minWidth:aMinWidth };
}

{var the_class = objj_allocateClassPair(CPView, "_CPToolbarView"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_toolbar"), new objj_ivar("_flexibleWidthIndexes"), new objj_ivar("_visibleFlexibleWidthIndexes"), new objj_ivar("_itemInfos"), new objj_ivar("_visibleItems"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("initialize"), function(self, _cmd)
{ with(self)
{
    if (self != objj_msgSend(_CPToolbarView, "class"))
        return;

    var bundle = objj_msgSend(CPBundle, "bundleForClass:", self);

    _CPToolbarViewBackgroundColor = objj_msgSend(CPColor, "colorWithPatternImage:", objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "_CPToolbarView/_CPToolbarViewBackground.png"), CGSizeMake(1.0,59.0)));
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "initWithFrame:", aFrame);
    _minWidth = 0;
    if (self)
        objj_msgSend(self, "setBackgroundColor:", _CPToolbarViewBackgroundColor);

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("setToolbar:"), function(self, _cmd, aToolbar)
{ with(self)
{
    _toolbar = aToolbar;
}
});
instance_methods[2] = new objj_method(sel_registerName("toolbar"), function(self, _cmd)
{ with(self)
{
    return _toolbar;
}
});
instance_methods[3] = new objj_method(sel_registerName("resizeSubviewsWithOldSize:"), function(self, _cmd, aSize)
{ with(self)
{
    objj_msgSend(self, "layoutSubviews");
}
});
instance_methods[4] = new objj_method(sel_registerName("layoutSubviews"), function(self, _cmd)
{ with(self)
{

    var items = objj_msgSend(_toolbar, "items"),
        width = CGRectGetWidth(objj_msgSend(self, "bounds")),
        minWidth = _minWidth,
        flexibleItemIndexes = objj_msgSend(CPIndexSet, "indexSet");

    _visibleItems = items;



    if (width < minWidth)
    {
        _visibleItems = objj_msgSend(_visibleItems, "copy");

        var itemsSortedByVisibilityPriority = objj_msgSend(_toolbar, "itemsSortedByVisibilityPriority"),
            count = itemsSortedByVisibilityPriority.length;


        while (minWidth > width)
        {
            var item = itemsSortedByVisibilityPriority[count--];

            minWidth -= objj_msgSend(self, "minWidthForItem:", item) + TOOLBAR_ITEM_MARGIN;

            objj_msgSend(_visibleItems, "removeObjectIdenticalTo:", item);

            objj_msgSend(objj_msgSend(self, "viewForItem:", item), "setHidden:", YES);
            objj_msgSend(objj_msgSend(self, "labelForItem:", item), "setHidden:", YES);
        }
    }


    var index = _visibleItems.length;

    while (index--)
    {
        var item = _visibleItems[index];

        if (objj_msgSend(item, "minSize").width != objj_msgSend(item, "maxSize").width)
            objj_msgSend(flexibleItemIndexes, "addIndex:", index);

        objj_msgSend(objj_msgSend(self, "viewForItem:", item), "setHidden:", NO);
        objj_msgSend(objj_msgSend(self, "labelForItem:", item), "setHidden:", NO);
    }

    var remainingSpace = width - minWidth,
        proportionate = 0.0;




    while (remainingSpace && objj_msgSend(flexibleItemIndexes, "count"))
    {

        proportionate += remainingSpace / objj_msgSend(flexibleItemIndexes, "count");


        remainingSpace = 0.0;

        var index = CPNotFound;

        while ((index = objj_msgSend(flexibleItemIndexes, "indexGreaterThanIndex:", index)) != CPNotFound)
        {
            var item = _visibleItems[index];
                view = objj_msgSend(self, "viewForItem:", item),
                frame = objj_msgSend(view, "frame"),
                proposedWidth = objj_msgSend(item, "minSize").width + proportionate,
                constrainedWidth = MIN(proposedWidth, objj_msgSend(item, "maxSize").width);

            if (constrainedWidth < proposedWidth)
            {
                objj_msgSend(flexibleItemIndexes, "removeIndex:", index);

                remainingSpace += proposedWidth - constrainedWidth;
            }

            objj_msgSend(view, "setFrameSize:", CGSizeMake(constrainedWidth,CGRectGetHeight(frame)));
        }
    }


    var count = _visibleItems.length,
        x = TOOLBAR_ITEM_MARGIN;

    for (index = 0; index < count; ++index)
    {
        var item = _visibleItems[index],
            view = objj_msgSend(self, "viewForItem:", item),

            viewFrame = objj_msgSend(view, "frame"),
            viewWidth = CGRectGetWidth(viewFrame),

            label = objj_msgSend(self, "labelForItem:", item),
            labelFrame = objj_msgSend(label, "frame"),
            labelWidth = CGRectGetWidth(labelFrame),

            itemWidth = MAX(objj_msgSend(self, "minWidthForItem:", item), viewWidth);

        objj_msgSend(view, "setFrameOrigin:", CGPointMake(x+(itemWidth-viewWidth)/2.0,TOOLBAR_TOP_MARGIN));
        objj_msgSend(label, "setFrameOrigin:", CGPointMake(x+(itemWidth-labelWidth)/2.0,CGRectGetMaxY(viewFrame)));

        x += itemWidth + TOOLBAR_ITEM_MARGIN;
    }
}
});
instance_methods[5] = new objj_method(sel_registerName("indexOfItem:"), function(self, _cmd, anItem)
{ with(self)
{
    var info = objj_msgSend(_itemInfos, "objectForKey:", objj_msgSend(anItem, "hash"));

    if (!info)
        return CPNotFound;

    return info.index;
}
});
instance_methods[6] = new objj_method(sel_registerName("viewForItem:"), function(self, _cmd, anItem)
{ with(self)
{
    var info = objj_msgSend(_itemInfos, "objectForKey:", objj_msgSend(anItem, "hash"));

    if (!info)
        return nil;

    return info.view;
}
});
instance_methods[7] = new objj_method(sel_registerName("labelForItem:"), function(self, _cmd, anItem)
{ with(self)
{
    var info = objj_msgSend(_itemInfos, "objectForKey:", objj_msgSend(anItem, "hash"));

    if (!info)
        return nil;

    return info.label;
}
});
instance_methods[8] = new objj_method(sel_registerName("minWidthForItem:"), function(self, _cmd, anItem)
{ with(self)
{
    var info = objj_msgSend(_itemInfos, "objectForKey:", objj_msgSend(anItem, "hash"));

    if (!info)
        return 0;

    return info.minWidth;
}
});
instance_methods[9] = new objj_method(sel_registerName("reloadToolbarItems"), function(self, _cmd)
{ with(self)
{

    var subviews = objj_msgSend(self, "subviews"),
        count = subviews.length;

    while (count--)
        objj_msgSend(subviews, "removeObjectAtIndex:", count);


    var items = objj_msgSend(_toolbar, "items"),
        index = 0;

    count = items.length;

    _itemInfos = objj_msgSend(CPDictionary, "dictionary");
    _minWidth = TOOLBAR_ITEM_MARGIN;

    for (; index < count; ++index)
    {
        var item = items[index],
            view = objj_msgSend(item, "view");


        if (!view)
        {
            view = objj_msgSend(objj_msgSend(CPButton, "alloc"), "initWithFrame:", CGRectMake(0.0,0.0,32.0,32.0));

            objj_msgSend(view, "setImage:", objj_msgSend(item, "image"));
            objj_msgSend(view, "setAlternateImage:", objj_msgSend(item, "alternateImage"));

            objj_msgSend(view, "setTarget:", objj_msgSend(item, "target"));
            objj_msgSend(view, "setAction:", objj_msgSend(item, "action"));

            objj_msgSend(view, "setImagePosition:", CPImageOnly);
        }

        objj_msgSend(self, "addSubview:", view);


        var label = objj_msgSend(objj_msgSend(CPTextField, "alloc"), "initWithFrame:", CGRectMakeZero());

        objj_msgSend(label, "setStringValue:", objj_msgSend(item, "label"));
        objj_msgSend(label, "setFont:", objj_msgSend(CPFont, "systemFontOfSize:", 11.0));
        objj_msgSend(label, "sizeToFit");

        objj_msgSend(self, "addSubview:", label);

        var minSize = objj_msgSend(item, "minSize"),
            minWidth = MAX(minSize.width, CGRectGetWidth(objj_msgSend(label, "frame")));

        objj_msgSend(_itemInfos, "setObject:forKey:", _CPToolbarItemInfoMake(index,view,label,minWidth), objj_msgSend(item, "hash"));

        _minWidth += minWidth + TOOLBAR_ITEM_MARGIN;




    }

    objj_msgSend(self, "layoutSubviews");
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

p;15;CPToolbarItem.jI;21;Foundation/CPObject.jI;21;Foundation/CPString.jI;16;AppKit/CPImage.jI;15;AppKit/CPView.jc;9023;


CPToolbarItemVisibilityPriorityStandard = 0;
CPToolbarItemVisibilityPriorityLow = -1000;
CPToolbarItemVisibilityPriorityHigh = 1000;
CPToolbarItemVisibilityPriorityUser = 2000;

CPToolbarSeparatorItemIdentifier = "CPToolbarSeparatorItemIdentifier";
CPToolbarSpaceItemIdentifier = "CPToolbarSpaceItemIdentifier";
CPToolbarFlexibleSpaceItemIdentifier = "CPToolbarFlexibleSpaceItemIdentifier";
CPToolbarShowColorsItemIdentifier = "CPToolbarShowColorsItemIdentifier";
CPToolbarShowFontsItemIdentifier = "CPToolbarShowFontsItemIdentifier";
CPToolbarCustomizeToolbarItemIdentifier = "CPToolbarCustomizeToolbarItemIdentifier";
CPToolbarPrintItemIdentifier = "CPToolbarPrintItemIdentifier";

{var the_class = objj_allocateClassPair(CPObject, "CPToolbarItem"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, 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"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithItemIdentifier:"), function(self, _cmd, anItemIdentifier)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPObject") }, "init");

    if (self)
    {
        _itemIdentifier = anItemIdentifier;

        _minSize = CGSizeMakeZero();
        _maxSize = CGSizeMakeZero();

        _visibilityPriority = CPToolbarItemVisibilityPriorityStandard;
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("itemIdentifier"), function(self, _cmd)
{ with(self)
{
    return _itemIdentifier;
}
});
instance_methods[2] = new objj_method(sel_registerName("toolbar"), function(self, _cmd)
{ with(self)
{
    return _toolbar;
}
});
instance_methods[3] = new objj_method(sel_registerName("label"), function(self, _cmd)
{ with(self)
{
    return _label;
}
});
instance_methods[4] = new objj_method(sel_registerName("setLabel:"), function(self, _cmd, aLabel)
{ with(self)
{
    _label = aLabel;
}
});
instance_methods[5] = new objj_method(sel_registerName("paletteLabel"), function(self, _cmd)
{ with(self)
{
    return _paletteLabel;
}
});
instance_methods[6] = new objj_method(sel_registerName("setPaletteLabel:"), function(self, _cmd, aPaletteLabel)
{ with(self)
{
    _paletteLabel = aPaletteLabel;
}
});
instance_methods[7] = new objj_method(sel_registerName("toolTip"), function(self, _cmd)
{ with(self)
{
    return _toolTip;
}
});
instance_methods[8] = new objj_method(sel_registerName("setToolTip:"), function(self, _cmd, aToolTip)
{ with(self)
{
    _toolTip = aToolTip;
}
});
instance_methods[9] = new objj_method(sel_registerName("tag"), function(self, _cmd)
{ with(self)
{
    return _tag;
}
});
instance_methods[10] = new objj_method(sel_registerName("setTag:"), function(self, _cmd, aTag)
{ with(self)
{
    _tag = aTag;
}
});
instance_methods[11] = new objj_method(sel_registerName("target"), function(self, _cmd)
{ with(self)
{
    return _target;
}
});
instance_methods[12] = new objj_method(sel_registerName("setTarget:"), function(self, _cmd, aTarget)
{ with(self)
{
    _target = aTarget;

    objj_msgSend(_view, "setTarget:", aTarget);
}
});
instance_methods[13] = new objj_method(sel_registerName("action"), function(self, _cmd)
{ with(self)
{
    return _action;
}
});
instance_methods[14] = new objj_method(sel_registerName("setAction:"), function(self, _cmd, anAction)
{ with(self)
{
    _action = anAction;

    objj_msgSend(_view, "setAction:", anAction);
}
});
instance_methods[15] = new objj_method(sel_registerName("isEnabled"), function(self, _cmd)
{ with(self)
{
    return _isEnabled;
}
});
instance_methods[16] = new objj_method(sel_registerName("setEnabled:"), function(self, _cmd, aFlag)
{ with(self)
{
    _isEnabled = aFlag;
}
});
instance_methods[17] = new objj_method(sel_registerName("image"), function(self, _cmd)
{ with(self)
{
    return _image;
}
});
instance_methods[18] = new objj_method(sel_registerName("setImage:"), function(self, _cmd, anImage)
{ with(self)
{
    _image = anImage;

    objj_msgSend(_view, "setImage:", anImage);
}
});
instance_methods[19] = new objj_method(sel_registerName("setAlternateImage:"), function(self, _cmd, anImage)
{ with(self)
{
    _alternateImage = anImage;

    objj_msgSend(_view, "setAlternateImage:", anImage);
}
});
instance_methods[20] = new objj_method(sel_registerName("alternateImage"), function(self, _cmd)
{ with(self)
{
    return _alternateImage;
}
});
instance_methods[21] = new objj_method(sel_registerName("view"), function(self, _cmd)
{ with(self)
{
    return _view;
}
});
instance_methods[22] = new objj_method(sel_registerName("setView:"), function(self, _cmd, aView)
{ with(self)
{
    _view = aView;
}
});
instance_methods[23] = new objj_method(sel_registerName("minSize"), function(self, _cmd)
{ with(self)
{
    return _minSize;
}
});
instance_methods[24] = new objj_method(sel_registerName("setMinSize:"), function(self, _cmd, aMinSize)
{ with(self)
{
    _minSize = CGSizeCreateCopy(aMinSize);
}
});
instance_methods[25] = new objj_method(sel_registerName("maxSize"), function(self, _cmd)
{ with(self)
{
    return _maxSize;
}
});
instance_methods[26] = new objj_method(sel_registerName("setMaxSize:"), function(self, _cmd, aMaxSize)
{ with(self)
{
    _maxSize = CGSizeCreateCopy(aMaxSize);
}
});
instance_methods[27] = new objj_method(sel_registerName("visibilityPriority"), function(self, _cmd)
{ with(self)
{
    return _visibilityPriority;
}
});
instance_methods[28] = new objj_method(sel_registerName("setVisibilityPriority:"), function(self, _cmd, aVisibilityPriority)
{ with(self)
{
    _visibilityPriority = aVisibilityPriority;
}
});
class_addMethods(the_class, instance_methods);
}

{
var the_class = objj_getClass("CPToolbarItem")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPToolbarItem\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("copy"), function(self, _cmd)
{ with(self)
{
    var copy = objj_msgSend(objj_msgSend(objj_msgSend(self, "class"), "alloc"), "initWithItemIdentifier:", _itemIdentifier);

    objj_msgSend(copy, "setLabel:", _label);
    objj_msgSend(copy, "setPaletteLabel:", _paletteLabel);
    objj_msgSend(copy, "setToolTip:", _toolTip);

    objj_msgSend(copy, "setTag:", _tag);
    objj_msgSend(copy, "setTarget:", _target);
    objj_msgSend(copy, "setAction:", _action);

    objj_msgSend(copy, "setEnabled:", _isEnabled);
    objj_msgSend(copy, "setImage:", _image);
    objj_msgSend(copy, "setAlternateImage:", _alternateImage);

    if (_view)
        objj_msgSend(copy, "setView:", objj_msgSend(CPKeyedUnarchiver, "unarchiveObjectWithData:", objj_msgSend(CPKeyedArchiver, "archivedDataWithRootObject:", _view)));

    objj_msgSend(copy, "setMinSize:", _minSize);
    objj_msgSend(copy, "setMaxSize:", _maxSize);

    objj_msgSend(copy, "setVisibilityPriority:", _visibilityPriority);

    return copy;
}
});
class_addMethods(the_class, instance_methods);
}



{
var the_class = objj_getClass("CPToolbarItem")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPToolbarItem\""));
var meta_class = _class_getMeta(the_class);var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("_standardItemWithItemIdentifier:"), function(self, _cmd, anItemIdentifier)
{ with(self)
{
    var item = objj_msgSend(objj_msgSend(CPToolbarItem, "alloc"), "initWithItemIdentifier:", anItemIdentifier);

    switch (anItemIdentifier)
    {
        case CPToolbarSeparatorItemIdentifier: return nil;

        case CPToolbarSpaceItemIdentifier: objj_msgSend(item, "setMinSize:", CGSizeMake(32.0,32.0));
                                                        objj_msgSend(item, "setMaxSize:", CGSizeMake(32.0,32.0));

                                                        return item;

        case CPToolbarFlexibleSpaceItemIdentifier: objj_msgSend(item, "setMinSize:", CGSizeMake(32.0,32.0));
                                                        objj_msgSend(item, "setMaxSize:", CGSizeMake(10000.0,32.0));

                                                        return item;

        case CPToolbarShowColorsItemIdentifier: return nil;
        case CPToolbarShowFontsItemIdentifier: return nil;
        case CPToolbarCustomizeToolbarItemIdentifier: return nil;
        case CPToolbarPrintItemIdentifier: return nil;
    }

    return nil;
}
});
class_addMethods(meta_class, class_methods);
}

p;8;CPView.jI;20;Foundation/CPArray.jI;26;Foundation/CPObjJRuntime.ji;9;CPColor.ji;10;CPBorder.ji;12;CPGeometry.ji;13;CPResponder.ji;19;CPGraphicsContext.jc;36452;



CPViewNotSizable = 0;
CPViewMinXMargin = 1;
CPViewWidthSizable = 2;
CPViewMaxXMargin = 4;
CPViewMinYMargin = 8;
CPViewHeightSizable = 16;
CPViewMaxYMargin = 32;

CPViewFrameDidChangeNotification = "CPViewFrameDidChangeNotification";

var DOMCanvasElementZIndex = -1,
    DOMBackgroundElementZIndex = -2,
    DOMElementPrototype = nil;

{var the_class = objj_allocateClassPair(CPResponder, "CPView"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_window"), new objj_ivar("_superview"), new objj_ivar("_subviews"), new objj_ivar("_graphicsContext"), new objj_ivar("_index"), new objj_ivar("_frame"), new objj_ivar("_bounds"), new objj_ivar("_registeredDraggedTypes"), new objj_ivar("_isHidden"), new objj_ivar("_hitTests"), new objj_ivar("_DOMElement"), new objj_ivar("_DOMGraphicsElement"), new objj_ivar("_DOMBackgroundElement"), new objj_ivar("_opacity"), new objj_ivar("_borderSize"), new objj_ivar("_topBorder"), new objj_ivar("_leftBorder"), new objj_ivar("_rightBorder"), new objj_ivar("_bottomBorder"), new objj_ivar("_backgroundColor"), new objj_ivar("_autoresizesSubviews"), new objj_ivar("_autoresizingMask"), new objj_ivar("_layer"), new objj_ivar("_wantsLayer"), new objj_ivar("_isInFullScreenMode"), new objj_ivar("_fullScreenModeState"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("initialize"), function(self, _cmd)
{ with(self)
{
    if (self != objj_msgSend(CPView, "class"))
        return;

    DOMElementPrototype = document.createElement("div");

    var style = DOMElementPrototype.style;

    style.overflow = "hidden";
    style.position = "absolute";
    style.visibility = "visible";
    style.zIndex = 0;
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPResponder") }, "init");

    if (self)
    {
        var width = (aFrame.size.width),
            height = (aFrame.size.height);

        _subviews = [];

        _index = 0;
        _frame = { origin: { x:aFrame.origin.x, y:aFrame.origin.y }, size: { width:aFrame.size.width, height:aFrame.size.height } };
        _bounds = { origin: { x:0.0, y:0.0 }, size: { width:width, height:height } };

        _registeredDraggedTypes = [];

        _autoresizingMask = CPViewNotSizable;
        _autoresizesSubviews = YES;

        _opacity = 1.0;
        _isHidden = NO;
        _hitTests = YES;

        _borderSize = { width:0.0, height:0.0 };

        _DOMElement = DOMElementPrototype.cloneNode(false);

        var style = _DOMElement.style;

        style.top = (aFrame.origin.y) + "px";
        style.left = (aFrame.origin.x) + "px";

        style.width = width + "px";
        style.height = height + "px";
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("superview"), function(self, _cmd)
{ with(self)
{
    return _superview;
}
});
instance_methods[2] = new objj_method(sel_registerName("subviews"), function(self, _cmd)
{ with(self)
{
    return _subviews;
}
});
instance_methods[3] = new objj_method(sel_registerName("window"), function(self, _cmd)
{ with(self)
{
    return _window;
}
});
instance_methods[4] = new objj_method(sel_registerName("addSubview:"), function(self, _cmd, aSubview)
{ with(self)
{
    objj_msgSend(self, "insertSubview:atIndex:", aSubview, CPNotFound);
}
});
instance_methods[5] = new objj_method(sel_registerName("moveSubview:underSubview:"), function(self, _cmd, aSubview, anotherSubview)
{ with(self)
{
    if (aSubview == anotherSubview || objj_msgSend(aSubview, "superview") != self || objj_msgSend(anotherSubview, "superview") != self)
        return;

    var index = objj_msgSend(aSubview, "index"),
        count = objj_msgSend(_subviews, "count")
        anotherIndex = objj_msgSend(anotherSubview, "index");

    objj_msgSend(_subviews, "removeObjectAtIndex:", index);
    objj_msgSend(_subviews, "insertObject:atIndex:", aSubview, anotherIndex);

    for(index = Math.min(index, anotherIndex); index < count; ++index)
    {
        _subviews[index]._index = index;
        _subviews[index]._DOMElement.style.zIndex = index;
    }
}
});
instance_methods[6] = new objj_method(sel_registerName("replaceSubview:with:"), function(self, _cmd, aSubview, aView)
{ with(self)
{
    if (aSubview._superview != self)
        return;

    var index = aSubview._index;

    objj_msgSend(aSubview, "removeFromSuperview");

    objj_msgSend(aView, "insertSubview:atIndex:", aView, index);
}
});
instance_methods[7] = new objj_method(sel_registerName("_setWindow:"), function(self, _cmd, aWindow)
{ with(self)
{

    if (objj_msgSend(_window, "firstResponder") == self)
        objj_msgSend(_window, "makeFirstResponder:", nil);


    objj_msgSend(self, "viewWillMoveToWindow:", aWindow);
    objj_msgSend(_subviews, "makeObjectsPerformSelector:withObject:", sel_registerName("_setWindow:"), aWindow);

    _window = aWindow;

    objj_msgSend(self, "viewDidMoveToWindow");
}
});
instance_methods[8] = new objj_method(sel_registerName("insertSubview:atIndex:"), function(self, _cmd, aSubview, anIndex)
{ with(self)
{

    var count = _subviews.length,
        zIndex = (anIndex == CPNotFound ? count : anIndex);


    if (aSubview._superview == self)
    {
        zIndex = MIN(aSubview._index, zIndex);
        objj_msgSend(_subviews, "removeObjectAtIndex:", aSubview._index);
    }
    else
    {

        objj_msgSend(aSubview, "removeFromSuperview");


        objj_msgSend(aSubview, "_setWindow:", _window);


        objj_msgSend(aSubview, "viewWillMoveToSuperview:", self);


        aSubview._superview = self;

        ++count;
    }

    if (anIndex == CPNotFound || anIndex >= count)
        _subviews.push(aSubview);
    else
        _subviews.splice(anIndex, 0, aSubview)


    for (; zIndex < count; ++zIndex)
    {
        _subviews[zIndex]._index = zIndex;
        _subviews[zIndex]._DOMElement.style.zIndex = zIndex;
    }


    _DOMElement.appendChild(aSubview._DOMElement);

    objj_msgSend(aSubview, "setNextResponder:", self);
    objj_msgSend(aSubview, "viewDidMoveToSuperview");

    objj_msgSend(self, "didAddSubview:", aSubview);
}
});
instance_methods[9] = new objj_method(sel_registerName("didAddSubview:"), function(self, _cmd, aSubview)
{ with(self)
{}
});
instance_methods[10] = new objj_method(sel_registerName("isDescendantOf:"), function(self, _cmd, aView)
{ with(self)
{
    var view = self;

    do
    {
        if (view == aView)
            return YES;
    } while(view = objj_msgSend(view, "superview"))

    return NO;
}
});
instance_methods[11] = new objj_method(sel_registerName("isFlipped"), function(self, _cmd)
{ with(self)
{
    return YES;
}
});
instance_methods[12] = new objj_method(sel_registerName("viewDidMoveToSuperview"), function(self, _cmd)
{ with(self)
{
    objj_msgSend(self, "setNextResponder:", _superview);


    if (_graphicsContext)
        objj_msgSend(self, "setNeedsDisplay:", YES);
}
});
instance_methods[13] = new objj_method(sel_registerName("viewDidMoveToWindow"), function(self, _cmd)
{ with(self)
{}
});
instance_methods[14] = new objj_method(sel_registerName("viewWillMoveToSuperview:"), function(self, _cmd, aView)
{ with(self)
{}
});
instance_methods[15] = new objj_method(sel_registerName("viewWillMoveToWindow:"), function(self, _cmd, aWindow)
{ with(self)
{}
});
instance_methods[16] = new objj_method(sel_registerName("willRemoveSubview:"), function(self, _cmd, aView)
{ with(self)
{}
});
instance_methods[17] = new objj_method(sel_registerName("removeFromSuperview"), function(self, _cmd)
{ with(self)
{
    if (!_superview)
        return;

    objj_msgSend(_superview, "willRemoveSubview:", self);

    var zIndex = _index,
        subviews = objj_msgSend(_superview, "subviews"),
        count = objj_msgSend(subviews, "count") - 1;

    objj_msgSend(subviews, "removeObjectAtIndex:", _index);

    for(; zIndex < count; ++zIndex)
    {
        subviews[zIndex]._index = zIndex;
        subviews[zIndex]._DOMElement.style.zIndex = zIndex;
    }
    _index = 0;

    _superview._DOMElement.removeChild(_DOMElement);
    _superview = nil;

    objj_msgSend(self, "_setWindow:", nil);
}
});
instance_methods[18] = new objj_method(sel_registerName("setFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    objj_msgSend(self, "setFrameOrigin:", aFrame.origin);
    objj_msgSend(self, "setFrameSize:", aFrame.size);


}
});
instance_methods[19] = new objj_method(sel_registerName("frame"), function(self, _cmd)
{ with(self)
{
    return _frame;
}
});
instance_methods[20] = new objj_method(sel_registerName("index"), function(self, _cmd)
{ with(self)
{
    return _index;
}
});
instance_methods[21] = new objj_method(sel_registerName("setFrameOrigin:"), function(self, _cmd, aPoint)
{ with(self)
{
    if (CPPointEqualToPoint(_frame.origin, aPoint))
        return;

    var style = _DOMElement.style;


    _frame.origin = CPPointCreateCopy(aPoint);

    style.top = ROUND(CPRectGetMinY(_frame)) + "px";
    style.left = ROUND(CPRectGetMinX(_frame)) + "px";


}
});
instance_methods[22] = new objj_method(sel_registerName("setFrameSize:"), function(self, _cmd, aSize)
{ with(self)
{
    if (CPSizeEqualToSize(_frame.size, aSize))
        return;

    var oldSize = _frame.size;

    _frame.size = CPSizeCreateCopy(aSize);
    _bounds.size = CPSizeCreateCopy(aSize);


    if (_DOMBackgroundElement || _DOMGraphicsElement)
        objj_msgSend(self, "_setSizeFromFrame");
    else
    {
        _DOMElement.style.width = MAX(0.0, ROUND(CPRectGetWidth(_frame))) + "px";
        _DOMElement.style.height = MAX(0.0, ROUND(CPRectGetHeight(_frame))) + "px";
    }

    if (_layer)
        objj_msgSend(_layer, "_owningViewBoundsChanged");

    if (_autoresizesSubviews)
        objj_msgSend(self, "resizeSubviewsWithOldSize:", oldSize);
}
});
instance_methods[23] = new objj_method(sel_registerName("_setSizeFromFrame"), function(self, _cmd)
{ with(self)
{
    var width = MAX(0.0, ROUND(CPRectGetWidth(_frame))),
        height = MAX(0.0, ROUND(CPRectGetHeight(_frame)));

    _DOMElement.style.width = width + "px";
    _DOMElement.style.height = height + "px";

    if (_DOMGraphicsElement)
    {
        _DOMElement.removeChild(_DOMGraphicsElement);

        _DOMGraphicsElement.width = width;
        _DOMGraphicsElement.height = height;

        _DOMGraphicsElement.style.width = width + "px";
        _DOMGraphicsElement.style.height = height + "px";

        _DOMElement.appendChild(_DOMGraphicsElement);
    }

    if (_DOMBackgroundElement)
    {
        if ((width -= _borderSize.width) < 0.0)
            width = 0;
        if ((height -= _borderSize.height) < 0.0)
            height = 0;

        _DOMBackgroundElement.style.width = width + "px";
        _DOMBackgroundElement.style.height = height + "px";
    }
}
});
instance_methods[24] = new objj_method(sel_registerName("bounds"), function(self, _cmd)
{ with(self)
{
    return _bounds;
}
});
instance_methods[25] = new objj_method(sel_registerName("resizeWithOldSuperviewSize:"), function(self, _cmd, aSize)
{ with(self)
{
    var mask = _autoresizingMask;

    if(mask == CPViewNotSizable)
        return;

    var frame = objj_msgSend(objj_msgSend(self, "superview"), "frame"),
        newFrame = CPRectCreateCopy(_frame),
        dX = (CPRectGetWidth(frame) - aSize.width) /
            (((mask & CPViewMinXMargin) ? 1 : 0) + (mask & CPViewWidthSizable ? 1 : 0) + (mask & CPViewMaxXMargin ? 1 : 0)),
        dY = (CPRectGetHeight(frame) - aSize.height) /
            ((mask & CPViewMinYMargin ? 1 : 0) + (mask & CPViewHeightSizable ? 1 : 0) + (mask & CPViewMaxYMargin ? 1 : 0));

    if (mask & CPViewMinXMargin)
        newFrame.origin.x += dX;
    if (mask & CPViewWidthSizable)
        newFrame.size.width += dX;

    if (mask & CPViewMinYMargin)
        newFrame.origin.y += dY;
    if (mask & CPViewHeightSizable)
        newFrame.size.height += dY;

    objj_msgSend(self, "setFrame:", newFrame);
}
});
instance_methods[26] = new objj_method(sel_registerName("resizeSubviewsWithOldSize:"), function(self, _cmd, aSize)
{ with(self)
{
    var i = _subviews.length - 1;

    for(; i >= 0; --i)
        objj_msgSend(_subviews[i], "resizeWithOldSuperviewSize:", aSize);
}
});
instance_methods[27] = new objj_method(sel_registerName("setAutoresizesSubviews:"), function(self, _cmd, aFlag)
{ with(self)
{
    _autoresizesSubviews = aFlag;
}
});
instance_methods[28] = new objj_method(sel_registerName("autoresizesSubviews"), function(self, _cmd)
{ with(self)
{
    return _autoresizesSubviews;
}
});
instance_methods[29] = new objj_method(sel_registerName("setAutoresizingMask:"), function(self, _cmd, aMask)
{ with(self)
{
    _autoresizingMask = aMask;
}
});
instance_methods[30] = new objj_method(sel_registerName("autoresizingMask"), function(self, _cmd)
{ with(self)
{
    return _autoresizingMask;
}
});
instance_methods[31] = new objj_method(sel_registerName("enterFullScreenMode:withOptions:"), function(self, _cmd, aScreen, options)
{ with(self)
{
    _fullScreenModeState = _CPViewFullScreenModeStateMake(self);

    var fullScreenWindow = objj_msgSend(objj_msgSend(CPWindow, "alloc"), "initWithContentRect:styleMask:", objj_msgSend(objj_msgSend(CPDOMWindowBridge, "sharedDOMWindowBridge"), "contentBounds"), CPBorderlessWindowMask);

    objj_msgSend(fullScreenWindow, "setLevel:", CPScreenSaverWindowLevel);
    objj_msgSend(fullScreenWindow, "setAutoresizingMask:", CPViewWidthSizable|CPViewHeightSizable);

    var contentView = objj_msgSend(fullScreenWindow, "contentView");

    objj_msgSend(contentView, "setBackgroundColor:", objj_msgSend(CPColor, "blackColor"));
    objj_msgSend(contentView, "addSubview:", self);

    objj_msgSend(self, "setAutoresizingMask:", CPViewWidthSizable|CPViewHeightSizable);
    objj_msgSend(self, "setFrame:", CGRectMakeCopy(objj_msgSend(contentView, "bounds")));

    objj_msgSend(fullScreenWindow, "makeKeyAndOrderFront:", self);

    objj_msgSend(fullScreenWindow, "makeFirstResponder:", self);

    _isInFullScreenMode = YES;

    return YES;
}
});
instance_methods[32] = new objj_method(sel_registerName("exitFullScreenModeWithOptions:"), function(self, _cmd, options)
{ with(self)
{
    if (!_isInFullScreenMode)
        return;

    _isInFullScreenMode = NO;

    objj_msgSend(self, "setFrame:", _fullScreenModeState.frame);
    objj_msgSend(self, "setAutoresizingMask:", _fullScreenModeState.autoresizingMask);
    objj_msgSend(_fullScreenModeState.superview, "insertSubview:atIndex:", self, _fullScreenModeState.index);

    objj_msgSend(objj_msgSend(self, "window"), "orderOut:", self);
}
});
instance_methods[33] = new objj_method(sel_registerName("isInFullScreenMode"), function(self, _cmd)
{ with(self)
{
    return _isInFullScreenMode;
}
});
instance_methods[34] = new objj_method(sel_registerName("setHidden:"), function(self, _cmd, aFlag)
{ with(self)
{
    if(_isHidden == aFlag)
        return;


    _DOMElement.style.display = (_isHidden = aFlag) ? "none" : "block";
}
});
instance_methods[35] = new objj_method(sel_registerName("isHidden"), function(self, _cmd)
{ with(self)
{
    return _isHidden;
}
});
instance_methods[36] = new objj_method(sel_registerName("setAlphaValue:"), function(self, _cmd, anAlphaValue)
{ with(self)
{
    if (_opacity == anAlphaValue)
        return;

    _opacity = anAlphaValue;

    _DOMElement.style.opacity = anAlphaValue;
    _DOMElement.style.filter = "alpha(opacity=" + anAlphaValue * 100 + ")";
}
});
instance_methods[37] = new objj_method(sel_registerName("alphaValue"), function(self, _cmd)
{ with(self)
{
    return _opacity;
}
});
instance_methods[38] = new objj_method(sel_registerName("setOpacity:"), function(self, _cmd, anOpacity)
{ with(self)
{
    _DOMElement.style.opacity = _opacity = anOpacity;
}
});
instance_methods[39] = new objj_method(sel_registerName("opacity"), function(self, _cmd)
{ with(self)
{
    return _opacity;
}
});
instance_methods[40] = new objj_method(sel_registerName("isHiddenOrHasHiddenAncestor"), function(self, _cmd)
{ with(self)
{
    var view = self;

    while (!objj_msgSend(view, "isHidden"))
        view = objj_msgSend(view, "superview");

    return view != nil;
}
});
instance_methods[41] = new objj_method(sel_registerName("acceptsFirstMouse:"), function(self, _cmd, anEvent)
{ with(self)
{
    return YES;
}
});
instance_methods[42] = new objj_method(sel_registerName("hitTests"), function(self, _cmd)
{ with(self)
{
    return YES;
}
});
instance_methods[43] = new objj_method(sel_registerName("setHitTests:"), function(self, _cmd, shouldHitTest)
{ with(self)
{
    _hitTests = shouldHitTest;
}
});
instance_methods[44] = new objj_method(sel_registerName("hitTest:"), function(self, _cmd, aPoint)
{ with(self)
{
    if(_isHidden || !_hitTests || !CPRectContainsPoint(_frame, aPoint))
        return nil;

    var view = nil,
        i = _subviews.length,
        adjustedPoint = CPPointMake(aPoint.x - CPRectGetMinX(_frame), aPoint.y - CPRectGetMinY(_frame));

    while (i--)
        if (view = objj_msgSend(_subviews[i], "hitTest:", adjustedPoint))
            return view;

    return self;
}
});
instance_methods[45] = new objj_method(sel_registerName("_createSeparateBackground"), function(self, _cmd)
{ with(self)
{
    _DOMBackgroundElement = document.createElement("div");
    _DOMBackgroundElement.style.position = "absolute";
    _DOMBackgroundElement.style.top = "0px";
    _DOMBackgroundElement.style.left = "0px";
    _DOMBackgroundElement.style.zIndex = DOMBackgroundElementZIndex;
    _DOMBackgroundElement.style.width = CPRectGetWidth(_frame) + "px";
    _DOMBackgroundElement.style.height = CPRectGetHeight(_frame) + "px";
    _DOMBackgroundElement.style.background = _DOMElement.style.background;

    _DOMElement.appendChild(_DOMBackgroundElement);

    _DOMElement.style.background = "";
}
});
instance_methods[46] = new objj_method(sel_registerName("setBackgroundColor:"), function(self, _cmd, aColor)
{ with(self)
{
    _backgroundColor = aColor;



    var cssString = _backgroundColor ? objj_msgSend(_backgroundColor, "cssString") : "";

    if (_DOMBackgroundElement)
        _DOMBackgroundElement.style.background = cssString;
    else
        _DOMElement.style.background = cssString;
}
});
instance_methods[47] = new objj_method(sel_registerName("backgroundColor"), function(self, _cmd)
{ with(self)
{
    return _backgroundColor;
}
});
instance_methods[48] = new objj_method(sel_registerName("setTopBorder:"), function(self, _cmd, aBorder)
{ with(self)
{
    if (!_DOMBackgroundElement)
        objj_msgSend(self, "_createSeparateBackground");

    _borderSize.height = _borderSize.height - objj_msgSend(_topBorder, "thickness") + objj_msgSend(aBorder, "thickness");
    _DOMBackgroundElement.style.borderTop = objj_msgSend(_topBorder=aBorder, "cssString");

    objj_msgSend(self, "_setSizeFromFrame");
}
});
instance_methods[49] = new objj_method(sel_registerName("topBorder"), function(self, _cmd)
{ with(self)
{
    return _topBorder;
}
});
instance_methods[50] = new objj_method(sel_registerName("setLeftBorder:"), function(self, _cmd, aBorder)
{ with(self)
{
    if (!_DOMBackgroundElement)
        objj_msgSend(self, "_createSeparateBackground");

    _borderSize.width = (_borderSize.width - objj_msgSend(_leftBorder, "thickness") + objj_msgSend(aBorder, "thickness"));
    _DOMBackgroundElement.style.borderLeft = objj_msgSend(_leftBorder=aBorder, "cssString");

    objj_msgSend(self, "_setSizeFromFrame");
}
});
instance_methods[51] = new objj_method(sel_registerName("leftBorder"), function(self, _cmd)
{ with(self)
{
    return _leftBorder;
}
});
instance_methods[52] = new objj_method(sel_registerName("setRightBorder:"), function(self, _cmd, aBorder)
{ with(self)
{
    if (!_DOMBackgroundElement)
        objj_msgSend(self, "_createSeparateBackground");

    _borderSize.width = (_borderSize.width - objj_msgSend(_rightBorder, "thickness") + objj_msgSend(aBorder, "thickness"));
    _DOMBackgroundElement.style.borderRight = objj_msgSend(_rightBorder=aBorder, "cssString");

    objj_msgSend(self, "_setSizeFromFrame");
}
});
instance_methods[53] = new objj_method(sel_registerName("rightBorder"), function(self, _cmd)
{ with(self)
{
    return _rightBorder;
}
});
instance_methods[54] = new objj_method(sel_registerName("setBottomBorder:"), function(self, _cmd, aBorder)
{ with(self)
{
    if (!_DOMBackgroundElement)
        objj_msgSend(self, "_createSeparateBackground");

    _borderSize.height = _borderSize.height - objj_msgSend(_bottomBorder, "thickness") + objj_msgSend(aBorder, "thickness");
    _DOMBackgroundElement.style.borderBottom = objj_msgSend(_bottomBorder=aBorder, "cssString");

    objj_msgSend(self, "_setSizeFromFrame");
}
});
instance_methods[55] = new objj_method(sel_registerName("bottomBorder"), function(self, _cmd)
{ with(self)
{
    return _bottomBorder;
}
});
instance_methods[56] = new objj_method(sel_registerName("setBorder:"), function(self, _cmd, aBorder)
{ with(self)
{
    if (!_DOMBackgroundElement)
        objj_msgSend(self, "_createSeparateBackground");

    _topBorder = _leftBorder = _rightBorder = _bottomBorder = aBorder;

    _DOMBackgroundElement.style.borderTop = "";
    _DOMBackgroundElement.style.borderLeft = "";
    _DOMBackgroundElement.style.borderRight = "";
    _DOMBackgroundElement.style.borderBottom = "";

    _DOMBackgroundElement.style.border = objj_msgSend(aBorder, "cssString");

    _borderSize = CPSizeMake(objj_msgSend(aBorder, "thickness") * 2.0, objj_msgSend(aBorder, "thickness") * 2.0);

    objj_msgSend(self, "_setSizeFromFrame");
}
});
instance_methods[57] = new objj_method(sel_registerName("convertRect:fromView:"), function(self, _cmd, aRect, aView)
{ with(self)
{
    var converted = CPRectCreateCopy(aRect);

    converted.origin = objj_msgSend(self, "convertPoint:fromView:", aRect.origin, aView);

    return converted;
}
});
instance_methods[58] = new objj_method(sel_registerName("convertPoint:fromView:"), function(self, _cmd, aPoint, aView)
{ with(self)
{
    var view = self,
        point = CPPointCreateCopy(aPoint);

    while (view != aView)
    {
        var frame = objj_msgSend(view, "frame");
        point.x -= CPRectGetMinX(frame);
        point.y -= CPRectGetMinY(frame);

        view = objj_msgSend(view, "superview");
    }

    return point;
}
});
instance_methods[59] = new objj_method(sel_registerName("convertPoint:toView:"), function(self, _cmd, aPoint, aView)
{ with(self)
{
    var view = self,
        point = CPPointCreateCopy(aPoint);

    while (view != aView)
    {
        var frame = objj_msgSend(view, "frame");
        point.x += CPRectGetMinX(frame);
        point.y += CPRectGetMinY(frame);

        view = objj_msgSend(view, "superview");
    }

    return point;
}
});
instance_methods[60] = new objj_method(sel_registerName("FIXME_convertPoint:fromView:"), function(self, _cmd, aPoint, aView)
{ with(self)
{
    var point = CPPointCreateCopy(aPoint);

    while (aView != self)
    {
        var frame = objj_msgSend(aView, "frame");
        point.x += CPRectGetMinX(frame);
        point.y += CPRectGetMinY(frame);

        aView = objj_msgSend(aView, "superview");
    }

    return point;
}
});
instance_methods[61] = new objj_method(sel_registerName("FIXME_convertRect:fromView:"), function(self, _cmd, aRect, aView)
{ with(self)
{
    rect = CPRectCreateCopy(aRect);

    rect.origin = objj_msgSend(self, "FIXME_convertPoint:fromView:", aRect.origin, aView);

    return rect;
}
});
instance_methods[62] = new objj_method(sel_registerName("dragImage:at:offset:event:pasteboard:source:slideBack:"), function(self, _cmd, anImage, aLocation, mouseOffset, anEvent, aPasteboard, aSourceObject, slideBack)
{ with(self)
{
    objj_msgSend(_window, "dragImage:at:offset:event:pasteboard:source:slideBack:", anImage, objj_msgSend(self, "convertPoint:toView:", aLocation, nil), mouseOffset, anEvent, aPasteboard, aSourceObject, slideBack);
}
});
instance_methods[63] = new objj_method(sel_registerName("dragView:at:offset:event:pasteboard:source:slideBack:"), function(self, _cmd, aView, aLocation, mouseOffset, anEvent, aPasteboard, aSourceObject, slideBack)
{ with(self)
{
    objj_msgSend(_window, "dragView:at:offset:event:pasteboard:source:slideBack:", aView, objj_msgSend(self, "convertPoint:toView:", aLocation, nil), mouseOffset, anEvent, aPasteboard, aSourceObject, slideBack);
}
});
instance_methods[64] = new objj_method(sel_registerName("registerForDraggedTypes:"), function(self, _cmd, pasteboardTypes)
{ with(self)
{
    _registeredDraggedTypes = objj_msgSend(pasteboardTypes, "copy");
}
});
instance_methods[65] = new objj_method(sel_registerName("registeredDraggedTypes"), function(self, _cmd)
{ with(self)
{
    return _registeredDraggedTypes;
}
});
instance_methods[66] = new objj_method(sel_registerName("unregisterDraggedTypes"), function(self, _cmd)
{ with(self)
{
    _registeredDraggedTypes = nil;
}
});
instance_methods[67] = new objj_method(sel_registerName("drawRect:"), function(self, _cmd, aRect)
{ with(self)
{}
});
instance_methods[68] = new objj_method(sel_registerName("lockFocus"), function(self, _cmd)
{ with(self)
{


    if (!_graphicsContext)
    {
        var context = CGBitmapGraphicsContextCreate();

        _DOMGraphicsElement = context.DOMElement;

        _DOMGraphicsElement.style.position = "absolute";
        _DOMGraphicsElement.style.top = "0px";
        _DOMGraphicsElement.style.left = "0px";
        _DOMGraphicsElement.style.zIndex = DOMCanvasElementZIndex;

        _DOMGraphicsElement.width = CPRectGetWidth(_frame);
        _DOMGraphicsElement.height = CPRectGetHeight(_frame);

        _DOMGraphicsElement.style.width = CPRectGetWidth(_frame) + "px";
        _DOMGraphicsElement.style.height = CPRectGetHeight(_frame) + "px";

        _DOMElement.appendChild(_DOMGraphicsElement);

        _graphicsContext = objj_msgSend(CPGraphicsContext, "graphicsContextWithGraphicsPort:flipped:", context, YES);
    }

    objj_msgSend(CPGraphicsContext, "setCurrentContext:", _graphicsContext);

    CGContextSaveGState(objj_msgSend(_graphicsContext, "graphicsPort"));
}
});
instance_methods[69] = new objj_method(sel_registerName("unlockFocus"), function(self, _cmd)
{ with(self)
{
    var graphicsPort = objj_msgSend(_graphicsContext, "graphicsPort");

    CGContextRestoreGState(graphicsPort);

    objj_msgSend(CPGraphicsContext, "setCurrentContext:", nil);
}
});
instance_methods[70] = new objj_method(sel_registerName("setNeedsDisplay:"), function(self, _cmd, aFlag)
{ with(self)
{
    if (aFlag)
        objj_msgSend(self, "display");
}
});
instance_methods[71] = new objj_method(sel_registerName("setNeedsDisplayInRect:"), function(self, _cmd, aRect)
{ with(self)
{
    objj_msgSend(self, "displayRect:", aRect);
}
});
instance_methods[72] = new objj_method(sel_registerName("display"), function(self, _cmd)
{ with(self)
{
    objj_msgSend(self, "displayRect:", _bounds);
}
});
instance_methods[73] = new objj_method(sel_registerName("displayRect:"), function(self, _cmd, aRect)
{ with(self)
{
    objj_msgSend(self, "lockFocus");
    objj_msgSend(self, "drawRect:", aRect);
    objj_msgSend(self, "unlockFocus");
}
});
instance_methods[74] = new objj_method(sel_registerName("visibleRect"), function(self, _cmd)
{ with(self)
{
    if (!_superview)
        return _bounds;

    return CGRectIntersection(objj_msgSend(self, "convertRect:fromView:", objj_msgSend(_superview, "visibleRect"), _superview), _bounds);
}
});
instance_methods[75] = new objj_method(sel_registerName("_enclosingClipView"), function(self, _cmd)
{ with(self)
{
    var superview = _superview,
        clipViewClass = objj_msgSend(CPClipView, "class");

    while(superview && !objj_msgSend(superview, "isKindOfClass:", clipViewClass))
        superview = superview._superview;

    return superview;
}
});
instance_methods[76] = new objj_method(sel_registerName("scrollPoint:"), function(self, _cmd, aPoint)
{ with(self)
{
    var clipView = objj_msgSend(self, "_enclosingClipView");

    if (!clipView)
        return;

    objj_msgSend(clipView, "scrollToPoint:", objj_msgSend(clipView, "convertPoint:fromView:", aPoint, self));
}
});
instance_methods[77] = new objj_method(sel_registerName("scrollRectToVisible:"), function(self, _cmd, aRect)
{ with(self)
{
    var visibleRect = objj_msgSend(self, "visibleRect");


    aRect = CGRectIntersection(aRect, objj_msgSend(self, "bounds"));


    if (CGRectIsEmpty(aRect) || CGRectContainsRect(visibleRect, aRect))
        return NO;

    var enclosingClipView = objj_msgSend(self, "_enclosingClipView");


    if (!enclosingClipView)
        return NO;

    var scrollPoint = CGPointMakeCopy(visibleRect.origin);


    if (CGRectGetMinX(aRect) <= CGRectGetMinX(visibleRect))
        scrollPoint.x = CGRectGetMinX(aRect);
    else if (CGRectGetMaxX(aRect) > CGRectGetMaxX(visibleRect))
        scrollPoint.x += CGRectGetMaxX(aRect) - CGRectGetMaxX(visibleRect);

    if (CGRectGetMinY(aRect) <= CGRectGetMinY(visibleRect))
        scrollPoint.y = CGRectGetMinY(aRect);
    else if (CGRectGetMaxY(aRect) > CGRectGetMaxY(visibleRect))
        scrollPoint.y += CGRectGetMaxY(aRect) - CGRectGetMaxY(visibleRect);





    objj_msgSend(enclosingClipView, "scrollToPoint:", CGPointMake(-scrollPoint.x,-scrollPoint.y));
    objj_msgSend(objj_msgSend(enclosingClipView, "superview"), "reflectScrolledClipView:", enclosingClipView);


    return YES;
}
});
instance_methods[78] = new objj_method(sel_registerName("autoscroll:"), function(self, _cmd, anEvent)
{ with(self)
{

    return NO;
}
});
instance_methods[79] = new objj_method(sel_registerName("adjustScroll:"), function(self, _cmd, proposedVisibleRect)
{ with(self)
{
    return proposedVisibleRect;
}
});
instance_methods[80] = new objj_method(sel_registerName("scrollRect:by:"), function(self, _cmd, aRect, anAmount)
{ with(self)
{}
});
instance_methods[81] = new objj_method(sel_registerName("enclosingScrollView"), function(self, _cmd)
{ with(self)
{
    var superview = _superview,
        scrollViewClass = objj_msgSend(CPScrollView, "class");

    while(superview && !objj_msgSend(superview, "isKindOfClass:", scrollViewClass))
        superview = superview._superview;

    return superview;
}
});
instance_methods[82] = new objj_method(sel_registerName("scrollClipView:toPoint:"), function(self, _cmd, aClipView, aPoint)
{ with(self)
{
    objj_msgSend(aClipView, "scrollToPoint:", aPoint);
}
});
instance_methods[83] = new objj_method(sel_registerName("reflectScrolledClipView:"), function(self, _cmd, aClipView)
{ with(self)
{}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

{
var the_class = objj_getClass("CPView")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPView\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("setLayer:"), function(self, _cmd, aLayer)
{ with(self)
{
    if (_layer == aLayer)
        return;

    if (_layer)
    {
        _layer._owningView = nil;
        _DOMElement.removeChild(_layer._DOMElement);
    }

    _layer = aLayer;

    if (_layer)
    {
        var bounds = CGRectMakeCopy(objj_msgSend(self, "bounds"));

        objj_msgSend(_layer, "_setOwningView:", self);

        _layer._DOMElement.style.zIndex = 100;

        _DOMElement.appendChild(_layer._DOMElement);
    }
}
});
instance_methods[1] = new objj_method(sel_registerName("layer"), function(self, _cmd)
{ with(self)
{
    return _layer;
}
});
instance_methods[2] = new objj_method(sel_registerName("setWantsLayer:"), function(self, _cmd, aFlag)
{ with(self)
{
    _wantsLayer = aFlag;
}
});
instance_methods[3] = new objj_method(sel_registerName("wantsLayer"), function(self, _cmd)
{ with(self)
{
    return _wantsLayer;
}
});
class_addMethods(the_class, instance_methods);
}

var CPViewAutoresizingMaskKey = "CPViewAutoresizingMask",
    CPViewAutoresizesSubviewsKey = "CPViewAutoresizesSubviews",
    CPViewBackgroundColorKey = "CPViewBackgroundColor",
    CPViewBoundsKey = "CPViewBoundsKey",
    CPViewFrameKey = "CPViewFrameKey",
    CPViewHitTestsKey = "CPViewHitTestsKey",
    CPViewIsHiddenKey = "CPViewIsHiddenKey",
    CPViewOpacityKey = "CPViewOpacityKey",
    CPViewSubviewsKey = "CPViewSubviewsKey",
    CPViewSuperviewKey = "CPViewSuperviewKey",
    CPViewWindowKey = "CPViewWindowKey",

    FIXME_indexKey = "FIXME_indexKey";

{
var the_class = objj_getClass("CPView")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPView\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPResponder") }, "initWithCoder:", aCoder);

    if (self)
    {
        _frame = objj_msgSend(aCoder, "decodeRectForKey:", CPViewFrameKey);
        _bounds = objj_msgSend(aCoder, "decodeRectForKey:", CPViewBoundsKey);

        _window = objj_msgSend(aCoder, "decodeObjectForKey:", CPViewWindowKey);
        _subviews = objj_msgSend(aCoder, "decodeObjectForKey:", CPViewSubviewsKey);
        _superview = objj_msgSend(aCoder, "decodeObjectForKey:", CPViewSuperviewKey);

        _autoresizingMask = objj_msgSend(aCoder, "decodeIntForKey:", CPViewAutoresizingMaskKey);
        _autoresizesSubviews = objj_msgSend(aCoder, "decodeBoolForKey:", CPViewAutoresizesSubviewsKey);


        _index = objj_msgSend(aCoder, "decodeIntForKey:", FIXME_indexKey);

        _hitTests = objj_msgSend(aCoder, "decodeObjectForKey:", CPViewHitTestsKey);
        _isHidden = objj_msgSend(aCoder, "decodeObjectForKey:", CPViewIsHiddenKey);
        _opacity = objj_msgSend(aCoder, "decodeIntForKey:", CPViewOpacityKey);



        _DOMElement = document.createElement("div");
        _DOMElement.style.overflow = "hidden";
        _DOMElement.style.position = "absolute";
        _DOMElement.style.visibility = "visible";
        _DOMElement.style.top = CPRectGetMinY(_frame) + "px";
        _DOMElement.style.left = CPRectGetMinX(_frame) + "px";
        _DOMElement.style.zIndex = 0;
        _DOMElement.style.width = CPRectGetWidth(_frame) + "px";
        _DOMElement.style.height = CPRectGetHeight(_frame) + "px";

        var index = 0,
            count = _subviews.length;

        for (; index < count; ++index)
            _DOMElement.appendChild(_subviews[index]._DOMElement);

        objj_msgSend(self, "setBackgroundColor:", objj_msgSend(aCoder, "decodeObjectForKey:", CPViewBackgroundColorKey));
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("encodeWithCoder:"), function(self, _cmd, aCoder)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPResponder") }, "encodeWithCoder:", aCoder);

    objj_msgSend(aCoder, "encodeRect:forKey:", _frame, CPViewFrameKey);
    objj_msgSend(aCoder, "encodeRect:forKey:", _bounds, CPViewBoundsKey);

    objj_msgSend(aCoder, "encodeConditionalObject:forKey:", _window, CPViewWindowKey);
    objj_msgSend(aCoder, "encodeObject:forKey:", _subviews, CPViewSubviewsKey);
    objj_msgSend(aCoder, "encodeConditionalObject:forKey:", _superview, CPViewSuperviewKey);

    objj_msgSend(aCoder, "encodeInt:forKey:", _autoresizingMask, CPViewAutoresizingMaskKey);
    objj_msgSend(aCoder, "encodeBool:forKey:", _autoresizesSubviews, CPViewAutoresizesSubviewsKey);

    objj_msgSend(aCoder, "encodeObject:forKey:", _backgroundColor, CPViewBackgroundColorKey);

    objj_msgSend(aCoder, "encodeBool:forKey:", _hitTests, CPViewHitTestsKey);
    objj_msgSend(aCoder, "encodeBool:forKey:", _isHidden, CPViewIsHiddenKey);
    objj_msgSend(aCoder, "encodeFloat:forKey:", _opacity, CPViewOpacityKey);


    objj_msgSend(aCoder, "encodeInt:forKey:", _index, FIXME_indexKey);
}
});
class_addMethods(the_class, instance_methods);
}

var _CPViewFullScreenModeStateMake = function(aView)
{
    return { autoresizingMask:aView._autoresizingMask, frame:CGRectMakeCopy(aView._frame), index:aView._index, superview:aView._superview };
}

p;10;CPWindow.jI;33;Foundation/CPNotificationCenter.jI;26;Foundation/CPUndoManager.ji;26;_CPBorderlessBridgeFrame.ji;12;CGGeometry.ji;19;CPCoreDragManager.ji;19;CPDOMWindowBridge.ji;13;CPResponder.ji;14;CPThemeFrame.ji;8;CPView.ji;13;CPAnimation.jc;35861;

CPBorderlessWindowMask = 0;
CPTitledWindowMask = 1 << 0;
CPClosableWindowMask = 1 << 1;
CPMiniaturizableWindowMask = 1 << 2;
CPResizableWindowMask = 1 << 3;
CPTexturedBackgroundWindowMask = 1 << 8;

CPBorderlessBridgeWindowMask = 1 << 20;
CPHUDBackgroundWindowMask = 1 << 21;

CPWindowNotSizable = 0;
CPWindowMinXMargin = 1;
CPWindowWidthSizable = 2;
CPWindowMaxXMargin = 4;
CPWindowMinYMargin = 8;
CPWindowHeightSizable = 16;
CPWindowMaxYMargin = 32;

CPNormalWindowLevel = 4;
CPFloatingWindowLevel = 5;
CPSubmenuWindowLevel = 6;
CPTornOffMenuWindowLevel = 6;
CPMainMenuWindowLevel = 8;
CPStatusWindowLevel = 9;
CPModalPanelWindowLevel = 10;
CPPopUpMenuWindowLevel = 11;
CPDraggingWindowLevel = 12;
CPScreenSaverWindowLevel = 13;

CPWindowOut = 0;
CPWindowAbove = 1;
CPWindowBelow = 2;

CPWindowWillCloseNotification = "CPWindowWillCloseNotification";
CPWindowDidBecomeMainNotification = "CPWindowDidBecomeMainNotification";
CPWindowDidResignMainNotification = "CPWindowDidResignMainNotification";

{var the_class = objj_allocateClassPair(CPResponder, "CPWindow"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_windowNumber"), new objj_ivar("_styleMask"), new objj_ivar("_frame"), new objj_ivar("_level"), new objj_ivar("_isVisible"), new objj_ivar("_isAnimating"), new objj_ivar("_isDocumentEdited"), new objj_ivar("_isDocumentSaving"), new objj_ivar("_themeFrame"), new objj_ivar("_contentView"), new objj_ivar("_toolbarView"), new objj_ivar("_mouseOverView"), new objj_ivar("_leftMouseDownView"), new objj_ivar("_rightMouseDownView"), new objj_ivar("_toolbar"), new objj_ivar("_firstResponder"), new objj_ivar("_delegate"), new objj_ivar("_windowController"), new objj_ivar("_minSize"), new objj_ivar("_maxSize"), new objj_ivar("_resizeFrame"), new objj_ivar("_undoManager"), new objj_ivar("_representedURL"), new objj_ivar("_DOMElement"), new objj_ivar("_bridge"), new objj_ivar("_autoresizingMask"), new objj_ivar("_delegateRespondsToWindowWillReturnUndoManagerSelector"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("initialize"), function(self, _cmd)
{ with(self)
{
    if (self != objj_msgSend(CPWindow, "class"))
        return;

    CPWindowResizeIndicatorImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(objj_msgSend(CPBundle, "bundleForClass:", self), "pathForResource:", "CPWindowResizeIndicator.png"), CGSizeMake(12.0,12.0));
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithContentRect:styleMask:"), function(self, _cmd, aContentRect, aStyleMask)
{ with(self)
{
    return objj_msgSend(self, "initWithContentRect:styleMask:bridge:", aContentRect, aStyleMask, objj_msgSend(CPDOMWindowBridge, "sharedDOMWindowBridge"));
}
});
instance_methods[1] = new objj_method(sel_registerName("initWithContentRect:styleMask:bridge:"), function(self, _cmd, aContentRect, aStyleMask, aBridge)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPResponder") }, "init");

    if (self)
    {

        _windowNumber = objj_msgSend(CPApp._windows, "count");
        CPApp._windows[_windowNumber] = self;

        _styleMask = aStyleMask;

        _frame = objj_msgSend(self, "frameRectForContentRect:", aContentRect);

        _level = CPNormalWindowLevel;

        _minSize = CGSizeMake(0.0, 0.0);
        _maxSize = CGSizeMake(1000000.0, 1000000.0);

        if (_styleMask & CPBorderlessBridgeWindowMask)
            _autoresizingMask = CPWindowWidthSizable | CPWindowHeightSizable;


        _themeFrame = objj_msgSend(objj_msgSend(CPThemeFrame, "alloc"), "initWithFrame:forStyleMask:", CGRectMake(0.0,0.0,CGRectGetWidth(_frame),CGRectGetHeight(_frame)), _styleMask);
        objj_msgSend(_themeFrame, "_setWindow:", self);
        objj_msgSend(_themeFrame, "setNextResponder:", self);


        objj_msgSend(self, "setContentView:", objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", CGRectMakeZero()));

        _firstResponder = self;

        _DOMElement = document.createElement("div");
        _DOMElement.style.overflow = "hidden";
        _DOMElement.style.position = "absolute";
        _DOMElement.style.visibility = "visible";
        _DOMElement.style.top = CGRectGetMinY(_frame) + "px";
        _DOMElement.style.left = CGRectGetMinX(_frame) + "px";
        _DOMElement.style.zIndex = 0;
        _DOMElement.style.width = CGRectGetWidth(_frame) + "px";
        _DOMElement.style.height = CGRectGetHeight(_frame) + "px";

        _DOMElement.appendChild(_themeFrame._DOMElement);

        objj_msgSend(self, "setBridge:", aBridge);

        objj_msgSend(self, "setNextResponder:", CPApp);
    }

    return self;
}
});
instance_methods[2] = new objj_method(sel_registerName("styleMask"), function(self, _cmd)
{ with(self)
{
    return _styleMask;
}
});
class_methods[1] = new objj_method(sel_registerName("frameRectForContentRect:styleMask:"), function(self, _cmd, aContentRect, aStyleMask)
{ with(self)
{
    var frame = CGRectMakeCopy(aContentRect);

    return frame;
}
});
instance_methods[3] = new objj_method(sel_registerName("contentRectForFrameRect:"), function(self, _cmd, aFrame)
{ with(self)
{

    var contentRect = CGRectMakeCopy(objj_msgSend(_themeFrame, "bounds"));

    if (_styleMask & CPHUDBackgroundWindowMask)
    {
        contentRect.origin.x += 7.0;
        contentRect.origin.y += 30.0;
        contentRect.size.width -= 14.0;
        contentRect.size.height -= 40.0;
    }

    else if (_styleMask & CPBorderlessBridgeWindowMask)
    {
        contentRect.origin.y += 29.0;
        contentRect.size.height -= 29.0;
    }

    if (objj_msgSend(_toolbar, "isVisible"))
    {
        var toolbarHeight = CGRectGetHeight(objj_msgSend(_toolbarView, "frame"));

        contentRect.origin.y += toolbarHeight;
        contentRect.size.height -= toolbarHeight;
    }

    return contentRect;
}
});
instance_methods[4] = new objj_method(sel_registerName("frameRectForContentRect:"), function(self, _cmd, aContentRect)
{ with(self)
{
    if (_styleMask & CPBorderlessBridgeWindowMask)
        return _bridge ? objj_msgSend(_bridge, "contentBounds") : CGRectMakeZero();

    var frame = objj_msgSend(objj_msgSend(self, "class"), "frameRectForContentRect:styleMask:", aContentRect, _styleMask);

    return frame;
}
});
instance_methods[5] = new objj_method(sel_registerName("frame"), function(self, _cmd)
{ with(self)
{
    return _frame;
}
});
instance_methods[6] = new objj_method(sel_registerName("setFrame:display:animate:"), function(self, _cmd, aFrame, shouldDisplay, shouldAnimate)
{ with(self)
{
    if (shouldAnimate)
    {
        var animation = objj_msgSend(objj_msgSend(_CPWindowFrameAnimation, "alloc"), "initWithWindow:targetFrame:", self, aFrame);

        objj_msgSend(animation, "startAnimation");
    }
    else
    {
        objj_msgSend(self, "setFrameOrigin:", aFrame.origin);
        objj_msgSend(self, "setFrameSize:", aFrame.size);
    }
}
});
instance_methods[7] = new objj_method(sel_registerName("setFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    objj_msgSend(self, "setFrame:display:animate:", aFrame, YES, NO);
}
});
instance_methods[8] = new objj_method(sel_registerName("setFrameOrigin:"), function(self, _cmd, anOrigin)
{ with(self)
{
    _frame.origin = CGPointMakeCopy(anOrigin);

    _DOMElement.style.top = CGRectGetMinY(_frame) + "px";
    _DOMElement.style.left = CGRectGetMinX(_frame) + "px";
}
});
instance_methods[9] = new objj_method(sel_registerName("setFrameSize:"), function(self, _cmd, aSize)
{ with(self)
{
    aSize = CGSizeMake(MIN(MAX(aSize.width, _minSize.width), _maxSize.width), MIN(MAX(aSize.height, _minSize.height), _maxSize.height));

    if (CGSizeEqualToSize(_frame.size, aSize))
        return;

    _frame.size = CGSizeMakeCopy(aSize);

    _DOMElement.style.width = CGRectGetWidth(_frame) + "px";
    _DOMElement.style.height = CGRectGetHeight(_frame) + "px";

    objj_msgSend(_themeFrame, "setFrameSize:", aSize);

    if (!_isAnimating && objj_msgSend(_delegate, "respondsToSelector:", sel_registerName("windowDidResize:")))
        objj_msgSend(_delegate, "windowDidResize:", self);
}
});
instance_methods[10] = new objj_method(sel_registerName("trackResizeWithEvent:"), function(self, _cmd, anEvent)
{ with(self)
{
    var location = objj_msgSend(anEvent, "locationInWindow"),
        type = objj_msgSend(anEvent, "type");

    if (type == CPLeftMouseUp)
        return;
    else if (type == CPLeftMouseDown)
        _resizeFrame = CGRectMake(location.x, location.y, CGRectGetWidth(_frame), CGRectGetHeight(_frame));
    else if (type == CPLeftMouseDragged)
        objj_msgSend(self, "setFrameSize:", CGSizeMake(CGRectGetWidth(_resizeFrame)+location.x-CGRectGetMinX(_resizeFrame),CGRectGetHeight(_resizeFrame)+location.y-CGRectGetMinY(_resizeFrame)));

    objj_msgSend(CPApp, "setTarget:selector:forNextEventMatchingMask:untilDate:inMode:dequeue:", self, sel_registerName("trackResizeWithEvent:"), CPLeftMouseDraggedMask|CPLeftMouseUpMask, nil, nil, YES);
}
});
instance_methods[11] = new objj_method(sel_registerName("orderFront:"), function(self, _cmd, aSender)
{ with(self)
{
    objj_msgSend(_bridge, "order:window:relativeTo:", CPWindowAbove, self, nil);
}
});
instance_methods[12] = new objj_method(sel_registerName("orderBack:"), function(self, _cmd, aSender)
{ with(self)
{}
});
instance_methods[13] = new objj_method(sel_registerName("orderOut:"), function(self, _cmd, aSender)
{ with(self)
{
    objj_msgSend(_bridge, "order:window:relativeTo:", CPWindowOut, self, nil);
}
});
instance_methods[14] = new objj_method(sel_registerName("orderWindow:relativeTo:"), function(self, _cmd, aPlace, otherWindowNumber)
{ with(self)
{
    objj_msgSend(_bridge, "order:window:relativeTo:", aPlace, self, CPApp._windows[otherWindowNumber]);
}
});
instance_methods[15] = new objj_method(sel_registerName("setLevel:"), function(self, _cmd, aLevel)
{ with(self)
{
    _level = aLevel;
}
});
instance_methods[16] = new objj_method(sel_registerName("level"), function(self, _cmd)
{ with(self)
{
    return _level;
}
});
instance_methods[17] = new objj_method(sel_registerName("isVisible"), function(self, _cmd)
{ with(self)
{
    return _isVisible;
}
});
instance_methods[18] = new objj_method(sel_registerName("showsResizeIndicator"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(_themeFrame, "showsResizeIndicator");
}
});
instance_methods[19] = new objj_method(sel_registerName("setShowsResizeIndicator:"), function(self, _cmd, shouldShowResizeIndicator)
{ with(self)
{
    objj_msgSend(_themeFrame, "setShowsResizeIndicator:", shouldShowResizeIndicator);
}
});
instance_methods[20] = new objj_method(sel_registerName("resizeIndicatorOffset"), function(self, _cmd)
{ with(self)
{
    return _resizeIndicatorOffset;
}
});
instance_methods[21] = new objj_method(sel_registerName("setResizeIndicatorOffset:"), function(self, _cmd, aSize)
{ with(self)
{
    _resizeIndicatorOffset = CGSizeCreateCopy(aSize);

    if (_showsResizeIndicator)
    {
        _resizeIndicator.style.top = (CGRectGetMaxY(_themeFrame._frame) - 13.0 + _resizeIndicatorOffset.height) + "px";
        _resizeIndicator.style.left = (CGRectGetMaxX(_themeFrame._frame) - 13.0 + _resizeIndicatorOffset.width) + "px";
    }
}
});
instance_methods[22] = new objj_method(sel_registerName("setContentView:"), function(self, _cmd, aView)
{ with(self)
{
    if (_contentView)
        objj_msgSend(_contentView, "removeFromSuperview");

    _contentView = aView;
    objj_msgSend(_contentView, "setFrame:", objj_msgSend(self, "contentRectForFrameRect:", _frame));

    objj_msgSend(_contentView, "setAutoresizingMask:", CPViewWidthSizable|CPViewHeightSizable);
    objj_msgSend(_themeFrame, "addSubview:", _contentView);
}
});
instance_methods[23] = new objj_method(sel_registerName("contentView"), function(self, _cmd)
{ with(self)
{
    return _contentView;
}
});
instance_methods[24] = new objj_method(sel_registerName("setBackgroundColor:"), function(self, _cmd, aColor)
{ with(self)
{
    objj_msgSend(_themeFrame, "setBackgroundColor:", aColor);
}
});
instance_methods[25] = new objj_method(sel_registerName("backgroundColor"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(_themeFrame, "backgroundColor");
}
});
instance_methods[26] = new objj_method(sel_registerName("setMinSize:"), function(self, _cmd, aSize)
{ with(self)
{
    if (CGSizeEqualToSize(_minSize, aSize))
        return;

    _minSize = CGSizeCreateCopy(aSize);

    var size = CGSizeMakeCopy(objj_msgSend(self, "frame").size),
        needsFrameChange = NO;

    if (size.width < _minSize.width)
    {
        size.width = _minSize.width;
        needsFrameChange = YES;
    }

    if (size.height < _minSize.height)
    {
        size.height = _minSize.height;
        needsFrameChange = YES;
    }

    if (needsFrameChange)
        objj_msgSend(self, "setFrameSize:", size);
}
});
instance_methods[27] = new objj_method(sel_registerName("minSize"), function(self, _cmd)
{ with(self)
{
    return _minSize;
}
});
instance_methods[28] = new objj_method(sel_registerName("setMaxSize:"), function(self, _cmd, aSize)
{ with(self)
{
    if (CGSizeEqualToSize(_maxSize, aSize))
        return;

    _maxSize = CGSizeCreateCopy(aSize);

    var size = CGSizeMakeCopy(objj_msgSend(self, "frame").size),
        needsFrameChange = NO;

    if (size.width > _maxSize.width)
    {
        size.width = _maxSize.width;
        needsFrameChange = YES;
    }

    if (size.height > _maxSize.height)
    {
        size.height = _maxSize.height;
        needsFrameChange = YES;
    }

    if (needsFrameChange)
        objj_msgSend(self, "setFrameSize:", size);
}
});
instance_methods[29] = new objj_method(sel_registerName("maxSize"), function(self, _cmd)
{ with(self)
{
    return _maxSize;
}
});
instance_methods[30] = new objj_method(sel_registerName("setDelegate:"), function(self, _cmd, aDelegate)
{ with(self)
{
    _delegate = aDelegate;

    _delegateRespondsToWindowWillReturnUndoManagerSelector = objj_msgSend(_delegate, "respondsToSelector:", sel_registerName("windowWillReturnUndoManager:"));

    if (objj_msgSend(_delegate, "respondsToSelector:", sel_registerName("windowDidBecomeMain:")))
        objj_msgSend(defaultCenter, "addObserver:selector:name:object:", _delegate, sel_registerName("windowDidBecomeMain:"), CPWindowDidBecomeMainNotification, self);

    if (objj_msgSend(_delegate, "respondsToSelector:", sel_registerName("windowDidResignMain:")))
        objj_msgSend(defaultCenter, "addObserver:selector:name:object:", _delegate, sel_registerName("windowDidResignMain:"), CPWindowDidResignMainNotification, self);
}
});
instance_methods[31] = new objj_method(sel_registerName("delegate"), function(self, _cmd)
{ with(self)
{
    return _delegate;
}
});
instance_methods[32] = new objj_method(sel_registerName("setWindowController:"), function(self, _cmd, aWindowController)
{ with(self)
{
    _windowController = aWindowController;
}
});
instance_methods[33] = new objj_method(sel_registerName("windowController"), function(self, _cmd)
{ with(self)
{
    return _windowController;
}
});
instance_methods[34] = new objj_method(sel_registerName("doCommandBySelector:"), function(self, _cmd, aSelector)
{ with(self)
{
    if (objj_msgSend(_delegate, "respondsToSelector:", aSelector))
        objj_msgSend(_delegate, "performSelector:", aSelector);
    else
        objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPResponder") }, "doCommandBySelector:", aSelector);
}
});
instance_methods[35] = new objj_method(sel_registerName("acceptsFirstResponder"), function(self, _cmd)
{ with(self)
{
    return YES;
}
});
instance_methods[36] = new objj_method(sel_registerName("makeFirstResponder:"), function(self, _cmd, aResponder)
{ with(self)
{
    if (_firstResponder == aResponder)
        return YES;

    if(!objj_msgSend(_firstResponder, "resignFirstResponder"))
        return NO;

    if(!aResponder || !objj_msgSend(aResponder, "acceptsFirstResponder") || !objj_msgSend(aResponder, "becomeFirstResponder"))
    {
        _firstResponder = self;

        return NO;
    }

    _firstResponder = aResponder;

    return YES;
}
});
instance_methods[37] = new objj_method(sel_registerName("firstResponder"), function(self, _cmd)
{ with(self)
{
    return _firstResponder;
}
});
instance_methods[38] = new objj_method(sel_registerName("title"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(_themeFrame, "title");
}
});
instance_methods[39] = new objj_method(sel_registerName("setTitle:"), function(self, _cmd, aTitle)
{ with(self)
{
    objj_msgSend(_themeFrame, "setTitle:", aTitle);
}
});
instance_methods[40] = new objj_method(sel_registerName("setTitleWithRepresentedFilename:"), function(self, _cmd, aFilePath)
{ with(self)
{
    objj_msgSend(self, "setRepresentedFilename:", aFilePath);
    objj_msgSend(self, "setTitle:", objj_msgSend(aFilePath, "lastPathComponent"));
}
});
instance_methods[41] = new objj_method(sel_registerName("setRepresentedFilename:"), function(self, _cmd, aFilePath)
{ with(self)
{

    objj_msgSend(self, "setRepresentedURL:", aFilePath);
}
});
instance_methods[42] = new objj_method(sel_registerName("representedFilename"), function(self, _cmd)
{ with(self)
{
    return _representedURL;
}
});
instance_methods[43] = new objj_method(sel_registerName("setRepresentedURL:"), function(self, _cmd, aURL)
{ with(self)
{
    _representedURL = aURL;
}
});
instance_methods[44] = new objj_method(sel_registerName("representedURL"), function(self, _cmd)
{ with(self)
{
    return _representedURL;
}
});
instance_methods[45] = new objj_method(sel_registerName("center"), function(self, _cmd)
{ with(self)
{
    var size = objj_msgSend(self, "frame").size,
        bridgeSize = objj_msgSend(_bridge, "contentBounds").size;

    objj_msgSend(self, "setFrameOrigin:", CGPointMake((bridgeSize.width-size.width)/2.0,(bridgeSize.height-size.height)/2.0));
}
});
instance_methods[46] = new objj_method(sel_registerName("sendEvent:"), function(self, _cmd, anEvent)
{ with(self)
{
    var type = objj_msgSend(anEvent, "type"),
        point = objj_msgSend(anEvent, "locationInWindow");

    switch (type)
    {
        case CPKeyUp: return objj_msgSend(objj_msgSend(self, "firstResponder"), "keyUp:", anEvent);
        case CPKeyDown: return objj_msgSend(objj_msgSend(self, "firstResponder"), "keyDown:", anEvent);

        case CPScrollWheel: return objj_msgSend(objj_msgSend(_themeFrame, "hitTest:", point), "scrollWheel:", anEvent);

        case CPLeftMouseUp: return objj_msgSend(_leftMouseDownView, "mouseUp:", anEvent);
        case CPLeftMouseDown: _leftMouseDownView = objj_msgSend(_themeFrame, "hitTest:", point);

                                    if (_leftMouseDownView != _firstResponder && objj_msgSend(_leftMouseDownView, "acceptsFirstResponder"))
                                        objj_msgSend(self, "makeFirstResponder:", _leftMouseDownView);

                                    var theWindow = objj_msgSend(anEvent, "window");

                                    if (objj_msgSend(theWindow, "isKeyWindow") || objj_msgSend(theWindow, "isKindOfClass:", objj_msgSend(CPPanel, "class")) && objj_msgSend(theWindow, "becomesKeyOnlyIfNeeded"))
                                        return objj_msgSend(_leftMouseDownView, "mouseDown:", anEvent);
                                    else
                                    {

                                        objj_msgSend(self, "makeKeyAndOrderFront:", self);

                                        if (objj_msgSend(_leftMouseDownView, "acceptsFirstMouse:", anEvent))
                                            return objj_msgSend(_leftMouseDownView, "mouseDown:", anEvent)
                                    }
                                    break;
        case CPLeftMouseDragged: return objj_msgSend(_leftMouseDownView, "mouseDragged:", anEvent);

        case CPRightMouseUp: return objj_msgSend(_rightMouseDownView, "mouseUp:", anEvent);
        case CPRightMouseDown: _rightMouseDownView = objj_msgSend(_themeFrame, "hitTest:", point);
                                    return objj_msgSend(_rightMouseDownView, "mouseDown:", anEvent);
        case CPRightMouseDragged: return objj_msgSend(_rightMouseDownView, "mouseDragged:", anEvent);

        case CPMouseMoved: var hitTestView = objj_msgSend(_themeFrame, "hitTest:", point);

                                    if (hitTestView != _mouseOverView)
                                    {
                                        if (_mouseOverView)
                                            objj_msgSend(_mouseOverView, "mouseExited:", objj_msgSend(CPEvent, "mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:", CPMouseExited, point, objj_msgSend(anEvent, "modifierFlags"), objj_msgSend(anEvent, "timestamp"), _windowNumber, nil, -1, 1, 0));

                                        if (hitTestView)
                                            objj_msgSend(_mouseOverView, "mouseEntered:", objj_msgSend(CPEvent, "mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:", CPMouseEntered, point, objj_msgSend(anEvent, "modifierFlags"), objj_msgSend(anEvent, "timestamp"), _windowNumber, nil, -1, 1, 0));

                                        _mouseOverView = hitTestView;
                                    }
    }
}
});
instance_methods[47] = new objj_method(sel_registerName("windowNumber"), function(self, _cmd)
{ with(self)
{
    return _windowNumber;
}
});
instance_methods[48] = new objj_method(sel_registerName("becomeKeyWindow"), function(self, _cmd)
{ with(self)
{
    if (_firstResponder != self && objj_msgSend(_firstResponder, "respondsToSelector:", sel_registerName("becomeKeyWindow")))
        objj_msgSend(_firstResponder, "becomeKeyWindow");
}
});
instance_methods[49] = new objj_method(sel_registerName("canBecomeKeyWindow"), function(self, _cmd)
{ with(self)
{
    return YES;
}
});
instance_methods[50] = new objj_method(sel_registerName("isKeyWindow"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(CPApp, "keyWindow") == self;
}
});
instance_methods[51] = new objj_method(sel_registerName("makeKeyAndOrderFront:"), function(self, _cmd, aSender)
{ with(self)
{
    objj_msgSend(self, "orderFront:", self);

    objj_msgSend(self, "makeKeyWindow");
    objj_msgSend(self, "makeMainWindow");
}
});
instance_methods[52] = new objj_method(sel_registerName("makeKeyWindow"), function(self, _cmd)
{ with(self)
{
    if (!objj_msgSend(self, "canBecomeKeyWindow"))
        return;

    objj_msgSend(CPApp._keyWindow, "resignKeyWindow");

    CPApp._keyWindow = self;

    objj_msgSend(self, "becomeKeyWindow");
}
});
instance_methods[53] = new objj_method(sel_registerName("resignKeyWindow"), function(self, _cmd)
{ with(self)
{
    if (_firstResponder != self && objj_msgSend(_firstResponder, "respondsToSelector:", sel_registerName("resignKeyWindow")))
        objj_msgSend(_firstResponder, "resignKeyWindow");

    if (objj_msgSend(_delegate, "respondsToSelector:", sel_registerName("windowDidResignKey:")))
        objj_msgSend(_delegate, "windowDidResignKey:", self);
}
});
instance_methods[54] = new objj_method(sel_registerName("dragImage:at:offset:event:pasteboard:source:slideBack:"), function(self, _cmd, anImage, imageLocation, mouseOffset, anEvent, aPasteboard, aSourceObject, slideBack)
{ with(self)
{
    objj_msgSend(objj_msgSend(CPCoreDragManager, "sharedCoreDragManager"), "dragImage:fromWindow:at:offset:event:pasteboard:source:slideBack:", anImage, self, objj_msgSend(self, "convertBaseToBridge:", imageLocation), mouseOffset, anEvent, aPasteboard, aSourceObject, slideBack);
}
});
instance_methods[55] = new objj_method(sel_registerName("dragView:at:offset:event:pasteboard:source:slideBack:"), function(self, _cmd, aView, imageLocation, mouseOffset, anEvent, aPasteboard, aSourceObject, slideBack)
{ with(self)
{
    objj_msgSend(objj_msgSend(CPCoreDragManager, "sharedCoreDragManager"), "dragView:fromWindow:at:offset:event:pasteboard:source:slideBack:", aView, self, objj_msgSend(self, "convertBaseToBridge:", imageLocation), mouseOffset, anEvent, aPasteboard, aSourceObject, slideBack);
}
});
instance_methods[56] = new objj_method(sel_registerName("setDocumentEdited:"), function(self, _cmd, isDocumentEdited)
{ with(self)
{
    if (_isDocumentEdited == isDocumentEdited)
        return;

    _isDocumentEdited = isDocumentEdited;

    objj_msgSend(_themeFrame, "windowDidChangeDocumentEdited");
}
});
instance_methods[57] = new objj_method(sel_registerName("isDocumentEdited"), function(self, _cmd)
{ with(self)
{
    return _isDocumentEdited;
}
});
instance_methods[58] = new objj_method(sel_registerName("setDocumentSaving:"), function(self, _cmd, isDocumentSaving)
{ with(self)
{
    if (_isDocumentSaving == isDocumentSaving)
        return;

    _isDocumentSaving = isDocumentSaving;

    objj_msgSend(_themeFrame, "windowDidChangeDocumentSaving");
}
});
instance_methods[59] = new objj_method(sel_registerName("isDocumentSaving"), function(self, _cmd)
{ with(self)
{
    return _isDocumentSaving;
}
});
instance_methods[60] = new objj_method(sel_registerName("performClose:"), function(self, _cmd, aSender)
{ with(self)
{
    if (objj_msgSend(_delegate, "respondsToSelector:", sel_registerName("windowShouldClose:")) && !objj_msgSend(_delegate, "windowShouldClose:", self) ||
        objj_msgSend(self, "respondsToSelector:", sel_registerName("windowShouldClose:")) && !objj_msgSend(self, "windowShouldClose:", self))
        return;

    objj_msgSend(self, "close");
}
});
instance_methods[61] = new objj_method(sel_registerName("close"), function(self, _cmd)
{ with(self)
{
   objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:", CPWindowWillCloseNotification, self);

   objj_msgSend(self, "orderOut:", nil);
}
});
instance_methods[62] = new objj_method(sel_registerName("isMainWindow"), function(self, _cmd)
{ with(self)
{
    return objj_msgSend(CPApp, "mainWindow") == self;
}
});
instance_methods[63] = new objj_method(sel_registerName("canBecomeMainWindow"), function(self, _cmd)
{ with(self)
{

    if (objj_msgSend(self, "isVisible"))
        return YES;

    return NO;
}
});
instance_methods[64] = new objj_method(sel_registerName("makeMainWindow"), function(self, _cmd)
{ with(self)
{
    if (!objj_msgSend(self, "canBecomeMainWindow"))
        return;

    objj_msgSend(CPApp._mainWindow, "resignMainWindow");

    CPApp._mainWindow = self;

    objj_msgSend(self, "becomeMainWindow");
}
});
instance_methods[65] = new objj_method(sel_registerName("becomeMainWindow"), function(self, _cmd)
{ with(self)
{
    objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:", CPWindowDidBecomeMainNotification, self);
}
});
instance_methods[66] = new objj_method(sel_registerName("resignMainWindow"), function(self, _cmd)
{ with(self)
{
    objj_msgSend(objj_msgSend(CPNotificationCenter, "defaultCenter"), "postNotificationName:object:", CPWindowDidResignMainNotification, self);
}
});
instance_methods[67] = new objj_method(sel_registerName("toolbar"), function(self, _cmd)
{ with(self)
{
    return _toolbar;
}
});
instance_methods[68] = new objj_method(sel_registerName("setToolbar:"), function(self, _cmd, aToolbar)
{ with(self)
{
    if (_toolbar == aToolbar)
        return;


    if (_toolbar)
    {
        objj_msgSend(self, "_setToolbarVisible:", NO);

        _toolbar._window = nil;
        _toolbarView = nil;
    }

    if (_toolbar = aToolbar)
    {

        _toolbar = aToolbar;
        _toolbar._window = self;

        if (objj_msgSend(_toolbar, "isVisible"))
            objj_msgSend(self, "_setToolbarVisible:", YES);

        objj_msgSend(_toolbar, "_reloadToolbarItems");
    }
}
});
instance_methods[69] = new objj_method(sel_registerName("_setToolbarVisible:"), function(self, _cmd, aFlag)
{ with(self)
{
    if (aFlag)
    {
        if (!_toolbarView)
            _toolbarView = objj_msgSend(_toolbar, "_toolbarView");

        objj_msgSend(_toolbarView, "setFrame:", CGRectMake(0.0,29.0,CGRectGetWidth(objj_msgSend(_themeFrame, "bounds")),CGRectGetHeight(objj_msgSend(_toolbarView, "frame"))));
        objj_msgSend(_themeFrame, "addSubview:", _toolbarView);
    }
    else
        objj_msgSend(_toolbarView, "removeFromSuperview");

    objj_msgSend(_contentView, "setFrame:", objj_msgSend(self, "contentRectForFrameRect:", objj_msgSend(_themeFrame, "bounds")));
}
});
instance_methods[70] = new objj_method(sel_registerName("_setAttachedSheetFrameOrigin"), function(self, _cmd)
{ with(self)
{

    var contentRect = objj_msgSend(objj_msgSend(self, "contentView"), "frame"),
        sheetFrame = CGRectMakeCopy(objj_msgSend(_attachedSheet, "frame"));

   sheetFrame.origin.y = CGRectGetMinY(_frame) + CGRectGetMinY(contentRect);
   sheetFrame.origin.x = CGRectGetMinX(_frame) + FLOOR((CGRectGetWidth(_frame) - CGRectGetWidth(sheetFrame)) / 2.0);

   objj_msgSend(_attachedSheet, "setFrameOrigin:", sheetFrame.origin);
}
});
instance_methods[71] = new objj_method(sel_registerName("_animateAttachedSheet"), function(self, _cmd)
{ with(self)
{}
});
instance_methods[72] = new objj_method(sel_registerName("_attachSheet:modalDelegate:didEndSelector:contextInfo:"), function(self, _cmd, aSheet, aModalDelegate, aDidEndSelector, aContextInfo)
{ with(self)
{
    _attachedSheet = aSheet;
    aSheet._isSheet = YES;
    objj_msgSend(self, "_setAttachedSheetFrameOrigin");
    objj_msgSend(_bridge, "order:window:relativeTo:", CPWindowAbove, aSheet, self);
}
});
instance_methods[73] = new objj_method(sel_registerName("attachedSheet"), function(self, _cmd)
{ with(self)
{
    return _attachedSheet;
}
});
instance_methods[74] = new objj_method(sel_registerName("isSheet"), function(self, _cmd)
{ with(self)
{
    return _isSheet;
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}
{
var the_class = objj_getClass("CPWindow")
if(!the_class) objj_exception_throw(new objj_exception(OBJJClassNotFoundException, "*** Could not find definition for class \"CPWindow\""));
var meta_class = _class_getMeta(the_class);var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("setBridge:"), function(self, _cmd, aBridge)
{ with(self)
{
    if (_bridge == aBridge)
        return;
    if (_bridge)
    {
        objj_msgSend(self, "orderOut:", self);
    }
    _bridge = aBridge;
    if (_styleMask & CPBorderlessBridgeWindowMask)
        objj_msgSend(self, "setFrame:", objj_msgSend(aBridge, "contentBounds"));
}
});
instance_methods[1] = new objj_method(sel_registerName("resizeWithOldBridgeSize:"), function(self, _cmd, aSize)
{ with(self)
{
    if (_styleMask & CPBorderlessBridgeWindowMask)
        return objj_msgSend(self, "setFrame:", objj_msgSend(_bridge, "contentBounds"));
    if (_autoresizingMask == CPWindowNotSizable)
        return;
    var frame = objj_msgSend(_bridge, "contentBounds"),
        newFrame = CGRectMakeCopy(_frame),
        dX = (CGRectGetWidth(frame) - aSize.width) /
            (((_autoresizingMask & CPWindowMinXMargin) ? 1 : 0) + (_autoresizingMask & CPWindowWidthSizable ? 1 : 0) + (_autoresizingMask & CPWindowMaxXMargin ? 1 : 0)),
        dY = (CGRectGetHeight(frame) - aSize.height) /
            ((_autoresizingMask & CPWindowMinYMargin ? 1 : 0) + (_autoresizingMask & CPWindowHeightSizable ? 1 : 0) + (_autoresizingMask & CPWindowMaxYMargin ? 1 : 0));
    if (_autoresizingMask & CPWindowMinXMargin)
        newFrame.origin.x += dX;
    if (_autoresizingMask & CPWindowWidthSizable)
        newFrame.size.width += dX;
    if (_autoresizingMask & CPWindowMinYMargin)
        newFrame.origin.y += dY;
    if (_autoresizingMask & CPWindowHeightSizable)
        newFrame.size.height += dY;
    objj_msgSend(self, "setFrame:", newFrame);
}
});
instance_methods[2] = new objj_method(sel_registerName("setAutoresizingMask:"), function(self, _cmd, anAutoresizingMask)
{ with(self)
{
    _autoresizingMask = anAutoresizingMask;
}
});
instance_methods[3] = new objj_method(sel_registerName("autoresizingMask"), function(self, _cmd)
{ with(self)
{
    return _autoresizingMask;
}
});
instance_methods[4] = new objj_method(sel_registerName("convertBaseToBridge:"), function(self, _cmd, aPoint)
{ with(self)
{
    var origin = objj_msgSend(self, "frame").origin;
    return CGPointMake(aPoint.x + origin.x, aPoint.y + origin.y);
}
});
instance_methods[5] = new objj_method(sel_registerName("convertBridgeToBase:"), function(self, _cmd, aPoint)
{ with(self)
{
    var origin = objj_msgSend(self, "frame").origin;
    return CGPointMake(aPoint.x - origin.x, aPoint.y - origin.y);
}
});
instance_methods[6] = new objj_method(sel_registerName("undoManager"), function(self, _cmd)
{ with(self)
{
    if (_delegateRespondsToWindowWillReturnUndoManagerSelector)
        return objj_msgSend(_delegate, "windowWillReturnUndoManager:", self);
    if (!_undoManager)
        _undoManager = objj_msgSend(objj_msgSend(CPUndoManager, "alloc"), "init");
    return _undoManager;
}
});
instance_methods[7] = new objj_method(sel_registerName("undo:"), function(self, _cmd, aSender)
{ with(self)
{
    objj_msgSend(objj_msgSend(self, "undoManager"), "undo");
}
});
instance_methods[8] = new objj_method(sel_registerName("redo:"), function(self, _cmd, aSender)
{ with(self)
{
    objj_msgSend(objj_msgSend(self, "undoManager"), "redo");
}
});
class_addMethods(the_class, instance_methods);
}
var interpolate = function(fromValue, toValue, progress)
{
    return fromValue + (toValue - fromValue) * progress;
}
{var the_class = objj_allocateClassPair(CPAnimation, "_CPWindowFrameAnimation"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_window"), new objj_ivar("_startFrame"), new objj_ivar("_targetFrame"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithWindow:targetFrame:"), function(self, _cmd, aWindow, aTargetFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPAnimation") }, "initWithDuration:animationCurve:", 0.2, CPAnimationLinear);
    if (self)
    {
        _window = aWindow;
        _targetFrame = CGRectMakeCopy(aTargetFrame);
        _startFrame = CGRectMakeCopy(objj_msgSend(_window, "frame"));
    }
    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("startAnimation"), function(self, _cmd)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPAnimation") }, "startAnimation");
    _window._isAnimating = YES;
}
});
instance_methods[2] = new objj_method(sel_registerName("setCurrentProgress:"), function(self, _cmd, aProgress)
{ with(self)
{
    objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPAnimation") }, "setCurrentProgress:", aProgress);
    var value = objj_msgSend(self, "currentValue");
    if (value == 1.0)
        _window._isAnimating = NO;
    objj_msgSend(_window, "setFrameOrigin:", CGPointMake(interpolate(CGRectGetMinX(_startFrame),CGRectGetMinX(_targetFrame),value),interpolate(CGRectGetMinY(_startFrame),CGRectGetMinY(_targetFrame),value)));
    objj_msgSend(_window, "setFrameSize:", CGSizeMake(interpolate(CGRectGetWidth(_startFrame),CGRectGetWidth(_targetFrame),value),interpolate(CGRectGetHeight(_startFrame),CGRectGetHeight(_targetFrame),value)));
}
});
class_addMethods(the_class, instance_methods);
}

p;20;CPWindowController.jI;21;Foundation/CPObject.jI;21;Foundation/CPString.ji;13;CPResponder.ji;10;CPWindow.ji;12;CPDocument.jc;6150;


{var the_class = objj_allocateClassPair(CPResponder, "CPWindowController"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_owner"), new objj_ivar("_window"), new objj_ivar("_document"), new objj_ivar("_windowCibName"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithWindow:"), function(self, _cmd, aWindow)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPResponder") }, "init");

    if (self)
    {
        objj_msgSend(self, "setWindow:", aWindow);

        objj_msgSend(self, "setNextResponder:", CPApp);
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("initWithWindowCibName:"), function(self, _cmd, aWindowCibName)
{ with(self)
{
    return objj_msgSend(self, "initWithWindowCibName:owner:", aWindowCibName, self);
}
});
instance_methods[2] = new objj_method(sel_registerName("initWithWindowCibName:owner:"), function(self, _cmd, aWindowCibName, anOwner)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPResponder") }, "init");

    if (self)
    {
        _owner = anOwner;
        _windowCibName = aWindowCibName;

        objj_msgSend(self, "setNextResponder:", CPApp);
    }

    return self;
}
});
instance_methods[3] = new objj_method(sel_registerName("loadWindow"), function(self, _cmd)
{ with(self)
{
    objj_msgSend(self, "windowWillLoad");

    objj_msgSend(self, "setWindow:", CPApp._keyWindow=objj_msgSend(objj_msgSend(CPWindow, "alloc"), "initWithContentRect:styleMask:", CPRectMakeZero(), CPBorderlessBridgeWindowMask|CPTitledWindowMask|CPClosableWindowMask|CPResizableWindowMask));

    objj_msgSend(self, "windowDidLoad");
}
});
instance_methods[4] = new objj_method(sel_registerName("showWindow:"), function(self, _cmd, aSender)
{ with(self)
{
    var theWindow = objj_msgSend(self, "window");

 if (objj_msgSend(theWindow, "isKindOfClass:", objj_msgSend(CPPanel, "class")) && objj_msgSend(theWindow, "becomesKeyOnlyIfNeeded"))
        objj_msgSend(theWindow, "orderFront:", aSender);
    else
        objj_msgSend(theWindow, "makeKeyAndOrderFront:", aSender);
}
});
instance_methods[5] = new objj_method(sel_registerName("isWindowLoaded"), function(self, _cmd)
{ with(self)
{
    return _window;
}
});
instance_methods[6] = new objj_method(sel_registerName("window"), function(self, _cmd)
{ with(self)
{
    if (!_window)
         objj_msgSend(self, "loadWindow");

    return _window;
}
});
instance_methods[7] = new objj_method(sel_registerName("setWindow:"), function(self, _cmd, aWindow)
{ with(self)
{
    _window = aWindow;

    objj_msgSend(_window, "setWindowController:", self);
    objj_msgSend(_window, "setNextResponder:", self);
}
});
instance_methods[8] = new objj_method(sel_registerName("windowDidLoad"), function(self, _cmd)
{ with(self)
{
    objj_msgSend(_document, "windowControllerDidLoadNib:", self);

    objj_msgSend(self, "synchronizeWindowTitleWithDocumentName");
}
});
instance_methods[9] = new objj_method(sel_registerName("windowWillLoad"), function(self, _cmd)
{ with(self)
{
    objj_msgSend(_document, "windowControllerWillLoadNib:", self);
}
});
instance_methods[10] = new objj_method(sel_registerName("setDocument:"), function(self, _cmd, aDocument)
{ with(self)
{
    if (_document == aDocument)
        return;

    var defaultCenter = objj_msgSend(CPNotificationCenter, "defaultCenter");

    if (_document)
    {
        objj_msgSend(defaultCenter, "removeObserver:name:object:", self, CPDocumentWillSaveNotification, _document);

        objj_msgSend(defaultCenter, "removeObserver:name:object:", self, CPDocumentDidSaveNotification, _document);

        objj_msgSend(defaultCenter, "removeObserver:name:object:", self, CPDocumentDidFailToSaveNotification, _document);
    }

    _document = aDocument;

    if (_document)
    {
        objj_msgSend(defaultCenter, "addObserver:selector:name:object:", self, sel_registerName("_documentWillSave:"), CPDocumentWillSaveNotification, _document);

        objj_msgSend(defaultCenter, "addObserver:selector:name:object:", self, sel_registerName("_documentDidSave:"), CPDocumentDidSaveNotification, _document);

        objj_msgSend(defaultCenter, "addObserver:selector:name:object:", self, sel_registerName("_documentDidFailToSave:"), CPDocumentDidFailToSaveNotification, _document);
    }

    objj_msgSend(self, "synchronizeWindowTitleWithDocumentName");
}
});
instance_methods[11] = new objj_method(sel_registerName("_documentWillSave:"), function(self, _cmd, aNotification)
{ with(self)
{
    objj_msgSend(objj_msgSend(self, "window"), "setDocumentSaving:", YES);
}
});
instance_methods[12] = new objj_method(sel_registerName("_documentDidSave:"), function(self, _cmd, aNotification)
{ with(self)
{
    objj_msgSend(objj_msgSend(self, "window"), "setDocumentSaving:", NO);
}
});
instance_methods[13] = new objj_method(sel_registerName("_documentDidFailToSave:"), function(self, _cmd, aNotification)
{ with(self)
{
    objj_msgSend(objj_msgSend(self, "window"), "setDocumentSaving:", NO);
}
});
instance_methods[14] = new objj_method(sel_registerName("document"), function(self, _cmd)
{ with(self)
{
    return _document;
}
});
instance_methods[15] = new objj_method(sel_registerName("setDocumentEdited:"), function(self, _cmd, isEdited)
{ with(self)
{
    objj_msgSend(objj_msgSend(self, "window"), "setDocumentEdited:", isEdited);
}
});
instance_methods[16] = new objj_method(sel_registerName("synchronizeWindowTitleWithDocumentName"), function(self, _cmd)
{ with(self)
{
    if (!_document || !_window)
        return;


    objj_msgSend(_window, "setTitle:", objj_msgSend(self, "windowTitleForDocumentDisplayName:", objj_msgSend(_document, "displayName")));
}
});
instance_methods[17] = new objj_method(sel_registerName("windowTitleForDocumentDisplayName:"), function(self, _cmd, aDisplayName)
{ with(self)
{
    return aDisplayName;
}
});
class_addMethods(the_class, instance_methods);
}

p;26;_CPBorderlessBridgeFrame.jI;33;Foundation/CPUserSessionManager.jI;21;AppKit/CPThemeFrame.jc;14418;


var _CPBorderlessBridgeFrameTitleBarColor = nil,

    _CPBorderlessBridgeFrameNewImage = nil,
    _CPBorderlessBridgeFrameNewHighlightedImage = nil,

    _CPBorderlessBridgeFrameOpenImage = nil,
    _CPBorderlessBridgeFrameOpenHighlightedImage = nil,

    _CPBorderlessBridgeFrameSaveImage = nil,
    _CPBorderlessBridgeFrameSaveHighlightedImage = nil,

    _CPBorderlessBridgeFrameSavingImage = nil,

 _CPBorderlessBridgeFrameSessionImage = nil,
 _CPBorderlessBridgeFrameSessionHighlightedImage = nil,

    _CPBorderlessBridgeFrameIcon = nil;

var TITLEBAR_HEIGHT = 29.0,
    TITLEBAR_BUTTON_MARGIN = 8.0,
    TITLEBAR_HORIZONTAL_EDGE_MARGIN = 10.0;

{var the_class = objj_allocateClassPair(CPView, "_CPBorderlessBridgeFrame"),
meta_class = _class_getMeta(the_class);the_class.ivars.splice(the_class.ivars.length, 0, new objj_ivar("_title"), new objj_ivar("_titlebar"), new objj_ivar("_iconView"), new objj_ivar("_titleField"), new objj_ivar("_newButton"), new objj_ivar("_openButton"), new objj_ivar("_saveButton"), new objj_ivar("_feedbackButton"), new objj_ivar("_sessionButton"));
objj_registerClassPair(the_class);
objj_addClassForBundle(the_class, objj_getBundleWithPath(OBJJ_CURRENT_BUNDLE.path));
var class_methods = [];
class_methods[0] = new objj_method(sel_registerName("initialize"), function(self, _cmd)
{ with(self)
{
    if (self != objj_msgSend(_CPBorderlessBridgeFrame, "class"))
        return;

    var bundle = objj_msgSend(CPBundle, "bundleForClass:", self);

    _CPBorderlessBridgeFrameTitleBarColor = objj_msgSend(CPColor, "colorWithPatternImage:", objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "_CPBorderlessBridgeFrame/TitlebarBackground.png"), CGSizeMake(1.0,18.0)));

    _CPBorderlessBridgeFrameNewImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "_CPBorderlessBridgeFrame/New.png"), CGSizeMake(16.0,16.0));
    _CPBorderlessBridgeFrameNewHighlightedImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "_CPBorderlessBridgeFrame/NewHighlighted.png"), CGSizeMake(16.0,16.0));

    _CPBorderlessBridgeFrameOpenImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "_CPBorderlessBridgeFrame/Open.png"), CGSizeMake(16.0,16.0));
    _CPBorderlessBridgeFrameOpenHighlightedImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "_CPBorderlessBridgeFrame/OpenHighlighted.png"), CGSizeMake(16.0,16.0));

    _CPBorderlessBridgeFrameSaveImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "_CPBorderlessBridgeFrame/Save.png"), CGSizeMake(16.0,16.0));
    _CPBorderlessBridgeFrameSaveHighlightedImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "_CPBorderlessBridgeFrame/SaveHighlighted.png"), CGSizeMake(16.0,16.0));


    _CPBorderlessBridgeFrameSavingImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "CPProgressIndicator/CPProgressIndicatorSpinningStyleRegular.gif"), CGSizeMake(16.0,16.0));


    _CPBorderlessBridgeFrameFeedbackImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "_CPBorderlessBridgeFrame/FIXME_Feedback.png"), CGSizeMake(16.0,16.0));
    _CPBorderlessBridgeFrameFeedbackHighlightedImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "_CPBorderlessBridgeFrame/FIXME_FeedbackHighlighted.png"), CGSizeMake(16.0,16.0));


    _CPBorderlessBridgeFrameSessionImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "_CPBorderlessBridgeFrame/FIXME_Session.png"), CGSizeMake(16.0,16.0));
    _CPBorderlessBridgeFrameSessionHighlightedImage = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "_CPBorderlessBridgeFrame/FIXME_SessionHighlighted.png"), CGSizeMake(16.0,16.0));

    _CPBorderlessBridgeFrameIcon = objj_msgSend(objj_msgSend(CPImage, "alloc"), "initWithContentsOfFile:size:", objj_msgSend(bundle, "pathForResource:", "_CPBorderlessBridgeFrame/Icon.png"), CGSizeMake(16.0,16.0));
}
});
var instance_methods = [];
instance_methods[0] = new objj_method(sel_registerName("initWithFrame:"), function(self, _cmd, aFrame)
{ with(self)
{
    self = objj_msgSendSuper({ receiver:self, super_class:objj_getClass("CPView") }, "initWithFrame:", aFrame);

    if (self)
    {
        var bounds = objj_msgSend(self, "bounds");

        _titlebar = objj_msgSend(objj_msgSend(CPView, "alloc"), "initWithFrame:", CGRectMake(0.0,0.0,CGRectGetWidth(bounds),TITLEBAR_HEIGHT));

        objj_msgSend(_titlebar, "setAutoresizingMask:", CPViewWidthSizable|CPViewMaxYMargin);
        objj_msgSend(_titlebar, "setBackgroundColor:", _CPBorderlessBridgeFrameTitleBarColor);

        objj_msgSend(self, "addSubview:", _titlebar);

        _iconView = objj_msgSend(objj_msgSend(CPImageView, "alloc"), "initWithFrame:", CGRectMake(0.0,0.0,16.0,16.0));

        objj_msgSend(_iconView, "setImage:", _CPBorderlessBridgeFrameIcon);
        objj_msgSend(_iconView, "setAutoresizingMask:", CPViewMinXMargin|CPViewMaxXMargin);

        objj_msgSend(self, "addSubview:", _iconView);

        _titleField = objj_msgSend(objj_msgSend(CPTextField, "alloc"), "initWithFrame:", CGRectMakeZero());

        objj_msgSend(_titleField, "setStringValue:", "jars");
        objj_msgSend(_titleField, "setFont:", objj_msgSend(CPFont, "boldSystemFontOfSize:", 12.0));
        objj_msgSend(_titleField, "setAlignment:", CPCenterTextAlignment);
        objj_msgSend(_titleField, "setAutoresizingMask:", CPViewMinXMargin|CPViewMaxXMargin);

        objj_msgSend(_titleField, "sizeToFit");

        objj_msgSend(self, "addSubview:", _titleField);

        var iconViewFrame = objj_msgSend(_iconView, "frame"),
            titleFieldFrame = objj_msgSend(_titleField, "frame"),
            x = (CGRectGetWidth(bounds) - CGRectGetWidth(iconViewFrame) - CGRectGetWidth(titleFieldFrame)) / 2.0,
            y = (TITLEBAR_HEIGHT - CGRectGetHeight(iconViewFrame)) / 2.0;

        objj_msgSend(_iconView, "setFrameOrigin:", CGPointMake(x,y));
        objj_msgSend(_titleField, "setFrameOrigin:", CGPointMake(x+CGRectGetWidth(iconViewFrame),(TITLEBAR_HEIGHT-CGRectGetHeight(titleFieldFrame))/2.0));


        _newButton = objj_msgSend(self, "buttonWithTitle:action:image:alternateImage:", "New", sel_registerName("newDocument:"), _CPBorderlessBridgeFrameNewImage, _CPBorderlessBridgeFrameNewHighlightedImage);

        objj_msgSend(_newButton, "setFrameOrigin:", CGPointMake(TITLEBAR_HORIZONTAL_EDGE_MARGIN,y));
        objj_msgSend(_newButton, "setAutoresizingMask:", CPViewMaxXMargin);

        objj_msgSend(self, "addSubview:", _newButton);

        _openButton = objj_msgSend(self, "buttonWithTitle:action:image:alternateImage:", "Open", sel_registerName("openDocument:"), _CPBorderlessBridgeFrameOpenImage, _CPBorderlessBridgeFrameOpenHighlightedImage);

        objj_msgSend(_openButton, "setFrameOrigin:", CGPointMake(CGRectGetMaxX(objj_msgSend(_newButton, "frame"))+TITLEBAR_BUTTON_MARGIN,y));
        objj_msgSend(_openButton, "setAutoresizingMask:", CPViewMaxXMargin);

        objj_msgSend(self, "addSubview:", _openButton);

        _saveButton = objj_msgSend(self, "buttonWithTitle:action:image:alternateImage:", "Save", sel_registerName("saveDocument:"), _CPBorderlessBridgeFrameSaveImage, _CPBorderlessBridgeFrameSaveHighlightedImage);

        objj_msgSend(_saveButton, "setFrameOrigin:", CGPointMake(CGRectGetMaxX(objj_msgSend(_openButton, "frame"))+TITLEBAR_BUTTON_MARGIN,y));
        objj_msgSend(_saveButton, "setAutoresizingMask:", CPViewMaxXMargin);

        objj_msgSend(self, "addSubview:", _saveButton);

        _feedbackButton = objj_msgSend(self, "buttonWithTitle:action:image:alternateImage:", "Feedback", sel_registerName("feedback:"), _CPBorderlessBridgeFrameFeedbackImage, _CPBorderlessBridgeFrameFeedbackHighlightedImage);

        objj_msgSend(_feedbackButton, "setFrameOrigin:", CGPointMake(0.0,y));
        objj_msgSend(_feedbackButton, "setAutoresizingMask:", CPViewMinXMargin);

        objj_msgSend(self, "addSubview:", _feedbackButton);

        _sessionButton = objj_msgSend(self, "buttonWithTitle:action:image:alternateImage:", "Login", sel_registerName("feedback:"), _CPBorderlessBridgeFrameSessionImage, _CPBorderlessBridgeFrameSessionHighlightedImage);

        objj_msgSend(_sessionButton, "setFrameOrigin:", CGPointMake(0.0,y));
        objj_msgSend(_sessionButton, "setAutoresizingMask:", CPViewMinXMargin);

        objj_msgSend(self, "addSubview:", _sessionButton);

        objj_msgSend(self, "tileButtons");

        var defaultCenter = objj_msgSend(CPNotificationCenter, "defaultCenter");

        objj_msgSend(defaultCenter, "addObserver:selector:name:object:", self, sel_registerName("updateSessionButton"), CPUserSessionManagerStatusDidChangeNotification, objj_msgSend(CPUserSessionManager, "defaultManager"));

        objj_msgSend(defaultCenter, "addObserver:selector:name:object:", self, sel_registerName("updateSessionButton"), CPUserSessionManagerUserIdentifierDidChangeNotification, objj_msgSend(CPUserSessionManager, "defaultManager"));

        objj_msgSend(self, "updateSessionButton");
    }

    return self;
}
});
instance_methods[1] = new objj_method(sel_registerName("buttonWithTitle:action:image:alternateImage:"), function(self, _cmd, aTitle, anAction, anImage, anAlternateImage)
{ with(self)
{
    var button = objj_msgSend(objj_msgSend(CPButton, "alloc"), "initWithFrame:", CGRectMakeZero());

    objj_msgSend(button, "setAlignment:", CPLeftTextAlignment);
    objj_msgSend(button, "setImagePosition:", CPImageLeft);
    objj_msgSend(button, "setFont:", objj_msgSend(CPFont, "systemFontOfSize:", 11.0));

    objj_msgSend(button, "setAction:", anAction);
    objj_msgSend(button, "setTitle:", aTitle);

    objj_msgSend(button, "setImage:", anImage);
    objj_msgSend(button, "setAlternateImage:", anAlternateImage);

    objj_msgSend(button, "sizeToFit");

    return button;
}
});
instance_methods[2] = new objj_method(sel_registerName("setTitle:"), function(self, _cmd, aTitle)
{ with(self)
{
    var bundleName = objj_msgSend(objj_msgSend(CPBundle, "mainBundle"), "objectForInfoDictionaryKey:", "CPBundleName");

    if (objj_msgSend(bundleName, "length"))
        document.title = aTitle + " - " + bundleName;
    else
        document.title = aTitle;

    objj_msgSend(_titleField, "setStringValue:", aTitle);
    objj_msgSend(_titleField, "sizeToFit");

    var bounds = objj_msgSend(self, "bounds"),
        iconViewFrame = objj_msgSend(_iconView, "frame"),
        titleFieldFrame = objj_msgSend(_titleField, "frame"),
        x = (CGRectGetWidth(bounds) - CGRectGetWidth(iconViewFrame) - CGRectGetWidth(titleFieldFrame)) / 2.0,
        y = (TITLEBAR_HEIGHT - CGRectGetHeight(iconViewFrame)) / 2.0;

    objj_msgSend(_iconView, "setFrameOrigin:", CGPointMake(x,y));
    objj_msgSend(_titleField, "setFrameOrigin:", CGPointMake(x+CGRectGetWidth(iconViewFrame),(TITLEBAR_HEIGHT-CGRectGetHeight(titleFieldFrame))/2.0));
}
});
instance_methods[3] = new objj_method(sel_registerName("updateSessionButton"), function(self, _cmd)
{ with(self)
{
    var manager = objj_msgSend(CPUserSessionManager, "defaultManager"),
        status = objj_msgSend(manager, "status");

    if (status == CPUserSessionLoggedInStatus)
    {
        var userIdentifier = objj_msgSend(manager, "userIdentifier");

        objj_msgSend(_sessionButton, "setAction:", sel_registerName("logout:"));

        if (objj_msgSend(userIdentifier, "length"))
            objj_msgSend(_sessionButton, "setTitle:", "Logout ("+userIdentifier+")");
        else
            objj_msgSend(_sessionButton, "setTitle:", "Logout");
    }
    else
    {
        objj_msgSend(_sessionButton, "setAction:", sel_registerName("login:"));
        objj_msgSend(_sessionButton, "setTitle:", "Login");
    }

    objj_msgSend(_sessionButton, "sizeToFit");

    objj_msgSend(self, "tileButtons");
}
});
instance_methods[4] = new objj_method(sel_registerName("tileButtons"), function(self, _cmd)
{ with(self)
{
    var sessionButtonFrame = objj_msgSend(_sessionButton, "frame"),
        x = CGRectGetMaxX(objj_msgSend(self, "bounds")) - CGRectGetWidth(sessionButtonFrame) - TITLEBAR_HORIZONTAL_EDGE_MARGIN,
        y = CGRectGetMinY(sessionButtonFrame);

    objj_msgSend(_sessionButton, "setFrameOrigin:", CGPointMake(x,y));

    var feedbackButtonFrame = objj_msgSend(_feedbackButton, "frame");

    objj_msgSend(_feedbackButton, "setFrameOrigin:", CGPointMake(x-CGRectGetWidth(feedbackButtonFrame)-TITLEBAR_BUTTON_MARGIN,y));
}
});
instance_methods[5] = new objj_method(sel_registerName("windowDidChangeDocumentEdited"), function(self, _cmd)
{ with(self)
{
    objj_msgSend(_iconView, "setAlphaValue:", objj_msgSend(objj_msgSend(self, "window"), "isDocumentEdited")?0.5:1.0);
}
});
instance_methods[6] = new objj_method(sel_registerName("windowDidChangeDocumentSaving"), function(self, _cmd)
{ with(self)
{
    var isDocumentSaving = objj_msgSend(objj_msgSend(self, "window"), "isDocumentSaving");

    if (isDocumentSaving)
    {
        objj_msgSend(_saveButton, "setImage:", _CPBorderlessBridgeFrameSavingImage);
        objj_msgSend(_saveButton, "setAlternateImage:", _CPBorderlessBridgeFrameSavingImage);

        objj_msgSend(_saveButton, "setTitle:", "Saving...");
        objj_msgSend(_saveButton, "setAction:", nil);
    }
    else
    {
        objj_msgSend(_saveButton, "setImage:", _CPBorderlessBridgeFrameSaveImage);
        objj_msgSend(_saveButton, "setAlternateImage:", _CPBorderlessBridgeFrameSaveHighlightedImage);

        objj_msgSend(_saveButton, "setTitle:", "Save");
        objj_msgSend(_saveButton, "setAction:", sel_registerName("saveDocument:"));
    }

    objj_msgSend(_saveButton, "sizeToFit");
}
});
class_addMethods(the_class, instance_methods);
class_addMethods(meta_class, class_methods);
}

