diff options
author | Alex Merry <alex.merry@cs.ox.ac.uk> | 2013-02-04 14:45:56 +0000 |
---|---|---|
committer | Alex Merry <alex.merry@cs.ox.ac.uk> | 2013-02-04 14:45:56 +0000 |
commit | 19e555267a2170d38e77e563192bfafe20d2f5c5 (patch) | |
tree | 526dff96fc68289ba6ff932f16dfe748b8991f11 /tikzit/src/common/StyleManager.m | |
parent | fe1b43c7b7c83e392b60ffc71ac29f7e63810f58 (diff) |
Only change style settings when OK is clicked
If the user clicks Cancel, nothing changes.
Diffstat (limited to 'tikzit/src/common/StyleManager.m')
-rw-r--r-- | tikzit/src/common/StyleManager.m | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tikzit/src/common/StyleManager.m b/tikzit/src/common/StyleManager.m index 837a094..ae0d488 100644 --- a/tikzit/src/common/StyleManager.m +++ b/tikzit/src/common/StyleManager.m @@ -294,6 +294,48 @@ [style release]; } +- (void) updateFromManager:(StyleManager*)m { + NSMutableArray *ns = [NSMutableArray arrayWithCapacity:[[m nodeStyles] count]]; + for (NodeStyle *style in [m nodeStyles]) { + NodeStyle *currentStyle = [self nodeStyleForName:[style name]]; + if (currentStyle != nil) { + [currentStyle updateFromStyle:style]; + [ns addObject:currentStyle]; + } else { + [ns addObject:[[style copy] autorelease]]; + } + } + NSMutableArray *es = [NSMutableArray arrayWithCapacity:[[m edgeStyles] count]]; + for (EdgeStyle *style in [m edgeStyles]) { + EdgeStyle *currentStyle = [self edgeStyleForName:[style name]]; + if (currentStyle != nil) { + [currentStyle updateFromStyle:style]; + [es addObject:currentStyle]; + } else { + [es addObject:[[style copy] autorelease]]; + } + } + [self _setNodeStyles:ns]; + [self _setEdgeStyles:es]; +} + +- (id) copyWithZone:(NSZone*)zone { + StyleManager *m = [[StyleManager allocWithZone:zone] init]; + + NSMutableArray *ns = [NSMutableArray arrayWithCapacity:[nodeStyles count]]; + for (NodeStyle *style in nodeStyles) { + [ns addObject:[[style copyWithZone:zone] autorelease]]; + } + NSMutableArray *es = [NSMutableArray arrayWithCapacity:[edgeStyles count]]; + for (EdgeStyle *style in edgeStyles) { + [es addObject:[[style copyWithZone:zone] autorelease]]; + } + [m _setNodeStyles:ns]; + [m _setEdgeStyles:es]; + + return m; +} + @end // vi:ft=objc:ts=4:noet:sts=4:sw=4 |