Skip to content

Commit

Permalink
refactoring for use of navigation controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Edwards authored and Kevin Edwards committed Jul 17, 2009
1 parent 1d72dc9 commit 4bc755c
Show file tree
Hide file tree
Showing 13 changed files with 576 additions and 132 deletions.
22 changes: 22 additions & 0 deletions ChemDraw/ChemDraw.xcodeproj/project.pbxproj
Expand Up @@ -15,6 +15,12 @@
2899E5220DE3E06400AC0155 /* ChemDrawViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2899E5210DE3E06400AC0155 /* ChemDrawViewController.xib */; };
28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD733E0D9D9553002E5188 /* MainWindow.xib */; };
28D7ACF80DDB3853001CB0EB /* ChemDrawViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28D7ACF70DDB3853001CB0EB /* ChemDrawViewController.m */; };
DE15A73710107CF10080291E /* GestureView.m in Sources */ = {isa = PBXBuildFile; fileRef = DE15A73610107CF10080291E /* GestureView.m */; };
DE15A73810107CF10080291E /* GestureView.m in Sources */ = {isa = PBXBuildFile; fileRef = DE15A73610107CF10080291E /* GestureView.m */; };
DE15A73D1010829A0080291E /* GestureViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DE15A73C1010829A0080291E /* GestureViewController.m */; };
DE15A73E1010829A0080291E /* GestureViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DE15A73C1010829A0080291E /* GestureViewController.m */; };
DE15A7401010835B0080291E /* GestureViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = DE15A73F1010835B0080291E /* GestureViewController.xib */; };
DE15A7411010835B0080291E /* GestureViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = DE15A73F1010835B0080291E /* GestureViewController.xib */; };
DE2091440FF4E840001FECDA /* DrawView.m in Sources */ = {isa = PBXBuildFile; fileRef = DE2091430FF4E840001FECDA /* DrawView.m */; };
DE2091FF0FF4F578001FECDA /* Node.m in Sources */ = {isa = PBXBuildFile; fileRef = DE2091FE0FF4F578001FECDA /* Node.m */; };
DE2093480FF50B67001FECDA /* Bond.m in Sources */ = {isa = PBXBuildFile; fileRef = DE2093470FF50B67001FECDA /* Bond.m */; };
Expand Down Expand Up @@ -99,6 +105,11 @@
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
32CA4F630368D1EE00C91783 /* ChemDraw_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChemDraw_Prefix.pch; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
DE15A73510107CF10080291E /* GestureView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GestureView.h; sourceTree = "<group>"; };
DE15A73610107CF10080291E /* GestureView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GestureView.m; sourceTree = "<group>"; };
DE15A73B1010829A0080291E /* GestureViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GestureViewController.h; sourceTree = "<group>"; };
DE15A73C1010829A0080291E /* GestureViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GestureViewController.m; sourceTree = "<group>"; };
DE15A73F1010835B0080291E /* GestureViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = GestureViewController.xib; sourceTree = "<group>"; };
DE2091420FF4E840001FECDA /* DrawView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawView.h; sourceTree = "<group>"; };
DE2091430FF4E840001FECDA /* DrawView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DrawView.m; sourceTree = "<group>"; };
DE2091FD0FF4F578001FECDA /* Node.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Node.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -254,6 +265,7 @@
2899E5210DE3E06400AC0155 /* ChemDrawViewController.xib */,
28AD733E0D9D9553002E5188 /* MainWindow.xib */,
8D1107310486CEB800E47090 /* Info.plist */,
DE15A73F1010835B0080291E /* GestureViewController.xib */,
);
name = Resources;
sourceTree = "<group>";
Expand Down Expand Up @@ -376,6 +388,8 @@
children = (
28D7ACF60DDB3853001CB0EB /* ChemDrawViewController.h */,
28D7ACF70DDB3853001CB0EB /* ChemDrawViewController.m */,
DE15A73B1010829A0080291E /* GestureViewController.h */,
DE15A73C1010829A0080291E /* GestureViewController.m */,
);
name = Controllers;
sourceTree = "<group>";
Expand All @@ -385,6 +399,8 @@
children = (
DE2091420FF4E840001FECDA /* DrawView.h */,
DE2091430FF4E840001FECDA /* DrawView.m */,
DE15A73510107CF10080291E /* GestureView.h */,
DE15A73610107CF10080291E /* GestureView.m */,
);
name = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -461,13 +477,15 @@
files = (
28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */,
2899E5220DE3E06400AC0155 /* ChemDrawViewController.xib in Resources */,
DE15A7401010835B0080291E /* GestureViewController.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
DE874F850FFA592000B1E023 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DE15A7411010835B0080291E /* GestureViewController.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -525,6 +543,8 @@
DE536536100F706D00A098FF /* DoubleBondAction.m in Sources */,
DE53653A100F707500A098FF /* TripleBondAction.m in Sources */,
DE53653E100F707F00A098FF /* SingleBondAction.m in Sources */,
DE15A73710107CF10080291E /* GestureView.m in Sources */,
DE15A73D1010829A0080291E /* GestureViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -566,6 +586,8 @@
DE536537100F706D00A098FF /* DoubleBondAction.m in Sources */,
DE53653B100F707500A098FF /* TripleBondAction.m in Sources */,
DE53653F100F707F00A098FF /* SingleBondAction.m in Sources */,
DE15A73810107CF10080291E /* GestureView.m in Sources */,
DE15A73E1010829A0080291E /* GestureViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
72 changes: 22 additions & 50 deletions ChemDraw/ChemDrawViewController.xib
Expand Up @@ -85,61 +85,13 @@
</object>
<int key="connectionID">11</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">changeElementButton</string>
<reference key="source" ref="774585933"/>
<reference key="destination" ref="1035624878"/>
</object>
<int key="connectionID">20</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">changeElement:</string>
<reference key="source" ref="1035624878"/>
<reference key="destination" ref="774585933"/>
</object>
<int key="connectionID">21</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">undoLastAction:</string>
<reference key="source" ref="190725965"/>
<reference key="destination" ref="774585933"/>
</object>
<int key="connectionID">23</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">undoButton</string>
<reference key="source" ref="774585933"/>
<reference key="destination" ref="190725965"/>
</object>
<int key="connectionID">24</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">cancel</string>
<reference key="source" ref="948987760"/>
<reference key="destination" ref="774585933"/>
</object>
<int key="connectionID">26</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">cancelButton</string>
<reference key="source" ref="774585933"/>
<reference key="destination" ref="948987760"/>
</object>
<int key="connectionID">27</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">view</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="774585933"/>
</object>
<int key="connectionID">31</int>
<int key="connectionID">36</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
Expand Down Expand Up @@ -172,6 +124,7 @@
<reference ref="44421683"/>
</object>
<reference key="parent" ref="360949347"/>
<string key="objectName">view</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">8</int>
Expand Down Expand Up @@ -248,14 +201,33 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">31</int>
<int key="maxID">36</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">ChemDrawViewController</string>
<string key="superclassName">UIViewController</string>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>cancelButton</string>
<string>changeElementButton</string>
<string>toolBar</string>
<string>undoButton</string>
<string>view</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>UIBarButtonItem</string>
<string>UIBarButtonItem</string>
<string>UIToolbar</string>
<string>UIBarButtonItem</string>
<string>DrawView</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">Classes/ChemDrawViewController.h</string>
Expand Down
20 changes: 12 additions & 8 deletions ChemDraw/Classes/ChemDrawAppDelegate.h
Expand Up @@ -9,19 +9,23 @@
#import <UIKit/UIKit.h>

@class ChemDrawViewController;
//@class DrawView;
@class GestureViewController;

@interface ChemDrawAppDelegate : NSObject <UIApplicationDelegate, UIScrollViewDelegate> {
@interface ChemDrawAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
IBOutlet ChemDrawViewController *viewController;
IBOutlet UIScrollView *scrollView;
//DrawView *drawView;
IBOutlet UINavigationController *navigationController;
IBOutlet ChemDrawViewController *drawViewController;
IBOutlet GestureViewController *gestureViewController;
}

- (IBAction)changeElement:(id)sender;

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet ChemDrawViewController *viewController;
@property (nonatomic, retain) IBOutlet UIScrollView *scrollView;
//@property (nonatomic, retain) IBOutlet DrawView *drawView;
@property (nonatomic, retain) IBOutlet ChemDrawViewController *drawViewController;
@property (nonatomic, retain) IBOutlet GestureViewController *gestureViewController;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;



@end

47 changes: 18 additions & 29 deletions ChemDraw/Classes/ChemDrawAppDelegate.m
Expand Up @@ -10,53 +10,42 @@
#import "ChemDrawViewController.h"
#import "DrawView.h"

#import "GestureViewController.h"
#import "GestureView.h"

@implementation ChemDrawAppDelegate

@synthesize window;
@synthesize viewController;
@synthesize scrollView;
//@synthesize drawView;
@synthesize drawViewController;
@synthesize gestureViewController;
@synthesize navigationController;


- (void)applicationDidFinishLaunching:(UIApplication *)application {

//CGRect frame = CGRectMake(0, 0, 640, 960);
//NSLog(@"CREATE RECT");
//drawView = [[DrawView alloc] initWithFrame:frame];
//NSLog(@"INIT DRAW VIEW");


// Override point for customization after app launch
//[window addSubview:viewController.view];


//scrollView.contentSize = CGSizeMake([[[viewController view] frame] width], 960);
CGSize frameRect = CGSizeMake(640, 960);
scrollView.contentSize = frameRect;
scrollView.maximumZoomScale = 4.0;
scrollView.minimumZoomScale = 0.75;
scrollView.clipsToBounds = YES;
scrollView.delegate = self;
scrollView.bounces = YES;
//[scrollView addSubview:drawView];
[scrollView addSubview:viewController.view];
navigationController = [[UINavigationController alloc] initWithRootViewController:drawViewController];
[window addSubview:[navigationController view]];

CGRect centerRect = CGRectMake(320, 480, 320, 480);
[scrollView zoomToRect:centerRect animated:YES];

[window makeKeyAndVisible];

NSLog(@"END OF APP LAUNCH");

}

- (UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollView {
return viewController.view;
//return drawView;
- (IBAction)changeElement:(id)sender {
NSLog(@"CHANGE ELEMENT CLICKED");
}



- (void)dealloc {
//[drawView release];
[scrollView release];
[viewController release];

[navigationController release];
[gestureViewController release];
[drawViewController release];
[window release];
[super dealloc];
}
Expand Down
12 changes: 9 additions & 3 deletions ChemDraw/Classes/ChemDrawViewController.h
Expand Up @@ -8,21 +8,27 @@

#import <UIKit/UIKit.h>

@class DrawView;

@interface ChemDrawViewController : UIViewController {
IBOutlet UIToolbar *toolBar;
IBOutlet UIBarButtonItem *changeElementButton;

IBOutlet UIBarButtonItem *undoButton;
IBOutlet UIBarButtonItem *cancelButton;

// IBOutlet UIScrollView *scrollView;
IBOutlet DrawView *view;
}

- (IBAction)changeElement:(id)sender;
//- (IBAction)changeElement:(id)sender;

- (IBAction)undoLastAction:(id)sender;
//- (IBAction)undoLastAction:(id)sender;

- (IBAction) cancel;
//- (IBAction) cancel;

//@property (nonatomic, retain) IBOutlet DrawView *drawView;
//@property (nonatomic, retain) IBOutlet UIScrollView *scrollView;

@end

14 changes: 7 additions & 7 deletions ChemDraw/Classes/ChemDrawViewController.m
Expand Up @@ -7,10 +7,12 @@
//

#import "ChemDrawViewController.h"
#import "DrawView.h"

@implementation ChemDrawViewController

//@synthesize drawView;
//@synthesize scrollView;

/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
Expand All @@ -34,9 +36,8 @@ - (void)loadView {
- (void)viewDidLoad {
NSLog(@"VIEW DID LOAD");
[super viewDidLoad];
CGRect frame = CGRectMake(0, 0, 640, 960);
[[self view] initWithFrame:frame];
// [view initWithFrame:frame];
[[self view] initWithFrame:CGRectMake(0, 0, 320, 480)];

[[self view] setNeedsDisplay];
}

Expand All @@ -50,23 +51,22 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
}
*/


- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
// Release anything that's not essential, such as cached data
}

- (IBAction)undoLastAction:(id)sender {
[[self view] undoLastAction];
// [[self view] undoLastAction];
}

- (IBAction)changeElement:(id)sender {
[[self view] changeElement:sender];
// [[self view] changeElement:sender];

}

- (IBAction) cancel {
[[self view] cancel];
// [[self view] cancel];
}


Expand Down
2 changes: 1 addition & 1 deletion ChemDraw/Classes/DrawView.m
Expand Up @@ -45,7 +45,7 @@ - (id)initWithFrame:(CGRect)frame {


NSLog(@"DRAW VIEW INIT 5");
[self setupToolbarButtonArrays];
// [self setupToolbarButtonArrays];
NSLog(@"DRAW VIEW INIT 6");

//[self setNeedsDisplay];
Expand Down

0 comments on commit 4bc755c

Please sign in to comment.