diff options
Diffstat (limited to 'tikzit/src/osx')
-rw-r--r-- | tikzit/src/osx/AppDelegate.m | 4 | ||||
-rw-r--r-- | tikzit/src/osx/PreambleController.h | 2 | ||||
-rw-r--r-- | tikzit/src/osx/PreambleController.m | 3 | ||||
-rw-r--r-- | tikzit/src/osx/PropertyInspectorController.h | 10 | ||||
-rw-r--r-- | tikzit/src/osx/PropertyInspectorController.m | 7 | ||||
-rw-r--r-- | tikzit/src/osx/TikzFormatter.h | 29 | ||||
-rw-r--r-- | tikzit/src/osx/TikzFormatter.m | 92 |
7 files changed, 142 insertions, 5 deletions
diff --git a/tikzit/src/osx/AppDelegate.m b/tikzit/src/osx/AppDelegate.m index edfaf19..bb1b5d6 100644 --- a/tikzit/src/osx/AppDelegate.m +++ b/tikzit/src/osx/AppDelegate.m @@ -51,7 +51,9 @@ preambleController = [[PreambleController alloc] initWithWindowNibName:@"Preamble" plist:preamblePlist - styles:[stylePaletteController nodeStyles]]; + styles:[stylePaletteController nodeStyles] + edges:[stylePaletteController edgeStyles]]; + char template[] = "/tmp/tikzit_tmp_XXXXXXX"; char *dir = mkdtemp(template); diff --git a/tikzit/src/osx/PreambleController.h b/tikzit/src/osx/PreambleController.h index 4f7fb33..2d5a8ab 100644 --- a/tikzit/src/osx/PreambleController.h +++ b/tikzit/src/osx/PreambleController.h @@ -44,7 +44,7 @@ @property (retain) NSAttributedString *preambleText; @property (retain) NSIndexSet *selectionIndexes; -- (id)initWithWindowNibName:(NSString *)windowNibName plist:(NSString*)plist styles:(NSArray*)sty; +- (id)initWithWindowNibName:(NSString *)windowNibName plist:(NSString*)plist styles:(NSArray*)sty edges:(NSArray*)edg; - (void)savePreambles:(NSString*)plist; - (NSString*)currentPreamble; - (NSString*)currentPostamble; diff --git a/tikzit/src/osx/PreambleController.m b/tikzit/src/osx/PreambleController.m index e09a3fc..e424e7b 100644 --- a/tikzit/src/osx/PreambleController.m +++ b/tikzit/src/osx/PreambleController.m @@ -28,11 +28,12 @@ @synthesize preambleText, preambles; -- (id)initWithWindowNibName:(NSString *)windowNibName plist:(NSString*)plist styles:(NSArray*)sty { +- (id)initWithWindowNibName:(NSString *)windowNibName plist:(NSString*)plist styles:(NSArray*)sty edges:(NSArray*)edg { [super initWithWindowNibName:windowNibName]; preambles = (Preambles*)[NSKeyedUnarchiver unarchiveObjectWithFile:plist]; [preambles setStyles:sty]; + [preambles setEdges:edg]; if (preambles == nil) preambles = [[Preambles alloc] init]; preambleText = nil; diff --git a/tikzit/src/osx/PropertyInspectorController.h b/tikzit/src/osx/PropertyInspectorController.h index cb14021..0625f9b 100644 --- a/tikzit/src/osx/PropertyInspectorController.h +++ b/tikzit/src/osx/PropertyInspectorController.h @@ -18,6 +18,8 @@ IBOutlet NSView *nodePropertiesView; IBOutlet NSView *graphPropertiesView; IBOutlet NSView *edgePropertiesView; + IBOutlet NSComboBox *sourceAnchorComboBox; + IBOutlet NSComboBox *targetAnchorComboBox; IBOutlet NSTextField *edgeNodeLabelField; IBOutlet NSButton *edgeNodeCheckbox; IBOutlet NSArrayController *nodeDataArrayController; @@ -25,6 +27,12 @@ IBOutlet NSArrayController *edgeDataArrayController; IBOutlet NSArrayController *edgeNodeDataArrayController; + NSMutableArray *sourceAnchorNames; + IBOutlet NSArrayController *sourceAnchorNamesArrayController; + + NSMutableArray *targetAnchorNames; + IBOutlet NSArrayController *targetAnchorNamesArrayController; + NSMutableArray *selectedNodes; IBOutlet NSArrayController *selectedNodesArrayController; @@ -46,6 +54,8 @@ //@property (readonly) BOOL enableEdgeDataControls; @property (retain) NSMutableArray *selectedNodes; @property (retain) NSMutableArray *selectedEdges; +@property (retain) NSMutableArray *sourceAnchorNames; +@property (retain) NSMutableArray *targetAnchorNames; @property (retain) StylePaletteController *stylePaletteController; - (id)initWithWindowNibName:(NSString *)windowNibName; diff --git a/tikzit/src/osx/PropertyInspectorController.m b/tikzit/src/osx/PropertyInspectorController.m index 8254949..1411549 100644 --- a/tikzit/src/osx/PropertyInspectorController.m +++ b/tikzit/src/osx/PropertyInspectorController.m @@ -22,6 +22,7 @@ @synthesize stylePaletteController; @synthesize selectedNodes, selectedEdges; +@synthesize sourceAnchorNames, targetAnchorNames; - (id)initWithWindowNibName:(NSString *)windowNibName { [super initWithWindowNibName:windowNibName]; @@ -50,8 +51,10 @@ name:@"NSWindowDidBecomeMainNotification" object:nil]; - - + [self setSourceAnchorNames: [[NSMutableArray alloc] initWithArray: [@"north south west east" componentsSeparatedByString:@" "]]]; + + [self setTargetAnchorNames: [[NSMutableArray alloc] initWithArray:[@"north south west east" componentsSeparatedByString:@" "]]]; + [[self window] setLevel:NSNormalWindowLevel]; [self showWindow:self]; diff --git a/tikzit/src/osx/TikzFormatter.h b/tikzit/src/osx/TikzFormatter.h new file mode 100644 index 0000000..4d9ec04 --- /dev/null +++ b/tikzit/src/osx/TikzFormatter.h @@ -0,0 +1,29 @@ +// +// NSTikzFormatter.h +// TikZiT +// +// Created by Karl Johan Paulsson on 27/01/2013. +// Copyright (c) 2013 Aleks Kissinger. All rights reserved. +// +// +// This file is part of TikZiT. +// +// TikZiT is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// TikZiT is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with TikZiT. If not, see <http://www.gnu.org/licenses/>. +// + +#import <Foundation/Foundation.h> + +@interface TikzFormatter : NSFormatter + +@end diff --git a/tikzit/src/osx/TikzFormatter.m b/tikzit/src/osx/TikzFormatter.m new file mode 100644 index 0000000..ecbb0bc --- /dev/null +++ b/tikzit/src/osx/TikzFormatter.m @@ -0,0 +1,92 @@ +// +// NSTikzFormatter.m +// TikZiT +// +// Created by Karl Johan Paulsson on 27/01/2013. +// Copyright (c) 2013 Aleks Kissinger. All rights reserved. +// +// +// This file is part of TikZiT. +// +// TikZiT is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// TikZiT is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with TikZiT. If not, see <http://www.gnu.org/licenses/>. +// + +#import "TikzFormatter.h" +#import "TikzGraphAssembler.h" + +@implementation TikzFormatter + +- (NSString *)stringForObjectValue:(id)obj{ + if (![obj isKindOfClass:[NSString class]]) { + return @""; + } + + return [NSString stringWithString:obj]; +} + +- (BOOL)getObjectValue:(out id *)obj forString:(NSString *)string errorDescription:(out NSString **)error{ + *obj = [NSString stringWithString:string]; + + TikzGraphAssembler *ass = [[TikzGraphAssembler alloc] init]; + BOOL r = [ass testTikz:string]; + + if (!r && error) + *error = NSLocalizedString(@"Invalid input, couldn't parse value.", @"tikz user input error"); + + return r; +} + +- (BOOL)isPartialStringValid:(NSString **)partialStringPtr proposedSelectedRange:(NSRangePointer)proposedSelRangePtr originalString:(NSString *)origString originalSelectedRange:(NSRange)origSelRange errorDescription:(NSString **)error{ + NSRange addedRange; + NSString *addedString; + + addedRange = NSMakeRange(origSelRange.location, proposedSelRangePtr->location - origSelRange.location); + addedString = [*partialStringPtr substringWithRange: addedRange]; + + if([addedString isEqualToString:@"{"]){ + NSString *s = [[NSString stringWithString:*partialStringPtr] stringByAppendingString:@"}"]; + *partialStringPtr = s; + + return NO; + } + + if([addedString isEqualToString:@"}"]){ + NSScanner *scanner = [NSScanner scannerWithString:*partialStringPtr]; + + NSCharacterSet *cs = [NSCharacterSet characterSetWithCharactersInString:@"{}"]; + NSMutableString *strippedString = [NSMutableString stringWithCapacity:[*partialStringPtr length]]; + + while ([scanner isAtEnd] == NO) { + NSString *buffer; + if ([scanner scanCharactersFromSet:cs intoString:&buffer]) { + [strippedString appendString:buffer]; + + } else { + [scanner setScanLocation:([scanner scanLocation] + 1)]; + } + } + + [cs autorelease]; + [scanner autorelease]; + [strippedString autorelease]; + + if([strippedString length] % 2 == 1){ + return NO; + } + } + + return YES; +} + +@end |