forked from erkyrath/Inform7-IDE-Mac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIFPretendWebView.m
101 lines (77 loc) · 2.02 KB
/
IFPretendWebView.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
//
// IFPretendWebView.m
// Inform
//
// Created by Andrew Hunter on 18/11/2004.
// Copyright 2004 Andrew Hunter. All rights reserved.
//
#import "IFPretendWebView.h"
#import "IFPreferences.h"
@implementation IFPretendWebView
- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
aRequest = nil;
hostWindow = nil;
}
return self;
}
- (void) dealloc {
[aRequest release];
[hostWindow release];
[super dealloc];
}
- (void) morph {
}
- (void)drawRect:(NSRect)rect {
// Morphing time!
[[NSRunLoop currentRunLoop] performSelector: @selector(morphMe)
target: self
argument: nil
order: 128
modes: [NSArray arrayWithObject: NSDefaultRunLoopMode]];
}
- (void) setRequest: (NSURLRequest*) request {
if (aRequest) [aRequest release];
aRequest = [request copy];
}
- (NSURLRequest*) request {
return aRequest;
}
- (void) setHostWindow: (NSWindow*) newHostWindow {
if (hostWindow) [hostWindow release];
hostWindow = [newHostWindow retain];
}
- (void) setPolicyDelegate: (id) delegate {
policyDelegate = delegate;
}
- (void) setFrameLoadDelegate: (id) delegate {
frameLoadDelegate = delegate;
}
- (void) morphMe {
// Schedule our destruction
[[self retain] autorelease];
// Create the webview
WebView* replacementView = [[WebView alloc] initWithFrame: [self frame]];
[replacementView setAutoresizingMask: [self autoresizingMask]];
[replacementView setTextSizeMultiplier: [[IFPreferences sharedPreferences] fontSize]];
if (hostWindow) {
[replacementView setHostWindow: hostWindow];
}
if (policyDelegate) {
[replacementView setPolicyDelegate: policyDelegate];
}
if (frameLoadDelegate) {
[replacementView setFrameLoadDelegate: frameLoadDelegate];
}
// Leave our superview
NSView* sview = [[[self superview] retain] autorelease];
[self removeFromSuperview];
// Add to the superview
[sview addSubview: replacementView];
// Load the request
if (aRequest) {
[[replacementView mainFrame] loadRequest: aRequest];
}
}
@end