summaryrefslogtreecommitdiff
path: root/tikzit/src/common/EdgeStyle.m
diff options
context:
space:
mode:
Diffstat (limited to 'tikzit/src/common/EdgeStyle.m')
-rw-r--r--tikzit/src/common/EdgeStyle.m30
1 files changed, 30 insertions, 0 deletions
diff --git a/tikzit/src/common/EdgeStyle.m b/tikzit/src/common/EdgeStyle.m
index da669e3..88b1f54 100644
--- a/tikzit/src/common/EdgeStyle.m
+++ b/tikzit/src/common/EdgeStyle.m
@@ -31,9 +31,16 @@
@"headStyle",
@"decorationStyle",
@"thickness",
+ @"colorRGB.red",
+ @"colorRGB.blue",
+ @"colorRGB.green",
@"name",
nil]
triggerChangeNotificationsForDependentKey:@"tikz"];
+ [self setKeys:[NSArray arrayWithObjects:
+ @"colorRGB.name",
+ nil]
+ triggerChangeNotificationsForDependentKey:@"colorIsKnown"];
}
- (id)initWithName:(NSString*)nm {
@@ -43,6 +50,7 @@
headStyle = AH_None;
tailStyle = AH_None;
decorationStyle = ED_None;
+ colorRGB = [[ColorRGB alloc] initWithRed:0 green:0 blue:0];
name = nm;
category = nil;
thickness = 1.0f;
@@ -64,12 +72,14 @@
[style setTailStyle:[self tailStyle]];
[style setDecorationStyle:[self decorationStyle]];
[style setThickness:[self thickness]];
+ [style setColorRGB:[self colorRGB]];
return style;
}
- (void)dealloc {
[name release];
[category release];
+ [colorRGB release];
[super dealloc];
}
@@ -127,9 +137,26 @@
}
}
+- (ColorRGB*)colorRGB {
+ return colorRGB;
+}
+
+- (void)setColorRGB:(ColorRGB*)c {
+ if (colorRGB != c) {
+ ColorRGB *oldValue = colorRGB;
+ colorRGB = [c copy];
+ [self postPropertyChanged:@"colorRGB" oldValue:oldValue];
+ [oldValue release];
+ }
+}
+
- (NSString*)tikz {
NSMutableString *buf = [NSMutableString stringWithFormat:@"\\tikzstyle{%@}=[", name];
+ NSString *colorName = [colorRGB name];
+ if (colorName == nil)
+ colorName = [colorRGB hexName];
+
if (tailStyle == AH_Plain)
[buf appendString:@"<"];
else if (tailStyle == AH_Latex)
@@ -142,6 +169,9 @@
else if (headStyle == AH_Latex)
[buf appendString:@"latex"];
+ [buf appendString:@",draw="];
+ [buf appendString:colorName];
+
if (decorationStyle != ED_None) {
[buf appendString:@",postaction={decorate},decoration={markings,mark="];
if (decorationStyle == ED_Arrow)