Initial Commit

This commit is contained in:
ken
2026-02-22 13:24:11 -08:00
commit fcd6316c7f
207 changed files with 20533 additions and 0 deletions
+73
View File
@@ -0,0 +1,73 @@
//
// HP16AppDelegate.m
// HPcalc
//
// Created by Ken on 8/5/08.
// Copyright Ken Staton 2008. All rights reserved.
//
#import "HP16AppDelegate.h"
#import "HP16ViewController.h"
#import "DisplayView.h"
#import "DisplayView.h"
#import "hpcalc.h"
#import <AudioToolbox/AudioServices.h>
@implementation HP16AppDelegate
@synthesize window;
@synthesize hp16ViewController;
@synthesize display;
@synthesize calc;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
HP16ViewController *aViewController = [[HP16ViewController alloc]
initWithNibName:@"ControllerView" bundle:[NSBundle mainBundle]];
self.hp16ViewController = aViewController;
[aViewController release];
UIView *controllersView = [hp16ViewController view];
CGRect frame = CGRectMake(230, 0, 320, 480);
display = [[DisplayView alloc] initWithFrame: frame];
[window addSubview:controllersView];
[window addSubview:display];
//[display displayString:@"42"];
[window makeKeyAndVisible];
calc = [[HPCalc alloc] initWithDisplay:display];
[hp16ViewController calcInstance:calc]; // tell the view controller about this calc instance
//NSLog(@"done DidFinishLaunch");
}
- (void)awakeFromNib
{
//NSLog(@"awakeFromNib");
}
- (void) applicationWillTerminate:(UIApplication *)application {
[calc shutdown];
//NSLog(@"applicationWillTerminate");
}
- (void)dealloc {
[display release];
[hp16ViewController release];
[window release];
[super dealloc];
}
@end
+30
View File
@@ -0,0 +1,30 @@
//
// HPcalc_hp16AppDelegate.h
// HPcalc
//
// Created by Ken on 8/5/08.
// Copyright Ken Staton 2008. All rights reserved.
//
#import <UIKit/UIKit.h>
@class HP16ViewController;
@class DisplayView;
@class HPCalc;
@interface HP16AppDelegate : NSObject <UIApplicationDelegate> {
IBOutlet UIWindow *window;
HP16ViewController *hp16ViewController;
DisplayView *display;
HPCalc *calc;
}
@property (nonatomic, strong) UIWindow *window;
@property (nonatomic, strong) HP16ViewController *hp16ViewController;
@property (nonatomic, strong) DisplayView *display;
@property (nonatomic, strong) HPCalc *calc;
@end
+76
View File
@@ -0,0 +1,76 @@
//
// HP16AppDelegate.m
// HPcalc
//
// Created by Ken on 8/5/08.
// Copyright Ken Staton 2008. All rights reserved.
//
#import "HP16AppDelegate.h"
#import "HP16ViewController.h"
#import "DisplayView.h"
#import "DisplayView.h"
#import "hpcalc.h"
#import <AudioToolbox/AudioServices.h>
@implementation HP16AppDelegate
@synthesize window;
@synthesize hp16ViewController;
@synthesize display;
@synthesize calc;
// KLS see NSAutoreleasePool
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(nullable NSDictionary<UIApplicationLaunchOptionsKey,id> *)launchOptions
{
HP16ViewController *aViewController = [[HP16ViewController alloc]
initWithNibName:@"ControllerView" bundle:[NSBundle mainBundle]];
self.hp16ViewController = aViewController;
UIView *controllersView = [hp16ViewController view];
// this is the location of the Calculator's LCD display
// x,y,w,h
//CGRect frame = CGRectMake(230, 0, 320, 480); //ORIGINAL
CGRect frame = CGRectMake(74, 24, 314, 52);
display = [[DisplayView alloc] initWithFrame: frame];
//display.backgroundColor=[UIColor redColor]; //kls
display.opaque=TRUE;
display.alpha=1.0;
self.window.rootViewController = self.hp16ViewController;
[self.window addSubview:controllersView];
[self.window addSubview:display];
[self.window bringSubviewToFront:display];
[self.window makeKeyAndVisible];
calc = [[HPCalc alloc] initWithDisplay:display];
[hp16ViewController calcInstance:calc]; // tell the view controller about this calc instance
NSLog(@"done DidFinishLaunchWithOptions");
return YES;
}
- (void)awakeFromNib
{
NSLog(@"awakeFromNib");
[super awakeFromNib];
}
- (void) applicationWillTerminate:(UIApplication *)application {
[calc shutdown];
NSLog(@"applicationWillTerminate");
}
@end
+99
View File
@@ -0,0 +1,99 @@
//
// HP16ViewController.m
// HPcalc
//
// Created by Ken on 8/5/08.
// Copyright 2008 Ken Staton. All rights reserved.
//
#import "HP16ViewController.h"
#import "HP16AppDelegate.h"
#import "hpcalc.h"
#import <CoreGraphics/CGAffineTransform.h>
#import <AudioToolbox/AudioServices.h>
@implementation HP16ViewController
-(void)calcInstance:(id)calc {
thecalc = calc;
}
- (IBAction)keyPressed:(id)sender {
NSInteger code = [sender tag];
//NSLog(@"in vc keyPressed. key = %d",code);
[thecalc processKeypress: code];
[thecalc processKeypress: -1];
AudioServicesPlaySystemSound(1105); // key click
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Initialization code
//NSLog(@"initWithNibName");
}
return self;
}
/*
Implement loadView if you want to create a view hierarchy programmatically
- (void)loadView {
}
*/
// If you need to do additional setup after loading the view, override viewDidLoad.
- (void)viewDidLoad {
//UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
[super viewDidLoad];
//if (orientation == UIInterfaceOrientationLandscapeLeft) {
if (TRUE) {
CGAffineTransform transform = self.view.transform;
// Use the status bar frame to determine the center point of the window's content area.
//CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
//CGRect bounds = CGRectMake(0, 0, statusBarFrame.size.height, statusBarFrame.origin.x);
//CGPoint center = CGPointMake(bounds.size.height / 2.0, bounds.size.width / 2.0);
CGPoint center = CGPointMake(320 / 2.0, 480 / 2.0);
// Set the center point of the view to the center point of the window's content area.
self.view.center = center;
// Rotate the view 90 degrees around center point.
transform = CGAffineTransformRotate(transform, (M_PI / 2.0));
self.view.transform = transform;
}
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
//return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
//return YES;
return NO;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
// Release anything that's not essential, such as cached data
}
- (void)dealloc {
[super dealloc];
}
@end
+23
View File
@@ -0,0 +1,23 @@
//
// HP16ViewController.h
// HPcalc
//
// Created by Ken on 8/5/08.
// Copyright 2008 Ken Staton. All rights reserved.
//
#import <UIKit/UIKit.h>
@class HPCalc;
@interface HP16ViewController : UIViewController {
HPCalc *thecalc;
}
- (void)calcInstance:(id)calc;
- (IBAction)keyPressed:(id)sender;
@end
+133
View File
@@ -0,0 +1,133 @@
//
// HP16ViewController.m
// HPcalc
//
// Created by Ken on 8/5/08.
// Copyright 2008 Ken Staton. All rights reserved.
//
/*
The UIScreen bounds behavior has changed in iOS8.
Previously it would always give you width and height of the screen in portrait (so 320 x 568 on the iPhone 5),
but in iOS8 it will give you width and height with respect to whatever orientation you're in,
i.e. in landscape you would get 568 x 320.
If you want to get the bounds in portrait (like before), use:
[UIScreen mainScreen].fixedCoordinateSpace.bounds.size
*/
// landscape on iPhone 6:
// 667 x 375
// 1334 x 750 (@2x)
// landscape on iPadPro 9":
//
// landscape on iPhone 11pro:
// 812 x 375 points
// 1624 x 750 (@2x)
#import "HP16ViewController.h"
#import "HP16AppDelegate.h"
#import "hpcalc.h"
#import <CoreGraphics/CGAffineTransform.h>
#import <AudioToolbox/AudioServices.h>
@implementation HP16ViewController
-(void)calcInstance:(id)calc {
thecalc = calc;
}
- (IBAction)keyPressed:(id)sender {
NSInteger code = [sender tag];
NSLog(@"in vc keyPressed. key = %ld",(long)code);
PowerState PWR = thecalc->_PWR;
[thecalc processKeypress: (int)code];
[thecalc processKeypress: -1];
if (code == 24) {
//NSLog(@"power button pressed %lu",(unsigned long)PWR);
if (PWR == ON) { thecalc->_PWR=OFF;}
else { thecalc->_PWR=ON;}
}
if (PWR == ON) { // key click only when "on"
AudioServicesPlaySystemSound(1105);
}
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Initialization code
NSLog(@"initWithNibName");
}
return self;
}
//Implement loadView if you want to create a view hierarchy programmatically
/*- (void)loadView {
[super loadView];
NSLog(@"loadview");
}*/
// If you need to do additional setup after loading the view, override viewDidLoad.
- (void)viewDidLoad {
[super viewDidLoad];
if (FALSE) {
NSLog(@"transform_rotate");
CGAffineTransform transform = self.view.transform;
//CGPoint center = CGPointMake(bounds.size.height / 2.0, bounds.size.width / 2.0);
//CGPoint center = CGPointMake(667 / 4.0, 375 / 4.0);
//CGPoint center = CGPointMake(812 / 2.0, 375 / 2.0);
//CGPoint center = CGPointMake(1624 / 2.0, 750 / 2.0);
CGPoint center = CGPointMake(375 / 2.0, 812 / 2.0);
// Set the center point of the view to the center point of the window's content area.
self.view.center = center;
// Rotate the view 90 degrees around center point.
transform = CGAffineTransformRotate(transform, (M_PI / 2.0));
self.view.transform = transform;
}
NSLog(@"viewDidLoad");
NSLog(@"H %f, W %f", [UIScreen mainScreen].fixedCoordinateSpace.bounds.size.height, [UIScreen mainScreen].fixedCoordinateSpace.bounds.size.width);
}
/*
- (BOOL)shouldAutorotate:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
//return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
return NO;
}
*/
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
// Release anything that's not essential, such as cached data
NSLog(@"Memory Warning");
}
@end