KMSystemMenu.swift 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. //
  2. // KMSystemMenu.swift
  3. // PDF Master
  4. //
  5. // Created by tangchao on 2023/4/24.
  6. //
  7. import Cocoa
  8. protocol KMSystemFileMenuProtocol {
  9. func menuItemClick_mergePDF(_ sender: Any)
  10. func menuItemClick_Compress(_ sender: Any)
  11. func menuItemClick_Convert(_ sender: Any)
  12. func menuItemAction_ConvertToWord(_ sender: Any)
  13. func menuItemAction_ConvertToExcel(_ sender: Any)
  14. func menuItemAction_ConvertToPPT(_ sender: Any)
  15. func menuItemAction_ConvertToRTF(_ sender: Any)
  16. func menuItemAction_ConvertToHTML(_ sender: Any)
  17. func menuItemAction_ConvertToText(_ sender: Any)
  18. func menuItemAction_ConvertToCSV(_ sender: Any)
  19. func menuItemAction_ConvertToImage(_ sender: Any)
  20. func menuItemClick_SettingPassword(_ sender: Any)
  21. func menuItemClick_RemovePassword(_ sender: Any)
  22. func menuItemAction_closeWindow(_ sender: Any)
  23. func menuItemAction_closeAllWindows(_ sender: Any)
  24. func menuItemAction_closeTagPage(_ sender: Any)
  25. func menuItemAction_showInFinder(_ sender: Any)
  26. func menuItemAction_property(_ sender: Any)
  27. func menuItemAction_print(_ sender: Any)
  28. }
  29. extension KMSystemFileMenuProtocol {
  30. func menuItemClick_Convert(_ sender: Any) {}
  31. }
  32. protocol KMSystemEditMenuProtocol {
  33. func menuItemAction_find(_ sender: Any)
  34. }
  35. protocol KMSystemAnnotationMenuProtocol: NSObjectProtocol {
  36. func menuItemAction_highlight(_ sender: Any)
  37. func menuItemAction_underline(_ sender: Any)
  38. func menuItemAction_deleteLine(_ sender: Any)
  39. func menuItemAction_freehand(_ sender: Any)
  40. func menuItemAction_text(_ sender: Any)
  41. func menuItemAction_note(_ sender: Any)
  42. func menuItemAction_squre(_ sender: Any)
  43. func menuItemAction_circle(_ sender: Any)
  44. func menuItemAction_arrow(_ sender: Any)
  45. func menuItemAction_line(_ sender: Any)
  46. // link
  47. func menuItemAction_link(_ sender: Any)
  48. func menuItemAction_linkPage(_ sender: Any)
  49. func menuItemAction_linkHttps(_ sender: Any)
  50. func menuItemAction_linkEmail(_ sender: Any)
  51. // stamp
  52. func menuItemAction_stamp(_ sender: Any)
  53. func menuItemAction_stampStandard(_ sender: Any)
  54. func menuItemAction_stampDynamic(_ sender: Any)
  55. func menuItemAction_stampCustom(_ sender: Any)
  56. func menuItemAction_signure(_ sender: Any)
  57. func menuItemAction_hiddenAllAnnotation(_ sender: Any)
  58. func menuItemAction_clearAllAnnotation(_ sender: Any)
  59. }
  60. extension KMSystemAnnotationMenuProtocol {
  61. func menuItemAction_linkHttps(_ sender: Any) {}
  62. func menuItemAction_linkEmail(_ sender: Any) {}
  63. func menuItemAction_stampStandard(_ sender: Any) {}
  64. func menuItemAction_stampDynamic(_ sender: Any) {}
  65. func menuItemAction_stampCustom(_ sender: Any) {}
  66. }
  67. protocol KMSystemGotoMenuProtocol {
  68. func menuItemAction_nextPage(_ sender: Any)
  69. func menuItemAction_forwardPage(_ sender: Any)
  70. func menuItemAction_firstPage(_ sender: Any)
  71. func menuItemAction_lastPage(_ sender: Any)
  72. func menuItemAction_forward(_ sender: Any)
  73. func menuItemAction_goback(_ sender: Any)
  74. func menuItemAction_gotoPage(_ sender: Any)
  75. }
  76. protocol KMSystemToolMenuProtocol {
  77. func menuItemAction_textTool(_ sender: Any)
  78. func menuItemAction_scrolTool(_ sender: Any)
  79. func menuItemAction_zoomOutTool(_ sender: Any)
  80. func menuItemAction_selectTool(_ sender: Any)
  81. func menuItemAction_redact(_ sender: Any)
  82. func menuItemAction_warkmark(_ sender: Any)
  83. func menuItemAction_background(_ sender: Any)
  84. func menuItemAction_headerfooter(_ sender: Any)
  85. func menuItemAction_bates(_ sender: Any)
  86. func menuItemAction_batch(_ sender: Any)
  87. }
  88. extension KMSystemToolMenuProtocol {
  89. func menuItemAction_textTool(_ sender: Any) {}
  90. func menuItemAction_redact(_ sender: Any) {}
  91. func menuItemAction_warkmark(_ sender: Any) {}
  92. func menuItemAction_background(_ sender: Any) {}
  93. func menuItemAction_headerfooter(_ sender: Any) {}
  94. func menuItemAction_bates(_ sender: Any) {}
  95. func menuItemAction_batch(_ sender: Any) {}
  96. }
  97. protocol KMSystemWindowMenuRrotocol {
  98. func menuItemAction_showForwardTagPage(_ sender: Any)
  99. func menuItemAction_showNextTagPage(_ sender: Any)
  100. func menuItemAction_newTagPageToNewWindow(_ sender: Any)
  101. func menuItemAction_mergeAllWindow(_ sender: Any)
  102. func menuItemAction_currentWindowName(_ sender: Any)
  103. }
  104. extension KMSystemWindowMenuRrotocol {
  105. func menuItemAction_currentWindowName(_ sender: Any) {}
  106. }
  107. protocol KMSystemViewMenuProtocol {
  108. // scale
  109. func menuItemAction_adjustWidth(_ sender: Any)
  110. func menuItemAction_adjustPage(_ sender: Any)
  111. func menuItemAction_size(_ sender: Any)
  112. func menuItemAction_zoomOut(_ sender: Any)
  113. func menuItemAction_zoomIn(_ sender: Any)
  114. // page show
  115. func menuItemAction_singlePage(_ sender: Any)
  116. func menuItemAction_singlePageContinue(_ sender: Any)
  117. func menuItemAction_doublePage(_ sender: Any)
  118. func menuItemAction_doublePageContinue(_ sender: Any)
  119. func menuItemAction_bookMode(_ sender: Any)
  120. func menuItemAction_readMode(_ sender: Any)
  121. func menuItemAction_showSplitPage(_ sender: Any)
  122. func menuItemAction_autoScrol(_ sender: Any)
  123. func menuItemAction_autoScrolSetting(_ sender: Any)
  124. // rotate
  125. func menuItemAction_rotateLeft(_ sender: Any)
  126. func menuItemAction_rotateRight(_ sender: Any)
  127. func menuItemAction_rotateAllPageLeft(_ sender: Any)
  128. func menuItemAction_rotateAllPageRight(_ sender: Any)
  129. // split screen
  130. func menuItemAction_splitScreenVerti(_ sender: Any)
  131. func menuItemAction_splitScreenHorti(_ sender: Any)
  132. func menuItemAction_splitScreenNo(_ sender: Any)
  133. func menuItemAction_view_readMode(_ sender: Any)
  134. func menuItemAction_enterFullScreen(_ sender: Any)
  135. func menuItemAction_hiddenLeftSide(_ sender: Any)
  136. func menuItemAction_hiddenRightSide(_ sender: Any)
  137. func menuItemAction_thumai(_ sender: Any)
  138. func menuItemAction_outline(_ sender: Any)
  139. func menuItemAction_bookmark(_ sender: Any)
  140. func menuItemAction_annotation(_ sender: Any)
  141. func menuItemAction_search(_ sender: Any)
  142. func menuItemAction_topic(_ sender: Any)
  143. func menuItemAction_hiddenPageIndicator(_ sender: Any)
  144. }
  145. extension KMSystemViewMenuProtocol {
  146. func menuItemAction_autoScrol(_ sender: Any) {}
  147. func menuItemAction_autoScrolSetting(_ sender: Any) {}
  148. func menuItemAction_splitScreenVerti(_ sender: Any) {}
  149. func menuItemAction_splitScreenHorti(_ sender: Any) {}
  150. func menuItemAction_splitScreenNo(_ sender: Any) {}
  151. func menuItemAction_enterFullScreen(_ sender: Any) {}
  152. func menuItemAction_topic(_ sender: Any) {}
  153. }
  154. extension KMSystemMenu.File {
  155. public static let mergePDFSelector = NSSelectorFromString("menuItemClick_mergePDF:")
  156. public static let compressSelector = NSSelectorFromString("menuItemClick_Compress:")
  157. public static let convertSelector = NSSelectorFromString("menuItemClick_Convert:")
  158. public static let convertToWordSelector = NSSelectorFromString("menuItemAction_ConvertToWord:")
  159. public static let convertToExcelSelector = NSSelectorFromString("menuItemAction_ConvertToExcel:")
  160. public static let convertToPPTSelector = NSSelectorFromString("menuItemAction_ConvertToPPT:")
  161. public static let convertToRTFSelector = NSSelectorFromString("menuItemAction_ConvertToRTF:")
  162. public static let convertToHTMLSelector = NSSelectorFromString("menuItemAction_ConvertToHTML:")
  163. public static let convertToTextSelector = NSSelectorFromString("menuItemAction_ConvertToText:")
  164. public static let convertToCSVSelector = NSSelectorFromString("menuItemAction_ConvertToCSV:")
  165. public static let convertToImageSelector = NSSelectorFromString("menuItemAction_ConvertToImage:")
  166. public static let settingPasswordSelector = NSSelectorFromString("menuItemClick_SettingPassword:")
  167. public static let removePasswordSelector = NSSelectorFromString("menuItemClick_RemovePassword:")
  168. public static let closeWindowSelector = NSSelectorFromString("menuItemAction_closeWindow:")
  169. public static let closeAllWindowsSelector = NSSelectorFromString("menuItemAction_closeAllWindows:")
  170. public static let closeTagPageSelector = NSSelectorFromString("menuItemAction_closeTagPage:")
  171. public static let showInFinderSelector = NSSelectorFromString("menuItemAction_showInFinder:")
  172. public static let propertySelector = NSSelectorFromString("menuItemAction_property:")
  173. public static let printSelector = NSSelectorFromString("menuItemAction_print:")
  174. public static func actions() -> [Selector] {
  175. return [self.mergePDFSelector, self.compressSelector,
  176. // convert
  177. self.convertSelector, self.convertToWordSelector, self.convertToExcelSelector, self.convertToPPTSelector,
  178. self.convertToRTFSelector, self.convertToHTMLSelector, self.convertToTextSelector, self.convertToCSVSelector,
  179. self.convertToImageSelector,
  180. // secure
  181. self.settingPasswordSelector, self.removePasswordSelector,
  182. // other
  183. self.closeWindowSelector, self.closeAllWindowsSelector, self.closeTagPageSelector,
  184. self.showInFinderSelector, self.propertySelector,
  185. self.printSelector]
  186. }
  187. }
  188. extension KMSystemMenu.Edit {
  189. public static let findSelector = NSSelectorFromString("menuItemAction_find:")
  190. public static func actions() -> [Selector] {
  191. return [self.findSelector]
  192. }
  193. }
  194. extension KMSystemMenu.View {
  195. // scale
  196. public static let adjustWidthSelector = NSSelectorFromString("menuItemAction_adjustWidth:")
  197. public static let adjustPageSelector = NSSelectorFromString("menuItemAction_adjustPage:")
  198. public static let sizeSelector = NSSelectorFromString("menuItemAction_size:")
  199. public static let zoomOutSelector = NSSelectorFromString("menuItemAction_zoomOut:")
  200. public static let zoomInSelector = NSSelectorFromString("menuItemAction_zoomIn:")
  201. // page show
  202. public static let singlePageSelector = NSSelectorFromString("menuItemAction_singlePage:")
  203. public static let singlePageContinueSelector = NSSelectorFromString("menuItemAction_singlePageContinue:")
  204. public static let doublePageSelector = NSSelectorFromString("menuItemAction_doublePage:")
  205. public static let doublePageContinueSelector = NSSelectorFromString("menuItemAction_doublePageContinue:")
  206. public static let bookModeSelector = NSSelectorFromString("menuItemAction_bookMode:")
  207. public static let readModeSelector = NSSelectorFromString("menuItemAction_readMode:")
  208. public static let showSplitPageSelector = NSSelectorFromString("menuItemAction_showSplitPage:")
  209. public static let autoScrolSelector = NSSelectorFromString("menuItemAction_autoScrol:")
  210. public static let autoScrolSettingSelector = NSSelectorFromString("menuItemAction_autoScrolSetting:")
  211. // rotate
  212. public static let rotateLeftSelector = NSSelectorFromString("menuItemAction_rotateLeft:")
  213. public static let rotateRightSelector = NSSelectorFromString("menuItemAction_rotateRight:")
  214. public static let rotateAllPageLeftSelector = NSSelectorFromString("menuItemAction_rotateAllPageLeft:")
  215. public static let rotateAllPageRightSelector = NSSelectorFromString("menuItemAction_rotateAllPageRight:")
  216. // split screen
  217. public static let splitScreenVertiSelector = NSSelectorFromString("menuItemAction_splitScreenVerti:")
  218. public static let splitScreenHortiSelector = NSSelectorFromString("menuItemAction_splitScreenHorti:")
  219. public static let splitScreenNoSelector = NSSelectorFromString("menuItemAction_splitScreenNo:")
  220. public static let viewReadModeSelector = NSSelectorFromString("menuItemAction_view_readMode:")
  221. public static let enterFullScreenSelector = NSSelectorFromString("menuItemAction_enterFullScreen:")
  222. public static let hiddenLeftSideSelector = NSSelectorFromString("menuItemAction_hiddenLeftSide:")
  223. public static let hiddenRightSideSelector = NSSelectorFromString("menuItemAction_hiddenRightSide:")
  224. public static let thumaiSelector = NSSelectorFromString("menuItemAction_thumai:")
  225. public static let outlineSelector = NSSelectorFromString("menuItemAction_outline:")
  226. public static let bookmarkSelector = NSSelectorFromString("menuItemAction_bookmark:")
  227. public static let annotationSelector = NSSelectorFromString("menuItemAction_annotation:")
  228. public static let searchSelector = NSSelectorFromString("menuItemAction_search:")
  229. public static let topicSelector = NSSelectorFromString("menuItemAction_topic:")
  230. public static let hiddenPageIndicatorSelector = NSSelectorFromString("menuItemAction_hiddenPageIndicator:")
  231. public static func actions() -> [Selector] {
  232. return [self.adjustWidthSelector, self.adjustPageSelector, self.sizeSelector, self.zoomOutSelector, self.zoomInSelector,
  233. // page show
  234. self.singlePageSelector, self.singlePageContinueSelector, self.doublePageSelector, self.doublePageContinueSelector,
  235. self.bookModeSelector, self.readModeSelector, self.showSplitPageSelector, self.autoScrolSelector,
  236. self.autoScrolSettingSelector,
  237. // rotate
  238. self.rotateLeftSelector, self.rotateRightSelector, self.rotateAllPageLeftSelector, self.rotateAllPageRightSelector,
  239. // split screen
  240. self.splitScreenVertiSelector, self.splitScreenHortiSelector, self.splitScreenNoSelector,
  241. self.viewReadModeSelector, self.enterFullScreenSelector,
  242. self.hiddenLeftSideSelector, self.hiddenRightSideSelector,
  243. self.thumaiSelector, self.outlineSelector, self.bookmarkSelector, self.annotationSelector,
  244. self.searchSelector, self.topicSelector, self.hiddenPageIndicatorSelector]
  245. }
  246. }
  247. extension KMSystemMenu.Annotation {
  248. public static let highlightSelector = NSSelectorFromString("menuItemAction_highlight:")
  249. public static let underlineSelector = NSSelectorFromString("menuItemAction_underline:")
  250. public static let strikeOutSelector = NSSelectorFromString("menuItemAction_deleteLine:")
  251. public static let freehandSelector = NSSelectorFromString("menuItemAction_freehand:")
  252. public static let textSelector = NSSelectorFromString("menuItemAction_text:")
  253. public static let noteSelector = NSSelectorFromString("menuItemAction_note:")
  254. public static let squreSelector = NSSelectorFromString("menuItemAction_squre:")
  255. public static let circleSelector = NSSelectorFromString("menuItemAction_circle:")
  256. public static let arrowSelector = NSSelectorFromString("menuItemAction_arrow:")
  257. public static let lineSelector = NSSelectorFromString("menuItemAction_line:")
  258. public static let linkSelector = NSSelectorFromString("menuItemAction_link:")
  259. public static let linkPageSelector = NSSelectorFromString("menuItemAction_linkPage:")
  260. public static let linkHttpsSelector = NSSelectorFromString("menuItemAction_linkHttps:")
  261. public static let linkEmailSelector = NSSelectorFromString("menuItemAction_linkEmail:")
  262. public static let stampSelector = NSSelectorFromString("menuItemAction_stamp:")
  263. public static let stampStandardSelector = NSSelectorFromString("menuItemAction_stampStandard:")
  264. public static let stampDynamicSelector = NSSelectorFromString("menuItemAction_stampDynamic:")
  265. public static let stampCustomSelector = NSSelectorFromString("menuItemAction_stampCustom:")
  266. public static let signureSelector = NSSelectorFromString("menuItemAction_signure:")
  267. public static let hiddenAllSelector = NSSelectorFromString("menuItemAction_hiddenAllAnnotation:")
  268. public static let clearAllSelector = NSSelectorFromString("menuItemAction_clearAllAnnotation:")
  269. public static func actions() -> [Selector] {
  270. return [self.highlightSelector, self.underlineSelector, self.strikeOutSelector, self.freehandSelector,
  271. self.textSelector, self.noteSelector, self.squreSelector, self.circleSelector,
  272. self.arrowSelector, self.lineSelector,
  273. // link
  274. self.linkSelector, self.linkPageSelector, self.linkHttpsSelector, self.linkEmailSelector,
  275. // stamp
  276. self.stampSelector, self.stampStandardSelector, self.stampDynamicSelector, self.stampCustomSelector,
  277. // other
  278. self.signureSelector, self.hiddenAllSelector, self.clearAllSelector]
  279. }
  280. }
  281. extension KMSystemMenu.Goto {
  282. public static let nextPageSelector = NSSelectorFromString("menuItemAction_nextPage:")
  283. public static let forwardPageSelector = NSSelectorFromString("menuItemAction_forwardPage:")
  284. public static let firstPageSelector = NSSelectorFromString("menuItemAction_firstPage:")
  285. public static let lastPageSelector = NSSelectorFromString("menuItemAction_lastPage:")
  286. public static let forwardSelector = NSSelectorFromString("menuItemAction_forward:")
  287. public static let gobackSelector = NSSelectorFromString("menuItemAction_goback:")
  288. public static let gotoPageSelector = NSSelectorFromString("menuItemAction_gotoPage:")
  289. public static func actions() -> [Selector] {
  290. return [self.nextPageSelector, self.forwardPageSelector, self.firstPageSelector, self.lastPageSelector,
  291. self.forwardSelector, self.gobackSelector, self.gotoPageSelector]
  292. }
  293. }
  294. extension KMSystemMenu.Tool {
  295. public static let textToolSelector = NSSelectorFromString("menuItemAction_textTool:")
  296. public static let scrolToolSelector = NSSelectorFromString("menuItemAction_scrolTool:")
  297. public static let zoomToolSelector = NSSelectorFromString("menuItemAction_zoomOutTool:")
  298. public static let selectToolSelector = NSSelectorFromString("menuItemAction_selectTool:")
  299. public static let redactSelector = NSSelectorFromString("menuItemAction_redact:")
  300. public static let warkmarkSelector = NSSelectorFromString("menuItemAction_warkmark:")
  301. public static let backgroundSelector = NSSelectorFromString("menuItemAction_background:")
  302. public static let headerfooterSelector = NSSelectorFromString("menuItemAction_headerfooter:")
  303. public static let batesSelector = NSSelectorFromString("menuItemAction_bates:")
  304. public static let batchSelector = NSSelectorFromString("menuItemAction_batch:")
  305. public static func actions() -> [Selector] {
  306. return [self.textToolSelector, self.scrolToolSelector, self.zoomToolSelector, self.selectToolSelector,
  307. self.redactSelector, self.warkmarkSelector, self.backgroundSelector, self.headerfooterSelector,
  308. self.batesSelector, self.batchSelector]
  309. }
  310. }
  311. extension KMSystemMenu.Window {
  312. public static let showForwardTagPageSelector = NSSelectorFromString("menuItemAction_showForwardTagPage:")
  313. public static let showNextTagPageSelector = NSSelectorFromString("menuItemAction_showNextTagPage:")
  314. public static let newTagPageToNewWindowSelector = NSSelectorFromString("menuItemAction_newTagPageToNewWindow:")
  315. public static let mergeAllWindowSelector = NSSelectorFromString("menuItemAction_mergeAllWindow:")
  316. public static let currentWindowNameSelector = NSSelectorFromString("menuItemAction_currentWindowName:")
  317. public static func actions() -> [Selector] {
  318. return [self.showForwardTagPageSelector, self.showNextTagPageSelector,
  319. self.newTagPageToNewWindowSelector, self.mergeAllWindowSelector,
  320. self.currentWindowNameSelector]
  321. }
  322. }
  323. class KMSystemMenu: NSObject {
  324. public struct File {
  325. }
  326. public struct Edit {
  327. }
  328. public struct View {
  329. }
  330. public struct Annotation {
  331. }
  332. public struct Goto {
  333. }
  334. public struct Tool {
  335. }
  336. public struct Window {
  337. }
  338. public static func isFileSelector(sel: Selector) -> Bool {
  339. return KMSystemMenu.File.actions().contains(sel)
  340. }
  341. public static func isEditSelector(sel: Selector) -> Bool {
  342. return KMSystemMenu.Edit.actions().contains(sel)
  343. }
  344. public static func isViewSelector(sel: Selector) -> Bool {
  345. return KMSystemMenu.View.actions().contains(sel)
  346. }
  347. public static func isAnnotationSelector(sel: Selector) -> Bool {
  348. return KMSystemMenu.Annotation.actions().contains(sel)
  349. }
  350. public static func isGotoSelector(sel: Selector) -> Bool {
  351. return KMSystemMenu.Goto.actions().contains(sel)
  352. }
  353. public static func isToolSelector(sel: Selector) -> Bool {
  354. return KMSystemMenu.Tool.actions().contains(sel)
  355. }
  356. public static func isWindowSelector(sel: Selector) -> Bool {
  357. return KMSystemMenu.Window.actions().contains(sel)
  358. }
  359. }