
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[])
{
return NSApplicationMain(argc, (const char **) argv);
}
#import "UberCalculatorController.h"
#import "UberCalculator_prefix.pch.h"
@implementation MasterView
- (id) initWithFrame: (CGRect) frame {
//NSLog(@"MasterView initWithFrame");
self = [super initWithFrame: frame];
views = [[NSMutableArray alloc] init];
currentViewIndex = -1;
return self;
}
- (BOOL) canHandleSwipes {
return TRUE;
}
- (int)swipe:(int)type withEvent:(struct __GSEvent *)event {
//NSLog(@"MasterView swipe: %d withEvent: %@", type, event);
int transType = 0;
if (type == 4) { // kUIViewSwipeLeft
transType = 1;
currentViewIndex--;
if (currentViewIndex < 0) {
currentViewIndex = [views count] - 1;
}
} else if (type == 8) { //kUIViewSwipeRight
transType = 2;
currentViewIndex++;
if (currentViewIndex == [views count]) {
currentViewIndex = 0;
}
}
//NSLog(@"transition to view %d", currentViewIndex);
if (transType != 0) {
[self transition:transType toView: [views objectAtIndex: currentViewIndex]];
}
// transition to current view
return [ super swipe:type withEvent:event ];
}
- (void) addView: (id) fp8 {
[views addObject: fp8];
if (currentViewIndex == -1) {
[super addSubview: fp8];
currentViewIndex = 0;
}
}
- (void) dealloc {
[views release];
[super dealloc];
}
@end
@implementation CalculatorApp
- (void) handleCommand: (NSString *) command {
//NSLog(@"CalculatorApp handleCommand: [%@]", command);
// pass the commands down the chain
[engine sendCommand: command];
// then update all the views...
[self updateViews];
}
- (void) updateViews {
[basicCalculatorView updateView];
}
/- (void) applicationDidFinishLaunching: (id) fp8 {
engine = [[CalculatorEngine alloc] init];
struct CGRect frame = [UIHardware fullScreenApplicationContentRect];
frame.origin.x = frame.origin.y = 0.0f;
mainWindow = [[UIWindow alloc] initWithContentRect: frame];
masterView = [[MasterView alloc] initWithFrame: frame];
basicCalculatorView = [[BasicCalculatorView alloc] initWithFrame: frame withController: self withEngine: engine withType: 0];
[masterView addView: basicCalculatorView];
sciCalculatorView = [[BasicCalculatorView alloc] initWithFrame: frame withController: self withEngine: engine withType: 1];
[masterView addView: sciCalculatorView];
navView = [[UINavigationBar alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 48.0f)];
[navView showButtonsWithLeftTitle: @"Decimal" rightTitle: @"Hex" leftBack: YES];
[navView setPrompt: @"Caclulator2"];
[navView setBarStyle: 0];
[navView enableAnimation];
//[masterView addView: navView];
diagView = [[UITouchDiagnosticsLayer alloc] initWithFrame: frame];
[diagView setDisplayChargeMap: true];
[diagView setDisplayHitRects: true];
[diagView setDisplayTouchEvents: true];
[diagView setTrackTouchEvents: true];
//[masterView addView: diagView];
[mainWindow orderFront: self];
[mainWindow makeKey: self];
[mainWindow _setHidden: NO];
[mainWindow setContentView: masterView];
}
- (void)acceleratedInX:(float)xx Y:(float)yy Z:(float)zz {
NSLog(@"accelerated x=%g, y=%g, z=%g", xx, yy, zz);
}
@end

- (int)swipe:(int)type withEvent:(struct __GSEvent *)event {
- (int)swipe:(int)type withEvent:(struct __GSEvent *)event {
//NSLog(@"MasterView swipe: %d withEvent: %@", type, event);
int transType = 0;
if (type == 4) { // kUIViewSwipeLeft
transType = 1;
currentViewIndex--;
if (currentViewIndex < 0) {
currentViewIndex = [views count] - 1;
}
} else if (type == 8) { //kUIViewSwipeRight
transType = 2;
currentViewIndex++;
if (currentViewIndex == [views count]) {
currentViewIndex = 0;
}
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[])
{
return NSApplicationMain(argc, (const char **) argv);
}
#import "UberCalculatorController.h"
#import "UberCalculator_prefix.pch.h"
@implementation MasterView
- (id) initWithFrame: (CGRect) frame
{
//NSLog(@"MasterView initWithFrame");
self = [super initWithFrame: frame];
views = [[NSMutableArray alloc] init];
currentViewIndex = -1;
return self;
}
- (BOOL) canHandleSwipes
{
return TRUE;
}
- (int)swipe:(int)type withEvent:(struct __GSEvent *)event
{
//NSLog(@"MasterView swipe: %d withEvent: %@", type, event);
int transType = 0;
if (type == 4)
{
// kUIViewSwipeLeft
transType = 1;
currentViewIndex--;
if (currentViewIndex < 0)
{
currentViewIndex = [views count] - 1;
}
}
else if (type == 8)
{
//kUIViewSwipeRight
transType = 2;
currentViewIndex++;
if (currentViewIndex == [views count])
{
currentViewIndex = 0;
}
}
//NSLog(@"transition to view %d", currentViewIndex);
if (transType != 0)
{
[self transition:transType toView: [views objectAtIndex: currentViewIndex]];
}
// transition to current view
return [ super swipe:type withEvent:event ];
}
- (void) addView: (id) fp8
{
[views addObject: fp8];
if (currentViewIndex == -1)
{
[super addSubview: fp8];
currentViewIndex = 0;
}
}
- (void) dealloc
{
[views release];
[super dealloc];
}
@end
@implementation CalculatorApp
- (void) handleCommand: (NSString *) command
{
//NSLog(@"CalculatorApp handleCommand: [%@]", command);
// pass the commands down the chain
[engine sendCommand: command];
// then update all the views...
[self updateViews];
}
- (void) updateViews
{
[basicCalculatorView updateView];
}
- (void) applicationDidFinishLaunching: (id) fp8
{
engine = [[CalculatorEngine alloc] init];
struct CGRect frame = [UIHardware fullScreenApplicationContentRect];
frame.origin.x = frame.origin.y = 0.0f;
mainWindow = [[UIWindow alloc] initWithContentRect: frame];
masterView = [[MasterView alloc] initWithFrame: frame];
basicCalculatorView = [[BasicCalculatorView alloc] initWithFrame: frame withController: self withEngine: engine withType: 0];
[masterView addView: basicCalculatorView];
sciCalculatorView = [[BasicCalculatorView alloc] initWithFrame: frame withController: self withEngine: engine withType: 1];
[masterView addView: sciCalculatorView];
navView = [[UINavigationBar alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 48.0f)];
[navView showButtonsWithLeftTitle: @"Decimal" rightTitle: @"Hex" leftBack: YES];
[navView setPrompt: @"Caclulator2"];
[navView setBarStyle: 0];
[navView enableAnimation];
//[masterView addView: navView];
diagView = [[UITouchDiagnosticsLayer alloc] initWithFrame: frame];
[diagView setDisplayChargeMap: true];
[diagView setDisplayHitRects: true];
[diagView setDisplayTouchEvents: true];
[diagView setTrackTouchEvents: true];
//[masterView addView: diagView];
[mainWindow orderFront: self];
[mainWindow makeKey: self];
[mainWindow _setHidden: NO];
[mainWindow setContentView: masterView];
}
- (void)acceleratedInX:(float)xx Y:(float)yy Z:(float)zz
{
NSLog(@"accelerated x=%g, y=%g, z=%g", xx, yy, zz);
}
@end
