Skip to content

Instantly share code, notes, and snippets.

Created October 12, 2008 01:48
Show Gist options
  • Save anonymous/16352 to your computer and use it in GitHub Desktop.
Save anonymous/16352 to your computer and use it in GitHub Desktop.
import <Foundation/CPObject.j>
import "CalculatorLogic.j"
@implementation CalculatorButton : CPButton
{
}
+(id)initCalculatorButton:(CPText)buttonText target:(id)aTarget selector:(SEL)aSelector rect:(CGRect)aFrame
{
var returnValue = [[CalculatorButton alloc] initWithFrame: aFrame ];
[returnValue setTitle:buttonText];
[returnValue setTarget:aTarget];
[returnValue setAction:aSelector];
[returnValue setBezelStyle:CPHUDBezelStyle];
return returnValue;
}
@end
buttonSeven = [CalculatorButton initCalculatorButton:"7" target:calculatorLogic selector: @selector(buttonSeven) rect:[self buttonWidth:1 column:1 extend:NO]];
buttonEight = [CalculatorButton initCalculatorButton:"8" target:calculatorLogic selector: @selector(buttonEight) rect:[self buttonWidth:1 column:2 extend:NO]];
buttonNine = [CalculatorButton initCalculatorButton:"9" target:calculatorLogic selector: @selector(buttonNine) rect:[self buttonWidth:1 column:3 extend:NO]];
buttonFour = [CalculatorButton initCalculatorButton:"4" target:calculatorLogic selector: @selector(buttonFour) rect:[self buttonWidth:2 column:1 extend:NO]];
buttonFive = [CalculatorButton initCalculatorButton:"5" target:calculatorLogic selector: @selector(buttonFive) rect:[self buttonWidth:2 column:2 extend:NO]];
buttonSix = [CalculatorButton initCalculatorButton:"6" target:calculatorLogic selector: @selector(buttonSix) rect:[self buttonWidth:2 column:3 extend:NO]];
buttonOne = [CalculatorButton initCalculatorButton:"1" target:calculatorLogic selector: @selector(buttonOne) rect:[self buttonWidth:3 column:1 extend:NO]];
buttonTwo = [CalculatorButton initCalculatorButton:"2" target:calculatorLogic selector: @selector(buttonTwo) rect:[self buttonWidth:3 column:2 extend:NO]];
buttonThree = [CalculatorButton initCalculatorButton:"3" target:calculatorLogic selector: @selector(buttonThree) rect:[self buttonWidth:3 column:3 extend:NO]];
buttonZero = [CalculatorButton initCalculatorButton:"0" target:calculatorLogic selector: @selector(buttonZero) rect:[self buttonWidth:4 column:1 extend:YES]];
buttonDot = [CalculatorButton initCalculatorButton:"." target:calculatorLogic selector: @selector(buttonDot) rect:[self buttonWidth:4 column:3 extend:NO]];
[[self contentView] addSubview:buttonOne];
[[self contentView] addSubview:buttonTwo];
[[self contentView] addSubview:buttonThree];
[[self contentView] addSubview:buttonFour];
[[self contentView] addSubview:buttonFive];
[[self contentView] addSubview:buttonSix];
[[self contentView] addSubview:buttonSeven];
[[self contentView] addSubview:buttonEight];
[[self contentView] addSubview:buttonNine];
[[self contentView] addSubview:buttonZero];
[[self contentView] addSubview:buttonDot];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment