Skip to content

Commit 5d877de

Browse files
committed
Initial commit
0 parents  commit 5d877de

17 files changed

+4360
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build

Classes/DetailViewController.h

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// DetailViewController.h
3+
// Lisp
4+
//
5+
// Created by David Pollak on 6/7/11.
6+
// Copyright 2011 lift Web Framework. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@interface DetailViewController : UIViewController <UIPopoverControllerDelegate, UISplitViewControllerDelegate> {
12+
13+
UIPopoverController *popoverController;
14+
UIToolbar *toolbar;
15+
16+
id detailItem;
17+
UILabel *detailDescriptionLabel;
18+
19+
@public void (*cb_lispEval)(void* vc, const char* touch);
20+
}
21+
22+
@property (nonatomic, retain) IBOutlet UIToolbar *toolbar;
23+
24+
@property (nonatomic, retain) id detailItem;
25+
@property (nonatomic, retain) IBOutlet UILabel *detailDescriptionLabel;
26+
27+
@property (nonatomic, retain) IBOutlet UITextField *textField;
28+
@property (nonatomic, retain) IBOutlet UITextView *tableDude;
29+
30+
-(IBAction)buttonPressed: (id)sender;
31+
32+
@end

Classes/DetailViewController.m

+182
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
//
2+
// DetailViewController.m
3+
// Lisp
4+
//
5+
// Created by David Pollak on 6/7/11.
6+
// Copyright 2011 lift Web Framework. All rights reserved.
7+
//
8+
9+
#import "DetailViewController.h"
10+
#import "RootViewController.h"
11+
12+
static void (*cb_viewDidLoad)(void*);
13+
14+
void setViewDidLoad(void (*fp)(void*))
15+
{
16+
cb_viewDidLoad = fp;
17+
}
18+
19+
void addToResult(DetailViewController* vc, char *str)
20+
{
21+
NSString *resStr = [[NSString alloc] initWithCString:str];
22+
23+
NSString *curText = vc.tableDude.text;
24+
vc.tableDude.text = [[curText stringByAppendingString:@": "] stringByAppendingString:resStr];
25+
}
26+
27+
void setLispEval(DetailViewController *vc, void (*cb)(void *vc, const char *))
28+
{
29+
vc -> cb_lispEval = cb;
30+
}
31+
32+
@interface DetailViewController ()
33+
@property (nonatomic, retain) UIPopoverController *popoverController;
34+
- (void)configureView;
35+
@end
36+
37+
38+
39+
@implementation DetailViewController
40+
41+
@synthesize toolbar, popoverController, detailItem, detailDescriptionLabel, textField, tableDude;
42+
43+
44+
-(IBAction)buttonPressed: (id)sender {
45+
NSString *curVal = textField.text;
46+
[curVal retain];
47+
48+
NSString *curText = tableDude.text;
49+
tableDude.text = [[curText stringByAppendingString:@"\n"] stringByAppendingString:curVal];
50+
51+
textField.text = [[NSString alloc] init];
52+
const char *str = [curVal UTF8String];
53+
54+
(*cb_lispEval)(self, str);
55+
[curVal release];
56+
}
57+
58+
#pragma mark -
59+
#pragma mark Managing the detail item
60+
61+
/*
62+
When setting the detail item, update the view and dismiss the popover controller if it's showing.
63+
*/
64+
- (void)setDetailItem:(id)newDetailItem {
65+
if (detailItem != newDetailItem) {
66+
[detailItem release];
67+
detailItem = [newDetailItem retain];
68+
69+
// Update the view.
70+
[self configureView];
71+
}
72+
73+
if (self.popoverController != nil) {
74+
[self.popoverController dismissPopoverAnimated:YES];
75+
}
76+
}
77+
78+
79+
- (void)configureView {
80+
// Update the user interface for the detail item.
81+
detailDescriptionLabel.text = [detailItem description];
82+
}
83+
84+
85+
#pragma mark -
86+
#pragma mark Split view support
87+
88+
- (void)splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc {
89+
90+
barButtonItem.title = @"Root List";
91+
NSMutableArray *items = [[toolbar items] mutableCopy];
92+
[items insertObject:barButtonItem atIndex:0];
93+
[toolbar setItems:items animated:YES];
94+
[items release];
95+
self.popoverController = pc;
96+
}
97+
98+
99+
// Called when the view is shown again in the split view, invalidating the button and popover controller.
100+
- (void)splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
101+
102+
NSMutableArray *items = [[toolbar items] mutableCopy];
103+
[items removeObjectAtIndex:0];
104+
[toolbar setItems:items animated:YES];
105+
[items release];
106+
self.popoverController = nil;
107+
}
108+
109+
110+
#pragma mark -
111+
#pragma mark Rotation support
112+
113+
// Ensure that the view controller supports rotation and that the split view can therefore show in both portrait and landscape.
114+
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
115+
return YES;
116+
}
117+
118+
119+
#pragma mark -
120+
#pragma mark View lifecycle
121+
122+
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
123+
- (void)viewDidLoad {
124+
[super viewDidLoad];
125+
self -> cb_lispEval = NULL;
126+
cb_viewDidLoad(self);
127+
}
128+
129+
/*
130+
131+
*/
132+
133+
/*
134+
- (void)viewWillAppear:(BOOL)animated {
135+
[super viewWillAppear:animated];
136+
}
137+
*/
138+
/*
139+
- (void)viewDidAppear:(BOOL)animated {
140+
[super viewDidAppear:animated];
141+
}
142+
*/
143+
/*
144+
- (void)viewWillDisappear:(BOOL)animated {
145+
[super viewWillDisappear:animated];
146+
}
147+
*/
148+
/*
149+
- (void)viewDidDisappear:(BOOL)animated {
150+
[super viewDidDisappear:animated];
151+
}
152+
*/
153+
154+
- (void)viewDidUnload {
155+
// Release any retained subviews of the main view.
156+
// e.g. self.myOutlet = nil;
157+
self.popoverController = nil;
158+
}
159+
160+
161+
#pragma mark -
162+
#pragma mark Memory management
163+
164+
/*
165+
- (void)didReceiveMemoryWarning {
166+
// Releases the view if it doesn't have a superview.
167+
[super didReceiveMemoryWarning];
168+
169+
// Release any cached data, images, etc that aren't in use.
170+
}
171+
*/
172+
173+
- (void)dealloc {
174+
[popoverController release];
175+
[toolbar release];
176+
177+
[detailItem release];
178+
[detailDescriptionLabel release];
179+
[super dealloc];
180+
}
181+
182+
@end

Classes/LispAppDelegate.h

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// LispAppDelegate.h
3+
// Lisp
4+
//
5+
// Created by David Pollak on 6/7/11.
6+
// Copyright 2011 lift Web Framework. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
12+
@class RootViewController;
13+
@class DetailViewController;
14+
15+
@interface LispAppDelegate : NSObject <UIApplicationDelegate> {
16+
17+
UIWindow *window;
18+
19+
UISplitViewController *splitViewController;
20+
21+
RootViewController *rootViewController;
22+
DetailViewController *detailViewController;
23+
}
24+
25+
@property (nonatomic, retain) IBOutlet UIWindow *window;
26+
27+
@property (nonatomic, retain) IBOutlet UISplitViewController *splitViewController;
28+
@property (nonatomic, retain) IBOutlet RootViewController *rootViewController;
29+
@property (nonatomic, retain) IBOutlet DetailViewController *detailViewController;
30+
31+
@end

Classes/LispAppDelegate.m

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
//
2+
// LispAppDelegate.m
3+
// Lisp
4+
//
5+
// Created by David Pollak on 6/7/11.
6+
// Copyright 2011 lift Web Framework. All rights reserved.
7+
//
8+
9+
#import "LispAppDelegate.h"
10+
11+
12+
#import "RootViewController.h"
13+
#import "DetailViewController.h"
14+
15+
16+
@implementation LispAppDelegate
17+
18+
@synthesize window, splitViewController, rootViewController, detailViewController;
19+
20+
21+
#pragma mark -
22+
#pragma mark Application lifecycle
23+
24+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
25+
26+
// Override point for customization after app launch.
27+
28+
// Add the split view controller's view to the window and display.
29+
[self.window addSubview:splitViewController.view];
30+
[self.window makeKeyAndVisible];
31+
32+
return YES;
33+
}
34+
35+
36+
- (void)applicationWillResignActive:(UIApplication *)application {
37+
/*
38+
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
39+
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
40+
*/
41+
}
42+
43+
44+
- (void)applicationDidBecomeActive:(UIApplication *)application {
45+
/*
46+
Restart any tasks that were paused (or not yet started) while the application was inactive.
47+
*/
48+
}
49+
50+
51+
- (void)applicationWillTerminate:(UIApplication *)application {
52+
/*
53+
Called when the application is about to terminate.
54+
*/
55+
}
56+
57+
58+
#pragma mark -
59+
#pragma mark Memory management
60+
61+
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
62+
/*
63+
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
64+
*/
65+
}
66+
67+
68+
- (void)dealloc {
69+
[splitViewController release];
70+
[window release];
71+
[super dealloc];
72+
}
73+
74+
75+
@end
76+

Classes/RootViewController.h

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// RootViewController.h
3+
// Lisp
4+
//
5+
// Created by David Pollak on 6/7/11.
6+
// Copyright 2011 lift Web Framework. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@class DetailViewController;
12+
13+
@interface RootViewController : UITableViewController {
14+
DetailViewController *detailViewController;
15+
}
16+
17+
@property (nonatomic, retain) IBOutlet DetailViewController *detailViewController;
18+
19+
@end

0 commit comments

Comments
 (0)