├── vertical.png ├── horizontal.png ├── Unit Tests ├── PSTTreeGraph │ ├── en.lproj │ │ ├── InfoPlist.strings │ │ ├── PSTTreeGraphViewController.xib │ │ └── MainWindow.xib │ ├── PSTTreeGraphViewController.h │ ├── PSTTreeGraph-Prefix.pch │ ├── main.m │ ├── PSTTreeGraphAppDelegate.h │ ├── PSTTreeGraphAppDelegate.m │ ├── PSTTreeGraphViewController.m │ └── PSTTreeGraph-Info.plist ├── PSTTreeGraphTests │ ├── en.lproj │ │ └── InfoPlist.strings │ ├── GraphTests.h │ ├── SubTreeTests.h │ ├── LeafTests.h │ ├── BranchTests.h │ ├── GraphTests.m │ ├── SubTreeTests.m │ ├── BranchTests.m │ ├── PSTTreeGraphTests-Info.plist │ └── LeafTests.m └── PSTTreeGraph.xcodeproj │ └── project.pbxproj ├── Example 1 ├── Graphics │ ├── GObject.png │ ├── Icon-72.png │ ├── TreeViewDirectLinesButton.png │ ├── TreeViewOrthogonalLinesButton.png │ ├── TreeViewSubtreeCollapsedButton.png │ └── TreeViewSubtreeExpandedButton.png ├── Target │ ├── PSHTreeGraph_Prefix.pch │ ├── main.m │ └── PSHTreeGraph-Info.plist ├── Classes │ ├── View │ │ ├── MyTreeGraphView.h │ │ ├── MyLeafView.h │ │ ├── MyLeafView.m │ │ └── MyTreeGraphView.m │ ├── Controller │ │ ├── PSHTreeGraphAppDelegate.h │ │ ├── PSHTreeGraphViewController.h │ │ ├── PSHTreeGraphAppDelegate.m │ │ └── PSHTreeGraphViewController.m │ └── Model │ │ └── ObjCClass │ │ ├── ObjCClassWrapper.h │ │ └── ObjCClassWrapper.m ├── Interface │ ├── MainWindow.xib │ ├── PSHTreeGraphViewController.xib │ └── ObjCClassTreeNodeView.xib └── PSHTreeGraph.xcodeproj │ ├── xcshareddata │ └── xcschemes │ │ └── PSHTreeGraph.xcscheme │ └── project.pbxproj ├── .travis.yml ├── .gitignore ├── PSTreeGraphView ├── PSTreeGraphDelegate.h ├── PSBaseBranchView.h ├── PSTreeGraphModelNode.h ├── PSBaseLeafView.h ├── PSBaseTreeGraphView_Internal.h ├── PSBaseSubtreeView.h ├── PSBaseLeafView.m ├── PSBaseBranchView.m ├── PSBaseTreeGraphView.h ├── PSBaseSubtreeView.m └── PSBaseTreeGraphView.m └── README.md /vertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epreston/PSTreeGraph/HEAD/vertical.png -------------------------------------------------------------------------------- /horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epreston/PSTreeGraph/HEAD/horizontal.png -------------------------------------------------------------------------------- /Unit Tests/PSTTreeGraph/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Unit Tests/PSTTreeGraphTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /Example 1/Graphics/GObject.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epreston/PSTreeGraph/HEAD/Example 1/Graphics/GObject.png -------------------------------------------------------------------------------- /Example 1/Graphics/Icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epreston/PSTreeGraph/HEAD/Example 1/Graphics/Icon-72.png -------------------------------------------------------------------------------- /Example 1/Graphics/TreeViewDirectLinesButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epreston/PSTreeGraph/HEAD/Example 1/Graphics/TreeViewDirectLinesButton.png -------------------------------------------------------------------------------- /Example 1/Graphics/TreeViewOrthogonalLinesButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epreston/PSTreeGraph/HEAD/Example 1/Graphics/TreeViewOrthogonalLinesButton.png -------------------------------------------------------------------------------- /Example 1/Graphics/TreeViewSubtreeCollapsedButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epreston/PSTreeGraph/HEAD/Example 1/Graphics/TreeViewSubtreeCollapsedButton.png -------------------------------------------------------------------------------- /Example 1/Graphics/TreeViewSubtreeExpandedButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/epreston/PSTreeGraph/HEAD/Example 1/Graphics/TreeViewSubtreeExpandedButton.png -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | xcode_project: PSHTreeGraph.xcodeproj 3 | xcode_scheme: PSHTreeGraph 4 | xcode_sdk: iphonesimulator 5 | 6 | before_install: 7 | - git submodule update --init --recursive 8 | - cd Example\ 1/ 9 | 10 | # whitelist 11 | branches: 12 | only: 13 | - master 14 | 15 | -------------------------------------------------------------------------------- /Unit Tests/PSTTreeGraphTests/GraphTests.h: -------------------------------------------------------------------------------- 1 | // 2 | // GraphTests.h 3 | // PSTTreeGraphTests 4 | // 5 | // Created by Ed Preston on 26/08/11. 6 | // Copyright 2011 Preston Software. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface GraphTests : XCTestCase 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Unit Tests/PSTTreeGraphTests/SubTreeTests.h: -------------------------------------------------------------------------------- 1 | // 2 | // SubTreeTests.h 3 | // PSTTreeGraphTests 4 | // 5 | // Created by Ed Preston on 26/08/11. 6 | // Copyright 2011 Preston Software. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SubTreeTests : XCTestCase 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Unit Tests/PSTTreeGraph/PSTTreeGraphViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // PSTTreeGraphViewController.h 3 | // PSTTreeGraph 4 | // 5 | // Created by Ed Preston on 26/08/11. 6 | // Copyright 2011 Preston Software. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface PSTTreeGraphViewController : UIViewController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Unit Tests/PSTTreeGraphTests/LeafTests.h: -------------------------------------------------------------------------------- 1 | // 2 | // LeafTests.h 3 | // PSTTreeGraphTests 4 | // 5 | // Created by Ed Preston on 26/08/11. 6 | // Copyright 2011 Preston Software. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "PSBaseLeafView.h" 12 | 13 | @interface LeafTests : XCTestCase 14 | { 15 | PSBaseLeafView* aLeaf; 16 | } 17 | @end 18 | -------------------------------------------------------------------------------- /Example 1/Target/PSHTreeGraph_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the projects which reference it. 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_6_0 8 | #warning "This project uses features only available in iOS SDK 6.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /Unit Tests/PSTTreeGraphTests/BranchTests.h: -------------------------------------------------------------------------------- 1 | // 2 | // BranchTests.h 3 | // PSTTreeGraphTests 4 | // 5 | // Created by Ed Preston on 26/08/11. 6 | // Copyright 2011 Preston Software. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "PSBaseBranchView.h" 12 | 13 | @interface BranchTests : XCTestCase 14 | { 15 | PSBaseBranchView* aBranch; 16 | } 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Unit Tests/PSTTreeGraph/PSTTreeGraph-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'PSTTreeGraph' target in the 'PSTTreeGraph' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_3_0 8 | #warning "This project uses features only available in iPhone SDK 3.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /Example 1/Classes/View/MyTreeGraphView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MyTreeGraphView.h 3 | // PSHTreeGraph - Example 1 4 | // 5 | // Created by Ed Preston on 7/25/10. 6 | // Copyright 2010 Preston Software. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | 12 | #import "PSBaseTreeGraphView.h" 13 | 14 | 15 | @interface MyTreeGraphView : PSBaseTreeGraphView 16 | 17 | // TODO: Place project specific code, extentions here. 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Example 1/Target/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // PSHTreeGraph 4 | // 5 | // Created by Ed Preston on 7/25/10. 6 | // Copyright Preston Software 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "PSHTreeGraphAppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([PSHTreeGraphAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Unit Tests/PSTTreeGraph/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // PSTTreeGraph 4 | // 5 | // Created by Ed Preston on 26/08/11. 6 | // Copyright 2011 Preston Software. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "PSTTreeGraphAppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([PSTTreeGraphAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Example 1/Classes/View/MyLeafView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MyLeafView.h 3 | // PSHTreeGraph - Example 1 4 | // 5 | // Created by Ed Preston on 7/26/10. 6 | // Copyright 2010 Preston Software. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | 12 | #import "PSBaseLeafView.h" 13 | 14 | 15 | @interface MyLeafView : PSBaseLeafView 16 | 17 | @property (nonatomic, weak) IBOutlet UIButton *expandButton; 18 | @property (nonatomic, weak) IBOutlet UILabel *titleLabel; 19 | @property (nonatomic, weak) IBOutlet UILabel *detailLabel; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /Unit Tests/PSTTreeGraph/PSTTreeGraphAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // PSTTreeGraphAppDelegate.h 3 | // PSTTreeGraph 4 | // 5 | // Created by Ed Preston on 26/08/11. 6 | // Copyright 2011 Preston Software. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class PSTTreeGraphViewController; 12 | 13 | @interface PSTTreeGraphAppDelegate : NSObject 14 | 15 | @property (nonatomic, retain) IBOutlet UIWindow *window; 16 | @property (nonatomic, retain) IBOutlet PSTTreeGraphViewController *viewController; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Example 1/Classes/Controller/PSHTreeGraphAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // PSHTreeGraphAppDelegate.h 3 | // PSHTreeGraph - Example 1 4 | // 5 | // Created by Ed Preston on 7/25/10. 6 | // Copyright Preston Software 2010. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | 12 | @class PSHTreeGraphViewController; 13 | 14 | @interface PSHTreeGraphAppDelegate : UIResponder 15 | 16 | @property (nonatomic, strong) IBOutlet UIWindow *window; 17 | @property (nonatomic, strong) IBOutlet PSHTreeGraphViewController *viewController; 18 | 19 | @end 20 | 21 | -------------------------------------------------------------------------------- /Unit Tests/PSTTreeGraphTests/GraphTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // GraphTests.m 3 | // PSTTreeGraphTests 4 | // 5 | // Created by Ed Preston on 26/08/11. 6 | // Copyright 2011 Preston Software. All rights reserved. 7 | // 8 | 9 | #import "GraphTests.h" 10 | 11 | @implementation GraphTests 12 | 13 | - (void)setUp 14 | { 15 | [super setUp]; 16 | 17 | // Set-up code here. 18 | } 19 | 20 | - (void)tearDown 21 | { 22 | // Tear-down code here. 23 | 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample 28 | { 29 | // STFail(@"Unit tests are not implemented yet in PSTTreeGraphTests"); 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /Unit Tests/PSTTreeGraphTests/SubTreeTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SubTreeTests.m 3 | // PSTTreeGraphTests 4 | // 5 | // Created by Ed Preston on 26/08/11. 6 | // Copyright 2011 Preston Software. All rights reserved. 7 | // 8 | 9 | #import "SubTreeTests.h" 10 | 11 | @implementation SubTreeTests 12 | 13 | - (void)setUp 14 | { 15 | [super setUp]; 16 | 17 | // Set-up code here. 18 | } 19 | 20 | - (void)tearDown 21 | { 22 | // Tear-down code here. 23 | 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample 28 | { 29 | // STFail(@"Unit tests are not implemented yet in PSTTreeGraphTests"); 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX Specific System Files 2 | .DS_Store 3 | profile 4 | *.swp 5 | ehthumbs.db 6 | Thumbs.db 7 | 8 | # Backup files 9 | *~.nib 10 | 11 | # Generated Docs 12 | Documentation/* 13 | 14 | # Xcode Specific Files 15 | build/* 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | *.xcworkspace 25 | !default.xcworkspace 26 | xcuserdata 27 | *.moved-aside 28 | 29 | # Textmate - if you build your xcode projects with it 30 | *.tm_build_errors 31 | 32 | # old skool 33 | .svn 34 | 35 | #new skewl 36 | .hgignore 37 | .hg 38 | -------------------------------------------------------------------------------- /Example 1/Classes/Controller/PSHTreeGraphViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // PSHTreeGraphViewController.h 3 | // PSHTreeGraph - Example 1 4 | // 5 | // Created by Ed Preston on 7/25/10. 6 | // Copyright Preston Software 2010. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | #import "PSTreeGraphDelegate.h" 12 | 13 | 14 | @class PSBaseTreeGraphView; 15 | 16 | 17 | @interface PSHTreeGraphViewController : UIViewController 18 | 19 | // The TreeGraph 20 | @property(nonatomic, weak) IBOutlet PSBaseTreeGraphView *treeGraphView; 21 | 22 | // The name of the root class that the TreeGraph is currently showing. 23 | @property(nonatomic, copy) NSString *rootClassName; 24 | 25 | @end 26 | 27 | -------------------------------------------------------------------------------- /Unit Tests/PSTTreeGraph/PSTTreeGraphAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // PSTTreeGraphAppDelegate.m 3 | // PSTTreeGraph 4 | // 5 | // Created by Ed Preston on 26/08/11. 6 | // Copyright 2011 Preston Software. All rights reserved. 7 | // 8 | 9 | #import "PSTTreeGraphAppDelegate.h" 10 | 11 | #import "PSTTreeGraphViewController.h" 12 | 13 | @implementation PSTTreeGraphAppDelegate 14 | 15 | 16 | - (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 17 | { 18 | // Override point for customization after application launch. 19 | [_window setRootViewController:_viewController]; 20 | [_window addSubview:_viewController.view]; 21 | [_window makeKeyAndVisible]; 22 | 23 | return YES; 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Unit Tests/PSTTreeGraphTests/BranchTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // BranchTests.m 3 | // PSTTreeGraphTests 4 | // 5 | // Created by Ed Preston on 26/08/11. 6 | // Copyright 2011 Preston Software. All rights reserved. 7 | // 8 | 9 | #import "BranchTests.h" 10 | 11 | @implementation BranchTests 12 | 13 | - (void)setUp 14 | { 15 | [super setUp]; 16 | 17 | // Set-up code here. 18 | 19 | aBranch = [[PSBaseBranchView alloc] initWithFrame:CGRectZero]; 20 | XCTAssertNotNil(aBranch, @"Couldn't create branch view."); 21 | 22 | } 23 | 24 | - (void)tearDown 25 | { 26 | // Tear-down code here. 27 | 28 | [super tearDown]; 29 | } 30 | 31 | - (void)testExample 32 | { 33 | // STFail(@"Unit tests are not implemented yet in PSTTreeGraphTests"); 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /PSTreeGraphView/PSTreeGraphDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // PSTreeGraphDelegate.h 3 | // PSTreeGraphView 4 | // 5 | // Created by Ed Preston on 9/08/12. 6 | // Copyright (c) 2012 Preston Software. All rights reserved. 7 | // 8 | // 9 | // This is a port of the sample code from Max OS X to iOS (iPad). 10 | // 11 | // WWDC 2010 Session 141, “Crafting Custom Cocoa Views” 12 | // 13 | 14 | 15 | #import 16 | 17 | // Forward declaration of Model Node 18 | 19 | @protocol PSTreeGraphModelNode; 20 | 21 | 22 | @protocol PSTreeGraphDelegate 23 | 24 | @required 25 | 26 | /// The delegate will configure the nodeView with the modelNode provided. 27 | 28 | - (void) configureNodeView:(UIView *)nodeView withModelNode:(id )modelNode; 29 | 30 | @end -------------------------------------------------------------------------------- /Unit Tests/PSTTreeGraphTests/PSTTreeGraphTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /Example 1/Classes/Controller/PSHTreeGraphAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // PSHTreeGraphAppDelegate.m 3 | // PSHTreeGraph - Example 1 4 | // 5 | // Created by Ed Preston on 7/25/10. 6 | // Copyright Preston Software 2010. All rights reserved. 7 | // 8 | 9 | 10 | #import "PSHTreeGraphAppDelegate.h" 11 | #import "PSHTreeGraphViewController.h" 12 | 13 | 14 | @implementation PSHTreeGraphAppDelegate 15 | 16 | 17 | #pragma mark - Application Lifecycle 18 | 19 | - (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 20 | { 21 | // Override point for customization after application launch. 22 | _window.rootViewController = _viewController; 23 | [_window addSubview:_viewController.view]; 24 | [_window makeKeyAndVisible]; 25 | 26 | return YES; 27 | } 28 | 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /Example 1/Classes/View/MyLeafView.m: -------------------------------------------------------------------------------- 1 | // 2 | // MyLeafView.m 3 | // PSHTreeGraph - Example 1 4 | // 5 | // Created by Ed Preston on 7/26/10. 6 | // Copyright 2015 Preston Software. All rights reserved. 7 | // 8 | 9 | 10 | #import "MyLeafView.h" 11 | 12 | 13 | 14 | @implementation MyLeafView 15 | 16 | 17 | #pragma mark - NSCoding 18 | 19 | - (instancetype) initWithCoder:(NSCoder *)decoder 20 | { 21 | self = [super initWithCoder:decoder]; 22 | if (self) { 23 | 24 | // Initialization code, leaf views are always loaded from the corresponding XIB. 25 | // Be sure to set the view class to your subclass in interface builder. 26 | 27 | // Example: Inverse the color scheme 28 | 29 | // self.fillColor = [UIColor yellowColor]; 30 | // self.selectionColor = [UIColor orangeColor]; 31 | 32 | } 33 | return self; 34 | } 35 | 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /PSTreeGraphView/PSBaseBranchView.h: -------------------------------------------------------------------------------- 1 | // 2 | // PSBaseBranchView.h 3 | // PSTreeGraphView 4 | // 5 | // Created by Ed Preston on 7/25/10. 6 | // Copyright 2010 Preston Software. All rights reserved. 7 | // 8 | // 9 | // This is a port of the sample code from Max OS X to iOS (iPad). 10 | // 11 | // WWDC 2010 Session 141, “Crafting Custom Cocoa Views” 12 | // 13 | 14 | 15 | #import 16 | 17 | @class PSBaseTreeGraphView; 18 | 19 | /// Each SubtreeView has a BranchView subview that draws the connecting lines 20 | /// between its root node and its child subtrees. 21 | 22 | @interface PSBaseBranchView : UIView 23 | 24 | /// @return Link to the enclosing TreeGraph. 25 | /// 26 | /// @note The getter for this is a convenience method that ascends the view tree 27 | /// until it encounters a TreeGraph. 28 | 29 | @property (weak, nonatomic, readonly) PSBaseTreeGraphView *enclosingTreeGraph; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Example 1/Classes/View/MyTreeGraphView.m: -------------------------------------------------------------------------------- 1 | // 2 | // MyTreeGraphView.m 3 | // PSHTreeGraph - Example 1 4 | // 5 | // Created by Ed Preston on 7/25/10. 6 | // Copyright 2015 Preston Software. All rights reserved. 7 | // 8 | 9 | 10 | #import "MyTreeGraphView.h" 11 | 12 | 13 | @implementation MyTreeGraphView 14 | 15 | 16 | #pragma mark - UIView 17 | 18 | - (instancetype) initWithFrame:(CGRect)frame 19 | { 20 | if ((self = [super initWithFrame:frame])) { 21 | 22 | // Initialization code when created dynamicly 23 | 24 | } 25 | return self; 26 | } 27 | 28 | 29 | #pragma mark - NSCoding 30 | 31 | - (instancetype) initWithCoder:(NSCoder *)decoder 32 | { 33 | self = [super initWithCoder:decoder]; 34 | if (self) { 35 | 36 | // Initialization code when loaded from XIB (this example) 37 | 38 | // Example: Set a larger content margin than default. 39 | 40 | // self.contentMargin = 60.0; 41 | 42 | } 43 | return self; 44 | } 45 | 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /PSTreeGraphView/PSTreeGraphModelNode.h: -------------------------------------------------------------------------------- 1 | // 2 | // PSTreeGraphModelNode.h 3 | // PSTreeGraphView 4 | // 5 | // Created by Ed Preston on 7/25/10. 6 | // Copyright 2010 Preston Software. All rights reserved. 7 | // 8 | // 9 | // This is a port of the sample code from Max OS X to iOS (iPad). 10 | // 11 | // WWDC 2010 Session 141, “Crafting Custom Cocoa Views” 12 | // 13 | 14 | 15 | #import 16 | 17 | /// The model nodes used with a TreeGraph are required to conform to the this protocol, 18 | /// which enables the TreeGraph to navigate the model tree to find related nodes. 19 | 20 | @protocol PSTreeGraphModelNode 21 | 22 | @required 23 | 24 | /// @return The model node's parent node, or nil if it doesn't have a parent node. 25 | 26 | - (id )parentModelNode; 27 | 28 | /// @return The model node's child nodes. 29 | /// 30 | /// @note If the node has no children, this should return an empty array 31 | /// ([NSArray array]), not nil. 32 | 33 | - (NSArray *) childModelNodes; 34 | 35 | @end -------------------------------------------------------------------------------- /Unit Tests/PSTTreeGraphTests/LeafTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // LeafTests.m 3 | // PSTTreeGraphTests 4 | // 5 | // Created by Ed Preston on 26/08/11. 6 | // Copyright 2011 Preston Software. All rights reserved. 7 | // 8 | 9 | #import "LeafTests.h" 10 | 11 | @implementation LeafTests 12 | 13 | - (void)setUp 14 | { 15 | [super setUp]; 16 | 17 | // Set-up code here. 18 | 19 | 20 | aLeaf = [[PSBaseLeafView alloc] initWithFrame:CGRectZero]; 21 | XCTAssertNotNil(aLeaf, @"Couldn't create leaf view."); 22 | 23 | 24 | } 25 | 26 | - (void)tearDown 27 | { 28 | // Tear-down code here. 29 | 30 | [super tearDown]; 31 | } 32 | 33 | - (void)testSelectionState 34 | { 35 | XCTAssertFalse(aLeaf.showingSelected, @"Leaf nodes should not be selected by default."); 36 | 37 | aLeaf.showingSelected = YES; 38 | XCTAssertTrue(aLeaf.showingSelected, @"showingSelected property assignment failed."); 39 | 40 | aLeaf.showingSelected = NO; 41 | XCTAssertFalse(aLeaf.showingSelected, @"showingSelected property assignment failed."); 42 | } 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /Unit Tests/PSTTreeGraph/PSTTreeGraphViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // PSTTreeGraphViewController.m 3 | // PSTTreeGraph 4 | // 5 | // Created by Ed Preston on 26/08/11. 6 | // Copyright 2011 Preston Software. All rights reserved. 7 | // 8 | 9 | #import "PSTTreeGraphViewController.h" 10 | 11 | @implementation PSTTreeGraphViewController 12 | 13 | 14 | #pragma mark - View lifecycle 15 | 16 | /* 17 | // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 18 | - (void)viewDidLoad 19 | { 20 | [super viewDidLoad]; 21 | } 22 | */ 23 | 24 | #pragma mark - View Creation and Initializer 25 | 26 | - (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 27 | { 28 | // Return YES for supported orientations 29 | return YES; 30 | } 31 | 32 | 33 | #pragma mark - Resouce Management 34 | 35 | - (void) didReceiveMemoryWarning 36 | { 37 | // Releases the view if it doesn't have a superview. 38 | [super didReceiveMemoryWarning]; 39 | 40 | // Release any cached data, images, etc that aren't in use. 41 | } 42 | 43 | - (void) viewDidUnload 44 | { 45 | // Depricated in iOS 6.0 - This method is never called. 46 | 47 | [super viewDidUnload]; 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Unit Tests/PSTTreeGraph/en.lproj/PSTTreeGraphViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Unit Tests/PSTTreeGraph/PSTTreeGraph-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | $(PRODUCT_BUNDLE_IDENTIFIER) 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 1.0 27 | LSRequiresIPhoneOS 28 | 29 | NSMainNibFile 30 | MainWindow 31 | UISupportedInterfaceOrientations~ipad 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationPortraitUpsideDown 35 | UIInterfaceOrientationLandscapeLeft 36 | UIInterfaceOrientationLandscapeRight 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /PSTreeGraphView/PSBaseLeafView.h: -------------------------------------------------------------------------------- 1 | // 2 | // PSBaseLeafView.h 3 | // PSTreeGraphView 4 | // 5 | // Created by Ed Preston on 7/25/10. 6 | // Copyright 2010 Preston Software. All rights reserved. 7 | // 8 | // 9 | // This is a port of the sample code from Max OS X to iOS (iPad). 10 | // 11 | // WWDC 2010 Session 141, “Crafting Custom Cocoa Views” 12 | // 13 | 14 | #import 15 | 16 | 17 | /// Draws background fill and a stroked, optionally rounded rectangular shape. This is meant 18 | /// to be a subclass for project specific node views loaded from a nib file. 19 | 20 | @interface PSBaseLeafView : UIView 21 | 22 | 23 | #pragma mark - Styling 24 | 25 | /// The color of the ContainerView's stroked border. 26 | @property (nonatomic, strong) UIColor *borderColor; 27 | 28 | /// The width of the ContainerView's stroked border. May be zero. 29 | @property (nonatomic, assign) CGFloat borderWidth; 30 | 31 | /// The radius of the ContainerView's rounded corners. May be zero. 32 | @property (nonatomic, assign) CGFloat cornerRadius; 33 | 34 | /// The fill color for the ContainerView's interior. 35 | @property (nonatomic, strong) UIColor *fillColor; 36 | 37 | /// The fill color for the ContainerView's interior when selected. 38 | @property (nonatomic, strong) UIColor *selectionColor; 39 | 40 | 41 | #pragma mark - Selection State 42 | 43 | @property (nonatomic, assign, getter=isShowingSelected) BOOL showingSelected; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /Example 1/Target/PSHTreeGraph-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleDocumentTypes 10 | 11 | CFBundleExecutable 12 | ${EXECUTABLE_NAME} 13 | CFBundleIconFile 14 | graphics/Icon-72.png 15 | CFBundleIconFiles 16 | 17 | Icon-72.png 18 | 19 | CFBundleIdentifier 20 | $(PRODUCT_BUNDLE_IDENTIFIER) 21 | CFBundleInfoDictionaryVersion 22 | 6.0 23 | CFBundleName 24 | ${PRODUCT_NAME} 25 | CFBundlePackageType 26 | APPL 27 | CFBundleShortVersionString 28 | 1.0 29 | CFBundleSignature 30 | ???? 31 | CFBundleURLTypes 32 | 33 | CFBundleVersion 34 | 1.0 35 | LSRequiresIPhoneOS 36 | 37 | NSMainNibFile 38 | MainWindow 39 | UISupportedInterfaceOrientations 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | UTExportedTypeDeclarations 47 | 48 | UTImportedTypeDeclarations 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /Example 1/Classes/Model/ObjCClass/ObjCClassWrapper.h: -------------------------------------------------------------------------------- 1 | 2 | // File: ObjCClassWrapper.h 3 | // Abstract: ObjCClassWrapper Interface 4 | // Version: 1.1 5 | // 6 | // Based largely on Apple TreeView's example. 7 | 8 | 9 | #import 10 | #import "PSTreeGraphModelNode.h" 11 | 12 | 13 | /// Wraps an Objective-C Class in an NSObject, that we can conveninently query to find 14 | /// related classes (superclass and subclasses) and the instance size. Conforms to 15 | /// the PSTreeGraphModelNode protocol, so that we can use these as model nodes with a TreeGraph. 16 | 17 | @interface ObjCClassWrapper : NSObject 18 | 19 | 20 | #pragma mark - Creating Instances 21 | 22 | /// Returns an ObjCClassWrapper for the given Objective-C class. ObjCClassWrapper maintains 23 | /// a set of unique instances, so this will always return the same ObjCClassWrapper for a given Class. 24 | 25 | + (ObjCClassWrapper *) wrapperForClass:(Class)aClass; 26 | 27 | 28 | /// Returns an ObjCClassWrapper for the given Objective-C class, by looking the Class up by 29 | /// name and then invoking +wrapperForClass: 30 | 31 | + (ObjCClassWrapper *) wrapperForClassNamed:(NSString *)aClassName; 32 | 33 | 34 | #pragma mark - Property Accessors 35 | 36 | /// The wrappedClass' name (e.g. @"UIControl" or @"CALayer" or "CAAnimation") 37 | 38 | @property (weak, nonatomic, readonly) NSString *name; 39 | 40 | 41 | /// An ObjCClassWrapper representing the wrappedClass' superclass. 42 | 43 | @property (weak, nonatomic, readonly) ObjCClassWrapper *superclassWrapper; 44 | 45 | 46 | /// An array of ObjCClassWrappers representing the wrappedClass' subclasses. 47 | /// (For convenience, the subclasses are sorted by name.) 48 | 49 | @property (weak, nonatomic, readonly) NSArray *subclasses; 50 | 51 | 52 | /// The wrappedClass' intrinsic instance size (which doesn't include external/auxiliary storage). 53 | 54 | @property (nonatomic, readonly) size_t wrappedClassInstanceSize; 55 | 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /Unit Tests/PSTTreeGraph/en.lproj/MainWindow.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Example 1/Interface/MainWindow.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Example 1/Interface/PSHTreeGraphViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /PSTreeGraphView/PSBaseTreeGraphView_Internal.h: -------------------------------------------------------------------------------- 1 | // 2 | // PSBaseTreeGraphView_Internal.h 3 | // PSTreeGraphView 4 | // 5 | // Created by Ed Preston on 7/25/10. 6 | // Copyright 2010 Preston Software. All rights reserved. 7 | // 8 | // 9 | // This is a port of the sample code from Max OS X to iOS (iPad). 10 | // 11 | // WWDC 2010 Session 141, “Crafting Custom Cocoa Views” 12 | // 13 | 14 | 15 | #import 16 | 17 | #import "PSTreeGraphModelNode.h" 18 | 19 | @class PSBaseSubtreeView; 20 | 21 | // This category declares "Internal" methods that make up part of TreeGraph's 22 | // implementation, but aren't intended to be used as TreeGraph API. 23 | 24 | @interface PSBaseTreeGraphView (Internal) 25 | 26 | 27 | #pragma mark - ModelNode -> SubtreeView Relationship Management 28 | 29 | // Returns the SubtreeView that corresponds to the specified modelNode, as 30 | // tracked by the TreeGraph's modelNodeToSubtreeViewMapTable. 31 | 32 | - (PSBaseSubtreeView *) subtreeViewForModelNode:(id)modelNode; 33 | 34 | // Associates the specified subtreeView with the given modelNode in the TreeGraph's 35 | // modelNodeToSubtreeViewMapTable, so that it can later be looked up using -subtreeViewForModelNode: 36 | 37 | - (void) setSubtreeView:(PSBaseSubtreeView *)subtreeView 38 | forModelNode:(id)modelNode; 39 | 40 | 41 | #pragma mark - Model Tree Navigation 42 | 43 | // Returns YES if modelNode is a descendant of possibleAncestor, NO if not. 44 | // 45 | // Neither modelNode or possibleAncestor should be nil. 46 | 47 | - (BOOL) modelNode:(id )modelNode 48 | isDescendantOf:(id )possibleAncestor; 49 | 50 | // Returns YES if modelNode is the TreeGraph's assigned modelRoot, or a descendant of modelRoot. 51 | // 52 | // Returns NO if not. TreeGraph uses this determination to avoid traversing nodes above its 53 | // assigned modelRoot (if there are any). 54 | // 55 | // modelNode should not be nil. 56 | 57 | - (BOOL) modelNodeIsInAssignedTree:(id )modelNode; 58 | 59 | // Returns the sibling at the given offset relative to the given modelNode. 60 | // (e.g. relativeIndex == -1 requests the previous sibling. relativeIndex == +1 requests the next sibling.) 61 | // 62 | // Returns nil if the modelNode has no sibling at the specified relativeIndex (resultant index out of bounds). 63 | // 64 | // This method won't go above the subtree defined by the TreeGraph's modelRoot. 65 | // (That is: If the given modelNode is the TreeGraph's modelRoot, this method returns nil, even if 66 | // the requested sibling exists.) 67 | // 68 | // Checks modelNode is nil, or if modelNode is not within the subtree assigned to the TreeGraph. 69 | // 70 | 71 | - (id) siblingOfModelNode:(id )modelNode 72 | atRelativeIndex:(NSInteger)relativeIndex; 73 | 74 | 75 | #pragma mark - Node View Nib Caching 76 | 77 | //* NOT SUPPORTED ON iOS 3.2* 78 | 79 | // Returns an UINib instance created from the TreeGraphs's nodeViewNibName. 80 | // We automatically let go of the cachedNodeViewNib when this property changes. 81 | // Keeping a cached UINib instance helps speed up repeated instantiation of node views. 82 | 83 | @property (nonatomic, retain) UINib *cachedNodeViewNib; 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /Example 1/PSHTreeGraph.xcodeproj/xcshareddata/xcschemes/PSHTreeGraph.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Example 1/Classes/Controller/PSHTreeGraphViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // PSHTreeGraphViewController.m 3 | // PSHTreeGraph - Example 1 4 | // 5 | // Created by Ed Preston on 7/25/10. 6 | // Copyright Preston Software 2010. All rights reserved. 7 | // 8 | 9 | 10 | #import "PSHTreeGraphViewController.h" 11 | 12 | #import "PSBaseTreeGraphView.h" 13 | #import "MyLeafView.h" 14 | 15 | #import "ObjCClassWrapper.h" 16 | 17 | 18 | 19 | @implementation PSHTreeGraphViewController 20 | 21 | 22 | #pragma mark - Property Accessors 23 | 24 | - (void) setRootClassName:(NSString *)newRootClassName 25 | { 26 | NSParameterAssert(newRootClassName != nil); 27 | 28 | if (![_rootClassName isEqualToString:newRootClassName]) { 29 | _rootClassName = [newRootClassName copy]; 30 | 31 | // Set the orientation of the Graph 32 | _treeGraphView.treeGraphOrientation = PSTreeGraphOrientationStyleHorizontal; 33 | 34 | // See the enum for more options 35 | // _treeGraphView.treeGraphOrientation = PSTreeGraphOrientationStyleHorizontalFlipped; 36 | 37 | // Get an ObjCClassWrapper for the named Objective-C Class, and set it as the TreeGraph's root. 38 | _treeGraphView.modelRoot = [ObjCClassWrapper wrapperForClassNamed:_rootClassName]; 39 | } 40 | } 41 | 42 | 43 | #pragma mark - View Creation and Initializer 44 | 45 | // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 46 | - (void) viewDidLoad 47 | { 48 | [super viewDidLoad]; 49 | 50 | // Set the delegate to self. 51 | (self.treeGraphView).delegate = self; 52 | 53 | // Specify a .nib file for the TreeGraph to load each time it needs to create a new node view. 54 | (self.treeGraphView).nodeViewNibName = @"ObjCClassTreeNodeView"; 55 | 56 | // Specify a starting root class to inspect on launch. 57 | 58 | self.rootClassName = @"UIControl"; 59 | 60 | // The system includes some other abstract base classes that are interesting: 61 | // [self setRootClassName:@"CAAnimation"]; 62 | 63 | } 64 | 65 | // Override to allow orientations other than the default portrait orientation. 66 | - (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 67 | { 68 | return YES; 69 | } 70 | 71 | - (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 72 | duration:(NSTimeInterval)duration 73 | { 74 | // Keep the view in sync 75 | [self.treeGraphView parentClipViewDidResize:nil]; 76 | } 77 | 78 | 79 | #pragma mark - TreeGraph Delegate 80 | 81 | -(void) configureNodeView:(UIView *)nodeView 82 | withModelNode:(id )modelNode 83 | { 84 | NSParameterAssert(nodeView != nil); 85 | NSParameterAssert(modelNode != nil); 86 | 87 | // NOT FLEXIBLE: treat it like a model node instead of the interface. 88 | ObjCClassWrapper *objectWrapper = (ObjCClassWrapper *)modelNode; 89 | MyLeafView *leafView = (MyLeafView *)nodeView; 90 | 91 | // button 92 | if ( [objectWrapper childModelNodes].count == 0 ) { 93 | [leafView.expandButton setHidden:YES]; 94 | } 95 | 96 | // labels 97 | leafView.titleLabel.text = objectWrapper.name; 98 | leafView.detailLabel.text = [NSString stringWithFormat:@"%zd bytes", 99 | objectWrapper.wrappedClassInstanceSize]; 100 | 101 | } 102 | 103 | 104 | #pragma mark - Resouce Management 105 | 106 | - (void) didReceiveMemoryWarning 107 | { 108 | // Releases the view if it doesn't have a superview. 109 | [super didReceiveMemoryWarning]; 110 | 111 | // Release any cached data, images, etc that aren't in use. 112 | } 113 | 114 | - (void) viewDidUnload 115 | { 116 | // Depricated in iOS 6.0 - This method is never called. 117 | 118 | [super viewDidUnload]; 119 | } 120 | 121 | 122 | @end 123 | -------------------------------------------------------------------------------- /Example 1/Classes/Model/ObjCClass/ObjCClassWrapper.m: -------------------------------------------------------------------------------- 1 | 2 | // File: ObjCClassWrapper.m 3 | // Abstract: ObjCClassWrapper Implementation 4 | // Version: 1.1 5 | // 6 | // Based largely on Apple TreeView's example. 7 | 8 | 9 | #import "ObjCClassWrapper.h" 10 | #import 11 | 12 | 13 | // Keeps track of the ObjCClassWrapper instances we create. We create one unique 14 | // ObjCClassWrapper for each Objective-C "Class" we're asked to wrap. 15 | 16 | static NSMutableDictionary *classToWrapperMapTable = nil; 17 | 18 | 19 | // Compares two ObjCClassWrappers by name, and returns an NSComparisonResult. 20 | 21 | static NSInteger CompareClassNames(id classA, id classB, void* context) 22 | { 23 | return [[classA description] compare:[classB description]]; 24 | } 25 | 26 | 27 | @interface ObjCClassWrapper () 28 | { 29 | 30 | @private 31 | Class wrappedClass; 32 | NSMutableArray *subclassesCache; 33 | } 34 | 35 | @end 36 | 37 | 38 | @implementation ObjCClassWrapper 39 | 40 | 41 | #pragma mark - NSCopying 42 | 43 | - (id) copyWithZone:(NSZone *)zone 44 | { 45 | return self; 46 | } 47 | 48 | 49 | #pragma mark - Creating Instances 50 | 51 | - (instancetype) initWithWrappedClass:(Class)aClass 52 | { 53 | self = [super init]; 54 | if (self) { 55 | if (aClass != Nil) { 56 | wrappedClass = aClass; 57 | if (classToWrapperMapTable == nil) { 58 | classToWrapperMapTable = [NSMutableDictionary dictionaryWithCapacity:16]; 59 | } 60 | classToWrapperMapTable[(id)wrappedClass] = self; 61 | } else { 62 | return nil; 63 | } 64 | } 65 | return self; 66 | } 67 | 68 | + (ObjCClassWrapper *) wrapperForClass:(Class)aClass 69 | { 70 | ObjCClassWrapper *wrapper = classToWrapperMapTable[aClass]; 71 | if (wrapper == nil) { 72 | wrapper = [[self alloc] initWithWrappedClass:aClass]; 73 | } 74 | return wrapper; 75 | } 76 | 77 | + (ObjCClassWrapper *) wrapperForClassNamed:(NSString *)aClassName 78 | { 79 | return [self wrapperForClass:NSClassFromString(aClassName)]; 80 | } 81 | 82 | 83 | #pragma mark - Property Accessors 84 | 85 | - (NSString *) name 86 | { 87 | return NSStringFromClass(wrappedClass); 88 | } 89 | 90 | - (NSString *) description 91 | { 92 | return self.name; 93 | } 94 | 95 | - (size_t) wrappedClassInstanceSize 96 | { 97 | return class_getInstanceSize(wrappedClass); 98 | } 99 | 100 | - (ObjCClassWrapper *) superclassWrapper 101 | { 102 | return [[self class] wrapperForClass:class_getSuperclass(wrappedClass)]; 103 | } 104 | 105 | - (NSArray *) subclasses 106 | { 107 | // If we haven't built our array of subclasses yet, do so. 108 | if (subclassesCache == nil) { 109 | 110 | // Iterate over all classes (as described in objc/objc-runtime.h) to find the subclasses of wrappedClass. 111 | int i; 112 | int numClasses = 0; 113 | int newNumClasses = objc_getClassList(NULL, 0); 114 | Class* classes = NULL; 115 | while (numClasses < newNumClasses) { 116 | numClasses = newNumClasses; 117 | classes = (Class*)realloc(classes, sizeof(Class) * numClasses); 118 | newNumClasses = objc_getClassList(classes, numClasses); 119 | } 120 | 121 | // Make an array of ObjCClassWrapper instances to represent the classes. 122 | subclassesCache = [[NSMutableArray alloc] initWithCapacity:numClasses]; 123 | for (i = 0; i < numClasses; i++) { 124 | if (class_getSuperclass(classes[i]) == wrappedClass) { 125 | [subclassesCache addObject:[[self class] wrapperForClass:classes[i]]]; 126 | } 127 | } 128 | free(classes); 129 | 130 | // Sort subclasses by name. 131 | [subclassesCache sortUsingFunction:CompareClassNames context:NULL]; 132 | } 133 | return subclassesCache; 134 | } 135 | 136 | 137 | #pragma mark - TreeGraphModelNode Protocol 138 | 139 | - (id ) parentModelNode 140 | { 141 | return self.superclassWrapper; 142 | } 143 | 144 | - (NSArray *) childModelNodes 145 | { 146 | return self.subclasses; 147 | } 148 | 149 | 150 | @end 151 | -------------------------------------------------------------------------------- /Example 1/Interface/ObjCClassTreeNodeView.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 33 | 40 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PSTreeGraph 2 | 3 | [![Build Status](https://travis-ci.org/epreston/PSTreeGraph.png?branch=master)](https://travis-ci.org/epreston/PSTreeGraph) 4 | 5 | PSTreeGraph is a treegraph view control implementation for Cocoa Touch. 6 | 7 | This is a port of the sample code from Max OS X to iOS (iPad). 8 | WWDC 2010 Session 141, “Crafting Custom Cocoa Views” 9 | 10 | ![](http://farm7.static.flickr.com/6193/6055022105_ab831b2d8e.jpg) 11 | 12 | 13 | # Example Project 14 | 15 | There is an iPad example application to demonstrate the features of PSTreeGraph. 16 | 17 | 18 | # Status 19 | 20 | PSTreeGraph should be considered an viable solution for displaying single parent tree data in an interactive hierarchy. The "ARC" branch contains the automatic reference counting compatible code base. In the very near future, this will be merged with "master", non "ARC" code will be frozen at the 1.0 release. Those looking for a reference counted implementation should look for a "Non ARC 1.0" branch. 21 | 22 | This project follows the [SemVer](http://semver.org/) standard. The API may change in backwards-incompatible ways before the 1.0 release. 23 | 24 | The goal of PSTreeGraph is to build a high-quality UI control designed specifically for the iPad. The inspiration / structure comes from WWDC 2010 Session 141, “Crafting Custom Cocoa Views”, an extremely valuable and informative presentation that has proven to be applicable (see this project) to other platforms. 25 | 26 | 27 | # Getting Started 28 | 29 | See [Wiki](https://github.com/epreston/PSTreeGraph/wiki). 30 | 31 | Useful information can also be found in the issues log. The following discussions might be helpful. If you can't find what you are looking for, start a new topic. 32 | 33 | * [Display hierarchical data from xml or json](https://github.com/epreston/PSTreeGraph/issues/9) 34 | * [Can you select arbitrary nodes?](https://github.com/epreston/PSTreeGraph/issues/5) 35 | * [Customizing the leaf view](https://github.com/epreston/PSTreeGraph/issues/7) 36 | 37 | 38 | # Known Improvements 39 | 40 | See [Milestones](https://github.com/epreston/PSTreeGraph/issues/milestones?with_issues=no). 41 | 42 | There are many places where PSTreeGraph could be improved: 43 | 44 | * Use GCD to load model data asyncronously. This control uses a simple protocol implemented by each node in the data model so the control can walk the tree. This can be loaded asynchronously to avoid blocking the main thread when displaying large graphs. 45 | 46 | * Cache the bezier path used to render lines in each subtree. The bezier path used to render the lines between each node in the graph can be cached to improve performance. 47 | 48 | * Use CATiledLayer to support much larger graphs. Investigate using a CATiledLayer to further reduce drawing and memory usage, support scaling, etc. This feature will make it possible support graphs of unlimited size and scale. Rendering time and resource usage would be constant regardless of the number of nodes in the graph. 49 | 50 | 51 | # Documentation 52 | 53 | You can generate documentation with [doxygen](http://www.doxygen.org). The example project includes a documentation build target to do this within Xcode. For more details, see the [Documentation](https://github.com/epreston/PSTreeGraph/wiki/Documentation) page in this projects wiki. 54 | 55 | ## Contribute 56 | 57 | If you'd like to contribute to PSTreeGraph, start by forking this repository on GitHub: 58 | 59 | http://github.com/epreston/PSTreeGraph 60 | 61 | The best way to get your changes merged back into core is as follows: 62 | 63 | 1. Clone down your fork 64 | 2. Create a thoughtfully named topic branch to contain your change 65 | 3. Hack away 66 | 4. Add tests and make sure everything still passes 67 | 5. If you are adding new functionality, document it in the README 68 | 6. Do not change the version number, I will do that on my end 69 | 7. If necessary, rebase your commits into logical chunks, without errors 70 | 8. Push the branch up to GitHub 71 | 9. Send a pull request to the epreston/PSTreeGraph project. 72 | 73 | Or better still, [donate] (http://epreston.github.com/PSTreeGraph/) via the [project website] (http://epreston.github.com/PSTreeGraph/). 74 | 75 | 76 | # Copyright and License 77 | 78 | Copyright 2012 Preston Software. 79 | 80 | Licensed under the Apache License, Version 2.0 (the "License"); 81 | you may not use this work except in compliance with the License. 82 | You may obtain a copy of the License in the LICENSE file, or at: 83 | 84 | http://www.apache.org/licenses/LICENSE-2.0 85 | 86 | Unless required by applicable law or agreed to in writing, software 87 | distributed under the License is distributed on an "AS IS" BASIS, 88 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 89 | See the License for the specific language governing permissions and 90 | limitations under the License. 91 | 92 | 93 | 94 | 95 | [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/epreston/pstreegraph/trend.png)](https://bitdeli.com/free "Bitdeli Badge") 96 | 97 | -------------------------------------------------------------------------------- /PSTreeGraphView/PSBaseSubtreeView.h: -------------------------------------------------------------------------------- 1 | // 2 | // PSBaseSubtreeView.h 3 | // PSTreeGraphView 4 | // 5 | // Created by Ed Preston on 7/25/10. 6 | // Copyright 2015 Preston Software. All rights reserved. 7 | // 8 | // 9 | // This is a port of the sample code from Max OS X to iOS (iPad). 10 | // 11 | // WWDC 2010 Session 141, “Crafting Custom Cocoa Views” 12 | // 13 | 14 | 15 | #import 16 | 17 | #import "PSTreeGraphModelNode.h" 18 | 19 | 20 | @class PSBaseTreeGraphView; 21 | 22 | 23 | /// A SubtreeView draws nothing itself (unless showsSubtreeFrames is set to YES for 24 | /// the enclosingTreeGraph), but provides a local coordinate frame and grouping mechanism 25 | /// for a graph subtree, and implements subtree layout. 26 | 27 | 28 | @interface PSBaseSubtreeView : UIView 29 | 30 | /// Initializes a SubtreeView with the associated modelNode. This is SubtreeView's designated initializer. 31 | 32 | - (instancetype) initWithModelNode:( id )newModelNode NS_DESIGNATED_INITIALIZER; 33 | 34 | // Don't initialise with these: 35 | - (instancetype) initWithFrame:(CGRect)frame NS_UNAVAILABLE; 36 | - (instancetype) initWithCoder:(NSCoder *)aDecoder NS_UNAVAILABLE; 37 | 38 | 39 | /// The root of the model subtree that this SubtreeView represents. 40 | 41 | @property (nonatomic, strong) id modelNode; 42 | 43 | /// The view that represents the modelNode. Is a subview of SubtreeView, and may itself have descendant views. 44 | 45 | @property (nonatomic, weak) IBOutlet UIView *nodeView; 46 | 47 | /// Link to the enclosing TreeGraph. (The getter for this is a convenience method that ascends 48 | /// the view tree until it encounters a TreeGraph.) 49 | 50 | @property (weak, nonatomic, readonly) PSBaseTreeGraphView *enclosingTreeGraph; 51 | 52 | // Whether the model node represented by this SubtreeView is a leaf node (one without child nodes). This 53 | // can be a useful property to bind user interface state to. In the TreeGraph demo app, for example, 54 | // we've bound the "isHidden" property of subtree expand/collapse buttons to this, so that expand/collapse 55 | // buttons will only be shown for non-leaf nodes. 56 | 57 | @property (nonatomic, readonly, getter=isLeaf) BOOL leaf; 58 | 59 | 60 | #pragma mark - Selection State 61 | 62 | /// Whether the node is part of the TreeGraph's current selection. This can be a useful property to bind user 63 | /// interface state to. 64 | 65 | @property (nonatomic, readonly) BOOL nodeIsSelected; 66 | 67 | 68 | #pragma mark - Layout 69 | 70 | /// Returns YES if this subtree needs relayout. 71 | 72 | @property (nonatomic, assign) BOOL needsGraphLayout; 73 | 74 | /// Recursively marks this subtree, and all of its descendants, as needing relayout. 75 | 76 | - (void) recursiveSetNeedsGraphLayout; 77 | 78 | /// Recursively performs graph layout, if this subtree is marked as needing it. 79 | 80 | - (CGSize) layoutGraphIfNeeded; 81 | 82 | // Flip the treeGraph end for end (or top for bottom) 83 | - (void) flipTreeGraph; 84 | 85 | /// Resizes this subtree's nodeView to the minimum size required to hold its content, and returns the nodeView's 86 | /// new size. (This currently does nothing, and is just stubbed out for future use.) 87 | 88 | - (CGSize) sizeNodeViewToFitContent; 89 | 90 | /// Whether this subtree is currently shown as expanded. If NO, the node's children have been collapsed into it. 91 | 92 | @property (nonatomic, assign, getter=isExpanded) BOOL expanded; 93 | 94 | /// Toggles expansion of this subtree. This can be wired up as the action of a button or other user interface 95 | /// control. 96 | 97 | - (IBAction) toggleExpansion:(id)sender; 98 | 99 | 100 | #pragma mark - Invalidation 101 | 102 | /// Marks all BranchView instances in this subtree as needing display. 103 | 104 | - (void) recursiveSetConnectorsViewsNeedDisplay; 105 | 106 | /// Marks all SubtreeView debug borders as needing display. 107 | 108 | - (void) resursiveSetSubtreeBordersNeedDisplay; 109 | 110 | 111 | #pragma mark - Node Hit-Testing 112 | 113 | /// Returns the visible model node whose nodeView contains the given point "p", where "p" is specified in the 114 | /// SubtreeView's interior (bounds) coordinate space. Returns nil if there is no node under the specified point. 115 | /// When a subtree is collapsed, only its root nodeView is eligible for hit-testing. 116 | 117 | - ( id ) modelNodeAtPoint:(CGPoint)p; 118 | 119 | /// Returns the visible model node that is closest to the specified y coordinate, where "y" is specified in the 120 | /// SubtreeView's interior (bounds) coordinate space. 121 | 122 | - ( id ) modelNodeClosestToY:(CGFloat)y; 123 | 124 | /// Returns the visible model node that is closest to the specified x coordinate, where "x" is specified in the 125 | /// SubtreeView's interior (bounds) coordinate space. 126 | 127 | - ( id ) modelNodeClosestToX:(CGFloat)x; 128 | 129 | 130 | #pragma mark - Debugging 131 | 132 | /// Returns an indented multi-line NSString summary of the displayed tree. Provided as a debugging aid. 133 | 134 | - (NSString *) treeSummaryWithDepth:(NSInteger)depth; 135 | 136 | @end 137 | -------------------------------------------------------------------------------- /PSTreeGraphView/PSBaseLeafView.m: -------------------------------------------------------------------------------- 1 | // 2 | // PSBaseLeafView.m 3 | // PSTreeGraphView 4 | // 5 | // Created by Ed Preston on 7/25/10. 6 | // Copyright 2015 Preston Software. All rights reserved. 7 | // 8 | // 9 | // This is a port of the sample code from Max OS X to iOS (iPad). 10 | // 11 | // WWDC 2010 Session 141, “Crafting Custom Cocoa Views” 12 | // 13 | 14 | #import "PSBaseLeafView.h" 15 | 16 | // for CALayer definition 17 | #import 18 | 19 | 20 | @implementation PSBaseLeafView 21 | 22 | 23 | #pragma mark - Styling 24 | 25 | 26 | - (void) setBorderColor:(UIColor *)color 27 | { 28 | if (_borderColor != color) { 29 | _borderColor = color; 30 | [self updateLayerAppearanceToMatchContainerView]; 31 | } 32 | } 33 | 34 | - (void) setBorderWidth:(CGFloat)width 35 | { 36 | if (_borderWidth != width) { 37 | _borderWidth = width; 38 | [self updateLayerAppearanceToMatchContainerView]; 39 | } 40 | } 41 | 42 | - (void) setCornerRadius:(CGFloat)radius 43 | { 44 | if (_cornerRadius != radius) { 45 | _cornerRadius = radius; 46 | [self updateLayerAppearanceToMatchContainerView]; 47 | } 48 | } 49 | 50 | - (void) setFillColor:(UIColor *)color 51 | { 52 | if (_fillColor != color) { 53 | _fillColor = color; 54 | [self updateLayerAppearanceToMatchContainerView]; 55 | } 56 | } 57 | 58 | - (void) setSelectionColor:(UIColor *)color 59 | { 60 | if (_selectionColor != color) { 61 | _selectionColor = color; 62 | [self updateLayerAppearanceToMatchContainerView]; 63 | } 64 | } 65 | 66 | 67 | #pragma mark - Selection State 68 | 69 | - (void) setShowingSelected:(BOOL)newShowingSelected 70 | { 71 | if (_showingSelected != newShowingSelected) { 72 | _showingSelected = newShowingSelected; 73 | [self updateLayerAppearanceToMatchContainerView]; 74 | } 75 | } 76 | 77 | 78 | #pragma mark - Update Layer (internal) 79 | 80 | - (void) updateLayerAppearanceToMatchContainerView 81 | { 82 | // // Disable implicit animations during these layer property changes, to make them take effect immediately. 83 | 84 | // BOOL actionsWereDisabled = [CATransaction disableActions]; 85 | // [CATransaction setDisableActions:YES]; 86 | 87 | // Apply the ContainerView's appearance properties to its backing layer. 88 | // Important: While UIView metrics are conventionally expressed in points, CALayer metrics are 89 | // expressed in pixels. To produce the correct borderWidth and cornerRadius to apply to the 90 | // layer, we must multiply by the window's userSpaceScaleFactor (which is normally 1.0, but may 91 | // be larger on a higher-resolution display) to yield pixel units. 92 | 93 | // CGFloat scaleFactor = [[self window] userSpaceScaleFactor]; 94 | CGFloat scaleFactor = 1.0f; 95 | 96 | CALayer *layer = self.layer; 97 | 98 | layer.borderWidth = (_borderWidth * scaleFactor); 99 | if (_borderWidth > 0.0f) { 100 | layer.borderColor = _borderColor.CGColor; 101 | } 102 | 103 | layer.cornerRadius = (_cornerRadius * scaleFactor); 104 | 105 | if ( _showingSelected ) { 106 | layer.backgroundColor = self.selectionColor.CGColor ; 107 | } else { 108 | layer.backgroundColor = self.fillColor.CGColor ; 109 | } 110 | 111 | // // Disable implicit animations during these layer property changes 112 | // [CATransaction setDisableActions:actionsWereDisabled]; 113 | } 114 | 115 | 116 | #pragma mark - Initialization (internal) 117 | 118 | - (void) configureDetaults 119 | { 120 | // Initialize ivars directly. As a rule, it's best to avoid invoking accessors from an -init... 121 | // method, since they may wrongly expect the instance to be fully formed. 122 | 123 | _borderColor = [UIColor colorWithRed:1.0 green:0.8 blue:0.4 alpha:1.0]; 124 | _borderWidth = 3.0; 125 | _cornerRadius = 8.0; 126 | _fillColor = [UIColor colorWithRed:1.0 green:0.5 blue:0.0 alpha:1.0]; 127 | _selectionColor = [UIColor colorWithRed:1.0 green:1.0 blue:0.0 alpha:1.0]; 128 | _showingSelected = NO; 129 | } 130 | 131 | 132 | #pragma mark - UIView 133 | 134 | - (instancetype) initWithFrame:(CGRect)newFrame 135 | { 136 | self = [super initWithFrame:newFrame]; 137 | if (self) { 138 | [self configureDetaults]; 139 | [self updateLayerAppearanceToMatchContainerView]; 140 | } 141 | return self; 142 | } 143 | 144 | 145 | #pragma mark - NSCoding 146 | 147 | - (void) encodeWithCoder:(NSCoder *)encoder 148 | { 149 | [super encodeWithCoder:encoder]; 150 | [encoder encodeObject:_borderColor forKey:@"borderColor"]; 151 | [encoder encodeFloat:_borderWidth forKey:@"borderWidth"]; 152 | [encoder encodeFloat:_cornerRadius forKey:@"cornerRadius"]; 153 | [encoder encodeObject:_fillColor forKey:@"fillColor"]; 154 | [encoder encodeObject:_selectionColor forKey:@"selectionColor"]; 155 | [encoder encodeBool:_showingSelected forKey:@"showingSelected"]; 156 | } 157 | 158 | - (instancetype) initWithCoder:(NSCoder *)decoder 159 | { 160 | self = [super initWithCoder:decoder]; 161 | if (self) { 162 | 163 | [self configureDetaults]; 164 | 165 | if ([decoder containsValueForKey:@"borderColor"]) 166 | _borderColor = [decoder decodeObjectForKey:@"borderColor"]; 167 | if ([decoder containsValueForKey:@"borderWidth"]) 168 | _borderWidth = [decoder decodeFloatForKey:@"borderWidth"]; 169 | if ([decoder containsValueForKey:@"cornerRadius"]) 170 | _cornerRadius = [decoder decodeFloatForKey:@"cornerRadius"]; 171 | if ([decoder containsValueForKey:@"fillColor"]) 172 | _fillColor = [decoder decodeObjectForKey:@"fillColor"]; 173 | if ([decoder containsValueForKey:@"selectionColor"]) 174 | _selectionColor = [decoder decodeObjectForKey:@"selectionColor"]; 175 | if ([decoder containsValueForKey:@"showingSelected"]) 176 | _showingSelected = [decoder decodeBoolForKey:@"showingSelected"]; 177 | 178 | [self updateLayerAppearanceToMatchContainerView]; 179 | } 180 | return self; 181 | } 182 | 183 | 184 | @end 185 | -------------------------------------------------------------------------------- /PSTreeGraphView/PSBaseBranchView.m: -------------------------------------------------------------------------------- 1 | // 2 | // PSBaseBranchView.m 3 | // PSTreeGraphView 4 | // 5 | // Created by Ed Preston on 7/25/10. 6 | // Copyright 2010 Preston Software. All rights reserved. 7 | // 8 | // 9 | // This is a port of the sample code from Max OS X to iOS (iPad). 10 | // 11 | // WWDC 2010 Session 141, “Crafting Custom Cocoa Views” 12 | // 13 | 14 | 15 | #import "PSBaseBranchView.h" 16 | #import "PSBaseSubtreeView.h" 17 | #import "PSBaseTreeGraphView.h" 18 | 19 | 20 | @implementation PSBaseBranchView 21 | 22 | 23 | - (PSBaseTreeGraphView *) enclosingTreeGraph 24 | { 25 | UIView *ancestor = self.superview; 26 | while (ancestor) { 27 | if ([ancestor isKindOfClass:[PSBaseTreeGraphView class]]) { 28 | return (PSBaseTreeGraphView *)ancestor; 29 | } 30 | ancestor = ancestor.superview; 31 | } 32 | return nil; 33 | } 34 | 35 | 36 | #pragma mark - Drawing (internal) 37 | 38 | - (UIBezierPath *) directConnectionsPath 39 | { 40 | CGRect bounds = self.bounds; 41 | CGPoint rootPoint = CGPointZero; 42 | 43 | PSTreeGraphOrientationStyle treeDirection = self.enclosingTreeGraph.treeGraphOrientation; 44 | 45 | if (( treeDirection == PSTreeGraphOrientationStyleHorizontal ) || 46 | ( treeDirection == PSTreeGraphOrientationStyleHorizontalFlipped )){ 47 | rootPoint = CGPointMake(CGRectGetMinX(bounds), 48 | CGRectGetMidY(bounds)); 49 | } else { 50 | rootPoint = CGPointMake(CGRectGetMidX(bounds), 51 | CGRectGetMinY(bounds)); 52 | } 53 | 54 | // Create a single bezier path that we'll use to stroke all the lines. 55 | UIBezierPath *path = [UIBezierPath bezierPath]; 56 | 57 | // Add a stroke from rootPoint to each child SubtreeView of our containing SubtreeView. 58 | UIView *subtreeView = self.superview; 59 | if ([subtreeView isKindOfClass:[PSBaseSubtreeView class]]) { 60 | 61 | for (UIView *subview in subtreeView.subviews) { 62 | if ([subview isKindOfClass:[PSBaseSubtreeView class]]) { 63 | CGRect subviewBounds = subview.bounds; 64 | CGPoint targetPoint = CGPointZero; 65 | 66 | if (( treeDirection == PSTreeGraphOrientationStyleHorizontal ) || 67 | ( treeDirection == PSTreeGraphOrientationStyleHorizontalFlipped )){ 68 | targetPoint = [self convertPoint:CGPointMake(CGRectGetMinX(subviewBounds), CGRectGetMidY(subviewBounds)) 69 | fromView:subview]; 70 | } else { 71 | targetPoint = [self convertPoint:CGPointMake(CGRectGetMidX(subviewBounds), CGRectGetMinY(subviewBounds)) 72 | fromView:subview]; 73 | } 74 | 75 | [path moveToPoint:rootPoint]; 76 | [path addLineToPoint:targetPoint]; 77 | } 78 | } 79 | } 80 | 81 | // Return the path. 82 | return path; 83 | } 84 | 85 | - (UIBezierPath *) orthogonalConnectionsPath 86 | { 87 | // Compute the needed adjustment in x and y to align our lines for crisp, exact pixel coverage. 88 | // (We can only do this if the lineWidth is integral, which it usually is.) 89 | // CGFloat adjustment = 0.0; 90 | // CGFloat lineWidth = [[self enclosingTreeGraph] connectingLineWidth]; 91 | // CGSize lineSize = CGSizeMake(lineWidth, lineWidth); 92 | // CGSize lineSizeInPixels = [self convertSizeToBase:lineSize]; 93 | // 94 | // CGFloat halfLineWidthInPixels = 0.5 * lineSizeInPixels.width; 95 | // if (fabs(halfLineWidthInPixels - floor(halfLineWidthInPixels)) > 0.0001) { 96 | // // If line width in pixels is odd, lay our path segments along the centers of pixel rows. 97 | // CGSize adjustmentAsSizeInPixels = CGSizeMake(0.5, 0.5); 98 | // CGSize adjustmentAsSize = [self convertSizeFromBase:adjustmentAsSizeInPixels]; 99 | // 100 | // adjustment = adjustmentAsSize.width; 101 | // } 102 | 103 | CGRect bounds = self.bounds; 104 | // CGPoint basePoint; 105 | 106 | PSTreeGraphOrientationStyle treeDirection = self.enclosingTreeGraph.treeGraphOrientation; 107 | 108 | CGPoint rootPoint = CGPointZero; 109 | if ( treeDirection == PSTreeGraphOrientationStyleHorizontal ) { 110 | // Compute point at right edge of root node, from which its connecting line to the vertical line will emerge. 111 | rootPoint = CGPointMake(CGRectGetMinX(bounds), 112 | CGRectGetMidY(bounds)); 113 | } else if ( treeDirection == PSTreeGraphOrientationStyleHorizontalFlipped ){ 114 | // Compute point at left edge of root node, from which its connecting line to the vertical line will emerge. 115 | rootPoint = CGPointMake(CGRectGetMaxX(bounds), 116 | CGRectGetMidY(bounds)); 117 | } else if ( treeDirection == PSTreeGraphOrientationStyleVerticalFlipped ){ 118 | // Compute point at top edge of root node, from which its connecting line to the vertical line will emerge. 119 | rootPoint = CGPointMake(CGRectGetMidX(bounds), 120 | CGRectGetMaxY(bounds)); 121 | } else { 122 | rootPoint = CGPointMake(CGRectGetMidX(bounds), 123 | CGRectGetMinY(bounds)); 124 | } 125 | 126 | 127 | // Align the line to get exact pixel coverage, for sharper rendering. 128 | // basePoint = [self convertPointToBase:rootPoint]; 129 | // basePoint.x = round(basePoint.x) + adjustment; 130 | // basePoint.y = round(basePoint.y) + adjustment; 131 | // rootPoint = [self convertPointFromBase:basePoint]; 132 | 133 | 134 | // Compute point (really, we're just interested in the x value) at which line 135 | // from root node intersects the vertical connecting line. 136 | 137 | CGPoint rootIntersection = CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds)); 138 | 139 | 140 | // Align the line to get exact pixel coverage, for sharper rendering. 141 | // basePoint = [self convertPointToBase:rootIntersection]; 142 | // basePoint.x = round(basePoint.x) + adjustment; 143 | // basePoint.y = round(basePoint.y) + adjustment; 144 | // rootIntersection = [self convertPointFromBase:basePoint]; 145 | 146 | // Create a single bezier path that we'll use to stroke all the lines. 147 | UIBezierPath *path = [UIBezierPath bezierPath]; 148 | 149 | // Add a stroke from each child SubtreeView to where we'll put the vertical connecting line. 150 | // And while we're iterating over SubtreeViews, make a note of the minimum and maximum Y we'll 151 | // want for the endpoints of the vertical connecting line. 152 | 153 | CGFloat minY = rootPoint.y; 154 | CGFloat maxY = rootPoint.y; 155 | CGFloat minX = rootPoint.x; 156 | CGFloat maxX = rootPoint.x; 157 | 158 | UIView *subtreeView = self.superview; 159 | NSInteger subtreeViewCount = 0; 160 | 161 | if ([subtreeView isKindOfClass:[PSBaseSubtreeView class]]) { 162 | 163 | for (UIView *subview in subtreeView.subviews) { 164 | if ([subview isKindOfClass:[PSBaseSubtreeView class]]) { 165 | ++subtreeViewCount; 166 | 167 | CGRect subviewBounds = subview.bounds; 168 | CGPoint targetPoint = CGPointZero; 169 | 170 | if (( treeDirection == PSTreeGraphOrientationStyleHorizontal ) || 171 | ( treeDirection == PSTreeGraphOrientationStyleHorizontalFlipped )){ 172 | targetPoint = [self convertPoint:CGPointMake(CGRectGetMinX(subviewBounds), CGRectGetMidY(subviewBounds)) 173 | fromView:subview]; 174 | } else { 175 | targetPoint = [self convertPoint:CGPointMake(CGRectGetMidX(subviewBounds), CGRectGetMinY(subviewBounds)) 176 | fromView:subview]; 177 | } 178 | 179 | // Align the line to get exact pixel coverage, for sharper rendering. 180 | // basePoint = [self convertPointToBase:targetPoint]; 181 | // basePoint.x = round(basePoint.x) + adjustment; 182 | // basePoint.y = round(basePoint.y) + adjustment; 183 | // targetPoint = [self convertPointFromBase:basePoint]; 184 | 185 | // TODO: Make clean line joins (test at high values of line thickness to see the problem). 186 | 187 | if (( treeDirection == PSTreeGraphOrientationStyleHorizontal ) || 188 | ( treeDirection == PSTreeGraphOrientationStyleHorizontalFlipped )){ 189 | [path moveToPoint:CGPointMake(rootIntersection.x, targetPoint.y)]; 190 | 191 | if (minY > targetPoint.y) { 192 | minY = targetPoint.y; 193 | } 194 | if (maxY < targetPoint.y) { 195 | maxY = targetPoint.y; 196 | } 197 | } else { 198 | [path moveToPoint:CGPointMake(targetPoint.x, rootIntersection.y)]; 199 | 200 | if (minX > targetPoint.x) { 201 | minX = targetPoint.x; 202 | } 203 | if (maxX < targetPoint.x) { 204 | maxX = targetPoint.x; 205 | } 206 | } 207 | 208 | [path addLineToPoint:targetPoint]; 209 | 210 | } 211 | } 212 | } 213 | 214 | if (subtreeViewCount) { 215 | // Add a stroke from rootPoint to where we'll put the vertical connecting line. 216 | [path moveToPoint:rootPoint]; 217 | [path addLineToPoint:rootIntersection]; 218 | 219 | if (( treeDirection == PSTreeGraphOrientationStyleHorizontal ) || 220 | ( treeDirection == PSTreeGraphOrientationStyleHorizontalFlipped )){ 221 | // Add a stroke for the vertical connecting line. 222 | [path moveToPoint:CGPointMake(rootIntersection.x, minY)]; 223 | [path addLineToPoint:CGPointMake(rootIntersection.x, maxY)]; 224 | } else { 225 | // Add a stroke for the vertical connecting line. 226 | [path moveToPoint:CGPointMake(minX, rootIntersection.y)]; 227 | [path addLineToPoint:CGPointMake(maxX, rootIntersection.y)]; 228 | } 229 | 230 | } 231 | 232 | // Return the path. 233 | return path; 234 | } 235 | 236 | 237 | #pragma mark - UIView 238 | 239 | - (void) drawRect:(CGRect)dirtyRect 240 | { 241 | // Build the set of lines to stroke, according to our enclosingTreeGraph's connectingLineStyle. 242 | UIBezierPath *path = nil; 243 | 244 | switch (self.enclosingTreeGraph.connectingLineStyle) { 245 | case PSTreeGraphConnectingLineStyleDirect: 246 | default: 247 | path = [self directConnectionsPath]; 248 | break; 249 | 250 | case PSTreeGraphConnectingLineStyleOrthogonal: 251 | path = [self orthogonalConnectionsPath]; 252 | break; 253 | } 254 | 255 | // Stroke the path with the appropriate color and line width. 256 | PSBaseTreeGraphView *treeGraph = self.enclosingTreeGraph; 257 | 258 | if ( self.opaque ) { 259 | // Fill background. 260 | [treeGraph.backgroundColor set]; 261 | UIRectFill(dirtyRect); 262 | } 263 | 264 | // Draw lines 265 | [treeGraph.connectingLineColor set]; 266 | path.lineWidth = treeGraph.connectingLineWidth; 267 | [path stroke]; 268 | } 269 | 270 | 271 | @end 272 | -------------------------------------------------------------------------------- /PSTreeGraphView/PSBaseTreeGraphView.h: -------------------------------------------------------------------------------- 1 | // 2 | // PSBaseTreeGraphView.h 3 | // PSTreeGraphView 4 | // 5 | // Created by Ed Preston on 7/25/10. 6 | // Copyright 2015 Preston Software. All rights reserved. 7 | // 8 | // 9 | // This is a port of the sample code from Max OS X to iOS (iPad). 10 | // 11 | // WWDC 2010 Session 141, “Crafting Custom Cocoa Views” 12 | // 13 | 14 | 15 | #import 16 | 17 | 18 | /// A TreeGraph's nodes may be connected by either "direct" or "orthogonal" lines. 19 | 20 | typedef NS_ENUM(NSUInteger, PSTreeGraphConnectingLineStyle) { 21 | PSTreeGraphConnectingLineStyleDirect = 0, 22 | PSTreeGraphConnectingLineStyleOrthogonal = 1, 23 | }; 24 | 25 | 26 | /// A TreeGraph's orientation may be either "horizontal" or "vertical". 27 | 28 | typedef NS_ENUM(NSUInteger, PSTreeGraphOrientationStyle) { 29 | PSTreeGraphOrientationStyleHorizontal = 0, 30 | PSTreeGraphOrientationStyleVertical = 1, 31 | PSTreeGraphOrientationStyleHorizontalFlipped = 2, 32 | PSTreeGraphOrientationStyleVerticalFlipped = 3, 33 | }; 34 | 35 | 36 | 37 | @class PSBaseSubtreeView; 38 | 39 | @protocol PSTreeGraphModelNode; 40 | @protocol PSTreeGraphDelegate; 41 | 42 | 43 | 44 | @interface PSBaseTreeGraphView : UIView 45 | 46 | 47 | #pragma mark - Delegate 48 | 49 | @property (nonatomic, weak) id delegate; 50 | 51 | 52 | #pragma mark - Parent Resize Notification 53 | 54 | /// Use this method to keep the view in sync for now. 55 | 56 | - (void) parentClipViewDidResize:(id)object; 57 | 58 | 59 | #pragma mark - Creating Instances 60 | 61 | /// Initializes a new TreeGraph instance. (TreeGraph's designated initializer is the same as 62 | /// UIView's: -initWithFrame:.) The TreeGraph has default appearance properties and layout 63 | /// metrics, but to have a usable TreeGraph with actual content, you need to specify a 64 | /// nodeViewNibName and a modelRoot. 65 | 66 | - (instancetype) initWithFrame:(CGRect)frame; 67 | 68 | 69 | #pragma mark - Connection to Model 70 | 71 | /// The root of the model node tree that the TreeGraph is being asked to display. (The modelRoot 72 | /// may have ancestor nodes, but TreeGraph will ignore them and treat modelRoot as the root.) May 73 | /// be set to nil, in which case the TreeGraph displays no content. The modelRoot object, and all 74 | /// of its desdendants as exposed through recursive application of the "-childModelNodes" accessor 75 | /// to traverse the model tree, must conform to the TreeGraphModelNode protocol declared in 76 | /// TreeGraphModelNode.h 77 | 78 | @property (nonatomic, strong) id modelRoot; 79 | 80 | 81 | #pragma mark - Root SubtreeView Access 82 | 83 | /// A TreeGraph builds the tree it displays using recursively nested SubtreeView instances. This 84 | /// read-only accessor provides a way to get the rootmost SubtreeView (the one that corresponds 85 | /// to the modelRoot model node). 86 | 87 | @property (weak, nonatomic, readonly) PSBaseSubtreeView *rootSubtreeView; 88 | 89 | 90 | #pragma mark - Node View Nib Specification 91 | 92 | /// The name of the .nib file from which to instantiate node views. (This API design assumes that 93 | /// all node views should be instantiated from the same .nib. If a tree of heterogeneous nodes 94 | /// was desired, we could switch to a different mechanism for identifying the .nib to instantiate.) 95 | /// Must specify a "View" .nib file, whose File's Owner is a SubtreeView, or the TreeGraph will be 96 | /// unable to instantiate node views. 97 | 98 | @property (nonatomic, copy) NSString *nodeViewNibName; 99 | 100 | 101 | #pragma mark - Selection State 102 | 103 | /// The unordered set of model nodes that are currently selected in the TreeGraph. When no nodes 104 | /// are selected, this is an empty NSSet. It will never be nil (and attempting to set it to nil 105 | /// will raise an exception). Every member of this set must be a descendant of the TreeGraph's 106 | /// modelRoot (or modelRoot itself). If any member is not, TreeGraph will raise an exception. 107 | 108 | @property (nonatomic, copy) NSSet *selectedModelNodes; 109 | 110 | /// Convenience accessor that returns the selected node, if exactly one node is currently 111 | /// selected. Returns nil if zero, or more than one, nodes are currently selected. 112 | 113 | @property (weak, nonatomic, readonly) id singleSelectedModelNode; 114 | 115 | /// Returns the bounding box of the selectedModelNodes. The bounding box takes only the selected 116 | /// nodes into account, disregarding any descendants they might have. 117 | 118 | @property (nonatomic, readonly) CGRect selectionBounds; 119 | 120 | 121 | #pragma mark - Node Hit-Testing 122 | 123 | /// Returns the model node under the given point, which must be expressed in the TreeGraph's 124 | /// interior (bounds) coordinate space. If there is a collapsed subtree at the given point, 125 | /// returns the model node at the root of the collapsed subtree. If there is no model node 126 | /// at the given point, returns nil. 127 | 128 | - (id ) modelNodeAtPoint:(CGPoint)p; 129 | 130 | 131 | #pragma mark - Sizing and Layout 132 | 133 | /// A TreeGraph's minimumFrameSize is the size needed to accommodate its content (as currently 134 | /// laid out) and margins. Changes to the TreeGraph's content, layout, or margins will update 135 | /// this. When a TreeGraph is the documentView of an UIScrollView, its actual frame may be larger 136 | /// than its minimumFrameSize, since we automatically expand the TreeGraph to always be at least 137 | /// as large as the UIScrollView's clip area (contentView) to provide a nicer user experience. 138 | 139 | @property (nonatomic, readonly) CGSize minimumFrameSize; 140 | 141 | /// If YES, and if the TreeGraph is the documentView of an UIScrollView, the TreeGraph will 142 | /// automatically resize itself as needed to ensure that it always at least fills the content 143 | /// area of its enclosing UIScrollView. If NO, or if the TreeGraph is not the documentView of 144 | /// an UIScrollView, the TreeGraph's size is determined only by its content and margins. 145 | 146 | @property (nonatomic, assign) BOOL resizesToFillEnclosingScrollView; 147 | 148 | /// The style for tree graph orientation 149 | /// @note See the PSTreeGraphOrientationStyle enumeration. 150 | 151 | @property (nonatomic, assign) PSTreeGraphOrientationStyle treeGraphOrientation; 152 | 153 | /// Is the TreeGraph flipped 154 | /// Flipped means the graph is drawn with the branches to the left or top and the root node 155 | /// to the right or bottom. Default is NO 156 | 157 | @property (nonatomic, assign) BOOL treeGraphFlipped; 158 | 159 | /// Returns YES if the tree needs relayout. 160 | 161 | - (BOOL) needsGraphLayout; 162 | 163 | /// Marks the tree as needing relayout. 164 | 165 | - (void) setNeedsGraphLayout; 166 | 167 | /// Performs graph layout, if the tree is marked as needing it. Returns the size computed for the 168 | /// tree (not including contentMargin). 169 | 170 | - (CGSize) layoutGraphIfNeeded; 171 | 172 | /// Collapses the root node, if it is currently expanded. 173 | 174 | - (void) collapseRoot; 175 | 176 | /// Expands the root node, if it is currently collapsed. 177 | 178 | - (void) expandRoot; 179 | 180 | /// Toggles the expansion state of the TreeGraph's selectedModelNodes, expanding those that are 181 | /// currently collapsed, and collapsing those that are currently expanded. 182 | 183 | - (IBAction) toggleExpansionOfSelectedModelNodes:(id)sender; 184 | 185 | /// Returns the bounding box of the node views that represent the specified modelNodes. Model 186 | /// nodes that aren't part of the displayed tree, or are part of a collapsed subtree, are ignored 187 | /// and don't contribute to the returned bounding box. The bounding box takes only the specified 188 | /// nodes into account, disregarding any descendants they might have. 189 | 190 | - (CGRect) boundsOfModelNodes:(NSSet *)modelNodes; 191 | 192 | 193 | #pragma mark - Scrolling 194 | 195 | /// Does a [self scrollRectToVisible:] with the bounding box of the specified model nodes. 196 | 197 | - (void) scrollModelNodesToVisible:(NSSet *)modelNodes animated:(BOOL)animated; 198 | 199 | /// Does a [self scrollRectToVisible:] with the bounding box of the selected model nodes. 200 | 201 | - (void) scrollSelectedModelNodesToVisibleAnimated:(BOOL)animated; 202 | 203 | 204 | #pragma mark - Animation Support 205 | 206 | /// Whether the TreeGraph animates layout operations. Defaults to YES. If set to NO, layout 207 | /// jumpst instantaneously to the tree's new state. 208 | 209 | @property (nonatomic, assign) BOOL animatesLayout; 210 | 211 | /// Used to temporarily suppress layout animation during event tracking. Layout animation happens 212 | /// only if animatesLayout is YES and this is NO. 213 | 214 | @property (nonatomic, assign) BOOL layoutAnimationSuppressed; 215 | 216 | 217 | #pragma mark - Layout Metrics 218 | 219 | /// The amount of padding to leave between the displayed tree and each of the 220 | /// four edges of the TreeGraph's bounds. 221 | 222 | @property (nonatomic, assign) CGFloat contentMargin; 223 | 224 | /// The horizonal spacing between each parent node and its child nodes. 225 | 226 | @property (nonatomic, assign) CGFloat parentChildSpacing; 227 | 228 | /// The vertical spacing betwen sibling nodes. 229 | 230 | @property (nonatomic, assign) CGFloat siblingSpacing; 231 | 232 | 233 | #pragma mark - Styling 234 | 235 | // The fill color for the TreeGraph's content area. 236 | 237 | // @property(copy) UIColor *backgroundColor; 238 | 239 | /// The stroke color for node connecting lines. 240 | 241 | @property (nonatomic, strong) UIColor *connectingLineColor; 242 | 243 | /// The width for node connecting lines. 244 | 245 | @property (nonatomic, assign) CGFloat connectingLineWidth; 246 | 247 | /// The style for node connecting lines. 248 | /// @note See the PSTreeGraphConnectingLineStyle enumeration. 249 | 250 | @property (nonatomic, assign) PSTreeGraphConnectingLineStyle connectingLineStyle; 251 | 252 | /// Defaults to NO. If YES, a stroked outline is shown around each of the TreeGraph's 253 | /// SubtreeViews. This can be helpful for visualizing the TreeGraph's structure and layout. 254 | 255 | @property (nonatomic, assign) BOOL showsSubtreeFrames; 256 | 257 | 258 | #pragma mark - Input and Navigation 259 | 260 | /// Custom input view for navigation. 261 | /// 262 | /// By default, this control supports a hardware keyboard unless this property is assigned 263 | /// to another input view. 264 | /// 265 | /// More Info: 266 | /// 267 | /// A placeholder view is created to so the default keyboard is not presented to the user. 268 | /// When a hardware keyboard is attached, touching the TreeGraph makes it first responder 269 | /// and certain keyboard shortcuts become available for navigation. ie. the space bar 270 | /// expands and collapses the current selection. The following keys; w, a, s, d, navigate 271 | /// relative to the graph. 272 | /// 273 | /// Custom navigation can be added by assigning a custom UIView to inputView, and linking 274 | /// it up to some of the actions below. 275 | 276 | @property (nonatomic, strong) IBOutlet UIView *inputView; 277 | 278 | // Model relative navigation 279 | - (void) moveToSiblingByRelativeIndex:(NSInteger)relativeIndex; 280 | - (IBAction) moveToParent:(id)sender; 281 | - (IBAction) moveToNearestChild:(id)sender; 282 | 283 | // Graph relative navigation 284 | - (IBAction) moveUp:(id)sender; 285 | - (IBAction) moveDown:(id)sender; 286 | - (IBAction) moveLeft:(id)sender; 287 | - (IBAction) moveRight:(id)sender; 288 | 289 | @end 290 | -------------------------------------------------------------------------------- /PSTreeGraphView/PSBaseSubtreeView.m: -------------------------------------------------------------------------------- 1 | // 2 | // PSBaseSubtreeView.m 3 | // PSTreeGraphView 4 | // 5 | // Created by Ed Preston on 7/25/10. 6 | // Copyright 2015 Preston Software. All rights reserved. 7 | // 8 | // 9 | // This is a port of the sample code from Max OS X to iOS (iPad). 10 | // 11 | // WWDC 2010 Session 141, “Crafting Custom Cocoa Views” 12 | // 13 | 14 | 15 | #import "PSBaseSubtreeView.h" 16 | #import "PSBaseBranchView.h" 17 | #import "PSBaseTreeGraphView.h" 18 | 19 | 20 | // for CALayer definition 21 | #import 22 | 23 | 24 | #define CENTER_COLLAPSED_SUBTREE_ROOT 1 25 | 26 | static UIColor *subtreeBorderColor(void) 27 | { 28 | return [UIColor colorWithRed:0.0f green:0.5f blue:0.0f alpha:1.0f]; 29 | } 30 | 31 | static CGFloat subtreeBorderWidth(void) 32 | { 33 | return 2.0f; 34 | } 35 | 36 | 37 | #pragma mark - Internal Interface 38 | 39 | @interface PSBaseSubtreeView () 40 | { 41 | 42 | @private 43 | 44 | // the view that shows connections from nodeView to its child nodes 45 | PSBaseBranchView *_connectorsView; 46 | } 47 | 48 | 49 | @end 50 | 51 | 52 | @implementation PSBaseSubtreeView 53 | 54 | 55 | #pragma mark - Attributes 56 | 57 | - (void) setExpanded:(BOOL)flag 58 | { 59 | if (_expanded != flag) { 60 | 61 | // Remember this SubtreeView's new state. 62 | _expanded = flag; 63 | 64 | // Notify the TreeGraph we need layout. 65 | [self.enclosingTreeGraph setNeedsGraphLayout]; 66 | 67 | // Expand or collapse subtrees recursively. 68 | for (UIView *subview in self.subviews) { 69 | if ([subview isKindOfClass:[PSBaseSubtreeView class]]) { 70 | ((PSBaseSubtreeView *)subview).expanded = _expanded; 71 | } 72 | } 73 | } 74 | } 75 | 76 | - (IBAction) toggleExpansion:(id)sender 77 | { 78 | [UIView beginAnimations:@"TreeNodeExpansion" context:nil]; 79 | // [UIView setAnimationDuration:8.0]; 80 | [UIView setAnimationBeginsFromCurrentState:YES]; 81 | [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; 82 | 83 | self.expanded = !self.expanded; 84 | 85 | [self.enclosingTreeGraph layoutGraphIfNeeded]; 86 | 87 | if ( self.modelNode != nil ) { 88 | NSSet *visibleSet = [NSSet setWithObject:self.modelNode]; 89 | [self.enclosingTreeGraph scrollModelNodesToVisible:visibleSet animated:NO]; 90 | } 91 | 92 | [UIView commitAnimations]; 93 | } 94 | 95 | - (BOOL) isLeaf 96 | { 97 | return [self.modelNode childModelNodes].count == 0; 98 | } 99 | 100 | 101 | #pragma mark - Instance Initialization 102 | 103 | // Use initWithModelNode below. 104 | - (instancetype) initWithFrame:(CGRect)frame { @throw nil; } 105 | - (instancetype) initWithCoder:(NSCoder *)aDecoder { @throw nil; } 106 | 107 | 108 | - (instancetype) initWithModelNode:( id )newModelNode 109 | { 110 | NSParameterAssert(newModelNode); 111 | 112 | self = [super initWithFrame:CGRectMake(10.0, 10.0, 100.0, 25.0)]; 113 | if (self) { 114 | 115 | // Initialize ivars directly. As a rule, it's best to avoid invoking accessors from an -init... 116 | // method, since they may wrongly expect the instance to be fully formed. 117 | 118 | _expanded = YES; 119 | _needsGraphLayout = YES; 120 | 121 | // autoresizesSubviews defaults to YES. We don't want autoresizing, which would interfere 122 | // with the explicit layout we do, so we switch it off for SubtreeView instances. 123 | [self setAutoresizesSubviews:NO]; 124 | 125 | self.modelNode = newModelNode; 126 | _connectorsView = [[PSBaseBranchView alloc] initWithFrame:CGRectZero]; 127 | if (_connectorsView) { 128 | [_connectorsView setAutoresizesSubviews:YES]; 129 | // if we dont redraw lines, they get out of place 130 | _connectorsView.contentMode = UIViewContentModeRedraw; 131 | [_connectorsView setOpaque:YES]; 132 | 133 | [self addSubview:_connectorsView]; 134 | } 135 | } 136 | return self; 137 | } 138 | 139 | 140 | - (PSBaseTreeGraphView *) enclosingTreeGraph 141 | { 142 | UIView *ancestor = self.superview; 143 | while (ancestor) { 144 | if ([ancestor isKindOfClass:[PSBaseTreeGraphView class]]) { 145 | return (PSBaseTreeGraphView *)ancestor; 146 | } 147 | ancestor = ancestor.superview; 148 | } 149 | return nil; 150 | } 151 | 152 | 153 | #pragma mark - Layout 154 | 155 | - (void) recursiveSetNeedsGraphLayout 156 | { 157 | [self setNeedsGraphLayout:YES]; 158 | for (UIView *subview in self.subviews) { 159 | if ([subview isKindOfClass:[PSBaseSubtreeView class]]) { 160 | [(PSBaseSubtreeView *)subview recursiveSetNeedsGraphLayout]; 161 | } 162 | } 163 | } 164 | 165 | - (CGSize) sizeNodeViewToFitContent 166 | { 167 | // TODO: Node size is hardwired for now, but the layout algorithm could accommodate 168 | // variable-sized nodes if we implement size-to-fit for nodes. 169 | 170 | return (self.nodeView).frame.size; 171 | } 172 | 173 | - (void) flipTreeGraph 174 | { 175 | // Recurse for descendant SubtreeViews. 176 | CGFloat myWidth = self.frame.size.width; 177 | CGFloat myHeight = self.frame.size.height; 178 | PSBaseTreeGraphView *treeGraph = self.enclosingTreeGraph; 179 | PSTreeGraphOrientationStyle treeOrientation = treeGraph.treeGraphOrientation; 180 | 181 | NSArray *subviews = self.subviews; 182 | for (UIView *subview in subviews) { 183 | CGPoint subviewCenter = subview.center; 184 | CGPoint newCenter; 185 | CGFloat offset; 186 | if (treeOrientation == PSTreeGraphOrientationStyleHorizontalFlipped ){ 187 | offset = subviewCenter.x; 188 | newCenter = CGPointMake(myWidth-offset, subviewCenter.y); 189 | } 190 | else{ 191 | offset = subviewCenter.y; 192 | newCenter = CGPointMake(subviewCenter.x, myHeight-offset); 193 | } 194 | subview.center = newCenter; 195 | if ([subview isKindOfClass:[PSBaseSubtreeView class]]) { 196 | [(PSBaseSubtreeView *)subview flipTreeGraph]; 197 | } 198 | } 199 | } 200 | 201 | - (CGSize) layoutGraphIfNeeded 202 | { 203 | // Return early if layout not needed 204 | if ( !self.needsGraphLayout ) 205 | return self.frame.size; 206 | 207 | // Do the layout 208 | CGSize selfTargetSize; 209 | if ( self.expanded ) { 210 | selfTargetSize = [self layoutExpandedGraph]; 211 | } else { 212 | selfTargetSize = [self layoutCollapsedGraph]; 213 | } 214 | 215 | // Mark as having completed layout. 216 | self.needsGraphLayout = NO; 217 | 218 | // Return our new size. 219 | return selfTargetSize; 220 | } 221 | 222 | - (CGSize) layoutExpandedGraph 223 | { 224 | CGSize selfTargetSize; 225 | 226 | PSBaseTreeGraphView *treeGraph = self.enclosingTreeGraph; 227 | 228 | CGFloat parentChildSpacing = treeGraph.parentChildSpacing; 229 | CGFloat siblingSpacing = treeGraph.siblingSpacing; 230 | PSTreeGraphOrientationStyle treeOrientation = treeGraph.treeGraphOrientation; 231 | 232 | // Size this SubtreeView's nodeView to fit its content. Our tree layout model assumes the assessment 233 | // of a node's natural size is a function of intrinsic properties of the node, and isn't influenced 234 | // by any other nodes or layout in the tree. 235 | 236 | CGSize rootNodeViewSize = [self sizeNodeViewToFitContent]; 237 | 238 | // Recurse to lay out each of our child SubtreeViews (and their non-collapsed descendants in turn). 239 | // Knowing the sizes of our child SubtreeViews will tell us what size this SubtreeView needs to be 240 | // to contain them (and our nodeView and connectorsView). 241 | 242 | NSArray *subviews = self.subviews; 243 | NSInteger count = subviews.count; 244 | NSInteger index; 245 | NSUInteger subtreeViewCount = 0; 246 | CGFloat maxWidth = 0.0f; 247 | CGFloat maxHeight = 0.0f; 248 | CGPoint nextSubtreeViewOrigin = CGPointZero; 249 | 250 | if (( treeOrientation == PSTreeGraphOrientationStyleHorizontal ) || 251 | ( treeOrientation == PSTreeGraphOrientationStyleHorizontalFlipped )){ 252 | nextSubtreeViewOrigin = CGPointMake(rootNodeViewSize.width + parentChildSpacing, 0.0f); 253 | } else { 254 | nextSubtreeViewOrigin = CGPointMake(0.0f, rootNodeViewSize.height + parentChildSpacing); 255 | } 256 | 257 | for (index = count - 1; index >= 0; index--) { 258 | UIView *subview = subviews[index]; 259 | 260 | if ([subview isKindOfClass:[PSBaseSubtreeView class]]) { 261 | ++subtreeViewCount; 262 | 263 | // Unhide the view if needed. 264 | [subview setHidden:NO]; 265 | 266 | // Recursively layout the subtree, and obtain the SubtreeView's resultant size. 267 | CGSize subtreeViewSize = [(PSBaseSubtreeView *)subview layoutGraphIfNeeded]; 268 | 269 | // Position the SubtreeView. 270 | // [(animateLayout ? [subview animator] : subview) setFrameOrigin:nextSubtreeViewOrigin]; 271 | 272 | if (( treeOrientation == PSTreeGraphOrientationStyleHorizontal ) || 273 | (treeOrientation == PSTreeGraphOrientationStyleHorizontalFlipped )) { 274 | // Since SubtreeView is unflipped, lay out our child SubtreeViews going upward from our 275 | // bottom edge, from last to first. 276 | subview.frame = CGRectMake( nextSubtreeViewOrigin.x, 277 | nextSubtreeViewOrigin.y, 278 | subtreeViewSize.width, 279 | subtreeViewSize.height ); 280 | 281 | // Advance nextSubtreeViewOrigin for the next SubtreeView. 282 | nextSubtreeViewOrigin.y += subtreeViewSize.height + siblingSpacing; 283 | 284 | // Keep track of the widest SubtreeView width we encounter. 285 | if (maxWidth < subtreeViewSize.width) { 286 | maxWidth = subtreeViewSize.width; 287 | } 288 | 289 | } else { 290 | // TODO: Lay out our child SubtreeViews going from our left edge, last to first. SWITCH ME 291 | subview.frame = CGRectMake( nextSubtreeViewOrigin.x, 292 | nextSubtreeViewOrigin.y, 293 | subtreeViewSize.width, 294 | subtreeViewSize.height ); 295 | 296 | // Advance nextSubtreeViewOrigin for the next SubtreeView. 297 | nextSubtreeViewOrigin.x += subtreeViewSize.width + siblingSpacing; 298 | 299 | // Keep track of the widest SubtreeView width we encounter. 300 | if (maxHeight < subtreeViewSize.height) { 301 | maxHeight = subtreeViewSize.height; 302 | } 303 | } 304 | } 305 | } 306 | 307 | // Calculate the total height of all our SubtreeViews, including the vertical spacing between them. 308 | // We have N child SubtreeViews, but only (N-1) gaps between them, so subtract 1 increment of 309 | // siblingSpacing that was added by the loop above. 310 | 311 | CGFloat totalHeight = 0.0f; 312 | CGFloat totalWidth = 0.0f; 313 | 314 | if (( treeOrientation == PSTreeGraphOrientationStyleHorizontal ) || 315 | (treeOrientation == PSTreeGraphOrientationStyleHorizontalFlipped )) { 316 | totalHeight = nextSubtreeViewOrigin.y; 317 | if (subtreeViewCount > 0) { 318 | totalHeight -= siblingSpacing; 319 | } 320 | } else { 321 | totalWidth = nextSubtreeViewOrigin.x; 322 | if (subtreeViewCount > 0) { 323 | totalWidth -= siblingSpacing; 324 | } 325 | } 326 | 327 | // Size self to contain our nodeView all our child SubtreeViews, and position our 328 | // nodeView and connectorsView. 329 | if (subtreeViewCount > 0) { 330 | 331 | // Determine our width and height. 332 | if (( treeOrientation == PSTreeGraphOrientationStyleHorizontal ) || 333 | ( treeOrientation == PSTreeGraphOrientationStyleHorizontalFlipped )) { 334 | selfTargetSize = CGSizeMake(rootNodeViewSize.width + parentChildSpacing + maxWidth, 335 | MAX(totalHeight, rootNodeViewSize.height) ); 336 | } else { 337 | selfTargetSize = CGSizeMake(MAX(totalWidth, rootNodeViewSize.width), 338 | rootNodeViewSize.height + parentChildSpacing + maxHeight); 339 | } 340 | 341 | // Resize to our new width and height. 342 | // [(animateLayout ? [self animator] : self) setFrameSize:selfTargetSize]; 343 | self.frame = CGRectMake(self.frame.origin.x, 344 | self.frame.origin.y, 345 | selfTargetSize.width, 346 | selfTargetSize.height ); 347 | 348 | CGPoint nodeViewOrigin = CGPointZero; 349 | if (( treeOrientation == PSTreeGraphOrientationStyleHorizontal ) || 350 | ( treeOrientation == PSTreeGraphOrientationStyleHorizontalFlipped )){ 351 | // Position our nodeView vertically centered along the left edge of our new bounds. 352 | nodeViewOrigin = CGPointMake(0.0f, 0.5f * (selfTargetSize.height - rootNodeViewSize.height)); 353 | 354 | } else { 355 | // Position our nodeView horizontally centered along the top edge of our new bounds. 356 | nodeViewOrigin = CGPointMake(0.5f * (selfTargetSize.width - rootNodeViewSize.width), 0.0f); 357 | } 358 | 359 | // Pixel-align its position to keep its rendering crisp. 360 | CGPoint windowPoint = [self convertPoint:nodeViewOrigin toView:nil]; 361 | windowPoint.x = round(windowPoint.x); 362 | windowPoint.y = round(windowPoint.y); 363 | nodeViewOrigin = [self convertPoint:windowPoint fromView:nil]; 364 | 365 | self.nodeView.frame = CGRectMake(nodeViewOrigin.x, 366 | nodeViewOrigin.y, 367 | self.nodeView.frame.size.width, 368 | self.nodeView.frame.size.height ); 369 | 370 | // Position, show our connectorsView and button. 371 | 372 | // TODO: Can shrink height a bit on top and bottom ends, since the connecting lines 373 | // meet at the nodes' vertical centers 374 | 375 | // NOTE: It may be better to stretch the content if a collapse animation is added? 376 | // Be sure to test. Given the size, and how they just contain the lines, it seems 377 | // best to just redraw these things. 378 | 379 | // [_connectorsView setContentMode:UIViewContentModeScaleToFill ]; 380 | 381 | if (( treeOrientation == PSTreeGraphOrientationStyleHorizontal ) || 382 | ( treeOrientation == PSTreeGraphOrientationStyleHorizontalFlipped )){ 383 | _connectorsView.frame = CGRectMake(rootNodeViewSize.width, 384 | 0.0f, 385 | parentChildSpacing, 386 | selfTargetSize.height ); 387 | } else { 388 | _connectorsView.frame = CGRectMake(0.0f, 389 | rootNodeViewSize.height, 390 | selfTargetSize.width, 391 | parentChildSpacing ); 392 | } 393 | 394 | // NOTE: Enable this line if a collapse animation is added (line below not used) 395 | // [_connectorsView setContentMode:UIViewContentModeRedraw]; 396 | 397 | [_connectorsView setHidden:NO]; 398 | 399 | } else { 400 | // No SubtreeViews; this is a leaf node. 401 | // Size self to exactly wrap nodeView, hide connectorsView, and hide the button. 402 | 403 | selfTargetSize = rootNodeViewSize; 404 | 405 | self.frame = CGRectMake(self.frame.origin.x, 406 | self.frame.origin.y, 407 | selfTargetSize.width, 408 | selfTargetSize.height ); 409 | 410 | self.nodeView.frame = CGRectMake(0.0f, 411 | 0.0f, 412 | self.nodeView.frame.size.width, 413 | self.nodeView.frame.size.height ); 414 | 415 | [_connectorsView setHidden:YES]; 416 | } 417 | 418 | // Return our new size. 419 | return selfTargetSize; 420 | } 421 | 422 | - (CGSize) layoutCollapsedGraph 423 | { 424 | 425 | // This node is collapsed. Everything will be collapsed behind the leafNode 426 | CGSize selfTargetSize = [self sizeNodeViewToFitContent]; 427 | 428 | self.frame = CGRectMake(self.frame.origin.x, 429 | self.frame.origin.y, 430 | selfTargetSize.width, 431 | selfTargetSize.height ); 432 | 433 | for (UIView *subview in self.subviews) { 434 | if ([subview isKindOfClass:[PSBaseSubtreeView class]]) { 435 | 436 | [(PSBaseSubtreeView *)subview layoutGraphIfNeeded]; 437 | 438 | subview.frame = CGRectMake(0.0f, 439 | 0.0f, 440 | subview.frame.size.width, 441 | subview.frame.size.height ); 442 | 443 | [subview setHidden:YES]; 444 | 445 | } else if (subview == _connectorsView) { 446 | 447 | // NOTE: It may be better to stretch the content if a collapse animation is added? 448 | // Be sure to test. Given the size, and how they just contain the lines, it seems 449 | // best to just redraw these things. 450 | 451 | // [_connectorsView setContentMode:UIViewContentModeScaleToFill ]; 452 | 453 | PSTreeGraphOrientationStyle treeOrientation = self.enclosingTreeGraph.treeGraphOrientation; 454 | if (( treeOrientation == PSTreeGraphOrientationStyleHorizontal ) || 455 | ( treeOrientation == PSTreeGraphOrientationStyleHorizontal )){ 456 | _connectorsView.frame = CGRectMake(0.0f, 457 | 0.5f * selfTargetSize.height, 458 | 0.0f, 459 | 0.0f ); 460 | } else { 461 | _connectorsView.frame = CGRectMake(0.5f * selfTargetSize.width, 462 | 0.0f, 463 | 0.0f, 464 | 0.0f ); 465 | } 466 | 467 | // NOTE: Enable this line if a collapse animation is added (line below not used) 468 | // [_connectorsView setContentMode:UIViewContentModeRedraw]; 469 | 470 | [subview setHidden:YES]; 471 | 472 | } else if (subview == _nodeView) { 473 | 474 | subview.frame = CGRectMake(0.0f, 475 | 0.0f, 476 | selfTargetSize.width, 477 | selfTargetSize.height ); 478 | 479 | } 480 | } 481 | 482 | // Return our new size. 483 | return selfTargetSize; 484 | } 485 | 486 | 487 | #pragma mark - Drawing 488 | 489 | - (void) updateSubtreeBorder 490 | { 491 | // // Disable implicit animations during these layer property changes, to make them take effect immediately. 492 | // BOOL actionsWereDisabled = [CATransaction disableActions]; 493 | // [CATransaction setDisableActions:YES]; 494 | 495 | // If the enclosing TreeGraph has its "showsSubtreeFrames" debug feature enabled, 496 | // configure the backing layer to draw its border programmatically. This is much more efficient 497 | // than allocating a backing store for each SubtreeView's backing layer, only to stroke a simple 498 | // rectangle into that backing store. 499 | 500 | CALayer *layer = self.layer; 501 | 502 | PSBaseTreeGraphView *treeGraph = self.enclosingTreeGraph; 503 | 504 | if (treeGraph.showsSubtreeFrames) { 505 | layer.borderWidth = subtreeBorderWidth(); 506 | layer.borderColor = subtreeBorderColor().CGColor; 507 | } else { 508 | layer.borderWidth = 0.0; 509 | } 510 | 511 | // // Disable implicit animations during these layer property changes 512 | // [CATransaction setDisableActions:actionsWereDisabled]; 513 | 514 | } 515 | 516 | 517 | #pragma mark - Invalidation 518 | 519 | - (void) recursiveSetConnectorsViewsNeedDisplay 520 | { 521 | // Mark this SubtreeView's connectorsView as needing display. 522 | [_connectorsView setNeedsDisplay]; 523 | 524 | // Recurse for descendant SubtreeViews. 525 | NSArray *subviews = self.subviews; 526 | for (UIView *subview in subviews) { 527 | if ([subview isKindOfClass:[PSBaseSubtreeView class]]) { 528 | [(PSBaseSubtreeView *)subview recursiveSetConnectorsViewsNeedDisplay]; 529 | } 530 | } 531 | } 532 | 533 | - (void) resursiveSetSubtreeBordersNeedDisplay 534 | { 535 | // We only need this if layer-backed. When we have a backing layer, we use the 536 | // layer's "border" properties to draw the subtree debug border. 537 | 538 | [self updateSubtreeBorder]; 539 | 540 | // Recurse for descendant SubtreeViews. 541 | NSArray *subviews = self.subviews; 542 | for (UIView *subview in subviews) { 543 | if ([subview isKindOfClass:[PSBaseSubtreeView class]]) { 544 | [(PSBaseSubtreeView *)subview updateSubtreeBorder]; 545 | } 546 | } 547 | } 548 | 549 | 550 | #pragma mark - Selection State 551 | 552 | - (BOOL) nodeIsSelected 553 | { 554 | return [self.enclosingTreeGraph.selectedModelNodes containsObject:self.modelNode]; 555 | } 556 | 557 | 558 | #pragma mark - Node Hit-Testing 559 | 560 | - (id ) modelNodeAtPoint:(CGPoint)p 561 | { 562 | // Check for intersection with our subviews, enumerating them in reverse order to get 563 | // front-to-back ordering. We could use UIView's -hitTest: method here, but we don't 564 | // want to bother hit-testing deeper than the nodeView level. 565 | 566 | NSArray *subviews = self.subviews; 567 | NSInteger count = subviews.count; 568 | NSInteger index; 569 | 570 | for (index = count - 1; index >= 0; index--) { 571 | UIView *subview = subviews[index]; 572 | 573 | // CGRect subviewBounds = [subview bounds]; 574 | CGPoint subviewPoint = [subview convertPoint:p fromView:self]; 575 | // 576 | // if (CGPointInRect(subviewPoint, subviewBounds)) { 577 | 578 | if ( [subview pointInside:subviewPoint withEvent:nil] ) { 579 | 580 | if (subview == self.nodeView) { 581 | return self.modelNode; 582 | } else if ( [subview isKindOfClass:[PSBaseSubtreeView class]] ) { 583 | return [(PSBaseSubtreeView *)subview modelNodeAtPoint:subviewPoint]; 584 | } else { 585 | // Ignore subview. It's probably a BranchView. 586 | } 587 | } 588 | } 589 | 590 | // We didn't find a hit. 591 | return nil; 592 | } 593 | 594 | - (id ) modelNodeClosestToY:(CGFloat)y 595 | { 596 | // Do a simple linear search of our subviews, ignoring non-SubtreeViews. If performance was ever 597 | // an issue for this code, we could take advantage of knowing the layout order of the nodes to do 598 | // a sort of binary search. 599 | 600 | NSArray *subviews = self.subviews; 601 | PSBaseSubtreeView *subtreeViewWithClosestNodeView = nil; 602 | CGFloat closestNodeViewDistance = MAXFLOAT; 603 | 604 | for (UIView *subview in subviews) { 605 | if ([subview isKindOfClass:[PSBaseSubtreeView class]]) { 606 | UIView *childNodeView = ((PSBaseSubtreeView *)subview).nodeView; 607 | if (childNodeView) { 608 | CGRect rect = [self convertRect:childNodeView.bounds fromView:childNodeView]; 609 | CGFloat nodeViewDistance = fabs(y - CGRectGetMidY(rect)); 610 | if (nodeViewDistance < closestNodeViewDistance) { 611 | closestNodeViewDistance = nodeViewDistance; 612 | subtreeViewWithClosestNodeView = (PSBaseSubtreeView *)subview; 613 | } 614 | } 615 | } 616 | } 617 | 618 | return subtreeViewWithClosestNodeView.modelNode; 619 | } 620 | 621 | - (id ) modelNodeClosestToX:(CGFloat)x 622 | { 623 | // Do a simple linear search of our subviews, ignoring non-SubtreeViews. If performance was ever 624 | // an issue for this code, we could take advantage of knowing the layout order of the nodes to do 625 | // a sort of binary search. 626 | 627 | NSArray *subviews = self.subviews; 628 | PSBaseSubtreeView *subtreeViewWithClosestNodeView = nil; 629 | CGFloat closestNodeViewDistance = MAXFLOAT; 630 | 631 | for (UIView *subview in subviews) { 632 | if ([subview isKindOfClass:[PSBaseSubtreeView class]]) { 633 | UIView *childNodeView = ((PSBaseSubtreeView *)subview).nodeView; 634 | if (childNodeView) { 635 | CGRect rect = [self convertRect:childNodeView.bounds fromView:childNodeView]; 636 | CGFloat nodeViewDistance = fabs(x - CGRectGetMidX(rect)); 637 | if (nodeViewDistance < closestNodeViewDistance) { 638 | closestNodeViewDistance = nodeViewDistance; 639 | subtreeViewWithClosestNodeView = (PSBaseSubtreeView *)subview; 640 | } 641 | } 642 | } 643 | } 644 | 645 | return subtreeViewWithClosestNodeView.modelNode; 646 | } 647 | 648 | 649 | #pragma mark - Debugging 650 | 651 | // These methods access private member variables so they do not invoke app logic. We only 652 | // want to dump the current state. Change this if these properties are synthesized. 653 | 654 | - (NSString *) description 655 | { 656 | return [NSString stringWithFormat:@"SubtreeView<%@>", _modelNode.description]; 657 | } 658 | 659 | - (NSString *) nodeSummary 660 | { 661 | return [NSString stringWithFormat:@"f=%@ %@", NSStringFromCGRect(_nodeView.frame), _modelNode.description]; 662 | } 663 | 664 | - (NSString *) treeSummaryWithDepth:(NSInteger)depth 665 | { 666 | NSEnumerator *subviewsEnumerator = [self.subviews objectEnumerator]; 667 | UIView *subview; 668 | NSMutableString *description = [NSMutableString string]; 669 | NSInteger i; 670 | for (i = 0; i < depth; i++) { 671 | [description appendString:@" "]; 672 | } 673 | [description appendFormat:@"%@\n", [self nodeSummary]]; 674 | while (subview = [subviewsEnumerator nextObject]) { 675 | if ([subview isKindOfClass:[PSBaseSubtreeView class]]) { 676 | [description appendString:[(PSBaseSubtreeView *)subview treeSummaryWithDepth:(depth + 1)]]; 677 | } 678 | } 679 | return description; 680 | } 681 | 682 | 683 | @end 684 | -------------------------------------------------------------------------------- /Example 1/PSHTreeGraph.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1D3623260D0F684500981E51 /* PSHTreeGraphAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* PSHTreeGraphAppDelegate.m */; }; 11 | 1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; }; 12 | 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 13 | 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 14 | 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; }; 15 | 2899E5220DE3E06400AC0155 /* PSHTreeGraphViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2899E5210DE3E06400AC0155 /* PSHTreeGraphViewController.xib */; }; 16 | 28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD733E0D9D9553002E5188 /* MainWindow.xib */; }; 17 | 28D7ACF80DDB3853001CB0EB /* PSHTreeGraphViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28D7ACF70DDB3853001CB0EB /* PSHTreeGraphViewController.m */; }; 18 | 4F3536F511FC851F00AABFF1 /* MyTreeGraphView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F3536F411FC851F00AABFF1 /* MyTreeGraphView.m */; }; 19 | 4F35379D11FC8EC900AABFF1 /* PSBaseBranchView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F35379611FC8EC900AABFF1 /* PSBaseBranchView.m */; }; 20 | 4F35379E11FC8EC900AABFF1 /* PSBaseLeafView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F35379811FC8EC900AABFF1 /* PSBaseLeafView.m */; }; 21 | 4F35379F11FC8EC900AABFF1 /* PSBaseSubtreeView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F35379A11FC8EC900AABFF1 /* PSBaseSubtreeView.m */; }; 22 | 4F3537A011FC8EC900AABFF1 /* PSBaseTreeGraphView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F35379C11FC8EC900AABFF1 /* PSBaseTreeGraphView.m */; }; 23 | 4F3537ED11FC9A2F00AABFF1 /* ObjCClassWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F3537EC11FC9A2F00AABFF1 /* ObjCClassWrapper.m */; }; 24 | 4F35382611FC9FD500AABFF1 /* ObjCClassTreeNodeView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4F35382511FC9FD500AABFF1 /* ObjCClassTreeNodeView.xib */; }; 25 | 4F35382E11FCA00700AABFF1 /* TreeViewSubtreeCollapsedButton.png in Resources */ = {isa = PBXBuildFile; fileRef = 4F35382A11FCA00700AABFF1 /* TreeViewSubtreeCollapsedButton.png */; }; 26 | 4F35382F11FCA00700AABFF1 /* TreeViewSubtreeExpandedButton.png in Resources */ = {isa = PBXBuildFile; fileRef = 4F35382B11FCA00700AABFF1 /* TreeViewSubtreeExpandedButton.png */; }; 27 | 4F35383011FCA00700AABFF1 /* TreeViewDirectLinesButton.png in Resources */ = {isa = PBXBuildFile; fileRef = 4F35382C11FCA00700AABFF1 /* TreeViewDirectLinesButton.png */; }; 28 | 4F35383111FCA00700AABFF1 /* TreeViewOrthogonalLinesButton.png in Resources */ = {isa = PBXBuildFile; fileRef = 4F35382D11FCA00700AABFF1 /* TreeViewOrthogonalLinesButton.png */; }; 29 | 4F353B8711FCF1A400AABFF1 /* MyLeafView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F353B8611FCF1A400AABFF1 /* MyLeafView.m */; }; 30 | 4F4AA34513FA32C700607517 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 4F4AA34413FA32C700607517 /* Icon-72.png */; }; 31 | /* End PBXBuildFile section */ 32 | 33 | /* Begin PBXFileReference section */ 34 | 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 35 | 1D3623240D0F684500981E51 /* PSHTreeGraphAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PSHTreeGraphAppDelegate.h; path = Controller/PSHTreeGraphAppDelegate.h; sourceTree = ""; }; 36 | 1D3623250D0F684500981E51 /* PSHTreeGraphAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PSHTreeGraphAppDelegate.m; path = Controller/PSHTreeGraphAppDelegate.m; sourceTree = ""; }; 37 | 1D6058910D05DD3D006BFB54 /* PSHTreeGraph.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PSHTreeGraph.app; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 39 | 288765A40DF7441C002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 40 | 2899E5210DE3E06400AC0155 /* PSHTreeGraphViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = PSHTreeGraphViewController.xib; path = Interface/PSHTreeGraphViewController.xib; sourceTree = ""; }; 41 | 28AD733E0D9D9553002E5188 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = MainWindow.xib; path = Interface/MainWindow.xib; sourceTree = ""; }; 42 | 28D7ACF60DDB3853001CB0EB /* PSHTreeGraphViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PSHTreeGraphViewController.h; path = Controller/PSHTreeGraphViewController.h; sourceTree = ""; }; 43 | 28D7ACF70DDB3853001CB0EB /* PSHTreeGraphViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PSHTreeGraphViewController.m; path = Controller/PSHTreeGraphViewController.m; sourceTree = ""; }; 44 | 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 45 | 32CA4F630368D1EE00C91783 /* PSHTreeGraph_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSHTreeGraph_Prefix.pch; sourceTree = ""; }; 46 | 4F0E109E1407EB94009B9214 /* Doxyfile */ = {isa = PBXFileReference; explicitFileType = text.script; fileEncoding = 4; name = Doxyfile; path = ../Doxyfile; sourceTree = ""; }; 47 | 4F0EE31B15D2F99B009BC883 /* PSTreeGraphDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PSTreeGraphDelegate.h; sourceTree = ""; }; 48 | 4F2A233D180B3AEB00778BA1 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = text; name = README.md; path = ../README.md; sourceTree = ""; wrapsLines = 1; }; 49 | 4F3536F311FC851F00AABFF1 /* MyTreeGraphView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MyTreeGraphView.h; path = Classes/View/MyTreeGraphView.h; sourceTree = SOURCE_ROOT; }; 50 | 4F3536F411FC851F00AABFF1 /* MyTreeGraphView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MyTreeGraphView.m; path = Classes/View/MyTreeGraphView.m; sourceTree = SOURCE_ROOT; }; 51 | 4F35379511FC8EC900AABFF1 /* PSBaseBranchView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PSBaseBranchView.h; path = ../PSTreeGraphView/PSBaseBranchView.h; sourceTree = ""; }; 52 | 4F35379611FC8EC900AABFF1 /* PSBaseBranchView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PSBaseBranchView.m; path = ../PSTreeGraphView/PSBaseBranchView.m; sourceTree = ""; }; 53 | 4F35379711FC8EC900AABFF1 /* PSBaseLeafView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PSBaseLeafView.h; path = ../PSTreeGraphView/PSBaseLeafView.h; sourceTree = ""; }; 54 | 4F35379811FC8EC900AABFF1 /* PSBaseLeafView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PSBaseLeafView.m; path = ../PSTreeGraphView/PSBaseLeafView.m; sourceTree = ""; }; 55 | 4F35379911FC8EC900AABFF1 /* PSBaseSubtreeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PSBaseSubtreeView.h; path = ../PSTreeGraphView/PSBaseSubtreeView.h; sourceTree = ""; }; 56 | 4F35379A11FC8EC900AABFF1 /* PSBaseSubtreeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PSBaseSubtreeView.m; path = ../PSTreeGraphView/PSBaseSubtreeView.m; sourceTree = ""; }; 57 | 4F35379B11FC8EC900AABFF1 /* PSBaseTreeGraphView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PSBaseTreeGraphView.h; path = ../PSTreeGraphView/PSBaseTreeGraphView.h; sourceTree = ""; }; 58 | 4F35379C11FC8EC900AABFF1 /* PSBaseTreeGraphView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PSBaseTreeGraphView.m; path = ../PSTreeGraphView/PSBaseTreeGraphView.m; sourceTree = ""; }; 59 | 4F3537B011FC90B200AABFF1 /* PSBaseTreeGraphView_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PSBaseTreeGraphView_Internal.h; path = ../PSTreeGraphView/PSBaseTreeGraphView_Internal.h; sourceTree = ""; }; 60 | 4F3537EB11FC9A2F00AABFF1 /* ObjCClassWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjCClassWrapper.h; path = Model/ObjCClass/ObjCClassWrapper.h; sourceTree = ""; }; 61 | 4F3537EC11FC9A2F00AABFF1 /* ObjCClassWrapper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ObjCClassWrapper.m; path = Model/ObjCClass/ObjCClassWrapper.m; sourceTree = ""; }; 62 | 4F35382511FC9FD500AABFF1 /* ObjCClassTreeNodeView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = ObjCClassTreeNodeView.xib; path = Interface/ObjCClassTreeNodeView.xib; sourceTree = ""; }; 63 | 4F35382A11FCA00700AABFF1 /* TreeViewSubtreeCollapsedButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = TreeViewSubtreeCollapsedButton.png; path = Graphics/TreeViewSubtreeCollapsedButton.png; sourceTree = ""; }; 64 | 4F35382B11FCA00700AABFF1 /* TreeViewSubtreeExpandedButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = TreeViewSubtreeExpandedButton.png; path = Graphics/TreeViewSubtreeExpandedButton.png; sourceTree = ""; }; 65 | 4F35382C11FCA00700AABFF1 /* TreeViewDirectLinesButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = TreeViewDirectLinesButton.png; path = Graphics/TreeViewDirectLinesButton.png; sourceTree = ""; }; 66 | 4F35382D11FCA00700AABFF1 /* TreeViewOrthogonalLinesButton.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = TreeViewOrthogonalLinesButton.png; path = Graphics/TreeViewOrthogonalLinesButton.png; sourceTree = ""; }; 67 | 4F353B8511FCF1A400AABFF1 /* MyLeafView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MyLeafView.h; path = Classes/View/MyLeafView.h; sourceTree = SOURCE_ROOT; }; 68 | 4F353B8611FCF1A400AABFF1 /* MyLeafView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MyLeafView.m; path = Classes/View/MyLeafView.m; sourceTree = SOURCE_ROOT; }; 69 | 4F4AA34413FA32C700607517 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-72.png"; path = "Graphics/Icon-72.png"; sourceTree = ""; }; 70 | 4F86D04113FAADAF00A494AE /* PSTreeGraphModelNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PSTreeGraphModelNode.h; path = ../PSTreeGraphView/PSTreeGraphModelNode.h; sourceTree = ""; }; 71 | 8D1107310486CEB800E47090 /* PSHTreeGraph-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "PSHTreeGraph-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = ""; }; 72 | /* End PBXFileReference section */ 73 | 74 | /* Begin PBXFrameworksBuildPhase section */ 75 | 1D60588F0D05DD3D006BFB54 /* Frameworks */ = { 76 | isa = PBXFrameworksBuildPhase; 77 | buildActionMask = 2147483647; 78 | files = ( 79 | 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */, 80 | 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */, 81 | 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */, 82 | ); 83 | runOnlyForDeploymentPostprocessing = 0; 84 | }; 85 | /* End PBXFrameworksBuildPhase section */ 86 | 87 | /* Begin PBXGroup section */ 88 | 080E96DDFE201D6D7F000001 /* Classes */ = { 89 | isa = PBXGroup; 90 | children = ( 91 | 4F3536A811FC7C1F00AABFF1 /* Controller */, 92 | 4F3536AC11FC7C2A00AABFF1 /* View */, 93 | 4F3536AB11FC7C2500AABFF1 /* Model */, 94 | ); 95 | path = Classes; 96 | sourceTree = ""; 97 | }; 98 | 19C28FACFE9D520D11CA2CBB /* Products */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | 1D6058910D05DD3D006BFB54 /* PSHTreeGraph.app */, 102 | ); 103 | name = Products; 104 | sourceTree = ""; 105 | }; 106 | 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | 4F2A233D180B3AEB00778BA1 /* README.md */, 110 | 4F0E109E1407EB94009B9214 /* Doxyfile */, 111 | 080E96DDFE201D6D7F000001 /* Classes */, 112 | 29B97315FDCFA39411CA2CEA /* Target */, 113 | 29B97317FDCFA39411CA2CEA /* Resources */, 114 | 29B97323FDCFA39411CA2CEA /* Frameworks */, 115 | 19C28FACFE9D520D11CA2CBB /* Products */, 116 | ); 117 | name = CustomTemplate; 118 | sourceTree = ""; 119 | }; 120 | 29B97315FDCFA39411CA2CEA /* Target */ = { 121 | isa = PBXGroup; 122 | children = ( 123 | 32CA4F630368D1EE00C91783 /* PSHTreeGraph_Prefix.pch */, 124 | 29B97316FDCFA39411CA2CEA /* main.m */, 125 | 8D1107310486CEB800E47090 /* PSHTreeGraph-Info.plist */, 126 | ); 127 | path = Target; 128 | sourceTree = ""; 129 | }; 130 | 29B97317FDCFA39411CA2CEA /* Resources */ = { 131 | isa = PBXGroup; 132 | children = ( 133 | 4F86D04413FAAE9D00A494AE /* Interfaces */, 134 | 4F35381C11FC9F8300AABFF1 /* Graphics */, 135 | ); 136 | name = Resources; 137 | sourceTree = ""; 138 | }; 139 | 29B97323FDCFA39411CA2CEA /* Frameworks */ = { 140 | isa = PBXGroup; 141 | children = ( 142 | 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */, 143 | 1D30AB110D05D00D00671497 /* Foundation.framework */, 144 | 288765A40DF7441C002DB57D /* CoreGraphics.framework */, 145 | ); 146 | name = Frameworks; 147 | sourceTree = ""; 148 | }; 149 | 4F3536A811FC7C1F00AABFF1 /* Controller */ = { 150 | isa = PBXGroup; 151 | children = ( 152 | 1D3623240D0F684500981E51 /* PSHTreeGraphAppDelegate.h */, 153 | 1D3623250D0F684500981E51 /* PSHTreeGraphAppDelegate.m */, 154 | 28D7ACF60DDB3853001CB0EB /* PSHTreeGraphViewController.h */, 155 | 28D7ACF70DDB3853001CB0EB /* PSHTreeGraphViewController.m */, 156 | ); 157 | name = Controller; 158 | sourceTree = ""; 159 | }; 160 | 4F3536AB11FC7C2500AABFF1 /* Model */ = { 161 | isa = PBXGroup; 162 | children = ( 163 | 4F86D04213FAADC000A494AE /* ObjCClass */, 164 | ); 165 | name = Model; 166 | sourceTree = ""; 167 | }; 168 | 4F3536AC11FC7C2A00AABFF1 /* View */ = { 169 | isa = PBXGroup; 170 | children = ( 171 | 4F35370D11FC86C600AABFF1 /* PSTreeGraphView */, 172 | 4F3536F311FC851F00AABFF1 /* MyTreeGraphView.h */, 173 | 4F3536F411FC851F00AABFF1 /* MyTreeGraphView.m */, 174 | 4F353B8511FCF1A400AABFF1 /* MyLeafView.h */, 175 | 4F353B8611FCF1A400AABFF1 /* MyLeafView.m */, 176 | ); 177 | name = View; 178 | sourceTree = ""; 179 | }; 180 | 4F35370D11FC86C600AABFF1 /* PSTreeGraphView */ = { 181 | isa = PBXGroup; 182 | children = ( 183 | 4F0EE31B15D2F99B009BC883 /* PSTreeGraphDelegate.h */, 184 | 4F86D04113FAADAF00A494AE /* PSTreeGraphModelNode.h */, 185 | 4F3537B011FC90B200AABFF1 /* PSBaseTreeGraphView_Internal.h */, 186 | 4F35379B11FC8EC900AABFF1 /* PSBaseTreeGraphView.h */, 187 | 4F35379C11FC8EC900AABFF1 /* PSBaseTreeGraphView.m */, 188 | 4F35379911FC8EC900AABFF1 /* PSBaseSubtreeView.h */, 189 | 4F35379A11FC8EC900AABFF1 /* PSBaseSubtreeView.m */, 190 | 4F35379511FC8EC900AABFF1 /* PSBaseBranchView.h */, 191 | 4F35379611FC8EC900AABFF1 /* PSBaseBranchView.m */, 192 | 4F35379711FC8EC900AABFF1 /* PSBaseLeafView.h */, 193 | 4F35379811FC8EC900AABFF1 /* PSBaseLeafView.m */, 194 | ); 195 | name = PSTreeGraphView; 196 | path = ../PSTreeGraphView; 197 | sourceTree = SOURCE_ROOT; 198 | }; 199 | 4F35381C11FC9F8300AABFF1 /* Graphics */ = { 200 | isa = PBXGroup; 201 | children = ( 202 | 4F86D04313FAAE8B00A494AE /* Icons */, 203 | 4F35382811FC9FF900AABFF1 /* Buttons */, 204 | ); 205 | name = Graphics; 206 | sourceTree = ""; 207 | }; 208 | 4F35382811FC9FF900AABFF1 /* Buttons */ = { 209 | isa = PBXGroup; 210 | children = ( 211 | 4F35382A11FCA00700AABFF1 /* TreeViewSubtreeCollapsedButton.png */, 212 | 4F35382B11FCA00700AABFF1 /* TreeViewSubtreeExpandedButton.png */, 213 | 4F35382C11FCA00700AABFF1 /* TreeViewDirectLinesButton.png */, 214 | 4F35382D11FCA00700AABFF1 /* TreeViewOrthogonalLinesButton.png */, 215 | ); 216 | name = Buttons; 217 | sourceTree = ""; 218 | }; 219 | 4F86D04213FAADC000A494AE /* ObjCClass */ = { 220 | isa = PBXGroup; 221 | children = ( 222 | 4F3537EB11FC9A2F00AABFF1 /* ObjCClassWrapper.h */, 223 | 4F3537EC11FC9A2F00AABFF1 /* ObjCClassWrapper.m */, 224 | ); 225 | name = ObjCClass; 226 | sourceTree = ""; 227 | }; 228 | 4F86D04313FAAE8B00A494AE /* Icons */ = { 229 | isa = PBXGroup; 230 | children = ( 231 | 4F4AA34413FA32C700607517 /* Icon-72.png */, 232 | ); 233 | name = Icons; 234 | sourceTree = ""; 235 | }; 236 | 4F86D04413FAAE9D00A494AE /* Interfaces */ = { 237 | isa = PBXGroup; 238 | children = ( 239 | 2899E5210DE3E06400AC0155 /* PSHTreeGraphViewController.xib */, 240 | 4F35382511FC9FD500AABFF1 /* ObjCClassTreeNodeView.xib */, 241 | 28AD733E0D9D9553002E5188 /* MainWindow.xib */, 242 | ); 243 | name = Interfaces; 244 | sourceTree = ""; 245 | }; 246 | /* End PBXGroup section */ 247 | 248 | /* Begin PBXNativeTarget section */ 249 | 1D6058900D05DD3D006BFB54 /* PSHTreeGraph */ = { 250 | isa = PBXNativeTarget; 251 | buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "PSHTreeGraph" */; 252 | buildPhases = ( 253 | 1D60588D0D05DD3D006BFB54 /* Resources */, 254 | 1D60588E0D05DD3D006BFB54 /* Sources */, 255 | 1D60588F0D05DD3D006BFB54 /* Frameworks */, 256 | ); 257 | buildRules = ( 258 | ); 259 | dependencies = ( 260 | ); 261 | name = PSHTreeGraph; 262 | productName = PSHTreeView; 263 | productReference = 1D6058910D05DD3D006BFB54 /* PSHTreeGraph.app */; 264 | productType = "com.apple.product-type.application"; 265 | }; 266 | /* End PBXNativeTarget section */ 267 | 268 | /* Begin PBXProject section */ 269 | 29B97313FDCFA39411CA2CEA /* Project object */ = { 270 | isa = PBXProject; 271 | attributes = { 272 | LastUpgradeCheck = 0700; 273 | ORGANIZATIONNAME = "Preston Software"; 274 | TargetAttributes = { 275 | 1D6058900D05DD3D006BFB54 = { 276 | SystemCapabilities = { 277 | com.apple.Keychain = { 278 | enabled = 0; 279 | }; 280 | }; 281 | }; 282 | }; 283 | }; 284 | buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "PSHTreeGraph" */; 285 | compatibilityVersion = "Xcode 3.2"; 286 | developmentRegion = English; 287 | hasScannedForEncodings = 1; 288 | knownRegions = ( 289 | en, 290 | ); 291 | mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; 292 | projectDirPath = ""; 293 | projectRoot = ""; 294 | targets = ( 295 | 1D6058900D05DD3D006BFB54 /* PSHTreeGraph */, 296 | ); 297 | }; 298 | /* End PBXProject section */ 299 | 300 | /* Begin PBXResourcesBuildPhase section */ 301 | 1D60588D0D05DD3D006BFB54 /* Resources */ = { 302 | isa = PBXResourcesBuildPhase; 303 | buildActionMask = 2147483647; 304 | files = ( 305 | 28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */, 306 | 2899E5220DE3E06400AC0155 /* PSHTreeGraphViewController.xib in Resources */, 307 | 4F35382611FC9FD500AABFF1 /* ObjCClassTreeNodeView.xib in Resources */, 308 | 4F35382E11FCA00700AABFF1 /* TreeViewSubtreeCollapsedButton.png in Resources */, 309 | 4F35382F11FCA00700AABFF1 /* TreeViewSubtreeExpandedButton.png in Resources */, 310 | 4F35383011FCA00700AABFF1 /* TreeViewDirectLinesButton.png in Resources */, 311 | 4F35383111FCA00700AABFF1 /* TreeViewOrthogonalLinesButton.png in Resources */, 312 | 4F4AA34513FA32C700607517 /* Icon-72.png in Resources */, 313 | ); 314 | runOnlyForDeploymentPostprocessing = 0; 315 | }; 316 | /* End PBXResourcesBuildPhase section */ 317 | 318 | /* Begin PBXSourcesBuildPhase section */ 319 | 1D60588E0D05DD3D006BFB54 /* Sources */ = { 320 | isa = PBXSourcesBuildPhase; 321 | buildActionMask = 2147483647; 322 | files = ( 323 | 1D60589B0D05DD56006BFB54 /* main.m in Sources */, 324 | 1D3623260D0F684500981E51 /* PSHTreeGraphAppDelegate.m in Sources */, 325 | 28D7ACF80DDB3853001CB0EB /* PSHTreeGraphViewController.m in Sources */, 326 | 4F3536F511FC851F00AABFF1 /* MyTreeGraphView.m in Sources */, 327 | 4F35379D11FC8EC900AABFF1 /* PSBaseBranchView.m in Sources */, 328 | 4F35379E11FC8EC900AABFF1 /* PSBaseLeafView.m in Sources */, 329 | 4F35379F11FC8EC900AABFF1 /* PSBaseSubtreeView.m in Sources */, 330 | 4F3537A011FC8EC900AABFF1 /* PSBaseTreeGraphView.m in Sources */, 331 | 4F3537ED11FC9A2F00AABFF1 /* ObjCClassWrapper.m in Sources */, 332 | 4F353B8711FCF1A400AABFF1 /* MyLeafView.m in Sources */, 333 | ); 334 | runOnlyForDeploymentPostprocessing = 0; 335 | }; 336 | /* End PBXSourcesBuildPhase section */ 337 | 338 | /* Begin XCBuildConfiguration section */ 339 | 1D6058940D05DD3E006BFB54 /* Debug */ = { 340 | isa = XCBuildConfiguration; 341 | buildSettings = { 342 | ALWAYS_SEARCH_USER_PATHS = NO; 343 | CODE_SIGN_IDENTITY = "iPhone Developer"; 344 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 345 | COPY_PHASE_STRIP = NO; 346 | GCC_DYNAMIC_NO_PIC = NO; 347 | GCC_OPTIMIZATION_LEVEL = 0; 348 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 349 | GCC_PREFIX_HEADER = "$(SRCROOT)/Target/PSHTreeGraph_Prefix.pch"; 350 | INFOPLIST_FILE = "$(SRCROOT)/Target/PSHTreeGraph-Info.plist"; 351 | PRODUCT_BUNDLE_IDENTIFIER = "com.prestonsoft.${PRODUCT_NAME:rfc1034identifier}"; 352 | PRODUCT_NAME = PSHTreeGraph; 353 | PROVISIONING_PROFILE = ""; 354 | TARGETED_DEVICE_FAMILY = 2; 355 | }; 356 | name = Debug; 357 | }; 358 | 1D6058950D05DD3E006BFB54 /* Release */ = { 359 | isa = XCBuildConfiguration; 360 | buildSettings = { 361 | ALWAYS_SEARCH_USER_PATHS = NO; 362 | CODE_SIGN_IDENTITY = "iPhone Developer"; 363 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 364 | COPY_PHASE_STRIP = YES; 365 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 366 | GCC_PREFIX_HEADER = "$(SRCROOT)/Target/PSHTreeGraph_Prefix.pch"; 367 | INFOPLIST_FILE = "$(SRCROOT)/Target/PSHTreeGraph-Info.plist"; 368 | PRODUCT_BUNDLE_IDENTIFIER = "com.prestonsoft.${PRODUCT_NAME:rfc1034identifier}"; 369 | PRODUCT_NAME = PSHTreeGraph; 370 | PROVISIONING_PROFILE = ""; 371 | TARGETED_DEVICE_FAMILY = 2; 372 | VALIDATE_PRODUCT = YES; 373 | }; 374 | name = Release; 375 | }; 376 | C01FCF4F08A954540054247B /* Debug */ = { 377 | isa = XCBuildConfiguration; 378 | buildSettings = { 379 | CLANG_ENABLE_MODULES = YES; 380 | CLANG_ENABLE_OBJC_ARC = YES; 381 | CLANG_WARN_BOOL_CONVERSION = YES; 382 | CLANG_WARN_CONSTANT_CONVERSION = YES; 383 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 384 | CLANG_WARN_EMPTY_BODY = YES; 385 | CLANG_WARN_ENUM_CONVERSION = YES; 386 | CLANG_WARN_INT_CONVERSION = YES; 387 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 388 | CLANG_WARN_UNREACHABLE_CODE = YES; 389 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 390 | CODE_SIGN_IDENTITY = "iPhone Developer"; 391 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 392 | ENABLE_STRICT_OBJC_MSGSEND = YES; 393 | ENABLE_TESTABILITY = YES; 394 | GCC_C_LANGUAGE_STANDARD = c99; 395 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 396 | GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; 397 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 398 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 399 | GCC_WARN_UNDECLARED_SELECTOR = YES; 400 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 401 | GCC_WARN_UNUSED_FUNCTION = YES; 402 | GCC_WARN_UNUSED_PARAMETER = NO; 403 | GCC_WARN_UNUSED_VARIABLE = YES; 404 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 405 | ONLY_ACTIVE_ARCH = YES; 406 | SDKROOT = iphoneos; 407 | TARGETED_DEVICE_FAMILY = 2; 408 | USER_HEADER_SEARCH_PATHS = ../PSTreeGraphView/; 409 | }; 410 | name = Debug; 411 | }; 412 | C01FCF5008A954540054247B /* Release */ = { 413 | isa = XCBuildConfiguration; 414 | buildSettings = { 415 | CLANG_ENABLE_MODULES = YES; 416 | CLANG_ENABLE_OBJC_ARC = YES; 417 | CLANG_WARN_BOOL_CONVERSION = YES; 418 | CLANG_WARN_CONSTANT_CONVERSION = YES; 419 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 420 | CLANG_WARN_EMPTY_BODY = YES; 421 | CLANG_WARN_ENUM_CONVERSION = YES; 422 | CLANG_WARN_INT_CONVERSION = YES; 423 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 424 | CLANG_WARN_UNREACHABLE_CODE = YES; 425 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 426 | CODE_SIGN_IDENTITY = "iPhone Developer"; 427 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 428 | ENABLE_STRICT_OBJC_MSGSEND = YES; 429 | GCC_C_LANGUAGE_STANDARD = c99; 430 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 431 | GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; 432 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 433 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 434 | GCC_WARN_UNDECLARED_SELECTOR = YES; 435 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 436 | GCC_WARN_UNUSED_FUNCTION = YES; 437 | GCC_WARN_UNUSED_PARAMETER = NO; 438 | GCC_WARN_UNUSED_VARIABLE = YES; 439 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 440 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 441 | SDKROOT = iphoneos; 442 | TARGETED_DEVICE_FAMILY = 2; 443 | USER_HEADER_SEARCH_PATHS = ../PSTreeGraphView/; 444 | }; 445 | name = Release; 446 | }; 447 | /* End XCBuildConfiguration section */ 448 | 449 | /* Begin XCConfigurationList section */ 450 | 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "PSHTreeGraph" */ = { 451 | isa = XCConfigurationList; 452 | buildConfigurations = ( 453 | 1D6058940D05DD3E006BFB54 /* Debug */, 454 | 1D6058950D05DD3E006BFB54 /* Release */, 455 | ); 456 | defaultConfigurationIsVisible = 0; 457 | defaultConfigurationName = Release; 458 | }; 459 | C01FCF4E08A954540054247B /* Build configuration list for PBXProject "PSHTreeGraph" */ = { 460 | isa = XCConfigurationList; 461 | buildConfigurations = ( 462 | C01FCF4F08A954540054247B /* Debug */, 463 | C01FCF5008A954540054247B /* Release */, 464 | ); 465 | defaultConfigurationIsVisible = 0; 466 | defaultConfigurationName = Release; 467 | }; 468 | /* End XCConfigurationList section */ 469 | }; 470 | rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; 471 | } 472 | -------------------------------------------------------------------------------- /Unit Tests/PSTTreeGraph.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 4F1FC8401407441500C343D9 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4F1FC83F1407441500C343D9 /* UIKit.framework */; }; 11 | 4F1FC8421407441500C343D9 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4F1FC8411407441500C343D9 /* Foundation.framework */; }; 12 | 4F1FC8441407441500C343D9 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4F1FC8431407441500C343D9 /* CoreGraphics.framework */; }; 13 | 4F1FC84A1407441500C343D9 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4F1FC8481407441500C343D9 /* InfoPlist.strings */; }; 14 | 4F1FC84C1407441500C343D9 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F1FC84B1407441500C343D9 /* main.m */; }; 15 | 4F1FC8501407441600C343D9 /* PSTTreeGraphAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F1FC84F1407441600C343D9 /* PSTTreeGraphAppDelegate.m */; }; 16 | 4F1FC8531407441600C343D9 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4F1FC8511407441600C343D9 /* MainWindow.xib */; }; 17 | 4F1FC8561407441600C343D9 /* PSTTreeGraphViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F1FC8551407441600C343D9 /* PSTTreeGraphViewController.m */; }; 18 | 4F1FC8591407441600C343D9 /* PSTTreeGraphViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4F1FC8571407441600C343D9 /* PSTTreeGraphViewController.xib */; }; 19 | 4F1FC8621407441600C343D9 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4F1FC83F1407441500C343D9 /* UIKit.framework */; }; 20 | 4F1FC8631407441600C343D9 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4F1FC8411407441500C343D9 /* Foundation.framework */; }; 21 | 4F1FC8641407441600C343D9 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4F1FC8431407441500C343D9 /* CoreGraphics.framework */; }; 22 | 4F1FC86C1407441600C343D9 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4F1FC86A1407441600C343D9 /* InfoPlist.strings */; }; 23 | 4F1FC89714074E3300C343D9 /* PSBaseBranchView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F1FC88E14074E3300C343D9 /* PSBaseBranchView.m */; }; 24 | 4F1FC89814074E3300C343D9 /* PSBaseLeafView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F1FC89014074E3300C343D9 /* PSBaseLeafView.m */; }; 25 | 4F1FC89914074E3300C343D9 /* PSBaseSubtreeView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F1FC89214074E3300C343D9 /* PSBaseSubtreeView.m */; }; 26 | 4F1FC89A14074E3300C343D9 /* PSBaseTreeGraphView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F1FC89414074E3300C343D9 /* PSBaseTreeGraphView.m */; }; 27 | 4F1FC8B3140755CD00C343D9 /* BranchTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F1FC8AC140755CD00C343D9 /* BranchTests.m */; }; 28 | 4F1FC8B4140755CD00C343D9 /* GraphTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F1FC8AE140755CD00C343D9 /* GraphTests.m */; }; 29 | 4F1FC8B5140755CD00C343D9 /* LeafTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F1FC8B0140755CD00C343D9 /* LeafTests.m */; }; 30 | 4F1FC8B6140755CD00C343D9 /* SubTreeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4F1FC8B2140755CD00C343D9 /* SubTreeTests.m */; }; 31 | /* End PBXBuildFile section */ 32 | 33 | /* Begin PBXContainerItemProxy section */ 34 | 4F1FC8651407441600C343D9 /* PBXContainerItemProxy */ = { 35 | isa = PBXContainerItemProxy; 36 | containerPortal = 4F1FC8321407441500C343D9 /* Project object */; 37 | proxyType = 1; 38 | remoteGlobalIDString = 4F1FC83A1407441500C343D9; 39 | remoteInfo = PSTTreeGraph; 40 | }; 41 | /* End PBXContainerItemProxy section */ 42 | 43 | /* Begin PBXFileReference section */ 44 | 4F1FC83B1407441500C343D9 /* PSTTreeGraph.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PSTTreeGraph.app; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | 4F1FC83F1407441500C343D9 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 46 | 4F1FC8411407441500C343D9 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 47 | 4F1FC8431407441500C343D9 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 48 | 4F1FC8471407441500C343D9 /* PSTTreeGraph-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "PSTTreeGraph-Info.plist"; sourceTree = ""; }; 49 | 4F1FC8491407441500C343D9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 50 | 4F1FC84B1407441500C343D9 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 51 | 4F1FC84D1407441600C343D9 /* PSTTreeGraph-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PSTTreeGraph-Prefix.pch"; sourceTree = ""; }; 52 | 4F1FC84E1407441600C343D9 /* PSTTreeGraphAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PSTTreeGraphAppDelegate.h; sourceTree = ""; }; 53 | 4F1FC84F1407441600C343D9 /* PSTTreeGraphAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PSTTreeGraphAppDelegate.m; sourceTree = ""; }; 54 | 4F1FC8521407441600C343D9 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainWindow.xib; sourceTree = ""; }; 55 | 4F1FC8541407441600C343D9 /* PSTTreeGraphViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PSTTreeGraphViewController.h; sourceTree = ""; }; 56 | 4F1FC8551407441600C343D9 /* PSTTreeGraphViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PSTTreeGraphViewController.m; sourceTree = ""; }; 57 | 4F1FC8581407441600C343D9 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/PSTTreeGraphViewController.xib; sourceTree = ""; }; 58 | 4F1FC85F1407441600C343D9 /* PSTTreeGraphTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PSTTreeGraphTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 59 | 4F1FC8691407441600C343D9 /* PSTTreeGraphTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "PSTTreeGraphTests-Info.plist"; sourceTree = ""; }; 60 | 4F1FC86B1407441600C343D9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 61 | 4F1FC88D14074E3300C343D9 /* PSBaseBranchView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSBaseBranchView.h; sourceTree = ""; }; 62 | 4F1FC88E14074E3300C343D9 /* PSBaseBranchView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSBaseBranchView.m; sourceTree = ""; }; 63 | 4F1FC88F14074E3300C343D9 /* PSBaseLeafView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSBaseLeafView.h; sourceTree = ""; }; 64 | 4F1FC89014074E3300C343D9 /* PSBaseLeafView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSBaseLeafView.m; sourceTree = ""; }; 65 | 4F1FC89114074E3300C343D9 /* PSBaseSubtreeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSBaseSubtreeView.h; sourceTree = ""; }; 66 | 4F1FC89214074E3300C343D9 /* PSBaseSubtreeView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSBaseSubtreeView.m; sourceTree = ""; }; 67 | 4F1FC89314074E3300C343D9 /* PSBaseTreeGraphView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSBaseTreeGraphView.h; sourceTree = ""; }; 68 | 4F1FC89414074E3300C343D9 /* PSBaseTreeGraphView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSBaseTreeGraphView.m; sourceTree = ""; }; 69 | 4F1FC89514074E3300C343D9 /* PSBaseTreeGraphView_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSBaseTreeGraphView_Internal.h; sourceTree = ""; }; 70 | 4F1FC89614074E3300C343D9 /* PSTreeGraphModelNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PSTreeGraphModelNode.h; sourceTree = ""; }; 71 | 4F1FC8AB140755CD00C343D9 /* BranchTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BranchTests.h; sourceTree = ""; }; 72 | 4F1FC8AC140755CD00C343D9 /* BranchTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BranchTests.m; sourceTree = ""; }; 73 | 4F1FC8AD140755CD00C343D9 /* GraphTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphTests.h; sourceTree = ""; }; 74 | 4F1FC8AE140755CD00C343D9 /* GraphTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GraphTests.m; sourceTree = ""; }; 75 | 4F1FC8AF140755CD00C343D9 /* LeafTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LeafTests.h; sourceTree = ""; }; 76 | 4F1FC8B0140755CD00C343D9 /* LeafTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LeafTests.m; sourceTree = ""; }; 77 | 4F1FC8B1140755CD00C343D9 /* SubTreeTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SubTreeTests.h; sourceTree = ""; }; 78 | 4F1FC8B2140755CD00C343D9 /* SubTreeTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SubTreeTests.m; sourceTree = ""; }; 79 | /* End PBXFileReference section */ 80 | 81 | /* Begin PBXFrameworksBuildPhase section */ 82 | 4F1FC8381407441500C343D9 /* Frameworks */ = { 83 | isa = PBXFrameworksBuildPhase; 84 | buildActionMask = 2147483647; 85 | files = ( 86 | 4F1FC8401407441500C343D9 /* UIKit.framework in Frameworks */, 87 | 4F1FC8421407441500C343D9 /* Foundation.framework in Frameworks */, 88 | 4F1FC8441407441500C343D9 /* CoreGraphics.framework in Frameworks */, 89 | ); 90 | runOnlyForDeploymentPostprocessing = 0; 91 | }; 92 | 4F1FC85B1407441600C343D9 /* Frameworks */ = { 93 | isa = PBXFrameworksBuildPhase; 94 | buildActionMask = 2147483647; 95 | files = ( 96 | 4F1FC8621407441600C343D9 /* UIKit.framework in Frameworks */, 97 | 4F1FC8631407441600C343D9 /* Foundation.framework in Frameworks */, 98 | 4F1FC8641407441600C343D9 /* CoreGraphics.framework in Frameworks */, 99 | ); 100 | runOnlyForDeploymentPostprocessing = 0; 101 | }; 102 | /* End PBXFrameworksBuildPhase section */ 103 | 104 | /* Begin PBXGroup section */ 105 | 4F1FC8301407441500C343D9 = { 106 | isa = PBXGroup; 107 | children = ( 108 | 4F1FC8451407441500C343D9 /* PSTTreeGraph */, 109 | 4F1FC8671407441600C343D9 /* PSTTreeGraphTests */, 110 | 4F1FC83E1407441500C343D9 /* Frameworks */, 111 | 4F1FC83C1407441500C343D9 /* Products */, 112 | ); 113 | sourceTree = ""; 114 | }; 115 | 4F1FC83C1407441500C343D9 /* Products */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | 4F1FC83B1407441500C343D9 /* PSTTreeGraph.app */, 119 | 4F1FC85F1407441600C343D9 /* PSTTreeGraphTests.xctest */, 120 | ); 121 | name = Products; 122 | sourceTree = ""; 123 | }; 124 | 4F1FC83E1407441500C343D9 /* Frameworks */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | 4F1FC83F1407441500C343D9 /* UIKit.framework */, 128 | 4F1FC8411407441500C343D9 /* Foundation.framework */, 129 | 4F1FC8431407441500C343D9 /* CoreGraphics.framework */, 130 | ); 131 | name = Frameworks; 132 | sourceTree = ""; 133 | }; 134 | 4F1FC8451407441500C343D9 /* PSTTreeGraph */ = { 135 | isa = PBXGroup; 136 | children = ( 137 | 4F1FC88814074D6F00C343D9 /* Controller */, 138 | 4F1FC88A14074D7800C343D9 /* View */, 139 | 4F1FC88B14074D8100C343D9 /* Model */, 140 | 4F1FC8461407441500C343D9 /* Supporting Files */, 141 | ); 142 | path = PSTTreeGraph; 143 | sourceTree = ""; 144 | }; 145 | 4F1FC8461407441500C343D9 /* Supporting Files */ = { 146 | isa = PBXGroup; 147 | children = ( 148 | 4F1FC8A4140751EF00C343D9 /* Interface */, 149 | 4F1FC8471407441500C343D9 /* PSTTreeGraph-Info.plist */, 150 | 4F1FC8481407441500C343D9 /* InfoPlist.strings */, 151 | 4F1FC84B1407441500C343D9 /* main.m */, 152 | 4F1FC84D1407441600C343D9 /* PSTTreeGraph-Prefix.pch */, 153 | ); 154 | name = "Supporting Files"; 155 | sourceTree = ""; 156 | }; 157 | 4F1FC8671407441600C343D9 /* PSTTreeGraphTests */ = { 158 | isa = PBXGroup; 159 | children = ( 160 | 4F1FC8AD140755CD00C343D9 /* GraphTests.h */, 161 | 4F1FC8AE140755CD00C343D9 /* GraphTests.m */, 162 | 4F1FC8B1140755CD00C343D9 /* SubTreeTests.h */, 163 | 4F1FC8B2140755CD00C343D9 /* SubTreeTests.m */, 164 | 4F1FC8AB140755CD00C343D9 /* BranchTests.h */, 165 | 4F1FC8AC140755CD00C343D9 /* BranchTests.m */, 166 | 4F1FC8AF140755CD00C343D9 /* LeafTests.h */, 167 | 4F1FC8B0140755CD00C343D9 /* LeafTests.m */, 168 | 4F1FC8681407441600C343D9 /* Supporting Files */, 169 | ); 170 | path = PSTTreeGraphTests; 171 | sourceTree = ""; 172 | }; 173 | 4F1FC8681407441600C343D9 /* Supporting Files */ = { 174 | isa = PBXGroup; 175 | children = ( 176 | 4F1FC8691407441600C343D9 /* PSTTreeGraphTests-Info.plist */, 177 | 4F1FC86A1407441600C343D9 /* InfoPlist.strings */, 178 | ); 179 | name = "Supporting Files"; 180 | sourceTree = ""; 181 | }; 182 | 4F1FC88814074D6F00C343D9 /* Controller */ = { 183 | isa = PBXGroup; 184 | children = ( 185 | 4F1FC84E1407441600C343D9 /* PSTTreeGraphAppDelegate.h */, 186 | 4F1FC84F1407441600C343D9 /* PSTTreeGraphAppDelegate.m */, 187 | 4F1FC8541407441600C343D9 /* PSTTreeGraphViewController.h */, 188 | 4F1FC8551407441600C343D9 /* PSTTreeGraphViewController.m */, 189 | ); 190 | name = Controller; 191 | sourceTree = ""; 192 | }; 193 | 4F1FC88A14074D7800C343D9 /* View */ = { 194 | isa = PBXGroup; 195 | children = ( 196 | 4F1FC88C14074E3300C343D9 /* PSTreeGraphView */, 197 | ); 198 | name = View; 199 | sourceTree = ""; 200 | }; 201 | 4F1FC88B14074D8100C343D9 /* Model */ = { 202 | isa = PBXGroup; 203 | children = ( 204 | ); 205 | name = Model; 206 | sourceTree = ""; 207 | }; 208 | 4F1FC88C14074E3300C343D9 /* PSTreeGraphView */ = { 209 | isa = PBXGroup; 210 | children = ( 211 | 4F1FC88D14074E3300C343D9 /* PSBaseBranchView.h */, 212 | 4F1FC88E14074E3300C343D9 /* PSBaseBranchView.m */, 213 | 4F1FC88F14074E3300C343D9 /* PSBaseLeafView.h */, 214 | 4F1FC89014074E3300C343D9 /* PSBaseLeafView.m */, 215 | 4F1FC89114074E3300C343D9 /* PSBaseSubtreeView.h */, 216 | 4F1FC89214074E3300C343D9 /* PSBaseSubtreeView.m */, 217 | 4F1FC89314074E3300C343D9 /* PSBaseTreeGraphView.h */, 218 | 4F1FC89414074E3300C343D9 /* PSBaseTreeGraphView.m */, 219 | 4F1FC89514074E3300C343D9 /* PSBaseTreeGraphView_Internal.h */, 220 | 4F1FC89614074E3300C343D9 /* PSTreeGraphModelNode.h */, 221 | ); 222 | name = PSTreeGraphView; 223 | path = ../../PSTreeGraphView; 224 | sourceTree = ""; 225 | }; 226 | 4F1FC8A4140751EF00C343D9 /* Interface */ = { 227 | isa = PBXGroup; 228 | children = ( 229 | 4F1FC8571407441600C343D9 /* PSTTreeGraphViewController.xib */, 230 | 4F1FC8511407441600C343D9 /* MainWindow.xib */, 231 | ); 232 | name = Interface; 233 | sourceTree = ""; 234 | }; 235 | /* End PBXGroup section */ 236 | 237 | /* Begin PBXNativeTarget section */ 238 | 4F1FC83A1407441500C343D9 /* PSTTreeGraph */ = { 239 | isa = PBXNativeTarget; 240 | buildConfigurationList = 4F1FC8731407441600C343D9 /* Build configuration list for PBXNativeTarget "PSTTreeGraph" */; 241 | buildPhases = ( 242 | 4F1FC8371407441500C343D9 /* Sources */, 243 | 4F1FC8381407441500C343D9 /* Frameworks */, 244 | 4F1FC8391407441500C343D9 /* Resources */, 245 | ); 246 | buildRules = ( 247 | ); 248 | dependencies = ( 249 | ); 250 | name = PSTTreeGraph; 251 | productName = PSTTreeGraph; 252 | productReference = 4F1FC83B1407441500C343D9 /* PSTTreeGraph.app */; 253 | productType = "com.apple.product-type.application"; 254 | }; 255 | 4F1FC85E1407441600C343D9 /* PSTTreeGraphTests */ = { 256 | isa = PBXNativeTarget; 257 | buildConfigurationList = 4F1FC8761407441600C343D9 /* Build configuration list for PBXNativeTarget "PSTTreeGraphTests" */; 258 | buildPhases = ( 259 | 4F1FC85A1407441600C343D9 /* Sources */, 260 | 4F1FC85B1407441600C343D9 /* Frameworks */, 261 | 4F1FC85C1407441600C343D9 /* Resources */, 262 | 4F1FC85D1407441600C343D9 /* ShellScript */, 263 | ); 264 | buildRules = ( 265 | ); 266 | dependencies = ( 267 | 4F1FC8661407441600C343D9 /* PBXTargetDependency */, 268 | ); 269 | name = PSTTreeGraphTests; 270 | productName = PSTTreeGraphTests; 271 | productReference = 4F1FC85F1407441600C343D9 /* PSTTreeGraphTests.xctest */; 272 | productType = "com.apple.product-type.bundle.unit-test"; 273 | }; 274 | /* End PBXNativeTarget section */ 275 | 276 | /* Begin PBXProject section */ 277 | 4F1FC8321407441500C343D9 /* Project object */ = { 278 | isa = PBXProject; 279 | attributes = { 280 | LastUpgradeCheck = 0700; 281 | ORGANIZATIONNAME = "Preston Software"; 282 | }; 283 | buildConfigurationList = 4F1FC8351407441500C343D9 /* Build configuration list for PBXProject "PSTTreeGraph" */; 284 | compatibilityVersion = "Xcode 3.2"; 285 | developmentRegion = English; 286 | hasScannedForEncodings = 0; 287 | knownRegions = ( 288 | en, 289 | ); 290 | mainGroup = 4F1FC8301407441500C343D9; 291 | productRefGroup = 4F1FC83C1407441500C343D9 /* Products */; 292 | projectDirPath = ""; 293 | projectRoot = ""; 294 | targets = ( 295 | 4F1FC83A1407441500C343D9 /* PSTTreeGraph */, 296 | 4F1FC85E1407441600C343D9 /* PSTTreeGraphTests */, 297 | ); 298 | }; 299 | /* End PBXProject section */ 300 | 301 | /* Begin PBXResourcesBuildPhase section */ 302 | 4F1FC8391407441500C343D9 /* Resources */ = { 303 | isa = PBXResourcesBuildPhase; 304 | buildActionMask = 2147483647; 305 | files = ( 306 | 4F1FC84A1407441500C343D9 /* InfoPlist.strings in Resources */, 307 | 4F1FC8531407441600C343D9 /* MainWindow.xib in Resources */, 308 | 4F1FC8591407441600C343D9 /* PSTTreeGraphViewController.xib in Resources */, 309 | ); 310 | runOnlyForDeploymentPostprocessing = 0; 311 | }; 312 | 4F1FC85C1407441600C343D9 /* Resources */ = { 313 | isa = PBXResourcesBuildPhase; 314 | buildActionMask = 2147483647; 315 | files = ( 316 | 4F1FC86C1407441600C343D9 /* InfoPlist.strings in Resources */, 317 | ); 318 | runOnlyForDeploymentPostprocessing = 0; 319 | }; 320 | /* End PBXResourcesBuildPhase section */ 321 | 322 | /* Begin PBXShellScriptBuildPhase section */ 323 | 4F1FC85D1407441600C343D9 /* ShellScript */ = { 324 | isa = PBXShellScriptBuildPhase; 325 | buildActionMask = 2147483647; 326 | files = ( 327 | ); 328 | inputPaths = ( 329 | ); 330 | outputPaths = ( 331 | ); 332 | runOnlyForDeploymentPostprocessing = 0; 333 | shellPath = /bin/sh; 334 | shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; 335 | }; 336 | /* End PBXShellScriptBuildPhase section */ 337 | 338 | /* Begin PBXSourcesBuildPhase section */ 339 | 4F1FC8371407441500C343D9 /* Sources */ = { 340 | isa = PBXSourcesBuildPhase; 341 | buildActionMask = 2147483647; 342 | files = ( 343 | 4F1FC84C1407441500C343D9 /* main.m in Sources */, 344 | 4F1FC8501407441600C343D9 /* PSTTreeGraphAppDelegate.m in Sources */, 345 | 4F1FC8561407441600C343D9 /* PSTTreeGraphViewController.m in Sources */, 346 | 4F1FC89714074E3300C343D9 /* PSBaseBranchView.m in Sources */, 347 | 4F1FC89814074E3300C343D9 /* PSBaseLeafView.m in Sources */, 348 | 4F1FC89914074E3300C343D9 /* PSBaseSubtreeView.m in Sources */, 349 | 4F1FC89A14074E3300C343D9 /* PSBaseTreeGraphView.m in Sources */, 350 | ); 351 | runOnlyForDeploymentPostprocessing = 0; 352 | }; 353 | 4F1FC85A1407441600C343D9 /* Sources */ = { 354 | isa = PBXSourcesBuildPhase; 355 | buildActionMask = 2147483647; 356 | files = ( 357 | 4F1FC8B3140755CD00C343D9 /* BranchTests.m in Sources */, 358 | 4F1FC8B4140755CD00C343D9 /* GraphTests.m in Sources */, 359 | 4F1FC8B5140755CD00C343D9 /* LeafTests.m in Sources */, 360 | 4F1FC8B6140755CD00C343D9 /* SubTreeTests.m in Sources */, 361 | ); 362 | runOnlyForDeploymentPostprocessing = 0; 363 | }; 364 | /* End PBXSourcesBuildPhase section */ 365 | 366 | /* Begin PBXTargetDependency section */ 367 | 4F1FC8661407441600C343D9 /* PBXTargetDependency */ = { 368 | isa = PBXTargetDependency; 369 | target = 4F1FC83A1407441500C343D9 /* PSTTreeGraph */; 370 | targetProxy = 4F1FC8651407441600C343D9 /* PBXContainerItemProxy */; 371 | }; 372 | /* End PBXTargetDependency section */ 373 | 374 | /* Begin PBXVariantGroup section */ 375 | 4F1FC8481407441500C343D9 /* InfoPlist.strings */ = { 376 | isa = PBXVariantGroup; 377 | children = ( 378 | 4F1FC8491407441500C343D9 /* en */, 379 | ); 380 | name = InfoPlist.strings; 381 | sourceTree = ""; 382 | }; 383 | 4F1FC8511407441600C343D9 /* MainWindow.xib */ = { 384 | isa = PBXVariantGroup; 385 | children = ( 386 | 4F1FC8521407441600C343D9 /* en */, 387 | ); 388 | name = MainWindow.xib; 389 | sourceTree = ""; 390 | }; 391 | 4F1FC8571407441600C343D9 /* PSTTreeGraphViewController.xib */ = { 392 | isa = PBXVariantGroup; 393 | children = ( 394 | 4F1FC8581407441600C343D9 /* en */, 395 | ); 396 | name = PSTTreeGraphViewController.xib; 397 | sourceTree = ""; 398 | }; 399 | 4F1FC86A1407441600C343D9 /* InfoPlist.strings */ = { 400 | isa = PBXVariantGroup; 401 | children = ( 402 | 4F1FC86B1407441600C343D9 /* en */, 403 | ); 404 | name = InfoPlist.strings; 405 | sourceTree = ""; 406 | }; 407 | /* End PBXVariantGroup section */ 408 | 409 | /* Begin XCBuildConfiguration section */ 410 | 4F1FC8711407441600C343D9 /* Debug */ = { 411 | isa = XCBuildConfiguration; 412 | buildSettings = { 413 | ALWAYS_SEARCH_USER_PATHS = NO; 414 | CLANG_ENABLE_MODULES = YES; 415 | CLANG_ENABLE_OBJC_ARC = YES; 416 | CLANG_WARN_BOOL_CONVERSION = YES; 417 | CLANG_WARN_CONSTANT_CONVERSION = YES; 418 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 419 | CLANG_WARN_EMPTY_BODY = YES; 420 | CLANG_WARN_ENUM_CONVERSION = YES; 421 | CLANG_WARN_INT_CONVERSION = YES; 422 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 423 | CLANG_WARN_UNREACHABLE_CODE = YES; 424 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 425 | CODE_SIGN_IDENTITY = "iPhone Developer"; 426 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 427 | COPY_PHASE_STRIP = NO; 428 | ENABLE_STRICT_OBJC_MSGSEND = YES; 429 | ENABLE_TESTABILITY = YES; 430 | GCC_C_LANGUAGE_STANDARD = gnu99; 431 | GCC_DYNAMIC_NO_PIC = NO; 432 | GCC_NO_COMMON_BLOCKS = YES; 433 | GCC_OPTIMIZATION_LEVEL = 0; 434 | GCC_PREPROCESSOR_DEFINITIONS = ( 435 | "DEBUG=1", 436 | "$(inherited)", 437 | ); 438 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 439 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 440 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 441 | GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; 442 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 443 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 444 | GCC_WARN_UNDECLARED_SELECTOR = YES; 445 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 446 | GCC_WARN_UNUSED_FUNCTION = YES; 447 | GCC_WARN_UNUSED_VARIABLE = YES; 448 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 449 | ONLY_ACTIVE_ARCH = YES; 450 | SDKROOT = iphoneos; 451 | TARGETED_DEVICE_FAMILY = 2; 452 | }; 453 | name = Debug; 454 | }; 455 | 4F1FC8721407441600C343D9 /* Release */ = { 456 | isa = XCBuildConfiguration; 457 | buildSettings = { 458 | ALWAYS_SEARCH_USER_PATHS = NO; 459 | CLANG_ENABLE_MODULES = YES; 460 | CLANG_ENABLE_OBJC_ARC = YES; 461 | CLANG_WARN_BOOL_CONVERSION = YES; 462 | CLANG_WARN_CONSTANT_CONVERSION = YES; 463 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 464 | CLANG_WARN_EMPTY_BODY = YES; 465 | CLANG_WARN_ENUM_CONVERSION = YES; 466 | CLANG_WARN_INT_CONVERSION = YES; 467 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 468 | CLANG_WARN_UNREACHABLE_CODE = YES; 469 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 470 | CODE_SIGN_IDENTITY = "iPhone Developer"; 471 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 472 | COPY_PHASE_STRIP = YES; 473 | ENABLE_STRICT_OBJC_MSGSEND = YES; 474 | GCC_C_LANGUAGE_STANDARD = gnu99; 475 | GCC_NO_COMMON_BLOCKS = YES; 476 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 477 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 478 | GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; 479 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 480 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 481 | GCC_WARN_UNDECLARED_SELECTOR = YES; 482 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 483 | GCC_WARN_UNUSED_FUNCTION = YES; 484 | GCC_WARN_UNUSED_VARIABLE = YES; 485 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 486 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 487 | SDKROOT = iphoneos; 488 | TARGETED_DEVICE_FAMILY = 2; 489 | VALIDATE_PRODUCT = YES; 490 | }; 491 | name = Release; 492 | }; 493 | 4F1FC8741407441600C343D9 /* Debug */ = { 494 | isa = XCBuildConfiguration; 495 | buildSettings = { 496 | CLANG_ENABLE_OBJC_ARC = YES; 497 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 498 | GCC_PREFIX_HEADER = "PSTTreeGraph/PSTTreeGraph-Prefix.pch"; 499 | INFOPLIST_FILE = "PSTTreeGraph/PSTTreeGraph-Info.plist"; 500 | PRODUCT_BUNDLE_IDENTIFIER = "com.prestonsoft.${PRODUCT_NAME:rfc1034identifier}"; 501 | PRODUCT_NAME = "$(TARGET_NAME)"; 502 | WRAPPER_EXTENSION = app; 503 | }; 504 | name = Debug; 505 | }; 506 | 4F1FC8751407441600C343D9 /* Release */ = { 507 | isa = XCBuildConfiguration; 508 | buildSettings = { 509 | CLANG_ENABLE_OBJC_ARC = YES; 510 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 511 | GCC_PREFIX_HEADER = "PSTTreeGraph/PSTTreeGraph-Prefix.pch"; 512 | INFOPLIST_FILE = "PSTTreeGraph/PSTTreeGraph-Info.plist"; 513 | PRODUCT_BUNDLE_IDENTIFIER = "com.prestonsoft.${PRODUCT_NAME:rfc1034identifier}"; 514 | PRODUCT_NAME = "$(TARGET_NAME)"; 515 | WRAPPER_EXTENSION = app; 516 | }; 517 | name = Release; 518 | }; 519 | 4F1FC8771407441600C343D9 /* Debug */ = { 520 | isa = XCBuildConfiguration; 521 | buildSettings = { 522 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/PSTTreeGraph.app/PSTTreeGraph"; 523 | CLANG_ENABLE_OBJC_ARC = YES; 524 | FRAMEWORK_SEARCH_PATHS = ( 525 | "$(SDKROOT)/Developer/Library/Frameworks", 526 | "$(inherited)", 527 | ); 528 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 529 | GCC_PREFIX_HEADER = "PSTTreeGraph/PSTTreeGraph-Prefix.pch"; 530 | INFOPLIST_FILE = "PSTTreeGraphTests/PSTTreeGraphTests-Info.plist"; 531 | PRODUCT_BUNDLE_IDENTIFIER = "com.prestonsoft.${PRODUCT_NAME:rfc1034identifier}"; 532 | PRODUCT_NAME = "$(TARGET_NAME)"; 533 | TEST_HOST = "$(BUNDLE_LOADER)"; 534 | }; 535 | name = Debug; 536 | }; 537 | 4F1FC8781407441600C343D9 /* Release */ = { 538 | isa = XCBuildConfiguration; 539 | buildSettings = { 540 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/PSTTreeGraph.app/PSTTreeGraph"; 541 | CLANG_ENABLE_OBJC_ARC = YES; 542 | FRAMEWORK_SEARCH_PATHS = ( 543 | "$(SDKROOT)/Developer/Library/Frameworks", 544 | "$(inherited)", 545 | ); 546 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 547 | GCC_PREFIX_HEADER = "PSTTreeGraph/PSTTreeGraph-Prefix.pch"; 548 | INFOPLIST_FILE = "PSTTreeGraphTests/PSTTreeGraphTests-Info.plist"; 549 | PRODUCT_BUNDLE_IDENTIFIER = "com.prestonsoft.${PRODUCT_NAME:rfc1034identifier}"; 550 | PRODUCT_NAME = "$(TARGET_NAME)"; 551 | TEST_HOST = "$(BUNDLE_LOADER)"; 552 | }; 553 | name = Release; 554 | }; 555 | /* End XCBuildConfiguration section */ 556 | 557 | /* Begin XCConfigurationList section */ 558 | 4F1FC8351407441500C343D9 /* Build configuration list for PBXProject "PSTTreeGraph" */ = { 559 | isa = XCConfigurationList; 560 | buildConfigurations = ( 561 | 4F1FC8711407441600C343D9 /* Debug */, 562 | 4F1FC8721407441600C343D9 /* Release */, 563 | ); 564 | defaultConfigurationIsVisible = 0; 565 | defaultConfigurationName = Release; 566 | }; 567 | 4F1FC8731407441600C343D9 /* Build configuration list for PBXNativeTarget "PSTTreeGraph" */ = { 568 | isa = XCConfigurationList; 569 | buildConfigurations = ( 570 | 4F1FC8741407441600C343D9 /* Debug */, 571 | 4F1FC8751407441600C343D9 /* Release */, 572 | ); 573 | defaultConfigurationIsVisible = 0; 574 | defaultConfigurationName = Release; 575 | }; 576 | 4F1FC8761407441600C343D9 /* Build configuration list for PBXNativeTarget "PSTTreeGraphTests" */ = { 577 | isa = XCConfigurationList; 578 | buildConfigurations = ( 579 | 4F1FC8771407441600C343D9 /* Debug */, 580 | 4F1FC8781407441600C343D9 /* Release */, 581 | ); 582 | defaultConfigurationIsVisible = 0; 583 | defaultConfigurationName = Release; 584 | }; 585 | /* End XCConfigurationList section */ 586 | }; 587 | rootObject = 4F1FC8321407441500C343D9 /* Project object */; 588 | } 589 | -------------------------------------------------------------------------------- /PSTreeGraphView/PSBaseTreeGraphView.m: -------------------------------------------------------------------------------- 1 | // 2 | // PSBaseTreeGraphView.m 3 | // PSTreeGraphView 4 | // 5 | // Created by Ed Preston on 7/25/10. 6 | // Copyright 2015 Preston Software. All rights reserved. 7 | // 8 | // 9 | // This is a port of the sample code from Max OS X to iOS (iPad). 10 | // 11 | // WWDC 2010 Session 141, “Crafting Custom Cocoa Views” 12 | // 13 | 14 | #import "PSBaseTreeGraphView.h" 15 | #import "PSBaseTreeGraphView_Internal.h" 16 | #import "PSBaseSubtreeView.h" 17 | #import "PSBaseLeafView.h" 18 | 19 | #import "PSTreeGraphDelegate.h" 20 | #import "PSTreeGraphModelNode.h" 21 | 22 | // For displayIfNeeded 23 | #import 24 | 25 | 26 | #pragma mark - Internal Interface 27 | 28 | @interface PSBaseTreeGraphView () 29 | { 30 | 31 | @private 32 | 33 | // Model Object -> SubtreeView Mapping 34 | NSMutableDictionary *_modelNodeToSubtreeViewMapTable; 35 | 36 | // Node View Nib Specification 37 | NSString *_nodeViewNibName; 38 | 39 | // iOS 4 and above ONLY 40 | UINib *_cachedNodeViewNib; 41 | 42 | } 43 | 44 | @end 45 | 46 | 47 | @implementation PSBaseTreeGraphView 48 | 49 | 50 | #pragma mark - Styling 51 | 52 | // Getters and setters for TreeGraph's appearance-related properties: colors, metrics, etc. We could almost 53 | // leave the auto-generated ones, but we want each setter to automatically mark the affected parts 54 | // of the TreeGraph (and/or the descendant views that it's responsible for) as needing drawing to reflet the 55 | // appearance change. In other respects, these are unremarkable accessor methods that follow standard accessor 56 | // conventions. 57 | 58 | 59 | - (void) setConnectingLineColor:(UIColor *)newConnectingLineColor 60 | { 61 | if (_connectingLineColor != newConnectingLineColor) { 62 | _connectingLineColor = newConnectingLineColor; 63 | [self.rootSubtreeView recursiveSetConnectorsViewsNeedDisplay]; 64 | } 65 | } 66 | 67 | - (void) setContentMargin:(CGFloat)newContentMargin 68 | { 69 | if (_contentMargin != newContentMargin) { 70 | _contentMargin = newContentMargin; 71 | [self setNeedsGraphLayout]; 72 | } 73 | } 74 | 75 | - (void) setParentChildSpacing:(CGFloat)newParentChildSpacing 76 | { 77 | if (_parentChildSpacing != newParentChildSpacing) { 78 | _parentChildSpacing = newParentChildSpacing; 79 | [self setNeedsGraphLayout]; 80 | } 81 | } 82 | 83 | - (void) setSiblingSpacing:(CGFloat)newSiblingSpacing 84 | { 85 | if (_siblingSpacing != newSiblingSpacing) { 86 | _siblingSpacing = newSiblingSpacing; 87 | [self setNeedsGraphLayout]; 88 | } 89 | } 90 | 91 | - (void) setTreeGraphOrientation:(PSTreeGraphOrientationStyle)newTreeGraphOrientation 92 | { 93 | if (_treeGraphOrientation != newTreeGraphOrientation) { 94 | _treeGraphOrientation = newTreeGraphOrientation; 95 | [self.rootSubtreeView recursiveSetConnectorsViewsNeedDisplay]; 96 | } 97 | } 98 | 99 | - (void) setTreeGraphFlipped:(BOOL)newTreeGraphFlipped 100 | { 101 | if (_treeGraphFlipped != newTreeGraphFlipped) { 102 | _treeGraphFlipped = newTreeGraphFlipped; 103 | [self.rootSubtreeView recursiveSetConnectorsViewsNeedDisplay]; 104 | } 105 | } 106 | 107 | - (void) setConnectingLineStyle:(PSTreeGraphConnectingLineStyle)newConnectingLineStyle 108 | { 109 | if (_connectingLineStyle != newConnectingLineStyle) { 110 | _connectingLineStyle = newConnectingLineStyle; 111 | [self.rootSubtreeView recursiveSetConnectorsViewsNeedDisplay]; 112 | } 113 | } 114 | 115 | - (void) setConnectingLineWidth:(CGFloat)newConnectingLineWidth { 116 | if (_connectingLineWidth != newConnectingLineWidth) { 117 | _connectingLineWidth = newConnectingLineWidth; 118 | [self.rootSubtreeView recursiveSetConnectorsViewsNeedDisplay]; 119 | } 120 | } 121 | 122 | - (void) setResizesToFillEnclosingScrollView:(BOOL)flag 123 | { 124 | if (_resizesToFillEnclosingScrollView != flag) { 125 | _resizesToFillEnclosingScrollView = flag; 126 | [self updateFrameSizeForContentAndClipView]; 127 | [self updateRootSubtreeViewPositionForSize:self.rootSubtreeView.frame.size]; 128 | } 129 | } 130 | 131 | - (void) setShowsSubtreeFrames:(BOOL)newShowsSubtreeFrames 132 | { // DEBUG 133 | if (_showsSubtreeFrames != newShowsSubtreeFrames) { 134 | _showsSubtreeFrames = newShowsSubtreeFrames; 135 | [self.rootSubtreeView resursiveSetSubtreeBordersNeedDisplay]; 136 | } 137 | } 138 | 139 | 140 | #pragma mark - Initialization 141 | 142 | - (void) configureDefaults 143 | { 144 | self.backgroundColor = [UIColor colorWithRed:0.55 green:0.76 blue:0.93 alpha:1.0]; 145 | //[self setClipsToBounds:YES]; 146 | 147 | // Initialize ivars directly. As a rule, it's best to avoid invoking accessors from an -init... method, 148 | // since they may wrongly expect the instance to be fully formed. 149 | 150 | // May be configured by user in code, loaded from NSCoder, etc 151 | _connectingLineColor = [UIColor blackColor]; 152 | _contentMargin = 20.0; 153 | _parentChildSpacing = 50.0; 154 | _siblingSpacing = 10.0; 155 | _animatesLayout = YES; 156 | _resizesToFillEnclosingScrollView = YES; 157 | _treeGraphFlipped = NO; 158 | _treeGraphOrientation = PSTreeGraphOrientationStyleHorizontal ; 159 | _connectingLineStyle = PSTreeGraphConnectingLineStyleOrthogonal ; 160 | _connectingLineWidth = 1.0; 161 | 162 | // Internal 163 | _layoutAnimationSuppressed = NO; 164 | _showsSubtreeFrames = NO; 165 | _minimumFrameSize = CGSizeMake(2.0 * _contentMargin, 2.0 * _contentMargin); 166 | _selectedModelNodes = [[NSMutableSet alloc] init]; 167 | _modelNodeToSubtreeViewMapTable = [NSMutableDictionary dictionaryWithCapacity:10]; 168 | 169 | // If this has been configured by the XIB, leave it during initialization. 170 | if (_inputView == nil) { 171 | _inputView = [[UIView alloc] initWithFrame:CGRectZero]; 172 | } 173 | } 174 | 175 | 176 | #pragma mark - Resource Management 177 | 178 | - (void) dealloc 179 | { 180 | self.delegate = nil; 181 | } 182 | 183 | 184 | #pragma mark - UIView 185 | 186 | - (instancetype) initWithFrame:(CGRect)frame 187 | { 188 | self = [super initWithFrame:frame]; 189 | if (self) { 190 | [self configureDefaults]; 191 | } 192 | return self; 193 | } 194 | 195 | 196 | #pragma mark - Root SubtreeView Access 197 | 198 | - (PSBaseSubtreeView *) rootSubtreeView 199 | { 200 | return [self subtreeViewForModelNode:self.modelRoot]; 201 | } 202 | 203 | 204 | #pragma mark - Node View Nib Caching 205 | 206 | // iOS 4.0 and above ONLY - 207 | 208 | - (UINib *) cachedNodeViewNib { 209 | return _cachedNodeViewNib; 210 | 211 | // If 3.x Support required, change references to UINib to ID (careful not to modify 212 | // the one below.) uncomment the following code, test. Note: Does not check for valid 213 | // [self nodeViewNibName]. 214 | 215 | // if (!_cachedNodeViewNib) { 216 | // Class cls = NSClassFromString(@"UINib"); 217 | // if ([cls respondsToSelector:@selector(nibWithNibName:bundle:)]) { 218 | // _cachedNodeViewNib = [[cls nibWithNibName:[self nodeViewNibName] bundle:[NSBundle mainBundle]] retain]; 219 | // } 220 | // } 221 | } 222 | 223 | - (void) setCachedNodeViewNib:(UINib *)newNib { 224 | if (_cachedNodeViewNib != newNib) { 225 | _cachedNodeViewNib = newNib; 226 | } 227 | } 228 | 229 | 230 | #pragma mark - Node View Nib Specification 231 | 232 | - (void) setNodeViewNibName:(NSString *)newName 233 | { 234 | if (_nodeViewNibName != newName) { 235 | 236 | // iOS 4.0 and above ONLY 237 | [self setCachedNodeViewNib:nil]; 238 | 239 | _nodeViewNibName = [newName copy]; 240 | 241 | // TODO: Tear down and (later) rebuild view tree. 242 | } 243 | } 244 | 245 | 246 | #pragma mark - Selection State 247 | 248 | // The unordered set of model nodes that are currently selected in the TreeGraph. When 249 | // no nodes are selected, this is an empty NSSet. It will never be nil (and attempting 250 | // to set it to nil is not allowed.). 251 | 252 | - (void) setSelectedModelNodes:(NSSet *)newSelectedModelNodes 253 | { 254 | NSParameterAssert(newSelectedModelNodes != nil); // Never pass nil. Pass [NSSet set] instead. 255 | 256 | // Verify that each of the nodes in the new selection is in the TreeGraph's assigned model tree. 257 | for (id modelNode in newSelectedModelNodes) { 258 | NSAssert([self modelNodeIsInAssignedTree:modelNode], @"modelNode is not in the tree"); 259 | } 260 | 261 | if (_selectedModelNodes != newSelectedModelNodes) { 262 | 263 | // Determine which nodes are changing selection state (either becoming selected, or ceasing to 264 | // be selected), and mark affected areas as needing display. Take the union of the previous and 265 | // new selected node sets, subtract the set of nodes that are in both the old and new selection, 266 | // and the result is the set of nodes whose selection state is changing. 267 | 268 | NSMutableSet *combinedSet = [_selectedModelNodes mutableCopy]; 269 | [combinedSet unionSet:newSelectedModelNodes]; 270 | 271 | NSMutableSet *intersectionSet = [_selectedModelNodes mutableCopy]; 272 | [intersectionSet intersectSet:newSelectedModelNodes]; 273 | 274 | NSMutableSet *differenceSet = [combinedSet mutableCopy]; 275 | [differenceSet minusSet:intersectionSet]; 276 | 277 | // Discard the old selectedModelNodes set and replace it with the new one. 278 | _selectedModelNodes = [newSelectedModelNodes mutableCopy]; 279 | 280 | for (id modelNode in differenceSet) { 281 | PSBaseSubtreeView *subtreeView = [self subtreeViewForModelNode:modelNode]; 282 | UIView *nodeView = subtreeView.nodeView; 283 | if (nodeView && [nodeView isKindOfClass:[PSBaseLeafView class]]) { 284 | // TODO: Selection-highlighting is currently hardwired to our use of ContainerView. 285 | // This should be generalized. 286 | ((PSBaseLeafView *)nodeView).showingSelected = ([newSelectedModelNodes containsObject:modelNode] ? YES : NO); 287 | } 288 | } 289 | 290 | // Release the temporary sets we created. 291 | } 292 | } 293 | 294 | - (id ) singleSelectedModelNode 295 | { 296 | NSSet *selection = self.selectedModelNodes; 297 | return (selection.count == 1) ? [selection anyObject] : nil; 298 | } 299 | 300 | - (CGRect) selectionBounds 301 | { 302 | return [self boundsOfModelNodes:self.selectedModelNodes]; 303 | } 304 | 305 | 306 | #pragma mark - Graph Building 307 | 308 | - (PSBaseSubtreeView *) newGraphForModelNode:(id )modelNode 309 | { 310 | NSParameterAssert(modelNode); 311 | 312 | PSBaseSubtreeView *subtreeView = [[PSBaseSubtreeView alloc] initWithModelNode:modelNode]; 313 | if (subtreeView) { 314 | 315 | // Get nib from which to load nodeView. 316 | UINib *nodeViewNib = self.cachedNodeViewNib; 317 | 318 | if (nodeViewNib == nil) { 319 | NSString *nibName = self.nodeViewNibName; 320 | NSAssert(nibName != nil, 321 | @"You must set a non-nil nodeViewNibName for TreeGraph to be able to build its view tree"); 322 | if (nibName != nil) { 323 | nodeViewNib = [UINib nibWithNibName:self.nodeViewNibName bundle:[NSBundle mainBundle]]; 324 | self.cachedNodeViewNib = nodeViewNib; 325 | } 326 | } 327 | 328 | NSArray *nibViews = nil; 329 | if (nodeViewNib != nil) { 330 | // Instantiate the nib to create our nodeView and associate it with the subtreeView (the nib's owner). 331 | nibViews = [nodeViewNib instantiateWithOwner:subtreeView options:nil]; 332 | } 333 | 334 | if ( nibViews ) { 335 | 336 | // Ask our delete to configure the interface for the modelNode displayed in nodeView. 337 | if ( [self.delegate conformsToProtocol:@protocol(PSTreeGraphDelegate)] ) { 338 | [self.delegate configureNodeView:subtreeView.nodeView withModelNode:modelNode ]; 339 | } 340 | 341 | // Add the nodeView as a subview of the subtreeView. 342 | [subtreeView addSubview:subtreeView.nodeView]; 343 | 344 | // Register the subtreeView in our map table, so we can look it up by its modelNode. 345 | [self setSubtreeView:subtreeView forModelNode:modelNode]; 346 | 347 | // Recurse to create a SubtreeView for each descendant of modelNode. 348 | NSArray *childModelNodes = [modelNode childModelNodes]; 349 | 350 | NSAssert(childModelNodes != nil, 351 | @"childModelNodes should return an empty array ([NSArray array]), not nil."); 352 | 353 | if (childModelNodes != nil) { 354 | for (id childModelNode in childModelNodes) { 355 | PSBaseSubtreeView *childSubtreeView = [self newGraphForModelNode:childModelNode]; 356 | if (childSubtreeView != nil) { 357 | 358 | // Add the child subtreeView behind the parent subtreeView's nodeView (so that when we 359 | // collapse the subtree, its nodeView will remain frontmost). 360 | 361 | [subtreeView insertSubview:childSubtreeView belowSubview:subtreeView.nodeView]; 362 | } 363 | } 364 | } 365 | 366 | } else { 367 | subtreeView = nil; 368 | } 369 | } 370 | 371 | return subtreeView; 372 | } 373 | 374 | - (void) buildGraph 375 | { 376 | @autoreleasepool { 377 | 378 | // Traverse the model tree, building a SubtreeView for each model node. 379 | id root = self.modelRoot; 380 | if (root) { 381 | PSBaseSubtreeView *rootSubtreeView = [self newGraphForModelNode:root]; 382 | if (rootSubtreeView) { 383 | [self addSubview:rootSubtreeView]; 384 | } 385 | } 386 | 387 | } // Drain the pool 388 | } 389 | 390 | 391 | #pragma mark - Layout 392 | 393 | - (void) updateFrameSizeForContentAndClipView 394 | { 395 | CGSize newFrameSize; 396 | CGSize newMinimumFrameSize = self.minimumFrameSize; 397 | 398 | // TODO: Additional checks to ensure we are in a UIScrollView 399 | UIScrollView *enclosingScrollView = (UIScrollView *)self.superview; 400 | 401 | 402 | if ( self.resizesToFillEnclosingScrollView && enclosingScrollView ) { 403 | 404 | // This TreeGraph is a child of a UIScrollView: Size it to always fill the content area (at minimum). 405 | 406 | CGRect contentViewBounds = enclosingScrollView.bounds; 407 | newFrameSize.width = MAX(newMinimumFrameSize.width, contentViewBounds.size.width); 408 | newFrameSize.height = MAX(newMinimumFrameSize.height, contentViewBounds.size.height); 409 | 410 | enclosingScrollView.contentSize = newFrameSize; 411 | 412 | } else { 413 | newFrameSize = newMinimumFrameSize; 414 | } 415 | 416 | self.frame = CGRectMake(self.frame.origin.x, 417 | self.frame.origin.y, 418 | newFrameSize.width, 419 | newFrameSize.height ); 420 | 421 | } 422 | 423 | - (void) updateRootSubtreeViewPositionForSize:(CGSize)rootSubtreeViewSize 424 | { 425 | // Position the rootSubtreeView within the TreeGraph. 426 | PSBaseSubtreeView *rootSubtreeView = self.rootSubtreeView; 427 | 428 | // BOOL animateLayout = [self animatesLayout] && ![self layoutAnimationSuppressed]; 429 | CGPoint newOrigin; 430 | if ( self.resizesToFillEnclosingScrollView ) { 431 | CGRect bounds = self.bounds; 432 | 433 | if (( self.treeGraphOrientation == PSTreeGraphOrientationStyleHorizontal ) || 434 | ( self.treeGraphOrientation == PSTreeGraphOrientationStyleHorizontalFlipped )){ 435 | newOrigin = CGPointMake(self.contentMargin, 436 | 0.5 * (bounds.size.height - rootSubtreeViewSize.height)); 437 | } else { 438 | newOrigin = CGPointMake(0.5 * (bounds.size.width - rootSubtreeViewSize.width), 439 | self.contentMargin); 440 | } 441 | 442 | } else { 443 | newOrigin = CGPointMake(self.contentMargin, 444 | self.contentMargin); 445 | } 446 | 447 | // [(animateLayout ? [rootSubtreeView animator] : rootSubtreeView) setFrameOrigin:newOrigin]; 448 | 449 | rootSubtreeView.frame = CGRectMake(newOrigin.x, 450 | newOrigin.y, 451 | rootSubtreeView.frame.size.width, 452 | rootSubtreeView.frame.size.height ); 453 | 454 | } 455 | 456 | - (void) parentClipViewDidResize:(id)object 457 | { 458 | UIScrollView *enclosingScrollView = (UIScrollView *)self.superview; 459 | 460 | if ( enclosingScrollView && [enclosingScrollView isKindOfClass:[UIScrollView class]] ) { 461 | [self updateFrameSizeForContentAndClipView]; 462 | [self updateRootSubtreeViewPositionForSize:self.rootSubtreeView.frame.size]; 463 | [self scrollSelectedModelNodesToVisibleAnimated:NO]; 464 | } 465 | } 466 | 467 | - (void) layoutSubviews 468 | { 469 | // Do graph layout if we need to. 470 | [self layoutGraphIfNeeded]; 471 | } 472 | 473 | - (CGSize) layoutGraphIfNeeded 474 | { 475 | PSBaseSubtreeView *rootSubtreeView = self.rootSubtreeView; 476 | if ([self needsGraphLayout] && self.modelRoot) { 477 | 478 | // Do recursive graph layout, starting at our rootSubtreeView. 479 | CGSize rootSubtreeViewSize = [rootSubtreeView layoutGraphIfNeeded]; 480 | 481 | // Compute self's new minimumFrameSize. Make sure it's pixel-integral. 482 | CGFloat margin = self.contentMargin; 483 | CGSize minimumBoundsSize = CGSizeMake(rootSubtreeViewSize.width + 2.0 * margin, 484 | rootSubtreeViewSize.height + 2.0 * margin); 485 | 486 | _minimumFrameSize = minimumBoundsSize; 487 | 488 | // Set the TreeGraph's frame size. 489 | [self updateFrameSizeForContentAndClipView]; 490 | 491 | // Position the TreeGraph's root SubtreeView. 492 | [self updateRootSubtreeViewPositionForSize:rootSubtreeViewSize]; 493 | 494 | if (( self.treeGraphOrientation == PSTreeGraphOrientationStyleHorizontalFlipped ) || 495 | ( self.treeGraphOrientation == PSTreeGraphOrientationStyleVerticalFlipped )){ 496 | [rootSubtreeView flipTreeGraph]; 497 | } 498 | return rootSubtreeViewSize; 499 | } else { 500 | return rootSubtreeView ? rootSubtreeView.frame.size : CGSizeZero; 501 | } 502 | } 503 | 504 | - (BOOL) needsGraphLayout 505 | { 506 | return self.rootSubtreeView.needsGraphLayout; 507 | } 508 | 509 | - (void) setNeedsGraphLayout 510 | { 511 | [self.rootSubtreeView recursiveSetNeedsGraphLayout]; 512 | } 513 | 514 | - (void) collapseRoot 515 | { 516 | [self.rootSubtreeView setExpanded:NO]; 517 | } 518 | 519 | - (void) expandRoot 520 | { 521 | [self.rootSubtreeView setExpanded:YES]; 522 | } 523 | 524 | - (IBAction) toggleExpansionOfSelectedModelNodes:(id)sender 525 | { 526 | for (id modelNode in self.selectedModelNodes) { 527 | PSBaseSubtreeView *subtreeView = [self subtreeViewForModelNode:modelNode]; 528 | [subtreeView toggleExpansion:sender]; 529 | } 530 | } 531 | 532 | 533 | #pragma mark - Scrolling 534 | 535 | - (CGRect) boundsOfModelNodes:(NSSet *)modelNodes 536 | { 537 | CGRect boundingBox = CGRectZero; 538 | BOOL firstNodeFound = NO; 539 | for (id modelNode in modelNodes) { 540 | PSBaseSubtreeView *subtreeView = [self subtreeViewForModelNode:modelNode]; 541 | if ( subtreeView && (subtreeView.hidden == NO) ) { 542 | UIView *nodeView = subtreeView.nodeView; 543 | if (nodeView) { 544 | CGRect rect = [self convertRect:nodeView.bounds fromView:nodeView]; 545 | 546 | if (!firstNodeFound) { 547 | // The first node found gives us the starting boundingBox, after 548 | // that we take the take union of each successive node. 549 | boundingBox = rect; 550 | firstNodeFound = YES; 551 | } else { 552 | boundingBox = CGRectUnion(boundingBox, rect); 553 | } 554 | } 555 | } 556 | } 557 | 558 | return boundingBox; 559 | } 560 | 561 | - (void) scrollModelNodesToVisible:(NSSet *)modelNodes animated:(BOOL)animated 562 | { 563 | CGRect targetRect = [self boundsOfModelNodes:modelNodes]; 564 | if (!CGRectIsEmpty(targetRect)) { 565 | CGFloat padding = self.contentMargin; 566 | 567 | UIScrollView *parentScroll = (UIScrollView *)self.superview; 568 | 569 | if ( parentScroll && [parentScroll isKindOfClass:[UIScrollView class]] ) { 570 | targetRect = CGRectInset(targetRect, -padding, -padding); 571 | // NSLog(@"Scrolling to target rect: %@", NSStringFromCGRect(targetRect) ); 572 | [parentScroll scrollRectToVisible:targetRect animated:animated]; 573 | } 574 | } 575 | } 576 | 577 | - (void) scrollSelectedModelNodesToVisibleAnimated:(BOOL)animated 578 | { 579 | [self scrollModelNodesToVisible:self.selectedModelNodes animated:animated]; 580 | } 581 | 582 | 583 | #pragma mark - Data Source 584 | 585 | - (void) setModelRoot:(id )newModelRoot 586 | { 587 | NSParameterAssert(newModelRoot == nil || [newModelRoot conformsToProtocol:@protocol(PSTreeGraphModelNode)]); 588 | 589 | if ( _modelRoot != newModelRoot ) { 590 | PSBaseSubtreeView *rootSubtreeView = self.rootSubtreeView; 591 | [rootSubtreeView removeFromSuperview]; 592 | [_modelNodeToSubtreeViewMapTable removeAllObjects]; 593 | 594 | // Discard any previous selection. 595 | self.selectedModelNodes = [NSSet set]; 596 | 597 | // Switch to new modelRoot. 598 | _modelRoot = newModelRoot; 599 | 600 | // Discard and reload content. 601 | [self buildGraph]; 602 | [self setNeedsDisplay]; 603 | [self.rootSubtreeView resursiveSetSubtreeBordersNeedDisplay]; 604 | [self layoutGraphIfNeeded]; 605 | 606 | // Start with modelRoot selected. 607 | if ( _modelRoot ) { 608 | self.selectedModelNodes = [NSSet setWithObject:_modelRoot]; 609 | [self scrollSelectedModelNodesToVisibleAnimated:NO]; 610 | } 611 | } 612 | } 613 | 614 | 615 | #pragma mark - NSCoding 616 | 617 | - (void) encodeWithCoder:(NSCoder *)encoder 618 | { 619 | [super encodeWithCoder:encoder]; 620 | [encoder encodeBool:_animatesLayout forKey:@"animatesLayout"]; 621 | [encoder encodeFloat:_contentMargin forKey:@"contentMargin"]; 622 | [encoder encodeFloat:_parentChildSpacing forKey:@"parentChildSpacing"]; 623 | [encoder encodeFloat:_siblingSpacing forKey:@"siblingSpacing"]; 624 | [encoder encodeBool:_resizesToFillEnclosingScrollView forKey:@"resizesToFillEnclosingScrollView"]; 625 | [encoder encodeObject:_connectingLineColor forKey:@"connectingLineColor"]; 626 | [encoder encodeFloat:_connectingLineWidth forKey:@"connectingLineWidth"]; 627 | 628 | [encoder encodeInt:_treeGraphOrientation forKey:@"treeGraphOrientation"]; 629 | [encoder encodeInt:_connectingLineStyle forKey:@"connectingLineStyle"]; 630 | } 631 | 632 | - (instancetype) initWithCoder:(NSCoder *)decoder 633 | { 634 | self = [super initWithCoder:decoder]; 635 | if (self) { 636 | 637 | [self configureDefaults]; 638 | 639 | if ([decoder containsValueForKey:@"animatesLayout"]) 640 | _animatesLayout = [decoder decodeBoolForKey:@"animatesLayout"]; 641 | if ([decoder containsValueForKey:@"contentMargin"]) 642 | _contentMargin = [decoder decodeFloatForKey:@"contentMargin"]; 643 | if ([decoder containsValueForKey:@"parentChildSpacing"]) 644 | _parentChildSpacing = [decoder decodeFloatForKey:@"parentChildSpacing"]; 645 | if ([decoder containsValueForKey:@"siblingSpacing"]) 646 | _siblingSpacing = [decoder decodeFloatForKey:@"siblingSpacing"]; 647 | if ([decoder containsValueForKey:@"resizesToFillEnclosingScrollView"]) 648 | _resizesToFillEnclosingScrollView = [decoder decodeBoolForKey:@"resizesToFillEnclosingScrollView"]; 649 | if ([decoder containsValueForKey:@"connectingLineColor"]) 650 | _connectingLineColor = [decoder decodeObjectForKey:@"connectingLineColor"]; 651 | if ([decoder containsValueForKey:@"connectingLineWidth"]) 652 | _connectingLineWidth = [decoder decodeFloatForKey:@"connectingLineWidth"]; 653 | 654 | if ([decoder containsValueForKey:@"treeGraphOrientation"]) 655 | _treeGraphOrientation = [decoder decodeIntForKey:@"treeGraphOrientation"]; 656 | if ([decoder containsValueForKey:@"connectingLineStyle"]) 657 | _connectingLineStyle = [decoder decodeIntForKey:@"connectingLineStyle"]; 658 | } 659 | return self; 660 | } 661 | 662 | 663 | #pragma mark - Node Hit-Testing 664 | 665 | // Returns the model node under the given point, which must be expressed in the 666 | // TreeGraph's interior (bounds) coordinate space. If there is a collapsed subtree at the 667 | // given point, returns the model node at the root of the collapsed subtree. If there is 668 | // no model node at the given point, returns nil. 669 | 670 | - (id ) modelNodeAtPoint:(CGPoint)p 671 | { 672 | // Since we've composed our content using views (SubtreeViews and enclosed nodeViews), 673 | // we can use UIView's -hitTest: method to easily identify our deepest descendant view 674 | // under the given point. We rely on the front-to-back order of hit-testing to ensure 675 | // that we return the root of a collapsed subtree, instead of one of its descendant nodes. 676 | // (To do this, we must make sure, when collapsing a subtree, to keep the SubtreeView's 677 | // nodeView frontmost among its siblings.) 678 | 679 | PSBaseSubtreeView *rootSubtreeView = self.rootSubtreeView; 680 | CGPoint subviewPoint = [self convertPoint:p toView:rootSubtreeView]; 681 | id hitModelNode = [self.rootSubtreeView modelNodeAtPoint:subviewPoint]; 682 | 683 | return hitModelNode; 684 | } 685 | 686 | 687 | #pragma mark - Input and Navigation 688 | 689 | - (BOOL) canBecomeFirstResponder 690 | { 691 | // Make TreeGraphs able to -canBecomeFirstResponder, so they can receive key events. 692 | return YES; 693 | } 694 | 695 | -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 696 | { 697 | UITouch *touch = [touches anyObject]; 698 | CGPoint viewPoint = [touch locationInView:self]; 699 | 700 | // Identify the mdoel node (if any) that the user clicked, and make it the new selection. 701 | id hitModelNode = [self modelNodeAtPoint:viewPoint]; 702 | self.selectedModelNodes = (hitModelNode ? [NSSet setWithObject:hitModelNode] : [NSSet set]); 703 | 704 | // Respond to touch and become first responder. 705 | [self becomeFirstResponder]; 706 | } 707 | 708 | - (void) moveToSiblingByRelativeIndex:(NSInteger)relativeIndex 709 | { 710 | id modelNode = self.singleSelectedModelNode; 711 | if (modelNode) { 712 | id sibling = [self siblingOfModelNode:modelNode atRelativeIndex:relativeIndex]; 713 | if (sibling) { 714 | self.selectedModelNodes = [NSSet setWithObject:sibling]; 715 | } 716 | } else if (self.selectedModelNodes.count == 0) { 717 | // If nothing selected, select root. 718 | self.selectedModelNodes = (self.modelRoot ? [NSSet setWithObject:self.modelRoot] : nil); 719 | } 720 | 721 | // Scroll new selection to visible. 722 | [self scrollSelectedModelNodesToVisibleAnimated:YES]; 723 | } 724 | 725 | - (IBAction) moveToParent:(id)sender 726 | { 727 | id modelNode = self.singleSelectedModelNode; 728 | if (modelNode) { 729 | if (modelNode != self.modelRoot) { 730 | id parent = [modelNode parentModelNode]; 731 | if (parent) { 732 | self.selectedModelNodes = [NSSet setWithObject:parent]; 733 | } 734 | } 735 | } else if (self.selectedModelNodes.count == 0) { 736 | // If nothing selected, select root. 737 | self.selectedModelNodes = (self.modelRoot ? [NSSet setWithObject:self.modelRoot] : nil); 738 | } 739 | 740 | // Scroll new selection to visible. 741 | [self scrollSelectedModelNodesToVisibleAnimated:YES]; 742 | } 743 | 744 | - (IBAction) moveToNearestChild:(id)sender 745 | { 746 | id modelNode = self.singleSelectedModelNode; 747 | if (modelNode) { 748 | PSBaseSubtreeView *subtreeView = [self subtreeViewForModelNode:modelNode]; 749 | if (subtreeView && subtreeView.expanded) { 750 | UIView *nodeView = subtreeView.nodeView; 751 | if (nodeView) { 752 | CGRect nodeViewFrame = nodeView.frame; 753 | id nearestChild = nil; 754 | if (( self.treeGraphOrientation == PSTreeGraphOrientationStyleHorizontal ) || 755 | ( self.treeGraphOrientation == PSTreeGraphOrientationStyleHorizontalFlipped )){ 756 | nearestChild = [subtreeView modelNodeClosestToY:CGRectGetMidY(nodeViewFrame)]; 757 | } else { 758 | nearestChild = [subtreeView modelNodeClosestToX:CGRectGetMidX(nodeViewFrame)]; 759 | } 760 | if (nearestChild != nil) { 761 | self.selectedModelNodes = [NSSet setWithObject:nearestChild]; 762 | } 763 | } 764 | } 765 | } else if (self.selectedModelNodes.count == 0) { 766 | // If nothing selected, select root. 767 | self.selectedModelNodes = (self.modelRoot ? [NSSet setWithObject:self.modelRoot] : nil); 768 | } 769 | 770 | // Scroll new selection to visible. 771 | [self scrollSelectedModelNodesToVisibleAnimated:YES]; 772 | } 773 | 774 | - (void) moveUp:(id)sender 775 | { 776 | if (( self.treeGraphOrientation == PSTreeGraphOrientationStyleHorizontal ) || 777 | ( self.treeGraphOrientation == PSTreeGraphOrientationStyleHorizontalFlipped )){ 778 | [self moveToSiblingByRelativeIndex:1]; 779 | } else { 780 | [self moveToParent:sender]; 781 | } 782 | 783 | } 784 | 785 | - (void) moveDown:(id)sender 786 | { 787 | if (( self.treeGraphOrientation == PSTreeGraphOrientationStyleHorizontal ) || 788 | ( self.treeGraphOrientation == PSTreeGraphOrientationStyleHorizontalFlipped )){ 789 | [self moveToSiblingByRelativeIndex:-1]; 790 | } else { 791 | [self moveToNearestChild:sender]; 792 | } 793 | 794 | } 795 | 796 | - (void) moveLeft:(id)sender 797 | { 798 | if (( self.treeGraphOrientation == PSTreeGraphOrientationStyleHorizontal ) || 799 | ( self.treeGraphOrientation == PSTreeGraphOrientationStyleHorizontalFlipped )){ 800 | [self moveToParent:sender]; 801 | } else { 802 | [self moveToSiblingByRelativeIndex:1]; 803 | } 804 | 805 | } 806 | 807 | - (void) moveRight:(id)sender 808 | { 809 | if (( self.treeGraphOrientation == PSTreeGraphOrientationStyleHorizontal ) || 810 | ( self.treeGraphOrientation == PSTreeGraphOrientationStyleHorizontalFlipped )){ 811 | [self moveToNearestChild:sender]; 812 | } else { 813 | [self moveToSiblingByRelativeIndex:-1]; 814 | } 815 | 816 | } 817 | 818 | 819 | #pragma mark UIKeyInput Protocol Methods 820 | 821 | - (BOOL) hasText 822 | { 823 | if ( self.modelRoot != nil ) { 824 | return YES; 825 | } 826 | return NO; 827 | } 828 | 829 | - (void) insertText:(NSString *)theText 830 | { 831 | // Hardware keyboard, desktop keyboard in simulator support. 832 | if (theText && theText.length > 0) { 833 | switch ([theText characterAtIndex:0]) { 834 | case ' ': 835 | [self toggleExpansionOfSelectedModelNodes:self]; 836 | break; 837 | case 'w': 838 | if (self.treeGraphOrientation == PSTreeGraphOrientationStyleVerticalFlipped ) { 839 | [self moveDown:self]; 840 | } else { 841 | [self moveUp:self]; 842 | } 843 | break; 844 | case 'a': 845 | if (self.treeGraphOrientation == PSTreeGraphOrientationStyleHorizontalFlipped ) { 846 | [self moveRight:self]; 847 | } else { 848 | [self moveLeft:self]; 849 | } 850 | break; 851 | case 's': 852 | if (self.treeGraphOrientation == PSTreeGraphOrientationStyleVerticalFlipped ) { 853 | [self moveUp:self]; 854 | } else { 855 | [self moveDown:self]; 856 | } 857 | break; 858 | case 'd': 859 | if (self.treeGraphOrientation == PSTreeGraphOrientationStyleHorizontalFlipped ) { 860 | [self moveLeft:self]; 861 | } else { 862 | [self moveRight:self]; 863 | } 864 | break; 865 | 866 | default: 867 | // Input from keyboard or other device not handled. 868 | break; 869 | } 870 | } 871 | } 872 | 873 | - (void) deleteBackward 874 | { 875 | [self moveLeft:nil]; 876 | } 877 | 878 | 879 | #pragma mark - Gesture Event Handling 880 | 881 | //- (void) beginGestureWithEvent:(NSEvent *)event { 882 | // // Temporarily suspend layout animations during handling of a gesture sequence. 883 | // [self setLayoutAnimationSuppressed:YES]; 884 | //} 885 | // 886 | //- (void) endGestureWithEvent:(NSEvent *)event { 887 | // // Re-enable layout animations at the end of a gesture sequence. 888 | // [self setLayoutAnimationSuppressed:NO]; 889 | //} 890 | // 891 | //- (void) magnifyWithEvent:(NSEvent *)event { 892 | // CGFloat spacing = [self parentChildSpacing]; 893 | // spacing = spacing * (1.0 + [event magnification]); 894 | // [self setParentChildSpacing:spacing]; 895 | //} 896 | // 897 | //- (void) swipeWithEvent:(NSEvent *)event { 898 | // // Expand or collapse the entire tree according to the direction of the swipe. 899 | // // (An alternative behavior might be to identify node under mouse, and 900 | // // collapse/expand that instead of root node.) 901 | // 902 | // CGFloat deltaX = [event deltaX]; 903 | // if (deltaX < 0.0) { 904 | // // Swipe was to the right. 905 | // [self expandRoot]; 906 | // } else if (deltaX > 0.0) { 907 | // // Swipe was to the left. 908 | // [self collapseRoot]; 909 | // } 910 | //} 911 | 912 | 913 | @end 914 | 915 | 916 | #pragma mark - 917 | @implementation PSBaseTreeGraphView (Internal) 918 | 919 | 920 | #pragma mark - ModelNode -> SubtreeView Relationship Management 921 | 922 | - (PSBaseSubtreeView *) subtreeViewForModelNode:(id)modelNode 923 | { 924 | return _modelNodeToSubtreeViewMapTable[modelNode]; 925 | } 926 | 927 | - (void) setSubtreeView:(PSBaseSubtreeView *)subtreeView forModelNode:(id)modelNode 928 | { 929 | _modelNodeToSubtreeViewMapTable[modelNode] = subtreeView; 930 | } 931 | 932 | 933 | #pragma mark - Model Tree Navigation 934 | 935 | - (BOOL) modelNode:(id )modelNode 936 | isDescendantOf:(id )possibleAncestor 937 | { 938 | NSParameterAssert(modelNode != nil); 939 | NSParameterAssert(possibleAncestor != nil); 940 | 941 | id node = [modelNode parentModelNode]; 942 | while (node != nil) { 943 | if (node == possibleAncestor) { 944 | return YES; 945 | } 946 | node = [node parentModelNode]; 947 | } 948 | return NO; 949 | } 950 | 951 | - (BOOL) modelNodeIsInAssignedTree:(id )modelNode 952 | { 953 | NSParameterAssert(modelNode != nil); 954 | 955 | id root = self.modelRoot; 956 | return (modelNode == root || [self modelNode:modelNode isDescendantOf:root]) ? YES : NO; 957 | } 958 | 959 | - (id ) siblingOfModelNode:(id )modelNode 960 | atRelativeIndex:(NSInteger)relativeIndex 961 | { 962 | NSParameterAssert(modelNode != nil); 963 | NSAssert([self modelNodeIsInAssignedTree:modelNode], @"modelNode is not in the tree"); 964 | 965 | if (modelNode == self.modelRoot) { 966 | // modelNode is modelRoot. Disallow traversal to its siblings (if it has any). 967 | return nil; 968 | } else { 969 | // modelNode is a descendant of modelRoot. 970 | // Find modelNode's position in its parent node's array of children. 971 | id parent = [modelNode parentModelNode]; 972 | NSArray *siblings = [parent childModelNodes]; 973 | 974 | NSAssert(siblings != nil, 975 | @"childModelNodes should return an empty array ([NSArray array]), not nil."); 976 | 977 | if (siblings != nil) { 978 | NSInteger index = [siblings indexOfObject:modelNode]; 979 | if (index != NSNotFound) { 980 | index += relativeIndex; 981 | if (index >= 0 && index < siblings.count) { 982 | return siblings[index]; 983 | } 984 | } 985 | } 986 | return nil; 987 | } 988 | } 989 | 990 | 991 | @end --------------------------------------------------------------------------------