Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: cb6bcdde24
Fetching contributors…

Cannot retrieve contributors at this time

file 138 lines (95 sloc) 3.452 kb
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
//
// PSHTreeGraphViewController.m
// PSHTreeGraph - Example 1
//
// Created by Ed Preston on 7/25/10.
// Copyright Preston Software 2010. All rights reserved.
//


#import "PSHTreeGraphViewController.h"

#import "PSBaseTreeGraphView.h"
#import "MyLeafView.h"

#import "ObjCClassWrapper.h"


#pragma mark - Internal Interface

@interface PSHTreeGraphViewController ()
{

@private
PSBaseTreeGraphView *treeGraphView_;
NSString *rootClassName_;
}

@end


@implementation PSHTreeGraphViewController


#pragma mark - Property Accessors

@synthesize treeGraphView = treeGraphView_;
@synthesize rootClassName = rootClassName_;

- (void) setRootClassName:(NSString *)newRootClassName
{
    NSParameterAssert(newRootClassName != nil);

    if (![rootClassName_ isEqualToString:newRootClassName]) {
        [rootClassName_ release];
        rootClassName_ = [newRootClassName copy];

        treeGraphView_.treeGraphOrientation = PSTreeGraphOrientationStyleHorizontalFlipped;

        // Get an ObjCClassWrapper for the named Objective-C Class, and set it as the TreeGraph's root.
        [treeGraphView_ setModelRoot:[ObjCClassWrapper wrapperForClassNamed:rootClassName_]];
    }
}


#pragma mark - View Creation and Initializer

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void) viewDidLoad
{
    [super viewDidLoad];

// Set the delegate to self.
[self.treeGraphView setDelegate:self];

// Specify a .nib file for the TreeGraph to load each time it needs to create a new node view.
    [self.treeGraphView setNodeViewNibName:@"ObjCClassTreeNodeView"];

    // Specify a starting root class to inspect on launch.
    
    [self setRootClassName:@"UIControl"];
    
    // The system includes some other abstract base classes that are interesting:
    // [self setRootClassName:@"CAAnimation"];

}

// Override to allow orientations other than the default portrait orientation.
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
                                         duration:(NSTimeInterval)duration
{
// Keep the view in sync
[self.treeGraphView parentClipViewDidResize:nil];
}


#pragma mark - TreeGraph Delegate

-(void) configureNodeView:(UIView *)nodeView
            withModelNode:(id <PSTreeGraphModelNode> )modelNode
{
    NSParameterAssert(nodeView != nil);
    NSParameterAssert(modelNode != nil);

// NOT FLEXIBLE: treat it like a model node instead of the interface.
ObjCClassWrapper *objectWrapper = (ObjCClassWrapper *)modelNode;
MyLeafView *leafView = (MyLeafView *)nodeView;

// button
if ( [[objectWrapper childModelNodes] count] == 0 ) {
[leafView.expandButton setHidden:YES];
}

// labels
leafView.titleLabel.text = [objectWrapper name];
leafView.detailLabel.text = [NSString stringWithFormat:@"%zd bytes",
                                   [objectWrapper wrappedClassInstanceSize]];

}


#pragma mark - Resouce Management

- (void) didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

- (void) viewDidUnload
{
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}

- (void) dealloc
{
[rootClassName_ release];
    [super dealloc];
}

@end
Something went wrong with that request. Please try again.