Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated property declarations in most headers

Most property declarations did not have very specific attributes.
  • Loading branch information...
commit 616f319ebd37f2774a3adec995a73e699b877814 1 parent 347003d
@epreston authored
View
21 Example 1/Classes/Controller/PSHTreeGraphAppDelegate.m
@@ -18,8 +18,8 @@ @implementation PSHTreeGraphAppDelegate
#pragma mark - Application Lifecycle
-- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
-
+- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
// Override point for customization after app launch.
[window addSubview:viewController.view];
[window makeKeyAndVisible];
@@ -28,7 +28,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
}
-- (void)applicationWillResignActive:(UIApplication *)application {
+- (void) applicationWillResignActive:(UIApplication *)application
+{
// Sent when the application is about to move from active to inactive state. This can occur for
// certain types of temporary interruptions (such as an incoming phone call or SMS message) or
// when the user quits the application and it begins the transition to the background state.
@@ -38,26 +39,30 @@ - (void)applicationWillResignActive:(UIApplication *)application {
}
-- (void)applicationDidBecomeActive:(UIApplication *)application {
+- (void) applicationDidBecomeActive:(UIApplication *)application
+{
// Restart any tasks that were paused (or not yet started) while the application was inactive.
// If the application was previously in the background, optionally refresh the user interface.
}
-- (void)applicationWillTerminate:(UIApplication *)application {
+- (void) applicationWillTerminate:(UIApplication *)application
+{
// Called when the application is about to terminate.
// See also applicationDidEnterBackground:.
}
-#pragma mark - Memory Management
+#pragma mark - Resouce Management
-- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
+- (void) applicationDidReceiveMemoryWarning:(UIApplication *)application
+{
// Free up as much memory as possible by purging cached data objects that can be recreated
// (or reloaded from disk) later.
}
-- (void)dealloc {
+- (void) dealloc
+{
[viewController release];
[window release];
[super dealloc];
View
4 Example 1/Classes/Controller/PSHTreeGraphViewController.h
@@ -19,10 +19,10 @@
}
// The TreeGraph
-@property(assign) IBOutlet PSBaseTreeGraphView *treeGraphView;
+@property(nonatomic, assign) IBOutlet PSBaseTreeGraphView *treeGraphView;
// The name of the root class that the TreeGraph is currently showing.
-@property(copy) NSString *rootClassName;
+@property(nonatomic, copy) NSString *rootClassName;
@end
View
48 Example 1/Classes/Controller/PSHTreeGraphViewController.m
@@ -22,12 +22,13 @@ @implementation PSHTreeGraphViewController
@synthesize treeGraphView;
-- (NSString *)rootClassName {
+- (NSString *) rootClassName
+{
return rootClassName;
}
-- (void)setRootClassName:(NSString *)newRootClassName {
-
+- (void) setRootClassName:(NSString *)newRootClassName
+{
NSParameterAssert(newRootClassName != nil);
if (![rootClassName isEqualToString:newRootClassName]) {
@@ -42,22 +43,9 @@ - (void)setRootClassName:(NSString *)newRootClassName {
#pragma mark - View Creation and Initializer
-// The designated initializer. Override to perform setup that is required before the view is loaded.
-//- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
-// if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
-// // Custom initialization
-// }
-// return self;
-//}
-
-
-// Implement loadView to create a view hierarchy programmatically, without using a nib.
-//- (void)loadView {
-//}
-
-
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
-- (void)viewDidLoad {
+- (void) viewDidLoad
+{
[super viewDidLoad];
// Set the delegate to self.
@@ -72,13 +60,14 @@ - (void)viewDidLoad {
// Override to allow orientations other than the default portrait orientation.
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
+- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
return YES;
}
-- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
- duration:(NSTimeInterval)duration {
-
+- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+ duration:(NSTimeInterval)duration
+{
// Keep the view in sync
[treeGraphView parentClipViewDidResize:nil];
}
@@ -87,8 +76,8 @@ - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interf
#pragma mark - TreeGraph Delegate
-(void) configureNodeView:(UIView *)nodeView
- withModelNode:(id <PSTreeGraphModelNode> )modelNode {
-
+ withModelNode:(id <PSTreeGraphModelNode> )modelNode
+{
NSParameterAssert(nodeView != nil);
NSParameterAssert(modelNode != nil);
@@ -108,21 +97,24 @@ -(void) configureNodeView:(UIView *)nodeView
}
-#pragma mark - Memory Management
+#pragma mark - Resouce Management
-- (void)didReceiveMemoryWarning {
+- (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 {
+- (void) viewDidUnload
+{
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
-- (void)dealloc {
+- (void) dealloc
+{
[rootClassName release];
[super dealloc];
}
View
12 Example 1/Classes/Model/ObjCClass/ObjCClassWrapper.h
@@ -26,32 +26,32 @@
// Returns an ObjCClassWrapper for the given Objective-C class. ObjCClassWrapper maintains
// a set of unique instances, so this will always return the same ObjCClassWrapper for a given Class.
-+ (ObjCClassWrapper *)wrapperForClass:(Class)aClass;
++ (ObjCClassWrapper *) wrapperForClass:(Class)aClass;
// Returns an ObjCClassWrapper for the given Objective-C class, by looking the Class up by
// name and then invoking +wrapperForClass:
-+ (ObjCClassWrapper *)wrapperForClassNamed:(NSString *)aClassName;
++ (ObjCClassWrapper *) wrapperForClassNamed:(NSString *)aClassName;
#pragma mark - Property Accessors
// The wrappedClass' name (e.g. @"UIButton")
-@property(readonly) NSString *name;
+@property (nonatomic, readonly) NSString *name;
// An ObjCClassWrapper representing the wrappedClass' superclass.
-@property(readonly) ObjCClassWrapper *superclassWrapper;
+@property (nonatomic, readonly) ObjCClassWrapper *superclassWrapper;
// An array of ObjCClassWrappers representing the wrappedClass' subclasses.
// (For convenience, the subclasses are sorted by name.)
-@property(readonly) NSArray *subclasses;
+@property (nonatomic, readonly) NSArray *subclasses;
// The wrappedClass' intrinsic instance size (which doesn't include external/auxiliary storage).
-@property(readonly) size_t wrappedClassInstanceSize;
+@property (nonatomic, readonly) size_t wrappedClassInstanceSize;
@end
View
43 Example 1/Classes/Model/ObjCClass/ObjCClassWrapper.m
@@ -15,9 +15,11 @@
static NSMutableDictionary *classToWrapperMapTable = nil;
+
// Compares two ObjCClassWrappers by name, and returns an NSComparisonResult.
-static NSInteger CompareClassNames(id classA, id classB, void* context) {
+static NSInteger CompareClassNames(id classA, id classB, void* context)
+{
return [[classA description] compare:[classB description]];
}
@@ -26,14 +28,16 @@ static NSInteger CompareClassNames(id classA, id classB, void* context) {
@implementation ObjCClassWrapper
-- (id)copyWithZone:(NSZone *)zone {
+- (id) copyWithZone:(NSZone *)zone
+{
return [self retain];
}
#pragma mark - Creating Instances
-- initWithWrappedClass:(Class)aClass {
+- initWithWrappedClass:(Class)aClass
+{
self = [super init];
if (self) {
if (aClass != Nil) {
@@ -50,7 +54,8 @@ - (id)copyWithZone:(NSZone *)zone {
return self;
}
-+ (ObjCClassWrapper *)wrapperForClass:(Class)aClass {
++ (ObjCClassWrapper *) wrapperForClass:(Class)aClass
+{
ObjCClassWrapper *wrapper = [classToWrapperMapTable objectForKey:aClass];
if (wrapper == nil) {
wrapper = [[[self alloc] initWithWrappedClass:aClass] autorelease];
@@ -58,31 +63,36 @@ + (ObjCClassWrapper *)wrapperForClass:(Class)aClass {
return wrapper;
}
-+ (ObjCClassWrapper *)wrapperForClassNamed:(NSString *)aClassName {
++ (ObjCClassWrapper *) wrapperForClassNamed:(NSString *)aClassName
+{
return [self wrapperForClass:NSClassFromString(aClassName)];
}
#pragma mark - Property Accessors
-- (NSString *)name {
+- (NSString *) name
+{
return NSStringFromClass(wrappedClass);
}
-- (NSString *)description {
+- (NSString *) description
+{
return [self name];
}
-- (size_t)wrappedClassInstanceSize {
+- (size_t) wrappedClassInstanceSize
+{
return class_getInstanceSize(wrappedClass);
}
-- (ObjCClassWrapper *)superclassWrapper {
+- (ObjCClassWrapper *) superclassWrapper
+{
return [[self class] wrapperForClass:class_getSuperclass(wrappedClass)];
}
-- (NSArray *)subclasses {
-
+- (NSArray *) subclasses
+{
// If we haven't built our array of subclasses yet, do so.
if (subclassesCache == nil) {
@@ -115,18 +125,21 @@ - (NSArray *)subclasses {
#pragma mark - TreeGraphModelNode Protocol
-- (id <PSTreeGraphModelNode> )parentModelNode {
+- (id <PSTreeGraphModelNode> ) parentModelNode
+{
return [self superclassWrapper];
}
-- (NSArray *)childModelNodes {
+- (NSArray *) childModelNodes
+{
return [self subclasses];
}
-#pragma mark - Memory Management
+#pragma mark - Resource Management
-- (void)dealloc {
+- (void) dealloc
+{
[subclassesCache release];
[super dealloc];
}
View
6 Example 1/Classes/View/PSHLeafView.h
@@ -19,8 +19,8 @@
UILabel *detailLabel;
}
-@property(assign) IBOutlet UIButton *expandButton;
-@property(assign) IBOutlet UILabel *titleLabel;
-@property(assign) IBOutlet UILabel *detailLabel;
+@property (nonatomic, assign) IBOutlet UIButton *expandButton;
+@property (nonatomic, assign) IBOutlet UILabel *titleLabel;
+@property (nonatomic, assign) IBOutlet UILabel *detailLabel;
@end
View
6 Example 1/Classes/View/PSHLeafView.m
@@ -14,14 +14,16 @@ @implementation PSHLeafView
@synthesize expandButton, titleLabel, detailLabel;
-- (id)initWithFrame:(CGRect)frame {
+- (id) initWithFrame:(CGRect)frame
+{
if ((self = [super initWithFrame:frame])) {
// Initialization code
}
return self;
}
-- (void)dealloc {
+- (void) dealloc
+{
[super dealloc];
}
View
6 Example 1/Classes/View/PSHTreeGraphView.m
@@ -13,14 +13,16 @@
@implementation PSHTreeGraphView
-- (id)initWithFrame:(CGRect)frame {
+- (id) initWithFrame:(CGRect)frame
+{
if ((self = [super initWithFrame:frame])) {
// Initialization code
}
return self;
}
-- (void)dealloc {
+- (void) dealloc
+{
[super dealloc];
}
View
2  PSTreeGraphView/PSBaseBranchView.h
@@ -25,6 +25,6 @@
// Link to the enclosing TreeGraph. (The getter for this is a convenience method that ascends the view tree
// until it encounters a TreeGraph.)
-@property(readonly) PSBaseTreeGraphView *enclosingTreeGraph;
+@property (nonatomic, readonly) PSBaseTreeGraphView *enclosingTreeGraph;
@end
View
15 PSTreeGraphView/PSBaseBranchView.m
@@ -20,7 +20,8 @@
@implementation PSBaseBranchView
-- (PSBaseTreeGraphView *)enclosingTreeGraph {
+- (PSBaseTreeGraphView *) enclosingTreeGraph
+{
UIView *ancestor = [self superview];
while (ancestor) {
if ([ancestor isKindOfClass:[PSBaseTreeGraphView class]]) {
@@ -34,7 +35,8 @@ - (PSBaseTreeGraphView *)enclosingTreeGraph {
#pragma mark - Drawing
-- (UIBezierPath *)directConnectionsPath {
+- (UIBezierPath *) directConnectionsPath
+{
CGRect bounds = [self bounds];
CGPoint rootPoint = CGPointZero;
@@ -46,7 +48,6 @@ - (UIBezierPath *)directConnectionsPath {
rootPoint = CGPointMake(CGRectGetMidX(bounds), CGRectGetMinY(bounds));
}
-
// Create a single bezier path that we'll use to stroke all the lines.
UIBezierPath *path = [UIBezierPath bezierPath];
@@ -65,7 +66,6 @@ - (UIBezierPath *)directConnectionsPath {
targetPoint = [self convertPoint:CGPointMake(CGRectGetMidX(subviewBounds), CGRectGetMinY(subviewBounds)) fromView:subview];
}
-
[path moveToPoint:rootPoint];
[path addLineToPoint:targetPoint];
}
@@ -76,7 +76,8 @@ - (UIBezierPath *)directConnectionsPath {
return path;
}
-- (UIBezierPath *)orthogonalConnectionsPath {
+- (UIBezierPath *) orthogonalConnectionsPath
+{
// Compute the needed adjustment in x and y to align our lines for crisp, exact pixel coverage.
// (We can only do this if the lineWidth is integral, which it usually is.)
// CGFloat adjustment = 0.0;
@@ -212,8 +213,8 @@ - (UIBezierPath *)orthogonalConnectionsPath {
return path;
}
-- (void)drawRect:(CGRect)dirtyRect {
-
+- (void) drawRect:(CGRect)dirtyRect
+{
// Build the set of lines to stroke, according to our enclosingTreeGraph's connectingLineStyle.
UIBezierPath *path = nil;
View
10 PSTreeGraphView/PSBaseLeafView.h
@@ -35,20 +35,20 @@
#pragma mark - Styling
//The color of the ContainerView's stroked border.
-@property(copy) UIColor *borderColor;
+@property (nonatomic, copy) UIColor *borderColor;
//The width of the ContainerView's stroked border. May be zero.
-@property float borderWidth;
+@property (nonatomic, assign) CGFloat borderWidth;
//The radius of the ContainerView's rounded corners. May be zero.
-@property float cornerRadius;
+@property (nonatomic, assign) CGFloat cornerRadius;
//The fill color for the ContainerView's interior.
-@property(copy) UIColor *fillColor;
+@property (nonatomic, copy) UIColor *fillColor;
#pragma mark - Selection State
-@property BOOL showingSelected;
+@property (nonatomic, assign) BOOL showingSelected;
@end
View
47 PSTreeGraphView/PSBaseLeafView.m
@@ -24,7 +24,8 @@ @implementation PSBaseLeafView
#pragma mark - Update Layer
-- (void)updateLayerAppearanceToMatchContainerView {
+- (void) updateLayerAppearanceToMatchContainerView
+{
CALayer *layer = [self layer];
if (layer) {
@@ -65,7 +66,8 @@ - (void)updateLayerAppearanceToMatchContainerView {
#pragma mark - Initialization
-- (void)configureDetaults {
+- (void) configureDetaults
+{
// Initialize ivars directly. As a rule, it's best to avoid invoking accessors from an -init...
// method, since they may wrongly expect the instance to be fully formed.
@@ -77,7 +79,8 @@ - (void)configureDetaults {
[self updateLayerAppearanceToMatchContainerView];
}
-- initWithFrame:(CGRect)newFrame {
+- initWithFrame:(CGRect)newFrame
+{
self = [super initWithFrame:newFrame];
if (self) {
[self configureDetaults];
@@ -86,7 +89,8 @@ - (void)configureDetaults {
return self;
}
-- (void)awakeFromNib {
+- (void) awakeFromNib
+{
[super awakeFromNib];
[self configureDetaults];
}
@@ -128,11 +132,13 @@ - (void)awakeFromNib {
#pragma mark - Styling
-- (UIColor *)borderColor {
+- (UIColor*) borderColor
+{
return borderColor;
}
-- (void)setBorderColor:(UIColor *)color {
+- (void) setBorderColor:(UIColor *)color
+{
if (borderColor != color) {
[borderColor release];
borderColor = [[color copy] retain];
@@ -140,33 +146,39 @@ - (void)setBorderColor:(UIColor *)color {
}
}
-- (float)borderWidth {
+- (CGFloat) borderWidth
+{
return borderWidth;
}
-- (void)setBorderWidth:(float)width {
+- (void) setBorderWidth:(CGFloat)width
+{
if (borderWidth != width) {
borderWidth = width;
[self updateLayerAppearanceToMatchContainerView];
}
}
-- (float)cornerRadius {
+- (CGFloat)cornerRadius
+{
return cornerRadius;
}
-- (void)setCornerRadius:(float)radius {
+- (void) setCornerRadius:(CGFloat)radius
+{
if (cornerRadius != radius) {
cornerRadius = radius;
[self updateLayerAppearanceToMatchContainerView];
}
}
-- (UIColor *)fillColor {
+- (UIColor*) fillColor
+{
return fillColor;
}
-- (void)setFillColor:(UIColor *)color {
+- (void) setFillColor:(UIColor *)color
+{
if (fillColor != color) {
[fillColor release];
fillColor = [[color copy] retain];
@@ -177,11 +189,13 @@ - (void)setFillColor:(UIColor *)color {
#pragma mark - Selection State
-- (BOOL)showingSelected {
+- (BOOL) showingSelected
+{
return showingSelected;
}
-- (void)setShowingSelected:(BOOL)newShowingSelected {
+- (void) setShowingSelected:(BOOL)newShowingSelected
+{
if (showingSelected != newShowingSelected) {
showingSelected = newShowingSelected;
[self updateLayerAppearanceToMatchContainerView];
@@ -189,9 +203,10 @@ - (void)setShowingSelected:(BOOL)newShowingSelected {
}
-#pragma mark - Memory Management
+#pragma mark - Resource Management
-- (void)dealloc {
+- (void) dealloc
+{
[borderColor release];
[fillColor release];
View
34 PSTreeGraphView/PSBaseSubtreeView.h
@@ -48,23 +48,23 @@
// The root of the model subtree that this SubtreeView represents.
-@property(retain) id <PSTreeGraphModelNode> modelNode;
+@property (nonatomic, retain) id <PSTreeGraphModelNode> modelNode;
// The view that represents the modelNode. Is a subview of SubtreeView, and may itself have descendant views.
-@property(assign) IBOutlet UIView *nodeView;
+@property (nonatomic, assign) IBOutlet UIView *nodeView;
// Link to the enclosing TreeGraph. (The getter for this is a convenience method that ascends the view tree until
// it encounters a TreeGraph.)
-@property(readonly) PSBaseTreeGraphView *enclosingTreeGraph;
+@property (nonatomic, readonly) PSBaseTreeGraphView *enclosingTreeGraph;
// Whether the model node represented by this SubtreeView is a leaf node (one without child nodes). This
// can be a useful property to bind user interface state to. In the TreeGraph demo app, for example,
// we've bound the "isHidden" property of subtree expand/collapse buttons to this, so that expand/collapse
// buttons will only be shown for non-leaf nodes.
-@property(readonly,getter=isLeaf) BOOL leaf;
+@property (nonatomic, readonly, getter=isLeaf) BOOL leaf;
#pragma mark - Selection State
@@ -72,51 +72,51 @@
// Whether the node is part of the TreeGraph's current selection. This can be a useful property to bind user
// interface state to.
-@property(readonly) BOOL nodeIsSelected;
+@property (nonatomic, readonly) BOOL nodeIsSelected;
#pragma mark - Layout
//Returns YES if this subtree needs relayout.
-- (BOOL)needsGraphLayout;
+- (BOOL) needsGraphLayout;
//Marks this subtree as needing relayout.
-- (void)setNeedsGraphLayout;
+- (void) setNeedsGraphLayout;
//Recursively marks this subtree, and all of its descendants, as needing relayout.
-- (void)recursiveSetNeedsGraphLayout;
+- (void) recursiveSetNeedsGraphLayout;
//Recursively performs graph layout, if this subtree is marked as needing it.
-- (CGSize)layoutGraphIfNeeded;
+- (CGSize) layoutGraphIfNeeded;
// Resizes this subtree's nodeView to the minimum size required to hold its content, and returns the nodeView's
// new size. (This currently does nothing, and is just stubbed out for future use.)
-- (CGSize)sizeNodeViewToFitContent;
+- (CGSize) sizeNodeViewToFitContent;
//Whether this subtree is currently shown as expanded. If NO, the node's children have been collapsed into it.
-@property(getter=isExpanded) BOOL expanded;
+@property (nonatomic, assign, getter=isExpanded) BOOL expanded;
// Toggles expansion of this subtree. This can be wired up as the action of a button or other user interface
// control.
-- (IBAction)toggleExpansion:(id)sender;
+- (IBAction) toggleExpansion:(id)sender;
#pragma mark - Invalidation
//Marks all BranchView instances in this subtree as needing display.
-- (void)recursiveSetConnectorsViewsNeedDisplay;
+- (void) recursiveSetConnectorsViewsNeedDisplay;
//Marks all SubtreeView debug borders as needing display.
-- (void)resursiveSetSubtreeBordersNeedDisplay;
+- (void) resursiveSetSubtreeBordersNeedDisplay;
#pragma mark - Node Hit-Testing
@@ -125,18 +125,18 @@
// SubtreeView's interior (bounds) coordinate space. Returns nil if there is no node under the specified point.
// When a subtree is collapsed, only its root nodeView is eligible for hit-testing.
-- ( id <PSTreeGraphModelNode> )modelNodeAtPoint:(CGPoint)p;
+- ( id <PSTreeGraphModelNode> ) modelNodeAtPoint:(CGPoint)p;
// Returns the visible model node that is closest to the specified y coordinate, where "y" is specified in the
// SubtreeView's interior (bounds) coordinate space.
-- ( id <PSTreeGraphModelNode> )modelNodeClosestToY:(CGFloat)y;
+- ( id <PSTreeGraphModelNode> ) modelNodeClosestToY:(CGFloat)y;
#pragma mark - Debugging
//Returns an indented multi-line NSString summary of the displayed tree. Provided as a debugging aid.
-- (NSString *)treeSummaryWithDepth:(NSInteger)depth;
+- (NSString *) treeSummaryWithDepth:(NSInteger)depth;
@end
View
70 PSTreeGraphView/PSBaseSubtreeView.m
@@ -41,15 +41,16 @@ @implementation PSBaseSubtreeView
@synthesize nodeView;
-- (BOOL)isLeaf {
+- (BOOL)isLeaf
+{
return [[[self modelNode] childModelNodes] count] == 0;
}
#pragma mark - Instance Initialization
-- initWithModelNode:(id <PSTreeGraphModelNode> )newModelNode {
-
+- initWithModelNode:(id <PSTreeGraphModelNode> )newModelNode
+{
NSParameterAssert(newModelNode);
self = [super initWithFrame:CGRectMake(10, 10, 100, 25)];
@@ -79,7 +80,8 @@ - (BOOL)isLeaf {
}
-- (PSBaseTreeGraphView *)enclosingTreeGraph {
+- (PSBaseTreeGraphView *) enclosingTreeGraph
+{
UIView *ancestor = [self superview];
while (ancestor) {
if ([ancestor isKindOfClass:[PSBaseTreeGraphView class]]) {
@@ -93,15 +95,18 @@ - (PSBaseTreeGraphView *)enclosingTreeGraph {
#pragma mark - Layout
-- (BOOL)needsGraphLayout {
+- (BOOL) needsGraphLayout
+{
return needsGraphLayout;
}
-- (void)setNeedsGraphLayout {
+- (void) setNeedsGraphLayout
+{
needsGraphLayout = YES;
}
-- (void)recursiveSetNeedsGraphLayout {
+- (void) recursiveSetNeedsGraphLayout
+{
[self setNeedsGraphLayout];
for (UIView *subview in [self subviews]) {
if ([subview isKindOfClass:[PSBaseSubtreeView class]]) {
@@ -110,14 +115,16 @@ - (void)recursiveSetNeedsGraphLayout {
}
}
-- (CGSize)sizeNodeViewToFitContent {
+- (CGSize) sizeNodeViewToFitContent
+{
// TODO: Node size is hardwired for now, but the layout algorithm could accommodate variable-sized nodes
// if we implement size-to-fit for nodes.
return [nodeView frame].size;
}
-- (CGSize)layoutGraphIfNeeded {
+- (CGSize) layoutGraphIfNeeded
+{
CGSize selfTargetSize;
if (!needsGraphLayout)
@@ -385,11 +392,13 @@ - (CGSize)layoutGraphIfNeeded {
return selfTargetSize;
}
-- (BOOL)isExpanded {
+- (BOOL) isExpanded
+{
return expanded;
}
-- (void)setExpanded:(BOOL)flag {
+- (void) setExpanded:(BOOL)flag
+{
if (expanded != flag) {
// Remember this SubtreeView's new state.
@@ -407,8 +416,8 @@ - (void)setExpanded:(BOOL)flag {
}
}
-- (IBAction)toggleExpansion:(id)sender {
-
+- (IBAction) toggleExpansion:(id)sender
+{
[UIView beginAnimations:@"TreeNodeExpansion" context:nil];
// [UIView setAnimationDuration:0.5];
[UIView setAnimationBeginsFromCurrentState:YES];
@@ -443,7 +452,8 @@ - (IBAction)toggleExpansion:(id)sender {
// }
//}
-- (void)updateSubtreeBorder {
+- (void) updateSubtreeBorder
+{
CALayer *layer = [self layer];
if (layer) {
// Disable implicit animations during these layer property changes, to make them take effect immediately.
@@ -470,8 +480,8 @@ - (void)updateSubtreeBorder {
#pragma mark - Invalidation
-- (void)recursiveSetConnectorsViewsNeedDisplay {
-
+- (void) recursiveSetConnectorsViewsNeedDisplay
+{
// Mark this SubtreeView's connectorsView as needing display.
[connectorsView setNeedsDisplay];
@@ -484,7 +494,8 @@ - (void)recursiveSetConnectorsViewsNeedDisplay {
}
}
-- (void)resursiveSetSubtreeBordersNeedDisplay {
+- (void) resursiveSetSubtreeBordersNeedDisplay
+{
if ( [self layer] ) {
// We only need this if layer-backed. When we have a backing layer, we use the
// layer's "border" properties to draw the subtree debug border.
@@ -506,15 +517,16 @@ - (void)resursiveSetSubtreeBordersNeedDisplay {
#pragma mark - Selection State
-- (BOOL)nodeIsSelected {
+- (BOOL) nodeIsSelected
+{
return [[[self enclosingTreeGraph] selectedModelNodes] containsObject:[self modelNode]];
}
#pragma mark - Node Hit-Testing
-- (id <PSTreeGraphModelNode> )modelNodeAtPoint:(CGPoint)p {
-
+- (id <PSTreeGraphModelNode> ) modelNodeAtPoint:(CGPoint)p
+{
// Check for intersection with our subviews, enumerating them in reverse order to get
// front-to-back ordering. We could use UIView's -hitTest: method here, but we don't
// want to bother hit-testing deeper than the nodeView level.
@@ -547,8 +559,8 @@ - (BOOL)nodeIsSelected {
return nil;
}
-- (id <PSTreeGraphModelNode> )modelNodeClosestToY:(CGFloat)y {
-
+- (id <PSTreeGraphModelNode> ) modelNodeClosestToY:(CGFloat)y
+{
// Do a simple linear search of our subviews, ignoring non-SubtreeViews. If performance was ever
// an issue for this code, we could take advantage of knowing the layout order of the nodes to do
// a sort of binary search.
@@ -577,15 +589,18 @@ - (BOOL)nodeIsSelected {
#pragma mark - Debugging
-- (NSString *)description {
+- (NSString *) description
+{
return [NSString stringWithFormat:@"SubtreeView<%@>", [modelNode description]];
}
-- (NSString *)nodeSummary {
+- (NSString *) nodeSummary
+{
return [NSString stringWithFormat:@"f=%@ %@", NSStringFromCGRect([nodeView frame]), [modelNode description]];
}
-- (NSString *)treeSummaryWithDepth:(NSInteger)depth {
+- (NSString *) treeSummaryWithDepth:(NSInteger)depth
+{
NSEnumerator *subviewsEnumerator = [[self subviews] objectEnumerator];
UIView *subview;
NSMutableString *description = [NSMutableString string];
@@ -603,9 +618,10 @@ - (NSString *)treeSummaryWithDepth:(NSInteger)depth {
}
-#pragma mark - Memory Management
+#pragma mark - Resource Management
-- (void)dealloc {
+- (void) dealloc
+{
// [nodeView release]; // not retained, since an IBOutlet
[connectorsView release];
[modelNode release];
View
60 PSTreeGraphView/PSBaseTreeGraphView.h
@@ -103,7 +103,7 @@ typedef NSInteger PSTreeGraphOrientationStyle;
// Use this method to keep the view in sync for now.
-- (void)parentClipViewDidResize:(id)object;
+- (void) parentClipViewDidResize:(id)object;
#pragma mark - Creating Instances
@@ -113,7 +113,7 @@ typedef NSInteger PSTreeGraphOrientationStyle;
// metrics, but to have a usable TreeGraph with actual content, you need to specify a
// nodeViewNibName, an optional nodeViewNibBundle, and a modelRoot.
-- (id)initWithFrame:(CGRect)frame;
+- (id) initWithFrame:(CGRect)frame;
#pragma mark - Connection to Model
@@ -125,7 +125,7 @@ typedef NSInteger PSTreeGraphOrientationStyle;
// to traverse the model tree, must conform to the TreeGraphModelNode protocol declared in
// TreeGraphModelNode.h
-@property(retain) id <PSTreeGraphModelNode> modelRoot;
+@property (nonatomic, retain) id <PSTreeGraphModelNode> modelRoot;
#pragma mark - Root SubtreeView Access
@@ -134,7 +134,7 @@ typedef NSInteger PSTreeGraphOrientationStyle;
// read-only accessor provides a way to get the rootmost SubtreeView (the one that corresponds
// to the modelRoot model node).
-@property(readonly) PSBaseSubtreeView *rootSubtreeView;
+@property (nonatomic, readonly) PSBaseSubtreeView *rootSubtreeView;
#pragma mark - Node View Nib Specification
@@ -145,13 +145,13 @@ typedef NSInteger PSTreeGraphOrientationStyle;
// Must specify a "View" .nib file, whose File's Owner is a SubtreeView, or the TreeGraph will be
// unable to instantiate node views.
-@property(copy) NSString *nodeViewNibName;
+@property (nonatomic, copy) NSString *nodeViewNibName;
// The NSBundle from which the .nib named by nodeViewNibName can be loaded. May be nil, in which
// case we follow the usual UIKit-implemented rules for automatically finding the named .nib
// file.
-@property(retain) NSBundle *nodeViewNibBundle;
+@property (nonatomic, retain) NSBundle *nodeViewNibBundle;
#pragma mark - Selection State
@@ -161,17 +161,17 @@ typedef NSInteger PSTreeGraphOrientationStyle;
// will raise an exception). Every member of this set must be a descendant of the TreeGraph's
// modelRoot (or modelRoot itself). If any member is not, TreeGraph will raise an exception.
-@property(copy) NSSet *selectedModelNodes;
+@property (nonatomic, copy) NSSet *selectedModelNodes;
// Convenience accessor that returns the selected node, if exactly one node is currently
// selected. Returns nil if zero, or more than one, nodees are currently selected.
-@property(readonly) id <PSTreeGraphModelNode> singleSelectedModelNode;
+@property (nonatomic, readonly) id <PSTreeGraphModelNode> singleSelectedModelNode;
// Returns the bounding box of the selectedModelNodes. The bounding box takes only the selected
// nodes into account, disregarding any descendants they might have.
-@property(readonly) CGRect selectionBounds;
+@property (nonatomic, readonly) CGRect selectionBounds;
#pragma mark - Node Hit-Testing
@@ -192,62 +192,62 @@ typedef NSInteger PSTreeGraphOrientationStyle;
// than its minimumFrameSize, since we automatically expand the TreeGraph to always be at least
// as large as the NSScrollView's clip area (contentView) to provide a nicer user experience.
-@property CGSize minimumFrameSize;
+@property (nonatomic, assign) CGSize minimumFrameSize;
// If YES, and if the TreeGraph is the documentView of an UIScrollView, the TreeGraph will
// automatically resize itself as needed to ensure that it always at least fills the content
// area of its enclosing UIScrollView. If NO, or if the TreeGraph is not the documentView of
// an UIScrollView, the TreeGraph's size is determined only by its content and margins.
-@property BOOL resizesToFillEnclosingScrollView;
+@property (nonatomic, assign) BOOL resizesToFillEnclosingScrollView;
// The style for tree graph orientation (See the TreeGraphOrientationStyle enumeration above.)
-@property PSTreeGraphOrientationStyle treeGraphOrientation;
+@property (nonatomic) PSTreeGraphOrientationStyle treeGraphOrientation;
//Returns YES if the tree needs relayout.
-- (BOOL)needsGraphLayout;
+- (BOOL) needsGraphLayout;
//Marks the tree as needing relayout.
-- (void)setNeedsGraphLayout;
+- (void) setNeedsGraphLayout;
// Performs graph layout, if the tree is marked as needing it. Returns the size computed for the
// tree (not including contentMargin).
-- (CGSize)layoutGraphIfNeeded;
+- (CGSize) layoutGraphIfNeeded;
// Collapses the root node, if it is currently expanded.
-- (void)collapseRoot;
+- (void) collapseRoot;
// Expands the root node, if it is currently collapsed.
-- (void)expandRoot;
+- (void) expandRoot;
// Toggles the expansion state of the TreeGraph's selectedModelNodes, expanding those that are
// currently collapsed, and collapsing those that are currently expanded.
-- (IBAction)toggleExpansionOfSelectedModelNodes:(id)sender;
+- (IBAction) toggleExpansionOfSelectedModelNodes:(id)sender;
// Returns the bounding box of the node views that represent the specified modelNodes. Model
// nodes that aren't part of the displayed tree, or are part of a collapsed subtree, are ignored
// and don't contribute to the returned bounding box. The bounding box takes only the specified
// nodes into account, disregarding any descendants they might have.
-- (CGRect)boundsOfModelNodes:(NSSet *)modelNodes;
+- (CGRect) boundsOfModelNodes:(NSSet *)modelNodes;
#pragma mark - Scrolling
// Does a [self scrollRectToVisible:] with the bounding box of the specified model nodes.
-- (void)scrollModelNodesToVisible:(NSSet *)modelNodes;
+- (void) scrollModelNodesToVisible:(NSSet *)modelNodes;
// Does a [self scrollRectToVisible:] with the bounding box of the selected model nodes.
-- (void)scrollSelectedModelNodesToVisible;
+- (void) scrollSelectedModelNodesToVisible;
#pragma mark - Animation Support
@@ -255,12 +255,12 @@ typedef NSInteger PSTreeGraphOrientationStyle;
// Whether the TreeGraph animates layout operations. Defaults to YES. If set to NO, layout
// jumpst instantaneously to the tree's new state.
-@property BOOL animatesLayout;
+@property (nonatomic, assign) BOOL animatesLayout;
// Used to temporarily suppress layout animation during event tracking. Layout animation happens
// only if animatesLayout is YES and this is NO.
-@property BOOL layoutAnimationSuppressed;
+@property (nonatomic, assign) BOOL layoutAnimationSuppressed;
#pragma mark - Layout Metrics
@@ -268,15 +268,15 @@ typedef NSInteger PSTreeGraphOrientationStyle;
// The amount of padding to leave between the displayed tree and each of the four edges of the
// TreeGraph's bounds.
-@property CGFloat contentMargin;
+@property (nonatomic, assign) CGFloat contentMargin;
// The horizonal spacing between each parent node and its child nodes.
-@property CGFloat parentChildSpacing;
+@property (nonatomic, assign) CGFloat parentChildSpacing;
// The vertical spacing betwen sibling nodes.
-@property CGFloat siblingSpacing;
+@property (nonatomic, assign) CGFloat siblingSpacing;
#pragma mark - Styling
@@ -287,20 +287,20 @@ typedef NSInteger PSTreeGraphOrientationStyle;
// The stroke color for node connecting lines.
-@property(copy) UIColor *connectingLineColor;
+@property (nonatomic, copy) UIColor *connectingLineColor;
// The width for node connecting lines.
-@property CGFloat connectingLineWidth;
+@property (nonatomic, assign) CGFloat connectingLineWidth;
// The style for node connecting lines. (See the PSTreeGraphConnectingLineStyle enumeration above.)
-@property PSTreeGraphConnectingLineStyle connectingLineStyle;
+@property (nonatomic) PSTreeGraphConnectingLineStyle connectingLineStyle;
// Defaults to NO. If YES, a stroked outline is shown around each of the TreeGraph's
// SubtreeViews. This can be helpful for visualizing the TreeGraph's structure and layout.
-@property BOOL showsSubtreeFrames;
+@property (nonatomic, assign) BOOL showsSubtreeFrames;
@end
View
202 PSTreeGraphView/PSBaseTreeGraphView.m
@@ -33,8 +33,8 @@ @implementation PSBaseTreeGraphView
#pragma mark - Creating Instances
-- (void)configureDetaults {
-
+- (void) configureDetaults
+{
[self setBackgroundColor: [UIColor colorWithRed:0.55 green:0.76 blue:0.93 alpha:1.0]];
//[self setClipsToBounds:YES];
@@ -59,7 +59,8 @@ - (void)configureDetaults {
// [self setLayerContentsRedrawPolicy:UIViewLayerContentsRedrawNever];
}
-- (id)initWithFrame:(CGRect)frame {
+- (id) initWithFrame:(CGRect)frame
+{
self = [super initWithFrame:frame];
if (self) {
[self configureDetaults];
@@ -67,7 +68,8 @@ - (id)initWithFrame:(CGRect)frame {
return self;
}
-- (void)awakeFromNib {
+- (void) awakeFromNib
+{
[super awakeFromNib];
[self configureDetaults];
}
@@ -75,7 +77,8 @@ - (void)awakeFromNib {
#pragma mark - Root SubtreeView Access
-- (PSBaseSubtreeView *)rootSubtreeView {
+- (PSBaseSubtreeView *) rootSubtreeView
+{
return [self subtreeViewForModelNode:[self modelRoot]];
}
@@ -103,7 +106,7 @@ - (NSBundle *)nodeViewNibBundle {
return nodeViewNibBundle;
}
-- (void)setNodeViewNibBundle:(NSBundle *)newBundle {
+- (void) setNodeViewNibBundle:(NSBundle *)newBundle {
if (nodeViewNibBundle != newBundle) {
// iOS 4.0 and above ONLY
@@ -139,12 +142,13 @@ - (void)setNodeViewNibBundle:(NSBundle *)newBundle {
// no nodes are selected, this is an empty NSSet. It will never be nil (and attempting
// to set it to nil will raise an exception).
-- (NSSet *)selectedModelNodes {
+- (NSSet *) selectedModelNodes
+{
return [[selectedModelNodes retain] autorelease];
}
-- (void)setSelectedModelNodes:(NSSet *)newSelectedModelNodes {
-
+- (void) setSelectedModelNodes:(NSSet *)newSelectedModelNodes
+{
NSParameterAssert(newSelectedModelNodes != nil); // Never pass nil. Pass [NSSet set] instead.
// Verify that each of the nodes in the new selection is in the TreeGraph's assigned model tree.
@@ -189,19 +193,21 @@ - (void)setSelectedModelNodes:(NSSet *)newSelectedModelNodes {
}
}
-- (id <PSTreeGraphModelNode> )singleSelectedModelNode {
+- (id <PSTreeGraphModelNode> ) singleSelectedModelNode
+{
NSSet *selection = [self selectedModelNodes];
return ([selection count] == 1) ? [selection anyObject] : nil;
}
-- (CGRect)selectionBounds {
+- (CGRect) selectionBounds
+{
return [self boundsOfModelNodes:[self selectedModelNodes]];
}
#pragma mark - Graph Building
-- (PSBaseSubtreeView *)newGraphForModelNode:(id <PSTreeGraphModelNode> )modelNode {
+- (PSBaseSubtreeView *) newGraphForModelNode:(id <PSTreeGraphModelNode> )modelNode {
NSParameterAssert(modelNode);
@@ -273,8 +279,8 @@ - (PSBaseSubtreeView *)newGraphForModelNode:(id <PSTreeGraphModelNode> )modelNod
return subtreeView;
}
-- (void)buildGraph {
-
+- (void) buildGraph
+{
// Traverse the model tree, building a SubtreeView for each model node.
id <PSTreeGraphModelNode> root = [self modelRoot];
if (root) {
@@ -288,7 +294,8 @@ - (void)buildGraph {
#pragma mark - Layout
-- (void)updateFrameSizeForContentAndClipView {
+- (void) updateFrameSizeForContentAndClipView
+{
CGSize newFrameSize;
CGSize newMinimumFrameSize = [self minimumFrameSize];
@@ -314,8 +321,8 @@ - (void)updateFrameSizeForContentAndClipView {
}
-- (void)updateRootSubtreeViewPositionForSize:(CGSize)rootSubtreeViewSize {
-
+- (void) updateRootSubtreeViewPositionForSize:(CGSize)rootSubtreeViewSize
+{
// Position the rootSubtreeView within the TreeGraph.
PSBaseSubtreeView *rootSubtreeView = [self rootSubtreeView];
@@ -342,22 +349,26 @@ - (void)updateRootSubtreeViewPositionForSize:(CGSize)rootSubtreeViewSize {
}
-- (PSTreeGraphOrientationStyle)treeGraphOrientation {
+- (PSTreeGraphOrientationStyle) treeGraphOrientation
+{
return treeGraphOrientation;
}
-- (void)setTreeGraphOrientation:(PSTreeGraphOrientationStyle)newTreeGraphOrientation {
+- (void) setTreeGraphOrientation:(PSTreeGraphOrientationStyle)newTreeGraphOrientation
+{
if (treeGraphOrientation != newTreeGraphOrientation) {
treeGraphOrientation = newTreeGraphOrientation;
[[self rootSubtreeView] recursiveSetConnectorsViewsNeedDisplay];
}
}
-- (BOOL)resizesToFillEnclosingScrollView {
+- (BOOL) resizesToFillEnclosingScrollView
+{
return resizesToFillEnclosingScrollView;
}
-- (void)setResizesToFillEnclosingScrollView:(BOOL)flag {
+- (void) setResizesToFillEnclosingScrollView:(BOOL)flag
+{
if (resizesToFillEnclosingScrollView != flag) {
resizesToFillEnclosingScrollView = flag;
[self updateFrameSizeForContentAndClipView];
@@ -365,8 +376,8 @@ - (void)setResizesToFillEnclosingScrollView:(BOOL)flag {
}
}
-- (void)parentClipViewDidResize:(id)object {
-
+- (void) parentClipViewDidResize:(id)object
+{
// TODO: Additional checks to ensure we are in a UIScrollView
UIScrollView *enclosingScrollView = (UIScrollView *)[self superview];
@@ -376,7 +387,8 @@ - (void)parentClipViewDidResize:(id)object {
}
}
-- (void)willMoveToSuperview:(UIView *)newSuperview {
+- (void) willMoveToSuperview:(UIView *)newSuperview
+{
// Ask to be notified when our superview's frame size changes (if it's an NSClipView, which is a pretty
// good indication that this TreeGraph is an UIScrollView's documentView), so that we can automatically
// resize to always fill the UIScrollView's content area.
@@ -392,8 +404,8 @@ - (void)willMoveToSuperview:(UIView *)newSuperview {
[super willMoveToSuperview:newSuperview];
}
-- (void)layoutSubviews {
-
+- (void) layoutSubviews
+{
// Do graph layout if we need to.
[self layoutGraphIfNeeded];
@@ -403,7 +415,8 @@ - (void)layoutSubviews {
[super layoutSubviews];
}
-- (CGSize)layoutGraphIfNeeded {
+- (CGSize) layoutGraphIfNeeded
+{
PSBaseSubtreeView *rootSubtreeView = [self rootSubtreeView];
if ([self needsGraphLayout] && [self modelRoot]) {
@@ -431,31 +444,37 @@ - (CGSize)layoutGraphIfNeeded {
}
}
-- (BOOL)needsGraphLayout {
+- (BOOL) needsGraphLayout
+{
return [[self rootSubtreeView] needsGraphLayout];
}
-- (void)setNeedsGraphLayout {
+- (void) setNeedsGraphLayout
+{
[[self rootSubtreeView] recursiveSetNeedsGraphLayout];
[self setNeedsDisplay];
}
-- (void)collapseRoot {
+- (void) collapseRoot
+{
[[self rootSubtreeView] setExpanded:NO];
}
-- (void)expandRoot {
+- (void) expandRoot
+{
[[self rootSubtreeView] setExpanded:YES];
}
-- (IBAction)toggleExpansionOfSelectedModelNodes:(id)sender {
+- (IBAction) toggleExpansionOfSelectedModelNodes:(id)sender
+{
for (id <PSTreeGraphModelNode> modelNode in [self selectedModelNodes]) {
PSBaseSubtreeView *subtreeView = [self subtreeViewForModelNode:modelNode];
[subtreeView toggleExpansion:sender];
}
}
-- (CGRect)boundsOfModelNodes:(NSSet *)modelNodes {
+- (CGRect) boundsOfModelNodes:(NSSet *)modelNodes
+{
CGRect boundingBox = CGRectZero;
for (id <PSTreeGraphModelNode> modelNode in modelNodes) {
PSBaseSubtreeView *subtreeView = [self subtreeViewForModelNode:modelNode];
@@ -473,7 +492,8 @@ - (CGRect)boundsOfModelNodes:(NSSet *)modelNodes {
#pragma mark - Scrolling
-- (void)scrollModelNodesToVisible:(NSSet *)modelNodes {
+- (void) scrollModelNodesToVisible:(NSSet *)modelNodes
+{
CGRect targetRect = [self boundsOfModelNodes:modelNodes];
if (!CGRectIsEmpty(targetRect)) {
CGFloat padding = [self contentMargin];
@@ -487,7 +507,8 @@ - (void)scrollModelNodesToVisible:(NSSet *)modelNodes {
}
}
-- (void)scrollSelectedModelNodesToVisible {
+- (void) scrollSelectedModelNodesToVisible
+{
[self scrollModelNodesToVisible:[self selectedModelNodes]];
}
@@ -505,24 +526,16 @@ - (void)scrollSelectedModelNodesToVisible {
// return ( CGColorGetAlpha([[self backgroundColor] CGColor]) < 1.0) ? NO : YES;
//}
-// REMOVED: USED LAYER PROPERTY INSTEAD
-
-//- (void)drawRect:(CGRect)rect {
-//
-// // Fill background.
-// [[self backgroundColor] set];
-// UIRectFill(rect);
-//}
-
#pragma mark - Data Source
-- (id <PSTreeGraphModelNode> )modelRoot {
+- (id <PSTreeGraphModelNode> ) modelRoot
+{
return modelRoot;
}
-- (void)setModelRoot:(id <PSTreeGraphModelNode> )newModelRoot {
-
+- (void) setModelRoot:(id <PSTreeGraphModelNode> )newModelRoot
+{
NSParameterAssert(newModelRoot == nil || [newModelRoot conformsToProtocol:@protocol(PSTreeGraphModelNode)]);
if (modelRoot != newModelRoot) {
@@ -557,8 +570,8 @@ - (void)setModelRoot:(id <PSTreeGraphModelNode> )newModelRoot {
// coordinate space. If there is a collapsed subtree at the given point, returns the model node at the root
// of the collapsed subtree. If there is no model node at the given point, returns nil.
-- (id <PSTreeGraphModelNode> )modelNodeAtPoint:(CGPoint)p {
-
+- (id <PSTreeGraphModelNode> ) modelNodeAtPoint:(CGPoint)p
+{
// Since we've composed our content using views (SubtreeViews and enclosed nodeViews), we can use
// UIView's -hitTest: method to easily identify our deepest descendant view under the given point.
// We rely on the front-to-back order of hit-testing to ensure that we return the root of a collapsed
@@ -577,11 +590,13 @@ - (void)setModelRoot:(id <PSTreeGraphModelNode> )newModelRoot {
// Make TreeGraphs able to -becomeFirstResponder, so they can receive key events.
-- (BOOL)acceptsFirstResponder {
+- (BOOL) acceptsFirstResponder
+{
return YES;
}
-- (void)moveToSiblingByRelativeIndex:(NSInteger)relativeIndex {
+- (void) moveToSiblingByRelativeIndex:(NSInteger)relativeIndex
+{
id <PSTreeGraphModelNode> modelNode = [self singleSelectedModelNode];
if (modelNode) {
id <PSTreeGraphModelNode> sibling = [self siblingOfModelNode:modelNode atRelativeIndex:relativeIndex];
@@ -597,7 +612,8 @@ - (void)moveToSiblingByRelativeIndex:(NSInteger)relativeIndex {
[self scrollSelectedModelNodesToVisible];
}
-- (void)moveToParent:(id)sender {
+- (void) moveToParent:(id)sender
+{
id <PSTreeGraphModelNode> modelNode = [self singleSelectedModelNode];
if (modelNode) {
if (modelNode != [self modelRoot]) {
@@ -615,7 +631,8 @@ - (void)moveToParent:(id)sender {
[self scrollSelectedModelNodesToVisible];
}
-- (void)moveToNearestChild:(id)sender {
+- (void) moveToNearestChild:(id)sender
+{
id <PSTreeGraphModelNode> modelNode = [self singleSelectedModelNode];
if (modelNode) {
PSBaseSubtreeView *subtreeView = [self subtreeViewForModelNode:modelNode];
@@ -638,19 +655,23 @@ - (void)moveToNearestChild:(id)sender {
[self scrollSelectedModelNodesToVisible];
}
-- (void)moveUp:(id)sender {
+- (void) moveUp:(id)sender
+{
[self moveToSiblingByRelativeIndex:-1];
}
-- (void)moveDown:(id)sender {
+- (void) moveDown:(id)sender
+{
[self moveToSiblingByRelativeIndex:1];
}
-- (void)moveLeft:(id)sender {
+- (void) moveLeft:(id)sender
+{
[self moveToParent:sender];
}
-- (void)moveRight:(id)sender {
+- (void) moveRight:(id)sender
+{
[self moveToNearestChild:sender];
}
@@ -765,11 +786,13 @@ - (void)moveRight:(id)sender {
// }
//}
-- (UIColor *)connectingLineColor {
+- (UIColor *) connectingLineColor
+{
return connectingLineColor;
}
-- (void)setConnectingLineColor:(UIColor *)newConnectingLineColor {
+- (void) setConnectingLineColor:(UIColor *)newConnectingLineColor
+{
if (connectingLineColor != newConnectingLineColor) {
[connectingLineColor release];
connectingLineColor = [newConnectingLineColor copy];
@@ -777,11 +800,13 @@ - (void)setConnectingLineColor:(UIColor *)newConnectingLineColor {
}
}
-- (CGFloat)contentMargin {
+- (CGFloat) contentMargin
+{
return contentMargin;
}
-- (void)setContentMargin:(CGFloat)newContentMargin {
+- (void) setContentMargin:(CGFloat)newContentMargin
+{
if (contentMargin != newContentMargin) {
contentMargin = newContentMargin;
[self setNeedsGraphLayout];
@@ -789,11 +814,13 @@ - (void)setContentMargin:(CGFloat)newContentMargin {
}
}
-- (CGFloat)parentChildSpacing {
+- (CGFloat) parentChildSpacing
+{
return parentChildSpacing;
}
-- (void)setParentChildSpacing:(CGFloat)newParentChildSpacing {
+- (void) setParentChildSpacing:(CGFloat)newParentChildSpacing
+{
if (parentChildSpacing != newParentChildSpacing) {
parentChildSpacing = newParentChildSpacing;
[self setNeedsGraphLayout];
@@ -801,11 +828,13 @@ - (void)setParentChildSpacing:(CGFloat)newParentChildSpacing {
}
}
-- (CGFloat)siblingSpacing {
+- (CGFloat) siblingSpacing
+{
return siblingSpacing;
}
-- (void)setSiblingSpacing:(CGFloat)newSiblingSpacing {
+- (void) setSiblingSpacing:(CGFloat)newSiblingSpacing
+{
if (siblingSpacing != newSiblingSpacing) {
siblingSpacing = newSiblingSpacing;
[self setNeedsGraphLayout];
@@ -813,18 +842,21 @@ - (void)setSiblingSpacing:(CGFloat)newSiblingSpacing {
}
}
-- (PSTreeGraphConnectingLineStyle)connectingLineStyle {
+- (PSTreeGraphConnectingLineStyle) connectingLineStyle
+{
return connectingLineStyle;
}
-- (void)setConnectingLineStyle:(PSTreeGraphConnectingLineStyle)newConnectingLineStyle {
+- (void) setConnectingLineStyle:(PSTreeGraphConnectingLineStyle)newConnectingLineStyle
+{
if (connectingLineStyle != newConnectingLineStyle) {
connectingLineStyle = newConnectingLineStyle;
[[self rootSubtreeView] recursiveSetConnectorsViewsNeedDisplay];
}
}
-- (CGFloat)connectingLineWidth {
+- (CGFloat) connectingLineWidth
+{
return connectingLineWidth;
}
@@ -835,11 +867,13 @@ - (void)setConnectingLineWidth:(CGFloat)newConnectingLineWidth {
}
}
-- (BOOL)showsSubtreeFrames {
+- (BOOL) showsSubtreeFrames
+{
return showsSubtreeFrames;
}
-- (void)setShowsSubtreeFrames:(BOOL)newShowsSubtreeFrames {
+- (void) setShowsSubtreeFrames:(BOOL)newShowsSubtreeFrames
+{
if (showsSubtreeFrames != newShowsSubtreeFrames) {
showsSubtreeFrames = newShowsSubtreeFrames;
[[self rootSubtreeView] resursiveSetSubtreeBordersNeedDisplay];
@@ -855,20 +889,22 @@ @implementation PSBaseTreeGraphView (Internal)
#pragma mark - ModelNode -> SubtreeView Relationship Management
-- (PSBaseSubtreeView *)subtreeViewForModelNode:(id)modelNode {
+- (PSBaseSubtreeView *) subtreeViewForModelNode:(id)modelNode
+{
return [modelNodeToSubtreeViewMapTable objectForKey:modelNode];
}
-- (void)setSubtreeView:(PSBaseSubtreeView *)subtreeView forModelNode:(id)modelNode {
+- (void) setSubtreeView:(PSBaseSubtreeView *)subtreeView forModelNode:(id)modelNode
+{
[modelNodeToSubtreeViewMapTable setObject:subtreeView forKey:modelNode];
}
#pragma mark - Model Tree Navigation
-- (BOOL)modelNode:(id <PSTreeGraphModelNode> )modelNode
- isDescendantOf:(id <PSTreeGraphModelNode> )possibleAncestor {
-
+- (BOOL) modelNode:(id <PSTreeGraphModelNode> )modelNode
+ isDescendantOf:(id <PSTreeGraphModelNode> )possibleAncestor
+{
NSParameterAssert(modelNode != nil);
NSParameterAssert(possibleAncestor != nil);
@@ -882,17 +918,17 @@ - (BOOL)modelNode:(id <PSTreeGraphModelNode> )modelNode
return NO;
}
-- (BOOL)modelNodeIsInAssignedTree:(id <PSTreeGraphModelNode> )modelNode {
-
+- (BOOL) modelNodeIsInAssignedTree:(id <PSTreeGraphModelNode> )modelNode
+{
NSParameterAssert(modelNode != nil);
id <PSTreeGraphModelNode> root = [self modelRoot];
return (modelNode == root || [self modelNode:modelNode isDescendantOf:root]) ? YES : NO;
}
-- (id <PSTreeGraphModelNode> )siblingOfModelNode:(id <PSTreeGraphModelNode> )modelNode
- atRelativeIndex:(NSInteger)relativeIndex {
-
+- (id <PSTreeGraphModelNode> ) siblingOfModelNode:(id <PSTreeGraphModelNode> )modelNode
+ atRelativeIndex:(NSInteger)relativeIndex
+{
NSParameterAssert(modelNode != nil);
NSAssert([self modelNodeIsInAssignedTree:modelNode], @"modelNode is not in the tree");
@@ -918,10 +954,10 @@ - (BOOL)modelNodeIsInAssignedTree:(id <PSTreeGraphModelNode> )modelNode {
}
-#pragma mark - Memory Management
+#pragma mark - Resource Management
-- (void)dealloc {
-
+- (void) dealloc
+{
// iOS 4.0 and above ONLY
// [cachedNodeViewNib release];
View
18 PSTreeGraphView/PSBaseTreeGraphView_Internal.h
@@ -29,13 +29,13 @@
// Returns the SubtreeView that corresponds to the specified modelNode, as tracked by the TreeGraph's
// modelNodeToSubtreeViewMapTable.
-- (PSBaseSubtreeView *)subtreeViewForModelNode:(id)modelNode;
+- (PSBaseSubtreeView *) subtreeViewForModelNode:(id)modelNode;
// Associates the specified subtreeView with the given modelNode in the TreeGraph's
// modelNodeToSubtreeViewMapTable, so that it can later be looked up using -subtreeViewForModelNode:
-- (void)setSubtreeView:(PSBaseSubtreeView *)subtreeView
- forModelNode:(id)modelNode;
+- (void) setSubtreeView:(PSBaseSubtreeView *)subtreeView
+ forModelNode:(id)modelNode;
#pragma mark - Model Tree Navigation
@@ -44,8 +44,8 @@
//
// Raises an exception if either modelNode or possibleAncestor is nil.
-- (BOOL)modelNode:(id <PSTreeGraphModelNode> )modelNode
- isDescendantOf:(id <PSTreeGraphModelNode> )possibleAncestor;
+- (BOOL) modelNode:(id <PSTreeGraphModelNode> )modelNode
+ isDescendantOf:(id <PSTreeGraphModelNode> )possibleAncestor;
// Returns YES if modelNode is the TreeGraph's assigned modelRoot, or a descendant of modelRoot.
//
@@ -54,7 +54,7 @@
//
// Raises an exception if modelNode is nil.
-- (BOOL)modelNodeIsInAssignedTree:(id <PSTreeGraphModelNode> )modelNode;
+- (BOOL) modelNodeIsInAssignedTree:(id <PSTreeGraphModelNode> )modelNode;
// Returns the sibling at the given offset relative to the given modelNode.
// (e.g. relativeIndex == -1 requests the previous sibling. relativeIndex == +1 requests the next sibling.)
@@ -67,8 +67,8 @@
//
// Raises an exception if modelNode is nil, or if modelNode is not within the subtree assigned to the TreeGraph.
-- (id<PSTreeGraphModelNode>)siblingOfModelNode:(id <PSTreeGraphModelNode> )modelNode
- atRelativeIndex:(NSInteger)relativeIndex;
+- (id<PSTreeGraphModelNode>) siblingOfModelNode:(id <PSTreeGraphModelNode> )modelNode
+ atRelativeIndex:(NSInteger)relativeIndex;
#pragma mark - Node View Nib Caching
@@ -79,6 +79,6 @@
// We automatically let go of the cachedNodeViewNib when either of these properties changes.
// Keeping a cached NSNib instance helps speed up repeated instantiation of node views.
-// @property(retain) UINib *cachedNodeViewNib;
+// @property (nonatomic, retain) UINib *cachedNodeViewNib;
@end
View
4 PSTreeGraphView/PSTreeGraphModelNode.h
@@ -28,7 +28,7 @@
// The model node's child nodes. If the node has no children, this should return an
// empty array ([NSArray array]), not nil.
-- (NSArray *)childModelNodes;
+- (NSArray *) childModelNodes;
@end
@@ -40,7 +40,7 @@
// The delegate will configure the nodeView with the modelNode provided.
--(void) configureNodeView:(UIView *)nodeView withModelNode:(id <PSTreeGraphModelNode> )modelNode;
+- (void) configureNodeView:(UIView *)nodeView withModelNode:(id <PSTreeGraphModelNode> )modelNode;
@end
Please sign in to comment.
Something went wrong with that request. Please try again.