VocalEasel/Sources/VLPDFView.mm

82 lines
1.7 KiB
Plaintext
Raw Normal View History

2006-10-26 08:21:50 +00:00
//
2007-04-27 06:41:34 +00:00
// File: VLPDFView.mm - Display PDF output for lead sheet
2006-10-26 08:21:50 +00:00
//
2007-04-27 06:41:34 +00:00
// Author(s):
//
// (MN) Matthias Neeracher
//
2018-02-19 00:59:23 +00:00
// Copyright © 2005-2018 Matthias Neeracher
2006-10-26 08:21:50 +00:00
//
#import "VLPDFView.h"
2006-11-06 15:49:50 +00:00
#include <algorithm>
2006-10-26 08:21:50 +00:00
@implementation VLPDFView
#if 0
2006-10-26 08:21:50 +00:00
- (BOOL)tryOpenURL:(NSURL *)url
{
if ([[url scheme] isEqual: @"textedit"]) {
//
// Handle TextEdit links internally
//
NSString * path = [url path];
NSArray * components = [[path lastPathComponent] componentsSeparatedByString: @":"];
unsigned count = [components count];
if (count > 2) {
int line = [[components objectAtIndex: count-2] intValue];
int pos = [[components objectAtIndex: count-1] intValue];
[[[[self window] windowController] document] selectCharacter:pos inLine:line];
}
return YES;
} else
return [super tryOpenURL:url] != NULL;
}
#endif
2006-10-26 08:21:50 +00:00
- (BOOL) canBecomeKeyView
{
return YES;
}
2006-11-06 15:49:50 +00:00
- (IBAction) displaySinglePage: (id) sender
{
// Display single page mode.
if ([self displayMode] > kPDFDisplaySinglePageContinuous)
2018-02-19 00:59:23 +00:00
[self setDisplayMode: static_cast<PDFDisplayMode>([self displayMode] - 2)];
2006-11-06 15:49:50 +00:00
}
- (IBAction) displayTwoUp: (id) sender
{
// Display two-up.
if ([self displayMode] < kPDFDisplayTwoUp)
2018-02-19 00:59:23 +00:00
[self setDisplayMode: static_cast<PDFDisplayMode>([self displayMode] + 2)];
2006-11-06 15:49:50 +00:00
}
- (IBAction) zoomToFit: (id) sender
{
NSSize sz = [self frame].size;
NSSize frame= [[self documentView] frame].size;
float scale = std::min(sz.width / frame.width, sz.height / frame.height);
[self setScaleFactor: scale];
}
- (IBAction) zoomToFitWidth: (id) sender
{
NSSize sz = [self frame].size;
NSSize frame= [[self documentView] frame].size;
[self setScaleFactor: sz.width / frame.width];
}
- (IBAction) zoomToActualSize: (id) sender
{
[self setScaleFactor: 1.0];
}
2006-10-26 08:21:50 +00:00
@end