|
@@ -49,7 +49,6 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
if self._selectsText != newValue {
|
|
|
self._selectsText = newValue
|
|
|
if newValue == false {
|
|
|
-// [self setCurrentSelection:RUNNING_AFTER(10_11) ? [[[PDFSelection alloc] initWithDocument:[self document]] autorelease] : nil];
|
|
|
self.currentSelection = CPDFSelection(document: self.document)
|
|
|
}
|
|
|
self.toolModeButton?.state = self.selectsText ? .on : .off
|
|
@@ -70,18 +69,16 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
private var SKDefaultScaleMenuLabels = ["=", "Auto", "10%", "20%", "25%", "35%", "50%", "60%", "71%", "85%", "100%", "120%", "141%", "170%", "200%", "300%", "400%", "600%", "800%", "1000%", "1200%", "1400%", "1700%", "2000%"]
|
|
|
private var SKDefaultScaleMenuFactors = [0.0, 0.0, 0.1, 0.2, 0.25, 0.35, 0.5, 0.6, 0.71, 0.85, 1.0, 1.2, 1.41, 1.7, 2.0, 3.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, 17.0, 20.0]
|
|
|
|
|
|
-// #define SKMinDefaultScaleMenuFactor (SKDefaultScaleMenuFactors[2])
|
|
|
private var SKMinDefaultScaleMenuFactor = 0.1
|
|
|
private var SKDefaultScaleMenuFactorsCount = 24
|
|
|
|
|
|
-
|
|
|
private var CONTROL_FONT_SIZE = 10.0
|
|
|
private var CONTROL_HEIGHT = 15.0
|
|
|
private var CONTROL_WIDTH_OFFSET = 20.0
|
|
|
-
|
|
|
+
|
|
|
override func draw(_ dirtyRect: NSRect) {
|
|
|
super.draw(dirtyRect)
|
|
|
-
|
|
|
+
|
|
|
// Drawing code here.
|
|
|
}
|
|
|
|
|
@@ -113,9 +110,6 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
self.selectsText = KMDataManager.ud_bool(forKey: SKLastSecondarySelectsTextKey)
|
|
|
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(handlePageChangedNotification), name: NSNotification.Name.CPDFViewPageChanged, object: self)
|
|
|
-// if ([PDFView instancesRespondToSelector:@selector(magnifyWithEvent:)] == NO || [PDFView instanceMethodForSelector:@selector(magnifyWithEvent:)] == [NSView instanceMethodForSelector:@selector(magnifyWithEvent:)])
|
|
|
-// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handlePDFViewScaleChangedNotification:)
|
|
|
-// name:PDFViewScaleChangedNotification object:self];
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(themeChanged), name: NSApplication.interfaceThemeChangedNotification, object: nil)
|
|
|
}
|
|
|
|
|
@@ -128,12 +122,12 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
self.scalePopUpButton?.isEnabled = true
|
|
|
self.scalePopUpButton?.refusesFirstResponder = true
|
|
|
(self.scalePopUpButton?.cell as? NSPopUpButtonCell)?.usesItemFromMenu = true
|
|
|
-
|
|
|
+
|
|
|
// set a suitable font, the control size is 0, 1 or 2
|
|
|
self.scalePopUpButton?.font = .toolTipsFont(ofSize: CONTROL_FONT_SIZE)
|
|
|
-
|
|
|
+
|
|
|
var cnt = 0
|
|
|
- var numberOfDefaultItems = SKDefaultScaleMenuFactorsCount
|
|
|
+ let numberOfDefaultItems = SKDefaultScaleMenuFactorsCount
|
|
|
var curItem: NSMenuItem?
|
|
|
var label: String?
|
|
|
var width: CGFloat = 0
|
|
@@ -142,7 +136,6 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
let attrs = [NSAttributedString.Key.font : self.scalePopUpButton?.font ?? .toolTipsFont(ofSize: CONTROL_FONT_SIZE)]
|
|
|
var maxIndex = 0
|
|
|
|
|
|
- // fill it
|
|
|
for i in 0 ..< numberOfDefaultItems {
|
|
|
cnt = i
|
|
|
label = Bundle.main.localizedString(forKey: SKDefaultScaleMenuLabels[i], value: "", table: "")
|
|
@@ -155,7 +148,7 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
curItem = self.scalePopUpButton?.item(at: cnt)
|
|
|
curItem?.representedObject = SKDefaultScaleMenuFactors[cnt] > 0.0 ? NSNumber(value: SKDefaultScaleMenuFactors[cnt]) : nil
|
|
|
}
|
|
|
- // select the appropriate item, adjusting the scaleFactor if necessary
|
|
|
+
|
|
|
if self.synchronizeZoom {
|
|
|
self.setSynchronizeZoom(true, adjustPopup: true)
|
|
|
} else if self.autoScales {
|
|
@@ -163,55 +156,44 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
} else {
|
|
|
self.setScaleFactor(self.scaleFactor, adjustPopup: true)
|
|
|
}
|
|
|
-
|
|
|
- // Make sure the popup is big enough to fit the largest cell
|
|
|
+
|
|
|
self.sizePopUpToItemAtIndex(self.scalePopUpButton, anIndex: UInt(maxIndex))
|
|
|
-
|
|
|
- // don't let it become first responder
|
|
|
+
|
|
|
self.scalePopUpButton?.refusesFirstResponder = true
|
|
|
-
|
|
|
- // hook it up
|
|
|
+
|
|
|
self.scalePopUpButton?.target = self
|
|
|
self.scalePopUpButton?.action = #selector(scalePopUpAction)
|
|
|
}
|
|
|
|
|
|
if (self.pagePopUpButton == nil) {
|
|
|
- // create it
|
|
|
self.pagePopUpButton = NSPopUpButton(frame: NSMakeRect(0.0, 0.0, 1.0, 1.0), pullsDown: false)
|
|
|
self.pagePopUpButton?.cell?.controlSize = .small
|
|
|
self.pagePopUpButton?.isBordered = false
|
|
|
self.pagePopUpButton?.isEnabled = true
|
|
|
self.pagePopUpButton?.refusesFirstResponder = true
|
|
|
(self.pagePopUpButton?.cell as? NSPopUpButtonCell)?.usesItemFromMenu = true
|
|
|
-
|
|
|
- // set a suitable font, the control size is 0, 1 or 2
|
|
|
+
|
|
|
self.pagePopUpButton?.font = .toolTipsFont(ofSize: CONTROL_FONT_SIZE)
|
|
|
|
|
|
self.reloadPagePopUpButton()
|
|
|
-
|
|
|
- // don't let it become first responder
|
|
|
+
|
|
|
self.pagePopUpButton?.refusesFirstResponder = true
|
|
|
-
|
|
|
- // hook it up
|
|
|
+
|
|
|
self.pagePopUpButton?.target = self
|
|
|
self.pagePopUpButton?.action = #selector(pagePopUpAction)
|
|
|
}
|
|
|
|
|
|
if (self.toolModeButton == nil) {
|
|
|
- // create it
|
|
|
self.toolModeButton = NSButton(frame: NSMakeRect(0.0, 0.0, 17.0, 15.0))
|
|
|
|
|
|
self.toolModeButton?.setButtonType(.onOff)
|
|
|
self.toolModeButton?.bezelStyle = .texturedSquare
|
|
|
-// self.toolModeButton?.image = NSImage(named: SKImageNameTextToolAdorn)
|
|
|
self.toolModeButton?.image = NSImage(named: "TextToolAdorn")
|
|
|
|
|
|
self.toolModeButton?.state = self.selectsText ? .on : .off
|
|
|
|
|
|
- // don't let it become first responder
|
|
|
self.toolModeButton?.refusesFirstResponder = true
|
|
|
|
|
|
- // hook it up
|
|
|
self.toolModeButton?.target = self
|
|
|
self.toolModeButton?.action = #selector(toolModeButtonAction)
|
|
|
}
|
|
@@ -304,8 +286,6 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
var maxWidth = 0.0
|
|
|
var maxIndex = 0
|
|
|
|
|
|
-// while (count--)
|
|
|
-// [pagePopUpButton removeItemAtIndex:count];
|
|
|
while count > 0 {
|
|
|
count -= 1
|
|
|
self.pagePopUpButton?.removeItem(at: count)
|
|
@@ -324,14 +304,13 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
self.sizePopUpToItemAtIndex(self.pagePopUpButton, anIndex: UInt(maxIndex))
|
|
|
self.pagePopUpButton?.selectItem(at: self.currentPageIndex)
|
|
|
if (self.controlView != nil) {
|
|
|
- // [controlView setFrameSize:NSMakeSize(NSWidth([toolModeButton frame]) + NSWidth([pagePopUpButton frame]) + NSWidth([scalePopUpButton frame]), NSHeight([controlView frame]))];
|
|
|
let w = NSWidth(self.toolModeButton?.frame ?? .zero) + NSWidth(self.pagePopUpButton?.frame ?? .zero) + NSWidth(self.scalePopUpButton?.frame ?? .zero)
|
|
|
let h = NSHeight(self.controlView?.frame ?? .zero)
|
|
|
self.controlView?.setFrameSize(NSMakeSize(w, h))
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@objc func scalePopUpAction(_ sender: NSPopUpButton) {
|
|
|
let selectedFactorObject = sender.selectedItem?.representedObject
|
|
|
if (selectedFactorObject != nil) {
|
|
@@ -341,15 +320,15 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
} else {
|
|
|
self.setAutoScales(true, adjustPopup: false)
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
@objc func pagePopUpAction(_ sender: NSPopUpButton) {
|
|
|
self.go(toPageIndex: sender.indexOfSelectedItem, animated: false)
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
@objc func toolModeButtonAction(_ sender: NSButton) {
|
|
|
self.selectsText = sender.state == .on
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
override var canZoomIn: Bool {
|
|
|
if super.canZoomIn == false {
|
|
@@ -365,7 +344,7 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
let numberOfDefaultItems = SKDefaultScaleMenuFactorsCount
|
|
|
var i = self.lowerIndex(for: self.scaleFactor)
|
|
|
if i < numberOfDefaultItems-1 {
|
|
|
- i += 1
|
|
|
+ i += 1
|
|
|
}
|
|
|
self.setScaleFactor(SKDefaultScaleMenuFactors[Int(i)], adjustPopup: true)
|
|
|
}
|
|
@@ -381,7 +360,7 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
override func zoomOut(_ sender: Any!) {
|
|
|
var i = self.upperIndex(for: self.scaleFactor)
|
|
|
if i > 2 {
|
|
|
- i -= 1
|
|
|
+ i -= 1
|
|
|
}
|
|
|
self.setScaleFactor(SKDefaultScaleMenuFactors[Int(i)], adjustPopup: true)
|
|
|
}
|
|
@@ -409,7 +388,7 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
}
|
|
|
|
|
|
@objc func doPhysicalSize(_ sender: AnyObject?) {
|
|
|
-// [self setPhysicalScaleFactor:1.0];
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@objc func changeToolMode(_ sender: NSMenuItem?) {
|
|
@@ -425,8 +404,6 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
while let cnt = menu?.numberOfItems, cnt > 0 {
|
|
|
item = menu?.item(at: 0)
|
|
|
if item!.isSeparatorItem || selectionActions.contains(NSStringFromSelector(item!.action!)) {
|
|
|
- // if ([item isSeparatorItem] || [self validateMenuItem:item] == NO || [selectionActions containsObject:NSStringFromSelector([item action])])
|
|
|
- // [menu removeItemAtIndex:0];
|
|
|
menu?.removeItem(at: 0)
|
|
|
} else {
|
|
|
break
|
|
@@ -441,7 +418,6 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// var i = menu?.indexOfItem(withTarget: self, andAction: NSSelectorFromString("menuItemClick_TwoPagesContinuous:"))
|
|
|
var i = menu?.indexOfItem(withTarget: nil, andAction: NSSelectorFromString("menuItemClick_TwoPagesContinuous:"))
|
|
|
if (i == -1) {
|
|
|
i = menu?.indexOfItem(withTarget: self, andAction: NSSelectorFromString("_toggleContinuous:"))
|
|
@@ -462,7 +438,6 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
if let data = i, data != -1 {
|
|
|
menu?.item(at: data)?.action = #selector(doActualSize)
|
|
|
item = menu?.insertItem(withTitle: KMLocalizedString("Physical Size"), action: #selector(doPhysicalSize), target: self, at: data + 1)
|
|
|
-// [item setKeyEquivalentModifierMask:NSAlternateKeyMask];
|
|
|
item?.keyEquivalentModifierMask = [.option]
|
|
|
item?.isAlternate = true
|
|
|
}
|
|
@@ -473,7 +448,7 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
} else if let data = i {
|
|
|
i = data - 1
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if let data = i {
|
|
|
_ = menu?.insertItem(withTitle: KMLocalizedString("Scroll Tool"), action: #selector(changeToolMode), target: self, at: data)
|
|
|
_ = menu?.insertItem(withTitle: KMLocalizedString("Text Tool"), action: #selector(changeToolMode), target: self, tag: 1 ,at: data)
|
|
@@ -497,116 +472,6 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
-
|
|
|
- // we don't want to steal the printDocument: action from the responder chain
|
|
|
- - (void)printDocument:(id)sender{}
|
|
|
-
|
|
|
- - (BOOL)respondsToSelector:(SEL)aSelector {
|
|
|
- return aSelector != @selector(printDocument:) && [super respondsToSelector:aSelector];
|
|
|
- }
|
|
|
-
|
|
|
- #pragma mark Gestures
|
|
|
-
|
|
|
- - (void)beginGestureWithEvent:(NSEvent *)theEvent {
|
|
|
- if ([[SKSecondaryPDFView superclass] instancesRespondToSelector:_cmd])
|
|
|
- [super beginGestureWithEvent:theEvent];
|
|
|
- startScale = [self scaleFactor];
|
|
|
- }
|
|
|
-
|
|
|
- - (void)endGestureWithEvent:(NSEvent *)theEvent {
|
|
|
- if (fabs(startScale - [self scaleFactor]) > 0.001)
|
|
|
- [self setScaleFactor:fmax([self scaleFactor], SKMinDefaultScaleMenuFactor) adjustPopup:YES];
|
|
|
- if ([[SKSecondaryPDFView superclass] instancesRespondToSelector:_cmd])
|
|
|
- [super endGestureWithEvent:theEvent];
|
|
|
- }
|
|
|
-
|
|
|
- - (void)magnifyWithEvent:(NSEvent *)theEvent {
|
|
|
- if ([[NSUserDefaults standardUserDefaults] boolForKey:SKDisablePinchZoomKey] == NO && [theEvent respondsToSelector:@selector(magnification)]) {
|
|
|
- if ([theEvent respondsToSelector:@selector(phase)] && [theEvent phase] == NSEventPhaseBegan)
|
|
|
- startScale = [self scaleFactor];
|
|
|
- CGFloat magnifyFactor = (1.0 + fmax(-0.5, fmin(1.0 , [theEvent magnification])));
|
|
|
- [super setScaleFactor:magnifyFactor * [self scaleFactor]];
|
|
|
- if ([theEvent respondsToSelector:@selector(phase)] && ([theEvent phase] == NSEventPhaseEnded || [theEvent phase] == NSEventPhaseCancelled) && fabs(startScale - [self scaleFactor]) > 0.001)
|
|
|
- [self setScaleFactor:fmax([self scaleFactor], SKMinDefaultScaleMenuFactor) adjustPopup:YES];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- #pragma mark Dragging
|
|
|
-
|
|
|
- - (void)mouseDown:(NSEvent *)theEvent{
|
|
|
- [[self window] makeFirstResponder:self];
|
|
|
-
|
|
|
- NSUInteger modifiers = [theEvent standardModifierFlags];
|
|
|
-
|
|
|
- if (modifiers == NSCommandKeyMask) {
|
|
|
-
|
|
|
- [[NSCursor arrowCursor] push];
|
|
|
-
|
|
|
- // eat up mouseDragged/mouseUp events, so we won't get their event handlers
|
|
|
- NSEvent *lastEvent = theEvent;
|
|
|
- while (YES) {
|
|
|
- lastEvent = [[self window] nextEventMatchingMask: NSLeftMouseUpMask | NSLeftMouseDraggedMask];
|
|
|
- if ([lastEvent type] == NSLeftMouseUp)
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- [NSCursor pop];
|
|
|
- [self performSelector:@selector(mouseMoved:) withObject:lastEvent afterDelay:0];
|
|
|
-
|
|
|
- NSPoint location = NSZeroPoint;
|
|
|
- PDFPage *page = [self pageAndPoint:&location forEvent:theEvent nearest:YES];
|
|
|
- [synchronizedPDFView goToDestination:[[[PDFDestination alloc] initWithPage:page atPoint:location] autorelease]];
|
|
|
-
|
|
|
- } else if (modifiers == (NSEventModifierFlagCommand | NSEventModifierFlagShift)) {
|
|
|
-
|
|
|
- [self doPdfsyncWithEvent:theEvent];
|
|
|
-
|
|
|
- } else if ([self selectsText] == NO) {
|
|
|
-
|
|
|
- [self doDragWithEvent:theEvent];
|
|
|
-
|
|
|
- } else if (([self areaOfInterestForMouse:theEvent] & SKDragArea)) {
|
|
|
-
|
|
|
- [self doDragWithEvent:theEvent];
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- [super mouseDown:theEvent];
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- #define TEXT_SELECT_MARGIN_SIZE ((NSSize){80.0, 100.0})
|
|
|
-
|
|
|
- - (PDFAreaOfInterest)areaOfInterestForMouse:(NSEvent *)theEvent {
|
|
|
- PDFAreaOfInterest area = [super areaOfInterestForMouse:theEvent];
|
|
|
- NSInteger modifiers = [theEvent standardModifierFlags];
|
|
|
-
|
|
|
- if ((modifiers & ~NSEventModifierFlagShift) == NSEventModifierFlagCommand) {
|
|
|
- area = (area & kPDFPageArea) | SKSpecialToolArea;
|
|
|
- } else if ([self selectsText] == NO) {
|
|
|
- area = (area & kPDFPageArea) | SKDragArea;
|
|
|
- } else if ((area & kPDFPageArea) && (area & kPDFTextArea) == 0 && modifiers == 0) {
|
|
|
- NSPoint p = [theEvent locationInWindow];
|
|
|
- PDFPage *page = [self pageAndPoint:&p forEvent:theEvent nearest:YES];
|
|
|
- if ([[page selectionForRect:SKRectFromCenterAndSize(p, TEXT_SELECT_MARGIN_SIZE)] hasCharacters] == NO)
|
|
|
- area |= SKDragArea;
|
|
|
- }
|
|
|
-
|
|
|
- return area;
|
|
|
- }
|
|
|
-
|
|
|
- - (void)setCursorForAreaOfInterest:(PDFAreaOfInterest)area {
|
|
|
- if ((area & SKSpecialToolArea))
|
|
|
- [[NSCursor arrowCursor] set];
|
|
|
- else if ((area & SKDragArea))
|
|
|
- [[NSCursor openHandCursor] set];
|
|
|
- else
|
|
|
- [super setCursorForAreaOfInterest:area];
|
|
|
- }
|
|
|
- */
|
|
|
-
|
|
|
// MARK: - mark Notification handling
|
|
|
|
|
|
private func _startObservingSynchronizedPDFView() {
|
|
@@ -614,7 +479,7 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(handleSynchronizedScaleChangedNotification), name: NSNotification.Name.CPDFViewScaleChanged, object: self.synchronizedPDFView)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private func _stopObservingSynchronizedPDFView() {
|
|
|
if self.synchronizedPDFView != nil {
|
|
|
NotificationCenter.default.removeObserver(self, name: NSNotification.Name.CPDFViewScaleChanged, object: self.synchronizedPDFView)
|
|
@@ -622,9 +487,7 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
}
|
|
|
|
|
|
@objc func handlePageChangedNotification(_ notification: Notification) {
|
|
|
-// if self.document != nil && !self.document.isLocked {
|
|
|
-// self.pagePopUpButton?.selectItem(at: self.currentPageIndex)
|
|
|
-// }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@objc func handleSynchronizedScaleChangedNotification(_ notification: Notification) {
|
|
@@ -650,7 +513,7 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
}
|
|
|
|
|
|
func sizePopUpToItemAtIndex(_ popUpButton: NSPopUpButton?, anIndex: UInt) {
|
|
|
- var i = popUpButton?.indexOfSelectedItem
|
|
|
+ let i = popUpButton?.indexOfSelectedItem
|
|
|
popUpButton?.selectItem(at: Int(anIndex))
|
|
|
popUpButton?.sizeToFit()
|
|
|
popUpButton?.setFrameSize(NSMakeSize(NSWidth(popUpButton?.frame ?? .zero) - CONTROL_WIDTH_OFFSET, CONTROL_HEIGHT))
|
|
@@ -707,7 +570,7 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
self.switching = savedSwitching
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
func setAutoScales(_ newAuto: Bool, adjustPopup flag: Bool) {
|
|
|
let savedSwitching = self.switching
|
|
|
self.switching = true
|
|
@@ -723,10 +586,8 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
|
|
|
|
|
|
func lowerIndex(for scaleFactor: CGFloat) -> UInt {
|
|
|
-// var i = 0
|
|
|
- var count = SKDefaultScaleMenuFactorsCount
|
|
|
+ let count = SKDefaultScaleMenuFactorsCount
|
|
|
for i in 1 ..< count-1 {
|
|
|
-// for (i = count - 1; i > 1; i--) {
|
|
|
let index = count-i
|
|
|
if (scaleFactor * 1.01 > SKDefaultScaleMenuFactors[index]) {
|
|
|
return UInt(index)
|
|
@@ -734,19 +595,17 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
}
|
|
|
return 2
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
func upperIndex(for scaleFactor: CGFloat) -> UInt {
|
|
|
-// NSUInteger i, count = SKDefaultScaleMenuFactorsCount;
|
|
|
- var count = SKDefaultScaleMenuFactorsCount
|
|
|
+ let count = SKDefaultScaleMenuFactorsCount
|
|
|
for i in 2 ..< count {
|
|
|
-// for (i = 2; i < count; i++) {
|
|
|
if (scaleFactor * 0.99 < SKDefaultScaleMenuFactors[i]) {
|
|
|
return UInt(i)
|
|
|
}
|
|
|
}
|
|
|
return UInt(count - 1)
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
func index(for scaleFactor: CGFloat) -> UInt {
|
|
|
let lower = self.lowerIndex(for: scaleFactor)
|
|
|
let upper = self.upperIndex(for: scaleFactor)
|
|
@@ -768,8 +627,6 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
menuItem.state = abs(self.scaleFactor-1.0) < 0.1 ? .on : .off
|
|
|
return true
|
|
|
} else if action == #selector(doPhysicalSize) {
|
|
|
-// [menuItem setState:([self autoScales] || fabs([self physicalScaleFactor] - 1.0 ) > 0.01) ? NSOffState : NSOnState];
|
|
|
-// return YES;
|
|
|
} else if action == #selector(changeToolMode) {
|
|
|
if self.selectsText {
|
|
|
menuItem.state = menuItem.tag == 1 ? .on : .off
|
|
@@ -778,9 +635,7 @@ class KMSecondaryPDFView: CPDFListView {
|
|
|
}
|
|
|
return true
|
|
|
} else if let supCls = self.superclass as? NSObject.Type {
|
|
|
-// if supCls.instancesRespond(to: _cmd) {
|
|
|
- return super.validate(menuItem)
|
|
|
-// }
|
|
|
+ return super.validate(menuItem)
|
|
|
}
|
|
|
return true
|
|
|
}
|