forked from rentzsch/Blitz
-
Notifications
You must be signed in to change notification settings - Fork 1
/
SpeakerNotesWindowController.m
86 lines (68 loc) · 2.03 KB
/
SpeakerNotesWindowController.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
//
// SpeakerNotesWindowController.m
// Blitz
//
// Created by Timothy J. Wood on 9/19/09.
// Copyright 2009 The Omni Group. All rights reserved.
//
#import "SpeakerNotesWindowController.h"
#import <WebKit/WebKit.h>
@implementation SpeakerNotesWindowController
- initWithHTMLData:(NSData *)htmlData;
{
if (!(self = [super initWithWindowNibName:@"SpeakerNotes"]))
return nil;
_pageIndex = (NSUInteger)-1;
_htmlData = [htmlData copy];
return self;
}
@synthesize webView = _webView;
@synthesize slidesView = _slidesView;
- (void)dealloc;
{
[_webView release];
[_slidesView release];
[_htmlData release];
[super dealloc];
}
#pragma mark -
#pragma mark NSWindowController subclass
- (void)windowDidLoad;
{
[super windowDidLoad];
[[_webView mainFrame] loadData:_htmlData MIMEType:@"text/html" textEncodingName:@"utf-8" baseURL:nil];
}
- (void)setDocument:(NSDocument *)document;
{
[super setDocument:document];
if (document) {
[self window]; // make sure we have a _slidesView...
[self bind:@"pageIndex" toObject:document withKeyPath:@"pageIndex" options:nil];
[_slidesView bind:@"pdfDocument" toObject:document withKeyPath:@"pdfDocument" options:nil];
[_slidesView bind:@"pageIndex" toObject:document withKeyPath:@"pageIndex" options:nil];
} else {
[self unbind:@"pageIndex"];
[_slidesView unbind:@"pdfDocument"];
[_slidesView unbind:@"pageIndex"];
}
}
#pragma mark -
#pragma mark KVC
- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)webFrame;
{
// show the first set of speaker notes once we are fully loaded.
self.pageIndex = 0;
}
@synthesize pageIndex = _pageIndex;
- (void)setPageIndex:(NSUInteger)pageIndex;
{
_pageIndex = pageIndex;
[[_webView windowScriptObject] evaluateWebScript:[NSString stringWithFormat:@"displayNotesForSlide(%lu);", pageIndex]];
}
#pragma mark -
#pragma mark Actions
- (void)changeFont:(id)sender;
{
[_webView setTextSizeMultiplier:[sender floatValue]];
}
@end