// // KMSystemMenu.swift // PDF Master // // Created by tangchao on 2023/4/24. // import Cocoa protocol KMSystemFileMenuProtocol { func menuItemClick_saveAsFlattenedPDF(_ sender: Any) func menuItemClick_mergePDF(_ sender: Any) func menuItemClick_Compress(_ sender: Any) func menuItemClick_Convert(_ sender: Any) func menuItemAction_ConvertToWord(_ sender: Any) func menuItemAction_ConvertToExcel(_ sender: Any) func menuItemAction_ConvertToPPT(_ sender: Any) func menuItemAction_ConvertToRTF(_ sender: Any) func menuItemAction_ConvertToHTML(_ sender: Any) func menuItemAction_ConvertToText(_ sender: Any) func menuItemAction_ConvertToCSV(_ sender: Any) func menuItemAction_ConvertToImage(_ sender: Any) func menuItemClick_SettingPassword(_ sender: Any) func menuItemClick_RemovePassword(_ sender: Any) func menuItemAction_closeWindow(_ sender: Any) func menuItemAction_closeAllWindows(_ sender: Any) func menuItemAction_closeTagPage(_ sender: Any) func menuItemAction_showInFinder(_ sender: Any) func menuItemAction_property(_ sender: Any) func menuItemAction_print(_ sender: Any) } extension KMSystemFileMenuProtocol { func menuItemClick_Convert(_ sender: Any) {} } @objc protocol KMSystemEditMenuProtocol { @objc optional func undo(_ sender: Any?) @objc optional func redo(_ sender: Any?) @objc optional func cut(_ sender: Any?) @objc optional func copy(_ sender: Any?) @objc optional func paste(_ sender: Any?) @objc optional func delete(_ sender: Any?) @objc optional func menuItemAction_find(_ sender: Any) } protocol KMSystemAnnotationMenuProtocol: NSObjectProtocol { func menuItemAction_highlight(_ sender: Any) func menuItemAction_underline(_ sender: Any) func menuItemAction_deleteLine(_ sender: Any) func menuItemAction_freehand(_ sender: Any) func menuItemAction_text(_ sender: Any) func menuItemAction_note(_ sender: Any) func menuItemAction_squre(_ sender: Any) func menuItemAction_circle(_ sender: Any) func menuItemAction_arrow(_ sender: Any) func menuItemAction_line(_ sender: Any) // link func menuItemAction_link(_ sender: Any) func menuItemAction_linkPage(_ sender: Any) func menuItemAction_linkHttps(_ sender: Any) func menuItemAction_linkEmail(_ sender: Any) // stamp func menuItemAction_stamp(_ sender: Any) func menuItemAction_stampStandard(_ sender: Any) func menuItemAction_stampDynamic(_ sender: Any) func menuItemAction_stampCustom(_ sender: Any) func menuItemAction_signure(_ sender: Any) func menuItemAction_hiddenAllAnnotation(_ sender: Any) func menuItemAction_clearAllAnnotation(_ sender: Any) } extension KMSystemAnnotationMenuProtocol { func menuItemAction_linkHttps(_ sender: Any) {} func menuItemAction_linkEmail(_ sender: Any) {} func menuItemAction_stampStandard(_ sender: Any) {} func menuItemAction_stampDynamic(_ sender: Any) {} func menuItemAction_stampCustom(_ sender: Any) {} } protocol KMSystemGotoMenuProtocol { func menuItemAction_nextPage(_ sender: Any) func menuItemAction_forwardPage(_ sender: Any) func menuItemAction_firstPage(_ sender: Any) func menuItemAction_lastPage(_ sender: Any) func menuItemAction_forward(_ sender: Any) func menuItemAction_goback(_ sender: Any) func menuItemAction_gotoPage(_ sender: Any) } protocol KMSystemToolMenuProtocol { func menuItemAction_textTool(_ sender: Any) func menuItemAction_scrolTool(_ sender: Any) func menuItemAction_zoomOutTool(_ sender: Any) func menuItemAction_selectTool(_ sender: Any) func menuItemAction_redact(_ sender: Any) func menuItemAction_warkmark(_ sender: Any) func menuItemAction_background(_ sender: Any) func menuItemAction_headerfooter(_ sender: Any) func menuItemAction_bates(_ sender: Any) func menuItemAction_batch(_ sender: Any) } extension KMSystemToolMenuProtocol { func menuItemAction_textTool(_ sender: Any) {} func menuItemAction_redact(_ sender: Any) {} func menuItemAction_warkmark(_ sender: Any) {} func menuItemAction_background(_ sender: Any) {} func menuItemAction_headerfooter(_ sender: Any) {} func menuItemAction_bates(_ sender: Any) {} func menuItemAction_batch(_ sender: Any) {} } protocol KMSystemWindowMenuRrotocol { func menuItemAction_showForwardTagPage(_ sender: Any) func menuItemAction_showNextTagPage(_ sender: Any) func menuItemAction_newTagPageToNewWindow(_ sender: Any) func menuItemAction_mergeAllWindow(_ sender: Any) func menuItemAction_currentWindowName(_ sender: Any) } extension KMSystemWindowMenuRrotocol { func menuItemAction_currentWindowName(_ sender: Any) {} } protocol KMSystemViewMenuProtocol { // scale func menuItemAction_adjustWidth(_ sender: Any) func menuItemAction_adjustPage(_ sender: Any) func menuItemAction_size(_ sender: Any) func menuItemAction_zoomOut(_ sender: Any) func menuItemAction_zoomIn(_ sender: Any) // page show func menuItemAction_singlePage(_ sender: Any) func menuItemAction_singlePageContinue(_ sender: Any) func menuItemAction_doublePage(_ sender: Any) func menuItemAction_doublePageContinue(_ sender: Any) func menuItemAction_bookMode(_ sender: Any) func menuItemAction_readMode(_ sender: Any) func menuItemAction_showSplitPage(_ sender: Any) func menuItemAction_autoScrol(_ sender: Any) func menuItemAction_autoScrolSetting(_ sender: Any) // rotate func menuItemAction_rotateLeft(_ sender: Any) func menuItemAction_rotateRight(_ sender: Any) func menuItemAction_rotateAllPageLeft(_ sender: Any) func menuItemAction_rotateAllPageRight(_ sender: Any) // split screen func menuItemAction_splitScreenVerti(_ sender: Any) func menuItemAction_splitScreenHorti(_ sender: Any) func menuItemAction_splitScreenNo(_ sender: Any) func menuItemAction_view_readMode(_ sender: Any) func menuItemAction_enterFullScreen(_ sender: Any) func menuItemAction_hiddenLeftSide(_ sender: Any) func menuItemAction_hiddenRightSide(_ sender: Any) func menuItemAction_thumai(_ sender: Any) func menuItemAction_outline(_ sender: Any) func menuItemAction_bookmark(_ sender: Any) func menuItemAction_annotation(_ sender: Any) func menuItemAction_search(_ sender: Any) func menuItemAction_topic(_ sender: Any) func menuItemAction_hiddenPageIndicator(_ sender: Any) } extension KMSystemViewMenuProtocol { func menuItemAction_autoScrol(_ sender: Any) {} func menuItemAction_autoScrolSetting(_ sender: Any) {} func menuItemAction_splitScreenVerti(_ sender: Any) {} func menuItemAction_splitScreenHorti(_ sender: Any) {} func menuItemAction_splitScreenNo(_ sender: Any) {} func menuItemAction_enterFullScreen(_ sender: Any) {} func menuItemAction_topic(_ sender: Any) {} } extension KMSystemMenu.File { public static let saveAsFlattenedPDFSelector = NSSelectorFromString("menuItemClick_saveAsFlattenedPDF:") public static let mergePDFSelector = NSSelectorFromString("menuItemClick_mergePDF:") public static let compressSelector = NSSelectorFromString("menuItemClick_Compress:") public static let convertSelector = NSSelectorFromString("menuItemClick_Convert:") public static let convertToWordSelector = NSSelectorFromString("menuItemAction_ConvertToWord:") public static let convertToExcelSelector = NSSelectorFromString("menuItemAction_ConvertToExcel:") public static let convertToPPTSelector = NSSelectorFromString("menuItemAction_ConvertToPPT:") public static let convertToRTFSelector = NSSelectorFromString("menuItemAction_ConvertToRTF:") public static let convertToHTMLSelector = NSSelectorFromString("menuItemAction_ConvertToHTML:") public static let convertToTextSelector = NSSelectorFromString("menuItemAction_ConvertToText:") public static let convertToCSVSelector = NSSelectorFromString("menuItemAction_ConvertToCSV:") public static let convertToImageSelector = NSSelectorFromString("menuItemAction_ConvertToImage:") public static let settingPasswordSelector = NSSelectorFromString("menuItemClick_SettingPassword:") public static let removePasswordSelector = NSSelectorFromString("menuItemClick_RemovePassword:") public static let closeWindowSelector = NSSelectorFromString("menuItemAction_closeWindow:") public static let closeAllWindowsSelector = NSSelectorFromString("menuItemAction_closeAllWindows:") public static let closeTagPageSelector = NSSelectorFromString("menuItemAction_closeTagPage:") public static let showInFinderSelector = NSSelectorFromString("menuItemAction_showInFinder:") public static let propertySelector = NSSelectorFromString("menuItemAction_property:") public static let printSelector = NSSelectorFromString("menuItemAction_print:") public static func actions() -> [Selector] { return [self.saveAsFlattenedPDFSelector, self.mergePDFSelector, self.compressSelector, // convert self.convertSelector, self.convertToWordSelector, self.convertToExcelSelector, self.convertToPPTSelector, self.convertToRTFSelector, self.convertToHTMLSelector, self.convertToTextSelector, self.convertToCSVSelector, self.convertToImageSelector, // secure self.settingPasswordSelector, self.removePasswordSelector, // other self.closeWindowSelector, self.closeAllWindowsSelector, self.closeTagPageSelector, self.showInFinderSelector, self.propertySelector, self.printSelector] } } extension KMSystemMenu.Edit { public static let undoSelector = NSSelectorFromString("undo:") public static let redoSelector = NSSelectorFromString("redo:") public static let cutSelector = NSSelectorFromString("cut:") public static let copySelector = NSSelectorFromString("copy:") public static let pasteSelector = NSSelectorFromString("paste:") public static let deleteSelector = NSSelectorFromString("delete:") public static let findSelector = NSSelectorFromString("menuItemAction_find:") public static func actions() -> [Selector] { return [self.undoSelector, self.redoSelector, self.cutSelector, self.copySelector, self.pasteSelector, self.deleteSelector, self.findSelector] } } extension KMSystemMenu.View { // scale public static let adjustWidthSelector = NSSelectorFromString("menuItemAction_adjustWidth:") public static let adjustPageSelector = NSSelectorFromString("menuItemAction_adjustPage:") public static let sizeSelector = NSSelectorFromString("menuItemAction_size:") public static let zoomOutSelector = NSSelectorFromString("menuItemAction_zoomOut:") public static let zoomInSelector = NSSelectorFromString("menuItemAction_zoomIn:") // page show public static let singlePageSelector = NSSelectorFromString("menuItemAction_singlePage:") public static let singlePageContinueSelector = NSSelectorFromString("menuItemAction_singlePageContinue:") public static let doublePageSelector = NSSelectorFromString("menuItemAction_doublePage:") public static let doublePageContinueSelector = NSSelectorFromString("menuItemAction_doublePageContinue:") public static let bookModeSelector = NSSelectorFromString("menuItemAction_bookMode:") public static let readModeSelector = NSSelectorFromString("menuItemAction_readMode:") public static let showSplitPageSelector = NSSelectorFromString("menuItemAction_showSplitPage:") public static let autoScrolSelector = NSSelectorFromString("menuItemAction_autoScrol:") public static let autoScrolSettingSelector = NSSelectorFromString("menuItemAction_autoScrolSetting:") // rotate public static let rotateLeftSelector = NSSelectorFromString("menuItemAction_rotateLeft:") public static let rotateRightSelector = NSSelectorFromString("menuItemAction_rotateRight:") public static let rotateAllPageLeftSelector = NSSelectorFromString("menuItemAction_rotateAllPageLeft:") public static let rotateAllPageRightSelector = NSSelectorFromString("menuItemAction_rotateAllPageRight:") // split screen public static let splitScreenVertiSelector = NSSelectorFromString("menuItemAction_splitScreenVerti:") public static let splitScreenHortiSelector = NSSelectorFromString("menuItemAction_splitScreenHorti:") public static let splitScreenNoSelector = NSSelectorFromString("menuItemAction_splitScreenNo:") public static let viewReadModeSelector = NSSelectorFromString("menuItemAction_view_readMode:") public static let enterFullScreenSelector = NSSelectorFromString("menuItemAction_enterFullScreen:") public static let hiddenLeftSideSelector = NSSelectorFromString("menuItemAction_hiddenLeftSide:") public static let hiddenRightSideSelector = NSSelectorFromString("menuItemAction_hiddenRightSide:") public static let thumaiSelector = NSSelectorFromString("menuItemAction_thumai:") public static let outlineSelector = NSSelectorFromString("menuItemAction_outline:") public static let bookmarkSelector = NSSelectorFromString("menuItemAction_bookmark:") public static let annotationSelector = NSSelectorFromString("menuItemAction_annotation:") public static let searchSelector = NSSelectorFromString("menuItemAction_search:") public static let topicSelector = NSSelectorFromString("menuItemAction_topic:") public static let hiddenPageIndicatorSelector = NSSelectorFromString("menuItemAction_hiddenPageIndicator:") public static func actions() -> [Selector] { return [self.adjustWidthSelector, self.adjustPageSelector, self.sizeSelector, self.zoomOutSelector, self.zoomInSelector, // page show self.singlePageSelector, self.singlePageContinueSelector, self.doublePageSelector, self.doublePageContinueSelector, self.bookModeSelector, self.readModeSelector, self.showSplitPageSelector, self.autoScrolSelector, self.autoScrolSettingSelector, // rotate self.rotateLeftSelector, self.rotateRightSelector, self.rotateAllPageLeftSelector, self.rotateAllPageRightSelector, // split screen self.splitScreenVertiSelector, self.splitScreenHortiSelector, self.splitScreenNoSelector, self.viewReadModeSelector, self.enterFullScreenSelector, self.hiddenLeftSideSelector, self.hiddenRightSideSelector, self.thumaiSelector, self.outlineSelector, self.bookmarkSelector, self.annotationSelector, self.searchSelector, self.topicSelector, self.hiddenPageIndicatorSelector] } } extension KMSystemMenu.Annotation { public static let highlightSelector = NSSelectorFromString("menuItemAction_highlight:") public static let underlineSelector = NSSelectorFromString("menuItemAction_underline:") public static let strikeOutSelector = NSSelectorFromString("menuItemAction_deleteLine:") public static let freehandSelector = NSSelectorFromString("menuItemAction_freehand:") public static let textSelector = NSSelectorFromString("menuItemAction_text:") public static let noteSelector = NSSelectorFromString("menuItemAction_note:") public static let squreSelector = NSSelectorFromString("menuItemAction_squre:") public static let circleSelector = NSSelectorFromString("menuItemAction_circle:") public static let arrowSelector = NSSelectorFromString("menuItemAction_arrow:") public static let lineSelector = NSSelectorFromString("menuItemAction_line:") public static let linkSelector = NSSelectorFromString("menuItemAction_link:") public static let linkPageSelector = NSSelectorFromString("menuItemAction_linkPage:") public static let linkHttpsSelector = NSSelectorFromString("menuItemAction_linkHttps:") public static let linkEmailSelector = NSSelectorFromString("menuItemAction_linkEmail:") public static let stampSelector = NSSelectorFromString("menuItemAction_stamp:") public static let stampStandardSelector = NSSelectorFromString("menuItemAction_stampStandard:") public static let stampDynamicSelector = NSSelectorFromString("menuItemAction_stampDynamic:") public static let stampCustomSelector = NSSelectorFromString("menuItemAction_stampCustom:") public static let signureSelector = NSSelectorFromString("menuItemAction_signure:") public static let hiddenAllSelector = NSSelectorFromString("menuItemAction_hiddenAllAnnotation:") public static let clearAllSelector = NSSelectorFromString("menuItemAction_clearAllAnnotation:") public static func actions() -> [Selector] { return [self.highlightSelector, self.underlineSelector, self.strikeOutSelector, self.freehandSelector, self.textSelector, self.noteSelector, self.squreSelector, self.circleSelector, self.arrowSelector, self.lineSelector, // link self.linkSelector, self.linkPageSelector, self.linkHttpsSelector, self.linkEmailSelector, // stamp self.stampSelector, self.stampStandardSelector, self.stampDynamicSelector, self.stampCustomSelector, // other self.signureSelector, self.hiddenAllSelector, self.clearAllSelector] } } extension KMSystemMenu.Goto { public static let nextPageSelector = NSSelectorFromString("menuItemAction_nextPage:") public static let forwardPageSelector = NSSelectorFromString("menuItemAction_forwardPage:") public static let firstPageSelector = NSSelectorFromString("menuItemAction_firstPage:") public static let lastPageSelector = NSSelectorFromString("menuItemAction_lastPage:") public static let forwardSelector = NSSelectorFromString("menuItemAction_forward:") public static let gobackSelector = NSSelectorFromString("menuItemAction_goback:") public static let gotoPageSelector = NSSelectorFromString("menuItemAction_gotoPage:") public static func actions() -> [Selector] { return [self.nextPageSelector, self.forwardPageSelector, self.firstPageSelector, self.lastPageSelector, self.forwardSelector, self.gobackSelector, self.gotoPageSelector] } } extension KMSystemMenu.Tool { public static let textToolSelector = NSSelectorFromString("menuItemAction_textTool:") public static let scrolToolSelector = NSSelectorFromString("menuItemAction_scrolTool:") public static let zoomToolSelector = NSSelectorFromString("menuItemAction_zoomOutTool:") public static let selectToolSelector = NSSelectorFromString("menuItemAction_selectTool:") public static let redactSelector = NSSelectorFromString("menuItemAction_redact:") public static let warkmarkSelector = NSSelectorFromString("menuItemAction_warkmark:") public static let backgroundSelector = NSSelectorFromString("menuItemAction_background:") public static let headerfooterSelector = NSSelectorFromString("menuItemAction_headerfooter:") public static let batesSelector = NSSelectorFromString("menuItemAction_bates:") public static let batchSelector = NSSelectorFromString("menuItemAction_batch:") public static func actions() -> [Selector] { return [self.textToolSelector, self.scrolToolSelector, self.zoomToolSelector, self.selectToolSelector, self.redactSelector, self.warkmarkSelector, self.backgroundSelector, self.headerfooterSelector, self.batesSelector, self.batchSelector] } } extension KMSystemMenu.Window { public static let showForwardTagPageSelector = NSSelectorFromString("menuItemAction_showForwardTagPage:") public static let showNextTagPageSelector = NSSelectorFromString("menuItemAction_showNextTagPage:") public static let newTagPageToNewWindowSelector = NSSelectorFromString("menuItemAction_newTagPageToNewWindow:") public static let mergeAllWindowSelector = NSSelectorFromString("menuItemAction_mergeAllWindow:") public static let currentWindowNameSelector = NSSelectorFromString("menuItemAction_currentWindowName:") public static func actions() -> [Selector] { return [self.showForwardTagPageSelector, self.showNextTagPageSelector, self.newTagPageToNewWindowSelector, self.mergeAllWindowSelector, self.currentWindowNameSelector] } } class KMSystemMenu: NSObject { public struct File { } public struct Edit { } public struct View { } public struct Annotation { } public struct Goto { } public struct Tool { } public struct Window { } public static func isFileSelector(sel: Selector) -> Bool { return KMSystemMenu.File.actions().contains(sel) } public static func isEditSelector(sel: Selector) -> Bool { return KMSystemMenu.Edit.actions().contains(sel) } public static func isViewSelector(sel: Selector) -> Bool { return KMSystemMenu.View.actions().contains(sel) } public static func isAnnotationSelector(sel: Selector) -> Bool { return KMSystemMenu.Annotation.actions().contains(sel) } public static func isGotoSelector(sel: Selector) -> Bool { return KMSystemMenu.Goto.actions().contains(sel) } public static func isToolSelector(sel: Selector) -> Bool { return KMSystemMenu.Tool.actions().contains(sel) } public static func isWindowSelector(sel: Selector) -> Bool { return KMSystemMenu.Window.actions().contains(sel) } }