Skip to content

Instantly share code, notes, and snippets.

@import <AppKit/CPView.j>
@import <AppKit/CPAnimation.j>
CPViewAnimationStartFrameKey = "CPViewAnimationStartFrameKey";
CPViewAnimationEndFrameKey = "CPViewAnimationEndFrameKey";
CPViewAnimationTargetKey = "CPViewAnimationTargetKey";
CPViewAnimationEffectKey = "CPViewAnimationEffectKey";
CPViewAnimationFadeInEffect = "CPViewAnimationFadeInEffect";
CPViewAnimationFadeOutEffect = "CPViewAnimationFadeOutEffect";
/*
* CPUserDefaults.j
* AppKit
*
* Created by Nicholas Small.
* Copyright 2009, 280 North, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@cacaodev
cacaodev / Variable row height
Created December 1, 2010 22:03
Test live variable row height in CPtableView
/*
* AppController.j
* TestTemplate
*
* Created by You on August 10, 2010.
* Copyright 2010, Your Company All rights reserved.
*/
@import <Foundation/CPObject.j>
@cacaodev
cacaodev / -valueForKey:
Created December 19, 2010 20:29
Return a KVC proxy if the receiver implements -countOfKey AND objectInKeyAtIndex:
- (id)valueForKey:(CPString)aKey
{
var capitalizedKey = aKey.charAt(0).toUpperCase() + aKey.substring(1),
objectAtIndexSEL = sel_getName(@"objectIn" + capitalizedKey + "AtIndex:"),
objectsAtIndexesSEL = sel_getName(aKey + "AtIndexes:"),
countSEL = sel_getName(@"countOf" + capitalizedKey);
if ([destination respondsToSelector:countSEL] && ([destination respondsToSelector:objectAtIndexSEL] || [destination respondsToSelector:objectsAtIndexesSEL]))
return [destination mutableArrayValueForKey:aKey];
@cacaodev
cacaodev / cocoa_binders
Created July 3, 2012 13:47
cocoa binders & bindings
NSColorPanelColorWell
NSDisplayFontBinder:NSBinder: font,fontSize,fontName,fontFamilyName,fontItalic,fontBold
NSEditableBinder:NSBinder: enabled,hidden
NSObjectParameterBinder:NSBinder: toolTip
NSValueBinder:NSEditorBinder:NSBinder: value
NSStepper
@cacaodev
cacaodev / CPCollectionView -setItemPrototype:
Last active December 14, 2015 16:29
CPCollectionView -setItemPrototype: documentation
Sets the item prototype to \c anItem.
If the item prototype view is located in an external cib file, then the representedObject, outlets and bindings will be automatically restored when an item is created.
If the prototype item view belong to the same cib as the collection view, then the item prototype should implement the CPCoding protocol
because the item is copied by archiving and unarchiving the
prototypal view.
Bindings won't be restored throught archiving, instead you need to subclass the -representedObject: method and update the view there.
@cacaodev
cacaodev / CPAutosizeTest
Created April 12, 2014 06:27
Cappuccino: autosize perf / autoresizeMask
@import <AppKit/AppKit.j>
@import <Foundation/Foundation.j>
[CPApplication sharedApplication];
@implementation CPAutosizeTest : OJTestCase
{
CPInteger NUMBER_OF_VIEWS;
CPInteger RESIZES_COUNT;
var CSSStringFromCGAffineTransform = function(anAffineTransform)
{
// Firefox : add px to the translate values.
return "matrix(" + anAffineTransform.a + ", " + anAffineTransform.b + ", " + anAffineTransform.c + ", " + anAffineTransform.d + ", " + anAffineTransform.tx + ", " + anAffineTransform.ty + ")";
};
var frameOriginToCSSTransformMatrix = function(start, current)
{
var affine = CGAffineTransformMakeTranslation(current.x - start.x, current.y - start.y);
@cacaodev
cacaodev / CPViewAnimator.j
Created November 2, 2016 09:57
Ask the animator if he wants frame updates for a given key path
- (id)initWithTarget:(id)aTarget
{
self = [super initWithTarget:aTarget];
_wantsPeriodicFrameUpdates = NO;
return self;
}
- (void)requestPeriodicFrameUpdates
@implementation NSTreeController
- (id)initWithCoder:(id)
//id __cdecl -[NSTreeController initWithCoder:](struct NSTreeController *self, SEL a2, id a3)
{
void *v3; // esi@1
void *v4; // eax@2
void *v5; // eax@2
void *v6; // eax@2
void *v7; // eax@2