diff options
author | randomguy3 <randomguy3@7c02a99a-9b00-45e3-bf44-6f3dd7fddb64> | 2012-03-10 13:37:44 +0000 |
---|---|---|
committer | randomguy3 <randomguy3@7c02a99a-9b00-45e3-bf44-6f3dd7fddb64> | 2012-03-10 13:37:44 +0000 |
commit | e6636042890e1dbfc442dfa0fedd9797c7cb8eff (patch) | |
tree | 20ce19e671bdd0e43fceed86172a41724c94926f /tikzit/src/common/NodeStyle.m | |
parent | 0cd05a572e48b1e649ecdc8b24920c497e40466e (diff) |
Make common code KVC compliant, and implement NSCopying where relevant
git-svn-id: https://tikzit.svn.sourceforge.net/svnroot/tikzit/trunk@420 7c02a99a-9b00-45e3-bf44-6f3dd7fddb64
Diffstat (limited to 'tikzit/src/common/NodeStyle.m')
-rw-r--r-- | tikzit/src/common/NodeStyle.m | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/tikzit/src/common/NodeStyle.m b/tikzit/src/common/NodeStyle.m index b3d9ab2..8d8b83f 100644 --- a/tikzit/src/common/NodeStyle.m +++ b/tikzit/src/common/NodeStyle.m @@ -28,7 +28,7 @@ + (int) defaultStrokeThickness { return 1; } -- (id)init { +- (id)initWithName:(NSString*)nm { self = [super initWithNotificationName:@"NodeStylePropertyChanged"]; if (self != nil) { strokeThickness = [NodeStyle defaultStrokeThickness]; @@ -36,21 +36,41 @@ strokeColorRGB = [[ColorRGB alloc] initWithRed:0 green:0 blue:0]; fillColorRGB = [[ColorRGB alloc] initWithRed:255 green:255 blue:255]; - name = @"new"; + name = nm; category = nil; shapeName = SHAPE_CIRCLE; } return self; } -- (id)initWithName:(NSString*)nm { - self = [self init]; - if (self != nil) { - [self setName:nm]; - } +- (id)init { + self = [self initWithName:@"new"]; return self; } +- (id)copyWithZone:(NSZone*)zone { + NodeStyle *style = [[NodeStyle allocWithZone:zone] init]; + + [style setStrokeThickness:[self strokeThickness]]; + [style setScale:[self scale]]; + [style setStrokeColorRGB:[self strokeColorRGB]]; + [style setFillColorRGB:[self fillColorRGB]]; + [style setName:[self name]]; + [style setShapeName:[self shapeName]]; + [style setCategory:[self category]]; + + return style; +} + +- (void)dealloc { + [name release]; + [category release]; + [shapeName release]; + [strokeColorRGB release]; + [fillColorRGB release]; + [super dealloc]; +} + + (NodeStyle*)defaultNodeStyleWithName:(NSString*)nm { return [[[NodeStyle alloc] initWithName:nm] autorelease]; } @@ -164,11 +184,6 @@ return ([fillColorRGB name] != nil); } -- (void)dealloc { - [self setName:nil]; - [super dealloc]; -} - @end // vi:ft=objc:ts=4:noet:sts=4:sw=4 |