summaryrefslogtreecommitdiff
path: root/tikzit/src/osx/CustomNodeController.m
blob: ef6b5bdb620175801a5c6c35d8e45ef2b7be8a1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//
//  CustomNodeController.m
//  TikZiT
//
//  Created by Johan Paulsson on 12/4/13.
//  Copyright (c) 2013 Aleks Kissinger. All rights reserved.
//

#import "CustomNodeController.h"
#import "NodeStyle.h"

@interface CustomNodeController ()

@end

@implementation CustomNodeController

@synthesize nodeStyles, onodeStyles;
@synthesize graphicsView, tikzSourceController;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
//        [SupportDir createUserSupportDir];
//        NSString *supportDir = [SupportDir userSupportDir];
        
//        NSString *ns = [supportDir stringByAppendingPathComponent:@"nodeStyles.plist"];
//        NSString *es = [supportDir stringByAppendingPathComponent:@"edgeStyles.plist"];
//		onodeStyles = (NSMutableArray*)[NSKeyedUnarchiver
//                                       unarchiveObjectWithFile:ns];
 //       edgeStyles = (NSMutableArray*)[NSKeyedUnarchiver
//                                     unarchiveObjectWithFile:es];
		
        if (onodeStyles == nil) onodeStyles = [NSMutableArray array];
//		if (edgeStyles == nil) edgeStyles = [NSMutableArray array];
        
//		[[self window] setLevel:NSNormalWindowLevel];
//		[self showWindow:self];
	
        // Initialization code here.
        
        NSLog(@"Custom Node controller up and running!");
        
        nodeStyles= [Shape shapeDictionary];

        customNodeStyles = [NSMutableArray array];
        
        NSLog(@"Got a shape dictionary?");
        
        NSString *meh;
        
        for(id key in nodeStyles) {
            Shape *value = [nodeStyles objectForKey:key];
            
            if([value isKindOfClass:[TikzShape class]]){
                NSLog(@"Got a custom node shape!");
                NodeStyle *newNodeStyle = [[NodeStyle alloc] init];
                [newNodeStyle setShapeName:key];
                
                [customNodeStyles addObject:newNodeStyle];
                [onodeStyles addObject:newNodeStyle];
                
//                meh = [(TikzShape *) value tikz];
            }
        }
        
        NSLog(@"Trying to display tikz.");
        
//        [tikzSourceController setTikz:meh];
//        [tikzSourceController parseTikz:self];
    }
    
    return self;
}

-(NSArray *)onodeStyles{
    return onodeStyles;
    //return [nodeStyles allValues];
}

- (void)tableViewSelectionDidChange:(NSNotification *)aNotification{
    NSLog(@"Changed selection!");
}

- (id)valueForUndefinedKey:(NSString *)key{
    return nil;
}

@end