/
WILDCardWindowController.m
116 lines (87 loc) · 2.41 KB
/
WILDCardWindowController.m
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//
// WILDCardWindowController.m
// Stacksmith
//
// Created by Uli Kusterer on 18.04.10.
// Copyright 2010 The Void Software. All rights reserved.
//
#import "WILDCardWindowController.h"
#import "WILDDocument.h"
#import "WILDStack.h"
#import "WILDCard.h"
#import "WILDXMLUtils.h"
#import "WILDCardViewController.h"
#import "WILDCardView.h"
#import "NSFileHandle+UKReadLinewise.h"
#import "UKProgressPanelController.h"
#import "NSView+SizeWindowForViewSize.h"
#import <Quartz/Quartz.h>
@implementation WILDCardWindowController
- (id)initWithStack: (WILDStack*)inStack
{
self = [super initWithWindowNibName: NSStringFromClass([self class])];
if( self )
{
[self setShouldCascadeWindows: NO];
mStack = inStack;
}
return self;
}
-(void) dealloc
{
mCardViewController = nil; // It's an outlet now.
mStack = nil;
[super dealloc];
}
-(void) awakeFromNib
{
// Make sure window fits the cards:
NSSize cardSize = [mStack cardSize];
if( cardSize.width == 0 || cardSize.height == 0 )
cardSize = NSMakeSize( 512, 342 );
[mView sizeWindowForViewSize: cardSize];
[self.window centerHorizontallyAndVertically];
[mCardViewController setView: mView];
if( [[mStack cards] count] > 0 )
[mCardViewController loadCard: [[mStack cards] objectAtIndex: 0]];
// if( [self fileURL] )
// {
// NSString* iconPath = [[[self fileURL] path] stringByAppendingPathComponent: @"Icon\r"];
// if( ![[NSFileManager defaultManager] fileExistsAtPath: iconPath] )
// [self performSelector: @selector(generatePreview) withObject: nil afterDelay: 0.0];
// }
}
-(WILDStack*) stack
{
return mStack;
}
-(id<WILDVisibleObject>) visibleObjectForWILDObject: (id)inObjectToFind
{
if( inObjectToFind == [mCardViewController currentCard]
|| inObjectToFind == [[mCardViewController currentCard] owningBackground] )
return self; // Window is also visible object for card & bg.
return [mCardViewController visibleObjectForWILDObject: inObjectToFind];
}
-(NSRect) frameInScreenCoordinates
{
return [[self window] frame];
}
-(void) goToCard: (WILDCard*)inCard
{
[mCardViewController loadCard: inCard];
}
-(WILDCard*) currentCard
{
return [mCardViewController currentCard];
}
-(void) close
{
[[self window] orderOut: self];
[mCardViewController loadCard: nil];
[super close];
}
-(void) setTransitionType: (NSString*)inType subtype: (NSString*)inSubtype
{
[mCardViewController setTransitionType: inType subtype: inSubtype];
}
@end