This repository has been archived by the owner on May 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFPWindowController.m
273 lines (260 loc) · 10.8 KB
/
FPWindowController.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
//
// FPWindowController.m
// FormulatePro
//
// Created by Andrew de los Reyes on 1/21/08.
// Copyright 2008 Andrew de los Reyes. All rights reserved.
//
#import "FPWindowController.h"
#import "MyDocument.h"
#import "FPLogging.h"
@implementation FPWindowController
- (id)init {
self = [super initWithWindowNibName:@"MyDocument"];
if (self) {
// do stuff
}
return self;
}
#pragma mark -
#pragma mark Overrides of NSWindowController Methods
- (void)setDocument:(NSDocument *)document
{
[super setDocument:document];
}
- (void)windowDidLoad
{
[super windowDidLoad];
DLog(@"FPWindowController: windowDidLoad called\n");
[_graphicsView bind:FPDocumentViewSelectionIndexesBindingName
toObject:_graphicsController
withKeyPath:@"selectionIndexes"
options:nil];
[_graphicsView bind:FPDocumentViewGraphicsBindingName
toObject:self
withKeyPath:[NSString stringWithFormat:@"%@.%@", @"document", @"overlayGraphics"]
options:nil];
[_graphicsView setPDFDocument:[(MyDocument*)[self document] pdfDocument]];
[_graphicsView setFrame:[_graphicsView idealFrame]];
}
- (id)valueForUndefinedKey:(NSString *)key
{
return [super valueForUndefinedKey:key];
}
#pragma mark -
#pragma mark NSToolbar methods
//- (IBAction)goToNextPage:(id)sender
//{
// //[_document_view nextPage];
//}
//
//- (IBAction)goToPreviousPage:(id)sender
//{
// //[_document_view previousPage];
//}
//
//- (void) setupToolbar {
// // Create a new toolbar instance, and attach it to our document window
// NSToolbar *toolbar =
// [[[NSToolbar alloc] initWithIdentifier:MyDocToolbarIdentifier]
// autorelease];
//
// // Set up toolbar properties: Allow customization, give a default display
// // mode, and remember state in user defaults
// [toolbar setAllowsUserCustomization:YES];
// [toolbar setAutosavesConfiguration:YES];
// [toolbar setDisplayMode:NSToolbarDisplayModeIconAndLabel];
//
// // We are the delegate
// [toolbar setDelegate: self];
//
// // Attach the toolbar to the document window
// [_document_window setToolbar:toolbar];
//}
//
//- (NSToolbarItem *) toolbar:(NSToolbar *)toolbar
// itemForItemIdentifier:(NSString *)itemIdent
// willBeInsertedIntoToolbar:(BOOL)willBeInserted {
// // Required delegate method: Given an item identifier, this method
// // returns an item. The toolbar will use this method to obtain toolbar
// // items that can be displayed in the customization sheet, or in the
// // toolbar itself
// NSToolbarItem *toolbarItem = nil;
//
// if ([itemIdent isEqual: MyDocToolbarIdentifierZoomIn]) {
// toolbarItem =
// [[[NSToolbarItem alloc] initWithItemIdentifier:itemIdent]
// autorelease];
//
// // Set the text label to be displayed in the toolbar and customization
// // palette
// [toolbarItem setLabel: @"Zoom In"];
// [toolbarItem setPaletteLabel: @"Zoom In"];
//
// // Set up a reasonable tooltip, and image Note, these aren't
// // localized, but you will likely want to localize many of the item's
// // properties
// [toolbarItem setToolTip: @"Zoom In"];
// [toolbarItem setImage: [NSImage imageNamed: @"viewmag+"]];
//
// // Tell the item what message to send when it is clicked
// [toolbarItem setTarget: self];
// [toolbarItem setAction: @selector(zoomIn:)];
// } else if ([itemIdent isEqual: MyDocToolbarIdentifierZoomOut]) {
// toolbarItem =
// [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent]
// autorelease];
//
// // Set the text label to be displayed in the toolbar and customization
// // palette
// [toolbarItem setLabel: @"Zoom Out"];
// [toolbarItem setPaletteLabel: @"Zoom Out"];
//
// // Set up a reasonable tooltip, and image Note, these aren't
// // localized, but you will likely want to localize many of the item's
// // properties
// [toolbarItem setToolTip: @"Zoom Out"];
// [toolbarItem setImage: [NSImage imageNamed: @"viewmag-"]];
//
// // Tell the item what message to send when it is clicked
// [toolbarItem setTarget: self];
// [toolbarItem setAction: @selector(zoomOut:)];
// } else if ([itemIdent isEqual: MyDocToolbarIdentifierOneUpTwoUpBook]) {
// toolbarItem =
// [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent]
// autorelease];
//
// // Set the text label to be displayed in the toolbar and customization
// // palette
// [toolbarItem setLabel: @"One Up, Two Up, Book Mode"];
// [toolbarItem setPaletteLabel: @"One Up, Two Up, Book Mode"];
//
// // Set up a reasonable tooltip, and image Note, these aren't
// // localized, but you will likely want to localize many of the item's
// // properties
// [toolbarItem setToolTip: @"One Up, Two Up, Book Mode"];
// //[toolbarItem setImage:
// // [NSImage imageNamed:@"SaveDocumentItemImage"]];
// [toolbarItem setView:_one_up_vs_two_up_vs_book];
// [toolbarItem setMinSize:
// NSMakeSize(NSWidth([_one_up_vs_two_up_vs_book frame]),
// NSHeight([_one_up_vs_two_up_vs_book frame]))];
// [toolbarItem setMaxSize:
// NSMakeSize(NSWidth([_one_up_vs_two_up_vs_book frame]),
// NSHeight([_one_up_vs_two_up_vs_book frame]))];
//
// // Tell the item what message to send when it is clicked
// [toolbarItem setTarget: self];
// [toolbarItem setAction: @selector(toggleOneUpTwoUpBookMode:)];
// } else if ([itemIdent isEqual: MyDocToolbarIdentifierSingleContinuous]) {
// toolbarItem =
// [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent]
// autorelease];
//
// // Set the text label to be displayed in the toolbar and customization
// // palette
// [toolbarItem setLabel: @"(Non) Continuous"];
// [toolbarItem setPaletteLabel: @"(Non) Continuous"];
//
// // Set up a reasonable tooltip, and image Note, these aren't
// // localized, but you will likely want to localize many of the item's
// // properties
// [toolbarItem setToolTip:
// @"Display the entire document or just current spread"];
// //[toolbarItem setImage:
// // [NSImage imageNamed: @"SaveDocumentItemImage"]];
// [toolbarItem setView:_single_vs_continuous];
// [toolbarItem setMinSize:
// NSMakeSize(NSWidth([_single_vs_continuous frame]),
// NSHeight([_single_vs_continuous frame]))];
// [toolbarItem setMaxSize:
// NSMakeSize(NSWidth([_single_vs_continuous frame]),
// NSHeight([_single_vs_continuous frame]))];
// [toolbarItem setAutovalidates:YES];
//
// // Tell the item what message to send when it is clicked
// [toolbarItem setTarget: self];
// [toolbarItem setAction: @selector(toggleContinuous:)];
// } else if ([itemIdent isEqual: MyDocToolbarIdentifierNextPage]) {
// toolbarItem =
// [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent]
// autorelease];
//
// // Set the text label to be displayed in the toolbar and customization
// // palette
// [toolbarItem setLabel: @"Next Page"];
// [toolbarItem setPaletteLabel: @"Next Page"];
//
// // Set up a reasonable tooltip, and image Note, these aren't
// // localized, but you will likely want to localize many of the item's
// // properties
// [toolbarItem setToolTip: @"Next Page"];
// [toolbarItem setImage: [NSImage imageNamed: @"next"]];
//
// // Tell the item what message to send when it is clicked
// [toolbarItem setTarget: self];
// [toolbarItem setAction: @selector(goToNextPage:)];
// } else if ([itemIdent isEqual: MyDocToolbarIdentifierPreviousPage]) {
// toolbarItem =
// [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent]
// autorelease];
//
// // Set the text label to be displayed in the toolbar and customization
// // palette
// [toolbarItem setLabel: @"Previous Page"];
// [toolbarItem setPaletteLabel: @"Previous Page"];
//
// // Set up a reasonable tooltip, and image Note, these aren't
// // localized, but you will likely want to localize many of the item's
// // properties
// [toolbarItem setToolTip: @"Previous Page"];
// [toolbarItem setImage: [NSImage imageNamed: @"previous"]];
//
// // Tell the item what message to send when it is clicked
// [toolbarItem setTarget: self];
// [toolbarItem setAction: @selector(goToPreviousPage:)];
// } else {
// // itemIdent refered to a toolbar item that is not provide or
// // supported by us or cocoa. Returning nil will inform the toolbar
// // this kind of item is not supported
// toolbarItem = nil;
// }
// return toolbarItem;
//}
//
//- (NSArray *) toolbarDefaultItemIdentifiers: (NSToolbar *) toolbar {
// // Required delegate method: Returns the ordered list of items to be
// // shown in the toolbar by default. If during the toolbar's
// // initialization, no overriding values are found in the user defaults, or
// // if the user chooses to revert to the default items this set will be
// // used
// return [NSArray arrayWithObjects:
// MyDocToolbarIdentifierZoomIn,
// MyDocToolbarIdentifierZoomOut,
// NSToolbarSeparatorItemIdentifier,
// NSToolbarFlexibleSpaceItemIdentifier,
// NSToolbarCustomizeToolbarItemIdentifier,
// nil];
//}
//
//- (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar {
// // Required delegate method: Returns the list of all allowed items by
// // identifier. By default, the toolbar does not assume any items are
// // allowed, even the separator. So, every allowed item must be explicitly
// // listed. The set of allowed items is used to construct the customization
// // palette
// return [NSArray arrayWithObjects:
// MyDocToolbarIdentifierZoomIn,
// MyDocToolbarIdentifierZoomOut,
// //MyDocToolbarIdentifierOneUpTwoUpBook,
// //MyDocToolbarIdentifierSingleContinuous,
// MyDocToolbarIdentifierPreviousPage,
// MyDocToolbarIdentifierNextPage,
//
// NSToolbarCustomizeToolbarItemIdentifier,
// NSToolbarFlexibleSpaceItemIdentifier,
// NSToolbarSpaceItemIdentifier,
// NSToolbarSeparatorItemIdentifier,
// nil];
//}
@end